Commit 1c63703fa798b4ac59913ed56942eca989a8b70a
1 parent
c18dfa92
修改的定时器时间
Showing
7 changed files
with
218 additions
and
153 deletions
pom.xml
| @@ -93,6 +93,11 @@ | @@ -93,6 +93,11 @@ | ||
| 93 | <artifactId>druid-spring-boot-starter</artifactId> | 93 | <artifactId>druid-spring-boot-starter</artifactId> |
| 94 | <version>1.1.20</version> | 94 | <version>1.1.20</version> |
| 95 | </dependency> | 95 | </dependency> |
| 96 | + <dependency> | ||
| 97 | + <groupId>cn.hutool</groupId> | ||
| 98 | + <artifactId>hutool-all</artifactId> | ||
| 99 | + <version>5.7.12</version> | ||
| 100 | + </dependency> | ||
| 96 | </dependencies> | 101 | </dependencies> |
| 97 | 102 | ||
| 98 | <build> | 103 | <build> |
src/main/java/com/example/demo/SaticScheduleTask.java
| 1 | package com.example.demo; | 1 | package com.example.demo; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | +import cn.hutool.core.io.FileUtil; | ||
| 4 | import com.example.demo.model.Scheduling; | 5 | import com.example.demo.model.Scheduling; |
| 6 | +import com.example.demo.model.TJRL; | ||
| 7 | +import com.example.demo.model.TJRLDB; | ||
| 5 | import com.example.demo.service.Analysis; | 8 | import com.example.demo.service.Analysis; |
| 6 | import com.example.demo.service.Contrast; | 9 | import com.example.demo.service.Contrast; |
| 7 | import org.slf4j.Logger; | 10 | import org.slf4j.Logger; |
| @@ -34,21 +37,22 @@ public class SaticScheduleTask implements InitializingBean { | @@ -34,21 +37,22 @@ public class SaticScheduleTask implements InitializingBean { | ||
| 34 | @Value("${ftp.root}") | 37 | @Value("${ftp.root}") |
| 35 | private String rootPath; | 38 | private String rootPath; |
| 36 | 39 | ||
| 37 | - | ||
| 38 | private WatchService watchService; | 40 | private WatchService watchService; |
| 39 | 41 | ||
| 40 | @Autowired | 42 | @Autowired |
| 41 | private Contrast contrast; | 43 | private Contrast contrast; |
| 42 | 44 | ||
| 45 | + @Autowired | ||
| 46 | + private Analysis analysis; | ||
| 43 | 47 | ||
| 44 | public Map<String,List<Scheduling>> getSchedulingS; | 48 | public Map<String,List<Scheduling>> getSchedulingS; |
| 45 | public Map<String,List<Scheduling>> getSchedulingSSell; | 49 | public Map<String,List<Scheduling>> getSchedulingSSell; |
| 46 | - public List<Map> data=new ArrayList<>(); | 50 | + public List<TJRLDB> data=new ArrayList<>(); |
| 47 | 51 | ||
| 48 | /** | 52 | /** |
| 49 | * 定时任务 | 53 | * 定时任务 |
| 50 | */ | 54 | */ |
| 51 | - @Scheduled(cron = "0 0/10 * * * ?") | 55 | + /*@Scheduled(cron = "0 0/10 * * * ?") |
| 52 | private void configureTasks() throws Exception{ | 56 | private void configureTasks() throws Exception{ |
| 53 | logger.info("执行静态定时任务时间: " + LocalDateTime.now()); | 57 | logger.info("执行静态定时任务时间: " + LocalDateTime.now()); |
| 54 | WatchKey watchKey = null; | 58 | WatchKey watchKey = null; |
| @@ -64,38 +68,91 @@ public class SaticScheduleTask implements InitializingBean { | @@ -64,38 +68,91 @@ public class SaticScheduleTask implements InitializingBean { | ||
| 64 | watchKey.reset(); | 68 | watchKey.reset(); |
| 65 | } | 69 | } |
| 66 | System.out.println("文件数"+files); | 70 | System.out.println("文件数"+files); |
| 67 | - // "TJRLAMT" -> "00000200" 交易金额 | ||
| 68 | - // "TJRLCDKIND" -> "01" 卡类型 | ||
| 69 | - // "TJRLCDBAL" -> "00000000" 交易前余额 | ||
| 70 | - // "TJRLTXFG" -> "88" 交易类型 | ||
| 71 | - // "TJRLPOSID" -> "00A699" POS机号 | ||
| 72 | - // "TJRLRTIME" -> "23:58:46" | ||
| 73 | - // "TJRLORGAMT" -> "0200" 交易原始金额 | ||
| 74 | - // "TJRLCARDNO" -> "B1403683" 交通卡号 | ||
| 75 | - // "TJRLRDATE" -> "2021-07-09" | 71 | + |
| 76 | //先把处理上一次没匹配到的 | 72 | //先把处理上一次没匹配到的 |
| 77 | if(!data.isEmpty()){ | 73 | if(!data.isEmpty()){ |
| 78 | contrast.filterCardList(data,true); | 74 | contrast.filterCardList(data,true); |
| 79 | } | 75 | } |
| 80 | - List<Map> allFile = Analysis.getAllFile(files); | 76 | + List<TJRLDB> allFile = Analysis.getAllFile(files); |
| 81 | System.out.println("交易数"+allFile); | 77 | System.out.println("交易数"+allFile); |
| 82 | contrast.filterCardList(allFile,false); | 78 | contrast.filterCardList(allFile,false); |
| 83 | - } | 79 | + }*/ |
| 80 | + | ||
| 84 | 81 | ||
| 85 | - @Scheduled(cron = "0 0/9 * * * ?") | 82 | + /* @Scheduled(cron = "0 0/9 * * * ?") |
| 86 | @PostConstruct | 83 | @PostConstruct |
| 87 | void getArrivalInfos() { | 84 | void getArrivalInfos() { |
| 88 | logger.info("票务数据缓存加载: " + LocalDateTime.now()); | 85 | logger.info("票务数据缓存加载: " + LocalDateTime.now()); |
| 89 | LocalDateTime now=LocalDateTime.now(); | 86 | LocalDateTime now=LocalDateTime.now(); |
| 90 | //测试 | 87 | //测试 |
| 91 | - /* DateTimeFormatter tdf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | ||
| 92 | - now=LocalDateTime.parse("2021-08-01 00:00",tdf);*/ | 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 | + | ||
| 95 | + /* @Scheduled(cron = "0 0/10 * * * ?") | ||
| 96 | + @PostConstruct*/ | ||
| 97 | + void getArrivalInfos() throws Exception { | ||
| 98 | + logger.info("票务数据缓存加载: " + LocalDateTime.now()); | ||
| 99 | + if(watchService==null){ | ||
| 100 | + afterPropertiesSet(); | ||
| 101 | + } | ||
| 102 | + LocalDateTime now=LocalDateTime.now(); | ||
| 93 | List<Map<String,List<Scheduling>>> result=contrast.getSchedulingS(now,1); | 103 | List<Map<String,List<Scheduling>>> result=contrast.getSchedulingS(now,1); |
| 94 | getSchedulingS=result.get(0); | 104 | getSchedulingS=result.get(0); |
| 95 | getSchedulingSSell=result.get(1); | 105 | getSchedulingSSell=result.get(1); |
| 106 | + | ||
| 107 | + WatchKey watchKey = null; | ||
| 108 | + List<File> files = new ArrayList<>(); | ||
| 109 | + while ((watchKey = watchService.poll()) != null) { | ||
| 110 | + for (WatchEvent watchEvent : watchKey.pollEvents()) { | ||
| 111 | + Path path = (Path)watchEvent.context(); | ||
| 112 | + if(path!=null){ | ||
| 113 | + files.add(new File(rootPath + File.separator + path)); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + } | ||
| 117 | + watchKey.reset(); | ||
| 118 | + } | ||
| 119 | + System.out.println("文件数"+files.size()); | ||
| 120 | + //先把处理上一次没匹配到的 | ||
| 121 | + if(!data.isEmpty()){ | ||
| 122 | + contrast.filterCardList(data,true); | ||
| 123 | + } | ||
| 124 | + List<TJRLDB> allFile = analysis.getAllFile(files); | ||
| 125 | + System.out.println("交易数"+allFile.size()); | ||
| 126 | + contrast.filterCardList(allFile,false); | ||
| 96 | } | 127 | } |
| 97 | 128 | ||
| 98 | 129 | ||
| 130 | + @PostConstruct | ||
| 131 | + void getArrivalInfos2() throws Exception { | ||
| 132 | + logger.info("票务数据缓存加载: " + LocalDateTime.now()); | ||
| 133 | + if(watchService==null){ | ||
| 134 | + afterPropertiesSet(); | ||
| 135 | + } | ||
| 136 | + LocalDateTime now=LocalDateTime.now(); | ||
| 137 | + //测试 | ||
| 138 | + DateTimeFormatter tdf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm"); | ||
| 139 | + now=LocalDateTime.parse("2021-08-01 00:00",tdf); | ||
| 140 | + 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"); | ||
| 144 | + List<List<File>> subList=getSubList(100,fl); | ||
| 145 | + if(!subList.isEmpty()){ | ||
| 146 | + subList.forEach(fs->{ | ||
| 147 | + if (!fs.isEmpty()) { | ||
| 148 | + System.out.println("文件数"+fs.size()); | ||
| 149 | + List<TJRLDB> allFile = analysis.getAllFile(fs); | ||
| 150 | + System.out.println("交易数"+allFile.size()); | ||
| 151 | + contrast.filterCardList(allFile,true); | ||
| 152 | + } | ||
| 153 | + }); | ||
| 154 | + } | ||
| 155 | + } | ||
| 99 | /** | 156 | /** |
| 100 | * @Description: 用来计算数据库中的乘车记录 | 157 | * @Description: 用来计算数据库中的乘车记录 |
| 101 | * @Param: | 158 | * @Param: |
| @@ -130,4 +187,22 @@ public class SaticScheduleTask implements InitializingBean { | @@ -130,4 +187,22 @@ public class SaticScheduleTask implements InitializingBean { | ||
| 130 | Path path = Paths.get(rootPath); | 187 | Path path = Paths.get(rootPath); |
| 131 | path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE); | 188 | path.register(watchService, StandardWatchEventKinds.ENTRY_CREATE); |
| 132 | } | 189 | } |
| 190 | + | ||
| 191 | + public List<List<File>> getSubList(int length, List<File> list){ | ||
| 192 | + int size = list.size(); | ||
| 193 | + int temp = size / length + 1; | ||
| 194 | + boolean result = size % length == 0; | ||
| 195 | + List<List<File>> subList = new ArrayList<>(); | ||
| 196 | + for (int i = 0; i < temp; i++) { | ||
| 197 | + if (i == temp - 1) { | ||
| 198 | + if (result) { | ||
| 199 | + break; | ||
| 200 | + } | ||
| 201 | + subList.add(list.subList(length * i, size)) ; | ||
| 202 | + } else { | ||
| 203 | + subList.add(list.subList(length * i, length * (i + 1))) ; | ||
| 204 | + } | ||
| 205 | + } | ||
| 206 | + return subList; | ||
| 207 | + } | ||
| 133 | } | 208 | } |
| 134 | \ No newline at end of file | 209 | \ No newline at end of file |
src/main/java/com/example/demo/mapper/db1/SiteMapper1.java
| @@ -2,9 +2,7 @@ package com.example.demo.mapper.db1; | @@ -2,9 +2,7 @@ package com.example.demo.mapper.db1; | ||
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | import com.baomidou.dynamic.datasource.annotation.DS; | 4 | import com.baomidou.dynamic.datasource.annotation.DS; |
| 5 | -import com.example.demo.model.ArrivalInfo; | ||
| 6 | -import com.example.demo.model.Scheduling; | ||
| 7 | -import com.example.demo.model.StationRoute; | 5 | +import com.example.demo.model.*; |
| 8 | import org.apache.ibatis.annotations.Mapper; | 6 | import org.apache.ibatis.annotations.Mapper; |
| 9 | 7 | ||
| 10 | import java.util.List; | 8 | import java.util.List; |
| @@ -18,7 +16,7 @@ public interface SiteMapper1 { | @@ -18,7 +16,7 @@ public interface SiteMapper1 { | ||
| 18 | 16 | ||
| 19 | 17 | ||
| 20 | @DS("db1") | 18 | @DS("db1") |
| 21 | - void insertResult(List<Map> list); | 19 | + void insertResult(List<TJRLDB> list); |
| 22 | 20 | ||
| 23 | @DS("db1") | 21 | @DS("db1") |
| 24 | List<Scheduling> getScheduling(Map<String, Object> map); | 22 | List<Scheduling> getScheduling(Map<String, Object> map); |
| @@ -30,5 +28,5 @@ public interface SiteMapper1 { | @@ -30,5 +28,5 @@ public interface SiteMapper1 { | ||
| 30 | List<StationRoute> getStationRoute(); | 28 | List<StationRoute> getStationRoute(); |
| 31 | 29 | ||
| 32 | @DS("db1") | 30 | @DS("db1") |
| 33 | - List<Map> getRecords(Map<String, Object> map); | 31 | + List<TJRLDB> getRecords(Map<String, Object> map); |
| 34 | } | 32 | } |
| 35 | \ No newline at end of file | 33 | \ No newline at end of file |
src/main/java/com/example/demo/service/Analysis.java
| 1 | package com.example.demo.service; | 1 | package com.example.demo.service; |
| 2 | 2 | ||
| 3 | import com.example.demo.SaticScheduleTask; | 3 | import com.example.demo.SaticScheduleTask; |
| 4 | +import com.example.demo.model.TJRL; | ||
| 5 | +import com.example.demo.model.TJRLDB; | ||
| 4 | import org.slf4j.Logger; | 6 | import org.slf4j.Logger; |
| 5 | import org.slf4j.LoggerFactory; | 7 | import org.slf4j.LoggerFactory; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | 8 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -22,7 +24,8 @@ public class Analysis { | @@ -22,7 +24,8 @@ public class Analysis { | ||
| 22 | private static Date startDate = subtractTime(new Date(), -300000); | 24 | private static Date startDate = subtractTime(new Date(), -300000); |
| 23 | 25 | ||
| 24 | 26 | ||
| 25 | - private static String oldFile; | 27 | + @Value("${ftp.oldFile}") |
| 28 | + private String oldFile; | ||
| 26 | 29 | ||
| 27 | 30 | ||
| 28 | /** | 31 | /** |
| @@ -31,12 +34,12 @@ public class Analysis { | @@ -31,12 +34,12 @@ public class Analysis { | ||
| 31 | * @param files 需要遍历的文件夹路径 | 34 | * @param files 需要遍历的文件夹路径 |
| 32 | * @return | 35 | * @return |
| 33 | */ | 36 | */ |
| 34 | - public static List<Map> getAllFile(List<File> files) { | ||
| 35 | - List<Map> listMap = new ArrayList<>(); | 37 | + public List<TJRLDB> getAllFile(List<File> files) { |
| 38 | + List<TJRLDB> listMap = new ArrayList<>(); | ||
| 36 | List<String> list = new ArrayList<String>(); | 39 | List<String> list = new ArrayList<String>(); |
| 37 | - System.out.println("文件数"+files.size()); | ||
| 38 | for (File file : files) { | 40 | for (File file : files) { |
| 39 | if (!file.isDirectory()) { | 41 | if (!file.isDirectory()) { |
| 42 | + String name=file.getName().substring(0,10); | ||
| 40 | String absolutePath = file.getAbsolutePath(); | 43 | String absolutePath = file.getAbsolutePath(); |
| 41 | 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", ""); |
| 42 | Date nowTime = null; | 45 | Date nowTime = null; |
| @@ -51,23 +54,24 @@ public class Analysis { | @@ -51,23 +54,24 @@ public class Analysis { | ||
| 51 | for (int i = 0; i < strings.size(); i++) { | 54 | for (int i = 0; i < strings.size(); i++) { |
| 52 | String text = strings.get(i); | 55 | String text = strings.get(i); |
| 53 | Map<String, Object> map = new HashMap<>(); | 56 | Map<String, Object> map = new HashMap<>(); |
| 57 | + TJRLDB tjrl=new TJRLDB(); | ||
| 54 | Long val = Long.parseLong(text.substring(30, 40)); | 58 | Long val = Long.parseLong(text.substring(30, 40)); |
| 55 | String cardId = Long.toHexString(val).toUpperCase(); | 59 | String cardId = Long.toHexString(val).toUpperCase(); |
| 56 | - map.put("TJRLDRVCRDID", cardId); //司售卡号 DriverCardId签到卡片ID号,BCD编码,司售卡卡号 | 60 | + tjrl.setTJRLDRVCRDID(cardId);//司售卡号 DriverCardId签到卡片ID号,BCD编码,司售卡卡号 |
| 57 | //map.put("DriverCardType", text.substring(40, 42));//DriverCardType HEX格式,签到卡的卡型,BCD编码 | 61 | //map.put("DriverCardType", text.substring(40, 42));//DriverCardType HEX格式,签到卡的卡型,BCD编码 |
| 58 | //map.put("CHECKINDATE", text.substring(42, 54));//签到时间YYYYMMDDhhmm,BCD编码 | 62 | //map.put("CHECKINDATE", text.substring(42, 54));//签到时间YYYYMMDDhhmm,BCD编码 |
| 59 | //map.put("CHECKOUTCOUNT", text.substring(54, 60));//签到总次数,BCD编码 | 63 | //map.put("CHECKOUTCOUNT", text.substring(54, 60));//签到总次数,BCD编码 |
| 60 | - map.put("TJRLTXFG", text.substring(60, 62));//交易类型 Txn Flag HEX格式,交易标志,其中88为正常交易,99为锁卡交易,BCD编码,定义见附录1交易类型对照表 | 64 | + tjrl.setTJRLTXFG(text.substring(60, 62));//交易类型 Txn Flag HEX格式,交易标志,其中88为正常交易,99为锁卡交易,BCD编码,定义见附录1交易类型对照表 |
| 61 | String TJRLPOSID=text.substring(62, 68); | 65 | String TJRLPOSID=text.substring(62, 68); |
| 62 | - map.put("TJRLPOSID", TJRLPOSID); //HEX格式,消费交易流水号,BCD编码 | 66 | + tjrl.setTJRLPOSID(TJRLPOSID);//HEX格式,消费交易流水号,BCD编码 |
| 63 | //map.put("CITYCODE", text.substring(68, 72)); //城市代码号,BCD编码 | 67 | //map.put("CITYCODE", text.substring(68, 72)); //城市代码号,BCD编码 |
| 64 | - map.put("TJRLCARDNO", text.substring(72, 82));//CARDID消费卡的ID号,BCD编码 | ||
| 65 | - map.put("TJRLCDKIND", text.substring(82, 84));//Card Type HEX格式,消费卡卡型,BCD编码 | ||
| 66 | - map.put("TJRLCDBAL", text.substring(84, 92)); //交易前余额 BalBef消费卡交易前金额,BCD编码 BCD编码之前最高位1表示负数,0表示正数 | ||
| 67 | - map.put("TJRLAMT", text.substring(92, 100)); //交易金额 TxnAmount本次消费交易金额,BCD编码 | 68 | + tjrl.setTJRLCARDNO(text.substring(72, 82));//CARDID消费卡的ID号,BCD编码 |
| 69 | + tjrl.setTJRLCDKIND(text.substring(82, 84));//Card Type HEX格式,消费卡卡型,BCD编码 | ||
| 70 | + tjrl.setTJRLCDBAL(text.substring(84, 92));//交易前余额 BalBef消费卡交易前金额,BCD编码 BCD编码之前最高位1表示负数,0表示正数 | ||
| 71 | + tjrl.setTJRLAMT(text.substring(92, 100));//交易金额 TxnAmount本次消费交易金额,BCD编码 | ||
| 68 | String TJRLRDATE=text.substring(100, 108); | 72 | String TJRLRDATE=text.substring(100, 108); |
| 69 | try { | 73 | try { |
| 70 | - map.put("TJRLRDATE",new SimpleDateFormat("yyyy-MM-dd"). | 74 | + tjrl.setTJRLRDATE(new SimpleDateFormat("yyyy-MM-dd"). |
| 71 | format(new SimpleDateFormat("yyyyMMdd").parse(text.substring(100, 108)))); | 75 | format(new SimpleDateFormat("yyyyMMdd").parse(text.substring(100, 108)))); |
| 72 | //交易日期 本次消费交易日期,BCD编码YYYYMMDD | 76 | //交易日期 本次消费交易日期,BCD编码YYYYMMDD |
| 73 | } catch (ParseException e) { | 77 | } catch (ParseException e) { |
| @@ -75,26 +79,29 @@ public class Analysis { | @@ -75,26 +79,29 @@ public class Analysis { | ||
| 75 | } | 79 | } |
| 76 | String TJRLRTIME=text.substring(108, 114); | 80 | String TJRLRTIME=text.substring(108, 114); |
| 77 | try { | 81 | try { |
| 78 | - map.put("TJRLRTIME",new SimpleDateFormat("HH:mm:ss"). | 82 | + tjrl.setTJRLRTIME(new SimpleDateFormat("HH:mm:ss"). |
| 79 | format(new SimpleDateFormat("HHmmss").parse(text.substring(108, 114)))); | 83 | format(new SimpleDateFormat("HHmmss").parse(text.substring(108, 114)))); |
| 80 | //交易时间 Txn Time本次消费交易时间,BCD编码hhmmss | 84 | //交易时间 Txn Time本次消费交易时间,BCD编码hhmmss |
| 81 | } catch (ParseException e) { | 85 | } catch (ParseException e) { |
| 82 | e.printStackTrace(); | 86 | e.printStackTrace(); |
| 83 | } | 87 | } |
| 84 | //map.put("COUNT", text.substring(114, 120)); //交易计数器,BCD编码 | 88 | //map.put("COUNT", text.substring(114, 120)); //交易计数器,BCD编码 |
| 85 | - map.put("TJRLORGAMT", text.substring(120, 124)); //交易原始金额Orignal Txn Amount | 89 | + tjrl.setTJRLORGAMT(text.substring(120, 124));//交易原始金额Orignal Txn Amount |
| 86 | //map.put("CARDSPEC", text.substring(124, 126)); //卡规范,BCD编码 01—建设部卡 02—交通部卡 03-交通部二维码 | 90 | //map.put("CARDSPEC", text.substring(124, 126)); //卡规范,BCD编码 01—建设部卡 02—交通部卡 03-交通部二维码 |
| 87 | - String TAC=text.substring(126, 134); | ||
| 88 | - map.put("TAC",TAC);//HEX格式,交易认证码,BCD编码 | 91 | + String TAC=text.substring(126, 134);//HEX格式,交易认证码,BCD编码 |
| 89 | String TRAD_ID=TAC+TJRLPOSID+TJRLRDATE+TJRLRTIME; | 92 | String TRAD_ID=TAC+TJRLPOSID+TJRLRDATE+TJRLRTIME; |
| 90 | - map.put("TRAD_ID",TRAD_ID); | ||
| 91 | - //pos交易数据需要加上 trad_id 用tac+pos流水+交易日期+交易时间 | ||
| 92 | - listMap.add(map); | 93 | + tjrl.setTRAD_ID(TRAD_ID);////pos交易数据需要加上 trad_id 用tac+pos流水+交易日期+交易时间 |
| 94 | + | ||
| 95 | + listMap.add(tjrl); | ||
| 93 | } | 96 | } |
| 94 | //} | 97 | //} |
| 95 | - Analysis analysis=new Analysis(); | ||
| 96 | - analysis.setOldFile(oldFile); | ||
| 97 | - File f=new File(analysis.oldFile+File.separator+file.getName()); | 98 | + /* Analysis analysis=new Analysis(); |
| 99 | + analysis.setOldFile(oldFile);*/ | ||
| 100 | + File f2=new File(oldFile+File.separator+name); | ||
| 101 | + if(!f2.exists()&&!f2.isDirectory()){ | ||
| 102 | + f2.mkdir(); | ||
| 103 | + } | ||
| 104 | + File f=new File(oldFile+File.separator+name+File.separator+file.getName()); | ||
| 98 | file.renameTo(f); | 105 | file.renameTo(f); |
| 99 | } | 106 | } |
| 100 | } | 107 | } |
| @@ -165,10 +172,10 @@ public class Analysis { | @@ -165,10 +172,10 @@ public class Analysis { | ||
| 165 | } | 172 | } |
| 166 | } | 173 | } |
| 167 | 174 | ||
| 168 | - @Value("${ftp.oldFile}") | 175 | + /* @Value("${ftp.oldFile}") |
| 169 | public void setOldFile(String oldFile) { | 176 | public void setOldFile(String oldFile) { |
| 170 | Analysis.oldFile = oldFile; | 177 | Analysis.oldFile = oldFile; |
| 171 | - } | 178 | + }*/ |
| 172 | 179 | ||
| 173 | } | 180 | } |
| 174 | 181 |
src/main/java/com/example/demo/service/Contrast.java
| @@ -6,9 +6,7 @@ import com.bsth.util.HttpUtils; | @@ -6,9 +6,7 @@ import com.bsth.util.HttpUtils; | ||
| 6 | import com.example.demo.SaticScheduleTask; | 6 | import com.example.demo.SaticScheduleTask; |
| 7 | import com.example.demo.mapper.db1.SiteMapper1; | 7 | import com.example.demo.mapper.db1.SiteMapper1; |
| 8 | import com.example.demo.mapper.db2.SiteMapper2; | 8 | import com.example.demo.mapper.db2.SiteMapper2; |
| 9 | -import com.example.demo.model.ArrivalInfo; | ||
| 10 | -import com.example.demo.model.Scheduling; | ||
| 11 | -import com.example.demo.model.StationRoute; | 9 | +import com.example.demo.model.*; |
| 12 | import com.fasterxml.jackson.core.JsonProcessingException; | 10 | import com.fasterxml.jackson.core.JsonProcessingException; |
| 13 | import com.fasterxml.jackson.databind.ObjectMapper; | 11 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 14 | import org.slf4j.Logger; | 12 | import org.slf4j.Logger; |
| @@ -185,9 +183,6 @@ public class Contrast { | @@ -185,9 +183,6 @@ public class Contrast { | ||
| 185 | return result; | 183 | return result; |
| 186 | } | 184 | } |
| 187 | 185 | ||
| 188 | - | ||
| 189 | - | ||
| 190 | - | ||
| 191 | /** | 186 | /** |
| 192 | * @Description: 根据carid 获取票务数据 | 187 | * @Description: 根据carid 获取票务数据 |
| 193 | * @Param: allData交易记录 isOld是否是残余数据(上次未匹配到的数据) | 188 | * @Param: allData交易记录 isOld是否是残余数据(上次未匹配到的数据) |
| @@ -195,7 +190,7 @@ public class Contrast { | @@ -195,7 +190,7 @@ public class Contrast { | ||
| 195 | * @Author: YM | 190 | * @Author: YM |
| 196 | * @Date: 2021/10/13 | 191 | * @Date: 2021/10/13 |
| 197 | */ | 192 | */ |
| 198 | - public void filterCardList(List<Map> allData,Boolean isOld) { | 193 | + public void filterCardList(List<TJRLDB> allData, Boolean isOld) { |
| 199 | long start = System.currentTimeMillis(); | 194 | long start = System.currentTimeMillis(); |
| 200 | List<Map> driverCardList = getDriverCardList();//获取司机信息 | 195 | List<Map> driverCardList = getDriverCardList();//获取司机信息 |
| 201 | Map<String,List<Scheduling>> schedulingS =saticScheduleTask.getSchedulingS; | 196 | Map<String,List<Scheduling>> schedulingS =saticScheduleTask.getSchedulingS; |
| @@ -203,14 +198,12 @@ public class Contrast { | @@ -203,14 +198,12 @@ public class Contrast { | ||
| 203 | DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | 198 | DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| 204 | int b=0;//用于计算匹配成功的数量 | 199 | int b=0;//用于计算匹配成功的数量 |
| 205 | for (int i = 0; i < allData.size(); i++) { | 200 | for (int i = 0; i < allData.size(); i++) { |
| 206 | - Map data = allData.get(i); | ||
| 207 | - | 201 | + TJRLDB data = allData.get(i); |
| 208 | //通过司售卡找到司机 | 202 | //通过司售卡找到司机 |
| 209 | - String carId = data.get("TJRLDRVCRDID").toString().length()>8? | ||
| 210 | - data.get("TJRLDRVCRDID").toString().substring( data.get("TJRLDRVCRDID").toString().length()-8): | ||
| 211 | - data.get("TJRLDRVCRDID").toString(); | 203 | + String carId = data.getTJRLDRVCRDID().length()>8? |
| 204 | + data.getTJRLDRVCRDID().substring( data.getTJRLDRVCRDID().length()-8): | ||
| 205 | + data.getTJRLDRVCRDID(); | ||
| 212 | List<Map> collect = driverCardList.stream().filter(map -> map.get("cardno").equals(carId)).collect(Collectors.toList()); | 206 | List<Map> collect = driverCardList.stream().filter(map -> map.get("cardno").equals(carId)).collect(Collectors.toList()); |
| 213 | - | ||
| 214 | String mark=""; | 207 | String mark=""; |
| 215 | String jobCodes = ""; | 208 | String jobCodes = ""; |
| 216 | Boolean flag=false;//用来判断是否没有匹配成功 | 209 | Boolean flag=false;//用来判断是否没有匹配成功 |
| @@ -220,9 +213,8 @@ public class Contrast { | @@ -220,9 +213,8 @@ public class Contrast { | ||
| 220 | String personalName = collect.get(0).get("personalName").toString();//姓名 | 213 | String personalName = collect.get(0).get("personalName").toString();//姓名 |
| 221 | String[] arr=collect.get(0).get("jobCode").toString().split("-"); | 214 | String[] arr=collect.get(0).get("jobCode").toString().split("-"); |
| 222 | jobCodes =arr.length==0?collect.get(0).get("jobCode").toString():arr[arr.length-1];//工号 | 215 | jobCodes =arr.length==0?collect.get(0).get("jobCode").toString():arr[arr.length-1];//工号 |
| 223 | - String time=String.valueOf(data.get("TJRLRTIME"));//时间 | ||
| 224 | - String date=String.valueOf(data.get("TJRLRDATE"));//日期 | ||
| 225 | - | 216 | + String time=String.valueOf(data.getTJRLRTIME());//时间 |
| 217 | + String date=String.valueOf(data.getTJRLRDATE());//日期 | ||
| 226 | cardDate = LocalDateTime.parse(date+" "+time,dtf).toInstant(ZoneOffset.of("+8")).toEpochMilli(); //刷卡时间(时间戳) | 218 | cardDate = LocalDateTime.parse(date+" "+time,dtf).toInstant(ZoneOffset.of("+8")).toEpochMilli(); //刷卡时间(时间戳) |
| 227 | 219 | ||
| 228 | //通过司机姓名获得进出记录 | 220 | //通过司机姓名获得进出记录 |
| @@ -233,7 +225,6 @@ public class Contrast { | @@ -233,7 +225,6 @@ public class Contrast { | ||
| 233 | } | 225 | } |
| 234 | Scheduling scheduling = null; | 226 | Scheduling scheduling = null; |
| 235 | 227 | ||
| 236 | - | ||
| 237 | if(schedulingList1!=null){ | 228 | if(schedulingList1!=null){ |
| 238 | Collections.sort(schedulingList1, Comparator.comparing(Scheduling::getTs).reversed()); | 229 | Collections.sort(schedulingList1, Comparator.comparing(Scheduling::getTs).reversed()); |
| 239 | for (int i1 = 0; i1 < schedulingList1.size(); i1++) { | 230 | for (int i1 = 0; i1 < schedulingList1.size(); i1++) { |
| @@ -250,46 +241,43 @@ public class Contrast { | @@ -250,46 +241,43 @@ public class Contrast { | ||
| 250 | } | 241 | } |
| 251 | 242 | ||
| 252 | if (scheduling!=null) { | 243 | if (scheduling!=null) { |
| 253 | - data.put("STATION_FLAG", 1); | ||
| 254 | - data.put("TJRLUNITID", scheduling.getGs_name()); | ||
| 255 | - data.put("TJRLSTATID", scheduling.getXl_name()); | ||
| 256 | - data.put("ROAD_FORM_TYPE", scheduling.getBc_type()); | ||
| 257 | - data.put("UPDOWN", scheduling.getXl_dir()); | ||
| 258 | - data.put("BUS_CODE", scheduling.getCl_zbh()); | ||
| 259 | - data.put("BUS_PLATE", scheduling.getCar_plate()); | ||
| 260 | - data.put("ROAD_CODE", scheduling.getLp_name()); | ||
| 261 | - data.put("DEPART_NAME", scheduling.getQdz_name()); | ||
| 262 | - data.put("DEPART_CODE", scheduling.getQdz_code()); | ||
| 263 | - data.put("DEPART_ACTUAL_TIME", scheduling.getFcsj_actual()); | ||
| 264 | - data.put("REACH_NAME", scheduling.getZdz_name()); | ||
| 265 | - data.put("REACH_CODE", scheduling.getZdz_code()); | ||
| 266 | - data.put("REACH_ACTUAL_TIME", scheduling.getZdsj_actual()); | ||
| 267 | - | ||
| 268 | - | 244 | + data.setSTATION_FLAG("1"); |
| 245 | + data.setTJRLUNITID(scheduling.getGs_name()); | ||
| 246 | + data.setTJRLSTATID(scheduling.getXl_name()); | ||
| 247 | + data.setROAD_FORM_TYPE(scheduling.getBc_type()); | ||
| 248 | + data.setUPDOWN(scheduling.getXl_dir()); | ||
| 249 | + data.setBUS_CODE(scheduling.getCl_zbh()); | ||
| 250 | + data.setBUS_PLATE(scheduling.getCar_plate()); | ||
| 251 | + data.setROAD_CODE(scheduling.getLp_name()); | ||
| 252 | + data.setDEPART_NAME(scheduling.getQdz_name()); | ||
| 253 | + data.setDEPART_CODE(scheduling.getQdz_code()); | ||
| 254 | + data.setDEPART_ACTUAL_TIME(scheduling.getFcsj_actual()); | ||
| 255 | + data.setREACH_NAME(scheduling.getZdz_name()); | ||
| 256 | + data.setREACH_CODE(scheduling.getZdz_code()); | ||
| 257 | + data.setREACH_ACTUAL_TIME(scheduling.getZdsj_actual()); | ||
| 269 | if(scheduling.getStation_name()!=null){ | 258 | if(scheduling.getStation_name()!=null){ |
| 270 | - data.put("LEVELS_FLAG",1); | ||
| 271 | - data.put("LEVELS1",scheduling.getStation_route_code());//站点路由序号 | ||
| 272 | - data.put("LEVELS_NAME1",scheduling.getStation_name());//站点名 | ||
| 273 | - data.put("LEVELS1_CODE",scheduling.getStop_no());//站点编号 | 259 | + data.setLEVELS_FLAG("1"); |
| 260 | + data.setLEVELS1(scheduling.getStation_route_code());//站点路由序号 | ||
| 261 | + data.setLEVELS_NAME1(scheduling.getStation_name());//站点名 | ||
| 262 | + data.setLEVELS1_CODE(scheduling.getStop_no());//站点编号 | ||
| 274 | }else { | 263 | }else { |
| 275 | - data.put("LEVELS_FLAG",0); | 264 | + data.setLEVELS_FLAG("0"); |
| 276 | } | 265 | } |
| 277 | } else { | 266 | } else { |
| 278 | - data.put("STATION_FLAG", 0); | 267 | + data.setSTATION_FLAG("0"); |
| 279 | } | 268 | } |
| 280 | } | 269 | } |
| 281 | }else { | 270 | }else { |
| 282 | mark="未查到驾驶员 卡号:"+carId; | 271 | mark="未查到驾驶员 卡号:"+carId; |
| 283 | - data.put("STATION_FLAG", 0); | 272 | + data.setSTATION_FLAG("0"); |
| 284 | } | 273 | } |
| 285 | if(mark.length()==0 && !flag){ | 274 | if(mark.length()==0 && !flag){ |
| 286 | mark="未匹配到班次 "+jobCodes+"刷卡时间为:"+LocalDateTime.ofEpochSecond(cardDate/1000, 0, ZoneOffset.ofHours(8)); | 275 | mark="未匹配到班次 "+jobCodes+"刷卡时间为:"+LocalDateTime.ofEpochSecond(cardDate/1000, 0, ZoneOffset.ofHours(8)); |
| 287 | } | 276 | } |
| 288 | - data.put("MARK",mark); | ||
| 289 | - | 277 | + data.setMARK(mark); |
| 290 | //如果是新数据 没匹配到 去除这条记录 并放入缓存等到下次继续匹配 | 278 | //如果是新数据 没匹配到 去除这条记录 并放入缓存等到下次继续匹配 |
| 291 | if(!isOld && !flag){ | 279 | if(!isOld && !flag){ |
| 292 | - List<Map> m =saticScheduleTask.data; | 280 | + List<TJRLDB> m =saticScheduleTask.data; |
| 293 | m.add(data); | 281 | m.add(data); |
| 294 | allData.set(i,null); | 282 | allData.set(i,null); |
| 295 | 283 | ||
| @@ -298,7 +286,7 @@ public class Contrast { | @@ -298,7 +286,7 @@ public class Contrast { | ||
| 298 | int size=allData.size(); | 286 | int size=allData.size(); |
| 299 | allData.removeIf(Objects::isNull); | 287 | allData.removeIf(Objects::isNull); |
| 300 | //防止数据过多 分批插入 | 288 | //防止数据过多 分批插入 |
| 301 | - List<List<Map>> subList = getSubList(2000, allData); | 289 | + List<List<TJRLDB>> subList = getSubList(2000, allData); |
| 302 | if(!subList.isEmpty()){ | 290 | if(!subList.isEmpty()){ |
| 303 | subList.forEach(data->{ | 291 | subList.forEach(data->{ |
| 304 | if (!data.isEmpty()) { | 292 | if (!data.isEmpty()) { |
| @@ -307,13 +295,18 @@ public class Contrast { | @@ -307,13 +295,18 @@ public class Contrast { | ||
| 307 | }); | 295 | }); |
| 308 | } | 296 | } |
| 309 | 297 | ||
| 310 | - List<List<Map>> subList2 = getSubList(500, allData); | 298 | + List<List<TJRLDB>> subList2 = getSubList(500, allData); |
| 311 | if(!subList2.isEmpty()){ | 299 | if(!subList2.isEmpty()){ |
| 312 | subList2.forEach(data->{ | 300 | subList2.forEach(data->{ |
| 313 | if (!data.isEmpty()) { | 301 | if (!data.isEmpty()) { |
| 314 | Map<String, Object> map = new HashMap<>(); | 302 | Map<String, Object> map = new HashMap<>(); |
| 315 | map.put("datatype", "passengerflow"); | 303 | map.put("datatype", "passengerflow"); |
| 316 | - map.put("datas", data); | 304 | + List<TJRL> data2 =new ArrayList<>(); |
| 305 | + for (TJRLDB tjrldb : data) { | ||
| 306 | + TJRL tjrl= new TJRL(tjrldb); | ||
| 307 | + data2.add(tjrl); | ||
| 308 | + } | ||
| 309 | + map.put("datas", data2); | ||
| 317 | 310 | ||
| 318 | ObjectMapper mapper = new ObjectMapper(); | 311 | ObjectMapper mapper = new ObjectMapper(); |
| 319 | String json = null; | 312 | String json = null; |
| @@ -336,17 +329,14 @@ public class Contrast { | @@ -336,17 +329,14 @@ public class Contrast { | ||
| 336 | } | 329 | } |
| 337 | }); | 330 | }); |
| 338 | } | 331 | } |
| 339 | - | ||
| 340 | - | ||
| 341 | - | ||
| 342 | //如果是上次遗留的数据不管这是是否匹配到都清空 | 332 | //如果是上次遗留的数据不管这是是否匹配到都清空 |
| 343 | if(isOld){ | 333 | if(isOld){ |
| 344 | saticScheduleTask.data.clear(); | 334 | saticScheduleTask.data.clear(); |
| 345 | } | 335 | } |
| 346 | - | ||
| 347 | logger.warn("======匹配"+size+"条======匹配到"+b+"条=====耗时=="+(System.currentTimeMillis() - start)/1000 + "秒"); | 336 | logger.warn("======匹配"+size+"条======匹配到"+b+"条=====耗时=="+(System.currentTimeMillis() - start)/1000 + "秒"); |
| 348 | } | 337 | } |
| 349 | 338 | ||
| 339 | + | ||
| 350 | /** | 340 | /** |
| 351 | * @Description: 根据carid 获取票务数据 | 341 | * @Description: 根据carid 获取票务数据 |
| 352 | * @Param: allData交易记录 isOld是否是残余数据(上次未匹配到的数据) | 342 | * @Param: allData交易记录 isOld是否是残余数据(上次未匹配到的数据) |
| @@ -354,7 +344,7 @@ public class Contrast { | @@ -354,7 +344,7 @@ public class Contrast { | ||
| 354 | * @Author: YM | 344 | * @Author: YM |
| 355 | * @Date: 2021/10/13 | 345 | * @Date: 2021/10/13 |
| 356 | */ | 346 | */ |
| 357 | - public void filterCardListByDB(List<Map> allData,Boolean isOld) { | 347 | + public void filterCardListByDB(List<TJRLDB> allData,Boolean isOld) { |
| 358 | long start = System.currentTimeMillis(); | 348 | long start = System.currentTimeMillis(); |
| 359 | List<Map> driverCardList = getDriverCardList();//获取司机信息 | 349 | List<Map> driverCardList = getDriverCardList();//获取司机信息 |
| 360 | Map<String,List<Scheduling>> schedulingS =saticScheduleTask.getSchedulingS; | 350 | Map<String,List<Scheduling>> schedulingS =saticScheduleTask.getSchedulingS; |
| @@ -362,14 +352,12 @@ public class Contrast { | @@ -362,14 +352,12 @@ public class Contrast { | ||
| 362 | DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | 352 | DateTimeFormatter dtf=DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); |
| 363 | int b=0;//用于计算匹配成功的数量 | 353 | int b=0;//用于计算匹配成功的数量 |
| 364 | for (int i = 0; i < allData.size(); i++) { | 354 | for (int i = 0; i < allData.size(); i++) { |
| 365 | - Map data = allData.get(i); | ||
| 366 | - | ||
| 367 | - //通过卡号找到司机 | ||
| 368 | - String carId = data.get("TJRLDRVCRDID").toString().length()>8? | ||
| 369 | - data.get("TJRLDRVCRDID").toString().substring( data.get("TJRLDRVCRDID").toString().length()-8): | ||
| 370 | - data.get("TJRLDRVCRDID").toString();//交通卡号 | 355 | + TJRLDB data = allData.get(i); |
| 356 | + //通过司售卡找到司机 | ||
| 357 | + String carId = data.getTJRLDRVCRDID().length()>8? | ||
| 358 | + data.getTJRLDRVCRDID().substring( data.getTJRLDRVCRDID().length()-8): | ||
| 359 | + data.getTJRLDRVCRDID(); | ||
| 371 | List<Map> collect = driverCardList.stream().filter(map -> map.get("cardno").equals(carId)).collect(Collectors.toList()); | 360 | List<Map> collect = driverCardList.stream().filter(map -> map.get("cardno").equals(carId)).collect(Collectors.toList()); |
| 372 | - | ||
| 373 | String mark=""; | 361 | String mark=""; |
| 374 | String jobCodes = ""; | 362 | String jobCodes = ""; |
| 375 | Boolean flag=false;//用来判断是否没有匹配成功 | 363 | Boolean flag=false;//用来判断是否没有匹配成功 |
| @@ -379,9 +367,8 @@ public class Contrast { | @@ -379,9 +367,8 @@ public class Contrast { | ||
| 379 | String personalName = collect.get(0).get("personalName").toString();//姓名 | 367 | String personalName = collect.get(0).get("personalName").toString();//姓名 |
| 380 | String[] arr=collect.get(0).get("jobCode").toString().split("-"); | 368 | String[] arr=collect.get(0).get("jobCode").toString().split("-"); |
| 381 | jobCodes =arr.length==0?collect.get(0).get("jobCode").toString():arr[arr.length-1];//工号 | 369 | jobCodes =arr.length==0?collect.get(0).get("jobCode").toString():arr[arr.length-1];//工号 |
| 382 | - String time=String.valueOf(data.get("TJRLRTIME"));//时间 | ||
| 383 | - String date=String.valueOf(data.get("TJRLRDATE"));//日期 | ||
| 384 | - | 370 | + String time=String.valueOf(data.getTJRLRTIME());//时间 |
| 371 | + String date=String.valueOf(data.getTJRLRDATE());//日期 | ||
| 385 | cardDate = LocalDateTime.parse(date+" "+time,dtf).toInstant(ZoneOffset.of("+8")).toEpochMilli(); //刷卡时间(时间戳) | 372 | cardDate = LocalDateTime.parse(date+" "+time,dtf).toInstant(ZoneOffset.of("+8")).toEpochMilli(); //刷卡时间(时间戳) |
| 386 | 373 | ||
| 387 | //通过司机姓名获得进出记录 | 374 | //通过司机姓名获得进出记录 |
| @@ -392,7 +379,6 @@ public class Contrast { | @@ -392,7 +379,6 @@ public class Contrast { | ||
| 392 | } | 379 | } |
| 393 | Scheduling scheduling = null; | 380 | Scheduling scheduling = null; |
| 394 | 381 | ||
| 395 | - | ||
| 396 | if(schedulingList1!=null){ | 382 | if(schedulingList1!=null){ |
| 397 | Collections.sort(schedulingList1, Comparator.comparing(Scheduling::getTs).reversed()); | 383 | Collections.sort(schedulingList1, Comparator.comparing(Scheduling::getTs).reversed()); |
| 398 | for (int i1 = 0; i1 < schedulingList1.size(); i1++) { | 384 | for (int i1 = 0; i1 < schedulingList1.size(); i1++) { |
| @@ -409,55 +395,52 @@ public class Contrast { | @@ -409,55 +395,52 @@ public class Contrast { | ||
| 409 | } | 395 | } |
| 410 | 396 | ||
| 411 | if (scheduling!=null) { | 397 | if (scheduling!=null) { |
| 412 | - data.put("STATION_FLAG", 1); | ||
| 413 | - data.put("TJRLUNITID", scheduling.getGs_name()); | ||
| 414 | - data.put("TJRLSTATID", scheduling.getXl_name()); | ||
| 415 | - data.put("ROAD_FORM_TYPE", scheduling.getBc_type()); | ||
| 416 | - data.put("UPDOWN", scheduling.getXl_dir()); | ||
| 417 | - data.put("BUS_CODE", scheduling.getCl_zbh()); | ||
| 418 | - data.put("BUS_PLATE", scheduling.getCar_plate()); | ||
| 419 | - data.put("ROAD_CODE", scheduling.getLp_name()); | ||
| 420 | - data.put("DEPART_NAME", scheduling.getQdz_name()); | ||
| 421 | - data.put("DEPART_CODE", scheduling.getQdz_code()); | ||
| 422 | - data.put("DEPART_ACTUAL_TIME", scheduling.getFcsj_actual()); | ||
| 423 | - data.put("REACH_NAME", scheduling.getZdz_name()); | ||
| 424 | - data.put("REACH_CODE", scheduling.getZdz_code()); | ||
| 425 | - data.put("REACH_ACTUAL_TIME", scheduling.getZdsj_actual()); | ||
| 426 | - | ||
| 427 | - | 398 | + data.setSTATION_FLAG("1"); |
| 399 | + data.setTJRLUNITID(scheduling.getGs_name()); | ||
| 400 | + data.setTJRLSTATID(scheduling.getXl_name()); | ||
| 401 | + data.setROAD_FORM_TYPE(scheduling.getBc_type()); | ||
| 402 | + data.setUPDOWN(scheduling.getXl_dir()); | ||
| 403 | + data.setBUS_CODE(scheduling.getCl_zbh()); | ||
| 404 | + data.setBUS_PLATE(scheduling.getCar_plate()); | ||
| 405 | + data.setROAD_CODE(scheduling.getLp_name()); | ||
| 406 | + data.setDEPART_NAME(scheduling.getQdz_name()); | ||
| 407 | + data.setDEPART_CODE(scheduling.getQdz_code()); | ||
| 408 | + data.setDEPART_ACTUAL_TIME(scheduling.getFcsj_actual()); | ||
| 409 | + data.setREACH_NAME(scheduling.getZdz_name()); | ||
| 410 | + data.setREACH_CODE(scheduling.getZdz_code()); | ||
| 411 | + data.setREACH_ACTUAL_TIME(scheduling.getZdsj_actual()); | ||
| 428 | if(scheduling.getStation_name()!=null){ | 412 | if(scheduling.getStation_name()!=null){ |
| 429 | - data.put("LEVELS_FLAG",1); | ||
| 430 | - data.put("LEVELS1",scheduling.getStation_route_code());//站点路由序号 | ||
| 431 | - data.put("LEVELS_NAME1",scheduling.getStation_name());//站点名 | ||
| 432 | - data.put("LEVELS1_CODE",scheduling.getStop_no());//站点编号 | 413 | + data.setLEVELS_FLAG("1"); |
| 414 | + data.setLEVELS1(scheduling.getStation_route_code());//站点路由序号 | ||
| 415 | + data.setLEVELS_NAME1(scheduling.getStation_name());//站点名 | ||
| 416 | + data.setLEVELS1_CODE(scheduling.getStop_no());//站点编号 | ||
| 433 | }else { | 417 | }else { |
| 434 | - data.put("LEVELS_FLAG",0); | 418 | + data.setLEVELS_FLAG("0"); |
| 435 | } | 419 | } |
| 436 | } else { | 420 | } else { |
| 437 | - data.put("STATION_FLAG", 0); | 421 | + data.setSTATION_FLAG("0"); |
| 438 | } | 422 | } |
| 439 | } | 423 | } |
| 440 | }else { | 424 | }else { |
| 441 | mark="未查到驾驶员 卡号:"+carId; | 425 | mark="未查到驾驶员 卡号:"+carId; |
| 442 | - data.put("STATION_FLAG", 0); | 426 | + data.setSTATION_FLAG("0"); |
| 443 | } | 427 | } |
| 444 | if(mark.length()==0 && !flag){ | 428 | if(mark.length()==0 && !flag){ |
| 445 | mark="未匹配到班次 "+jobCodes+"刷卡时间为:"+LocalDateTime.ofEpochSecond(cardDate/1000, 0, ZoneOffset.ofHours(8)); | 429 | mark="未匹配到班次 "+jobCodes+"刷卡时间为:"+LocalDateTime.ofEpochSecond(cardDate/1000, 0, ZoneOffset.ofHours(8)); |
| 446 | } | 430 | } |
| 447 | - data.put("MARK",mark); | ||
| 448 | - | 431 | + data.setMARK(mark); |
| 449 | //如果是新数据 没匹配到 去除这条记录 并放入缓存等到下次继续匹配 | 432 | //如果是新数据 没匹配到 去除这条记录 并放入缓存等到下次继续匹配 |
| 450 | if(!isOld && !flag){ | 433 | if(!isOld && !flag){ |
| 451 | - List<Map> m =saticScheduleTask.data; | 434 | + List<TJRLDB> m =saticScheduleTask.data; |
| 452 | m.add(data); | 435 | m.add(data); |
| 453 | allData.set(i,null); | 436 | allData.set(i,null); |
| 454 | 437 | ||
| 455 | } | 438 | } |
| 456 | } | 439 | } |
| 457 | int size=allData.size(); | 440 | int size=allData.size(); |
| 458 | -// allData.removeIf(Objects::isNull); | 441 | + allData.removeIf(Objects::isNull); |
| 459 | //防止数据过多 分批插入 | 442 | //防止数据过多 分批插入 |
| 460 | - List<List<Map>> subList = getSubList(8000, allData); | 443 | + List<List<TJRLDB>> subList = getSubList(2000, allData); |
| 461 | if(!subList.isEmpty()){ | 444 | if(!subList.isEmpty()){ |
| 462 | subList.forEach(data->{ | 445 | subList.forEach(data->{ |
| 463 | if (!data.isEmpty()) { | 446 | if (!data.isEmpty()) { |
| @@ -466,13 +449,14 @@ public class Contrast { | @@ -466,13 +449,14 @@ public class Contrast { | ||
| 466 | }); | 449 | }); |
| 467 | } | 450 | } |
| 468 | 451 | ||
| 469 | - List<List<Map>> subList2 = getSubList(500, allData); | 452 | + List<List<TJRLDB>> subList2 = getSubList(500, allData); |
| 470 | if(!subList2.isEmpty()){ | 453 | if(!subList2.isEmpty()){ |
| 471 | subList2.forEach(data->{ | 454 | subList2.forEach(data->{ |
| 472 | if (!data.isEmpty()) { | 455 | if (!data.isEmpty()) { |
| 473 | Map<String, Object> map = new HashMap<>(); | 456 | Map<String, Object> map = new HashMap<>(); |
| 474 | map.put("datatype", "passengerflow"); | 457 | map.put("datatype", "passengerflow"); |
| 475 | - map.put("datas", data); | 458 | + TJRL tjrl= (TJRL) data; |
| 459 | + map.put("datas", tjrl); | ||
| 476 | 460 | ||
| 477 | ObjectMapper mapper = new ObjectMapper(); | 461 | ObjectMapper mapper = new ObjectMapper(); |
| 478 | String json = null; | 462 | String json = null; |
| @@ -495,14 +479,10 @@ public class Contrast { | @@ -495,14 +479,10 @@ public class Contrast { | ||
| 495 | } | 479 | } |
| 496 | }); | 480 | }); |
| 497 | } | 481 | } |
| 498 | - | ||
| 499 | - | ||
| 500 | - | ||
| 501 | //如果是上次遗留的数据不管这是是否匹配到都清空 | 482 | //如果是上次遗留的数据不管这是是否匹配到都清空 |
| 502 | if(isOld){ | 483 | if(isOld){ |
| 503 | saticScheduleTask.data.clear(); | 484 | saticScheduleTask.data.clear(); |
| 504 | } | 485 | } |
| 505 | - | ||
| 506 | logger.warn("======匹配"+size+"条======匹配到"+b+"条=====耗时=="+(System.currentTimeMillis() - start)/1000 + "秒"); | 486 | logger.warn("======匹配"+size+"条======匹配到"+b+"条=====耗时=="+(System.currentTimeMillis() - start)/1000 + "秒"); |
| 507 | } | 487 | } |
| 508 | 488 | ||
| @@ -541,21 +521,21 @@ public class Contrast { | @@ -541,21 +521,21 @@ public class Contrast { | ||
| 541 | 521 | ||
| 542 | 522 | ||
| 543 | public void filterCardListByDB(Map<String,Object> params) throws Exception{ | 523 | public void filterCardListByDB(Map<String,Object> params) throws Exception{ |
| 544 | - List<Map> records=siteMapper1.getRecords(params); | ||
| 545 | - for (Map record : records) { | ||
| 546 | - String date=record.get("TJRLRDATE")+" "+String.format("%06d", Integer.parseInt(record.get("TJRLRTIME").toString())); | 524 | + List<TJRLDB> records=siteMapper1.getRecords(params); |
| 525 | + for (TJRL record : records) { | ||
| 526 | + String date=record.getTJRLRDATE()+" "+String.format("%06d", Integer.parseInt(record.getTJRLRTIME())); | ||
| 547 | String s=this.getTransTime(date); | 527 | String s=this.getTransTime(date); |
| 548 | - record.put("TJRLRDATE",s.split(" ")[0]); | ||
| 549 | - record.put("TJRLRTIME",s.split(" ")[1]); | 528 | + record.setTJRLRDATE(s.split(" ")[0]); |
| 529 | + record.setTJRLRTIME(s.split(" ")[1]); | ||
| 550 | } | 530 | } |
| 551 | filterCardListByDB(records,false); | 531 | filterCardListByDB(records,false); |
| 552 | } | 532 | } |
| 553 | 533 | ||
| 554 | - public List<List<Map>> getSubList(int length, List<Map> list){ | 534 | + public List<List<TJRLDB>> getSubList(int length, List<TJRLDB> list){ |
| 555 | int size = list.size(); | 535 | int size = list.size(); |
| 556 | int temp = size / length + 1; | 536 | int temp = size / length + 1; |
| 557 | boolean result = size % length == 0; | 537 | boolean result = size % length == 0; |
| 558 | - List<List<Map>> subList = new ArrayList<>(); | 538 | + List<List<TJRLDB>> subList = new ArrayList<>(); |
| 559 | for (int i = 0; i < temp; i++) { | 539 | for (int i = 0; i < temp; i++) { |
| 560 | if (i == temp - 1) { | 540 | if (i == temp - 1) { |
| 561 | if (result) { | 541 | if (result) { |
src/main/resources/application.properties
| @@ -37,7 +37,7 @@ spring.kafka.producer.properties.max.request.size=20971520 | @@ -37,7 +37,7 @@ spring.kafka.producer.properties.max.request.size=20971520 | ||
| 37 | 37 | ||
| 38 | logging.path=/home/demo/log | 38 | logging.path=/home/demo/log |
| 39 | 39 | ||
| 40 | -#?? | 40 | + |
| 41 | #spring.datasource.db1.jdbc-url=jdbc:mysql://192.168.168.240:3306/pd_control?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC | 41 | #spring.datasource.db1.jdbc-url=jdbc:mysql://192.168.168.240:3306/pd_control?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC |
| 42 | #spring.datasource.db1.username=root | 42 | #spring.datasource.db1.username=root |
| 43 | #spring.datasource.db1.password=root2jsp | 43 | #spring.datasource.db1.password=root2jsp |
| @@ -68,6 +68,6 @@ logging.path=/home/demo/log | @@ -68,6 +68,6 @@ logging.path=/home/demo/log | ||
| 68 | #spring.kafka.producer.buffer-memory=33554432 | 68 | #spring.kafka.producer.buffer-memory=33554432 |
| 69 | #spring.kafka.producer.acks=all | 69 | #spring.kafka.producer.acks=all |
| 70 | #spring.kafka.producer.properties.max.request.size=10485760 | 70 | #spring.kafka.producer.properties.max.request.size=10485760 |
| 71 | -# | ||
| 72 | -# | 71 | + |
| 72 | + | ||
| 73 | #logging.path=E:/log | 73 | #logging.path=E:/log |
| 74 | \ No newline at end of file | 74 | \ No newline at end of file |
src/main/resources/mapping/db1/Site-mapper1.xml
| @@ -62,7 +62,7 @@ | @@ -62,7 +62,7 @@ | ||
| 62 | from control.bsth_c_stationroute WHERE destroy=0 ORDER BY station_code,directions,line_code | 62 | from control.bsth_c_stationroute WHERE destroy=0 ORDER BY station_code,directions,line_code |
| 63 | </select> | 63 | </select> |
| 64 | 64 | ||
| 65 | - <select id="getRecords" resultType="map"> | 65 | + <select id="getRecords" resultType="com.example.demo.model.TJRLDB"> |
| 66 | SELECT * | 66 | SELECT * |
| 67 | from ${table} where TJRLRDATE >= '${start}' and TJRLRDATE < '${end}' | 67 | from ${table} where TJRLRDATE >= '${start}' and TJRLRDATE < '${end}' |
| 68 | </select> | 68 | </select> |