yi.wang

Merge remote-tracking branch 'origin/master'

1 +package com.erry.iclear.dateInterface.api;
2 +
3 +import com.erry.iclear.dateInterface.api.request.BasfMawb;
4 +import com.erry.iclear.dateInterface.api.request.Basfc;
5 +import com.erry.iclear.dateInterface.api.response.ResultRS;
6 +import com.erry.iclear.dateInterface.entity.IClearApiLog;
7 +import com.erry.iclear.dateInterface.service.BasfService;
8 +import com.erry.iclear.dateInterface.service.ChmConsignmentService;
9 +import com.erry.iclear.dateInterface.service.IClearApiLogService;
10 +import com.google.gson.Gson;
11 +import io.swagger.annotations.ApiOperation;
12 +import lombok.extern.slf4j.Slf4j;
13 +import org.springframework.beans.factory.annotation.Autowired;
14 +import org.springframework.util.StopWatch;
15 +import org.springframework.validation.annotation.Validated;
16 +import org.springframework.web.bind.annotation.*;
17 +
18 +import javax.servlet.http.HttpServletRequest;
19 +import java.util.Date;
20 +import java.util.Objects;
21 +
22 +@RestController
23 +@RequestMapping("/basf")
24 +@Slf4j
25 +public class BasfDataInterface {
26 + private Gson gson = new Gson();
27 +
28 + @Autowired
29 + private BasfService basfService;
30 +
31 + @Autowired
32 + private ChmConsignmentService chmConsignmentService;
33 +
34 + @Autowired
35 + private IClearApiLogService iClearApiLogService;
36 +
37 + @ApiOperation(value = "BASF推送运单数据", httpMethod = "POST", notes = "ex: http://192.168.1.75:8080/customs/sendMawbBasf")
38 + @PostMapping("/sendMawbBasf")
39 + @ResponseBody
40 + public ResultRS sendMawbBasf(HttpServletRequest request
41 + , @Validated @RequestBody Basfc basfc) {
42 + log.info("接收到请求数据consignmentCode:"+basfc.getConsignmentCode()+" data:" + gson.toJson(basfc));
43 + ResultRS result = new ResultRS(Boolean.FALSE,"","");
44 +
45 + if(Objects.equals(basfc,null)){
46 + result.setCode("-7");
47 + result.setMsg("请求信息不能为空");
48 + return result;
49 + }
50 + //1、保存请求信息,保存到iClear的 SQLServer
51 +
52 + StopWatch sw = new StopWatch("receice mawbBasf");
53 + sw.start("save log");
54 +
55 + String appId=(String) request.getHeader("Appid");
56 + String appKey=(String) request.getHeader("Appkey");
57 + String timeStamp=(String) request.getHeader("TimeStamp");
58 + IClearApiLog saveIClearApiLogResult = iClearApiLogService.saveIClearApiLog(iClearApiLogService.convertToIClearApiLogC(basfc,appId,appKey,new Date(Long.valueOf(timeStamp))));
59 +
60 + basfc.setAppId(appId);
61 + BasfMawb saveMawbBasfResult = null;
62 + if(!Objects.equals(saveIClearApiLogResult,null)){
63 + log.info("请求保存成功,msgId:"+saveIClearApiLogResult.getMsgId());
64 + basfc.setMsgId(saveIClearApiLogResult.getMsgId());
65 + basfc.getBasfcDetailList().forEach(d->{
66 + d.setMsgId(saveIClearApiLogResult.getMsgId());
67 + });
68 + saveMawbBasfResult = basfService.saveMawbBasf(basfc);
69 + if(!Objects.equals(saveMawbBasfResult,null)){
70 + log.info("请求数据运单号"+basfc.getConsignmentCode()+"保存成功,msgId:"+saveMawbBasfResult.getMsgId());
71 + }else{
72 + log.info("请求数据运单号"+basfc.getConsignmentCode()+"保存失败,msgId:"+saveMawbBasfResult.getMsgId());
73 + }
74 + }else{
75 + log.info("请求日志保存失败,consignmentCode:"+basfc.getConsignmentCode());
76 + }
77 + sw.stop();
78 +
79 +
80 + //2、TODO 校验主单
81 + /* sw.start("checkMawb");
82 + result=mawbService.checkMawb(mawb);
83 + if(!result.getSuccess()){
84 + return result;
85 + }
86 + sw.stop();*/
87 +
88 +// //3、TODO 校验子单
89 +// sw.start("checkMawbDetail");
90 +// result=mawbDetailServicel.checkMawbDetail(mawb);
91 +// if(!result.getSuccess()){
92 +// return result;
93 +// }
94 +// sw.stop();
95 +
96 +
97 + //4、保存运单到iclear中
98 + sw.start("processChmConsignment");
99 + result = chmConsignmentService.processChmConsignmentBasf(saveMawbBasfResult, timeStamp,appId);
100 + if(!result.getSuccess()){
101 + return result;
102 + }
103 + sw.stop();
104 +
105 +
106 + //5、更新日志
107 + sw.start("updateIClearApiLog");
108 + if(!Objects.equals(saveIClearApiLogResult,null)){
109 + saveIClearApiLogResult.setReceiveResult(result.getSuccess().toString());
110 + saveIClearApiLogResult.setErrorCode(result.getCode());
111 + saveIClearApiLogResult.setResponseTime(new Date());
112 + saveIClearApiLogResult.setSpendTime(sw.getTotalTimeMillis());
113 +
114 + iClearApiLogService.updateIClearApiLog(saveIClearApiLogResult);
115 + }
116 + log.info("请求数据consignmentCode:"+basfc.getConsignmentCode() +" 接收结束");
117 + sw.stop();
118 + log.info(sw.prettyPrint());
119 +
120 + //6、return result
121 + result.setSuccess(Boolean.TRUE);
122 + result.setCode("0");
123 + return result;
124 + }
125 +}
1 package com.erry.iclear.dateInterface.api; 1 package com.erry.iclear.dateInterface.api;
2 2
3 +import com.erry.iclear.dateInterface.api.request.Basfc;
3 import com.erry.iclear.dateInterface.api.request.Mawb; 4 import com.erry.iclear.dateInterface.api.request.Mawb;
4 import com.erry.iclear.dateInterface.api.response.ResultRS; 5 import com.erry.iclear.dateInterface.api.response.ResultRS;
5 import com.erry.iclear.dateInterface.common.Constant; 6 import com.erry.iclear.dateInterface.common.Constant;
6 import com.erry.iclear.dateInterface.entity.IClearApiLog; 7 import com.erry.iclear.dateInterface.entity.IClearApiLog;
8 +import com.erry.iclear.dateInterface.repository.MawbAdd;
7 import com.erry.iclear.dateInterface.service.*; 9 import com.erry.iclear.dateInterface.service.*;
8 import com.erry.iclear.dateInterface.util.DateUtils; 10 import com.erry.iclear.dateInterface.util.DateUtils;
9 import com.erry.iclear.dateInterface.util.SHA256Util; 11 import com.erry.iclear.dateInterface.util.SHA256Util;
...@@ -49,7 +51,7 @@ public class CustomsDataInterface { ...@@ -49,7 +51,7 @@ public class CustomsDataInterface {
49 @PostMapping("/sendMawb") 51 @PostMapping("/sendMawb")
50 @ResponseBody 52 @ResponseBody
51 public ResultRS sendMawb(HttpServletRequest request 53 public ResultRS sendMawb(HttpServletRequest request
52 - ,@Validated @RequestBody Mawb mawb) { 54 + ,@Validated(MawbAdd.class) @RequestBody Mawb mawb) {
53 log.info("接收到请求数据billNo:"+mawb.getBillNo()+" data:" + gson.toJson(mawb)); 55 log.info("接收到请求数据billNo:"+mawb.getBillNo()+" data:" + gson.toJson(mawb));
54 ResultRS result = new ResultRS(Boolean.FALSE,"",""); 56 ResultRS result = new ResultRS(Boolean.FALSE,"","");
55 57
...@@ -133,7 +135,6 @@ public class CustomsDataInterface { ...@@ -133,7 +135,6 @@ public class CustomsDataInterface {
133 result.setCode("0"); 135 result.setCode("0");
134 return result; 136 return result;
135 } 137 }
136 -
137 } 138 }
138 139
139 140
......
1 +package com.erry.iclear.dateInterface.api.request;
2 +
3 +import com.erry.iclear.dateInterface.repository.MawbAdd;
4 +import io.swagger.annotations.ApiModel;
5 +import io.swagger.annotations.ApiModelProperty;
6 +import lombok.Data;
7 +import org.hibernate.annotations.DynamicInsert;
8 +import org.hibernate.annotations.DynamicUpdate;
9 +
10 +import javax.persistence.*;
11 +import javax.validation.Valid;
12 +import javax.validation.constraints.NotBlank;
13 +import javax.validation.constraints.NotNull;
14 +import java.io.Serializable;
15 +import java.math.BigDecimal;
16 +import java.util.List;
17 +
18 +/**
19 + * @author Administrator
20 + */
21 +
22 +@ApiModel(value = "mawb", description = "主运单")
23 +@Entity
24 +@Table(name = "T_ICLEAR_API_MAWB")
25 +@DynamicInsert
26 +@DynamicUpdate
27 +@Data
28 +public class BasfMawb implements Serializable {
29 +
30 + private static final long serialVersionUID = -7092144710653831972L;
31 + @Id
32 + @GeneratedValue(strategy = GenerationType.IDENTITY)
33 + @Column(name = "Id", insertable = false, nullable = false)
34 + private Long id;
35 +
36 + @Column(name = "MSGID")
37 + private Long msgId;
38 +
39 + @ApiModelProperty(value = "用户ID", name = "AppId", example = "IDE")
40 + @Column(name = "APPID")
41 + private String AppId;
42 +
43 +
44 + @ApiModelProperty(value = "进出口标志", name = "IEFlag", example = "固定值:E")
45 + @Column(name = "IEFLAG")
46 + private String ieFlag;
47 +
48 + @ApiModelProperty(value = "报关类型", name = "Type", example = "固定值:EX")
49 + @Column(name = "TYPE")
50 + private String type;
51 +
52 + @ApiModelProperty(value = "申报单位代码", name = "agentCode", example = "固定值:1111980005")
53 + //@NotBlank(message="参数agentCode不能为空")
54 + @Column(name = "AGENTCODE")
55 + private String agentCode;
56 +
57 + @ApiModelProperty(value = "申报单位名称", name = "agentName", example = "固定值:联邦快递(中国)有限公司")
58 + //@NotBlank(message="参数agentName不能为空")
59 + @Column(name = "AGENTNAME")
60 + private String agentName;
61 +
62 + @ApiModelProperty(value = "提单号", name = "billNo", example = "固定值:有总单号则取值‘总单号_运单号‘,没有总单号则取值‘运单号‘")
63 + @Column(name = "BILLNO")
64 + private String billNo;
65 +
66 + @ApiModelProperty(value = "合同号", name = "contrNo", example = "")
67 + @Column(name = "CONTRNO")
68 + private String contrNo;
69 +
70 + @ApiModelProperty(value = "主管海关(申报地海关)", name = "customMaster", example = "固定值:0101")
71 + @Column(name = "CUSTOMMASTER")
72 + private String customMaster;
73 +
74 + @ApiModelProperty(value = "征免性质", name = "cutMode", example = "101")
75 + @Column(name = "CUTMODE")
76 + private String cutMode;
77 +
78 + @ApiModelProperty(value = "报关/转关关系标志", name = "declTrnRel", example = "固定值:0")
79 + //@NotBlank(message="参数declTrnRel不能为空")
80 + @Column(name = "DECLTRNREL")
81 + private String declTrnRel;
82 +
83 + @ApiModelProperty(value = "经停港/指运港", name = "distinatePort", example = "ASM000")
84 + @Column(name = "DISTINATEPORT")
85 + private String distinatePort;
86 +
87 + @ApiModelProperty(value = "报关标志", name = "EdiId", example = "001")
88 + @Column(name = "EDIID")
89 + private String ediId;
90 +
91 + @ApiModelProperty(value = "海关编号", name = "EntryId", example = "001")
92 + @Column(name = "ENTRYID")
93 + private String entryId;
94 +
95 + @ApiModelProperty(value = "运费币制", name = "feeCurr", example = "固定值:3")
96 + @Column(name = "FEECURR")
97 + private String feeCurr;
98 +
99 + @ApiModelProperty(value = "运费标记", name = "feeMark", example = "99.22")
100 + @Column(name = "FEEMARK")
101 + private String feeMark;
102 +
103 + @ApiModelProperty(value = "运费/率", name = "feeRate", example = "43.34358")
104 + @Column(name = "FEERATE")
105 + private BigDecimal feeRate;
106 +
107 + @ApiModelProperty(value = "毛重", name = "grossWet", example = "")
108 + @Column(name = "CROSSWET")
109 + private BigDecimal grossWet;
110 +
111 + @ApiModelProperty(value = "出入境关闭", name = "IEPort", example = "固定值:0101")
112 + @Column(name = "IEPORT")
113 + private String iePort;
114 +
115 + @ApiModelProperty(value = "录入人名称", name = "InputerName", example = "固定值:0101")
116 + @Column(name = "INPUTERNAME")
117 + private String inputerName;
118 +
119 + @ApiModelProperty(value = "保险费币制", name = "insurCurr", example = "MOP")
120 + @Column(name = "INSURCURR")
121 + private String insurCurr;
122 +
123 + @ApiModelProperty(value = "保险费标记", name = "insurMark", example = "固定值:3")
124 + @Column(name = "INSURMARK")
125 + private String insurMark;
126 +
127 + @ApiModelProperty(value = "保险费/率", name = "insurRate", example = "")
128 + @Column(name = "INSURRATE")
129 + private BigDecimal insurRate;
130 +
131 + @ApiModelProperty(value = "备案号", name = "manualNo", example = "")
132 + @Column(name = "MANUALNO")
133 + private String manualNo;
134 +
135 + @ApiModelProperty(value = "净重", name = "netWt", example = "")
136 + @Column(name = "NETWT")
137 + private BigDecimal netWt;
138 +
139 + @ApiModelProperty(value = "杂费币制", name = "otherCurr", example = "")
140 + @Column(name = "OTHERCURR")
141 + private String otherCurr;
142 +
143 + @ApiModelProperty(value = "杂费/率", name = "otherRate", example = "")
144 + @Column(name = "OTHERRATE")
145 + private BigDecimal otherRate;
146 +
147 + @ApiModelProperty(value = "杂费标志", name = "otherMark", example = "")
148 + @Column(name = "OTHERMARK")
149 + private String otherMark;
150 +
151 + @ApiModelProperty(value = "消费使用/生产销售单位代码", name = "ownerCode", example = "Z321654987")
152 + @Column(name = "OWNERCODE")
153 + private String ownerCode;
154 +
155 + @ApiModelProperty(value = "消费使用/生产销售单位名称", name = "ownerName", example = "上海保险")
156 + @NotBlank(message="参数ownerName不能为空", groups = {MawbAdd.class})
157 + @Column(name = "OWNERNAME")
158 + private String ownerName;
159 +
160 + @ApiModelProperty(value = "件数", name = "packNo", example = "")
161 + @Column(name = "PACKNO")
162 + private Integer packNo;
163 +
164 + @ApiModelProperty(value = "预录入编号", name = "preEntryId", example = "")
165 + private String preEntryId;
166 +
167 + @ApiModelProperty(value = "启运国/运抵国", name = "tradeCountry", example = "USA")
168 + @Column(name = "TRADECOUNTRY")
169 + private String tradeCountry;
170 +
171 + @ApiModelProperty(value = "监管方式", name = "tradeMode", example = "0200")
172 + @Column(name = "TRADEMODE")
173 + private String tradeMode;
174 +
175 + @ApiModelProperty(value = "境内收发货人编号", name = "tradeCode", example = "Z321654987")
176 + @Column(name = "TRADECODE")
177 + private String tradeCode;
178 +
179 + @ApiModelProperty(value = "运输方式代码", name = "trafMode", example = "1")
180 + @Column(name = "TRAFMODE")
181 + private String trafMode;
182 +
183 + @ApiModelProperty(value = "境内收发货人名称", name = "tradeName", example = "上海铢怡国际货物运输代理有限公司")
184 + @Column(name = "TRADENAME")
185 + private String tradeName;
186 +
187 + @ApiModelProperty(value = "成交方式", name = "transMode", example = "2")
188 + @Column(name = "TRANSMODE")
189 + private String transMode;
190 +
191 + @ApiModelProperty(value = "包装种类", name = "wrapType", example = "22")
192 + @Column(name = "WRAPTYPE")
193 + private String wrapType;
194 +
195 + @ApiModelProperty(value = "生产核销单位统一信用代码---报关形式类型", name = "TradeCodeScc", example = "A74125896321456987")
196 + @Column(name = "TRADECODESCC")
197 + private String tradeCodeScc;
198 +
199 + @ApiModelProperty(value = "消费使用/生产销售单位单位统一编码", name = "ownerCodeScc", example = "")
200 + @Column(name = "OWNERCODESCC")
201 + private String ownerCodeScc;
202 +
203 + @ApiModelProperty(value = "贸易国别", name = "tradeAreaCode", example = "")
204 + @Column(name = "TRADEAREACODE")
205 + private String tradeAreaCode;
206 +
207 + @ApiModelProperty(value = "标记及号码", name = "markNo", example = "N/M")
208 + @Column(name = "MARKNO")
209 + private String markNo;
210 +
211 + @ApiModelProperty(value = "入境口岸代码", name = "entyPortCode", example = "固定值:310302")
212 + @Column(name = "ENTYPORTCODE")
213 + private String entyPortCode;
214 +
215 + @ApiModelProperty(value = "入境口岸代码", name = "goodsPlace", example = "固定值:空值")
216 + @Column(name = "GOODSPLACE")
217 + private String goodsPlace;
218 +
219 + @ApiModelProperty(value = "申报人员姓名---报关员证号", name = "declareName", example = "固定值:空值")
220 + @Column(name = "DECLARENAME")
221 + private String declareName;
222 +
223 + @ApiModelProperty(value = "境外发货人代码", name = "overseasConsignorCode", example = "")
224 + private String overseasConsignorCode;
225 +
226 + @ApiModelProperty(value = "境外收货人编码", name = "overseasConsigneeCode", example = "")
227 + @Column(name = "OVERSEASCONSIGNEECODE")
228 + private String overseasConsigneeCode;
229 +
230 + @ApiModelProperty(value = "境外收货人名称(外文)", name = "overseasConsigneeEname", example = "")
231 + @Column(name = "OVERSEASCONSIGNEEENAME")
232 + private String overseasConsigneeEname;
233 +
234 + @ApiModelProperty(value = "运单ID", name = "consignmentCodeId", example = "")
235 + @Column(name = "CONSIGNMENTCODEID")
236 + private Long consignmentCodeId;
237 +
238 + @ApiModelProperty(value = "EANNo", name = "EANNo", example = "")
239 + @Column(name = "EANNO")
240 + private String EANNo;
241 +
242 + @Valid
243 + @ApiModelProperty(value = "运单明细", name = "mawbDetailList", example = "")
244 + @OneToMany(cascade = CascadeType.PERSIST)
245 + @JoinColumn(name = "mawbId")
246 + private List<MawbDetail> mawbDetailList;
247 +}
1 +package com.erry.iclear.dateInterface.api.request;
2 +
3 +public class BasfMawbDetail {
4 +}
1 +package com.erry.iclear.dateInterface.api.request;
2 +
3 +import io.swagger.annotations.ApiModel;
4 +import io.swagger.annotations.ApiModelProperty;
5 +import io.swagger.annotations.ApiOperation;
6 +import lombok.Data;
7 +import org.hibernate.annotations.DynamicInsert;
8 +import org.hibernate.annotations.DynamicUpdate;
9 +
10 +import javax.persistence.*;
11 +import javax.validation.Valid;
12 +import javax.validation.constraints.NotBlank;
13 +import java.io.Serializable;
14 +import java.util.List;
15 +
16 +@ApiModel(value = "basfc", description = "主运单")
17 +@Entity
18 +@Table(name = "T_ICLEAR_API_BASFC")
19 +@DynamicInsert
20 +@DynamicUpdate
21 +@Data
22 +public class Basfc implements Serializable {
23 +
24 +
25 + private static final long serialVersionUID = -7092144710653831972L;
26 + @Id
27 + @GeneratedValue(strategy = GenerationType.IDENTITY)
28 + @Column(name = "Id", insertable = false, nullable = false)
29 + private Long id;
30 +
31 + @ApiModelProperty(value = "用户ID", name = "AppId", example = "BASF")
32 + @Column(name = "APPID")
33 + private String AppId;
34 +
35 + @Column(name = "MSGID")
36 + private Long msgId;
37 +
38 + /*@ApiModelProperty(value = "权限", name = "AppKey", example = "iClearExportC")
39 + @Column(name = "APP_KEY")
40 + private String AppKey;*/
41 +
42 + @ApiModelProperty(value = "加密码", name = "Secret")
43 + @Column(name = "SECRET")
44 + private String secret;
45 +
46 + @ApiModelProperty(value = "运单号", name = "consignmentCode")
47 + @Column(name = "CONSIGNMENTCODE")
48 + @NotBlank(message="参数consignmentCode不能为空!")
49 + private String consignmentCode;
50 +
51 + @ApiModelProperty(value = "运单ID", name = "consignmentId", example = "运单记录的唯一ID")
52 + @Column(name = "CONSIGNMENTID")
53 + @NotBlank(message="参数consignmentId不能为空!")
54 + private Long consignmentId;
55 +
56 + @ApiModelProperty(value = "运单类型",name = "consType", example = "A/B/C/D")
57 + @Column(name = "CONSTYPE")
58 + @NotBlank(message = "参数consType不能为空!")
59 + private String consType;
60 +
61 + @ApiModelProperty(value = "发件人", name = "sender")
62 + @Column(name = "SENDER")
63 + @NotBlank(message = "参数sender不能为空!")
64 + private String sender;
65 +
66 + @ApiModelProperty(value = "发件人海关编码", name = "shipperCustomsCode")
67 + @Column(name = "SHIPPERCUSTOMSCODE")
68 + private String shipperCustomsCode;
69 +
70 + @ApiModelProperty(value = "发件人社会信用证代码", name = "shipperSCC")
71 + @Column(name = "SHIPPERSCC")
72 + @NotBlank(message = "参数shipperSCC不能为空!")
73 + private String shipperSCC;
74 +
75 + @ApiModelProperty(value = "经营单位", name = "operateUnitName")
76 + @Column(name = "OPERATEUNITNAME")
77 + private String operateUnitName;
78 +
79 + @ApiModelProperty(value = "经营单位海关编码", name = "operateUnitCode")
80 + @Column(name = "OPERATEUNITCODE")
81 + private String operateUnitCode;
82 +
83 + @ApiModelProperty(value = "经营单位社会信用证代码", name = "operateSCC")
84 + @Column(name = "OPERATESCC")
85 + private String operateSCC;
86 +
87 + @ApiModelProperty(value = "EANNo", name = "EANNo")
88 + @Column(name = "EANNO")
89 + private String EANNo;
90 +
91 + @Valid
92 + @ApiModelProperty(value = "运单明细", name = "basfcDetailList", example = "")
93 + @OneToMany(cascade = CascadeType.PERSIST)
94 + @JoinColumn(name = "BASFCID")
95 + private List<BasfcDetail> basfcDetailList;
96 +}
1 +package com.erry.iclear.dateInterface.api.request;
2 +
3 +import io.swagger.annotations.ApiModel;
4 +import io.swagger.annotations.ApiModelProperty;
5 +import lombok.Data;
6 +
7 +import javax.persistence.*;
8 +import javax.validation.constraints.NotBlank;
9 +import javax.validation.constraints.NotNull;
10 +import java.math.BigDecimal;
11 +
12 +
13 +@ApiModel(value = "basfcDetail", description = "运单明细")
14 +@Entity
15 +@Table(name = "T_ICLEAR_API_BASFCDETAIL")
16 +@Data
17 +public class BasfcDetail {
18 +
19 +
20 + private static final long serialVersionUID = -6706944312498119267L;
21 + @Id
22 + @GeneratedValue(strategy = GenerationType.IDENTITY)
23 + @Column(name = "Id", insertable = false, nullable = false)
24 + private Long id;
25 +
26 + @Column(name = "MSGID")
27 + private Long msgId;
28 +
29 + @Column(name="BASFCID")
30 + private Long basfId;
31 +
32 + @Column(name="CONSIGNMENTDETAILID")
33 + @NotBlank(message="参数consignmentDetailId不能为空")
34 + private String consignmentDetailId;
35 +
36 + @ApiModelProperty(value = "商品编号")
37 + @NotBlank(message="参数skuCode不能为空")
38 + @Column(name = "SKUCODE")
39 + private String skuCode;
40 +
41 + @ApiModelProperty(value = "品名")
42 + @NotBlank(message = "参数skuName不能为空")
43 + @Column(name = "SKUNAME")
44 + private String skuName;
45 +
46 + @ApiModelProperty(value = "规格型号")
47 + @NotBlank(message="参数model不能为空")
48 + @Column(name = "MODEL")
49 + private String model;
50 +
51 + @ApiModelProperty(value = "第一计量单位(法定单位)")
52 + @Column(name = "UNITLEGALFIRST")
53 + private String unitLegalFirst;
54 +
55 + @ApiModelProperty(value = "第一法定数量")
56 + @Column(name = "QTY_LEGALFIRST")
57 + private BigDecimal qtyLegalFirst;
58 +
59 + @ApiModelProperty(value = "成交计量单位")
60 + @Column(name = "KNOCKDOWNUNIT")
61 + private String knockdownUnit;
62 +
63 + @ApiModelProperty(value = "成交数量")
64 + @Column(name = "KNOCKDOWNNUMBER")
65 + private BigDecimal knockdownNumber;
66 +
67 + @ApiModelProperty(value = "第二计量单位")
68 + @Column(name = "UNITLEGALSECOND")
69 + private String unitLegalSecond;
70 +
71 + @ApiModelProperty(value = "第二法定数量")
72 + @Column(name = "QTYLEGALSECOND")
73 + private BigDecimal qtyLegalSecond;
74 +
75 + @ApiModelProperty(value = "申报金额")
76 + @Column(name = "DECLAREDAMOUNT")
77 + private BigDecimal declaredAmount;
78 +
79 + @ApiModelProperty(value = "币制")
80 + @Column(name = "CURRENCY")
81 + private String currency;
82 +
83 + @ApiModelProperty(value = "申报重量")
84 + @Column(name = "DECLAREDWEIGHT")
85 + private BigDecimal declaredWeight;
86 +}
1 package com.erry.iclear.dateInterface.api.request; 1 package com.erry.iclear.dateInterface.api.request;
2 2
3 +import com.erry.iclear.dateInterface.repository.MawbAdd;
3 import io.swagger.annotations.ApiModel; 4 import io.swagger.annotations.ApiModel;
4 import io.swagger.annotations.ApiModelProperty; 5 import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data; 6 import lombok.Data;
...@@ -259,6 +260,14 @@ public class Mawb implements Serializable { ...@@ -259,6 +260,14 @@ public class Mawb implements Serializable {
259 @Column(name = "OVERSEASCONSIGNEEENAME") 260 @Column(name = "OVERSEASCONSIGNEEENAME")
260 private String overseasConsigneeEname; 261 private String overseasConsigneeEname;
261 262
263 + @ApiModelProperty(value = "运单ID", name = "consignmentCodeId", example = "")
264 + @Column(name = "CONSIGNMENTCODEID")
265 + private Long consignmentCodeId;
266 +
267 + @ApiModelProperty(value = "EANNo", name = "EANNo", example = "")
268 + @Column(name = "EANNO")
269 + private String EANNo;
270 +
262 @Valid 271 @Valid
263 @ApiModelProperty(value = "运单明细", name = "mawbDetailList", example = "") 272 @ApiModelProperty(value = "运单明细", name = "mawbDetailList", example = "")
264 @OneToMany(cascade = CascadeType.PERSIST) 273 @OneToMany(cascade = CascadeType.PERSIST)
......
1 package com.erry.iclear.dateInterface.api.request; 1 package com.erry.iclear.dateInterface.api.request;
2 2
3 +import com.erry.iclear.dateInterface.repository.MawbAdd;
3 import io.swagger.annotations.ApiModel; 4 import io.swagger.annotations.ApiModel;
4 import io.swagger.annotations.ApiModelProperty; 5 import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data; 6 import lombok.Data;
...@@ -152,5 +153,7 @@ public class MawbDetail implements Serializable{ ...@@ -152,5 +153,7 @@ public class MawbDetail implements Serializable{
152 @Column(name = "DISTRICTCODE") 153 @Column(name = "DISTRICTCODE")
153 private String districtCode; 154 private String districtCode;
154 155
155 - 156 + @ApiModelProperty(value = "申报重量")
157 + @Column(name = "DECLAREDWEIGHT")
158 + private BigDecimal declaredWeight;
156 } 159 }
......
...@@ -246,8 +246,8 @@ public class ChmConsignmentDetail implements Serializable { ...@@ -246,8 +246,8 @@ public class ChmConsignmentDetail implements Serializable {
246 /** 246 /**
247 * 申报重量 247 * 申报重量
248 * */ 248 * */
249 -// @Column(name = "DECLARED_WEIGHT") 249 + @Column(name = "DECLARED_WEIGHT")
250 -// private BigDecimal declaredWeight; 250 + private BigDecimal declaredWeight;
251 /** 251 /**
252 * 录入品名 252 * 录入品名
253 */ 253 */
......
1 +package com.erry.iclear.dateInterface.repository;
2 +
3 +import com.erry.iclear.dateInterface.api.request.BasfMawb;
4 +import org.springframework.data.jpa.repository.JpaRepository;
5 +import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
6 +import org.springframework.stereotype.Repository;
7 +import org.springframework.transaction.annotation.Transactional;
8 +
9 +/**
10 + * @author Administrator
11 + */
12 +@Repository
13 +@Transactional(rollbackFor = Exception.class)
14 +public interface BasfMawbRepository extends JpaRepository<BasfMawb, Integer>, JpaSpecificationExecutor<BasfMawb> {
15 +}
1 +package com.erry.iclear.dateInterface.repository;
2 +
3 +public interface MawbAdd {
4 +}
1 +package com.erry.iclear.dateInterface.service;
2 +
3 +import com.erry.iclear.dateInterface.api.request.*;
4 +import com.erry.iclear.dateInterface.repository.BasfMawbRepository;
5 +import com.erry.iclear.dateInterface.util.NumberUtils;
6 +import lombok.extern.slf4j.Slf4j;
7 +import org.springframework.beans.factory.annotation.Autowired;
8 +import org.springframework.stereotype.Service;
9 +
10 +import java.util.ArrayList;
11 +import java.util.List;
12 +
13 +/**
14 + * @author Administrator
15 + */
16 +@Service
17 +@Slf4j
18 +public class BasfService {
19 + @Autowired
20 + private BasfMawbRepository basfMawbRepository;
21 +
22 + /**
23 + * 保存主单Request --basfc
24 + * @param basfc
25 + */
26 + public BasfMawb saveMawbBasf(Basfc basfc){
27 + BasfMawb result=null;
28 + try{
29 + log.info("saveMawb start>>>>>>>>>>>");
30 + //运单头部信息
31 + BasfMawb basfMawb = new BasfMawb();
32 + basfMawb.setAppId(basfc.getAppId());
33 + basfMawb.setMsgId(basfc.getMsgId());
34 + basfMawb.setConsignmentCodeId(basfc.getConsignmentId());
35 + basfMawb.setType(basfc.getConsType());
36 + //TODO 记录时为同一张表,用 '-->' 记录具体存放字段(方便查看,以免误解)
37 + //运单号-->提单号
38 + basfMawb.setBillNo(basfc.getConsignmentCode());
39 + //经营单位 --> 消费使用/生产销售单位名称
40 + basfMawb.setOwnerName(basfc.getOperateUnitName());
41 + //经营单位海关编码 --> 消费使用/生产销售单位代码
42 + basfMawb.setOwnerCode(basfc.getOperateUnitCode());
43 + //经营单位社会信用证代码 --> 消费使用/生产销售单位单位统一编码
44 + basfMawb.setOwnerCodeScc(basfc.getOperateSCC());
45 + //发件人 --> 境内收发货人名称
46 + basfMawb.setTradeName(basfc.getSender());
47 + //发件人海关编码 --> 境内收发货人编号
48 + basfMawb.setTradeCode(basfc.getShipperCustomsCode());
49 + //发件人社会信用证代码 --> 生产核销单位统一信用代码---报关形式类型
50 + basfMawb.setTradeCodeScc(basfc.getShipperSCC());
51 +
52 + basfMawb.setEANNo(basfc.getEANNo());
53 + //明细
54 + List<MawbDetail> mawbDetailList = new ArrayList<>();
55 + if (basfc.getBasfcDetailList().size()>0){
56 + for (BasfcDetail basfcDetail : basfc.getBasfcDetailList()){
57 + MawbDetail mawbDetail = new MawbDetail();
58 + mawbDetail.setDetailId(basfcDetail.getConsignmentDetailId());
59 + mawbDetail.setGmodel(basfcDetail.getModel());
60 + mawbDetail.setCodeTS(basfcDetail.getSkuCode());
61 + mawbDetail.setGname(basfcDetail.getSkuName());
62 + mawbDetail.setGqty(basfcDetail.getKnockdownNumber());
63 + mawbDetail.setGunit(basfcDetail.getKnockdownUnit());
64 + mawbDetail.setFirstUnit(basfcDetail.getUnitLegalFirst());
65 + mawbDetail.setFirstQty(NumberUtils.bigDecimalToIntger(basfcDetail.getQtyLegalFirst()));
66 + mawbDetail.setSecondQty(NumberUtils.bigDecimalToIntger(basfcDetail.getQtyLegalSecond()));
67 + mawbDetail.setSecondUnit(basfcDetail.getUnitLegalSecond());
68 + mawbDetail.setDeclTotal(basfcDetail.getDeclaredAmount());
69 + mawbDetail.setTradeCurr(basfcDetail.getCurrency());
70 + mawbDetail.setDeclaredWeight(basfcDetail.getDeclaredWeight());
71 + mawbDetailList.add(mawbDetail);
72 + }
73 + }
74 + basfMawb.setMawbDetailList(mawbDetailList);
75 + result = basfMawbRepository.save(basfMawb);
76 + log.info("saveMawb end>>>>>>>>>>>");
77 + }catch (Exception e){
78 + log.error("saveMawb() error:"+e.getMessage());
79 + }
80 + return result;
81 + }
82 +}
...@@ -134,6 +134,62 @@ public class ChmConsignmentDetailService { ...@@ -134,6 +134,62 @@ public class ChmConsignmentDetailService {
134 134
135 /** 135 /**
136 * 转换运单明细 136 * 转换运单明细
137 + * @param mawbDetail
138 + * @return
139 + */
140 + public ChmConsignmentDetail convertToChmConsignmentDetailBasf(MawbDetail mawbDetail,ChmConsignment chmConsignment){
141 + ChmConsignmentDetail result = new ChmConsignmentDetail();
142 + try{
143 + result.setChmConsignment(chmConsignment);
144 + //商品编号
145 + result.setSkuCode(mawbDetail.getCodeTS());
146 + //申报总价
147 + result.setAmount(mawbDetail.getDeclTotal());
148 + //第一计量单位(法定单位)
149 + DictionaryEntries firstUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getFirstUnit());
150 + if(!Objects.equals(firstUnitDictionaryEntries,null)){
151 + result.setUnitLegalFirstId(firstUnitDictionaryEntries);
152 + result.setUnitLegalFirst(firstUnitDictionaryEntries.getChineseName());
153 + }
154 + //第一法定数量
155 + result.setQtyLegalFirst(BigDecimal.valueOf(mawbDetail.getFirstQty().doubleValue()));
156 + //成交计量单位
157 + //2021年7月8日 成交单位有修改,原取值第一法定计量单位,先取值成交单位。xjq
158 + DictionaryEntries knockdownUnitEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getGunit());
159 + if(!Objects.equals(knockdownUnitEntries,null)){
160 + result.setKnockdownUnitDic(knockdownUnitEntries);
161 + result.setKnockdownUnit(knockdownUnitEntries.getChineseName());
162 + }
163 + //商品规格、型号
164 + result.setModel(mawbDetail.getGmodel());
165 + //商品名称
166 + result.setSkuName(mawbDetail.getGname());
167 + //成交数量
168 + result.setKnockdownNumber(BigDecimal.valueOf(mawbDetail.getGqty().doubleValue()));
169 + //第二计量单位
170 + DictionaryEntries secondUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getSecondUnit());
171 + if(!Objects.equals(secondUnitDictionaryEntries,null)){
172 + result.setUnitLegalSecondId(secondUnitDictionaryEntries);
173 + result.setUnitLegalSecond(secondUnitDictionaryEntries.getChineseName());
174 + }
175 + //第二法定数量
176 + result.setQtyLegalSecond(BigDecimal.valueOf(mawbDetail.getSecondQty().doubleValue()));
177 + //成交币制
178 + DictionaryEntries currencyDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM+ mawbDetail.getTradeCurr());
179 + if(!Objects.equals(currencyDictionaryEntries,null)){
180 + result.setCurrencyDic(currencyDictionaryEntries);
181 + result.setCurrency(currencyDictionaryEntries.getChineseName());
182 + }
183 + result.setDeclaredWeight(mawbDetail.getDeclaredWeight());
184 + result.setDetailId(mawbDetail.getDetailId());
185 + }catch (Exception e){
186 + log.error("convertToChmConsignmentDetailBasf() error:"+e.getMessage());
187 + }
188 + return result;
189 + }
190 +
191 + /**
192 + * 转换运单明细
137 * @param detail 193 * @param detail
138 * @param gno 194 * @param gno
139 * @return 195 * @return
......
1 package com.erry.iclear.dateInterface.service; 1 package com.erry.iclear.dateInterface.service;
2 2
3 //import cn.hutool.core.date.DateUtil; 3 //import cn.hutool.core.date.DateUtil;
4 +import com.erry.iclear.dateInterface.api.request.BasfMawb;
4 import com.erry.iclear.dateInterface.api.request.Mawb; 5 import com.erry.iclear.dateInterface.api.request.Mawb;
5 import com.erry.iclear.dateInterface.api.response.ResultRS; 6 import com.erry.iclear.dateInterface.api.response.ResultRS;
6 import com.erry.iclear.dateInterface.common.Constant; 7 import com.erry.iclear.dateInterface.common.Constant;
...@@ -235,6 +236,59 @@ public class ChmConsignmentService { ...@@ -235,6 +236,59 @@ public class ChmConsignmentService {
235 return result; 236 return result;
236 } 237 }
237 238
239 + public ChmConsignment convertToChmConsignmentBasf(BasfMawb mawb,Date pushTime,String creator){
240 + ChmConsignment result = new ChmConsignment();
241 + try{
242 + //运单号
243 + result.setConsignmentCode(mawb.getBillNo());
244 + //运单类型
245 + DictionaryEntries consType = Constant.dictionaryEntriesCache.get(Constant.MSG_TYPE_C);
246 + if(consType != null){
247 + result.setConsTypeId(consType);
248 + result.setConsType(consType.getChineseName());
249 + }
250 + //监管方式
251 + /*DictionaryEntries tradeModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.SUPERVISION_MODE+Integer.parseInt(mawb.getTradeMode()));
252 + if(!Objects.equals(tradeModeDictionaryEntries,null)){
253 + result.setTradeModeDic(tradeModeDictionaryEntries);
254 + result.setTradeMode(tradeModeDictionaryEntries.getChineseName());
255 + }*/
256 + //境内收发货人社会信用证代码
257 + result.setTradeCoSCC(mawb.getTradeCodeScc());
258 + //境内发货人(经营单位编码)
259 + result.setOperateUnitCode(mawb.getTradeCode());
260 + //境内收发货人名称
261 + result.setOperateUnitName(mawb.getTradeName());
262 + //经营单位
263 + result.setOwnerName(mawb.getOwnerName());
264 + //经营单位海关编码
265 + result.setOwnerCode(mawb.getOwnerCode());
266 + //经营单位社会信用证代码
267 + result.setOwnerCodeScc(mawb.getOwnerCodeScc());
268 +
269 + /*//TODO 生产核销单位统一信用代码---报关形式类型
270 + result.setTradeCoSCC(mawb.getTradeCodeScc());
271 + //TODO 消费使用/生产销售单位单位统一编码
272 + result.setOwnerCodeScc(mawb.getOwnerCodeScc());*/
273 + //运单状态: C类待申报
274 + DictionaryEntries transferWaybillStatusDictionaryEntries=Constant.dictionaryEntriesCache.get(Constant.TRANSFER_WAY_BILL_STATUS+"16");
275 + if(!Objects.equals(transferWaybillStatusDictionaryEntries,null)){
276 + result.setConsStatusDic(transferWaybillStatusDictionaryEntries);
277 + result.setConsStatus(transferWaybillStatusDictionaryEntries.getChineseName());
278 + }
279 + //推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据
280 + result.setCreateTime(new Date());
281 + result.setUpdateTime(pushTime);
282 + result.setCreator(creator);
283 +
284 + }catch (Exception e){
285 + result=null;
286 + e.printStackTrace();
287 + log.error("convertToChmConsignmentBasf() error:"+e.getMessage());
288 + }
289 + return result;
290 + }
291 +
238 /** 292 /**
239 * 运单转换主单 293 * 运单转换主单
240 * @return 294 * @return
...@@ -425,8 +479,6 @@ public class ChmConsignmentService { ...@@ -425,8 +479,6 @@ public class ChmConsignmentService {
425 ResultRS result = new ResultRS(Boolean.FALSE,null,null); 479 ResultRS result = new ResultRS(Boolean.FALSE,null,null);
426 try { 480 try {
427 Date pushTime = DateUtils.timeStampToDate(Long.valueOf(timeStamp)); 481 Date pushTime = DateUtils.timeStampToDate(Long.valueOf(timeStamp));
428 -
429 - //1、将请求转换为运单
430 ChmConsignment chmConsignment=this.convertToChmConsignment(mawb,pushTime,creator); 482 ChmConsignment chmConsignment=this.convertToChmConsignment(mawb,pushTime,creator);
431 if(Objects.equals(chmConsignment,null)){ 483 if(Objects.equals(chmConsignment,null)){
432 result.setCode("30001"); 484 result.setCode("30001");
...@@ -435,7 +487,7 @@ public class ChmConsignmentService { ...@@ -435,7 +487,7 @@ public class ChmConsignmentService {
435 } 487 }
436 List<ChmConsignmentDetail> chmConsignmentDetailList = new ArrayList<>(); 488 List<ChmConsignmentDetail> chmConsignmentDetailList = new ArrayList<>();
437 mawb.getMawbDetailList().forEach(detail ->{ 489 mawb.getMawbDetailList().forEach(detail ->{
438 - chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetail(detail,chmConsignment)); 490 + chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetail(detail, chmConsignment));
439 }); 491 });
440 chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList); 492 chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList);
441 493
...@@ -495,4 +547,83 @@ public class ChmConsignmentService { ...@@ -495,4 +547,83 @@ public class ChmConsignmentService {
495 result.setSuccess(Boolean.TRUE); 547 result.setSuccess(Boolean.TRUE);
496 return result; 548 return result;
497 } 549 }
550 +
551 + /**
552 + * 保存或更新 iclear中的运单信息
553 + * @param mawb
554 + * @param timeStamp
555 + */
556 + public ResultRS processChmConsignmentBasf(BasfMawb basfMawb, String timeStamp, String creator) {
557 + ResultRS result = new ResultRS(Boolean.FALSE,null,null);
558 + try {
559 + Date pushTime = DateUtils.timeStampToDate(Long.valueOf(timeStamp));
560 + ChmConsignment chmConsignment = this.convertToChmConsignmentBasf(basfMawb,pushTime,creator);
561 + if(Objects.equals(chmConsignment,null)){
562 + result.setCode("30001");
563 + result.setMsg("数据格式不正确");
564 + return result;
565 + }
566 + List<ChmConsignmentDetail> chmConsignmentDetailList = new ArrayList<>();
567 +
568 + basfMawb.getMawbDetailList().forEach(detail ->{
569 + chmConsignmentDetailList.add(chmConsignmentDetailService.convertToChmConsignmentDetailBasf(detail, chmConsignment));
570 + });
571 + chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList);
572 +
573 + //2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入
574 + ChmConsignment chmConsignmentDB=this.findChmConsignmentByConsignmentCode(chmConsignment.getConsignmentCode(), DateUtils.addDate(DateUtils.getCurrentDate(),-7));
575 +
576 + //3、新增或更新
577 + //新增:如果没有就插入
578 + if (Objects.equals(chmConsignmentDB,null)){
579 + log.info("新增主单"+ basfMawb.getBillNo());
580 + ChmConsignment chmConsignmentSaveResult = this.saveChmConsignment(chmConsignment);
581 + if(!Objects.equals(chmConsignmentSaveResult,null)){
582 + log.info("主单"+ basfMawb.getBillNo()+" 保存成功,chmConsignmentId:"+chmConsignmentSaveResult.getId());
583 + }else{
584 + log.info("主单"+ basfMawb.getBillNo()+" 保存失败");
585 + result.setCode("30002");
586 + result.setMsg("主单"+ basfMawb.getBillNo()+" 保存失败");
587 + return result;
588 + }
589 + //更新:
590 + //如果有数据并且满足条件后才能更新数据
591 + //条件1、状态为 待申报海关
592 + //条件2、本次推送时间 > 上次推送的时间
593 + }else if(!Objects.equals(chmConsignmentDB,null)
594 + && Objects.equals(chmConsignmentDB.getConsStatusDic().getCode(),"transferWaybillStatus_5")
595 + //TODO 提交时需要打开
596 + && pushTime.getTime()>chmConsignmentDB.getUpdateTime().getTime()
597 + ){
598 + //更新数据
599 + log.info("更新主单"+ basfMawb.getBillNo());
600 +
601 + for(ChmConsignmentDetail newDetail:chmConsignment.getChmConsignmentDetailList()){
602 + for(ChmConsignmentDetail oldDetail: chmConsignmentDB.getChmConsignmentDetailList()){
603 + if(Objects.equals(newDetail.getDetailId(),oldDetail.getDetailId())){
604 + //newDetail.setChmConsignment(chmConsignmentDB);
605 + newDetail.setId(oldDetail.getId());
606 + }
607 + }
608 + }
609 +
610 + chmConsignment.setId(chmConsignmentDB.getId());
611 + chmConsignment.setCreateTime(chmConsignmentDB.getCreateTime());
612 + chmConsignment.setUpdateTime(pushTime);
613 + ChmConsignment updateResult = this.saveChmConsignment(chmConsignment);
614 + if(!Objects.equals(updateResult,null)){
615 + log.info("主单"+ basfMawb.getBillNo()+" 更新成功,chmConsignmentId:"+updateResult.getId());
616 + }else{
617 + log.info("主单"+ basfMawb.getBillNo()+" 更新失败");
618 + result.setCode("30003");
619 + result.setMsg("主单"+ basfMawb.getBillNo()+" 更新失败");
620 + return result;
621 + }
622 + }
623 + }catch (Exception e){
624 + log.error(""+e.getMessage());
625 + }
626 + result.setSuccess(Boolean.TRUE);
627 + return result;
628 + }
498 } 629 }
......
1 package com.erry.iclear.dateInterface.service; 1 package com.erry.iclear.dateInterface.service;
2 2
3 +import com.erry.iclear.dateInterface.api.request.Basfc;
3 import com.erry.iclear.dateInterface.api.request.Mawb; 4 import com.erry.iclear.dateInterface.api.request.Mawb;
4 import com.erry.iclear.dateInterface.common.Constant; 5 import com.erry.iclear.dateInterface.common.Constant;
5 import com.erry.iclear.dateInterface.entity.IClearApiLog; 6 import com.erry.iclear.dateInterface.entity.IClearApiLog;
...@@ -58,6 +59,29 @@ public class IClearApiLogService { ...@@ -58,6 +59,29 @@ public class IClearApiLogService {
58 return result; 59 return result;
59 } 60 }
60 61
62 + /**
63 + * 创建日志
64 + * @return
65 + */
66 + public IClearApiLog convertToIClearApiLogC(Basfc basfc, String appId, String appKey, Date pushTime){
67 + IClearApiLog result = new IClearApiLog();
68 + try{
69 + result.setMsgType(Constant.MSG_TYPE_C);
70 + result.setAppId(appId);
71 + result.setAppKey(appKey);
72 + result.setCreateTime(new Date());
73 + result.setPushTime(pushTime);
74 + result.setReceiveResult(null);
75 + result.setResponseTime(null);
76 + result.setSpendTime(null);
77 + result.setSendTimes(1);
78 + result.setBillNo(basfc.getConsignmentCode());
79 + //result.setContrNo(mawb.getContrNo());
80 + }catch (Exception e){
81 + log.error("convertToIClearApiLog() error:"+e.getMessage());
82 + }
83 + return result;
84 + }
61 85
62 86
63 public void updateIClearApiLog(IClearApiLog iClearApiLog){ 87 public void updateIClearApiLog(IClearApiLog iClearApiLog){
......
...@@ -3,21 +3,25 @@ package com.erry.iclear.dateInterface.service; ...@@ -3,21 +3,25 @@ package com.erry.iclear.dateInterface.service;
3 import com.arronlong.httpclientutil.HttpClientUtil; 3 import com.arronlong.httpclientutil.HttpClientUtil;
4 import com.arronlong.httpclientutil.common.HttpConfig; 4 import com.arronlong.httpclientutil.common.HttpConfig;
5 import com.arronlong.httpclientutil.common.HttpHeader; 5 import com.arronlong.httpclientutil.common.HttpHeader;
6 +import com.erry.iclear.dateInterface.api.request.Basfc;
7 +import com.erry.iclear.dateInterface.api.request.BasfcDetail;
6 import com.erry.iclear.dateInterface.api.request.Mawb; 8 import com.erry.iclear.dateInterface.api.request.Mawb;
9 +import com.erry.iclear.dateInterface.api.request.MawbDetail;
7 import com.erry.iclear.dateInterface.api.response.IClearCheckResponseResult; 10 import com.erry.iclear.dateInterface.api.response.IClearCheckResponseResult;
8 import com.erry.iclear.dateInterface.api.response.ResultRS; 11 import com.erry.iclear.dateInterface.api.response.ResultRS;
9 -import com.erry.iclear.dateInterface.api.response.TokenResult;
10 import com.erry.iclear.dateInterface.entity.ChmConsignment; 12 import com.erry.iclear.dateInterface.entity.ChmConsignment;
11 import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail; 13 import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail;
14 +import com.erry.iclear.dateInterface.repository.MawbAdd;
12 import com.erry.iclear.dateInterface.repository.MawbRepository; 15 import com.erry.iclear.dateInterface.repository.MawbRepository;
13 import com.erry.iclear.dateInterface.util.JsonToJava; 16 import com.erry.iclear.dateInterface.util.JsonToJava;
17 +import com.erry.iclear.dateInterface.util.NumberUtils;
14 import com.google.gson.Gson; 18 import com.google.gson.Gson;
15 import lombok.extern.slf4j.Slf4j; 19 import lombok.extern.slf4j.Slf4j;
16 import org.apache.http.Header; 20 import org.apache.http.Header;
17 import org.springframework.beans.factory.annotation.Autowired; 21 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.beans.factory.annotation.Value; 22 import org.springframework.beans.factory.annotation.Value;
19 -import org.springframework.scheduling.annotation.Scheduled;
20 import org.springframework.stereotype.Service; 23 import org.springframework.stereotype.Service;
24 +import org.springframework.validation.annotation.Validated;
21 25
22 import java.util.ArrayList; 26 import java.util.ArrayList;
23 import java.util.List; 27 import java.util.List;
......
...@@ -25,20 +25,8 @@ public class IClearApiTask { ...@@ -25,20 +25,8 @@ public class IClearApiTask {
25 public void pushCustomsTask(){ 25 public void pushCustomsTask(){
26 try{ 26 try{
27 log.info("pushCustomsTask start>>>>>>>>>>>>"); 27 log.info("pushCustomsTask start>>>>>>>>>>>>");
28 - if(token == null){ 28 + //获取token
29 - try { 29 + getToken();
30 - //获取token
31 - TokenResult tokenResult = apiService.getToken();
32 - if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
33 - this.token = tokenResult.getData().getToken();
34 - }
35 - }catch(Exception ex){
36 - ex.printStackTrace();
37 - }
38 - }
39 - if(this.token == null){
40 - throw new Exception("获取token失败!");
41 - }
42 //获取token成功则进行海关回执推送 30 //获取token成功则进行海关回执推送
43 apiService.pushCustoms(this.token); 31 apiService.pushCustoms(this.token);
44 log.info("pushCustomsTask end>>>>>>>>>>>>"); 32 log.info("pushCustomsTask end>>>>>>>>>>>>");
...@@ -54,20 +42,8 @@ public class IClearApiTask { ...@@ -54,20 +42,8 @@ public class IClearApiTask {
54 public void pushMawbTask(){ 42 public void pushMawbTask(){
55 try{ 43 try{
56 log.info("pushMawbTask start>>>>>>>>>>>>"); 44 log.info("pushMawbTask start>>>>>>>>>>>>");
57 - if(token == null){ 45 + //获取token
58 - try { 46 + getToken();
59 - //获取token
60 - TokenResult tokenResult = apiService.getToken();
61 - if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
62 - this.token = tokenResult.getData().getToken();
63 - }
64 - }catch(Exception ex){
65 - ex.printStackTrace();
66 - }
67 - }
68 - if(this.token == null){
69 - throw new Exception("获取token失败!");
70 - }
71 //获取token成功则进行海关回执推送 47 //获取token成功则进行海关回执推送
72 apiService.pushMawb(this.token); 48 apiService.pushMawb(this.token);
73 log.info("pushMawbTask end>>>>>>>>>>>>"); 49 log.info("pushMawbTask end>>>>>>>>>>>>");
...@@ -82,20 +58,8 @@ public class IClearApiTask { ...@@ -82,20 +58,8 @@ public class IClearApiTask {
82 public void pushErrorReturnDate(){ 58 public void pushErrorReturnDate(){
83 try{ 59 try{
84 log.info("pushErrorReturnDate start>>>>>>>>>>>>"); 60 log.info("pushErrorReturnDate start>>>>>>>>>>>>");
85 - if(token == null){ 61 + //获取token
86 - try { 62 + getToken();
87 - //获取token
88 - TokenResult tokenResult = apiService.getToken();
89 - if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
90 - this.token = tokenResult.getData().getToken();
91 - }
92 - }catch(Exception ex){
93 - ex.printStackTrace();
94 - }
95 - }
96 - if(this.token == null){
97 - throw new Exception("获取token失败!");
98 - }
99 //获取token成功则进行海关回执推送 63 //获取token成功则进行海关回执推送
100 apiService.pushErrorReturnDate(this.token); 64 apiService.pushErrorReturnDate(this.token);
101 log.info("pushErrorReturnDate end>>>>>>>>>>>>"); 65 log.info("pushErrorReturnDate end>>>>>>>>>>>>");
...@@ -110,20 +74,8 @@ public class IClearApiTask { ...@@ -110,20 +74,8 @@ public class IClearApiTask {
110 public void pushErrorData(){ 74 public void pushErrorData(){
111 try{ 75 try{
112 log.info("pushErrorDeclareDate start>>>>>>>>>>>>"); 76 log.info("pushErrorDeclareDate start>>>>>>>>>>>>");
113 - if(token == null){ 77 + //获取token
114 - try { 78 + getToken();
115 - //获取token
116 - TokenResult tokenResult = apiService.getToken();
117 - if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
118 - this.token = tokenResult.getData().getToken();
119 - }
120 - }catch(Exception ex){
121 - ex.printStackTrace();
122 - }
123 - }
124 - if(this.token == null){
125 - throw new Exception("获取token失败!");
126 - }
127 //获取token成功则进行海关回执推送 79 //获取token成功则进行海关回执推送
128 apiService.pushErrorDeclareDate(this.token); 80 apiService.pushErrorDeclareDate(this.token);
129 log.info("pushErrorDeclareDate end>>>>>>>>>>>>"); 81 log.info("pushErrorDeclareDate end>>>>>>>>>>>>");
...@@ -131,4 +83,25 @@ public class IClearApiTask { ...@@ -131,4 +83,25 @@ public class IClearApiTask {
131 log.error("pushErrorDeclareDate() error:" +e.getMessage()); 83 log.error("pushErrorDeclareDate() error:" +e.getMessage());
132 } 84 }
133 } 85 }
86 +
87 + /**
88 + * 获取token
89 + * @throws Exception
90 + */
91 + private void getToken() throws Exception{
92 + if(token == null){
93 + try {
94 + //获取token
95 + TokenResult tokenResult = apiService.getToken();
96 + if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
97 + this.token = tokenResult.getData().getToken();
98 + }
99 + }catch(Exception ex){
100 + ex.printStackTrace();
101 + }
102 + }
103 + if(this.token == null){
104 + throw new Exception("获取token失败!");
105 + }
106 + }
134 } 107 }
......
...@@ -27,6 +27,8 @@ api: ...@@ -27,6 +27,8 @@ api:
27 address: 27 address:
28 #IClear校验运单地址 28 #IClear校验运单地址
29 iclear-check-url: http://40.73.78.157:8081/chmConsignmentController/checkChmAndDetaliD 29 iclear-check-url: http://40.73.78.157:8081/chmConsignmentController/checkChmAndDetaliD
30 + #IClear校验C类运单地址
31 + iclear-check-url-c: http://40.73.78.157:8081/chmConsignmentController/checkChmAndDetaliC
30 #获取token地址 32 #获取token地址
31 token-url: https://apiuat.iclrccd-fedex.com/login 33 token-url: https://apiuat.iclrccd-fedex.com/login
32 #刷新token地址 34 #刷新token地址
......
1 package com.erry.iclear.dateInterface; 1 package com.erry.iclear.dateInterface;
2 2
3 -import com.erry.iclear.dateInterface.api.request.Mawb; 3 +import com.erry.iclear.dateInterface.api.CustomsDataInterface;
4 -import com.erry.iclear.dateInterface.api.request.MawbDetail; 4 +import com.erry.iclear.dateInterface.api.request.*;
5 +import com.erry.iclear.dateInterface.api.response.ResultRS;
6 +import com.erry.iclear.dateInterface.repository.MawbAdd;
7 +import com.erry.iclear.dateInterface.service.BasfService;
5 import com.erry.iclear.dateInterface.service.ChmConsignmentService; 8 import com.erry.iclear.dateInterface.service.ChmConsignmentService;
9 +import com.erry.iclear.dateInterface.service.MawbService;
6 import org.junit.Test; 10 import org.junit.Test;
7 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
12 +import org.springframework.validation.annotation.Validated;
8 13
9 import java.math.BigDecimal; 14 import java.math.BigDecimal;
10 import java.util.ArrayList; 15 import java.util.ArrayList;
...@@ -17,8 +22,14 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests { ...@@ -17,8 +22,14 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests {
17 @Autowired 22 @Autowired
18 private ChmConsignmentService chmConsignmentService; 23 private ChmConsignmentService chmConsignmentService;
19 24
25 + @Autowired
26 + private CustomsDataInterface customsDataInterface;
20 27
21 - @Test 28 + @Autowired
29 + private BasfService mawbService;
30 +
31 +
32 + /*@Test
22 public void testProcessChmConsignment(){ 33 public void testProcessChmConsignment(){
23 try{ 34 try{
24 Mawb mawb = this.createNewMawb(); 35 Mawb mawb = this.createNewMawb();
...@@ -28,12 +39,59 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests { ...@@ -28,12 +39,59 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests {
28 }catch (Exception e){ 39 }catch (Exception e){
29 e.printStackTrace(); 40 e.printStackTrace();
30 } 41 }
42 + }*/
43 +
44 + @Test
45 + public void testProcessChmConsignment1(){
46 + try{
47 + Basfc basfc = this.createNewBasf();
48 + BasfMawb mawb = mawbService.saveMawbBasf(basfc);
49 + //Basfc basfc = this.createNewBasf();
50 + String timeStamp = String.valueOf(new Date().getTime());
51 + ResultRS resultRS = chmConsignmentService.processChmConsignmentBasf(mawb, timeStamp, "BASF");
52 + System.out.println(resultRS.toString());
53 + }catch (Exception e){
54 + e.printStackTrace();
55 + }
56 + }
57 +
58 + private Basfc createNewBasf(){
59 + List<BasfcDetail> basfcDetailList = new ArrayList<>();
60 + BasfcDetail basfcDetail = new BasfcDetail();
61 + basfcDetail.setConsignmentDetailId("111");
62 + basfcDetail.setSkuCode("123456789");
63 + basfcDetail.setSkuName("测试");
64 + basfcDetail.setModel("0|0|1|||||||||");
65 + basfcDetail.setUnitLegalFirst("035");
66 + basfcDetail.setQtyLegalFirst(BigDecimal.valueOf(1));
67 + basfcDetail.setKnockdownUnit("035");
68 + basfcDetail.setKnockdownNumber(BigDecimal.valueOf(1));
69 + basfcDetail.setUnitLegalSecond("007");
70 + basfcDetail.setQtyLegalSecond(BigDecimal.valueOf(1));
71 + basfcDetail.setDeclaredAmount(BigDecimal.valueOf(1));
72 + basfcDetail.setCurrency("USD");
73 + basfcDetail.setDeclaredWeight(BigDecimal.valueOf(1));
74 + basfcDetailList.add(basfcDetail);
75 +
76 + Basfc basfc = new Basfc();
77 + basfc.setConsignmentCode("211015003");
78 + basfc.setConsignmentId(1L);
79 + basfc.setConsType("C");
80 + basfc.setSender("发件人");
81 + basfc.setShipperCustomsCode("1234567890");
82 + basfc.setShipperSCC("123456789012345678");
83 + basfc.setOperateUnitName("");
84 + basfc.setOperateUnitCode("");
85 + basfc.setOperateSCC("");
86 + basfc.setEANNo("");
87 + basfc.setBasfcDetailList(basfcDetailList);
88 + return basfc;
31 } 89 }
32 90
33 private Mawb createNewMawb(){ 91 private Mawb createNewMawb(){
34 MawbDetail d1 = new MawbDetail(); 92 MawbDetail d1 = new MawbDetail();
35 d1.setClassMark(""); 93 d1.setClassMark("");
36 - d1.setCodeTS("69125472"); 94 + d1.setCodeTS("");
37 d1.setDeclPrice(BigDecimal.valueOf(111.123)); 95 d1.setDeclPrice(BigDecimal.valueOf(111.123));
38 d1.setDeclTotal(BigDecimal.valueOf(788)); 96 d1.setDeclTotal(BigDecimal.valueOf(788));
39 d1.setDutyMode("1"); 97 d1.setDutyMode("1");
...@@ -100,7 +158,7 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests { ...@@ -100,7 +158,7 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests {
100 mawb.setType("EX"); 158 mawb.setType("EX");
101 mawb.setAgentCode("1111980005"); 159 mawb.setAgentCode("1111980005");
102 mawb.setAgentName("联邦快递(中国)有限公司"); 160 mawb.setAgentName("联邦快递(中国)有限公司");
103 - mawb.setBillNo("202105210784"); 161 + mawb.setBillNo("211015002");
104 mawb.setContrNo("NO.565733"); 162 mawb.setContrNo("NO.565733");
105 mawb.setCustomMaster("0101"); 163 mawb.setCustomMaster("0101");
106 mawb.setCutMode("101"); 164 mawb.setCutMode("101");
......