Commit 38ef3a7ca231d191abece33d50bcab96c0f3e0f4

Authored by 潘钊
2 parents 7880c549 c2a61e14

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

src/main/java/com/bsth/service/oil/impl/DlbServiceImpl.java
... ... @@ -48,6 +48,7 @@ import com.bsth.service.impl.BaseServiceImpl;
48 48 import com.bsth.service.oil.DlbService;
49 49 import com.bsth.service.realcontrol.ScheduleRealInfoService;
50 50 import com.bsth.util.Arith;
  51 +import com.bsth.util.BatchSaveUtils;
51 52  
52 53 @Service
53 54 public class DlbServiceImpl extends BaseServiceImpl<Dlb,Integer> implements DlbService{
... ... @@ -245,8 +246,8 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS
245 246 List<Cdl> cdyList=cdlRepository.obtainCdl();
246 247 //从排班表中计算出行驶的总里程
247 248 List<Map<String,Object>> listpb=scheduleRealInfoService.yesterdayDataList(line,rq,"","","","");
248   - List<Ylb> addList=new ArrayList<Ylb>();
249   - List<Ylb> updateList=new ArrayList<Ylb>();
  249 + List<Dlb> addList=new ArrayList<Dlb>();
  250 + List<Dlb> updateList=new ArrayList<Dlb>();
250 251 for(int x=0;x<listpb.size();x++){
251 252 String type="add";
252 253 boolean sfdc=false;
... ... @@ -332,12 +333,11 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS
332 333 t.setJhsj(map.get("fcsj")==null?"":map.get("fcsj").toString());
333 334 t.setRq(sdf.parse(rq));
334 335 t.setCreatetime(new Date());
335   - /*if(type.equals("add")){
  336 + if(type.equals("add")){
336 337 addList.add(t);
337 338 }else{
338 339 updateList.add(t);
339   - }*/
340   - repository.save(t);
  340 + }
341 341 newMap.put("status", ResponseCode.SUCCESS);
342 342 } catch (ParseException e) {
343 343 // TODO Auto-generated catch block
... ... @@ -346,20 +346,30 @@ public class DlbServiceImpl extends BaseServiceImpl&lt;Dlb,Integer&gt; implements DlbS
346 346 }
347 347 }
348 348 }
349   - /* try {
  349 + try {
350 350 if(addList.size()>0){
351   - new BatchSaveUtils<Ylb>().saveList(addList, Ylb.class);
  351 + try{
  352 + new BatchSaveUtils<Dlb>().saveList(addList, Dlb.class);
  353 + } catch (Exception e) {
  354 + // TODO: handle exception
  355 + if(e.getMessage().indexOf("PK_DLB_UK")>0){
  356 + newMap.put("fage", "存在相同数据,数据已经过滤");
  357 + logger.info("获取:存在相同数据,数据已经过滤");
  358 + }
  359 + }
352 360 }
353 361  
354 362 if(updateList.size()>0){
355   -
  363 + for (int i = 0; i < updateList.size(); i++) {
  364 + repository.save(updateList.get(i));
  365 + }
356 366 }
357 367 newMap.put("status", ResponseCode.SUCCESS);
358 368 }
359 369 catch (Exception e) {
360 370 // TODO: handle exception
361 371 newMap.put("status", ResponseCode.ERROR);
362   - }*/
  372 + }
363 373 return newMap;
364 374 }
365 375  
... ...
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
... ... @@ -875,7 +875,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
875 875 double ksgl=Arith.add(culateMieageService.culateKsgl(lists),culateMieageService.culateJccgl(lists));
876 876 map.put("ksgl",ksgl);
877 877 map.put("realMileage", Arith.add(yygl ,ksgl));
878   - map.put("jhbc", culateMieageService.culateJhgl(scheduleRealInfos));
  878 + map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos,""));
879 879 map.put("cjbc", culateMieageService.culateLbbc(lists));
880 880 map.put("ljbc", culateMieageService.culateLjbc(lists, ""));
881 881 int sjbc =culateMieageService.culateLjbc(lists, "")+culateMieageService.culateSjbc(lists, "");
... ... @@ -2674,8 +2674,18 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
2674 2674 }
2675 2675 for (int i = 0; i < newList.size(); i++) {
2676 2676 ScheduleRealInfo t1 = newList.get(i);
  2677 + String reamrks1=t1.getRemarks()==null?"":t1.getRemarks();
  2678 + if(reamrks1.length()>5){
  2679 + t1.setRemarks(reamrks1.substring(0, 5));
  2680 + t1.setRemark(reamrks1);
  2681 + }
2677 2682 for (int j = 0; j < list.size(); j++) {
2678 2683 ScheduleRealInfo t2 = list.get(j);
  2684 + String reamrks2=t2.getRemarks()==null?"":t2.getRemarks();
  2685 + if(reamrks2.length()>5){
  2686 + t2.setRemarks(reamrks2.substring(0, 5));
  2687 + t2.setRemark(reamrks2);
  2688 + }
2679 2689 if (t1.getId() == t2.getId()) {
2680 2690 t1 = t2;
2681 2691 }
... ... @@ -3989,7 +3999,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3989 3999 }
3990 4000 tempMap.put("fcsjk" + x, fcsjk);
3991 4001 tempMap.put("fcsjm" + x, fcsjm);
3992   - tempMap.put("remarks" + x, schedule.getRemarks() != null ? schedule.getRemarks() : "");
  4002 + tempMap.put("remarks" + x, schedule.getRemark() != null ? schedule.getRemark() : "");
3993 4003  
3994 4004 size++;
3995 4005 }
... ... @@ -4084,7 +4094,7 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
4084 4094 double ksgl=Arith.add(culateMieageService.culateKsgl(lists),culateMieageService.culateJccgl(lists));
4085 4095 map.put("ksgl",ksgl);
4086 4096 map.put("realMileage", Arith.add(yygl ,ksgl));
4087   - map.put("jhbc", culateMieageService.culateJhgl(scheduleRealInfos));
  4097 + map.put("jhbc", culateMieageService.culateJhbc(scheduleRealInfos,""));
4088 4098 map.put("cjbc", culateMieageService.culateLbbc(lists));
4089 4099 map.put("ljbc", culateMieageService.culateLjbc(lists, ""));
4090 4100 int sjbc =culateMieageService.culateLjbc(lists, "")+culateMieageService.culateSjbc(lists, "");
... ...
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
... ... @@ -864,12 +864,14 @@ public class ReportServiceImpl implements ReportService{
864 864 //查询时间里程
865 865 String sqlPc=" (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,2 as xh FROM "
866 866 + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and "
867   - + " fcsj <='"+minfcsj+"' and bc_type!='in' and bc_type!='out' and bc_type!='ldks') "
  867 + + " fcsj <='"+minfcsj+"' and bc_type!='in' and bc_type!='out' and bc_type!='ldks'"
  868 + + " and bc_type !='region') "
868 869 + " union "
869 870 + " (SELECT jhlc,fcsj,bcsj,bc_type,lp,xl_dir,ists,1 as xh FROM "
870 871 + " bsth_c_s_ttinfo_detail where ttinfo ='"+ttinfo+"' and "
871   - + " fcsj > '"+minfcsj+"' and bc_type!='in' and bc_type!='out' and bc_type!='ldks') "
872   - + " order by xl_dir, xh, fcsj";
  872 + + " fcsj > '"+minfcsj+"' and bc_type!='in' and bc_type!='out' and bc_type!='ldks' "
  873 + + " and bc_type !='region') "
  874 + + " order by xl_dir, xh, lp,fcsj";
873 875 Map<String, Object> map=new HashMap<String,Object>();
874 876 List<Map<String, Object>> list= jdbcTemplate.query(sqlPc,
875 877 new RowMapper<Map<String, Object>>(){
... ... @@ -923,13 +925,17 @@ public class ReportServiceImpl implements ReportService{
923 925 Map<String, Object> tempMap = new HashMap<String, Object>();
924 926 List<Map<String, Object>> list2 = keyMap.get(key);
925 927 List<Integer> cjs = new ArrayList<Integer>();
  928 + List<Integer> fcsj_s = new ArrayList<Integer>();
  929 + List<Integer> fcsj_x = new ArrayList<Integer>();
926 930 int sxsj = 0, xxsj = 0, sxtssj = 0, xxtssj = 0;
927 931 int sxbc = 0, xxbc = 0, sxtsbc = 0, xxtsbc = 0;
928 932 int temp = 24*60+1, zcj = 0;
929 933 boolean ists = false;
  934 + String lpname="";
930 935 for(Map<String, Object> m : list2){
931 936 String[] split = m.get("fcsj").toString().split(":");
932 937 int fcsj = Integer.valueOf(split[0])*60 + Integer.valueOf(split[1]);
  938 +
933 939 int xlDir = Integer.valueOf(m.get("dir").toString());
934 940 int bcsj = Integer.valueOf(m.get("bcsj").toString());
935 941 if(temp >= fcsj){
... ... @@ -937,28 +943,68 @@ public class ReportServiceImpl implements ReportService{
937 943 ists = false;
938 944 }
939 945 if(xlDir == 0){
  946 + fcsj_s.add(fcsj);
940 947 sxsj += bcsj;
941 948 sxbc ++;
942   - if(ists){
943   - sxtssj += fcsj - temp;
  949 + if(!ists){
  950 + if(lpname.equals("")){
  951 + lpname=m.get("lp").toString();
  952 + }else{
  953 + if(lpname.equals(m.get("lp").toString())){
  954 + sxtssj += (fcsj+bcsj) - temp;
  955 + }
  956 + }
944 957 sxtsbc++;
945 958 }
946 959 } else {
  960 + fcsj_x.add(fcsj);
947 961 xxsj += bcsj;
948 962 xxbc ++;
949   - if(ists){
950   - xxtssj += fcsj - temp;
  963 +
  964 + if(!ists){
  965 +
  966 + if(lpname.equals("")){
  967 + lpname=m.get("lp").toString();
  968 + }else{
  969 + if(lpname.equals(m.get("lp").toString())){
  970 + xxtssj += (fcsj+bcsj) - temp;
  971 + }
  972 + }
951 973 xxtsbc++;
952 974 }
953 975 }
954   - if(temp < fcsj){
  976 + /*if(temp < fcsj){
955 977 cjs.add(fcsj - temp);
956 978 temp = fcsj;
957   - }
  979 + }*/
958 980 if(m.get("ists").toString().trim().equals("1")){
959 981 ists = true;
  982 + }else{
  983 + ists=false;
960 984 }
961 985 }
  986 + Collections.sort(fcsj_s);
  987 + int fcsjs=0;
  988 + for (int i = 0; i < fcsj_s.size(); i++) {
  989 + if(i==0){
  990 + fcsjs =fcsj_s.get(i);
  991 + }else{
  992 + cjs.add(fcsj_s.get(i)-fcsjs);
  993 + fcsjs=fcsj_s.get(i);
  994 + }
  995 +
  996 + }
  997 + Collections.sort(fcsj_x);
  998 + int fcsjx=0;
  999 + for (int i = 0; i < fcsj_x.size(); i++) {
  1000 + if(i==0){
  1001 + fcsjx =fcsj_x.get(i);
  1002 + }else{
  1003 + cjs.add(fcsj_x.get(i)-fcsjx);
  1004 + fcsjx =fcsj_x.get(i);
  1005 + }
  1006 +
  1007 + }
962 1008 Collections.sort(cjs);
963 1009 for(int i : cjs){
964 1010 zcj += i;
... ...
src/main/java/com/bsth/service/schedule/rules/shiftloop/GidFbFcnoFunction.java 0 → 100644
  1 +package com.bsth.service.schedule.rules.shiftloop;
  2 +
  3 +import com.bsth.entity.schedule.TTInfoDetail;
  4 +import org.kie.api.runtime.rule.AccumulateFunction;
  5 +
  6 +import java.io.*;
  7 +
  8 +/**
  9 + * 时刻表路牌下的分班班次发车顺序号。
  10 + */
  11 +public class GidFbFcnoFunction implements AccumulateFunction {
  12 + @Override
  13 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  14 + }
  15 +
  16 + @Override
  17 + public void writeExternal(ObjectOutput out) throws IOException {
  18 + }
  19 +
  20 + protected static class GidFbInfoData implements Externalizable {
  21 + public Integer fbfcno;
  22 + public TTInfoDetail ttInfoDetail;
  23 +
  24 + public GidFbInfoData() {}
  25 +
  26 + @Override
  27 + public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
  28 + fbfcno = (Integer) in.readObject();
  29 + ttInfoDetail = (TTInfoDetail) in.readObject();
  30 + }
  31 +
  32 + @Override
  33 + public void writeExternal(ObjectOutput out) throws IOException {
  34 + out.writeObject(fbfcno);
  35 + out.writeObject(ttInfoDetail);
  36 + }
  37 + }
  38 +
  39 + @Override
  40 + public Serializable createContext() {
  41 + return new GidFbInfoData();
  42 + }
  43 +
  44 + @Override
  45 + public void init(Serializable context) throws Exception {
  46 + GidFbInfoData gidFbInfoData = (GidFbInfoData) context;
  47 + gidFbInfoData.fbfcno = 999;
  48 + }
  49 +
  50 + @Override
  51 + public void accumulate(Serializable context, Object value) {
  52 + GidFbInfoData gidFbInfoData = (GidFbInfoData) context;
  53 + TTInfoDetail ttInfoDetail = (TTInfoDetail) value;
  54 +
  55 + // 1块路牌有多个分班班次,取最早的时间作为起始分班班次发车顺序号
  56 + if (ttInfoDetail.getIsFB()) {
  57 + if (ttInfoDetail.getFcno() <= gidFbInfoData.fbfcno) {
  58 + gidFbInfoData.fbfcno = ttInfoDetail.getFcno();
  59 + }
  60 + }
  61 + }
  62 +
  63 + @Override
  64 + public void reverse(Serializable serializable, Object o) throws Exception {
  65 +
  66 + }
  67 +
  68 + @Override
  69 + public boolean supportsReverse() {
  70 + return false;
  71 + }
  72 +
  73 + @Override
  74 + public Class<?> getResultType() {
  75 + return Integer.class;
  76 + }
  77 +
  78 + @Override
  79 + public Object getResult(Serializable context) throws Exception {
  80 + GidFbInfoData gidFbInfoData = (GidFbInfoData) context;
  81 +
  82 + return gidFbInfoData.fbfcno;
  83 + }
  84 +
  85 +}
... ...
src/main/java/com/bsth/service/schedule/rules/shiftloop/readme.txt deleted 100644 → 0
1   -翻班循环规则
2 0 \ No newline at end of file
src/main/resources/rules/functions.drl
... ... @@ -3,6 +3,7 @@ package com.bsth.service.schedule;
3 3 import accumulate com.bsth.service.schedule.rules.ttinfo2.ErrorBcCountFunction ecount;
4 4 import accumulate com.bsth.service.schedule.rules.shiftloop.GidsCountFunction gidscount;
5 5 import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbTimeFunction gidfbtime;
  6 +import accumulate com.bsth.service.schedule.rules.shiftloop.GidFbFcnoFunction gidfbfcno;
6 7 import accumulate com.bsth.service.schedule.rules.ttinfo.LpInfoResultsFunction lpinforesult;
7 8 import accumulate com.bsth.service.schedule.rules.ttinfo.MinRuleQyrqFunction minruleqyrq;
8 9 import accumulate com.bsth.service.schedule.rules.validate.ValidRepeatBcFunction vrb;
9 10 \ No newline at end of file
... ...
src/main/resources/rules/plan.drl
... ... @@ -224,6 +224,7 @@ declare TTInfo_gid_stat
224 224 maxFcno: Integer // 最大发车顺序号
225 225  
226 226 fbTime: LocalTime // 分班时间
  227 + fbfcno: Integer // 分班发车顺序号
227 228 end
228 229  
229 230 rule "calcu_TTInfo_gid_stat"
... ... @@ -234,6 +235,7 @@ rule &quot;calcu_TTInfo_gid_stat&quot;
234 235 $gids: List() from accumulate ($ttd: TTInfoDetail() from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidscount($ttd))
235 236 $gid: String() from $gids
236 237 $fbtime_str: String() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbtime($ttd))
  238 + $fbfcno: Integer() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), gidfbfcno($ttd))
237 239 $maxfcno: Double() from accumulate ($ttd: TTInfoDetail(lp.id.toString() == $gid) from tTInfoDetailRepository.findByTtinfoId(Long.parseLong($ttInfoId)), max($ttd.getFcno()))
238 240 then
239 241 TTInfo_gid_stat ttInfo_gid_stat = new TTInfo_gid_stat();
... ... @@ -243,11 +245,12 @@ rule &quot;calcu_TTInfo_gid_stat&quot;
243 245  
244 246 ttInfo_gid_stat.setMaxFcno($maxfcno.intValue());
245 247 ttInfo_gid_stat.setFbTime(fcsjTime($fbtime_str));
  248 + ttInfo_gid_stat.setFbfcno($fbfcno);
246 249  
247 250 insert(ttInfo_gid_stat);
248 251  
249   -// log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={}",
250   -// $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime());
  252 +// log.info("xlid={},ttid={},gid={},maxfcno={},fbtime={},fbfcno={}",
  253 +// $xlId, $ttInfoId, $gid, ttInfo_gid_stat.getMaxFcno(), ttInfo_gid_stat.getFbTime(), ttInfo_gid_stat.getFbfcno());
251 254  
252 255 end
253 256  
... ... @@ -304,7 +307,10 @@ rule &quot;calcu_TTInfoDetail_Wraps&quot;
304 307  
305 308 LocalTime fcsj = fcsjTime(ttInfoDetail.getFcsj());
306 309 LocalTime fbsj = ttInfo_gid_stat.getFbTime();
307   - ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj)));
  310 + Integer fbfcno = ttInfo_gid_stat.getFbfcno();
  311 + // 不用时间判定,因为有的路牌,后面的班次都是凌晨的,时间反而比分班时间早,不合理,所以使用发车顺序号做第二次比较
  312 +// ttInfoDetail_wrap.setIsFb(fbsj == null ? false : (fcsj.isEqual(fbsj) || fcsj.isAfter(fbsj)));
  313 + ttInfoDetail_wrap.setIsFb(fbsj == null ? false : ttInfoDetail.getFcno() >= fbfcno);
308 314  
309 315 ttInfoDetail_wrap.setSelf(ttInfoDetail);
310 316  
... ...
src/main/resources/static/pages/forms/statement/scheduleDaily.html
... ... @@ -594,7 +594,7 @@
594 594 <td>{{obj.slow0}}
595 595  
596 596 </td>
597   - <td colspan="2"></td>
  597 + <td colspan="2" title="{{obj.remark}}">{{obj.remarks}}</td>
598 598 {{if (i+1)%3 == 0}}
599 599 <td>&nbsp;</td>
600 600 </tr>
... ...