正在显示
1 个修改的文件
包含
597 行增加
和
0 行删除
src/main/java/com/sy/logic/NewLeftBar.java
0 → 100644
| 1 | +package com.sy.logic; | ||
| 2 | + | ||
| 3 | +import com.alibaba.fastjson.JSON; | ||
| 4 | +import com.alibaba.fastjson.JSONArray; | ||
| 5 | +import com.sy.crossDomain.buildBarCode; | ||
| 6 | +import com.sy.model.*; | ||
| 7 | +import com.sy.relation.VeManifestRelation; | ||
| 8 | +import com.sy.service.*; | ||
| 9 | +import com.sy.socket.CommandClient; | ||
| 10 | +import com.sy.utils.FileTool; | ||
| 11 | +import org.apache.http.HttpEntity; | ||
| 12 | +import org.apache.http.HttpResponse; | ||
| 13 | +import org.apache.http.client.HttpClient; | ||
| 14 | +import org.apache.http.client.methods.HttpGet; | ||
| 15 | +import org.apache.http.impl.client.DefaultHttpClient; | ||
| 16 | +import org.apache.http.util.EntityUtils; | ||
| 17 | +import org.apache.log4j.PropertyConfigurator; | ||
| 18 | +import org.springframework.beans.factory.annotation.Autowired; | ||
| 19 | +import org.springframework.beans.factory.annotation.Value; | ||
| 20 | +import org.springframework.scheduling.annotation.Async; | ||
| 21 | +import org.springframework.stereotype.Component; | ||
| 22 | +import org.apache.log4j.Logger; | ||
| 23 | + | ||
| 24 | +import javax.annotation.PostConstruct; | ||
| 25 | +import java.io.BufferedReader; | ||
| 26 | +import java.io.IOException; | ||
| 27 | +import java.io.InputStreamReader; | ||
| 28 | +import java.net.MalformedURLException; | ||
| 29 | +import java.net.URL; | ||
| 30 | +import java.net.URLConnection; | ||
| 31 | +import java.text.DecimalFormat; | ||
| 32 | +import java.text.NumberFormat; | ||
| 33 | +import java.text.ParseException; | ||
| 34 | +import java.util.Date; | ||
| 35 | +import java.util.HashMap; | ||
| 36 | +import java.util.List; | ||
| 37 | +import java.util.Map; | ||
| 38 | + | ||
| 39 | + | ||
| 40 | +@Component | ||
| 41 | +public class NewLeftBar { | ||
| 42 | + private static final Logger logger = Logger.getLogger(NewLeftBar.class); | ||
| 43 | + @Autowired | ||
| 44 | + private LandBusListService listService;//进出场申请表 | ||
| 45 | + @Autowired | ||
| 46 | + private LandRoadVeService veService;//车辆信息备案表 | ||
| 47 | + @Autowired | ||
| 48 | + private ResMessageService resMessageService;//查询运单放行表 | ||
| 49 | + @Autowired | ||
| 50 | + private EnterCancelServer enterCancelServer;//调拨业务单独记录表 | ||
| 51 | + @Autowired | ||
| 52 | + private BusnesslistinfoService busnesslistinfoService; | ||
| 53 | + @Autowired | ||
| 54 | + BusnessViewService busnessViewService; | ||
| 55 | + @Value("${wharf.interface.host}") | ||
| 56 | + private String wharfHost; | ||
| 57 | + | ||
| 58 | + @Value("${nmms.interface.host}") | ||
| 59 | + private String nmmsHost; | ||
| 60 | + | ||
| 61 | + private static NewLeftBar logic = new NewLeftBar(); | ||
| 62 | + //从配置文件中读取货物重差可控范围 | ||
| 63 | + private static String checkWt = FileTool.readProperties("grossWt"); | ||
| 64 | + //逻辑判断后的返回信息定义 | ||
| 65 | + private static String PERMITTHOUGH = "直接放行"; | ||
| 66 | + private static String GROWSSEXCETION = "禁止通行,重量不在可控范围"; | ||
| 67 | + private static String NORECORD = "车辆未备案或者识别错误,车牌号:"; | ||
| 68 | + private static String INPUTSTATION = "此车辆未做进站申请"; | ||
| 69 | + private static String ENTERSTATION = "此车辆未做出站申请"; | ||
| 70 | + private static String ISVALID = "二维码数据异常,请使用正确的二维码数据"; | ||
| 71 | + private static String ERRORWT = "出起始场站的重量和进目的场站的重量不一致"; | ||
| 72 | + private static String IEPORSE = "无相对应进出场申请"; | ||
| 73 | + private static String FANGXING="有运单未放行"; | ||
| 74 | + | ||
| 75 | + @Autowired | ||
| 76 | + private FeignService feignService; | ||
| 77 | + @PostConstruct | ||
| 78 | + public void init() { | ||
| 79 | + logic = this; | ||
| 80 | + logic.listService = this.listService; | ||
| 81 | + logic.veService = this.veService; | ||
| 82 | + logic.resMessageService = this.resMessageService; | ||
| 83 | + logic.enterCancelServer = this.enterCancelServer; | ||
| 84 | + logic.feignService=this.feignService; | ||
| 85 | + logic.busnesslistinfoService=this.busnesslistinfoService; | ||
| 86 | + logic.busnessViewService=this.busnessViewService; | ||
| 87 | + logic.wharfHost=this.wharfHost; | ||
| 88 | + logic.nmmsHost=this.nmmsHost; | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + /** | ||
| 92 | + * @Param info 卡口采集数据 | ||
| 93 | + * @Result 计算卡口采集数据并发送报文 | ||
| 94 | + */ | ||
| 95 | + public static boolean newLiftBar(GatherInfo info) throws InterruptedException { | ||
| 96 | + PropertyConfigurator.configure("config/log4j.properties"); | ||
| 97 | + //默认返回值 | ||
| 98 | + boolean result = false; | ||
| 99 | + //获取过磅重量 | ||
| 100 | + double growssWt = info.getGrosswt().doubleValue(); | ||
| 101 | + double goodsWt=0.0,inWt=0.0,diffVal=0.0; | ||
| 102 | + //取车牌号,判定卡口是否取到车牌号 | ||
| 103 | + String vaName = info.getVename(); | ||
| 104 | + //若无车牌号,返回未识别错误 | ||
| 105 | + if (vaName.length() <= 0) { | ||
| 106 | + CommandClient.Client(info, NORECORD + vaName); | ||
| 107 | + return result; | ||
| 108 | + } | ||
| 109 | + //校验车辆是否备案 | ||
| 110 | + LandRoadVe ve = logic.veService.selectByFrameNo(vaName); | ||
| 111 | + //若无备案信息,返回车辆未备案或者识别错误 | ||
| 112 | + if (ve == null) { | ||
| 113 | + CommandClient.Client(info, NORECORD + vaName); | ||
| 114 | + return result; | ||
| 115 | + } | ||
| 116 | + /*if("4604600000".equals(info.getAreaid())){ | ||
| 117 | + return result; | ||
| 118 | + }*/ | ||
| 119 | + /** | ||
| 120 | + * 车牌号,二维码,场站ID/号,通道ID/号,进出业务类型标识I/E | ||
| 121 | + * 查询是否已有此场站通道的申请 | ||
| 122 | + */ | ||
| 123 | + //通过车牌号,二维码,场站,通道号,进出类型查询进出场站申请列表 | ||
| 124 | + LandBusinessTypeList land = logic.listService.selectForOne(info.getVename(), info.getBarcode(), info.getAreaid(), info.getChnlno(), info.getIetype()); | ||
| 125 | + //若查询结果为null,返回无相对应进出场申请 | ||
| 126 | + if (land == null) { | ||
| 127 | + CommandClient.Client(info, IEPORSE); | ||
| 128 | + return result; | ||
| 129 | + } | ||
| 130 | + //判断进出场申请二维码是否已经失效,若失效,sendError | ||
| 131 | + if ("0".equals(land.getIsvalid())) { | ||
| 132 | + //校验重量开始 | ||
| 133 | + boolean checkResult = false; | ||
| 134 | + boolean check = false; | ||
| 135 | + boolean checkMainfest =false; | ||
| 136 | + | ||
| 137 | + //判断是进场申请还是出场申请 | ||
| 138 | + if("I".equals(info.getIetype())){ | ||
| 139 | + /** | ||
| 140 | + * 若进场站为北货,只允许空车进,备案车重=过卡车重 | ||
| 141 | + * 其它走校验 | ||
| 142 | + * */ | ||
| 143 | + if(FileTool.readProperties("stationb").equals(info.getAreaid())){ | ||
| 144 | + logger.info("--------->车辆进入北货场站"); | ||
| 145 | + if(logic.checkFlag(growssWt, Double.parseDouble(ve.getSelfWt()))){ | ||
| 146 | + checkResult=true; | ||
| 147 | + logger.info("--------------->北货站车辆进入重量校验通过,车车牌号为:"+info.getVename()); | ||
| 148 | + }else{ | ||
| 149 | + logger.info("--------------->车辆未进入北货站,重量校验没通过,车车牌号为:"+info.getVename()); | ||
| 150 | + CommandClient.Client(info, GROWSSEXCETION); | ||
| 151 | + return result; | ||
| 152 | + } | ||
| 153 | + }else{ | ||
| 154 | + check=logic.checkResultIn(growssWt,Double.parseDouble(ve.getSelfWt()), goodsWt); | ||
| 155 | + if(check){ | ||
| 156 | + checkResult=check; | ||
| 157 | + logger.info("--------------->车辆进入场站"+info.getAreaid()+"重量校验通过,车车牌号为:"+info.getVename()); | ||
| 158 | + }else{ | ||
| 159 | + logger.info("--------------->车辆未进入"+info.getAreaid()+"货站,重量校验没通过,车车牌号为:"+info.getVename()); | ||
| 160 | + CommandClient.Client(info, GROWSSEXCETION); | ||
| 161 | + return result; | ||
| 162 | + } | ||
| 163 | + } | ||
| 164 | + } else{ | ||
| 165 | + //获取对应场站进场申请的货物重量,进场过磅重量 | ||
| 166 | + List<LandBusinessTypeList> listWt=logic.listService.selectwt(land.getTrailerFrameNo(),land.getBarcode(),land.getEndstation(),"I"); | ||
| 167 | + for(LandBusinessTypeList typeList:listWt){ | ||
| 168 | + if(typeList.getRemark()!=null && typeList.getRemark()!=""){ | ||
| 169 | + //货物重量 | ||
| 170 | + goodsWt=Double.parseDouble(typeList.getRemark()); | ||
| 171 | + } | ||
| 172 | + if(typeList.getAislewt()!=null){ | ||
| 173 | + //对应场站进场过磅重量 | ||
| 174 | + inWt=typeList.getAislewt(); | ||
| 175 | + } | ||
| 176 | + //进出差值 | ||
| 177 | + diffVal = inWt- growssWt; | ||
| 178 | + } | ||
| 179 | + //判断场站出场是否要重量校验 | ||
| 180 | + if(FileTool.readProperties("station").equals(land.getEndstation())||FileTool.readProperties("stationsf").equals(land.getEndstation()) | ||
| 181 | + || "4604600000".equals(land.getEndstation())){ | ||
| 182 | + checkResult=true; | ||
| 183 | + }else if(!"普通货".equals(land.getCocode())){ | ||
| 184 | + checkResult=true; | ||
| 185 | + }else { | ||
| 186 | + check = logic.checkResult(growssWt, Double.parseDouble(ve.getSelfWt()), goodsWt,inWt); | ||
| 187 | + if("出口送货".equals(land.getBusinesstype())){ | ||
| 188 | + if(check){ | ||
| 189 | + checkResult=true; | ||
| 190 | + }else{ | ||
| 191 | + CommandClient.Client(info, GROWSSEXCETION); | ||
| 192 | + } | ||
| 193 | + }else{ | ||
| 194 | + checkMainfest = logic.checkManifest(land.getMasterList()); | ||
| 195 | + if(checkMainfest){ | ||
| 196 | + checkResult=check || checkMainfest; | ||
| 197 | + }else{ | ||
| 198 | + CommandClient.Client(info, FANGXING);//有运单未放行 | ||
| 199 | + } | ||
| 200 | + } | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + } | ||
| 204 | + if(logic.sendBw(info, checkResult)){//发送抬杆儿报文 | ||
| 205 | + if ("I".equals(info.getIetype())) { | ||
| 206 | + land.setAislewt(info.getGrosswt().doubleValue()); | ||
| 207 | + land.setUpdateDate(new Date()); | ||
| 208 | + //list.setRemark(String.format("%.1f", goodsWt)); | ||
| 209 | + land.setRemark2(ve.getSelfWt()); | ||
| 210 | + land.setContrastflag("已进站"); | ||
| 211 | + //logic.checkData(list); | ||
| 212 | + } else { | ||
| 213 | + LandRoadVe veName = logic.veService.selectByFrameNo(vaName); | ||
| 214 | + land.setAislewt(info.getGrosswt().doubleValue()); | ||
| 215 | + land.setUpdateDate(new Date()); | ||
| 216 | + land.setRemark(String.format("%.1f", goodsWt)); | ||
| 217 | + land.setRemark1(String.format("%.1f", diffVal)); | ||
| 218 | + land.setRemark2(veName.getSelfWt()); | ||
| 219 | + land.setContrastflag("已出站"); | ||
| 220 | + //logic.checkData(list); | ||
| 221 | + } | ||
| 222 | + logic.listService.updateById(land);//更新进出场申请业务表 | ||
| 223 | + //进出场申请业务表对应场站的卡口失效 | ||
| 224 | + logic.listService.updateisvalid(land.getTrailerFrameNo(),land.getBarcode(),land.getEndstation(),land.getTurnoverflag()); | ||
| 225 | + //判断是否为最后一个场站,若是最后个场站申请为出,二维码失效 | ||
| 226 | + int count=logic.listService.selectlaststation(land.getTrailerFrameNo(),land.getBarcode()); | ||
| 227 | + //二维码失效 | ||
| 228 | + if(count==0){ | ||
| 229 | + buildBarCode.cancleBarCode(vaName); | ||
| 230 | + } | ||
| 231 | + /** | ||
| 232 | + * 提前运抵判断 | ||
| 233 | + * 如果有提前运抵标识,判断是否分批,不分批直接通知 | ||
| 234 | + * 分批是否最后一批,最后一批通知 | ||
| 235 | + * */ | ||
| 236 | + if("I".equals(info.getIetype())){ | ||
| 237 | + try{ | ||
| 238 | + List<LAND_BUSINEESTYPE_LIST_INFO> arrive_infos=logic.busnesslistinfoService.selectarrvie(info.getBarcode());//查询是否提前运抵 | ||
| 239 | + if(arrive_infos!=null && arrive_infos.size()>0){ | ||
| 240 | + for (LAND_BUSINEESTYPE_LIST_INFO businees:arrive_infos) { | ||
| 241 | + //判断运单是否分批 | ||
| 242 | + if ("0".equals(businees.getPartialidentity())){ | ||
| 243 | + logger.info("运单号{}不分批,不从通知数组删除"); | ||
| 244 | + }else { //分批后的处理 | ||
| 245 | + List<businesstypelistinfo_view> info_view=logic.busnessViewService.selectawb(businees.getAwba()); | ||
| 246 | + // 装载运单的分批车辆还有未入场的,从通知数组中删除他 | ||
| 247 | + if (info_view.size()>0){ | ||
| 248 | + arrive_infos.remove(businees); | ||
| 249 | + } | ||
| 250 | + } | ||
| 251 | + } | ||
| 252 | + //最后发送通知数组 | ||
| 253 | + /*try{ | ||
| 254 | + new LiftBar().sendMessage(info.getVename(),arrive_infos); | ||
| 255 | + }catch (Exception e){ | ||
| 256 | + logger.info("新舱单发送消息异常---"+e.toString()); | ||
| 257 | + }*/ | ||
| 258 | + } | ||
| 259 | + }catch (Exception e){ | ||
| 260 | + logger.info("运单分批消息异常---"+e.toString()); | ||
| 261 | + } | ||
| 262 | + } | ||
| 263 | + //调拨货冻结 | ||
| 264 | + if (land.getBusinesstype().indexOf("业务") > 0) { | ||
| 265 | + logic.inOrUpEnterCancel(land); | ||
| 266 | + } | ||
| 267 | + } | ||
| 268 | + //绑定车单关系 | ||
| 269 | + if(land.getMasterList().length()>0){ | ||
| 270 | + boolean flag = VeManifestRelation.createFile(land); | ||
| 271 | + if(flag){ | ||
| 272 | + logger.info(">>>>>>>>>>-----车单关系报文生成成功-----<<<<<<<<<<<<"); | ||
| 273 | + } | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + } else { | ||
| 277 | + sendError(info); | ||
| 278 | + logger.error("------->>>>>>>二维码数据异常,请使用正确的二维码数据<<<<<<<-----"); | ||
| 279 | + } | ||
| 280 | + return true; | ||
| 281 | + } | ||
| 282 | + /** | ||
| 283 | + * 进场校验重量核对 | ||
| 284 | + * **/ | ||
| 285 | + | ||
| 286 | + public boolean checkResultIn(double grossWt, double vewt, double goodsWt) { | ||
| 287 | + DecimalFormat df = new DecimalFormat("0.00"); | ||
| 288 | + boolean flag = false; | ||
| 289 | + double result= 0.0,result2= 0.0,result3= 0.0,result4= 0.0; | ||
| 290 | + if(grossWt>0){ | ||
| 291 | + result2 = Double.parseDouble(df.format(Math.abs((grossWt-vewt)) / grossWt)); | ||
| 292 | + result3 = Double.parseDouble(df.format(Math.abs((grossWt-vewt-goodsWt)) / grossWt)); | ||
| 293 | + } | ||
| 294 | + if (result2 <= valueDob() || result3 <= valueDob()) { | ||
| 295 | + flag = true; | ||
| 296 | + } | ||
| 297 | + return flag; | ||
| 298 | + } | ||
| 299 | + /** | ||
| 300 | + * 校验重量并发送报文 | ||
| 301 | + */ | ||
| 302 | + | ||
| 303 | + public boolean sendBw(GatherInfo info, boolean check) { | ||
| 304 | + logger.info(String.format("开始发送指令:车牌%s,场站%s,通道%s,重量%s",info.getVename(),info.getAreaid(),info.getChnlno(),info.getGrosswt())); | ||
| 305 | + boolean flag = false; | ||
| 306 | + if (check) { | ||
| 307 | + CommandClient.Client(info, PERMITTHOUGH); | ||
| 308 | + logger.info("=============>>>>>>>>放行报文发送成功<<<<<<<<<=============="); | ||
| 309 | + flag = true; | ||
| 310 | + } else { | ||
| 311 | + CommandClient.Client(info, GROWSSEXCETION); | ||
| 312 | + logger.info("=============>>>>>>>>重量异常报文发送成功<<<<<<<<<=============="); | ||
| 313 | + } | ||
| 314 | + return flag; | ||
| 315 | + } | ||
| 316 | + /** | ||
| 317 | + * 给码头发送卡口数据 | ||
| 318 | + * | ||
| 319 | + * @param stationCode | ||
| 320 | + * @param carNo | ||
| 321 | + * @param IEtype | ||
| 322 | + */ | ||
| 323 | + public static void sendData(String stationCode, String carNo, boolean IEtype) { | ||
| 324 | + String url = logic.wharfHost+"air-api/car/channelCar?stationCode=" + stationCode + "&carNo=" + carNo + "&isPickup=" + IEtype; | ||
| 325 | + try { | ||
| 326 | + HttpClient httpClient = new DefaultHttpClient(); | ||
| 327 | + HttpGet httpGet = new HttpGet(url); | ||
| 328 | + HttpResponse httpResponse = httpClient.execute(httpGet); | ||
| 329 | + HttpEntity entity = httpResponse.getEntity(); | ||
| 330 | + String entityStr = EntityUtils.toString(entity); | ||
| 331 | + logger.info("------------>>>>>>>>>>>>>>发送车辆信息:{stationCode:" + stationCode + ",carNo:" + carNo + ",isPickup:" + IEtype + "}"); | ||
| 332 | + logger.info("------------>>>>>>>>>>>>>>响应返回内容:" + entityStr + "<<<<<<<<<<<<-----------"); | ||
| 333 | + } catch (Exception e) { | ||
| 334 | + logger.info(e.toString()); | ||
| 335 | + } | ||
| 336 | + } | ||
| 337 | + /** | ||
| 338 | + * 给码头发送卡口数据 | ||
| 339 | + * | ||
| 340 | + * @param list | ||
| 341 | + */ | ||
| 342 | + public void checkData(LandBusinessTypeList list) { | ||
| 343 | + String sationCode = null; | ||
| 344 | + boolean flag = false; | ||
| 345 | + if ("出口送货".equals(list.getBusinesstype()) || "出口流转".equals(list.getBusinesstype())) { | ||
| 346 | + flag = false; | ||
| 347 | + } | ||
| 348 | + if ("进口提货".equals(list.getBusinesstype()) || "进口流转".equals(list.getBusinesstype())) { | ||
| 349 | + flag = true; | ||
| 350 | + } | ||
| 351 | + if ("4604000000".equals(list.getEndstation())) { | ||
| 352 | + if ("I".equals(list.getTurnoverflag())) { | ||
| 353 | + sationCode = "HK05"; | ||
| 354 | + } else { | ||
| 355 | + sationCode = "HK06"; | ||
| 356 | + } | ||
| 357 | + //TODO:加场站判定 | ||
| 358 | + } | ||
| 359 | + try{ | ||
| 360 | + sendData(sationCode, list.getTrailerFrameNo(), flag); | ||
| 361 | + }catch (Exception e){ | ||
| 362 | + logger.info("码头发送消息异常---"+e.toString()); | ||
| 363 | + } | ||
| 364 | + } | ||
| 365 | + /** | ||
| 366 | + * 查询运单是否全部放行 | ||
| 367 | + * | ||
| 368 | + * @param manifestList | ||
| 369 | + * @return | ||
| 370 | + */ | ||
| 371 | + public boolean checkManifest(String manifestList) { | ||
| 372 | + if (manifestList.length() < 1) return false; | ||
| 373 | + manifestList = manifestList.replace("-", ""); | ||
| 374 | + String[] maifest = manifestList.split(","); | ||
| 375 | + boolean flag = false; | ||
| 376 | + int count = 0; | ||
| 377 | + for (int i = 0; i < maifest.length; i++) { | ||
| 378 | + RESMESSAGE resmessage = logic.resMessageService.selectByManifest(maifest[i]); | ||
| 379 | + if (resmessage != null) { | ||
| 380 | + if ("11".equals(resmessage.getResponsecode())) { | ||
| 381 | + count++; | ||
| 382 | + } | ||
| 383 | + } | ||
| 384 | + } | ||
| 385 | + if (count == maifest.length) { | ||
| 386 | + flag = true; | ||
| 387 | + } | ||
| 388 | + return flag; | ||
| 389 | + } | ||
| 390 | + /** | ||
| 391 | + * 校验载重和称重是否在合理的范围 | ||
| 392 | + * | ||
| 393 | + * @Param grossWt 地磅称重 | ||
| 394 | + * @Param wt 车辆自重 | ||
| 395 | + * @Param goodsWt 货物总重 | ||
| 396 | + * @Result 获取运单重量 | ||
| 397 | + */ | ||
| 398 | + /** | ||
| 399 | + * 进场卸货误差判定 | ||
| 400 | + * 出场重量 = 进场重量 - 货物重量 | ||
| 401 | + * 首先计算 进出场差值数 ABS(进场重量-货物重量-出场重量)/出场重量, 计算出出场误差百分比 | ||
| 402 | + * (出场重量 - 车辆备案重量) /出场重量 | ||
| 403 | + * (出场重量 - (车辆备案重量+货物重量)/出场重量 | ||
| 404 | + * (出场重量 - (进场重量+货物重量)/出场重量 | ||
| 405 | + */ | ||
| 406 | + public boolean checkResult(double grossWt, double wt, double goodsWt,double inWt) { | ||
| 407 | + DecimalFormat df = new DecimalFormat("0.00"); | ||
| 408 | + boolean flag = false; | ||
| 409 | + double result= 0.0,result2= 0.0,result3= 0.0,result4= 0.0; | ||
| 410 | + if(grossWt>0){ | ||
| 411 | + result = Double.parseDouble(df.format(Math.abs((inWt - goodsWt - grossWt)) / grossWt)); | ||
| 412 | + result2 = Double.parseDouble(df.format(Math.abs((grossWt-wt)) / grossWt)); | ||
| 413 | + result3 = Double.parseDouble(df.format(Math.abs((grossWt-wt-goodsWt)) / grossWt)); | ||
| 414 | + result4 = Double.parseDouble(df.format(Math.abs((inWt + goodsWt)) / grossWt)); | ||
| 415 | + } | ||
| 416 | + if (result <= valueDob() ||result2 <= valueDob() || result3 <= valueDob() || result4 <= valueDob()) { | ||
| 417 | + flag = true; | ||
| 418 | + } | ||
| 419 | + return flag; | ||
| 420 | + } | ||
| 421 | + | ||
| 422 | + | ||
| 423 | + | ||
| 424 | + /** | ||
| 425 | + * 排除当前系统问题发送错误commandInfo | ||
| 426 | + */ | ||
| 427 | + public static void sendError(GatherInfo info) { | ||
| 428 | + //二维码数据异常,请使用正确的二维码数据 | ||
| 429 | + CommandClient.Client(info, ISVALID); | ||
| 430 | + } | ||
| 431 | + | ||
| 432 | + /** | ||
| 433 | + * @Param mainifast 主单列表 | ||
| 434 | + * @Param ietype 进出标志 | ||
| 435 | + * 获取货物总重 | ||
| 436 | + */ | ||
| 437 | + public double GoodsWt(String mainifast, String ietype) { | ||
| 438 | + Double sum = 0.0; | ||
| 439 | + if (mainifast.length() > 0) { | ||
| 440 | + String[] mainifastList = mainifast.split(","); | ||
| 441 | + for (String mainBill : mainifastList) { | ||
| 442 | + sum += getGrossWt(mainBill, ietype); | ||
| 443 | + } | ||
| 444 | + } | ||
| 445 | + return sum; | ||
| 446 | + } | ||
| 447 | + | ||
| 448 | + /** | ||
| 449 | + * @Param waybill 主单号 | ||
| 450 | + * @Param imp 进出港标识 | ||
| 451 | + * @Result 获取运单重量 | ||
| 452 | + */ | ||
| 453 | + public double getGrossWt(String waybill, String imp) { | ||
| 454 | + logger.info("进入获取重量action"); | ||
| 455 | + if (!(waybill.indexOf("-") != -1)) { | ||
| 456 | + waybill = waybill.substring(0, 3) + "-" + waybill.substring(3); | ||
| 457 | + } | ||
| 458 | + String url = logic.nmmsHost+"orig/orig?waybill=" + waybill + "&imp=" + imp; | ||
| 459 | + // String url = "http://tjfx.15miaoo.com:8003/tj/orig/orig?waybill=" + waybill + "&imp=" + imp; | ||
| 460 | + StringBuilder json = new StringBuilder(); | ||
| 461 | + Map map = null; | ||
| 462 | + double bg = 0; | ||
| 463 | + try { | ||
| 464 | + URL Url = new URL(url); | ||
| 465 | + URLConnection yc = Url.openConnection(); | ||
| 466 | + BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream(), "utf-8")); | ||
| 467 | + String inputLine = null; | ||
| 468 | + while ((inputLine = in.readLine()) != null) { | ||
| 469 | + json.append(inputLine); | ||
| 470 | + } | ||
| 471 | + logger.info("返回数据:" + json); | ||
| 472 | + JSONArray array = JSONArray.parseArray(json.toString()); | ||
| 473 | + for (int i = 0; i < array.size(); i++) { | ||
| 474 | + map = JSON.parseObject(array.getString(i)); | ||
| 475 | + if (map.containsKey("receiptinformation")) { | ||
| 476 | + if (map.get("receiptinformation").toString().startsWith("41301") || map.get("receiptinformation") | ||
| 477 | + .toString().startsWith("41106") || map.get("receiptinformation") | ||
| 478 | + .toString().startsWith("31301") || map.get("receiptinformation") | ||
| 479 | + .toString().startsWith("31106") || map.get("receiptinformation") | ||
| 480 | + .toString().indexOf("提运单放行") != -1) { | ||
| 481 | + logger.info(map); | ||
| 482 | + bg = Double.parseDouble((String) map.get("totalweight")); | ||
| 483 | + logger.info("for循环取重量:" + bg); | ||
| 484 | + return bg; | ||
| 485 | + } | ||
| 486 | + } | ||
| 487 | + } | ||
| 488 | + logger.info("访问返回的数据重量:" + bg); | ||
| 489 | + in.close(); | ||
| 490 | + } catch (MalformedURLException e) { | ||
| 491 | + logger.info("运单放行消息异常---"+e.toString()); | ||
| 492 | + logger.error(e); | ||
| 493 | + } catch (IOException e) { | ||
| 494 | + e.printStackTrace(); | ||
| 495 | + logger.error(e); | ||
| 496 | + } | ||
| 497 | + return bg; | ||
| 498 | + } | ||
| 499 | + | ||
| 500 | + /** | ||
| 501 | + * 判断地磅称重,备案车重是否在合理范围 | ||
| 502 | + * | ||
| 503 | + * @param grossWt | ||
| 504 | + * @param wt | ||
| 505 | + * @return | ||
| 506 | + */ | ||
| 507 | + public boolean checkFlag(double grossWt, double wt) { | ||
| 508 | + DecimalFormat df = new DecimalFormat("0.00"); | ||
| 509 | + boolean flag = false; | ||
| 510 | + double reult = Double.parseDouble(df.format(Math.abs((grossWt - wt)) / grossWt)); | ||
| 511 | + if (reult <= valueDob()) { | ||
| 512 | + flag = true; | ||
| 513 | + } | ||
| 514 | + return flag; | ||
| 515 | + } | ||
| 516 | + //将获取的checkWt进行小数转化 | ||
| 517 | + public static double valueDob() { | ||
| 518 | + NumberFormat nf = NumberFormat.getPercentInstance(); | ||
| 519 | + Number m = null; | ||
| 520 | + try { | ||
| 521 | + m = nf.parse(checkWt);//将百分数转换成Number类型 | ||
| 522 | + } catch (ParseException e) { | ||
| 523 | + logger.info("重量校验消息异常---"+e.toString()); | ||
| 524 | + logger.info(e.getMessage()); | ||
| 525 | + } | ||
| 526 | + return m.doubleValue(); | ||
| 527 | + } | ||
| 528 | + /** | ||
| 529 | + * 生成或者更新货物冻结标识 | ||
| 530 | + * | ||
| 531 | + * @param landBusinessTypeList | ||
| 532 | + */ | ||
| 533 | + public void inOrUpEnterCancel(LandBusinessTypeList landBusinessTypeList) { | ||
| 534 | + if (landBusinessTypeList.getMasterList().length() < 1) return; | ||
| 535 | + String[] list = landBusinessTypeList.getMasterList().split(","); | ||
| 536 | + String flag = null; | ||
| 537 | + for (int i = 0; i < list.length; i++) { | ||
| 538 | + if("调拨业务".equals(landBusinessTypeList.getBusinesstype())){ | ||
| 539 | + flag = "E"; | ||
| 540 | + }else { | ||
| 541 | + flag = "I"; | ||
| 542 | + } | ||
| 543 | + double wt = getGrossWt(list[i],flag); | ||
| 544 | + | ||
| 545 | + ENTERCANCCEL entercanccel = logic.enterCancelServer.selectByManifest(list[i]); | ||
| 546 | + if (entercanccel != null) { | ||
| 547 | + if(entercanccel.getVename().equals(landBusinessTypeList.getTrailerFrameNo())){ | ||
| 548 | + if ("0".equals(entercanccel.getIsfreeze())) { | ||
| 549 | + entercanccel.setIsfreeze("1"); | ||
| 550 | + entercanccel.setEndport(landBusinessTypeList.getEndstation()); | ||
| 551 | + entercanccel.setUpdateBy(landBusinessTypeList.getCreateBy()); | ||
| 552 | + entercanccel.setUpdateTime(new Date()); | ||
| 553 | + logic.enterCancelServer.updateByPermaryKey(entercanccel); | ||
| 554 | + } | ||
| 555 | + } | ||
| 556 | + }else { | ||
| 557 | + if("E".equals(landBusinessTypeList.getTurnoverflag())){ | ||
| 558 | + ENTERCANCCEL canccel = new ENTERCANCCEL(); | ||
| 559 | + canccel.setIsfreeze("0"); | ||
| 560 | + canccel.setVename(landBusinessTypeList.getTrailerFrameNo()); | ||
| 561 | + canccel.setId(String.valueOf(System.currentTimeMillis())); | ||
| 562 | + canccel.setVeCompanyName(landBusinessTypeList.getAgentno()); | ||
| 563 | + canccel.setBusinesstype(landBusinessTypeList.getBusinesstype()); | ||
| 564 | + canccel.setManifest(list[i]); | ||
| 565 | + canccel.setAgentname(landBusinessTypeList.getAgentname()); | ||
| 566 | + canccel.setStartport(landBusinessTypeList.getEndstation()); | ||
| 567 | + canccel.setGrosswt(landBusinessTypeList.getAislewt()); | ||
| 568 | + canccel.setCreateBy(landBusinessTypeList.getCreateBy()); | ||
| 569 | + canccel.setCreateTime(new Date()); | ||
| 570 | + canccel.setUpdateBy(landBusinessTypeList.getCreateBy()); | ||
| 571 | + canccel.setUpdateTime(new Date()); | ||
| 572 | + canccel.setWeight(wt); | ||
| 573 | + logic.enterCancelServer.insertEntry(canccel); | ||
| 574 | + } | ||
| 575 | + | ||
| 576 | + } | ||
| 577 | + } | ||
| 578 | + } | ||
| 579 | + /** | ||
| 580 | + * 为提前运抵服务发送数据 | ||
| 581 | + * | ||
| 582 | + * @param | ||
| 583 | + * @param | ||
| 584 | + * @return | ||
| 585 | + */ | ||
| 586 | + @Async("asyncPoolTaskExecutor") | ||
| 587 | + public void sendMessage(String vname, List<LAND_BUSINEESTYPE_LIST_INFO> list_infos)throws InterruptedException{ | ||
| 588 | + logger.info("新舱单发送服务开始"); | ||
| 589 | + AdvanceArrive arrive=new AdvanceArrive(); | ||
| 590 | + arrive.setVname(vname); | ||
| 591 | + arrive.setMasterList(list_infos); | ||
| 592 | + logger.info("新舱单发送服务数据",arrive); | ||
| 593 | + Map<String,Object> map=logic.feignService.sendMessage(arrive); | ||
| 594 | + logger.info(""+map); | ||
| 595 | + } | ||
| 596 | +} | ||
| 597 | + |
-
请 注册 或 登录 后发表评论