Commit d8d81bbe4b7bfe6d470e613b49009c63235cf7c4

Authored by 潘钊
2 parents 15705f25 ec87f635

Merge branch 'minhang' into pudong

Showing 34 changed files with 1644 additions and 887 deletions
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
... ... @@ -314,9 +314,9 @@ public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo,
314 314 }
315 315  
316 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 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 322 @RequestMapping(value="/findKMBCQp",method = RequestMethod.GET)
... ...
src/main/java/com/bsth/controller/report/ReportController.java
1 1 package com.bsth.controller.report;
2 2  
  3 +import java.util.HashMap;
3 4 import java.util.List;
4 5 import java.util.Map;
5 6  
... ... @@ -78,5 +79,23 @@ public class ReportController {
78 79 public List<Map<String,Object>> getTtinfo(@RequestParam Map<String, Object> map){
79 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 +
82 101 }
... ...
src/main/java/com/bsth/entity/schedule/SchedulePlan.java
1 1 package com.bsth.entity.schedule;
2 2  
3 3 import com.bsth.entity.Line;
4   -import com.bsth.entity.schedule.rule.ScheduleRule1;
5 4 import com.fasterxml.jackson.annotation.JsonIgnore;
6 5  
7 6 import javax.persistence.*;
... ... @@ -15,9 +14,8 @@ import java.util.List;
15 14 @Entity
16 15 @Table(name = "bsth_c_s_sp")
17 16 @NamedEntityGraphs({
18   - @NamedEntityGraph(name = "schedulePlan_xl_ttinfo", attributeNodes = {
  17 + @NamedEntityGraph(name = "schedulePlan_xl", attributeNodes = {
19 18 @NamedAttributeNode("xl"),
20   - @NamedAttributeNode("ttInfo")
21 19 })
22 20 })
23 21 public class SchedulePlan extends BEntity {
... ... @@ -30,22 +28,6 @@ public class SchedulePlan extends BEntity {
30 28 /** 关联的线路 */
31 29 @ManyToOne(optional = false, cascade = CascadeType.DETACH, fetch = FetchType.LAZY)
32 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 33 @Column(nullable = false)
... ... @@ -54,6 +36,11 @@ public class SchedulePlan extends BEntity {
54 36 @Column(nullable = false)
55 37 private Date scheduleToTime;
56 38  
  39 + /** 使用的时刻表名字列表(用逗号连接) */
  40 + private String ttInfoNames;
  41 + /** 使用的时刻表id列表(用逗号连接) */
  42 + private String ttInfoIds;
  43 +
57 44 @JsonIgnore
58 45 /** 使用中间表的一对多关联 明细信息 */
59 46 @OneToMany(mappedBy = "schedulePlan", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
... ... @@ -75,22 +62,6 @@ public class SchedulePlan extends BEntity {
75 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 65 public Date getScheduleFromTime() {
95 66 return scheduleFromTime;
96 67 }
... ... @@ -123,19 +94,11 @@ public class SchedulePlan extends BEntity {
123 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/repository/BusinessRepository.java
... ... @@ -4,6 +4,8 @@ import org.springframework.stereotype.Repository;
4 4  
5 5 import com.bsth.entity.Business;
6 6  
  7 +import java.util.List;
  8 +
7 9 /**
8 10 *
9 11 * @Interface: BusinessRepository(公司Repository数据持久层接口)
... ... @@ -23,4 +25,8 @@ import com.bsth.entity.Business;
23 25 @Repository
24 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/realcontrol/ScheduleRealInfoRepository.java
... ... @@ -89,6 +89,16 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
89 89 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
90 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 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 +
  98 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  99 + @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.adjustExps,s.fcsj")
  100 + List<ScheduleRealInfo> scheduleByDateAndLineTjrb(String line,String date);
  101 +
92 102  
93 103 @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
94 104 @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 +129,30 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
119 129 void deleteByLineCodeAndDate(String xlBm, String schDate);
120 130  
121 131 //去掉了 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)")
  132 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  133 + @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 134 List<ScheduleRealInfo> scheduleByDateAndLine(String line,String date);
124 135  
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")
  136 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  137 + @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 138 List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date);
127 139  
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")
  140 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  141 + @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 142 List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date);
130 143  
131 144 //按月统计
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")
  145 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  146 + @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 147 List<ScheduleRealInfo> scheduleByDateAndLine3(String line,String date);
134 148  
135 149 //按照时间段统计
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")
  150 + @EntityGraph(value = "scheduleRealInfo_cTasks", type = EntityGraph.EntityGraphType.FETCH)
  151 + @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 152 List<ScheduleRealInfo> scheduleByDateAndLineTj(String line,String date,String date2);
138 153  
139 154 //按照时间段统计
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")
  155 + @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 156 List<ScheduleRealInfo> scheduleByDateAndLineTj2(String line,String date,String date2);
142 157  
143 158 @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
... ... @@ -45,4 +45,7 @@ public interface CarConfigInfoRepository extends BaseRepository&lt;CarConfigInfo, L
45 45  
46 46 @Query("select new map(cc.cl.id as id, cc.cl.insideCode as insideCode) from CarConfigInfo cc")
47 47 List<Map<String, Object>> findCarsFromConfig();
  48 +
  49 + @EntityGraph(value = "carConfigInfo_xl_cl", type = EntityGraph.EntityGraphType.FETCH)
  50 + List<CarConfigInfo> findByXlId(Integer xlid);
48 51 }
49 52 \ No newline at end of file
... ...
src/main/java/com/bsth/repository/schedule/EmployeeConfigInfoRepository.java
... ... @@ -25,6 +25,9 @@ public interface EmployeeConfigInfoRepository extends BaseRepository&lt;EmployeeCon
25 25 List<EmployeeConfigInfo> findBylineCode(String lineCode);
26 26  
27 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)
28 31 @Override
29 32 Page<EmployeeConfigInfo> findAll(Specification<EmployeeConfigInfo> spec, Pageable pageable);
30 33  
... ...
src/main/java/com/bsth/repository/schedule/SchedulePlanRepository.java
... ... @@ -13,7 +13,7 @@ import org.springframework.stereotype.Repository;
13 13 */
14 14 @Repository
15 15 public interface SchedulePlanRepository extends BaseRepository<SchedulePlan, Long> {
16   - @EntityGraph(value = "schedulePlan_xl_ttinfo", type = EntityGraph.EntityGraphType.FETCH)
  16 + @EntityGraph(value = "schedulePlan_xl", type = EntityGraph.EntityGraphType.FETCH)
17 17 @Override
18 18 Page<SchedulePlan> findAll(Specification<SchedulePlan> spec, Pageable pageable);
19 19  
... ...
src/main/java/com/bsth/repository/schedule/ScheduleRule1FlatRepository.java
1 1 package com.bsth.repository.schedule;
2 2  
  3 +import com.bsth.entity.Line;
3 4 import com.bsth.entity.schedule.rule.ScheduleRule1Flat;
4 5 import com.bsth.repository.BaseRepository;
5 6 import org.springframework.data.domain.Page;
... ... @@ -9,6 +10,8 @@ import org.springframework.data.jpa.repository.EntityGraph;
9 10 import org.springframework.data.jpa.repository.Query;
10 11 import org.springframework.stereotype.Repository;
11 12  
  13 +import java.util.List;
  14 +
12 15 /**
13 16 * Created by xu on 16/7/4.
14 17 */
... ... @@ -22,4 +25,6 @@ public interface ScheduleRule1FlatRepository extends BaseRepository&lt;ScheduleRule
22 25 @EntityGraph(value = "scheduleRule1Flat_xl_carconfig", type = EntityGraph.EntityGraphType.FETCH)
23 26 @Query("select cc from ScheduleRule1Flat cc where cc.id=?1")
24 27 ScheduleRule1Flat findOneExtend(Long aLong);
  28 +
  29 + List<ScheduleRule1Flat> findByXl(Line line);
25 30 }
... ...
src/main/java/com/bsth/repository/schedule/TTInfoDetailRepository.java
... ... @@ -45,8 +45,11 @@ public interface TTInfoDetailRepository extends BaseRepository&lt;TTInfoDetail, Lon
45 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 46 List<TTInfoDetail> findBcdetails(Integer xlId, Long ttinfoId, Long lpId);
47 47  
  48 + List<TTInfoDetail> findByTtinfoId(Long id);
  49 +
48 50 @Modifying
49 51 @Query(value = "delete from TTInfoDetail t where t.ttinfo.id = ?1")
50 52 void deleteByTtinfoIdWithModify(Long ttinfoid);
51 53  
  54 +
52 55 }
... ...
src/main/java/com/bsth/repository/schedule/TTInfoRepository.java
1 1 package com.bsth.repository.schedule;
2 2  
  3 +import com.bsth.entity.Line;
3 4 import com.bsth.entity.schedule.EmployeeConfigInfo;
4 5 import com.bsth.entity.schedule.TTInfo;
5 6 import com.bsth.repository.BaseRepository;
... ... @@ -10,6 +11,8 @@ import org.springframework.data.jpa.repository.EntityGraph;
10 11 import org.springframework.data.jpa.repository.Query;
11 12 import org.springframework.stereotype.Repository;
12 13  
  14 +import java.util.List;
  15 +
13 16 /**
14 17 * Created by xu on 16/5/12.
15 18 */
... ... @@ -23,4 +26,7 @@ public interface TTInfoRepository extends BaseRepository&lt;TTInfo, Long&gt; {
23 26 @EntityGraph(value = "ttInfo_xl", type = EntityGraph.EntityGraphType.FETCH)
24 27 @Query("select cc from TTInfo cc where cc.id=?1")
25 28 TTInfo findOneExtend(Long aLong);
  29 +
  30 + @Query("select t from TTInfo t where t.xl = ?1 and t.isCancel = false")
  31 + List<TTInfo> findInCanceledByXl(Line xl);
26 32 }
... ...
src/main/java/com/bsth/service/realcontrol/ScheduleRealInfoService.java
... ... @@ -92,7 +92,7 @@ public interface ScheduleRealInfoService extends BaseService&lt;ScheduleRealInfo, L
92 92  
93 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 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 40 import com.bsth.service.SectionRouteService;
41 41 import com.bsth.service.impl.BaseServiceImpl;
42 42 import com.bsth.service.realcontrol.ScheduleRealInfoService;
  43 +import com.bsth.service.report.CulateMileageService;
  44 +import com.bsth.service.report.ReportService;
43 45 import com.bsth.service.schedule.SchedulePlanInfoService;
44 46 import com.bsth.service.sys.DutyEmployeeService;
45 47 import com.bsth.util.*;
... ... @@ -120,6 +122,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
120 122  
121 123 @Autowired
122 124 YlbRepository ylbRepository;
  125 +
  126 + @Autowired
  127 + ReportService reposrService;
  128 +
  129 + @Autowired
  130 + CulateMileageService culateService;
123 131  
124 132 Logger logger = LoggerFactory.getLogger(this.getClass());
125 133  
... ... @@ -1298,7 +1306,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1298 1306 }
1299 1307  
1300 1308  
1301   - @Override
  1309 + /* @Override
1302 1310 public Map<String, Object> findKMBC(String jName, String clZbh,
1303 1311 String lpName, String date, String line) {
1304 1312 List<ScheduleRealInfo> list = scheduleRealInfoRepository.queryListWaybill(jName, clZbh, lpName, date, line);
... ... @@ -1398,6 +1406,31 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1398 1406 map.put("zkslc", format.format(ksgl + jcclc));
1399 1407 // map.put("zkslc", format.format(ksgl + jcclc+addMileageJc));
1400 1408 return map;
  1409 + }*/
  1410 +
  1411 + public Map<String, Object> findKMBC(String jGh, String clZbh,
  1412 + String lpName, String date, String line) {
  1413 + Map<String, Object> map = new HashMap<String, Object>();
  1414 + List<ScheduleRealInfo> lists=scheduleRealInfoRepository.queryListWaybillXcld(jGh, clZbh, lpName, date, line);
  1415 + double ksgl=culateService.culateKsgl(lists);
  1416 + double sjgl=culateService.culateSjgl(lists);
  1417 + double jccgl=culateService.culateJccgl(lists);
  1418 + double ljgl=culateService.culateLjgl(lists);
  1419 + map.put("jhlc", culateService.culateJhgl(lists)); //计划里程
  1420 + map.put("remMileage", culateService.culateLbgl(lists)); //烂班公里
  1421 + map.put("addMileage", ljgl); //临加公里
  1422 + map.put("yygl",Arith.add(sjgl,ljgl)); //实际公里
  1423 + map.put("ksgl", ksgl);//空驶公里
  1424 + map.put("realMileage",Arith.add(Arith.add(ksgl,jccgl ),Arith.add(sjgl,ljgl)));
  1425 +// map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage));
  1426 + map.put("jhbc", culateService.culateJhbc(lists,""));
  1427 + map.put("cjbc", culateService.culateLbbc(lists));
  1428 + map.put("ljbc", culateService.culateLjbc(lists,""));
  1429 + map.put("sjbc", culateService.culateJhbc(lists,"") - culateService.culateLbbc(lists) + culateService.culateLjbc(lists,""));
  1430 + map.put("jcclc", jccgl);
  1431 + map.put("zkslc", Arith.add(ksgl,jccgl));
  1432 +// map.put("zkslc", format.format(ksgl + jcclc+addMileageJc));
  1433 + return map;
1401 1434 }
1402 1435  
1403 1436  
... ... @@ -1611,10 +1644,55 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1611 1644 }
1612 1645 return rs;
1613 1646 }
1614   -
1615 1647 @Override
1616 1648 public List<Map<String, Object>> statisticsDaily(String line, String date,
1617 1649 String xlName, String type) {
  1650 + List<Map<String, Object>> lMap= new ArrayList<Map<String, Object>>();
  1651 + List<ScheduleRealInfo> lists = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);
  1652 + Map<String, Object> map = new HashMap<String, Object>();
  1653 + map.put("xlName", xlName);
  1654 + map.put("jhlc", culateService.culateJhgl(lists));
  1655 + map.put("sjgl", culateService.culateSjgl(lists));
  1656 + map.put("ssgl", culateService.culateLbgl(lists));
  1657 + map.put("ssgl_lz", culateService.culateCJLC(lists, "路阻"));
  1658 + map.put("ssgl_dm", culateService.culateCJLC(lists, "吊慢"));
  1659 + map.put("ssgl_gz", culateService.culateCJLC(lists, "故障"));
  1660 + map.put("ssgl_jf", culateService.culateCJLC(lists, "纠纷"));
  1661 + map.put("ssgl_zs", culateService.culateCJLC(lists, "肇事"));
  1662 + map.put("ssgl_qr", culateService.culateCJLC(lists, "缺人"));
  1663 + map.put("ssgl_qc", culateService.culateCJLC(lists, "缺车"));
  1664 + map.put("ssgl_kx", culateService.culateCJLC(lists, "客稀"));
  1665 + map.put("ssgl_qh", culateService.culateCJLC(lists, "气候"));
  1666 + map.put("ssgl_yw", culateService.culateCJLC(lists, "援外"));
  1667 + map.put("ssgl_other", culateService.culateCJLC(lists, "其他"));
  1668 + map.put("ssbc", culateService.culateLbbc(lists));
  1669 + map.put("ljgl", culateService.culateLjgl(lists));
  1670 + map.put("jhbc", culateService.culateJhbc(lists,""));
  1671 + map.put("jhbc_m", culateService.culateJhbc(lists, "zgf"));
  1672 + map.put("jhbc_a", culateService.culateJhbc(lists, "wgf"));
  1673 + map.put("sjbc", culateService.culateSjbc(lists,""));
  1674 + map.put("sjbc_m", culateService.culateSjbc(lists,"zgf"));
  1675 + map.put("sjbc_a", culateService.culateSjbc(lists,"wgf"));
  1676 + map.put("ljbc", culateService.culateLjbc(lists,""));
  1677 + map.put("ljbc_m", culateService.culateLjbc(lists,"zgf"));
  1678 + map.put("ljbc_a", culateService.culateLjbc(lists,"wgf"));
  1679 + map.put("fzbc", culateService.culateFzbc(lists, ""));
  1680 + map.put("fzbc_m", culateService.culateFzbc(lists, "zgf"));
  1681 + map.put("fzbc_a", culateService.culateFzbc(lists, "wgf"));
  1682 + map.put("dtbc", 0);
  1683 + map.put("dtbc_m", 0);
  1684 + map.put("dtbc_a", 0);
  1685 + map.put("djg", 0);
  1686 + map.put("djg_m", 0);
  1687 + map.put("djg_a", 0);
  1688 + map.put("djg_time", 0);
  1689 + lMap.add(map);
  1690 + return lMap;
  1691 + }
  1692 +
  1693 + /* @Override
  1694 + public List<Map<String, Object>> statisticsDaily(String line, String date,
  1695 + String xlName, String type) {
1618 1696 List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
1619 1697 if (date.length() == 10)
1620 1698 list = scheduleRealInfoRepository.scheduleByDateAndLine2(line, date);
... ... @@ -1748,8 +1826,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1748 1826 while (it.hasNext()) {
1749 1827 ChildTaskPlan childTaskPlan = it.next();
1750 1828 childMileage = childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
1751   - jhlc += childMileage;
1752   - jhlcZ += childMileage;
1753 1829 if (childTaskPlan.isDestroy()) {
1754 1830 ssgl += childMileage;
1755 1831 ssglZ += childMileage;
... ... @@ -2101,7 +2177,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2101 2177 map.put("djg_a", djg_aZ);
2102 2178 map.put("djg_time", djg_timeZ);
2103 2179 lMap.add(map);
2104   - /* for (int i = 0; i < lMap.size(); i++) {
  2180 + for (int i = 0; i < lMap.size(); i++) {
2105 2181 Map<String, Object> m=lMap.get(i);
2106 2182 // m.get(""))
2107 2183 jhlc += Double.parseDouble(m.get("jhlc").toString());
... ... @@ -2138,7 +2214,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2138 2214 m.get("djg_m", djg_m);
2139 2215 m.get("djg_a", djg_a);
2140 2216 m.get("djg_time", djg_time);
2141   - }*/
  2217 + }
2142 2218  
2143 2219 if (type != null && type.length() != 0 && type.equals("export")) {
2144 2220 SimpleDateFormat sdfMonth = new SimpleDateFormat("yyyy-MM-dd"),
... ... @@ -2158,7 +2234,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2158 2234 }
2159 2235  
2160 2236 return lMap;
2161   - }
  2237 + }*/
2162 2238  
2163 2239 @Override
2164 2240 public List<Map<String, Object>> statisticsDailyTj(String line, String date,String date2,
... ...
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 +
... ...
src/main/java/com/bsth/service/report/ReportService.java
... ... @@ -29,5 +29,9 @@ public interface ReportService {
29 29 List<Map<String, Object>> tbodyTime5(String line ,String ttinfo);
30 30  
31 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);
33 37 }
... ...
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 + String[] fcsjStr = scheduleRealInfo.getFcsj().split(":");
  225 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  226 + if(item.equals("zgf")){
  227 + if(fcsj>=zgf1 && fcsj<=zgf2){
  228 + ljbc++;
  229 + }
  230 + }else if(item.equals("wgf")){
  231 + if(fcsj>=wgf1 && fcsj<=wgf2){
  232 + ljbc++;
  233 + }
  234 + }else{
  235 + ljbc++;
  236 + }
  237 + }
  238 + }
  239 + }
  240 + return ljbc;
  241 + }
  242 +
  243 + @Override
  244 + public double culateJhgl(List<ScheduleRealInfo> lists) {
  245 + // TODO Auto-generated method stub
  246 + double jhgl=0;
  247 + for (int i = 0; i < lists.size(); i++) {
  248 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  249 + if (!(scheduleRealInfo.getBcType().equals("in")
  250 + || scheduleRealInfo.getBcType().equals("out"))) {
  251 + if(!scheduleRealInfo.isSflj()){
  252 + jhgl=Arith.add(jhgl,scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig());
  253 + }
  254 + }
  255 + }
  256 + return jhgl;
  257 + }
  258 +
  259 + @Override
  260 + public int culateJhbc(List<ScheduleRealInfo> lists,String item) {
  261 + // TODO Auto-generated method stub
  262 + int jhbc=0;
  263 + for (int i = 0; i < lists.size(); i++) {
  264 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  265 + if (!(scheduleRealInfo.getBcType().equals("in")
  266 + || scheduleRealInfo.getBcType().equals("out"))) {
  267 + if(!scheduleRealInfo.isSflj()){
  268 + String[] fcsjStr = scheduleRealInfo.getFcsj().split(":");
  269 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  270 + if(item.equals("zgf")){
  271 + if(fcsj>=zgf1 && fcsj<=zgf2){
  272 + jhbc++;
  273 + }
  274 + }else if(item.equals("wgf")){
  275 + if(fcsj>=wgf1 && fcsj<=wgf2){
  276 + jhbc++;
  277 + }
  278 + }else{
  279 + jhbc++;
  280 + }
  281 +
  282 + }
  283 + }
  284 + }
  285 + return jhbc;
  286 + }
  287 +
  288 + @Override
  289 + public double culateSjgl(List<ScheduleRealInfo> lists) {
  290 + // TODO Auto-generated method stub
  291 + double sjgl =0;
  292 + for (int i = 0; i < lists.size(); i++) {
  293 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  294 + if (!isInOut(scheduleRealInfo)) {
  295 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  296 + if(!scheduleRealInfo.isSflj()){
  297 + if(childTaskPlans.isEmpty()){
  298 + if(scheduleRealInfo.getStatus() != -1){
  299 + double jggl=scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  300 + sjgl=Arith.add(sjgl,jggl);
  301 + }
  302 + }else{
  303 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  304 + while (it.hasNext()) {
  305 + ChildTaskPlan childTaskPlan = it.next();
  306 + if(childTaskPlan.getMileageType().equals("service")){
  307 + if (!childTaskPlan.isDestroy()) {
  308 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  309 + sjgl=Arith.add(sjgl,jhgl);
  310 + }
  311 + }
  312 + }
  313 + }
  314 + }
  315 + }
  316 + }
  317 + return sjgl;
  318 + }
  319 +
  320 + @Override
  321 + public int culateSjbc(List<ScheduleRealInfo> lists,String item) {
  322 + // TODO Auto-generated method stub
  323 + int sjbc=0;
  324 + for (int i = 0; i < lists.size(); i++) {
  325 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  326 + if (!(scheduleRealInfo.getBcType().equals("in")
  327 + || scheduleRealInfo.getBcType().equals("out"))) {
  328 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  329 + if(!scheduleRealInfo.isSflj()){
  330 + String[] fcsjStr = scheduleRealInfo.getFcsj().split(":");
  331 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  332 + if(childTaskPlans.isEmpty()){
  333 + if(scheduleRealInfo.getStatus()!=-1){
  334 + if(item.equals("zgf")){
  335 + if(fcsj>=zgf1 && fcsj<=zgf2){
  336 + sjbc++;
  337 + }
  338 + }else if(item.equals("wgf")){
  339 + if(fcsj>=wgf1 && fcsj<=wgf2){
  340 + sjbc++;
  341 + }
  342 + }else{
  343 + sjbc++;
  344 + }
  345 +
  346 + }
  347 + }else{
  348 + if(scheduleRealInfo.getStatus() == -1){
  349 + boolean fage=false;
  350 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  351 + if(it.hasNext()){
  352 + ChildTaskPlan childTaskPlan = it.next();
  353 + if(!childTaskPlan.isDestroy()){
  354 + if(childTaskPlan.getMileageType().equals("service")){
  355 + fage=true;
  356 + }
  357 + }
  358 +
  359 + }
  360 + if(fage){
  361 + if(item.equals("zgf")){
  362 + if(fcsj>=zgf1 && fcsj<=zgf2){
  363 + sjbc++;
  364 + }
  365 + }else if(item.equals("wgf")){
  366 + if(fcsj>=wgf1 && fcsj<=wgf2){
  367 + sjbc++;
  368 + }
  369 + }else{
  370 + sjbc++;
  371 + }
  372 + }
  373 +
  374 + }else{
  375 + if(item.equals("zgf")){
  376 + if(fcsj>=zgf1 && fcsj<=zgf2){
  377 + sjbc++;
  378 + }
  379 + }else if(item.equals("wgf")){
  380 + if(fcsj>=wgf1 && fcsj<=wgf2){
  381 + sjbc++;
  382 + }
  383 + }else{
  384 + sjbc++;
  385 + }
  386 + }
  387 + }
  388 + }
  389 + }
  390 + }
  391 + return sjbc;
  392 + }
  393 +
  394 + @Override
  395 + public double culateKsgl(List<ScheduleRealInfo> lists) {
  396 + // TODO Auto-generated method stub
  397 + double ksgl =0;
  398 + for (int i = 0; i < lists.size(); i++) {
  399 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  400 + if (!(scheduleRealInfo.getBcType().equals("in")
  401 + || scheduleRealInfo.getBcType().equals("out"))) {
  402 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  403 + if(!childTaskPlans.isEmpty()){
  404 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  405 + while (it.hasNext()) {
  406 + ChildTaskPlan childTaskPlan = it.next();
  407 + if(childTaskPlan.getMileageType().equals("empty")){
  408 + if (!childTaskPlan.isDestroy()) {
  409 + Float jhgl=childTaskPlan.getMileage()==null?0:childTaskPlan.getMileage();
  410 + ksgl=Arith.add(ksgl,jhgl);
  411 + }
  412 + }
  413 + }
  414 + }
  415 + }
  416 + }
  417 + return ksgl;
  418 + }
  419 +
  420 + @Override
  421 + public double culateJccgl(List<ScheduleRealInfo> lists) {
  422 + // TODO Auto-generated method stub
  423 + double jcclc =0;
  424 + for (int i = 0; i < lists.size(); i++) {
  425 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  426 + if (scheduleRealInfo.getBcType().equals("in")
  427 + || scheduleRealInfo.getBcType().equals("out")) {
  428 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  429 + if(childTaskPlans.isEmpty()){
  430 + if(!scheduleRealInfo.isDestroy())
  431 + jcclc =Arith.add(jcclc, scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig());
  432 + }else{
  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 + jcclc=Arith.add(jcclc,jhgl);
  440 + }
  441 + }
  442 + }
  443 + }
  444 + }
  445 + }
  446 + return jcclc;
  447 + }
  448 +
  449 + public static boolean isInOut(ScheduleRealInfo s){
  450 + boolean fage=false;
  451 + if(s.getBcType().equals("in")){
  452 + fage=true;
  453 + }
  454 + if(s.getBcType().equals("out")){
  455 + fage=true;
  456 + }
  457 +
  458 + return fage;
  459 + }
  460 +
  461 + @Override
  462 + public double culateCJLC(List<ScheduleRealInfo> list, String item) {
  463 + // TODO Auto-generated method stub
  464 + double sum = 0;
  465 + Set<ChildTaskPlan> cts;
  466 + for(ScheduleRealInfo sch : list){
  467 + if (sch.isSflj())
  468 + continue;
  469 + cts = sch.getcTasks();
  470 + //有子任务
  471 + if (cts != null && cts.size() > 0) {
  472 + for(ChildTaskPlan c : cts){
  473 + if(c.isDestroy() && c.getDestroyReason().equals(item))
  474 + sum = Arith.add(sum, c.getMileage());
  475 + }
  476 + }
  477 + else if(isInOut(sch))
  478 + continue;
  479 + //主任务烂班
  480 + else if(sch.getStatus() == -1){
  481 + if(sch.getAdjustExps().equals(item) ||
  482 + (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))){
  483 + sum = Arith.add(sum, sch.getJhlcOrig());
  484 + }
  485 + }
  486 + else if(item.equals("其他")){
  487 + double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc());
  488 + if(diff > 0){
  489 + sum = Arith.add(sum, diff);
  490 + }
  491 + }
  492 + }
  493 + return sum;
  494 +
  495 + }
  496 +
  497 + @Override
  498 + public int culateFzbc(List<ScheduleRealInfo> lists, String item) {
  499 + // TODO Auto-generated method stub
  500 + int fzbc=0;
  501 + for (int i = 0; i < lists.size(); i++) {
  502 + ScheduleRealInfo scheduleRealInfo=lists.get(i);
  503 + if (scheduleRealInfo.getBcType().equals("venting")) {
  504 +// if(!scheduleRealInfo.isSflj()){
  505 + String[] fcsjStr = scheduleRealInfo.getFcsj().split(":");
  506 + long fcsj= Long.parseLong(fcsjStr[0])*60+Long.parseLong(fcsjStr[1]);
  507 + if(item.equals("zgf")){
  508 + if(fcsj>=zgf1 && fcsj<=zgf2){
  509 + fzbc++;
  510 + }
  511 + }else if(item.equals("wgf")){
  512 + if(fcsj>=wgf1 && fcsj<=wgf2){
  513 + fzbc++;
  514 + }
  515 + }else{
  516 + fzbc++;
  517 + }
  518 +
  519 +// }
  520 + }
  521 + }
  522 + return fzbc;
  523 + }
  524 +
  525 +}
... ...
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
... ... @@ -10,9 +10,12 @@ import java.util.ArrayList;
10 10 import java.util.Calendar;
11 11 import java.util.Date;
12 12 import java.util.HashMap;
  13 +import java.util.Iterator;
13 14 import java.util.List;
14 15 import java.util.Map;
  16 +import java.util.Set;
15 17  
  18 +import org.apache.commons.lang.StringUtils;
16 19 import org.slf4j.Logger;
17 20 import org.slf4j.LoggerFactory;
18 21 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -24,11 +27,14 @@ import com.bsth.data.BasicData;
24 27 import com.bsth.entity.StationRoute;
25 28 import com.bsth.entity.excep.ArrivalInfo;
26 29 import com.bsth.entity.oil.Ylb;
  30 +import com.bsth.entity.realcontrol.ChildTaskPlan;
27 31 import com.bsth.entity.realcontrol.ScheduleRealInfo;
28 32 import com.bsth.entity.schedule.SchedulePlanInfo;
29 33 import com.bsth.repository.StationRouteRepository;
30 34 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
  35 +import com.bsth.service.report.CulateMileageService;
31 36 import com.bsth.service.report.ReportService;
  37 +import com.bsth.util.Arith;
32 38 import com.bsth.util.db.DBUtils_MS;
33 39  
34 40 @Service
... ... @@ -44,6 +50,8 @@ public class ReportServiceImpl implements ReportService{
44 50 ScheduleRealInfoRepository scheduleRealInfoRepository;
45 51 @Autowired
46 52 StationRouteRepository stationRoutRepository;
  53 + @Autowired
  54 + CulateMileageService culateService;
47 55 @Override
48 56 public List<ScheduleRealInfo> queryListBczx(String line, String date,String clzbh) {
49 57 // TODO Auto-generated method stub
... ... @@ -1059,4 +1067,242 @@ public class ReportServiceImpl implements ReportService{
1059 1067 return list;
1060 1068 }
1061 1069  
  1070 + private List<ScheduleRealInfo> getListSinfo(Map<String, Object> map){
  1071 + List<ScheduleRealInfo> list =new ArrayList<ScheduleRealInfo>();
  1072 +
  1073 + String sql="select DISTINCT a.* from (select * from bsth_c_s_sp_info_real where 1=1 ";
  1074 + if(map.get("date")!=null){
  1075 + sql += " and schedule_date_str='"+map.get("date").toString()+"'";
  1076 + }
  1077 + if(map.get("line")!=null){
  1078 + if(map.get("line").toString()!=""){
  1079 + sql += " and xl_bm='"+map.get("line").toString()+"'";
  1080 + }
  1081 +
  1082 + }
  1083 + if(map.get("bcType")!=null){
  1084 + if(map.get("bcType").toString().equals("inout")){
  1085 + sql += " and bc_type in ('in','out')";
  1086 + }
  1087 +
  1088 + if(map.get("bcType").toString().equals("normal")){
  1089 + sql += " and bc_type not in ('in','out')";
  1090 + }
  1091 + }
  1092 +
  1093 + sql += " )a left join bsth_c_s_child_task b on a.id=b.schedule";
  1094 + list= jdbcTemplate.query(sql,
  1095 + new RowMapper<ScheduleRealInfo>(){
  1096 + @Override
  1097 + public ScheduleRealInfo mapRow(ResultSet rs, int rowNum) throws SQLException {
  1098 + ScheduleRealInfo m=new ScheduleRealInfo();
  1099 + m.setId(rs.getLong("id"));
  1100 +// m.setBcs();
  1101 +// m.setBcsj();
  1102 + m.setClZbh(rs.getString("cl_zbh"));
  1103 + m.setFcsj(rs.getString("fcsj"));
  1104 + m.setFcsjActual(rs.getString("fcsj_actual"));
  1105 + m.setjGh(rs.getString("j_gh"));
  1106 + m.setjName(rs.getString("j_name"));
  1107 + m.setJhlc(rs.getDouble("jhlc"));
  1108 + m.setLpName(rs.getString("lp_name"));
  1109 + m.setQdzCode(rs.getString("qdz_code"));
  1110 + m.setQdzName(rs.getString("qdz_name"));
  1111 + m.setRealExecDate(rs.getString("real_exec_date"));
  1112 + m.setRealMileage(rs.getDouble("real_mileage"));
  1113 + m.setRemarks(rs.getString("remarks"));
  1114 + m.setsGh(rs.getString("s_gh"));
  1115 + m.setsName(rs.getString("s_name"));
  1116 + m.setScheduleDate(rs.getDate("schedule_date"));
  1117 + m.setScheduleDateStr(rs.getString("schedule_date_str"));
  1118 + m.setSflj(rs.getBoolean("sflj"));
  1119 + m.setSpId(rs.getLong("sp_id"));
  1120 + m.setStatus(rs.getInt("status"));
  1121 + m.setXlBm(rs.getString("xl_bm"));
  1122 + m.setXlDir(rs.getString("xl_dir"));
  1123 + m.setXlName(rs.getString("xl_name"));
  1124 + m.setZdsj(rs.getString("zdsj"));
  1125 + m.setZdsjActual(rs.getString("zdsj_actual"));
  1126 + m.setZdzCode(rs.getString("zdz_code"));
  1127 + m.setZdzName(rs.getString("zdz_name"));
  1128 + m.setCcno(rs.getInt("ccno"));
  1129 + m.setDfAuto(rs.getBoolean("df_auto"));
  1130 + m.setFgsBm(rs.getString("fgs_bm"));
  1131 + m.setFgsName(rs.getString("fgs_name"));
  1132 + m.setGsBm(rs.getString("gs_bm"));
  1133 + m.setGsName(rs.getString("gs_name"));
  1134 + m.setOnline(rs.getBoolean("online"));
  1135 + m.setAdjustExps(rs.getString("adjust_exps"));
  1136 + m.setReissue(rs.getBoolean("reissue"));
  1137 + m.setJhlcOrig(rs.getDouble("jhlc_orig"));
  1138 + return m;
  1139 + }
  1140 + });
  1141 +
  1142 + return list;
  1143 + }
  1144 +
  1145 + @Override
  1146 + public List<Map<String, Object>> jobFwqk(Map<String, Object> map) {
  1147 + // TODO Auto-generated method stub
  1148 + String line=map.get("line").toString();
  1149 + String date=map.get("date").toString();
  1150 + map.put("bcType", "normal");
  1151 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  1152 + List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
  1153 + for (int i = 0; i < sList.size(); i++) {
  1154 + ScheduleRealInfo scheduleRealInfo = sList.get(i);
  1155 + if (!(scheduleRealInfo.getBcType().equals("in")
  1156 + || scheduleRealInfo.getBcType().equals("out"))) {
  1157 + Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1158 + if (childTaskPlans.isEmpty()) {
  1159 + Map<String, Object> newMap = new HashMap<String, Object>();
  1160 + String adjustExps = "";
  1161 + if (scheduleRealInfo.getAdjustExps() == "" || scheduleRealInfo.getAdjustExps() == null) {
  1162 + adjustExps = "其他";
  1163 + } else {
  1164 + adjustExps = scheduleRealInfo.getAdjustExps();
  1165 + }
  1166 + if (scheduleRealInfo.getStatus() == -1) {
  1167 + newMap.put("nr", adjustExps);
  1168 + newMap.put("lp", scheduleRealInfo.getLpName());
  1169 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  1170 + newMap.put("jgh", scheduleRealInfo.getjGh());
  1171 + newMap.put("dz", scheduleRealInfo.getQdzName());
  1172 + newMap.put("sj", scheduleRealInfo.getFcsj());
  1173 + newMap.put("lbbc", 1);
  1174 + newMap.put("lblc", scheduleRealInfo.getJhlcOrig());
  1175 + newMap.put("jyqp", scheduleRealInfo.getRealMileage());
  1176 + list.add(newMap);
  1177 + }
  1178 +
  1179 + } else {
  1180 + Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1181 + while (it.hasNext()) {
  1182 + ChildTaskPlan childTaskPlan = it.next();
  1183 + if (childTaskPlan.isDestroy()) {
  1184 + String destroyReason = "";
  1185 + if (childTaskPlan.getDestroyReason() == "" || childTaskPlan.getDestroyReason() == null) {
  1186 + destroyReason = "其他";
  1187 + } else {
  1188 + destroyReason = childTaskPlan.getDestroyReason();
  1189 + }
  1190 + Map<String, Object> newMap = new HashMap<String, Object>();
  1191 + newMap.put("nr", destroyReason);
  1192 + newMap.put("lp", scheduleRealInfo.getLpName());
  1193 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  1194 + newMap.put("jgh", scheduleRealInfo.getjGh());
  1195 + newMap.put("dz", childTaskPlan.getStartStationName());
  1196 + newMap.put("sj", childTaskPlan.getStartDate());
  1197 + newMap.put("lbbc", 0);
  1198 + newMap.put("lblc", childTaskPlan.getMileage());
  1199 + newMap.put("jyqp", scheduleRealInfo.getRealMileage());
  1200 + list.add(newMap);
  1201 +
  1202 + }
  1203 + }
  1204 + }
  1205 + }
  1206 + }
  1207 + return list;
  1208 + }
  1209 +
  1210 + //统计临加班次详细信息
  1211 + @Override
  1212 + public List<Map<String, Object>> jobLjqk(Map<String, Object> map) {
  1213 + // TODO Auto-generated method stub
  1214 + String line=map.get("line").toString();
  1215 + String date=map.get("date").toString();
  1216 + map.put("bcType", "normal");
  1217 + List<Map<String, Object>> list=new ArrayList<Map<String,Object>>();
  1218 + List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
  1219 + for (int i = 0; i < sList.size(); i++) {
  1220 + ScheduleRealInfo scheduleRealInfo=sList.get(i);
  1221 + if (!(scheduleRealInfo.getBcType().equals("in")
  1222 + || scheduleRealInfo.getBcType().equals("out"))) {
  1223 +// Set<ChildTaskPlan> childTaskPlans = scheduleRealInfo.getcTasks();
  1224 +// if(childTaskPlans.isEmpty()){
  1225 + if(scheduleRealInfo.isSflj()){
  1226 + Map<String, Object> newMap=new HashMap<String,Object>();
  1227 + newMap.put("lp", scheduleRealInfo.getLpName());
  1228 + newMap.put("nbbm", scheduleRealInfo.getClZbh());
  1229 + newMap.put("jgh", scheduleRealInfo.getjGh());
  1230 + newMap.put("dz", scheduleRealInfo.getQdzName());
  1231 + newMap.put("sj", scheduleRealInfo.getFcsj());
  1232 + newMap.put("ljlc", scheduleRealInfo.getJhlc()==null?0:scheduleRealInfo.getJhlc());
  1233 + newMap.put("jyqp", scheduleRealInfo.getRealMileage());
  1234 + list.add(newMap);
  1235 + }
  1236 +// }else{
  1237 +// Iterator<ChildTaskPlan> it = childTaskPlans.iterator();
  1238 +// while (it.hasNext()) {
  1239 +// ChildTaskPlan childTaskPlan = it.next();
  1240 +// if (childTaskPlan.isDestroy()) {
  1241 +// }
  1242 +// }
  1243 +// }
  1244 + }
  1245 + }
  1246 + return list;
  1247 + }
  1248 +
  1249 + public static double culateCJLC2(List<ScheduleRealInfo> list, String item) {
  1250 + // TODO Auto-generated method stub
  1251 + double sum = 0;
  1252 + Set<ChildTaskPlan> cts;
  1253 + for(ScheduleRealInfo sch : list){
  1254 + if (sch.isSflj())
  1255 + continue;
  1256 + cts = sch.getcTasks();
  1257 + //有子任务
  1258 + if (cts != null && cts.size() > 0) {
  1259 + for(ChildTaskPlan c : cts){
  1260 + if(c.isDestroy() && c.getDestroyReason().equals(item))
  1261 + sum = Arith.add(sum, c.getMileage());
  1262 + }
  1263 + }
  1264 +// else if(isInOut(sch))
  1265 +// continue;
  1266 + //主任务烂班
  1267 + else if(sch.getStatus() == -1){
  1268 + if(sch.getAdjustExps().equals(item) ||
  1269 + (StringUtils.isEmpty(sch.getAdjustExps()) && item.equals("其他"))){
  1270 + sum = Arith.add(sum, sch.getJhlcOrig());
  1271 + }
  1272 + }
  1273 + else if(item.equals("其他")){
  1274 + double diff = Arith.sub(sch.getJhlcOrig(), sch.getJhlc());
  1275 + if(diff > 0){
  1276 + sum = Arith.add(sum, diff);
  1277 + }
  1278 + }
  1279 + }
  1280 + return sum;
  1281 +
  1282 + }
  1283 + @Override
  1284 + public Map<String, Object> jobHzxx(Map<String, Object> map) {
  1285 + // TODO Auto-generated method stub
  1286 + String line="";
  1287 + if(map.get("line")!=null){
  1288 + line=map.get("line").toString();
  1289 + }
  1290 + String date="";
  1291 + if(map.get("date")!=null){
  1292 + date=map.get("date").toString();
  1293 + }
  1294 +
  1295 + List<ScheduleRealInfo> sList=scheduleRealInfoRepository.scheduleByDateAndLineTjrb(line, date);
  1296 + Map<String, Object> newMap=new HashMap<String,Object>();
  1297 + newMap.put("jhbc", culateService.culateJhbc(sList,""));
  1298 + newMap.put("jhgl", culateService.culateJhgl(sList));
  1299 + newMap.put("sjbc", culateService.culateSjbc(sList,""));
  1300 + newMap.put("sjgl", culateService.culateSjgl(sList));
  1301 + newMap.put("lbgl", culateService.culateLbgl(sList));
  1302 + newMap.put("lbbc", culateService.culateLbbc(sList));
  1303 + newMap.put("ljgl", culateService.culateLjgl(sList));
  1304 + newMap.put("ljbc", culateService.culateLjbc(sList,""));
  1305 + newMap.put("ksgl", culateService.culateKsgl(sList));
  1306 + return newMap;
  1307 + }
1062 1308 }
... ...
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
1 1 package com.bsth.service.schedule.impl;
2 2  
3   -import com.bsth.entity.Line;
4 3 import com.bsth.entity.schedule.SchedulePlan;
5 4 import com.bsth.entity.schedule.TTInfo;
6 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.SchedulePlanService;
12 10 import com.bsth.service.schedule.rules.plan.PlanCalcuParam_input;
13 11 import com.bsth.service.schedule.rules.plan.PlanResult;
14 12 import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input;
15 13 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
16 14 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
17   -import com.bsth.service.schedule.rules.strategy.IStrategy;
18 15 import com.bsth.service.schedule.rules.ttinfo.*;
19 16 import com.bsth.service.schedule.rules.ttinfo2.CalcuParam;
20 17 import com.bsth.service.schedule.rules.ttinfo2.Result;
... ... @@ -28,7 +25,6 @@ import org.springframework.stereotype.Service;
28 25 import org.springframework.transaction.annotation.Isolation;
29 26 import org.springframework.transaction.annotation.Propagation;
30 27 import org.springframework.transaction.annotation.Transactional;
31   -import org.springframework.util.CollectionUtils;
32 28  
33 29 import java.util.*;
34 30  
... ... @@ -40,75 +36,45 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
40 36 @Autowired
41 37 private KieBase kieBase;
42 38 @Autowired
43   - private IStrategy strategy;
44   - @Autowired
45   - private SchedulePlanRepository schedulePlanRepository;
46   - @Autowired
47 39 private SchedulePlanInfoRepository schedulePlanInfoRepository;
48 40 @Autowired
49   - private LineService lineService;
  41 + private ScheduleRule1FlatRepository scheduleRule1FlatRepository;
  42 + @Autowired
  43 + private TTInfoRepository ttInfoRepository;
50 44 @Autowired
51   - private TTInfoService ttInfoService;
  45 + private TTInfoDetailRepository ttInfoDetailRepository;
52 46 @Autowired
53   - private TTInfoDetailService ttInfoDetailService;
  47 + private LineRepository lineRepository;
54 48 @Autowired
55   - private BusinessService businessService;
  49 + private CarConfigInfoRepository carConfigInfoRepository;
56 50 @Autowired
57   - private CarConfigInfoService carConfigInfoService;
  51 + private EmployeeConfigInfoRepository employeeConfigInfoRepository;
58 52 @Autowired
59   - private EmployeeConfigInfoService employeeConfigInfoService;
  53 + private BusinessRepository businessRepository;
60 54  
61 55 /** 日志记录器 */
62 56 private Logger logger = LoggerFactory.getLogger(SchedulePlanServiceImpl.class);
63 57  
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 58 /**
94 59 * 循环规则输出。
95   - * @param schedulePlan
  60 + * @param schedulePlan 排班计划对象
  61 + * @param lpInfoResults_output 时刻表每日路牌的情况
96 62 */
97   - private ScheduleResults_output loopRuleOutput(SchedulePlan schedulePlan, LpInfoResults_output lpInfoResults_output) {
98   - // 获取主线路
99   - Line xl = strategy.getLine(schedulePlan.getXl().getId());
100   -
  63 + private ScheduleResults_output loopRuleOutput(
  64 + SchedulePlan schedulePlan,
  65 + LpInfoResults_output lpInfoResults_output) {
101 66 // 1-1、构造drools规则输入数据,输出数据
102 67 // 全局计算参数
103 68 ScheduleCalcuParam_input scheduleCalcuParam_input = new ScheduleCalcuParam_input(schedulePlan);
104 69 // 每个规则对应的输入参数
105 70 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);
  71 + List<ScheduleRule1Flat> scheduleRule1Flats = scheduleRule1FlatRepository.findByXl(schedulePlan.getXl());
  72 +
  73 + for (ScheduleRule1Flat scheduleRule1Flat: scheduleRule1Flats) {
  74 + ScheduleRule_input scheduleRule_input = new ScheduleRule_input(scheduleRule1Flat);
110 75 scheduleRule_inputs.add(scheduleRule_input);
111 76 }
  77 +
112 78 // 规则输出数据
113 79 ScheduleResults_output scheduleResults_output = new ScheduleResults_output();
114 80  
... ... @@ -124,6 +90,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
124 90 for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) {
125 91 session.insert(scheduleRule_input);
126 92 }
  93 + // 每日时刻表路牌数据
127 94 for (LpInfoResult_output lpInfoResult_output: lpInfoResults_output.getLpInfoResult_outputs()) {
128 95 session.insert(lpInfoResult_output);
129 96 }
... ... @@ -140,12 +107,12 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
140 107  
141 108 /**
142 109 * 时刻表选择(判定每天使用的时刻表,以及路牌数据输出)。
143   - * @param schedulePlan
  110 + * @param schedulePlan 排班计划对象
144 111 * @return TTInfoResults_output, LpInfoResults_output
145 112 */
146 113 private Object[] ttInfoOutput(SchedulePlan schedulePlan) {
147 114 // 获取线路的所有未作废的时刻表
148   - List<TTInfo> ttInfos = getTTInfos(schedulePlan.getXl().getId());
  115 + List<TTInfo> ttInfos = ttInfoRepository.findInCanceledByXl(schedulePlan.getXl());
149 116  
150 117 // 1-1、构造drools规则输入数据,输出数据
151 118 // 全局计算参数
... ... @@ -167,8 +134,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
167 134 session.setGlobal("results", ttInfoResults_output);
168 135 session.setGlobal("lpInfoResults_output", lpInfoResults_output);
169 136 session.setGlobal("log", logger); // 设置日志
170   -
171   - session.setGlobal("tTInfoDetailService", ttInfoDetailService);
  137 + session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository);
172 138  
173 139 // 载入数据
174 140 session.insert(ttInfoCalcuParam_input);
... ... @@ -177,12 +143,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
177 143 session.insert(ttInfo_input);
178 144 }
179 145  
  146 + // 载入数据2(计算规则最早启用时间)
  147 + List<ScheduleRule1Flat> scheduleRule1Flats = scheduleRule1FlatRepository.findByXl(schedulePlan.getXl());
180 148  
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);
  149 + for (ScheduleRule1Flat scheduleRule1Flat: scheduleRule1Flats) {
  150 + ScheduleRule_input scheduleRule_input = new ScheduleRule_input(scheduleRule1Flat);
186 151 session.insert(scheduleRule_input);
187 152 }
188 153  
... ... @@ -196,6 +161,13 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
196 161  
197 162 }
198 163  
  164 + /**
  165 + * 排班生成。
  166 + * @param schedulePlan 排班计划对象
  167 + * @param scheduleResults_output loopRuleOutput方法规则输出
  168 + * @param ttInfoResults_output ttInfoOutput方法规则输出
  169 + * @return PlanResult
  170 + */
199 171 private PlanResult planResultOutput(
200 172 SchedulePlan schedulePlan,
201 173 ScheduleResults_output scheduleResults_output,
... ... @@ -216,14 +188,14 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
216 188  
217 189 // 设置gloable对象,在drl中通过别名使用
218 190 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 191 session.setGlobal("log", logger); // 设置日志
226 192  
  193 + session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository);
  194 + session.setGlobal("carConfigInfoRepository", carConfigInfoRepository);
  195 + session.setGlobal("employeeConfigInfoRepository", employeeConfigInfoRepository);
  196 + session.setGlobal("lineRepository", lineRepository);
  197 + session.setGlobal("businessRepository", businessRepository);
  198 +
227 199 // 载入数据
228 200 session.insert(planCalcuParam_input);
229 201  
... ... @@ -238,207 +210,28 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
238 210 }
239 211  
240 212 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
241   - public SchedulePlan save2(SchedulePlan schedulePlan) {
  213 + public SchedulePlan save(SchedulePlan schedulePlan) {
  214 + // pre、如果排班的数据之前已经有了,删除之前的数据
  215 + schedulePlanInfoRepository.deleteByXlAndScheduleDateGreaterThanEqualAndScheduleDateLessThanEqual(
  216 + schedulePlan.getXl().getId(), schedulePlan.getScheduleFromTime(), schedulePlan.getScheduleToTime()
  217 + );
  218 +
242 219 // 1、时刻表数据及每日路牌数据计算
243 220 Object[] ttInfoRets = ttInfoOutput(schedulePlan);
244 221 TTInfoResults_output ttInfoResults_output = (TTInfoResults_output) ttInfoRets[0];
245 222 LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1];
246   -
247 223 // 2、循环规则计算输出
248 224 ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan, lpInfoResults_output);
249   -
250 225 // 3、计划输出
251 226 PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output);
252 227  
253   - schedulePlan.setTtInfoId("todo"); // TODO:待修正
254   - schedulePlan.setTtInfoNames("todo"); // TODO:待修正
255   -
  228 + // 4、保存数据(TODO:之后改成批量保存)
256 229 schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos());
257   -
258 230 super.save(schedulePlan);
259 231  
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);
274   -
275 232 return new SchedulePlan();
276 233 }
277 234  
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 235 @Override
443 236 public SchedulePlan findSchedulePlanTommorw() {
444 237 DateTime today = new DateTime(new Date());
... ... @@ -460,8 +253,8 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
460 253 KieSession session = kieBase.newKieSession();
461 254 // 设置gloable对象,在drl中通过别名使用
462 255 session.setGlobal("log", logger);
463   - session.setGlobal("lineService", lineService);
464   - session.setGlobal("ttInfoDetailService", ttInfoDetailService);
  256 + session.setGlobal("lineRepository", lineRepository);
  257 + session.setGlobal("tTInfoDetailRepository", ttInfoDetailRepository);
465 258  
466 259 Result rs = new Result(); // 输出gloable对象
467 260 session.setGlobal("rs", rs);
... ... @@ -470,11 +263,10 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
470 263 CalcuParam calcuParam = new CalcuParam(
471 264 new DateTime(from), new DateTime(to), xlid);
472 265 session.insert(calcuParam);
473   - List<TTInfo> ttInfos = ttInfoService.findAll();
  266 + List<TTInfo> ttInfos = (List<TTInfo>) ttInfoRepository.findAll();
474 267 for (TTInfo ttInfo: ttInfos)
475 268 session.insert(ttInfo);
476 269  
477   -
478 270 // 执行rule
479 271 session.fireAllRules();
480 272  
... ...
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 55 kfs.write("src/main/resources/functions.drl", kieServices.getResources()
56 56 .newInputStreamResource(this.getClass().getResourceAsStream(
57 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 58 kfs.write("src/main/resources/shiftloop_fb_2.drl", kieServices.getResources()
62 59 .newInputStreamResource(this.getClass().getResourceAsStream(
63 60 "/rules/shiftloop_fb_2.drl"), "UTF-8"));
... ...
src/main/java/com/bsth/util/Arith.java
... ... @@ -20,9 +20,9 @@ public class Arith {
20 20 * @param v2 加数
21 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 26 return b1.add(b2).doubleValue();
27 27 }
28 28  
... ... @@ -32,9 +32,9 @@ public class Arith {
32 32 * @param v2 减数
33 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 38 return b1.subtract(b2).doubleValue();
39 39 }
40 40  
... ... @@ -44,9 +44,9 @@ public class Arith {
44 44 * @param v2 乘数
45 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 50 return b1.multiply(b2).doubleValue();
51 51 }
52 52  
... ... @@ -57,7 +57,7 @@ public class Arith {
57 57 * @param v2 除数
58 58 * @return 两个参数的商
59 59 */
60   - public static double div(double v1,double v2){
  60 + public static double div(Object v1,Object v2){
61 61 return div(v1,v2,DEF_DIV_SCALE);
62 62 }
63 63  
... ... @@ -69,13 +69,13 @@ public class Arith {
69 69 * @param scale 表示表示需要精确到小数点以后几位。
70 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 73 if(scale<0){
74 74 throw new IllegalArgumentException(
75 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 79 return b1.divide(b2,scale,BigDecimal.ROUND_HALF_UP).doubleValue();
80 80 }
81 81  
... ... @@ -85,12 +85,12 @@ public class Arith {
85 85 * @param scale 小数点后保留几位
86 86 * @return 四舍五入后的结果
87 87 */
88   - public static double round(double v,int scale){
  88 + public static double round(Object v,int scale){
89 89 if(scale<0){
90 90 throw new IllegalArgumentException(
91 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 94 BigDecimal one = new BigDecimal("1");
95 95 return b.divide(one,scale,BigDecimal.ROUND_HALF_UP).doubleValue();
96 96 }
... ... @@ -100,8 +100,8 @@ public class Arith {
100 100 * @param v 需要被转换的数字
101 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 105 return b.floatValue();
106 106 }
107 107  
... ... @@ -110,8 +110,8 @@ public class Arith {
110 110 * @param v 需要被转换的数字
111 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 115 return b.intValue();
116 116 }
117 117  
... ... @@ -120,8 +120,8 @@ public class Arith {
120 120 * @param v 需要被转换的数字
121 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 125 return b.longValue();
126 126 }
127 127  
... ... @@ -131,9 +131,9 @@ public class Arith {
131 131 * @param v2 需要被对比的第二个数
132 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 137 return b1.max(b2).doubleValue();
138 138 }
139 139  
... ... @@ -143,9 +143,9 @@ public class Arith {
143 143 * @param v2 需要被对比的第二个数
144 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 149 return b1.min(b2).doubleValue();
150 150 }
151 151  
... ... @@ -155,9 +155,9 @@ public class Arith {
155 155 * @param v2 需要被对比的第二个数
156 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 161 return b1.compareTo(b2);
162 162 }
163 163 }
... ...
src/main/resources/rules/HelloWorld.drl deleted 100644 → 0
1   -package com.bsth.service.schedule
2   -
3   -//list any import classes here.
4   -
5   -import com.bsth.service.schedule.rules.Message;
6   -
7   -//declare any global variables here
8   -
9   -global java.util.List list
10   -
11   -
12   -rule "Hello World"
13   - dialect "mvel"
14   - when
15   - $m : Message( status == Message.HELLO, $message : message )
16   - then
17   - System.out.println($message);
18   - $m.status = com.bsth.service.schedule.rules.Message.GOODBYE;
19   - $m.message = "Goodbye cruel world";
20   - update($m);
21   -end
22   -
23   -rule "Good bye"
24   - dialect "mvel"
25   - when
26   - $m : Message( status == Message.GOODBYE, $message : message )
27   - then
28   - System.out.println($message);
29   - list.add("you come on!");
30   -end
src/main/resources/rules/plan.drl
... ... @@ -6,12 +6,11 @@ import java.util.*;
6 6 import com.bsth.service.schedule.rules.plan.PlanCalcuParam_input;
7 7 import com.bsth.service.schedule.rules.plan.PlanResult;
8 8  
9   -import com.bsth.service.schedule.TTInfoService;
10   -import com.bsth.service.schedule.TTInfoDetailService;
11   -import com.bsth.service.schedule.CarConfigInfoService;
12   -import com.bsth.service.schedule.EmployeeConfigInfoService;
13   -import com.bsth.service.LineService;
14   -import com.bsth.service.BusinessService;
  9 +import com.bsth.repository.schedule.TTInfoDetailRepository;
  10 +import com.bsth.repository.schedule.CarConfigInfoRepository;
  11 +import com.bsth.repository.schedule.EmployeeConfigInfoRepository;
  12 +import com.bsth.repository.LineRepository;
  13 +import com.bsth.repository.BusinessRepository;
15 14  
16 15 import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output;
17 16 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
... ... @@ -33,33 +32,27 @@ import org.apache.commons.lang3.StringUtils;
33 32  
34 33 // 全局日志类(一般使用调用此规则的service类)
35 34 global Logger log;
36   -global TTInfoDetailService tTInfoDetailService;
37   -global TTInfoService tTInfoService;
38   -global CarConfigInfoService carConfigInfoService;
39   -global EmployeeConfigInfoService employeeConfigInfoService;
40   -global LineService lineService;
41   -global BusinessService businessService;
  35 +
  36 +global TTInfoDetailRepository tTInfoDetailRepository;
  37 +global CarConfigInfoRepository carConfigInfoRepository;
  38 +global EmployeeConfigInfoRepository employeeConfigInfoRepository;
  39 +global LineRepository lineRepository;
  40 +global BusinessRepository businessRepository;
42 41  
43 42 // 输出
44 43 global PlanResult planResult;
45 44  
46   -function Map ttidParams(String ttid) {
47   - Map param = new HashMap();
48   - param.put("ttinfo.id_eq", Long.parseLong(ttid));
49   - return param;
50   -}
51   -
52 45 function Map xlidParams(String xlid) {
53 46 Map param = new HashMap();
54 47 param.put("xl.id_eq", Integer.valueOf(xlid));
55 48 return param;
56 49 }
57 50  
58   -function List ecList(EmployeeConfigInfoService service, String ecids) {
  51 +function List ecList(EmployeeConfigInfoRepository repo, String ecids) {
59 52 List<String> ids = Arrays.asList(ecids.split("-"));
60 53 List rst = new ArrayList();
61 54 for (int i = 0; i < ids.size(); i++) {
62   - rst.add(service.findById(Long.parseLong(ids.get(i))));
  55 + rst.add(repo.findOne(Long.parseLong(ids.get(i))));
63 56 }
64 57 return rst;
65 58 }
... ... @@ -149,7 +142,7 @@ rule &quot;calcu_CarConfig_Wrap&quot;
149 142 salience 800
150 143 when
151 144 $lr: Loop_result($xlId: xlId)
152   - $ccf: CarConfigInfo() from carConfigInfoService.list(xlidParams($xlId))
  145 + $ccf: CarConfigInfo() from carConfigInfoRepository.findByXlId(Integer.parseInt($xlId))
153 146 then
154 147 CarConfig_Wrap carConfig_wrap = new CarConfig_Wrap();
155 148 carConfig_wrap.setId(String.valueOf($ccf.getId()));
... ... @@ -169,7 +162,7 @@ rule &quot;calcu_EmployeeConfig_Wrap&quot;
169 162 salience 800
170 163 when
171 164 $lr: Loop_result($xlId: xlId)
172   - $eci: EmployeeConfigInfo() from employeeConfigInfoService.list(xlidParams($xlId))
  165 + $eci: EmployeeConfigInfo() from employeeConfigInfoRepository.findByXlId(Integer.parseInt($xlId))
173 166 then
174 167 EmployeeConfig_Wrap employeeConfig_wrap = new EmployeeConfig_Wrap();
175 168 employeeConfig_wrap.setId(String.valueOf($eci.getId()));
... ... @@ -194,10 +187,10 @@ rule &quot;calcu_TTInfo_gid_stat&quot;
194 187 when
195 188 $lr: Loop_result($xlId: xlId)
196 189 $ttInfoId: String() from $lr.getTtInfoMap().keySet()
197   - $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttInfoId)), gidscount($ttd))
  190 + $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidscount($ttd))
198 191 $gid: String() from $gids
199   - $fbtime_str: String() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailService.list(ttidParams($ttInfoId)), gidfbtime($ttd))
200   - $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailService.list(ttidParams($ttInfoId)), max($ttd.getFcno()))
  192 + $fbtime_str: String() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbtime($ttd))
  193 + $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), max($ttd.getFcno()))
201 194 then
202 195 TTInfo_gid_stat ttInfo_gid_stat = new TTInfo_gid_stat();
203 196 ttInfo_gid_stat.setXlId($xlId);
... ... @@ -234,7 +227,7 @@ rule &quot;calcu_TTInfoDetail_Wrap&quot;
234 227 $ttInfoStat: TTInfo_gid_stat(
235 228 ttInfoId == $ttInfoId,
236 229 $gid: gid, $maxFcno: maxFcno)
237   - $ttInfoDetail: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailService.list(ttidParams($ttInfoId))
  230 + $ttInfoDetail: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId))
238 231 then
239 232 TTInfoDetail_Wrap ttInfoDetail_wrap = new TTInfoDetail_Wrap();
240 233 ttInfoDetail_wrap.setXlId($xlId);
... ... @@ -276,7 +269,7 @@ rule &quot;Calcu_SchedulePlanInfo&quot;
276 269 )
277 270 then
278 271 // 线路
279   - Line xl = lineService.findById(Integer.valueOf($xlId));
  272 + Line xl = lineRepository.findOne(Integer.parseInt($xlId));
280 273  
281 274 SchedulePlanInfo schedulePlanInfo = new SchedulePlanInfo(
282 275 xl,
... ... @@ -284,7 +277,7 @@ rule &quot;Calcu_SchedulePlanInfo&quot;
284 277 $ttInfoDetail,
285 278 $isFb,
286 279 $cc,
287   - ecList(employeeConfigInfoService, $sro.getEmployeeConfigId()),
  280 + ecList(employeeConfigInfoRepository, $sro.getEmployeeConfigId()),
288 281 $param.getSchedulePlan(),
289 282 $isFirstBc,
290 283 $isLastBc
... ... @@ -296,23 +289,16 @@ rule &quot;Calcu_SchedulePlanInfo&quot;
296 289 Business gs = null;
297 290 Business fgs = null;
298 291  
299   - Map<String, Object> param = new HashMap<>();
300   -
301 292 if (StringUtils.isNotEmpty(gsbm)) {
302   - param.clear();
303   - param.put("businessCode_eq", gsbm);
304   - Iterator<Business> businessIterator = businessService.list(param).iterator();
305   - if (businessIterator.hasNext()) {
306   - gs = businessIterator.next();
  293 + Iterator<Business> businessIterator1 = businessRepository.findByBusinessCode(gsbm).iterator();
  294 + if (businessIterator1.hasNext()) {
  295 + gs = (Business) businessIterator1.next();
307 296 }
308 297 }
309 298 if (StringUtils.isNotEmpty(gsbm) && StringUtils.isNotEmpty(fgsbm)) {
310   - param.clear();;
311   - param.put("upCode_eq", gsbm);
312   - param.put("businessCode_eq", fgsbm);
313   - Iterator<Business> businessIterator = businessService.list(param).iterator();
314   - if (businessIterator.hasNext()) {
315   - fgs = businessIterator.next();
  299 + Iterator<Business> businessIterator2 = businessRepository.findByUpCodeAndBusinessCode(gsbm, fgsbm).iterator();
  300 + if (businessIterator2.hasNext()) {
  301 + fgs = (Business) businessIterator2.next();
316 302 }
317 303 }
318 304  
... ... @@ -331,14 +317,11 @@ rule &quot;Calcu_SchedulePlanInfo&quot;
331 317 schedulePlanInfo.setUpdateBy($param.getSchedulePlan().getUpdateBy());
332 318 schedulePlanInfo.setUpdateDate($param.getSchedulePlan().getUpdateDate());
333 319  
334   - // TODO:
335   - $param.getSchedulePlan().setTtInfo($ttInfoDetail.getTtinfo());
336   -
337 320 // result 输出
338 321 planResult.getSchedulePlanInfos().add(schedulePlanInfo);
339 322  
340 323 log.info("gid={},ecid={},ttInfoId={}",
341   - $gid, ecList(employeeConfigInfoService, $sro.getEmployeeConfigId()),
  324 + $gid, ecList(employeeConfigInfoRepository, $sro.getEmployeeConfigId()),
342 325 ttInfoId_sd($lr.getTtInfoMapLoop(), $sd));
343 326  
344 327 end
... ...
src/main/resources/rules/ttinfo.drl
... ... @@ -12,7 +12,7 @@ import com.bsth.service.schedule.rules.ttinfo.LpInfoResults_output;
12 12  
13 13 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
14 14  
15   -import com.bsth.service.schedule.TTInfoDetailService;
  15 +import com.bsth.repository.schedule.TTInfoDetailRepository;
16 16  
17 17 import com.bsth.entity.schedule.TTInfo;
18 18 import com.bsth.entity.schedule.TTInfoDetail;
... ... @@ -21,21 +21,18 @@ import org.slf4j.Logger
21 21  
22 22 // 全局日志
23 23 global Logger log;
24   -// service
25   -global TTInfoDetailService tTInfoDetailService;
  24 +// repostory
  25 +global TTInfoDetailRepository tTInfoDetailRepository;
26 26 // return输出
27 27 global TTInfoResults_output results
28 28 global LpInfoResults_output lpInfoResults_output
29 29  
30   -function Map ttidParams(List ttinfolist) {
  30 +function Long ttidParams(List ttinfolist) {
31 31 // 获取第一张时刻表id
32 32 TTInfo_input ttInfo_input = (TTInfo_input) ttinfolist.get(0);
33   - Map param = new HashMap();
34   - param.put("ttinfo.id_eq", Long.parseLong(ttInfo_input.getTtInfoId()));
35   - return param;
  33 + return Long.parseLong(ttInfo_input.getTtInfoId());
36 34 }
37 35  
38   -
39 36 /*
40 37 TODO:规则说明,以后待说明
41 38 */
... ... @@ -124,7 +121,7 @@ rule &quot;calcu_ttinfo_special_day&quot; // 特殊日期匹配
124 121 $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)
125 122 $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day)
126 123 $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays contains $calcu_date) from $ttInfo_input_list)
127   - $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttinfolist)), lpinforesult($ttd))
  124 + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(ttidParams($ttinfolist)), lpinforesult($ttd))
128 125 then
129 126 // 更新Calcu_days_result对象
130 127 int new_calcu_day = $calcu_day + 1;
... ... @@ -155,7 +152,7 @@ rule &quot;calcu_ttinfo_normal_day&quot; // 平日匹配
155 152 $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)
156 153 $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday)
157 154 $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == true) from $ttInfo_input_list)
158   - $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttinfolist)), lpinforesult($ttd))
  155 + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(ttidParams($ttinfolist)), lpinforesult($ttd))
159 156 then
160 157 // 更新Calcu_days_result对象
161 158 int new_calcu_day = $calcu_day + 1;
... ... @@ -186,7 +183,7 @@ rule &quot;calcu_ttinfo_other_day&quot; // 都没有的情况下,匹配
186 183 $calcu_ttinfo_enable_result : Calcu_ttinfo_enable_result($xlId : xlId, $calcu_date : calcu_date, $ttInfo_input_list : ttInfo_input_list)
187 184 $calcu_days_result : Calcu_days_result(calcu_date == $calcu_date, xlId == $xlId, $calcu_day : calcu_day, $calcu_weekday : calcu_weekday)
188 185 $ttinfolist : ArrayList(size >= 1) from collect (TTInfo_input(specialDays not contains $calcu_date, weekdays[$calcu_weekday - 1] == false) from $ttInfo_input_list)
189   - $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailService.list(ttidParams($ttinfolist)), lpinforesult($ttd))
  186 + $lpInfoResults: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(ttidParams($ttinfolist)), lpinforesult($ttd))
190 187 then
191 188 // 更新Calcu_days_result对象
192 189 int new_calcu_day = $calcu_day + 1;
... ...
src/main/resources/rules/ttinfo2.drl
... ... @@ -12,8 +12,8 @@ import com.bsth.entity.schedule.TTInfo;
12 12 import com.bsth.entity.schedule.TTInfoDetail;
13 13 import com.bsth.entity.Line;
14 14  
15   -import com.bsth.service.LineService;
16   -import com.bsth.service.schedule.TTInfoDetailService;
  15 +import com.bsth.repository.LineRepository;
  16 +import com.bsth.repository.schedule.TTInfoDetailRepository;
17 17  
18 18 import org.slf4j.Logger
19 19 import org.joda.time.format.DateTimeFormat
... ... @@ -23,8 +23,8 @@ import java.lang.Object;
23 23  
24 24 // 全局日志类(一般使用调用此规则的service类)
25 25 global Logger log;
26   -global LineService lineService;
27   -global TTInfoDetailService ttInfoDetailService;
  26 +global LineRepository lineRepository;
  27 +global TTInfoDetailRepository tTInfoDetailRepository;
28 28  
29 29 // 输出
30 30 global Result rs;
... ... @@ -68,7 +68,7 @@ rule &quot;calcu_iter_days&quot;
68 68 Calcu_iter_days_result cidr = new Calcu_iter_days_result();
69 69 Period p = new Period($fromDate, $toDate, PeriodType.days());
70 70  
71   - Line line = (Line) lineService.findById($xlId);
  71 + Line line = (Line) lineRepository.findOne($xlId);
72 72  
73 73 cidr.setXlId($xlId);
74 74 cidr.setXlName(line.getName());
... ... @@ -192,9 +192,7 @@ rule &quot;Calcu_iter_days_special_day&quot; // 特殊日期匹配
192 192  
193 193 TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();
194 194 ttInfoDetails_wrap.setTtInfoId($tid);
195   - Map<String, Object> param = new HashMap<String, Object>();
196   - param.put("ttinfo.id_eq", $tid);
197   - ttInfoDetails_wrap.setBcInfoList(ttInfoDetailService.list(param));
  195 + ttInfoDetails_wrap.setBcInfoList(tTInfoDetailRepository.findByTtinfoId($tid));
198 196 insert(ttInfoDetails_wrap);
199 197 }
200 198 update($cid);
... ... @@ -239,9 +237,7 @@ rule &quot;Calcu_iter_days_normal_day&quot; // 平日匹配
239 237  
240 238 TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();
241 239 ttInfoDetails_wrap.setTtInfoId($tid);
242   - Map<String, Object> param = new HashMap<String, Object>();
243   - param.put("ttinfo.id_eq", $tid);
244   - ttInfoDetails_wrap.setBcInfoList(ttInfoDetailService.list(param));
  240 + ttInfoDetails_wrap.setBcInfoList(tTInfoDetailRepository.findByTtinfoId($tid));
245 241 insert(ttInfoDetails_wrap);
246 242 }
247 243 update($cid);
... ... @@ -286,8 +282,7 @@ rule &quot;Calcu_iter_days_other_day&quot; // 都没有的情况下,匹配
286 282 TTInfoDetails_wrap ttInfoDetails_wrap = new TTInfoDetails_wrap();
287 283 ttInfoDetails_wrap.setTtInfoId($tid);
288 284 Map<String, Object> param = new HashMap<String, Object>();
289   - param.put("ttinfo.id_eq", $tid);
290   - ttInfoDetails_wrap.setBcInfoList(ttInfoDetailService.list(param));
  285 + ttInfoDetails_wrap.setBcInfoList(tTInfoDetailRepository.findByTtinfoId($tid));
291 286 insert(ttInfoDetails_wrap);
292 287 }
293 288 update($cid);
... ...
src/main/resources/static/pages/forms/statement/jobSummary.html
... ... @@ -49,16 +49,16 @@
49 49 <th colspan="10">调度员工作汇总日报</th>
50 50 </tr>
51 51 <tr>
52   - <td colspan="10">线路:85路&nbsp;&nbsp;&nbsp;&nbsp;日期:2016/5/26</td>
  52 + <td colspan="10">线路:<label id="xlid"></label> &nbsp;&nbsp;&nbsp;&nbsp;日期:<label id="dateid"></label></td>
53 53 </tr>
54 54 <tr>
55   - <td colspan="10">安全服务情况</td>
  55 + <td colspan="10">安全服务情况</td>
56 56 </tr>
57 57 <tr>
58 58 <td colspan="2">少驶班次数</td>
59   - <td colspan="2">&nbsp;</td>
  59 + <td colspan="2"><label id="lbbcs"></label> </td>
60 60 <td colspan="2">少驶公里数</td>
61   - <td colspan="4">&nbsp;</td>
  61 + <td colspan="4"><label id="lbgls"></label> </td>
62 62 </tr>
63 63 </thead>
64 64 <tbody>
... ... @@ -76,23 +76,18 @@
76 76 <td>烂班里程</td>
77 77 <td>简要情况</td>
78 78 </tr>
79   - <tr>
80   - <td>&nbsp;</td>
81   - <td>小计</td>
82   - <td colspan="2">少驶班次</td>
83   - <td>&nbsp;</td>
84   - <td colspan="4">少驶公里</td>
85   - <td>&nbsp;</td>
86   - </tr>
  79 + <tbody class="list_lbqk">
  80 +
  81 + </tbody>
87 82 <tr><td colspan="10">&nbsp;</td></tr>
88 83 <tr>
89 84 <td colspan="10">服务临加增加情况</td>
90 85 </tr>
91 86 <tr>
92   - <td colspan="2">临加班次书</td>
93   - <td colspan="2">&nbsp;</td>
  87 + <td colspan="2">临加班次数</td>
  88 + <td colspan="2"><label id="ljbcs"></label> </td>
94 89 <td colspan="2">临加公里数</td>
95   - <td colspan="4">&nbsp;</td>
  90 + <td colspan="4"><label id="ljgls"></label> </td>
96 91 </tr>
97 92 <tr>
98 93 <td>路牌</td>
... ... @@ -100,8 +95,12 @@
100 95 <td>司售</td>
101 96 <td>地点</td>
102 97 <td>时间</td>
103   - <td colspan="5">简要情况</td>
  98 + <td>临加公里</td>
  99 + <td colspan="4">简要情况</td>
104 100 </tr>
  101 + <tbody class="list_ljqk">
  102 +
  103 + </tbody>
105 104 <tr><td colspan="10">&nbsp;</td></tr>
106 105 <tr>
107 106 <td colspan="10">当日汇总</td>
... ... @@ -115,22 +114,22 @@
115 114 </tr>
116 115 <tr>
117 116 <td colspan="2">班次</td>
118   - <td>&nbsp;</td>
119   - <td>&nbsp;</td>
  117 + <td><label id="jhbc"></label></td>
  118 + <td><label id="sjbc"></label></td>
120 119 <td colspan="3">&nbsp;</td>
121 120 <td colspan="3">&nbsp;</td>
122 121 </tr>
123 122 <tr>
124 123 <td colspan="2">公里</td>
125   - <td>&nbsp;</td>
126   - <td>&nbsp;</td>
  124 + <td><label id="jhgl"></label></td>
  125 + <td><label id="sjgl"></label></td>
127 126 <td colspan="3">&nbsp;</td>
128 127 <td colspan="3">&nbsp;</td>
129 128 </tr>
130 129 <tr>
131 130 <td colspan="2">临加</td>
132 131 <td>&nbsp;</td>
133   - <td>&nbsp;</td>
  132 + <td><label id="sjljgl"></label></td>
134 133 <td colspan="3">&nbsp;</td>
135 134 <td colspan="3">&nbsp;</td>
136 135 </tr>
... ... @@ -200,22 +199,93 @@
200 199 for(var code in result){
201 200 data.push({id: code, text: result[code]});
202 201 }
203   - console.log(data);
204 202 initPinYinSelect2('#line',data,'');
205 203  
206 204 })
207 205  
  206 + $("#query").on("click",function(){
  207 + var line=$("#line").val();;
  208 + var lineName=$(".select2-selection__rendered").html();
  209 + var date =$("#date").val();
  210 + if(line=="" || line==null){
  211 + layer.msg('请选择线路.');
  212 + }else if(date==""||date==null){
  213 + layer.msg('请选择日期.');
  214 + }else{
  215 + $("#xlid").html(lineName);
  216 + $("#dateid").html(date);
  217 + $get('/report/jobFwqk',{line:line,date:date},function(result){
  218 + var list_lbqk = template('list_lbqk',{list:result});
  219 + // 把渲染好的模版html文本追加到表格中
  220 + $('#forms .list_lbqk').html(list_lbqk);
  221 + })
  222 +
  223 + $get('/report/jobLjqk',{line:line,date:date},function(result){
  224 + var list_lbqk = template('list_ljqk',{list:result});
  225 + // 把渲染好的模版html文本追加到表格中
  226 + $('#forms .list_ljqk').html(list_lbqk);
  227 + })
  228 +
  229 + $get('/report/jobHzxx',{line:line,date:date},function(result){
  230 + console.log(result)
  231 + $("#jhbc").html(result.jhbc);
  232 + $("#sjbc").html(result.sjbc)
  233 + $("#jhgl").html(result.jhgl);
  234 + $("#sjgl").html(result.sjgl)
  235 + $("#sjljgl").html(result.ljgl);
  236 +
  237 + //临加
  238 + $("#ljbcs").html(result.ljbc);
  239 + $("#ljgls").html(result.ljgl)
  240 +
  241 + //烂班
  242 + $("#lbbcs").html(result.lbbc);
  243 + $("#lbgls").html(result.lbgl)
  244 + })
  245 +
  246 + }
  247 +
  248 + })
  249 +
208 250 });
209 251 </script>
210   -<script type="text/html" id="list_forms">
  252 +<script type="text/html" id="list_lbqk">
211 253 {{each list as obj i}}
212 254 <tr>
213   -
  255 + <td>{{obj.nr}}</td>
  256 + <td>{{obj.lp}}</td>
  257 + <td>{{obj.nbbm}}</td>
  258 + <td>{{obj.jgh}}</td>
  259 + <td>{{obj.dz}}</td>
  260 + <td>{{obj.sj}}</td>
  261 + <td>&nbsp;</td>
  262 + <td>{{obj.lbbc}}</td>
  263 + <td>{{obj.lblc}}</td>
  264 + <td>{{obj.jyqp}}</td>
214 265 </tr>
215 266 {{/each}}
216 267 {{if list.length == 0}}
217 268 <tr>
218   - <td colspan="6"><h6 class="muted">没有找到相关数据</h6></td>
  269 + <td colspan="10"><h6 class="muted">没有找到相关数据</h6></td>
219 270 </tr>
220 271 {{/if}}
221   -</script>
222 272 \ No newline at end of file
  273 +</script>
  274 +
  275 +<script type="text/html" id="list_ljqk">
  276 + {{each list as obj i}}
  277 + <tr>
  278 + <td>{{obj.lp}}</td>
  279 + <td>{{obj.nbbm}}</td>
  280 + <td>{{obj.jgh}}</td>
  281 + <td>{{obj.dz}}</td>
  282 + <td>{{obj.sj}}</td>
  283 + <td>{{obj.ljlc}}</td>
  284 + <td colspan="4">{{obj.jyqp}}</td>
  285 + </tr>
  286 + {{/each}}
  287 + {{if list.length == 0}}
  288 + <tr>
  289 + <td colspan="10"><h6 class="muted">没有找到相关数据</h6></td>
  290 + </tr>
  291 + {{/if}}
  292 +</script>
... ...
src/main/resources/static/pages/forms/statement/scheduleDaily.html
... ... @@ -51,7 +51,7 @@
51 51 <th colspan="40">线路调度日报</th>
52 52 </tr>
53 53 <tr>
54   - <td rowspan="3">路线</td>
  54 + <td rowspan="3">路线</td>
55 55 <td colspan="16"><c>全日</c>营运里程(公里)</td>
56 56 <td colspan="15"><c>全日</c>营运班次</td>
57 57 <td colspan="9">大间隔情况</td>
... ...
src/main/resources/static/pages/forms/statement/waybill.html
... ... @@ -222,6 +222,7 @@
222 222  
223 223 var params = new Array();
224 224 var jName = '';
  225 + var jGh = '';
225 226 $("#info tbody").on("click","tr",function(){
226 227 if($(this).children().size() < 2){
227 228 return;
... ... @@ -231,6 +232,7 @@
231 232 params[index] = $(this).text();
232 233 });
233 234 jName = params[0].split("\\")[0];
  235 + jGh = params[0].split("\\")[1];
234 236 var id = $("#"+params[1]).val();
235 237 $get('/realSchedule/MapById',{id:id},function(result){
236 238 result.scheduleDate = moment(result.scheduleDate).format("YYYY/MM/DD");
... ... @@ -238,13 +240,14 @@
238 240 // 把渲染好的模版html文本追加到表格中
239 241 $('#forms .ludan_1').html(ludan_1);
240 242 });
  243 + console.log(params);
241 244 $get('/realSchedule/queryListWaybill',{jName:jName,clZbh:params[1],lpName:params[2],date:date,line:line},function(result){
242 245 getTime(result);
243 246 var ludan_2 = template('ludan_2',{list:result});
244 247 // 把渲染好的模版html文本追加到表格中
245 248 $('#forms .ludan_2').html(ludan_2);
246 249 });
247   - $get('/realSchedule/findKMBC',{jName:jName,clZbh:params[1],lpName:params[2],date:date,line:line},function(result){
  250 + $get('/realSchedule/findKMBC',{jGh:jGh,clZbh:params[1],lpName:params[2],date:date,line:line},function(result){
248 251 var ludan_3 = template('ludan_3',result);
249 252 $('#forms .ludan_3').html(ludan_3);
250 253 });
... ...
src/main/resources/static/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdate.js
... ... @@ -21,6 +21,8 @@ angular.module(&#39;ScheduleApp&#39;).directive(
21 21 to: '=',
22 22 xlid: '=',
23 23 xlname: '=',
  24 + ttinfonames: '=',
  25 + ttinfoids: '=',
24 26 error: '='
25 27 },
26 28 controllerAs: '$saScpdateCtrl',
... ... @@ -116,6 +118,8 @@ angular.module(&#39;ScheduleApp&#39;).directive(
116 118 }
117 119  
118 120 var QClass = service.ttinfo;
  121 + var ttinfonames = [];
  122 + var ttinfoids = [];
119 123 QClass.val({xlid: xl_id, from: from_date, to: to_date},
120 124 function(result) {
121 125 scope[ctrlAs].$$ds = [];
... ... @@ -141,6 +145,9 @@ angular.module(&#39;ScheduleApp&#39;).directive(
141 145  
142 146 if (obj.errorbc > 0) {
143 147 errorTTInfos ++;
  148 + } else {
  149 + ttinfonames.push(obj.ttname);
  150 + ttinfoids.push(obj.ttid);
144 151 }
145 152 });
146 153  
... ... @@ -148,8 +155,9 @@ angular.module(&#39;ScheduleApp&#39;).directive(
148 155 scope[ctrlAs].$$internalmodel = undefined;
149 156 scope[ctrlAs].error = "时刻表有错误班次";
150 157 } else {
151   -
152 158 scope[ctrlAs].$$internalmodel = "ok";
  159 + scope[ctrlAs].ttinfonames = ttinfonames.join(",");
  160 + scope[ctrlAs].ttinfoids = ttinfoids.join(",");
153 161 }
154 162  
155 163 } else {
... ...
src/main/resources/static/pages/scheduleApp/module/common/prj-common-directive.js
... ... @@ -3688,354 +3688,362 @@ angular.module(&#39;ScheduleApp&#39;).directive(&#39;saBcgroup&#39;, [
3688 3688 }
3689 3689 }
3690 3690 ]);
3691   -/**
3692   - * saTimeTable指令,时刻表显示指令,excel表格形式,支持菜单,事件处理。
3693   - * name(必须),控件的名字
3694   - * celldbclickFn,单元格双击事件
3695   - * ds,外部数据源
3696   - *
3697   - * TODO:优化开发中
3698   - *
3699   - */
3700   -angular.module('ScheduleApp').directive('saTimetable', ['$compile', '$window',
3701   - function($compile, $window) {
3702   - return {
3703   - restrict: 'E',
3704   - templateUrl: '/pages/scheduleApp/module/common/dts2/ttinfotable/saTimeTableTemplate.html',
3705   - scope: { // 独立作用域
3706   - // 注意:数据暂时从外部ngModel里获取,以后内部自己处理
3707   - ds: "=ngModel",
3708   - celldbclickFn: "&celldbclick"
3709   -
3710   - // TODO:
3711   -
3712   - },
3713   - controllerAs: "$saTimeTableCtrl",
3714   - bindToController: true,
3715   - controller: function() {
3716   - var self = this;
3717   - this.$$headToolTip = ""; // 表头tooltip信息
3718   -
3719   - // TODO:
3720   - },
3721   -
3722   - /**,
3723   - * compile阶段,angular还没有编译模版,根据需要可以修改模版dom
3724   - * @param tElem
3725   - * @param tAttrs
3726   - * @returns {{pre: Function, post: Function}}
3727   - */
3728   - compile: function(tElem, tAttrs) {
3729   - // 获取属性
3730   - var $attr_name = tAttrs["name"]; // 控件的名字
3731   - if (!$attr_name) {
3732   - throw new Error("saTimeTable指令 name属性required");
3733   - }
3734   - var $attr_celldbclick = tAttrs["celldbclick"]; // 单元格双击事件名
3735   -
3736   - // 内部controlAs名字
3737   - var ctrlAs = '$saTimeTableCtrl';
3738   -
3739   - // 当前选中的cell
3740   - var startRowIndex = undefined;
3741   - var startColIndex = undefined;
3742   - var shiftKey = false; // shift键是否被按住
3743   - var ctrlKey = false; // ctrl是否被按住
3744   - // shift选中的cell
3745   - var shiftCells = [];
3746   -
3747   - // TODO:
3748   -
3749   - return {
3750   - pre: function(scope, element, attr) {
3751   - // TODO:
3752   - //alert(element.find("#tooltipTest").html());
3753   - //$compile(element.find("#tooltipTest"))(scope);
3754   -
3755   - },
3756   - post: function(scope, element, attr) {
3757   - // TODO:
3758   -
3759   - // ------------------- dom事件处理function -----------------//
3760   - scope[ctrlAs].$$cell_click = function(rowindex, colindex, cell) {
3761   - console.log("click " + "row=" + rowindex + ",col=" + colindex);
3762   - var internal_ds = scope[ctrlAs].ds.detailInfos;
3763   -
3764   - if (cell.ttdid) { // 是班次的单元格才能操作
3765   - cell.sel = !cell.sel;
3766   - }
3767   -
3768   - };
3769   - scope[ctrlAs].$$cell_dbclick = function(rowindex, colindex, cell) {
3770   - if (cell.ttdid) { // 是班次的单元格才能操作
3771   - if ($attr_celldbclick) {
3772   - // 注意调用方法
3773   - scope[ctrlAs].celldbclickFn()(rowindex, colindex);
3774   - }
3775   - }
3776   - };
3777   -
3778   - // ------------------- 监控function ------------------//
3779   - // 监控明细数据,生成表头的tooltip
3780   - scope.$watch(
3781   - function() {
3782   - return scope[ctrlAs].ds;
3783   - },
3784   - function(newValue, oldValue) {
3785   - if (newValue &&
3786   - newValue.detailHeads &&
3787   - newValue.detailHeads.length > 0) {
3788   - var tooltip = [];
3789   - tooltip.push("出场");
3790   - angular.forEach(newValue.detailHeads, function(value) {
3791   - if (value != "出场" &&
3792   - value != "路牌" &&
3793   - value != "进场" &&
3794   - value != "空驶班次/空驶里程" &&
3795   - value != "运营班次/运营里程" ) {
3796   - var exist = false;
3797   - angular.forEach(tooltip, function(tip) {
3798   - if (tip == value) {
3799   - exist = true;
3800   - }
3801   - });
3802   - if (!exist) {
3803   - tooltip.push(value);
3804   - }
3805   - }
3806   - });
3807   - tooltip.push("进场");
3808   - scope[ctrlAs].$$headToolTip = tooltip.join(",");
3809   - }
3810   - },
3811   - true
3812   - )
3813   - }
3814   - };
3815   - }
3816   -
3817   - };
3818   - }
3819   -]);
3820   -
3821   -/**
3822   - * saScpdate指令(非通用指令,只在排版计划form中使用)。
3823   - * 属性如下:
3824   - * name(必须):控件的名字
3825   - * xlid(必须):线路id
3826   - * xlname(必须):线路名字
3827   - * from(必须):独立作用域-绑定的开始时间属性名
3828   - * to(必须):独立作用域-绑定的结束时间属性名
3829   - * error(必须):独立作用域-绑定的错误描述属性名
3830   - */
3831   -angular.module('ScheduleApp').directive(
3832   - 'saScpdate',
3833   - [
3834   - 'SchedulePlanManageService_g',
3835   - function(service) {
3836   - return {
3837   - restrict: 'E',
3838   - templateUrl: '/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdateTemplate.html',
3839   - scope: {
3840   - from: '=',
3841   - to: '=',
3842   - xlid: '=',
3843   - xlname: '=',
3844   - error: '='
3845   - },
3846   - controllerAs: '$saScpdateCtrl',
3847   - bindToController: true,
3848   - controller: function() {
3849   - var self = this;
3850   -
3851   - // 内部ng-model值,用于和required配对
3852   - self.$$internalmodel = undefined;
3853   -
3854   - // 内部数据源(时刻表的一些信息)
3855   - self.$$ds = [];
3856   -
3857   - },
3858   - compile: function(tElem, tAttrs) {
3859   - // 获取所有属性,并验证
3860   - var $name_attr = tAttrs['name']; // 控件的名字
3861   - if (!$name_attr) {
3862   - throw "必须有名称属性";
3863   - }
3864   -
3865   - // controlAs名字
3866   - var ctrlAs = '$saScpdateCtrl';
3867   -
3868   - // 线路id
3869   - var xl_id = undefined;
3870   - // 线路名字
3871   - var xl_name = undefined;
3872   - // 开始时间
3873   - var from_date = undefined;
3874   - // 结束时间
3875   - var to_date = undefined;
3876   -
3877   - // 内部添加required验证,将所有的错误应用到required验证上去
3878   - tElem.find("div").attr("required", "");
3879   -
3880   - return {
3881   - pre: function(scope, element, attr) {
3882   -
3883   - },
3884   -
3885   - post: function(scope, element, attr) {
3886   - // 属性值
3887   - if ($name_attr) {
3888   - scope[ctrlAs]["$name_attr"] = $name_attr;
3889   - }
3890   -
3891   - // 开始日期open属性,及方法
3892   - scope[ctrlAs].$$fromDateOpen = false;
3893   - scope[ctrlAs].$$fromDate_open = function() {
3894   - scope[ctrlAs].$$fromDateOpen = true;
3895   - };
3896   -
3897   - // 结束日期open属性,及方法
3898   - scope[ctrlAs].$$toDateOpen = false;
3899   - scope[ctrlAs].$$toDate_open = function() {
3900   - scope[ctrlAs].$$toDateOpen = true;
3901   - };
3902   -
3903   -
3904   - // 内部模型刷新
3905   - scope[ctrlAs].$$internal_model_refresh = function() {
3906   - if (!xl_id) {
3907   - scope[ctrlAs].$$internalmodel = undefined;
3908   - scope[ctrlAs].error = "线路必须选择";
3909   - return;
3910   - }
3911   - if (!xl_name) {
3912   - scope[ctrlAs].$$internalmodel = undefined;
3913   - scope[ctrlAs].error = "线路必须选择";
3914   - return;
3915   - }
3916   -
3917   - if (!from_date) {
3918   - scope[ctrlAs].$$internalmodel = undefined;
3919   - scope[ctrlAs].error = "开始日期必须选择";
3920   - return;
3921   - }
3922   - if (!to_date) {
3923   - scope[ctrlAs].$$internalmodel = undefined;
3924   - scope[ctrlAs].error = "结束日期必须选择";
3925   - return;
3926   - }
3927   - if (from_date > to_date) {
3928   - scope[ctrlAs].$$internalmodel = undefined;
3929   - scope[ctrlAs].error = "开始日期必须在结束日期之前";
3930   - return;
3931   - }
3932   -
3933   - if (!scope[ctrlAs].$$ds || scope[ctrlAs].$$ds.length == 0) {
3934   - scope[ctrlAs].$$internalmodel = undefined;
3935   - scope[ctrlAs].error = "无可用时刻表";
3936   - }
3937   -
3938   - var QClass = service.ttinfo;
3939   - QClass.val({xlid: xl_id, from: from_date, to: to_date},
3940   - function(result) {
3941   - scope[ctrlAs].$$ds = [];
3942   -
3943   - var errorTTInfos = 0;
3944   -
3945   - if (result && result.data && result.data.infos && result.data.infos.length > 0) {
3946   - angular.forEach(result.data.infos, function(obj) {
3947   - scope[ctrlAs].$$ds.push({
3948   - xlid: xl_id,
3949   - ttid: obj.ttid,
3950   - xlname: xl_name,
3951   - ttname: obj.ttname,
3952   -
3953   - allbc: obj.allbc,
3954   - inbc: obj.inbc,
3955   - outbc: obj.outbc,
3956   - yybc: obj.yybc,
3957   -
3958   - errorbc: obj.errorbc
3959   -
3960   - });
3961   -
3962   - if (obj.errorbc > 0) {
3963   - errorTTInfos ++;
3964   - }
3965   - });
3966   -
3967   - if (errorTTInfos > 0) {
3968   - scope[ctrlAs].$$internalmodel = undefined;
3969   - scope[ctrlAs].error = "时刻表有错误班次";
3970   - } else {
3971   -
3972   - scope[ctrlAs].$$internalmodel = "ok";
3973   - }
3974   -
3975   - } else {
3976   - scope[ctrlAs].$$internalmodel = undefined;
3977   - scope[ctrlAs].error = "无可用时刻表";
3978   - }
3979   - },
3980   - function() {
3981   - scope[ctrlAs].$$internalmodel = undefined;
3982   - scope[ctrlAs].error = "获取时刻表数据失败!";
3983   - }
3984   - );
3985   -
3986   -
3987   - scope[ctrlAs].$$internalmodel = "ok";
3988   - };
3989   -
3990   - scope[ctrlAs].$$internal_model_refresh(); // 初始执行
3991   -
3992   - //--------------------- 监控属性方法 -------------------//
3993   - // 监控线路id模型值变化
3994   - scope.$watch(
3995   - function() {
3996   - return scope[ctrlAs].xlid;
3997   - },
3998   - function(newValue, oldValue) {
3999   - xl_id = newValue;
4000   - scope[ctrlAs].$$internal_model_refresh();
4001   - }
4002   - );
4003   - // 监控线路name模型值变化
4004   - scope.$watch(
4005   - function() {
4006   - return scope[ctrlAs].xlname;
4007   - },
4008   - function(newValue, oldValue) {
4009   - xl_name = newValue;
4010   - scope[ctrlAs].$$internal_model_refresh();
4011   - }
4012   - );
4013   -
4014   - // 监控开始时间模型值变化
4015   - scope.$watch(
4016   - function() {
4017   - return scope[ctrlAs].from;
4018   - },
4019   - function(newValue, oldValue) {
4020   - from_date = newValue;
4021   - scope[ctrlAs].$$internal_model_refresh();
4022   - }
4023   - );
4024   - // 监控结束时间模型值变化
4025   - scope.$watch(
4026   - function() {
4027   - return scope[ctrlAs].to;
4028   - },
4029   - function(newValue, oldValue) {
4030   - to_date = newValue;
4031   - scope[ctrlAs].$$internal_model_refresh();
4032   - }
4033   - );
  3691 +/**
  3692 + * saTimeTable指令,时刻表显示指令,excel表格形式,支持菜单,事件处理。
  3693 + * name(必须),控件的名字
  3694 + * celldbclickFn,单元格双击事件
  3695 + * ds,外部数据源
  3696 + *
  3697 + * TODO:优化开发中
  3698 + *
  3699 + */
  3700 +angular.module('ScheduleApp').directive('saTimetable', ['$compile', '$window',
  3701 + function($compile, $window) {
  3702 + return {
  3703 + restrict: 'E',
  3704 + templateUrl: '/pages/scheduleApp/module/common/dts2/ttinfotable/saTimeTableTemplate.html',
  3705 + scope: { // 独立作用域
  3706 + // 注意:数据暂时从外部ngModel里获取,以后内部自己处理
  3707 + ds: "=ngModel",
  3708 + celldbclickFn: "&celldbclick"
  3709 +
  3710 + // TODO:
  3711 +
  3712 + },
  3713 + controllerAs: "$saTimeTableCtrl",
  3714 + bindToController: true,
  3715 + controller: function() {
  3716 + var self = this;
  3717 + this.$$headToolTip = ""; // 表头tooltip信息
  3718 +
  3719 + // TODO:
  3720 + },
  3721 +
  3722 + /**,
  3723 + * compile阶段,angular还没有编译模版,根据需要可以修改模版dom
  3724 + * @param tElem
  3725 + * @param tAttrs
  3726 + * @returns {{pre: Function, post: Function}}
  3727 + */
  3728 + compile: function(tElem, tAttrs) {
  3729 + // 获取属性
  3730 + var $attr_name = tAttrs["name"]; // 控件的名字
  3731 + if (!$attr_name) {
  3732 + throw new Error("saTimeTable指令 name属性required");
  3733 + }
  3734 + var $attr_celldbclick = tAttrs["celldbclick"]; // 单元格双击事件名
  3735 +
  3736 + // 内部controlAs名字
  3737 + var ctrlAs = '$saTimeTableCtrl';
  3738 +
  3739 + // 当前选中的cell
  3740 + var startRowIndex = undefined;
  3741 + var startColIndex = undefined;
  3742 + var shiftKey = false; // shift键是否被按住
  3743 + var ctrlKey = false; // ctrl是否被按住
  3744 + // shift选中的cell
  3745 + var shiftCells = [];
  3746 +
  3747 + // TODO:
  3748 +
  3749 + return {
  3750 + pre: function(scope, element, attr) {
  3751 + // TODO:
  3752 + //alert(element.find("#tooltipTest").html());
  3753 + //$compile(element.find("#tooltipTest"))(scope);
  3754 +
  3755 + },
  3756 + post: function(scope, element, attr) {
  3757 + // TODO:
  3758 +
  3759 + // ------------------- dom事件处理function -----------------//
  3760 + scope[ctrlAs].$$cell_click = function(rowindex, colindex, cell) {
  3761 + console.log("click " + "row=" + rowindex + ",col=" + colindex);
  3762 + var internal_ds = scope[ctrlAs].ds.detailInfos;
  3763 +
  3764 + if (cell.ttdid) { // 是班次的单元格才能操作
  3765 + cell.sel = !cell.sel;
  3766 + }
  3767 +
  3768 + };
  3769 + scope[ctrlAs].$$cell_dbclick = function(rowindex, colindex, cell) {
  3770 + if (cell.ttdid) { // 是班次的单元格才能操作
  3771 + if ($attr_celldbclick) {
  3772 + // 注意调用方法
  3773 + scope[ctrlAs].celldbclickFn()(rowindex, colindex);
  3774 + }
  3775 + }
  3776 + };
  3777 +
  3778 + // ------------------- 监控function ------------------//
  3779 + // 监控明细数据,生成表头的tooltip
  3780 + scope.$watch(
  3781 + function() {
  3782 + return scope[ctrlAs].ds;
  3783 + },
  3784 + function(newValue, oldValue) {
  3785 + if (newValue &&
  3786 + newValue.detailHeads &&
  3787 + newValue.detailHeads.length > 0) {
  3788 + var tooltip = [];
  3789 + tooltip.push("出场");
  3790 + angular.forEach(newValue.detailHeads, function(value) {
  3791 + if (value != "出场" &&
  3792 + value != "路牌" &&
  3793 + value != "进场" &&
  3794 + value != "空驶班次/空驶里程" &&
  3795 + value != "运营班次/运营里程" ) {
  3796 + var exist = false;
  3797 + angular.forEach(tooltip, function(tip) {
  3798 + if (tip == value) {
  3799 + exist = true;
  3800 + }
  3801 + });
  3802 + if (!exist) {
  3803 + tooltip.push(value);
  3804 + }
  3805 + }
  3806 + });
  3807 + tooltip.push("进场");
  3808 + scope[ctrlAs].$$headToolTip = tooltip.join(",");
  3809 + }
  3810 + },
  3811 + true
  3812 + )
  3813 + }
  3814 + };
  3815 + }
  3816 +
  3817 + };
  3818 + }
  3819 +]);
4034 3820  
4035   - }
4036   - };
4037   - }
4038   - };
4039   - }
4040   - ]
  3821 +/**
  3822 + * saScpdate指令(非通用指令,只在排版计划form中使用)。
  3823 + * 属性如下:
  3824 + * name(必须):控件的名字
  3825 + * xlid(必须):线路id
  3826 + * xlname(必须):线路名字
  3827 + * from(必须):独立作用域-绑定的开始时间属性名
  3828 + * to(必须):独立作用域-绑定的结束时间属性名
  3829 + * error(必须):独立作用域-绑定的错误描述属性名
  3830 + */
  3831 +angular.module('ScheduleApp').directive(
  3832 + 'saScpdate',
  3833 + [
  3834 + 'SchedulePlanManageService_g',
  3835 + function(service) {
  3836 + return {
  3837 + restrict: 'E',
  3838 + templateUrl: '/pages/scheduleApp/module/common/dts2/scheduleplan/saScpdateTemplate.html',
  3839 + scope: {
  3840 + from: '=',
  3841 + to: '=',
  3842 + xlid: '=',
  3843 + xlname: '=',
  3844 + ttinfonames: '=',
  3845 + ttinfoids: '=',
  3846 + error: '='
  3847 + },
  3848 + controllerAs: '$saScpdateCtrl',
  3849 + bindToController: true,
  3850 + controller: function() {
  3851 + var self = this;
  3852 +
  3853 + // 内部ng-model值,用于和required配对
  3854 + self.$$internalmodel = undefined;
  3855 +
  3856 + // 内部数据源(时刻表的一些信息)
  3857 + self.$$ds = [];
  3858 +
  3859 + },
  3860 + compile: function(tElem, tAttrs) {
  3861 + // 获取所有属性,并验证
  3862 + var $name_attr = tAttrs['name']; // 控件的名字
  3863 + if (!$name_attr) {
  3864 + throw "必须有名称属性";
  3865 + }
  3866 +
  3867 + // controlAs名字
  3868 + var ctrlAs = '$saScpdateCtrl';
  3869 +
  3870 + // 线路id
  3871 + var xl_id = undefined;
  3872 + // 线路名字
  3873 + var xl_name = undefined;
  3874 + // 开始时间
  3875 + var from_date = undefined;
  3876 + // 结束时间
  3877 + var to_date = undefined;
  3878 +
  3879 + // 内部添加required验证,将所有的错误应用到required验证上去
  3880 + tElem.find("div").attr("required", "");
  3881 +
  3882 + return {
  3883 + pre: function(scope, element, attr) {
  3884 +
  3885 + },
  3886 +
  3887 + post: function(scope, element, attr) {
  3888 + // 属性值
  3889 + if ($name_attr) {
  3890 + scope[ctrlAs]["$name_attr"] = $name_attr;
  3891 + }
  3892 +
  3893 + // 开始日期open属性,及方法
  3894 + scope[ctrlAs].$$fromDateOpen = false;
  3895 + scope[ctrlAs].$$fromDate_open = function() {
  3896 + scope[ctrlAs].$$fromDateOpen = true;
  3897 + };
  3898 +
  3899 + // 结束日期open属性,及方法
  3900 + scope[ctrlAs].$$toDateOpen = false;
  3901 + scope[ctrlAs].$$toDate_open = function() {
  3902 + scope[ctrlAs].$$toDateOpen = true;
  3903 + };
  3904 +
  3905 +
  3906 + // 内部模型刷新
  3907 + scope[ctrlAs].$$internal_model_refresh = function() {
  3908 + if (!xl_id) {
  3909 + scope[ctrlAs].$$internalmodel = undefined;
  3910 + scope[ctrlAs].error = "线路必须选择";
  3911 + return;
  3912 + }
  3913 + if (!xl_name) {
  3914 + scope[ctrlAs].$$internalmodel = undefined;
  3915 + scope[ctrlAs].error = "线路必须选择";
  3916 + return;
  3917 + }
  3918 +
  3919 + if (!from_date) {
  3920 + scope[ctrlAs].$$internalmodel = undefined;
  3921 + scope[ctrlAs].error = "开始日期必须选择";
  3922 + return;
  3923 + }
  3924 + if (!to_date) {
  3925 + scope[ctrlAs].$$internalmodel = undefined;
  3926 + scope[ctrlAs].error = "结束日期必须选择";
  3927 + return;
  3928 + }
  3929 + if (from_date > to_date) {
  3930 + scope[ctrlAs].$$internalmodel = undefined;
  3931 + scope[ctrlAs].error = "开始日期必须在结束日期之前";
  3932 + return;
  3933 + }
  3934 +
  3935 + if (!scope[ctrlAs].$$ds || scope[ctrlAs].$$ds.length == 0) {
  3936 + scope[ctrlAs].$$internalmodel = undefined;
  3937 + scope[ctrlAs].error = "无可用时刻表";
  3938 + }
  3939 +
  3940 + var QClass = service.ttinfo;
  3941 + var ttinfonames = [];
  3942 + var ttinfoids = [];
  3943 + QClass.val({xlid: xl_id, from: from_date, to: to_date},
  3944 + function(result) {
  3945 + scope[ctrlAs].$$ds = [];
  3946 +
  3947 + var errorTTInfos = 0;
  3948 +
  3949 + if (result && result.data && result.data.infos && result.data.infos.length > 0) {
  3950 + angular.forEach(result.data.infos, function(obj) {
  3951 + scope[ctrlAs].$$ds.push({
  3952 + xlid: xl_id,
  3953 + ttid: obj.ttid,
  3954 + xlname: xl_name,
  3955 + ttname: obj.ttname,
  3956 +
  3957 + allbc: obj.allbc,
  3958 + inbc: obj.inbc,
  3959 + outbc: obj.outbc,
  3960 + yybc: obj.yybc,
  3961 +
  3962 + errorbc: obj.errorbc
  3963 +
  3964 + });
  3965 +
  3966 + if (obj.errorbc > 0) {
  3967 + errorTTInfos ++;
  3968 + } else {
  3969 + ttinfonames.push(obj.ttname);
  3970 + ttinfoids.push(obj.ttid);
  3971 + }
  3972 + });
  3973 +
  3974 + if (errorTTInfos > 0) {
  3975 + scope[ctrlAs].$$internalmodel = undefined;
  3976 + scope[ctrlAs].error = "时刻表有错误班次";
  3977 + } else {
  3978 + scope[ctrlAs].$$internalmodel = "ok";
  3979 + scope[ctrlAs].ttinfonames = ttinfonames.join(",");
  3980 + scope[ctrlAs].ttinfoids = ttinfoids.join(",");
  3981 + }
  3982 +
  3983 + } else {
  3984 + scope[ctrlAs].$$internalmodel = undefined;
  3985 + scope[ctrlAs].error = "无可用时刻表";
  3986 + }
  3987 + },
  3988 + function() {
  3989 + scope[ctrlAs].$$internalmodel = undefined;
  3990 + scope[ctrlAs].error = "获取时刻表数据失败!";
  3991 + }
  3992 + );
  3993 +
  3994 +
  3995 + scope[ctrlAs].$$internalmodel = "ok";
  3996 + };
  3997 +
  3998 + scope[ctrlAs].$$internal_model_refresh(); // 初始执行
  3999 +
  4000 + //--------------------- 监控属性方法 -------------------//
  4001 + // 监控线路id模型值变化
  4002 + scope.$watch(
  4003 + function() {
  4004 + return scope[ctrlAs].xlid;
  4005 + },
  4006 + function(newValue, oldValue) {
  4007 + xl_id = newValue;
  4008 + scope[ctrlAs].$$internal_model_refresh();
  4009 + }
  4010 + );
  4011 + // 监控线路name模型值变化
  4012 + scope.$watch(
  4013 + function() {
  4014 + return scope[ctrlAs].xlname;
  4015 + },
  4016 + function(newValue, oldValue) {
  4017 + xl_name = newValue;
  4018 + scope[ctrlAs].$$internal_model_refresh();
  4019 + }
  4020 + );
  4021 +
  4022 + // 监控开始时间模型值变化
  4023 + scope.$watch(
  4024 + function() {
  4025 + return scope[ctrlAs].from;
  4026 + },
  4027 + function(newValue, oldValue) {
  4028 + from_date = newValue;
  4029 + scope[ctrlAs].$$internal_model_refresh();
  4030 + }
  4031 + );
  4032 + // 监控结束时间模型值变化
  4033 + scope.$watch(
  4034 + function() {
  4035 + return scope[ctrlAs].to;
  4036 + },
  4037 + function(newValue, oldValue) {
  4038 + to_date = newValue;
  4039 + scope[ctrlAs].$$internal_model_refresh();
  4040 + }
  4041 + );
  4042 +
  4043 + }
  4044 + };
  4045 + }
  4046 + };
  4047 + }
  4048 + ]
4041 4049 );
4042 4050 \ No newline at end of file
... ...
src/main/resources/static/pages/scheduleApp/module/core/schedulePlanManage/form.html
... ... @@ -114,6 +114,8 @@
114 114 xlname="ctrl.schedulePlanManageForSave.xl.name"
115 115 from="ctrl.schedulePlanManageForSave.scheduleFromTime"
116 116 to="ctrl.schedulePlanManageForSave.scheduleToTime"
  117 + ttinfonames="ctrl.schedulePlanManageForSave.ttInfoNames"
  118 + ttinfoids="ctrl.schedulePlanManageForSave.ttInfoIds"
117 119 error="ctrl.scperror"
118 120 required
119 121 >
... ...
src/main/resources/static/pages/scheduleApp/module/core/schedulePlanManage/list.html
... ... @@ -81,7 +81,11 @@
81 81 <span ng-bind="info.xl.name"></span>
82 82 </td>
83 83 <td>
84   - <span ng-bind="info.ttInfoNames"></span>
  84 + <div ng-repeat="tinfo in info.rst">
  85 + <a ui-sref="ttInfoDetailManage_edit3({xlid: info.xl.id, ttid : tinfo.ttInfoId, xlname: info.xl.name, ttname : tinfo.ttInfoName, rflag : true})">
  86 + {{tinfo.ttInfoName}}
  87 + </a>
  88 + </div>
85 89 </td>
86 90 <td>
87 91 <span ng-bind="info.scheduleFromTime | date: 'yyyy-MM-dd '"></span>
... ...
src/main/resources/static/pages/scheduleApp/module/core/schedulePlanManage/module.js
... ... @@ -96,12 +96,61 @@ angular.module(&#39;ScheduleApp&#39;).controller(
96 96 self.doPage = function() {
97 97 var page = SPlan.list(self.searchCondition(), function() {
98 98 service.getPage(page);
  99 +
  100 + // 重新组装关联时刻表信息
  101 + if (page.content) {
  102 + angular.forEach(page.content, function(ttinfo) {
  103 + var rst = [];
  104 + var temp1 = [];
  105 + var temp2 = [];
  106 + if (ttinfo.ttInfoNames && ttinfo.ttInfoIds) {
  107 + temp1 = ttinfo.ttInfoNames.split(",");
  108 + temp2 = ttinfo.ttInfoIds.split(",");
  109 + }
  110 +
  111 + if (temp1.length == temp2.length) {
  112 + for (var i = 0; i < temp1.length; i++) {
  113 + rst.push({
  114 + ttInfoName: temp1[i],
  115 + ttInfoId: temp2[i]
  116 + });
  117 + }
  118 + }
  119 +
  120 + ttinfo.rst = rst;
  121 + });
  122 + }
99 123 });
100 124 };
  125 +
101 126 self.reset = function() {
102 127 service.resetStatus();
103 128 var page = SPlan.list(self.searchCondition(), function() {
104 129 service.getPage(page);
  130 +
  131 + // 重新组装关联时刻表信息
  132 + if (page.content) {
  133 + angular.forEach(page.content, function(ttinfo) {
  134 + var rst = [];
  135 + var temp1 = [];
  136 + var temp2 = [];
  137 + if (ttinfo.ttInfoNames && ttinfo.ttInfoIds) {
  138 + temp1 = ttinfo.ttInfoNames.split(",");
  139 + temp2 = ttinfo.ttInfoIds.split(",");
  140 + }
  141 +
  142 + if (temp1.length == temp2.length) {
  143 + for (var i = 0; i < temp1.length; i++) {
  144 + rst.push({
  145 + ttInfoName: temp1[i],
  146 + ttInfoId: temp2[i]
  147 + });
  148 + }
  149 + }
  150 +
  151 + ttinfo.rst = rst;
  152 + });
  153 + }
105 154 });
106 155 };
107 156  
... ...
src/test/java/com/bsth/service/schedule/rules/DroolsRulesTest.java
... ... @@ -18,9 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
18 18 import org.springframework.boot.test.SpringApplicationConfiguration;
19 19 import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
20 20  
21   -import java.util.ArrayList;
22 21 import java.util.Arrays;
23   -import java.util.List;
24 22  
25 23 @RunWith(SpringJUnit4ClassRunner.class)
26 24 @SpringApplicationConfiguration(classes = {Application.class})
... ... @@ -33,30 +31,30 @@ public class DroolsRulesTest {
33 31 private KieBase kieBase;
34 32  
35 33 // @Test
36   - public void helloWorldDrlTest() throws Exception {
37   - // 1、创建session,内部配置的是stateful
38   - KieSession session = kieBase.newKieSession();
39   -
40   - // 1.1 设置gloable对象,在drl中通过别名使用
41   - List<String> gloableList = new ArrayList<String>();
42   - session.setGlobal("list", gloableList);
43   -
44   - // 1.2 可以设置一些监听器,再议
45   -
46   - // 2、创建fact对象
47   - Message message = new Message();
48   - message.setMessage("Hello World");
49   - message.setStatus(Message.HELLO);
50   - session.insert(message);
51   -
52   - // 3、执行rule
53   - session.fireAllRules();
54   -
55   - System.out.println(gloableList);
56   -
57   - // 4、执行完毕销毁,有日志的也要关闭
58   - session.dispose();
59   - }
  34 +// public void helloWorldDrlTest() throws Exception {
  35 +// // 1、创建session,内部配置的是stateful
  36 +// KieSession session = kieBase.newKieSession();
  37 +//
  38 +// // 1.1 设置gloable对象,在drl中通过别名使用
  39 +// List<String> gloableList = new ArrayList<String>();
  40 +// session.setGlobal("list", gloableList);
  41 +//
  42 +// // 1.2 可以设置一些监听器,再议
  43 +//
  44 +// // 2、创建fact对象
  45 +// Message message = new Message();
  46 +// message.setMessage("Hello World");
  47 +// message.setStatus(Message.HELLO);
  48 +// session.insert(message);
  49 +//
  50 +// // 3、执行rule
  51 +// session.fireAllRules();
  52 +//
  53 +// System.out.println(gloableList);
  54 +//
  55 +// // 4、执行完毕销毁,有日志的也要关闭
  56 +// session.dispose();
  57 +// }
60 58  
61 59 // @Test
62 60 public void ttinfoDrlTest() throws Exception {
... ...