Commit 89abebb9345a7d51e490530f72fb5a23c267ca28

Authored by 潘钊
2 parents 87be28a3 4935c902

Merge branch 'minhang' into qingpu

# Conflicts:
#	src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
#	src/main/resources/application-dev.properties
Showing 51 changed files with 2158 additions and 507 deletions

Too many changes to show.

To preserve performance only 51 of 97 files are displayed.

src/main/java/com/bsth/controller/forms/MCY_FormsController.java
@@ -115,7 +115,7 @@ public class MCY_FormsController { @@ -115,7 +115,7 @@ public class MCY_FormsController {
115 } 115 }
116 116
117 // 营运线路名称统计表 117 // 营运线路名称统计表
118 - @RequestMapping(value = "/daily", method = RequestMethod.POST) 118 + @RequestMapping(value = "/daily", method = RequestMethod.GET)
119 public List<Daily> daily(@RequestParam Map<String, Object> map) { 119 public List<Daily> daily(@RequestParam Map<String, Object> map) {
120 120
121 return formsService.daily(map); 121 return formsService.daily(map);
src/main/java/com/bsth/controller/oil/CwjyController.java
@@ -2,6 +2,8 @@ package com.bsth.controller.oil; @@ -2,6 +2,8 @@ package com.bsth.controller.oil;
2 2
3 3
4 import java.util.Date; 4 import java.util.Date;
  5 +import java.util.HashMap;
  6 +import java.util.List;
5 import java.util.Map; 7 import java.util.Map;
6 8
7 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,9 +33,9 @@ public class CwjyController extends BaseController&lt;Cwjy, Integer&gt;{ @@ -31,9 +33,9 @@ public class CwjyController extends BaseController&lt;Cwjy, Integer&gt;{
31 return service.save(t); 33 return service.save(t);
32 } 34 }
33 35
34 - @RequestMapping(value = "/pagequery",method = RequestMethod.GET)  
35 - public PageObject<Ylxxb> pagequery(@RequestParam Map<String, Object> map){  
36 - PageObject<Ylxxb> pagequery=null; 36 + @RequestMapping(value = "/queryList",method = RequestMethod.GET)
  37 + public List<Ylxxb> queryList(@RequestParam Map<String, Object> map){
  38 + List<Ylxxb> pagequery=null;
37 map.put("curPage", map.get("page").toString()); 39 map.put("curPage", map.get("page").toString());
38 map.put("pageData","10"); 40 map.put("pageData","10");
39 pagequery=service.Pagequery(map); 41 pagequery=service.Pagequery(map);
@@ -56,9 +58,15 @@ public class CwjyController extends BaseController&lt;Cwjy, Integer&gt;{ @@ -56,9 +58,15 @@ public class CwjyController extends BaseController&lt;Cwjy, Integer&gt;{
56 * @throws 58 * @throws
57 */ 59 */
58 @RequestMapping(value="/savejzl",method = RequestMethod.POST) 60 @RequestMapping(value="/savejzl",method = RequestMethod.POST)
59 - public Map<String, Object> savejzl(Ylxxb t){  
60 - Map<String, Object> map=service.savejzl(t);  
61 - return map; 61 + public Map<String, Object> savejzl(Map<String, Object> map){
  62 + Map<String, Object> maps=new HashMap<>();
  63 + try {
  64 + maps = service.savejzl(map);
  65 + } catch (Exception e) {
  66 + // TODO Auto-generated catch block
  67 + e.printStackTrace();
  68 + }
  69 + return maps;
62 } 70 }
63 71
64 } 72 }
src/main/java/com/bsth/controller/oil/YlbController.java
@@ -16,6 +16,7 @@ import org.springframework.data.domain.Page; @@ -16,6 +16,7 @@ import org.springframework.data.domain.Page;
16 import org.springframework.data.domain.PageRequest; 16 import org.springframework.data.domain.PageRequest;
17 import org.springframework.data.domain.Sort; 17 import org.springframework.data.domain.Sort;
18 import org.springframework.data.domain.Sort.Direction; 18 import org.springframework.data.domain.Sort.Direction;
  19 +import org.springframework.web.bind.annotation.PathVariable;
19 import org.springframework.web.bind.annotation.RequestMapping; 20 import org.springframework.web.bind.annotation.RequestMapping;
20 import org.springframework.web.bind.annotation.RequestMethod; 21 import org.springframework.web.bind.annotation.RequestMethod;
21 import org.springframework.web.bind.annotation.RequestParam; 22 import org.springframework.web.bind.annotation.RequestParam;
@@ -40,7 +41,7 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{ @@ -40,7 +41,7 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
40 // SysUser user = SecurityUtils.getCurrentUser(); 41 // SysUser user = SecurityUtils.getCurrentUser();
41 t.setCreatetime(new Date()); 42 t.setCreatetime(new Date());
42 // Ylb t=new Ylb(); 43 // Ylb t=new Ylb();
43 - return yblService.save(t); 44 + return yblService.saveYlb(t);
44 } 45 }
45 46
46 47
@@ -196,6 +197,17 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{ @@ -196,6 +197,17 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
196 return ylbList; 197 return ylbList;
197 } 198 }
198 199
  200 + @RequestMapping(value = "/deleteIds", method = RequestMethod.POST)
  201 + public Map<String, Object> deleteIds(@RequestParam Map<String, Object> map) {
  202 + Map<String, Object> maps=new HashMap<String, Object>();
  203 + try {
  204 + maps= yblService.deleteIds(map);
  205 + } catch (Exception e) {
  206 + // TODO Auto-generated catch block
  207 + e.printStackTrace();
  208 + }
  209 + return maps;
  210 + }
199 @RequestMapping(value="/oilListMonth") 211 @RequestMapping(value="/oilListMonth")
200 public List<Ylb> oilListMonth(@RequestParam String line,@RequestParam String date){ 212 public List<Ylb> oilListMonth(@RequestParam String line,@RequestParam String date){
201 return yblService.oilListMonth(line, date); 213 return yblService.oilListMonth(line, date);
@@ -219,17 +231,7 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{ @@ -219,17 +231,7 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
219 sdfSimple = new SimpleDateFormat("yyyyMMdd"); 231 sdfSimple = new SimpleDateFormat("yyyyMMdd");
220 List<Iterator<?>> listI = new ArrayList<Iterator<?>>(); 232 List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
221 ReportUtils ee = new ReportUtils(); 233 ReportUtils ee = new ReportUtils();
222 - String rq=map.get("rq").toString();  
223 - if(!(rq=="")){  
224 - SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");  
225 - try {  
226 - map.put("rq_eq", sdfMonth.parse(rq));  
227 - } catch (ParseException e) {  
228 - // TODO Auto-generated catch block  
229 - e.printStackTrace();  
230 - }  
231 - }  
232 - List<Ylb> ylb= (List<Ylb>)yblService.list(map); 234 + List<Ylb> ylb= yblService.listYlb(map);
233 // (new CustomerSpecs<Ylb>(map)).iterator(); 235 // (new CustomerSpecs<Ylb>(map)).iterator();
234 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>(); 236 List<Map<String, Object>> resList = new ArrayList<Map<String, Object>>();
235 for (Ylb y : ylb) { 237 for (Ylb y : ylb) {
@@ -245,12 +247,28 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{ @@ -245,12 +247,28 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
245 m.put("czyl", y.getCzyl()); 247 m.put("czyl", y.getCzyl());
246 m.put("jzyl", y.getJzyl()); 248 m.put("jzyl", y.getJzyl());
247 m.put("yh", y.getYh()); 249 m.put("yh", y.getYh());
248 - m.put("rylx", y.getRylx()); 250 + String rylx="";
  251 + if(y.getRylx()!=null){
  252 + if(y.getRylx().equals("0")){rylx="0号柴油";}
  253 + if(y.getRylx().equals("1")){rylx="负10号柴油";}
  254 + }
  255 + m.put("rylx", rylx);
249 m.put("ns", y.getNs()); 256 m.put("ns", y.getNs());
250 - m.put("shyy", y.getShyy()); 257 + String shyy ="无";
  258 + if(y.getShyy()!=null){
  259 + if(shyy.equals("1")){shyy="票务用油";}
  260 + else if(shyy.equals("2")){shyy="保养用油";}
  261 + else if(shyy.equals("3")){shyy="报废车用油";}
  262 + else if(shyy.equals("4")){shyy="其它用油";}
  263 + else if(shyy.equals("5")){shyy="人保部";}
  264 + else if(shyy.equals("6")){shyy="车队";}
  265 + else if(shyy.equals("7")){shyy="车间(高保)";}
  266 + else if(shyy.equals("8")){shyy="车间(小修)";}
  267 + else{shyy ="无";}
  268 + }
  269 + m.put("shyy", shyy);
251 m.put("sh", y.getSh()); 270 m.put("sh", y.getSh());
252 m.put("zlc", y.getZlc()); 271 m.put("zlc", y.getZlc());
253 - m.put("yhlx", y.getYhlx());  
254 m.put("bglyh", y.getBglyh()); 272 m.put("bglyh", y.getBglyh());
255 resList.add(m); 273 resList.add(m);
256 } 274 }
@@ -258,7 +276,7 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{ @@ -258,7 +276,7 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
258 listI.add(resList.iterator()); 276 listI.add(resList.iterator());
259 String path = this.getClass().getResource("/").getPath()+"static/pages/forms/"; 277 String path = this.getClass().getResource("/").getPath()+"static/pages/forms/";
260 ee.excelReplace(listI, new Object[] { map }, path+"mould/list.xls", 278 ee.excelReplace(listI, new Object[] { map }, path+"mould/list.xls",
261 - path+"export/进出场存油量" + sdfSimple.format(sdfMonth.parse(map.get("rq").toString())) + ".xls"); 279 + path+"export/"+map.get("rq").toString()+ "进出场存油量.xls");
262 } catch (Exception e) { 280 } catch (Exception e) {
263 e.printStackTrace(); 281 e.printStackTrace();
264 } 282 }
src/main/java/com/bsth/controller/oil/YlxxbController.java
1 package com.bsth.controller.oil; 1 package com.bsth.controller.oil;
2 2
  3 +import java.util.HashMap;
3 import java.util.Map; 4 import java.util.Map;
4 5
5 import org.springframework.beans.factory.annotation.Autowired; 6 import org.springframework.beans.factory.annotation.Autowired;
@@ -33,9 +34,15 @@ public class YlxxbController extends BaseController&lt;Ylxxb, Integer&gt;{ @@ -33,9 +34,15 @@ public class YlxxbController extends BaseController&lt;Ylxxb, Integer&gt;{
33 * @param map 34 * @param map
34 * @return 35 * @return
35 */ 36 */
36 - @RequestMapping(value = "/check",method = RequestMethod.GET) 37 + @RequestMapping(value = "/check",method = RequestMethod.POST)
37 public Map<String, Object> check(@RequestParam Map<String, Object> map){ 38 public Map<String, Object> check(@RequestParam Map<String, Object> map){
38 - Map<String, Object> list=service.checkJsy(map); 39 + Map<String, Object> list=new HashMap<>();
  40 + try {
  41 + list = service.checkJsy(map);
  42 + } catch (Exception e) {
  43 + // TODO Auto-generated catch block
  44 + e.printStackTrace();
  45 + }
39 return list; 46 return list;
40 } 47 }
41 } 48 }
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
@@ -314,9 +314,9 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo, @@ -314,9 +314,9 @@ public class ScheduleRealInfoController extends BaseController&lt;ScheduleRealInfo,
314 } 314 }
315 315
316 @RequestMapping(value="/findKMBC",method = RequestMethod.GET) 316 @RequestMapping(value="/findKMBC",method = RequestMethod.GET)
317 - public Map<String,Object> findKMBC(@RequestParam String jName,@RequestParam String clZbh,@RequestParam String lpName 317 + public Map<String,Object> findKMBC(@RequestParam String jGh,@RequestParam String clZbh,@RequestParam String lpName
318 ,@RequestParam String date,@RequestParam String line){ 318 ,@RequestParam String date,@RequestParam String line){
319 - return scheduleRealInfoService.findKMBC(jName, clZbh,lpName,date,line); 319 + return scheduleRealInfoService.findKMBC(jGh, clZbh,lpName,date,line);
320 } 320 }
321 321
322 @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET) 322 @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET)
src/main/java/com/bsth/controller/report/ReportController.java
1 package com.bsth.controller.report; 1 package com.bsth.controller.report;
2 2
  3 +import java.util.HashMap;
3 import java.util.List; 4 import java.util.List;
4 import java.util.Map; 5 import java.util.Map;
5 6
@@ -78,5 +79,38 @@ public class ReportController { @@ -78,5 +79,38 @@ public class ReportController {
78 public List<Map<String,Object>> getTtinfo(@RequestParam Map<String, Object> map){ 79 public List<Map<String,Object>> getTtinfo(@RequestParam Map<String, Object> map){
79 return service.getTtinfo(map); 80 return service.getTtinfo(map);
80 } 81 }
  82 +
  83 +
  84 + @RequestMapping(value="/jobFwqk", method = RequestMethod.GET)
  85 + public List<Map<String,Object>> jobFwqk(@RequestParam Map<String, Object> map){
  86 + return service.jobFwqk(map);
  87 + }
  88 +
  89 + @RequestMapping(value="/jobHzxx", method = RequestMethod.GET)
  90 + public Map<String,Object> jobHzxx(@RequestParam Map<String, Object> map){
  91 + Map<String, Object> newMap=service.jobHzxx(map);
  92 + return newMap;
  93 + }
  94 +
81 95
  96 + @RequestMapping(value="/jobLjqk", method = RequestMethod.GET)
  97 + public List<Map<String,Object>> jobLjqk(@RequestParam Map<String, Object> map){
  98 + return service.jobLjqk(map);
  99 + }
  100 +
  101 + @RequestMapping(value="/lineList",method = RequestMethod.GET)
  102 + public List<Map<String,Object>> lineList(){
  103 + return service.lineList();
  104 + }
  105 +
  106 + @RequestMapping(value="/carList",method = RequestMethod.GET)
  107 + public List<Map<String,String>> carList(@RequestParam Map<String, Object> map){
  108 + return service.carList(map);
  109 + }
  110 +
  111 + @RequestMapping(value="/userList",method = RequestMethod.GET)
  112 + public List<Map<String,String>> userList(@RequestParam Map<String, Object> map){
  113 + return service.userList(map);
  114 + }
  115 +
82 } 116 }
src/main/java/com/bsth/data/gpsdata/arrival/handlers/CorrectSignalHandle.java
@@ -6,6 +6,9 @@ import com.bsth.data.gpsdata.arrival.utils.CircleQueue; @@ -6,6 +6,9 @@ import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6 import com.bsth.data.schedule.DayOfSchedule; 6 import com.bsth.data.schedule.DayOfSchedule;
7 import com.bsth.entity.realcontrol.ChildTaskPlan; 7 import com.bsth.entity.realcontrol.ChildTaskPlan;
8 import com.bsth.entity.realcontrol.ScheduleRealInfo; 8 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  9 +import com.bsth.service.directive.DirectiveService;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
9 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.stereotype.Component; 13 import org.springframework.stereotype.Component;
11 14
@@ -18,6 +21,10 @@ public class CorrectSignalHandle extends SignalHandle { @@ -18,6 +21,10 @@ public class CorrectSignalHandle extends SignalHandle {
18 21
19 @Autowired 22 @Autowired
20 DayOfSchedule dayOfSchedule; 23 DayOfSchedule dayOfSchedule;
  24 + @Autowired
  25 + DirectiveService directiveService;
  26 +
  27 + Logger logger = LoggerFactory.getLogger(this.getClass());
21 28
22 @Override 29 @Override
23 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) { 30 public boolean handle(GpsEntity gps, CircleQueue<GpsEntity> prevs) {
@@ -41,6 +48,11 @@ public class CorrectSignalHandle extends SignalHandle { @@ -41,6 +48,11 @@ public class CorrectSignalHandle extends SignalHandle {
41 gps.setState(0); 48 gps.setState(0);
42 } 49 }
43 50
  51 + if(gps.getState() != 0){
  52 + logger.info(gps.getNbbm() + " 纠正状态到营运");
  53 + //切换到营运状态
  54 + directiveService.send60Operation(sch.getClZbh(), 0, Integer.parseInt(sch.getXlDir()), null, "纠正@系统");
  55 + }
44 56
45 return true; 57 return true;
46 } 58 }
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
@@ -235,6 +235,10 @@ public class InOutStationSignalHandle extends SignalHandle{ @@ -235,6 +235,10 @@ public class InOutStationSignalHandle extends SignalHandle{
235 235
236 //下发调度指令 236 //下发调度指令
237 directiveService.send60Dispatch(next, doneSum, "到站@系统"); 237 directiveService.send60Dispatch(next, doneSum, "到站@系统");
  238 +
  239 + //套跑 -下发线路切换指令
  240 + if(!next.getXlBm().equals(sch.getXlBm()))
  241 + directiveService.lineChange(next.getClZbh(), next.getXlBm(), "套跑@系统");
238 } 242 }
239 else if(sch.getBcType().equals("in")){ 243 else if(sch.getBcType().equals("in")){
240 //终班进场,切换成非营运状态 244 //终班进场,切换成非营运状态
src/main/java/com/bsth/entity/Cars.java
@@ -2,6 +2,7 @@ package com.bsth.entity; @@ -2,6 +2,7 @@ package com.bsth.entity;
2 2
3 import com.bsth.entity.schedule.BEntity; 3 import com.bsth.entity.schedule.BEntity;
4 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  5 +import org.hibernate.annotations.Formula;
5 6
6 import javax.persistence.*; 7 import javax.persistence.*;
7 import java.io.Serializable; 8 import java.io.Serializable;
@@ -47,6 +48,10 @@ public class Cars extends BEntity implements Serializable { @@ -47,6 +48,10 @@ public class Cars extends BEntity implements Serializable {
47 /** 分公司 */ 48 /** 分公司 */
48 private String brancheCompany; 49 private String brancheCompany;
49 50
  51 + /** 组合公司分公司编码 */
  52 + @Formula(" concat(business_code, '_', branche_company_code) ")
  53 + private String cgsbm;
  54 +
50 /** 车辆编码(TODO:在原系统里没有,这里暂时留着) */ 55 /** 车辆编码(TODO:在原系统里没有,这里暂时留着) */
51 @Column(nullable = false) 56 @Column(nullable = false)
52 private String carCode; 57 private String carCode;
@@ -499,4 +504,12 @@ public class Cars extends BEntity implements Serializable { @@ -499,4 +504,12 @@ public class Cars extends BEntity implements Serializable {
499 public void setXlmc(String xlmc) { 504 public void setXlmc(String xlmc) {
500 this.xlmc = xlmc; 505 this.xlmc = xlmc;
501 } 506 }
  507 +
  508 + public String getCgsbm() {
  509 + return cgsbm;
  510 + }
  511 +
  512 + public void setCgsbm(String cgsbm) {
  513 + this.cgsbm = cgsbm;
  514 + }
502 } 515 }
src/main/java/com/bsth/entity/Line.java
1 package com.bsth.entity; 1 package com.bsth.entity;
2 2
3 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 3 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  4 +import org.hibernate.annotations.Formula;
4 import org.springframework.format.annotation.DateTimeFormat; 5 import org.springframework.format.annotation.DateTimeFormat;
5 6
6 import javax.persistence.*; 7 import javax.persistence.*;
@@ -69,6 +70,10 @@ public class Line implements Serializable { @@ -69,6 +70,10 @@ public class Line implements Serializable {
69 /** 分公司 varchar length(50)*/ 70 /** 分公司 varchar length(50)*/
70 private String brancheCompany; 71 private String brancheCompany;
71 72
  73 + /** 组合公司分公司编码 */
  74 + @Formula(" concat(company, '_', branche_company) ")
  75 + private String cgsbm;
  76 +
72 /** 性质(线路类型) varchar length(50) */ 77 /** 性质(线路类型) varchar length(50) */
73 private String nature; 78 private String nature;
74 79
@@ -457,4 +462,12 @@ public class Line implements Serializable { @@ -457,4 +462,12 @@ public class Line implements Serializable {
457 public Integer getInUse() { return inUse; } 462 public Integer getInUse() { return inUse; }
458 463
459 public void setInUse(Integer inUse) { this.inUse = inUse; } 464 public void setInUse(Integer inUse) { this.inUse = inUse; }
  465 +
  466 + public String getCgsbm() {
  467 + return cgsbm;
  468 + }
  469 +
  470 + public void setCgsbm(String cgsbm) {
  471 + this.cgsbm = cgsbm;
  472 + }
460 } 473 }
src/main/java/com/bsth/entity/Personnel.java
@@ -2,6 +2,7 @@ package com.bsth.entity; @@ -2,6 +2,7 @@ package com.bsth.entity;
2 2
3 import com.bsth.entity.schedule.BEntity; 3 import com.bsth.entity.schedule.BEntity;
4 import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
  5 +import org.hibernate.annotations.Formula;
5 6
6 import javax.persistence.*; 7 import javax.persistence.*;
7 8
@@ -39,6 +40,10 @@ public class Personnel extends BEntity { @@ -39,6 +40,10 @@ public class Personnel extends BEntity {
39 private String brancheCompany; 40 private String brancheCompany;
40 /** 分公司编码 */ 41 /** 分公司编码 */
41 private String brancheCompanyCode; 42 private String brancheCompanyCode;
  43 + /** 组合公司分公司编码 */
  44 + @Formula(" concat(company_code, '_', branche_company_code) ")
  45 + private String cgsbm;
  46 +
42 /** 工号 */ 47 /** 工号 */
43 @Column(nullable = false) 48 @Column(nullable = false)
44 private String jobCode; 49 private String jobCode;
@@ -218,4 +223,12 @@ public class Personnel extends BEntity { @@ -218,4 +223,12 @@ public class Personnel extends BEntity {
218 public void setDescriptions(String descriptions) { 223 public void setDescriptions(String descriptions) {
219 this.descriptions = descriptions; 224 this.descriptions = descriptions;
220 } 225 }
  226 +
  227 + public String getCgsbm() {
  228 + return cgsbm;
  229 + }
  230 +
  231 + public void setCgsbm(String cgsbm) {
  232 + this.cgsbm = cgsbm;
  233 + }
221 } 234 }
src/main/java/com/bsth/entity/schedule/SchedulePlan.java
1 package com.bsth.entity.schedule; 1 package com.bsth.entity.schedule;
2 2
3 import com.bsth.entity.Line; 3 import com.bsth.entity.Line;
4 -import com.bsth.entity.schedule.rule.ScheduleRule1;  
5 import com.fasterxml.jackson.annotation.JsonIgnore; 4 import com.fasterxml.jackson.annotation.JsonIgnore;
6 5
7 import javax.persistence.*; 6 import javax.persistence.*;
@@ -15,9 +14,8 @@ import java.util.List; @@ -15,9 +14,8 @@ import java.util.List;
15 @Entity 14 @Entity
16 @Table(name = "bsth_c_s_sp") 15 @Table(name = "bsth_c_s_sp")
17 @NamedEntityGraphs({ 16 @NamedEntityGraphs({
18 - @NamedEntityGraph(name = "schedulePlan_xl_ttinfo", attributeNodes = { 17 + @NamedEntityGraph(name = "schedulePlan_xl", attributeNodes = {
19 @NamedAttributeNode("xl"), 18 @NamedAttributeNode("xl"),
20 - @NamedAttributeNode("ttInfo")  
21 }) 19 })
22 }) 20 })
23 public class SchedulePlan extends BEntity { 21 public class SchedulePlan extends BEntity {
@@ -30,22 +28,6 @@ public class SchedulePlan extends BEntity { @@ -30,22 +28,6 @@ public class SchedulePlan extends BEntity {
30 /** 关联的线路 */ 28 /** 关联的线路 */
31 @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY) 29 @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
32 private Line xl; 30 private Line xl;
33 - /** 关联的时刻表/模版 */  
34 - // TODO:这个字段之后就不用了  
35 - @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY)  
36 - private TTInfo ttInfo;  
37 - /** TODO:关联的排班规则(这里暂时改成可以不关联规则,直接生成排班) */  
38 - @ManyToOne(cascade = CascadeType.PERSIST, fetch = FetchType.LAZY)  
39 - private ScheduleRule1 scheduleRule1;  
40 -  
41 - // TODO: 新字段,测试完后删除旧的字段  
42 -  
43 - /** 使用的时刻表名字列表(用逗号连接) */  
44 - private String ttInfoNames;  
45 - /** 使用的时刻表id列表(用逗号连接) */  
46 - private String ttInfoId;  
47 - /** 使用的规则1列表(用逗号连接) */  
48 - private String rule1Ids;  
49 31
50 /** 排班计划的开始时间 */ 32 /** 排班计划的开始时间 */
51 @Column(nullable = false) 33 @Column(nullable = false)
@@ -54,6 +36,11 @@ public class SchedulePlan extends BEntity { @@ -54,6 +36,11 @@ public class SchedulePlan extends BEntity {
54 @Column(nullable = false) 36 @Column(nullable = false)
55 private Date scheduleToTime; 37 private Date scheduleToTime;
56 38
  39 + /** 使用的时刻表名字列表(用逗号连接) */
  40 + private String ttInfoNames;
  41 + /** 使用的时刻表id列表(用逗号连接) */
  42 + private String ttInfoIds;
  43 +
57 @JsonIgnore 44 @JsonIgnore
58 /** 使用中间表的一对多关联 明细信息 */ 45 /** 使用中间表的一对多关联 明细信息 */
59 @OneToMany(mappedBy = "schedulePlan", cascade = CascadeType.ALL, fetch = FetchType.LAZY) 46 @OneToMany(mappedBy = "schedulePlan", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
@@ -75,22 +62,6 @@ public class SchedulePlan extends BEntity { @@ -75,22 +62,6 @@ public class SchedulePlan extends BEntity {
75 this.xl = xl; 62 this.xl = xl;
76 } 63 }
77 64
78 - public TTInfo getTtInfo() {  
79 - return ttInfo;  
80 - }  
81 -  
82 - public void setTtInfo(TTInfo ttInfo) {  
83 - this.ttInfo = ttInfo;  
84 - }  
85 -  
86 - public ScheduleRule1 getScheduleRule1() {  
87 - return scheduleRule1;  
88 - }  
89 -  
90 - public void setScheduleRule1(ScheduleRule1 scheduleRule1) {  
91 - this.scheduleRule1 = scheduleRule1;  
92 - }  
93 -  
94 public Date getScheduleFromTime() { 65 public Date getScheduleFromTime() {
95 return scheduleFromTime; 66 return scheduleFromTime;
96 } 67 }
@@ -123,19 +94,11 @@ public class SchedulePlan extends BEntity { @@ -123,19 +94,11 @@ public class SchedulePlan extends BEntity {
123 this.ttInfoNames = ttInfoNames; 94 this.ttInfoNames = ttInfoNames;
124 } 95 }
125 96
126 - public String getTtInfoId() {  
127 - return ttInfoId;  
128 - }  
129 -  
130 - public void setTtInfoId(String ttInfoId) {  
131 - this.ttInfoId = ttInfoId;  
132 - }  
133 -  
134 - public String getRule1Ids() {  
135 - return rule1Ids; 97 + public String getTtInfoIds() {
  98 + return ttInfoIds;
136 } 99 }
137 100
138 - public void setRule1Ids(String rule1Ids) {  
139 - this.rule1Ids = rule1Ids; 101 + public void setTtInfoIds(String ttInfoIds) {
  102 + this.ttInfoIds = ttInfoIds;
140 } 103 }
141 } 104 }
src/main/java/com/bsth/entity/schedule/temp/SchedulePlanRuleResult.java 0 → 100644
  1 +package com.bsth.entity.schedule.temp;
  2 +
  3 +import com.bsth.entity.schedule.SchedulePlan;
  4 +
  5 +import javax.persistence.Entity;
  6 +import javax.persistence.GeneratedValue;
  7 +import javax.persistence.Id;
  8 +import javax.persistence.Table;
  9 +import java.util.Date;
  10 +
  11 +/**
  12 + * 排班的中间结果数据,记录每次排班后规则的变化。
  13 + */
  14 +@Entity
  15 +@Table(name = "bsth_c_s_sp_rule_rst")
  16 +public class SchedulePlanRuleResult {
  17 + /** 主键Id */
  18 + @Id
  19 + @GeneratedValue
  20 + private Long id;
  21 +
  22 + /** 线路id */
  23 + private String xlId;
  24 + /** 线路名字 */
  25 + private String xlName;
  26 +
  27 + /** 排班规则id */
  28 + private String ruleId;
  29 + /** 车辆配置id */
  30 + private String ccId;
  31 + /** 车辆自编号 */
  32 + private String ccZbh;
  33 +
  34 + /** 路牌id列表字符串 */
  35 + private String gids;
  36 + /** 路牌名字列表字符串 */
  37 + private String gnames;
  38 + /** 翻到哪个路牌索引 */
  39 + private String gidindex;
  40 + /** 人员配置id列表字符串 */
  41 + private String ecids;
  42 + /** 人员配置搭班编码列表字符串 */
  43 + private String ecdbbms;
  44 + /** 翻到哪个人员配置索引 */
  45 + private String ecindex;
  46 +
  47 + /** 时刻表id */
  48 + private String ttinfoId;
  49 + /** 时刻表名字 */
  50 + private String ttinfoName;
  51 +
  52 + /** 排班日期 */
  53 + private Date scheduleDate;
  54 +
  55 + /** 操作人员id */
  56 + private String sysuserId;
  57 + /** 操作人员姓名 */
  58 + private String sysuserName;
  59 + /** 操作时间 */
  60 + private Date createDate;
  61 +
  62 + public SchedulePlanRuleResult() {
  63 +
  64 + }
  65 + public SchedulePlanRuleResult(SchedulePlan schedulePlan) {
  66 + this.sysuserId = schedulePlan.getCreateBy().getId().toString();
  67 + this.sysuserName = schedulePlan.getCreateBy().getName();
  68 +// this.createDate = schedulePlan.getCreateDate();
  69 + this.createDate = new Date();
  70 + }
  71 +
  72 + public Long getId() {
  73 + return id;
  74 + }
  75 +
  76 + public void setId(Long id) {
  77 + this.id = id;
  78 + }
  79 +
  80 + public String getRuleId() {
  81 + return ruleId;
  82 + }
  83 +
  84 + public void setRuleId(String ruleId) {
  85 + this.ruleId = ruleId;
  86 + }
  87 +
  88 + public String getCcId() {
  89 + return ccId;
  90 + }
  91 +
  92 + public void setCcId(String ccId) {
  93 + this.ccId = ccId;
  94 + }
  95 +
  96 + public String getCcZbh() {
  97 + return ccZbh;
  98 + }
  99 +
  100 + public void setCcZbh(String ccZbh) {
  101 + this.ccZbh = ccZbh;
  102 + }
  103 +
  104 + public String getGids() {
  105 + return gids;
  106 + }
  107 +
  108 + public void setGids(String gids) {
  109 + this.gids = gids;
  110 + }
  111 +
  112 + public String getGnames() {
  113 + return gnames;
  114 + }
  115 +
  116 + public void setGnames(String gnames) {
  117 + this.gnames = gnames;
  118 + }
  119 +
  120 + public String getGidindex() {
  121 + return gidindex;
  122 + }
  123 +
  124 + public void setGidindex(String gidindex) {
  125 + this.gidindex = gidindex;
  126 + }
  127 +
  128 + public String getEcids() {
  129 + return ecids;
  130 + }
  131 +
  132 + public void setEcids(String ecids) {
  133 + this.ecids = ecids;
  134 + }
  135 +
  136 + public String getEcdbbms() {
  137 + return ecdbbms;
  138 + }
  139 +
  140 + public void setEcdbbms(String ecdbbms) {
  141 + this.ecdbbms = ecdbbms;
  142 + }
  143 +
  144 + public String getEcindex() {
  145 + return ecindex;
  146 + }
  147 +
  148 + public void setEcindex(String ecindex) {
  149 + this.ecindex = ecindex;
  150 + }
  151 +
  152 + public Date getScheduleDate() {
  153 + return scheduleDate;
  154 + }
  155 +
  156 + public void setScheduleDate(Date scheduleDate) {
  157 + this.scheduleDate = scheduleDate;
  158 + }
  159 +
  160 + public String getSysuserId() {
  161 + return sysuserId;
  162 + }
  163 +
  164 + public void setSysuserId(String sysuserId) {
  165 + this.sysuserId = sysuserId;
  166 + }
  167 +
  168 + public String getSysuserName() {
  169 + return sysuserName;
  170 + }
  171 +
  172 + public void setSysuserName(String sysuserName) {
  173 + this.sysuserName = sysuserName;
  174 + }
  175 +
  176 + public Date getCreateDate() {
  177 + return createDate;
  178 + }
  179 +
  180 + public void setCreateDate(Date createDate) {
  181 + this.createDate = createDate;
  182 + }
  183 +
  184 + public String getXlId() {
  185 + return xlId;
  186 + }
  187 +
  188 + public void setXlId(String xlId) {
  189 + this.xlId = xlId;
  190 + }
  191 +
  192 + public String getXlName() {
  193 + return xlName;
  194 + }
  195 +
  196 + public void setXlName(String xlName) {
  197 + this.xlName = xlName;
  198 + }
  199 +
  200 + public String getTtinfoId() {
  201 + return ttinfoId;
  202 + }
  203 +
  204 + public void setTtinfoId(String ttinfoId) {
  205 + this.ttinfoId = ttinfoId;
  206 + }
  207 +
  208 + public String getTtinfoName() {
  209 + return ttinfoName;
  210 + }
  211 +
  212 + public void setTtinfoName(String ttinfoName) {
  213 + this.ttinfoName = ttinfoName;
  214 + }
  215 +}
src/main/java/com/bsth/repository/BusinessRepository.java
@@ -4,6 +4,8 @@ import org.springframework.stereotype.Repository; @@ -4,6 +4,8 @@ import org.springframework.stereotype.Repository;
4 4
5 import com.bsth.entity.Business; 5 import com.bsth.entity.Business;
6 6
  7 +import java.util.List;
  8 +
7 /** 9 /**
8 * 10 *
9 * @Interface: BusinessRepository(公司Repository数据持久层接口) 11 * @Interface: BusinessRepository(公司Repository数据持久层接口)
@@ -23,4 +25,8 @@ import com.bsth.entity.Business; @@ -23,4 +25,8 @@ import com.bsth.entity.Business;
23 @Repository 25 @Repository
24 public interface BusinessRepository extends BaseRepository<Business, Integer> { 26 public interface BusinessRepository extends BaseRepository<Business, Integer> {
25 27
  28 + List<Business> findByBusinessCode(String code);
  29 +
  30 + List<Business> findByUpCodeAndBusinessCode(String c1, String c2);
  31 +
26 } 32 }
src/main/java/com/bsth/repository/oil/YlbRepository.java
@@ -42,8 +42,13 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{ @@ -42,8 +42,13 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{
42 42
43 @Transactional 43 @Transactional
44 @Modifying 44 @Modifying
45 - @Query(value="SELECT * FROM bsth_c_ylb where to_days(?1)=to_days(rq) and nbbm =?2 and jsy=?3",nativeQuery=true) 45 + @Query(value="SELECT * FROM bsth_c_ylb where to_days(?1)=to_days(rq) and nbbm =?2 and jsy=?3 ",nativeQuery=true)
46 List<Ylb> queryListYlb(String rq,String nbbm,String jgh); 46 List<Ylb> queryListYlb(String rq,String nbbm,String jgh);
  47 +
  48 + @Transactional
  49 + @Modifying
  50 + @Query(value="SELECT * FROM bsth_c_ylb where to_days(?1)=to_days(rq) and nbbm =?2 and jsy=?3 and xlbm=?4 order by ?5 asc",nativeQuery=true)
  51 + List<Ylb> checkYlb(String rq,String nbbm,String jgh,String xlbm,String px);
47 /** 52 /**
48 * 查询当天总的加注量和总里程 53 * 查询当天总的加注量和总里程
49 * @param rq 54 * @param rq
@@ -71,6 +76,23 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{ @@ -71,6 +76,23 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{
71 List<Object[]> checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm); 76 List<Object[]> checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm);
72 77
73 78
  79 + /**
  80 + *
  81 + * @param nbbm
  82 + * @param rq
  83 + * @param xlbm
  84 + * @return
  85 + */
  86 + @Transactional
  87 + @Modifying
  88 + @Query(value="select nbbm,sum(jzl*100) as jzl ,sum(zlc*100) as zlc from bsth_c_ylb where to_days(?1)=to_days(rq) and "
  89 + + " ssgsdm like %?2% "
  90 + + " and fgsdm like %?3%"
  91 + + " and xlbm like %?4% and nbbm like %?5% "
  92 + + " group by nbbm,rq,ssgsdm,fgsdm,xlbm",nativeQuery=true)
  93 + List<Object[]> checkNbmmYl(String rq, String gsbm,String fgsbm,String xlbm,String nbbm);
  94 +
  95 +
74 @Query(value="select jzl,yh,sh from Ylb s " 96 @Query(value="select jzl,yh,sh from Ylb s "
75 + " where to_days(?1)=to_days(s.rq) " 97 + " where to_days(?1)=to_days(s.rq) "
76 + " and s.ssgsdm like %?2% " 98 + " and s.ssgsdm like %?2% "
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
@@ -89,6 +89,19 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI @@ -89,6 +89,19 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
89 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) 89 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
90 @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and s.xlBm=?5 order by realExecDate,fcsj") 90 @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jName = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and s.xlBm=?5 order by realExecDate,fcsj")
91 List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line); 91 List<ScheduleRealInfo> queryListWaybill(String jName,String clZbh,String lpName,String date,String line);
  92 +
  93 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  94 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh = ?1 and s.clZbh = ?2 and s.lpName = ?3 and s.scheduleDate = str_to_date(?4,'%Y-%m-%d') and s.xlBm=?5 order by realExecDate,fcsj")
  95 + List<ScheduleRealInfo> queryListWaybillXcld(String jGh,String clZbh,String lpName,String date,String line);
  96 +
  97 +// @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  98 +// @Query(value="select DISTINCT s from ScheduleRealInfo s where s.jGh like %?1% and s.clZbh like %?2% and s.scheduleDate = str_to_date(?3,'%Y-%m-%d') and s.gsBm like %?4% and s.fgsBm like %?5% order by realExecDate,fcsj")
  99 +// List<ScheduleRealInfo> queryListWaybill3(String jName,String clZbh,String date,String gsbm,String fgsbm);
  100 +
  101 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  102 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.xlBm,s.clZbh,s.jGh,s.adjustExps,s.fcsj")
  103 + List<ScheduleRealInfo> scheduleByDateAndLineTjrb(String line,String date);
  104 +
92 105
93 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH) 106 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
94 @Query(value="select DISTINCT s from ScheduleRealInfo s where s.clZbh = ?1 and s.scheduleDate = str_to_date(?2,'%Y-%m-%d') and xlBm =?3 order by realExecDate,fcsj") 107 @Query(value="select DISTINCT s from ScheduleRealInfo s where s.clZbh = ?1 and s.scheduleDate = str_to_date(?2,'%Y-%m-%d') and xlBm =?3 order by realExecDate,fcsj")
@@ -119,25 +132,30 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI @@ -119,25 +132,30 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
119 void deleteByLineCodeAndDate(String xlBm, String schDate); 132 void deleteByLineCodeAndDate(String xlBm, String schDate);
120 133
121 //去掉了 xlBm is not null 134 //去掉了 xlBm is not null
122 - @Query(value="select s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.realExecDate,s.fcsj, (s.lpName+1)") 135 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  136 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by s.realExecDate,s.fcsj, (s.lpName+1)")
123 List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date); 137 List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date);
124 138
125 - @Query(value="select s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by (s.lpName+1), s.realExecDate,s.fcsj") 139 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  140 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 order by (s.lpName+1), s.realExecDate,s.fcsj")
126 List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date); 141 List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date);
127 142
128 - @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.bcType not in ('in','out') order by s.xlBm") 143 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  144 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.bcType not in ('in','out') order by s.xlBm,s.adjustExps,s.fcsj")
129 List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date); 145 List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date);
130 146
131 //按月统计 147 //按月统计
132 - @Query(value="select s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m') = ?2 and s.bcType not in ('in','out') order by s.xlBm") 148 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  149 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m') = ?2 and s.bcType not in ('in','out') order by s.xlBm")
133 List<ScheduleRealInfo> scheduleByDateAndLine3(String line,String date); 150 List<ScheduleRealInfo> scheduleByDateAndLine3(String line,String date);
134 151
135 //按照时间段统计 152 //按照时间段统计
136 - @Query(value="select s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') between ?2 and ?3 and s.bcType not in ('in','out') order by s.xlBm") 153 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  154 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') between ?2 and ?3 and s.bcType not in ('in','out') order by s.xlBm")
137 List<ScheduleRealInfo> scheduleByDateAndLineTj(String line,String date,String date2); 155 List<ScheduleRealInfo> scheduleByDateAndLineTj(String line,String date,String date2);
138 156
139 //按照时间段统计 157 //按照时间段统计
140 - @Query(value="select s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') between ?2 and ?3 and s.bcType not in ('in','out') order by s.xlBm") 158 + @Query(value="select DISTINCT s from ScheduleRealInfo s where s.xlBm = ?1 and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') between ?2 and ?3 and s.bcType not in ('in','out') order by s.xlBm")
141 List<ScheduleRealInfo> scheduleByDateAndLineTj2(String line,String date,String date2); 159 List<ScheduleRealInfo> scheduleByDateAndLineTj2(String line,String date,String date2);
142 160
143 @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,min(s.fcsj) as fcsj ) from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% GROUP BY xlBm,clZbh,jGh,scheduleDate,jGh ORDER BY clZbh,fcsj") 161 @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,min(s.fcsj) as fcsj ) from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% GROUP BY xlBm,clZbh,jGh,scheduleDate,jGh ORDER BY clZbh,fcsj")
src/main/java/com/bsth/repository/schedule/CarConfigInfoRepository.java
@@ -19,7 +19,9 @@ import org.springframework.stereotype.Repository; @@ -19,7 +19,9 @@ import org.springframework.stereotype.Repository;
19 @Repository 19 @Repository
20 public interface CarConfigInfoRepository extends BaseRepository<CarConfigInfo, Long> { 20 public interface CarConfigInfoRepository extends BaseRepository<CarConfigInfo, Long> {
21 21
22 - @EntityGraph(value = "carConfigInfo_xl_cl", type = EntityGraph.EntityGraphType.FETCH) 22 +// @EntityGraph(value = "carConfigInfo_xl_cl", type = EntityGraph.EntityGraphType.FETCH)
  23 + // 因为使用了in操作符,用 @EntityGraph会报错,升到hibernate 5.0.4就好了,暂时不用@EntityGraph
  24 + // Hibernate ORMHHH-9230
23 @Override 25 @Override
24 Page<CarConfigInfo> findAll(Specification<CarConfigInfo> spec, Pageable pageable); 26 Page<CarConfigInfo> findAll(Specification<CarConfigInfo> spec, Pageable pageable);
25 27
@@ -45,4 +47,7 @@ public interface CarConfigInfoRepository extends BaseRepository&lt;CarConfigInfo, L @@ -45,4 +47,7 @@ public interface CarConfigInfoRepository extends BaseRepository&lt;CarConfigInfo, L
45 47
46 @Query("select new map(cc.cl.id as id, cc.cl.insideCode as insideCode) from CarConfigInfo cc") 48 @Query("select new map(cc.cl.id as id, cc.cl.insideCode as insideCode) from CarConfigInfo cc")
47 List<Map<String, Object>> findCarsFromConfig(); 49 List<Map<String, Object>> findCarsFromConfig();
  50 +
  51 + @EntityGraph(value = "carConfigInfo_xl_cl", type = EntityGraph.EntityGraphType.FETCH)
  52 + List<CarConfigInfo> findByXlId(Integer xlid);
48 } 53 }
49 \ No newline at end of file 54 \ No newline at end of file
src/main/java/com/bsth/repository/schedule/EmployeeConfigInfoRepository.java
@@ -25,6 +25,11 @@ public interface EmployeeConfigInfoRepository extends BaseRepository&lt;EmployeeCon @@ -25,6 +25,11 @@ public interface EmployeeConfigInfoRepository extends BaseRepository&lt;EmployeeCon
25 List<EmployeeConfigInfo> findBylineCode(String lineCode); 25 List<EmployeeConfigInfo> findBylineCode(String lineCode);
26 26
27 @EntityGraph(value = "employeeConfigInfo_jsy_spy_xl", type = EntityGraph.EntityGraphType.FETCH) 27 @EntityGraph(value = "employeeConfigInfo_jsy_spy_xl", type = EntityGraph.EntityGraphType.FETCH)
  28 + List<EmployeeConfigInfo> findByXlId(Integer xlid);
  29 +
  30 +// @EntityGraph(value = "employeeConfigInfo_jsy_spy_xl", type = EntityGraph.EntityGraphType.FETCH)
  31 + // 因为使用了in操作符,用 @EntityGraph会报错,升到hibernate 5.0.4就好了,暂时不用@EntityGraph
  32 + // Hibernate ORMHHH-9230
28 @Override 33 @Override
29 Page<EmployeeConfigInfo> findAll(Specification<EmployeeConfigInfo> spec, Pageable pageable); 34 Page<EmployeeConfigInfo> findAll(Specification<EmployeeConfigInfo> spec, Pageable pageable);
30 35
src/main/java/com/bsth/repository/schedule/GuideboardInfoRepository.java
@@ -21,7 +21,9 @@ import org.springframework.stereotype.Repository; @@ -21,7 +21,9 @@ import org.springframework.stereotype.Repository;
21 @Repository 21 @Repository
22 public interface GuideboardInfoRepository extends BaseRepository<GuideboardInfo, Long> { 22 public interface GuideboardInfoRepository extends BaseRepository<GuideboardInfo, Long> {
23 23
24 - @EntityGraph(value = "guideboardInfo_xl", type = EntityGraph.EntityGraphType.FETCH) 24 +// @EntityGraph(value = "guideboardInfo_xl", type = EntityGraph.EntityGraphType.FETCH)
  25 + // 因为使用了in操作符,用 @EntityGraph会报错,升到hibernate 5.0.4就好了,暂时不用@EntityGraph
  26 + // Hibernate ORMHHH-9230
25 @Override 27 @Override
26 Page<GuideboardInfo> findAll(Specification<GuideboardInfo> spec, Pageable pageable); 28 Page<GuideboardInfo> findAll(Specification<GuideboardInfo> spec, Pageable pageable);
27 29
src/main/java/com/bsth/repository/schedule/RerunRuleRepository.java
@@ -15,7 +15,9 @@ import org.springframework.stereotype.Repository; @@ -15,7 +15,9 @@ import org.springframework.stereotype.Repository;
15 */ 15 */
16 @Repository 16 @Repository
17 public interface RerunRuleRepository extends BaseRepository<RerunRule, Long> { 17 public interface RerunRuleRepository extends BaseRepository<RerunRule, Long> {
18 - @EntityGraph(value = "dylp", type = EntityGraph.EntityGraphType.FETCH) 18 +// @EntityGraph(value = "dylp", type = EntityGraph.EntityGraphType.FETCH)
  19 + // 因为使用了in操作符,用 @EntityGraph会报错,升到hibernate 5.0.4就好了,暂时不用@EntityGraph
  20 + // Hibernate ORMHHH-9230
19 @Override 21 @Override
20 Page<RerunRule> findAll(Specification<RerunRule> spec, Pageable pageable); 22 Page<RerunRule> findAll(Specification<RerunRule> spec, Pageable pageable);
21 23
src/main/java/com/bsth/repository/schedule/SchedulePlanRepository.java
@@ -5,7 +5,6 @@ import com.bsth.repository.BaseRepository; @@ -5,7 +5,6 @@ import com.bsth.repository.BaseRepository;
5 import org.springframework.data.domain.Page; 5 import org.springframework.data.domain.Page;
6 import org.springframework.data.domain.Pageable; 6 import org.springframework.data.domain.Pageable;
7 import org.springframework.data.jpa.domain.Specification; 7 import org.springframework.data.jpa.domain.Specification;
8 -import org.springframework.data.jpa.repository.EntityGraph;  
9 import org.springframework.stereotype.Repository; 8 import org.springframework.stereotype.Repository;
10 9
11 /** 10 /**
@@ -13,7 +12,9 @@ import org.springframework.stereotype.Repository; @@ -13,7 +12,9 @@ import org.springframework.stereotype.Repository;
13 */ 12 */
14 @Repository 13 @Repository
15 public interface SchedulePlanRepository extends BaseRepository<SchedulePlan, Long> { 14 public interface SchedulePlanRepository extends BaseRepository<SchedulePlan, Long> {
16 - @EntityGraph(value = "schedulePlan_xl_ttinfo", type = EntityGraph.EntityGraphType.FETCH) 15 +// @EntityGraph(value = "schedulePlan_xl", type = EntityGraph.EntityGraphType.FETCH)
  16 + // 因为使用了in操作符,用 @EntityGraph会报错,升到hibernate 5.0.4就好了,暂时不用@EntityGraph
  17 + // Hibernate ORMHHH-9230
17 @Override 18 @Override
18 Page<SchedulePlan> findAll(Specification<SchedulePlan> spec, Pageable pageable); 19 Page<SchedulePlan> findAll(Specification<SchedulePlan> spec, Pageable pageable);
19 20
src/main/java/com/bsth/repository/schedule/SchedulePlanRuleResultRepository.java 0 → 100644
  1 +package com.bsth.repository.schedule;
  2 +
  3 +import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;
  4 +import com.bsth.repository.BaseRepository;
  5 +import org.springframework.data.jpa.repository.Modifying;
  6 +import org.springframework.data.jpa.repository.Query;
  7 +import org.springframework.stereotype.Repository;
  8 +
  9 +import java.util.Date;
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * Created by xu on 17/3/29.
  14 + */
  15 +@Repository
  16 +public interface SchedulePlanRuleResultRepository extends BaseRepository<SchedulePlanRuleResult, Long> {
  17 +
  18 + @Query("select t from SchedulePlanRuleResult t " +
  19 + "where not exists (select 1 from SchedulePlanRuleResult " +
  20 + "where createDate > t.createDate and scheduleDate < ?2 ) " +
  21 + "and t.xlId = ?1 and t.scheduleDate < ?2")
  22 + List<SchedulePlanRuleResult> findLastByXl(String xlid, Date from);
  23 +
  24 +// @Modifying
  25 +// @Query("delete from SchedulePlanRuleResult t " +
  26 +// "where t.xlId = ?1 and t.scheduleDate >= ?2 and t.scheduleDate <= ?3")
  27 +// void deleteByXlAndDate(String xlid, Date from, Date to);
  28 +}
src/main/java/com/bsth/repository/schedule/ScheduleRule1FlatRepository.java
1 package com.bsth.repository.schedule; 1 package com.bsth.repository.schedule;
2 2
  3 +import com.bsth.entity.Line;
3 import com.bsth.entity.schedule.rule.ScheduleRule1Flat; 4 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
4 import com.bsth.repository.BaseRepository; 5 import com.bsth.repository.BaseRepository;
5 import org.springframework.data.domain.Page; 6 import org.springframework.data.domain.Page;
@@ -9,17 +10,23 @@ import org.springframework.data.jpa.repository.EntityGraph; @@ -9,17 +10,23 @@ import org.springframework.data.jpa.repository.EntityGraph;
9 import org.springframework.data.jpa.repository.Query; 10 import org.springframework.data.jpa.repository.Query;
10 import org.springframework.stereotype.Repository; 11 import org.springframework.stereotype.Repository;
11 12
  13 +import java.util.List;
  14 +
12 /** 15 /**
13 * Created by xu on 16/7/4. 16 * Created by xu on 16/7/4.
14 */ 17 */
15 @Repository 18 @Repository
16 public interface ScheduleRule1FlatRepository extends BaseRepository<ScheduleRule1Flat, Long> { 19 public interface ScheduleRule1FlatRepository extends BaseRepository<ScheduleRule1Flat, Long> {
17 20
18 - @EntityGraph(value = "scheduleRule1Flat_xl_carconfig", type = EntityGraph.EntityGraphType.FETCH) 21 +// @EntityGraph(value = "scheduleRule1Flat_xl_carconfig", type = EntityGraph.EntityGraphType.FETCH)
  22 + // 因为使用了in操作符,用 @EntityGraph会报错,升到hibernate 5.0.4就好了,暂时不用@EntityGraph
  23 + // Hibernate ORMHHH-9230
19 @Override 24 @Override
20 Page<ScheduleRule1Flat> findAll(Specification<ScheduleRule1Flat> spec, Pageable pageable); 25 Page<ScheduleRule1Flat> findAll(Specification<ScheduleRule1Flat> spec, Pageable pageable);
21 26
22 @EntityGraph(value = "scheduleRule1Flat_xl_carconfig", type = EntityGraph.EntityGraphType.FETCH) 27 @EntityGraph(value = "scheduleRule1Flat_xl_carconfig", type = EntityGraph.EntityGraphType.FETCH)
23 @Query("select cc from ScheduleRule1Flat cc where cc.id=?1") 28 @Query("select cc from ScheduleRule1Flat cc where cc.id=?1")
24 ScheduleRule1Flat findOneExtend(Long aLong); 29 ScheduleRule1Flat findOneExtend(Long aLong);
  30 +
  31 + List<ScheduleRule1Flat> findByXl(Line line);
25 } 32 }
src/main/java/com/bsth/repository/schedule/TTInfoDetailRepository.java
@@ -45,8 +45,11 @@ public interface TTInfoDetailRepository extends BaseRepository&lt;TTInfoDetail, Lon @@ -45,8 +45,11 @@ public interface TTInfoDetailRepository extends BaseRepository&lt;TTInfoDetail, Lon
45 @Query(value = "select tt from TTInfoDetail tt where tt.xl.id = ?1 and tt.ttinfo.id = ?2 and tt.lp.id = ?3 order by tt.fcno asc") 45 @Query(value = "select tt from TTInfoDetail tt where tt.xl.id = ?1 and tt.ttinfo.id = ?2 and tt.lp.id = ?3 order by tt.fcno asc")
46 List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId); 46 List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId);
47 47
  48 + List<TTInfoDetail> findByTtinfoId(Long id);
  49 +
48 @Modifying 50 @Modifying
49 @Query(value = "delete from TTInfoDetail t where t.ttinfo.id = ?1") 51 @Query(value = "delete from TTInfoDetail t where t.ttinfo.id = ?1")
50 void deleteByTtinfoIdWithModify(Long ttinfoid); 52 void deleteByTtinfoIdWithModify(Long ttinfoid);
51 53
  54 +
52 } 55 }
src/main/java/com/bsth/repository/schedule/TTInfoRepository.java
1 package com.bsth.repository.schedule; 1 package com.bsth.repository.schedule;
2 2
  3 +import com.bsth.entity.Line;
3 import com.bsth.entity.schedule.EmployeeConfigInfo; 4 import com.bsth.entity.schedule.EmployeeConfigInfo;
4 import com.bsth.entity.schedule.TTInfo; 5 import com.bsth.entity.schedule.TTInfo;
5 import com.bsth.repository.BaseRepository; 6 import com.bsth.repository.BaseRepository;
@@ -10,17 +11,24 @@ import org.springframework.data.jpa.repository.EntityGraph; @@ -10,17 +11,24 @@ import org.springframework.data.jpa.repository.EntityGraph;
10 import org.springframework.data.jpa.repository.Query; 11 import org.springframework.data.jpa.repository.Query;
11 import org.springframework.stereotype.Repository; 12 import org.springframework.stereotype.Repository;
12 13
  14 +import java.util.List;
  15 +
13 /** 16 /**
14 * Created by xu on 16/5/12. 17 * Created by xu on 16/5/12.
15 */ 18 */
16 @Repository 19 @Repository
17 public interface TTInfoRepository extends BaseRepository<TTInfo, Long> { 20 public interface TTInfoRepository extends BaseRepository<TTInfo, Long> {
18 21
19 - @EntityGraph(value = "ttInfo_xl", type = EntityGraph.EntityGraphType.FETCH) 22 +// @EntityGraph(value = "ttInfo_xl", type = EntityGraph.EntityGraphType.FETCH)
  23 + // 因为使用了in操作符,用 @EntityGraph会报错,升到hibernate 5.0.4就好了,暂时不用@EntityGraph
  24 + // Hibernate ORMHHH-9230
20 @Override 25 @Override
21 Page<TTInfo> findAll(Specification<TTInfo> spec, Pageable pageable); 26 Page<TTInfo> findAll(Specification<TTInfo> spec, Pageable pageable);
22 27
23 @EntityGraph(value = "ttInfo_xl", type = EntityGraph.EntityGraphType.FETCH) 28 @EntityGraph(value = "ttInfo_xl", type = EntityGraph.EntityGraphType.FETCH)
24 @Query("select cc from TTInfo cc where cc.id=?1") 29 @Query("select cc from TTInfo cc where cc.id=?1")
25 TTInfo findOneExtend(Long aLong); 30 TTInfo findOneExtend(Long aLong);
  31 +
  32 + @Query("select t from TTInfo t where t.xl = ?1 and t.isCancel = false")
  33 + List<TTInfo> findInCanceledByXl(Line xl);
26 } 34 }
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
@@ -6,6 +6,7 @@ import java.text.DecimalFormat; @@ -6,6 +6,7 @@ import java.text.DecimalFormat;
6 import java.text.NumberFormat; 6 import java.text.NumberFormat;
7 import java.text.ParseException; 7 import java.text.ParseException;
8 import java.text.SimpleDateFormat; 8 import java.text.SimpleDateFormat;
  9 +import java.util.ArrayList;
9 import java.util.Date; 10 import java.util.Date;
10 import java.util.HashMap; 11 import java.util.HashMap;
11 import java.util.List; 12 import java.util.List;
@@ -24,6 +25,8 @@ import com.bsth.entity.mcy_forms.Singledata; @@ -24,6 +25,8 @@ import com.bsth.entity.mcy_forms.Singledata;
24 import com.bsth.entity.mcy_forms.Turnoutrate; 25 import com.bsth.entity.mcy_forms.Turnoutrate;
25 import com.bsth.entity.mcy_forms.Vehicleloading; 26 import com.bsth.entity.mcy_forms.Vehicleloading;
26 import com.bsth.entity.mcy_forms.Waybillday; 27 import com.bsth.entity.mcy_forms.Waybillday;
  28 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  29 +import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
27 import com.bsth.data.BasicData; 30 import com.bsth.data.BasicData;
28 import com.bsth.entity.mcy_forms.Allline; 31 import com.bsth.entity.mcy_forms.Allline;
29 import com.bsth.entity.mcy_forms.Changetochange; 32 import com.bsth.entity.mcy_forms.Changetochange;
@@ -32,6 +35,8 @@ import com.bsth.entity.mcy_forms.Executionrate; @@ -32,6 +35,8 @@ import com.bsth.entity.mcy_forms.Executionrate;
32 import com.bsth.service.forms.CommonService; 35 import com.bsth.service.forms.CommonService;
33 import com.bsth.service.forms.FormsService; 36 import com.bsth.service.forms.FormsService;
34 import com.bsth.service.realcontrol.ScheduleRealInfoService; 37 import com.bsth.service.realcontrol.ScheduleRealInfoService;
  38 +import com.bsth.service.report.CulateMileageService;
  39 +import com.bsth.util.Arith;
35 40
36 @Service 41 @Service
37 public class FormsServiceImpl implements FormsService { 42 public class FormsServiceImpl implements FormsService {
@@ -44,6 +49,12 @@ public class FormsServiceImpl implements FormsService { @@ -44,6 +49,12 @@ public class FormsServiceImpl implements FormsService {
44 49
45 @Autowired 50 @Autowired
46 CommonService commonService; 51 CommonService commonService;
  52 +
  53 + @Autowired
  54 + ScheduleRealInfoRepository scheduleRealInfoRepository;
  55 +
  56 + @Autowired
  57 + CulateMileageService culateMileageService;
47 58
48 // 行车路单日报表 59 // 行车路单日报表
49 @Override 60 @Override
@@ -720,20 +731,33 @@ public class FormsServiceImpl implements FormsService { @@ -720,20 +731,33 @@ public class FormsServiceImpl implements FormsService {
720 731
721 @Override 732 @Override
722 public List<Daily> daily(Map<String, Object> map) { 733 public List<Daily> daily(Map<String, Object> map) {
  734 +
  735 + String gsbm="";
  736 + if(map.get("gsdmDaily")!=null){
  737 + gsbm=map.get("gsdmDaily").toString();
  738 + }
  739 +
  740 + String fgsbm="";
  741 + if(map.get("fgsdmDaily").toString()!=null){
  742 + fgsbm=map.get("fgsdmDaily").toString();
  743 + }
  744 +
723 String sql="select t.schedule_date_str," 745 String sql="select t.schedule_date_str,"
724 + " t.cl_zbh,t.j_gh,t.j_name,x.yh from (select r.schedule_date_str,r.xl_bm,r.xl_name," 746 + " t.cl_zbh,t.j_gh,t.j_name,x.yh from (select r.schedule_date_str,r.xl_bm,r.xl_name,"
725 + " r.cl_zbh,r.j_gh,r.j_name from bsth_c_s_sp_info_real r WHERE " 747 + " r.cl_zbh,r.j_gh,r.j_name from bsth_c_s_sp_info_real r WHERE "
726 - + " r.xl_bm='" + map.get("line").toString() + "' and to_days(r.schedule_date)=to_days('"+map.get("date").toString()+"') "  
727 - + " and r.gs_bm like '%"+map.get("gsdmDaily").toString()+"%' "  
728 - + " and r.fgs_bm like '%"+map.get("fgsdmDaily").toString()+"%' " 748 + + " r.xl_bm='" + map.get("line").toString() + "' "
  749 + + " and to_days(r.schedule_date)=to_days('"+map.get("date").toString()+"') "
  750 + + " and r.gs_bm like '%"+gsbm+"%' "
  751 + + " and r.fgs_bm like '%"+fgsbm+"%' "
729 + " GROUP BY r.schedule_date_str,r.xl_bm,r.xl_name,r.cl_zbh,r.j_gh,r.j_name) t" 752 + " GROUP BY r.schedule_date_str,r.xl_bm,r.xl_name,r.cl_zbh,r.j_gh,r.j_name) t"
730 + " left join (select * from bsth_c_ylb y where " 753 + " left join (select * from bsth_c_ylb y where "
731 + " to_days(y.rq)=to_days('"+map.get("date").toString()+"') " 754 + " to_days(y.rq)=to_days('"+map.get("date").toString()+"') "
732 + " and y.xlbm= '" + map.get("line").toString() + "'" 755 + " and y.xlbm= '" + map.get("line").toString() + "'"
733 - + " and y.ssgsdm like '%"+map.get("gsdmDaily").toString()+"%' "  
734 - + " and y.fgsdm like '%"+map.get("fgsdmDaily").toString()+"%'" 756 + + " and y.ssgsdm like '%"+gsbm+"%' "
  757 + + " and y.fgsdm like '%"+fgsbm+"%'"
735 + " ) x" 758 + " ) x"
736 + " on t.cl_zbh = x.nbbm "; 759 + " on t.cl_zbh = x.nbbm ";
  760 +
737 List<Daily> list = jdbcTemplate.query(sql, new RowMapper<Daily>() { 761 List<Daily> list = jdbcTemplate.query(sql, new RowMapper<Daily>() {
738 @Override 762 @Override
739 public Daily mapRow(ResultSet arg0, int arg1) throws SQLException { 763 public Daily mapRow(ResultSet arg0, int arg1) throws SQLException {
@@ -746,14 +770,28 @@ public class FormsServiceImpl implements FormsService { @@ -746,14 +770,28 @@ public class FormsServiceImpl implements FormsService {
746 return daily; 770 return daily;
747 } 771 }
748 }); 772 });
749 - 773 + List<ScheduleRealInfo> sList;
  774 + List<ScheduleRealInfo> lists=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(map.get("line").toString(), map.get("date").toString());
750 for(int i=0;i<list.size();i++){ 775 for(int i=0;i<list.size();i++){
  776 + sList =new ArrayList<ScheduleRealInfo>();
751 Daily d=list.get(i); 777 Daily d=list.get(i);
752 - Map<String, Object> maps = new HashMap<>();  
753 - maps = commonService.findKMBC2(d.getJgh(),d.getZbh(),d.getRq());  
754 - d.setJzl1(maps.get("ksgl").toString());  
755 - d.setZlc(maps.get("realMileage").toString());  
756 - d.setBc(maps.get("sjbc").toString()); 778 + for (int j = 0; j < lists.size(); j++) {
  779 + ScheduleRealInfo s=lists.get(j);
  780 + if(d.getJgh().equals(s.getjGh()) && d.getZbh().equals(s.getClZbh())){
  781 + sList.add(s);
  782 + }
  783 + }
  784 +
  785 + double ksgl=culateMileageService.culateKsgl(sList);
  786 + double jccgl=culateMileageService.culateJccgl(sList);
  787 + double zksgl=Arith.add(ksgl, jccgl);
  788 + double ljgl=culateMileageService.culateLjgl(sList);
  789 + double sjgl=culateMileageService.culateSjgl(sList);
  790 + double zyygl=Arith.add(ljgl, sjgl);
  791 +
  792 + d.setJzl1(String.valueOf(zksgl));//空驶公里
  793 + d.setZlc(String.valueOf(Arith.add(zksgl, zyygl)));
  794 + d.setBc(String.valueOf(culateMileageService.culateSjbc(sList, "")+culateMileageService.culateLjbc(sList, "")));
757 } 795 }
758 return list; 796 return list;
759 } 797 }
src/main/java/com/bsth/service/oil/CwjyService.java
1 package com.bsth.service.oil; 1 package com.bsth.service.oil;
2 2
3 3
  4 +import java.util.List;
4 import java.util.Map; 5 import java.util.Map;
5 6
6 import com.bsth.entity.oil.Cwjy; 7 import com.bsth.entity.oil.Cwjy;
@@ -9,8 +10,8 @@ import com.bsth.service.BaseService; @@ -9,8 +10,8 @@ import com.bsth.service.BaseService;
9 import com.bsth.util.PageObject; 10 import com.bsth.util.PageObject;
10 11
11 public interface CwjyService extends BaseService<Cwjy, Integer>{ 12 public interface CwjyService extends BaseService<Cwjy, Integer>{
12 - PageObject<Ylxxb> Pagequery(Map<String, Object> map) ; 13 + List<Ylxxb> Pagequery(Map<String, Object> map) ;
13 Ylxxb bynbbm(Map<String, Object> map); 14 Ylxxb bynbbm(Map<String, Object> map);
14 15
15 - Map<String, Object> savejzl(Ylxxb t); 16 + Map<String, Object> savejzl(Map<String, Object> map) throws Exception ;
16 } 17 }
src/main/java/com/bsth/service/oil/YlbService.java
@@ -23,5 +23,6 @@ public interface YlbService extends BaseService&lt;Ylb, Integer&gt;{ @@ -23,5 +23,6 @@ public interface YlbService extends BaseService&lt;Ylb, Integer&gt;{
23 List<Ylb> listYlb(Map<String, Object> map); 23 List<Ylb> listYlb(Map<String, Object> map);
24 StringBuffer checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int lx); 24 StringBuffer checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int lx);
25 25
  26 + Map<String, Object> deleteIds(Map<String, Object> map) throws Exception;
26 27
27 } 28 }
src/main/java/com/bsth/service/oil/YlxxbService.java
@@ -9,6 +9,6 @@ import com.bsth.util.PageObject; @@ -9,6 +9,6 @@ import com.bsth.util.PageObject;
9 public interface YlxxbService extends BaseService<Ylxxb, Integer>{ 9 public interface YlxxbService extends BaseService<Ylxxb, Integer>{
10 PageObject<Ylxxb> Pagequery(Map<String, Object> map) ; 10 PageObject<Ylxxb> Pagequery(Map<String, Object> map) ;
11 11
12 - Map<String, Object> checkJsy(Map<String, Object> map); 12 + Map<String, Object> checkJsy(Map<String, Object> map) throws Exception;
13 13
14 } 14 }
src/main/java/com/bsth/service/oil/impl/CwjyServiceImpl.java
@@ -6,17 +6,26 @@ import java.text.ParseException; @@ -6,17 +6,26 @@ import java.text.ParseException;
6 import java.text.SimpleDateFormat; 6 import java.text.SimpleDateFormat;
7 import java.util.ArrayList; 7 import java.util.ArrayList;
8 import java.util.Arrays; 8 import java.util.Arrays;
  9 +import java.util.Date;
9 import java.util.HashMap; 10 import java.util.HashMap;
10 import java.util.List; 11 import java.util.List;
11 import java.util.Map; 12 import java.util.Map;
12 13
  14 +import javax.transaction.Transactional;
  15 +
  16 +import org.apache.commons.lang3.StringEscapeUtils;
  17 +import org.slf4j.Logger;
  18 +import org.slf4j.LoggerFactory;
13 import org.springframework.beans.factory.annotation.Autowired; 19 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.jdbc.core.JdbcTemplate; 20 import org.springframework.jdbc.core.JdbcTemplate;
15 import org.springframework.jdbc.core.RowMapper; 21 import org.springframework.jdbc.core.RowMapper;
16 import org.springframework.stereotype.Service; 22 import org.springframework.stereotype.Service;
17 23
  24 +import com.alibaba.fastjson.JSONArray;
  25 +import com.alibaba.fastjson.JSONObject;
18 import com.bsth.common.ResponseCode; 26 import com.bsth.common.ResponseCode;
19 import com.bsth.entity.oil.Cwjy; 27 import com.bsth.entity.oil.Cwjy;
  28 +import com.bsth.entity.oil.Cyl;
20 import com.bsth.entity.oil.Ylxxb; 29 import com.bsth.entity.oil.Ylxxb;
21 import com.bsth.repository.oil.CwjyRepository; 30 import com.bsth.repository.oil.CwjyRepository;
22 import com.bsth.repository.oil.YlxxbRepository; 31 import com.bsth.repository.oil.YlxxbRepository;
@@ -35,8 +44,8 @@ public class CwjyServiceImpl extends BaseServiceImpl&lt;Cwjy,Integer&gt; implements Cw @@ -35,8 +44,8 @@ public class CwjyServiceImpl extends BaseServiceImpl&lt;Cwjy,Integer&gt; implements Cw
35 44
36 @Autowired 45 @Autowired
37 JdbcTemplate jdbcTemplate; 46 JdbcTemplate jdbcTemplate;
38 -  
39 - @SuppressWarnings("unchecked") 47 + Logger logger = LoggerFactory.getLogger(this.getClass());
  48 + /*@SuppressWarnings("unchecked")
40 public PageObject<Ylxxb> Pagequery(Map<String, Object> map) { 49 public PageObject<Ylxxb> Pagequery(Map<String, Object> map) {
41 int page=Integer.parseInt(map.get("page").toString()); 50 int page=Integer.parseInt(map.get("page").toString());
42 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd"); 51 SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
@@ -129,7 +138,7 @@ public class CwjyServiceImpl extends BaseServiceImpl&lt;Cwjy,Integer&gt; implements Cw @@ -129,7 +138,7 @@ public class CwjyServiceImpl extends BaseServiceImpl&lt;Cwjy,Integer&gt; implements Cw
129 return t; 138 return t;
130 } 139 }
131 }); 140 });
132 - /*List<Object[]> list=repository.obtainCwjycl(rq,nbbm); 141 + List<Object[]> list=repository.obtainCwjycl(rq,nbbm);
133 for (int i = 0; i < list.size(); i++) { 142 for (int i = 0; i < list.size(); i++) {
134 Ylxxb y=new Ylxxb(); 143 Ylxxb y=new Ylxxb();
135 y.setGsdm(list.get(i)[0]==null?"":list.get(i)[0].toString()); 144 y.setGsdm(list.get(i)[0]==null?"":list.get(i)[0].toString());
@@ -148,13 +157,13 @@ public class CwjyServiceImpl extends BaseServiceImpl&lt;Cwjy,Integer&gt; implements Cw @@ -148,13 +157,13 @@ public class CwjyServiceImpl extends BaseServiceImpl&lt;Cwjy,Integer&gt; implements Cw
148 e.printStackTrace(); 157 e.printStackTrace();
149 } 158 }
150 yList.add(y); 159 yList.add(y);
151 - }*/ 160 + }
152 PageHelper pageHelper = new PageHelper(listsize, map); 161 PageHelper pageHelper = new PageHelper(listsize, map);
153 pageHelper.getMap(); 162 pageHelper.getMap();
154 PageObject<Ylxxb> pageObject=pageHelper.getPageObject(); 163 PageObject<Ylxxb> pageObject=pageHelper.getPageObject();
155 pageObject.setDataList(yList); 164 pageObject.setDataList(yList);
156 return pageObject; 165 return pageObject;
157 - } 166 + }*/
158 167
159 @Override 168 @Override
160 public Ylxxb bynbbm(Map<String, Object> map) { 169 public Ylxxb bynbbm(Map<String, Object> map) {
@@ -188,28 +197,112 @@ public class CwjyServiceImpl extends BaseServiceImpl&lt;Cwjy,Integer&gt; implements Cw @@ -188,28 +197,112 @@ public class CwjyServiceImpl extends BaseServiceImpl&lt;Cwjy,Integer&gt; implements Cw
188 return y; 197 return y;
189 } 198 }
190 199
  200 + @Transactional
191 @Override 201 @Override
192 - public Map<String, Object> savejzl(Ylxxb t) { 202 + public Map<String, Object> savejzl(Map<String, Object> maps) throws Exception {
193 // TODO Auto-generated method stub 203 // TODO Auto-generated method stub
194 Map<String, Object> map=new HashMap<String,Object>(); 204 Map<String, Object> map=new HashMap<String,Object>();
195 try { 205 try {
196 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); 206 SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
197 - String rq = sdf.format(t.getYyrq());  
198 - String nbbm=t.getNbbm();  
199 - List<Ylxxb> yList=ylxxbRepository.obtainYlxx2(rq,nbbm);  
200 - if(yList.size()>0){  
201 - t.setId(yList.get(0).getId());  
202 - ylxxbRepository.save(t);  
203 - }else{  
204 - ylxxbRepository.save(t); 207 +// String rq = sdf.format(t.getYyrq());
  208 +// String nbbm=t.getNbbm();
  209 +// List<Ylxxb> yList=ylxxbRepository.obtainYlxx2(rq,nbbm);
  210 +// if(yList.size()>0){
  211 +// t.setId(yList.get(0).getId());
  212 +// ylxxbRepository.save(t);
  213 +// }else{
  214 +// ylxxbRepository.save(t);
  215 +// }
  216 + String gsbm=maps.get("gsbm").toString();
  217 + String fgsbm=maps.get("fgsbm").toString();
  218 + String rq=maps.get("rq").toString();
  219 + Date date=sdf.parse(rq);
  220 + String json =StringEscapeUtils.unescapeHtml4(maps.get("ylbList").toString());
  221 + JSONArray jsonArray=JSONArray.parseArray(json);
  222 + JSONObject jsonObject;
  223 + // 获取车辆存油信息
  224 + for (int i = 0; i < jsonArray.size(); i++) {
  225 + jsonObject=jsonArray.getJSONObject(i);
  226 + Integer id =jsonObject.getInteger("id");
  227 + String jsy=jsonObject.getString("jsy");
  228 + double jzl=jsonObject.getDoubleValue("jzl");
  229 + String stationid=jsonObject.getString("stationid");
  230 + int nylx=jsonObject.getIntValue("nylx");
  231 + String jyggh=jsonObject.getString("jyggh");
  232 + String bz=jsonObject.getString("bz");
  233 + Ylxxb y;
  234 + if(id>0){
  235 + y=ylxxbRepository.findOne(id);
  236 + y.setJsy(jsy);
  237 + y.setJzl(jzl);
  238 + y.setStationid(stationid);
  239 + y.setJyggh(jyggh);
  240 + y.setBz(bz);
  241 + y.setCreatetime(date);
  242 + ylxxbRepository.save(y);
  243 + }else{
  244 + y=new Ylxxb();
  245 + y.setGsdm(gsbm);
  246 + y.setJsy(jsy);
  247 + y.setJzl(jzl);
  248 + y.setStationid(stationid);
  249 + y.setJyggh(jyggh);
  250 + y.setBz(bz);
  251 + y.setCreatetime(date);
  252 + y.setJylx(1);
  253 + ylxxbRepository.save(y);
  254 + }
205 } 255 }
206 map.put("status", ResponseCode.SUCCESS); 256 map.put("status", ResponseCode.SUCCESS);
  257 +
207 } catch (Exception e) { 258 } catch (Exception e) {
208 map.put("status", ResponseCode.ERROR); 259 map.put("status", ResponseCode.ERROR);
209 - e.printStackTrace(); 260 + logger.error("save erro.", e);
  261 + throw e;
210 // TODO: handle exception 262 // TODO: handle exception
211 } 263 }
212 return map; 264 return map;
213 } 265 }
214 266
  267 + @Override
  268 + public List<Ylxxb> Pagequery(Map<String, Object> map) {
  269 + // TODO Auto-generated method stub
  270 + String rq=map.get("rq").toString();
  271 + String nbbm=map.get("nbbh").toString();
  272 + String sql="SELECT a.gsdm as gsdm,a.fgsdm as fgsdm,a.nbbm as nbbm,"
  273 + + "b.jyggh as jyggh,b.jzl as jzl ,b.stationid as stationid,b.jsy as jsy,"
  274 + + "b.nylx as nylx,b.yj as yj,b.bz as bz,b.id as id ,c.jsy as ldgh FROM bsth_c_cwjy a "+
  275 + " left join ("
  276 + + " select * from bsth_c_ylxxb b "
  277 + + "where to_days(b.yyrq)=to_days('"+rq+"') and jylx=1) b " +
  278 + " on a.nbbm=b.nbbm "
  279 + + "left join (select nbbm,group_concat(jsy) as jsy "
  280 + + "from bsth_c_ylb where to_days(rq)= to_days('"+rq+"' ) group by nbbm "+
  281 + " ) c on a.nbbm=c.nbbm "
  282 + + "where a.nbbm like '%"+nbbm+"%'";
  283 +
  284 + List<Ylxxb> yList= jdbcTemplate.query(sql,
  285 + new RowMapper<Ylxxb>(){
  286 + @Override
  287 + public Ylxxb mapRow(ResultSet rs, int rowNum) throws SQLException {
  288 + Ylxxb t=new Ylxxb();
  289 + t.setId(rs.getInt("id"));
  290 + t.setGsdm(rs.getString("gsdm"));
  291 + t.setFgsdm(rs.getString("fgsdm"));
  292 + t.setNbbm(rs.getString("nbbm"));
  293 + t.setJyggh(rs.getString("jyggh"));
  294 + t.setJsy(rs.getString("jsy"));
  295 + t.setJzl(rs.getDouble("jzl"));
  296 + t.setStationid(rs.getString("stationid"));
  297 + t.setNylx(rs.getInt("nylx"));
  298 + t.setYj(rs.getDouble("yj"));
  299 + t.setBz(rs.getString("bz"));
  300 + t.setJsy(rs.getString("ldgh"));
  301 + return t;
  302 + }
  303 + });
  304 +
  305 + return yList;
  306 + }
  307 +
215 } 308 }
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
@@ -30,6 +30,7 @@ import com.alibaba.fastjson.JSONObject; @@ -30,6 +30,7 @@ import com.alibaba.fastjson.JSONObject;
30 import com.bsth.common.ResponseCode; 30 import com.bsth.common.ResponseCode;
31 import com.bsth.data.BasicData; 31 import com.bsth.data.BasicData;
32 import com.bsth.entity.Cars; 32 import com.bsth.entity.Cars;
  33 +import com.bsth.entity.Line;
33 import com.bsth.entity.oil.Cyl; 34 import com.bsth.entity.oil.Cyl;
34 import com.bsth.entity.oil.Ylb; 35 import com.bsth.entity.oil.Ylb;
35 import com.bsth.entity.oil.Ylxxb; 36 import com.bsth.entity.oil.Ylxxb;
@@ -134,11 +135,9 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -134,11 +135,9 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
134 Ylb ylb=ylListBe.get(i); 135 Ylb ylb=ylListBe.get(i);
135 if(map.get("clZbh").toString().equals(ylb.getNbbm())){ 136 if(map.get("clZbh").toString().equals(ylb.getNbbm())){
136 if(ylb.getJzyl()!=null){ 137 if(ylb.getJzyl()!=null){
137 - if(ylb.getJzyl()>0){  
138 - t.setCzyl(ylb.getJzyl());  
139 - fage=false;  
140 - break;  
141 - } 138 + t.setCzyl(ylb.getJzyl());
  139 + fage=false;
  140 + break;
142 } 141 }
143 142
144 } 143 }
@@ -178,6 +177,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -178,6 +177,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
178 t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString()); 177 t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString());
179 t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString()); 178 t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
180 t.setRq(sdf.parse(rq)); 179 t.setRq(sdf.parse(rq));
  180 + t.setCreatetime(dNow);
181 repository.save(t); 181 repository.save(t);
182 182
183 } 183 }
@@ -202,6 +202,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -202,6 +202,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
202 public Map<String, Object> obtain(Map<String, Object> map2) throws Exception{ 202 public Map<String, Object> obtain(Map<String, Object> map2) throws Exception{
203 Map<String, Object> newMap = new HashMap<String, Object>(); 203 Map<String, Object> newMap = new HashMap<String, Object>();
204 try { 204 try {
  205 + Date date=new Date();
205 List<Cars> carsList = carsRepository.findCars(); 206 List<Cars> carsList = carsRepository.findCars();
206 Map<String, Boolean> carsMap = new HashMap<String, Boolean>(); 207 Map<String, Boolean> carsMap = new HashMap<String, Boolean>();
207 for (int i = 0; i < carsList.size(); i++) { 208 for (int i = 0; i < carsList.size(); i++) {
@@ -269,7 +270,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -269,7 +270,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
269 for (int i = 0; i < ylListBe.size(); i++) { 270 for (int i = 0; i < ylListBe.size(); i++) {
270 Ylb ylb = ylListBe.get(i); 271 Ylb ylb = ylListBe.get(i);
271 if (map.get("clZbh").toString().equals(ylb.getNbbm())) { 272 if (map.get("clZbh").toString().equals(ylb.getNbbm())) {
272 - if(ylb.getJzyl()>0){ 273 + if(ylb.getJzyl()>=0){
273 t.setCzyl(ylb.getJzyl()); 274 t.setCzyl(ylb.getJzyl());
274 fage = false; 275 fage = false;
275 break; 276 break;
@@ -281,7 +282,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -281,7 +282,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
281 for (int y = 0; y < clyList.size(); y++) { 282 for (int y = 0; y < clyList.size(); y++) {
282 Cyl cyl = clyList.get(y); 283 Cyl cyl = clyList.get(y);
283 if (map.get("clZbh").toString().equals(cyl.getNbbm())) { 284 if (map.get("clZbh").toString().equals(cyl.getNbbm())) {
284 - if(cyl.getCyl()>0){ 285 + if(cyl.getCyl()>=0){
285 t.setCzyl(cyl.getCyl()); 286 t.setCzyl(cyl.getCyl());
286 fage = false; 287 fage = false;
287 break; 288 break;
@@ -312,12 +313,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -312,12 +313,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
312 jzl =Arith.add(jzl, ylxxb.getJzl()); 313 jzl =Arith.add(jzl, ylxxb.getJzl());
313 } 314 }
314 } 315 }
315 - if(map.get("clZbh").toString().equals("W0A-212")){  
316 - System.out.println();  
317 - }  
318 - if(map.get("clZbh").toString().equals("W0A-211")){  
319 - System.out.println();  
320 - } 316 +
321 t.setJzl(jzl); 317 t.setJzl(jzl);
322 t.setNbbm(map.get("clZbh").toString()); 318 t.setNbbm(map.get("clZbh").toString());
323 t.setJsy(map.get("jGh") == null ? "" : map.get("jGh").toString()); 319 t.setJsy(map.get("jGh") == null ? "" : map.get("jGh").toString());
@@ -329,6 +325,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -329,6 +325,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
329 t.setFgsdm(map.get("bCompany") == null ? "" : map.get("bCompany").toString()); 325 t.setFgsdm(map.get("bCompany") == null ? "" : map.get("bCompany").toString());
330 t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString()); 326 t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
331 t.setRq(sdf.parse(rq)); 327 t.setRq(sdf.parse(rq));
  328 + t.setCreatetime(date);
332 if(type.equals("add")){ 329 if(type.equals("add")){
333 addList.add(t); 330 addList.add(t);
334 }else{ 331 }else{
@@ -385,8 +382,6 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -385,8 +382,6 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
385 nbbm=map.get("nbbm_eq").toString(); 382 nbbm=map.get("nbbm_eq").toString();
386 } 383 }
387 384
388 - List<Cyl> cylListAdd=new ArrayList<Cyl>();  
389 - Map<String, Object> cylMapAdd=new HashMap<String,Object>();  
390 Map<String, Object> newMap=new HashMap<String,Object>(); 385 Map<String, Object> newMap=new HashMap<String,Object>();
391 Map<String, Object> map2=new HashMap<String,Object>(); 386 Map<String, Object> map2=new HashMap<String,Object>();
392 try { 387 try {
@@ -456,7 +451,10 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -456,7 +451,10 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
456 nextJzyl=ylxs; 451 nextJzyl=ylxs;
457 } else { 452 } else {
458 t.setCzyl(nextJzyl); 453 t.setCzyl(nextJzyl);
459 - Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); 454 + Double yh=0.0;
  455 + if(zlc>0){
  456 + yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
  457 + }
460 nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh); 458 nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh);
461 long l=Math.round(nextJzyl); 459 long l=Math.round(nextJzyl);
462 double ylxs=l*100/100; 460 double ylxs=l*100/100;
@@ -466,16 +464,21 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -466,16 +464,21 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
466 t.setJzyl(ylxs); 464 t.setJzyl(ylxs);
467 nextJzyl= ylxs; 465 nextJzyl= ylxs;
468 } 466 }
469 -  
470 repository.save(t); 467 repository.save(t);
  468 + for (int z = 0; z < cylList.size(); z++) {
  469 + Cyl cyl = cylList.get(z);
  470 + if (t.getNbbm().equals(cyl.getNbbm())) {
  471 + cyl.setCyl(t.getJzyl());
  472 + cyl.setUpdatetime(t.getRq());
  473 + break;
  474 + }
  475 + cylRepository.save(cyl);
  476 + }
471 } 477 }
472 map2.put("status", ResponseCode.SUCCESS); 478 map2.put("status", ResponseCode.SUCCESS);
473 } 479 }
474 } 480 }
475 } 481 }
476 - for (int i = 0; i < cylListAdd.size(); i++) {  
477 - cylRepository.save(cylListAdd.get(i));  
478 - }  
479 } catch (Exception e) { 482 } catch (Exception e) {
480 map2.put("status", ResponseCode.ERROR); 483 map2.put("status", ResponseCode.ERROR);
481 logger.error("save erro.", e); 484 logger.error("save erro.", e);
@@ -647,9 +650,17 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -647,9 +650,17 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
647 // xlbm=map.get("xlbm_like").toString(); 650 // xlbm=map.get("xlbm_like").toString();
648 // } 651 // }
649 // TODO Auto-generated method stub 652 // TODO Auto-generated method stub
  653 +
  654 + List<Cars> carsList = carsRepository.findCars();
  655 + Map<String, String> carsMap = new HashMap<String, String>();
  656 + for (int i = 0; i < carsList.size(); i++) {
  657 + Cars c = carsList.get(i);
  658 + carsMap.put(c.getInsideCode(), c.getBrancheCompanyCode()==null?"":c.getBrancheCompanyCode());
  659 + }
  660 +
650 try{ 661 try{
651 //获取车辆存油信息 662 //获取车辆存油信息
652 - List<Cyl> cylList=cylRepository.findAll(new CustomerSpecs<Cyl>(newMap)); 663 +
653 String rq=map.get("rq").toString(); 664 String rq=map.get("rq").toString();
654 String xlbm=""; 665 String xlbm="";
655 if(map.get("xlbm_like")!=null){ 666 if(map.get("xlbm_like")!=null){
@@ -667,6 +678,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -667,6 +678,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
667 if(map.get("nbbm_eq")!=null){ 678 if(map.get("nbbm_eq")!=null){
668 nbbm=map.get("nbbm_eq").toString(); 679 nbbm=map.get("nbbm_eq").toString();
669 } 680 }
  681 + List<Ylb> ylListBe=repository.obtainYlbefore(rq, gsbm, "", xlbm, nbbm);
  682 + List<Cyl> cylList=cylRepository.obtainCyl(nbbm, gsbm);
670 List<Ylb> ylbList=repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm"); 683 List<Ylb> ylbList=repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm");
671 List<Ylxxb> ylxxbList=ylxxbRepository.obtainYlxx(rq,0,gsbm); 684 List<Ylxxb> ylxxbList=ylxxbRepository.obtainYlxx(rq,0,gsbm);
672 for (int i = 0; i < ylxxbList.size(); i++) { 685 for (int i = 0; i < ylxxbList.size(); i++) {
@@ -681,14 +694,56 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -681,14 +694,56 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
681 } 694 }
682 695
683 if(fage){ 696 if(fage){
  697 + Cyl cyl=null;
684 Ylb t=new Ylb(); 698 Ylb t=new Ylb();
685 t.setNbbm(y1.getNbbm()); 699 t.setNbbm(y1.getNbbm());
686 t.setRq(y1.getYyrq()); 700 t.setRq(y1.getYyrq());
687 t.setJsy(y1.getJsy()); 701 t.setJsy(y1.getJsy());
688 t.setJzl(y1.getJzl()); 702 t.setJzl(y1.getJzl());
689 t.setSsgsdm(y1.getGsdm()); 703 t.setSsgsdm(y1.getGsdm());
690 - t.setXlbm(xlbm);  
691 - repository.save(t); 704 + String fgsdm=carsMap.get(y1.getNbbm());
  705 + t.setFgsdm(fgsdm);
  706 + t.setJcsx(1);
  707 + Line line= BasicData.nbbm2LineMap.get(y1.getNbbm());
  708 + if(null !=line){
  709 + t.setXlbm(line.getLineCode());
  710 + }else{
  711 + t.setXlbm("");
  712 + }
  713 + t.setJcsx(1);
  714 + boolean status=true;
  715 + for (int j = 0; j < ylListBe.size(); j++) {
  716 + Ylb b=ylListBe.get(j);
  717 + if(b.getNbbm().equals(y1.getNbbm())){
  718 + t.setCzyl(b.getJzyl());
  719 + status=false;
  720 + break;
  721 + }
  722 + }
  723 + if(status){
  724 + for (int j = 0; j < cylList.size(); j++) {
  725 + Cyl c=cylList.get(j);
  726 + if(c.getNbbm().equals(y1.getNbbm())){
  727 + t.setCzyl(c.getCyl());
  728 + cyl=c;
  729 + status=false;
  730 + break;
  731 + }
  732 + }
  733 + }
  734 + if(status){
  735 + t.setCzyl(0.0);
  736 + }
  737 +// double jzyl=Arith.add(t.getJzl(), t.getCzyl());
  738 + t.setJzyl(Arith.add(t.getJzl(), t.getCzyl()));
  739 + t.setYh(0.0);
  740 + if(fgsdm.equals("fgsbm")){
  741 + repository.save(t);
  742 + if(null!=cyl){
  743 + cyl.setCyl(Arith.add(t.getJzl(), t.getCzyl()));
  744 + cylRepository.save(cyl);
  745 + }
  746 + }
692 } 747 }
693 } 748 }
694 newMap.put("status", ResponseCode.SUCCESS); 749 newMap.put("status", ResponseCode.SUCCESS);
@@ -862,23 +917,52 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -862,23 +917,52 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
862 listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList); 917 listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);
863 } 918 }
864 }else{ 919 }else{
865 - List<Object[]> objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm);  
866 - for (int i = 0; i < objectLists.size(); i++) {  
867 - String clbm=objectLists.get(i)[0].toString();  
868 - int cs=Integer.parseInt(objectLists.get(i)[1].toString());  
869 - //一车一单  
870 - if(sxtj.equals("1")){  
871 - if(cs==1){ 920 + List<Object[]> objectLists;
  921 + if(sxtj.equals("3")){
  922 + //有加油没里程
  923 + objectLists=repository.checkNbmmYl(rq, gsbm, fgsbm, xlbm, nbbm);
  924 + for (int i = 0; i < objectLists.size(); i++) {
  925 + String clbm=objectLists.get(i)[0].toString();
  926 + double jzl=Double.parseDouble(objectLists.get(i)[1].toString());
  927 + double zlc=Double.parseDouble(objectLists.get(i)[2].toString());
  928 + if(jzl>0 && zlc<=0){
872 stringList.add(clbm); 929 stringList.add(clbm);
873 } 930 }
  931 +
874 } 932 }
875 - //一车多单  
876 - if(sxtj.equals("2")){  
877 - if(cs>1){ 933 +
  934 + }else if(sxtj.equals("4")){
  935 + //有里程没加油
  936 + objectLists=repository.checkNbmmYl(rq, gsbm, fgsbm, xlbm, nbbm);
  937 + for (int i = 0; i < objectLists.size(); i++) {
  938 + String clbm=objectLists.get(i)[0].toString();
  939 + double jzl=Double.parseDouble(objectLists.get(i)[1].toString());
  940 + double zlc=Double.parseDouble(objectLists.get(i)[2].toString());
  941 + if(zlc>0 && jzl<=0){
878 stringList.add(clbm); 942 stringList.add(clbm);
879 } 943 }
  944 +
  945 + }
  946 + }else{
  947 + objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm);
  948 + for (int i = 0; i < objectLists.size(); i++) {
  949 + String clbm=objectLists.get(i)[0].toString();
  950 + int cs=Integer.parseInt(objectLists.get(i)[1].toString());
  951 + //一车一单
  952 + if(sxtj.equals("1")){
  953 + if(cs==1){
  954 + stringList.add(clbm);
  955 + }
  956 + }
  957 + //一车多单
  958 + if(sxtj.equals("2")){
  959 + if(cs>1){
  960 + stringList.add(clbm);
  961 + }
  962 + }
880 } 963 }
881 } 964 }
  965 +
882 if(stringList.size()>0){ 966 if(stringList.size()>0){
883 listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList); 967 listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);
884 } 968 }
@@ -894,10 +978,12 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -894,10 +978,12 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
894 // TODO Auto-generated method stub 978 // TODO Auto-generated method stub
895 Map<String, Object> newMap=new HashMap<String,Object>(); 979 Map<String, Object> newMap=new HashMap<String,Object>();
896 try{ 980 try{
  981 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
897 String json =StringEscapeUtils.unescapeHtml4(map.get("ylbList").toString()); 982 String json =StringEscapeUtils.unescapeHtml4(map.get("ylbList").toString());
898 JSONArray jsonArray=JSONArray.parseArray(json); 983 JSONArray jsonArray=JSONArray.parseArray(json);
899 JSONObject jsonObject; 984 JSONObject jsonObject;
900 - 985 + // 获取车辆存油信息
  986 + List<Cyl> cylList = cylRepository.obtainCyl("","");
901 for (int i = 0; i < jsonArray.size(); i++) { 987 for (int i = 0; i < jsonArray.size(); i++) {
902 // Ylb t=new Ylb(); 988 // Ylb t=new Ylb();
903 jsonObject=jsonArray.getJSONObject(i); 989 jsonObject=jsonArray.getJSONObject(i);
@@ -910,6 +996,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -910,6 +996,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
910 String rylx =jsonObject.getString("rylx"); 996 String rylx =jsonObject.getString("rylx");
911 int yhlx =jsonObject.getIntValue("yhlx"); 997 int yhlx =jsonObject.getIntValue("yhlx");
912 Integer id =jsonObject.getInteger("id"); 998 Integer id =jsonObject.getInteger("id");
  999 + String nbbm =jsonObject.getString("nbbm");
  1000 + String rq=jsonObject.getString("rq");
913 double yh = Arith.sub(Arith.add(czyl, jzl), jzyl); 1001 double yh = Arith.sub(Arith.add(czyl, jzl), jzyl);
914 /*t.setJzyl(jzyl); 1002 /*t.setJzyl(jzyl);
915 t.setSh(sh); 1003 t.setSh(sh);
@@ -918,6 +1006,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -918,6 +1006,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
918 t.setRylx(rylx); 1006 t.setRylx(rylx);
919 t.setId(jsonObject.getInteger("id"));*/ 1007 t.setId(jsonObject.getInteger("id"));*/
920 repository.ylbUpdate(id, czyl, jzyl, yh, sh, shyy, ns, rylx,yhlx); 1008 repository.ylbUpdate(id, czyl, jzyl, yh, sh, shyy, ns, rylx,yhlx);
  1009 + for (int z = 0; z < cylList.size(); z++) {
  1010 + Cyl cyl = cylList.get(z);
  1011 + if (nbbm.equals(cyl.getNbbm())) {
  1012 + cyl.setCyl(jzyl);
  1013 + cyl.setUpdatetime(sdf.parse(rq));
  1014 + break;
  1015 + }
  1016 + cylRepository.save(cyl);
  1017 + }
921 } 1018 }
922 // List<Map<String, Object>> list=(List<Map<String, Object>>) map.get("ylbList"); 1019 // List<Map<String, Object>> list=(List<Map<String, Object>>) map.get("ylbList");
923 1020
@@ -986,8 +1083,6 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -986,8 +1083,6 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
986 Double zyl = 0.0; 1083 Double zyl = 0.0;
987 Double nextJzyl = 0.0; 1084 Double nextJzyl = 0.0;
988 // 车的,进,出油量及耗油 1085 // 车的,进,出油量及耗油
989 - Map<String, Object> cylMapAdd=new HashMap<String,Object>();  
990 - List<Cyl> cylListAdd=new ArrayList<Cyl>();  
991 for (int i = 0; i < iterator2.size(); i++) { 1086 for (int i = 0; i < iterator2.size(); i++) {
992 Ylb t = iterator2.get(i); 1087 Ylb t = iterator2.get(i);
993 if (t.getJcsx() == 1) { 1088 if (t.getJcsx() == 1) {
@@ -1029,9 +1124,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1029,9 +1124,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1029 nextJzyl=ylxs; 1124 nextJzyl=ylxs;
1030 } 1125 }
1031 repository.save(t); 1126 repository.save(t);
1032 - }  
1033 - for (int i = 0; i < cylListAdd.size(); i++) {  
1034 - cylRepository.save(cylListAdd.get(i)); 1127 + for (int z = 0; z < cylList.size(); z++) {
  1128 + Cyl cyl = cylList.get(z);
  1129 + if (t.getNbbm().equals(cyl.getNbbm())) {
  1130 + cyl.setCyl(t.getJzyl());
  1131 + cyl.setUpdatetime(t.getRq());
  1132 + break;
  1133 + }
  1134 + cylRepository.save(cyl);
  1135 + }
1035 } 1136 }
1036 newMap.put("status", ResponseCode.SUCCESS); 1137 newMap.put("status", ResponseCode.SUCCESS);
1037 } 1138 }
@@ -1050,19 +1151,71 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1050,19 +1151,71 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1050 String rq=map.get("date").toString(); 1151 String rq=map.get("date").toString();
1051 String nbbm=map.get("nbbm").toString(); 1152 String nbbm=map.get("nbbm").toString();
1052 String jsy =map.get("jsy").toString(); 1153 String jsy =map.get("jsy").toString();
1053 - List<Ylb> list= repository.queryListYlb(rq, nbbm, jsy);  
1054 - String type=""; 1154 + String xlbm=map.get("xlbm").toString();
  1155 + List<Ylb> list= repository.checkYlb(rq, nbbm, jsy,xlbm,"nbbm");
  1156 + String type="1";
1055 if(list.size()>0){ 1157 if(list.size()>0){
1056 - type="cunzai"; 1158 + type="0";
1057 } 1159 }
1058 return type; 1160 return type;
1059 } 1161 }
1060 1162
1061 @Override 1163 @Override
1062 public Map<String, Object> saveYlb(Ylb t) { 1164 public Map<String, Object> saveYlb(Ylb t) {
  1165 + Map<String, Object> map = new HashMap<>();
  1166 + SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
  1167 + String rq=sdf.format(t.getRq());
  1168 + String gsdm=t.getSsgsdm();
  1169 + String fgsdm=t.getFgsdm();
  1170 + String xlbm=t.getXlbm();
  1171 + String jhsj=t.getJhsj();
  1172 + String jsy=t.getJsy();
  1173 + String nbbm=t.getNbbm();
  1174 + t.setCreatetime(new Date());
  1175 + String[] jhsjStr = jhsj.split(":");
  1176 + long fcsjL= Long.parseLong(jhsjStr[0])*60+Long.parseLong(jhsjStr[1]);
  1177 + List<Ylb> list=repository.obtainYl(rq, gsdm, fgsdm, xlbm, nbbm, "jhsj");
  1178 + int jcsx=1;
  1179 + if(list.size()>0){
  1180 + for (int i = 0; i < list.size(); i++) {
  1181 + Ylb y=list.get(i);
  1182 + String[] fcsjStr = y.getJhsj().split(":");
  1183 + long fcsj=Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  1184 + if(fcsjL>fcsj){
  1185 + jcsx=jcsx+y.getJcsx();
  1186 + }else{
  1187 + y.setJcsx(y.getJcsx()+1);
  1188 + repository.save(y);
  1189 + }
  1190 + }
1063 1191
1064 - String gsbm="";  
1065 - String fgsbm="";  
1066 - return null; 1192 + }
  1193 + t.setJcsx(jcsx);
  1194 + repository.save(t);
  1195 + map.put("status", ResponseCode.SUCCESS);
  1196 + map.put("t", t);
  1197 + return map;
  1198 + }
  1199 + @Transactional
  1200 + @Override
  1201 + public Map<String, Object> deleteIds(Map<String, Object> map) throws Exception{
  1202 + // TODO Auto-generated method stub
  1203 + Map<String, Object> maps = new HashMap<>();
  1204 + try{
  1205 + String json =StringEscapeUtils.unescapeHtml4(map.get("ids").toString());
  1206 + JSONArray jsonArray=JSONArray.parseArray(json);
  1207 + JSONObject jsonObject;
  1208 + for (int x = 0; x < jsonArray.size(); x++) {
  1209 + jsonObject=jsonArray.getJSONObject(x);
  1210 + Integer id =jsonObject.getInteger("id");
  1211 + repository.delete(id);
  1212 + }
  1213 + maps.put("status", ResponseCode.SUCCESS);
  1214 + } catch (Exception e) {
  1215 + maps.put("status", ResponseCode.ERROR);
  1216 + logger.error("save erro.", e);
  1217 + throw e;
  1218 + }
  1219 + return maps;
1067 } 1220 }
1068 } 1221 }
1069 \ No newline at end of file 1222 \ No newline at end of file
src/main/java/com/bsth/service/oil/impl/YlxxbServiceImpl.java
@@ -9,6 +9,9 @@ import java.util.HashMap; @@ -9,6 +9,9 @@ import java.util.HashMap;
9 import java.util.List; 9 import java.util.List;
10 import java.util.Map; 10 import java.util.Map;
11 11
  12 +import javax.transaction.Transactional;
  13 +
  14 +import org.apache.commons.lang3.StringEscapeUtils;
12 import org.slf4j.Logger; 15 import org.slf4j.Logger;
13 import org.slf4j.LoggerFactory; 16 import org.slf4j.LoggerFactory;
14 import org.springframework.beans.factory.annotation.Autowired; 17 import org.springframework.beans.factory.annotation.Autowired;
@@ -16,6 +19,8 @@ import org.springframework.jdbc.core.JdbcTemplate; @@ -16,6 +19,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
16 import org.springframework.jdbc.core.RowMapper; 19 import org.springframework.jdbc.core.RowMapper;
17 import org.springframework.stereotype.Service; 20 import org.springframework.stereotype.Service;
18 21
  22 +import com.alibaba.fastjson.JSONArray;
  23 +import com.alibaba.fastjson.JSONObject;
19 import com.bsth.common.ResponseCode; 24 import com.bsth.common.ResponseCode;
20 import com.bsth.entity.excep.Offline; 25 import com.bsth.entity.excep.Offline;
21 import com.bsth.entity.oil.Ylb; 26 import com.bsth.entity.oil.Ylb;
@@ -44,12 +49,27 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements @@ -44,12 +49,27 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements
44 String rq=map.get("yyrq").toString(); 49 String rq=map.get("yyrq").toString();
45 String gsdm=map.get("gsdm_like").toString(); 50 String gsdm=map.get("gsdm_like").toString();
46 String fgsdm=map.get("fgsdm_like").toString(); 51 String fgsdm=map.get("fgsdm_like").toString();
47 - 52 + /*
48 String sql=" select x.*,y.jsy as ldgh,y.fgsdm as fgsdm from bsth_c_ylxxb x " 53 String sql=" select x.*,y.jsy as ldgh,y.fgsdm as fgsdm from bsth_c_ylxxb x "
49 + " left join bsth_c_ylb y on x.nbbm = y.nbbm and x.jsy !=y.jsy " 54 + " left join bsth_c_ylb y on x.nbbm = y.nbbm and x.jsy !=y.jsy "
50 + " where DATE_FORMAT(y.rq,'%Y-%m-%d')='"+rq+"' and y.ssgsdm='"+gsdm+"' " 55 + " where DATE_FORMAT(y.rq,'%Y-%m-%d')='"+rq+"' and y.ssgsdm='"+gsdm+"' "
51 + " and y.fgsdm='"+fgsdm+"' and DATE_FORMAT(x.yyrq,'%Y-%m-%d')='"+rq+"' " 56 + " and y.fgsdm='"+fgsdm+"' and DATE_FORMAT(x.yyrq,'%Y-%m-%d')='"+rq+"' "
52 - + " and x.gsdm='"+gsdm+"'"; 57 + + " and x.gsdm='"+gsdm+"'";*/
  58 +
  59 + String sql= "select v.*,u.jsy as ldgh from "
  60 + + " ( select * from bsth_c_ylxxb x where "
  61 + + " DATE_FORMAT(x.yyrq,'%Y-%m-%d')='"+rq+"' and x.gsdm='"+gsdm+"'"
  62 + + " and x.jsy not in ("
  63 + + " select jsy from bsth_c_ylb "
  64 + + " where DATE_FORMAT(rq,'%Y-%m-%d')='"+rq+"' "
  65 + + " and ssgsdm='"+gsdm+"' and fgsdm='"+fgsdm+"')"
  66 + + " and x.nbbm in (select nbbm from bsth_c_ylb "
  67 + + " where DATE_FORMAT(rq,'%Y-%m-%d')='"+rq+"' "
  68 + + " and ssgsdm='"+gsdm+"' and fgsdm='"+fgsdm+"' )) v "
  69 + + " left join (select * from bsth_c_ylb "
  70 + + " where DATE_FORMAT(rq,'%Y-%m-%d')='"+rq+"'"
  71 + + " and ssgsdm='"+gsdm+"' and fgsdm='"+fgsdm+"' ) u "
  72 + + " on v.nbbm=u.nbbm ";
53 73
54 //根具条件查询指定日期Ylxxb的数据 74 //根具条件查询指定日期Ylxxb的数据
55 // List<Ylxxb> iterator=repository.checkYlxx(rq,gsdm); 75 // List<Ylxxb> iterator=repository.checkYlxx(rq,gsdm);
@@ -114,21 +134,33 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements @@ -114,21 +134,33 @@ public class YlxxbServiceImpl extends BaseServiceImpl&lt;Ylxxb,Integer&gt; implements
114 pageObject.setDataList(list); 134 pageObject.setDataList(list);
115 return pageObject; 135 return pageObject;
116 } 136 }
117 - 137 + @Transactional
118 @Override 138 @Override
119 - public Map<String, Object> checkJsy(Map<String, Object> map) { 139 + public Map<String, Object> checkJsy(Map<String, Object> map) throws Exception{
120 Map<String, Object> newMap=new HashMap<String,Object>(); 140 Map<String, Object> newMap=new HashMap<String,Object>();
121 // TODO Auto-generated method stub 141 // TODO Auto-generated method stub
122 try { 142 try {
123 - int id=Integer.parseInt(map.get("id").toString());  
124 - String jsy=map.get("jsy").toString();  
125 - Ylxxb ylxxb=repository.findOne(id);  
126 - ylxxb.setJsy(jsy);  
127 - repository.save(ylxxb); 143 +// int id=Integer.parseInt(map.get("id").toString());
  144 +// String jsy=map.get("jsy").toString();
  145 +// Ylxxb ylxxb=repository.findOne(id);
  146 +// ylxxb.setJsy(jsy);
  147 +// repository.save(ylxxb);
  148 + String json =StringEscapeUtils.unescapeHtml4(map.get("ylbList").toString());
  149 + JSONArray jsonArray=JSONArray.parseArray(json);
  150 + JSONObject jsonObject;
  151 + for (int x = 0; x < jsonArray.size(); x++) {
  152 + jsonObject=jsonArray.getJSONObject(x);
  153 + Integer id =jsonObject.getInteger("id");
  154 + String jsy =jsonObject.getString("jsy");
  155 + Ylxxb ylxxb=repository.findOne(id);
  156 + ylxxb.setJsy(jsy);
  157 + repository.save(ylxxb);
  158 + }
128 newMap.put("status", ResponseCode.SUCCESS); 159 newMap.put("status", ResponseCode.SUCCESS);
129 }catch(Exception e){ 160 }catch(Exception e){
130 newMap.put("status", ResponseCode.ERROR); 161 newMap.put("status", ResponseCode.ERROR);
131 logger.error("save erro.", e); 162 logger.error("save erro.", e);
  163 + throw e;
132 } 164 }
133 return newMap; 165 return newMap;
134 } 166 }
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
@@ -92,7 +92,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L @@ -92,7 +92,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
92 92
93 Map<String,Object> findKMBC1(String jName,String clZbh, String date,String enddate); 93 Map<String,Object> findKMBC1(String jName,String clZbh, String date,String enddate);
94 94
95 - Map<String,Object> findKMBC(String jName,String clZbh,String lpName,String date,String line); 95 + Map<String,Object> findKMBC(String jGh,String clZbh,String lpName,String date,String line);
96 96
97 Map<String,Object> findKMBCQp(String clZbh,String date,String line); 97 Map<String,Object> findKMBCQp(String clZbh,String date,String line);
98 98
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -40,6 +40,8 @@ import com.bsth.security.util.SecurityUtils; @@ -40,6 +40,8 @@ import com.bsth.security.util.SecurityUtils;
40 import com.bsth.service.SectionRouteService; 40 import com.bsth.service.SectionRouteService;
41 import com.bsth.service.impl.BaseServiceImpl; 41 import com.bsth.service.impl.BaseServiceImpl;
42 import com.bsth.service.realcontrol.ScheduleRealInfoService; 42 import com.bsth.service.realcontrol.ScheduleRealInfoService;
  43 +import com.bsth.service.report.CulateMileageService;
  44 +import com.bsth.service.report.ReportService;
43 import com.bsth.service.schedule.SchedulePlanInfoService; 45 import com.bsth.service.schedule.SchedulePlanInfoService;
44 import com.bsth.service.sys.DutyEmployeeService; 46 import com.bsth.service.sys.DutyEmployeeService;
45 import com.bsth.util.*; 47 import com.bsth.util.*;
@@ -87,6 +89,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -87,6 +89,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
87 89
88 @Autowired 90 @Autowired
89 SectionRouteService sectionRouteService; 91 SectionRouteService sectionRouteService;
  92 +
  93 + @Autowired
  94 + CulateMileageService culateMieageService;
90 95
91 /*@Autowired 96 /*@Autowired
92 BorrowCenter borrowCenter;*/ 97 BorrowCenter borrowCenter;*/
@@ -120,6 +125,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -120,6 +125,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
120 125
121 @Autowired 126 @Autowired
122 YlbRepository ylbRepository; 127 YlbRepository ylbRepository;
  128 +
  129 + @Autowired
  130 + ReportService reposrService;
  131 +
  132 + @Autowired
  133 + CulateMileageService culateService;
123 134
124 Logger logger = LoggerFactory.getLogger(this.getClass()); 135 Logger logger = LoggerFactory.getLogger(this.getClass());
125 136
@@ -1298,7 +1309,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1298,7 +1309,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1298 } 1309 }
1299 1310
1300 1311
1301 - @Override 1312 + /* @Override
1302 public Map<String, Object> findKMBC(String jName, String clZbh, 1313 public Map<String, Object> findKMBC(String jName, String clZbh,
1303 String lpName, String date, String line) { 1314 String lpName, String date, String line) {
1304 List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date, line); 1315 List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date, line);
@@ -1398,6 +1409,31 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1398,6 +1409,31 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1398 map.put("zkslc", format.format(ksgl + jcclc)); 1409 map.put("zkslc", format.format(ksgl + jcclc));
1399 // map.put("zkslc", format.format(ksgl + jcclc+addMileageJc)); 1410 // map.put("zkslc", format.format(ksgl + jcclc+addMileageJc));
1400 return map; 1411 return map;
  1412 + }*/
  1413 +
  1414 + public Map<String, Object> findKMBC(String jGh, String clZbh,
  1415 + String lpName, String date, String line) {
  1416 + Map<String, Object> map = new HashMap<String, Object>();
  1417 + List<ScheduleRealInfo> lists=scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);
  1418 + double ksgl=culateService.culateKsgl(lists);
  1419 + double sjgl=culateService.culateSjgl(lists);
  1420 + double jccgl=culateService.culateJccgl(lists);
  1421 + double ljgl=culateService.culateLjgl(lists);
  1422 + map.put("jhlc", culateService.culateJhgl(lists)); //计划里程
  1423 + map.put("remMileage", culateService.culateLbgl(lists)); //烂班公里
  1424 + map.put("addMileage", ljgl); //临加公里
  1425 + map.put("yygl",Arith.add(sjgl,ljgl)); //实际公里
  1426 + map.put("ksgl", ksgl);//空驶公里
  1427 + map.put("realMileage",Arith.add(Arith.add(ksgl,jccgl ),Arith.add(sjgl,ljgl)));
  1428 +// map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage));
  1429 + map.put("jhbc", culateService.culateJhbc(lists,""));
  1430 + map.put("cjbc", culateService.culateLbbc(lists));
  1431 + map.put("ljbc", culateService.culateLjbc(lists,""));
  1432 + map.put("sjbc", culateService.culateJhbc(lists,"") - culateService.culateLbbc(lists) + culateService.culateLjbc(lists,""));
  1433 + map.put("jcclc", jccgl);
  1434 + map.put("zkslc", Arith.add(ksgl,jccgl));
  1435 +// map.put("zkslc", format.format(ksgl + jcclc+addMileageJc));
  1436 + return map;
1401 } 1437 }
1402 1438
1403 1439
@@ -1543,10 +1579,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1543,10 +1579,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1543 listSchedule.add(s); 1579 listSchedule.add(s);
1544 //计算营运里程,空驶里程 1580 //计算营运里程,空驶里程
1545 if (!childTaskPlans.isEmpty()) { 1581 if (!childTaskPlans.isEmpty()) {
1546 - Iterator<ChildTaskPlan> it = childTaskPlans.iterator();  
1547 - while (it.hasNext()) { 1582 +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1583 + List<ChildTaskPlan> listit=new ArrayList<ChildTaskPlan>(childTaskPlans);
  1584 + Collections.sort(listit, new ComparableChild());
  1585 + for (int j = 0; j < listit.size(); j++) {
1548 ScheduleRealInfo t = new ScheduleRealInfo(); 1586 ScheduleRealInfo t = new ScheduleRealInfo();
1549 - ChildTaskPlan childTaskPlan = it.next(); 1587 + ChildTaskPlan childTaskPlan = listit.get(j);
1550 if (childTaskPlan.isDestroy()) { 1588 if (childTaskPlan.isDestroy()) {
1551 t.setFcsjActual(""); 1589 t.setFcsjActual("");
1552 t.setZdsjActual(""); 1590 t.setZdsjActual("");
@@ -1611,10 +1649,55 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1611,10 +1649,55 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1611 } 1649 }
1612 return rs; 1650 return rs;
1613 } 1651 }
1614 -  
1615 @Override 1652 @Override
1616 public List<Map<String, Object>> statisticsDaily(String line, String date, 1653 public List<Map<String, Object>> statisticsDaily(String line, String date,
1617 String xlName, String type) { 1654 String xlName, String type) {
  1655 + List<Map<String, Object>> lMap= new ArrayList<Map<String, Object>>();
  1656 + List<ScheduleRealInfo> lists = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);
  1657 + Map<String, Object> map = new HashMap<String, Object>();
  1658 + map.put("xlName", xlName);
  1659 + map.put("jhlc", culateService.culateJhgl(lists));
  1660 + map.put("sjgl", Arith.add(culateService.culateSjgl(lists),culateService.culateLjgl(lists)));
  1661 + map.put("ssgl", culateService.culateLbgl(lists));
  1662 + map.put("ssgl_lz", culateService.culateCJLC(lists, "路阻"));
  1663 + map.put("ssgl_dm", culateService.culateCJLC(lists, "吊慢"));
  1664 + map.put("ssgl_gz", culateService.culateCJLC(lists, "故障"));
  1665 + map.put("ssgl_jf", culateService.culateCJLC(lists, "纠纷"));
  1666 + map.put("ssgl_zs", culateService.culateCJLC(lists, "肇事"));
  1667 + map.put("ssgl_qr", culateService.culateCJLC(lists, "缺人"));
  1668 + map.put("ssgl_qc", culateService.culateCJLC(lists, "缺车"));
  1669 + map.put("ssgl_kx", culateService.culateCJLC(lists, "客稀"));
  1670 + map.put("ssgl_qh", culateService.culateCJLC(lists, "气候"));
  1671 + map.put("ssgl_yw", culateService.culateCJLC(lists, "援外"));
  1672 + map.put("ssgl_other", culateService.culateCJLC(lists, "其他"));
  1673 + map.put("ssbc", culateService.culateLbbc(lists));
  1674 + map.put("ljgl", culateService.culateLjgl(lists));
  1675 + map.put("jhbc", culateService.culateJhbc(lists,""));
  1676 + map.put("jhbc_m", culateService.culateJhbc(lists, "zgf"));
  1677 + map.put("jhbc_a", culateService.culateJhbc(lists, "wgf"));
  1678 + map.put("sjbc", culateService.culateSjbc(lists,""));
  1679 + map.put("sjbc_m", culateService.culateSjbc(lists,"zgf"));
  1680 + map.put("sjbc_a", culateService.culateSjbc(lists,"wgf"));
  1681 + map.put("ljbc", culateService.culateLjbc(lists,""));
  1682 + map.put("ljbc_m", culateService.culateLjbc(lists,"zgf"));
  1683 + map.put("ljbc_a", culateService.culateLjbc(lists,"wgf"));
  1684 + map.put("fzbc", culateService.culateFzbc(lists, ""));
  1685 + map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));
  1686 + map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));
  1687 + map.put("dtbc", 0);
  1688 + map.put("dtbc_m", 0);
  1689 + map.put("dtbc_a", 0);
  1690 + map.put("djg", 0);
  1691 + map.put("djg_m", 0);
  1692 + map.put("djg_a", 0);
  1693 + map.put("djg_time", 0);
  1694 + lMap.add(map);
  1695 + return lMap;
  1696 + }
  1697 +
  1698 + /* @Override
  1699 + public List<Map<String, Object>> statisticsDaily(String line, String date,
  1700 + String xlName, String type) {
1618 List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); 1701 List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
1619 if (date.length() == 10) 1702 if (date.length() == 10)
1620 list = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date); 1703 list = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);
@@ -1748,8 +1831,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1748,8 +1831,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1748 while (it.hasNext()) { 1831 while (it.hasNext()) {
1749 ChildTaskPlan childTaskPlan = it.next(); 1832 ChildTaskPlan childTaskPlan = it.next();
1750 childMileage = childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage(); 1833 childMileage = childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
1751 - jhlc += childMileage;  
1752 - jhlcZ += childMileage;  
1753 if (childTaskPlan.isDestroy()) { 1834 if (childTaskPlan.isDestroy()) {
1754 ssgl += childMileage; 1835 ssgl += childMileage;
1755 ssglZ += childMileage; 1836 ssglZ += childMileage;
@@ -2101,7 +2182,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2101,7 +2182,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2101 map.put("djg_a", djg_aZ); 2182 map.put("djg_a", djg_aZ);
2102 map.put("djg_time", djg_timeZ); 2183 map.put("djg_time", djg_timeZ);
2103 lMap.add(map); 2184 lMap.add(map);
2104 - /* for (int i = 0; i < lMap.size(); i++) { 2185 + for (int i = 0; i < lMap.size(); i++) {
2105 Map<String, Object> m=lMap.get(i); 2186 Map<String, Object> m=lMap.get(i);
2106 // m.get("")) 2187 // m.get(""))
2107 jhlc += Double.parseDouble(m.get("jhlc").toString()); 2188 jhlc += Double.parseDouble(m.get("jhlc").toString());
@@ -2138,7 +2219,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2138,7 +2219,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2138 m.get("djg_m", djg_m); 2219 m.get("djg_m", djg_m);
2139 m.get("djg_a", djg_a); 2220 m.get("djg_a", djg_a);
2140 m.get("djg_time", djg_time); 2221 m.get("djg_time", djg_time);
2141 - }*/ 2222 + }
2142 2223
2143 if (type != null && type.length() != 0 && type.equals("export")) { 2224 if (type != null && type.length() != 0 && type.equals("export")) {
2144 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"), 2225 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
@@ -2158,7 +2239,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2158,7 +2239,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2158 } 2239 }
2159 2240
2160 return lMap; 2241 return lMap;
2161 - } 2242 + }*/
2162 2243
2163 @Override 2244 @Override
2164 public List<Map<String, Object>> statisticsDailyTj(String line, String date,String date2, 2245 public List<Map<String, Object>> statisticsDailyTj(String line, String date,String date2,
@@ -2969,12 +3050,13 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2969,12 +3050,13 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2969 String jName = yesterdayDataList.get(x).get("jGh").toString(); 3050 String jName = yesterdayDataList.get(x).get("jGh").toString();
2970 String clZbh = yesterdayDataList.get(x).get("clZbh").toString(); 3051 String clZbh = yesterdayDataList.get(x).get("clZbh").toString();
2971 3052
2972 - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0; 3053 +// double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0;
2973 double addMileage = 0, remMileage = 0; 3054 double addMileage = 0, remMileage = 0;
2974 Map<String, Object> map = new HashMap<String, Object>(); 3055 Map<String, Object> map = new HashMap<String, Object>();
2975 boolean fage = true; 3056 boolean fage = true;
2976 String company=""; 3057 String company="";
2977 String bCompany=""; 3058 String bCompany="";
  3059 + List<ScheduleRealInfo> listS=new ArrayList<ScheduleRealInfo>();
2978 for (ScheduleRealInfo scheduleRealInfo : lists) { 3060 for (ScheduleRealInfo scheduleRealInfo : lists) {
2979 if(scheduleRealInfo.getjGh().equals(jName) && scheduleRealInfo.getClZbh().equals(clZbh)){ 3061 if(scheduleRealInfo.getjGh().equals(jName) && scheduleRealInfo.getClZbh().equals(clZbh)){
2980 if (fage) { 3062 if (fage) {
@@ -2983,7 +3065,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2983,7 +3065,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2983 bCompany=scheduleRealInfo.getFgsBm(); 3065 bCompany=scheduleRealInfo.getFgsBm();
2984 fage = false; 3066 fage = false;
2985 } 3067 }
2986 - if (scheduleRealInfo != null) { 3068 + listS.add(scheduleRealInfo);
  3069 +
  3070 + /* if (scheduleRealInfo != null) {
2987 //计划里程(主任务过滤掉临加班次), 3071 //计划里程(主任务过滤掉临加班次),
2988 //烂班里程(主任务烂班), 3072 //烂班里程(主任务烂班),
2989 //临加里程(主任务临加), 3073 //临加里程(主任务临加),
@@ -3042,16 +3126,22 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -3042,16 +3126,22 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3042 } 3126 }
3043 } 3127 }
3044 } 3128 }
3045 - } 3129 + }*/
3046 } 3130 }
3047 } 3131 }
  3132 +
3048 yesterdayDataList.get(x).put("company", company); 3133 yesterdayDataList.get(x).put("company", company);
3049 yesterdayDataList.get(x).put("bCompany", bCompany); 3134 yesterdayDataList.get(x).put("bCompany", bCompany);
3050 - Double zgl=Arith.add(yygl,ksgl);  
3051 - yesterdayDataList.get(x).put("totalKilometers", Arith.add(zgl, jcclc)); 3135 +// Double zgl=Arith.add(yygl,ksgl);
  3136 + Double ljgl=culateMieageService.culateLjgl(listS);
  3137 + Double sjgl=culateMieageService.culateSjgl(listS);
  3138 + Double ksgl=culateMieageService.culateKsgl(listS);
  3139 + Double jccgl=culateMieageService.culateJccgl(listS);
  3140 + Double zyygl=Arith.add(sjgl, ljgl);
  3141 + Double zksgl=Arith.add(ksgl, jccgl);
  3142 + yesterdayDataList.get(x).put("totalKilometers", Arith.add(zyygl, zksgl));
3052 3143
3053 } 3144 }
3054 - System.out.println();  
3055 //增加顺序号 3145 //增加顺序号
3056 for (int i = 0; i < yesterdayDataList.size(); i++) { 3146 for (int i = 0; i < yesterdayDataList.size(); i++) {
3057 if (i == 0) { 3147 if (i == 0) {
src/main/java/com/bsth/service/report/CulateMileageService.java 0 → 100644
  1 +package com.bsth.service.report;
  2 +
  3 +import java.util.List;
  4 +import java.util.Map;
  5 +
  6 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  7 +
  8 +public interface CulateMileageService {
  9 +
  10 + List<Map<String,Object>> jobFwqk(List<ScheduleRealInfo> lists);
  11 + double culateLbgl(List<ScheduleRealInfo> lists);
  12 + int culateLbbc(List<ScheduleRealInfo> lists);
  13 +
  14 + List<Map<String,Object>> jobLjqk(List<ScheduleRealInfo> lists);
  15 + double culateLjgl(List<ScheduleRealInfo> lists);
  16 + int culateLjbc(List<ScheduleRealInfo> lists,String item);
  17 +
  18 + double culateJhgl(List<ScheduleRealInfo> lists);
  19 + int culateJhbc(List<ScheduleRealInfo> lists,String item);
  20 +
  21 + double culateSjgl(List<ScheduleRealInfo> lists);
  22 + int culateSjbc(List<ScheduleRealInfo> lists,String item);
  23 +
  24 + double culateKsgl(List<ScheduleRealInfo> lists);
  25 + double culateJccgl(List<ScheduleRealInfo> lists);
  26 +
  27 + double culateCJLC(List<ScheduleRealInfo> lists,String item);
  28 +
  29 + int culateFzbc(List<ScheduleRealInfo> lists,String item);
  30 +
  31 +}
  32 +
src/main/java/com/bsth/service/report/ReportService.java
@@ -29,5 +29,15 @@ public interface ReportService { @@ -29,5 +29,15 @@ public interface ReportService {
29 List<Map<String, Object>> tbodyTime5(String line ,String ttinfo); 29 List<Map<String, Object>> tbodyTime5(String line ,String ttinfo);
30 30
31 List<Map<String, Object>> getTtinfo(Map<String, Object> map); 31 List<Map<String, Object>> getTtinfo(Map<String, Object> map);
32 - 32 +
  33 + List<Map<String,Object>> jobFwqk(Map<String, Object> map);
  34 + List<Map<String,Object>> jobLjqk(Map<String, Object> map);
  35 +
  36 + Map<String, Object> jobHzxx(Map<String, Object> map);
  37 +
  38 + List<Map<String, Object>> lineList();
  39 +
  40 + List<Map<String, String>> carList(Map<String, Object> map);
  41 +
  42 + List<Map<String, String>> userList(Map<String, Object> map);
33 } 43 }
src/main/java/com/bsth/service/report/impl/CulateMileageServiceImpl.java 0 → 100644
  1 +package com.bsth.service.report.impl;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.HashMap;
  5 +import java.util.Iterator;
  6 +import java.util.List;
  7 +import java.util.Map;
  8 +import java.util.Set;
  9 +
  10 +import org.apache.commons.lang.StringUtils;
  11 +import org.springframework.stereotype.Service;
  12 +
  13 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  14 +import com.bsth.entity.realcontrol.ScheduleRealInfo;
  15 +import com.bsth.service.report.CulateMileageService;
  16 +import com.bsth.util.Arith;
  17 +
  18 +@Service
  19 +public class CulateMileageServiceImpl implements CulateMileageService{
  20 +
  21 + private static long zgf1 = 6 * 60 + 31,
  22 + zgf2 = 8 * 60 + 30,
  23 + wgf1 = 16 * 60 + 1,
  24 + wgf2 = 18 * 60;
  25 + @Override
  26 + public List<Map<String, Object>> jobFwqk(List<ScheduleRealInfo> lists) {
  27 + // TODO Auto-generated method stub
  28 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  29 + for (int i = 0; i < lists.size(); i++) {
  30 + ScheduleRealInfo scheduleRealInfo = lists.get(i);
  31 + if (!(scheduleRealInfo.getBcType().equals("in")
  32 + || scheduleRealInfo.getBcType().equals("out"))) {
  33 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  34 + if (childTaskPlans.isEmpty()) {
  35 + Map<String, Object> newMap = new HashMap<String, Object>();
  36 + String adjustExps = "";
  37 + if (scheduleRealInfo.getAdjustExps() == "" || scheduleRealInfo.getAdjustExps() == null) {
  38 + adjustExps = "其他";
  39 + } else {
  40 + adjustExps = scheduleRealInfo.getAdjustExps();
  41 + }
  42 + if (scheduleRealInfo.getStatus() == -1) {
  43 + newMap.put("nr", adjustExps);
  44 + newMap.put("lp", scheduleRealInfo.getLpName());
  45 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  46 + newMap.put("jgh", scheduleRealInfo.getjGh());
  47 + newMap.put("dz", scheduleRealInfo.getQdzName());
  48 + newMap.put("sj", scheduleRealInfo.getFcsj());
  49 + newMap.put("lbbc", 1);
  50 + newMap.put("lblc", scheduleRealInfo.getJhlcOrig());
  51 + newMap.put("jyqp", scheduleRealInfo.getRealMileage());
  52 + list.add(newMap);
  53 + }
  54 +
  55 + } else {
  56 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  57 + while (it.hasNext()) {
  58 + ChildTaskPlan childTaskPlan = it.next();
  59 + if (childTaskPlan.isDestroy()) {
  60 + String destroyReason = "";
  61 + if (childTaskPlan.getDestroyReason() == "" || childTaskPlan.getDestroyReason() == null) {
  62 + destroyReason = "其他";
  63 + } else {
  64 + destroyReason = childTaskPlan.getDestroyReason();
  65 + }
  66 + Map<String, Object> newMap = new HashMap<String, Object>();
  67 + newMap.put("nr", destroyReason);
  68 + newMap.put("lp", scheduleRealInfo.getLpName());
  69 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  70 + newMap.put("jgh", scheduleRealInfo.getjGh());
  71 + newMap.put("dz", childTaskPlan.getStartStationName());
  72 + newMap.put("sj", childTaskPlan.getStartDate());
  73 + newMap.put("lbbc", 0);
  74 + newMap.put("lblc", childTaskPlan.getMileage());
  75 + newMap.put("jyqp", scheduleRealInfo.getRealMileage());
  76 + list.add(newMap);
  77 +
  78 + }
  79 + }
  80 + }
  81 + }
  82 + }
  83 + return list;
  84 + }
  85 +
  86 + @Override
  87 + public double culateLbgl(List<ScheduleRealInfo> lists) {
  88 + // TODO Auto-generated method stub
  89 + double zlblc =0.0;
  90 + for (int i = 0; i < lists.size(); i++) {
  91 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  92 + if (!isInOut(scheduleRealInfo)) {
  93 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  94 + if(childTaskPlans.isEmpty()){
  95 + if(scheduleRealInfo.getStatus() == -1){
  96 + zlblc=Arith.add(zlblc,scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig());
  97 + }else{
  98 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  99 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  100 + double cjlc=Arith.sub(jhlcOrig,jhlc);
  101 + if(cjlc>0){
  102 + zlblc=Arith.add(zlblc, cjlc);
  103 + }
  104 + }
  105 + }else{
  106 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  107 + while (it.hasNext()) {
  108 + ChildTaskPlan childTaskPlan = it.next();
  109 + if (childTaskPlan.isDestroy()) {
  110 + zlblc=Arith.add(zlblc,childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage());
  111 + }
  112 + }
  113 + }
  114 + }
  115 + }
  116 + return zlblc;
  117 + }
  118 +
  119 + @Override
  120 + public int culateLbbc(List<ScheduleRealInfo> lists) {
  121 + // TODO Auto-generated method stub
  122 + int lbbc=0;
  123 + for (int i = 0; i < lists.size(); i++) {
  124 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  125 + if (!(scheduleRealInfo.getBcType().equals("in")
  126 + || scheduleRealInfo.getBcType().equals("out"))) {
  127 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  128 + if(childTaskPlans.isEmpty()){
  129 + if(scheduleRealInfo.getStatus() == -1){
  130 + lbbc++;
  131 + }
  132 + }else{
  133 + if(scheduleRealInfo.getStatus() == -1){
  134 + boolean fage=true;
  135 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  136 + if(it.hasNext()){
  137 + ChildTaskPlan childTaskPlan = it.next();
  138 + if(!childTaskPlan.isDestroy()){
  139 + if(childTaskPlan.getMileageType().equals("service")){
  140 + fage=false;
  141 + }
  142 + }
  143 +
  144 + }
  145 + if(fage){
  146 + lbbc++;
  147 + }
  148 + }
  149 + }
  150 + }
  151 + }
  152 + return lbbc;
  153 + }
  154 +
  155 + @Override
  156 + public List<Map<String, Object>> jobLjqk(List<ScheduleRealInfo> lists) {
  157 + // TODO Auto-generated method stub
  158 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  159 + for (int i = 0; i < lists.size(); i++) {
  160 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  161 + if (!(scheduleRealInfo.getBcType().equals("in")
  162 + || scheduleRealInfo.getBcType().equals("out"))) {
  163 +// Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  164 +// if(childTaskPlans.isEmpty()){
  165 + if(scheduleRealInfo.isSflj()){
  166 + Map<String, Object> newMap=new HashMap<String,Object>();
  167 + newMap.put("lp", scheduleRealInfo.getLpName());
  168 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  169 + newMap.put("jgh", scheduleRealInfo.getjGh());
  170 + newMap.put("dz", scheduleRealInfo.getQdzName());
  171 + newMap.put("sj", scheduleRealInfo.getFcsj());
  172 + newMap.put("ljlc", scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
  173 + newMap.put("jyqp", scheduleRealInfo.getRealMileage());
  174 + list.add(newMap);
  175 + }
  176 +// }else{
  177 +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  178 +// while (it.hasNext()) {
  179 +// ChildTaskPlan childTaskPlan = it.next();
  180 +// if (childTaskPlan.isDestroy()) {
  181 +// }
  182 +// }
  183 +// }
  184 + }
  185 + }
  186 + return list;
  187 + }
  188 +
  189 + @Override
  190 + public double culateLjgl(List<ScheduleRealInfo> lists) {
  191 + // TODO Auto-generated method stub
  192 + double ljgl=0;
  193 + for (int i = 0; i < lists.size(); i++) {
  194 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  195 + if (!(scheduleRealInfo.getBcType().equals("in")
  196 + || scheduleRealInfo.getBcType().equals("out"))) {
  197 + if(!scheduleRealInfo.isDestroy()){
  198 + if(scheduleRealInfo.isSflj()){
  199 + ljgl=Arith.add(ljgl,scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
  200 + }else{
  201 + double jhlc=scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc();
  202 + double jhlcOrig=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  203 + double zjlc=Arith.sub(jhlc, jhlcOrig);
  204 + if(zjlc>0){
  205 + ljgl=Arith.add(zjlc, ljgl);
  206 + }
  207 + }
  208 + }
  209 +
  210 + }
  211 + }
  212 + return ljgl;
  213 + }
  214 +
  215 + @Override
  216 + public int culateLjbc(List<ScheduleRealInfo> lists,String item) {
  217 + // TODO Auto-generated method stub
  218 + int ljbc=0;
  219 + for (int i = 0; i < lists.size(); i++) {
  220 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  221 + if (!(scheduleRealInfo.getBcType().equals("in")
  222 + || scheduleRealInfo.getBcType().equals("out"))) {
  223 + if(scheduleRealInfo.isSflj()){
  224 + if(item.equals("zgf") || item.equals("wgf")){
  225 + String time="";
  226 + if(scheduleRealInfo.getFcsjActual()!=null){
  227 + time=scheduleRealInfo.getFcsjActual();
  228 + }
  229 + if(time.equals("")){
  230 + if(scheduleRealInfo.getDfsj()!=null){
  231 + time=scheduleRealInfo.getDfsj();
  232 + }
  233 + }
  234 + if(!time.equals("")){
  235 + String[] fcsjStr = time.split(":");
  236 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  237 +
  238 + if(item.equals("zgf")){
  239 + if(fcsj>=zgf1 && fcsj<=zgf2){
  240 + ljbc++;
  241 + }
  242 + }else if(item.equals("wgf")){
  243 + if(fcsj>=wgf1 && fcsj<=wgf2){
  244 + ljbc++;
  245 + }
  246 + }
  247 + }
  248 + }else{
  249 + ljbc++;
  250 + }
  251 + }
  252 + }
  253 + }
  254 + return ljbc;
  255 + }
  256 +
  257 + @Override
  258 + public double culateJhgl(List<ScheduleRealInfo> lists) {
  259 + // TODO Auto-generated method stub
  260 + double jhgl=0;
  261 + for (int i = 0; i < lists.size(); i++) {
  262 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  263 + if (!(scheduleRealInfo.getBcType().equals("in")
  264 + || scheduleRealInfo.getBcType().equals("out"))) {
  265 + if(!scheduleRealInfo.isSflj()){
  266 + jhgl=Arith.add(jhgl,scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig());
  267 + }
  268 + }
  269 + }
  270 + return jhgl;
  271 + }
  272 +
  273 + @Override
  274 + public int culateJhbc(List<ScheduleRealInfo> lists,String item) {
  275 + // TODO Auto-generated method stub
  276 + int jhbc=0;
  277 + for (int i = 0; i < lists.size(); i++) {
  278 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  279 + if (!(scheduleRealInfo.getBcType().equals("in")
  280 + || scheduleRealInfo.getBcType().equals("out"))) {
  281 + if(!scheduleRealInfo.isSflj()){
  282 + String[] fcsjStr = scheduleRealInfo.getFcsj().split(":");
  283 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  284 + if(item.equals("zgf")){
  285 + if(fcsj>=zgf1 && fcsj<=zgf2){
  286 + jhbc++;
  287 + }
  288 + }else if(item.equals("wgf")){
  289 + if(fcsj>=wgf1 && fcsj<=wgf2){
  290 + jhbc++;
  291 + }
  292 + }else{
  293 + jhbc++;
  294 + }
  295 +
  296 + }
  297 + }
  298 + }
  299 + return jhbc;
  300 + }
  301 +
  302 + @Override
  303 + public double culateSjgl(List<ScheduleRealInfo> lists) {
  304 + // TODO Auto-generated method stub
  305 + double sjgl =0;
  306 + for (int i = 0; i < lists.size(); i++) {
  307 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  308 + if (!isInOut(scheduleRealInfo)) {
  309 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  310 + if(!scheduleRealInfo.isSflj()){
  311 + if(childTaskPlans.isEmpty()){
  312 + if(scheduleRealInfo.getStatus() != -1){
  313 + double jggl=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  314 + sjgl=Arith.add(sjgl,jggl);
  315 + }
  316 + }else{
  317 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  318 + while (it.hasNext()) {
  319 + ChildTaskPlan childTaskPlan = it.next();
  320 + if(childTaskPlan.getMileageType().equals("service")){
  321 + if (!childTaskPlan.isDestroy()) {
  322 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  323 + sjgl=Arith.add(sjgl,jhgl);
  324 + }
  325 + }
  326 + }
  327 + }
  328 + }
  329 + }
  330 + }
  331 + return sjgl;
  332 + }
  333 +
  334 + @Override
  335 + public int culateSjbc(List<ScheduleRealInfo> lists,String item) {
  336 + // TODO Auto-generated method stub
  337 + int sjbc=0;
  338 + for (int i = 0; i < lists.size(); i++) {
  339 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  340 + if (!(scheduleRealInfo.getBcType().equals("in")
  341 + || scheduleRealInfo.getBcType().equals("out"))) {
  342 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  343 + if(!scheduleRealInfo.isSflj()){
  344 + String time="";
  345 + if(item.equals("zgf") || item.equals("wgf")){
  346 + if(scheduleRealInfo.getFcsjActual()!=null){
  347 + time=scheduleRealInfo.getFcsjActual();
  348 + }
  349 + if(time.equals("")){
  350 + if(scheduleRealInfo.getDfsj()!=null){
  351 + time=scheduleRealInfo.getDfsj();
  352 + }
  353 + }
  354 + }else{
  355 + time=scheduleRealInfo.getFcsj();
  356 + }
  357 + if(!time.equals("")){
  358 + String[] fcsjStr = scheduleRealInfo.getFcsj().split(":");
  359 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  360 + if(childTaskPlans.isEmpty()){
  361 + if(scheduleRealInfo.getStatus()!=-1){
  362 + if(item.equals("zgf")){
  363 + if(fcsj>=zgf1 && fcsj<=zgf2){
  364 + sjbc++;
  365 + }
  366 + }else if(item.equals("wgf")){
  367 + if(fcsj>=wgf1 && fcsj<=wgf2){
  368 + sjbc++;
  369 + }
  370 + }else{
  371 + sjbc++;
  372 + }
  373 +
  374 + }
  375 + }else{
  376 + if(scheduleRealInfo.getStatus() == -1){
  377 + boolean fage=false;
  378 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  379 + if(it.hasNext()){
  380 + ChildTaskPlan childTaskPlan = it.next();
  381 + if(!childTaskPlan.isDestroy()){
  382 + if(childTaskPlan.getMileageType().equals("service")){
  383 + fage=true;
  384 + }
  385 + }
  386 +
  387 + }
  388 + if(fage){
  389 + if(item.equals("zgf")){
  390 + if(fcsj>=zgf1 && fcsj<=zgf2){
  391 + sjbc++;
  392 + }
  393 + }else if(item.equals("wgf")){
  394 + if(fcsj>=wgf1 && fcsj<=wgf2){
  395 + sjbc++;
  396 + }
  397 + }else{
  398 + sjbc++;
  399 + }
  400 + }
  401 +
  402 + }else{
  403 + if(item.equals("zgf")){
  404 + if(fcsj>=zgf1 && fcsj<=zgf2){
  405 + sjbc++;
  406 + }
  407 + }else if(item.equals("wgf")){
  408 + if(fcsj>=wgf1 && fcsj<=wgf2){
  409 + sjbc++;
  410 + }
  411 + }else{
  412 + sjbc++;
  413 + }
  414 + }
  415 + }
  416 + }
  417 + }
  418 + }
  419 + }
  420 + return sjbc;
  421 + }
  422 +
  423 + @Override
  424 + public double culateKsgl(List<ScheduleRealInfo> lists) {
  425 + // TODO Auto-generated method stub
  426 + double ksgl =0;
  427 + for (int i = 0; i < lists.size(); i++) {
  428 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  429 + if (!(scheduleRealInfo.getBcType().equals("in")
  430 + || scheduleRealInfo.getBcType().equals("out"))) {
  431 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  432 + if(!childTaskPlans.isEmpty()){
  433 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  434 + while (it.hasNext()) {
  435 + ChildTaskPlan childTaskPlan = it.next();
  436 + if(childTaskPlan.getMileageType().equals("empty")){
  437 + if (!childTaskPlan.isDestroy()) {
  438 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  439 + ksgl=Arith.add(ksgl,jhgl);
  440 + }
  441 + }
  442 + }
  443 + }
  444 + }
  445 + }
  446 + return ksgl;
  447 + }
  448 +
  449 + @Override
  450 + public double culateJccgl(List<ScheduleRealInfo> lists) {
  451 + // TODO Auto-generated method stub
  452 + double jcclc =0;
  453 + for (int i = 0; i < lists.size(); i++) {
  454 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  455 + if (scheduleRealInfo.getBcType().equals("in")
  456 + || scheduleRealInfo.getBcType().equals("out")) {
  457 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  458 + if(childTaskPlans.isEmpty()){
  459 + if(!scheduleRealInfo.isDestroy())
  460 + jcclc =Arith.add(jcclc, scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig());
  461 + }else{
  462 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  463 + while (it.hasNext()) {
  464 + ChildTaskPlan childTaskPlan = it.next();
  465 + if(childTaskPlan.getMileageType().equals("empty")){
  466 + if (!childTaskPlan.isDestroy()) {
  467 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  468 + jcclc=Arith.add(jcclc,jhgl);
  469 + }
  470 + }
  471 + }
  472 + }
  473 + }
  474 + }
  475 + return jcclc;
  476 + }
  477 +
  478 + public static boolean isInOut(ScheduleRealInfo s){
  479 + boolean fage=false;
  480 + if(s.getBcType().equals("in")){
  481 + fage=true;
  482 + }
  483 + if(s.getBcType().equals("out")){
  484 + fage=true;
  485 + }
  486 +
  487 + return fage;
  488 + }
  489 +
  490 + @Override
  491 + public double culateCJLC(List<ScheduleRealInfo> list, String item) {
  492 + // TODO Auto-generated method stub
  493 + double sum = 0;
  494 + Set<ChildTaskPlan> cts;
  495 + for(ScheduleRealInfo sch : list){
  496 + if (sch.isSflj())
  497 + continue;
  498 + cts = sch.getcTasks();
  499 + //有子任务
  500 + if (cts != null && cts.size() > 0) {
  501 + for(ChildTaskPlan c : cts){
  502 + if(c.isDestroy() && c.getDestroyReason().equals(item))
  503 + sum = Arith.add(sum, c.getMileage());
  504 + }
  505 + }
  506 + else if(isInOut(sch))
  507 + continue;
  508 + //主任务烂班
  509 + else if(sch.getStatus() == -1){
  510 + if(sch.getAdjustExps().equals(item) ||
  511 + (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))){
  512 + sum = Arith.add(sum, sch.getJhlcOrig());
  513 + }
  514 + }
  515 + else if(item.equals("其他")){
  516 + double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc());
  517 + if(diff > 0){
  518 + sum = Arith.add(sum, diff);
  519 + }
  520 + }
  521 + }
  522 + return sum;
  523 +
  524 + }
  525 +
  526 + @Override
  527 + public int culateFzbc(List<ScheduleRealInfo> lists, String item) {
  528 + // TODO Auto-generated method stub
  529 + int fzbc=0;
  530 + for (int i = 0; i < lists.size(); i++) {
  531 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  532 + if (scheduleRealInfo.getBcType().equals("venting")) {
  533 +// if(!scheduleRealInfo.isSflj()){
  534 + String[] fcsjStr = scheduleRealInfo.getFcsj().split(":");
  535 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  536 + if(item.equals("zgf")){
  537 + if(fcsj>=zgf1 && fcsj<=zgf2){
  538 + fzbc++;
  539 + }
  540 + }else if(item.equals("wgf")){
  541 + if(fcsj>=wgf1 && fcsj<=wgf2){
  542 + fzbc++;
  543 + }
  544 + }else{
  545 + fzbc++;
  546 + }
  547 +
  548 +// }
  549 + }
  550 + }
  551 + return fzbc;
  552 + }
  553 +
  554 +}
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
@@ -10,9 +10,12 @@ import java.util.ArrayList; @@ -10,9 +10,12 @@ import java.util.ArrayList;
10 import java.util.Calendar; 10 import java.util.Calendar;
11 import java.util.Date; 11 import java.util.Date;
12 import java.util.HashMap; 12 import java.util.HashMap;
  13 +import java.util.Iterator;
13 import java.util.List; 14 import java.util.List;
14 import java.util.Map; 15 import java.util.Map;
  16 +import java.util.Set;
15 17
  18 +import org.apache.commons.lang.StringUtils;
16 import org.slf4j.Logger; 19 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory; 20 import org.slf4j.LoggerFactory;
18 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,14 +24,20 @@ import org.springframework.jdbc.core.RowMapper; @@ -21,14 +24,20 @@ import org.springframework.jdbc.core.RowMapper;
21 import org.springframework.stereotype.Service; 24 import org.springframework.stereotype.Service;
22 25
23 import com.bsth.data.BasicData; 26 import com.bsth.data.BasicData;
  27 +import com.bsth.entity.Line;
  28 +import com.bsth.entity.Personnel;
24 import com.bsth.entity.StationRoute; 29 import com.bsth.entity.StationRoute;
25 import com.bsth.entity.excep.ArrivalInfo; 30 import com.bsth.entity.excep.ArrivalInfo;
26 import com.bsth.entity.oil.Ylb; 31 import com.bsth.entity.oil.Ylb;
  32 +import com.bsth.entity.realcontrol.ChildTaskPlan;
27 import com.bsth.entity.realcontrol.ScheduleRealInfo; 33 import com.bsth.entity.realcontrol.ScheduleRealInfo;
28 import com.bsth.entity.schedule.SchedulePlanInfo; 34 import com.bsth.entity.schedule.SchedulePlanInfo;
  35 +import com.bsth.repository.LineRepository;
29 import com.bsth.repository.StationRouteRepository; 36 import com.bsth.repository.StationRouteRepository;
30 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; 37 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  38 +import com.bsth.service.report.CulateMileageService;
31 import com.bsth.service.report.ReportService; 39 import com.bsth.service.report.ReportService;
  40 +import com.bsth.util.Arith;
32 import com.bsth.util.db.DBUtils_MS; 41 import com.bsth.util.db.DBUtils_MS;
33 42
34 @Service 43 @Service
@@ -44,6 +53,10 @@ public class ReportServiceImpl implements ReportService{ @@ -44,6 +53,10 @@ public class ReportServiceImpl implements ReportService{
44 ScheduleRealInfoRepository scheduleRealInfoRepository; 53 ScheduleRealInfoRepository scheduleRealInfoRepository;
45 @Autowired 54 @Autowired
46 StationRouteRepository stationRoutRepository; 55 StationRouteRepository stationRoutRepository;
  56 + @Autowired
  57 + CulateMileageService culateService;
  58 + @Autowired
  59 + LineRepository lineRepository;
47 @Override 60 @Override
48 public List<ScheduleRealInfo> queryListBczx(String line, String date,String clzbh) { 61 public List<ScheduleRealInfo> queryListBczx(String line, String date,String clzbh) {
49 // TODO Auto-generated method stub 62 // TODO Auto-generated method stub
@@ -1059,4 +1072,360 @@ public class ReportServiceImpl implements ReportService{ @@ -1059,4 +1072,360 @@ public class ReportServiceImpl implements ReportService{
1059 return list; 1072 return list;
1060 } 1073 }
1061 1074
  1075 + private List<ScheduleRealInfo> getListSinfo(Map<String, Object> map){
  1076 + List<ScheduleRealInfo> list =new ArrayList<ScheduleRealInfo>();
  1077 +
  1078 + String sql="select DISTINCT a.* from (select * from bsth_c_s_sp_info_real where 1=1 ";
  1079 + if(map.get("date")!=null){
  1080 + sql += " and schedule_date_str='"+map.get("date").toString()+"'";
  1081 + }
  1082 + if(map.get("line")!=null){
  1083 + if(map.get("line").toString()!=""){
  1084 + sql += " and xl_bm='"+map.get("line").toString()+"'";
  1085 + }
  1086 +
  1087 + }
  1088 + if(map.get("bcType")!=null){
  1089 + if(map.get("bcType").toString().equals("inout")){
  1090 + sql += " and bc_type in ('in','out')";
  1091 + }
  1092 +
  1093 + if(map.get("bcType").toString().equals("normal")){
  1094 + sql += " and bc_type not in ('in','out')";
  1095 + }
  1096 + }
  1097 +
  1098 + sql += " )a left join bsth_c_s_child_task b on a.id=b.schedule";
  1099 + list= jdbcTemplate.query(sql,
  1100 + new RowMapper<ScheduleRealInfo>(){
  1101 + @Override
  1102 + public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  1103 + ScheduleRealInfo m=new ScheduleRealInfo();
  1104 + m.setId(rs.getLong("id"));
  1105 +// m.setBcs();
  1106 +// m.setBcsj();
  1107 + m.setClZbh(rs.getString("cl_zbh"));
  1108 + m.setFcsj(rs.getString("fcsj"));
  1109 + m.setFcsjActual(rs.getString("fcsj_actual"));
  1110 + m.setjGh(rs.getString("j_gh"));
  1111 + m.setjName(rs.getString("j_name"));
  1112 + m.setJhlc(rs.getDouble("jhlc"));
  1113 + m.setLpName(rs.getString("lp_name"));
  1114 + m.setQdzCode(rs.getString("qdz_code"));
  1115 + m.setQdzName(rs.getString("qdz_name"));
  1116 + m.setRealExecDate(rs.getString("real_exec_date"));
  1117 + m.setRealMileage(rs.getDouble("real_mileage"));
  1118 + m.setRemarks(rs.getString("remarks"));
  1119 + m.setsGh(rs.getString("s_gh"));
  1120 + m.setsName(rs.getString("s_name"));
  1121 + m.setScheduleDate(rs.getDate("schedule_date"));
  1122 + m.setScheduleDateStr(rs.getString("schedule_date_str"));
  1123 + m.setSflj(rs.getBoolean("sflj"));
  1124 + m.setSpId(rs.getLong("sp_id"));
  1125 + m.setStatus(rs.getInt("status"));
  1126 + m.setXlBm(rs.getString("xl_bm"));
  1127 + m.setXlDir(rs.getString("xl_dir"));
  1128 + m.setXlName(rs.getString("xl_name"));
  1129 + m.setZdsj(rs.getString("zdsj"));
  1130 + m.setZdsjActual(rs.getString("zdsj_actual"));
  1131 + m.setZdzCode(rs.getString("zdz_code"));
  1132 + m.setZdzName(rs.getString("zdz_name"));
  1133 + m.setCcno(rs.getInt("ccno"));
  1134 + m.setDfAuto(rs.getBoolean("df_auto"));
  1135 + m.setFgsBm(rs.getString("fgs_bm"));
  1136 + m.setFgsName(rs.getString("fgs_name"));
  1137 + m.setGsBm(rs.getString("gs_bm"));
  1138 + m.setGsName(rs.getString("gs_name"));
  1139 + m.setOnline(rs.getBoolean("online"));
  1140 + m.setAdjustExps(rs.getString("adjust_exps"));
  1141 + m.setReissue(rs.getBoolean("reissue"));
  1142 + m.setJhlcOrig(rs.getDouble("jhlc_orig"));
  1143 + return m;
  1144 + }
  1145 + });
  1146 +
  1147 + return list;
  1148 + }
  1149 +
  1150 + @Override
  1151 + public List<Map<String, Object>> jobFwqk(Map<String, Object> map) {
  1152 + // TODO Auto-generated method stub
  1153 + String line=map.get("line").toString();
  1154 + String date=map.get("date").toString();
  1155 + map.put("bcType", "normal");
  1156 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  1157 + List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
  1158 + for (int i = 0; i < sList.size(); i++) {
  1159 + ScheduleRealInfo scheduleRealInfo = sList.get(i);
  1160 + if (!(scheduleRealInfo.getBcType().equals("in")
  1161 + || scheduleRealInfo.getBcType().equals("out"))) {
  1162 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1163 + if (childTaskPlans.isEmpty()) {
  1164 + Map<String, Object> newMap = new HashMap<String, Object>();
  1165 + String adjustExps = "";
  1166 + if (scheduleRealInfo.getAdjustExps() == null) {
  1167 + adjustExps = "其他";
  1168 + } else if(scheduleRealInfo.getAdjustExps().equals("")){
  1169 + adjustExps = "其他";
  1170 + }else {
  1171 + adjustExps = scheduleRealInfo.getAdjustExps();
  1172 + }
  1173 + if (scheduleRealInfo.getStatus() == -1) {
  1174 + newMap.put("nr", adjustExps);
  1175 + newMap.put("lp", scheduleRealInfo.getLpName());
  1176 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  1177 + newMap.put("jgh", scheduleRealInfo.getjGh());
  1178 + newMap.put("dz", scheduleRealInfo.getQdzName());
  1179 + newMap.put("sj", scheduleRealInfo.getFcsj());
  1180 + newMap.put("lbbc", 1);
  1181 + newMap.put("lblc", scheduleRealInfo.getJhlcOrig());
  1182 + newMap.put("jyqp", scheduleRealInfo.getRealMileage());
  1183 + list.add(newMap);
  1184 + }
  1185 +
  1186 + } else {
  1187 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1188 + while (it.hasNext()) {
  1189 + ChildTaskPlan childTaskPlan = it.next();
  1190 + if (childTaskPlan.isDestroy()) {
  1191 + String destroyReason = "";
  1192 + if ( childTaskPlan.getDestroyReason() == null) {
  1193 + destroyReason = "其他";
  1194 + }else if(childTaskPlan.getDestroyReason().equals("")){
  1195 + destroyReason = "其他";
  1196 + } else {
  1197 + destroyReason = childTaskPlan.getDestroyReason();
  1198 + }
  1199 + Map<String, Object> newMap = new HashMap<String, Object>();
  1200 + newMap.put("nr", destroyReason);
  1201 + newMap.put("lp", scheduleRealInfo.getLpName());
  1202 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  1203 + newMap.put("jgh", scheduleRealInfo.getjGh());
  1204 + newMap.put("dz", childTaskPlan.getStartStationName());
  1205 + newMap.put("sj", childTaskPlan.getStartDate());
  1206 + newMap.put("lbbc", 0);
  1207 + newMap.put("lblc", childTaskPlan.getMileage());
  1208 + newMap.put("jyqp", scheduleRealInfo.getRealMileage());
  1209 + list.add(newMap);
  1210 +
  1211 + }
  1212 + }
  1213 + }
  1214 + }
  1215 + }
  1216 + return list;
  1217 + }
  1218 +
  1219 + //统计临加班次详细信息
  1220 + @Override
  1221 + public List<Map<String, Object>> jobLjqk(Map<String, Object> map) {
  1222 + // TODO Auto-generated method stub
  1223 + String line=map.get("line").toString();
  1224 + String date=map.get("date").toString();
  1225 + map.put("bcType", "normal");
  1226 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  1227 + List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
  1228 + for (int i = 0; i < sList.size(); i++) {
  1229 + ScheduleRealInfo scheduleRealInfo=sList.get(i);
  1230 + if (!(scheduleRealInfo.getBcType().equals("in")
  1231 + || scheduleRealInfo.getBcType().equals("out"))) {
  1232 +// Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1233 +// if(childTaskPlans.isEmpty()){
  1234 + if(scheduleRealInfo.isSflj()){
  1235 + Map<String, Object> newMap=new HashMap<String,Object>();
  1236 + newMap.put("lp", scheduleRealInfo.getLpName());
  1237 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  1238 + newMap.put("jgh", scheduleRealInfo.getjGh());
  1239 + newMap.put("dz", scheduleRealInfo.getQdzName());
  1240 + newMap.put("sj", scheduleRealInfo.getFcsj());
  1241 + newMap.put("ljlc", scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
  1242 + newMap.put("jyqp", scheduleRealInfo.getRealMileage());
  1243 + list.add(newMap);
  1244 + }
  1245 +// }else{
  1246 +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1247 +// while (it.hasNext()) {
  1248 +// ChildTaskPlan childTaskPlan = it.next();
  1249 +// if (childTaskPlan.isDestroy()) {
  1250 +// }
  1251 +// }
  1252 +// }
  1253 + }
  1254 + }
  1255 + return list;
  1256 + }
  1257 +
  1258 + public static double culateCJLC2(List<ScheduleRealInfo> list, String item) {
  1259 + // TODO Auto-generated method stub
  1260 + double sum = 0;
  1261 + Set<ChildTaskPlan> cts;
  1262 + for(ScheduleRealInfo sch : list){
  1263 + if (sch.isSflj())
  1264 + continue;
  1265 + cts = sch.getcTasks();
  1266 + //有子任务
  1267 + if (cts != null && cts.size() > 0) {
  1268 + for(ChildTaskPlan c : cts){
  1269 + if(c.isDestroy() && c.getDestroyReason().equals(item))
  1270 + sum = Arith.add(sum, c.getMileage());
  1271 + }
  1272 + }
  1273 +// else if(isInOut(sch))
  1274 +// continue;
  1275 + //主任务烂班
  1276 + else if(sch.getStatus() == -1){
  1277 + if(sch.getAdjustExps().equals(item) ||
  1278 + (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))){
  1279 + sum = Arith.add(sum, sch.getJhlcOrig());
  1280 + }
  1281 + }
  1282 + else if(item.equals("其他")){
  1283 + double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc());
  1284 + if(diff > 0){
  1285 + sum = Arith.add(sum, diff);
  1286 + }
  1287 + }
  1288 + }
  1289 + return sum;
  1290 +
  1291 + }
  1292 + @Override
  1293 + public Map<String, Object> jobHzxx(Map<String, Object> map) {
  1294 + // TODO Auto-generated method stub
  1295 + String line="";
  1296 + if(map.get("line")!=null){
  1297 + line=map.get("line").toString();
  1298 + }
  1299 + String date="";
  1300 + if(map.get("date")!=null){
  1301 + date=map.get("date").toString();
  1302 + }
  1303 +
  1304 + List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
  1305 + Map<String, Object> newMap=new HashMap<String,Object>();
  1306 + newMap.put("jhbc", culateService.culateJhbc(sList,""));
  1307 + newMap.put("jhgl", culateService.culateJhgl(sList));
  1308 + newMap.put("sjbc", culateService.culateSjbc(sList,""));
  1309 + newMap.put("sjgl", culateService.culateSjgl(sList));
  1310 + newMap.put("lbgl", culateService.culateLbgl(sList));
  1311 + newMap.put("lbbc", culateService.culateLbbc(sList));
  1312 + newMap.put("ljgl", culateService.culateLjgl(sList));
  1313 + newMap.put("ljbc", culateService.culateLjbc(sList,""));
  1314 + newMap.put("ksgl", culateService.culateKsgl(sList));
  1315 + return newMap;
  1316 + }
  1317 + @Override
  1318 + public List<Map<String, Object>> lineList() {
  1319 + // TODO Auto-generated method stub
  1320 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  1321 + Iterator<Line> iterator = lineRepository.findAll().iterator();
  1322 + Line line;
  1323 + while (iterator.hasNext()) {
  1324 + line = iterator.next();
  1325 + Map<String, Object> map=new HashMap<String,Object>();
  1326 + map.put("gsbm", line.getCompany());
  1327 + map.put("fgsbm", line.getBrancheCompany());
  1328 + map.put("xlbm", line.getLineCode());
  1329 + map.put("xlname", line.getName());
  1330 + list.add(map);
  1331 + }
  1332 + return list;
  1333 + }
  1334 + @Override
  1335 + public List<Map<String, String>> carList(Map<String, Object> maps) {
  1336 + // TODO Auto-generated method stub
  1337 + // 转大写
  1338 + String nbbm =maps.get("nbbm").toString().toUpperCase();
  1339 + String gsbm=maps.get("gsbm").toString().trim();
  1340 +// String fgsbm=maps.get("fgsbm").toString().trim();
  1341 + String xlbm=maps.get("xlbm").toString().trim();
  1342 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  1343 + Map<String, String> map;
  1344 + Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();
  1345 +
  1346 + Line line;
  1347 + for (String k : allSet) {
  1348 + if (k.indexOf(nbbm) != -1) {
  1349 + // 所属线路
  1350 + boolean fage=true;
  1351 + map = new HashMap<>();
  1352 + line = BasicData.nbbm2LineMap.get(k);
  1353 + String clgsdm= BasicData.nbbm2CompanyCodeMap.get(k);
  1354 +
  1355 + map.put("id", k);
  1356 + map.put("text", k);
  1357 + if (null != line) {
  1358 + map.put("lineName", line.getName());
  1359 + map.put("lineCode", line.getLineCode());
  1360 + }
  1361 +
  1362 + if(!xlbm.equals("")){
  1363 + if(null!=line){
  1364 + if(!line.getLineCode().equals(xlbm)){
  1365 + fage=false;
  1366 + }
  1367 + }
  1368 +
  1369 + }
  1370 +
  1371 + if(!gsbm.equals("")){
  1372 + if(!clgsdm.equals(gsbm)){
  1373 + fage=false;
  1374 + }
  1375 + }
  1376 +
  1377 + if(fage){
  1378 + list.add(map);
  1379 + }
  1380 +
  1381 + }
  1382 +
  1383 + if (list.size() > 20)
  1384 + break;
  1385 + }
  1386 + return list;
  1387 + }
  1388 +
  1389 +
  1390 + @Override
  1391 + public List<Map<String, String>> userList(Map<String, Object> maps) {
  1392 + // TODO Auto-generated method stub
  1393 + // 转大写
  1394 + String jsy =maps.get("jsy").toString().toUpperCase();
  1395 + String gsbm=maps.get("gsbm").toString().trim();
  1396 +// String fgsbm=maps.get("fgsbm").toString().trim();
  1397 + List<Map<String, String>> list = new ArrayList<Map<String, String>>();
  1398 + Map<String, String> map;
  1399 +// Set<String> allSet = BasicData.nbbm2CompanyCodeMap.keySet();
  1400 + Set<String> allJsy = BasicData.jsyMap.keySet();
  1401 +
  1402 + Personnel per;
  1403 + for (String k : allJsy) {
  1404 + if (k.indexOf(jsy) != -1) {
  1405 + // 所属线路
  1406 + boolean fage=true;
  1407 + map = new HashMap<>();
  1408 + per = BasicData.jsyMap.get(k);
  1409 + String rygsdm= per.getCompanyCode();
  1410 +
  1411 + map.put("id", k);
  1412 + map.put("text", k+"/"+per.getPersonnelName());
  1413 +
  1414 + if(!gsbm.equals("")){
  1415 + if(!rygsdm.equals(gsbm)){
  1416 + fage=false;
  1417 + }
  1418 + }
  1419 +
  1420 + if(fage){
  1421 + list.add(map);
  1422 + }
  1423 +
  1424 + }
  1425 +
  1426 + if (list.size() > 20)
  1427 + break;
  1428 + }
  1429 + return list;
  1430 + }
1062 } 1431 }
src/main/java/com/bsth/service/schedule/SchedulePlanRuleResultService.java 0 → 100644
  1 +package com.bsth.service.schedule;
  2 +
  3 +import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;
  4 +
  5 +/**
  6 + * Created by xu on 17/3/29.
  7 + */
  8 +public interface SchedulePlanRuleResultService extends BService<SchedulePlanRuleResult, Long> {
  9 +}
src/main/java/com/bsth/service/schedule/impl/SchedulePlanRuleResultServiceImpl.java 0 → 100644
  1 +package com.bsth.service.schedule.impl;
  2 +
  3 +import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;
  4 +import com.bsth.service.schedule.SchedulePlanRuleResultService;
  5 +import org.springframework.stereotype.Service;
  6 +
  7 +/**
  8 + * Created by xu on 17/3/29.
  9 + */
  10 +@Service
  11 +public class SchedulePlanRuleResultServiceImpl extends BServiceImpl<SchedulePlanRuleResult, Long> implements SchedulePlanRuleResultService {
  12 +}
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
1 package com.bsth.service.schedule.impl; 1 package com.bsth.service.schedule.impl;
2 2
3 -import com.bsth.entity.Line;  
4 import com.bsth.entity.schedule.SchedulePlan; 3 import com.bsth.entity.schedule.SchedulePlan;
5 import com.bsth.entity.schedule.TTInfo; 4 import com.bsth.entity.schedule.TTInfo;
6 import com.bsth.entity.schedule.rule.ScheduleRule1Flat; 5 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
7 -import com.bsth.repository.schedule.SchedulePlanInfoRepository;  
8 -import com.bsth.repository.schedule.SchedulePlanRepository;  
9 -import com.bsth.service.BusinessService;  
10 -import com.bsth.service.LineService;  
11 -import com.bsth.service.schedule.*; 6 +import com.bsth.repository.BusinessRepository;
  7 +import com.bsth.repository.LineRepository;
  8 +import com.bsth.repository.schedule.*;
  9 +import com.bsth.service.schedule.SchedulePlanRuleResultService;
  10 +import com.bsth.service.schedule.SchedulePlanService;
12 import com.bsth.service.schedule.rules.plan.PlanCalcuParam_input; 11 import com.bsth.service.schedule.rules.plan.PlanCalcuParam_input;
13 import com.bsth.service.schedule.rules.plan.PlanResult; 12 import com.bsth.service.schedule.rules.plan.PlanResult;
14 import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input; 13 import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input;
15 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; 14 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
16 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input; 15 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
17 -import com.bsth.service.schedule.rules.strategy.IStrategy;  
18 import com.bsth.service.schedule.rules.ttinfo.*; 16 import com.bsth.service.schedule.rules.ttinfo.*;
19 import com.bsth.service.schedule.rules.ttinfo2.CalcuParam; 17 import com.bsth.service.schedule.rules.ttinfo2.CalcuParam;
20 import com.bsth.service.schedule.rules.ttinfo2.Result; 18 import com.bsth.service.schedule.rules.ttinfo2.Result;
@@ -28,7 +26,6 @@ import org.springframework.stereotype.Service; @@ -28,7 +26,6 @@ import org.springframework.stereotype.Service;
28 import org.springframework.transaction.annotation.Isolation; 26 import org.springframework.transaction.annotation.Isolation;
29 import org.springframework.transaction.annotation.Propagation; 27 import org.springframework.transaction.annotation.Propagation;
30 import org.springframework.transaction.annotation.Transactional; 28 import org.springframework.transaction.annotation.Transactional;
31 -import org.springframework.util.CollectionUtils;  
32 29
33 import java.util.*; 30 import java.util.*;
34 31
@@ -40,75 +37,49 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -40,75 +37,49 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
40 @Autowired 37 @Autowired
41 private KieBase kieBase; 38 private KieBase kieBase;
42 @Autowired 39 @Autowired
43 - private IStrategy strategy; 40 + private SchedulePlanInfoRepository schedulePlanInfoRepository;
44 @Autowired 41 @Autowired
45 - private SchedulePlanRepository schedulePlanRepository; 42 + private ScheduleRule1FlatRepository scheduleRule1FlatRepository;
46 @Autowired 43 @Autowired
47 - private SchedulePlanInfoRepository schedulePlanInfoRepository; 44 + private TTInfoRepository ttInfoRepository;
  45 + @Autowired
  46 + private TTInfoDetailRepository ttInfoDetailRepository;
48 @Autowired 47 @Autowired
49 - private LineService lineService; 48 + private LineRepository lineRepository;
50 @Autowired 49 @Autowired
51 - private TTInfoService ttInfoService; 50 + private CarConfigInfoRepository carConfigInfoRepository;
52 @Autowired 51 @Autowired
53 - private TTInfoDetailService ttInfoDetailService; 52 + private EmployeeConfigInfoRepository employeeConfigInfoRepository;
54 @Autowired 53 @Autowired
55 - private BusinessService businessService; 54 + private BusinessRepository businessRepository;
56 @Autowired 55 @Autowired
57 - private CarConfigInfoService carConfigInfoService; 56 + private SchedulePlanRuleResultService schedulePlanRuleResultService;
58 @Autowired 57 @Autowired
59 - private EmployeeConfigInfoService employeeConfigInfoService; 58 + private SchedulePlanRuleResultRepository schedulePlanRuleResultRepository;
60 59
61 /** 日志记录器 */ 60 /** 日志记录器 */
62 private Logger logger = LoggerFactory.getLogger(SchedulePlanServiceImpl.class); 61 private Logger logger = LoggerFactory.getLogger(SchedulePlanServiceImpl.class);
63 62
64 - // 查找线路(未撤销),TODO:到时候放入drl中  
65 - private Line getLine(Integer xlId) {  
66 - Map<String, Object> param = new HashMap<>();  
67 - param.put("id_eq", xlId);  
68 - param.put("destroy_eq", 0); // 未撤销  
69 - List<Line> lines = (List<Line>) lineService.list(param);  
70 - if (CollectionUtils.isEmpty(lines)) {  
71 - throw new RuntimeException("线路找不到,可能已经撤销!");  
72 - }  
73 - return lines.get(0);  
74 - }  
75 - // 查找时刻表(未作废),TODO:到时候放入drl中  
76 - private List<TTInfo> getTTInfos(Integer xlId) {  
77 - // 查询参数  
78 - Map<String, Object> param = new HashMap<>();  
79 - param.put("xl.id_eq", xlId); // 线路Id  
80 - param.put("isCancel_eq", false); // 作废的过滤掉  
81 - Iterator<TTInfo> ttInfoIterator = ttInfoService.list(param).iterator();  
82 - if (!ttInfoIterator.hasNext()) {  
83 - throw new RuntimeException("线路id=" + xlId + " 没有时刻表!");  
84 - }  
85 - List<TTInfo> ttInfos = new ArrayList<>();  
86 - while (ttInfoIterator.hasNext()) {  
87 - TTInfo ttInfo = ttInfoIterator.next();  
88 - ttInfos.add(ttInfo);  
89 - }  
90 - return ttInfos;  
91 - }  
92 -  
93 /** 63 /**
94 * 循环规则输出。 64 * 循环规则输出。
95 - * @param schedulePlan 65 + * @param schedulePlan 排班计划对象
  66 + * @param lpInfoResults_output 时刻表每日路牌的情况
96 */ 67 */
97 - private ScheduleResults_output loopRuleOutput(SchedulePlan schedulePlan, LpInfoResults_output lpInfoResults_output) {  
98 - // 获取主线路  
99 - Line xl = strategy.getLine(schedulePlan.getXl().getId());  
100 - 68 + private ScheduleResults_output loopRuleOutput(
  69 + SchedulePlan schedulePlan,
  70 + LpInfoResults_output lpInfoResults_output) {
101 // 1-1、构造drools规则输入数据,输出数据 71 // 1-1、构造drools规则输入数据,输出数据
102 // 全局计算参数 72 // 全局计算参数
103 ScheduleCalcuParam_input scheduleCalcuParam_input = new ScheduleCalcuParam_input(schedulePlan); 73 ScheduleCalcuParam_input scheduleCalcuParam_input = new ScheduleCalcuParam_input(schedulePlan);
104 // 每个规则对应的输入参数 74 // 每个规则对应的输入参数
105 List<ScheduleRule_input> scheduleRule_inputs = new ArrayList<>(); 75 List<ScheduleRule_input> scheduleRule_inputs = new ArrayList<>();
106 - Iterator<ScheduleRule1Flat> scheduleRule1FlatIterator = strategy.getScheduleRule(xl.getId()).iterator();  
107 - while (scheduleRule1FlatIterator.hasNext()) {  
108 - ScheduleRule1Flat scheduleRule1Flat_temp = scheduleRule1FlatIterator.next();  
109 - ScheduleRule_input scheduleRule_input = new ScheduleRule_input(scheduleRule1Flat_temp); 76 + List<ScheduleRule1Flat> scheduleRule1Flats = scheduleRule1FlatRepository.findByXl(schedulePlan.getXl());
  77 +
  78 + for (ScheduleRule1Flat scheduleRule1Flat: scheduleRule1Flats) {
  79 + ScheduleRule_input scheduleRule_input = new ScheduleRule_input(scheduleRule1Flat);
110 scheduleRule_inputs.add(scheduleRule_input); 80 scheduleRule_inputs.add(scheduleRule_input);
111 } 81 }
  82 +
112 // 规则输出数据 83 // 规则输出数据
113 ScheduleResults_output scheduleResults_output = new ScheduleResults_output(); 84 ScheduleResults_output scheduleResults_output = new ScheduleResults_output();
114 85
@@ -118,12 +89,14 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -118,12 +89,14 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
118 // 设置gloable对象,在drl中通过别名使用 89 // 设置gloable对象,在drl中通过别名使用
119 session.setGlobal("scheduleResult", scheduleResults_output); 90 session.setGlobal("scheduleResult", scheduleResults_output);
120 session.setGlobal("log", logger); // 设置日志 91 session.setGlobal("log", logger); // 设置日志
  92 + session.setGlobal("schedulePlanRuleResultRepository", schedulePlanRuleResultRepository);
121 93
122 // 载入数据 94 // 载入数据
123 session.insert(scheduleCalcuParam_input); 95 session.insert(scheduleCalcuParam_input);
124 for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) { 96 for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) {
125 session.insert(scheduleRule_input); 97 session.insert(scheduleRule_input);
126 } 98 }
  99 + // 每日时刻表路牌数据
127 for (LpInfoResult_output lpInfoResult_output: lpInfoResults_output.getLpInfoResult_outputs()) { 100 for (LpInfoResult_output lpInfoResult_output: lpInfoResults_output.getLpInfoResult_outputs()) {
128 session.insert(lpInfoResult_output); 101 session.insert(lpInfoResult_output);
129 } 102 }
@@ -140,12 +113,12 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -140,12 +113,12 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
140 113
141 /** 114 /**
142 * 时刻表选择(判定每天使用的时刻表,以及路牌数据输出)。 115 * 时刻表选择(判定每天使用的时刻表,以及路牌数据输出)。
143 - * @param schedulePlan 116 + * @param schedulePlan 排班计划对象
144 * @return TTInfoResults_output, LpInfoResults_output 117 * @return TTInfoResults_output, LpInfoResults_output
145 */ 118 */
146 private Object[] ttInfoOutput(SchedulePlan schedulePlan) { 119 private Object[] ttInfoOutput(SchedulePlan schedulePlan) {
147 // 获取线路的所有未作废的时刻表 120 // 获取线路的所有未作废的时刻表
148 - List<TTInfo> ttInfos = getTTInfos(schedulePlan.getXl().getId()); 121 + List<TTInfo> ttInfos = ttInfoRepository.findInCanceledByXl(schedulePlan.getXl());
149 122
150 // 1-1、构造drools规则输入数据,输出数据 123 // 1-1、构造drools规则输入数据,输出数据
151 // 全局计算参数 124 // 全局计算参数
@@ -167,8 +140,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -167,8 +140,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
167 session.setGlobal("results", ttInfoResults_output); 140 session.setGlobal("results", ttInfoResults_output);
168 session.setGlobal("lpInfoResults_output", lpInfoResults_output); 141 session.setGlobal("lpInfoResults_output", lpInfoResults_output);
169 session.setGlobal("log", logger); // 设置日志 142 session.setGlobal("log", logger); // 设置日志
170 -  
171 - session.setGlobal("tTInfoDetailService", ttInfoDetailService); 143 + session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository);
172 144
173 // 载入数据 145 // 载入数据
174 session.insert(ttInfoCalcuParam_input); 146 session.insert(ttInfoCalcuParam_input);
@@ -177,12 +149,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -177,12 +149,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
177 session.insert(ttInfo_input); 149 session.insert(ttInfo_input);
178 } 150 }
179 151
  152 + // 载入数据2(计算规则最早启用时间)
  153 + List<ScheduleRule1Flat> scheduleRule1Flats = scheduleRule1FlatRepository.findByXl(schedulePlan.getXl());
180 154
181 - // 载入数据2  
182 - Iterator<ScheduleRule1Flat> scheduleRule1FlatIterator = strategy.getScheduleRule(schedulePlan.getXl().getId()).iterator();  
183 - while (scheduleRule1FlatIterator.hasNext()) {  
184 - ScheduleRule1Flat scheduleRule1Flat_temp = scheduleRule1FlatIterator.next();  
185 - ScheduleRule_input scheduleRule_input = new ScheduleRule_input(scheduleRule1Flat_temp); 155 + for (ScheduleRule1Flat scheduleRule1Flat: scheduleRule1Flats) {
  156 + ScheduleRule_input scheduleRule_input = new ScheduleRule_input(scheduleRule1Flat);
186 session.insert(scheduleRule_input); 157 session.insert(scheduleRule_input);
187 } 158 }
188 159
@@ -196,6 +167,13 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -196,6 +167,13 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
196 167
197 } 168 }
198 169
  170 + /**
  171 + * 排班生成。
  172 + * @param schedulePlan 排班计划对象
  173 + * @param scheduleResults_output loopRuleOutput方法规则输出
  174 + * @param ttInfoResults_output ttInfoOutput方法规则输出
  175 + * @return PlanResult
  176 + */
199 private PlanResult planResultOutput( 177 private PlanResult planResultOutput(
200 SchedulePlan schedulePlan, 178 SchedulePlan schedulePlan,
201 ScheduleResults_output scheduleResults_output, 179 ScheduleResults_output scheduleResults_output,
@@ -216,14 +194,14 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -216,14 +194,14 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
216 194
217 // 设置gloable对象,在drl中通过别名使用 195 // 设置gloable对象,在drl中通过别名使用
218 session.setGlobal("planResult", planResult); 196 session.setGlobal("planResult", planResult);
219 - session.setGlobal("tTInfoService", ttInfoService);  
220 - session.setGlobal("tTInfoDetailService", ttInfoDetailService);  
221 - session.setGlobal("carConfigInfoService", carConfigInfoService);  
222 - session.setGlobal("employeeConfigInfoService", employeeConfigInfoService);  
223 - session.setGlobal("lineService", lineService);  
224 - session.setGlobal("businessService", businessService);  
225 session.setGlobal("log", logger); // 设置日志 197 session.setGlobal("log", logger); // 设置日志
226 198
  199 + session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository);
  200 + session.setGlobal("carConfigInfoRepository", carConfigInfoRepository);
  201 + session.setGlobal("employeeConfigInfoRepository", employeeConfigInfoRepository);
  202 + session.setGlobal("lineRepository", lineRepository);
  203 + session.setGlobal("businessRepository", businessRepository);
  204 +
227 // 载入数据 205 // 载入数据
228 session.insert(planCalcuParam_input); 206 session.insert(planCalcuParam_input);
229 207
@@ -238,207 +216,30 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -238,207 +216,30 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
238 } 216 }
239 217
240 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) 218 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
241 - public SchedulePlan save2(SchedulePlan schedulePlan) { 219 + public SchedulePlan save(SchedulePlan schedulePlan) {
  220 + // pre、如果排班的数据之前已经有了,删除之前的数据
  221 + schedulePlanInfoRepository.deleteByXlAndScheduleDateGreaterThanEqualAndScheduleDateLessThanEqual(
  222 + schedulePlan.getXl().getId(), schedulePlan.getScheduleFromTime(), schedulePlan.getScheduleToTime()
  223 + );
  224 +
242 // 1、时刻表数据及每日路牌数据计算 225 // 1、时刻表数据及每日路牌数据计算
243 Object[] ttInfoRets = ttInfoOutput(schedulePlan); 226 Object[] ttInfoRets = ttInfoOutput(schedulePlan);
244 TTInfoResults_output ttInfoResults_output = (TTInfoResults_output) ttInfoRets[0]; 227 TTInfoResults_output ttInfoResults_output = (TTInfoResults_output) ttInfoRets[0];
245 LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1]; 228 LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1];
246 -  
247 // 2、循环规则计算输出 229 // 2、循环规则计算输出
248 ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan, lpInfoResults_output); 230 ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan, lpInfoResults_output);
249 -  
250 // 3、计划输出 231 // 3、计划输出
251 PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output); 232 PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output);
252 233
253 - schedulePlan.setTtInfoId("todo"); // TODO:待修正  
254 - schedulePlan.setTtInfoNames("todo"); // TODO:待修正  
255 - 234 + // 4、保存数据(TODO:之后改成批量保存)
256 schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos()); 235 schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos());
257 -  
258 super.save(schedulePlan); 236 super.save(schedulePlan);
259 237
260 -  
261 -  
262 -// // 1、循环规则计算输出  
263 -// ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan);  
264 -// // 2、时刻表选择  
265 -// TTInfoResults_output ttInfoResults_output = ttInfoOutput(schedulePlan);  
266 -// // 3、计划输出  
267 -// PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output);  
268 -//  
269 -// schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos());  
270 -// schedulePlan.setTtInfoId("todo"); // TODO:待修正  
271 -// schedulePlan.setTtInfoNames("todo"); // TODO:待修正  
272 -//  
273 -// super.save(schedulePlan); 238 + schedulePlanRuleResultService.bulkSave(scheduleResults_output.getSchedulePlanRuleResults());
274 239
275 return new SchedulePlan(); 240 return new SchedulePlan();
276 } 241 }
277 242
278 - @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)  
279 - public SchedulePlan save(SchedulePlan schedulePlan) {  
280 - // 2-3、如果排班的数据之前已经有了,删除之前的数据  
281 - schedulePlanInfoRepository.deleteByXlAndScheduleDateGreaterThanEqualAndScheduleDateLessThanEqual(  
282 - schedulePlan.getXl().getId(), schedulePlan.getScheduleFromTime(), schedulePlan.getScheduleToTime()  
283 - );  
284 -  
285 - // 测试  
286 - return save2(schedulePlan);  
287 -  
288 -// // 1-1、查找线路具体信息  
289 -// Line xl = strategy.getLine(schedulePlan.getXl().getId());  
290 -// // 1-2、查出指定线路的所有规则  
291 -// TTInfo ttInfo = strategy.getTTInfo(xl.getId()).get(0); // 时刻表id  
292 -// schedulePlan.setTtInfo(ttInfo); // TODO:关联的时刻表,之后改掉  
293 -//  
294 -// // 2-1、构造drools规则输入数据,输出数据  
295 -// // 全局计算参数  
296 -// ScheduleCalcuParam_input scheduleCalcuParam_input = new ScheduleCalcuParam_input(schedulePlan);  
297 -// // 每个规则对应的输入参数  
298 -// List<ScheduleRule_input> scheduleRule_inputs = new ArrayList<>();  
299 -// Iterator<ScheduleRule1Flat> scheduleRule1FlatIterator = strategy.getScheduleRule(xl.getId()).iterator();  
300 -// while (scheduleRule1FlatIterator.hasNext()) {  
301 -// ScheduleRule1Flat scheduleRule1Flat_temp = scheduleRule1FlatIterator.next();  
302 -// ScheduleRule_input scheduleRule_input = new ScheduleRule_input(scheduleRule1Flat_temp);  
303 -// scheduleRule_inputs.add(scheduleRule_input);  
304 -// }  
305 -// // 规则输出数据  
306 -// ScheduleResults_output scheduleResults_output = new ScheduleResults_output();  
307 -//  
308 -// // 2-2、构造drools session->载入数据->启动规则->计算->销毁session  
309 -// // 创建session,内部配置的是stateful  
310 -// KieSession session = kieBase.newKieSession();  
311 -// // 设置gloable对象,在drl中通过别名使用  
312 -// session.setGlobal("scheduleResult", scheduleResults_output);  
313 -// session.setGlobal("log", logger); // 设置日志  
314 -//  
315 -// // 载入数据  
316 -// session.insert(scheduleCalcuParam_input);  
317 -// for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) {  
318 -// session.insert(scheduleRule_input);  
319 -// }  
320 -// // 执行rule  
321 -// session.fireAllRules();  
322 -//  
323 -// // 执行完毕销毁,有日志的也要关闭  
324 -// session.dispose();  
325 -//  
326 -// System.out.println(scheduleResults_output.showGuideboardDesc1());  
327 -//  
328 -// // 2-3、如果排班的数据之前已经有了,删除之前的数据  
329 -// schedulePlanInfoRepository.deleteByXlAndScheduleDateGreaterThanEqualAndScheduleDateLessThanEqual(  
330 -// xl.getId(), schedulePlan.getScheduleFromTime(), schedulePlan.getScheduleToTime()  
331 -// );  
332 -//  
333 -// // 3、根据规则返回,组合最后的输出数据  
334 -// // 3-1、根据注入的策略服务,获取原始数据  
335 -// Map<Date, Multimap<Long, TTInfoDetail>> gbdTTinfoMaps = strategy.getGuideboardXlTTInfoDetailMaps(  
336 -// xl.getId(), schedulePlan.getScheduleFromTime(), schedulePlan.getScheduleToTime());  
337 -//  
338 -// Map<Long, CarConfigInfo> carConfigMaps = strategy.getCarConfigMaps(xl.getId()); // 车辆配置对应车辆信息  
339 -// Map<Long, EmployeeConfigInfo> employeeConfigMaps = strategy.getEmployeeConfigMaps(xl.getId()); // 人员配置对应的人员信息  
340 -//  
341 -// // 3-2、循环规则输出  
342 -// Map<Long, String> ttInfoMap = new HashMap<>(); // 时刻表映射,id和名字  
343 -// List<SchedulePlanInfo> schedulePlanInfos = new ArrayList<>();  
344 -// for (ScheduleResult_output scheduleResult_output : scheduleResults_output.getResults()) {  
345 -// // 车辆配置对应的车辆  
346 -// CarConfigInfo configInfo = carConfigMaps.get(Long.valueOf(scheduleResult_output.getCarConfigId()));  
347 -// // 人员配置对应的人员,这里需要分班处理的  
348 -// List<EmployeeConfigInfo> employeeConfigInfoList = new ArrayList<>();  
349 -// String[] eids = scheduleResult_output.getEmployeeConfigId().split("-");  
350 -// for (String eid : eids) {  
351 -// employeeConfigInfoList.add(employeeConfigMaps.get(Long.valueOf(eid)));  
352 -// }  
353 -// // 排班明细(这个要迭代的)  
354 -// Collection<TTInfoDetail> ttInfoDetails_ = gbdTTinfoMaps.get(scheduleResult_output.getSd().toDate()).get(  
355 -// Long.parseLong(scheduleResult_output.getGuideboardId()));  
356 -// List<TTInfoDetail> ttInfoDetails = new ArrayList<>(ttInfoDetails_);  
357 -//  
358 -// // 排序ttInfoDetails  
359 -// Collections.sort(ttInfoDetails, new Comparator<TTInfoDetail>() {  
360 -// @Override  
361 -// public int compare(TTInfoDetail o1, TTInfoDetail o2) {  
362 -// return o1.getFcno().compareTo(o2.getFcno());  
363 -// }  
364 -// });  
365 -//  
366 -// Boolean isFb = false; // 是否分班  
367 -// for (int i = 0; i < ttInfoDetails.size(); i++) {  
368 -// TTInfoDetail ttInfoDetail = ttInfoDetails.get(i);  
369 -//  
370 -// if (ttInfoDetail.getIsFB())  
371 -// isFb = ttInfoDetail.getIsFB();  
372 -//  
373 -// SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo(  
374 -// xl,  
375 -// scheduleResult_output,  
376 -// ttInfoDetail,  
377 -// isFb,  
378 -// configInfo,  
379 -// employeeConfigInfoList,  
380 -// schedulePlan,  
381 -// i == 0,  
382 -// i == ttInfoDetails.size() - 1);  
383 -//  
384 -// // 获取公司,分公司信息  
385 -// String gsbm = xl.getCompany();  
386 -// String fgsbm = xl.getBrancheCompany();  
387 -// Business gs = null;  
388 -// Business fgs = null;  
389 -//  
390 -// Map<String, Object> param = new HashMap<>();  
391 -//  
392 -// if (StringUtils.isNotEmpty(gsbm)) {  
393 -// param.clear();  
394 -// param.put("businessCode_eq", gsbm);  
395 -// Iterator<Business> businessIterator = businessService.list(param).iterator();  
396 -// if (businessIterator.hasNext()) {  
397 -// gs = businessIterator.next();  
398 -// }  
399 -// }  
400 -// if (StringUtils.isNotEmpty(gsbm) && StringUtils.isNotEmpty(fgsbm)) {  
401 -// param.clear();;  
402 -// param.put("upCode_eq", gsbm);  
403 -// param.put("businessCode_eq", fgsbm);  
404 -// Iterator<Business> businessIterator = businessService.list(param).iterator();  
405 -// if (businessIterator.hasNext()) {  
406 -// fgs = businessIterator.next();  
407 -// }  
408 -// }  
409 -//  
410 -// if (gs != null) {  
411 -// schedulePlanInfo.setGsBm(gs.getBusinessCode());  
412 -// schedulePlanInfo.setGsName(gs.getBusinessName());  
413 -// }  
414 -// if (fgs != null) {  
415 -// schedulePlanInfo.setFgsBm(fgs.getBusinessCode());  
416 -// schedulePlanInfo.setFgsName(fgs.getBusinessName());  
417 -// }  
418 -//  
419 -// // 操作人,操作时间  
420 -// schedulePlanInfo.setCreateBy(schedulePlan.getCreateBy());  
421 -// schedulePlanInfo.setCreateDate(schedulePlan.getCreateDate());  
422 -// schedulePlanInfo.setUpdateBy(schedulePlan.getUpdateBy());  
423 -// schedulePlanInfo.setUpdateDate(schedulePlan.getUpdateDate());  
424 -//  
425 -// schedulePlanInfos.add(schedulePlanInfo);  
426 -// ttInfoMap.put(ttInfoDetail.getTtinfo().getId(), ttInfoDetail.getTtinfo().getName());  
427 -//  
428 -// }  
429 -//  
430 -// }  
431 -//  
432 -// schedulePlan.setTtInfoId(StringUtils.join(ttInfoMap.keySet(), ","));  
433 -// schedulePlan.setTtInfoNames(StringUtils.join(ttInfoMap.values(), ","));  
434 -//  
435 -// // 3-2、保存生成的排班和明细  
436 -// schedulePlan.getSchedulePlanInfoList().addAll(schedulePlanInfos); // 关联的排班明细信息  
437 -// super.save(schedulePlan);  
438 -//  
439 -// return new SchedulePlan();  
440 - }  
441 -  
442 @Override 243 @Override
443 public SchedulePlan findSchedulePlanTommorw() { 244 public SchedulePlan findSchedulePlanTommorw() {
444 DateTime today = new DateTime(new Date()); 245 DateTime today = new DateTime(new Date());
@@ -460,8 +261,8 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -460,8 +261,8 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
460 KieSession session = kieBase.newKieSession(); 261 KieSession session = kieBase.newKieSession();
461 // 设置gloable对象,在drl中通过别名使用 262 // 设置gloable对象,在drl中通过别名使用
462 session.setGlobal("log", logger); 263 session.setGlobal("log", logger);
463 - session.setGlobal("lineService", lineService);  
464 - session.setGlobal("ttInfoDetailService", ttInfoDetailService); 264 + session.setGlobal("lineRepository", lineRepository);
  265 + session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository);
465 266
466 Result rs = new Result(); // 输出gloable对象 267 Result rs = new Result(); // 输出gloable对象
467 session.setGlobal("rs", rs); 268 session.setGlobal("rs", rs);
@@ -470,11 +271,10 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -470,11 +271,10 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
470 CalcuParam calcuParam = new CalcuParam( 271 CalcuParam calcuParam = new CalcuParam(
471 new DateTime(from), new DateTime(to), xlid); 272 new DateTime(from), new DateTime(to), xlid);
472 session.insert(calcuParam); 273 session.insert(calcuParam);
473 - List<TTInfo> ttInfos = ttInfoService.findAll(); 274 + List<TTInfo> ttInfos = (List<TTInfo>) ttInfoRepository.findAll();
474 for (TTInfo ttInfo: ttInfos) 275 for (TTInfo ttInfo: ttInfos)
475 session.insert(ttInfo); 276 session.insert(ttInfo);
476 277
477 -  
478 // 执行rule 278 // 执行rule
479 session.fireAllRules(); 279 session.fireAllRules();
480 280
src/main/java/com/bsth/service/schedule/rules/Message.java deleted 100644 → 0
1 -package com.bsth.service.schedule.rules;  
2 -  
3 -/**  
4 - * Created by xu on 16/6/15.  
5 - */  
6 -public class Message {  
7 - public static final int HELLO = 0;  
8 - public static final int GOODBYE = 1;  
9 -  
10 - private String message;  
11 - private int status;  
12 - public String getMessage() {  
13 - return message;  
14 - }  
15 - public void setMessage(String message) {  
16 - this.message = message;  
17 - }  
18 - public int getStatus() {  
19 - return status;  
20 - }  
21 - public void setStatus(int status) {  
22 - this.status = status;  
23 - }  
24 -}  
src/main/java/com/bsth/service/schedule/rules/MyDroolsConfiguration.java
@@ -55,9 +55,6 @@ public class MyDroolsConfiguration { @@ -55,9 +55,6 @@ public class MyDroolsConfiguration {
55 kfs.write("src/main/resources/functions.drl", kieServices.getResources() 55 kfs.write("src/main/resources/functions.drl", kieServices.getResources()
56 .newInputStreamResource(this.getClass().getResourceAsStream( 56 .newInputStreamResource(this.getClass().getResourceAsStream(
57 "/rules/functions.drl"), "UTF-8")); 57 "/rules/functions.drl"), "UTF-8"));
58 - kfs.write("src/main/resources/HelloWorld.drl", kieServices.getResources()  
59 - .newInputStreamResource(this.getClass().getResourceAsStream(  
60 - "/rules/HelloWorld.drl"), "UTF-8"));  
61 kfs.write("src/main/resources/shiftloop_fb_2.drl", kieServices.getResources() 58 kfs.write("src/main/resources/shiftloop_fb_2.drl", kieServices.getResources()
62 .newInputStreamResource(this.getClass().getResourceAsStream( 59 .newInputStreamResource(this.getClass().getResourceAsStream(
63 "/rules/shiftloop_fb_2.drl"), "UTF-8")); 60 "/rules/shiftloop_fb_2.drl"), "UTF-8"));
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleCalcuParam_input.java
@@ -12,11 +12,20 @@ public class ScheduleCalcuParam_input { @@ -12,11 +12,20 @@ public class ScheduleCalcuParam_input {
12 /** 结束计算日期 */ 12 /** 结束计算日期 */
13 private DateTime toDate; 13 private DateTime toDate;
14 14
  15 + /** 线路Id */
  16 + private String xlId;
  17 +
  18 + /** 排班计划实体 */
  19 + private SchedulePlan schedulePlan;
  20 +
15 public ScheduleCalcuParam_input() {} 21 public ScheduleCalcuParam_input() {}
16 22
17 public ScheduleCalcuParam_input(SchedulePlan schedulePlan) { 23 public ScheduleCalcuParam_input(SchedulePlan schedulePlan) {
18 this.fromDate = new DateTime((schedulePlan.getScheduleFromTime())); 24 this.fromDate = new DateTime((schedulePlan.getScheduleFromTime()));
19 this.toDate = new DateTime((schedulePlan.getScheduleToTime())); 25 this.toDate = new DateTime((schedulePlan.getScheduleToTime()));
  26 +
  27 + this.schedulePlan = schedulePlan;
  28 + this.xlId = String.valueOf(schedulePlan.getXl().getId());
20 } 29 }
21 30
22 public DateTime getFromDate() { 31 public DateTime getFromDate() {
@@ -35,4 +44,19 @@ public class ScheduleCalcuParam_input { @@ -35,4 +44,19 @@ public class ScheduleCalcuParam_input {
35 this.toDate = toDate; 44 this.toDate = toDate;
36 } 45 }
37 46
  47 + public SchedulePlan getSchedulePlan() {
  48 + return schedulePlan;
  49 + }
  50 +
  51 + public void setSchedulePlan(SchedulePlan schedulePlan) {
  52 + this.schedulePlan = schedulePlan;
  53 + }
  54 +
  55 + public String getXlId() {
  56 + return xlId;
  57 + }
  58 +
  59 + public void setXlId(String xlId) {
  60 + this.xlId = xlId;
  61 + }
38 } 62 }
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleResults_output.java
1 package com.bsth.service.schedule.rules.shiftloop; 1 package com.bsth.service.schedule.rules.shiftloop;
2 2
  3 +import com.bsth.entity.schedule.temp.SchedulePlanRuleResult;
3 import org.apache.commons.lang3.StringUtils; 4 import org.apache.commons.lang3.StringUtils;
4 5
5 import java.util.*; 6 import java.util.*;
@@ -11,6 +12,17 @@ public class ScheduleResults_output { @@ -11,6 +12,17 @@ public class ScheduleResults_output {
11 /** 输出列表 */ 12 /** 输出列表 */
12 private List<ScheduleResult_output> results = new ArrayList<>(); 13 private List<ScheduleResult_output> results = new ArrayList<>();
13 14
  15 + /** 排班规则结果保存数据 */
  16 + private List<SchedulePlanRuleResult> schedulePlanRuleResults = new ArrayList<>();
  17 +
  18 + public List<SchedulePlanRuleResult> getSchedulePlanRuleResults() {
  19 + return schedulePlanRuleResults;
  20 + }
  21 +
  22 + public void setSchedulePlanRuleResults(List<SchedulePlanRuleResult> schedulePlanRuleResults) {
  23 + this.schedulePlanRuleResults = schedulePlanRuleResults;
  24 + }
  25 +
14 public List<ScheduleResult_output> getResults() { 26 public List<ScheduleResult_output> getResults() {
15 return results; 27 return results;
16 } 28 }
src/main/java/com/bsth/service/schedule/rules/shiftloop/ScheduleRule_input.java
@@ -36,6 +36,9 @@ public class ScheduleRule_input { @@ -36,6 +36,9 @@ public class ScheduleRule_input {
36 /** 车辆翻版(周一到周日是否启用) */ 36 /** 车辆翻版(周一到周日是否启用) */
37 private List<Boolean> weekdays = new ArrayList<>(); 37 private List<Boolean> weekdays = new ArrayList<>();
38 38
  39 + /** 关联的原始规则 */
  40 + private ScheduleRule1Flat self;
  41 +
39 public ScheduleRule_input() {} 42 public ScheduleRule_input() {}
40 43
41 public ScheduleRule_input(ScheduleRule1Flat scheduleRule1Flat) { 44 public ScheduleRule_input(ScheduleRule1Flat scheduleRule1Flat) {
@@ -74,6 +77,8 @@ public class ScheduleRule_input { @@ -74,6 +77,8 @@ public class ScheduleRule_input {
74 weekdays.add(false); 77 weekdays.add(false);
75 } 78 }
76 } 79 }
  80 +
  81 + this.self = scheduleRule1Flat;
77 } 82 }
78 83
79 public String getRuleId() { 84 public String getRuleId() {
@@ -147,4 +152,12 @@ public class ScheduleRule_input { @@ -147,4 +152,12 @@ public class ScheduleRule_input {
147 public void setXlId(String xlId) { 152 public void setXlId(String xlId) {
148 this.xlId = xlId; 153 this.xlId = xlId;
149 } 154 }
  155 +
  156 + public ScheduleRule1Flat getSelf() {
  157 + return self;
  158 + }
  159 +
  160 + public void setSelf(ScheduleRule1Flat self) {
  161 + this.self = self;
  162 + }
150 } 163 }
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResult_output.java
@@ -14,6 +14,8 @@ public class LpInfoResult_output { @@ -14,6 +14,8 @@ public class LpInfoResult_output {
14 private String xlId; 14 private String xlId;
15 /** 时刻表Id */ 15 /** 时刻表Id */
16 private String ttInfoId; 16 private String ttInfoId;
  17 + /** 时刻表名字 */
  18 + private String ttInfoName;
17 19
18 public DateTime getDateTime() { 20 public DateTime getDateTime() {
19 return dateTime; 21 return dateTime;
@@ -46,4 +48,12 @@ public class LpInfoResult_output { @@ -46,4 +48,12 @@ public class LpInfoResult_output {
46 public void setTtInfoId(String ttInfoId) { 48 public void setTtInfoId(String ttInfoId) {
47 this.ttInfoId = ttInfoId; 49 this.ttInfoId = ttInfoId;
48 } 50 }
  51 +
  52 + public String getTtInfoName() {
  53 + return ttInfoName;
  54 + }
  55 +
  56 + public void setTtInfoName(String ttInfoName) {
  57 + this.ttInfoName = ttInfoName;
  58 + }
49 } 59 }
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResultsFunction.java
@@ -66,6 +66,7 @@ public class LpInfoResultsFunction implements AccumulateFunction { @@ -66,6 +66,7 @@ public class LpInfoResultsFunction implements AccumulateFunction {
66 lpInfoResult_output.setLpId(String.valueOf(ttInfoDetail.getLp().getId())); 66 lpInfoResult_output.setLpId(String.valueOf(ttInfoDetail.getLp().getId()));
67 lpInfoResult_output.setXlId(String.valueOf(ttInfoDetail.getXl().getId())); 67 lpInfoResult_output.setXlId(String.valueOf(ttInfoDetail.getXl().getId()));
68 lpInfoResult_output.setTtInfoId(String.valueOf(ttInfoDetail.getTtinfo().getId())); 68 lpInfoResult_output.setTtInfoId(String.valueOf(ttInfoDetail.getTtinfo().getId()));
  69 + lpInfoResult_output.setTtInfoName(ttInfoDetail.getTtinfo().getName());
69 70
70 lpInfoResultsData.lpInfoResult_outputMap.put( 71 lpInfoResultsData.lpInfoResult_outputMap.put(
71 ttInfoDetail.getLp().getId(), 72 ttInfoDetail.getLp().getId(),
src/main/java/com/bsth/util/Arith.java
@@ -20,9 +20,9 @@ public class Arith { @@ -20,9 +20,9 @@ public class Arith {
20 * @param v2 加数 20 * @param v2 加数
21 * @return 两个参数的和 21 * @return 两个参数的和
22 */ 22 */
23 - public static double add(double v1,double v2){  
24 - BigDecimal b1 = new BigDecimal(Double.toString(v1));  
25 - BigDecimal b2 = new BigDecimal(Double.toString(v2)); 23 + public static double add(Object v1,Object v2){
  24 + BigDecimal b1 = new BigDecimal(v1.toString());
  25 + BigDecimal b2 = new BigDecimal(v2.toString());
26 return b1.add(b2).doubleValue(); 26 return b1.add(b2).doubleValue();
27 } 27 }
28 28
@@ -32,9 +32,9 @@ public class Arith { @@ -32,9 +32,9 @@ public class Arith {
32 * @param v2 减数 32 * @param v2 减数
33 * @return 两个参数的差 33 * @return 两个参数的差
34 */ 34 */
35 - public static double sub(double v1,double v2){  
36 - BigDecimal b1 = new BigDecimal(Double.toString(v1));  
37 - BigDecimal b2 = new BigDecimal(Double.toString(v2)); 35 + public static double sub(Object v1,Object v2){
  36 + BigDecimal b1 = new BigDecimal(v1.toString());
  37 + BigDecimal b2 = new BigDecimal(v2.toString());
38 return b1.subtract(b2).doubleValue(); 38 return b1.subtract(b2).doubleValue();
39 } 39 }
40 40
@@ -44,9 +44,9 @@ public class Arith { @@ -44,9 +44,9 @@ public class Arith {
44 * @param v2 乘数 44 * @param v2 乘数
45 * @return 两个参数的积 45 * @return 两个参数的积
46 */ 46 */
47 - public static double mul(double v1,double v2){  
48 - BigDecimal b1 = new BigDecimal(Double.toString(v1));  
49 - BigDecimal b2 = new BigDecimal(Double.toString(v2)); 47 + public static double mul(Object v1,Object v2){
  48 + BigDecimal b1 = new BigDecimal(v1.toString());
  49 + BigDecimal b2 = new BigDecimal(v2.toString());
50 return b1.multiply(b2).doubleValue(); 50 return b1.multiply(b2).doubleValue();
51 } 51 }
52 52
@@ -57,7 +57,7 @@ public class Arith { @@ -57,7 +57,7 @@ public class Arith {
57 * @param v2 除数 57 * @param v2 除数
58 * @return 两个参数的商 58 * @return 两个参数的商
59 */ 59 */
60 - public static double div(double v1,double v2){ 60 + public static double div(Object v1,Object v2){
61 return div(v1,v2,DEF_DIV_SCALE); 61 return div(v1,v2,DEF_DIV_SCALE);
62 } 62 }
63 63
@@ -69,13 +69,13 @@ public class Arith { @@ -69,13 +69,13 @@ public class Arith {
69 * @param scale 表示表示需要精确到小数点以后几位。 69 * @param scale 表示表示需要精确到小数点以后几位。
70 * @return 两个参数的商 70 * @return 两个参数的商
71 */ 71 */
72 - public static double div(double v1,double v2,int scale){ 72 + public static double div(Object v1,Object v2,int scale){
73 if(scale<0){ 73 if(scale<0){
74 throw new IllegalArgumentException( 74 throw new IllegalArgumentException(
75 "The scale must be a positive integer or zero"); 75 "The scale must be a positive integer or zero");
76 } 76 }
77 - BigDecimal b1 = new BigDecimal(Double.toString(v1));  
78 - BigDecimal b2 = new BigDecimal(Double.toString(v2)); 77 + BigDecimal b1 = new BigDecimal(v1.toString());
  78 + BigDecimal b2 = new BigDecimal(v2.toString());
79 return b1.divide(b2,scale,BigDecimal.ROUND_HALF_UP).doubleValue(); 79 return b1.divide(b2,scale,BigDecimal.ROUND_HALF_UP).doubleValue();
80 } 80 }
81 81
@@ -85,12 +85,12 @@ public class Arith { @@ -85,12 +85,12 @@ public class Arith {
85 * @param scale 小数点后保留几位 85 * @param scale 小数点后保留几位
86 * @return 四舍五入后的结果 86 * @return 四舍五入后的结果
87 */ 87 */
88 - public static double round(double v,int scale){ 88 + public static double round(Object v,int scale){
89 if(scale<0){ 89 if(scale<0){
90 throw new IllegalArgumentException( 90 throw new IllegalArgumentException(
91 "The scale must be a positive integer or zero"); 91 "The scale must be a positive integer or zero");
92 } 92 }
93 - BigDecimal b = new BigDecimal(Double.toString(v)); 93 + BigDecimal b = new BigDecimal(v.toString());
94 BigDecimal one = new BigDecimal("1"); 94 BigDecimal one = new BigDecimal("1");
95 return b.divide(one,scale,BigDecimal.ROUND_HALF_UP).doubleValue(); 95 return b.divide(one,scale,BigDecimal.ROUND_HALF_UP).doubleValue();
96 } 96 }
@@ -100,8 +100,8 @@ public class Arith { @@ -100,8 +100,8 @@ public class Arith {
100 * @param v 需要被转换的数字 100 * @param v 需要被转换的数字
101 * @return 返回转换结果 101 * @return 返回转换结果
102 */ 102 */
103 - public static float convertsToFloat(double v){  
104 - BigDecimal b = new BigDecimal(v); 103 + public static float convertsToFloat(Object v){
  104 + BigDecimal b = new BigDecimal(v.toString());
105 return b.floatValue(); 105 return b.floatValue();
106 } 106 }
107 107
@@ -110,8 +110,8 @@ public class Arith { @@ -110,8 +110,8 @@ public class Arith {
110 * @param v 需要被转换的数字 110 * @param v 需要被转换的数字
111 * @return 返回转换结果 111 * @return 返回转换结果
112 */ 112 */
113 - public static int convertsToInt(double v){  
114 - BigDecimal b = new BigDecimal(v); 113 + public static int convertsToInt(Object v){
  114 + BigDecimal b = new BigDecimal(v.toString());
115 return b.intValue(); 115 return b.intValue();
116 } 116 }
117 117
@@ -120,8 +120,8 @@ public class Arith { @@ -120,8 +120,8 @@ public class Arith {
120 * @param v 需要被转换的数字 120 * @param v 需要被转换的数字
121 * @return 返回转换结果 121 * @return 返回转换结果
122 */ 122 */
123 - public static long convertsToLong(double v){  
124 - BigDecimal b = new BigDecimal(v); 123 + public static long convertsToLong(Object v){
  124 + BigDecimal b = new BigDecimal(v.toString());
125 return b.longValue(); 125 return b.longValue();
126 } 126 }
127 127
@@ -131,9 +131,9 @@ public class Arith { @@ -131,9 +131,9 @@ public class Arith {
131 * @param v2 需要被对比的第二个数 131 * @param v2 需要被对比的第二个数
132 * @return 返回两个数中大的一个值 132 * @return 返回两个数中大的一个值
133 */ 133 */
134 - public static double returnMax(double v1,double v2){  
135 - BigDecimal b1 = new BigDecimal(v1);  
136 - BigDecimal b2 = new BigDecimal(v2); 134 + public static double returnMax(Object v1,Object v2){
  135 + BigDecimal b1 = new BigDecimal(v1.toString());
  136 + BigDecimal b2 = new BigDecimal(v2.toString());
137 return b1.max(b2).doubleValue(); 137 return b1.max(b2).doubleValue();
138 } 138 }
139 139
@@ -143,9 +143,9 @@ public class Arith { @@ -143,9 +143,9 @@ public class Arith {
143 * @param v2 需要被对比的第二个数 143 * @param v2 需要被对比的第二个数
144 * @return 返回两个数中小的一个值 144 * @return 返回两个数中小的一个值
145 */ 145 */
146 - public static double returnMin(double v1,double v2){  
147 - BigDecimal b1 = new BigDecimal(v1);  
148 - BigDecimal b2 = new BigDecimal(v2); 146 + public static double returnMin(Object v1,Object v2){
  147 + BigDecimal b1 = new BigDecimal(v1.toString());
  148 + BigDecimal b2 = new BigDecimal(v2.toString());
149 return b1.min(b2).doubleValue(); 149 return b1.min(b2).doubleValue();
150 } 150 }
151 151
@@ -155,9 +155,9 @@ public class Arith { @@ -155,9 +155,9 @@ public class Arith {
155 * @param v2 需要被对比的第二个数 155 * @param v2 需要被对比的第二个数
156 * @return 如果两个数一样则返回0,如果第一个数比第二个数大则返回1,反之返回-1 156 * @return 如果两个数一样则返回0,如果第一个数比第二个数大则返回1,反之返回-1
157 */ 157 */
158 - public static int compareTo(double v1,double v2){  
159 - BigDecimal b1 = new BigDecimal(v1);  
160 - BigDecimal b2 = new BigDecimal(v2); 158 + public static int compareTo(Object v1,Object v2){
  159 + BigDecimal b1 = new BigDecimal(v1.toString());
  160 + BigDecimal b2 = new BigDecimal(v2.toString());
161 return b1.compareTo(b2); 161 return b1.compareTo(b2);
162 } 162 }
163 } 163 }
src/main/java/com/bsth/util/ComparableChild.java 0 → 100644
  1 +package com.bsth.util;
  2 +
  3 +import java.util.Comparator;
  4 +import java.util.List;
  5 +
  6 +import com.bsth.entity.realcontrol.ChildTaskPlan;
  7 +
  8 +public class ComparableChild implements Comparator<ChildTaskPlan>{
  9 +
  10 + @Override
  11 + public int compare(ChildTaskPlan o1, ChildTaskPlan o2) {
  12 + // TODO Auto-generated method stub
  13 + return o1.getStartDate().compareTo(o2.getStartDate());
  14 + }
  15 +
  16 +}
src/main/resources/application-dev.properties
@@ -7,13 +7,14 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy @@ -7,13 +7,14 @@ spring.jpa.hibernate.naming_strategy= org.hibernate.cfg.ImprovedNamingStrategy
7 #DATABASE 7 #DATABASE
8 spring.jpa.database= MYSQL 8 spring.jpa.database= MYSQL
9 spring.jpa.show-sql= true 9 spring.jpa.show-sql= true
10 -#spring.datasource.driver-class-name= com.mysql.jdbc.Driver 10 +spring.datasource.driver-class-name= com.mysql.jdbc.Driver
11 #spring.datasource.url= jdbc:mysql://192.168.168.201/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false 11 #spring.datasource.url= jdbc:mysql://192.168.168.201/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
12 #spring.datasource.username= root 12 #spring.datasource.username= root
13 #spring.datasource.password= 123456 13 #spring.datasource.password= 123456
14 spring.datasource.url= jdbc:mysql://localhost/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false 14 spring.datasource.url= jdbc:mysql://localhost/mh_control?useUnicode=true&characterEncoding=utf-8&useSSL=false
  15 +
15 spring.datasource.username= root 16 spring.datasource.username= root
16 -spring.datasource.password= root 17 +spring.datasource.password=
17 #DATASOURCE 18 #DATASOURCE
18 spring.datasource.max-active=100 19 spring.datasource.max-active=100
19 spring.datasource.max-idle=8 20 spring.datasource.max-idle=8