审查视图

src/main/java/com/tianbo/analysis/service/imp/TALLYMASTERServiceImp.java 3.8 KB
申海龙 authored
1 2 3 4 5 6
package com.tianbo.analysis.service.imp;

import com.tianbo.analysis.dao.TALLYMASTERMapper;
import com.tianbo.analysis.dao.TALLYSECONDARYMapper;
import com.tianbo.analysis.model.TALLYMASTER;
import com.tianbo.analysis.model.TALLYSECONDARY;
7
import com.tianbo.analysis.model.NmmsBase;
申海龙 authored
8 9 10
import com.tianbo.analysis.service.TALLYMASTERService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
11
import org.springframework.scheduling.annotation.Async;
申海龙 authored
12 13 14 15 16
import org.springframework.stereotype.Service;

import java.util.List;

/**
17
 * 进出港理货回执解析入库
申海龙 authored
18 19 20 21 22 23
 * @Auther: shenhl
 * @Date: 2019/8/23 17:17
 */

@Service
@Slf4j
24 25
@Async
public class TALLYMASTERServiceImp extends NmmsBase implements TALLYMASTERService{
申海龙 authored
26 27 28 29 30 31 32

    @Autowired
    TALLYMASTERMapper tallymasterMapper;

    @Autowired
    TALLYSECONDARYMapper tallysecondaryMapper;
33 34 35 36
    /**
     * 入库主单回执信息
     * @return 成功返回1,失败返回0。
     */
朱兆平 authored
37
    @Override
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
    public int master(){
        String mt = customReception.getMessageType();
        //设置进出港理货回执、航班号、航班日期
        TALLYMASTER tallymaster = new TALLYMASTER();
        tallymaster.setWaybillnomaster(awbA);
        tallymaster.setReceiptinformation(reception);
        tallymaster.setFlightno(customReception.getFlightNo());
        tallymaster.setFlightdate(flightDate);
        tallymaster.setTalltype(mt);
        tallymaster.setStatus(nmsStatusCode);
        //更新主单回执
        int i = tallymasterMapper.updateRECEIPTION(tallymaster);
        //获取主单autoid
        List<TALLYMASTER> arrivedmasterList = tallymasterMapper.selectAutoIdByAwb(tallymaster);
        if(!arrivedmasterList.isEmpty()){
            TALLYMASTER originMaster = arrivedmasterList.get(0);
            String autoId = originMaster.getAutoid();

            int ii =coustomAnalysisServiceImp.insertSendlog(mt,reception,autoId);

            int iii = shareServiceImp.updateMessages(customReception);
            if (i>0 && ii>0 ){
                log.info("运单号 {} 理货回执更新成功",awbA);
                return 1;
            }
            if (iii > 0){
                return 1;
            }
        }
        return 0;
    }

    /**
     * 入库分单回执信息
朱兆平 authored
72
     * @return 成功返回1,失败返回0。
73
     */
朱兆平 authored
74
    @Override
75 76 77 78 79 80
    public int second(){
        TALLYSECONDARY tallysecondary = new TALLYSECONDARY();
        tallysecondary.setReceiptinformation(reception);
        tallysecondary.setStatus(nmsStatusCode);
        //设置主分单的 主单号
        tallysecondary.setWaybillnomaster(awbA);
81
        log.info("开始解析主单的{}分单{}",awbA,awbH);
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
        //取分单号
        String[] awbhArr = awbH.split("_");
        String awbh = awbhArr[1];
        tallysecondary.setWaybillnosecondary(awbh);
        //更新分单回执
        int i = tallysecondaryMapper.updateRECEIPTION(tallysecondary);
        //获取分单autoid
        List<TALLYSECONDARY> tallysecondaryList = tallysecondaryMapper.selectAutoIdByawbAawbH(tallysecondary);

        if(!tallysecondaryList.isEmpty()){
            TALLYSECONDARY arrivedSecond = tallysecondaryList.get(0);
            String autoId =  arrivedSecond.getAutoid();
            //插入sendlog记录表
            log.info("即将插入理货分单回执,运单号为:{},autoid:{}",awbH,autoId);
            int ii = coustomAnalysisServiceImp.insertSendlog(customReception.getMessageType(),reception,autoId);

            //通过messageid适配发送日志表并更新
            int iii = shareServiceImp.updateMessages(customReception);
            if (i>0 && ii>0){
                log.info("运单号 {} 理货回执更新成功",awbH);
                return 1;
            }
            if (iii > 0){
                return 1;
            }

        }
        return 0;
    }
申海龙 authored
111
}