作者 朱兆平

增加金二验放规则及金二放行指令

  1 +package com.sy.controller;
  2 +
  3 +import com.sy.handle.G2FeedBackHandel;
  4 +import com.sy.response.ResultJson;
  5 +import com.sy.service.X82Service;
  6 +import com.sy.service.router.MessageRouterG2;
  7 +import com.sy.utils.G2ThreadPoolFactory;
  8 +import lombok.extern.slf4j.Slf4j;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.web.bind.annotation.*;
  11 +
  12 +import java.util.concurrent.ThreadPoolExecutor;
  13 +
  14 +@RestController
  15 +@RequestMapping("/g2")
  16 +@Slf4j
  17 +public class G2ResponseController {
  18 +
  19 + @Autowired
  20 + X82Service x82Service;
  21 +
  22 + @Autowired
  23 + MessageRouterG2 messageRouterG2;
  24 +
  25 +
  26 + @PostMapping("/response")
  27 + public ResultJson response(@RequestParam("response") String response){
  28 + try {
  29 + //初始化线程池
  30 + ThreadPoolExecutor threadPool = G2ThreadPoolFactory.instance("G2FeedBack");
  31 + log.info("接收到金二验放回执报文,{},开始解密", response);
  32 + G2FeedBackHandel g2FeedBackHandel = new G2FeedBackHandel();
  33 + g2FeedBackHandel.setFeedBack(response);
  34 + g2FeedBackHandel.setX82Service(x82Service);
  35 + g2FeedBackHandel.setMessageRouterG2(messageRouterG2);
  36 +
  37 + threadPool.execute(g2FeedBackHandel);
  38 + }catch (Exception e){
  39 + return new ResultJson("200","接收回执成功",e.getMessage());
  40 + }
  41 + return new ResultJson("200","接收回执成功");
  42 + }
  43 +}
@@ -17,7 +17,7 @@ import org.springframework.context.ApplicationContext @@ -17,7 +17,7 @@ import org.springframework.context.ApplicationContext
17 * 金二通知验放规则 17 * 金二通知验放规则
18 * todo:需要改造成验放型.返回true false,某些业务类型需要强制走金二验放,海关智能卡口配置端也是根据通道进行配置的 18 * todo:需要改造成验放型.返回true false,某些业务类型需要强制走金二验放,海关智能卡口配置端也是根据通道进行配置的
19 */ 19 */
20 -class G2Notice extends Script implements ChannelCheckScript { 20 +class G2Notice extends Script {
21 private final Logger log = LoggerFactory.getLogger(getClass()); 21 private final Logger log = LoggerFactory.getLogger(getClass());
22 @Override 22 @Override
23 Object run() { 23 Object run() {
@@ -25,7 +25,7 @@ class G2Notice extends Script implements ChannelCheckScript { @@ -25,7 +25,7 @@ class G2Notice extends Script implements ChannelCheckScript {
25 } 25 }
26 26
27 27
28 - Boolean check(ExecuteParams executeParams) { 28 + void check(ExecuteParams executeParams) {
29 try{ 29 try{
30 /** 30 /**
31 * X21通道信息与流转信息比对 31 * X21通道信息与流转信息比对
@@ -35,19 +35,19 @@ class G2Notice extends Script implements ChannelCheckScript { @@ -35,19 +35,19 @@ class G2Notice extends Script implements ChannelCheckScript {
35 GatherInfo info = (GatherInfo) executeParams.get("GatherInfo"); 35 GatherInfo info = (GatherInfo) executeParams.get("GatherInfo");
36 LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo"); 36 LandBusinessTypeList landBusinessTypeList = (LandBusinessTypeList) executeParams.get("ChanelFormInfo");
37 if (landBusinessTypeList!=null){ 37 if (landBusinessTypeList!=null){
38 - rightChnelCheck(landBusinessTypeList.getBusinesstype(),info); 38 + cacheWithSeqno(info);
  39 + log.info("[G2-ROUTER-CACHE]-车辆[{}]流转已缓存[SEQNO]:{}",info.getVename(),info.getSeqno());
  40 + //将X21报文发给三宝,让三宝发给金二
  41 + sendToSample(info);
  42 + record(info,true,"已转金二验放-[SEQN]:"+info.getSeqno(),null);
39 }else { 43 }else {
40 - /**  
41 - * 对应进出场申请数据  
42 - */  
43 - log.error("[G2]-X21与流转信息核碰失败,未有流转缓存或者二维码对碰不成功");  
44 - CommandClient.Client(info,"未找到通道对应申报信息,或二维码信息不一致");  
45 - record(info,false,"[FormCheck]-未找到通道对应申报信息",null); 44 + record(info,true,"金二验放失败,未有相关通道流转申请信息",null);
  45 + CommandClient.Client(info,"金二验放失败,未有相关通道流转申请信息");
46 } 46 }
  47 +
47 }catch (Exception e){ 48 }catch (Exception e){
48 e.printStackTrace(); 49 e.printStackTrace();
49 log.error("[LockNoticeCheck-ERR]:",e); 50 log.error("[LockNoticeCheck-ERR]:",e);
50 - return false;  
51 } 51 }
52 } 52 }
53 53
@@ -58,76 +58,7 @@ class G2Notice extends Script implements ChannelCheckScript { @@ -58,76 +58,7 @@ class G2Notice extends Script implements ChannelCheckScript {
58 return context; 58 return context;
59 } 59 }
60 60
61 - void rightChnelCheck(String businessType,GatherInfo info){  
62 - LandRouterConfig landRouterConfig = new LandRouterConfig();  
63 - landRouterConfig.setBusinessType(businessType);  
64 - landRouterConfig.setAreaId(info.getAreaid());  
65 -  
66 - ApplicationContext context = getContext();  
67 - LandRouterConfigDao landRouterConfigDao = context.getBean(LandRouterConfigDao.class);  
68 - //查询此场站此业务类型有无金二业务配置  
69 - List<LandRouterConfig> routerConfigs = landRouterConfigDao.selectByBussType(landRouterConfig);  
70 - //有金二与业务类型绑定  
71 - if (!routerConfigs.isEmpty()){  
72 - /**  
73 - * 路由配置的卡口 是进出卡口都有 还是只有进或者出  
74 - * 根据X21过的通道类型(进卡口/出卡口)来判定,对应流转申报业务类型 的 进出卡口业务是否有金二通道配置  
75 - */  
76 - boolean anyMatch = routerConfigs.stream().anyMatch({router-> router.getChanelType().equals(info.getIetype())});  
77 -  
78 - /**  
79 - * 有对应卡口进出类型的配置  
80 - * 继续判定  
81 - * 1 通道是否走对. 走对 将X21报文给金二,由三宝转成X81  
82 - * 2 没走对 返回 走错通道.业务结束.  
83 - */  
84 - if (anyMatch){  
85 - //是否走对通道的判定  
86 - for (LandRouterConfig routerConfig : routerConfigs) {  
87 -  
88 - if (routerConfig.getChanelId().equals(info.getChnlno())){  
89 - /**  
90 - * 查找到金二与通道的验放配置  
91 - */  
92 - log.info("[G2-ROUTER]-车辆[{}]流转为金二业务,转金二处理",info.getVename());  
93 - //缓存X21,用来接收海关的x82指令核对.收到X22指令后进行核销此缓存.走金二验放的才缓存  
94 - cacheWithSeqno(info);  
95 - log.debug("[G2-ROUTER-CACHE]-车辆[{}]流转已缓存[SEQNO]:{}",info.getVename(),info.getSeqno());  
96 - //将X21报文发给三宝,让三宝发给金二  
97 - sendToSample(info);  
98 - record(info,true,"已转金二验放-[SEQN]:"+info.getSeqno(),null);  
99 - log.info("[G2]>>为[金二业务],已将[{}]过卡信息发送与金二",info.getVename());  
100 - return;  
101 - }  
102 - }  
103 -  
104 - /**  
105 - * 没适配上 为走错通道,走错通道直接给指令,不走本地验放.  
106 - * 为提高抬杆效率  
107 - */  
108 - //todo:走错通道的回执指令处理  
109 - log.info("[rightChnelCheck]-走错通道");  
110 - CommandClient.Client(info,"G2-走错通道,未找到通道对应申报信息,或二维码信息不一致");  
111 - record(info,false,"走错通道-[SEQN]:"+info.getSeqno(),null);  
112 - }  
113 - /**  
114 - * 有对应卡口进出类型的配置.  
115 - * 说明没有金二配置  
116 - * 走本地  
117 - */  
118 - else{  
119 - //没有金二配置,走本地  
120 -// X21Local(info);  
121 - log.info("[G2Notice-CHECK]-通道[{}]没有G2配置",info.getChnlno())  
122 - }  
123 - }else {  
124 -  
125 - //没有金二配置,走本地  
126 -// X21Local(info);  
127 - log.info("[G2Notice-CHECK]-通道[{}]没有G2配置",info.getChnlno())  
128 - }  
129 61
130 - }  
131 62
132 void record(GatherInfo info, boolean result, String reason, LandBusinessTypeList landBusinessTypeList){ 63 void record(GatherInfo info, boolean result, String reason, LandBusinessTypeList landBusinessTypeList){
133 ApplicationContext context = getContext(); 64 ApplicationContext context = getContext();
  1 +package com.sy.groovy
  2 +
  3 +import com.alibaba.fastjson.JSON
  4 +import com.alibaba.fastjson.JSONArray
  5 +import com.alibaba.fastjson.JSONObject
  6 +import com.sy.model.G2X81Template
  7 +import com.sy.model.GatherInfo
  8 +import com.sy.model.LandBusinessTypeList
  9 +import com.sy.model.LandRoadVe
  10 +import com.sy.response.ResultJson
  11 +import com.sy.service.CommandLogService
  12 +import com.sy.service.RedisService
  13 +import com.sy.service.feigin.G2X81FeignService
  14 +import com.sy.service.feigin.StationManageFeignService
  15 +import com.sy.socket.CommandClient
  16 +import org.apache.commons.lang.StringUtils
  17 +import org.basis.enhance.groovy.entity.ExecuteParams
  18 +import org.slf4j.Logger
  19 +import org.slf4j.LoggerFactory
  20 +import org.springframework.context.ApplicationContext
  21 +
  22 +import java.nio.charset.Charset
  23 +import java.text.SimpleDateFormat
  24 +
  25 +/**
  26 + * 金二特殊区域验放
  27 + * 必须返回false 为异步验放 由X82判定抬杆 ,验放排序放最后
  28 + * todo:需要改造成验放型.返回true false,某些业务类型需要强制走金二验放,海关智能卡口配置端也是根据通道进行配置的
  29 + */
  30 +class G2X81Notice extends Script implements ChannelCheckScript{
  31 + private final Logger log = LoggerFactory.getLogger(getClass());
  32 + @Override
  33 + Object run() {
  34 + return null
  35 + }
  36 +
  37 +
  38 + /**
  39 + * 此接口不做抬杆判定,只做报文通知,返回只有false
  40 + */
  41 + Boolean check(ExecuteParams executeParams) {
  42 + try{
  43 + /**
  44 + * X21通道信息与流转信息比对
  45 + * 1. 从缓存获取车辆进出场申请信息,有流转信息再进行通道对碰.
  46 + * 无流转信息则说明缓存失效或者二维码不对.
  47 + */
  48 + GatherInfo info = (GatherInfo) executeParams.get("GatherInfo");
  49 + LandRoadVe ve = (LandRoadVe) executeParams.get("LandRoadVe");
  50 + ApplicationContext context = getContext();
  51 + G2X81FeignService g2X81FeignService = context.getBean(G2X81FeignService.class);
  52 +
  53 + if (info!=null){
  54 + //缓存X21 的 seqn 需要作为异步X82回执验放时用到的信息
  55 + cacheWithSeqno(info);
  56 + log.info("[G2-X81-CACHE]-车辆[{}]特殊区域流转已缓存[SEQNO]:{}",info.getVename(),info.getSeqno());
  57 + //将X21报文转换成X81格式
  58 + String xmlStr = x22TransToX81(info,ve);
  59 + //调用本地X81申报接口
  60 + ResultJson g2ResultJson = g2X81FeignService.send(xmlStr);
  61 + log.info("[G2-X81-API-RSP]-金二通知接口返回,code:{},message:{},err:{}",g2ResultJson.getCode(),g2ResultJson.getMsg(),g2ResultJson.getError());
  62 + if ("200".equals(g2ResultJson.getCode())){
  63 + record(info,true,"已转金二验放-[SEQN]:"+info.getSeqno(),null);
  64 + log.info("[G2-ROUTER-SUCCESS]-已转金二验放路由成功-规则验放成功-需要忽略下方报错,SEQNO:{}",info.getSeqno());
  65 + }else{
  66 + log.error("[G2-X81-API-ERR]-金二路由接口访问出错")
  67 + }
  68 + }else {
  69 + record(info,true,"金二验放失败,未有相关通道流转申请信息",null);
  70 + CommandClient.Client(info,"金二验放失败,未有相关通道流转申请信息");
  71 + }
  72 +
  73 + }catch (Exception e){
  74 + e.printStackTrace();
  75 + log.error("[G2-ROUTER-ERR]:",e);
  76 + }
  77 + return false;
  78 + }
  79 +
  80 + // 获取spring容器
  81 + ApplicationContext getContext() {
  82 + // 获取spring IOC容器
  83 + ApplicationContext context = applicationContext;
  84 + return context;
  85 + }
  86 +
  87 +
  88 +
  89 + void record(GatherInfo info, boolean result, String reason, LandBusinessTypeList landBusinessTypeList){
  90 + ApplicationContext context = getContext();
  91 + CommandLogService commandLogService = context.getBean(CommandLogService.class);
  92 + commandLogService.commandlog(info,result,reason,landBusinessTypeList,null,0.0,0.0,0.0,0.0);
  93 + }
  94 +
  95 + String x22TransToX81(GatherInfo gatherInfo,LandRoadVe ve){
  96 + log.info("[SEQN]-处理X21报文:{}",gatherInfo.getSeqno());
  97 + //当前时间作为X81申报时间
  98 + final SimpleDateFormat sdf = new SimpleDateFormat(
  99 + "yyyy-MM-dd HH:mm:ss");
  100 + final String startTime = sdf.format(new Date());
  101 +
  102 + //金二场站ID与通道ID替换
  103 + ApplicationContext context = getContext();
  104 + StationManageFeignService stationManageFeignService = context.getBean(StationManageFeignService.class);
  105 + ResultJson resultJson = stationManageFeignService.getChanels(gatherInfo.getChnlno(),1,1);
  106 +
  107 + if ("200".equals(resultJson.getCode())){
  108 + JSONObject jsonObject = resultJson.getData();
  109 + int total = jsonObject.getInteger("total");
  110 + if (total>0){
  111 + JSONArray jsonArray = jsonObject.getJSONArray("list");
  112 + JSONObject chanel = jsonArray.getJSONObject(0);
  113 + String channelG2 = chanel.getString("channelG2");
  114 + log.info("[G2-CHANNEL]-{}",channelG2);
  115 + JSONObject yard = chanel.getJSONObject("yard");
  116 + String stationG2 = yard.getString("stationIdG2");
  117 + log.info("[G2-YARD]-{}",stationG2);
  118 +
  119 + log.info("[G2-TEMPLATE]-{}",G2X81Template.template)
  120 + String x81XML= G2X81Template.template.replace("#{ie_flag}",gatherInfo.getIetype())
  121 + .replace("#{area_id}",stationG2)
  122 + .replace("#{chnl_no}",channelG2)
  123 + .replace("#{session_id}",gatherInfo.getSeqno())
  124 + .replace("#{ve_license_no}",gatherInfo.getVename())
  125 + .replace("#{gross_wt}",gatherInfo.getGrosswt().toString())
  126 + .replace("#{rfid_id}",gatherInfo.getCarecno())
  127 + .replace("#{ve_wt}",ve.getSelfWt())
  128 + .replace("#{operate_time}",startTime);
  129 + log.info("[X21-TO-X81]-{}",x81XML);
  130 + String mqXMLStr = mqXMLMake(x81XML,gatherInfo.getSeqno(),startTime);
  131 + log.info("[X21-TO-X81]-加密后的报文为:{}",mqXMLStr)
  132 + return mqXMLStr;
  133 +
  134 + }else {
  135 + throw new Exception("未获取到通道金二配置信息")
  136 + }
  137 +
  138 + }else {
  139 + log.error("场站管理服务接口访问失败")
  140 + }
  141 +
  142 + return "";
  143 + }
  144 +
  145 + String mqXMLMake(String xmlStr,String copMsgId,String creatTime){
  146 + String base64EncodeToString = Base64.getEncoder().encodeToString(xmlStr.getBytes(Charset.forName("utf-8")));
  147 + log.info("[SEND-BASE64-ENCODE]-{}",base64EncodeToString)
  148 +
  149 + return G2X81Template.mq_template.replace("#{CopMsgId}",copMsgId)
  150 + .replace("#{CreatTime}",creatTime)
  151 + .replace("#{Data}",base64EncodeToString);
  152 + }
  153 +
  154 + void cacheWithSeqno(GatherInfo info){
  155 + ApplicationContext context = getContext();
  156 + RedisService redisService = context.getBean(RedisService.class);
  157 + if (info!=null && StringUtils.isNotEmpty(info.getSeqno())) {
  158 + redisService.set(info.getSeqno(), JSON.toJSONString(info),60*60*24*3);
  159 + }
  160 + }
  161 +}
  1 +package com.sy.handle;
  2 +
  3 +import com.sy.model.DxpMsg;
  4 +import com.sy.model.GatherInfo;
  5 +import com.sy.model.X82Feedback;
  6 +import com.sy.service.X82Service;
  7 +import com.sy.service.router.MessageRouterG2;
  8 +import com.sy.socket.CommandClient;
  9 +import com.sy.utils.Base64Tool;
  10 +import lombok.extern.slf4j.Slf4j;
  11 +import org.apache.commons.lang.StringUtils;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.stereotype.Component;
  14 +
  15 +@Component
  16 +@Slf4j
  17 +public class G2FeedBackHandel extends Thread {
  18 +
  19 + private String feedBack;
  20 +
  21 + private X82Service x82Service;
  22 +
  23 + private MessageRouterG2 messageRouterG2;
  24 +
  25 + public X82Service getX82Service() {
  26 + return x82Service;
  27 + }
  28 +
  29 + public void setX82Service(X82Service x82Service) {
  30 + this.x82Service = x82Service;
  31 + }
  32 +
  33 + public MessageRouterG2 getMessageRouterG2() {
  34 + return messageRouterG2;
  35 + }
  36 +
  37 + public void setMessageRouterG2(MessageRouterG2 messageRouterG2) {
  38 + this.messageRouterG2 = messageRouterG2;
  39 + }
  40 +
  41 + public String getFeedBack() {
  42 + return feedBack;
  43 + }
  44 +
  45 + public void setFeedBack(String feedBack) {
  46 + this.feedBack = feedBack;
  47 + }
  48 +
  49 + @Override
  50 + public void run() {
  51 + try {
  52 + DxpMsg dxpMsg = x82Service.analysis(feedBack);
  53 + String data = dxpMsg.getData();
  54 + //解密BASE64 得到X82报文
  55 + String x82Str = Base64Tool.decodeUtf8ToUtf8(data);
  56 + //解析报文
  57 + X82Feedback x82Feedback = x82Service.x82Analysis(x82Str);
  58 + String seqno = x82Feedback.getSessionId();
  59 + GatherInfo gatherInfo = x82Service.readCacheWithSeqno(seqno);
  60 +
  61 + //todo: X82Feedback 与 X21 实体类转换
  62 + if (StringUtils.isNotEmpty(x82Feedback.getChannelNo())){
  63 + if (gatherInfo!=null){
  64 + //得到sessionid ,申报出去的X81sessionId=seqno ,一去一回sessionId一样
  65 + if (x82Service.X82ReleaseCheck(x82Feedback)){
  66 + //放行及核销
  67 + messageRouterG2.route(gatherInfo,x82Feedback.getOpHint());
  68 + }else{
  69 + log.info("[G2-CHECK-FAILD]-金二验放失败,不予放行");
  70 + messageRouterG2.faild(gatherInfo,x82Feedback.getOpHint());
  71 + }
  72 + }else {
  73 + GatherInfo gatherInfo1 = x82Service.X82FeedBackToX21GatherInfo(x82Feedback);
  74 + messageRouterG2.faild(gatherInfo1,x82Feedback.getOpHint());
  75 + }
  76 + }else {
  77 + log.error("[G2-FEEDBACK-XML-ERR]-金二验放未知错误,源报文:{},解密报文:{}",feedBack,x82Str);
  78 + }
  79 + }catch (Exception e){
  80 + log.error("金二回执处理线程出错",e);
  81 + }
  82 + }
  83 +}
  1 +package com.sy.model;
  2 +
  3 +import com.thoughtworks.xstream.annotations.XStreamAlias;
  4 +import com.thoughtworks.xstream.annotations.XStreamImplicit;
  5 +
  6 +import java.util.List;
  7 +
  8 +
  9 +@XStreamAlias("DxpMsg")
  10 +public class DxpMsg {
  11 +
  12 + @XStreamAlias("TransInfo")
  13 + private TransInfo transInfo;
  14 +
  15 + @XStreamAlias("Data")
  16 + private String data;
  17 +
  18 + @XStreamAlias("AddInfo")
  19 + private AddInfo addInfo;
  20 +
  21 + public TransInfo getTransInfo() {
  22 + return transInfo;
  23 + }
  24 +
  25 + public void setTransInfo(TransInfo transInfo) {
  26 + this.transInfo = transInfo;
  27 + }
  28 +
  29 + public String getData() {
  30 + return data;
  31 + }
  32 +
  33 + public void setData(String data) {
  34 + this.data = data;
  35 + }
  36 +
  37 + public AddInfo getAddInfo() {
  38 + return addInfo;
  39 + }
  40 +
  41 + public void setAddInfo(AddInfo addInfo) {
  42 + this.addInfo = addInfo;
  43 + }
  44 +}
  45 +
  46 +class TransInfo{
  47 +
  48 + @XStreamAlias("CopMsgId")
  49 + private String copMsgId;
  50 +
  51 + @XStreamAlias("SenderId")
  52 + private String senderId;
  53 +
  54 + @XStreamAlias("ReceiverIds")
  55 + private ReceiverIds receiverIds;
  56 +
  57 + @XStreamAlias("CreatTime")
  58 + private String creatTime;
  59 +
  60 + @XStreamAlias("MsgType")
  61 + private String msgType;
  62 +
  63 + public String getCopMsgId() {
  64 + return copMsgId;
  65 + }
  66 +
  67 + public void setCopMsgId(String copMsgId) {
  68 + this.copMsgId = copMsgId;
  69 + }
  70 +
  71 + public String getSenderId() {
  72 + return senderId;
  73 + }
  74 +
  75 + public void setSenderId(String senderId) {
  76 + this.senderId = senderId;
  77 + }
  78 +
  79 + public ReceiverIds getReceiverIds() {
  80 + return receiverIds;
  81 + }
  82 +
  83 + public void setReceiverIds(ReceiverIds receiverIds) {
  84 + this.receiverIds = receiverIds;
  85 + }
  86 +
  87 + public String getCreatTime() {
  88 + return creatTime;
  89 + }
  90 +
  91 + public void setCreatTime(String creatTime) {
  92 + this.creatTime = creatTime;
  93 + }
  94 +
  95 + public String getMsgType() {
  96 + return msgType;
  97 + }
  98 +
  99 + public void setMsgType(String msgType) {
  100 + this.msgType = msgType;
  101 + }
  102 +}
  103 +
  104 +class ReceiverIds{
  105 +
  106 + @XStreamImplicit(itemFieldName = "ReceiverId")
  107 + private List<String> receiverId;
  108 +
  109 + public List<String> getReceiverId() {
  110 + return receiverId;
  111 + }
  112 +
  113 + public void setReceiverId(List<String> receiverId) {
  114 + this.receiverId = receiverId;
  115 + }
  116 +}
  117 +
  118 +class AddInfo{
  119 + @XStreamAlias("FileName")
  120 + private String fileName;
  121 +
  122 + public String getFileName() {
  123 + return fileName;
  124 + }
  125 +
  126 + public void setFileName(String fileName) {
  127 + this.fileName = fileName;
  128 + }
  129 +}
  1 +package com.sy.model;
  2 +
  3 +/**
  4 + * 金二X81报文xml模板
  5 + */
  6 +public class G2X81Template {
  7 + /**
  8 + * 金二X81报文封装模板
  9 + */
  10 + public static final String template= "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
  11 + "<GATHER_INFO xmlns=\"http://rpb.customs.gov.cn/common/FrontEndSchemas/\"\n" +
  12 + " xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" +
  13 + " xsi:schemaLocation=\"http://rpb.customs.gov.cn/common/FrontEndSchemas/\">\n" +
  14 + " <I_E_FLAG>#{ie_flag}</I_E_FLAG>\n" +
  15 + " <AREA_ID>#{area_id}</AREA_ID>\n" +
  16 + " <CHNL_NO>#{chnl_no}</CHNL_NO>\n" +
  17 + " <GETHER_MODE>A</GETHER_MODE>\n" +
  18 + " <SESSION_ID>#{session_id}</SESSION_ID>\n" +
  19 + " <IC_INFO>\n" +
  20 + " <IC_ID></IC_ID>\n" +
  21 + " <IC_NO></IC_NO>\n" +
  22 + " <IC_TYPE></IC_TYPE>\n" +
  23 + " <IC_EXTENDED_CONTENT></IC_EXTENDED_CONTENT>\n" +
  24 + " </IC_INFO>\n" +
  25 + " <FORM_INFO>\n" +
  26 + " <FORM_TYPE></FORM_TYPE>\n" +
  27 + " <FORM_ID></FORM_ID>\n" +
  28 + " </FORM_INFO>\n" +
  29 + " <VE_LICENSE_NO>#{ve_license_no}</VE_LICENSE_NO>\n" +
  30 + " <GROSS_WT>#{gross_wt}</GROSS_WT>\n" +
  31 + " <VE_RFID>\n" +
  32 + " <RFID_ID>#{rfid_id}</RFID_ID>\n" +
  33 + " <VE_LICENSE_NO>#{ve_license_no}</VE_LICENSE_NO>\n" +
  34 + " <VE_CUSTOMS_NO></VE_CUSTOMS_NO>\n" +
  35 + " <VE_WT>#{ve_wt}</VE_WT>\n" +
  36 + " <VE_COMPANY></VE_COMPANY>\n" +
  37 + " <VE_PERFORMANCE>1</VE_PERFORMANCE>\n" +
  38 + " </VE_RFID>\n" +
  39 + " <OPERATE_TIME>#{operate_time}</OPERATE_TIME>\n" +
  40 + "</GATHER_INFO>\n";
  41 + private static final String demo="<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" +
  42 + "<GATHER_INFO xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" \n" +
  43 + "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"http://rpb.customs.gov.cn/common/FrontEndSchemas/\">\n" +
  44 + "<I_E_FLAG>I</I_E_FLAG>\n" +
  45 + "<AREA_ID>5301HG</AREA_ID>\n" +
  46 + "<CHNL_NO>53010HITest101</CHNL_NO>\n" +
  47 + "<GETHER_MODE>B</GETHER_MODE>\n" +
  48 + "<SESSION_ID>20180130173410733</SESSION_ID>\n" +
  49 + " <VE_RFID>\n" +
  50 + "<RFID_ID>E0040000BA0EE801</RFID_ID>\n" +
  51 + "</VE_RFID>\n" +
  52 + "<OPERATOR_ID>5399990</OPERATOR_ID>\n" +
  53 + "<OPERATE_TIME>2016-11-24 11:31:52</OPERATE_TIME>\n" +
  54 + "</GATHER_INFO>";
  55 +
  56 + /**
  57 + * 发送报文封装模板
  58 + */
  59 + public static final String mq_template = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" +
  60 + "<DxpMsg xmlns=\"http://www.chinaport.gov.cn/dxp\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" ver=\"1.0\">\n" +
  61 + " <TransInfo>\n" +
  62 + " <CopMsgId>#{CopMsgId}</CopMsgId>\n" +
  63 + " <SenderId>GDXPKK0000000002</SenderId>\n" +
  64 + " <MsgType>JCKK</MsgType>\n" +
  65 + " <CreatTime>#{CreatTime}</CreatTime>\n" +
  66 + " <ReceiverIds>\n" +
  67 + " <ReceiverId>GJCKK00000000001</ReceiverId>\n" +
  68 + " </ReceiverIds>\n" +
  69 + " </TransInfo>\n" +
  70 + " <Data>#{Data}</Data>\n" +
  71 + "</DxpMsg>";
  72 +}
  1 +package com.sy.model;
  2 +
  3 +
  4 +import com.thoughtworks.xstream.annotations.XStreamAlias;
  5 +
  6 +@XStreamAlias("GATHER_FEEDBACK")
  7 +public class X82Feedback {
  8 +
  9 + @XStreamAlias("AREA_ID")
  10 + // 区域ID
  11 + private String areaId;
  12 +
  13 + @XStreamAlias("CHNL_NO")
  14 + // 渠道号
  15 + private String channelNo;
  16 +
  17 + @XStreamAlias("SESSION_ID")
  18 + // 会话ID
  19 + private String sessionId;
  20 +
  21 + @XStreamAlias("RELLIST_TYPE")
  22 + // 关联列表类型
  23 + private String relListType;
  24 +
  25 + @XStreamAlias("RELLIST_ID_TYPE")
  26 + // 关联列表ID类型
  27 + private String relListIdType;
  28 +
  29 + @XStreamAlias("RELLIST_ID")
  30 + // 关联列表ID
  31 + private String relListId;
  32 +
  33 + @XStreamAlias("FEEDBACK_TIME")
  34 + // 反馈时间
  35 + private String feedbackTime;
  36 +
  37 + @XStreamAlias("CHECK_RESULT")
  38 + // 检查结果
  39 + private String checkResult;
  40 +
  41 + @XStreamAlias("INSTRUCTION")
  42 + // 指令
  43 + private String instruction;
  44 +
  45 + @XStreamAlias("PROC_ERROR_CODE")
  46 + // 处理错误代码
  47 + private int procErrorCode;
  48 +
  49 + @XStreamAlias("PROC_ERROR_DESCRIPTION")
  50 + // 处理错误描述
  51 + private String procErrorDescription;
  52 +
  53 + @XStreamAlias("TECH_ERROR_CODE")
  54 + // 技术错误代码
  55 + private int techErrorCode;
  56 +
  57 + @XStreamAlias("TECH_ERROR_DESCRIPTION")
  58 + // 技术错误描述
  59 + private String techErrorDescription;
  60 +
  61 + @XStreamAlias("IC_INFO")
  62 + // IC信息
  63 + private ICInfo icInfo;
  64 +
  65 + @XStreamAlias("VE_INFO")
  66 + // 车辆信息
  67 + private VEInfo veInfo;
  68 +
  69 + @XStreamAlias("CONTA_ID")
  70 + // 货柜ID
  71 + private String contaId;
  72 +
  73 + @XStreamAlias("ESEAL_ID")
  74 + // 电子封条ID
  75 + private String eSealId;
  76 +
  77 + @XStreamAlias("SEAL_ID")
  78 + // 封条ID
  79 + private String sealId;
  80 +
  81 + @XStreamAlias("FORM_INFO")
  82 + // 表单信息
  83 + private FormInfo formInfo;
  84 +
  85 + @XStreamAlias("PACK_NO")
  86 + // 包裹数量
  87 + private int packNo;
  88 +
  89 + @XStreamAlias("DECL_PACK")
  90 + // 申报包裹数量
  91 + private int declPack;
  92 +
  93 + @XStreamAlias("DECL_GOODS_WEIGHT")
  94 + // 申报货物重量
  95 + private double declGoodsWeight;
  96 +
  97 + @XStreamAlias("OP_HINT")
  98 + // 操作提示
  99 + private String opHint;
  100 +
  101 + @XStreamAlias("LED_HINT")
  102 + // LED提示
  103 + private String ledHint;
  104 +
  105 + @XStreamAlias("EXTENDED_CONTENT")
  106 + // 扩展内容
  107 + private String extendedContent;
  108 +
  109 + public String getAreaId() {
  110 + return areaId;
  111 + }
  112 +
  113 + public void setAreaId(String areaId) {
  114 + this.areaId = areaId;
  115 + }
  116 +
  117 + public String getChannelNo() {
  118 + return channelNo;
  119 + }
  120 +
  121 + public void setChannelNo(String channelNo) {
  122 + this.channelNo = channelNo;
  123 + }
  124 +
  125 + public String getSessionId() {
  126 + return sessionId;
  127 + }
  128 +
  129 + public void setSessionId(String sessionId) {
  130 + this.sessionId = sessionId;
  131 + }
  132 +
  133 + public String getRelListType() {
  134 + return relListType;
  135 + }
  136 +
  137 + public void setRelListType(String relListType) {
  138 + this.relListType = relListType;
  139 + }
  140 +
  141 + public String getRelListIdType() {
  142 + return relListIdType;
  143 + }
  144 +
  145 + public void setRelListIdType(String relListIdType) {
  146 + this.relListIdType = relListIdType;
  147 + }
  148 +
  149 + public String getRelListId() {
  150 + return relListId;
  151 + }
  152 +
  153 + public void setRelListId(String relListId) {
  154 + this.relListId = relListId;
  155 + }
  156 +
  157 + public String getFeedbackTime() {
  158 + return feedbackTime;
  159 + }
  160 +
  161 + public void setFeedbackTime(String feedbackTime) {
  162 + this.feedbackTime = feedbackTime;
  163 + }
  164 +
  165 + public String getCheckResult() {
  166 + return checkResult;
  167 + }
  168 +
  169 + public void setCheckResult(String checkResult) {
  170 + this.checkResult = checkResult;
  171 + }
  172 +
  173 + public String getInstruction() {
  174 + return instruction;
  175 + }
  176 +
  177 + public void setInstruction(String instruction) {
  178 + this.instruction = instruction;
  179 + }
  180 +
  181 + public int getProcErrorCode() {
  182 + return procErrorCode;
  183 + }
  184 +
  185 + public void setProcErrorCode(int procErrorCode) {
  186 + this.procErrorCode = procErrorCode;
  187 + }
  188 +
  189 + public String getProcErrorDescription() {
  190 + return procErrorDescription;
  191 + }
  192 +
  193 + public void setProcErrorDescription(String procErrorDescription) {
  194 + this.procErrorDescription = procErrorDescription;
  195 + }
  196 +
  197 + public int getTechErrorCode() {
  198 + return techErrorCode;
  199 + }
  200 +
  201 + public void setTechErrorCode(int techErrorCode) {
  202 + this.techErrorCode = techErrorCode;
  203 + }
  204 +
  205 + public String getTechErrorDescription() {
  206 + return techErrorDescription;
  207 + }
  208 +
  209 + public void setTechErrorDescription(String techErrorDescription) {
  210 + this.techErrorDescription = techErrorDescription;
  211 + }
  212 +
  213 + public ICInfo getIcInfo() {
  214 + return icInfo;
  215 + }
  216 +
  217 + public void setIcInfo(ICInfo icInfo) {
  218 + this.icInfo = icInfo;
  219 + }
  220 +
  221 + public VEInfo getVeInfo() {
  222 + return veInfo;
  223 + }
  224 +
  225 + public void setVeInfo(VEInfo veInfo) {
  226 + this.veInfo = veInfo;
  227 + }
  228 +
  229 + public String getContaId() {
  230 + return contaId;
  231 + }
  232 +
  233 + public void setContaId(String contaId) {
  234 + this.contaId = contaId;
  235 + }
  236 +
  237 + public String geteSealId() {
  238 + return eSealId;
  239 + }
  240 +
  241 + public void seteSealId(String eSealId) {
  242 + this.eSealId = eSealId;
  243 + }
  244 +
  245 + public String getSealId() {
  246 + return sealId;
  247 + }
  248 +
  249 + public void setSealId(String sealId) {
  250 + this.sealId = sealId;
  251 + }
  252 +
  253 + public FormInfo getFormInfo() {
  254 + return formInfo;
  255 + }
  256 +
  257 + public void setFormInfo(FormInfo formInfo) {
  258 + this.formInfo = formInfo;
  259 + }
  260 +
  261 + public int getPackNo() {
  262 + return packNo;
  263 + }
  264 +
  265 + public void setPackNo(int packNo) {
  266 + this.packNo = packNo;
  267 + }
  268 +
  269 + public int getDeclPack() {
  270 + return declPack;
  271 + }
  272 +
  273 + public void setDeclPack(int declPack) {
  274 + this.declPack = declPack;
  275 + }
  276 +
  277 + public double getDeclGoodsWeight() {
  278 + return declGoodsWeight;
  279 + }
  280 +
  281 + public void setDeclGoodsWeight(double declGoodsWeight) {
  282 + this.declGoodsWeight = declGoodsWeight;
  283 + }
  284 +
  285 + public String getOpHint() {
  286 + return opHint;
  287 + }
  288 +
  289 + public void setOpHint(String opHint) {
  290 + this.opHint = opHint;
  291 + }
  292 +
  293 + public String getLedHint() {
  294 + return ledHint;
  295 + }
  296 +
  297 + public void setLedHint(String ledHint) {
  298 + this.ledHint = ledHint;
  299 + }
  300 +
  301 + public String getExtendedContent() {
  302 + return extendedContent;
  303 + }
  304 +
  305 + public void setExtendedContent(String extendedContent) {
  306 + this.extendedContent = extendedContent;
  307 + }
  308 +}
  309 +
  310 +@XStreamAlias("IC_INFO")
  311 +class ICInfo {
  312 + @XStreamAlias("IC_ID")
  313 + // IC ID
  314 + private String icId;
  315 +
  316 + @XStreamAlias("IC_NO")
  317 + // IC编号
  318 + private String icNo;
  319 +
  320 + @XStreamAlias("IC_TYPE")
  321 + // IC类型
  322 + private String icType;
  323 +
  324 + @XStreamAlias("IC_EXTENDED_CONTENT")
  325 + // IC扩展内容
  326 + private String icExtendedContent;
  327 +
  328 + public String getIcId() {
  329 + return icId;
  330 + }
  331 +
  332 + public void setIcId(String icId) {
  333 + this.icId = icId;
  334 + }
  335 +
  336 + public String getIcNo() {
  337 + return icNo;
  338 + }
  339 +
  340 + public void setIcNo(String icNo) {
  341 + this.icNo = icNo;
  342 + }
  343 +
  344 + public String getIcType() {
  345 + return icType;
  346 + }
  347 +
  348 + public void setIcType(String icType) {
  349 + this.icType = icType;
  350 + }
  351 +
  352 + public String getIcExtendedContent() {
  353 + return icExtendedContent;
  354 + }
  355 +
  356 + public void setIcExtendedContent(String icExtendedContent) {
  357 + this.icExtendedContent = icExtendedContent;
  358 + }
  359 +}
  360 +
  361 +@XStreamAlias("VE_INFO")
  362 +class VEInfo {
  363 + @XStreamAlias("VE_CUSTOMS_NO")
  364 + // 车辆海关编号
  365 + private String veCustomsNo;
  366 +
  367 + @XStreamAlias("VE_LICENSE_NO")
  368 + // 车辆牌照号码
  369 + private String veLicenseNo;
  370 +
  371 + @XStreamAlias("VE_LICENSE_NO2")
  372 + // 车辆牌照号码2
  373 + private String veLicenseNo2;
  374 +
  375 + @XStreamAlias("DR_CUSTOMS_NO")
  376 + // 驾驶员海关编号
  377 + private String drCustomsNo;
  378 +
  379 + @XStreamAlias("DR_NAME")
  380 + // 驾驶员姓名
  381 + private String drName;
  382 +
  383 + @XStreamAlias("TRAILER_ID")
  384 + // 拖车ID
  385 + private String trailerId;
  386 +
  387 + @XStreamAlias("WEIGHT_DIFF")
  388 + // 重量差异
  389 + private double weightDiff;
  390 +
  391 + @XStreamAlias("CHANNEL_WEIGHT")
  392 + // 渠道重量
  393 + private double channelWeight;
  394 +
  395 + @XStreamAlias("GROSS_WEIGHT")
  396 + // 毛重
  397 + private double grossWeight;
  398 +
  399 + @XStreamAlias("VEHICLE_WEIGHT")
  400 + // 车辆重量
  401 + private double vehicleWeight;
  402 +
  403 + public String getVeCustomsNo() {
  404 + return veCustomsNo;
  405 + }
  406 +
  407 + public void setVeCustomsNo(String veCustomsNo) {
  408 + this.veCustomsNo = veCustomsNo;
  409 + }
  410 +
  411 + public String getVeLicenseNo() {
  412 + return veLicenseNo;
  413 + }
  414 +
  415 + public void setVeLicenseNo(String veLicenseNo) {
  416 + this.veLicenseNo = veLicenseNo;
  417 + }
  418 +
  419 + public String getVeLicenseNo2() {
  420 + return veLicenseNo2;
  421 + }
  422 +
  423 + public void setVeLicenseNo2(String veLicenseNo2) {
  424 + this.veLicenseNo2 = veLicenseNo2;
  425 + }
  426 +
  427 + public String getDrCustomsNo() {
  428 + return drCustomsNo;
  429 + }
  430 +
  431 + public void setDrCustomsNo(String drCustomsNo) {
  432 + this.drCustomsNo = drCustomsNo;
  433 + }
  434 +
  435 + public String getDrName() {
  436 + return drName;
  437 + }
  438 +
  439 + public void setDrName(String drName) {
  440 + this.drName = drName;
  441 + }
  442 +
  443 + public String getTrailerId() {
  444 + return trailerId;
  445 + }
  446 +
  447 + public void setTrailerId(String trailerId) {
  448 + this.trailerId = trailerId;
  449 + }
  450 +
  451 + public double getWeightDiff() {
  452 + return weightDiff;
  453 + }
  454 +
  455 + public void setWeightDiff(double weightDiff) {
  456 + this.weightDiff = weightDiff;
  457 + }
  458 +
  459 + public double getChannelWeight() {
  460 + return channelWeight;
  461 + }
  462 +
  463 + public void setChannelWeight(double channelWeight) {
  464 + this.channelWeight = channelWeight;
  465 + }
  466 +
  467 + public double getGrossWeight() {
  468 + return grossWeight;
  469 + }
  470 +
  471 + public void setGrossWeight(double grossWeight) {
  472 + this.grossWeight = grossWeight;
  473 + }
  474 +
  475 + public double getVehicleWeight() {
  476 + return vehicleWeight;
  477 + }
  478 +
  479 + public void setVehicleWeight(double vehicleWeight) {
  480 + this.vehicleWeight = vehicleWeight;
  481 + }
  482 +
  483 +
  484 +}
  485 +
  486 +@XStreamAlias("FORM_INFO")
  487 +class FormInfo {
  488 + @XStreamAlias("FORM_TYPE")
  489 + // 表单类型
  490 + private String formType;
  491 +
  492 + @XStreamAlias("FORM_ID")
  493 + // 表单ID
  494 + private String formId;
  495 +
  496 + @XStreamAlias("MASTER_CUSTOMS_CODE")
  497 + // 主管海关代码
  498 + private String masterCustomsCode;
  499 +
  500 + public String getFormType() {
  501 + return formType;
  502 + }
  503 +
  504 + public void setFormType(String formType) {
  505 + this.formType = formType;
  506 + }
  507 +
  508 + public String getFormId() {
  509 + return formId;
  510 + }
  511 +
  512 + public void setFormId(String formId) {
  513 + this.formId = formId;
  514 + }
  515 +
  516 + public String getMasterCustomsCode() {
  517 + return masterCustomsCode;
  518 + }
  519 +
  520 + public void setMasterCustomsCode(String masterCustomsCode) {
  521 + this.masterCustomsCode = masterCustomsCode;
  522 + }
  523 +
  524 +}
@@ -44,6 +44,12 @@ public interface EnginCheckService { @@ -44,6 +44,12 @@ public interface EnginCheckService {
44 void pass(GatherInfo info,ExecuteParams executeParams); 44 void pass(GatherInfo info,ExecuteParams executeParams);
45 45
46 /** 46 /**
  47 + * 不放行
  48 + * @param info
  49 + */
  50 + void passFaild(GatherInfo info,String reason,ExecuteParams executeParams);
  51 +
  52 + /**
47 * 记录已进出区信息 53 * 记录已进出区信息
48 */ 54 */
49 void record(GatherInfo info,ExecuteParams executeParams); 55 void record(GatherInfo info,ExecuteParams executeParams);
  1 +package com.sy.service;
  2 +
  3 +import com.sy.model.DxpMsg;
  4 +import com.sy.model.GatherInfo;
  5 +import com.sy.model.X82Feedback;
  6 +
  7 +public interface X82Service {
  8 + /**
  9 + * 解析被封装的X82金二验放回执报文,并获取到DATA base64加密后的报体内容.
  10 + * @param response
  11 + */
  12 + DxpMsg analysis(String response);
  13 +
  14 + X82Feedback x82Analysis(String xml);
  15 +
  16 + Boolean X82ReleaseCheck(X82Feedback var);
  17 +
  18 + GatherInfo readCacheWithSeqno(String seqno);
  19 +
  20 + /**
  21 + * 将X82的报文实体类转换成X21GatherInfo 实体,用来做最终验放参数用
  22 + * @param var X82Feedback实体类
  23 + * @return X21 GatherInfo 实体类
  24 + */
  25 + GatherInfo X82FeedBackToX21GatherInfo(X82Feedback var);
  26 +}
  1 +package com.sy.service.feigin;
  2 +
  3 +import com.sy.model.LockFeignResponse;
  4 +import com.sy.model.NoticeLock;
  5 +import com.sy.response.ResultJson;
  6 +import feign.hystrix.FallbackFactory;
  7 +import lombok.extern.slf4j.Slf4j;
  8 +import org.springframework.stereotype.Component;
  9 +import org.springframework.web.bind.annotation.RequestBody;
  10 +
  11 +/**
  12 + * @author mrz
  13 + */
  14 +@Component
  15 +@Slf4j
  16 +public class G2X81FeignFallBackFactory implements FallbackFactory<G2X81FeignService> {
  17 +
  18 + @Override
  19 + public G2X81FeignService create(Throwable throwable) {
  20 + log.error("调用金二X81通知接口异常",throwable);
  21 + return new G2X81FeignService() {
  22 + @Override
  23 + public ResultJson send(String message) {
  24 + return new ResultJson("400","金二X81申报接口访问失败");
  25 + }
  26 + };
  27 + }
  28 +}
  1 +package com.sy.service.feigin;
  2 +
  3 +
  4 +import com.sy.model.LockFeignResponse;
  5 +import com.sy.model.NoticeLock;
  6 +import com.sy.response.ResultJson;
  7 +import org.springframework.cloud.openfeign.FeignClient;
  8 +import org.springframework.web.bind.annotation.PostMapping;
  9 +import org.springframework.web.bind.annotation.RequestBody;
  10 +import org.springframework.web.bind.annotation.RequestParam;
  11 +
  12 +/**
  13 + * 金二报文发送接口
  14 + * @author mrz
  15 + */
  16 +@FeignClient(name = "SEND-IBMMQ-SERVIER",fallbackFactory = G2X81FeignFallBackFactory.class)
  17 +public interface G2X81FeignService {
  18 +
  19 + @PostMapping("/ibm/mq/sendMsg")
  20 + ResultJson send(@RequestParam("message") String message);
  21 +}
  22 +
  1 +package com.sy.service.feigin;
  2 +
  3 +import com.sy.response.ResultJson;
  4 +import feign.hystrix.FallbackFactory;
  5 +import lombok.extern.slf4j.Slf4j;
  6 +import org.springframework.stereotype.Component;
  7 +import org.springframework.web.bind.annotation.RequestParam;
  8 +
  9 +/**
  10 + * @author mrz
  11 + */
  12 +@Component
  13 +@Slf4j
  14 +public class StationManageFallBackFactory implements FallbackFactory<StationManageFeignService> {
  15 +
  16 + @Override
  17 + public StationManageFeignService create(Throwable throwable) {
  18 + log.error("调用场站管理接口异常",throwable);
  19 + return new StationManageFeignService() {
  20 + @Override
  21 + public ResultJson getChanels(String channel, int pageNum, int pageSize) {
  22 + return new ResultJson("410","场站管理服务接口访问失败");
  23 + }
  24 + };
  25 + }
  26 +}
  1 +package com.sy.service.feigin;
  2 +
  3 +
  4 +import com.sy.response.ResultJson;
  5 +import org.springframework.cloud.openfeign.FeignClient;
  6 +import org.springframework.web.bind.annotation.GetMapping;
  7 +import org.springframework.web.bind.annotation.RequestParam;
  8 +
  9 +/**
  10 + * 金二报文发送接口
  11 + * @author mrz
  12 + */
  13 +@FeignClient(name = "STATION-MANAGE",fallbackFactory = StationManageFallBackFactory.class)
  14 +public interface StationManageFeignService {
  15 +
  16 + @GetMapping("/bayonet/page")
  17 + ResultJson getChanels(@RequestParam(value = "channel") String channel,@RequestParam(value = "pageNum") int pageNum,@RequestParam(value = "pageSize") int pageSize);
  18 +}
  19 +
@@ -209,11 +209,10 @@ public class EnginCheckServiceImpl implements EnginCheckService { @@ -209,11 +209,10 @@ public class EnginCheckServiceImpl implements EnginCheckService {
209 } 209 }
210 210
211 log.info(String.format("开始发送指令:车牌%s,场站%s,通道%s,重量%s",info.getVename(),info.getAreaid(),info.getChnlno(),info.getGrosswt())); 211 log.info(String.format("开始发送指令:车牌%s,场站%s,通道%s,重量%s",info.getVename(),info.getAreaid(),info.getChnlno(),info.getGrosswt()));
212 - boolean flag = false; 212 +
213 if (check) { 213 if (check) {
214 CommandClient.Client(info, PERMITTHOUGH); 214 CommandClient.Client(info, PERMITTHOUGH);
215 log.info("=============>>>>>>>>放行报文发送成功<<<<<<<<<=============="); 215 log.info("=============>>>>>>>>放行报文发送成功<<<<<<<<<==============");
216 - flag = true;  
217 record(info,executeParams); 216 record(info,executeParams);
218 217
219 //总进出车次计数 218 //总进出车次计数
@@ -233,6 +232,11 @@ public class EnginCheckServiceImpl implements EnginCheckService { @@ -233,6 +232,11 @@ public class EnginCheckServiceImpl implements EnginCheckService {
233 sendBw(info,true,PERMITTHOUGH,executeParams); 232 sendBw(info,true,PERMITTHOUGH,executeParams);
234 } 233 }
235 234
  235 + @Override
  236 + public void passFaild(GatherInfo info,String reason,ExecuteParams executeParams) {
  237 + sendBw(info,false,reason,executeParams);
  238 + }
  239 +
236 /** 240 /**
237 * 记录进出区信息 241 * 记录进出区信息
238 */ 242 */
  1 +package com.sy.service.impl;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.sy.model.DxpMsg;
  5 +import com.sy.model.GatherInfo;
  6 +import com.sy.model.X82Feedback;
  7 +import com.sy.service.CommandLogService;
  8 +import com.sy.service.RedisService;
  9 +import com.sy.service.X82Service;
  10 +import com.thoughtworks.xstream.XStream;
  11 +import com.thoughtworks.xstream.converters.Converter;
  12 +import com.thoughtworks.xstream.converters.MarshallingContext;
  13 +import com.thoughtworks.xstream.converters.UnmarshallingContext;
  14 +import com.thoughtworks.xstream.io.HierarchicalStreamReader;
  15 +import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
  16 +import com.thoughtworks.xstream.io.xml.DomDriver;
  17 +import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
  18 +import lombok.extern.slf4j.Slf4j;
  19 +import org.apache.commons.lang.StringUtils;
  20 +import org.springframework.beans.factory.annotation.Autowired;
  21 +import org.springframework.stereotype.Service;
  22 +
  23 +import java.text.ParseException;
  24 +import java.text.SimpleDateFormat;
  25 +import java.util.Date;
  26 +
  27 +@Service
  28 +@Slf4j
  29 +public class X82ServiceImpl implements X82Service {
  30 +
  31 + @Autowired
  32 + private RedisService redisService;
  33 +
  34 + @Autowired
  35 + private CommandLogService commandLogService;
  36 +
  37 + @Override
  38 + public DxpMsg analysis(String response) {
  39 + XStream xstream = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("_-", "_")));
  40 + xstream.processAnnotations(DxpMsg.class);
  41 + //对xstream对象设置默认的安全防护
  42 + XStream.setupDefaultSecurity(xstream);
  43 + //对xstream对象设置默认的安全防护时,允许设置类
  44 + xstream.allowTypes(new Class[]{DxpMsg.class});
  45 + return (DxpMsg) xstream.fromXML(response);
  46 + }
  47 +
  48 + @Override
  49 + public X82Feedback x82Analysis(String xml) {
  50 + XStream xstream = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("_-", "_")));
  51 +
  52 + xstream.processAnnotations(X82Feedback.class);
  53 + //对xstream对象设置默认的安全防护
  54 + XStream.setupDefaultSecurity(xstream);
  55 + //对xstream对象设置默认的安全防护时,允许设置类
  56 + xstream.allowTypes(new Class[]{X82Feedback.class});
  57 + return (X82Feedback) xstream.fromXML(xml);
  58 + }
  59 +
  60 + @Override
  61 + public Boolean X82ReleaseCheck(X82Feedback var) {
  62 + log.info("[X82-Result]金二验放结果-{}-{}",var.getCheckResult(),var.getOpHint());
  63 + if ("Y".equals(var.getCheckResult().trim()) || "1".equals(var.getCheckResult().trim())) {
  64 + return true;
  65 + }
  66 + return false;
  67 + }
  68 +
  69 + /**
  70 + * 根据seqno 获取缓存的X21信息
  71 + * @param seqno
  72 + * @return x21的gatherInfo
  73 + */
  74 + @Override
  75 + public GatherInfo readCacheWithSeqno(String seqno){
  76 + if (StringUtils.isNotEmpty(seqno)) {
  77 + String X21_GatherInfo = redisService.get(seqno);
  78 + if (StringUtils.isNotEmpty(X21_GatherInfo)){
  79 + GatherInfo gatherInfo = JSON.parseObject(X21_GatherInfo, GatherInfo.class);
  80 + return gatherInfo;
  81 + }
  82 + }
  83 + return null;
  84 + }
  85 +
  86 + @Override
  87 + public GatherInfo X82FeedBackToX21GatherInfo(X82Feedback var) {
  88 + GatherInfo gatherInfo = new GatherInfo();
  89 + gatherInfo.setAreaid(var.getAreaId());
  90 + gatherInfo.setChnlno(var.getChannelNo());
  91 + gatherInfo.setSeqno(var.getSessionId());
  92 +
  93 + return gatherInfo;
  94 + }
  95 +
  96 + public static class DateConverter implements Converter {
  97 + private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSXXX";
  98 + private final SimpleDateFormat dateFormat;
  99 +
  100 + public DateConverter() {
  101 + this.dateFormat = new SimpleDateFormat(DATE_FORMAT);
  102 + }
  103 +
  104 + @Override
  105 + public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext context) {
  106 + // Not used for unmarshalling
  107 + }
  108 +
  109 + @Override
  110 + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
  111 + String dateString = reader.getValue();
  112 + try {
  113 + return dateFormat.parse(dateString);
  114 + } catch (ParseException e) {
  115 + throw new IllegalArgumentException("Error parsing date string: " + dateString, e);
  116 + }
  117 + }
  118 +
  119 + @Override
  120 + public boolean canConvert(Class aClass) {
  121 + return aClass.equals(Date.class);
  122 + }
  123 +
  124 +
  125 + }
  126 +
  127 +
  128 +}
  1 +package com.sy.service.router;
  2 +
  3 +import com.sy.bwAssist.Message;
  4 +import com.sy.model.GatherInfo;
  5 +
  6 +/**
  7 + * 卡口业务报文处理路由
  8 + * 处理接收的卡口报文X22与X21,
  9 + * 并根据路由表,决定X21报文是否发送给金二,由金二验放处理,并本地记录.还是不发金二本地验放处理
  10 + * 集中核销流转申请.
  11 + * @author mrz
  12 + */
  13 +public interface MessageRouterG2 {
  14 + /**
  15 + * X82报文实体路由处理
  16 + */
  17 + void route(GatherInfo gatherInfo,String reason);
  18 +
  19 + /**
  20 + * 不放行处理
  21 + */
  22 + void faild(GatherInfo gatherInfo,String reason);
  23 +
  24 +
  25 +
  26 +
  27 +}
  1 +package com.sy.service.router;
  2 +
  3 +import com.sy.bwAssist.Message;
  4 +import com.sy.model.GatherInfo;
  5 +import com.sy.service.CommandLogService;
  6 +import com.sy.service.EnginCheckService;
  7 +import lombok.extern.slf4j.Slf4j;
  8 +import org.basis.enhance.groovy.entity.ExecuteParams;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.stereotype.Service;
  11 +
  12 +@Slf4j
  13 +@Service("X82")
  14 +public class MessageRouterX82 implements MessageRouterG2 {
  15 +
  16 + @Autowired
  17 + private EnginCheckService enginCheckService;
  18 +
  19 + @Autowired
  20 + private CommandLogService commandLogService;
  21 +
  22 + @Override
  23 + public void route(GatherInfo gatherInfo,String reason) {
  24 + log.info("[G2-SUCCESS]-金二验放通过,下放最终抬杆指令.");
  25 + enginCheck(gatherInfo,reason);
  26 + }
  27 +
  28 + @Override
  29 + public void faild(GatherInfo gatherInfo,String reason) {
  30 + commandLogService.commandlog(gatherInfo,false,"金二验放失败,原因:"+reason,null,null,0.0,0.0,0.0,0.0);
  31 + ExecuteParams executeParams = enginCheckService.makeParaByGagherInfo(gatherInfo);
  32 + enginCheckService.passFaild(gatherInfo,reason,executeParams);
  33 + log.info("[G2-FEEDBACK-CHECK-FAILD]-{}",reason);
  34 +
  35 + }
  36 +
  37 + public void enginCheck(GatherInfo gatherInfo,String reason){
  38 + commandLogService.commandlog(gatherInfo,true,"金二验放通过"+reason,null,null,0.0,0.0,0.0,0.0);
  39 + ExecuteParams executeParams = enginCheckService.makeParaByGagherInfo(gatherInfo);
  40 +
  41 + enginCheckService.pass(gatherInfo,executeParams);
  42 +
  43 + enginCheckService.formRelease(gatherInfo,executeParams);
  44 +
  45 + log.info("引擎验放完结");
  46 + }
  47 +}
  1 +package com.sy.utils;
  2 +
  3 +import lombok.extern.slf4j.Slf4j;
  4 +
  5 +import java.io.UnsupportedEncodingException;
  6 +import java.nio.charset.StandardCharsets;
  7 +import java.util.Base64;
  8 +
  9 +@Slf4j
  10 +public class Base64Tool {
  11 +
  12 + public static String encodeUtf8ToUtf8(String content){
  13 + String encodeToString = Base64.getEncoder().encodeToString(content.getBytes(StandardCharsets.UTF_8));
  14 + log.info("[BASE64-ENCODE] = {}" , encodeToString);
  15 + return encodeToString;
  16 + }
  17 +
  18 + public static String decodeUtf8ToUtf8(String encodeStr){
  19 + byte[] base64decodedBytes = Base64.getDecoder().decode(encodeStr);
  20 + String resoult = new String(base64decodedBytes, StandardCharsets.UTF_8);
  21 + log.info("[BASE64-DECODE]={}",resoult);
  22 + return resoult;
  23 + }
  24 +}
  1 +package com.sy.utils;
  2 +
  3 +import java.util.concurrent.LinkedBlockingQueue;
  4 +import java.util.concurrent.ThreadPoolExecutor;
  5 +import java.util.concurrent.TimeUnit;
  6 +
  7 +public class G2ThreadPoolFactory {
  8 +
  9 + private static ThreadPoolExecutor threadPool;
  10 +
  11 + public static ThreadPoolExecutor instance(String busstype){
  12 + if (threadPool==null){
  13 + XMLThreadFactory xmlThreadFactory = new XMLThreadFactory(busstype);
  14 + threadPool = new ThreadPoolExecutor(10, 200,
  15 + 1L, TimeUnit.SECONDS,
  16 + new LinkedBlockingQueue<Runnable>(4000),
  17 + xmlThreadFactory,
  18 + new ThreadPoolExecutor.AbortPolicy());
  19 +
  20 + }
  21 + return threadPool;
  22 + }
  23 +}
  1 +package com.sy;
  2 +
  3 +import com.sy.model.G2X81Template;
  4 +import lombok.extern.slf4j.Slf4j;
  5 +import org.junit.runner.RunWith;
  6 +import org.junit.Test;
  7 +import org.springframework.boot.test.context.SpringBootTest;
  8 +import org.springframework.test.context.junit4.SpringRunner;
  9 +
  10 +import java.io.UnsupportedEncodingException;
  11 +import java.nio.charset.Charset;
  12 +import java.util.Base64;
  13 +
  14 +@RunWith(SpringRunner.class)
  15 +@SpringBootTest
  16 +@Slf4j
  17 +public class Base64Test {
  18 +
  19 + @Test
  20 + public void base64Encode(){
  21 + String encode = "<?xml version='1.0' encoding='UTF-8'?><GATHER_FEEDBACK xmlns=\"http://rpb.customs.gov.cn/common/FrontEndSchemas/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema\"><AREA_ID>4604000006</AREA_ID><CHNL_NO>46040012232</CHNL_NO><SESSION_ID>20220630184441000028</SESSION_ID><FEEDBACK_TIME>2023-08-20 15:07:16</FEEDBACK_TIME><CHECK_RESULT>1</CHECK_RESULT><OP_HINT>海关放行</OP_HINT></GATHER_FEEDBACK>";
  22 + String encodeToString = Base64.getEncoder().encodeToString(encode.getBytes(Charset.forName("utf-8")));
  23 + System.out.println("encodeToString = " + encodeToString);
  24 + }
  25 +
  26 + @Test
  27 + public void base64Decode(){
  28 + String testcode = "PD94bWwgdmVyc2lvbj0nMS4wJyBlbmNvZGluZz0nVVRGLTgnPz48R0FUSEVSX0ZFRURCQUNLIHhtbG5zPSJodHRwOi8vcnBiLmN1c3RvbXMuZ292LmNuL2NvbW1vbi9Gcm9udEVuZFNjaGVtYXMvIiB4bWxuczp4c2k9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEvWE1MU2NoZW1hIj48QVJFQV9JRD40NjA0MDAwMDA2PC9BUkVBX0lEPjxDSE5MX05PPjQ2MDQwMDEyMjMyPC9DSE5MX05PPjxTRVNTSU9OX0lEPjIwMjIwNjMwMTg0NDQxMDAwMDI4PC9TRVNTSU9OX0lEPjxGRUVEQkFDS19USU1FPjIwMjMtMDgtMjAgMTU6MDc6MTY8L0ZFRURCQUNLX1RJTUU+PENIRUNLX1JFU1VMVD4wPC9DSEVDS19SRVNVTFQ+PE9QX0hJTlQ+55S15a2Q6L2m54mMOjrkuI3mlL7ooYzvvJrmib7kuI3liLDlr7nlupTnmoTmoLjmlL7ljZXvvIzkuI3kuojmlL7ooYw8L09QX0hJTlQ+PC9HQVRIRVJfRkVFREJBQ0s+";
  29 + byte[] base64decodedBytes = Base64.getDecoder().decode(testcode);
  30 + try {
  31 + System.out.println("解密后的信息为:"+new String(base64decodedBytes, "utf-8"));
  32 + } catch (UnsupportedEncodingException e) {
  33 + e.printStackTrace();
  34 + }
  35 + }
  36 +
  37 + @Test
  38 + public void replaceTest(){
  39 + String x81XML= G2X81Template.template.replace("#{ie_flag1}","I")
  40 + .replace("#{area_id}","stationG2")
  41 + .replace("#{chnl_no}","channelG2")
  42 + .replace("#{session_id}","123")
  43 + .replace("#{ve_license_no}","豫A61CR7")
  44 + .replace("#{rfid_id}","AFFC231321")
  45 + .replace("#{ve_wt}","1234.2")
  46 + .replace("#{operate_time}","2023-07-23 12:01:32");
  47 + System.out.println("x81XML = " + x81XML);
  48 + }
  49 +}
  1 +package com.sy;
  2 +
  3 +import com.sy.model.DxpMsg;
  4 +import com.sy.model.X82Feedback;
  5 +import com.thoughtworks.xstream.XStream;
  6 +import com.thoughtworks.xstream.converters.Converter;
  7 +import com.thoughtworks.xstream.converters.MarshallingContext;
  8 +import com.thoughtworks.xstream.converters.UnmarshallingContext;
  9 +import com.thoughtworks.xstream.io.HierarchicalStreamReader;
  10 +import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
  11 +import com.thoughtworks.xstream.io.xml.DomDriver;
  12 +import com.thoughtworks.xstream.io.xml.XmlFriendlyNameCoder;
  13 +
  14 +import java.text.ParseException;
  15 +import java.text.SimpleDateFormat;
  16 +import java.util.Date;
  17 +
  18 +public class X82Test {
  19 +
  20 + static String dxpmsg="<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
  21 + "<DxpMsg ver=\"1.0\" xmlns=\"http://www.chinaport.gov.cn/dxp\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
  22 + "\t<TransInfo>\n" +
  23 + "\t\t<CopMsgId>256afcf4887d49a2840ec24b78ed1755</CopMsgId>\n" +
  24 + "\t\t<SenderId>GJCKK00000000001</SenderId>\n" +
  25 + "\t\t<ReceiverIds>\n" +
  26 + "\t\t\t<ReceiverId>GDXPKK0000000002</ReceiverId>\n" +
  27 + "\t\t</ReceiverIds>\n" +
  28 + "\t\t<CreatTime>2022-08-17T15:00:52</CreatTime>\n" +
  29 + "\t\t<MsgType>JCKK</MsgType>\n" +
  30 + "\t</TransInfo>\n" +
  31 + "\t<Data>4lxLiQICAAAiNDYwNDYwMDAwMDQ2MDQ2MDEwMTFJ/////9oBAAA8Q09NTUFORF9JTkZPIEFSRUFfSUQ9IjQ2MDQ2MDAwMDAiIENITkxfTk89IjQ2MDQ2MDEwMTEiIElfRV9UWVBFPSJJIiBTRVFfTk89IjIwMjIwODE3MTQ0MjE1NjEwMDEwIj4KICAgIDxDSEVDS19SRVNVTFQ+MTEwMDAwMDAwMDAwMDAwMDAwMDA8L0NIRUNLX1JFU1VMVD4KICAgIDxPUF9ISU5UPrbByKGyu7W9tP3R6brLyv2+3TwvT1BfSElOVD4KICAgIDxHUFM+CiAgICAgICAgPFZFX05BTUU+PC9WRV9OQU1FPgogICAgICAgIDxHUFNfSUQ+PC9HUFNfSUQ+CiAgICAgICAgPE9SSUdJTl9DVVNUT01TPjwvT1JJR0lOX0NVU1RPTVM+CiAgICAgICAgPERFU1RfQ1VTVE9NUz48L0RFU1RfQ1VTVE9NUz4KICAgIDwvR1BTPgogICAgPFNFQUw+CiAgICAgICAgPEVTRUFMX0lEPjwvRVNFQUxfSUQ+CiAgICAgICAgPFNFQUxfS0VZPjwvU0VBTF9LRVk+CiAgICA8L1NFQUw+CiAgICA8Rk9STV9JRD48L0ZPUk1fSUQ+CjwvQ09NTUFORF9JTkZPPgr//w==</Data>\n" +
  32 + "\t<AddInfo>\n" +
  33 + "\t\t<FileName>20220817150050391844.dat</FileName>\n" +
  34 + "\t</AddInfo>\n" +
  35 + "</DxpMsg>";
  36 +
  37 + static String x82 = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
  38 + "<GATHER_FEEDBACK xmlns=\"http://rpb.customs.gov.cn/common/FrontEndSchemas/\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\">\n" +
  39 + " <AREA_ID>123</AREA_ID>\n" +
  40 + " <CHNL_NO>456</CHNL_NO>\n" +
  41 + " <SESSION_ID>789</SESSION_ID>\n" +
  42 + " <RELLIST_TYPE>TypeA</RELLIST_TYPE>\n" +
  43 + " <RELLIST_ID_TYPE>IDType1</RELLIST_ID_TYPE>\n" +
  44 + " <RELLIST_ID>001</RELLIST_ID>\n" +
  45 + " <FEEDBACK_TIME>2022-07-15T14:23:51.4679206+08:00</FEEDBACK_TIME>\n" +
  46 + " <CHECK_RESULT>Y</CHECK_RESULT>\n" +
  47 + " <INSTRUCTION>设备A:操作</INSTRUCTION>\n" +
  48 + " <PROC_ERROR_CODE>100</PROC_ERROR_CODE>\n" +
  49 + " <PROC_ERROR_DESCRIPTION>Error description</PROC_ERROR_DESCRIPTION>\n" +
  50 + " <TECH_ERROR_CODE>200</TECH_ERROR_CODE>\n" +
  51 + " <TECH_ERROR_DESCRIPTION>Technical error</TECH_ERROR_DESCRIPTION>\n" +
  52 + " <IC_INFO>\n" +
  53 + " <IC_ID>IC001</IC_ID>\n" +
  54 + " <IC_NO>123456</IC_NO>\n" +
  55 + " <IC_TYPE>TypeA</IC_TYPE>\n" +
  56 + " <IC_EXTENDED_CONTENT>Extended content for IC card</IC_EXTENDED_CONTENT>\n" +
  57 + " </IC_INFO>\n" +
  58 + " <VE_INFO>\n" +
  59 + " <VE_CUSTOMS_NO>7890123</VE_CUSTOMS_NO>\n" +
  60 + " <VE_LICENSE_NO>ABC123</VE_LICENSE_NO>\n" +
  61 + " <VE_LICENSE_NO2>XYZ987</VE_LICENSE_NO2>\n" +
  62 + " <DR_CUSTOMS_NO>4567890</DR_CUSTOMS_NO>\n" +
  63 + " <DR_NAME>John Doe</DR_NAME>\n" +
  64 + " <TRAILER_ID>Trailer001</TRAILER_ID>\n" +
  65 + " <WEIGHT_DIFF>0.5</WEIGHT_DIFF>\n" +
  66 + " <CHANNEL_WEIGHT>1000.0</CHANNEL_WEIGHT>\n" +
  67 + " <GROSS_WEIGHT>2000.0</GROSS_WEIGHT>\n" +
  68 + " <VEHICLE_WEIGHT>1000.0</VEHICLE_WEIGHT>\n" +
  69 + " </VE_INFO>\n" +
  70 + " <CONTA_ID>Container001</CONTA_ID>\n" +
  71 + " <ESEAL_ID>ESeal001</ESEAL_ID>\n" +
  72 + " <SEAL_ID>Seal001</SEAL_ID>\n" +
  73 + " <FORM_INFO>\n" +
  74 + " <FORM_TYPE>TypeA</FORM_TYPE>\n" +
  75 + " <FORM_ID>Form001</FORM_ID>\n" +
  76 + " <MASTER_CUSTOMS_CODE>MasterCode</MASTER_CUSTOMS_CODE>\n" +
  77 + " </FORM_INFO>\n" +
  78 + " <PACK_NO>10</PACK_NO>\n" +
  79 + " <DECL_PACK>12</DECL_PACK>\n" +
  80 + " <DECL_GOODS_WEIGHT>5000.0</DECL_GOODS_WEIGHT>\n" +
  81 + " <OP_HINT>Operation hint message</OP_HINT>\n" +
  82 + " <LED_HINT>LED hint message</LED_HINT>\n" +
  83 + " <EXTENDED_CONTENT>Extended content</EXTENDED_CONTENT>\n" +
  84 + "</GATHER_FEEDBACK>\n";
  85 + public static void main(String[] args) {
  86 +
  87 + System.out.println(x82);
  88 +// DxpMsg analysis = analysis(dxpmsg);
  89 + X82Feedback x82Feedback = x82analysis(x82);
  90 + System.out.println("OK");
  91 +
  92 + }
  93 +
  94 + static DxpMsg analysis(String str) {
  95 + XStream xstream = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("_-", "_")));
  96 + xstream.processAnnotations(DxpMsg.class);
  97 + //对xstream对象设置默认的安全防护
  98 + XStream.setupDefaultSecurity(xstream);
  99 + //对xstream对象设置默认的安全防护时,允许设置类
  100 + xstream.allowTypes(new Class[]{DxpMsg.class});
  101 + return (DxpMsg) xstream.fromXML(str);
  102 + }
  103 +
  104 + static X82Feedback x82analysis(String str) {
  105 + XStream xstream = new XStream(new DomDriver("UTF-8", new XmlFriendlyNameCoder("_-", "_")));
  106 + // 注册自定义转换器
  107 + xstream.registerConverter(new DateConverter());
  108 + xstream.processAnnotations(X82Feedback.class);
  109 + //对xstream对象设置默认的安全防护
  110 + XStream.setupDefaultSecurity(xstream);
  111 + //对xstream对象设置默认的安全防护时,允许设置类
  112 + xstream.allowTypes(new Class[]{X82Feedback.class});
  113 + return (X82Feedback) xstream.fromXML(str);
  114 + }
  115 +
  116 + public static class DateConverter implements Converter {
  117 + private static final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss.SSSSSSSXXX";
  118 + private final SimpleDateFormat dateFormat;
  119 +
  120 + public DateConverter() {
  121 + this.dateFormat = new SimpleDateFormat(DATE_FORMAT);
  122 + }
  123 +
  124 + @Override
  125 + public void marshal(Object o, HierarchicalStreamWriter writer, MarshallingContext context) {
  126 + // Not used for unmarshalling
  127 + }
  128 +
  129 + @Override
  130 + public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
  131 + String dateString = reader.getValue();
  132 + try {
  133 + return dateFormat.parse(dateString);
  134 + } catch (ParseException e) {
  135 + throw new IllegalArgumentException("Error parsing date string: " + dateString, e);
  136 + }
  137 + }
  138 +
  139 + @Override
  140 + public boolean canConvert(Class aClass) {
  141 + return aClass.equals(Date.class);
  142 + }
  143 +
  144 +
  145 + }
  146 +}
  147 +