Commit 6d79b0c9c4cb14895a482701ec95836e24dec96e

Authored by 娄高锋
2 parents 74be7f30 dcb17da2

Merge branch 'pudong' of 192.168.168.201:panzhaov5/bsth_control into pudong

src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
@@ -23,9 +23,6 @@ import java.util.*; @@ -23,9 +23,6 @@ import java.util.*;
23 @RequestMapping("/realSchedule") 23 @RequestMapping("/realSchedule")
24 public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> { 24 public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> {
25 25
26 - /*@Autowired  
27 - GetSchedulePlanThread getSchedulePlanThread;*/  
28 -  
29 @Autowired 26 @Autowired
30 ScheduleRealInfoService scheduleRealInfoService; 27 ScheduleRealInfoService scheduleRealInfoService;
31 28
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
@@ -110,4 +110,14 @@ public class anomalyCheckController { @@ -110,4 +110,14 @@ public class anomalyCheckController {
110 dayOfSchedule.removeExecPlan(nbbm); 110 dayOfSchedule.removeExecPlan(nbbm);
111 return 1; 111 return 1;
112 } 112 }
  113 +
  114 + @RequestMapping(value = "/sch_re_calc_id_maps")
  115 + public int reCalcIdMaps(){
  116 + return dayOfSchedule.reCalcIdMaps();
  117 + }
  118 +
  119 + @RequestMapping(value = "/sch_size_string")
  120 + public String schSizeString(){
  121 + return dayOfSchedule.sizeString();
  122 + }
113 } 123 }
src/main/java/com/bsth/controller/report/ReportController.java
@@ -325,4 +325,10 @@ public class ReportController { @@ -325,4 +325,10 @@ public class ReportController {
325 325
326 return lMap; 326 return lMap;
327 } 327 }
  328 +
  329 +
  330 + @RequestMapping(value="/online")
  331 + public Map<String, Object> online(@RequestParam Map<String, Object> map){
  332 + return service.online(map);
  333 + }
328 } 334 }
src/main/java/com/bsth/data/directive/DayOfDirectives.java
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; @@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
15 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
16 16
17 import java.util.*; 17 import java.util.*;
  18 +import java.util.concurrent.ConcurrentHashMap;
18 19
19 /** 20 /**
20 * 21 *
@@ -52,8 +53,8 @@ public class DayOfDirectives { @@ -52,8 +53,8 @@ public class DayOfDirectives {
52 53
53 54
54 static{ 55 static{
55 - d60Map = new HashMap<>();  
56 - d64Map = new HashMap<>(); 56 + d60Map = new ConcurrentHashMap<>();
  57 + d64Map = new ConcurrentHashMap<>();
57 pstDirectives = new LinkedList<>(); 58 pstDirectives = new LinkedList<>();
58 } 59 }
59 60
src/main/java/com/bsth/data/directive/DirectivesPstThread.java
@@ -51,10 +51,6 @@ public class DirectivesPstThread extends Thread { @@ -51,10 +51,6 @@ public class DirectivesPstThread extends Thread {
51 logger.warn("save 指令,发现 deleted=true 的班次,id=" + sch.getId()); 51 logger.warn("save 指令,发现 deleted=true 的班次,id=" + sch.getId());
52 continue; 52 continue;
53 } 53 }
54 - if(dayOfSchedule.get(sch.getId()) == null){  
55 - logger.warn("班次:" + sch.getId() + "不存在了,调度指令放弃入库。");  
56 - continue;  
57 - }  
58 } 54 }
59 d60Repository.save(d60); 55 d60Repository.save(d60);
60 } 56 }
src/main/java/com/bsth/data/schedule/DayOfSchedule.java
@@ -14,9 +14,7 @@ import com.bsth.entity.schedule.SchedulePlanInfo; @@ -14,9 +14,7 @@ import com.bsth.entity.schedule.SchedulePlanInfo;
14 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; 14 import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
15 import com.bsth.service.schedule.SchedulePlanInfoService; 15 import com.bsth.service.schedule.SchedulePlanInfoService;
16 import com.bsth.websocket.handler.SendUtils; 16 import com.bsth.websocket.handler.SendUtils;
17 -import com.google.common.base.Predicate;  
18 import com.google.common.collect.ArrayListMultimap; 17 import com.google.common.collect.ArrayListMultimap;
19 -import com.google.common.collect.Collections2;  
20 import org.apache.commons.lang3.StringUtils; 18 import org.apache.commons.lang3.StringUtils;
21 import org.joda.time.format.DateTimeFormat; 19 import org.joda.time.format.DateTimeFormat;
22 import org.joda.time.format.DateTimeFormatter; 20 import org.joda.time.format.DateTimeFormatter;
@@ -37,6 +35,7 @@ import java.sql.SQLException; @@ -37,6 +35,7 @@ import java.sql.SQLException;
37 import java.text.ParseException; 35 import java.text.ParseException;
38 import java.text.SimpleDateFormat; 36 import java.text.SimpleDateFormat;
39 import java.util.*; 37 import java.util.*;
  38 +import java.util.concurrent.ConcurrentHashMap;
40 import java.util.concurrent.ConcurrentLinkedQueue; 39 import java.util.concurrent.ConcurrentLinkedQueue;
41 40
42 /** 41 /**
@@ -100,11 +99,11 @@ public class DayOfSchedule { @@ -100,11 +99,11 @@ public class DayOfSchedule {
100 nbbmScheduleMap = ArrayListMultimap.create(); 99 nbbmScheduleMap = ArrayListMultimap.create();
101 lpScheduleMap = ArrayListMultimap.create(); 100 lpScheduleMap = ArrayListMultimap.create();
102 101
103 - id2SchedulMap = new HashMap<>(); 102 + id2SchedulMap = new ConcurrentHashMap<>();
104 pstBuffer = new ConcurrentLinkedQueue<>(); 103 pstBuffer = new ConcurrentLinkedQueue<>();
105 schFCSJComparator = new ScheduleComparator.FCSJ(); 104 schFCSJComparator = new ScheduleComparator.FCSJ();
106 currSchDateMap = new HashMap<>(); 105 currSchDateMap = new HashMap<>();
107 - carExecutePlanMap = new HashMap<>(); 106 + carExecutePlanMap = new ConcurrentHashMap<>();
108 107
109 schedulePlanMap = new HashMap<>(); 108 schedulePlanMap = new HashMap<>();
110 } 109 }
@@ -266,7 +265,7 @@ public class DayOfSchedule { @@ -266,7 +265,7 @@ public class DayOfSchedule {
266 public void clearRAMData(String lineCode) { 265 public void clearRAMData(String lineCode) {
267 int count = 0; 266 int count = 0;
268 List<ScheduleRealInfo> remList = new ArrayList<>(); 267 List<ScheduleRealInfo> remList = new ArrayList<>();
269 - Collection<ScheduleRealInfo> all = id2SchedulMap.values(); 268 + Collection<ScheduleRealInfo> all = nbbmScheduleMap.values();
270 for (ScheduleRealInfo sch : all) { 269 for (ScheduleRealInfo sch : all) {
271 if (sch.getXlBm().equals(lineCode)) 270 if (sch.getXlBm().equals(lineCode))
272 remList.add(sch); 271 remList.add(sch);
@@ -431,7 +430,7 @@ public class DayOfSchedule { @@ -431,7 +430,7 @@ public class DayOfSchedule {
431 ps.setInt(3, sch.getBcs()==null?0:sch.getBcs()); 430 ps.setInt(3, sch.getBcs()==null?0:sch.getBcs());
432 ps.setInt(4, sch.getBcsj()==null?0:sch.getBcsj()); 431 ps.setInt(4, sch.getBcsj()==null?0:sch.getBcsj());
433 ps.setString(5, sch.getClZbh()); 432 ps.setString(5, sch.getClZbh());
434 - ps.setDate(6, new java.sql.Date(sch.getCreateDate().getTime())); 433 + ps.setTimestamp(6, new java.sql.Timestamp(sch.getCreateDate().getTime()));
435 ps.setString(7, sch.getDfsj()); 434 ps.setString(7, sch.getDfsj());
436 ps.setInt(8, sch.getDirectiveState()); 435 ps.setInt(8, sch.getDirectiveState());
437 ps.setInt(9, sch.getFcno()==null?0:sch.getFcno()); 436 ps.setInt(9, sch.getFcno()==null?0:sch.getFcno());
@@ -447,12 +446,12 @@ public class DayOfSchedule { @@ -447,12 +446,12 @@ public class DayOfSchedule {
447 ps.setString(19, sch.getRemarks()); 446 ps.setString(19, sch.getRemarks());
448 ps.setString(20, sch.getsGh()); 447 ps.setString(20, sch.getsGh());
449 ps.setString(21, sch.getsName()); 448 ps.setString(21, sch.getsName());
450 - ps.setDate(22, new java.sql.Date(sch.getScheduleDate().getTime())); 449 + ps.setTimestamp(22, new java.sql.Timestamp(sch.getScheduleDate().getTime()));
451 ps.setString(23, sch.getScheduleDateStr()); 450 ps.setString(23, sch.getScheduleDateStr());
452 ps.setBoolean(24, sch.isSflj()); 451 ps.setBoolean(24, sch.isSflj());
453 ps.setLong(25, sch.getSpId()); 452 ps.setLong(25, sch.getSpId());
454 ps.setInt(26, sch.getStatus()); 453 ps.setInt(26, sch.getStatus());
455 - ps.setDate(27, new java.sql.Date(sch.getUpdateDate().getTime())); 454 + ps.setTimestamp(27, new java.sql.Timestamp(sch.getUpdateDate().getTime()));
456 ps.setString(28, sch.getXlBm()); 455 ps.setString(28, sch.getXlBm());
457 ps.setString(29, sch.getXlDir()); 456 ps.setString(29, sch.getXlDir());
458 ps.setString(30, sch.getXlName()); 457 ps.setString(30, sch.getXlName());
@@ -512,7 +511,7 @@ public class DayOfSchedule { @@ -512,7 +511,7 @@ public class DayOfSchedule {
512 public List<ScheduleRealInfo> findByLineCode(String lineCode) { 511 public List<ScheduleRealInfo> findByLineCode(String lineCode) {
513 List<ScheduleRealInfo> rs = new ArrayList<>(); 512 List<ScheduleRealInfo> rs = new ArrayList<>();
514 513
515 - Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); 514 + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
516 for (ScheduleRealInfo sch : schs) { 515 for (ScheduleRealInfo sch : schs) {
517 if (sch.getXlBm().equals(lineCode)) 516 if (sch.getXlBm().equals(lineCode))
518 rs.add(sch); 517 rs.add(sch);
@@ -527,7 +526,7 @@ public class DayOfSchedule { @@ -527,7 +526,7 @@ public class DayOfSchedule {
527 public Map<String, Collection<ScheduleRealInfo>> findByLineCodes(List<String> lineList) { 526 public Map<String, Collection<ScheduleRealInfo>> findByLineCodes(List<String> lineList) {
528 ArrayListMultimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); 527 ArrayListMultimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create();
529 528
530 - Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); 529 + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values();
531 for (ScheduleRealInfo sch : schs) { 530 for (ScheduleRealInfo sch : schs) {
532 if (lineList.contains(sch.getXlBm())) { 531 if (lineList.contains(sch.getXlBm())) {
533 mMap.put(sch.getXlBm(), sch); 532 mMap.put(sch.getXlBm(), sch);
@@ -584,24 +583,6 @@ public class DayOfSchedule { @@ -584,24 +583,6 @@ public class DayOfSchedule {
584 return next(list, sch); 583 return next(list, sch);
585 } 584 }
586 585
587 - /**  
588 - * 下一个相同走向的班次  
589 - *  
590 - * @param sch  
591 - * @return  
592 - */  
593 - public ScheduleRealInfo nextSame(final ScheduleRealInfo sch) {  
594 - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());  
595 - Collection<ScheduleRealInfo> subList = Collections2.filter(list, new Predicate<ScheduleRealInfo>() {  
596 -  
597 - @Override  
598 - public boolean apply(ScheduleRealInfo item) {  
599 - return item.getXlDir().equals(sch.getXlDir());  
600 - }  
601 - });  
602 - return next(subList, sch);  
603 - }  
604 -  
605 586
606 /** 587 /**
607 * 下一个班次 588 * 下一个班次
@@ -749,8 +730,7 @@ public class DayOfSchedule { @@ -749,8 +730,7 @@ public class DayOfSchedule {
749 .calcRealDate(sch) 730 .calcRealDate(sch)
750 .calcAllTimeByFcsj(sch); 731 .calcAllTimeByFcsj(sch);
751 732
752 - String nbbm = sch.getClZbh();  
753 - nbbmScheduleMap.put(nbbm, sch); 733 + nbbmScheduleMap.put(sch.getClZbh(), sch);
754 734
755 //主键索引 735 //主键索引
756 id2SchedulMap.put(sch.getId(), sch); 736 id2SchedulMap.put(sch.getId(), sch);
@@ -767,7 +747,6 @@ public class DayOfSchedule { @@ -767,7 +747,6 @@ public class DayOfSchedule {
767 } 747 }
768 748
769 public void delete(ScheduleRealInfo sch) { 749 public void delete(ScheduleRealInfo sch) {
770 - //ScheduleRealInfo sch = id2SchedulMap.get(id);  
771 if (!sch.isSflj()) 750 if (!sch.isSflj())
772 return; 751 return;
773 752
@@ -807,36 +786,6 @@ public class DayOfSchedule { @@ -807,36 +786,6 @@ public class DayOfSchedule {
807 return rs; 786 return rs;
808 } 787 }
809 788
810 - public boolean validTime(ScheduleRealInfo sch, Long ts) {  
811 - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());  
812 - int ci = list.indexOf(sch);  
813 - ScheduleRealInfo prve, next;  
814 - if (ci > 0) {  
815 - //之前班次实际时间不能大于该时间  
816 - for (int i = ci - 1; i >= 0; i--) {  
817 - prve = list.get(i);  
818 - if (prve.getZdsjActualTime() != null && prve.getZdsjActualTime() > ts)  
819 - return false;  
820 -  
821 - if (prve.getFcsjActualTime() != null && prve.getFcsjActualTime() > ts)  
822 - return false;  
823 - }  
824 - }  
825 -  
826 - if (ci < list.size() - 1) {  
827 - //之后班次实际时间不能小于该时间  
828 - for (int i = ci + 1; i < list.size(); i++) {  
829 - next = list.get(i);  
830 - if (next.getFcsjActualTime() != null && next.getFcsjActualTime() < ts)  
831 - return false;  
832 -  
833 - if (next.getZdsjActualTime() != null && next.getZdsjActualTime() < ts)  
834 - return false;  
835 - }  
836 - }  
837 - return true;  
838 - }  
839 -  
840 public void save(ScheduleRealInfo sch) { 789 public void save(ScheduleRealInfo sch) {
841 sch.setUpdateDate(new Date()); 790 sch.setUpdateDate(new Date());
842 pstBuffer.add(sch); 791 pstBuffer.add(sch);
@@ -860,26 +809,6 @@ public class DayOfSchedule { @@ -860,26 +809,6 @@ public class DayOfSchedule {
860 return sch; 809 return sch;
861 } 810 }
862 811
863 - /**  
864 - * @Title: nextByBcType  
865 - * @Description: TODO(获取下一个指定班次类型的班次)  
866 - */  
867 - public ScheduleRealInfo nextByBcType(ScheduleRealInfo sch, String bcType) {  
868 - List<ScheduleRealInfo> list = nbbmScheduleMap.get(sch.getClZbh());  
869 - Collections.sort(list, schFCSJComparator);  
870 -  
871 - boolean flag = false;  
872 - for (ScheduleRealInfo temp : list) {  
873 -  
874 - if (flag && temp.getBcType().equals(bcType))  
875 - return temp;  
876 -  
877 - if (temp == sch) {  
878 - flag = true;  
879 - }  
880 - }  
881 - return null;  
882 - }  
883 812
884 /** 813 /**
885 * 搜索离当前时间最近的一个指定类型的班次 814 * 搜索离当前时间最近的一个指定类型的班次
@@ -917,7 +846,7 @@ public class DayOfSchedule { @@ -917,7 +846,7 @@ public class DayOfSchedule {
917 } 846 }
918 847
919 public Collection<ScheduleRealInfo> findAll() { 848 public Collection<ScheduleRealInfo> findAll() {
920 - return id2SchedulMap.values(); 849 + return nbbmScheduleMap.values();
921 } 850 }
922 851
923 public boolean addExecPlan(ScheduleRealInfo sch) { 852 public boolean addExecPlan(ScheduleRealInfo sch) {
@@ -949,6 +878,8 @@ public class DayOfSchedule { @@ -949,6 +878,8 @@ public class DayOfSchedule {
949 * @return 878 * @return
950 */ 879 */
951 public ScheduleRealInfo executeCurr(String nbbm) { 880 public ScheduleRealInfo executeCurr(String nbbm) {
  881 + if(StringUtils.isEmpty(nbbm))
  882 + return null;
952 return carExecutePlanMap.get(nbbm); 883 return carExecutePlanMap.get(nbbm);
953 } 884 }
954 885
@@ -984,12 +915,12 @@ public class DayOfSchedule { @@ -984,12 +915,12 @@ public class DayOfSchedule {
984 } 915 }
985 916
986 public void reCalcExecPlan(String nbbm) { 917 public void reCalcExecPlan(String nbbm) {
987 - //logger.info("reCalcExecPlan...: " + nbbm);  
988 List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm); 918 List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm);
989 Collections.sort(list, schFCSJComparator); 919 Collections.sort(list, schFCSJComparator);
990 920
991 ScheduleRealInfo sch = schAttrCalculator.calcCurrentExecSch(list); 921 ScheduleRealInfo sch = schAttrCalculator.calcCurrentExecSch(list);
992 - carExecutePlanMap.put(nbbm, sch); 922 + if(null != sch)
  923 + carExecutePlanMap.put(nbbm, sch);
993 } 924 }
994 925
995 /** 926 /**
@@ -1130,4 +1061,24 @@ public class DayOfSchedule { @@ -1130,4 +1061,24 @@ public class DayOfSchedule {
1130 } 1061 }
1131 return count; 1062 return count;
1132 } 1063 }
  1064 +
  1065 + /**
  1066 + * 重新计算ID对照map
  1067 + */
  1068 + public int reCalcIdMaps(){
  1069 + Collection<ScheduleRealInfo> all = findAll();
  1070 + Map<Long, ScheduleRealInfo> id2SchedulMapCopy = new ConcurrentHashMap<>();
  1071 +
  1072 + for(ScheduleRealInfo sch : all){
  1073 + id2SchedulMapCopy.put(sch.getId(), sch);
  1074 + }
  1075 +
  1076 + id2SchedulMap = id2SchedulMapCopy;
  1077 +
  1078 + return id2SchedulMap.size();
  1079 + }
  1080 +
  1081 + public String sizeString(){
  1082 + return id2SchedulMap.size() + "/" + nbbmScheduleMap.size();
  1083 + }
1133 } 1084 }
1134 \ No newline at end of file 1085 \ No newline at end of file
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
@@ -206,6 +206,8 @@ public class SchAttrCalculator { @@ -206,6 +206,8 @@ public class SchAttrCalculator {
206 * @return 206 * @return
207 */ 207 */
208 public ScheduleRealInfo calcCurrentExecSch(List<ScheduleRealInfo> list) { 208 public ScheduleRealInfo calcCurrentExecSch(List<ScheduleRealInfo> list) {
  209 + if(list.size()==0)
  210 + return null;
209 String lineCode = list.get(0).getXlBm(); 211 String lineCode = list.get(0).getXlBm();
210 LineConfig conf = lineConfigData.get(lineCode); 212 LineConfig conf = lineConfigData.get(lineCode);
211 213
src/main/java/com/bsth/data/schedule/thread/SchedulePstThread.java
@@ -7,9 +7,18 @@ import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; @@ -7,9 +7,18 @@ import com.bsth.repository.realcontrol.ScheduleRealInfoRepository;
7 import org.slf4j.Logger; 7 import org.slf4j.Logger;
8 import org.slf4j.LoggerFactory; 8 import org.slf4j.LoggerFactory;
9 import org.springframework.beans.factory.annotation.Autowired; 9 import org.springframework.beans.factory.annotation.Autowired;
10 -import org.springframework.jdbc.core.namedparam.BeanPropertySqlParameterSource;  
11 -import org.springframework.jdbc.core.namedparam.NamedParameterJdbcTemplate; 10 +import org.springframework.jdbc.core.BatchPreparedStatementSetter;
  11 +import org.springframework.jdbc.core.JdbcTemplate;
  12 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
12 import org.springframework.stereotype.Component; 13 import org.springframework.stereotype.Component;
  14 +import org.springframework.transaction.TransactionDefinition;
  15 +import org.springframework.transaction.TransactionStatus;
  16 +import org.springframework.transaction.support.DefaultTransactionDefinition;
  17 +
  18 +import java.sql.PreparedStatement;
  19 +import java.sql.SQLException;
  20 +import java.util.ArrayList;
  21 +import java.util.List;
13 22
14 /** 23 /**
15 * @author PanZhao 24 * @author PanZhao
@@ -24,18 +33,20 @@ public class SchedulePstThread extends Thread { @@ -24,18 +33,20 @@ public class SchedulePstThread extends Thread {
24 ScheduleRealInfoRepository scheduleRepository; 33 ScheduleRealInfoRepository scheduleRepository;
25 34
26 @Autowired 35 @Autowired
27 - NamedParameterJdbcTemplate jdbcTemplate; 36 + JdbcTemplate jdbcTemplate;
28 37
29 @Autowired 38 @Autowired
30 DayOfSchedule dayOfSchedule; 39 DayOfSchedule dayOfSchedule;
31 40
32 Logger logger = LoggerFactory.getLogger(this.getClass()); 41 Logger logger = LoggerFactory.getLogger(this.getClass());
33 42
  43 + static List<ScheduleRealInfo> saveList = new ArrayList<>();
  44 +
34 @Override 45 @Override
35 public void run() { 46 public void run() {
36 47
37 ScheduleRealInfo schedule; 48 ScheduleRealInfo schedule;
38 - for (int i = 0; i < 1000; i++) { 49 + for (int i = 0; i < 500; i++) {
39 schedule = DayOfSchedule.pstBuffer.poll(); 50 schedule = DayOfSchedule.pstBuffer.poll();
40 if (null == schedule) 51 if (null == schedule)
41 break; 52 break;
@@ -45,46 +56,106 @@ public class SchedulePstThread extends Thread { @@ -45,46 +56,106 @@ public class SchedulePstThread extends Thread {
45 continue; 56 continue;
46 } 57 }
47 58
48 - save(schedule); 59 + saveList.add(schedule);
49 } 60 }
  61 +
  62 + //写入数据库
  63 + save();
50 } 64 }
51 65
52 - /**  
53 - * 班次更新到数据库,不走jpa  
54 - *  
55 - * @param sch  
56 - */  
57 - public void save(ScheduleRealInfo sch) {  
58 - if (sch.getId() == null) {  
59 - logger.error("入库的班次没有ID, " + JSON.toJSONString(sch));  
60 - return;  
61 - }  
62 66
63 - if(sch.getSaveFailCount() > 5){  
64 - logger.error("入库失败上限, " + JSON.toJSONString(sch));  
65 - return;  
66 - } 67 + private void save(){
  68 + //记录同步数据
  69 + logger.info("real schedule update size: " + saveList.size());
  70 + logger.info(JSON.toJSONString(saveList));
  71 +
  72 + //批量入库
  73 + update2Db();
  74 +
  75 + //清空容器
  76 + saveList.clear();
  77 + }
  78 +
  79 + private void update2Db(){
  80 + final List<ScheduleRealInfo> pstList = saveList;
  81 + //编程式事务
  82 + DataSourceTransactionManager tran = new DataSourceTransactionManager(jdbcTemplate.getDataSource());
  83 + DefaultTransactionDefinition def = new DefaultTransactionDefinition();
  84 + def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED);
  85 + TransactionStatus status = tran.getTransaction(def);
  86 +
  87 + try{
  88 + //更新
  89 + jdbcTemplate.batchUpdate("update bsth_c_s_sp_info_real set bc_type=?,bcs=?,bcsj=?,cl_zbh=?,create_date=?" +
  90 + ",dfsj=?,directive_state=?,fcno=?,fcsj=?,fcsj_actual=?,j_gh=?,j_name=?,jhlc=?,lp_name=?,qdz_code=?" +
  91 + ",qdz_name=?,real_exec_date=?,remarks=?,s_gh=?,s_name=?,schedule_date=?,schedule_date_str=?,sflj=?" +
  92 + ",sp_id=?,status=?,update_date=?,xl_bm=?,xl_dir=?,xl_name=?,zdsj=?,zdsj_actual=?,zdz_code=?,zdz_name=?" +
  93 + ",ccno=?,df_auto=?,fgs_bm=?,fgs_name=?,gs_bm=?,gs_name=?,online=?,adjust_exps=?,reissue=?,jhlc_orig=?" +
  94 + ",sigin_compate=?,drift_status=?,cc_service=?,major_station_name=? where id=?", new BatchPreparedStatementSetter() {
  95 + @Override
  96 + public void setValues(PreparedStatement ps, int i) throws SQLException {
  97 + ScheduleRealInfo sch = pstList.get(i);
  98 + ps.setString(1, sch.getBcType());
  99 + ps.setInt(2, sch.getBcs()==null?0:sch.getBcs());
  100 + ps.setInt(3, sch.getBcsj()==null?0:sch.getBcsj());
  101 + ps.setString(4, sch.getClZbh());
  102 + ps.setTimestamp(5, new java.sql.Timestamp(sch.getCreateDate().getTime()));
  103 + ps.setString(6, sch.getDfsj());
  104 + ps.setInt(7, sch.getDirectiveState());
  105 + ps.setInt(8, sch.getFcno()==null?0:sch.getFcno());
  106 + ps.setString(9, sch.getFcsj());
  107 + ps.setString(10, sch.getFcsjActual());
  108 + ps.setString(11, sch.getjGh());
  109 + ps.setString(12, sch.getjName());
  110 + ps.setDouble(13, sch.getJhlc());
  111 + ps.setString(14, sch.getLpName());
  112 + ps.setString(15, sch.getQdzCode());
  113 + ps.setString(16, sch.getQdzName());
  114 + ps.setString(17, sch.getRealExecDate());
  115 + ps.setString(18, sch.getRemarks());
  116 + ps.setString(19, sch.getsGh());
  117 + ps.setString(20, sch.getsName());
  118 + ps.setTimestamp(21, new java.sql.Timestamp(sch.getScheduleDate().getTime()));
  119 + ps.setString(22, sch.getScheduleDateStr());
  120 + ps.setBoolean(23, sch.isSflj());
  121 + ps.setLong(24, sch.getSpId());
  122 + ps.setInt(25, sch.getStatus());
  123 + ps.setTimestamp(26, new java.sql.Timestamp(sch.getUpdateDate().getTime()));
  124 + ps.setString(27, sch.getXlBm());
  125 + ps.setString(28, sch.getXlDir());
  126 + ps.setString(29, sch.getXlName());
  127 + ps.setString(30, sch.getZdsj());
  128 + ps.setString(31, sch.getZdsjActual());
  129 + ps.setString(32, sch.getZdzCode());
  130 + ps.setString(33, sch.getZdzName());
  131 + ps.setInt(34, sch.getCcno()==null?0:sch.getCcno());
  132 + ps.setBoolean(35, sch.isDfAuto());
  133 + ps.setString(36, sch.getFgsBm());
  134 + ps.setString(37, sch.getFgsName());
  135 + ps.setString(38, sch.getGsBm());
  136 + ps.setString(39, sch.getGsName());
  137 + ps.setBoolean(40, sch.isOnline());
  138 + ps.setString(41, sch.getAdjustExps());
  139 + ps.setBoolean(42, sch.isReissue());
  140 + ps.setDouble(43, sch.getJhlcOrig());
  141 + ps.setInt(44, sch.getSiginCompate());
  142 + ps.setInt(45, sch.getDriftStatus());
  143 + ps.setBoolean(46, sch.isCcService());
  144 + ps.setString(47, sch.getMajorStationName());
  145 +
  146 + ps.setLong(48, sch.getId());
  147 + }
  148 +
  149 + @Override
  150 + public int getBatchSize() {
  151 + return pstList.size();
  152 + }
  153 + });
67 154
68 - try {  
69 - String sql = "UPDATE bsth_c_s_sp_info_real" +  
70 - " SET adjust_exps=:adjustExps, bc_type=:bcType, bcs=:bcs, bcsj=:bcsj, ccno=:ccno, cl_zbh=:clZbh, df_auto=:dfAuto," +  
71 - " dfsj=:dfsj, directive_state=:directiveState, fcno=:fcno, fcsj=:fcsj, fcsj_actual=:fcsjActual, fgs_bm=:fgsBm, fgs_name=:fgsName, gs_bm=:gsBm, gs_name=:gsName," +  
72 - " j_gh=:jGh, j_name=:jName, jhlc=:jhlc, jhlc_orig=:jhlcOrig, lp_name=:lpName, ONLINE=:online, qdz_code=:qdzCode, qdz_name=:qdzName," +  
73 - " real_exec_date=:realExecDate, reissue=:reissue, remarks=:remarks, s_gh=:sGh, s_name=:sName, schedule_date=:scheduleDate," +  
74 - " schedule_date_str=:scheduleDateStr, sflj=:sflj, sp_id=:spId, STATUS=:status, update_date=:updateDate, xl_bm=:xlBm, xl_dir=:xlDir, xl_name=:xlName," +  
75 - " zdsj=:zdsj, zdsj_actual=:zdsjActual, zdz_code=:zdzCode, zdz_name=:zdzName" +  
76 - " WHERE " +  
77 - " id=:id";  
78 -  
79 - jdbcTemplate.update(sql, new BeanPropertySqlParameterSource(sch));  
80 - sch.setSaveFailCount(0);  
81 - } catch (Exception e) {  
82 - //下次入库再试  
83 - sch.setSaveFailCount(sch.getSaveFailCount()+1);  
84 - dayOfSchedule.save(sch);  
85 -  
86 - logger.error("班次 " + sch.getId() + "入库失败," + JSON.toJSONString(sch));  
87 - logger.error("", e); 155 + tran.commit(status);
  156 + }catch (Exception e){
  157 + tran.rollback(status);
  158 + logger.error("同步数据库失败," , e);
88 } 159 }
89 } 160 }
90 } 161 }
src/main/java/com/bsth/service/forms/impl/FormsServiceImpl.java
@@ -441,7 +441,7 @@ public class FormsServiceImpl implements FormsService { @@ -441,7 +441,7 @@ public class FormsServiceImpl implements FormsService {
441 + " r.cl_zbh,r.xl_bm, r.j_gh,r.gs_bm,r.fgs_bm,r.lp_name " 441 + " r.cl_zbh,r.xl_bm, r.j_gh,r.gs_bm,r.fgs_bm,r.lp_name "
442 + "FROM bsth_c_s_sp_info_real r where 1=1 " 442 + "FROM bsth_c_s_sp_info_real r where 1=1 "
443 + " and r.schedule_date_str='"+date + "' " 443 + " and r.schedule_date_str='"+date + "' "
444 - + " and r.xl_bm like '%"+line+"%' " 444 + + " and r.xl_bm = '"+line+"' "
445 + " and r.gs_bm like '%"+gsdmShif+"%' " 445 + " and r.gs_bm like '%"+gsdmShif+"%' "
446 + " and r.fgs_bm like '%"+fgsdmShif+"%' ) t" 446 + " and r.fgs_bm like '%"+fgsdmShif+"%' ) t"
447 + " GROUP BY t.schedule_date,t.j_name,t.s_name, " 447 + " GROUP BY t.schedule_date,t.j_name,t.s_name, "
@@ -787,27 +787,25 @@ public class FormsServiceImpl implements FormsService { @@ -787,27 +787,25 @@ public class FormsServiceImpl implements FormsService {
787 List<Ylb> listYlb= ylbRepository.obtainYl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); 787 List<Ylb> listYlb= ylbRepository.obtainYl(startDate, gsdm, fgsdm, xlbm, "", "xlbm");
788 for (int i = 0; i < listYlb.size(); i++) { 788 for (int i = 0; i < listYlb.size(); i++) {
789 Ylb y=listYlb.get(i); 789 Ylb y=listYlb.get(i);
790 - String jsy=y.getJsy();  
791 - String line=y.getXlbm();  
792 - String clzbh=y.getNbbm();  
793 - List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();  
794 - List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();  
795 - for (int j = 0; j < listReal.size(); j++) {  
796 - ScheduleRealInfo s=listReal.get(j);  
797 - if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)  
798 - &&s.getXlBm().equals(line)){  
799 - if(y.getLp()==null){  
800 - newList.add(s);  
801 - Set<ChildTaskPlan> cts = s.getcTasks();  
802 - if(cts != null && cts.size() > 0){  
803 - newList_.add(s);  
804 - }else{  
805 - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){  
806 - newList_.add(s);  
807 - }  
808 - }  
809 - }else{  
810 - if(y.getLp().equals(s.getLpName())){ 790 + boolean fage=false;
  791 + if(xlbm.equals("")){
  792 + fage=true;
  793 + }else{
  794 + if(xlbm.equals(y.getXlbm())){
  795 + fage=true;
  796 + }
  797 + }
  798 + if(fage){
  799 + String jsy=y.getJsy();
  800 + String line=y.getXlbm();
  801 + String clzbh=y.getNbbm();
  802 + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  803 + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();
  804 + for (int j = 0; j < listReal.size(); j++) {
  805 + ScheduleRealInfo s=listReal.get(j);
  806 + if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)
  807 + &&s.getXlBm().equals(line)){
  808 + if(y.getLp()==null){
811 newList.add(s); 809 newList.add(s);
812 Set<ChildTaskPlan> cts = s.getcTasks(); 810 Set<ChildTaskPlan> cts = s.getcTasks();
813 if(cts != null && cts.size() > 0){ 811 if(cts != null && cts.size() > 0){
@@ -817,65 +815,75 @@ public class FormsServiceImpl implements FormsService { @@ -817,65 +815,75 @@ public class FormsServiceImpl implements FormsService {
817 newList_.add(s); 815 newList_.add(s);
818 } 816 }
819 } 817 }
  818 + }else{
  819 + if(y.getLp().equals(s.getLpName())){
  820 + newList.add(s);
  821 + Set<ChildTaskPlan> cts = s.getcTasks();
  822 + if(cts != null && cts.size() > 0){
  823 + newList_.add(s);
  824 + }else{
  825 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  826 + newList_.add(s);
  827 + }
  828 + }
  829 + }
820 } 830 }
821 } 831 }
822 } 832 }
  833 + double jhgl=culateMileageService.culateJhgl(newList);
  834 + double jhjcc=culateMileageService.culateJhJccgl(newList);
  835 + double yygl=culateMileageService.culateSjgl(newList_);
  836 + double ljgl=culateMileageService.culateLjgl(newList_);
  837 + double ksgl=culateMileageService.culateKsgl(newList_);
  838 + double jcgl=culateMileageService.culateJccgl(newList_);
  839 +
  840 + double zyygl=Arith.add(yygl, ljgl);
  841 + double zksgl=Arith.add(ksgl, jcgl);
  842 +
  843 + Singledata sin=new Singledata();
  844 + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));
  845 +
  846 + sin.setEmptMileage(String.valueOf(zksgl));
  847 + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));
  848 + sin.setxL(y.getXlbm());
  849 + sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm()));
  850 + sin.setClzbh(clzbh);
  851 + sin.setJsy(jsy);
  852 + sin.setrQ(startDate);
  853 + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));
  854 + sin.setSgh("");
  855 + sin.setsName("");
  856 + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  857 + sin.setHyl(df.format(y.getYh()));
  858 + sin.setJzl(df.format(y.getJzl()));
  859 + sin.setUnyyyl(df.format(y.getSh()));
  860 + listY.add(sin);
823 } 861 }
824 - double jhgl=culateMileageService.culateJhgl(newList);  
825 - double jhjcc=culateMileageService.culateJhJccgl(newList);  
826 - double yygl=culateMileageService.culateSjgl(newList_);  
827 - double ljgl=culateMileageService.culateLjgl(newList_);  
828 - double ksgl=culateMileageService.culateKsgl(newList_);  
829 - double jcgl=culateMileageService.culateJccgl(newList_);  
830 862
831 - double zyygl=Arith.add(yygl, ljgl);  
832 - double zksgl=Arith.add(ksgl, jcgl);  
833 -  
834 - Singledata sin=new Singledata();  
835 - sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));  
836 -  
837 - sin.setEmptMileage(String.valueOf(zksgl));  
838 - sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));  
839 - sin.setxL(y.getXlbm());  
840 - sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm()));  
841 - sin.setClzbh(clzbh);  
842 - sin.setJsy(jsy);  
843 - sin.setrQ(startDate);  
844 - sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));  
845 - sin.setSgh("");  
846 - sin.setsName("");  
847 - sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
848 - sin.setHyl(df.format(y.getYh()));  
849 - sin.setJzl(df.format(y.getJzl()));  
850 - sin.setUnyyyl(df.format(y.getSh()));  
851 - listY.add(sin);  
852 } 863 }
853 864
854 List<Dlb> listDlb= dlbRepository.obtainDl(startDate, gsdm, fgsdm, xlbm, "", "xlbm"); 865 List<Dlb> listDlb= dlbRepository.obtainDl(startDate, gsdm, fgsdm, xlbm, "", "xlbm");
855 for (int i = 0; i < listDlb.size(); i++) { 866 for (int i = 0; i < listDlb.size(); i++) {
856 -  
857 Dlb y=listDlb.get(i); 867 Dlb y=listDlb.get(i);
858 - String jsy=y.getJsy();  
859 - String line=y.getXlbm();  
860 - String clzbh=y.getNbbm();  
861 - List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();  
862 - List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();  
863 - for (int j = 0; j < listReal.size(); j++) {  
864 - ScheduleRealInfo s=listReal.get(j);  
865 - if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)  
866 - &&s.getXlBm().equals(line)){  
867 - if(y.getLp()==null){  
868 - newList.add(s);  
869 - Set<ChildTaskPlan> cts = s.getcTasks();  
870 - if(cts != null && cts.size() > 0){  
871 - newList_.add(s);  
872 - }else{  
873 - if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){  
874 - newList_.add(s);  
875 - }  
876 - }  
877 - }else{  
878 - if(y.getLp().equals(s.getLpName())){ 868 + boolean fage=false;
  869 + if(xlbm.equals("")){
  870 + fage=true;
  871 + }else{
  872 + if(xlbm.equals(y.getXlbm())){
  873 + fage=true;
  874 + }
  875 + }
  876 + if(fage){
  877 + String jsy=y.getJsy();
  878 + String line=y.getXlbm();
  879 + String clzbh=y.getNbbm();
  880 + List<ScheduleRealInfo> newList=new ArrayList<ScheduleRealInfo>();
  881 + List<ScheduleRealInfo> newList_=new ArrayList<ScheduleRealInfo>();
  882 + for (int j = 0; j < listReal.size(); j++) {
  883 + ScheduleRealInfo s=listReal.get(j);
  884 + if(s.getjGh().equals(jsy) && s.getClZbh().equals(clzbh)
  885 + &&s.getXlBm().equals(line)){
  886 + if(y.getLp()==null){
879 newList.add(s); 887 newList.add(s);
880 Set<ChildTaskPlan> cts = s.getcTasks(); 888 Set<ChildTaskPlan> cts = s.getcTasks();
881 if(cts != null && cts.size() > 0){ 889 if(cts != null && cts.size() > 0){
@@ -885,38 +893,50 @@ public class FormsServiceImpl implements FormsService { @@ -885,38 +893,50 @@ public class FormsServiceImpl implements FormsService {
885 newList_.add(s); 893 newList_.add(s);
886 } 894 }
887 } 895 }
  896 + }else{
  897 + if(y.getLp().equals(s.getLpName())){
  898 + newList.add(s);
  899 + Set<ChildTaskPlan> cts = s.getcTasks();
  900 + if(cts != null && cts.size() > 0){
  901 + newList_.add(s);
  902 + }else{
  903 + if(s.getZdsjActual()!=null && s.getFcsjActual()!=null){
  904 + newList_.add(s);
  905 + }
  906 + }
  907 + }
888 } 908 }
889 } 909 }
890 } 910 }
  911 + double jhgl=culateMileageService.culateJhgl(newList);
  912 + double jhjcc=culateMileageService.culateJhJccgl(newList);
  913 + double yygl=culateMileageService.culateSjgl(newList_);
  914 + double ljgl=culateMileageService.culateLjgl(newList_);
  915 + double ksgl=culateMileageService.culateKsgl(newList_);
  916 + double jcgl=culateMileageService.culateJccgl(newList_);
  917 +
  918 + double zyygl=Arith.add(yygl, ljgl);
  919 + double zksgl=Arith.add(ksgl, jcgl);
  920 +
  921 + Singledata sin=new Singledata();
  922 + sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));
  923 +
  924 + sin.setEmptMileage(String.valueOf(zksgl));
  925 + sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));
  926 + sin.setxL(y.getXlbm());
  927 + sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm()));
  928 + sin.setClzbh(clzbh);
  929 + sin.setJsy(jsy);
  930 + sin.setrQ(startDate);
  931 + sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));
  932 + sin.setSgh("");
  933 + sin.setsName("");
  934 + sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));
  935 + sin.setHyl(df.format(y.getHd()));
  936 + sin.setJzl(df.format(y.getCdl()));
  937 + sin.setUnyyyl(df.format(y.getSh()));
  938 + listD.add(sin);
891 } 939 }
892 - double jhgl=culateMileageService.culateJhgl(newList);  
893 - double jhjcc=culateMileageService.culateJhJccgl(newList);  
894 - double yygl=culateMileageService.culateSjgl(newList_);  
895 - double ljgl=culateMileageService.culateLjgl(newList_);  
896 - double ksgl=culateMileageService.culateKsgl(newList_);  
897 - double jcgl=culateMileageService.culateJccgl(newList_);  
898 -  
899 - double zyygl=Arith.add(yygl, ljgl);  
900 - double zksgl=Arith.add(ksgl, jcgl);  
901 -  
902 - Singledata sin=new Singledata();  
903 - sin.setJhlc(String.valueOf(Arith.add(zyygl,zksgl)));  
904 -  
905 - sin.setEmptMileage(String.valueOf(zksgl));  
906 - sin.setJhjl(String.valueOf(Arith.add(jhgl,jhjcc)));  
907 - sin.setxL(y.getXlbm());  
908 - sin.setXlmc(BasicData.lineCode2NameMap.get(y.getXlbm()));  
909 - sin.setClzbh(clzbh);  
910 - sin.setJsy(jsy);  
911 - sin.setrQ(startDate);  
912 - sin.setjName(BasicData.allPerson.get(gsdm+"-"+jsy));  
913 - sin.setSgh("");  
914 - sin.setsName("");  
915 - sin.setgS(BasicData.businessFgsCodeNameMap.get(fgsdm+"_"+gsdm));  
916 - sin.setHyl(df.format(y.getHd()));  
917 - sin.setJzl(df.format(y.getCdl()));  
918 - sin.setUnyyyl(df.format(y.getSh()));  
919 - listD.add(sin);  
920 } 940 }
921 941
922 Collections.sort(listY,new SingledataByXlbm()); 942 Collections.sort(listY,new SingledataByXlbm());
src/main/java/com/bsth/service/oil/impl/YlbServiceImpl.java
@@ -38,6 +38,7 @@ import com.bsth.entity.oil.Ylb; @@ -38,6 +38,7 @@ import com.bsth.entity.oil.Ylb;
38 import com.bsth.entity.oil.Ylxxb; 38 import com.bsth.entity.oil.Ylxxb;
39 import com.bsth.entity.search.CustomerSpecs; 39 import com.bsth.entity.search.CustomerSpecs;
40 import com.bsth.repository.CarsRepository; 40 import com.bsth.repository.CarsRepository;
  41 +import com.bsth.repository.LineRepository;
41 import com.bsth.repository.oil.CylRepository; 42 import com.bsth.repository.oil.CylRepository;
42 import com.bsth.repository.oil.DlbRepository; 43 import com.bsth.repository.oil.DlbRepository;
43 import com.bsth.repository.oil.YlbRepository; 44 import com.bsth.repository.oil.YlbRepository;
@@ -73,6 +74,10 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -73,6 +74,10 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
73 @Autowired 74 @Autowired
74 CarsRepository carsRepository; 75 CarsRepository carsRepository;
75 76
  77 +
  78 + @Autowired
  79 + LineRepository lineRepository;
  80 +
76 @Autowired 81 @Autowired
77 ScheduleRealInfoService scheduleRealInfoService; 82 ScheduleRealInfoService scheduleRealInfoService;
78 83
@@ -1501,8 +1506,14 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1501,8 +1506,14 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1501 try{ 1506 try{
1502 String date = map.get("date").toString(); 1507 String date = map.get("date").toString();
1503 String line = map.get("line").toString(); 1508 String line = map.get("line").toString();
1504 - String gsdm = map.get("gsdm").toString();  
1505 - String fgsdm = map.get("fgsdm").toString(); 1509 + List<Line> listLine=lineRepository.findLineByCode(line);
  1510 + String gsdm ="";
  1511 + String fgsdm ="";
  1512 + if(listLine.size()>0){
  1513 + Line l=listLine.get(0);
  1514 + gsdm=l.getCompany();
  1515 + fgsdm=l.getBrancheCompany();
  1516 + }
1506 1517
1507 List<Map<String, Object>> listpbYc=new ArrayList<Map<String, Object>>();//油车数据 1518 List<Map<String, Object>> listpbYc=new ArrayList<Map<String, Object>>();//油车数据
1508 List<Map<String, Object>> listpbDc=new ArrayList<Map<String, Object>>();//电车数据 1519 List<Map<String, Object>> listpbDc=new ArrayList<Map<String, Object>>();//电车数据
@@ -1672,7 +1683,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1672,7 +1683,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1672 t.setUpdatetime(new Date()); 1683 t.setUpdatetime(new Date());
1673 } 1684 }
1674 } 1685 }
1675 - repository.save(t); 1686 + try {
  1687 + repository.save(t);
  1688 + } catch (Exception e) {
  1689 + // TODO: handle exception
  1690 + if(e.getMessage().indexOf("PK_YLB_UK")>0){
  1691 + newMap.put("fage", "存在相同数据,数据已经过滤");
  1692 + logger.info("油量存在相同数据,数据已经过滤");
  1693 + }
  1694 + }
1676 1695
1677 } 1696 }
1678 1697
@@ -1776,7 +1795,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS @@ -1776,7 +1795,15 @@ public class YlbServiceImpl extends BaseServiceImpl&lt;Ylb,Integer&gt; implements YlbS
1776 List<Dlb> updDlb=mapList.get("updList"); 1795 List<Dlb> updDlb=mapList.get("updList");
1777 for (int i = 0; i < updDlb.size(); i++) { 1796 for (int i = 0; i < updDlb.size(); i++) {
1778 Dlb d=updDlb.get(i); 1797 Dlb d=updDlb.get(i);
1779 - dlbRepository.save(d); 1798 + try {
  1799 + dlbRepository.save(d);
  1800 + } catch (Exception e) {
  1801 + // TODO: handle exception
  1802 + if(e.getMessage().indexOf("PK_DLB_UK")>0){
  1803 + newMap.put("fage", "存在相同数据,数据已经过滤");
  1804 + logger.info("电量存在相同数据,数据已经过滤");
  1805 + }
  1806 + }
1780 } 1807 }
1781 //重新获取电耗数据结束 1808 //重新获取电耗数据结束
1782 newMap.put("status", ResponseCode.SUCCESS); 1809 newMap.put("status", ResponseCode.SUCCESS);
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
@@ -77,7 +77,7 @@ import org.springframework.jdbc.core.JdbcTemplate; @@ -77,7 +77,7 @@ import org.springframework.jdbc.core.JdbcTemplate;
77 import org.springframework.jdbc.core.RowMapper; 77 import org.springframework.jdbc.core.RowMapper;
78 import org.springframework.stereotype.Service; 78 import org.springframework.stereotype.Service;
79 79
80 -import java.io.*; 80 +import java.io.File;
81 import java.sql.ResultSet; 81 import java.sql.ResultSet;
82 import java.sql.SQLException; 82 import java.sql.SQLException;
83 import java.text.DecimalFormat; 83 import java.text.DecimalFormat;
@@ -85,8 +85,6 @@ import java.text.ParseException; @@ -85,8 +85,6 @@ import java.text.ParseException;
85 import java.text.SimpleDateFormat; 85 import java.text.SimpleDateFormat;
86 import java.util.*; 86 import java.util.*;
87 import java.util.regex.Pattern; 87 import java.util.regex.Pattern;
88 -import java.util.zip.ZipEntry;  
89 -import java.util.zip.ZipOutputStream;  
90 88
91 @Service 89 @Service
92 public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long> 90 public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long>
@@ -3346,6 +3344,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf @@ -3346,6 +3344,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl&lt;ScheduleRealInf
3346 if("major".equals(bcType)){ 3344 if("major".equals(bcType)){
3347 sch.setMajorStationName(majorStationName); 3345 sch.setMajorStationName(majorStationName);
3348 } 3346 }
  3347 +
  3348 + dayOfSchedule.save(sch);
3349 } 3349 }
3350 } catch (Exception e) { 3350 } catch (Exception e) {
3351 logger.error("", e); 3351 logger.error("", e);
src/main/java/com/bsth/service/report/ReportService.java
@@ -50,4 +50,6 @@ public interface ReportService { @@ -50,4 +50,6 @@ public interface ReportService {
50 List<Map<String, Object>> countByBusList(Map<String, Object> map); 50 List<Map<String, Object>> countByBusList(Map<String, Object> map);
51 51
52 List<Map<String, Object>> countDjg(Map<String, Object> map); 52 List<Map<String, Object>> countDjg(Map<String, Object> map);
  53 +
  54 + Map<String, Object> online(Map<String, Object> map);
53 } 55 }
src/main/java/com/bsth/service/report/impl/ReportServiceImpl.java
@@ -3343,6 +3343,121 @@ public class ReportServiceImpl implements ReportService{ @@ -3343,6 +3343,121 @@ public class ReportServiceImpl implements ReportService{
3343 map.put("djgxx", mapList); 3343 map.put("djgxx", mapList);
3344 return map; 3344 return map;
3345 } 3345 }
  3346 +
  3347 +
  3348 + @Override
  3349 + public Map<String, Object> online(Map<String, Object> map) {
  3350 + String line =map.get("line").toString();
  3351 + String date =map.get("date").toString();
  3352 + String type =map.get("type").toString();
  3353 + DecimalFormat df = new DecimalFormat("#0.00");
  3354 + String sql="select cl_zbh from bsth_c_s_sp_info_real where "
  3355 + + " schedule_date_str ='"+date+"' and xl_bm='"+line+"' group by cl_zbh";
  3356 + List<String> list= jdbcTemplate.query(sql,
  3357 + new RowMapper<String>(){
  3358 + @Override
  3359 + public String mapRow(ResultSet rs, int rowNum) throws SQLException {
  3360 + String clzbh=rs.getString("cl_zbh");
  3361 + return clzbh;
  3362 + }
  3363 + });
  3364 + List<Line> lineList=lineRepository.findLineByCode(line);
  3365 + int qzpcs =0;
  3366 + for (int i = 0; i < lineList.size(); i++) {
  3367 + Line l=lineList.get(i);
  3368 + qzpcs = l.getWarrantCar()==null?0:l.getWarrantCar();
  3369 + }
  3370 +
  3371 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  3372 + SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
  3373 + int zxcl=0;
  3374 + try {
  3375 + Long date1 = simpleDateFormat.parse(date+" 00:00:01").getTime();
  3376 + Long date2=simpleDateFormat.parse(date+" 23:59:59").getTime();
  3377 + Date dates=simpleDateFormat.parse(date+" 00:00:00");
  3378 + List<ArrivalInfo> lists=load_online(line,date1,date2,dates);
  3379 + for (int i = 0; i < list.size(); i++) {
  3380 + String nbbm=list.get(i);
  3381 + String sbbb=BasicData.deviceId2NbbmMap.inverse().get(nbbm);
  3382 + for (int j = 0; j < lists.size(); j++) {
  3383 + ArrivalInfo a=lists.get(i);
  3384 + if(a.getDeviceId().equals(sbbb)){
  3385 + zxcl ++;
  3386 + break;
  3387 + }
  3388 + }
  3389 +
  3390 + }
  3391 + } catch (ParseException e) {
  3392 + // TODO Auto-generated catch block
  3393 + e.printStackTrace();
  3394 + }
  3395 + map.put("xlName", BasicData.lineCode2NameMap.get(line));
  3396 + map.put("qzpcs", qzpcs);
  3397 + map.put("ccs", list.size());
  3398 + map.put("zxcl", zxcl);
  3399 + String zxl="0";
  3400 + if(list.size()>0){
  3401 + zxl = df.format(zxcl/list.size());
  3402 + }
  3403 + map.put("zxl", zxl+"%");
  3404 +
  3405 + if(type.equals("export")){
  3406 + List<Map<String, Object>> lMap=new ArrayList<Map<String,Object>>();
  3407 +
  3408 + List<Iterator<?>> listI = new ArrayList<Iterator<?>>();
  3409 + Map<String, Object> m = new HashMap<String, Object>();
  3410 + m.put("date", date);
  3411 + m.put("xlName", BasicData.lineCode2NameMap.get(line));
  3412 + m.put("qzpcs", qzpcs);
  3413 + m.put("ccs", list.size());
  3414 + m.put("zxcl", zxcl);
  3415 + m.put("zxl", zxl+"%");
  3416 + lMap.add(m);
  3417 + ReportUtils ee = new ReportUtils();
  3418 + try {
  3419 + listI.add(lMap.iterator());
  3420 + String path = this.getClass().getResource("/").getPath() + "static/pages/forms/";
  3421 + ee.excelReplace(listI, new Object[]{m}, path + "mould/onlinelist.xls",
  3422 + path + "export/车辆在线率统计.xls");
  3423 + } catch (Exception e) {
  3424 + // TODO: handle exception
  3425 + e.printStackTrace();
  3426 + }
  3427 + }
  3428 + return map;
  3429 + }
  3430 +
  3431 + public List<ArrivalInfo> load_online(String line,Long date1,Long date2,Date dates){
  3432 + List<ArrivalInfo> list = null;
  3433 + Calendar cal = Calendar.getInstance();
  3434 + cal.setTime(dates);
  3435 + //周数,表分区字段
  3436 + int weeks_year = cal.get(Calendar.WEEK_OF_YEAR);
  3437 +
  3438 + Connection conn = null;
  3439 + PreparedStatement ps = null;
  3440 + ResultSet rs = null;
  3441 +
  3442 + String sql = "select * from bsth_c_arrival_info where line_id=? AND weeks_year=? AND ts > ? AND ts <=? order by ts";
  3443 + try{
  3444 + conn = DBUtils_MS.getConnection();
  3445 + ps = conn.prepareStatement(sql);
  3446 + ps.setString(1,line);
  3447 + ps.setInt(2, weeks_year);
  3448 + ps.setLong(3, date1);
  3449 + ps.setLong(4, date2);
  3450 + rs = ps.executeQuery();
  3451 +
  3452 + list = resultSet2Set(rs);
  3453 + }catch(Exception e){
  3454 + logger.error("", e);
  3455 + }finally {
  3456 + DBUtils_MS.close(rs, ps, conn);
  3457 + }
  3458 + return list;
  3459 + }
  3460 +
3346 3461
3347 } 3462 }
3348 3463
src/main/resources/logback.xml
@@ -250,6 +250,29 @@ @@ -250,6 +250,29 @@
250 <!--<appender-ref ref="STDOUT" />--> 250 <!--<appender-ref ref="STDOUT" />-->
251 <!--</logger>--> 251 <!--</logger>-->
252 252
  253 + <!-- 实际排班数据库更新日志 -->
  254 + <!-- 消息队列纪录 -->
  255 + <appender name="REAL_SCHEDULE_UPDATE"
  256 + class="ch.qos.logback.core.rolling.RollingFileAppender">
  257 + <file>${LOG_BASE}/real_sch_db/update.log</file>
  258 + <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
  259 + <fileNamePattern>${LOG_BASE}/real_sch_db/update-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
  260 + <timeBasedFileNamingAndTriggeringPolicy
  261 + class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
  262 + <maxFileSize>100MB</maxFileSize>
  263 + </timeBasedFileNamingAndTriggeringPolicy>
  264 + </rollingPolicy>
  265 +
  266 + <layout class="ch.qos.logback.classic.PatternLayout">
  267 + <pattern>%d{MM-dd HH:mm:ss.SSS} %-5level -%msg%n
  268 + </pattern>
  269 + </layout>
  270 + </appender>
  271 + <logger name="com.bsth.data.schedule.thread.SchedulePstThread"
  272 + level="INFO" additivity="false">
  273 + <appender-ref ref="REAL_SCHEDULE_UPDATE" />
  274 + </logger>
  275 +
253 <!--JdbcTemplate的日志输出器 --> 276 <!--JdbcTemplate的日志输出器 -->
254 <logger name="org.springframework.jdbc.core.StatementCreatorUtils" 277 <logger name="org.springframework.jdbc.core.StatementCreatorUtils"
255 additivity="false" level="INFO"> 278 additivity="false" level="INFO">
src/main/resources/static/pages/forms/mould/onlinelist.xls 0 → 100644
No preview for this file type
src/main/resources/static/pages/mforms/online/online.html 0 → 100644
  1 +<style type="text/css">
  2 + .table-bordered {
  3 + border: 1px solid; }
  4 + .table-bordered > thead > tr > th,
  5 + .table-bordered > thead > tr > td,
  6 + .table-bordered > tbody > tr > th,
  7 + .table-bordered > tbody > tr > td,
  8 + .table-bordered > tfoot > tr > th,
  9 + .table-bordered > tfoot > tr > td {
  10 + border: 1px solid; }
  11 + .table-bordered > thead > tr > th,
  12 + .table-bordered > thead > tr > td {
  13 + border-bottom-width: 2px;
  14 + text-align: center;}
  15 +
  16 + .table > tbody + tbody {
  17 + border-top: 1px solid; }
  18 + .table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{ text-align: center; }
  19 +.table-checkable tr > th:first-child, .table-checkable tr > td:first-child {
  20 + text-align: center;
  21 + max-width: initial;
  22 + min-width: 40px;
  23 + padding-left: 0;
  24 + padding-right: 0;
  25 +}
  26 +
  27 +</style>
  28 +
  29 +<div class="page-head">
  30 + <div class="page-title">
  31 + <h1>车辆在线率统计表</h1>
  32 + </div>
  33 +</div>
  34 +
  35 +<div class="row">
  36 + <div class="col-md-12">
  37 + <div class="portlet light porttlet-fit bordered">
  38 + <div class="portlet-title">
  39 + <form class="form-inline" action="" method="post">
  40 + <div style="display: inline-block; margin-left: 20px;" id="gsdmDiv_turn">
  41 + <span class="item-label" style="width: 80px;">公司: </span>
  42 + <select class="form-control" name="company" id="gsdmTurn" style="width: 140px;"></select>
  43 + </div>
  44 + <div style="display: inline-block; margin-left: 20px;" id="fgsdmDiv_turn">
  45 + <span class="item-label" style="width: 80px;">分公司: </span>
  46 + <select class="form-control" name="subCompany" id="fgsdmTurn" style="width: 140px;"></select>
  47 + </div>
  48 + <div style="display: inline-block; margin-left: 15px;">
  49 + <span class="item-label" style="width: 80px;">线路: </span>
  50 + <select class="form-control" name="line" id="line" style="width: 120px;"></select>
  51 + </div>
  52 + <div style="display: inline-block;margin-left: 15px;">
  53 + <span class="item-label" style="width: 80px;">日期: </span>
  54 + <input class="form-control" type="text" id="date" style="width: 120px;"/>
  55 + </div>
  56 +
  57 + <div class="form-group">
  58 + <input class="btn btn-default" type="button" id="query" value="筛选"/>
  59 + <input class="btn btn-default" type="button" id="export" value="导出"/>
  60 + </div>
  61 + </form>
  62 + </div>
  63 + <div class="portlet-body">
  64 + <div class="table-container" style="margin-top: 20px;overflow:auto;min-width: 1000px">
  65 + <table class="table table-bordered table-hover table-checkable" id="forms1">
  66 + <thead>
  67 + <tr>
  68 + <th colspan="6">车辆在线率统计表</th>
  69 + </tr>
  70 + <tr>
  71 + <td>日期</td>
  72 + <td>线路</td>
  73 + <td>权证配车数</td>
  74 + <td>实际出车数</td>
  75 + <td>在线车辆数</td>
  76 + <td>在线率</td>
  77 + </tr>
  78 + </thead>
  79 + <tbody id="tbody">
  80 +
  81 + </tbody>
  82 + </table>
  83 + </div>
  84 + </div>
  85 + </div>
  86 + </div>
  87 +</div>
  88 +
  89 +<script>
  90 + $(function(){
  91 + // 关闭左侧栏
  92 + if (!$('body').hasClass('page-sidebar-closed'))
  93 + $('.menu-toggler.sidebar-toggler').click();
  94 +
  95 + $("#date").datetimepicker({
  96 + format : 'YYYY-MM-DD',
  97 + locale : 'zh-cn'
  98 + });
  99 +
  100 + var d = new Date();
  101 + var year = d.getFullYear();
  102 + var month = d.getMonth() + 1;
  103 + var day = d.getDate();
  104 + if(month < 10)
  105 + month = "0" + month;
  106 + if(day < 10)
  107 + day = "0" + day;
  108 + $("#date").val(year + "-" + month + "-" + day);
  109 +
  110 + var fage=false;
  111 + var xlList;
  112 + var obj = [];
  113 +
  114 + $.get('/report/lineList',function(result){
  115 + xlList=result;
  116 + $.get('/user/companyData', function(result){
  117 + obj = result;
  118 + var options = '';
  119 + for(var i = 0; i < obj.length; i++){
  120 + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';
  121 + }
  122 +
  123 + if(obj.length ==0){
  124 + $("#gsdmDiv_turn").css('display','none');
  125 + }else if(obj.length ==1){
  126 + $("#gsdmDiv_turn").css('display','none');
  127 + if(obj[0].children.length == 1 || obj[0].children.length ==0)
  128 + $('#fgsdmDiv_turn').css('display','none');
  129 + }
  130 + $('#gsdmTurn').html(options);
  131 + updateCompany();
  132 + });
  133 + })
  134 + $("#gsdmTurn").on("change",updateCompany);
  135 + function updateCompany(){
  136 + var company = $('#gsdmTurn').val();
  137 + var options = '';
  138 + for(var i = 0; i < obj.length; i++){
  139 + if(obj[i].companyCode == company){
  140 + var children = obj[i].children;
  141 + for(var j = 0; j < children.length; j++){
  142 + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>';
  143 + }
  144 + }
  145 + }
  146 + $('#fgsdmTurn').html(options);
  147 + }
  148 +
  149 + var tempData = {};
  150 + $.get('/report/lineList',function(xlList){
  151 + var data = [];
  152 +// data.push({id: " ", text: "全部线路"});
  153 + $.get('/user/companyData', function(result){
  154 + for(var i = 0; i < result.length; i++){
  155 + var companyCode = result[i].companyCode;
  156 + var children = result[i].children;
  157 + for(var j = 0; j < children.length; j++){
  158 + var code = children[j].code;
  159 + for(var k=0;k < xlList.length;k++ ){
  160 + if(xlList[k]["fgsbm"]==code && xlList[k]["gsbm"]==companyCode){
  161 + data.push({id: xlList[k]["xlbm"], text: xlList[k]["xlname"]});
  162 + tempData[xlList[k]["xlbm"]] = companyCode+":"+code;
  163 + }
  164 + }
  165 + }
  166 + }
  167 + initPinYinSelect2('#line',data,'');
  168 +
  169 + });
  170 + });
  171 +
  172 + $("#line").on("change", function(){
  173 + if($("#line").val() == " "){
  174 + $("#gsdmTurn").attr("disabled", false);
  175 + $("#fgsdmTurn").attr("disabled", false);
  176 + } else {
  177 + var temp = tempData[$("#line").val()].split(":");
  178 + $("#gsdmTurn").val(temp[0]);
  179 + updateCompany();
  180 + $("#fgsdmTurn").val(temp[1]);
  181 + $("#gsdmTurn").attr("disabled", true);
  182 + $("#fgsdmTurn").attr("disabled", true);
  183 + }
  184 + });
  185 +
  186 + var line;
  187 + var date;
  188 + $("#query").on("click",function(){
  189 + line = $("#line").val();
  190 + date=$("#date").val();
  191 + if(date!=''){
  192 + $get('/report/online',
  193 + { line:line,date:date,type:'query'},function(result){
  194 + // 把数据填充到模版中
  195 + var tbodyHtml = template('online',result);
  196 + // 把渲染好的模版html文本追加到表格中
  197 + $('#tbody').html(tbodyHtml);
  198 + });
  199 +
  200 + }else{
  201 + layer.msg("请选择时间!");
  202 + }
  203 + });
  204 +
  205 + $("#export").on("click",function(){
  206 + line = $("#line").val();
  207 + date=$("#date").val();
  208 + $get('/report/online',{line:line,date:date,type:'export'},function(result){
  209 + window.open("/downloadFile/download?fileName=车辆在线率统计");
  210 + });
  211 + });
  212 + });
  213 +</script>
  214 +<script type="text/html" id="online">
  215 + <tr>
  216 + <td>{{date}}</td>
  217 + <td>{{xlName}}</td>
  218 + <td>{{qzpcs}}</td>
  219 + <td>{{ccs}}</td>
  220 + <td>{{zxcl}}</td>
  221 + <td>{{zxl}}</td>
  222 + </tr>
  223 +</script>
src/main/resources/static/pages/oil/history/history.html 0 → 100644
  1 +<style type="text/css">
  2 + .table-bordered {
  3 + border: 1px solid; }
  4 + .table-bordered > thead > tr > th,
  5 + .table-bordered > thead > tr > td,
  6 + .table-bordered > tbody > tr > th,
  7 + .table-bordered > tbody > tr > td,
  8 + .table-bordered > tfoot > tr > th,
  9 + .table-bordered > tfoot > tr > td {
  10 + border: 1px solid; }
  11 + .table-bordered > thead > tr > th,
  12 + .table-bordered > thead > tr > td {
  13 + border-bottom-width: 2px; }
  14 +
  15 + .table > tbody + tbody {
  16 + border-top: 1px solid; }
  17 +</style>
  18 +
  19 +<div class="page-head">
  20 + <div class="page-title">
  21 + <h1>重新统计</h1>
  22 + </div>
  23 +</div>
  24 +
  25 +<div class="row">
  26 + <div class="col-md-12">
  27 + <div class="portlet light porttlet-fit bordered">
  28 + <div class="portlet-title">
  29 + <form class="form-inline" action="">
  30 + <div style="display: inline-block; margin-left: 33px;" id="gsdmDiv_daily">
  31 + <span class="item-label" style="width: 80px;">公司: </span>
  32 + <select class="form-control" name="company" id="gsdmDaily" style="width: 180px;"></select>
  33 + </div>
  34 + <div style="display: inline-block; margin-left: 24px;" id="fgsdmDiv_daily">
  35 + <span class="item-label" style="width: 80px;">分公司: </span>
  36 + <select class="form-control" name="subCompany" id="fgsdmDaily" style="width: 180px;"></select>
  37 + </div>
  38 + <div style="margin-top: 2px"></div>
  39 + <div style="display: inline-block;margin-left: 33px;">
  40 + <span class="item-label" style="width: 80px;">线路: </span>
  41 + <select class="form-control" name="line" id="line" style="width: 180px;"></select>
  42 + </div>
  43 + <div style="display: inline-block;margin-left: 24px;">
  44 + <span class="item-label" style="width: 80px;">&nbsp;时间: </span>
  45 + <select class="form-control" id="date" style="width: 180px;">
  46 + <option value="2017-11-07">2017-11-07</option>
  47 + </select>
  48 + </div>
  49 + <div class="form-group">
  50 + <input class="btn btn-default" type="button" id="query" value="重新统计"/>
  51 + </div>
  52 + </form>
  53 + </div>
  54 + </div>
  55 + </div>
  56 +</div>
  57 +
  58 +<script>
  59 + $(function(){
  60 +
  61 + // 关闭左侧栏
  62 + if (!$('body').hasClass('page-sidebar-closed'))
  63 + $('.menu-toggler.sidebar-toggler').click();
  64 +
  65 + function GetDateStr(AddDayCount) {
  66 + var dd = new Date();
  67 + dd.setDate(dd.getDate()+AddDayCount);//获取AddDayCount天后的日期
  68 + var y = dd.getFullYear();
  69 + var m = dd.getMonth()+1;//获取当前月份的日期
  70 + if(m<10){
  71 + m="0" + m;
  72 + }
  73 +
  74 + var d = dd.getDate();
  75 + if(d<10){
  76 + d="0" +d;
  77 + }
  78 + return y+"-"+m+"-"+d;
  79 + }
  80 +// var optionsDate = '';
  81 +// for(var i = -1; i > -4; i--){
  82 +// optionsDate += '<option value="2017-11-01">'+2017-11-01+'</option>';
  83 +// }
  84 +// $('#date').html(optionsDate);
  85 + var fage=false;
  86 + var xlList;
  87 + var obj = [];
  88 +
  89 +
  90 + $.get('/report/lineList',function(result){
  91 + xlList=result;
  92 + $.get('/user/companyData', function(result){
  93 + obj = result;
  94 + var options = '';
  95 + for(var i = 0; i < obj.length; i++){
  96 + options += '<option value="'+obj[i].companyCode+'">'+obj[i].companyName+'</option>';
  97 + }
  98 +
  99 + if(obj.length ==0){
  100 + $("#gsdmDiv_daily").css('display','none');
  101 + }else if(obj.length ==1){
  102 + $("#gsdmDiv_daily").css('display','none');
  103 + if(obj[0].children.length == 1 || obj[0].children.length ==0)
  104 + $('#fgsdmDiv_daily').css('display','none');
  105 + }
  106 + $('#gsdmDaily').html(options);
  107 + updateCompany();
  108 + });
  109 + })
  110 + $("#gsdmDaily").on("change",updateCompany);
  111 + function updateCompany(){
  112 + var company = $('#gsdmDaily').val();
  113 + var options = '';
  114 + for(var i = 0; i < obj.length; i++){
  115 + if(obj[i].companyCode == company){
  116 + var children = obj[i].children;
  117 + for(var j = 0; j < children.length; j++){
  118 + options += '<option value="'+children[j].code+'">'+children[j].name+'</option>';
  119 + }
  120 + }
  121 + }
  122 + $('#fgsdmDaily').html(options);
  123 +// initXl();
  124 + }
  125 +
  126 +
  127 + var tempData = {};
  128 + $.get('/report/lineList',function(xlList){
  129 + var data = [];
  130 +// data.push({id: " ", text: "全部线路"});
  131 + $.get('/user/companyData', function(result){
  132 + for(var i = 0; i < result.length; i++){
  133 + var companyCode = result[i].companyCode;
  134 + var children = result[i].children;
  135 + for(var j = 0; j < children.length; j++){
  136 + var code = children[j].code;
  137 + for(var k=0;k < xlList.length;k++ ){
  138 + if(xlList[k]["fgsbm"]==code && xlList[k]["gsbm"]==companyCode){
  139 + data.push({id: xlList[k]["xlbm"], text: xlList[k]["xlname"]});
  140 + tempData[xlList[k]["xlbm"]] = companyCode+":"+code;
  141 + }
  142 + }
  143 + }
  144 + }
  145 + initPinYinSelect2('#line',data,'');
  146 +
  147 + });
  148 + });
  149 +
  150 + $("#line").on("change", function(){
  151 + if($("#line").val() == " "){
  152 + $("#gsdmDaily").attr("disabled", false);
  153 + $("#fgsdmDaily").attr("disabled", false);
  154 + } else {
  155 + var temp = tempData[$("#line").val()].split(":");
  156 + $("#gsdmDaily").val(temp[0]);
  157 + updateCompany();
  158 + $("#fgsdmDaily").val(temp[1]);
  159 + $("#gsdmDaily").attr("disabled", true);
  160 + $("#fgsdmDaily").attr("disabled", true);
  161 + }
  162 + });
  163 +
  164 +
  165 + var line;
  166 + var date;
  167 + var gsdmDaily;
  168 + var fgsdmDaily;
  169 + $("#query").on("click",function(){
  170 + if($("#date").val() == null || $("#date").val().trim().length == 0){
  171 + layer.msg("请选择时间");
  172 + return;
  173 + }
  174 + line = $("#line").val();
  175 + date = $("#date").val();
  176 + gsdmDaily=$("#gsdmDaily").val();
  177 + fgsdmDaily = $("#fgsdmDaily").val();
  178 + $post('/ylb/updateHistory', {date:date,line:line,gsdm:gsdmDaily,fgsdm:fgsdmDaily},
  179 + function (result) {
  180 + layer.msg("重新统计成功");
  181 + });
  182 + });
  183 +
  184 +});
  185 +</script>
src/main/resources/static/pages/oil/list_ph.html
@@ -59,10 +59,10 @@ @@ -59,10 +59,10 @@
59 id="export"> <i class="fa fa-file-excel-o"></i> 导出Excel 59 id="export"> <i class="fa fa-file-excel-o"></i> 导出Excel
60 </a></li> 60 </a></li>
61 61
62 -<!-- <li class="divider"></li> -->  
63 -<!-- <li><a href="javascript:;" data-action="3" class="tool-action" -->  
64 -<!-- id="cxtj"> <i class="fa fa-file-excel-o"></i> 导出Excel -->  
65 -<!-- </a></li> --> 62 + <li class="divider"></li>
  63 + <li><a href="javascript:;" data-action="3" class="tool-action"
  64 + id="cxtj"> <i class="fa fa-file-excel-o"></i> 重新统计
  65 + </a></li>
66 </ul> 66 </ul>
67 </div> 67 </div>
68 </div> 68 </div>
@@ -972,16 +972,16 @@ onkeyup=&quot;this.value=this.value.replace(/[^(\d||/.)]/g,&#39;&#39;).replace(&#39;.&#39;,&#39;$#$&#39;).rep @@ -972,16 +972,16 @@ onkeyup=&quot;this.value=this.value.replace(/[^(\d||/.)]/g,&#39;&#39;).replace(&#39;.&#39;,&#39;$#$&#39;).rep
972 } 972 }
973 // } 973 // }
974 974
975 -// $("#cxtj").on("click", function () {  
976 -// if ($("#rq").val() != "") {  
977 -// // var params=getParamsList();  
978 -// $post('/ylb/updateHistory', {date:'2017-10-01',line:'10845',gsdm:'55',fgsdm:'3'}, function (result) {  
979 -// window.open("/downloadFile/download?fileName="+$("#rq").val()+"进出场存油量" );  
980 -// });  
981 -// } else {  
982 -// layer.msg('请选择日期.');  
983 -// }  
984 -// }); 975 + $("#cxtj").on("click", function () {
  976 + if ($("#rq").val() != "") {
  977 +// var params=getParamsList();
  978 + $post('/ylb/updateHistory', {date:'2017-11-07',line:'10708',gsdm:'26',fgsdm:'1'}, function (result) {
  979 + window.open("/downloadFile/download?fileName="+$("#rq").val()+"进出场存油量" );
  980 + });
  981 + } else {
  982 + layer.msg('请选择日期.');
  983 + }
  984 + });
985 985
986 //导出 986 //导出
987 987
src/main/resources/static/real_control_v2/fragments/north/nav/history_sch_maintain.html
@@ -37,6 +37,8 @@ @@ -37,6 +37,8 @@
37 </div> 37 </div>
38 <button class="uk-button">检索</button> 38 <button class="uk-button">检索</button>
39 <a class="add_lp_link" ><i class="uk-icon-plus"></i> 临加路牌</a> 39 <a class="add_lp_link" ><i class="uk-icon-plus"></i> 临加路牌</a>
  40 + <button id="reCountBtn" class="uk-button uk-button-danger uk-button-mini" style="position: absolute;right: 12px;bottom: 14px;">
  41 + 重新统计</button>
40 </fieldset> 42 </fieldset>
41 </form> 43 </form>
42 </div> 44 </div>
@@ -414,6 +416,39 @@ @@ -414,6 +416,39 @@
414 416
415 return true; 417 return true;
416 } 418 }
  419 +
  420 + /**
  421 + * 重新统计
  422 + */
  423 + $('#reCountBtn', modal).on('click', function () {
  424 + $(this).attr('disabled', 'disabled');
  425 + $(this).prepend('<i class="uk-icon-spinner uk-icon-spin"></i>');
  426 +
  427 + var rq = $('.h-s-time li.uk-active', modal).text(),
  428 + lineName = $('.h-s-line li.uk-active', modal).text(),
  429 + lineCode = $('.h-s-line li.uk-active', modal).data('id');
  430 +
  431 + var that = this;
  432 + alt_confirm('确定要重新统计 ' + lineName + '('+rq+')的数据吗?',function () {
  433 +
  434 + var reCountEp = EventProxy.create('calcWaybill', 'ylbUpdate', function () {
  435 + $('i.uk-icon-spin', that).remove();
  436 + $(this).removeAttr('disabled');
  437 + notify_succ('重新统计成功!');
  438 + });
  439 +
  440 + //统计路单 -娄高峰
  441 + gb_common.$get('/calcWaybill/generateNew', {date:rq, line: lineCode}, function () {
  442 + reCountEp.emitLater('calcWaybill');
  443 + });
  444 +
  445 + //统计油 -廖磊
  446 + gb_common.$post('/ylb/updateHistory', {date:rq, line: lineCode}, function () {
  447 + reCountEp.emitLater('ylbUpdate');
  448 + });
  449 +
  450 + }, '我确定');
  451 + });
417 })(); 452 })();
418 </script> 453 </script>
419 </div> 454 </div>
420 \ No newline at end of file 455 \ No newline at end of file
src/main/resources/static/real_control_v2/js/forms/wrap.html
@@ -100,9 +100,13 @@ @@ -100,9 +100,13 @@
100 //ed=d.format(f), 100 //ed=d.format(f),
101 //sd=d.subtract(3, 'days').format(f); 101 //sd=d.subtract(3, 'days').format(f);
102 102
103 - $('#date', '.form-page-content').data('DateTimePicker')  
104 - .defaultDate(d.format(f));  
105 - //.maxDate(ed).minDate(sd); 103 + try{
  104 + $('#date', '.form-page-content').data('DateTimePicker')
  105 + .defaultDate(d.format(f));
  106 + //.maxDate(ed).minDate(sd);
  107 + }catch (e){
  108 + console.log(e);
  109 + }
106 110
107 if($("#ddrbBody").length > 0){ 111 if($("#ddrbBody").length > 0){
108 $("#ddrbBody").height("620px"); 112 $("#ddrbBody").height("620px");