Jiaqi.xu

BASF接口

package com.erry.iclear.dateInterface.api;
import com.erry.iclear.dateInterface.api.request.BasfMawb;
import com.erry.iclear.dateInterface.api.request.Basfc;
import com.erry.iclear.dateInterface.api.request.Mawb;
import com.erry.iclear.dateInterface.api.response.ResultRS;
import com.erry.iclear.dateInterface.entity.IClearApiLog;
import com.erry.iclear.dateInterface.service.BasfService;
import com.erry.iclear.dateInterface.service.ChmConsignmentService;
import com.erry.iclear.dateInterface.service.IClearApiLogService;
import com.erry.iclear.dateInterface.service.MawbService;
import com.google.gson.Gson;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
......@@ -29,6 +29,9 @@ public class BasfDataInterface {
private BasfService basfService;
@Autowired
private ChmConsignmentService chmConsignmentService;
@Autowired
private IClearApiLogService iClearApiLogService;
@ApiOperation(value = "BASF推送运单数据", httpMethod = "POST", notes = "ex: http://192.168.1.75:8080/customs/sendMawbBasf")
......@@ -55,7 +58,7 @@ public class BasfDataInterface {
IClearApiLog saveIClearApiLogResult = iClearApiLogService.saveIClearApiLog(iClearApiLogService.convertToIClearApiLogC(basfc,appId,appKey,new Date(Long.valueOf(timeStamp))));
basfc.setAppId(appId);
Mawb saveMawbBasfResult = null;
BasfMawb saveMawbBasfResult = null;
if(!Objects.equals(saveIClearApiLogResult,null)){
log.info("请求保存成功,msgId:"+saveIClearApiLogResult.getMsgId());
basfc.setMsgId(saveIClearApiLogResult.getMsgId());
......@@ -93,7 +96,7 @@ public class BasfDataInterface {
//4、保存运单到iclear中
sw.start("processChmConsignment");
result = chmConsignmentService.processChmConsignment(saveMawbBasfResult, timeStamp,appId);
result = chmConsignmentService.processChmConsignmentBasf(saveMawbBasfResult, timeStamp,appId);
if(!result.getSuccess()){
return result;
}
......
......@@ -42,12 +42,10 @@ public class BasfMawb implements Serializable {
@ApiModelProperty(value = "进出口标志", name = "IEFlag", example = "固定值:E")
@NotBlank(message="参数ieFlag不能为空", groups = {MawbAdd.class})
@Column(name = "IEFLAG")
private String ieFlag;
@ApiModelProperty(value = "报关类型", name = "Type", example = "固定值:EX")
@NotBlank(message="参数type不能为空", groups = {MawbAdd.class})
@Column(name = "TYPE")
private String type;
......@@ -62,7 +60,6 @@ public class BasfMawb implements Serializable {
private String agentName;
@ApiModelProperty(value = "提单号", name = "billNo", example = "固定值:有总单号则取值‘总单号_运单号‘,没有总单号则取值‘运单号‘")
@NotBlank(message="参数billNo不能为空")
@Column(name = "BILLNO")
private String billNo;
......@@ -71,12 +68,10 @@ public class BasfMawb implements Serializable {
private String contrNo;
@ApiModelProperty(value = "主管海关(申报地海关)", name = "customMaster", example = "固定值:0101")
@NotBlank(message="参数customMaster不能为空", groups = {MawbAdd.class})
@Column(name = "CUSTOMMASTER")
private String customMaster;
@ApiModelProperty(value = "征免性质", name = "cutMode", example = "101")
@NotBlank(message="参数cutMode不能为空", groups = {MawbAdd.class})
@Column(name = "CUTMODE")
private String cutMode;
......@@ -86,12 +81,10 @@ public class BasfMawb implements Serializable {
private String declTrnRel;
@ApiModelProperty(value = "经停港/指运港", name = "distinatePort", example = "ASM000")
@NotBlank(message="参数distinatePort不能为空", groups = {MawbAdd.class})
@Column(name = "DISTINATEPORT")
private String distinatePort;
@ApiModelProperty(value = "报关标志", name = "EdiId", example = "001")
@NotBlank(message="参数ediId不能为空", groups = {MawbAdd.class})
@Column(name = "EDIID")
private String ediId;
......@@ -100,27 +93,22 @@ public class BasfMawb implements Serializable {
private String entryId;
@ApiModelProperty(value = "运费币制", name = "feeCurr", example = "固定值:3")
@NotBlank(message="参数feeCurr不能为空", groups = {MawbAdd.class})
@Column(name = "FEECURR")
private String feeCurr;
@ApiModelProperty(value = "运费标记", name = "feeMark", example = "99.22")
@NotBlank(message="参数feeMark不能为空", groups = {MawbAdd.class})
@Column(name = "FEEMARK")
private String feeMark;
@ApiModelProperty(value = "运费/率", name = "feeRate", example = "43.34358")
@NotNull(message="参数feeRate不能为空", groups = {MawbAdd.class})
@Column(name = "FEERATE")
private BigDecimal feeRate;
@ApiModelProperty(value = "毛重", name = "grossWet", example = "")
@NotNull(message="参数grossWet不能为空", groups = {MawbAdd.class})
@Column(name = "CROSSWET")
private BigDecimal grossWet;
@ApiModelProperty(value = "出入境关闭", name = "IEPort", example = "固定值:0101")
@NotBlank(message="参数iePort不能为空", groups = {MawbAdd.class})
@Column(name = "IEPORT")
private String iePort;
......@@ -129,7 +117,6 @@ public class BasfMawb implements Serializable {
private String inputerName;
@ApiModelProperty(value = "保险费币制", name = "insurCurr", example = "MOP")
@NotBlank(message="参数insurCurr不能为空", groups = {MawbAdd.class})
@Column(name = "INSURCURR")
private String insurCurr;
......@@ -138,7 +125,6 @@ public class BasfMawb implements Serializable {
private String insurMark;
@ApiModelProperty(value = "保险费/率", name = "insurRate", example = "")
@NotNull(message="参数insurRate不能为空", groups = {MawbAdd.class})
@Column(name = "INSURRATE")
private BigDecimal insurRate;
......@@ -147,7 +133,6 @@ public class BasfMawb implements Serializable {
private String manualNo;
@ApiModelProperty(value = "净重", name = "netWt", example = "")
@NotNull(message="参数netWt不能为空", groups = {MawbAdd.class})
@Column(name = "NETWT")
private BigDecimal netWt;
......@@ -164,7 +149,6 @@ public class BasfMawb implements Serializable {
private String otherMark;
@ApiModelProperty(value = "消费使用/生产销售单位代码", name = "ownerCode", example = "Z321654987")
@NotBlank(message="参数ownerCode不能为空", groups = {MawbAdd.class})
@Column(name = "OWNERCODE")
private String ownerCode;
......@@ -174,7 +158,6 @@ public class BasfMawb implements Serializable {
private String ownerName;
@ApiModelProperty(value = "件数", name = "packNo", example = "")
@NotNull(message="参数packNo不能为空", groups = {MawbAdd.class})
@Column(name = "PACKNO")
private Integer packNo;
......@@ -182,52 +165,42 @@ public class BasfMawb implements Serializable {
private String preEntryId;
@ApiModelProperty(value = "启运国/运抵国", name = "tradeCountry", example = "USA")
@NotBlank(message="参数tradeCountry不能为空", groups = {MawbAdd.class})
@Column(name = "TRADECOUNTRY")
private String tradeCountry;
@ApiModelProperty(value = "监管方式", name = "tradeMode", example = "0200")
@NotBlank(message="参数tradeMode不能为空", groups = {MawbAdd.class})
@Column(name = "TRADEMODE")
private String tradeMode;
@ApiModelProperty(value = "境内收发货人编号", name = "tradeCode", example = "Z321654987")
@NotBlank(message="参数tradeCode不能为空")
@Column(name = "TRADECODE")
private String tradeCode;
@ApiModelProperty(value = "运输方式代码", name = "trafMode", example = "1")
@NotBlank(message="参数trafMode不能为空", groups = {MawbAdd.class})
@Column(name = "TRAFMODE")
private String trafMode;
@ApiModelProperty(value = "境内收发货人名称", name = "tradeName", example = "上海铢怡国际货物运输代理有限公司")
@NotBlank(message="参数tradeName不能为空")
@Column(name = "TRADENAME")
private String tradeName;
@ApiModelProperty(value = "成交方式", name = "transMode", example = "2")
@NotBlank(message="参数transMode不能为空", groups = {MawbAdd.class})
@Column(name = "TRANSMODE")
private String transMode;
@ApiModelProperty(value = "包装种类", name = "wrapType", example = "22")
@NotBlank(message="参数wrapType不能为空", groups = {MawbAdd.class})
@Column(name = "WRAPTYPE")
private String wrapType;
@ApiModelProperty(value = "生产核销单位统一信用代码---报关形式类型", name = "TradeCodeScc", example = "A74125896321456987")
@NotBlank(message="参数tradeCodeScc不能为空")
@Column(name = "TRADECODESCC")
private String tradeCodeScc;
@ApiModelProperty(value = "消费使用/生产销售单位单位统一编码", name = "ownerCodeScc", example = "")
@NotBlank(message="参数ownerCodeScc不能为空", groups = {MawbAdd.class})
@Column(name = "OWNERCODESCC")
private String ownerCodeScc;
@ApiModelProperty(value = "贸易国别", name = "tradeAreaCode", example = "")
@NotBlank(message="参数tradeAreaCode不能为空", groups = {MawbAdd.class})
@Column(name = "TRADEAREACODE")
private String tradeAreaCode;
......@@ -236,7 +209,6 @@ public class BasfMawb implements Serializable {
private String markNo;
@ApiModelProperty(value = "入境口岸代码", name = "entyPortCode", example = "固定值:310302")
@NotBlank(message="参数entyPortCode不能为空", groups = {MawbAdd.class})
@Column(name = "ENTYPORTCODE")
private String entyPortCode;
......@@ -256,7 +228,6 @@ public class BasfMawb implements Serializable {
private String overseasConsigneeCode;
@ApiModelProperty(value = "境外收货人名称(外文)", name = "overseasConsigneeEname", example = "")
@NotBlank(message="参数overseasConsigneeEname不能为空", groups = {MawbAdd.class})
@Column(name = "OVERSEASCONSIGNEEENAME")
private String overseasConsigneeEname;
......
package com.erry.iclear.dateInterface.api.request;
public class BasfMawbDetail {
}
......@@ -49,22 +49,18 @@ public class BasfcDetail {
private String model;
@ApiModelProperty(value = "第一计量单位(法定单位)")
@NotBlank(message="参数unitLegalFirst不能为空")
@Column(name = "UNITLEGALFIRST")
private String unitLegalFirst;
@ApiModelProperty(value = "第一法定数量")
@NotNull(message="参数qtyLegalFirst不能为空")
@Column(name = "QTY_LEGALFIRST")
private BigDecimal qtyLegalFirst;
@ApiModelProperty(value = "成交计量单位")
@NotBlank(message="参数knockdownUnit不能为空")
@Column(name = "KNOCKDOWNUNIT")
private String knockdownUnit;
@ApiModelProperty(value = "成交数量")
@NotNull(message="参数knockdownNumber不能为空")
@Column(name = "KNOCKDOWNNUMBER")
private BigDecimal knockdownNumber;
......@@ -73,22 +69,18 @@ public class BasfcDetail {
private String unitLegalSecond;
@ApiModelProperty(value = "第二法定数量")
@NotNull(message="参数qtyLegalSecond不能为空")
@Column(name = "QTYLEGALSECOND")
private BigDecimal qtyLegalSecond;
@ApiModelProperty(value = "申报金额")
@NotBlank(message = "参数declaredAmount不能为空")
@Column(name = "DECLAREDAMOUNT")
private BigDecimal declaredAmount;
@ApiModelProperty(value = "币制")
@NotBlank(message="参数currency不能为空")
@Column(name = "CURRENCY")
private String currency;
@ApiModelProperty(value = "申报重量")
@NotBlank(message = "参数declaredWeight不能为空")
@Column(name = "DECLAREDWEIGHT")
private BigDecimal declaredWeight;
}
......
......@@ -42,12 +42,12 @@ public class Mawb implements Serializable {
@ApiModelProperty(value = "进出口标志", name = "IEFlag", example = "固定值:E")
@NotBlank(message="参数ieFlag不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数ieFlag不能为空")
@Column(name = "IEFLAG")
private String ieFlag;
@ApiModelProperty(value = "报关类型", name = "Type", example = "固定值:EX")
@NotBlank(message="参数type不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数type不能为空")
@Column(name = "TYPE")
private String type;
......@@ -71,12 +71,12 @@ public class Mawb implements Serializable {
private String contrNo;
@ApiModelProperty(value = "主管海关(申报地海关)", name = "customMaster", example = "固定值:0101")
@NotBlank(message="参数customMaster不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数customMaster不能为空")
@Column(name = "CUSTOMMASTER")
private String customMaster;
@ApiModelProperty(value = "征免性质", name = "cutMode", example = "101")
@NotBlank(message="参数cutMode不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数cutMode不能为空")
@Column(name = "CUTMODE")
private String cutMode;
......@@ -86,12 +86,12 @@ public class Mawb implements Serializable {
private String declTrnRel;
@ApiModelProperty(value = "经停港/指运港", name = "distinatePort", example = "ASM000")
@NotBlank(message="参数distinatePort不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数distinatePort不能为空")
@Column(name = "DISTINATEPORT")
private String distinatePort;
@ApiModelProperty(value = "报关标志", name = "EdiId", example = "001")
@NotBlank(message="参数ediId不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数ediId不能为空")
@Column(name = "EDIID")
private String ediId;
......@@ -100,27 +100,27 @@ public class Mawb implements Serializable {
private String entryId;
@ApiModelProperty(value = "运费币制", name = "feeCurr", example = "固定值:3")
@NotBlank(message="参数feeCurr不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数feeCurr不能为空")
@Column(name = "FEECURR")
private String feeCurr;
@ApiModelProperty(value = "运费标记", name = "feeMark", example = "99.22")
@NotBlank(message="参数feeMark不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数feeMark不能为空")
@Column(name = "FEEMARK")
private String feeMark;
@ApiModelProperty(value = "运费/率", name = "feeRate", example = "43.34358")
@NotNull(message="参数feeRate不能为空", groups = {MawbAdd.class})
@NotNull(message="参数feeRate不能为空")
@Column(name = "FEERATE")
private BigDecimal feeRate;
@ApiModelProperty(value = "毛重", name = "grossWet", example = "")
@NotNull(message="参数grossWet不能为空", groups = {MawbAdd.class})
@NotNull(message="参数grossWet不能为空")
@Column(name = "CROSSWET")
private BigDecimal grossWet;
@ApiModelProperty(value = "出入境关闭", name = "IEPort", example = "固定值:0101")
@NotBlank(message="参数iePort不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数iePort不能为空")
@Column(name = "IEPORT")
private String iePort;
......@@ -129,7 +129,7 @@ public class Mawb implements Serializable {
private String inputerName;
@ApiModelProperty(value = "保险费币制", name = "insurCurr", example = "MOP")
@NotBlank(message="参数insurCurr不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数insurCurr不能为空")
@Column(name = "INSURCURR")
private String insurCurr;
......@@ -138,7 +138,7 @@ public class Mawb implements Serializable {
private String insurMark;
@ApiModelProperty(value = "保险费/率", name = "insurRate", example = "")
@NotNull(message="参数insurRate不能为空", groups = {MawbAdd.class})
@NotNull(message="参数insurRate不能为空")
@Column(name = "INSURRATE")
private BigDecimal insurRate;
......@@ -147,7 +147,7 @@ public class Mawb implements Serializable {
private String manualNo;
@ApiModelProperty(value = "净重", name = "netWt", example = "")
@NotNull(message="参数netWt不能为空", groups = {MawbAdd.class})
@NotNull(message="参数netWt不能为空")
@Column(name = "NETWT")
private BigDecimal netWt;
......@@ -164,17 +164,17 @@ public class Mawb implements Serializable {
private String otherMark;
@ApiModelProperty(value = "消费使用/生产销售单位代码", name = "ownerCode", example = "Z321654987")
@NotBlank(message="参数ownerCode不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数ownerCode不能为空")
@Column(name = "OWNERCODE")
private String ownerCode;
@ApiModelProperty(value = "消费使用/生产销售单位名称", name = "ownerName", example = "上海保险")
@NotBlank(message="参数ownerName不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数ownerName不能为空")
@Column(name = "OWNERNAME")
private String ownerName;
@ApiModelProperty(value = "件数", name = "packNo", example = "")
@NotNull(message="参数packNo不能为空", groups = {MawbAdd.class})
@NotNull(message="参数packNo不能为空")
@Column(name = "PACKNO")
private Integer packNo;
......@@ -182,12 +182,12 @@ public class Mawb implements Serializable {
private String preEntryId;
@ApiModelProperty(value = "启运国/运抵国", name = "tradeCountry", example = "USA")
@NotBlank(message="参数tradeCountry不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数tradeCountry不能为空")
@Column(name = "TRADECOUNTRY")
private String tradeCountry;
@ApiModelProperty(value = "监管方式", name = "tradeMode", example = "0200")
@NotBlank(message="参数tradeMode不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数tradeMode不能为空")
@Column(name = "TRADEMODE")
private String tradeMode;
......@@ -197,7 +197,7 @@ public class Mawb implements Serializable {
private String tradeCode;
@ApiModelProperty(value = "运输方式代码", name = "trafMode", example = "1")
@NotBlank(message="参数trafMode不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数trafMode不能为空")
@Column(name = "TRAFMODE")
private String trafMode;
......@@ -207,12 +207,12 @@ public class Mawb implements Serializable {
private String tradeName;
@ApiModelProperty(value = "成交方式", name = "transMode", example = "2")
@NotBlank(message="参数transMode不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数transMode不能为空")
@Column(name = "TRANSMODE")
private String transMode;
@ApiModelProperty(value = "包装种类", name = "wrapType", example = "22")
@NotBlank(message="参数wrapType不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数wrapType不能为空")
@Column(name = "WRAPTYPE")
private String wrapType;
......@@ -222,12 +222,12 @@ public class Mawb implements Serializable {
private String tradeCodeScc;
@ApiModelProperty(value = "消费使用/生产销售单位单位统一编码", name = "ownerCodeScc", example = "")
@NotBlank(message="参数ownerCodeScc不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数ownerCodeScc不能为空")
@Column(name = "OWNERCODESCC")
private String ownerCodeScc;
@ApiModelProperty(value = "贸易国别", name = "tradeAreaCode", example = "")
@NotBlank(message="参数tradeAreaCode不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数tradeAreaCode不能为空")
@Column(name = "TRADEAREACODE")
private String tradeAreaCode;
......@@ -236,7 +236,7 @@ public class Mawb implements Serializable {
private String markNo;
@ApiModelProperty(value = "入境口岸代码", name = "entyPortCode", example = "固定值:310302")
@NotBlank(message="参数entyPortCode不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数entyPortCode不能为空")
@Column(name = "ENTYPORTCODE")
private String entyPortCode;
......@@ -256,7 +256,7 @@ public class Mawb implements Serializable {
private String overseasConsigneeCode;
@ApiModelProperty(value = "境外收货人名称(外文)", name = "overseasConsigneeEname", example = "")
@NotBlank(message="参数overseasConsigneeEname不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数overseasConsigneeEname不能为空")
@Column(name = "OVERSEASCONSIGNEEENAME")
private String overseasConsigneeEname;
......
......@@ -47,7 +47,7 @@ public class MawbDetail implements Serializable{
private String codeTS;
@ApiModelProperty(value = "申报单价", example = "空值")
@NotNull(message="参数declPrice不能为空", groups = {MawbAdd.class})
@NotNull(message="参数declPrice不能为空")
@Column(name = "DECLPRICE")
private BigDecimal declPrice;
......@@ -57,7 +57,7 @@ public class MawbDetail implements Serializable{
private BigDecimal declTotal;
@ApiModelProperty(value = "征免方式")
@NotBlank(message="参数dutyMode不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数dutyMode不能为空")
@Column(name = "DUTYMODE")
private String dutyMode;
......@@ -95,7 +95,7 @@ public class MawbDetail implements Serializable{
private String gname;
@ApiModelProperty(value = "商品序号")
@NotBlank(message="参数gno不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数gno不能为空")
@Column(name = "GNO")
private String gno;
......@@ -105,7 +105,7 @@ public class MawbDetail implements Serializable{
private BigDecimal gqty;
@ApiModelProperty(value = "原产国")
@NotBlank(message="参数originCountry不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数originCountry不能为空")
@Column(name = "ORIGINCURRENTY")
private String originCountry;
......@@ -136,7 +136,7 @@ public class MawbDetail implements Serializable{
private String ciqCode;
@ApiModelProperty(value = "最终目的国(地区)")
@NotBlank(message="参数destinationCountry不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数destinationCountry不能为空")
@Column(name = "DESTINATIONCOUNTRY")
private String destinationCountry;
......@@ -149,7 +149,7 @@ public class MawbDetail implements Serializable{
private String destCode;
@ApiModelProperty(value = "境内目的地/境内货源地")
@NotBlank(message="参数districtCode不能为空", groups = {MawbAdd.class})
@NotBlank(message="参数districtCode不能为空")
@Column(name = "DISTRICTCODE")
private String districtCode;
......
......@@ -23,33 +23,33 @@ public class BasfService {
* 保存主单Request --basfc
* @param basfc
*/
public Mawb saveMawbBasf(Basfc basfc){
Mawb result=null;
public BasfMawb saveMawbBasf(Basfc basfc){
BasfMawb result=null;
try{
log.info("saveMawb start>>>>>>>>>>>");
//运单头部信息
BasfMawb mawb = new BasfMawb();
mawb.setAppId(basfc.getAppId());
mawb.setMsgId(basfc.getMsgId());
mawb.setConsignmentCodeId(basfc.getConsignmentId());
mawb.setType(basfc.getConsType());
BasfMawb basfMawb = new BasfMawb();
basfMawb.setAppId(basfc.getAppId());
basfMawb.setMsgId(basfc.getMsgId());
basfMawb.setConsignmentCodeId(basfc.getConsignmentId());
basfMawb.setType(basfc.getConsType());
//TODO 记录时为同一张表,用 '-->' 记录具体存放字段(方便查看,以免误解)
//运单号-->提单号
mawb.setBillNo(basfc.getConsignmentCode());
basfMawb.setBillNo(basfc.getConsignmentCode());
//经营单位 --> 消费使用/生产销售单位名称
mawb.setOwnerName(basfc.getOperateUnitName());
basfMawb.setOwnerName(basfc.getOperateUnitName());
//经营单位海关编码 --> 消费使用/生产销售单位代码
mawb.setOwnerCode(basfc.getOperateUnitCode());
basfMawb.setOwnerCode(basfc.getOperateUnitCode());
//经营单位社会信用证代码 --> 消费使用/生产销售单位单位统一编码
mawb.setOwnerCodeScc(basfc.getOperateSCC());
basfMawb.setOwnerCodeScc(basfc.getOperateSCC());
//发件人 --> 境内收发货人名称
mawb.setTradeName(basfc.getSender());
basfMawb.setTradeName(basfc.getSender());
//发件人海关编码 --> 境内收发货人编号
mawb.setTradeCode(basfc.getShipperCustomsCode());
basfMawb.setTradeCode(basfc.getShipperCustomsCode());
//发件人社会信用证代码 --> 生产核销单位统一信用代码---报关形式类型
mawb.setTradeCodeScc(basfc.getShipperSCC());
basfMawb.setTradeCodeScc(basfc.getShipperSCC());
mawb.setEANNo(basfc.getEANNo());
basfMawb.setEANNo(basfc.getEANNo());
//明细
List<MawbDetail> mawbDetailList = new ArrayList<>();
if (basfc.getBasfcDetailList().size()>0){
......@@ -71,8 +71,8 @@ public class BasfService {
mawbDetailList.add(mawbDetail);
}
}
mawb.setMawbDetailList(mawbDetailList);
result = basfMawbRepository.save(mawb);
basfMawb.setMawbDetailList(mawbDetailList);
result = basfMawbRepository.save(basfMawb);
log.info("saveMawb end>>>>>>>>>>>");
}catch (Exception e){
log.error("saveMawb() error:"+e.getMessage());
......
package com.erry.iclear.dateInterface.service;
//import cn.hutool.core.date.DateUtil;
import com.erry.iclear.dateInterface.api.request.BasfMawb;
import com.erry.iclear.dateInterface.api.request.Mawb;
import com.erry.iclear.dateInterface.api.response.ResultRS;
import com.erry.iclear.dateInterface.common.Constant;
......@@ -224,7 +225,7 @@ public class ChmConsignmentService {
return result;
}
public ChmConsignment convertToChmConsignmentBasf(Mawb mawb,Date pushTime,String creator){
public ChmConsignment convertToChmConsignmentBasf(BasfMawb mawb,Date pushTime,String creator){
ChmConsignment result = new ChmConsignment();
try{
//运单号
......@@ -467,29 +468,16 @@ public class ChmConsignmentService {
ResultRS result = new ResultRS(Boolean.FALSE,null,null);
try {
Date pushTime = DateUtils.timeStampToDate(Long.valueOf(timeStamp));
ChmConsignment chmConsignment = null;
//1、将请求转换为运单
if(mawb.getType().equals(Constant.MSG_TYPE_C)){
chmConsignment=this.convertToChmConsignmentBasf(mawb,pushTime,creator);
}else{
chmConsignment=this.convertToChmConsignment(mawb,pushTime,creator);
}
ChmConsignment chmConsignment=this.convertToChmConsignment(mawb,pushTime,creator);
if(Objects.equals(chmConsignment,null)){
result.setCode("30001");
result.setMsg("数据格式不正确");
return result;
}
List<ChmConsignmentDetail> chmConsignmentDetailList = new ArrayList<>();
ChmConsignment finalChmConsignment = chmConsignment;
if (mawb.getType().equals(Constant.MSG_TYPE_C)){
mawb.getMawbDetailList().forEach(detail ->{
chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetailBasf(detail, finalChmConsignment));
chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetail(detail, chmConsignment));
});
}else {
mawb.getMawbDetailList().forEach(detail ->{
chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetail(detail, finalChmConsignment));
});
}
chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList);
//2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入
......@@ -548,4 +536,83 @@ public class ChmConsignmentService {
result.setSuccess(Boolean.TRUE);
return result;
}
/**
* 保存或更新 iclear中的运单信息
* @param mawb
* @param timeStamp
*/
public ResultRS processChmConsignmentBasf(BasfMawb basfMawb, String timeStamp, String creator) {
ResultRS result = new ResultRS(Boolean.FALSE,null,null);
try {
Date pushTime = DateUtils.timeStampToDate(Long.valueOf(timeStamp));
ChmConsignment chmConsignment = this.convertToChmConsignmentBasf(basfMawb,pushTime,creator);
if(Objects.equals(chmConsignment,null)){
result.setCode("30001");
result.setMsg("数据格式不正确");
return result;
}
List<ChmConsignmentDetail> chmConsignmentDetailList = new ArrayList<>();
basfMawb.getMawbDetailList().forEach(detail ->{
chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetailBasf(detail, chmConsignment));
});
chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList);
//2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入
ChmConsignment chmConsignmentDB=this.findChmConsignmentByConsignmentCode(chmConsignment.getConsignmentCode(), DateUtils.addDate(DateUtils.getCurrentDate(),-7));
//3、新增或更新
//新增:如果没有就插入
if (Objects.equals(chmConsignmentDB,null)){
log.info("新增主单"+ basfMawb.getBillNo());
ChmConsignment chmConsignmentSaveResult = this.saveChmConsignment(chmConsignment);
if(!Objects.equals(chmConsignmentSaveResult,null)){
log.info("主单"+ basfMawb.getBillNo()+" 保存成功,chmConsignmentId:"+chmConsignmentSaveResult.getId());
}else{
log.info("主单"+ basfMawb.getBillNo()+" 保存失败");
result.setCode("30002");
result.setMsg("主单"+ basfMawb.getBillNo()+" 保存失败");
return result;
}
//更新:
//如果有数据并且满足条件后才能更新数据
//条件1、状态为 待申报海关
//条件2、本次推送时间 > 上次推送的时间
}else if(!Objects.equals(chmConsignmentDB,null)
&& Objects.equals(chmConsignmentDB.getConsStatusDic().getCode(),"transferWaybillStatus_5")
//TODO 提交时需要打开
&& pushTime.getTime()>chmConsignmentDB.getUpdateTime().getTime()
){
//更新数据
log.info("更新主单"+ basfMawb.getBillNo());
for(ChmConsignmentDetail newDetail:chmConsignment.getChmConsignmentDetailList()){
for(ChmConsignmentDetail oldDetail: chmConsignmentDB.getChmConsignmentDetailList()){
if(Objects.equals(newDetail.getDetailId(),oldDetail.getDetailId())){
//newDetail.setChmConsignment(chmConsignmentDB);
newDetail.setId(oldDetail.getId());
}
}
}
chmConsignment.setId(chmConsignmentDB.getId());
chmConsignment.setCreateTime(chmConsignmentDB.getCreateTime());
chmConsignment.setUpdateTime(pushTime);
ChmConsignment updateResult = this.saveChmConsignment(chmConsignment);
if(!Objects.equals(updateResult,null)){
log.info("主单"+ basfMawb.getBillNo()+" 更新成功,chmConsignmentId:"+updateResult.getId());
}else{
log.info("主单"+ basfMawb.getBillNo()+" 更新失败");
result.setCode("30003");
result.setMsg("主单"+ basfMawb.getBillNo()+" 更新失败");
return result;
}
}
}catch (Exception e){
log.error(""+e.getMessage());
}
result.setSuccess(Boolean.TRUE);
return result;
}
}
......
package com.erry.iclear.dateInterface;
import com.erry.iclear.dateInterface.api.CustomsDataInterface;
import com.erry.iclear.dateInterface.api.request.Basfc;
import com.erry.iclear.dateInterface.api.request.BasfcDetail;
import com.erry.iclear.dateInterface.api.request.Mawb;
import com.erry.iclear.dateInterface.api.request.MawbDetail;
import com.erry.iclear.dateInterface.api.request.*;
import com.erry.iclear.dateInterface.api.response.ResultRS;
import com.erry.iclear.dateInterface.repository.MawbAdd;
import com.erry.iclear.dateInterface.service.BasfService;
import com.erry.iclear.dateInterface.service.ChmConsignmentService;
import com.erry.iclear.dateInterface.service.MawbService;
import org.junit.Test;
......@@ -28,10 +26,10 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests {
private CustomsDataInterface customsDataInterface;
@Autowired
private MawbService mawbService;
private BasfService mawbService;
@Test
/*@Test
public void testProcessChmConsignment(){
try{
Mawb mawb = this.createNewMawb();
......@@ -41,16 +39,16 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests {
}catch (Exception e){
e.printStackTrace();
}
}
}*/
@Test
public void testProcessChmConsignment1(){
try{
Basfc basfc = this.createNewBasf();
Mawb mawb = mawbService.saveMawbBasf(basfc);
BasfMawb mawb = mawbService.saveMawbBasf(basfc);
//Basfc basfc = this.createNewBasf();
String timeStamp = String.valueOf(new Date().getTime());
ResultRS resultRS = chmConsignmentService.processChmConsignment(mawb, timeStamp, "BASF");
ResultRS resultRS = chmConsignmentService.processChmConsignmentBasf(mawb, timeStamp, "BASF");
System.out.println(resultRS.toString());
}catch (Exception e){
e.printStackTrace();
......@@ -61,7 +59,7 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests {
List<BasfcDetail> basfcDetailList = new ArrayList<>();
BasfcDetail basfcDetail = new BasfcDetail();
basfcDetail.setConsignmentDetailId("111");
basfcDetail.setSkuCode("");
basfcDetail.setSkuCode("123456789");
basfcDetail.setSkuName("测试");
basfcDetail.setModel("0|0|1|||||||||");
basfcDetail.setUnitLegalFirst("035");
......@@ -76,7 +74,7 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests {
basfcDetailList.add(basfcDetail);
Basfc basfc = new Basfc();
basfc.setConsignmentCode("211015001");
basfc.setConsignmentCode("211015003");
basfc.setConsignmentId(1L);
basfc.setConsType("C");
basfc.setSender("发件人");
......