审查视图

src/main/java/com/sy/logic/LogicOperation.java 24.0 KB
zhangFan authored
1 2 3
package com.sy.logic;

zhangFan authored
4 5
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
zhangFan authored
6
import com.sy.crossDomain.buildBarCode;
zhangFan authored
7
import com.sy.model.*;
zhangFan authored
8
import com.sy.relation.VeManifestRelation;
zhangFan authored
9
import com.sy.service.EnterCancelServer;
zhangFan authored
10
import com.sy.service.LandBusListService;
zhangFan authored
11
import com.sy.service.LandRoadVeService;
zhangFan authored
12
import com.sy.service.ResMessageService;
zhangFan authored
13
import com.sy.socket.CommandClient;
zhangFan authored
14
import com.sy.utils.FileTool;
zhangFan authored
15 16 17 18 19 20
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.util.EntityUtils;
zhangFan authored
21
import org.apache.log4j.Logger;
zhangFan authored
22
import org.apache.log4j.PropertyConfigurator;
zhangFan authored
23 24 25 26
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
zhangFan authored
27 28 29 30 31 32
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
zhangFan authored
33
import java.text.DecimalFormat;
zhangFan authored
34 35
import java.text.NumberFormat;
import java.text.ParseException;
zhangFan authored
36
import java.util.Date;
zhangFan authored
37
import java.util.List;
zhangFan authored
38
import java.util.Map;
zhangFan authored
39 40 41 42

@Component
public class LogicOperation {
zhangFan authored
43 44
    private static final Logger logger = Logger.getLogger(LogicOperation.class);
zhangFan authored
45 46 47
    @Autowired
    private LandBusListService listService;
zhangFan authored
48 49 50
    @Autowired
    private LandRoadVeService veService;
zhangFan authored
51 52 53
    @Autowired
    private ResMessageService resMessageService;
zhangFan authored
54 55 56 57
    @Autowired
    private EnterCancelServer enterCancelServer;

    private static LogicOperation logic = new LogicOperation();
zhangFan authored
58
zhangFan authored
59 60 61
    //读取配置文件里的载重与称重的可控范围
    private static String checkWt = FileTool.readProperties("grossWt");
zhangFan authored
62 63 64
    //逻辑判断后的结果定义
    private static String PERMITTHOUGH = "直接放行";
    private static String GROWSSEXCETION = "禁止通行,重量不在可控范围";
zhangFan authored
65
    private static String NORECORD = "车辆未备案或者识别错误,车牌号:";
zhangFan authored
66 67
    private static String INPUTSTATION = "此车辆未做进站申请";
    private static String ENTERSTATION = "此车辆未做出站申请";
zhangFan authored
68
    private static String ISVALID = "二维码数据异常,请使用正确的二维码数据";
zhangFan authored
69 70
    private static String ERRORWT = "出起始场站的重量和进目的场站的重量不一致";
    private static String IEPORSE = "无相对应进出场申请";
zhangFan authored
71
zhangFan authored
72
    @PostConstruct
zhangFan authored
73
    public void init() {
zhangFan authored
74 75
        logic = this;
        logic.listService = this.listService;
zhangFan authored
76
        logic.veService = this.veService;
zhangFan authored
77
        logic.resMessageService = this.resMessageService;
zhangFan authored
78
        logic.enterCancelServer = this.enterCancelServer;
zhangFan authored
79 80
    }
zhangFan authored
81 82 83
    /**
     * @Param info 卡口采集数据
     * @Result 计算卡口采集数据并发送报文
zhangFan authored
84 85
     */
    public static boolean operation(GatherInfo info) {
zhangFan authored
86 87 88
        if("综保区".equals(info.getAreaid())){
            //todo 加综保区的判断逻辑
        }
zhangFan authored
89
        PropertyConfigurator.configure("config/log4j.properties");
zhangFan authored
90
        boolean result = false;
zhangFan authored
91
        //转为double类型
zhangFan authored
92
        double growssWt = info.getGrosswt().doubleValue();
xudada authored
93
        //取车牌号,判定卡口是否取到车牌号
zhangFan authored
94
        String vaName = info.getVename();
zhangFan authored
95 96
        if (vaName.length() <= 0) {
            CommandClient.Client(info, NORECORD + vaName);
zhangFan authored
97 98
            return result;
        }
xudada authored
99
        //校验车辆是否备案
zhangFan authored
100
        LandRoadVe ve = logic.veService.selectByFrameNo(vaName);
zhangFan authored
101 102 103 104
        if (ve == null) {
            CommandClient.Client(info, NORECORD + vaName);
            return result;
        }
xudada authored
105 106 107 108 109 110

        /**
         * 车牌号,二维码,场站ID/号,通道ID/号,进出业务类型标识I/E
         * 查询是否已有此场站通道的申请
         */
        LandBusinessTypeList list = logic.listService.selectForOne(info.getVename(), info.getBarcode(), info.getAreaid(), info.getChnlno(), info.getIetype());
zhangFan authored
111
        if (list == null) {
zhangFan authored
112 113 114 115 116 117
            CommandClient.Client(info, IEPORSE);
            return result;
        }
        //判断是否失效
        if ("0".equals(list.getIsvalid())) {
            //获取总重
zhangFan authored
118
            double goodsWt = 0.0;
zhangFan authored
119 120 121 122 123 124 125 126 127
            if (list.getMasterList() != null || list.getMasterList().length() > 0) {
                String type = null;
                if ("进口提货".equals(list.getBusinesstype()) || "分拨业务".equals(list.getBusinesstype())) {
                    type = "I";
                }
                if ("出口送货".equals(list.getBusinesstype()) || "调拨业务".equals(list.getBusinesstype())) {
                    type = "E";
                }
                logger.info("=======================>>>>>>>>>>" + type + "<<<<<<<<<<========================");
xudada authored
128
                //获取车辆拉货重量
zhangFan authored
129
                goodsWt = logic.GoodsWt(list.getMasterList(), type);
zhangFan authored
130
            }
zhangFan authored
131
            //车自重
zhangFan authored
132
            double selfWt = Double.parseDouble(ve.getSelfWt());
zhangFan authored
133
xudada authored
134
            //重量误差判定,判断过磅重量减去(车备案重量+运单重量)/过磅重量是否在可控范围内
zhangFan authored
135
            if (!logic.checkFlag(growssWt, (selfWt + goodsWt))) {
xudada authored
136
                //根据二维码标识ID找进出场对应申请,并进行过卡数据与申请数据对碰
zhangFan authored
137 138
                List<LandBusinessTypeList> typeLists = logic.listService.selectMessageId(list.getMassageId());
                for (int i = 0; i < typeLists.size(); i++) {
xudada authored
139
                    //如果业务类型为进口提货,进出业务标识为出场(E),把已检验过进场过卡重量赋为空车重量,否则则取备案重量
zhangFan authored
140
                    if ("进口提货".equals(list.getBusinesstype())) {
xudada authored
141
                        //Turnoverflag()进出场标识
zhangFan authored
142
                        if ("E".equals(list.getTurnoverflag())) {
xudada authored
143
                            //Contrastflag检验标识,Aislewt过卡重量
zhangFan authored
144 145 146 147 148 149
                            if ("I".equals(typeLists.get(i).getTurnoverflag()) && typeLists.get(i).getContrastflag() != null) {
                                selfWt = typeLists.get(i).getAislewt() > 1 ? typeLists.get(i).getAislewt() : selfWt;
                                break;
                            }
                        }
                    }
xudada authored
150
                    //
zhangFan authored
151
                    if ("出口送货".equals(list.getBusinesstype())) {
zhangFan authored
152
                        if ("E".equals(list.getTurnoverflag())) {
xudada authored
153
                            //判断入场是否正常
zhangFan authored
154
                            if ("I".equals(typeLists.get(i).getTurnoverflag()) && typeLists.get(i).getContrastflag() != null) {
xudada authored
155
                                if ("1".equals(list.getIsfull())) {//
zhangFan authored
156 157 158 159
                                    if (list.getMasterList().length() > 0) {
                                        selfWt = typeLists.get(i).getAislewt() - Double.parseDouble(typeLists.get(i).getRemark());
                                    } else {
                                        selfWt = growssWt;
zhangFan authored
160 161 162 163 164 165 166
                                    }
                                }
                                break;
                            }
                        }
                    }
zhangFan authored
167
                    if (list.getBusinesstype().endsWith("业务")) {
zhangFan authored
168 169 170 171 172 173
                            if (list.getMasterList().length() > 0) {
                                if ("E".equals(list.getTurnoverflag())) {
                                    if ("I".equals(typeLists.get(i).getTurnoverflag()) && typeLists.get(i).getContrastflag() != null) {
                                        selfWt = typeLists.get(i).getAislewt() > 1 ? typeLists.get(i).getAislewt() : selfWt;
                                        break;
                                    }
zhangFan authored
174
                                }
zhangFan authored
175 176 177 178 179 180 181
                                if ("I".equals(list.getTurnoverflag())) {
                                    if ("E".equals(typeLists.get(i).getTurnoverflag()) && typeLists.get(i).getContrastflag() != null) {
                                        if (!logic.checkFlag(growssWt, typeLists.get(i).getAislewt())) {
                                            logger.info("-------->>>>>>>>出起始场站的重量和进目的场站的总量不一致<<<<<<<<--------");
                                            CommandClient.Client(info, ERRORWT);
                                            return result;
                                        }
zhangFan authored
182 183 184 185 186 187
                                    }
                                }
                            }
                        }
                }
            }
xudada authored
188
            //校验重量开始
zhangFan authored
189
            boolean checkResult = false;
zhangFan authored
190 191
            boolean check = false;
            boolean checkMainfest =false;
zhangFan authored
192
zhangFan authored
193
            if(!"普通货".equals(list.getCocode())){
zhangFan authored
194
                checkResult = true;
xudada authored
195 196 197
            }else if(list.getEndstation().equals("4600329012") || list.getEndstation().equals("4612199001")){
                checkResult = true;
            }else{
zhangFan authored
198 199 200 201 202 203 204 205 206 207 208 209 210 211
               check = logic.checkResult(growssWt, selfWt, goodsWt);
               checkMainfest = logic.checkManifest(list.getMasterList());

                if ("E".equals(list.getTurnoverflag())) {
                    checkResult = checkMainfest || check;
                } else {
                    checkResult = check || checkMainfest;
                }

                //宽进
                if ("I".equals(info.getIetype())) {
                    if (check == false && checkResult == false) {
                        checkResult = true;
                    }
zhangFan authored
212
                }
zhangFan authored
213
                logger.info("重量校验结果:" + check + ",运单校验结果:" + checkMainfest + ",最终校验结果:" + checkResult);
zhangFan authored
214 215
            }
zhangFan authored
216
            if (logic.sendBw(info, checkResult)) {
zhangFan authored
217
                if ("I".equals(info.getIetype())) {
zhangFan authored
218
                    //    LandRoadVe veName = logic.veService.selectByFrameNo(vaName);
zhangFan authored
219 220
                    list.setAislewt(info.getGrosswt().doubleValue());
                    list.setUpdateDate(new Date());
zhangFan authored
221 222
                    list.setRemark(String.format("%.1f", goodsWt));
                    list.setRemark2(ve.getSelfWt());
zhangFan authored
223
                    list.setContrastflag("已进站");
zhangFan authored
224
                    logic.checkData(list);
zhangFan authored
225
                } else {
zhangFan authored
226 227 228 229 230
                    List<LandBusinessTypeList> typeLists = logic.listService.selectMessageId(list.getMassageId());
                    //进出相差重量
                    double diffVal = 0;
                    for (int i = 0; i < typeLists.size(); i++) {
                        if ("I".equals(typeLists.get(i).getTurnoverflag()) && typeLists.get(i).getEndstation().equals(list.getEndstation())) {
zhangFan authored
231 232
                            System.out.println(typeLists.get(i).getAislewt());
                            System.out.println(growssWt);
zhangFan authored
233 234 235 236 237
                            diffVal = typeLists.get(i).getAislewt() - growssWt;
                            break;
                        }
                    }
                    LandRoadVe veName = logic.veService.selectByFrameNo(vaName);
zhangFan authored
238 239
                    list.setAislewt(info.getGrosswt().doubleValue());
                    list.setUpdateDate(new Date());
zhangFan authored
240 241 242
                    list.setRemark(String.format("%.1f", goodsWt));
                    list.setRemark1(String.format("%.1f", diffVal));
                    list.setRemark2(veName.getSelfWt());
zhangFan authored
243
                    list.setContrastflag("已出站");
zhangFan authored
244
                    logic.checkData(list);
zhangFan authored
245
                }
zhangFan authored
246
                int row = logic.listService.updateById(list);
zhangFan authored
247 248
                List<LandBusinessTypeList> businessTypeLists = logic.listService.selectByBarcode(info.getBarcode());
                int count = 0;
zhangFan authored
249
                for (int i = 0; i < businessTypeLists.size(); i++) {
zhangFan authored
250
                    String flag1 = businessTypeLists.get(i).getContrastflag();
zhangFan authored
251
                    if (flag1 != null) {
zhangFan authored
252 253 254
                        count++;
                    }
                }
xudada authored
255 256

                //决定所有业务走完 二维是否失效
zhangFan authored
257
                if (list.getBusinesstype().indexOf("业务") > 0) {
zhangFan authored
258
                    logic.inOrUpEnterCancel(list);
zhangFan authored
259
                    if (count == 4) {
zhangFan authored
260 261
                        buildBarCode.cancleBarCode(vaName);
                        logic.listService.updateByBarcode(info.getBarcode());
xudada authored
262 263 264
                    }else if(count==6){
                        buildBarCode.cancleBarCode(vaName);
                        logic.listService.updateByBarcode(info.getBarcode());
zhangFan authored
265
                    }
xudada authored
266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281
                } else if(list.getBusinesstype().equals("出口送货") && list.getEndport().equals("4620")){
                    if(list.getIsthree().equals("0")){
                        if(count==4){
                            buildBarCode.cancleBarCode(vaName);
                            logic.listService.updateByBarcode(info.getBarcode());
                        }
                    }else{
                        if(count==2){
                            buildBarCode.cancleBarCode(vaName);
                            logic.listService.updateByBarcode(info.getBarcode());
                        }
                    }


                }else{
                    if (count == 2 && !list.getEndport().equals("4620")) {
zhangFan authored
282 283 284 285 286 287
                        buildBarCode.cancleBarCode(vaName);
                        logic.listService.updateByBarcode(info.getBarcode());
                    }
                }
                result = true;
            }
zhangFan authored
288 289 290 291 292 293
            if(list.getMasterList().length()>0){
                boolean flag = VeManifestRelation.createFile(list);
                if(flag){
                    logger.info(">>>>>>>>>>-----车单关系报文生成成功-----<<<<<<<<<<<<");
                }
            }
zhangFan authored
294 295 296
        } else {
            sendError(info);
            logger.error("------->>>>>>>二维码数据异常,请使用正确的二维码数据<<<<<<<-----");
zhangFan authored
297
        }
zhangFan authored
298
        return result;
zhangFan authored
299
    }
zhangFan authored
300 301

    //将获取的checkWt进行小数转化
zhangFan authored
302 303
    public static double valueDob() {
        NumberFormat nf = NumberFormat.getPercentInstance();
zhangFan authored
304 305
        Number m = null;
        try {
zhangFan authored
306 307
            m = nf.parse(checkWt);//将百分数转换成Number类型
        } catch (ParseException e) {
zhangFan authored
308 309 310 311 312 313 314
            e.printStackTrace();
            logger.info(e.getMessage());
        }
        return m.doubleValue();
    }

    /**
zhangFan authored
315 316
     * 校验载重和称重是否在合理的范围
     *
zhangFan authored
317 318 319 320
     * @Param grossWt 地磅称重
     * @Param wt 车辆自重
     * @Param goodsWt 货物总重
     * @Result 获取运单重量
zhangFan authored
321
     */
zhangFan authored
322
    public boolean checkResult(double grossWt, double wt, double goodsWt) {
zhangFan authored
323
        DecimalFormat df = new DecimalFormat("0.00");
zhangFan authored
324
        boolean flag = false;
zhangFan authored
325 326
        double result = 0.0;
        if (goodsWt > 0) {
zhangFan authored
327
            result = Double.parseDouble(df.format(Math.abs((goodsWt + wt - grossWt)) / grossWt));
zhangFan authored
328
        } else {
zhangFan authored
329
            result = Double.parseDouble(df.format(Math.abs((grossWt - wt)) / grossWt));
zhangFan authored
330
        }
zhangFan authored
331
        if (result <= valueDob()) {
zhangFan authored
332 333 334 335 336 337 338 339 340
            flag = true;
        }
        return flag;
    }

    /**
     * @Param mainifast 主单列表
     * @Param ietype 进出标志
     * 获取货物总重
zhangFan authored
341
     */
zhangFan authored
342
    public double GoodsWt(String mainifast, String ietype) {
zhangFan authored
343
        Double sum = 0.0;
zhangFan authored
344 345 346
        if (mainifast.length() > 0) {
            String[] mainifastList = mainifast.split(",");
            for (String mainBill : mainifastList) {
zhangFan authored
347
                sum += getGrossWt(mainBill, ietype);
zhangFan authored
348
            }
zhangFan authored
349 350 351 352
        }
        return sum;
    }
zhangFan authored
353
    /**
zhangFan authored
354 355 356
     * @Param waybill 主单号
     * @Param imp 进出港标识
     * @Result 获取运单重量
zhangFan authored
357
     */
zhangFan authored
358 359 360 361 362
    public double getGrossWt(String waybill, String imp) {
        logger.info("进入获取重量action");
        if (!(waybill.indexOf("-") != -1)) {
            waybill = waybill.substring(0, 3) + "-" + waybill.substring(3);
        }
zhangFan authored
363
        String url = "http://10.50.3.82:8081/orig/orig?waybill=" + waybill + "&imp=" + imp;
zhangFan authored
364
        //  String url = "http://tjfx.15miaoo.com:8003/tj/orig/orig?waybill=" + waybill + "&imp=" + imp;
zhangFan authored
365 366 367 368
        StringBuilder json = new StringBuilder();
        Map map = null;
        double bg = 0;
        try {
zhangFan authored
369 370
            URL Url = new URL(url);
            URLConnection yc = Url.openConnection();
zhangFan authored
371
            BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream(), "utf-8"));
zhangFan authored
372 373 374 375
            String inputLine = null;
            while ((inputLine = in.readLine()) != null) {
                json.append(inputLine);
            }
zhangFan authored
376
            logger.info("返回数据:" + json);
zhangFan authored
377 378 379
            JSONArray array = JSONArray.parseArray(json.toString());
            for (int i = 0; i < array.size(); i++) {
                map = JSON.parseObject(array.getString(i));
zhangFan authored
380
                if (map.containsKey("receiptinformation")) {
zhangFan authored
381 382 383 384
                    if (map.get("receiptinformation").toString().startsWith("41301") || map.get("receiptinformation")
                            .toString().startsWith("41106") || map.get("receiptinformation")
                            .toString().startsWith("31301") || map.get("receiptinformation")
                            .toString().startsWith("31106") || map.get("receiptinformation")
zhangFan authored
385 386
                            .toString().indexOf("提运单放行") != -1) {
                        logger.info(map);
zhangFan authored
387 388 389 390
                        bg = Double.parseDouble((String) map.get("totalweight"));
                        logger.info("for循环取重量:" + bg);
                        return bg;
                    }
zhangFan authored
391 392
                }
            }
zhangFan authored
393
            logger.info("访问返回的数据重量:" + bg);
zhangFan authored
394 395
            in.close();
        } catch (MalformedURLException e) {
zhangFan authored
396 397
            e.printStackTrace();
            logger.error(e);
zhangFan authored
398
        } catch (IOException e) {
zhangFan authored
399 400
            e.printStackTrace();
            logger.error(e);
zhangFan authored
401 402 403
        }
        return bg;
    }
zhangFan authored
404
zhangFan authored
405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430
    /**
     * 查询运单是否全部放行
     *
     * @param manifestList
     * @return
     */
    public boolean checkManifest(String manifestList) {
        if (manifestList.length() < 1) return false;
        manifestList = manifestList.replace("-", "");
        String[] maifest = manifestList.split(",");
        boolean flag = false;
        int count = 0;
        for (int i = 0; i < maifest.length; i++) {
            RESMESSAGE resmessage = logic.resMessageService.selectByManifest(maifest[i]);
            if (resmessage != null) {
                if ("11".equals(resmessage.getResponsecode())) {
                    count++;
                }
            }
        }
        if (count == maifest.length) {
            flag = true;
        }
        return flag;
    }
zhangFan authored
431
zhangFan authored
432
    /**
zhangFan authored
433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473
     * 给码头发送卡口数据
     *
     * @param stationCode
     * @param carNo
     * @param IEtype
     */
    public static void sendData(String stationCode, String carNo, boolean IEtype) {
        String url = "http://10.50.3.73:8080/air-api/car/channelCar?stationCode=" + stationCode + "&carNo=" + carNo + "&isPickup=" + IEtype;
        try {
            HttpClient httpClient = new DefaultHttpClient();
            HttpGet httpGet = new HttpGet(url);
            HttpResponse httpResponse = httpClient.execute(httpGet);
            HttpEntity entity = httpResponse.getEntity();
            String entityStr = EntityUtils.toString(entity);
            logger.info("------------>>>>>>>>>>>>>>发送车辆信息:{stationCode:" + stationCode + ",carNo:" + carNo + ",isPickup:" + IEtype + "}");
            logger.info("------------>>>>>>>>>>>>>>响应返回内容:" + entityStr + "<<<<<<<<<<<<-----------");
        } catch (Exception e) {
            logger.info(e.toString());
        }
    }

    /**
     * 给码头发送卡口数据
     *
     * @param list
     */
    public void checkData(LandBusinessTypeList list) {
        String sationCode = null;
        boolean flag = false;
        if ("出口送货".equals(list.getBusinesstype()) || "出口流转".equals(list.getBusinesstype())) {
            flag = false;
        }
        if ("进口提货".equals(list.getBusinesstype()) || "进口流转".equals(list.getBusinesstype())) {
            flag = true;
        }
        if ("4604000000".equals(list.getEndstation())) {
            if ("I".equals(list.getTurnoverflag())) {
                sationCode = "HK05";
            } else {
                sationCode = "HK06";
            }
xudada authored
474
            //TODO:加场站判定
zhangFan authored
475 476 477 478 479 480
        }
        sendData(sationCode, list.getTrailerFrameNo(), flag);
    }


    /**
zhangFan authored
481 482 483
     * 校验重量并发送报文
     */
zhangFan authored
484
    public boolean sendBw(GatherInfo info, boolean check) {
xudada authored
485
        logger.info(String.format("开始发送指令:车牌%s,场站%s,通道%s,重量%s",info.getVename(),info.getAreaid(),info.getChnlno(),info.getGrosswt()));
zhangFan authored
486
        boolean flag = false;
zhangFan authored
487
        if (check) {
zhangFan authored
488
            CommandClient.Client(info, PERMITTHOUGH);
zhangFan authored
489
            logger.info("=============>>>>>>>>放行报文发送成功<<<<<<<<<==============");
zhangFan authored
490 491 492
            flag = true;
        } else {
            CommandClient.Client(info, GROWSSEXCETION);
zhangFan authored
493 494 495 496 497 498 499 500 501 502 503 504 505
            logger.info("=============>>>>>>>>重量异常报文发送成功<<<<<<<<<==============");
        }
        return flag;
    }

    /**
     * 排除当前系统问题发送错误commandInfo
     */
    public static void sendError(GatherInfo info) {
        CommandClient.Client(info, ISVALID);
    }

    /**
xudada authored
506
     * 判断空车加运单与地磅称重是否在合理范围
zhangFan authored
507 508 509 510 511 512 513 514 515 516 517
     *
     * @param grossWt
     * @param wt
     * @return
     */
    public boolean checkFlag(double grossWt, double wt) {
        DecimalFormat df = new DecimalFormat("0.00");
        boolean flag = false;
        double reult = Double.parseDouble(df.format(Math.abs((grossWt - wt)) / grossWt));
        if (reult <= valueDob()) {
            flag = true;
zhangFan authored
518
        }
zhangFan authored
519
        return flag;
zhangFan authored
520
    }
zhangFan authored
521
zhangFan authored
522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540
    /**
     * 生成或者更新货物冻结标识
     *
     * @param landBusinessTypeList
     */
    public void inOrUpEnterCancel(LandBusinessTypeList landBusinessTypeList) {
        if (landBusinessTypeList.getMasterList().length() < 1) return;
        String[] list = landBusinessTypeList.getMasterList().split(",");
        String flag = null;
        for (int i = 0; i < list.length; i++) {
            if("调拨业务".equals(landBusinessTypeList.getBusinesstype())){
                flag = "E";
            }else {
                flag = "I";
            }
            double wt = getGrossWt(list[i],flag);

            ENTERCANCCEL entercanccel = logic.enterCancelServer.selectByManifest(list[i]);
            if (entercanccel != null) {
zhangFan authored
541 542 543 544 545 546 547 548
                if(entercanccel.getVename().equals(landBusinessTypeList.getTrailerFrameNo())){
                    if ("0".equals(entercanccel.getIsfreeze())) {
                        entercanccel.setIsfreeze("1");
                        entercanccel.setEndport(landBusinessTypeList.getEndstation());
                        entercanccel.setUpdateBy(landBusinessTypeList.getCreateBy());
                        entercanccel.setUpdateTime(new Date());
                        logic.enterCancelServer.updateByPermaryKey(entercanccel);
                    }
zhangFan authored
549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
                }
            }else {
                if("E".equals(landBusinessTypeList.getTurnoverflag())){
                    ENTERCANCCEL canccel = new ENTERCANCCEL();
                    canccel.setIsfreeze("0");
                    canccel.setVename(landBusinessTypeList.getTrailerFrameNo());
                    canccel.setId(String.valueOf(System.currentTimeMillis()));
                    canccel.setVeCompanyName(landBusinessTypeList.getAgentno());
                    canccel.setBusinesstype(landBusinessTypeList.getBusinesstype());
                    canccel.setManifest(list[i]);
                    canccel.setAgentname(landBusinessTypeList.getAgentname());
                    canccel.setStartport(landBusinessTypeList.getEndstation());
                    canccel.setGrosswt(landBusinessTypeList.getAislewt());
                    canccel.setCreateBy(landBusinessTypeList.getCreateBy());
                    canccel.setCreateTime(new Date());
                    canccel.setUpdateBy(landBusinessTypeList.getCreateBy());
                    canccel.setUpdateTime(new Date());
                    canccel.setWeight(wt);
                    logic.enterCancelServer.insertEntry(canccel);
                }

            }
        }
    }
zhangFan authored
574
zhangFan authored
575
}