作者 zhangFan

kakoIMF check some message

@@ -96,6 +96,12 @@ @@ -96,6 +96,12 @@
96 <version>1.2.47</version> 96 <version>1.2.47</version>
97 </dependency> 97 </dependency>
98 98
  99 + <!-- 二维码 -->
  100 + <dependency>
  101 + <groupId>com.google.zxing</groupId>
  102 + <artifactId>core</artifactId>
  103 + <version>3.3.0</version>
  104 + </dependency>
99 105
100 <!--IMF need jar--> 106 <!--IMF need jar-->
101 <dependency> 107 <dependency>
@@ -22,8 +22,7 @@ public class KAKO_Reader extends Thread{ @@ -22,8 +22,7 @@ public class KAKO_Reader extends Thread{
22 String message = this.client.getMSG(); 22 String message = this.client.getMSG();
23 if (message != null) { 23 if (message != null) {
24 logger.info(message); 24 logger.info(message);
25 - AnalysisRoute route = new AnalysisRoute();  
26 - route.analysis(message); 25 + AnalysisRoute.analysis(message);
27 } 26 }
28 } 27 }
29 else { 28 else {
@@ -32,6 +32,9 @@ public class AnalysisRoute { @@ -32,6 +32,9 @@ public class AnalysisRoute {
32 @Autowired 32 @Autowired
33 private CommandInfoService commandService; 33 private CommandInfoService commandService;
34 34
  35 + @Autowired
  36 + private LandBusListService listService;
  37 +
35 private static AnalysisRoute route; 38 private static AnalysisRoute route;
36 39
37 private static MessageAnalysis analysis = new MessageAnalysis(); 40 private static MessageAnalysis analysis = new MessageAnalysis();
@@ -51,9 +54,10 @@ public class AnalysisRoute { @@ -51,9 +54,10 @@ public class AnalysisRoute {
51 route.gatService = this.gatService; 54 route.gatService = this.gatService;
52 route.infoService = this.infoService; 55 route.infoService = this.infoService;
53 route.commandService = this.commandService; 56 route.commandService = this.commandService;
  57 + route.listService = this.listService;
54 } 58 }
55 59
56 - public void analysis(String string) { 60 + public static void analysis(String string) {
57 Message message = analysis.readTicketsXml(string); 61 Message message = analysis.readTicketsXml(string);
58 String stype = message.getMeta().getSmType(); 62 String stype = message.getMeta().getSmType();
59 if (stype.equals("CARM")) { 63 if (stype.equals("CARM")) {
@@ -62,8 +66,9 @@ public class AnalysisRoute { @@ -62,8 +66,9 @@ public class AnalysisRoute {
62 route.commandService.save(info); 66 route.commandService.save(info);
63 }else{ 67 }else{
64 GatherInfo info = gatherInfoAnalysis.toJavaBean(message); 68 GatherInfo info = gatherInfoAnalysis.toJavaBean(message);
  69 + if(LogicOperation.operation(info)){
  70 + }
65 route.infoService.save(info); 71 route.infoService.save(info);
66 - LogicOperation.operation(info);  
67 } 72 }
68 } else if (stype.equals("ES1")) { 73 } else if (stype.equals("ES1")) {
69 airone_ex_stock exStock = exStockAnalysis.toExStock(message); 74 airone_ex_stock exStock = exStockAnalysis.toExStock(message);
@@ -22,6 +22,7 @@ public class CommandInfoAnalysis { @@ -22,6 +22,7 @@ public class CommandInfoAnalysis {
22 bean.setChnlNo(info.getCHNL_NO()); 22 bean.setChnlNo(info.getCHNL_NO());
23 bean.setiEType(info.getI_E_TYPE()); 23 bean.setiEType(info.getI_E_TYPE());
24 bean.setSeqNo(info.getSEQ_NO()); 24 bean.setSeqNo(info.getSEQ_NO());
  25 + bean.setCheckResult(info.getCheckResult());
25 bean.setEsealId(info.getSeal().getEsealId()); 26 bean.setEsealId(info.getSeal().getEsealId());
26 bean.setSealKey(info.getSeal().getSealKey()); 27 bean.setSealKey(info.getSeal().getSealKey());
27 bean.setVeName(info.getGps().getVeName()); 28 bean.setVeName(info.getGps().getVeName());
@@ -34,6 +34,9 @@ public class CommandInfo { @@ -34,6 +34,9 @@ public class CommandInfo {
34 @XStreamAlias("SEAL") 34 @XStreamAlias("SEAL")
35 private Seal seal; 35 private Seal seal;
36 36
  37 + @XStreamAlias("SZ_MSG")
  38 + private Seal seMsg;
  39 +
37 40
38 41
39 public String getAREA_ID() { 42 public String getAREA_ID() {
@@ -106,4 +109,12 @@ public class CommandInfo { @@ -106,4 +109,12 @@ public class CommandInfo {
106 public void setFormId(String formId) { 109 public void setFormId(String formId) {
107 this.formId = formId; 110 this.formId = formId;
108 } 111 }
  112 +
  113 + public Seal getSeMsg() {
  114 + return seMsg;
  115 + }
  116 +
  117 + public void setSeMsg(Seal seMsg) {
  118 + this.seMsg = seMsg;
  119 + }
109 } 120 }
@@ -14,6 +14,12 @@ public class Seal { @@ -14,6 +14,12 @@ public class Seal {
14 @XStreamAlias("CONTA_NUM") 14 @XStreamAlias("CONTA_NUM")
15 private String countNum; 15 private String countNum;
16 16
  17 + @XStreamAlias("OPEN_TIMES")
  18 + private String openTimes;
  19 +
  20 + @XStreamAlias("ESEAL_IC_NO")
  21 + private String EsealIdNo;
  22 +
17 23
18 public String getEsealId() { 24 public String getEsealId() {
19 return EsealId; 25 return EsealId;
@@ -38,6 +44,22 @@ public class Seal { @@ -38,6 +44,22 @@ public class Seal {
38 public void setCountNum(String countNum) { 44 public void setCountNum(String countNum) {
39 this.countNum = countNum; 45 this.countNum = countNum;
40 } 46 }
  47 +
  48 + public String getOpenTimes() {
  49 + return openTimes;
  50 + }
  51 +
  52 + public void setOpenTimes(String openTimes) {
  53 + this.openTimes = openTimes;
  54 + }
  55 +
  56 + public String getEsealIdNo() {
  57 + return EsealIdNo;
  58 + }
  59 +
  60 + public void setEsealIdNo(String esealIdNo) {
  61 + EsealIdNo = esealIdNo;
  62 + }
41 } 63 }
42 64
43 65
  1 +package com.sy.crossDomain;
  2 +
  3 +import com.alibaba.fastjson.JSON;
  4 +import com.alibaba.fastjson.JSONArray;
  5 +import com.alibaba.fastjson.JSONObject;
  6 +import org.springframework.stereotype.Component;
  7 +
  8 +import java.io.BufferedReader;
  9 +import java.io.IOException;
  10 +import java.io.InputStreamReader;
  11 +import java.io.OutputStreamWriter;
  12 +import java.net.HttpURLConnection;
  13 +import java.net.MalformedURLException;
  14 +import java.net.URL;
  15 +import java.util.Map;
  16 +
  17 +
  18 +@Component
  19 +public class buildBarCode {
  20 +
  21 + private static String CREATEBARCODE = "http://10.50.7.11:8088/publiclogistics/createVehicleBarCode";
  22 + private static String CANCLEBARCODE = "http://10.50.7.11:8088/publiclogistics/cancelVehicleBarCode";
  23 +
  24 + // 发送数据并接收返回数据
  25 + public static String sendData(String url, String json) {
  26 + StringBuilder str = new StringBuilder();
  27 + BufferedReader bf = null;
  28 + OutputStreamWriter writer = null;
  29 + try {
  30 + URL Url = new URL(url);
  31 + HttpURLConnection conn = (HttpURLConnection) Url.openConnection();
  32 + conn.setDoInput(true);
  33 + conn.setDoOutput(true);
  34 + conn.setRequestProperty("X-Rrquested-With", "XMLHttpRequest");
  35 + conn.setRequestProperty("Connection", "keep-alive");
  36 + conn.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
  37 + conn.setRequestMethod("POST");
  38 + conn.connect();
  39 + writer = new OutputStreamWriter(conn.getOutputStream(), "UTF-8");
  40 + writer.write(json);
  41 + writer.flush();
  42 + bf = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
  43 + String inputLine = null;
  44 + while ((inputLine = bf.readLine()) != null) {
  45 + str.append(inputLine);
  46 + }
  47 + } catch (MalformedURLException e) {
  48 + e.printStackTrace();
  49 + } catch (IOException e) {
  50 + e.printStackTrace();
  51 + } finally {
  52 + try {
  53 + writer.close();
  54 + bf.close();
  55 + } catch (IOException e) {
  56 + e.printStackTrace();
  57 + }
  58 + }
  59 + return str.toString();
  60 + }
  61 +
  62 + // 解析返回的json里的data数据
  63 + public static Map jsonFormat(String json) {
  64 + JSONObject jsonObject = JSONObject.parseObject(json);
  65 + Object data = jsonObject.get("data");
  66 + String content = "[" + data.toString() + "]";
  67 + JSONArray jsonArray = JSONArray.parseArray(content);
  68 + Map map = JSON.parseObject(jsonArray.getString(0));
  69 + return map;
  70 + }
  71 +
  72 + // 生成二维码
  73 + public static String CreateBarCode(String carCode,String carColor,String mainifist) {
  74 + String json = "{\"token\":\"samples\",\"data\":{\"vehicle_no\":\""+carCode+"\",\"vehicle_no_color\":\""
  75 + +carColor+"\",\"vehicle_rela_id\":\""+mainifist+"\"}}";
  76 + String content = buildBarCode.sendData(CREATEBARCODE, json);
  77 + Map map = buildBarCode.jsonFormat(content);
  78 + return map.get("vehicle_bar_code").toString();
  79 + }
  80 +
  81 + // 取消二维码
  82 + public static void cancleBarCode(String carCode,String carColor) {
  83 + String json = "{\"token\":\"samples\",\"data\":{\"vehicle_no\":\""+carCode+"\",\"vehicle_no_color\":\""+carColor+"\"}}";
  84 + buildBarCode.sendData(CANCLEBARCODE, json);
  85 + }
  86 +
  87 +}
@@ -3,6 +3,7 @@ package com.sy.logic; @@ -3,6 +3,7 @@ package com.sy.logic;
3 3
4 import com.alibaba.fastjson.JSON; 4 import com.alibaba.fastjson.JSON;
5 import com.alibaba.fastjson.JSONArray; 5 import com.alibaba.fastjson.JSONArray;
  6 +import com.sy.crossDomain.buildBarCode;
6 import com.sy.model.GatherInfo; 7 import com.sy.model.GatherInfo;
7 import com.sy.model.LandBusinessTypeList; 8 import com.sy.model.LandBusinessTypeList;
8 import com.sy.model.LandRoadVe; 9 import com.sy.model.LandRoadVe;
@@ -48,11 +49,12 @@ public class LogicOperation { @@ -48,11 +49,12 @@ public class LogicOperation {
48 //逻辑判断后的结果定义 49 //逻辑判断后的结果定义
49 private static String PERMITTHOUGH = "直接放行"; 50 private static String PERMITTHOUGH = "直接放行";
50 private static String GROWSSEXCETION = "禁止通行,重量不在可控范围"; 51 private static String GROWSSEXCETION = "禁止通行,重量不在可控范围";
  52 + private static String NORECORD = "车辆未备案";
51 private static String INPUTSTATION = "此车辆未做进站申请"; 53 private static String INPUTSTATION = "此车辆未做进站申请";
52 private static String ENTERSTATION = "此车辆未做出站申请"; 54 private static String ENTERSTATION = "此车辆未做出站申请";
53 55
54 @PostConstruct 56 @PostConstruct
55 - public void init(){ 57 + public void init() {
56 logic = this; 58 logic = this;
57 logic.listService = this.listService; 59 logic.listService = this.listService;
58 logic.veService = this.veService; 60 logic.veService = this.veService;
@@ -61,61 +63,76 @@ public class LogicOperation { @@ -61,61 +63,76 @@ public class LogicOperation {
61 /** 63 /**
62 * @Param info 卡口采集数据 64 * @Param info 卡口采集数据
63 * @Result 计算卡口采集数据并发送报文 65 * @Result 计算卡口采集数据并发送报文
64 - * */  
65 - public static void operation(GatherInfo info){ 66 + */
  67 + public static boolean operation(GatherInfo info) {
  68 + boolean result = false;
66 BigDecimal grosswt = info.getGrosswt(); 69 BigDecimal grosswt = info.getGrosswt();
67 //转为double类型 70 //转为double类型
68 double growssWt = grosswt.doubleValue(); 71 double growssWt = grosswt.doubleValue();
69 String ietype = info.getIetype(); 72 String ietype = info.getIetype();
70 - List<LandBusinessTypeList>lists = null;  
71 - LandRoadVe ve = logic.veService.selectByFrameNo(info.getIcvename());  
72 - if("E".equals(ietype)){ 73 + List<LandBusinessTypeList> lists = null;
  74 + String vaName = info.getVename();
  75 + LandRoadVe ve = logic.veService.selectByFrameNo(vaName);
  76 + if(ve ==null) return result;
  77 + if ("E".equals(ietype)) {
73 ietype = "出场站"; 78 ietype = "出场站";
74 - lists = logic.listService.selectByFrameNoAndType(info.getIcvename(),ietype);  
75 - for (LandBusinessTypeList list:lists) { 79 + lists = logic.listService.selectByFrameNoAndType(info.getVename(), ietype);
  80 + for (LandBusinessTypeList list : lists) {
76 //查询是否做了出场申请 81 //查询是否做了出场申请
77 - if(list.getContrastflag()=="" | list.getContrastflag()==null){ 82 + if (list.getContrastflag() == null || list.getContrastflag() == "" || list.getContrastflag().length() <= 0) {
78 //判断载货重量是否符合所设定的范围 83 //判断载货重量是否符合所设定的范围
79 - double goodsWt = GoodsWt(list.getMasterList(),"E"); 84 + double goodsWt = 0.0;
  85 + if (list.getMasterList().length() > 0) {
  86 + goodsWt = GoodsWt(list.getMasterList(), "I");
  87 + }
80 double selfWt = Double.parseDouble(ve.getSelfWt()); 88 double selfWt = Double.parseDouble(ve.getSelfWt());
81 - sendBw(info,growssWt,selfWt,goodsWt);  
82 - list.setContrastflag("已出站");  
83 - logic.listService.updateById(list);  
84 - if("货物流转".equals(list.getBusinesstype()) | "分拨分流".equals(list.getBusinesstype())){  
85 - if(list.getMasterList().length()>0) {  
86 - createTypeList(list); 89 + if (sendBw(info, growssWt, selfWt, goodsWt)) {
  90 + list.setContrastflag("已出站");
  91 + logic.listService.updateById(list);
  92 + if ("货物流转".equals(list.getBusinesstype()) | "分拨分流".equals(list.getBusinesstype())) {
  93 + if (list.getMasterList().length() > 0) {
  94 + createTypeList(list);
  95 + }
87 } 96 }
  97 + result = true;
88 } 98 }
89 - }else {  
90 - CommandClient.Client(info,ENTERSTATION); 99 + } else {
  100 + CommandClient.Client(info, ENTERSTATION);
91 } 101 }
92 } 102 }
93 - }else { 103 + } else {
94 ietype = "进场站"; 104 ietype = "进场站";
95 - lists = logic.listService.selectByFrameNoAndType(info.getIcvename(),ietype);  
96 - for (LandBusinessTypeList list:lists) { 105 + lists = logic.listService.selectByFrameNoAndType(info.getVename(), ietype);
  106 + for (LandBusinessTypeList list : lists) {
97 //查询是否做了出场申请 107 //查询是否做了出场申请
98 - if(list.getContrastflag()=="" | list.getContrastflag()==null){ 108 + if (list.getContrastflag() == null || list.getContrastflag() == "" || list.getContrastflag().length
  109 + () <= 0) {
99 //判断载货重量是否符合所设定的范围 110 //判断载货重量是否符合所设定的范围
100 - double goodsWt = GoodsWt(list.getMasterList(),"I"); 111 + double goodsWt = 0.0;
  112 + if(list.getMasterList().length() > 0){
  113 + goodsWt = GoodsWt(list.getMasterList(), "E");
  114 + }
101 double selfWt = Double.parseDouble(ve.getSelfWt()); 115 double selfWt = Double.parseDouble(ve.getSelfWt());
102 - sendBw(info,growssWt,selfWt,goodsWt);  
103 - list.setContrastflag("已进站");  
104 - logic.listService.updateById(list);  
105 - }else {  
106 - CommandClient.Client(info,INPUTSTATION); 116 + if (sendBw(info, growssWt, selfWt, goodsWt)) {
  117 + list.setContrastflag("已进站");
  118 + logic.listService.updateById(list);
  119 + result = true;
  120 + }
  121 + } else {
  122 + CommandClient.Client(info, INPUTSTATION);
107 } 123 }
108 } 124 }
109 } 125 }
  126 + return result;
110 } 127 }
111 128
112 //将获取的checkWt进行小数转化 129 //将获取的checkWt进行小数转化
113 - public static double valueDob(){  
114 - NumberFormat nf=NumberFormat.getPercentInstance(); 130 + public static double valueDob() {
  131 + NumberFormat nf = NumberFormat.getPercentInstance();
115 Number m = null; 132 Number m = null;
116 try { 133 try {
117 - m=nf.parse(checkWt);//将百分数转换成Number类型  
118 - }catch (ParseException e){ 134 + m = nf.parse(checkWt);//将百分数转换成Number类型
  135 + } catch (ParseException e) {
119 e.printStackTrace(); 136 e.printStackTrace();
120 logger.info(e.getMessage()); 137 logger.info(e.getMessage());
121 } 138 }
@@ -127,13 +144,23 @@ public class LogicOperation { @@ -127,13 +144,23 @@ public class LogicOperation {
127 * @Param wt 车辆自重 144 * @Param wt 车辆自重
128 * @Param goodsWt 货物总重 145 * @Param goodsWt 货物总重
129 * @Result 获取运单重量 146 * @Result 获取运单重量
130 - * */ 147 + */
131 //校验载重和称重是否在合理的范围 148 //校验载重和称重是否在合理的范围
132 - public static boolean checkResult(double grossWt,double wt,double goodsWt){ 149 + public static boolean checkResult(double grossWt, double wt, double goodsWt) {
133 boolean flag = false; 150 boolean flag = false;
134 - double result = (grossWt-wt)/goodsWt; 151 + double result = 0.0;
  152 + if (goodsWt > 0) {
  153 + result = (grossWt - wt) / goodsWt;
  154 + if (result > 1) {
  155 + result = result - 1;
  156 + } else {
  157 + result = 1 - result;
  158 + }
  159 + } else {
  160 + result = (grossWt - wt);
  161 + }
135 BigDecimal bd = new BigDecimal(result); 162 BigDecimal bd = new BigDecimal(result);
136 - if(bd.setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue()<=valueDob()){ 163 + if (bd.setScale(3, BigDecimal.ROUND_HALF_UP).doubleValue() <= valueDob()) {
137 flag = true; 164 flag = true;
138 } 165 }
139 return flag; 166 return flag;
@@ -143,13 +170,13 @@ public class LogicOperation { @@ -143,13 +170,13 @@ public class LogicOperation {
143 * @Param mainifast 主单列表 170 * @Param mainifast 主单列表
144 * @Param ietype 进出标志 171 * @Param ietype 进出标志
145 * 获取货物总重 172 * 获取货物总重
146 - * */  
147 - public static double GoodsWt(String mainifast,String ietype){ 173 + */
  174 + public static double GoodsWt(String mainifast, String ietype) {
148 Double sum = 0.0; 175 Double sum = 0.0;
149 - if(mainifast.length()>0){  
150 - String [] mainifastList = mainifast.split(",");  
151 - for (String mainBill:mainifastList) {  
152 - sum = sum+=getGrossWt(mainBill,ietype); 176 + if (mainifast.length() > 0) {
  177 + String[] mainifastList = mainifast.split(",");
  178 + for (String mainBill : mainifastList) {
  179 + sum = sum += getGrossWt(mainBill, ietype);
153 } 180 }
154 } 181 }
155 return sum; 182 return sum;
@@ -160,15 +187,15 @@ public class LogicOperation { @@ -160,15 +187,15 @@ public class LogicOperation {
160 * @Param waybill 主单号 187 * @Param waybill 主单号
161 * @Param imp 进出港标识 188 * @Param imp 进出港标识
162 * @Result 获取运单重量 189 * @Result 获取运单重量
163 - * */ 190 + */
164 public static double getGrossWt(String waybill, String imp) { 191 public static double getGrossWt(String waybill, String imp) {
165 String url = "http://tjfx.15miaoo.com:8003/tj/orig/orig?waybill=" + waybill + "&imp=" + imp; 192 String url = "http://tjfx.15miaoo.com:8003/tj/orig/orig?waybill=" + waybill + "&imp=" + imp;
166 StringBuilder json = new StringBuilder(); 193 StringBuilder json = new StringBuilder();
167 Map map = null; 194 Map map = null;
168 double bg = 0; 195 double bg = 0;
169 try { 196 try {
170 - URL oracle = new URL(url);  
171 - URLConnection yc = oracle.openConnection(); 197 + URL Url = new URL(url);
  198 + URLConnection yc = Url.openConnection();
172 BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream())); 199 BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));
173 String inputLine = null; 200 String inputLine = null;
174 while ((inputLine = in.readLine()) != null) { 201 while ((inputLine = in.readLine()) != null) {
@@ -177,7 +204,8 @@ public class LogicOperation { @@ -177,7 +204,8 @@ public class LogicOperation {
177 JSONArray array = JSONArray.parseArray(json.toString()); 204 JSONArray array = JSONArray.parseArray(json.toString());
178 for (int i = 0; i < array.size(); i++) { 205 for (int i = 0; i < array.size(); i++) {
179 map = JSON.parseObject(array.getString(i)); 206 map = JSON.parseObject(array.getString(i));
180 - if (map.get("receiptinformation").toString().startsWith("41301")) { 207 + if (map.get("receiptinformation").toString().startsWith("41301") || map.get("receiptinformation")
  208 + .toString().startsWith("41106")) {
181 bg = Double.parseDouble((String) map.get("totalweight")); 209 bg = Double.parseDouble((String) map.get("totalweight"));
182 return bg; 210 return bg;
183 } 211 }
@@ -190,43 +218,50 @@ public class LogicOperation { @@ -190,43 +218,50 @@ public class LogicOperation {
190 } 218 }
191 return bg; 219 return bg;
192 } 220 }
  221 +
193 /** 222 /**
194 * 分拨或者流转业务生成新的进站申请 223 * 分拨或者流转业务生成新的进站申请
195 - * */  
196 - public static void createTypeList(LandBusinessTypeList list){ 224 + */
  225 + public static void createTypeList(LandBusinessTypeList list) {
197 LandBusinessTypeList typeList = new LandBusinessTypeList(); 226 LandBusinessTypeList typeList = new LandBusinessTypeList();
198 typeList.setId(UUIDCreate.getUUID()); 227 typeList.setId(UUIDCreate.getUUID());
199 typeList.setAgentname(list.getAgentname()); 228 typeList.setAgentname(list.getAgentname());
200 typeList.setAgentno(list.getAgentno()); 229 typeList.setAgentno(list.getAgentno());
201 - typeList.setAisle("1号卡口"); 230 + typeList.setAisle("1号卡口-进");
202 typeList.setCreateBy(list.getCreateBy()); 231 typeList.setCreateBy(list.getCreateBy());
203 typeList.setUpdateBy(list.getUpdateBy()); 232 typeList.setUpdateBy(list.getUpdateBy());
204 typeList.setCreateDate(new Date()); 233 typeList.setCreateDate(new Date());
205 typeList.setUpdateDate(new Date()); 234 typeList.setUpdateDate(new Date());
206 typeList.setCocode(list.getCocode()); 235 typeList.setCocode(list.getCocode());
207 typeList.setDriverid(list.getDriverid()); 236 typeList.setDriverid(list.getDriverid());
  237 + typeList.setDrivername(list.getDrivername());
208 typeList.setStartport(list.getEndport()); 238 typeList.setStartport(list.getEndport());
209 typeList.setStartsatation(list.getEndstation()); 239 typeList.setStartsatation(list.getEndstation());
210 typeList.setEndport(list.getStartport()); 240 typeList.setEndport(list.getStartport());
211 typeList.setEndstation(list.getStartsatation()); 241 typeList.setEndstation(list.getStartsatation());
212 typeList.setTrailerFrameNo(list.getTrailerFrameNo()); 242 typeList.setTrailerFrameNo(list.getTrailerFrameNo());
213 - typeList.setTrailerLicenseNo(list.getTrailerFrameNo()); 243 + typeList.setTrailerLicenseNo(list.getTrailerLicenseNo());
214 typeList.setTurnoverflag("进场站"); 244 typeList.setTurnoverflag("进场站");
215 typeList.setProdectTime(new Date()); 245 typeList.setProdectTime(new Date());
216 typeList.setMasterList(list.getMasterList()); 246 typeList.setMasterList(list.getMasterList());
217 typeList.setBusinesstype(list.getBusinesstype()); 247 typeList.setBusinesstype(list.getBusinesstype());
  248 + String barCode = buildBarCode.CreateBarCode(list.getTrailerFrameNo(),"",list.getMasterList());
  249 + typeList.setBarCode(barCode);
218 logic.listService.saveList(typeList); 250 logic.listService.saveList(typeList);
219 } 251 }
  252 +
220 /** 253 /**
221 - *校验重量并发送报文  
222 - * */  
223 -  
224 - public static void sendBw(GatherInfo info,double growsswWt,double selfWt,double goodsWt){  
225 - String flag = null;  
226 - if(checkResult(growsswWt,selfWt,goodsWt)){  
227 - CommandClient.Client(info,PERMITTHOUGH);  
228 - }else {  
229 - CommandClient.Client(info,GROWSSEXCETION); 254 + * 校验重量并发送报文
  255 + */
  256 +
  257 + public static boolean sendBw(GatherInfo info, double growsswWt, double selfWt, double goodsWt) {
  258 + boolean flag = false;
  259 + if (checkResult(growsswWt, selfWt, goodsWt)) {
  260 + CommandClient.Client(info, PERMITTHOUGH);
  261 + flag = true;
  262 + } else {
  263 + CommandClient.Client(info, GROWSSEXCETION);
230 } 264 }
  265 + return flag;
231 } 266 }
232 } 267 }
1 package com.sy.mapper; 1 package com.sy.mapper;
2 2
3 import com.sy.model.LandBusinessTypeList; 3 import com.sy.model.LandBusinessTypeList;
  4 +import org.apache.ibatis.annotations.Param;
4 import org.springframework.stereotype.Component; 5 import org.springframework.stereotype.Component;
5 6
6 import java.util.List; 7 import java.util.List;
@@ -18,5 +19,6 @@ public interface LandBusinessTypeListMapper { @@ -18,5 +19,6 @@ public interface LandBusinessTypeListMapper {
18 19
19 int updateByPrimaryKey(LandBusinessTypeList record); 20 int updateByPrimaryKey(LandBusinessTypeList record);
20 //根据车牌号和进出场标志查询 21 //根据车牌号和进出场标志查询
21 - List<LandBusinessTypeList> selectFrameNoAndType(String frameNo,String flag); 22 + List<LandBusinessTypeList> selectFrameNoAndType(@Param("trailerFrameNo") String frameNo,
  23 + @Param("turnoverflag") String flag);
22 } 24 }
@@ -51,6 +51,8 @@ public class LandBusinessTypeList { @@ -51,6 +51,8 @@ public class LandBusinessTypeList {
51 51
52 private Date updateDate; 52 private Date updateDate;
53 53
  54 + private String barCode;
  55 +
54 public String getId() { 56 public String getId() {
55 return id; 57 return id;
56 } 58 }
@@ -242,4 +244,12 @@ public class LandBusinessTypeList { @@ -242,4 +244,12 @@ public class LandBusinessTypeList {
242 public void setUpdateDate(Date updateDate) { 244 public void setUpdateDate(Date updateDate) {
243 this.updateDate = updateDate; 245 this.updateDate = updateDate;
244 } 246 }
  247 +
  248 + public String getBarCode() {
  249 + return barCode;
  250 + }
  251 +
  252 + public void setBarCode(String barCode) {
  253 + this.barCode = barCode;
  254 + }
245 } 255 }
@@ -17,7 +17,13 @@ public class LandBusListServiceImpl implements LandBusListService { @@ -17,7 +17,13 @@ public class LandBusListServiceImpl implements LandBusListService {
17 17
18 @Override 18 @Override
19 public List<LandBusinessTypeList> selectByFrameNoAndType(String frameNo, String flag) { 19 public List<LandBusinessTypeList> selectByFrameNoAndType(String frameNo, String flag) {
20 - List<LandBusinessTypeList> lists = listMapper.selectFrameNoAndType(frameNo,flag); 20 + List<LandBusinessTypeList> lists = null;
  21 + try{
  22 + lists = listMapper.selectFrameNoAndType(frameNo,flag);
  23 + }catch (Exception e){
  24 + e.printStackTrace();
  25 + System.out.println(e.getMessage());
  26 + }
21 return lists; 27 return lists;
22 } 28 }
23 29
@@ -29,7 +35,7 @@ public class LandBusListServiceImpl implements LandBusListService { @@ -29,7 +35,7 @@ public class LandBusListServiceImpl implements LandBusListService {
29 }catch (Exception e){ 35 }catch (Exception e){
30 e.printStackTrace(); 36 e.printStackTrace();
31 } 37 }
32 - return 0; 38 + return result;
33 } 39 }
34 40
35 @Override 41 @Override
@@ -3,11 +3,13 @@ package com.sy.service.impl; @@ -3,11 +3,13 @@ package com.sy.service.impl;
3 import com.sy.mapper.LandRoadVeMapper; 3 import com.sy.mapper.LandRoadVeMapper;
4 import com.sy.model.LandRoadVe; 4 import com.sy.model.LandRoadVe;
5 import com.sy.service.LandRoadVeService; 5 import com.sy.service.LandRoadVeService;
  6 +import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.stereotype.Service; 7 import org.springframework.stereotype.Service;
7 8
8 @Service 9 @Service
9 public class LandRoadVeServiceImpl implements LandRoadVeService { 10 public class LandRoadVeServiceImpl implements LandRoadVeService {
10 11
  12 + @Autowired
11 private LandRoadVeMapper veMapper; 13 private LandRoadVeMapper veMapper;
12 14
13 @Override 15 @Override
@@ -15,15 +15,16 @@ public class CommandClient { @@ -15,15 +15,16 @@ public class CommandClient {
15 private static final Logger logger = Logger.getLogger(CommandClient.class); 15 private static final Logger logger = Logger.getLogger(CommandClient.class);
16 16
17 /** 17 /**
18 - * @Param GatherInfo 所传卡口信息  
19 - * @Param flag 是否放行标识符 18 + * @Param GatherInfo 卡口采集信息
  19 + * @Param flag 是否放行信息
20 * */ 20 * */
21 public static void Client(GatherInfo info,String flag) { 21 public static void Client(GatherInfo info,String flag) {
22 String xmlBody = getXmlInfo(info,flag); 22 String xmlBody = getXmlInfo(info,flag);
23 Socket socket =null; 23 Socket socket =null;
24 OutputStream op = null; 24 OutputStream op = null;
25 try { 25 try {
26 - socket = new Socket("192.168.1.107", 9002); 26 + //ip+端口
  27 + socket = new Socket("10.50.7.10", 9003);
27 logger.info("socket通讯创建连接成功"); 28 logger.info("socket通讯创建连接成功");
28 op = socket.getOutputStream(); 29 op = socket.getOutputStream();
29 //xml字节流 30 //xml字节流
@@ -45,19 +46,20 @@ public class CommandClient { @@ -45,19 +46,20 @@ public class CommandClient {
45 byte[]eType =info.getIetype().getBytes("ASCII"); 46 byte[]eType =info.getIetype().getBytes("ASCII");
46 //标识符 47 //标识符
47 byte[] bwFlag = new byte[4]; 48 byte[] bwFlag = new byte[4];
48 - bwFlag[0]=(byte)0xFF;  
49 - bwFlag[1]=(byte)0xFF;  
50 - bwFlag[2]=(byte)0xFF;  
51 - bwFlag[3]=(byte)0xFF; 49 + bwFlag[0]=(byte)0x00;
  50 + bwFlag[1]=(byte)0x00;
  51 + bwFlag[2]=(byte)0x00;
  52 + bwFlag[3]=(byte)0x00;
52 //xml字节流长度 53 //xml字节流长度
53 byte[]xmlLength = intToByte4(xBody.length); 54 byte[]xmlLength = intToByte4(xBody.length);
54 //包尾 55 //包尾
55 byte[]end = new byte[2]; 56 byte[]end = new byte[2];
56 end[0]=(byte)0xFF; 57 end[0]=(byte)0xFF;
57 end[1]=(byte)0xFF; 58 end[1]=(byte)0xFF;
58 - //总长 59 + System.out.println();
  60 + //总长 4为总长的length
59 byte [] packge = intToByte4((head.length+xBody.length+mType.length+station.length+aisle.length+eType 61 byte [] packge = intToByte4((head.length+xBody.length+mType.length+station.length+aisle.length+eType
60 - .length+bwFlag.length+xmlLength.length+end.length)); 62 + .length+bwFlag.length+xmlLength.length+end.length+4));
61 byte[]allByte = byteMergerAll(head,packge,mType,station,aisle,eType,bwFlag,xmlLength,xBody,end); 63 byte[]allByte = byteMergerAll(head,packge,mType,station,aisle,eType,bwFlag,xmlLength,xBody,end);
62 op.write(allByte); 64 op.write(allByte);
63 op.flush(); 65 op.flush();
@@ -82,9 +84,9 @@ public class CommandClient { @@ -82,9 +84,9 @@ public class CommandClient {
82 private static String getXmlInfo(GatherInfo info,String message) { 84 private static String getXmlInfo(GatherInfo info,String message) {
83 String flag = null; 85 String flag = null;
84 if ("直接放行".equals(message)){ 86 if ("直接放行".equals(message)){
85 - flag = "11";  
86 - } else{  
87 flag = "00"; 87 flag = "00";
  88 + } else{
  89 + flag = "11";
88 } 90 }
89 StringBuffer buffer = new StringBuffer(); 91 StringBuffer buffer = new StringBuffer();
90 buffer.append("<COMMAND_INFO AREA_ID=\""+info.getAreaid()+"\" CHNL_NO=\""+info.getChnlno()+"\" I_E_TYPE=\""+info 92 buffer.append("<COMMAND_INFO AREA_ID=\""+info.getAreaid()+"\" CHNL_NO=\""+info.getChnlno()+"\" I_E_TYPE=\""+info
@@ -123,6 +125,7 @@ public class CommandClient { @@ -123,6 +125,7 @@ public class CommandClient {
123 return value; 125 return value;
124 } 126 }
125 127
  128 + //合并byte数据
126 private static byte[] byteMergerAll(byte[]... values) { 129 private static byte[] byteMergerAll(byte[]... values) {
127 int length_byte = 0; 130 int length_byte = 0;
128 for (int i = 0; i < values.length; i++) { 131 for (int i = 0; i < values.length; i++) {
@@ -42,7 +42,7 @@ public final class FileTool { @@ -42,7 +42,7 @@ public final class FileTool {
42 42
43 } 43 }
44 public static String readfile(File file) throws IOException{ 44 public static String readfile(File file) throws IOException{
45 - String fileToString = FileUtils.readFileToString(file, "UTF-8"); 45 + String fileToString = CharasetCheck.getUTF8String(FileUtils.readFileToString(file, "GB2312"));
46 return fileToString; 46 return fileToString;
47 } 47 }
48 48
@@ -14,15 +14,15 @@ spring.mvc.view.suffix=/WEB-INF/jsp/ @@ -14,15 +14,15 @@ spring.mvc.view.suffix=/WEB-INF/jsp/
14 #映射后缀 14 #映射后缀
15 spring.mvc.view.prefix=.jsp 15 spring.mvc.view.prefix=.jsp
16 #设置本地数据源 16 #设置本地数据源
17 -spring.datasource.username=root  
18 -spring.datasource.password=root  
19 -spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver  
20 -spring.datasource.url=jdbc:mysql://localhost:3306/bysj?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true&useSSL=true&serverTimezone=Asia/Shanghai  
21 -#设置线上数据源 17 +#spring.datasource.username=root
  18 +#spring.datasource.password=root
22 #spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver 19 #spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
23 -#spring.datasource.url=jdbc:mysql://10.50.7.10:3306/station?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true  
24 -#spring.datasource.username=kako  
25 -#spring.datasource.password=mysql10.50.7.10 20 +#spring.datasource.url=jdbc:mysql://localhost:3306/bysj?useUnicode=true&characterEncoding=utf8&autoReconnect=true&failOverReadOnly=false&allowMultiQueries=true&useSSL=true&serverTimezone=Asia/Shanghai
  21 +#设置线上数据源
  22 +spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
  23 +spring.datasource.url=jdbc:mysql://10.50.7.10:3306/station?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true
  24 +spring.datasource.username=kako
  25 +spring.datasource.password=mysql10.50.7.10
26 #连接池类 26 #连接池类
27 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource 27 spring.datasource.type=com.alibaba.druid.pool.DruidDataSource
28 #连接池配置,因为springboot默认是开启了连接池的,它有默认配置,这一段可以忽略 28 #连接池配置,因为springboot默认是开启了连接池的,它有默认配置,这一段可以忽略