TALLYSECONDARY.java 6.4 KB
package com.tianbo.analysis.model;

import com.tianbo.analysis.bean.WlptBaseModel;
import com.tianbo.analysis.tools.AWBTools;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;
import java.util.List;

@Data
@Slf4j
public class TALLYSECONDARY extends WlptBaseModel {
    private String autoid;

    private String waybillnomaster;

    private String waybillnosecondary;

    private String weight;

    private String piece;

    private String tallypiece;

    private String tallyweight;

    private String customscode;

    private String productname;

    private Date dischargedate;

    private Date createdate;

    private Date loadstarttime;

    private Date loadendtime;

    private String tallymasterid;

    private String dealFlag;

    private String billTallyFlag;

    private Date dealTime;

    private String status;

    private String receiptinformation;

    private TALLYMASTER master;

    private CustomReception customReceptionT;

    public String getAutoid() {
        return autoid;
    }

    public void setAutoid(String autoid) {
        this.autoid = autoid == null ? null : autoid.trim();
    }

    public String getWaybillnomaster() {
        return waybillnomaster;
    }

    public void setWaybillnomaster(String waybillnomaster) {
        this.waybillnomaster = waybillnomaster == null ? null : waybillnomaster.trim();
    }

    public String getWaybillnosecondary() {
        return waybillnosecondary;
    }

    public void setWaybillnosecondary(String waybillnosecondary) {
        this.waybillnosecondary = waybillnosecondary == null ? null : waybillnosecondary.trim();
    }

    public String getWeight() {
        return weight;
    }

    public void setWeight(String weight) {
        this.weight = weight == null ? null : weight.trim();
    }

    public String getPiece() {
        return piece;
    }

    public void setPiece(String piece) {
        this.piece = piece == null ? null : piece.trim();
    }

    public String getTallypiece() {
        return tallypiece;
    }

    public void setTallypiece(String tallypiece) {
        this.tallypiece = tallypiece == null ? null : tallypiece.trim();
    }

    public String getTallyweight() {
        return tallyweight;
    }

    public void setTallyweight(String tallyweight) {
        this.tallyweight = tallyweight == null ? null : tallyweight.trim();
    }

    public String getCustomscode() {
        return customscode;
    }

    public void setCustomscode(String customscode) {
        this.customscode = customscode == null ? null : customscode.trim();
    }

    public String getProductname() {
        return productname;
    }

    public void setProductname(String productname) {
        this.productname = productname == null ? null : productname.trim();
    }

    public Date getDischargedate() {
        return dischargedate;
    }

    public void setDischargedate(Date dischargedate) {
        this.dischargedate = dischargedate;
    }

    public Date getCreatedate() {
        return createdate;
    }

    public void setCreatedate(Date createdate) {
        this.createdate = createdate;
    }

    public Date getLoadstarttime() {
        return loadstarttime;
    }

    public void setLoadstarttime(Date loadstarttime) {
        this.loadstarttime = loadstarttime;
    }

    public Date getLoadendtime() {
        return loadendtime;
    }

    public void setLoadendtime(Date loadendtime) {
        this.loadendtime = loadendtime;
    }

    public String getTallymasterid() {
        return tallymasterid;
    }

    public void setTallymasterid(String tallymasterid) {
        this.tallymasterid = tallymasterid == null ? null : tallymasterid.trim();
    }

    public String getDealFlag() {
        return dealFlag;
    }

    public void setDealFlag(String dealFlag) {
        this.dealFlag = dealFlag == null ? null : dealFlag.trim();
    }

    public String getBillTallyFlag() {
        return billTallyFlag;
    }

    public void setBillTallyFlag(String billTallyFlag) {
        this.billTallyFlag = billTallyFlag == null ? null : billTallyFlag.trim();
    }

    public Date getDealTime() {
        return dealTime;
    }

    public void setDealTime(Date dealTime) {
        this.dealTime = dealTime;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status == null ? null : status.trim();
    }

    public String getReceiptinformation() {
        return receiptinformation;
    }

    public void setReceiptinformation(String receiptinformation) {
        this.receiptinformation = receiptinformation == null ? null : receiptinformation.trim();
    }

    public TALLYSECONDARY(){

    }
    public TALLYSECONDARY(CustomReception customReception) {
        this.customReceptionT = customReception;
        this.waybillnomaster = AWBTools.awbFormat(customReception.getWayBillMaster());
        this.waybillnosecondary = customReception.getWayBillSecond().split("_")[1];
        this.status = AWBTools.transCusRspCode(customReception.getResponseCode());
        this.receiptinformation = customReception.getResponseText();
        this.master = new TALLYMASTER(customReception);
    }

    @Override
    public int secondAnalysisReception() {

        //todo:这里要根据回执的航班信息取到主单的autoid,设置到分单中。做到精确解析
        List<TALLYMASTER> masterlist = tallymasterMapper.selectAutoIdByAwb(this.master);
        if(!masterlist.isEmpty()){
            TALLYMASTER masterResult = masterlist.get(0);
            this.tallymasterid = masterResult.getAutoid();

        }
        //更新分单回执
        int i = tallysecondaryMapper.updateRECEIPTION(this);
        //获取分单autoid
        List<TALLYSECONDARY> tallysecondaryList = tallysecondaryMapper.selectAutoIdByawbAawbH(this);

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

            if (i>0 && ii>0){
                log.info("运单号 {} 理货回执更新成功",waybillnosecondary);
                return 1;
            }

        }
        return 0;
    }
}