CUSTOM_RESPONSE.java 9.3 KB
package com.tianbo.messagebus.model;

import com.tianbo.messagebus.dao.CUSTOM_RESPONSEMapper;
import com.tianbo.messagebus.tools.AWBTools;
import com.tianbo.util.Date.DateUtil;
import lombok.Data;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.UUID;

public class CUSTOM_RESPONSE {

    private String id;

    private Date flightdate;

    private String flightno;

    private String carrier;

    private String awbano;

    private String awbhno;

    private String bustype;

    private Date busdate;

    private BigDecimal busweight;

    private Integer buspiece;

    private String opertype;

    private String cusmsgid;

    private String cussenderid;

    private String cusreciverid;

    private String cusversion;

    private String cusfunctioncode;

    private Date cusresrcvtime;

    private Date cusressendtime;

    private String cusrescode;

    private String cusresstatus;

    private String operusername;

    private String opersystemname;

    private String operreason;

    private String operperson;

    private String opertel;

    private String cusrestext;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id == null ? null : id.trim();
    }

    public Date getFlightdate() {
        return flightdate;
    }

    public void setFlightdate(Date flightdate) {
        this.flightdate = flightdate;
    }

    public String getFlightno() {
        return flightno;
    }

    public void setFlightno(String flightno) {
        this.flightno = flightno == null ? null : flightno.trim();
    }

    public String getCarrier() {
        return carrier;
    }

    public void setCarrier(String carrier) {
        this.carrier = carrier == null ? null : carrier.trim();
    }

    public String getAwbano() {
        return awbano;
    }

    public void setAwbano(String awbano) {
        this.awbano = awbano == null ? null : awbano.trim();
    }

    public String getAwbhno() {
        return awbhno;
    }

    public void setAwbhno(String awbhno) {
        this.awbhno = awbhno == null ? null : awbhno.trim();
    }

    public String getBustype() {
        return bustype;
    }

    public void setBustype(String bustype) {
        this.bustype = bustype == null ? null : bustype.trim();
    }

    public Date getBusdate() {
        return busdate;
    }

    public void setBusdate(Date busdate) {
        this.busdate = busdate;
    }

    public BigDecimal getBusweight() {
        return busweight;
    }

    public void setBusweight(BigDecimal busweight) {
        this.busweight = busweight;
    }

    public Integer getBuspiece() {
        return buspiece;
    }

    public void setBuspiece(Integer buspiece) {
        this.buspiece = buspiece;
    }

    public String getOpertype() {
        return opertype;
    }

    public void setOpertype(String opertype) {
        this.opertype = opertype == null ? null : opertype.trim();
    }

    public String getCusmsgid() {
        return cusmsgid;
    }

    public void setCusmsgid(String cusmsgid) {
        this.cusmsgid = cusmsgid == null ? null : cusmsgid.trim();
    }

    public String getCussenderid() {
        return cussenderid;
    }

    public void setCussenderid(String cussenderid) {
        this.cussenderid = cussenderid == null ? null : cussenderid.trim();
    }

    public String getCusreciverid() {
        return cusreciverid;
    }

    public void setCusreciverid(String cusreciverid) {
        this.cusreciverid = cusreciverid == null ? null : cusreciverid.trim();
    }

    public String getCusversion() {
        return cusversion;
    }

    public void setCusversion(String cusversion) {
        this.cusversion = cusversion == null ? null : cusversion.trim();
    }

    public String getCusfunctioncode() {
        return cusfunctioncode;
    }

    public void setCusfunctioncode(String cusfunctioncode) {
        this.cusfunctioncode = cusfunctioncode == null ? null : cusfunctioncode.trim();
    }

    public Date getCusresrcvtime() {
        return cusresrcvtime;
    }

    public void setCusresrcvtime(Date cusresrcvtime) {
        this.cusresrcvtime = cusresrcvtime;
    }

    public Date getCusressendtime() {
        return cusressendtime;
    }

    public void setCusressendtime(Date cusressendtime) {
        this.cusressendtime = cusressendtime;
    }

    public String getCusrescode() {
        return cusrescode;
    }

    public void setCusrescode(String cusrescode) {
        this.cusrescode = cusrescode == null ? null : cusrescode.trim();
    }

    public String getCusresstatus() {
        return cusresstatus;
    }

    public void setCusresstatus(String cusresstatus) {
        this.cusresstatus = cusresstatus == null ? null : cusresstatus.trim();
    }

    public String getOperusername() {
        return operusername;
    }

    public void setOperusername(String operusername) {
        this.operusername = operusername == null ? null : operusername.trim();
    }

    public String getOpersystemname() {
        return opersystemname;
    }

    public void setOpersystemname(String opersystemname) {
        this.opersystemname = opersystemname == null ? null : opersystemname.trim();
    }

    public String getOperreason() {
        return operreason;
    }

    public void setOperreason(String operreason) {
        this.operreason = operreason == null ? null : operreason.trim();
    }

    public String getOperperson() {
        return operperson;
    }

    public void setOperperson(String operperson) {
        this.operperson = operperson == null ? null : operperson.trim();
    }

    public String getOpertel() {
        return opertel;
    }

    public void setOpertel(String opertel) {
        this.opertel = opertel == null ? null : opertel.trim();
    }

    public String getCusrestext() {
        return cusrestext;
    }

    public void setCusrestext(String cusrestext) {
        this.cusrestext = cusrestext == null ? null : cusrestext.trim();
    }

    public CUSTOM_RESPONSE() {

    }

    /**
     * 海关回执实体与系统回执实体转换
     * @param customReception
     */
    public CUSTOM_RESPONSE(CustomReception customReception) {
        this.id = UUID.randomUUID().toString();
        this.awbano = AWBTools.awbFormat(customReception.getWayBillMaster());

        //取分单号
        if (!StringUtils.isEmpty(customReception.getWayBillSecond())){
            String[] awbhArr = customReception.getWayBillSecond().split("_");
            this.awbhno = awbhArr[1];
        }


        String[] flightInfo = AWBTools.splitFlight(customReception.getFlightNo());
        this.setFlightno(flightInfo[1]);
        this.setCarrier(flightInfo[0]);
        if (!StringUtils.isEmpty(customReception.getFlightDate())) {
            this.setFlightdate(DateUtil.formatByyyyyMMdd(customReception.getFlightDate()));
        }
        this.cusrestext = customReception.getResponseText();
        this.cusrescode = customReception.getResponseCode();
        this.bustype = customReception.getMessageType();
        this.cusfunctioncode = customReception.getFunctionCode();
        this.operusername = "SYSTEM";
        this.cusmsgid = customReception.getMessageID();
        this.opertype = "回执";
        this.cussenderid = customReception.getSenderID();
        this.cusreciverid = customReception.getReceiverID();
        this.cusresrcvtime = new Date();
        this.cusressendtime = DateUtil.formatByyyyyMMddHHmmss(customReception.getSendTime());
        this.cusversion = customReception.getVersion();

        //单独存储下回执内容中的回执业务代码
        if(this.cusrescode!= "0" && this.cusrestext!= null && this.cusrestext.length()>5){
            this.cusresstatus = customReception.getResponseText().substring(0,5);
        }
    }

    @Override
    public String toString() {
        return "CUSTOM_RESPONSE{" +
                "id='" + id + '\'' +
                ", flightdate=" + flightdate +
                ", flightno='" + flightno + '\'' +
                ", carrier='" + carrier + '\'' +
                ", awbano='" + awbano + '\'' +
                ", awbhno='" + awbhno + '\'' +
                ", bustype='" + bustype + '\'' +
                ", busdate=" + busdate +
                ", busweight=" + busweight +
                ", buspiece=" + buspiece +
                ", opertype='" + opertype + '\'' +
                ", cusmsgid='" + cusmsgid + '\'' +
                ", cussenderid='" + cussenderid + '\'' +
                ", cusreciverid='" + cusreciverid + '\'' +
                ", cusversion='" + cusversion + '\'' +
                ", cusfunctioncode='" + cusfunctioncode + '\'' +
                ", cusresrcvtime=" + cusresrcvtime +
                ", cusressendtime=" + cusressendtime +
                ", cusrescode='" + cusrescode + '\'' +
                ", cusresstatus='" + cusresstatus + '\'' +
                ", operusername='" + operusername + '\'' +
                ", opersystemname='" + opersystemname + '\'' +
                ", operreason='" + operreason + '\'' +
                ", operperson='" + operperson + '\'' +
                ", opertel='" + opertel + '\'' +
                ", cusrestext='" + cusrestext + '\'' +
                '}';
    }
}