Commit f5b3a17bbfc30a2f42705e584757ba0fd0ccff25

Authored by 潘钊
2 parents 36933403 dea79286

Merge branch 'minhang' into qingpu

# Conflicts:
#	src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
src/main/java/com/bsth/controller/directive/DirectiveController.java
1 1 package com.bsth.controller.directive;
2 2  
3   -import java.util.List;
4   -import java.util.Map;
5   -
6   -import org.apache.commons.lang3.StringEscapeUtils;
7   -import org.springframework.beans.factory.annotation.Autowired;
8   -import org.springframework.web.bind.annotation.RequestMapping;
9   -import org.springframework.web.bind.annotation.RequestMethod;
10   -import org.springframework.web.bind.annotation.RequestParam;
11   -import org.springframework.web.bind.annotation.RestController;
12   -
13 3 import com.alibaba.fastjson.JSON;
14 4 import com.alibaba.fastjson.JSONObject;
15 5 import com.bsth.entity.directive.D80;
... ... @@ -17,6 +7,15 @@ import com.bsth.entity.directive.DC0_A3;
17 7 import com.bsth.entity.sys.SysUser;
18 8 import com.bsth.security.util.SecurityUtils;
19 9 import com.bsth.service.directive.DirectiveService;
  10 +import org.apache.commons.lang3.StringEscapeUtils;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.web.bind.annotation.RequestMapping;
  13 +import org.springframework.web.bind.annotation.RequestMethod;
  14 +import org.springframework.web.bind.annotation.RequestParam;
  15 +import org.springframework.web.bind.annotation.RestController;
  16 +
  17 +import java.util.List;
  18 +import java.util.Map;
20 19  
21 20 /**
22 21 *
... ... @@ -109,6 +108,20 @@ public class DirectiveController {
109 108 SysUser user = SecurityUtils.getCurrentUser();
110 109 return directiveService.upDownChange(nbbm, upDown, user.getUserName());
111 110 }
  111 +
  112 + /**
  113 + *
  114 + * @Title: upDownChange
  115 + * @Description: TODO(状态切换,营运状态 和 上下行)
  116 + * @param @param nbbm 车辆内部编码
  117 + * @param @param upDon
  118 + * @throws
  119 + */
  120 + @RequestMapping(value = "/stateChange", method = RequestMethod.POST)
  121 + public int stateChange(@RequestParam String nbbm, @RequestParam Integer upDown, @RequestParam Integer state){
  122 + SysUser user = SecurityUtils.getCurrentUser();
  123 + return directiveService.stateChange(nbbm, upDown, state, user.getUserName());
  124 + }
112 125  
113 126 /**
114 127 *
... ...
src/main/java/com/bsth/controller/oil/YlbController.java
... ... @@ -62,6 +62,18 @@ public class YlbController extends BaseController<Ylb, Integer>{
62 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 79 * @param map
... ... @@ -69,7 +81,12 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
69 81 */
70 82 @RequestMapping(value = "/sort",method = RequestMethod.GET)
71 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 90 return list;
74 91 }
75 92  
... ... @@ -97,7 +114,12 @@ public class YlbController extends BaseController&lt;Ylb, Integer&gt;{
97 114 */
98 115 @RequestMapping(value = "/checkYl",method = RequestMethod.GET)
99 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 123 return list;
102 124 }
103 125  
... ... @@ -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 199 @RequestMapping(value="/oilListMonth")
161 200 public List<Ylb> oilListMonth(@RequestParam String line,@RequestParam String date){
162 201 return yblService.oilListMonth(line, date);
... ...
src/main/java/com/bsth/data/gpsdata/arrival/SignalHandle.java
... ... @@ -5,6 +5,10 @@ import com.bsth.data.gpsdata.arrival.entity.StationRoute;
5 5 import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
6 6 import com.bsth.data.gpsdata.arrival.utils.GeoUtils;
7 7 import com.bsth.entity.realcontrol.ScheduleRealInfo;
  8 +import org.joda.time.format.DateTimeFormat;
  9 +import org.joda.time.format.DateTimeFormatter;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
8 12  
9 13 import java.util.List;
10 14  
... ... @@ -68,6 +72,8 @@ public abstract class SignalHandle {
68 72 * }
69 73 */
70 74  
  75 + Logger logger = LoggerFactory.getLogger(this.getClass());
  76 + private static DateTimeFormatter fmtHHmm = DateTimeFormat.forPattern("HH:mm");
71 77 protected void transformUpdown(GpsEntity gps, ScheduleRealInfo sch) {
72 78 int updown = Integer.parseInt(sch.getXlDir());
73 79 //gps 切换走向
... ... @@ -78,6 +84,8 @@ public abstract class SignalHandle {
78 84 if (station != null) {
79 85 gps.setStopNo(station.getCode());
80 86 }
  87 +
  88 + logger.info(fmtHHmm.print(gps.getTimestamp()) + " 车辆 :" + gps.getNbbm() + " 切换到走向 : " + updown);
81 89 }
82 90  
83 91 /**
... ...
src/main/java/com/bsth/data/gpsdata/arrival/handlers/InOutStationSignalHandle.java
... ... @@ -7,6 +7,7 @@ import com.bsth.data.gpsdata.arrival.utils.CircleQueue;
7 7 import com.bsth.data.gpsdata.arrival.utils.ScheduleSignalState;
8 8 import com.bsth.data.gpsdata.arrival.utils.SignalSchPlanMatcher;
9 9 import com.bsth.data.schedule.DayOfSchedule;
  10 +import com.bsth.data.schedule.ScheduleComparator;
10 11 import com.bsth.entity.realcontrol.LineConfig;
11 12 import com.bsth.entity.realcontrol.ScheduleRealInfo;
12 13 import com.bsth.service.directive.DirectiveService;
... ... @@ -17,6 +18,9 @@ import org.slf4j.LoggerFactory;
17 18 import org.springframework.beans.factory.annotation.Autowired;
18 19 import org.springframework.stereotype.Component;
19 20  
  21 +import java.util.Collections;
  22 +import java.util.List;
  23 +
20 24 /**
21 25 * 进出站动作处理
22 26 * Created by panzhao on 2016/12/27.
... ... @@ -138,6 +142,10 @@ public class InOutStationSignalHandle extends SignalHandle{
138 142 //持久化
139 143 dayOfSchedule.save(sch);
140 144  
  145 + if(sch.getBcType().equals("out")){
  146 + //出场时,切换成营运状态
  147 + directiveService.send60Operation(sch.getClZbh(), 0, Integer.parseInt(sch.getXlDir()), null, "出场@系统");
  148 + }
141 149 //出站既出场
142 150 outStationAndOutPark(sch);
143 151 logger.info("班次:" + sch.getDfsj() + "发车, 时间:" + sch.getFcsjActual());
... ... @@ -164,6 +172,11 @@ public class InOutStationSignalHandle extends SignalHandle{
164 172  
165 173 sendUtils.refreshSch(schPrev);
166 174 dayOfSchedule.save(schPrev);
  175 +
  176 + if(schPrev.getBcType().equals("out")){
  177 + //出场时,切换成营运状态
  178 + directiveService.send60Operation(schPrev.getClZbh(), 0, Integer.parseInt(schPrev.getXlDir()), null, "出场@系统");
  179 + }
167 180 }
168 181 }
169 182 }
... ... @@ -204,8 +217,14 @@ public class InOutStationSignalHandle extends SignalHandle{
204 217 sendUtils.sendZdsj(sch, next, doneSum);
205 218 //持久化
206 219 dayOfSchedule.save(sch);
207   - //下发调度指令
208   - directiveService.send60Dispatch(next, doneSum, "到站@系统");
  220 + if(next != null){
  221 + //下发调度指令
  222 + directiveService.send60Dispatch(next, doneSum, "到站@系统");
  223 + }
  224 + else if(sch.getBcType().equals("in")){
  225 + //终班进场,切换成非营运状态
  226 + directiveService.send60Operation(sch.getClZbh(), 1, Integer.parseInt(sch.getXlDir()), null, "进场@系统");
  227 + }
209 228  
210 229 //准备执行下一个班次
211 230 if (next != null) {
... ... @@ -217,10 +236,59 @@ public class InOutStationSignalHandle extends SignalHandle{
217 236 transformUpdown(gps, next);
218 237 }
219 238 }
220   - else if(sch.getFcsjActual() == null){
221   - //有进站,但班次没有实发,向前追溯一下信号
222   - scheduleSignalState.signalRetrospect(gps, sch);
  239 + else {
  240 + if(sch.getFcsjActual() == null){
  241 + //有进站,但班次没有实发,向前追溯一下信号
  242 + scheduleSignalState.signalRetrospect(gps, sch);
  243 + }
  244 +
  245 + //如果当前班次是出场,并且进的是下一个班次的终点
  246 + if(sch.getBcType().equals("out")){
  247 + ScheduleRealInfo next = dayOfSchedule.next(sch);
  248 + if(next.getZdzCode().equals(gps.getStopNo())){
  249 + List<ScheduleRealInfo> halfList = dayOfSchedule.findByNbbm(sch.getClZbh());
  250 + //和当前进站信号最匹配的一个班次
  251 + ScheduleRealInfo nearSch = nearScheduleByGpsIn(gps, halfList);
  252 +
  253 + if(nearSch != null){
  254 + //直接跳到这个班次
  255 + dayOfSchedule.addExecPlan(nearSch);
  256 + //重新进站
  257 + inStation(gps, prev);
  258 + }
  259 + }
  260 + }
  261 + }
  262 + }
  263 +
  264 + /**
  265 + * 和当前进站信号最匹配的一个班次
  266 + * @param gps
  267 + * @param halfList
  268 + * @return
  269 + */
  270 + private ScheduleRealInfo nearScheduleByGpsIn(GpsEntity gps, List<ScheduleRealInfo> halfList){
  271 + if(halfList == null || halfList.size() == 0)
  272 + return null;
  273 +
  274 + //排序
  275 + Collections.sort(halfList, new ScheduleComparator.FCSJ());
  276 + ScheduleRealInfo near = null;// = halfList.get(0);
  277 + ScheduleRealInfo sch;
  278 +
  279 + String stopId = gps.getStopNo();
  280 + for(int i = 0; i < halfList.size(); i ++){
  281 + sch = halfList.get(i);
  282 + if(!sch.getZdzCode().equals(stopId))
  283 + continue;
  284 +
  285 + if(sch.getZdsjT() < gps.getTimestamp())
  286 + near = sch;
  287 + else
  288 + break;
  289 +
223 290 }
  291 + return near;
224 292 }
225 293  
226 294 /**
... ...
src/main/java/com/bsth/data/gpsdata/recovery/GpsDataRecovery.java
... ... @@ -60,7 +60,7 @@ public class GpsDataRecovery implements ApplicationContextAware {
60 60 for (String nbbm : keys) {
61 61 Collections.sort(listMap.get(nbbm), comp);
62 62 threadPool.execute(new RecoveryThread(listMap.get(nbbm), count));
63   - /*if(nbbm.equals("W9H-003"))
  63 + /*if(nbbm.equals("SXC-YD012"))
64 64 new RecoveryThread(listMap.get(nbbm), count).run();*/
65 65 }
66 66  
... ... @@ -163,9 +163,8 @@ public class GpsDataRecovery implements ApplicationContextAware {
163 163 reverseSignalHandle.handle(gps, prevs);
164 164 //进出站动作处理
165 165 inOutStationSignalHandle.handle(gps, prevs);
166   - GeoCacheData.putGps(gps);
167 166  
168   - //Thread.sleep(50);
  167 + GeoCacheData.putGps(gps);
169 168 }
170 169 } catch (Exception e) {
171 170 logger.error("", e);
... ...
src/main/java/com/bsth/entity/oil/Ylb.java
... ... @@ -38,7 +38,7 @@ public class Ylb {
38 38 private String shyy;
39 39 private Double zlc=0.0;
40 40 private int yhlx;
41   - private String rylx;
  41 + private String rylx="0";
42 42 private Double ns=0.0;
43 43 private Double fyylc=0.0;
44 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 88 + " and xlbm like %?4% "
89 89 + " and nbbm like %?5%",nativeQuery=true)
90 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 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 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 129 List<ScheduleRealInfo> scheduleByDateAndLine2(String line,String date);
130 130  
131 131 //按月统计
... ... @@ -136,7 +136,11 @@ public interface ScheduleRealInfoRepository extends BaseRepository&lt;ScheduleRealI
136 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 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 144 List<Map<String,Object>> yesterdayDataList(String line,String date,String gsbm,String fgsbm);
141 145  
142 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 33 "info.lp_name as lpName, " +
34 34 "info.cl as clId, " +
35 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 38 "group_concat(distinct info.j) jsyId, " +
39 39 "group_concat(distinct info.j_gh) jsyGh, " +
40 40 "group_concat(distinct info.j_name) jsyName, " +
41 41 "group_concat(distinct info.s) spyId, " +
42 42 "group_concat(distinct info.s_gh) spyGh, " +
43 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 45 "max(info.update_date) as updateDate, " +
46 46 "max(user.user_name) as updateUserName, " +
47 47 "max(info.tt_info_name) as ttInfoName " +
... ... @@ -49,7 +49,7 @@ public interface SchedulePlanInfoRepository extends BaseRepository&lt;SchedulePlanI
49 49 "where info.xl = ?1 and " +
50 50 "info.schedule_date = ?2 " +
51 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 53 List<Object[]> findGroupInfo(Integer xlid, Date scheduleDate);
54 54  
55 55 @Modifying
... ...
src/main/java/com/bsth/service/directive/DirectiveService.java
1 1 package com.bsth.service.directive;
2 2  
3 3  
4   -import java.util.List;
5   -import java.util.Map;
6   -
7 4 import com.bsth.entity.directive.D60;
8 5 import com.bsth.entity.directive.D64;
9 6 import com.bsth.entity.directive.D80;
... ... @@ -11,6 +8,9 @@ import com.bsth.entity.directive.DC0_A3;
11 8 import com.bsth.entity.realcontrol.ScheduleRealInfo;
12 9 import com.bsth.service.BaseService;
13 10  
  11 +import java.util.List;
  12 +import java.util.Map;
  13 +
14 14 public interface DirectiveService extends BaseService<D60, Integer>{
15 15  
16 16 /**
... ... @@ -93,4 +93,6 @@ public interface DirectiveService extends BaseService&lt;D60, Integer&gt;{
93 93 int sendC0A5(String json);
94 94  
95 95 int refreshLineFile(String deviceId);
  96 +
  97 + int stateChange(String nbbm, Integer upDown, Integer state, String userName);
96 98 }
... ...
src/main/java/com/bsth/service/directive/DirectiveServiceImpl.java
... ... @@ -504,4 +504,9 @@ public class DirectiveServiceImpl extends BaseServiceImpl&lt;D60, Integer&gt; implemen
504 504  
505 505 return GatewayHttpUtils.postJson(new DirectiveCreator().createDeviceRefreshData(deviceId, gps.getLineId()));
506 506 }
  507 +
  508 + @Override
  509 + public int stateChange(String nbbm, Integer upDown, Integer state, String userName) {
  510 + return send60Operation(nbbm, state, upDown, null, userName);
  511 + }
507 512 }
... ...
src/main/java/com/bsth/service/oil/YlbService.java
... ... @@ -8,16 +8,17 @@ import com.bsth.service.BaseService;
8 8  
9 9 public interface YlbService extends BaseService<Ylb, Integer>{
10 10 Map<String, Object> obtain(Map<String, Object> map) throws Exception;
  11 + Map<String, Object> saveYlbList(Map<String, Object> map) throws Exception;
11 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 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 19 Map<String, Object> sumYlb(Map<String, Object> map);
19 20  
20 21 List<Ylb> oilListMonth(String line,String date);
21   -
  22 + List<Ylb> listYlb(Map<String, Object> map);
22 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
1 1 package com.bsth.service.oil.impl;
2 2  
  3 +import java.sql.ResultSet;
  4 +import java.sql.SQLException;
  5 +import java.text.DecimalFormat;
  6 +import java.text.ParseException;
  7 +import java.text.SimpleDateFormat;
  8 +import java.util.ArrayList;
  9 +import java.util.Calendar;
  10 +import java.util.Date;
  11 +import java.util.HashMap;
  12 +import java.util.Iterator;
  13 +import java.util.List;
  14 +import java.util.Map;
  15 +
  16 +import javax.transaction.Transactional;
  17 +
  18 +import org.apache.commons.lang3.StringEscapeUtils;
  19 +import org.slf4j.Logger;
  20 +import org.slf4j.LoggerFactory;
  21 +import org.springframework.beans.factory.annotation.Autowired;
  22 +import org.springframework.data.domain.Sort;
  23 +import org.springframework.data.domain.Sort.Direction;
  24 +import org.springframework.jdbc.core.JdbcTemplate;
  25 +import org.springframework.jdbc.core.RowMapper;
  26 +import org.springframework.stereotype.Service;
  27 +
  28 +import com.alibaba.fastjson.JSONArray;
  29 +import com.alibaba.fastjson.JSONObject;
3 30 import com.bsth.common.ResponseCode;
  31 +import com.bsth.data.BasicData;
4 32 import com.bsth.entity.Cars;
5 33 import com.bsth.entity.oil.Cyl;
6 34 import com.bsth.entity.oil.Ylb;
... ... @@ -15,20 +43,7 @@ import com.bsth.service.oil.YlbService;
15 43 import com.bsth.service.realcontrol.ScheduleRealInfoService;
16 44 import com.bsth.util.Arith;
17 45 import com.bsth.util.BatchSaveUtils;
18   -import org.slf4j.Logger;
19   -import org.slf4j.LoggerFactory;
20   -import org.springframework.beans.factory.annotation.Autowired;
21   -import org.springframework.jdbc.core.JdbcTemplate;
22   -import org.springframework.jdbc.core.RowMapper;
23   -import org.springframework.stereotype.Service;
24   -
25   -import javax.transaction.Transactional;
26   -import java.sql.ResultSet;
27   -import java.sql.SQLException;
28   -import java.text.DecimalFormat;
29   -import java.text.ParseException;
30   -import java.text.SimpleDateFormat;
31   -import java.util.*;
  46 +import com.github.abel533.echarts.code.Y;
32 47  
33 48 @Service
34 49 public class YlbServiceImpl extends BaseServiceImpl<Ylb,Integer> implements YlbService{
... ... @@ -161,6 +176,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
161 176 t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));
162 177 t.setSsgsdm(map.get("company")==null?"":map.get("company").toString());
163 178 t.setFgsdm(map.get("bCompany")==null?"":map.get("bCompany").toString());
  179 + t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
164 180 t.setRq(sdf.parse(rq));
165 181 repository.save(t);
166 182  
... ... @@ -311,8 +327,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
311 327 t.setJcsx(Integer.parseInt(map.get("seqNumber").toString()));
312 328 t.setSsgsdm(map.get("company") == null ? "" : map.get("company").toString());
313 329 t.setFgsdm(map.get("bCompany") == null ? "" : map.get("bCompany").toString());
  330 + t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
314 331 t.setRq(sdf.parse(rq));
315   -
316 332 if(type.equals("add")){
317 333 addList.add(t);
318 334 }else{
... ... @@ -369,6 +385,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
369 385 nbbm=map.get("nbbm_eq").toString();
370 386 }
371 387  
  388 + List<Cyl> cylListAdd=new ArrayList<Cyl>();
  389 + Map<String, Object> cylMapAdd=new HashMap<String,Object>();
372 390 Map<String, Object> newMap=new HashMap<String,Object>();
373 391 Map<String, Object> map2=new HashMap<String,Object>();
374 392 try {
... ... @@ -379,7 +397,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
379 397 // 获取车辆存油信息
380 398 List<Cyl> cylList = cylRepository.obtainCyl(nbbm,gsbm);
381 399 // 指定日期YLB信息
382   - List<Ylb> ylbList =repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm");
  400 + List<Ylb> ylbList =repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"nbbm,jcsx");
383 401 List<Ylb> iterator2=repository.obtainYl(rq,gsbm,fgsbm,xlbm,nbbm,"jcsx");
384 402 for (int i=0;i<ylbList.size();i++) {
385 403 Ylb ylb = ylbList.get(i);
... ... @@ -415,31 +433,40 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
415 433 // Iterator<Ylb> iterator2 = repository
416 434 // .findAll(new CustomerSpecs<Ylb>(map), new Sort(Direction.ASC, "jcsx")).iterator();
417 435 for (int j = 0; j < iterator2.size(); j++) {
418   -
419 436 Ylb t = iterator2.get(j);
420 437 if(t.getNbbm().equals(ylb.getNbbm())){
421 438 if (t.getJcsx() == 1) {
422 439 // 进场等于出场的操作 既 最后进场存油量等于第一次的出场存油量
423 440 Double yl = t.getCzyl();
424 441 Double jcyl = t.getCzyl();
425   -// zyl = jcyl + jzl - yl;
426 442 zyl =Arith.sub( Arith.add(jcyl, jzl),yl);
427   - Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
428   - t.setYh(yh);
429   -// 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 + }
430 447 nextJzyl =Arith.sub( Arith.add(t.getJzl(), t.getCzyl()),yh);
431   -// t.setJzyl(Double.parseDouble(df.format(nextJzyl)));
432   - 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;
433 457 } else {
434   -// t.setCzyl(Double.parseDouble(df.format(nextJzyl)));
435 458 t.setCzyl(nextJzyl);
436 459 Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
437   - t.setYh(yh);
438   -// nextJzyl = t.getJzl() + nextJzyl - yh;
439 460 nextJzyl =Arith.sub( Arith.add(t.getJzl(),nextJzyl),yh);
440   -// t.setJzyl(Double.parseDouble(df.format(nextJzyl)));
441   - 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;
442 468 }
  469 +
443 470 repository.save(t);
444 471 }
445 472  
... ... @@ -458,17 +485,36 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
458 485 if (fage) {
459 486 cylRepository.save(cyl);
460 487 } else {
461   - cyl = new Cyl();
462   - cyl.setNbbm(t.getNbbm());
463   - cyl.setCyl(t.getJzyl());
464   - cyl.setGsdm(t.getSsgsdm());
465   - cyl.setUpdatetime(t.getRq());
466   - 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 +
467 510 }
468 511 map2.put("status", ResponseCode.SUCCESS);
469 512 }
470 513 }
471 514 }
  515 + for (int i = 0; i < cylListAdd.size(); i++) {
  516 + cylRepository.save(cylListAdd.get(i));
  517 + }
472 518 } catch (Exception e) {
473 519 map2.put("status", ResponseCode.ERROR);
474 520 logger.error("save erro.", e);
... ... @@ -482,7 +528,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
482 528 */
483 529 @Transactional
484 530 @Override
485   - public Map<String, Object> sort(Map<String, Object> map) {
  531 + public Map<String, Object> sort(Map<String, Object> map) throws Exception{
486 532 // TODO Auto-generated method stub
487 533 Map<String, Object> newMap = new HashMap<String, Object>();
488 534 SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
... ... @@ -495,7 +541,8 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
495 541 Double sh= Double.parseDouble(map.get("sh").toString());
496 542 String shyy=map.get("shyy").toString();
497 543 Ylb ylb = repository.findOne(id);
498   -
  544 + List<Cyl> cylListAdd=new ArrayList<Cyl>();
  545 + Map<String, Object> cylMapAdd=new HashMap<String,Object>();
499 546 String nbbm_eq = ylb.getNbbm();
500 547 Date rq_eq = ylb.getRq();
501 548 // 得到一天总的加油和里程(根据车,时间)
... ... @@ -515,12 +562,9 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
515 562  
516 563 //新的 损耗不等于 旧的损耗 总损耗从新算
517 564 if(Arith.sub(ylb.getSh(),sh )!=0){
518   -// zsh =zsh-ylb.getSh()+sh;
519 565 zsh =Arith.add(Arith.sub(zsh, ylb.getSh()), sh);
520   -// jzl =jzl-zsh;
521 566 jzl =Arith.sub(jzl, zsh);
522 567 }else{
523   -// jzl=jzl-zsh;
524 568 jzl =Arith.sub(jzl, zsh);
525 569 }
526 570 map.put("nbbm_eq", nbbm_eq);
... ... @@ -543,33 +587,37 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
543 587 t.setShyy(shyy);
544 588 }
545 589 Double jcyl = t.getCzyl();
546   -// zyl = jcyl + jzl - yl;
547 590 zyl = Arith.sub(Arith.add(jcyl, jzl), yl);
548 591 Double yh = 0.0;
549 592 if (zlc > 0 && t.getZlc() > 0) {
550 593 yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
551 594 }
552   - t.setYh(yh);
553   -// nextJzyl = t.getJzl() + t.getCzyl() - yh-t.getSh();
554 595 nextJzyl =Arith.sub(Arith.add(t.getJzl(), t.getCzyl()), Arith.add(yh, t.getSh()));
555   -// t.setJzyl(Double.parseDouble(df.format(nextJzyl)));
556   - 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;
557 603 } else {
558 604 if(t.getId()==id){
559 605 t.setSh(sh);
560 606 t.setShyy(shyy);
561 607 }
  608 + t.setCzyl(nextJzyl);
  609 + Double yh =0.0;
562 610 if (t.getZlc() != 0) {
563   -// t.setCzyl(Double.parseDouble(df.format(nextJzyl)));
564   - t.setCzyl(nextJzyl);
565   - Double yh = Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
566   - t.setYh(yh);
567   -// nextJzyl = t.getJzl() + nextJzyl - yh-t.getSh();
568   - nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), Arith.add(yh, t.getSh()));
569   -// t.setJzyl(Double.parseDouble(df.format(nextJzyl)));
570   - t.setJzyl(nextJzyl);
  611 + yh= Double.parseDouble(df.format(zyl * (t.getZlc() / zlc)));
571 612 }
572   -
  613 + nextJzyl = Arith.sub(Arith.add(t.getJzl(), nextJzyl), Arith.add(yh, t.getSh()));
  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;
573 621 }
574 622 repository.save(t);
575 623  
... ... @@ -588,19 +636,37 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
588 636 if (fage) {
589 637 cylRepository.save(cyl);
590 638 } else {
591   - cyl = new Cyl();
592   - cyl.setNbbm(t.getNbbm());
593   - cyl.setCyl(t.getJzyl());
594   - cyl.setGsdm(t.getSsgsdm());
595   - cyl.setUpdatetime(t.getRq());
596   - 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 + }
597 659 }
598 660  
599 661 newMap.put("status", ResponseCode.SUCCESS);
600 662 }
  663 + for (int i = 0; i < cylListAdd.size(); i++) {
  664 + cylRepository.save(cylListAdd.get(i));
  665 + }
601 666 } catch (Exception e) {
602 667 newMap.put("status", ResponseCode.ERROR);
603 668 logger.error("save erro.", e);
  669 + throw e;
604 670 }
605 671 return newMap;
606 672 }
... ... @@ -612,7 +678,7 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
612 678 */
613 679 @Transactional
614 680 @Override
615   - public Map<String, Object> checkYl(Map<String, Object> map) {
  681 + public Map<String, Object> checkYl(Map<String, Object> map) throws Exception{
616 682 Map<String, Object> newMap=new HashMap<String,Object>();
617 683 // String xlbm="";
618 684 // if(map.get("xlbm_like")!=null){
... ... @@ -834,5 +900,96 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
834 900 return sumMap;
835 901 }
836 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 + }
  993 +
837 994  
838 995 }
839 996 \ No newline at end of file
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -1300,7 +1300,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1300 1300 // int cjbc = scheduleRealInfoRepository.findCjbc(jName, clZbh, lpName);
1301 1301 // int ljbc = scheduleRealInfoRepository.findLjbc(jName, clZbh, lpName);
1302 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 1304 float addMileage = 0l, remMileage = 0l,addMileageYy = 0l,addMileageJc =0l;
1305 1305 Map<String, Object> map = new HashMap<String, Object>();
1306 1306 for (ScheduleRealInfo scheduleRealInfo : list) {
... ... @@ -1310,6 +1310,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1310 1310 //临加里程(主任务临加),
1311 1311 //计划班次,烂班班次,增加班次
1312 1312 tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
  1313 + jhlcOrig = scheduleRealInfo.getJhlcOrig()==null?0:scheduleRealInfo.getJhlcOrig();
  1314 +
1313 1315 if (scheduleRealInfo.isSflj()) {
1314 1316 addMileage += tempJhlc;
1315 1317 if (scheduleRealInfo.getBcType().equals("in")
... ... @@ -1324,9 +1326,9 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1324 1326 if (!(scheduleRealInfo.getBcType().equals("in")
1325 1327 || scheduleRealInfo.getBcType().equals("out"))) {
1326 1328 jhbc++;
1327   - jhlc += tempJhlc;
  1329 + jhlc += jhlcOrig;
1328 1330 if (scheduleRealInfo.getStatus() == -1) {
1329   - remMileage += tempJhlc;
  1331 + remMileage += jhlcOrig;
1330 1332 cjbc++;
1331 1333 }
1332 1334 }
... ... @@ -1373,12 +1375,14 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
1373 1375 }
1374 1376 }
1375 1377 }
  1378 +
  1379 + //yygl 包含了临加的营运公里 jcclc包含了临加的进出场里程
1376 1380 map.put("jhlc", format.format(jhlc));
1377 1381 map.put("remMileage", format.format(remMileage));
1378 1382 map.put("addMileage", format.format(addMileage));
1379   - map.put("yygl", format.format(yygl+addMileageYy));
  1383 + map.put("yygl", format.format(yygl));
1380 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 1386 // map.put("realMileage", format.format(yygl + ksgl + jcclc+addMileage));
1383 1387 map.put("jhbc", jhbc);
1384 1388 map.put("cjbc", cjbc);
... ... @@ -2130,7 +2134,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2130 2134 public List<Map<String, Object>> statisticsDailyTj(String line, String date,String date2,
2131 2135 String xlName, String type) {
2132 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 2144 List<Map<String, Object>> lMap = new ArrayList<Map<String, Object>>();
2136 2145 DecimalFormat format = new DecimalFormat("0.00");
... ... @@ -2897,12 +2906,12 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2897 2906 //前一天日期
2898 2907 // String date = sdfMonth.format(org.apache.commons.lang.time.DateUtils.addDays(new Date(), -1));
2899 2908 // String date = "2016-09-20";
2900   - System.out.println("shijian1:"+new Date());
  2909 +// System.out.println("shijian1:"+new Date());
2901 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 2912 // List<ScheduleRealInfo> list = scheduleRealInfoRepository.scheduleByDateAndLine(line, date);
2904 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 2915 for (int x = 0; x < yesterdayDataList.size(); x++) {
2907 2916 String jName = yesterdayDataList.get(x).get("jGh").toString();
2908 2917 String clZbh = yesterdayDataList.get(x).get("clZbh").toString();
... ... @@ -2929,18 +2938,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2929 2938 tempJhlc = scheduleRealInfo.getJhlc() == null ? 0 : scheduleRealInfo.getJhlc();
2930 2939 if (scheduleRealInfo.isSflj()) {
2931 2940 if(scheduleRealInfo.getStatus() == -1){
2932   -// addMileage += tempJhlc;
2933 2941 addMileage =Arith.add(addMileage, tempJhlc);
2934 2942 }
2935 2943 } else {
2936 2944 if (!(scheduleRealInfo.getBcType().equals("in")
2937 2945 || scheduleRealInfo.getBcType().equals("out"))) {
2938   -// jhlc += tempJhlc;
2939 2946 jhlc =Arith.add(jhlc,tempJhlc);
2940 2947 }
2941 2948  
2942 2949 if (scheduleRealInfo.getStatus() == -1) {
2943   -// remMileage += tempJhlc;
2944 2950 remMileage =Arith.add(remMileage,tempJhlc);
2945 2951 }
2946 2952 }
... ... @@ -2950,7 +2956,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2950 2956 if (scheduleRealInfo.getBcType().equals("in") ||
2951 2957 scheduleRealInfo.getBcType().equals("out")) {
2952 2958 if (scheduleRealInfo.getStatus() != -1) {
2953   -// jcclc += tempJhlc;
2954 2959 jcclc=Arith.add(jcclc,tempJhlc);
2955 2960 }
2956 2961 }
... ... @@ -2960,7 +2965,6 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2960 2965 // }
2961 2966 else {
2962 2967 if (scheduleRealInfo.getStatus() != -1) {
2963   -// yygl += tempJhlc;
2964 2968 yygl=Arith.add(yygl,tempJhlc);
2965 2969 }
2966 2970 }
... ... @@ -2970,19 +2974,15 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2970 2974 ChildTaskPlan childTaskPlan = it.next();
2971 2975 if (childTaskPlan.getMileageType().equals("empty")) {
2972 2976 if (childTaskPlan.isDestroy()) {
2973   -// remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
2974 2977 remMileage=Arith.add(remMileage,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage());
2975 2978 } else {
2976   -// ksgl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
2977 2979 ksgl += Arith.add(ksgl,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage());
2978 2980 }
2979 2981 } else {
2980 2982 if (childTaskPlan.isDestroy()) {
2981   -// remMileage += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
2982 2983 remMileage=Arith.add(remMileage,childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage());
2983 2984  
2984 2985 } else {
2985   -// yygl += childTaskPlan.getMileage() == null ? 0 : childTaskPlan.getMileage();
2986 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 15 import com.bsth.service.schedule.rules.shiftloop.ScheduleResults_output;
16 16 import com.bsth.service.schedule.rules.shiftloop.ScheduleRule_input;
17 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 19 import com.bsth.service.schedule.rules.ttinfo2.CalcuParam;
23 20 import com.bsth.service.schedule.rules.ttinfo2.Result;
24 21 import org.joda.time.DateTime;
... ... @@ -97,7 +94,7 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
97 94 * 循环规则输出。
98 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 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 124 for (ScheduleRule_input scheduleRule_input : scheduleRule_inputs) {
128 125 session.insert(scheduleRule_input);
129 126 }
  127 + for (LpInfoResult_output lpInfoResult_output: lpInfoResults_output.getLpInfoResult_outputs()) {
  128 + session.insert(lpInfoResult_output);
  129 + }
130 130 // 执行rule
131 131 session.fireAllRules();
132 132  
... ... @@ -139,11 +139,11 @@ public class SchedulePlanServiceImpl extends BServiceImpl&lt;SchedulePlan, Long&gt; im
139 139 }
140 140  
141 141 /**
142   - * 时刻表选择(判定每天使用的时刻表)。
  142 + * 时刻表选择(判定每天使用的时刻表,以及路牌数据输出)。
143 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 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 183 // 执行完毕销毁,有日志的也要关闭
184 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 230  
231 231 @Transactional(propagation = Propagation.REQUIRED, isolation = Isolation.READ_COMMITTED)
232 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 253 // // 1、循环规则计算输出
234 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 257 // // 3、计划输出
238 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 17 public void setLpInfoResult_outputs(List<LpInfoResult_output> lpInfoResult_outputs) {
18 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 38 TODO:规则说明,以后待说明
39 39 */
40 40  
  41 +// TODO:
  42 +
41 43 //----------------- 第一阶段、计算规则准备数据(天数)----------------//
42 44  
43 45 declare Calcu_days_result
... ...
src/main/resources/static/pages/oil/list_ph.html
... ... @@ -23,7 +23,10 @@
23 23 <a class="btn btn-circle blue" href="add.html" data-pjax><i class="fa fa-plus"></i> 添加</a>
24 24 <button type="button" class="btn btn-circle blue" id="removeButton"><i class="fa fa-trash-o"></i> 删除</button>
25 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 30 </button>
28 31 <!-- <button type="button" class="btn btn-circle red" disabled="disabled" id="removeButton"><i class="fa fa-trash"></i> 删除用户</button> -->
29 32 <div class="btn-group">
... ... @@ -187,7 +190,7 @@
187 190 {{each list as obj i}}
188 191 <tr>
189 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 194 </td>
192 195  
193 196 <td>
... ... @@ -212,18 +215,23 @@
212 215 {{obj.czyl}}
213 216 </td>
214 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 221 </td>
219 222 <td>
220 223 {{obj.yh}}
221 224 </td>
222 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 230 </td>
225 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 235 </td>
228 236 <td>
229 237 <select data-id="{{obj.id}}" class="in_carpark_shyy">
... ... @@ -239,9 +247,9 @@
239 247 </select>
240 248 </td>
241 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 253 </td>
246 254 <td>
247 255 {{obj.zlc}}
... ... @@ -294,7 +302,49 @@
294 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 349 $("#sortButton").on('click', function () {
300 350 if ($("#rq").val() != "") {
... ... @@ -348,7 +398,7 @@
348 398  
349 399 var page = 0, initPagination;
350 400 var icheckOptions = {
351   - radioClass: 'iradio_square-blue icheck',
  401 + radioClass: 'icheckbox_flat-blue',
352 402 increaseArea: '20%'
353 403 }
354 404  
... ... @@ -473,31 +523,29 @@
473 523 } */
474 524  
475 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 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 534 .find('.icheck').iCheck(icheckOptions)
485 535 .on('ifChanged', iCheckChange);
486 536 if (pagination && data.content.length > 0) {
487 537 //重新分页
488 538 initPagination = true;
489 539 showPagination(data);
490   - }
  540 + } */
491 541 layer.close(l);
492 542 $get('/ylb/sumYlb',params,function(returns){
493   - console.log(returns);
494   - console.log(returns.jzl);
495 543 $("#sumJzl").html(returns.jzl);
496 544 $("#sumYh").html(returns.yh);
497 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  
... ...
src/main/resources/static/real_control_v2/fragments/north/nav/directive_history.html
... ... @@ -65,9 +65,9 @@
65 65 {{if obj.reply46 != 0}}
66 66 <div class="uk-badge uk-badge-danger"> 设备未响应</div>
67 67 {{else if obj.reply47 != 0}}
68   - <div class="uk-badge uk-badge-warning"> 驾驶员未确认</div>
  68 + <div class="uk-badge uk-badge-warning"> 设备已响应</div>
69 69 {{else if obj.reply46 == 0 && obj.reply47 == 0}}
70   - <div class="uk-badge"> 成功</div>
  70 + <div class="uk-badge"> 驾驶员已确认</div>
71 71 {{/if}}
72 72 {{/if}}
73 73 </td>
... ...
src/main/resources/static/real_control_v2/js/home/context_menu.js
... ... @@ -39,6 +39,20 @@ var gb_home_context_menu = (function() {
39 39 });
40 40 };
41 41  
  42 + //营运状态和上下行切换
  43 + var stateChange = function (nbbm, updown, state) {
  44 + $.post('/directive/stateChange', {
  45 + nbbm: nbbm,
  46 + upDown: updown,
  47 + state: state
  48 + }, function(rs) {
  49 + if (rs == 0)
  50 + notify_succ('指令已发出');
  51 + else
  52 + notify_err('发送失败,原因参考【指令下发记录】');
  53 + });
  54 + };
  55 +
42 56 // send phrase
43 57 var sendPhrase = function() {
44 58 var dom = temps['home-send-phrase-temp']({
... ... @@ -139,11 +153,19 @@ var gb_home_context_menu = (function() {
139 153 };
140 154  
141 155 var state_up_0 = function() {
142   - changeUpDown(active_car, 0);
  156 + stateChange(active_car, 0, 0);
143 157 };
144 158  
145 159 var state_down_0 = function() {
146   - changeUpDown(active_car, 1);
  160 + stateChange(active_car, 1, 0);
  161 + };
  162 +
  163 + var state_up_1 = function () {
  164 + stateChange(active_car, 0, 1);
  165 + };
  166 +
  167 + var state_down_1 = function () {
  168 + stateChange(active_car, 1, 1);
147 169 };
148 170  
149 171 var line_change = function() {
... ... @@ -179,7 +201,6 @@ var gb_home_context_menu = (function() {
179 201 });
180 202 };
181 203  
182   -
183 204 var C0_A3 = function(){
184 205 open_modal('/real_control_v2/fragments/home/c0_a3.html', {}, {center: false, bgclose: false});
185 206 };
... ... @@ -190,7 +211,9 @@ var gb_home_context_menu = (function() {
190 211 state_up_0: state_up_0,
191 212 state_down_0: state_down_0,
192 213 line_change: line_change,
193   - C0_A3: C0_A3
  214 + C0_A3: C0_A3,
  215 + state_up_1: state_up_1,
  216 + state_down_1: state_down_1
194 217 };
195 218  
196 219 $.contextMenu({
... ... @@ -210,6 +233,13 @@ var gb_home_context_menu = (function() {
210 233 'fold_state': {
211 234 name: '状态切换',
212 235 items: {
  236 + 'state_up_1': {
  237 + 'name': '上行非营运'
  238 + },
  239 + 'state_down_1': {
  240 + 'name': '下行非营运'
  241 + },
  242 + 'sep3_2': '---------',
213 243 'state_up_0': {
214 244 'name': '上行营运'
215 245 },
... ...