审查视图

src/main/java/com/sy/service/impl/ResMessageServiceImpl.java 4.0 KB
zhangFan authored
1 2 3
package com.sy.service.impl;

import com.sy.mapper.RESMESSAGEMapper;
4
import com.sy.model.GatherInfo;
xudada authored
5
import com.sy.model.LAND_BUSINEESTYPE_LIST_INFO;
zhangFan authored
6
import com.sy.model.RESMESSAGE;
7
import com.sy.service.CommandLogService;
zhangFan authored
8
import com.sy.service.ResMessageService;
9
import com.sy.socket.CommandClient;
10
import lombok.extern.slf4j.Slf4j;
zhangFan authored
11 12 13
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
xudada authored
14
import java.util.ArrayList;
15
import java.util.Arrays;
朱兆平 authored
16
import java.util.List;
17
import java.util.Vector;
18
import java.util.stream.Collectors;
朱兆平 authored
19
zhangFan authored
20 21 22 23 24
/**
 * @author
 * @time 2019-${MOUTH}-22 21:32
 */
@Service
25
@Slf4j
zhangFan authored
26
public class ResMessageServiceImpl implements ResMessageService {
27 28
    private static String FANGXING="-等运单未放行";
    private static String AWB_EMPTY="未申请装载运单";
29
zhangFan authored
30 31 32
    @Autowired
    private RESMESSAGEMapper mapper;
33 34 35
    @Autowired
    CommandLogService commandLogService;
zhangFan authored
36
朱兆平 authored
37
    @Override
zhangFan authored
38 39 40 41
    public int saveEnter(RESMESSAGE resmessage){
        return mapper.insertSelective(resmessage);
    }
朱兆平 authored
42
    @Override
zhangFan authored
43 44 45
    public RESMESSAGE selectByManifest(String manifest){
        return mapper.selectByManifest(manifest);
    }
朱兆平 authored
46 47 48 49 50 51 52

    @Override
    public List<RESMESSAGE> selectByManifestList(String[] manifest) {
        return mapper.selectByManifestList(manifest);
    }

    @Override
xudada authored
53
    public boolean checkManifestRelease(GatherInfo info, List<LAND_BUSINEESTYPE_LIST_INFO> list_infos) {
54
        List<String> noRelease = new Vector<>();
xudada authored
55
        if (list_infos.size() < 1) {
56
            CommandClient.Client(info, AWB_EMPTY);
朱兆平 authored
57 58
            return false;
        }
59
60 61 62 63 64 65 66 67 68
        //只拉板箱的话,这里list_infos会为null
        list_infos = list_infos.stream().filter(listInfo ->{
            if("B".equals(listInfo.getExt4())){
                return true;
            }else {
                return false;
            }
        }).collect(Collectors.toList());
69
        log.info("运单列表:" + toStrArry(list_infos));
朱兆平 authored
70 71
        boolean flag = false;
72 73 74 75 76 77
        /**
         * 这里如果list_infos为NULL,会报错NULL Exception.什么指令都不给了.
         * 如果申请单据只有ULD板箱类型的时候.
         */
        if (!list_infos.isEmpty()){
            List<RESMESSAGE> list = selectByManifestList(toStrArry(list_infos));
朱兆平 authored
78
79 80 81 82 83 84 85 86 87 88 89 90 91 92
            if (list.size() == toStrArry(list_infos).length) {
                flag = true;
            }else{
                //返回未放行的运单列表
                if (toStrArry(list_infos).length>0){
                    for (String awb : toStrArry(list_infos)) {
                        boolean anyMatch = list.stream().anyMatch(resmessage -> {
                            return resmessage.getManifest().equals(awb);
                        });
                        if (!anyMatch){
                            noRelease.add(awb);
                        }
                    }
                    if (!noRelease.isEmpty()) {
93
                        log.info(Arrays.toString(noRelease.toArray())+FANGXING);
94 95 96
                        commandLogService.commandlog(info,false,Arrays.toString(noRelease.toArray())+FANGXING,null,list_infos,
                                new Double("0.0"),new Double("0.0"),new Double("0.0"),new Double("0.0"));
                        CommandClient.Client(info, Arrays.toString(noRelease.toArray())+FANGXING);
97 98 99
                    }
                }
            }
朱兆平 authored
100
        }
101 102 103 104 105
        //todo:如果只拉集装器的判定
        else{
            log.info("[放行判定]:{}","集装器与散杂货放行");
            return true;
        }
106 107

朱兆平 authored
108 109
        return flag;
    }
110 111 112
    public static String[] toStrArry(List<LAND_BUSINEESTYPE_LIST_INFO> list_infos){
        List<String> manifestList=new ArrayList<String>();
        for(LAND_BUSINEESTYPE_LIST_INFO land:list_infos){
xudada authored
113
            manifestList.add(land.getAwba().replace("-",""));
114 115 116 117 118
        }
        //manifestList = manifestList.replace("-", "").replace(",", ",");
        String[] maifest = manifestList.toArray(new String[manifestList.size()]);
        return maifest;
    }
zhangFan authored
119
}