Commit aefacb214eee6669c1eff8fa782b43feb42733d4
1 parent
1c63703f
修改的定时器时间
Showing
5 changed files
with
452 additions
and
79 deletions
src/main/java/com/example/demo/SaticScheduleTask.java
| @@ -45,65 +45,17 @@ public class SaticScheduleTask implements InitializingBean { | @@ -45,65 +45,17 @@ public class SaticScheduleTask implements InitializingBean { | ||
| 45 | @Autowired | 45 | @Autowired |
| 46 | private Analysis analysis; | 46 | private Analysis analysis; |
| 47 | 47 | ||
| 48 | - public Map<String,List<Scheduling>> getSchedulingS; | ||
| 49 | - public Map<String,List<Scheduling>> getSchedulingSSell; | ||
| 50 | - public List<TJRLDB> data=new ArrayList<>(); | ||
| 51 | 48 | ||
| 52 | - /** | ||
| 53 | - * 定时任务 | ||
| 54 | - */ | ||
| 55 | - /*@Scheduled(cron = "0 0/10 * * * ?") | ||
| 56 | - private void configureTasks() throws Exception{ | ||
| 57 | - logger.info("执行静态定时任务时间: " + LocalDateTime.now()); | ||
| 58 | - WatchKey watchKey = null; | ||
| 59 | - List<File> files = new ArrayList<>(); | ||
| 60 | - while ((watchKey = watchService.poll()) != null) { | ||
| 61 | - for (WatchEvent watchEvent : watchKey.pollEvents()) { | ||
| 62 | - Path path = (Path)watchEvent.context(); | ||
| 63 | - if(path!=null){ | ||
| 64 | - files.add(new File(rootPath + File.separator + path)); | ||
| 65 | - } | ||
| 66 | 49 | ||
| 67 | - } | ||
| 68 | - watchKey.reset(); | ||
| 69 | - } | ||
| 70 | - System.out.println("文件数"+files); | ||
| 71 | 50 | ||
| 72 | - //先把处理上一次没匹配到的 | ||
| 73 | - if(!data.isEmpty()){ | ||
| 74 | - contrast.filterCardList(data,true); | ||
| 75 | - } | ||
| 76 | - List<TJRLDB> allFile = Analysis.getAllFile(files); | ||
| 77 | - System.out.println("交易数"+allFile); | ||
| 78 | - contrast.filterCardList(allFile,false); | ||
| 79 | - }*/ | ||
| 80 | - | ||
| 81 | - | ||
| 82 | - /* @Scheduled(cron = "0 0/9 * * * ?") | ||
| 83 | - @PostConstruct | ||
| 84 | - void getArrivalInfos() { | ||
| 85 | - logger.info("票务数据缓存加载: " + LocalDateTime.now()); | ||
| 86 | - LocalDateTime now=LocalDateTime.now(); | ||
| 87 | - //测试 | ||
| 88 | - *//* DateTimeFormatter tdf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | ||
| 89 | - now=LocalDateTime.parse("2021-08-01 00:00",tdf);*//* | ||
| 90 | - List<Map<String,List<Scheduling>>> result=contrast.getSchedulingS(now,1); | ||
| 91 | - getSchedulingS=result.get(0); | ||
| 92 | - getSchedulingSSell=result.get(1); | ||
| 93 | - }*/ | ||
| 94 | 51 | ||
| 95 | - /* @Scheduled(cron = "0 0/10 * * * ?") | ||
| 96 | - @PostConstruct*/ | 52 | + @Scheduled(cron = "0 0/10 * * * ?") |
| 97 | void getArrivalInfos() throws Exception { | 53 | void getArrivalInfos() throws Exception { |
| 98 | logger.info("票务数据缓存加载: " + LocalDateTime.now()); | 54 | logger.info("票务数据缓存加载: " + LocalDateTime.now()); |
| 99 | - if(watchService==null){ | ||
| 100 | - afterPropertiesSet(); | ||
| 101 | - } | ||
| 102 | LocalDateTime now=LocalDateTime.now(); | 55 | LocalDateTime now=LocalDateTime.now(); |
| 103 | List<Map<String,List<Scheduling>>> result=contrast.getSchedulingS(now,1); | 56 | List<Map<String,List<Scheduling>>> result=contrast.getSchedulingS(now,1); |
| 104 | - getSchedulingS=result.get(0); | ||
| 105 | - getSchedulingSSell=result.get(1); | ||
| 106 | - | 57 | + contrast.getSchedulingS=result.get(0); |
| 58 | + contrast.getSchedulingSSell=result.get(1); | ||
| 107 | WatchKey watchKey = null; | 59 | WatchKey watchKey = null; |
| 108 | List<File> files = new ArrayList<>(); | 60 | List<File> files = new ArrayList<>(); |
| 109 | while ((watchKey = watchService.poll()) != null) { | 61 | while ((watchKey = watchService.poll()) != null) { |
| @@ -118,8 +70,8 @@ public class SaticScheduleTask implements InitializingBean { | @@ -118,8 +70,8 @@ public class SaticScheduleTask implements InitializingBean { | ||
| 118 | } | 70 | } |
| 119 | System.out.println("文件数"+files.size()); | 71 | System.out.println("文件数"+files.size()); |
| 120 | //先把处理上一次没匹配到的 | 72 | //先把处理上一次没匹配到的 |
| 121 | - if(!data.isEmpty()){ | ||
| 122 | - contrast.filterCardList(data,true); | 73 | + if(!contrast.oldData.isEmpty()){ |
| 74 | + contrast.filterCardList(contrast.oldData,true); | ||
| 123 | } | 75 | } |
| 124 | List<TJRLDB> allFile = analysis.getAllFile(files); | 76 | List<TJRLDB> allFile = analysis.getAllFile(files); |
| 125 | System.out.println("交易数"+allFile.size()); | 77 | System.out.println("交易数"+allFile.size()); |
| @@ -127,20 +79,18 @@ public class SaticScheduleTask implements InitializingBean { | @@ -127,20 +79,18 @@ public class SaticScheduleTask implements InitializingBean { | ||
| 127 | } | 79 | } |
| 128 | 80 | ||
| 129 | 81 | ||
| 130 | - @PostConstruct | ||
| 131 | - void getArrivalInfos2() throws Exception { | 82 | + |
| 83 | + void getArrivalInfos2() { | ||
| 132 | logger.info("票务数据缓存加载: " + LocalDateTime.now()); | 84 | logger.info("票务数据缓存加载: " + LocalDateTime.now()); |
| 133 | - if(watchService==null){ | ||
| 134 | - afterPropertiesSet(); | ||
| 135 | - } | ||
| 136 | LocalDateTime now=LocalDateTime.now(); | 85 | LocalDateTime now=LocalDateTime.now(); |
| 137 | //测试 | 86 | //测试 |
| 138 | DateTimeFormatter tdf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | 87 | DateTimeFormatter tdf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); |
| 139 | - now=LocalDateTime.parse("2021-08-01 00:00",tdf); | 88 | + now=LocalDateTime.parse("2021-11-19 00:00",tdf); |
| 140 | List<Map<String,List<Scheduling>>> result=contrast.getSchedulingS(now,1); | 89 | List<Map<String,List<Scheduling>>> result=contrast.getSchedulingS(now,1); |
| 141 | - getSchedulingS=result.get(0); | ||
| 142 | - getSchedulingSSell=result.get(1); | ||
| 143 | - List<File> fl= FileUtil.loopFiles("E:\\data"); | 90 | + contrast.getSchedulingS=result.get(0); |
| 91 | + contrast.getSchedulingSSell=result.get(1); | ||
| 92 | + List<File> fl= FileUtil.loopFiles("/home/sftp/20211118"); | ||
| 93 | + System.out.println(fl.size()); | ||
| 144 | List<List<File>> subList=getSubList(100,fl); | 94 | List<List<File>> subList=getSubList(100,fl); |
| 145 | if(!subList.isEmpty()){ | 95 | if(!subList.isEmpty()){ |
| 146 | subList.forEach(fs->{ | 96 | subList.forEach(fs->{ |
| @@ -153,6 +103,8 @@ public class SaticScheduleTask implements InitializingBean { | @@ -153,6 +103,8 @@ public class SaticScheduleTask implements InitializingBean { | ||
| 153 | }); | 103 | }); |
| 154 | } | 104 | } |
| 155 | } | 105 | } |
| 106 | + | ||
| 107 | + | ||
| 156 | /** | 108 | /** |
| 157 | * @Description: 用来计算数据库中的乘车记录 | 109 | * @Description: 用来计算数据库中的乘车记录 |
| 158 | * @Param: | 110 | * @Param: |
| @@ -167,8 +119,8 @@ public class SaticScheduleTask implements InitializingBean { | @@ -167,8 +119,8 @@ public class SaticScheduleTask implements InitializingBean { | ||
| 167 | 119 | ||
| 168 | int day=1; | 120 | int day=1; |
| 169 | List<Map<String,List<Scheduling>>> result=contrast.getSchedulingS(now,day); | 121 | List<Map<String,List<Scheduling>>> result=contrast.getSchedulingS(now,day); |
| 170 | - getSchedulingS=result.get(0); | ||
| 171 | - getSchedulingSSell=result.get(1); | 122 | + contrast.getSchedulingS=result.get(0); |
| 123 | + contrast.getSchedulingSSell=result.get(1); | ||
| 172 | Map<String,Object> map=new HashMap<>(); | 124 | Map<String,Object> map=new HashMap<>(); |
| 173 | map.put("table","pd_control."+"fhtxnjrltb_jtb_copy1"); | 125 | map.put("table","pd_control."+"fhtxnjrltb_jtb_copy1"); |
| 174 | LocalDateTime startDate=now.minusDays(day); | 126 | LocalDateTime startDate=now.minusDays(day); |
| @@ -186,6 +138,7 @@ public class SaticScheduleTask implements InitializingBean { | @@ -186,6 +138,7 @@ public class SaticScheduleTask implements InitializingBean { | ||
| 186 | watchService = FileSystems.getDefault().newWatchService(); | 138 | watchService = FileSystems.getDefault().newWatchService(); |
| 187 | Path path = Paths.get(rootPath); | 139 | Path path = Paths.get(rootPath); |
| 188 | path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE); | 140 | path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE); |
| 141 | + this.getArrivalInfos(); | ||
| 189 | } | 142 | } |
| 190 | 143 | ||
| 191 | public List<List<File>> getSubList(int length, List<File> list){ | 144 | public List<List<File>> getSubList(int length, List<File> list){ |
src/main/java/com/example/demo/model/TJRL.java
0 → 100644
| 1 | +package com.example.demo.model; | ||
| 2 | + | ||
| 3 | +import com.fasterxml.jackson.annotation.JsonProperty; | ||
| 4 | + | ||
| 5 | +import java.beans.PropertyDescriptor; | ||
| 6 | +import java.lang.reflect.Field; | ||
| 7 | +import java.lang.reflect.Method; | ||
| 8 | + | ||
| 9 | +public class TJRL implements Cloneable { | ||
| 10 | + //@JsonProperty | ||
| 11 | + private String TJRLCARDNO;// NUMBER Y 交通卡号 | ||
| 12 | + private String TJRLINSID; // NUMBER Y 行业 | ||
| 13 | + private String TJRLCDKIND;// NUMBER Y 卡类型 | ||
| 14 | + private String TJRLPOSID;// NUMBER(10) POS机号 | ||
| 15 | + private String TJRLRDATE;// CHAR(8) Y 交易日期 | ||
| 16 | + private String TJRLRTIME;// CHAR(6) Y 交易时间 | ||
| 17 | + private String TJRLCDBAL;// NUMBER(10) Y 交易前余额 | ||
| 18 | + private String TJRLAMT;// NUMBER(10) Y 交易金额 | ||
| 19 | + private String TJRLORGAMT;// NUMBER(10) Y 交易原始金额 | ||
| 20 | + private String TJRLSTATID;// VARCHAR2(100) Y 公交线路 | ||
| 21 | + private String TJRLUNITID;// VARCHAR2(100) Y 运营单位 | ||
| 22 | + private String TJRLTXFG;// NUMBER Y 交易类型 | ||
| 23 | + private String STATION_FLAG;// VARCHAR2(100) Y 匹配上电子路单:1;匹配不上:0 | ||
| 24 | + private String ROAD_FORM_TYPE;// VARCHAR2(100) Y 路单类型 | ||
| 25 | + private String UPDOWN;// VARCHAR2(100) Y 上下行:0上1下 | ||
| 26 | + private String BUS_CODE;// VARCHAR2(100) Y 车辆自编号 | ||
| 27 | + private String BUS_PLATE;// VARCHAR2(100) Y 车牌号 | ||
| 28 | + private String ROAD_CODE;// VARCHAR2(100) Y 路牌编号 | ||
| 29 | + private String DEPART_NAME;// VARCHAR2(100) Y 发车站点名称 | ||
| 30 | + private String DEPART_CODE;// VARCHAR2(100) Y 发车站点编码 | ||
| 31 | + private String DEPART_ACTUAL_TIME;// VARCHAR2(100) Y 实际发车时间 | ||
| 32 | + private String REACH_NAME;// VARCHAR2(100) Y 到达站点名称 | ||
| 33 | + private String REACH_CODE;// VARCHAR2(100) Y 到达站点编码 | ||
| 34 | + private String REACH_ACTUAL_TIME;// VARCHAR2(100) Y 实际到达时间 | ||
| 35 | + private String LEVELS_FLAG;// VARCHAR2(100) Y 匹配上到离站:1;匹配不上:0 | ||
| 36 | + private String LEVELS1;// VARCHAR2(100) Y 站序1 | ||
| 37 | + private String LEVELS_NAME1;// VARCHAR2(100) Y 站序1名称 | ||
| 38 | + private String LEVELS1_CODE;// VARCHAR2(100) Y 站序1编码 | ||
| 39 | + private String LEVELS2;// VARCHAR2(100) Y 站序2 | ||
| 40 | + private String LEVELS_NAME2;// VARCHAR2(100) Y 站序2名称 | ||
| 41 | + private String LEVELS2_CODE;// VARCHAR2(100) Y 站序2编码 | ||
| 42 | + private String GPS_DATE_TIME1;// VARCHAR2(100) Y 站序1到站时间 | ||
| 43 | + private String GPS_DATE_TIME2;// VARCHAR2(100) Y 站序2到站时间 | ||
| 44 | + private String B_STATION_ID;// VARCHAR2(100) Y 电子路单id | ||
| 45 | + private String PLAN_START_TIME;// VARCHAR2(100) Y 计划发车时间 | ||
| 46 | + private String PLAN_ARRIVE_TIME;// VARCHAR2(100) Y 计划到达时间 | ||
| 47 | + private String ACTUAL_START_TIME;// VARCHAR2(100) Y 实际发车时间 | ||
| 48 | + private String ACTUAL_ARRIVE_TIME;// VARCHAR2(100) Y 实际到达时间实际到达时间 | ||
| 49 | + private String TRAD_ID; | ||
| 50 | + | ||
| 51 | + public TJRL(){ | ||
| 52 | + | ||
| 53 | + } | ||
| 54 | + public TJRL(TJRLDB tjrldb) { | ||
| 55 | + try { | ||
| 56 | + Field[] fields=TJRL.class.getDeclaredFields(); | ||
| 57 | + for(Field f : fields) { | ||
| 58 | + PropertyDescriptor pd = new PropertyDescriptor(f.getName(), TJRLDB.class); | ||
| 59 | + Method rM = pd.getReadMethod();//获得读方法 | ||
| 60 | + String v = rM.invoke(tjrldb)==null?"":rM.invoke(tjrldb).toString(); | ||
| 61 | + pd = new PropertyDescriptor(f.getName(), TJRL.class); | ||
| 62 | + Method wM = pd.getWriteMethod();//获得写方法 | ||
| 63 | + wM.invoke(this, v); | ||
| 64 | + } | ||
| 65 | + } catch (Exception e) { | ||
| 66 | + e.printStackTrace(); | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public String getTJRLCARDNO() { | ||
| 71 | + return TJRLCARDNO; | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + public void setTJRLCARDNO(String TJRLCARDNO) { | ||
| 75 | + this.TJRLCARDNO = TJRLCARDNO; | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + public String getTJRLINSID() { | ||
| 79 | + return TJRLINSID; | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + public void setTJRLINSID(String TJRLINSID) { | ||
| 83 | + this.TJRLINSID = TJRLINSID; | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public String getTJRLCDKIND() { | ||
| 87 | + return TJRLCDKIND; | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + public void setTJRLCDKIND(String TJRLCDKIND) { | ||
| 91 | + this.TJRLCDKIND = TJRLCDKIND; | ||
| 92 | + } | ||
| 93 | + | ||
| 94 | + public String getTJRLPOSID() { | ||
| 95 | + return TJRLPOSID; | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + public void setTJRLPOSID(String TJRLPOSID) { | ||
| 99 | + this.TJRLPOSID = TJRLPOSID; | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + public String getTJRLRDATE() { | ||
| 103 | + return TJRLRDATE; | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + public void setTJRLRDATE(String TJRLRDATE) { | ||
| 107 | + this.TJRLRDATE = TJRLRDATE; | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + public String getTJRLRTIME() { | ||
| 111 | + return TJRLRTIME; | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + public void setTJRLRTIME(String TJRLRTIME) { | ||
| 115 | + this.TJRLRTIME = TJRLRTIME; | ||
| 116 | + } | ||
| 117 | + | ||
| 118 | + public String getTJRLCDBAL() { | ||
| 119 | + return TJRLCDBAL; | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + public void setTJRLCDBAL(String TJRLCDBAL) { | ||
| 123 | + this.TJRLCDBAL = TJRLCDBAL; | ||
| 124 | + } | ||
| 125 | + | ||
| 126 | + public String getTJRLAMT() { | ||
| 127 | + return TJRLAMT; | ||
| 128 | + } | ||
| 129 | + | ||
| 130 | + public void setTJRLAMT(String TJRLAMT) { | ||
| 131 | + this.TJRLAMT = TJRLAMT; | ||
| 132 | + } | ||
| 133 | + | ||
| 134 | + public String getTJRLORGAMT() { | ||
| 135 | + return TJRLORGAMT; | ||
| 136 | + } | ||
| 137 | + | ||
| 138 | + public void setTJRLORGAMT(String TJRLORGAMT) { | ||
| 139 | + this.TJRLORGAMT = TJRLORGAMT; | ||
| 140 | + } | ||
| 141 | + | ||
| 142 | + public String getTJRLSTATID() { | ||
| 143 | + return TJRLSTATID; | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + public void setTJRLSTATID(String TJRLSTATID) { | ||
| 147 | + this.TJRLSTATID = TJRLSTATID; | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + public String getTJRLUNITID() { | ||
| 151 | + return TJRLUNITID; | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + public void setTJRLUNITID(String TJRLUNITID) { | ||
| 155 | + this.TJRLUNITID = TJRLUNITID; | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + public String getTJRLTXFG() { | ||
| 159 | + return TJRLTXFG; | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + public void setTJRLTXFG(String TJRLTXFG) { | ||
| 163 | + this.TJRLTXFG = TJRLTXFG; | ||
| 164 | + } | ||
| 165 | + | ||
| 166 | + public String getSTATION_FLAG() { | ||
| 167 | + return STATION_FLAG; | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + public void setSTATION_FLAG(String STATION_FLAG) { | ||
| 171 | + this.STATION_FLAG = STATION_FLAG; | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + public String getROAD_FORM_TYPE() { | ||
| 175 | + return ROAD_FORM_TYPE; | ||
| 176 | + } | ||
| 177 | + | ||
| 178 | + public void setROAD_FORM_TYPE(String ROAD_FORM_TYPE) { | ||
| 179 | + this.ROAD_FORM_TYPE = ROAD_FORM_TYPE; | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + public String getUPDOWN() { | ||
| 183 | + return UPDOWN; | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + public void setUPDOWN(String UPDOWN) { | ||
| 187 | + this.UPDOWN = UPDOWN; | ||
| 188 | + } | ||
| 189 | + | ||
| 190 | + public String getBUS_CODE() { | ||
| 191 | + return BUS_CODE; | ||
| 192 | + } | ||
| 193 | + | ||
| 194 | + public void setBUS_CODE(String BUS_CODE) { | ||
| 195 | + this.BUS_CODE = BUS_CODE; | ||
| 196 | + } | ||
| 197 | + | ||
| 198 | + public String getBUS_PLATE() { | ||
| 199 | + return BUS_PLATE; | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + public void setBUS_PLATE(String BUS_PLATE) { | ||
| 203 | + this.BUS_PLATE = BUS_PLATE; | ||
| 204 | + } | ||
| 205 | + | ||
| 206 | + public String getROAD_CODE() { | ||
| 207 | + return ROAD_CODE; | ||
| 208 | + } | ||
| 209 | + | ||
| 210 | + public void setROAD_CODE(String ROAD_CODE) { | ||
| 211 | + this.ROAD_CODE = ROAD_CODE; | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + public String getDEPART_NAME() { | ||
| 215 | + return DEPART_NAME; | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + public void setDEPART_NAME(String DEPART_NAME) { | ||
| 219 | + this.DEPART_NAME = DEPART_NAME; | ||
| 220 | + } | ||
| 221 | + | ||
| 222 | + public String getDEPART_CODE() { | ||
| 223 | + return DEPART_CODE; | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + public void setDEPART_CODE(String DEPART_CODE) { | ||
| 227 | + this.DEPART_CODE = DEPART_CODE; | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + public String getDEPART_ACTUAL_TIME() { | ||
| 231 | + return DEPART_ACTUAL_TIME; | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + public void setDEPART_ACTUAL_TIME(String DEPART_ACTUAL_TIME) { | ||
| 235 | + this.DEPART_ACTUAL_TIME = DEPART_ACTUAL_TIME; | ||
| 236 | + } | ||
| 237 | + | ||
| 238 | + public String getREACH_NAME() { | ||
| 239 | + return REACH_NAME; | ||
| 240 | + } | ||
| 241 | + | ||
| 242 | + public void setREACH_NAME(String REACH_NAME) { | ||
| 243 | + this.REACH_NAME = REACH_NAME; | ||
| 244 | + } | ||
| 245 | + | ||
| 246 | + public String getREACH_CODE() { | ||
| 247 | + return REACH_CODE; | ||
| 248 | + } | ||
| 249 | + | ||
| 250 | + public void setREACH_CODE(String REACH_CODE) { | ||
| 251 | + this.REACH_CODE = REACH_CODE; | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + public String getREACH_ACTUAL_TIME() { | ||
| 255 | + return REACH_ACTUAL_TIME; | ||
| 256 | + } | ||
| 257 | + | ||
| 258 | + public void setREACH_ACTUAL_TIME(String REACH_ACTUAL_TIME) { | ||
| 259 | + this.REACH_ACTUAL_TIME = REACH_ACTUAL_TIME; | ||
| 260 | + } | ||
| 261 | + | ||
| 262 | + public String getLEVELS_FLAG() { | ||
| 263 | + return LEVELS_FLAG; | ||
| 264 | + } | ||
| 265 | + | ||
| 266 | + public void setLEVELS_FLAG(String LEVELS_FLAG) { | ||
| 267 | + this.LEVELS_FLAG = LEVELS_FLAG; | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + public String getLEVELS1() { | ||
| 271 | + return LEVELS1; | ||
| 272 | + } | ||
| 273 | + | ||
| 274 | + public void setLEVELS1(String LEVELS1) { | ||
| 275 | + this.LEVELS1 = LEVELS1; | ||
| 276 | + } | ||
| 277 | + | ||
| 278 | + public String getLEVELS_NAME1() { | ||
| 279 | + return LEVELS_NAME1; | ||
| 280 | + } | ||
| 281 | + | ||
| 282 | + public void setLEVELS_NAME1(String LEVELS_NAME1) { | ||
| 283 | + this.LEVELS_NAME1 = LEVELS_NAME1; | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + public String getLEVELS1_CODE() { | ||
| 287 | + return LEVELS1_CODE; | ||
| 288 | + } | ||
| 289 | + | ||
| 290 | + public void setLEVELS1_CODE(String LEVELS1_CODE) { | ||
| 291 | + this.LEVELS1_CODE = LEVELS1_CODE; | ||
| 292 | + } | ||
| 293 | + | ||
| 294 | + public String getLEVELS2() { | ||
| 295 | + return LEVELS2; | ||
| 296 | + } | ||
| 297 | + | ||
| 298 | + public void setLEVELS2(String LEVELS2) { | ||
| 299 | + this.LEVELS2 = LEVELS2; | ||
| 300 | + } | ||
| 301 | + | ||
| 302 | + public String getLEVELS_NAME2() { | ||
| 303 | + return LEVELS_NAME2; | ||
| 304 | + } | ||
| 305 | + | ||
| 306 | + public void setLEVELS_NAME2(String LEVELS_NAME2) { | ||
| 307 | + this.LEVELS_NAME2 = LEVELS_NAME2; | ||
| 308 | + } | ||
| 309 | + | ||
| 310 | + public String getLEVELS2_CODE() { | ||
| 311 | + return LEVELS2_CODE; | ||
| 312 | + } | ||
| 313 | + | ||
| 314 | + public void setLEVELS2_CODE(String LEVELS2_CODE) { | ||
| 315 | + this.LEVELS2_CODE = LEVELS2_CODE; | ||
| 316 | + } | ||
| 317 | + | ||
| 318 | + public String getGPS_DATE_TIME1() { | ||
| 319 | + return GPS_DATE_TIME1; | ||
| 320 | + } | ||
| 321 | + | ||
| 322 | + public void setGPS_DATE_TIME1(String GPS_DATE_TIME1) { | ||
| 323 | + this.GPS_DATE_TIME1 = GPS_DATE_TIME1; | ||
| 324 | + } | ||
| 325 | + | ||
| 326 | + public String getGPS_DATE_TIME2() { | ||
| 327 | + return GPS_DATE_TIME2; | ||
| 328 | + } | ||
| 329 | + | ||
| 330 | + public void setGPS_DATE_TIME2(String GPS_DATE_TIME2) { | ||
| 331 | + this.GPS_DATE_TIME2 = GPS_DATE_TIME2; | ||
| 332 | + } | ||
| 333 | + | ||
| 334 | + public String getB_STATION_ID() { | ||
| 335 | + return B_STATION_ID; | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + public void setB_STATION_ID(String b_STATION_ID) { | ||
| 339 | + B_STATION_ID = b_STATION_ID; | ||
| 340 | + } | ||
| 341 | + | ||
| 342 | + public String getPLAN_START_TIME() { | ||
| 343 | + return PLAN_START_TIME; | ||
| 344 | + } | ||
| 345 | + | ||
| 346 | + public void setPLAN_START_TIME(String PLAN_START_TIME) { | ||
| 347 | + this.PLAN_START_TIME = PLAN_START_TIME; | ||
| 348 | + } | ||
| 349 | + | ||
| 350 | + public String getPLAN_ARRIVE_TIME() { | ||
| 351 | + return PLAN_ARRIVE_TIME; | ||
| 352 | + } | ||
| 353 | + | ||
| 354 | + public void setPLAN_ARRIVE_TIME(String PLAN_ARRIVE_TIME) { | ||
| 355 | + this.PLAN_ARRIVE_TIME = PLAN_ARRIVE_TIME; | ||
| 356 | + } | ||
| 357 | + | ||
| 358 | + public String getACTUAL_START_TIME() { | ||
| 359 | + return ACTUAL_START_TIME; | ||
| 360 | + } | ||
| 361 | + | ||
| 362 | + public void setACTUAL_START_TIME(String ACTUAL_START_TIME) { | ||
| 363 | + this.ACTUAL_START_TIME = ACTUAL_START_TIME; | ||
| 364 | + } | ||
| 365 | + | ||
| 366 | + public String getACTUAL_ARRIVE_TIME() { | ||
| 367 | + return ACTUAL_ARRIVE_TIME; | ||
| 368 | + } | ||
| 369 | + | ||
| 370 | + public void setACTUAL_ARRIVE_TIME(String ACTUAL_ARRIVE_TIME) { | ||
| 371 | + this.ACTUAL_ARRIVE_TIME = ACTUAL_ARRIVE_TIME; | ||
| 372 | + } | ||
| 373 | + | ||
| 374 | + public String getTRAD_ID() { | ||
| 375 | + return TRAD_ID; | ||
| 376 | + } | ||
| 377 | + | ||
| 378 | + public void setTRAD_ID(String TRAD_ID) { | ||
| 379 | + this.TRAD_ID = TRAD_ID; | ||
| 380 | + } | ||
| 381 | + | ||
| 382 | + @Override | ||
| 383 | + public Object clone() throws CloneNotSupportedException { | ||
| 384 | + return super.clone(); | ||
| 385 | + } | ||
| 386 | +} |
src/main/java/com/example/demo/model/TJRLDB.java
0 → 100644
| 1 | +package com.example.demo.model; | ||
| 2 | + | ||
| 3 | +public class TJRLDB extends TJRL{ | ||
| 4 | + private String TJRLDRVCRDID; | ||
| 5 | + private String MARK; | ||
| 6 | + | ||
| 7 | + public TJRLDB(){ | ||
| 8 | + super(); | ||
| 9 | + } | ||
| 10 | + public TJRLDB(TJRLDB tjrldb) throws Exception { | ||
| 11 | + super(tjrldb); | ||
| 12 | + } | ||
| 13 | + | ||
| 14 | + public String getTJRLDRVCRDID() { | ||
| 15 | + return TJRLDRVCRDID; | ||
| 16 | + } | ||
| 17 | + | ||
| 18 | + public void setTJRLDRVCRDID(String TJRLDRVCRDID) { | ||
| 19 | + this.TJRLDRVCRDID = TJRLDRVCRDID; | ||
| 20 | + } | ||
| 21 | + | ||
| 22 | + public String getMARK() { | ||
| 23 | + return MARK; | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + public void setMARK(String MARK) { | ||
| 27 | + this.MARK = MARK; | ||
| 28 | + } | ||
| 29 | +} |
src/main/java/com/example/demo/service/Analysis.java
| @@ -39,7 +39,7 @@ public class Analysis { | @@ -39,7 +39,7 @@ public class Analysis { | ||
| 39 | List<String> list = new ArrayList<String>(); | 39 | List<String> list = new ArrayList<String>(); |
| 40 | for (File file : files) { | 40 | for (File file : files) { |
| 41 | if (!file.isDirectory()) { | 41 | if (!file.isDirectory()) { |
| 42 | - String name=file.getName().substring(0,10); | 42 | + String name=file.getName().substring(2,10); |
| 43 | String absolutePath = file.getAbsolutePath(); | 43 | String absolutePath = file.getAbsolutePath(); |
| 44 | String time = (absolutePath.substring(absolutePath.indexOf("GJ"), absolutePath.indexOf("GJ") + 16)).replace("GJ", ""); | 44 | String time = (absolutePath.substring(absolutePath.indexOf("GJ"), absolutePath.indexOf("GJ") + 16)).replace("GJ", ""); |
| 45 | Date nowTime = null; | 45 | Date nowTime = null; |
| @@ -171,7 +171,6 @@ public class Analysis { | @@ -171,7 +171,6 @@ public class Analysis { | ||
| 171 | return false; | 171 | return false; |
| 172 | } | 172 | } |
| 173 | } | 173 | } |
| 174 | - | ||
| 175 | /* @Value("${ftp.oldFile}") | 174 | /* @Value("${ftp.oldFile}") |
| 176 | public void setOldFile(String oldFile) { | 175 | public void setOldFile(String oldFile) { |
| 177 | Analysis.oldFile = oldFile; | 176 | Analysis.oldFile = oldFile; |
src/main/java/com/example/demo/service/Contrast.java
| @@ -18,6 +18,7 @@ import org.springframework.stereotype.Service; | @@ -18,6 +18,7 @@ import org.springframework.stereotype.Service; | ||
| 18 | import org.springframework.util.concurrent.ListenableFuture; | 18 | import org.springframework.util.concurrent.ListenableFuture; |
| 19 | import org.springframework.util.concurrent.ListenableFutureCallback; | 19 | import org.springframework.util.concurrent.ListenableFutureCallback; |
| 20 | 20 | ||
| 21 | +import javax.annotation.Resource; | ||
| 21 | import java.text.ParseException; | 22 | import java.text.ParseException; |
| 22 | import java.text.SimpleDateFormat; | 23 | import java.text.SimpleDateFormat; |
| 23 | import java.time.*; | 24 | import java.time.*; |
| @@ -40,11 +41,13 @@ public class Contrast { | @@ -40,11 +41,13 @@ public class Contrast { | ||
| 40 | @Autowired | 41 | @Autowired |
| 41 | private KafkaTemplate kafkaTemplate; | 42 | private KafkaTemplate kafkaTemplate; |
| 42 | 43 | ||
| 43 | - | ||
| 44 | - | ||
| 45 | @Autowired | 44 | @Autowired |
| 46 | private SaticScheduleTask saticScheduleTask; | 45 | private SaticScheduleTask saticScheduleTask; |
| 47 | 46 | ||
| 47 | + public Map<String,List<Scheduling>> getSchedulingS; | ||
| 48 | + public Map<String,List<Scheduling>> getSchedulingSSell; | ||
| 49 | + public List<TJRLDB> oldData=new ArrayList<>(); | ||
| 50 | + | ||
| 48 | private final int TIME=5; | 51 | private final int TIME=5; |
| 49 | private final int TIME2=0;//刷卡的时间和到站实际允许误差值 | 52 | private final int TIME2=0;//刷卡的时间和到站实际允许误差值 |
| 50 | 53 | ||
| @@ -193,8 +196,10 @@ public class Contrast { | @@ -193,8 +196,10 @@ public class Contrast { | ||
| 193 | public void filterCardList(List<TJRLDB> allData, Boolean isOld) { | 196 | public void filterCardList(List<TJRLDB> allData, Boolean isOld) { |
| 194 | long start = System.currentTimeMillis(); | 197 | long start = System.currentTimeMillis(); |
| 195 | List<Map> driverCardList = getDriverCardList();//获取司机信息 | 198 | List<Map> driverCardList = getDriverCardList();//获取司机信息 |
| 196 | - Map<String,List<Scheduling>> schedulingS =saticScheduleTask.getSchedulingS; | ||
| 197 | - Map<String,List<Scheduling>> schedulingSSell =saticScheduleTask.getSchedulingSSell; | 199 | + Map<String,List<Scheduling>> schedulingS =getSchedulingS; |
| 200 | + Map<String,List<Scheduling>> schedulingSSell =getSchedulingSSell; | ||
| 201 | + System.out.println(schedulingS.size()); | ||
| 202 | + System.out.println(schedulingSSell.size()); | ||
| 198 | DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | 203 | DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| 199 | int b=0;//用于计算匹配成功的数量 | 204 | int b=0;//用于计算匹配成功的数量 |
| 200 | for (int i = 0; i < allData.size(); i++) { | 205 | for (int i = 0; i < allData.size(); i++) { |
| @@ -229,6 +234,7 @@ public class Contrast { | @@ -229,6 +234,7 @@ public class Contrast { | ||
| 229 | Collections.sort(schedulingList1, Comparator.comparing(Scheduling::getTs).reversed()); | 234 | Collections.sort(schedulingList1, Comparator.comparing(Scheduling::getTs).reversed()); |
| 230 | for (int i1 = 0; i1 < schedulingList1.size(); i1++) { | 235 | for (int i1 = 0; i1 < schedulingList1.size(); i1++) { |
| 231 | Scheduling s=schedulingList1.get(i1); | 236 | Scheduling s=schedulingList1.get(i1); |
| 237 | + //进站时间小于刷卡时间 | ||
| 232 | if((Long.parseLong(s.getTs())-TIME2*60*1000)<=cardDate){ | 238 | if((Long.parseLong(s.getTs())-TIME2*60*1000)<=cardDate){ |
| 233 | scheduling=s; | 239 | scheduling=s; |
| 234 | b++; | 240 | b++; |
| @@ -237,7 +243,7 @@ public class Contrast { | @@ -237,7 +243,7 @@ public class Contrast { | ||
| 237 | } | 243 | } |
| 238 | } | 244 | } |
| 239 | }else { | 245 | }else { |
| 240 | - mark="未查到驾驶员排班:"+personalName+" 工号:"+jobCodes; | 246 | + mark="没有匹配的进站记录:"+personalName+" 工号:"+jobCodes; |
| 241 | } | 247 | } |
| 242 | 248 | ||
| 243 | if (scheduling!=null) { | 249 | if (scheduling!=null) { |
| @@ -268,16 +274,16 @@ public class Contrast { | @@ -268,16 +274,16 @@ public class Contrast { | ||
| 268 | } | 274 | } |
| 269 | } | 275 | } |
| 270 | }else { | 276 | }else { |
| 271 | - mark="未查到驾驶员 卡号:"+carId; | 277 | + mark="未查工号:"+carId; |
| 272 | data.setSTATION_FLAG("0"); | 278 | data.setSTATION_FLAG("0"); |
| 273 | } | 279 | } |
| 274 | if(mark.length()==0 && !flag){ | 280 | if(mark.length()==0 && !flag){ |
| 275 | - mark="未匹配到班次 "+jobCodes+"刷卡时间为:"+LocalDateTime.ofEpochSecond(cardDate/1000, 0, ZoneOffset.ofHours(8)); | 281 | + mark="没有匹配的班次 "+jobCodes+"刷卡时间为:"+LocalDateTime.ofEpochSecond(cardDate/1000, 0, ZoneOffset.ofHours(8)); |
| 276 | } | 282 | } |
| 277 | data.setMARK(mark); | 283 | data.setMARK(mark); |
| 278 | //如果是新数据 没匹配到 去除这条记录 并放入缓存等到下次继续匹配 | 284 | //如果是新数据 没匹配到 去除这条记录 并放入缓存等到下次继续匹配 |
| 279 | if(!isOld && !flag){ | 285 | if(!isOld && !flag){ |
| 280 | - List<TJRLDB> m =saticScheduleTask.data; | 286 | + List<TJRLDB> m =oldData; |
| 281 | m.add(data); | 287 | m.add(data); |
| 282 | allData.set(i,null); | 288 | allData.set(i,null); |
| 283 | 289 | ||
| @@ -331,7 +337,7 @@ public class Contrast { | @@ -331,7 +337,7 @@ public class Contrast { | ||
| 331 | } | 337 | } |
| 332 | //如果是上次遗留的数据不管这是是否匹配到都清空 | 338 | //如果是上次遗留的数据不管这是是否匹配到都清空 |
| 333 | if(isOld){ | 339 | if(isOld){ |
| 334 | - saticScheduleTask.data.clear(); | 340 | + oldData.clear(); |
| 335 | } | 341 | } |
| 336 | logger.warn("======匹配"+size+"条======匹配到"+b+"条=====耗时=="+(System.currentTimeMillis() - start)/1000 + "秒"); | 342 | logger.warn("======匹配"+size+"条======匹配到"+b+"条=====耗时=="+(System.currentTimeMillis() - start)/1000 + "秒"); |
| 337 | } | 343 | } |
| @@ -347,8 +353,8 @@ public class Contrast { | @@ -347,8 +353,8 @@ public class Contrast { | ||
| 347 | public void filterCardListByDB(List<TJRLDB> allData,Boolean isOld) { | 353 | public void filterCardListByDB(List<TJRLDB> allData,Boolean isOld) { |
| 348 | long start = System.currentTimeMillis(); | 354 | long start = System.currentTimeMillis(); |
| 349 | List<Map> driverCardList = getDriverCardList();//获取司机信息 | 355 | List<Map> driverCardList = getDriverCardList();//获取司机信息 |
| 350 | - Map<String,List<Scheduling>> schedulingS =saticScheduleTask.getSchedulingS; | ||
| 351 | - Map<String,List<Scheduling>> schedulingSSell =saticScheduleTask.getSchedulingSSell; | 356 | + Map<String,List<Scheduling>> schedulingS =getSchedulingS; |
| 357 | + Map<String,List<Scheduling>> schedulingSSell =getSchedulingSSell; | ||
| 352 | DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | 358 | DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| 353 | int b=0;//用于计算匹配成功的数量 | 359 | int b=0;//用于计算匹配成功的数量 |
| 354 | for (int i = 0; i < allData.size(); i++) { | 360 | for (int i = 0; i < allData.size(); i++) { |
| @@ -431,7 +437,7 @@ public class Contrast { | @@ -431,7 +437,7 @@ public class Contrast { | ||
| 431 | data.setMARK(mark); | 437 | data.setMARK(mark); |
| 432 | //如果是新数据 没匹配到 去除这条记录 并放入缓存等到下次继续匹配 | 438 | //如果是新数据 没匹配到 去除这条记录 并放入缓存等到下次继续匹配 |
| 433 | if(!isOld && !flag){ | 439 | if(!isOld && !flag){ |
| 434 | - List<TJRLDB> m =saticScheduleTask.data; | 440 | + List<TJRLDB> m =oldData; |
| 435 | m.add(data); | 441 | m.add(data); |
| 436 | allData.set(i,null); | 442 | allData.set(i,null); |
| 437 | 443 | ||
| @@ -481,7 +487,7 @@ public class Contrast { | @@ -481,7 +487,7 @@ public class Contrast { | ||
| 481 | } | 487 | } |
| 482 | //如果是上次遗留的数据不管这是是否匹配到都清空 | 488 | //如果是上次遗留的数据不管这是是否匹配到都清空 |
| 483 | if(isOld){ | 489 | if(isOld){ |
| 484 | - saticScheduleTask.data.clear(); | 490 | + oldData.clear(); |
| 485 | } | 491 | } |
| 486 | logger.warn("======匹配"+size+"条======匹配到"+b+"条=====耗时=="+(System.currentTimeMillis() - start)/1000 + "秒"); | 492 | logger.warn("======匹配"+size+"条======匹配到"+b+"条=====耗时=="+(System.currentTimeMillis() - start)/1000 + "秒"); |
| 487 | } | 493 | } |