Commit ceb8a823b8359d214822e7ec6d89233af8d0ec1e
Merge branch 'pudong' of http://222.66.0.204:8090/panzhaov5/bsth_control
into pudong
Showing
12 changed files
with
229 additions
and
140 deletions
src/main/java/com/bsth/controller/realcontrol/ScheduleRealInfoController.java
| ... | ... | @@ -23,9 +23,6 @@ import java.util.*; |
| 23 | 23 | @RequestMapping("/realSchedule") |
| 24 | 24 | public class ScheduleRealInfoController extends BaseController<ScheduleRealInfo, Long> { |
| 25 | 25 | |
| 26 | - /*@Autowired | |
| 27 | - GetSchedulePlanThread getSchedulePlanThread;*/ | |
| 28 | - | |
| 29 | 26 | @Autowired |
| 30 | 27 | ScheduleRealInfoService scheduleRealInfoService; |
| 31 | 28 | ... | ... |
src/main/java/com/bsth/controller/realcontrol/anomalyCheckController.java
| ... | ... | @@ -110,4 +110,14 @@ public class anomalyCheckController { |
| 110 | 110 | dayOfSchedule.removeExecPlan(nbbm); |
| 111 | 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/data/directive/DayOfDirectives.java
| ... | ... | @@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 15 | 15 | import org.springframework.stereotype.Component; |
| 16 | 16 | |
| 17 | 17 | import java.util.*; |
| 18 | +import java.util.concurrent.ConcurrentHashMap; | |
| 18 | 19 | |
| 19 | 20 | /** |
| 20 | 21 | * |
| ... | ... | @@ -52,8 +53,8 @@ public class DayOfDirectives { |
| 52 | 53 | |
| 53 | 54 | |
| 54 | 55 | static{ |
| 55 | - d60Map = new HashMap<>(); | |
| 56 | - d64Map = new HashMap<>(); | |
| 56 | + d60Map = new ConcurrentHashMap<>(); | |
| 57 | + d64Map = new ConcurrentHashMap<>(); | |
| 57 | 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 | 51 | logger.warn("save 指令,发现 deleted=true 的班次,id=" + sch.getId()); |
| 52 | 52 | continue; |
| 53 | 53 | } |
| 54 | - if(dayOfSchedule.get(sch.getId()) == null){ | |
| 55 | - logger.warn("班次:" + sch.getId() + "不存在了,调度指令放弃入库。"); | |
| 56 | - continue; | |
| 57 | - } | |
| 58 | 54 | } |
| 59 | 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 | 14 | import com.bsth.repository.realcontrol.ScheduleRealInfoRepository; |
| 15 | 15 | import com.bsth.service.schedule.SchedulePlanInfoService; |
| 16 | 16 | import com.bsth.websocket.handler.SendUtils; |
| 17 | -import com.google.common.base.Predicate; | |
| 18 | 17 | import com.google.common.collect.ArrayListMultimap; |
| 19 | -import com.google.common.collect.Collections2; | |
| 20 | 18 | import org.apache.commons.lang3.StringUtils; |
| 21 | 19 | import org.joda.time.format.DateTimeFormat; |
| 22 | 20 | import org.joda.time.format.DateTimeFormatter; |
| ... | ... | @@ -37,6 +35,7 @@ import java.sql.SQLException; |
| 37 | 35 | import java.text.ParseException; |
| 38 | 36 | import java.text.SimpleDateFormat; |
| 39 | 37 | import java.util.*; |
| 38 | +import java.util.concurrent.ConcurrentHashMap; | |
| 40 | 39 | import java.util.concurrent.ConcurrentLinkedQueue; |
| 41 | 40 | |
| 42 | 41 | /** |
| ... | ... | @@ -100,11 +99,11 @@ public class DayOfSchedule { |
| 100 | 99 | nbbmScheduleMap = ArrayListMultimap.create(); |
| 101 | 100 | lpScheduleMap = ArrayListMultimap.create(); |
| 102 | 101 | |
| 103 | - id2SchedulMap = new HashMap<>(); | |
| 102 | + id2SchedulMap = new ConcurrentHashMap<>(); | |
| 104 | 103 | pstBuffer = new ConcurrentLinkedQueue<>(); |
| 105 | 104 | schFCSJComparator = new ScheduleComparator.FCSJ(); |
| 106 | 105 | currSchDateMap = new HashMap<>(); |
| 107 | - carExecutePlanMap = new HashMap<>(); | |
| 106 | + carExecutePlanMap = new ConcurrentHashMap<>(); | |
| 108 | 107 | |
| 109 | 108 | schedulePlanMap = new HashMap<>(); |
| 110 | 109 | } |
| ... | ... | @@ -266,7 +265,7 @@ public class DayOfSchedule { |
| 266 | 265 | public void clearRAMData(String lineCode) { |
| 267 | 266 | int count = 0; |
| 268 | 267 | List<ScheduleRealInfo> remList = new ArrayList<>(); |
| 269 | - Collection<ScheduleRealInfo> all = id2SchedulMap.values(); | |
| 268 | + Collection<ScheduleRealInfo> all = nbbmScheduleMap.values(); | |
| 270 | 269 | for (ScheduleRealInfo sch : all) { |
| 271 | 270 | if (sch.getXlBm().equals(lineCode)) |
| 272 | 271 | remList.add(sch); |
| ... | ... | @@ -431,7 +430,7 @@ public class DayOfSchedule { |
| 431 | 430 | ps.setInt(3, sch.getBcs()==null?0:sch.getBcs()); |
| 432 | 431 | ps.setInt(4, sch.getBcsj()==null?0:sch.getBcsj()); |
| 433 | 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 | 434 | ps.setString(7, sch.getDfsj()); |
| 436 | 435 | ps.setInt(8, sch.getDirectiveState()); |
| 437 | 436 | ps.setInt(9, sch.getFcno()==null?0:sch.getFcno()); |
| ... | ... | @@ -447,12 +446,12 @@ public class DayOfSchedule { |
| 447 | 446 | ps.setString(19, sch.getRemarks()); |
| 448 | 447 | ps.setString(20, sch.getsGh()); |
| 449 | 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 | 450 | ps.setString(23, sch.getScheduleDateStr()); |
| 452 | 451 | ps.setBoolean(24, sch.isSflj()); |
| 453 | 452 | ps.setLong(25, sch.getSpId()); |
| 454 | 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 | 455 | ps.setString(28, sch.getXlBm()); |
| 457 | 456 | ps.setString(29, sch.getXlDir()); |
| 458 | 457 | ps.setString(30, sch.getXlName()); |
| ... | ... | @@ -512,7 +511,7 @@ public class DayOfSchedule { |
| 512 | 511 | public List<ScheduleRealInfo> findByLineCode(String lineCode) { |
| 513 | 512 | List<ScheduleRealInfo> rs = new ArrayList<>(); |
| 514 | 513 | |
| 515 | - Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); | |
| 514 | + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 516 | 515 | for (ScheduleRealInfo sch : schs) { |
| 517 | 516 | if (sch.getXlBm().equals(lineCode)) |
| 518 | 517 | rs.add(sch); |
| ... | ... | @@ -527,7 +526,7 @@ public class DayOfSchedule { |
| 527 | 526 | public Map<String, Collection<ScheduleRealInfo>> findByLineCodes(List<String> lineList) { |
| 528 | 527 | ArrayListMultimap<String, ScheduleRealInfo> mMap = ArrayListMultimap.create(); |
| 529 | 528 | |
| 530 | - Collection<ScheduleRealInfo> schs = id2SchedulMap.values(); | |
| 529 | + Collection<ScheduleRealInfo> schs = nbbmScheduleMap.values(); | |
| 531 | 530 | for (ScheduleRealInfo sch : schs) { |
| 532 | 531 | if (lineList.contains(sch.getXlBm())) { |
| 533 | 532 | mMap.put(sch.getXlBm(), sch); |
| ... | ... | @@ -584,24 +583,6 @@ public class DayOfSchedule { |
| 584 | 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 | 730 | .calcRealDate(sch) |
| 750 | 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 | 736 | id2SchedulMap.put(sch.getId(), sch); |
| ... | ... | @@ -767,7 +747,6 @@ public class DayOfSchedule { |
| 767 | 747 | } |
| 768 | 748 | |
| 769 | 749 | public void delete(ScheduleRealInfo sch) { |
| 770 | - //ScheduleRealInfo sch = id2SchedulMap.get(id); | |
| 771 | 750 | if (!sch.isSflj()) |
| 772 | 751 | return; |
| 773 | 752 | |
| ... | ... | @@ -807,36 +786,6 @@ public class DayOfSchedule { |
| 807 | 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 | 789 | public void save(ScheduleRealInfo sch) { |
| 841 | 790 | sch.setUpdateDate(new Date()); |
| 842 | 791 | pstBuffer.add(sch); |
| ... | ... | @@ -860,26 +809,6 @@ public class DayOfSchedule { |
| 860 | 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 | 846 | } |
| 918 | 847 | |
| 919 | 848 | public Collection<ScheduleRealInfo> findAll() { |
| 920 | - return id2SchedulMap.values(); | |
| 849 | + return nbbmScheduleMap.values(); | |
| 921 | 850 | } |
| 922 | 851 | |
| 923 | 852 | public boolean addExecPlan(ScheduleRealInfo sch) { |
| ... | ... | @@ -949,6 +878,8 @@ public class DayOfSchedule { |
| 949 | 878 | * @return |
| 950 | 879 | */ |
| 951 | 880 | public ScheduleRealInfo executeCurr(String nbbm) { |
| 881 | + if(StringUtils.isEmpty(nbbm)) | |
| 882 | + return null; | |
| 952 | 883 | return carExecutePlanMap.get(nbbm); |
| 953 | 884 | } |
| 954 | 885 | |
| ... | ... | @@ -984,12 +915,12 @@ public class DayOfSchedule { |
| 984 | 915 | } |
| 985 | 916 | |
| 986 | 917 | public void reCalcExecPlan(String nbbm) { |
| 987 | - //logger.info("reCalcExecPlan...: " + nbbm); | |
| 988 | 918 | List<ScheduleRealInfo> list = nbbmScheduleMap.get(nbbm); |
| 989 | 919 | Collections.sort(list, schFCSJComparator); |
| 990 | 920 | |
| 991 | 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 | 1061 | } |
| 1131 | 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 | 1085 | \ No newline at end of file | ... | ... |
src/main/java/com/bsth/data/schedule/SchAttrCalculator.java
| ... | ... | @@ -206,6 +206,8 @@ public class SchAttrCalculator { |
| 206 | 206 | * @return |
| 207 | 207 | */ |
| 208 | 208 | public ScheduleRealInfo calcCurrentExecSch(List<ScheduleRealInfo> list) { |
| 209 | + if(list.size()==0) | |
| 210 | + return null; | |
| 209 | 211 | String lineCode = list.get(0).getXlBm(); |
| 210 | 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 | 7 | import org.slf4j.Logger; |
| 8 | 8 | import org.slf4j.LoggerFactory; |
| 9 | 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 | 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 | 24 | * @author PanZhao |
| ... | ... | @@ -24,18 +33,20 @@ public class SchedulePstThread extends Thread { |
| 24 | 33 | ScheduleRealInfoRepository scheduleRepository; |
| 25 | 34 | |
| 26 | 35 | @Autowired |
| 27 | - NamedParameterJdbcTemplate jdbcTemplate; | |
| 36 | + JdbcTemplate jdbcTemplate; | |
| 28 | 37 | |
| 29 | 38 | @Autowired |
| 30 | 39 | DayOfSchedule dayOfSchedule; |
| 31 | 40 | |
| 32 | 41 | Logger logger = LoggerFactory.getLogger(this.getClass()); |
| 33 | 42 | |
| 43 | + static List<ScheduleRealInfo> saveList = new ArrayList<>(); | |
| 44 | + | |
| 34 | 45 | @Override |
| 35 | 46 | public void run() { |
| 36 | 47 | |
| 37 | 48 | ScheduleRealInfo schedule; |
| 38 | - for (int i = 0; i < 1000; i++) { | |
| 49 | + for (int i = 0; i < 500; i++) { | |
| 39 | 50 | schedule = DayOfSchedule.pstBuffer.poll(); |
| 40 | 51 | if (null == schedule) |
| 41 | 52 | break; |
| ... | ... | @@ -45,46 +56,106 @@ public class SchedulePstThread extends Thread { |
| 45 | 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/calc/impl/CalcWaybillServiceImpl.java
| ... | ... | @@ -69,7 +69,7 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 69 | 69 | return newMap; |
| 70 | 70 | } |
| 71 | 71 | |
| 72 | - String sql = "select c.id,c.out_config,c.start_opt,c.trust,t.line_code from bsth_c_line_config c LEFT JOIN bsth_c_line t on c.line=t.id"; | |
| 72 | + String sql = "select c.id,c.out_config,c.start_opt,t.line_code from bsth_c_line_config c LEFT JOIN bsth_c_line t on c.line=t.id"; | |
| 73 | 73 | if(line.length() != 0){ |
| 74 | 74 | sql += " where t.line_code = " + line; |
| 75 | 75 | } |
| ... | ... | @@ -82,7 +82,6 @@ public class CalcWaybillServiceImpl extends BaseServiceImpl<CalcWaybill, Integer |
| 82 | 82 | m.put("id", rs.getLong("id")); |
| 83 | 83 | m.put("out_config", rs.getString("out_config")); |
| 84 | 84 | m.put("start_opt", rs.getString("start_opt")); |
| 85 | - m.put("trust", rs.getString("trust")); | |
| 86 | 85 | m.put("line_code", rs.getString("line_code")); |
| 87 | 86 | return m; |
| 88 | 87 | }}); | ... | ... |
src/main/java/com/bsth/service/realcontrol/impl/ScheduleRealInfoServiceImpl.java
| ... | ... | @@ -77,7 +77,7 @@ import org.springframework.jdbc.core.JdbcTemplate; |
| 77 | 77 | import org.springframework.jdbc.core.RowMapper; |
| 78 | 78 | import org.springframework.stereotype.Service; |
| 79 | 79 | |
| 80 | -import java.io.*; | |
| 80 | +import java.io.File; | |
| 81 | 81 | import java.sql.ResultSet; |
| 82 | 82 | import java.sql.SQLException; |
| 83 | 83 | import java.text.DecimalFormat; |
| ... | ... | @@ -85,8 +85,6 @@ import java.text.ParseException; |
| 85 | 85 | import java.text.SimpleDateFormat; |
| 86 | 86 | import java.util.*; |
| 87 | 87 | import java.util.regex.Pattern; |
| 88 | -import java.util.zip.ZipEntry; | |
| 89 | -import java.util.zip.ZipOutputStream; | |
| 90 | 88 | |
| 91 | 89 | @Service |
| 92 | 90 | public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInfo, Long> |
| ... | ... | @@ -3346,6 +3344,8 @@ public class ScheduleRealInfoServiceImpl extends BaseServiceImpl<ScheduleRealInf |
| 3346 | 3344 | if("major".equals(bcType)){ |
| 3347 | 3345 | sch.setMajorStationName(majorStationName); |
| 3348 | 3346 | } |
| 3347 | + | |
| 3348 | + dayOfSchedule.save(sch); | |
| 3349 | 3349 | } |
| 3350 | 3350 | } catch (Exception e) { |
| 3351 | 3351 | logger.error("", e); | ... | ... |
src/main/resources/logback.xml
| ... | ... | @@ -250,6 +250,29 @@ |
| 250 | 250 | <!--<appender-ref ref="STDOUT" />--> |
| 251 | 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 | 276 | <!--JdbcTemplate的日志输出器 --> |
| 254 | 277 | <logger name="org.springframework.jdbc.core.StatementCreatorUtils" |
| 255 | 278 | additivity="false" level="INFO"> | ... | ... |
src/main/resources/static/real_control_v2/fragments/north/nav/history_sch_maintain.html
| ... | ... | @@ -37,6 +37,8 @@ |
| 37 | 37 | </div> |
| 38 | 38 | <button class="uk-button">检索</button> |
| 39 | 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 | 42 | </fieldset> |
| 41 | 43 | </form> |
| 42 | 44 | </div> |
| ... | ... | @@ -414,6 +416,39 @@ |
| 414 | 416 | |
| 415 | 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 | 453 | </script> |
| 419 | 454 | </div> |
| 420 | 455 | \ No newline at end of file | ... | ... |
src/main/resources/static/real_control_v2/js/forms/wrap.html
| ... | ... | @@ -100,9 +100,13 @@ |
| 100 | 100 | //ed=d.format(f), |
| 101 | 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 | 111 | if($("#ddrbBody").length > 0){ |
| 108 | 112 | $("#ddrbBody").height("620px"); | ... | ... |