正在显示
11 个修改的文件
包含
171 行增加
和
35 行删除
1 | package com.tianbo.analysis.bean; | 1 | package com.tianbo.analysis.bean; |
2 | 2 | ||
3 | +import com.netflix.discovery.converters.Auto; | ||
3 | import com.tianbo.analysis.dao.*; | 4 | import com.tianbo.analysis.dao.*; |
5 | +import com.tianbo.analysis.service.CustomMessageService; | ||
4 | import com.tianbo.analysis.service.SendLogService; | 6 | import com.tianbo.analysis.service.SendLogService; |
5 | import org.springframework.beans.factory.annotation.Autowired; | 7 | import org.springframework.beans.factory.annotation.Autowired; |
6 | import org.springframework.stereotype.Component; | 8 | import org.springframework.stereotype.Component; |
@@ -48,6 +50,12 @@ public class WlptBaseModel { | @@ -48,6 +50,12 @@ public class WlptBaseModel { | ||
48 | @Autowired | 50 | @Autowired |
49 | public TALLYSECONDARYMapper tallysecondaryMapper; | 51 | public TALLYSECONDARYMapper tallysecondaryMapper; |
50 | 52 | ||
53 | + @Autowired | ||
54 | + public CUSTOMSMESSAGEMapper customsmessageMapper; | ||
55 | + | ||
56 | + @Autowired | ||
57 | + public CustomMessageService customMessageService; | ||
58 | + | ||
51 | public WlptBaseModel() { | 59 | public WlptBaseModel() { |
52 | //处理多线程时 springboot 无法注入bean的问题 | 60 | //处理多线程时 springboot 无法注入bean的问题 |
53 | if (allocatearrivalMapper==null){ | 61 | if (allocatearrivalMapper==null){ |
@@ -89,6 +97,13 @@ public class WlptBaseModel { | @@ -89,6 +97,13 @@ public class WlptBaseModel { | ||
89 | if(tallysecondaryMapper==null){ | 97 | if(tallysecondaryMapper==null){ |
90 | tallysecondaryMapper = SpringBeanUtitl.getBean(TALLYSECONDARYMapper.class); | 98 | tallysecondaryMapper = SpringBeanUtitl.getBean(TALLYSECONDARYMapper.class); |
91 | } | 99 | } |
100 | + if(customsmessageMapper==null){ | ||
101 | + customsmessageMapper = SpringBeanUtitl.getBean(CUSTOMSMESSAGEMapper.class); | ||
102 | + } | ||
103 | + if(customMessageService==null){ | ||
104 | + customMessageService = SpringBeanUtitl.getBean(CustomMessageService.class); | ||
105 | + } | ||
106 | + | ||
92 | } | 107 | } |
93 | 108 | ||
94 | public static void init(){ | 109 | public static void init(){ |
1 | package com.tianbo.analysis.dao; | 1 | package com.tianbo.analysis.dao; |
2 | 2 | ||
3 | +import com.tianbo.analysis.model.CUSTOMSMESSAGE; | ||
3 | import com.tianbo.analysis.model.CUSTOMSMESSAGEWithBLOBs; | 4 | import com.tianbo.analysis.model.CUSTOMSMESSAGEWithBLOBs; |
4 | 5 | ||
6 | +import java.util.List; | ||
7 | + | ||
5 | public interface CUSTOMSMESSAGEMapper { | 8 | public interface CUSTOMSMESSAGEMapper { |
6 | int insert(CUSTOMSMESSAGEWithBLOBs record); | 9 | int insert(CUSTOMSMESSAGEWithBLOBs record); |
7 | 10 | ||
8 | int insertSelective(CUSTOMSMESSAGEWithBLOBs record); | 11 | int insertSelective(CUSTOMSMESSAGEWithBLOBs record); |
9 | 12 | ||
10 | - CUSTOMSMESSAGEWithBLOBs selectMessage(String messageId); | 13 | + List<CUSTOMSMESSAGEWithBLOBs> selectMessage(String messageId); |
11 | 14 | ||
12 | - int updateMessage(CUSTOMSMESSAGEWithBLOBs record); | 15 | + int updateMessageByMessageid(CUSTOMSMESSAGE record); |
13 | } | 16 | } |
1 | package com.tianbo.analysis.handle; | 1 | package com.tianbo.analysis.handle; |
2 | 2 | ||
3 | import com.tianbo.analysis.model.*; | 3 | import com.tianbo.analysis.model.*; |
4 | +import com.tianbo.analysis.service.CustomMessageService; | ||
4 | import com.tianbo.analysis.tools.AWBTools; | 5 | import com.tianbo.analysis.tools.AWBTools; |
5 | import com.tianbo.util.Date.DateUtil; | 6 | import com.tianbo.util.Date.DateUtil; |
6 | import com.tianbo.util.XML.XMLXPath; | 7 | import com.tianbo.util.XML.XMLXPath; |
@@ -43,6 +44,7 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -43,6 +44,7 @@ public class CustomXmlHandleThread implements Runnable{ | ||
43 | private String errBakDir; | 44 | private String errBakDir; |
44 | 45 | ||
45 | private File xmlfile; | 46 | private File xmlfile; |
47 | + | ||
46 | private static CustomXmlHandleThread customXmlHandle; | 48 | private static CustomXmlHandleThread customXmlHandle; |
47 | //海关新舱单回执报头 | 49 | //海关新舱单回执报头 |
48 | public final static String MessageID = "//Manifest/Head/MessageID"; | 50 | public final static String MessageID = "//Manifest/Head/MessageID"; |
@@ -60,8 +62,8 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -60,8 +62,8 @@ public class CustomXmlHandleThread implements Runnable{ | ||
60 | public final static String JourneyID = "//Manifest/Response/BorderTransportMeans/JourneyID"; | 62 | public final static String JourneyID = "//Manifest/Response/BorderTransportMeans/JourneyID"; |
61 | public final static String WaybillMaster = "//Manifest/Response/Consignment/TransportContractDocument/ID"; | 63 | public final static String WaybillMaster = "//Manifest/Response/Consignment/TransportContractDocument/ID"; |
62 | public final static String WaybillSecond = "//Manifest/Response/Consignment/AssociatedTransportDocument/ID"; | 64 | public final static String WaybillSecond = "//Manifest/Response/Consignment/AssociatedTransportDocument/ID"; |
63 | - public final static String ResponseCode = "//Manifest/Response/Consignment/ResponseType/Code"; | ||
64 | - public final static String ResponseText = "//Manifest/Response/Consignment/ResponseType/Text"; | 65 | + public final static String ResponseCode = "//ResponseType/Code"; |
66 | + public final static String ResponseText = "//ResponseType/Text"; | ||
65 | 67 | ||
66 | /** | 68 | /** |
67 | * 海关国际转运业务回执报体 | 69 | * 海关国际转运业务回执报体 |
@@ -70,8 +72,10 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -70,8 +72,10 @@ public class CustomXmlHandleThread implements Runnable{ | ||
70 | public final static String ImportWaybillMaster = "//Manifest/Response/ImportInformation/Consignment/TransportContractDocument/ID"; | 72 | public final static String ImportWaybillMaster = "//Manifest/Response/ImportInformation/Consignment/TransportContractDocument/ID"; |
71 | public final static String ExportJourneyID = "//Manifest/Response/ExportInformation/BorderTransportMeans/JourneyID"; | 73 | public final static String ExportJourneyID = "//Manifest/Response/ExportInformation/BorderTransportMeans/JourneyID"; |
72 | public final static String ExportWaybillMaster = "//Manifest/Response/ExportInformation/Consignment/TransportContractDocument/ID"; | 74 | public final static String ExportWaybillMaster = "//Manifest/Response/ExportInformation/Consignment/TransportContractDocument/ID"; |
73 | - public final static String TransResponseCode = "//Manifest/Response/ResponseType/Code"; | ||
74 | - public final static String TransResponseText = "//Manifest/Response/ResponseType/Text"; | 75 | +// public final static String TransResponseCode = "//Manifest/Response/ResponseType/Code"; |
76 | +// public final static String TransResponseText = "//Manifest/Response/ResponseType/Text"; | ||
77 | + public final static String TransResponseCode = "//ResponseType/Code"; | ||
78 | + public final static String TransResponseText = "//ResponseType/Text"; | ||
75 | 79 | ||
76 | 80 | ||
77 | //通过@PostConstruct实现初始化bean之前进行的操作,解决service调用空指针问题 | 81 | //通过@PostConstruct实现初始化bean之前进行的操作,解决service调用空指针问题 |
@@ -96,7 +100,6 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -96,7 +100,6 @@ public class CustomXmlHandleThread implements Runnable{ | ||
96 | //操作成功,则转移剪切解析文件到备份目录,否则转移到error目录备份 | 100 | //操作成功,则转移剪切解析文件到备份目录,否则转移到error目录备份 |
97 | if(i>0){ | 101 | if(i>0){ |
98 | File bakupDirectory = new File(backdireByDay); | 102 | File bakupDirectory = new File(backdireByDay); |
99 | - //复制一份到转发目录 | ||
100 | //解析成功备份一份到备份目录 | 103 | //解析成功备份一份到备份目录 |
101 | FileUtils.moveFileToDirectory(xmlfile,bakupDirectory,true); | 104 | FileUtils.moveFileToDirectory(xmlfile,bakupDirectory,true); |
102 | }else { | 105 | }else { |
@@ -113,7 +116,6 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -113,7 +116,6 @@ public class CustomXmlHandleThread implements Runnable{ | ||
113 | log.info("线程:{}结束",xmlfile.getName()); | 116 | log.info("线程:{}结束",xmlfile.getName()); |
114 | latch.countDown(); | 117 | latch.countDown(); |
115 | log.info("剩余线程数量{}",latch.getCount()); | 118 | log.info("剩余线程数量{}",latch.getCount()); |
116 | - | ||
117 | } | 119 | } |
118 | /** | 120 | /** |
119 | * | 121 | * |
@@ -132,24 +134,14 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -132,24 +134,14 @@ public class CustomXmlHandleThread implements Runnable{ | ||
132 | Document document = saxReader.read(xmlfile); | 134 | Document document = saxReader.read(xmlfile); |
133 | Element contentRoot = document.getRootElement(); | 135 | Element contentRoot = document.getRootElement(); |
134 | 136 | ||
135 | - String flightNo = ""; | ||
136 | - String flightDate = ""; | 137 | + String flightNo = "UNKONW"; |
138 | + String flightDate = "20101010"; | ||
137 | 139 | ||
138 | //开始解析 | 140 | //开始解析 |
139 | String msgType = XMLXPath.getSingleValueByPath(document,MessageType); | 141 | String msgType = XMLXPath.getSingleValueByPath(document,MessageType); |
140 | String journeyid = XMLXPath.getSingleValueByPath(document,JourneyID); | 142 | String journeyid = XMLXPath.getSingleValueByPath(document,JourneyID); |
141 | // XMLXPath.getSingleValueByPath(document, ) | 143 | // XMLXPath.getSingleValueByPath(document, ) |
142 | 144 | ||
143 | - if(!StringUtils.isEmpty(journeyid)){ | ||
144 | - | ||
145 | - String[] flightList = journeyid.split("/"); | ||
146 | - if(flightList.length > 0){ | ||
147 | - flightNo = flightList[0]; | ||
148 | - flightDate = flightList[1]; | ||
149 | - } | ||
150 | - | ||
151 | - | ||
152 | - } | ||
153 | 145 | ||
154 | String awbA = XMLXPath.getSingleValueByPath(document,WaybillMaster); | 146 | String awbA = XMLXPath.getSingleValueByPath(document,WaybillMaster); |
155 | //全格式的分单 如 17212345678_ADBD | 147 | //全格式的分单 如 17212345678_ADBD |
@@ -163,6 +155,8 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -163,6 +155,8 @@ public class CustomXmlHandleThread implements Runnable{ | ||
163 | String version = XMLXPath.getSingleValueByPath(document,Version); | 155 | String version = XMLXPath.getSingleValueByPath(document,Version); |
164 | String functionCode = XMLXPath.getSingleValueByPath(document,FunctionCode); | 156 | String functionCode = XMLXPath.getSingleValueByPath(document,FunctionCode); |
165 | 157 | ||
158 | + | ||
159 | + | ||
166 | CustomReception customReception = new CustomReception( msgType, | 160 | CustomReception customReception = new CustomReception( msgType, |
167 | flightNo, | 161 | flightNo, |
168 | flightDate, | 162 | flightDate, |
@@ -176,6 +170,25 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -176,6 +170,25 @@ public class CustomXmlHandleThread implements Runnable{ | ||
176 | reciveId, | 170 | reciveId, |
177 | version, | 171 | version, |
178 | functionCode); | 172 | functionCode); |
173 | + | ||
174 | + /** | ||
175 | + * 如果回执中没有携带航班信息节点,说明是出错报文 | ||
176 | + * 到发送日志表根据messageid 找到相应的发送日志报文的航班及运单信息,再进行解析 | ||
177 | + */ | ||
178 | + if(!StringUtils.isEmpty(journeyid)){ | ||
179 | + | ||
180 | + String[] flightList = journeyid.split("/"); | ||
181 | + if(flightList.length > 0){ | ||
182 | + flightNo = flightList[0]; | ||
183 | + flightDate = flightList[1]; | ||
184 | + customReception.setFlightNo(flightNo); | ||
185 | + customReception.setFlightDate(flightDate); | ||
186 | + } | ||
187 | + }else { | ||
188 | + CUSTOMSMESSAGE customsmessage = new CUSTOMSMESSAGE(); | ||
189 | + customReception = customsmessage.getWaybillInfoByCutomResponse(customReception); | ||
190 | + } | ||
191 | + | ||
179 | switch (msgType){ | 192 | switch (msgType){ |
180 | case "MT9999": | 193 | case "MT9999": |
181 | ORIGINMANIFESTMASTER originmanifestmaster = new ORIGINMANIFESTMASTER(customReception); | 194 | ORIGINMANIFESTMASTER originmanifestmaster = new ORIGINMANIFESTMASTER(customReception); |
@@ -254,6 +267,7 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -254,6 +267,7 @@ public class CustomXmlHandleThread implements Runnable{ | ||
254 | 267 | ||
255 | } | 268 | } |
256 | 269 | ||
270 | + updateCustomMessage(customReception); | ||
257 | return i; | 271 | return i; |
258 | 272 | ||
259 | } | 273 | } |
@@ -268,7 +282,7 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -268,7 +282,7 @@ public class CustomXmlHandleThread implements Runnable{ | ||
268 | 282 | ||
269 | String importJourneyID = XMLXPath.getSingleValueByPath(document,ImportJourneyID); | 283 | String importJourneyID = XMLXPath.getSingleValueByPath(document,ImportJourneyID); |
270 | String importFlightNo = "UNKONW"; | 284 | String importFlightNo = "UNKONW"; |
271 | - String importFlightDate = "00000000"; | 285 | + String importFlightDate = "20101010"; |
272 | if(!StringUtils.isEmpty(importJourneyID)){ | 286 | if(!StringUtils.isEmpty(importJourneyID)){ |
273 | importFlightNo = AWBTools.splitFlightAndDate(importJourneyID)[0]; | 287 | importFlightNo = AWBTools.splitFlightAndDate(importJourneyID)[0]; |
274 | importFlightDate = AWBTools.splitFlightAndDate(importJourneyID)[1]; | 288 | importFlightDate = AWBTools.splitFlightAndDate(importJourneyID)[1]; |
@@ -298,6 +312,11 @@ public class CustomXmlHandleThread implements Runnable{ | @@ -298,6 +312,11 @@ public class CustomXmlHandleThread implements Runnable{ | ||
298 | 312 | ||
299 | } | 313 | } |
300 | 314 | ||
315 | + private int updateCustomMessage(CustomReception customReception){ | ||
316 | + CUSTOMSMESSAGE customsmessage = new CUSTOMSMESSAGE(customReception); | ||
317 | + return customsmessage.updateMessageByMessageid(); | ||
318 | + } | ||
319 | + | ||
301 | private void errBak(File file){ | 320 | private void errBak(File file){ |
302 | try { | 321 | try { |
303 | String today = DateUtil.getTodayBy_yyyyMMdd(); | 322 | String today = DateUtil.getTodayBy_yyyyMMdd(); |
1 | package com.tianbo.analysis.model; | 1 | package com.tianbo.analysis.model; |
2 | 2 | ||
3 | +import com.tianbo.analysis.bean.WlptBaseModel; | ||
4 | +import com.tianbo.util.Date.DateUtil; | ||
5 | +import lombok.Data; | ||
6 | +import lombok.extern.slf4j.Slf4j; | ||
7 | + | ||
3 | import java.math.BigDecimal; | 8 | import java.math.BigDecimal; |
4 | import java.util.Date; | 9 | import java.util.Date; |
5 | 10 | ||
6 | -public class CUSTOMSMESSAGE { | 11 | +@Data |
12 | +@Slf4j | ||
13 | +public class CUSTOMSMESSAGE extends WlptBaseModel { | ||
7 | private String autoid; | 14 | private String autoid; |
8 | 15 | ||
9 | private String messageid; | 16 | private String messageid; |
@@ -183,4 +190,31 @@ public class CUSTOMSMESSAGE { | @@ -183,4 +190,31 @@ public class CUSTOMSMESSAGE { | ||
183 | public void setCreatetime(Date createtime) { | 190 | public void setCreatetime(Date createtime) { |
184 | this.createtime = createtime; | 191 | this.createtime = createtime; |
185 | } | 192 | } |
193 | + | ||
194 | + public CUSTOMSMESSAGE(){ | ||
195 | + | ||
196 | + } | ||
197 | + public CUSTOMSMESSAGE(CustomReception customReception) { | ||
198 | + this.messageid = customReception.getMessageID(); | ||
199 | + this.messagetype = customReception.getMessageType(); | ||
200 | + this.receivetime = new Date(); | ||
201 | + this.flightno = customReception.getFlightNo(); | ||
202 | + this.flightdate = DateUtil.formatByyyyyMMdd(customReception.getFlightDate()); | ||
203 | + this.waybillnomaster = customReception.getWayBillMaster(); | ||
204 | + this.waybillnosecondary = customReception.getWayBillSecond(); | ||
205 | + this.responsecode = customReception.getResponseCode(); | ||
206 | + this.responsetext = customReception.getResponseText(); | ||
207 | + this.messagestatus = "3"; | ||
208 | + } | ||
209 | + | ||
210 | + public CustomReception getWaybillInfoByCutomResponse(CustomReception customReception){ | ||
211 | + return customMessageService.getWaybillInfoByCutomResponse(customReception); | ||
212 | + } | ||
213 | + | ||
214 | + public int updateMessageByMessageid(){ | ||
215 | + return customsmessageMapper.updateMessageByMessageid(this); | ||
216 | + } | ||
217 | + | ||
218 | + | ||
219 | + | ||
186 | } | 220 | } |
1 | package com.tianbo.analysis.model; | 1 | package com.tianbo.analysis.model; |
2 | 2 | ||
3 | +import com.tianbo.util.Date.DateUtil; | ||
4 | + | ||
5 | +import java.util.Date; | ||
6 | + | ||
3 | public class CUSTOMSMESSAGEWithBLOBs extends CUSTOMSMESSAGE { | 7 | public class CUSTOMSMESSAGEWithBLOBs extends CUSTOMSMESSAGE { |
4 | private String messagecontent; | 8 | private String messagecontent; |
5 | 9 | ||
@@ -20,4 +24,5 @@ public class CUSTOMSMESSAGEWithBLOBs extends CUSTOMSMESSAGE { | @@ -20,4 +24,5 @@ public class CUSTOMSMESSAGEWithBLOBs extends CUSTOMSMESSAGE { | ||
20 | public void setReceivecontent(String receivecontent) { | 24 | public void setReceivecontent(String receivecontent) { |
21 | this.receivecontent = receivecontent == null ? null : receivecontent.trim(); | 25 | this.receivecontent = receivecontent == null ? null : receivecontent.trim(); |
22 | } | 26 | } |
27 | + | ||
23 | } | 28 | } |
1 | +package com.tianbo.analysis.service; | ||
2 | + | ||
3 | +import com.tianbo.analysis.model.CUSTOMSMESSAGE; | ||
4 | +import com.tianbo.analysis.model.CustomReception; | ||
5 | + | ||
6 | +public interface CustomMessageService { | ||
7 | + | ||
8 | + /** | ||
9 | + * 根据回执的messageid 取得已发送舱单的相关信息 | ||
10 | + * @param customReception 主要传送发送时的messageid,即回执中的messagesid | ||
11 | + * @return | ||
12 | + */ | ||
13 | + CustomReception getWaybillInfoByCutomResponse(CustomReception customReception); | ||
14 | +} |
1 | +package com.tianbo.analysis.service.imp; | ||
2 | + | ||
3 | +import com.tianbo.analysis.dao.CUSTOMSMESSAGEMapper; | ||
4 | +import com.tianbo.analysis.model.CUSTOMSMESSAGE; | ||
5 | +import com.tianbo.analysis.model.CUSTOMSMESSAGEWithBLOBs; | ||
6 | +import com.tianbo.analysis.model.CustomReception; | ||
7 | +import com.tianbo.analysis.service.CustomMessageService; | ||
8 | +import com.tianbo.util.Date.DateUtil; | ||
9 | +import org.springframework.beans.factory.annotation.Autowired; | ||
10 | +import org.springframework.stereotype.Service; | ||
11 | + | ||
12 | +import java.util.List; | ||
13 | + | ||
14 | +@Service | ||
15 | +public class CustomMessageServiceImp implements CustomMessageService{ | ||
16 | + | ||
17 | + @Autowired | ||
18 | + public CUSTOMSMESSAGEMapper customsmessageMapper; | ||
19 | + | ||
20 | + @Override | ||
21 | + public CustomReception getWaybillInfoByCutomResponse(CustomReception customReception){ | ||
22 | + List<CUSTOMSMESSAGEWithBLOBs> customsmessages = customsmessageMapper.selectMessage(customReception.getMessageID()); | ||
23 | + if(!customsmessages.isEmpty()){ | ||
24 | + CUSTOMSMESSAGE customsmessage = customsmessages.get(0); | ||
25 | + customReception.setFlightDate(DateUtil.dateToString(customsmessage.getFlightdate(),"yyyyMMdd")); | ||
26 | + customReception.setFlightNo(customsmessage.getFlightno()); | ||
27 | + customReception.setWayBillMaster(customsmessage.getWaybillnomaster()); | ||
28 | + customReception.setWayBillSecond(customsmessage.getWaybillnosecondary()); | ||
29 | + } | ||
30 | + | ||
31 | + | ||
32 | + return customReception; | ||
33 | + } | ||
34 | +} |
@@ -57,7 +57,9 @@ public class ShareServiceImp { | @@ -57,7 +57,9 @@ public class ShareServiceImp { | ||
57 | // 发送日志 插入 | 57 | // 发送日志 插入 |
58 | CoustomAnalysisServiceImp coustomAnalysisServiceImp = new CoustomAnalysisServiceImp(); | 58 | CoustomAnalysisServiceImp coustomAnalysisServiceImp = new CoustomAnalysisServiceImp(); |
59 | 59 | ||
60 | - CUSTOMSMESSAGEWithBLOBs cus = customsmessageMapper.selectMessage(customReception.getMessageID()); | 60 | +// CUSTOMSMESSAGEWithBLOBs cus = customsmessageMapper.selectMessage(customReception.getMessageID()); |
61 | + CUSTOMSMESSAGEWithBLOBs cus = new CUSTOMSMESSAGEWithBLOBs(); | ||
62 | + | ||
61 | 63 | ||
62 | switch (type){ | 64 | switch (type){ |
63 | case "MT9999": | 65 | case "MT9999": |
@@ -313,8 +315,8 @@ public class ShareServiceImp { | @@ -313,8 +315,8 @@ public class ShareServiceImp { | ||
313 | 315 | ||
314 | // messageId 更新 | 316 | // messageId 更新 |
315 | public int updateMessage(CUSTOMSMESSAGEWithBLOBs cus){ | 317 | public int updateMessage(CUSTOMSMESSAGEWithBLOBs cus){ |
316 | - | ||
317 | - return customsmessageMapper.updateMessage(cus); | 318 | + return 0; |
319 | +// return customsmessageMapper.updateMessage(cus); | ||
318 | } | 320 | } |
319 | 321 | ||
320 | 322 | ||
@@ -325,7 +327,8 @@ public class ShareServiceImp { | @@ -325,7 +327,8 @@ public class ShareServiceImp { | ||
325 | cus.setMessageid(cr.getMessageID()); | 327 | cus.setMessageid(cr.getMessageID()); |
326 | cus.setResponsetext(cr.getResponseText()); | 328 | cus.setResponsetext(cr.getResponseText()); |
327 | 329 | ||
328 | - return customsmessageMapper.updateMessage(cus); | 330 | +// return customsmessageMapper.updateMessage(cus); |
331 | + return 0; | ||
329 | } | 332 | } |
330 | 333 | ||
331 | } | 334 | } |
@@ -31,6 +31,11 @@ public class TaskAnalysis { | @@ -31,6 +31,11 @@ public class TaskAnalysis { | ||
31 | @Value("${custom.transmitDir}") | 31 | @Value("${custom.transmitDir}") |
32 | private String transmitDir; | 32 | private String transmitDir; |
33 | 33 | ||
34 | + /** | ||
35 | + * 线程数量 | ||
36 | + */ | ||
37 | + private final static int theadamount = 50; | ||
38 | + | ||
34 | @Scheduled(fixedRate = 5000) | 39 | @Scheduled(fixedRate = 5000) |
35 | public void startTask(){ | 40 | public void startTask(){ |
36 | final SimpleDateFormat sdf = new SimpleDateFormat( | 41 | final SimpleDateFormat sdf = new SimpleDateFormat( |
@@ -51,16 +56,16 @@ public class TaskAnalysis { | @@ -51,16 +56,16 @@ public class TaskAnalysis { | ||
51 | File fileDirectory = new File(readDir); | 56 | File fileDirectory = new File(readDir); |
52 | List<File> files = FileTool.readDirectoryFiles(fileDirectory); | 57 | List<File> files = FileTool.readDirectoryFiles(fileDirectory); |
53 | //文件数量大于50个,每次只解析前50个 | 58 | //文件数量大于50个,每次只解析前50个 |
54 | - if (files!=null && !files.isEmpty() && files.size()>10){ | ||
55 | - CountDownLatch latch = new CountDownLatch(10); | ||
56 | - log.trace("解析任务开始{},文件数量:{}",startTime,10); | ||
57 | - for (int i=0;i<10;i++){ | 59 | + if (files!=null && !files.isEmpty() && files.size()>theadamount){ |
60 | + CountDownLatch latch = new CountDownLatch(theadamount); | ||
61 | + log.trace("解析任务开始{},文件数量:{}",startTime,theadamount); | ||
62 | + for (int i=0;i<theadamount;i++){ | ||
58 | threadJbob(files.get(i),latch,transToCfps,threadPool); | 63 | threadJbob(files.get(i),latch,transToCfps,threadPool); |
59 | } | 64 | } |
60 | latch.await(); | 65 | latch.await(); |
61 | } | 66 | } |
62 | //文件数量小于50个,全部一次解析完 | 67 | //文件数量小于50个,全部一次解析完 |
63 | - if (files!=null && !files.isEmpty() && files.size()<10){ | 68 | + else if (files!=null && !files.isEmpty() && files.size()<theadamount){ |
64 | CountDownLatch latch = new CountDownLatch(files.size()); | 69 | CountDownLatch latch = new CountDownLatch(files.size()); |
65 | log.info("解析任务开始{},文件数量:{}",startTime,files.size()); | 70 | log.info("解析任务开始{},文件数量:{}",startTime,files.size()); |
66 | for (int i=0;i<files.size();i++){ | 71 | for (int i=0;i<files.size();i++){ |
@@ -11,7 +11,7 @@ public class XMLThreadPoolFactory { | @@ -11,7 +11,7 @@ public class XMLThreadPoolFactory { | ||
11 | public static ThreadPoolExecutor instance(){ | 11 | public static ThreadPoolExecutor instance(){ |
12 | if (threadPool==null){ | 12 | if (threadPool==null){ |
13 | XMLThreadFactory xmlThreadFactory = new XMLThreadFactory("xml"); | 13 | XMLThreadFactory xmlThreadFactory = new XMLThreadFactory("xml"); |
14 | - threadPool = new ThreadPoolExecutor(5, 100, | 14 | + threadPool = new ThreadPoolExecutor(10, 100, |
15 | 0L, TimeUnit.MILLISECONDS, | 15 | 0L, TimeUnit.MILLISECONDS, |
16 | new LinkedBlockingQueue<Runnable>(1024), | 16 | new LinkedBlockingQueue<Runnable>(1024), |
17 | xmlThreadFactory, | 17 | xmlThreadFactory, |
@@ -173,13 +173,17 @@ | @@ -173,13 +173,17 @@ | ||
173 | </insert> | 173 | </insert> |
174 | 174 | ||
175 | <select id="selectMessage" parameterType="string" resultType="com.tianbo.analysis.model.CUSTOMSMESSAGEWithBLOBs"> | 175 | <select id="selectMessage" parameterType="string" resultType="com.tianbo.analysis.model.CUSTOMSMESSAGEWithBLOBs"> |
176 | - select * from CUSTOMSMESSAGE where MESSAGEID = #{value} | 176 | + select * from CUSTOMSMESSAGE where MESSAGEID = #{value,jdbcType=VARCHAR} |
177 | </select> | 177 | </select> |
178 | 178 | ||
179 | 179 | ||
180 | - <update id="updateMessage" parameterType="com.tianbo.analysis.model.CUSTOMSMESSAGEWithBLOBs"> | 180 | + <update id="updateMessageByMessageid" parameterType="com.tianbo.analysis.model.CUSTOMSMESSAGE"> |
181 | UPDATE CUSTOMSMESSAGE | 181 | UPDATE CUSTOMSMESSAGE |
182 | - SET RESPONSETEXT = #{responsetext, jdbcType=VARCHAR} | 182 | + SET |
183 | + RESPONSETEXT = #{responsetext, jdbcType=VARCHAR}, | ||
184 | + MESSAGESTATUS = #{messagestatus,jdbcType=VARCHAR}, | ||
185 | + RESPONSECODE = #{responsecode,jdbcType=VARCHAR}, | ||
186 | + RECEIVETIME = #{receivetime,jdbcType=TIMESTAMP } | ||
183 | WHERE | 187 | WHERE |
184 | MESSAGEID = #{messageid, jdbcType=VARCHAR} | 188 | MESSAGEID = #{messageid, jdbcType=VARCHAR} |
185 | </update> | 189 | </update> |
-
请 注册 或 登录 后发表评论