Commit 3308eb29cfb4ad55a187918de5440ae05dbfc186

Authored by 潘钊
2 parents 66d81f18 bcf1dcf2

Merge branch 'minhang' of http://222.66.0.204:8090/panzhaov5/bsth_control into minhang

src/main/java/com/bsth/controller/oil/YlbController.java
@@ -62,6 +62,18 @@ public class YlbController extends BaseController<Ylb, Integer>{ @@ -62,6 +62,18 @@ public class YlbController extends BaseController<Ylb, Integer>{
62 return list; 62 return list;
63 } 63 }
64 64
  65 +
  66 + @RequestMapping(value = "/saveYlbList",method = RequestMethod.GET)
  67 + public Map<String, Object> saveYlbList(@RequestParam Map<String, Object> map){
  68 + Map<String, Object> list=new HashMap<String, Object>();
  69 + try {
  70 + list = yblService.saveYlbList(map);
  71 + } catch (Exception e) {
  72 + // TODO Auto-generated catch block
  73 + e.printStackTrace();
  74 + }
  75 + return list;
  76 + }
65 /** 77 /**
66 * 拆分油量 78 * 拆分油量
67 * @param map 79 * @param map
@@ -69,7 +81,12 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{ @@ -69,7 +81,12 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
69 */ 81 */
70 @RequestMapping(value = "/sort",method = RequestMethod.GET) 82 @RequestMapping(value = "/sort",method = RequestMethod.GET)
71 public Map<String, Object> sort(@RequestParam Map<String, Object> map){ 83 public Map<String, Object> sort(@RequestParam Map<String, Object> map){
72 - Map<String, Object> list=yblService.sort(map); 84 + Map<String, Object> list=new HashMap<String, Object>();
  85 + try {
  86 + list=yblService.sort(map);
  87 + } catch (Exception e) {
  88 + // TODO: handle exception
  89 + }
73 return list; 90 return list;
74 } 91 }
75 92
@@ -97,7 +114,12 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{ @@ -97,7 +114,12 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
97 */ 114 */
98 @RequestMapping(value = "/checkYl",method = RequestMethod.GET) 115 @RequestMapping(value = "/checkYl",method = RequestMethod.GET)
99 public Map<String, Object> checkYl(@RequestParam Map<String, Object> map){ 116 public Map<String, Object> checkYl(@RequestParam Map<String, Object> map){
100 - Map<String, Object> list=yblService.checkYl(map); 117 + Map<String, Object> list=new HashMap<String, Object>();
  118 + try {
  119 + list=yblService.checkYl(map);
  120 + } catch (Exception e) {
  121 + // TODO: handle exception
  122 + }
101 return list; 123 return list;
102 } 124 }
103 125
@@ -157,6 +179,23 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{ @@ -157,6 +179,23 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
157 } 179 }
158 180
159 181
  182 +
  183 +
  184 + /**
  185 + *
  186 + * @Title: list
  187 + * @Description: TODO(多条件分页查询)
  188 + * @param @param map 查询条件
  189 + * @param @param page 页码
  190 + * @param @param size 每页显示数量
  191 + * @throws
  192 + */
  193 + @RequestMapping(value = "/ylbList",method = RequestMethod.GET)
  194 + public List<Ylb> ylbList(@RequestParam Map<String, Object> map){
  195 + List<Ylb> ylbList=yblService.listYlb(map);
  196 + return ylbList;
  197 + }
  198 +
160 @RequestMapping(value="/oilListMonth") 199 @RequestMapping(value="/oilListMonth")
161 public List<Ylb> oilListMonth(@RequestParam String line,@RequestParam String date){ 200 public List<Ylb> oilListMonth(@RequestParam String line,@RequestParam String date){
162 return yblService.oilListMonth(line, date); 201 return yblService.oilListMonth(line, date);
src/main/java/com/bsth/entity/oil/Ylb.java
@@ -38,7 +38,7 @@ public class Ylb { @@ -38,7 +38,7 @@ public class Ylb {
38 private String shyy; 38 private String shyy;
39 private Double zlc=0.0; 39 private Double zlc=0.0;
40 private int yhlx; 40 private int yhlx;
41 - private String rylx; 41 + private String rylx="0";
42 private Double ns=0.0; 42 private Double ns=0.0;
43 private Double fyylc=0.0; 43 private Double fyylc=0.0;
44 private Double jhzlc=0.0; 44 private Double jhzlc=0.0;
src/main/java/com/bsth/repository/oil/YlbRepository.java
@@ -88,4 +88,26 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{ @@ -88,4 +88,26 @@ public interface YlbRepository extends BaseRepository&lt;Ylb, Integer&gt;{
88 + " and xlbm like %?4% " 88 + " and xlbm like %?4% "
89 + " and nbbm like %?5%",nativeQuery=true) 89 + " and nbbm like %?5%",nativeQuery=true)
90 List<Object[]> sumYlb2(String rq, String gsbm,String fgsbm,String xlbm,String nbbm); 90 List<Object[]> sumYlb2(String rq, String gsbm,String fgsbm,String xlbm,String nbbm);
  91 +
  92 +
  93 +
  94 + @Query(value="select s from Ylb s "
  95 + + " where to_days(?1)=to_days(s.rq) "
  96 + + " and s.ssgsdm like %?2% "
  97 + + " and s.fgsdm like %?3%"
  98 + + " and s.xlbm like %?4% "
  99 + + " and s.nbbm in ?5 ")
  100 + List<Ylb> listYlb(String rq, String gsbm,String fgsbm,String xlbm,List<String> listNbbm);
  101 +
  102 +
  103 + @Transactional
  104 + @Modifying
  105 + @Query(value="UPDATE bsth_c_ylb SET " +
  106 + " jzyl = ?2, " +
  107 + " sh = ?3," +
  108 + " shyy = ?4," +
  109 + " ns = ?5," +
  110 + " rylx = ?6" +
  111 + " WHERE id = ?1", nativeQuery=true)
  112 + public void ylbUpdate(Integer id,double jzyl,double sh,String shyy,double ns,String rylx);
91 } 113 }
src/main/java/com/bsth/repository/realcontrol/ScheduleRealInfoRepository.java
@@ -125,7 +125,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI @@ -125,7 +125,7 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
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") 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")
126 List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date); 126 List<ScheduleRealInfo> scheduleByDateAndLineQp(String line,String date);
127 127
128 - @Query(value="select s from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.bcType not in ('in','out') order by s.xlBm") 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")
129 List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date); 129 List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date);
130 130
131 //按月统计 131 //按月统计
@@ -136,7 +136,11 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI @@ -136,7 +136,11 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
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") 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")
137 List<ScheduleRealInfo> scheduleByDateAndLineTj(String line,String date,String date2); 137 List<ScheduleRealInfo> scheduleByDateAndLineTj(String line,String date,String date2);
138 138
139 - @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh) 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 xlBm,clZbh") 139 + //按照时间段统计
  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")
  141 + List<ScheduleRealInfo> scheduleByDateAndLineTj2(String line,String date,String date2);
  142 +
  143 + @Query(value="select new map(s.scheduleDate as scheduleDate,s.xlBm as xlBm,s.clZbh as clZbh,s.jGh as jGh,min(s.fcsj) as fcsj ) from ScheduleRealInfo s where s.xlBm like %?1% and DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?2 and s.gsBm like %?3% and s.fgsBm like %?4% GROUP BY xlBm,clZbh,jGh,scheduleDate,jGh ORDER BY clZbh,fcsj")
140 List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm); 144 List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm);
141 145
142 @Query(value="select s from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 ORDER BY xlBm,lpName,clZbh,xlDir") 146 @Query(value="select s from ScheduleRealInfo s where DATE_FORMAT(s.scheduleDate,'%Y-%m-%d') = ?1 ORDER BY xlBm,lpName,clZbh,xlDir")
src/main/java/com/bsth/repository/schedule/SchedulePlanInfoRepository.java
@@ -33,15 +33,15 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI @@ -33,15 +33,15 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI
33 "info.lp_name as lpName, " + 33 "info.lp_name as lpName, " +
34 "info.cl as clId, " + 34 "info.cl as clId, " +
35 "info.cl_zbh as clZbh, " + 35 "info.cl_zbh as clZbh, " +
36 - "group_concat(info.fcsj) ccsj, " +  
37 - "group_concat(info.bc_type) bctype, " + 36 + "group_concat(info.fcsj order by info.fcno) ccsj, " +
  37 + "group_concat(info.bc_type order by info.fcno) bctype, " +
38 "group_concat(distinct info.j) jsyId, " + 38 "group_concat(distinct info.j) jsyId, " +
39 "group_concat(distinct info.j_gh) jsyGh, " + 39 "group_concat(distinct info.j_gh) jsyGh, " +
40 "group_concat(distinct info.j_name) jsyName, " + 40 "group_concat(distinct info.j_name) jsyName, " +
41 "group_concat(distinct info.s) spyId, " + 41 "group_concat(distinct info.s) spyId, " +
42 "group_concat(distinct info.s_gh) spyGh, " + 42 "group_concat(distinct info.s_gh) spyGh, " +
43 "group_concat(distinct info.s_name) spyName, " + 43 "group_concat(distinct info.s_name) spyName, " +
44 - "group_concat(info.fcno) fcno, " + 44 + "group_concat(info.fcno order by info.fcno) fcno, " +
45 "max(info.update_date) as updateDate, " + 45 "max(info.update_date) as updateDate, " +
46 "max(user.user_name) as updateUserName, " + 46 "max(user.user_name) as updateUserName, " +
47 "max(info.tt_info_name) as ttInfoName " + 47 "max(info.tt_info_name) as ttInfoName " +
@@ -49,7 +49,7 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI @@ -49,7 +49,7 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI
49 "where info.xl = ?1 and " + 49 "where info.xl = ?1 and " +
50 "info.schedule_date = ?2 " + 50 "info.schedule_date = ?2 " +
51 "group by info.xl_name, info.schedule_date, info.lp, info.lp_name, info.cl, info.cl_zbh " + 51 "group by info.xl_name, info.schedule_date, info.lp, info.lp_name, info.cl, info.cl_zbh " +
52 - "order by info.xl_name, info.schedule_date, info.lp, info.fcno ", nativeQuery = true) 52 + "order by info.xl_name, info.schedule_date, info.lp ", nativeQuery = true)
53 List<Object[]> findGroupInfo(Integer xlid, Date scheduleDate); 53 List<Object[]> findGroupInfo(Integer xlid, Date scheduleDate);
54 54
55 @Modifying 55 @Modifying
src/main/java/com/bsth/service/oil/YlbService.java
@@ -8,16 +8,17 @@ import com.bsth.service.BaseService; @@ -8,16 +8,17 @@ import com.bsth.service.BaseService;
8 8
9 public interface YlbService extends BaseService<Ylb, Integer>{ 9 public interface YlbService extends BaseService<Ylb, Integer>{
10 Map<String, Object> obtain(Map<String, Object> map) throws Exception; 10 Map<String, Object> obtain(Map<String, Object> map) throws Exception;
  11 + Map<String, Object> saveYlbList(Map<String, Object> map) throws Exception;
11 String obtainDsq() throws Exception; 12 String obtainDsq() throws Exception;
12 - Map<String, Object> sort(Map<String, Object> map); 13 + Map<String, Object> sort(Map<String, Object> map) throws Exception;
13 14
14 Map<String, Object> outAndIn(Map<String, Object> map) throws Exception; 15 Map<String, Object> outAndIn(Map<String, Object> map) throws Exception;
15 16
16 - Map<String, Object> checkYl(Map<String, Object> map); 17 + Map<String, Object> checkYl(Map<String, Object> map) throws Exception;
17 18
18 Map<String, Object> sumYlb(Map<String, Object> map); 19 Map<String, Object> sumYlb(Map<String, Object> map);
19 20
20 List<Ylb> oilListMonth(String line,String date); 21 List<Ylb> oilListMonth(String line,String date);
21 - 22 + List<Ylb> listYlb(Map<String, Object> map);
22 StringBuffer checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int lx); 23 StringBuffer checkNbmmNum(String rq, String gsbm,String fgsbm,String xlbm,String nbbm,int lx);
23 } 24 }
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
@@ -15,6 +15,7 @@ import java.util.Map; @@ -15,6 +15,7 @@ import java.util.Map;
15 15
16 import javax.transaction.Transactional; 16 import javax.transaction.Transactional;
17 17
  18 +import org.apache.commons.lang3.StringEscapeUtils;
18 import org.slf4j.Logger; 19 import org.slf4j.Logger;
19 import org.slf4j.LoggerFactory; 20 import org.slf4j.LoggerFactory;
20 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
@@ -24,6 +25,8 @@ import org.springframework.jdbc.core.JdbcTemplate; @@ -24,6 +25,8 @@ import org.springframework.jdbc.core.JdbcTemplate;
24 import org.springframework.jdbc.core.RowMapper; 25 import org.springframework.jdbc.core.RowMapper;
25 import org.springframework.stereotype.Service; 26 import org.springframework.stereotype.Service;
26 27
  28 +import com.alibaba.fastjson.JSONArray;
  29 +import com.alibaba.fastjson.JSONObject;
27 import com.bsth.common.ResponseCode; 30 import com.bsth.common.ResponseCode;
28 import com.bsth.data.BasicData; 31 import com.bsth.data.BasicData;
29 import com.bsth.entity.Cars; 32 import com.bsth.entity.Cars;
@@ -173,6 +176,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -173,6 +176,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
173 t.setJcsx(Integer.parseInt(map.get("seqNumber").toString())); 176 t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));
174 t.setSsgsdm(map.get("company")==null?"":map.get("company").toString()); 177 t.setSsgsdm(map.get("company")==null?"":map.get("company").toString());
175 t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString()); 178 t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString());
  179 + t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
176 t.setRq(sdf.parse(rq)); 180 t.setRq(sdf.parse(rq));
177 repository.save(t); 181 repository.save(t);
178 182
@@ -323,8 +327,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -323,8 +327,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
323 t.setJcsx(Integer.parseInt(map.get("seqNumber").toString())); 327 t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));
324 t.setSsgsdm(map.get("company") == null ? "" : map.get("company").toString()); 328 t.setSsgsdm(map.get("company") == null ? "" : map.get("company").toString());
325 t.setFgsdm(map.get("bCompany") == null ? "" : map.get("bCompany").toString()); 329 t.setFgsdm(map.get("bCompany") == null ? "" : map.get("bCompany").toString());
  330 + t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
326 t.setRq(sdf.parse(rq)); 331 t.setRq(sdf.parse(rq));
327 -  
328 if(type.equals("add")){ 332 if(type.equals("add")){
329 addList.add(t); 333 addList.add(t);
330 }else{ 334 }else{
@@ -381,6 +385,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -381,6 +385,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
381 nbbm=map.get("nbbm_eq").toString(); 385 nbbm=map.get("nbbm_eq").toString();
382 } 386 }
383 387
  388 + List<Cyl> cylListAdd=new ArrayList<Cyl>();
  389 + Map<String, Object> cylMapAdd=new HashMap<String,Object>();
384 Map<String, Object> newMap=new HashMap<String,Object>(); 390 Map<String, Object> newMap=new HashMap<String,Object>();
385 Map<String, Object> map2=new HashMap<String,Object>(); 391 Map<String, Object> map2=new HashMap<String,Object>();
386 try { 392 try {
@@ -391,7 +397,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -391,7 +397,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
391 // 获取车辆存油信息 397 // 获取车辆存油信息
392 List<Cyl> cylList = cylRepository.obtainCyl(nbbm,gsbm); 398 List<Cyl> cylList = cylRepository.obtainCyl(nbbm,gsbm);
393 // 指定日期YLB信息 399 // 指定日期YLB信息
394 - List<Ylb> ylbList =repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm"); 400 + List<Ylb> ylbList =repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm,jcsx");
395 List<Ylb> iterator2=repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"jcsx"); 401 List<Ylb> iterator2=repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"jcsx");
396 for (int i=0;i<ylbList.size();i++) { 402 for (int i=0;i<ylbList.size();i++) {
397 Ylb ylb = ylbList.get(i); 403 Ylb ylb = ylbList.get(i);
@@ -427,31 +433,40 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -427,31 +433,40 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
427 // Iterator<Ylb> iterator2 = repository 433 // Iterator<Ylb> iterator2 = repository
428 // .findAll(new CustomerSpecs<Ylb>(map), new Sort(Direction.ASC, "jcsx")).iterator(); 434 // .findAll(new CustomerSpecs<Ylb>(map), new Sort(Direction.ASC, "jcsx")).iterator();
429 for (int j = 0; j < iterator2.size(); j++) { 435 for (int j = 0; j < iterator2.size(); j++) {
430 -  
431 Ylb t = iterator2.get(j); 436 Ylb t = iterator2.get(j);
432 if(t.getNbbm().equals(ylb.getNbbm())){ 437 if(t.getNbbm().equals(ylb.getNbbm())){
433 if (t.getJcsx() == 1) { 438 if (t.getJcsx() == 1) {
434 // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量 439 // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量
435 Double yl = t.getCzyl(); 440 Double yl = t.getCzyl();
436 Double jcyl = t.getCzyl(); 441 Double jcyl = t.getCzyl();
437 -// zyl = jcyl + jzl - yl;  
438 zyl =Arith.sub( Arith.add(jcyl, jzl),yl); 442 zyl =Arith.sub( Arith.add(jcyl, jzl),yl);
439 - Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));  
440 - t.setYh(yh);  
441 -// nextJzyl = t.getJzl() + t.getCzyl() - yh; 443 + Double yh=0.0;
  444 + if(zlc>0){
  445 + yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
  446 + }
442 nextJzyl =Arith.sub( Arith.add(t.getJzl(), t.getCzyl()),yh); 447 nextJzyl =Arith.sub( Arith.add(t.getJzl(), t.getCzyl()),yh);
443 -// t.setJzyl(Double.parseDouble(df.format(nextJzyl)));  
444 - t.setJzyl(nextJzyl); 448 + //把进场油量的小数和整数分别取出
  449 +// int ylxs=(int) nextJzyl; 10.6--11 10.3--10
  450 + long l=Math.round(nextJzyl);
  451 + double ylxs=l*100/100;
  452 +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
  453 + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
  454 + t.setYh(yh);
  455 + t.setJzyl(ylxs);
  456 + nextJzyl=ylxs;
445 } else { 457 } else {
446 -// t.setCzyl(Double.parseDouble(df.format(nextJzyl)));  
447 t.setCzyl(nextJzyl); 458 t.setCzyl(nextJzyl);
448 Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); 459 Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
449 - t.setYh(yh);  
450 -// nextJzyl = t.getJzl() + nextJzyl - yh;  
451 nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh); 460 nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh);
452 -// t.setJzyl(Double.parseDouble(df.format(nextJzyl)));  
453 - t.setJzyl(nextJzyl); 461 + long l=Math.round(nextJzyl);
  462 + double ylxs=l*100/100;
  463 +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
  464 + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
  465 + t.setYh(yh);
  466 + t.setJzyl(ylxs);
  467 + nextJzyl= ylxs;
454 } 468 }
  469 +
455 repository.save(t); 470 repository.save(t);
456 } 471 }
457 472
@@ -470,17 +485,36 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -470,17 +485,36 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
470 if (fage) { 485 if (fage) {
471 cylRepository.save(cyl); 486 cylRepository.save(cyl);
472 } else { 487 } else {
473 - cyl = new Cyl();  
474 - cyl.setNbbm(t.getNbbm());  
475 - cyl.setCyl(t.getJzyl());  
476 - cyl.setGsdm(t.getSsgsdm());  
477 - cyl.setUpdatetime(t.getRq());  
478 - cylRepository.save(cyl); 488 + if(cylMapAdd.get(t.getNbbm())!=null){
  489 + for (int l = 0; l < cylListAdd.size(); l++) {
  490 + cyl=cylListAdd.get(l);
  491 + if(cyl.getNbbm().equals(t.getNbbm())){
  492 + cyl.setNbbm(t.getNbbm());
  493 + cyl.setCyl(t.getJzyl());
  494 + cyl.setGsdm(t.getSsgsdm());
  495 + cyl.setFgsdm(t.getFgsdm());
  496 + cyl.setUpdatetime(t.getRq());
  497 + }
  498 + }
  499 + }else{
  500 + cyl = new Cyl();
  501 + cyl.setNbbm(t.getNbbm());
  502 + cyl.setCyl(t.getJzyl());
  503 + cyl.setGsdm(t.getSsgsdm());
  504 + cyl.setFgsdm(t.getFgsdm());
  505 + cyl.setUpdatetime(t.getRq());
  506 + cylListAdd.add(cyl);
  507 + }
  508 +
  509 +
479 } 510 }
480 map2.put("status", ResponseCode.SUCCESS); 511 map2.put("status", ResponseCode.SUCCESS);
481 } 512 }
482 } 513 }
483 } 514 }
  515 + for (int i = 0; i < cylListAdd.size(); i++) {
  516 + cylRepository.save(cylListAdd.get(i));
  517 + }
484 } catch (Exception e) { 518 } catch (Exception e) {
485 map2.put("status", ResponseCode.ERROR); 519 map2.put("status", ResponseCode.ERROR);
486 logger.error("save erro.", e); 520 logger.error("save erro.", e);
@@ -494,7 +528,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -494,7 +528,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
494 */ 528 */
495 @Transactional 529 @Transactional
496 @Override 530 @Override
497 - public Map<String, Object> sort(Map<String, Object> map) { 531 + public Map<String, Object> sort(Map<String, Object> map) throws Exception{
498 // TODO Auto-generated method stub 532 // TODO Auto-generated method stub
499 Map<String, Object> newMap = new HashMap<String, Object>(); 533 Map<String, Object> newMap = new HashMap<String, Object>();
500 SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); 534 SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
@@ -507,7 +541,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -507,7 +541,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
507 Double sh= Double.parseDouble(map.get("sh").toString()); 541 Double sh= Double.parseDouble(map.get("sh").toString());
508 String shyy=map.get("shyy").toString(); 542 String shyy=map.get("shyy").toString();
509 Ylb ylb = repository.findOne(id); 543 Ylb ylb = repository.findOne(id);
510 - 544 + List<Cyl> cylListAdd=new ArrayList<Cyl>();
  545 + Map<String, Object> cylMapAdd=new HashMap<String,Object>();
511 String nbbm_eq = ylb.getNbbm(); 546 String nbbm_eq = ylb.getNbbm();
512 Date rq_eq = ylb.getRq(); 547 Date rq_eq = ylb.getRq();
513 // 得到一天总的加油和里程(根据车,时间) 548 // 得到一天总的加油和里程(根据车,时间)
@@ -527,12 +562,9 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -527,12 +562,9 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
527 562
528 //新的 损耗不等于 旧的损耗 总损耗从新算 563 //新的 损耗不等于 旧的损耗 总损耗从新算
529 if(Arith.sub(ylb.getSh(),sh )!=0){ 564 if(Arith.sub(ylb.getSh(),sh )!=0){
530 -// zsh =zsh-ylb.getSh()+sh;  
531 zsh =Arith.add(Arith.sub(zsh, ylb.getSh()), sh); 565 zsh =Arith.add(Arith.sub(zsh, ylb.getSh()), sh);
532 -// jzl =jzl-zsh;  
533 jzl =Arith.sub(jzl, zsh); 566 jzl =Arith.sub(jzl, zsh);
534 }else{ 567 }else{
535 -// jzl=jzl-zsh;  
536 jzl =Arith.sub(jzl, zsh); 568 jzl =Arith.sub(jzl, zsh);
537 } 569 }
538 map.put("nbbm_eq", nbbm_eq); 570 map.put("nbbm_eq", nbbm_eq);
@@ -555,33 +587,37 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -555,33 +587,37 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
555 t.setShyy(shyy); 587 t.setShyy(shyy);
556 } 588 }
557 Double jcyl = t.getCzyl(); 589 Double jcyl = t.getCzyl();
558 -// zyl = jcyl + jzl - yl;  
559 zyl = Arith.sub(Arith.add(jcyl, jzl), yl); 590 zyl = Arith.sub(Arith.add(jcyl, jzl), yl);
560 Double yh = 0.0; 591 Double yh = 0.0;
561 if (zlc > 0 && t.getZlc() > 0) { 592 if (zlc > 0 && t.getZlc() > 0) {
562 yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc))); 593 yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
563 } 594 }
564 - t.setYh(yh);  
565 -// nextJzyl = t.getJzl() + t.getCzyl() - yh-t.getSh();  
566 nextJzyl =Arith.sub(Arith.add(t.getJzl(), t.getCzyl()), Arith.add(yh, t.getSh())); 595 nextJzyl =Arith.sub(Arith.add(t.getJzl(), t.getCzyl()), Arith.add(yh, t.getSh()));
567 -// t.setJzyl(Double.parseDouble(df.format(nextJzyl)));  
568 - t.setJzyl(nextJzyl); 596 + long l=Math.round(nextJzyl);
  597 + double ylxs=l*100/100;
  598 +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
  599 + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
  600 + t.setJzyl(ylxs);
  601 + t.setYh(yh);
  602 + nextJzyl=ylxs;
569 } else { 603 } else {
570 if(t.getId()==id){ 604 if(t.getId()==id){
571 t.setSh(sh); 605 t.setSh(sh);
572 t.setShyy(shyy); 606 t.setShyy(shyy);
573 } 607 }
574 - if (t.getZlc() != 0) {  
575 -// t.setCzyl(Double.parseDouble(df.format(nextJzyl)));  
576 t.setCzyl(nextJzyl); 608 t.setCzyl(nextJzyl);
577 - Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));  
578 - t.setYh(yh);  
579 -// nextJzyl = t.getJzl() + nextJzyl - yh-t.getSh(); 609 + Double yh =0.0;
  610 + if (t.getZlc() != 0) {
  611 + yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
  612 + }
580 nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), Arith.add(yh, t.getSh())); 613 nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), Arith.add(yh, t.getSh()));
581 -// t.setJzyl(Double.parseDouble(df.format(nextJzyl)));  
582 - t.setJzyl(nextJzyl);  
583 - }  
584 - 614 + long l=Math.round(nextJzyl);
  615 + double ylxs=l*100/100;
  616 +// nextJzyl = Arith.add(nextJzyl,Arith.sub(nextJzyl,ylxs));
  617 + yh=Arith.add(yh, Arith.sub(ylxs,nextJzyl));
  618 + t.setJzyl(ylxs);
  619 + t.setYh(yh);
  620 + nextJzyl=ylxs;
585 } 621 }
586 repository.save(t); 622 repository.save(t);
587 623
@@ -600,19 +636,37 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -600,19 +636,37 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
600 if (fage) { 636 if (fage) {
601 cylRepository.save(cyl); 637 cylRepository.save(cyl);
602 } else { 638 } else {
603 - cyl = new Cyl();  
604 - cyl.setNbbm(t.getNbbm());  
605 - cyl.setCyl(t.getJzyl());  
606 - cyl.setGsdm(t.getSsgsdm());  
607 - cyl.setUpdatetime(t.getRq());  
608 - cylRepository.save(cyl); 639 + if(cylMapAdd.get(t.getNbbm())!=null){
  640 + for (int l = 0; l < cylListAdd.size(); l++) {
  641 + cyl=cylListAdd.get(l);
  642 + if(cyl.getNbbm().equals(t.getNbbm())){
  643 + cyl.setNbbm(t.getNbbm());
  644 + cyl.setCyl(t.getJzyl());
  645 + cyl.setGsdm(t.getSsgsdm());
  646 + cyl.setFgsdm(t.getFgsdm());
  647 + cyl.setUpdatetime(t.getRq());
  648 + }
  649 + }
  650 + }else{
  651 + cyl = new Cyl();
  652 + cyl.setNbbm(t.getNbbm());
  653 + cyl.setCyl(t.getJzyl());
  654 + cyl.setGsdm(t.getSsgsdm());
  655 + cyl.setFgsdm(t.getFgsdm());
  656 + cyl.setUpdatetime(t.getRq());
  657 + cylListAdd.add(cyl);
  658 + }
609 } 659 }
610 660
611 newMap.put("status", ResponseCode.SUCCESS); 661 newMap.put("status", ResponseCode.SUCCESS);
612 } 662 }
  663 + for (int i = 0; i < cylListAdd.size(); i++) {
  664 + cylRepository.save(cylListAdd.get(i));
  665 + }
613 } catch (Exception e) { 666 } catch (Exception e) {
614 newMap.put("status", ResponseCode.ERROR); 667 newMap.put("status", ResponseCode.ERROR);
615 logger.error("save erro.", e); 668 logger.error("save erro.", e);
  669 + throw e;
616 } 670 }
617 return newMap; 671 return newMap;
618 } 672 }
@@ -624,7 +678,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -624,7 +678,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
624 */ 678 */
625 @Transactional 679 @Transactional
626 @Override 680 @Override
627 - public Map<String, Object> checkYl(Map<String, Object> map) { 681 + public Map<String, Object> checkYl(Map<String, Object> map) throws Exception{
628 Map<String, Object> newMap=new HashMap<String,Object>(); 682 Map<String, Object> newMap=new HashMap<String,Object>();
629 // String xlbm=""; 683 // String xlbm="";
630 // if(map.get("xlbm_like")!=null){ 684 // if(map.get("xlbm_like")!=null){
@@ -845,6 +899,97 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -845,6 +899,97 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
845 // } 899 // }
846 return sumMap; 900 return sumMap;
847 } 901 }
  902 +
  903 + @Override
  904 + public List<Ylb> listYlb(Map<String, Object> map) {
  905 + // TODO Auto-generated method stub
  906 + List<Ylb> listYlb=new ArrayList<Ylb>();
  907 + List<String> stringList=new ArrayList<String>();
  908 + String rq=map.get("rq").toString();
  909 + String gsbm=map.get("ssgsdm_like").toString();
  910 + String fgsbm=map.get("fgsdm_like").toString();
  911 + String xlbm=map.get("xlbm_like").toString().trim();
  912 + String nbbm=map.get("nbbm_eq").toString();
  913 + String sxtj=map.get("sxtj").toString();
  914 + if(nbbm.trim()!=""){
  915 + stringList.add(nbbm);
  916 + listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);
  917 + }else{
  918 + //全部
  919 + if(sxtj.equals("0")){
  920 + List<Object[]> objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm);
  921 + for (int i = 0; i < objectLists.size(); i++) {
  922 + String clbm=objectLists.get(i)[0].toString();
  923 + stringList.add(clbm);
  924 + }
  925 + if(stringList.size()>0){
  926 + listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);
  927 + }
  928 + }else{
  929 + List<Object[]> objectLists=repository.checkNbmmNum(rq, gsbm, fgsbm, xlbm,nbbm);
  930 + for (int i = 0; i < objectLists.size(); i++) {
  931 + String clbm=objectLists.get(i)[0].toString();
  932 + int cs=Integer.parseInt(objectLists.get(i)[1].toString());
  933 + //一车一单
  934 + if(sxtj.equals("1")){
  935 + if(cs==1){
  936 + stringList.add(clbm);
  937 + }
  938 + }
  939 + //一车多单
  940 + if(sxtj.equals("2")){
  941 + if(cs>1){
  942 + stringList.add(clbm);
  943 + }
  944 + }
  945 + }
  946 + if(stringList.size()>0){
  947 + listYlb=repository.listYlb(rq, gsbm, fgsbm, xlbm, stringList);
  948 + }
  949 + }
  950 + }
  951 +
  952 + return listYlb;
  953 + }
  954 +
  955 + @Transactional
  956 + @Override
  957 + public Map<String, Object> saveYlbList(Map<String, Object> map) throws Exception {
  958 + // TODO Auto-generated method stub
  959 + Map<String, Object> newMap=new HashMap<String,Object>();
  960 + try{
  961 + String json =StringEscapeUtils.unescapeHtml4(map.get("ylbList").toString());
  962 + JSONArray jsonArray=JSONArray.parseArray(json);
  963 + JSONObject jsonObject;
  964 +
  965 + for (int i = 0; i < jsonArray.size(); i++) {
  966 +// Ylb t=new Ylb();
  967 + jsonObject=jsonArray.getJSONObject(i);
  968 +
  969 + Double jzyl =jsonObject.getDoubleValue("jzyl");
  970 + Double sh =jsonObject.getDoubleValue("sh");
  971 + String shyy =jsonObject.getString("shyy");
  972 + Double ns = jsonObject.getDoubleValue("ns");
  973 + String rylx =jsonObject.getString("rylx");
  974 + Integer id =jsonObject.getInteger("id");
  975 + /*t.setJzyl(jzyl);
  976 + t.setSh(sh);
  977 + t.setShyy(shyy);
  978 + t.setNs(ns);
  979 + t.setRylx(rylx);
  980 + t.setId(jsonObject.getInteger("id"));*/
  981 + repository.ylbUpdate(id, jzyl, sh, shyy, ns, rylx);
  982 + }
  983 +// List<Map<String, Object>> list=(List<Map<String, Object>>) map.get("ylbList");
  984 +
  985 + newMap.put("status", ResponseCode.SUCCESS);
  986 + }catch(Exception e){
  987 + newMap.put("status", ResponseCode.ERROR);
  988 + logger.error("save erro.", e);
  989 + throw e;
  990 + }
  991 + return newMap;
  992 + }
848 993
849 994
850 } 995 }
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -1300,7 +1300,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1300,7 +1300,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1300 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName); 1300 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
1301 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName); 1301 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
1302 int jhbc = 0, cjbc = 0, ljbc = 0; 1302 int jhbc = 0, cjbc = 0, ljbc = 0;
1303 - double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0, jcclc = 0; 1303 + double jhlc = 0, yygl = 0, ksgl = 0, tempJhlc = 0,jhlcOrig=0, jcclc = 0;
1304 float addMileage = 0l, remMileage = 0l,addMileageYy = 0l,addMileageJc =0l; 1304 float addMileage = 0l, remMileage = 0l,addMileageYy = 0l,addMileageJc =0l;
1305 Map<String, Object> map = new HashMap<String, Object>(); 1305 Map<String, Object> map = new HashMap<String, Object>();
1306 for (ScheduleRealInfo scheduleRealInfo : list) { 1306 for (ScheduleRealInfo scheduleRealInfo : list) {
@@ -1310,6 +1310,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1310,6 +1310,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1310 //临加里程(主任务临加), 1310 //临加里程(主任务临加),
1311 //计划班次,烂班班次,增加班次 1311 //计划班次,烂班班次,增加班次
1312 tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); 1312 tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1313 + jhlcOrig = scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  1314 +
1313 if (scheduleRealInfo.isSflj()) { 1315 if (scheduleRealInfo.isSflj()) {
1314 addMileage += tempJhlc; 1316 addMileage += tempJhlc;
1315 if (scheduleRealInfo.getBcType().equals("in") 1317 if (scheduleRealInfo.getBcType().equals("in")
@@ -1324,9 +1326,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1324,9 +1326,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1324 if (!(scheduleRealInfo.getBcType().equals("in") 1326 if (!(scheduleRealInfo.getBcType().equals("in")
1325 || scheduleRealInfo.getBcType().equals("out"))) { 1327 || scheduleRealInfo.getBcType().equals("out"))) {
1326 jhbc++; 1328 jhbc++;
1327 - jhlc += tempJhlc; 1329 + jhlc += jhlcOrig;
1328 if (scheduleRealInfo.getStatus() == -1) { 1330 if (scheduleRealInfo.getStatus() == -1) {
1329 - remMileage += tempJhlc; 1331 + remMileage += jhlcOrig;
1330 cjbc++; 1332 cjbc++;
1331 } 1333 }
1332 } 1334 }
@@ -1373,12 +1375,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -1373,12 +1375,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1373 } 1375 }
1374 } 1376 }
1375 } 1377 }
  1378 +
  1379 + //yygl 包含了临加的营运公里 jcclc包含了临加的进出场里程
1376 map.put("jhlc", format.format(jhlc)); 1380 map.put("jhlc", format.format(jhlc));
1377 map.put("remMileage", format.format(remMileage)); 1381 map.put("remMileage", format.format(remMileage));
1378 map.put("addMileage", format.format(addMileage)); 1382 map.put("addMileage", format.format(addMileage));
1379 - map.put("yygl", format.format(yygl+addMileageYy)); 1383 + map.put("yygl", format.format(yygl));
1380 map.put("ksgl", format.format(ksgl)); 1384 map.put("ksgl", format.format(ksgl));
1381 - map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileageYy)); 1385 + map.put("realMileage", format.format(yygl + ksgl + jcclc));
1382 // map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage)); 1386 // map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage));
1383 map.put("jhbc", jhbc); 1387 map.put("jhbc", jhbc);
1384 map.put("cjbc", cjbc); 1388 map.put("cjbc", cjbc);
@@ -2130,7 +2134,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2130,7 +2134,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2130 public List<Map<String, Object>> statisticsDailyTj(String line, String date,String date2, 2134 public List<Map<String, Object>> statisticsDailyTj(String line, String date,String date2,
2131 String xlName, String type) { 2135 String xlName, String type) {
2132 List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>(); 2136 List<ScheduleRealInfo> list = new ArrayList<ScheduleRealInfo>();
2133 - list = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date,date2); 2137 + if(line!=null){
  2138 + list = scheduleRealInfoRepository.scheduleByDateAndLineTj2(line, date,date2);
  2139 + }else{
  2140 + list = scheduleRealInfoRepository.scheduleByDateAndLineTj(line, date,date2);
  2141 + }
  2142 +
2134 2143
2135 List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>(); 2144 List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
2136 DecimalFormat format = new DecimalFormat("0.00"); 2145 DecimalFormat format = new DecimalFormat("0.00");
@@ -2897,12 +2906,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2897,12 +2906,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2897 //前一天日期 2906 //前一天日期
2898 // String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1)); 2907 // String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1));
2899 // String date = "2016-09-20"; 2908 // String date = "2016-09-20";
2900 - System.out.println("shijian1:"+new Date()); 2909 +// System.out.println("shijian1:"+new Date());
2901 List<Map<String, Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date,gsbm,fgsbm); 2910 List<Map<String, Object>> yesterdayDataList = scheduleRealInfoRepository.yesterdayDataList(line, date,gsbm,fgsbm);
2902 - System.out.println("shijian2:"+new Date()); 2911 +// System.out.println("shijian2:"+new Date());
2903 // List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date); 2912 // List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
2904 List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date,gsbm,fgsbm); 2913 List<ScheduleRealInfo> lists = scheduleRealInfoRepository.queryListWaybill3(jGh, nbbm, date,gsbm,fgsbm);
2905 - System.out.println("shijian3:"+new Date()); 2914 +// System.out.println("shijian3:"+new Date());
2906 for (int x = 0; x < yesterdayDataList.size(); x++) { 2915 for (int x = 0; x < yesterdayDataList.size(); x++) {
2907 String jName = yesterdayDataList.get(x).get("jGh").toString(); 2916 String jName = yesterdayDataList.get(x).get("jGh").toString();
2908 String clZbh = yesterdayDataList.get(x).get("clZbh").toString(); 2917 String clZbh = yesterdayDataList.get(x).get("clZbh").toString();
@@ -2929,18 +2938,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2929,18 +2938,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2929 tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc(); 2938 tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
2930 if (scheduleRealInfo.isSflj()) { 2939 if (scheduleRealInfo.isSflj()) {
2931 if(scheduleRealInfo.getStatus() == -1){ 2940 if(scheduleRealInfo.getStatus() == -1){
2932 -// addMileage += tempJhlc;  
2933 addMileage =Arith.add(addMileage, tempJhlc); 2941 addMileage =Arith.add(addMileage, tempJhlc);
2934 } 2942 }
2935 } else { 2943 } else {
2936 if (!(scheduleRealInfo.getBcType().equals("in") 2944 if (!(scheduleRealInfo.getBcType().equals("in")
2937 || scheduleRealInfo.getBcType().equals("out"))) { 2945 || scheduleRealInfo.getBcType().equals("out"))) {
2938 -// jhlc += tempJhlc;  
2939 jhlc =Arith.add(jhlc,tempJhlc); 2946 jhlc =Arith.add(jhlc,tempJhlc);
2940 } 2947 }
2941 2948
2942 if (scheduleRealInfo.getStatus() == -1) { 2949 if (scheduleRealInfo.getStatus() == -1) {
2943 -// remMileage += tempJhlc;  
2944 remMileage =Arith.add(remMileage,tempJhlc); 2950 remMileage =Arith.add(remMileage,tempJhlc);
2945 } 2951 }
2946 } 2952 }
@@ -2950,7 +2956,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2950,7 +2956,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2950 if (scheduleRealInfo.getBcType().equals("in") || 2956 if (scheduleRealInfo.getBcType().equals("in") ||
2951 scheduleRealInfo.getBcType().equals("out")) { 2957 scheduleRealInfo.getBcType().equals("out")) {
2952 if (scheduleRealInfo.getStatus() != -1) { 2958 if (scheduleRealInfo.getStatus() != -1) {
2953 -// jcclc += tempJhlc;  
2954 jcclc=Arith.add(jcclc,tempJhlc); 2959 jcclc=Arith.add(jcclc,tempJhlc);
2955 } 2960 }
2956 } 2961 }
@@ -2960,7 +2965,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2960,7 +2965,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2960 // } 2965 // }
2961 else { 2966 else {
2962 if (scheduleRealInfo.getStatus() != -1) { 2967 if (scheduleRealInfo.getStatus() != -1) {
2963 -// yygl += tempJhlc;  
2964 yygl=Arith.add(yygl,tempJhlc); 2968 yygl=Arith.add(yygl,tempJhlc);
2965 } 2969 }
2966 } 2970 }
@@ -2970,19 +2974,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -2970,19 +2974,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2970 ChildTaskPlan childTaskPlan = it.next(); 2974 ChildTaskPlan childTaskPlan = it.next();
2971 if (childTaskPlan.getMileageType().equals("empty")) { 2975 if (childTaskPlan.getMileageType().equals("empty")) {
2972 if (childTaskPlan.isDestroy()) { 2976 if (childTaskPlan.isDestroy()) {
2973 -// remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
2974 remMileage=Arith.add(remMileage,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage()); 2977 remMileage=Arith.add(remMileage,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage());
2975 } else { 2978 } else {
2976 -// ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
2977 ksgl += Arith.add(ksgl,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage()); 2979 ksgl += Arith.add(ksgl,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage());
2978 } 2980 }
2979 } else { 2981 } else {
2980 if (childTaskPlan.isDestroy()) { 2982 if (childTaskPlan.isDestroy()) {
2981 -// remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
2982 remMileage=Arith.add(remMileage,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage()); 2983 remMileage=Arith.add(remMileage,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage());
2983 2984
2984 } else { 2985 } else {
2985 -// yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();  
2986 yygl=Arith.add(yygl,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage()); 2986 yygl=Arith.add(yygl,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage());
2987 2987
2988 } 2988 }
src/main/java/com/bsth/service/schedule/impl/SchedulePlanServiceImpl.java
@@ -15,10 +15,7 @@ import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input; @@ -15,10 +15,7 @@ import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input;
15 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output; 15 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
16 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input; 16 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
17 import com.bsth.service.schedule.rules.strategy.IStrategy; 17 import com.bsth.service.schedule.rules.strategy.IStrategy;
18 -import com.bsth.service.schedule.rules.ttinfo.LpInfoResults_output;  
19 -import com.bsth.service.schedule.rules.ttinfo.TTInfoCalcuParam_input;  
20 -import com.bsth.service.schedule.rules.ttinfo.TTInfoResults_output;  
21 -import com.bsth.service.schedule.rules.ttinfo.TTInfo_input; 18 +import com.bsth.service.schedule.rules.ttinfo.*;
22 import com.bsth.service.schedule.rules.ttinfo2.CalcuParam; 19 import com.bsth.service.schedule.rules.ttinfo2.CalcuParam;
23 import com.bsth.service.schedule.rules.ttinfo2.Result; 20 import com.bsth.service.schedule.rules.ttinfo2.Result;
24 import org.joda.time.DateTime; 21 import org.joda.time.DateTime;
@@ -97,7 +94,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -97,7 +94,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
97 * 循环规则输出。 94 * 循环规则输出。
98 * @param schedulePlan 95 * @param schedulePlan
99 */ 96 */
100 - private ScheduleResults_output loopRuleOutput(SchedulePlan schedulePlan) { 97 + private ScheduleResults_output loopRuleOutput(SchedulePlan schedulePlan, LpInfoResults_output lpInfoResults_output) {
101 // 获取主线路 98 // 获取主线路
102 Line xl = strategy.getLine(schedulePlan.getXl().getId()); 99 Line xl = strategy.getLine(schedulePlan.getXl().getId());
103 100
@@ -127,6 +124,9 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -127,6 +124,9 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
127 for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) { 124 for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) {
128 session.insert(scheduleRule_input); 125 session.insert(scheduleRule_input);
129 } 126 }
  127 + for (LpInfoResult_output lpInfoResult_output: lpInfoResults_output.getLpInfoResult_outputs()) {
  128 + session.insert(lpInfoResult_output);
  129 + }
130 // 执行rule 130 // 执行rule
131 session.fireAllRules(); 131 session.fireAllRules();
132 132
@@ -139,11 +139,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -139,11 +139,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
139 } 139 }
140 140
141 /** 141 /**
142 - * 时刻表选择(判定每天使用的时刻表)。 142 + * 时刻表选择(判定每天使用的时刻表,以及路牌数据输出)。
143 * @param schedulePlan 143 * @param schedulePlan
144 - * @return 144 + * @return TTInfoResults_output, LpInfoResults_output
145 */ 145 */
146 - private TTInfoResults_output ttInfoOutput(SchedulePlan schedulePlan) { 146 + private Object[] ttInfoOutput(SchedulePlan schedulePlan) {
147 // 获取线路的所有未作废的时刻表 147 // 获取线路的所有未作废的时刻表
148 List<TTInfo> ttInfos = getTTInfos(schedulePlan.getXl().getId()); 148 List<TTInfo> ttInfos = getTTInfos(schedulePlan.getXl().getId());
149 149
@@ -183,7 +183,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -183,7 +183,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
183 // 执行完毕销毁,有日志的也要关闭 183 // 执行完毕销毁,有日志的也要关闭
184 session.dispose(); 184 session.dispose();
185 185
186 - return ttInfoResults_output; 186 + return new Object[] {ttInfoResults_output, lpInfoResults_output};
187 187
188 } 188 }
189 189
@@ -230,10 +230,30 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im @@ -230,10 +230,30 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
230 230
231 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED) 231 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
232 public SchedulePlan save2(SchedulePlan schedulePlan) { 232 public SchedulePlan save2(SchedulePlan schedulePlan) {
  233 + // 1、时刻表数据及每日路牌数据计算
  234 + Object[] ttInfoRets = ttInfoOutput(schedulePlan);
  235 + TTInfoResults_output ttInfoResults_output = (TTInfoResults_output) ttInfoRets[0];
  236 + LpInfoResults_output lpInfoResults_output = (LpInfoResults_output) ttInfoRets[1];
  237 +
  238 + // 2、循环规则计算输出
  239 + ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan, lpInfoResults_output);
  240 +
  241 + // 3、计划输出
  242 + PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output);
  243 +
  244 + schedulePlan.setTtInfoId("todo"); // TODO:待修正
  245 + schedulePlan.setTtInfoNames("todo"); // TODO:待修正
  246 +
  247 + schedulePlan.getSchedulePlanInfoList().addAll(planResult.getSchedulePlanInfos());
  248 +
  249 + super.save(schedulePlan);
  250 +
  251 +
  252 +
233 // // 1、循环规则计算输出 253 // // 1、循环规则计算输出
234 // ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan); 254 // ScheduleResults_output scheduleResults_output = loopRuleOutput(schedulePlan);
235 - // 2、时刻表选择  
236 - TTInfoResults_output ttInfoResults_output = ttInfoOutput(schedulePlan); 255 +// // 2、时刻表选择
  256 +// TTInfoResults_output ttInfoResults_output = ttInfoOutput(schedulePlan);
237 // // 3、计划输出 257 // // 3、计划输出
238 // PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output); 258 // PlanResult planResult = planResultOutput(schedulePlan, scheduleResults_output, ttInfoResults_output);
239 // 259 //
src/main/java/com/bsth/service/schedule/rules/ttinfo/LpInfoResults_output.java
@@ -17,4 +17,8 @@ public class LpInfoResults_output { @@ -17,4 +17,8 @@ public class LpInfoResults_output {
17 public void setLpInfoResult_outputs(List<LpInfoResult_output> lpInfoResult_outputs) { 17 public void setLpInfoResult_outputs(List<LpInfoResult_output> lpInfoResult_outputs) {
18 this.lpInfoResult_outputs = lpInfoResult_outputs; 18 this.lpInfoResult_outputs = lpInfoResult_outputs;
19 } 19 }
  20 +
  21 + public void add(LpInfoResult_output lpInfoResult_output) {
  22 +
  23 + }
20 } 24 }
src/main/resources/rules/shiftloop_fb_2.drl 0 → 100644
  1 +package com.bsth.service.schedule.shiftloop;
  2 +
  3 +import org.joda.time.*;
  4 +import java.util.*;
  5 +
  6 +import com.bsth.service.schedule.rules.ttinfo.LpInfoResult_output;
  7 +
  8 +import com.bsth.service.schedule.rules.shiftloop.ScheduleCalcuParam_input;
  9 +import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
  10 +import com.bsth.service.schedule.rules.shiftloop.ScheduleResult_output;
  11 +import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
  12 +
  13 +import org.slf4j.Logger;
  14 +
  15 +global Logger log;
  16 +global ScheduleResults_output scheduleResult;
  17 +
  18 +/*
  19 + 存在(翻班格式)
  20 +*/
  21 +
  22 +//------------------------- 第一阶段、计算规则准备数据(天数) ----------------------------//
  23 +
  24 +declare Calcu_days_result_pre
  25 + ruleId: String // 规则Id
  26 +
  27 + calcu_index_lp : Integer // 计算之后路牌的起始索引
  28 + calcu_index_ry : Integer // 计算之后人员的起始索引
  29 +
  30 + // 1、第一部分循环需要用到的数据(当开始日期大于启用日期的时候才有)
  31 + calcu_start_date_1: DateTime // 第一部分开始计算日期
  32 + calcu_end_date_1: DateTime // 第一部分结束计算日期
  33 +
  34 + // 2、第二部分循环需要用到的数据
  35 + sdays : Integer // 总共需要排班的天数
  36 + calcu_start_date_2 : DateTime // 开始计算日期
  37 + calcu_end_date_2 : DateTime // 结束计算日期
  38 +
  39 +end
  40 +
  41 +/*
  42 + 计算启用日期,开始计算日期,结束计算日期,相差天数
  43 + 1、规则启用日期小于开始计算日期
  44 + 2、规则启用日期大于等于开始日期,小于等于结束日期
  45 +*/
  46 +// 1、启用日期 < 开始日期
  47 +rule "calcu_days_1_"
  48 + salience 1000
  49 + when
  50 + ScheduleCalcuParam_input(
  51 + fromDate.isBefore(toDate) || fromDate.isEqual(toDate),
  52 + $fromDate : fromDate,
  53 + $toDate : toDate
  54 + )
  55 + ScheduleRule_input(
  56 + $ruleId : ruleId, $qyrq : qyrq,
  57 + $lpindex : startGbdIndex, $ryindex: startEIndex)
  58 + eval($qyrq.isBefore($fromDate))
  59 + then
  60 + // 构造Calcu_days_result_pre,用于路牌
  61 + Calcu_days_result_pre cdrp = new Calcu_days_result_pre();
  62 + cdrp.setRuleId($ruleId);
  63 + cdrp.setCalcu_index_lp($lpindex);
  64 + cdrp.setCalcu_index_ry($ryindex);
  65 + cdrp.setCalcu_start_date_1($qyrq);
  66 + cdrp.setCalcu_end_date_1($fromDate);
  67 + Period p2 = new Period($fromDate, $toDate, PeriodType.days());
  68 + cdrp.setSdays(p2.getDays() + 1);
  69 + cdrp.setCalcu_start_date_2($fromDate);
  70 + cdrp.setCalcu_end_date_2($toDate);
  71 +
  72 + insert(cdrp);
  73 +
  74 + log.info("总共需要排班的天数 sdays={} ruleId={}", (p2.getDays() + 1), $ruleId);
  75 +
  76 +end
  77 +
  78 +// 启用日期 属于 [开始日期,结束日期]
  79 +rule "calcu_days_2_"
  80 + salience 1000
  81 + when
  82 + ScheduleCalcuParam_input(
  83 + fromDate.isBefore(toDate) || fromDate.isEqual(toDate),
  84 + $fromDate : fromDate,
  85 + $toDate : toDate
  86 + )
  87 + ScheduleRule_input(
  88 + $ruleId : ruleId, $qyrq : qyrq,
  89 + $lpindex : startGbdIndex, $ryindex: startEIndex)
  90 + eval((!$qyrq.isBefore($fromDate)) && (!$qyrq.isAfter($toDate)))
  91 + then
  92 + // 构造Calcu_days_result_pre,用于路牌
  93 + Calcu_days_result_pre cdrp = new Calcu_days_result_pre();
  94 + cdrp.setRuleId($ruleId);
  95 + cdrp.setCalcu_index_lp($lpindex);
  96 + cdrp.setCalcu_index_ry($ryindex);
  97 + cdrp.setCalcu_start_date_1($qyrq);
  98 + cdrp.setCalcu_end_date_1($qyrq);
  99 + Period p2 = new Period($qyrq, $toDate, PeriodType.days());
  100 + cdrp.setSdays(p2.getDays() + 1);
  101 + cdrp.setCalcu_start_date_2($qyrq);
  102 + cdrp.setCalcu_end_date_2($toDate);
  103 +
  104 + insert(cdrp);
  105 +
  106 + log.info("总共需要排班的天数 sdays={} ruleId={}", (p2.getDays() + 1), $ruleId);
  107 +
  108 +end
  109 +
  110 +//------------------------- 第二阶段、计算规则准备数据2(第一组循环) ----------------------------//
  111 +rule "Calcu_loop1_1_" // 时刻表的关联的路牌不存在,调整翻版规则
  112 + salience 900
  113 + when
  114 + $cdrp: Calcu_days_result_pre(
  115 + calcu_start_date_1.isBefore(calcu_end_date_1),
  116 + $csd1: calcu_start_date_1,
  117 + $ced1: calcu_end_date_1,
  118 + $ruleId: ruleId,
  119 + $lpindex: calcu_index_lp,
  120 + $ryindex: calcu_index_ry
  121 + )
  122 + $sri: ScheduleRule_input(
  123 + ruleId == $ruleId,
  124 + $gids: guideboardIds,
  125 + $lprangesize : guideboardIds.size(),
  126 + $ryrangesize: employeeConfigIds.size()
  127 + )
  128 + $liro: LpInfoResult_output(
  129 + dateTime.isEqual($csd1),
  130 + $gids.get($lpindex) == lpId,
  131 + $lpId: lpId
  132 + )
  133 + then
  134 + $cdrp.setCalcu_index_lp(($lpindex + 1) % $lprangesize);
  135 + $cdrp.setCalcu_index_ry(($ryindex + 1) % $ryrangesize);
  136 + $cdrp.setCalcu_start_date_1($csd1.plusDays(1));
  137 +
  138 + log.info("Calcu_loop1_1_ ruleId={}, calcu_index_lp/ry={}/{}",
  139 + $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry());
  140 +
  141 + update($cdrp);
  142 +end
  143 +
  144 +rule "Calcu_loop1_2_" // 时刻表的关联路牌存在,就翻
  145 + salience 800
  146 + when
  147 + $cdrp: Calcu_days_result_pre(
  148 + calcu_start_date_1.isBefore(calcu_end_date_1),
  149 + $csd1: calcu_start_date_1,
  150 + $ced1: calcu_end_date_1,
  151 + $ruleId: ruleId
  152 + )
  153 + $sri: ScheduleRule_input(
  154 + ruleId == $ruleId,
  155 + $rangesize : guideboardIds.size()
  156 + )
  157 + then
  158 + $cdrp.setCalcu_start_date_1($csd1.plusDays(1));
  159 +
  160 + log.info("Calcu_loop1_2_ ruleId={}, calcu_index_lp/ry={}/{}",
  161 + $ruleId, $cdrp.getCalcu_index_lp(), $cdrp.getCalcu_index_ry());
  162 +
  163 + update($cdrp);
  164 +end
  165 +
  166 +
  167 +//----------------------- 路牌范围循环计算 ------------------------//
  168 +
  169 +//declare Calcu_guideboard_index_result
  170 +// ruleId : String // 规则Id
  171 +// calcu_index : Integer // 计算之后的起始索引
  172 +//end
  173 +//
  174 +//// 启用日期等于开始日期
  175 +//rule "calcu_guideboard_index_qyrq_eq_startrq"
  176 +// when
  177 +// $calcu_days_result : Calcu_days_result(
  178 +// qyrq_days == 0,
  179 +// $ruleId: ruleId
  180 +// )
  181 +// $scheduleRule_input : ScheduleRule_input(
  182 +// ruleId == $ruleId,
  183 +// $oindex : startGbdIndex
  184 +// )
  185 +// then
  186 +// Calcu_guideboard_index_result cgir = new Calcu_guideboard_index_result();
  187 +// cgir.setRuleId($ruleId);
  188 +// cgir.setCalcu_index($oindex);
  189 +//
  190 +// log.info("calcu_guideboard_index_qyrq_eq_startrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());
  191 +//
  192 +// insert(cgir);
  193 +//end
  194 +//
  195 +//// 开始日期大于启用日期
  196 +//rule "calcu_guideboard_index_startrq_gt_qyrq"
  197 +// when
  198 +// $calcu_days_result : Calcu_days_result(
  199 +// qyrq_days > 0,
  200 +// $ruleId: ruleId, $qyrq_days: qyrq_days,
  201 +// $calcu_start_date: calcu_start_date
  202 +// )
  203 +// $scheduleRule_input : ScheduleRule_input(
  204 +// ruleId == $ruleId,
  205 +// $qyrq: qyrq,
  206 +// $rangesize : guideboardIds.size(),
  207 +// $oindex : startGbdIndex,
  208 +// $weekdays: weekdays
  209 +// )
  210 +// then
  211 +// // 开始时间
  212 +// DateTime initDate = $qyrq;
  213 +// int index = $oindex;
  214 +// int resultIndex = index;
  215 +//
  216 +// while (!initDate.isAfter($calcu_start_date)) {
  217 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {
  218 +// resultIndex = index;
  219 +// index = (index + 1) % $rangesize;
  220 +// }
  221 +// initDate = initDate.plusDays(1);
  222 +// }
  223 +//
  224 +// Calcu_guideboard_index_result cgir = new Calcu_guideboard_index_result();
  225 +// cgir.setRuleId($ruleId);
  226 +// cgir.setCalcu_index(resultIndex);
  227 +//
  228 +// log.info("calcu_guideboard_index_startrq_gt_qyrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());
  229 +//
  230 +// insert(cgir);
  231 +//end
  232 +//
  233 +////----------------------- 人员范围循环计算 ------------------------//
  234 +//
  235 +//declare Calcu_employee_index_result
  236 +// ruleId : String // 规则Id
  237 +// calcu_index : Integer // 计算之后的起始索引
  238 +//end
  239 +//
  240 +//// 启用日期等于开始日期
  241 +//rule "calcu_employee_index_qyrq_eq_startrq"
  242 +// when
  243 +// $calcu_days_result : Calcu_days_result(
  244 +// qyrq_days == 0,
  245 +// $ruleId: ruleId)
  246 +// $scheduleRule_input : ScheduleRule_input(
  247 +// ruleId == $ruleId,
  248 +// $oindex : startEIndex)
  249 +// then
  250 +// Calcu_employee_index_result cgir = new Calcu_employee_index_result();
  251 +// cgir.setRuleId($ruleId);
  252 +// cgir.setCalcu_index($oindex);
  253 +//
  254 +// log.info("calcu_employee_index_qyrq_eq_startrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());
  255 +//
  256 +// insert(cgir);
  257 +//end
  258 +//
  259 +//// 开始日期大于启用日期
  260 +//rule "calcu_employee_index_startrq_gt_qyrq"
  261 +// when
  262 +// $calcu_days_result : Calcu_days_result(
  263 +// qyrq_days > 0,
  264 +// $ruleId: ruleId, $qyrq_days: qyrq_days,
  265 +// $calcu_start_date: calcu_start_date
  266 +// )
  267 +// $scheduleRule_input : ScheduleRule_input(
  268 +// ruleId == $ruleId,
  269 +// $qyrq: qyrq,
  270 +// $rangesize : employeeConfigIds.size(),
  271 +// $oindex : startEIndex,
  272 +// $weekdays: weekdays
  273 +// )
  274 +// then
  275 +// // 开始时间
  276 +// DateTime initDate = $qyrq;
  277 +// int index = $oindex;
  278 +// int resultIndex = index;
  279 +//
  280 +// while (!initDate.isAfter($calcu_start_date)) {
  281 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {
  282 +// resultIndex = index;
  283 +// index = (index + 1) % $rangesize;
  284 +// }
  285 +// initDate = initDate.plusDays(1);
  286 +// }
  287 +//
  288 +// Calcu_employee_index_result cgir = new Calcu_employee_index_result();
  289 +// cgir.setRuleId($ruleId);
  290 +// cgir.setCalcu_index(resultIndex);
  291 +//
  292 +// log.info("calcu_employee_index_startrq_gt_qyrq ruleId={}, calcu_index={}", $ruleId, cgir.getCalcu_index());
  293 +//
  294 +// insert(cgir);
  295 +//
  296 +//end
  297 +//
  298 +////------------------------- 第三阶段、循环计算 ------------------------//
  299 +//
  300 +////----------------------- 路牌范围循环计算 ------------------------//
  301 +//declare loop_guideboard_result
  302 +// ruleId : String // 规则id
  303 +// go_list : List // 路牌循环的列表
  304 +//end
  305 +//
  306 +//// 循环路牌计算
  307 +//rule "Calcu_loop_guideboard_result"
  308 +// when
  309 +// Calcu_days_result(
  310 +// $ruleId: ruleId,
  311 +// $startDate : calcu_start_date,
  312 +// $calcu_end_date: calcu_end_date
  313 +// )
  314 +// $ruleData : ScheduleRule_input(
  315 +// ruleId == $ruleId,
  316 +// $rangesize : guideboardIds.size(),
  317 +// $weekdays: weekdays
  318 +// )
  319 +// $indexData : Calcu_guideboard_index_result(
  320 +// ruleId == $ruleId
  321 +// )
  322 +// then
  323 +// DateTime initDate = $startDate; // 开始时间
  324 +// DateTime endDate = $calcu_end_date; // 结束实际
  325 +// List<ScheduleResult_output> scheduleResult_outputs =
  326 +// new ArrayList<ScheduleResult_output>();
  327 +//
  328 +// int i = $indexData.getCalcu_index();
  329 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue() == false) {
  330 +// i = (i + 1) % $rangesize;
  331 +// }
  332 +//
  333 +// while (!initDate.isAfter(endDate)) {
  334 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {
  335 +// ScheduleResult_output ro = new ScheduleResult_output();
  336 +// ro.setRuleId($ruleId);
  337 +// ro.setSd(initDate);
  338 +// ro.setGuideboardId($ruleData.getGuideboardIds().get(i));
  339 +// ro.setCarConfigId($ruleData.getCarConfigId());
  340 +// scheduleResult_outputs.add(ro);
  341 +//
  342 +// i = (i + 1) % $rangesize;
  343 +// }
  344 +//
  345 +// initDate = initDate.plusDays(1);
  346 +// }
  347 +//
  348 +// loop_guideboard_result clgr = new loop_guideboard_result();
  349 +// clgr.setRuleId($ruleId);
  350 +// clgr.setGo_list(scheduleResult_outputs);
  351 +//
  352 +// log.info(String.valueOf(scheduleResult_outputs.size()));
  353 +//
  354 +// insert(clgr);
  355 +//
  356 +//end
  357 +//
  358 +////----------------------- 人员范围循环计算 ------------------------//
  359 +//declare loop_employee_result
  360 +// ruleId : String // 规则id
  361 +// eo_list : List // 人员循环的列表
  362 +//end
  363 +//
  364 +//// 循环人员计算
  365 +//rule "Calcu_loop_employee_result"
  366 +// when
  367 +// Calcu_days_result(
  368 +// $ruleId: ruleId,
  369 +// $startDate : calcu_start_date,
  370 +// $calcu_end_date: calcu_end_date
  371 +// )
  372 +// $ruleData : ScheduleRule_input(
  373 +// ruleId == $ruleId,
  374 +// $rangesize : employeeConfigIds.size(),
  375 +// $weekdays: weekdays
  376 +// )
  377 +// $indexData : Calcu_employee_index_result(
  378 +// ruleId == $ruleId
  379 +// )
  380 +// then
  381 +// DateTime initDate = $startDate; // 开始时间
  382 +// DateTime endDate = $calcu_end_date; // 结束实际
  383 +// List<ScheduleResult_output> scheduleResult_outputs =
  384 +// new ArrayList<ScheduleResult_output>();
  385 +//
  386 +// int i = $indexData.getCalcu_index();
  387 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue() == false) {
  388 +// i = (i + 1) % $rangesize;
  389 +// }
  390 +//
  391 +// while (!initDate.isAfter(endDate)) {
  392 +// if (((Boolean) $weekdays.get(initDate.getDayOfWeek() - 1)).booleanValue()) {
  393 +// ScheduleResult_output ro = new ScheduleResult_output();
  394 +// ro.setRuleId($ruleId);
  395 +// ro.setSd(initDate);
  396 +// ro.setEmployeeConfigId($ruleData.getEmployeeConfigIds().get(i));
  397 +// ro.setCarConfigId($ruleData.getCarConfigId());
  398 +// scheduleResult_outputs.add(ro);
  399 +//
  400 +// i = (i + 1) % $rangesize;
  401 +// }
  402 +//
  403 +// initDate = initDate.plusDays(1);
  404 +// }
  405 +//
  406 +// loop_employee_result clgr = new loop_employee_result();
  407 +// clgr.setRuleId($ruleId);
  408 +// clgr.setEo_list(scheduleResult_outputs);
  409 +//
  410 +// log.info(String.valueOf(scheduleResult_outputs.size()));
  411 +//
  412 +// insert(clgr);
  413 +//end
  414 +//
  415 +////------------------------- 第四阶段、范围组循环计算 ----------------------------//
  416 +//
  417 +//global ScheduleResults_output scheduleResult;
  418 +//
  419 +//rule "output"
  420 +// when
  421 +// loop_guideboard_result(
  422 +// go_list.size() > 0,
  423 +// $ruleId : ruleId, $go_list : go_list
  424 +// )
  425 +// loop_employee_result(
  426 +// ruleId == $ruleId,
  427 +// eo_list.size() == $go_list.size(),
  428 +// $eo_list : eo_list
  429 +// )
  430 +// then
  431 +// for (int i = 0; i < $go_list.size(); i++) {
  432 +// ScheduleResult_output go = (ScheduleResult_output) $go_list.get(i);
  433 +// ScheduleResult_output eo = (ScheduleResult_output) $eo_list.get(i);
  434 +// go.setEmployeeConfigId(eo.getEmployeeConfigId());
  435 +// scheduleResult.getResults().add(go);
  436 +// }
  437 +//
  438 +//end
  439 +//
  440 +//
  441 +//
  442 +//
  443 +//
  444 +//
  445 +//
  446 +//
  447 +//
  448 +//
  449 +//
  450 +//
  451 +//
  452 +//
  453 +
  454 +
src/main/resources/rules/ttinfo.drl
@@ -38,6 +38,8 @@ function Map ttidParams(List ttinfolist) { @@ -38,6 +38,8 @@ function Map ttidParams(List ttinfolist) {
38 TODO:规则说明,以后待说明 38 TODO:规则说明,以后待说明
39 */ 39 */
40 40
  41 +// TODO:
  42 +
41 //----------------- 第一阶段、计算规则准备数据(天数)----------------// 43 //----------------- 第一阶段、计算规则准备数据(天数)----------------//
42 44
43 declare Calcu_days_result 45 declare Calcu_days_result
src/main/resources/static/pages/oil/list_ph.html
@@ -23,7 +23,10 @@ @@ -23,7 +23,10 @@
23 <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加</a> 23 <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加</a>
24 <button type="button" class="btn btn-circle blue" id="removeButton"><i class="fa fa-trash-o"></i> 删除</button> 24 <button type="button" class="btn btn-circle blue" id="removeButton"><i class="fa fa-trash-o"></i> 删除</button>
25 <button type="button" class="btn btn-circle blue" id="sortButton"><i class="fa fa-minus-square"></i> 25 <button type="button" class="btn btn-circle blue" id="sortButton"><i class="fa fa-minus-square"></i>
26 - 拆分/保存 26 + 拆分
  27 + </button>
  28 + <button type="button" class="btn btn-circle blue" id="saveButton"><i class="fa fa-check-circle"></i>
  29 + 保存
27 </button> 30 </button>
28 <!-- <button type="button" class="btn btn-circle red" disabled="disabled" id="removeButton"><i class="fa fa-trash"></i> 删除用户</button> --> 31 <!-- <button type="button" class="btn btn-circle red" disabled="disabled" id="removeButton"><i class="fa fa-trash"></i> 删除用户</button> -->
29 <div class="btn-group"> 32 <div class="btn-group">
@@ -187,7 +190,7 @@ @@ -187,7 +190,7 @@
187 {{each list as obj i}} 190 {{each list as obj i}}
188 <tr> 191 <tr>
189 <td style="vertical-align: middle;"> 192 <td style="vertical-align: middle;">
190 - <input type="radio" name="id" class="group-checkable icheck" data-id="{{obj.id}}"> 193 + <input type="checkbox" name="id" class="group-checkable icheck" data-id="{{obj.id}}">
191 </td> 194 </td>
192 195
193 <td> 196 <td>
@@ -212,18 +215,23 @@ @@ -212,18 +215,23 @@
212 {{obj.czyl}} 215 {{obj.czyl}}
213 </td> 216 </td>
214 <td> 217 <td>
215 - <a data-id="{{obj.id}}" href="javascript:;" class="in_carpark_jzyl">  
216 - {{obj.jzyl}}  
217 - </a> 218 + <input data-id="{{obj.id}}" href="javascript:;" class="in_carpark_jzyl"
  219 +type="text" value=" {{obj.jzyl}}" style=" width:40px" onkeyup="this.value=this.value.replace(/[^(\d||/.)]/g,'')"
  220 +onafterpaste="this.value=this.value.replace(/[^(\d||/.)]/g,'')">
218 </td> 221 </td>
219 <td> 222 <td>
220 {{obj.yh}} 223 {{obj.yh}}
221 </td> 224 </td>
222 <td> 225 <td>
223 - {{obj.rylx}} 226 + <select data-id="{{obj.id}}" class="in_carpark_rylx">
  227 + <option value='0' {{if obj.rylx==0}} selected = 'selected' {{/if}}>0号柴油</option>
  228 + <option value='1' {{if obj.rylx==1}} selected = 'selected' {{/if}}>负10号柴油</option>
  229 + </select>
224 </td> 230 </td>
225 <td> 231 <td>
226 - {{obj.ns}} 232 + <input data-id="{{obj.id}}" href="javascript:;"
  233 +class="in_carpark_ns" type="text" value=" {{obj.ns}}" style=" width:40px" onkeyup="this.value=this.value.replace(/[^(\d||/.)]/g,'')"
  234 +onafterpaste="this.value=this.value.replace(/[^(\d||/.)]/g,'')">
227 </td> 235 </td>
228 <td> 236 <td>
229 <select data-id="{{obj.id}}" class="in_carpark_shyy"> 237 <select data-id="{{obj.id}}" class="in_carpark_shyy">
@@ -239,9 +247,9 @@ @@ -239,9 +247,9 @@
239 </select> 247 </select>
240 </td> 248 </td>
241 <td> 249 <td>
242 - <a data-id="{{obj.id}}" href="javascript:;" class="in_carpark_shyl">  
243 - {{obj.sh}}  
244 - </a> 250 + <input data-id="{{obj.id}}" href="javascript:;" class="in_carpark_shyl" type="text"
  251 +value=" {{obj.sh}}" style=" width:40px" onkeyup="this.value=this.value.replace(/[^(\d||/.)]/g,'')"
  252 +onafterpaste="this.value=this.value.replace(/[^(\d||/.)]/g,'')" >
245 </td> 253 </td>
246 <td> 254 <td>
247 {{obj.zlc}} 255 {{obj.zlc}}
@@ -294,7 +302,49 @@ @@ -294,7 +302,49 @@
294 layer.msg('请选择日期.'); 302 layer.msg('请选择日期.');
295 } 303 }
296 }); 304 });
297 - 305 +
  306 +
  307 + //保存
  308 + $("#saveButton").on('click',function(){
  309 + var ylArray = [];
  310 + /* $('input.icheck:checked').each(function(){
  311 + var map = {};
  312 + var id=$(this).data('id');
  313 + var jzyl=$('.in_carpark_jzyl[data-id='+id+']', '#ll_oil_list').html();
  314 + var sh = $('.in_carpark_shyl[data-id='+id+']', '#ll_oil_list').html();
  315 + var shyy = $('.in_carpark_shyy[data-id='+id+']', '#ll_oil_list').val();
  316 + map['id']=id;
  317 + map['jzyl']=jzyl;
  318 + map['sh']=sh;
  319 + map['shyy']=shyy;
  320 + ylArray.push(map);
  321 + }) */
  322 +
  323 + $('input.icheck').each(function(){
  324 + var map = {};
  325 + var id=$(this).data('id');
  326 + var jzyl=$('.in_carpark_jzyl[data-id='+id+']', '#ll_oil_list').val();
  327 + var sh = $('.in_carpark_shyl[data-id='+id+']', '#ll_oil_list').val();
  328 + var shyy = $('.in_carpark_shyy[data-id='+id+']', '#ll_oil_list').val();
  329 + var ns = $('.in_carpark_ns[data-id='+id+']', '#ll_oil_list').val();
  330 + var rylx= $('.in_carpark_rylx[data-id='+id+']', '#ll_oil_list').val();
  331 + map['id']=id;
  332 + map['jzyl']=jzyl;
  333 + map['sh']=sh;
  334 + map['shyy']=shyy;
  335 + map['ns']=ns;
  336 + map['rylx']=rylx;
  337 + ylArray.push(map);
  338 + })
  339 + var params = {};
  340 + params['ylbList']=JSON.stringify(ylArray);
  341 + var i = layer.load(2);
  342 + $get('/ylb/saveYlbList', params, function () {
  343 + layer.close(i);
  344 + var params1 =getParamsList();
  345 + jsDoQuery(params1, true);
  346 + });
  347 + })
298 //拆分 348 //拆分
299 $("#sortButton").on('click', function () { 349 $("#sortButton").on('click', function () {
300 if ($("#rq").val() != "") { 350 if ($("#rq").val() != "") {
@@ -348,7 +398,7 @@ @@ -348,7 +398,7 @@
348 398
349 var page = 0, initPagination; 399 var page = 0, initPagination;
350 var icheckOptions = { 400 var icheckOptions = {
351 - radioClass: 'iradio_square-blue icheck', 401 + radioClass: 'icheckbox_flat-blue',
352 increaseArea: '20%' 402 increaseArea: '20%'
353 } 403 }
354 404
@@ -473,31 +523,29 @@ @@ -473,31 +523,29 @@
473 } */ 523 } */
474 524
475 var l = layer.load(2); 525 var l = layer.load(2);
476 - $get('/ylb', params, function (data) { 526 + $get('/ylb/ylbList', params, function (data) {
477 527
478 - $.each(data.content, function (i, obj) { 528 + $.each(data, function (i, obj) {
479 obj.rq = moment(obj.rq).format("YYYY-MM-DD"); 529 obj.rq = moment(obj.rq).format("YYYY-MM-DD");
480 }); 530 });
481 - var bodyHtm = template('ylb_list_temp', {list: data.content});  
482 -  
483 - $('#datatable_ylb tbody').html(bodyHtm) 531 + var bodyHtm = template('ylb_list_temp', {list:data});
  532 + $('#datatable_ylb tbody').html(bodyHtm);
  533 + /* $('#datatable_ylb tbody').html(bodyHtm)
484 .find('.icheck').iCheck(icheckOptions) 534 .find('.icheck').iCheck(icheckOptions)
485 .on('ifChanged', iCheckChange); 535 .on('ifChanged', iCheckChange);
486 if (pagination && data.content.length > 0) { 536 if (pagination && data.content.length > 0) {
487 //重新分页 537 //重新分页
488 initPagination = true; 538 initPagination = true;
489 showPagination(data); 539 showPagination(data);
490 - } 540 + } */
491 layer.close(l); 541 layer.close(l);
492 $get('/ylb/sumYlb',params,function(returns){ 542 $get('/ylb/sumYlb',params,function(returns){
493 - console.log(returns);  
494 - console.log(returns.jzl);  
495 $("#sumJzl").html(returns.jzl); 543 $("#sumJzl").html(returns.jzl);
496 $("#sumYh").html(returns.yh); 544 $("#sumYh").html(returns.yh);
497 $("#sumSh").html(returns.sh); 545 $("#sumSh").html(returns.sh);
498 }); 546 });
499 - startOptJzylLink($('#ll_oil_list .in_carpark_jzyl'));  
500 - startOptShylLink($('#ll_oil_list .in_carpark_shyl')); 547 +// startOptJzylLink($('#ll_oil_list .in_carpark_jzyl'));
  548 +// startOptShylLink($('#ll_oil_list .in_carpark_shyl'));
501 }); 549 });
502 } 550 }
503 551