tao.mo

API代码提交

mt
2021年8月6日13:35:03
...@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data; 5 import lombok.Data;
6 import org.hibernate.annotations.DynamicInsert; 6 import org.hibernate.annotations.DynamicInsert;
7 import org.hibernate.annotations.DynamicUpdate; 7 import org.hibernate.annotations.DynamicUpdate;
8 -import org.springframework.validation.annotation.Validated;
9 8
10 import javax.persistence.*; 9 import javax.persistence.*;
11 import javax.validation.Valid; 10 import javax.validation.Valid;
...@@ -117,7 +116,7 @@ public class Mawb implements Serializable { ...@@ -117,7 +116,7 @@ public class Mawb implements Serializable {
117 @ApiModelProperty(value = "毛重", name = "grossWet", example = "") 116 @ApiModelProperty(value = "毛重", name = "grossWet", example = "")
118 @NotNull(message="参数grossWet不能为空") 117 @NotNull(message="参数grossWet不能为空")
119 @Column(name = "CROSSWET") 118 @Column(name = "CROSSWET")
120 - private Integer grossWet; 119 + private BigDecimal grossWet;
121 120
122 @ApiModelProperty(value = "出入境关闭", name = "IEPort", example = "固定值:0101") 121 @ApiModelProperty(value = "出入境关闭", name = "IEPort", example = "固定值:0101")
123 @NotBlank(message="参数iePort不能为空") 122 @NotBlank(message="参数iePort不能为空")
......
1 package com.erry.iclear.dateInterface.api.request; 1 package com.erry.iclear.dateInterface.api.request;
2 2
3 -import com.fasterxml.jackson.annotation.JsonProperty;
4 import io.swagger.annotations.ApiModel; 3 import io.swagger.annotations.ApiModel;
5 import io.swagger.annotations.ApiModelProperty; 4 import io.swagger.annotations.ApiModelProperty;
6 import lombok.Data; 5 import lombok.Data;
7 -import org.springframework.validation.annotation.Validated;
8 6
9 import javax.persistence.*; 7 import javax.persistence.*;
10 import javax.validation.constraints.NotBlank; 8 import javax.validation.constraints.NotBlank;
...@@ -20,7 +18,7 @@ import java.math.BigDecimal; ...@@ -20,7 +18,7 @@ import java.math.BigDecimal;
20 @Entity 18 @Entity
21 @Table(name = "T_ICLEAR_API_MAWBDETAIL") 19 @Table(name = "T_ICLEAR_API_MAWBDETAIL")
22 @Data 20 @Data
23 -public class MawbDetail implements Serializable { 21 +public class MawbDetail implements Serializable{
24 22
25 private static final long serialVersionUID = -6706944312498119267L; 23 private static final long serialVersionUID = -6706944312498119267L;
26 @Id 24 @Id
......
...@@ -33,6 +33,9 @@ public class DictionaryEntries implements Serializable { ...@@ -33,6 +33,9 @@ public class DictionaryEntries implements Serializable {
33 @Column(name = "DICT_CODE") 33 @Column(name = "DICT_CODE")
34 private String dictCode; 34 private String dictCode;
35 35
36 + @Column(name = "EXT2")
37 + private String ext2;
38 +
36 @Column(name = "EXT3") 39 @Column(name = "EXT3")
37 private String ext3; 40 private String ext3;
38 41
......
...@@ -16,6 +16,6 @@ public interface DeclearTaskRepository extends JpaSpecificationExecutor<DeclearT ...@@ -16,6 +16,6 @@ public interface DeclearTaskRepository extends JpaSpecificationExecutor<DeclearT
16 * 根据运单号集合+创建时间 运单 16 * 根据运单号集合+创建时间 运单
17 * @return 17 * @return
18 */ 18 */
19 - @Query( nativeQuery = true,value ="SELECT * FROM T_DECLEAR_TASK WHERE FILE_TYPE = 1 AND PUSH_NUMBER < 3 AND (RESPONSE_RESULTS IS NULL OR RESPONSE_RESULTS <> '0') ORDER BY OPERATION_TIME ASC" ) 19 + @Query( nativeQuery = true,value ="SELECT TOP 10 * FROM T_DECLEAR_TASK WHERE FILE_TYPE = 1 AND PUSH_NUMBER < 3 AND (RESPONSE_RESULTS IS NULL OR RESPONSE_RESULTS <> '0') ORDER BY OPERATION_TIME ASC" )
20 public List<DeclearTask> findDeclearTask(); 20 public List<DeclearTask> findDeclearTask();
21 } 21 }
......
...@@ -30,7 +30,7 @@ public interface DictionaryEntriesRepository extends JpaRepository<DictionaryEn ...@@ -30,7 +30,7 @@ public interface DictionaryEntriesRepository extends JpaRepository<DictionaryEn
30 * 查找全部DictionaryEntries 30 * 查找全部DictionaryEntries
31 * @return 31 * @return
32 */ 32 */
33 - @Query(nativeQuery = true, value = "select ID,CODE,CHINESE_NAME,DICT_CODE,EXT3,EXT6 from T_BI_DICTIONARY_ENTRIES where STATUS=1") 33 + @Query(nativeQuery = true, value = "select ID,CODE,CHINESE_NAME,DICT_CODE,EXT2,EXT3,EXT6 from T_BI_DICTIONARY_ENTRIES where STATUS=1")
34 public List<DictionaryEntries> findAllDictionaryEntries(); 34 public List<DictionaryEntries> findAllDictionaryEntries();
35 35
36 } 36 }
......
...@@ -30,8 +30,8 @@ public interface ReceiptMessageRepository extends JpaSpecificationExecutor<Recei ...@@ -30,8 +30,8 @@ public interface ReceiptMessageRepository extends JpaSpecificationExecutor<Recei
30 public List<ReceiptMessage> findReceiptMessageList(); 30 public List<ReceiptMessage> findReceiptMessageList();
31 31
32 @Modifying(clearAutomatically = false) 32 @Modifying(clearAutomatically = false)
33 - @Query(nativeQuery = true,value = "UPDATE T_DECLEAR_TASK SET PUSH_TIME = ?1,PUSH_NUMBER = PUSH_NUMBER + 1,RESPONSE_TIME = ?2,RESPONSE_RESULTS = ?3,RESPONSE_CONTENT = ?4 WHERE FILE_TYPE = 2 AND CHMSIGNMENT_ID = ?5") 33 + @Query(nativeQuery = true,value = "UPDATE T_DECLEAR_TASK SET PUSH_TIME = ?1,PUSH_NUMBER = PUSH_NUMBER + 1,RESPONSE_TIME = ?2,RESPONSE_RESULTS = ?3,RESPONSE_CONTENT = ?4 WHERE FILE_TYPE = ?5 AND CHMSIGNMENT_ID = ?6")
34 - void updateDeclearTaskStatus(Date pushTime, Date responseTime, String responseResults, String responseContent, Long chmsignmentId); 34 + void updateDeclearTaskStatus(Date pushTime, Date responseTime, String responseResults, String responseContent, String fileType, Long chmsignmentId);
35 35
36 36
37 } 37 }
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -3,9 +3,13 @@ package com.erry.iclear.dateInterface.service; ...@@ -3,9 +3,13 @@ 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.Mawb;
7 +import com.erry.iclear.dateInterface.api.request.MawbDetail;
6 import com.erry.iclear.dateInterface.api.request.ReceiptMessage; 8 import com.erry.iclear.dateInterface.api.request.ReceiptMessage;
7 import com.erry.iclear.dateInterface.api.response.TokenResult; 9 import com.erry.iclear.dateInterface.api.response.TokenResult;
8 import com.erry.iclear.dateInterface.common.Constants; 10 import com.erry.iclear.dateInterface.common.Constants;
11 +import com.erry.iclear.dateInterface.entity.ChmConsignment;
12 +import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail;
9 import com.erry.iclear.dateInterface.entity.DeclearTask; 13 import com.erry.iclear.dateInterface.entity.DeclearTask;
10 import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository; 14 import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository;
11 import com.erry.iclear.dateInterface.repository.DeclearTaskRepository; 15 import com.erry.iclear.dateInterface.repository.DeclearTaskRepository;
...@@ -52,6 +56,12 @@ public class ApiService { ...@@ -52,6 +56,12 @@ public class ApiService {
52 @Autowired 56 @Autowired
53 ChmConsignmentRepository consignmentRepository; 57 ChmConsignmentRepository consignmentRepository;
54 58
59 + @Autowired
60 + ChmConsignmentService consignmentService;
61 +
62 + @Autowired
63 + ChmConsignmentDetailService consignmentDetailService;
64 +
55 /** 65 /**
56 * 获取token信息 66 * 获取token信息
57 * @return 67 * @return
...@@ -62,7 +72,7 @@ public class ApiService { ...@@ -62,7 +72,7 @@ public class ApiService {
62 map.put("username", this.username); 72 map.put("username", this.username);
63 map.put("password", this.password); 73 map.put("password", this.password);
64 HttpConfig config = HttpConfig.custom() 74 HttpConfig config = HttpConfig.custom()
65 - .url(tokenUrl) 75 + .url(this.tokenUrl)
66 .map(map) 76 .map(map)
67 .encoding("utf-8"); 77 .encoding("utf-8");
68 String tokenJson = HttpClientUtil.post(config); 78 String tokenJson = HttpClientUtil.post(config);
...@@ -79,7 +89,7 @@ public class ApiService { ...@@ -79,7 +89,7 @@ public class ApiService {
79 Map<String,Object> map = new HashMap<String,Object>(); 89 Map<String,Object> map = new HashMap<String,Object>();
80 map.put("token", token); 90 map.put("token", token);
81 HttpConfig config = HttpConfig.custom() 91 HttpConfig config = HttpConfig.custom()
82 - .url(refreshTokenUrl) 92 + .url(this.refreshTokenUrl)
83 .map(map) 93 .map(map)
84 .encoding("utf-8"); 94 .encoding("utf-8");
85 HttpClientUtil.post(config); 95 HttpClientUtil.post(config);
...@@ -92,7 +102,7 @@ public class ApiService { ...@@ -92,7 +102,7 @@ public class ApiService {
92 */ 102 */
93 public void pushCustoms(String token){ 103 public void pushCustoms(String token){
94 //获取海关回执数据 104 //获取海关回执数据
95 - List<ReceiptMessage> receiptMessageList = receiptMessageRepository.findReceiptMessageList(); 105 + List<ReceiptMessage> receiptMessageList = this.receiptMessageRepository.findReceiptMessageList();
96 this.sendCustoms(token,receiptMessageList); 106 this.sendCustoms(token,receiptMessageList);
97 } 107 }
98 108
...@@ -118,7 +128,7 @@ public class ApiService { ...@@ -118,7 +128,7 @@ public class ApiService {
118 //推送海关回执数据 128 //推送海关回执数据
119 HttpConfig config = HttpConfig.custom() 129 HttpConfig config = HttpConfig.custom()
120 .headers(headers) 130 .headers(headers)
121 - .url(customsUrl) 131 + .url(this.customsUrl)
122 .encoding("utf-8") 132 .encoding("utf-8")
123 .json(objJson); 133 .json(objJson);
124 String json = HttpClientUtil.post(config); 134 String json = HttpClientUtil.post(config);
...@@ -151,10 +161,11 @@ public class ApiService { ...@@ -151,10 +161,11 @@ public class ApiService {
151 }); 161 });
152 declearTaskList.forEach(declearTask -> { 162 declearTaskList.forEach(declearTask -> {
153 //将已经推送完成的回执信息状态修改 163 //将已经推送完成的回执信息状态修改
154 - receiptMessageRepository.updateDeclearTaskStatus(declearTask.getPushTime(), 164 + this.receiptMessageRepository.updateDeclearTaskStatus(declearTask.getPushTime(),
155 declearTask.getResponseTime(), 165 declearTask.getResponseTime(),
156 declearTask.getResponseResults(), 166 declearTask.getResponseResults(),
157 declearTask.getResponseContent(), 167 declearTask.getResponseContent(),
168 + "2",
158 declearTask.getChmsignmentId().longValue()); 169 declearTask.getChmsignmentId().longValue());
159 }); 170 });
160 } 171 }
...@@ -165,19 +176,95 @@ public class ApiService { ...@@ -165,19 +176,95 @@ public class ApiService {
165 * @throws Exception 176 * @throws Exception
166 */ 177 */
167 public void pushMawb(String token){ 178 public void pushMawb(String token){
168 - Header[] headers = HttpHeader.custom()
169 - .other("Content-Type", "application/json")
170 - .other("Authorization", token)
171 - .build();
172 - //获取海关回执数据
173 try{ 179 try{
174 - List<DeclearTask> declearTaskList = declearTaskRepository.findDeclearTask(); 180 + /****************将Export对象转换成西门子交互实体对象****************/
181 + //查询需要推送数据
182 + List<Mawb> mawbList = new ArrayList<Mawb>();
183 + List<DeclearTask> declearTaskList = this.declearTaskRepository.findDeclearTask();
175 declearTaskList.forEach(declearTask -> { 184 declearTaskList.forEach(declearTask -> {
176 Long consignmentId = declearTask.getChmsignmentId().longValue(); 185 Long consignmentId = declearTask.getChmsignmentId().longValue();
177 - consignmentRepository.findChmConsignmentById(consignmentId); 186 + //查询需要推送运单数据,并且转换
187 + ChmConsignment consignment = this.consignmentRepository.findChmConsignmentById(consignmentId);
188 + Mawb mawb = this.consignmentService.convertToChmConsignment(consignment);
189 + //获取需要推送运单数据,并且转换
190 + if(consignment.getChmConsignmentDetailList() != null){
191 + List<MawbDetail> mawbDetailList = new ArrayList<MawbDetail>();
192 + for(int i = 0 ; i < consignment.getChmConsignmentDetailList().size() ; i++){
193 + ChmConsignmentDetail detail = consignment.getChmConsignmentDetailList().get(i);
194 + MawbDetail mawbDetail = this.consignmentDetailService.convertToChmConsignmentDetail(detail, String.valueOf((i + 1)));
195 + mawbDetailList.add(mawbDetail);
196 + }
197 + mawb.setMawbDetailList(mawbDetailList);
198 + }
199 + mawbList.add(mawb);
178 }); 200 });
201 + this.sendMawb(token,mawbList);
202 + }catch(Exception ex){
203 + ex.printStackTrace();
204 + }
205 + }
206 +
207 + /**
208 + * 将完整报文发送至西门子
209 + * @param token
210 + * @param mawbList
211 + */
212 + public void sendMawb(String token ,List<Mawb> mawbList){
213 + Header[] headers = HttpHeader.custom()
214 + .other("Content-Type", "application/json")
215 + .other("Authorization", token)
216 + .build();
217 + List<DeclearTask> declearTaskList = new ArrayList<DeclearTask>();
218 + mawbList.forEach(d->{
219 + DeclearTask declearTask = new DeclearTask();
220 + try {
221 + //设置ID
222 + declearTask.setChmsignmentId(BigDecimal.valueOf(d.getId()));
223 + //推送时间
224 + declearTask.setPushTime(new Date());
225 + String objJson = JsonToJava.toJson(d);
226 + //推送海关回执数据
227 + HttpConfig config = HttpConfig.custom()
228 + .headers(headers)
229 + .url(this.customsUrl)
230 + .encoding("utf-8")
231 + .json(objJson);
232 + String json = HttpClientUtil.post(config);
233 + //接口响应时间
234 + declearTask.setResponseTime(new Date());
235 + TokenResult tokenResult = JsonToJava.parseJson(json,TokenResult.class);
236 + if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.SUCCESS)){
237 + //推送成功,记录推送状态
238 + declearTask.setResponseResults(tokenResult.getErrorcode());
239 + declearTask.setResponseContent(tokenResult.getErrormessage());
240 + declearTaskList.add(declearTask);
241 + }else if(tokenResult.getErrorcode().equals(Constants.ApiResponseKeys.KEY_10004)){
242 + //如果凭证失效,则刷新凭证
243 + refreshToken(token);
244 + }else{
245 + //推送失败,记录推送状态
246 + declearTask.setResponseResults(tokenResult.getErrorcode());
247 + declearTask.setResponseContent(tokenResult.getErrormessage());
248 + declearTaskList.add(declearTask);
249 + log.info("完整报关单推送失败,推送相应码为:"+tokenResult.getErrorcode() + ",推送ID为:" + d.getId());
250 + }
179 }catch(Exception ex){ 251 }catch(Exception ex){
252 + //接口响应时间
253 + declearTask.setResponseTime(new Date());
254 + declearTask.setResponseResults("接口调用失败!");
255 + declearTask.setResponseContent(ex.getMessage());
256 + declearTaskList.add(declearTask);
180 ex.printStackTrace(); 257 ex.printStackTrace();
181 } 258 }
259 + });
260 + declearTaskList.forEach(declearTask -> {
261 + //将已经推送完成的报关单状态修改
262 + this.receiptMessageRepository.updateDeclearTaskStatus(declearTask.getPushTime(),
263 + declearTask.getResponseTime(),
264 + declearTask.getResponseResults(),
265 + declearTask.getResponseContent(),
266 + "1",
267 + declearTask.getChmsignmentId().longValue());
268 + });
182 } 269 }
183 } 270 }
......
...@@ -5,6 +5,7 @@ import com.erry.iclear.dateInterface.common.Constant; ...@@ -5,6 +5,7 @@ import com.erry.iclear.dateInterface.common.Constant;
5 import com.erry.iclear.dateInterface.entity.*; 5 import com.erry.iclear.dateInterface.entity.*;
6 import com.erry.iclear.dateInterface.repository.ChmConsignmentDetailRepository; 6 import com.erry.iclear.dateInterface.repository.ChmConsignmentDetailRepository;
7 import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository; 7 import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository;
8 +import com.erry.iclear.dateInterface.util.NumberUtils;
8 import lombok.extern.slf4j.Slf4j; 9 import lombok.extern.slf4j.Slf4j;
9 import org.apache.commons.lang3.StringUtils; 10 import org.apache.commons.lang3.StringUtils;
10 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
...@@ -51,7 +52,6 @@ public class ChmConsignmentDetailService { ...@@ -51,7 +52,6 @@ public class ChmConsignmentDetailService {
51 result.setLevyTypeDic(levyTypeDictionaryEntries); 52 result.setLevyTypeDic(levyTypeDictionaryEntries);
52 result.setLevyType(levyTypeDictionaryEntries.getChineseName()); 53 result.setLevyType(levyTypeDictionaryEntries.getChineseName());
53 } 54 }
54 -
55 //货号 55 //货号
56 //版本号 56 //版本号
57 //第一计量单位(法定单位) 57 //第一计量单位(法定单位)
...@@ -60,8 +60,6 @@ public class ChmConsignmentDetailService { ...@@ -60,8 +60,6 @@ public class ChmConsignmentDetailService {
60 result.setUnitLegalFirstId(firstUnitDictionaryEntries); 60 result.setUnitLegalFirstId(firstUnitDictionaryEntries);
61 result.setUnitLegalFirst(firstUnitDictionaryEntries.getChineseName()); 61 result.setUnitLegalFirst(firstUnitDictionaryEntries.getChineseName());
62 } 62 }
63 -
64 -
65 //第一法定数量 63 //第一法定数量
66 result.setQtyLegalFirst(BigDecimal.valueOf(mawbDetail.getFirstQty().doubleValue())); 64 result.setQtyLegalFirst(BigDecimal.valueOf(mawbDetail.getFirstQty().doubleValue()));
67 //成交计量单位 65 //成交计量单位
...@@ -71,7 +69,6 @@ public class ChmConsignmentDetailService { ...@@ -71,7 +69,6 @@ public class ChmConsignmentDetailService {
71 result.setKnockdownUnitDic(knockdownUnitEntries); 69 result.setKnockdownUnitDic(knockdownUnitEntries);
72 result.setKnockdownUnit(knockdownUnitEntries.getChineseName()); 70 result.setKnockdownUnit(knockdownUnitEntries.getChineseName());
73 } 71 }
74 -
75 //商品规格、型号 72 //商品规格、型号
76 result.setModel(mawbDetail.getGmodel()); 73 result.setModel(mawbDetail.getGmodel());
77 //商品名称 74 //商品名称
...@@ -85,16 +82,12 @@ public class ChmConsignmentDetailService { ...@@ -85,16 +82,12 @@ public class ChmConsignmentDetailService {
85 result.setHabitatDic(habitatDictonaryEntries); 82 result.setHabitatDic(habitatDictonaryEntries);
86 result.setHabitat(habitatDictonaryEntries.getChineseName()); 83 result.setHabitat(habitatDictonaryEntries.getChineseName());
87 } 84 }
88 -
89 -
90 //第二计量单位 85 //第二计量单位
91 DictionaryEntries secondUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getSecondUnit()); 86 DictionaryEntries secondUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getSecondUnit());
92 if(!Objects.equals(secondUnitDictionaryEntries,null)){ 87 if(!Objects.equals(secondUnitDictionaryEntries,null)){
93 result.setUnitLegalSecondId(secondUnitDictionaryEntries); 88 result.setUnitLegalSecondId(secondUnitDictionaryEntries);
94 result.setUnitLegalSecond(secondUnitDictionaryEntries.getChineseName()); 89 result.setUnitLegalSecond(secondUnitDictionaryEntries.getChineseName());
95 } 90 }
96 -
97 -
98 //第二法定数量 91 //第二法定数量
99 result.setQtyLegalSecond(BigDecimal.valueOf(mawbDetail.getSecondQty().doubleValue())); 92 result.setQtyLegalSecond(BigDecimal.valueOf(mawbDetail.getSecondQty().doubleValue()));
100 //成交币制 93 //成交币制
...@@ -104,7 +97,6 @@ public class ChmConsignmentDetailService { ...@@ -104,7 +97,6 @@ public class ChmConsignmentDetailService {
104 result.setCurrency(currencyDictionaryEntries.getChineseName()); 97 result.setCurrency(currencyDictionaryEntries.getChineseName());
105 } 98 }
106 99
107 -
108 //用途/生产厂家 100 //用途/生产厂家
109 //工缴费 101 //工缴费
110 //最终目的国 102 //最终目的国
...@@ -114,8 +106,6 @@ public class ChmConsignmentDetailService { ...@@ -114,8 +106,6 @@ public class ChmConsignmentDetailService {
114 result.setDestinationCountry(destinationCountryDictionaryEntries.getChineseName()); 106 result.setDestinationCountry(destinationCountryDictionaryEntries.getChineseName());
115 } 107 }
116 108
117 -
118 -
119 //检验检疫编码 109 //检验检疫编码
120 //申报货物英文名称 110 //申报货物英文名称
121 result.setContentDescription(mawbDetail.getDeclGoodsEname()); 111 result.setContentDescription(mawbDetail.getDeclGoodsEname());
...@@ -126,27 +116,107 @@ public class ChmConsignmentDetailService { ...@@ -126,27 +116,107 @@ public class ChmConsignmentDetailService {
126 result.setOrigplacecode(Objects.equals(origplacecodeMapping,null)?"":origplacecodeMapping.getOrigplaceName()); 116 result.setOrigplacecode(Objects.equals(origplacecodeMapping,null)?"":origplacecodeMapping.getOrigplaceName());
127 } 117 }
128 118
129 -
130 -
131 //境内目的地/境内货源地 119 //境内目的地/境内货源地
132 DomesticDestinationMapping domesticDestinationDictionaryEntries = Constant.domesticDestinationMappingCache.get(mawbDetail.getDistrictCode()); 120 DomesticDestinationMapping domesticDestinationDictionaryEntries = Constant.domesticDestinationMappingCache.get(mawbDetail.getDistrictCode());
133 if(!Objects.equals(domesticDestinationDictionaryEntries,null)){ 121 if(!Objects.equals(domesticDestinationDictionaryEntries,null)){
134 result.setDomesticDestinationMapping(domesticDestinationDictionaryEntries); 122 result.setDomesticDestinationMapping(domesticDestinationDictionaryEntries);
135 result.setDomesticDestination(Objects.equals(destinationCountryDictionaryEntries,null)?"":destinationCountryDictionaryEntries.getChineseName()); 123 result.setDomesticDestination(Objects.equals(destinationCountryDictionaryEntries,null)?"":destinationCountryDictionaryEntries.getChineseName());
136 } 124 }
137 -
138 -
139 result.setDetailId(mawbDetail.getDetailId()); 125 result.setDetailId(mawbDetail.getDetailId());
140 -
141 }catch (Exception e){ 126 }catch (Exception e){
142 log.error("convertToChmConsignmentDetail() error:"+e.getMessage()); 127 log.error("convertToChmConsignmentDetail() error:"+e.getMessage());
143 } 128 }
144 -
145 return result; 129 return result;
146 } 130 }
147 131
132 + /**
133 + * 转换运单明细
134 + * @param detail
135 + * @param gno
136 + * @return
137 + */
138 + public MawbDetail convertToChmConsignmentDetail(ChmConsignmentDetail detail,String gno){
139 + MawbDetail result = new MawbDetail();
140 + try{
141 + //明细ID
142 + result.setDetailId(detail.getId().toString());
143 + //归类标志
144 + result.setClassMark("");
145 + //商品编号 必须是十位,不足的后补 00
146 + result.setCodeTS(detail.getSkuCode());
147 + //申报单价 小数点保留4位
148 + result.setDeclPrice(NumberUtils.bigDecimalFormat(detail.getOriRegion(),4));
149 + //申报总价 小数点保留2位
150 + result.setDeclTotal(NumberUtils.bigDecimalFormat(detail.getAmount(),2));
151 + //征免方式 数字一字码,0~9
152 + if(!Objects.equals(detail.getLevyTypeDic(),null)){
153 + result.setDutyMode(detail.getLevyTypeDic().getExt2());
154 + }
155 + //货号 有值传值,无值填空值
156 + result.setExgNo("");
157 + //版本号 有值传值,无值填空值
158 + result.setExgVersion("");
159 + //第一计量单位(法定单位) 数字三字码
160 + if(!Objects.equals(detail.getUnitLegalFirstId(),null)){
161 + result.setFirstUnit(detail.getUnitLegalFirstId().getExt2());
162 + }
163 + //第一法定数量
164 + result.setFirstQty(NumberUtils.bigDecimalToIntger(detail.getQtyLegalFirst()));
165 + //成交计量单位 数字三字码
166 + if(!Objects.equals(detail.getKnockdownUnitDic(),null)){
167 + result.setGunit(detail.getKnockdownUnitDic().getExt2());
168 + }
169 + //商品规格、型号
170 + result.setGmodel(detail.getModel());
171 + //商品名称 品名必填且必须包含中文字符
172 + result.setGname(detail.getSkuName());
173 + //商品序号
174 + result.setGno(gno);
175 + //成交数量
176 + result.setGqty(detail.getKnockdownNumber());
177 + //原产国 英文三字码
178 + if(!Objects.equals(detail.getHabitatDic(),null)){
179 + result.setOriginCountry(detail.getHabitatDic().getExt3());
180 + }
181 + //第二计量单位 数字三字码
182 + if(!Objects.equals(detail.getUnitLegalSecondId(),null)){
183 + result.setSecondUnit(detail.getUnitLegalSecondId().getExt2());
184 + }
185 + //第二法定数量
186 + result.setSecondQty(NumberUtils.bigDecimalToIntger(detail.getQtyLegalSecond()));
187 + //成交币制 英文三字码
188 + if(!Objects.equals(detail.getCurrencyDic(),null)){
189 + result.setTradeCurr(detail.getCurrencyDic().getExt2());
190 + }
191 + //用途/生产厂家
192 + result.setUseTo("");
193 + //工缴费
194 + result.setWorkUsd(new BigDecimal(0));
195 + //最终目的国 英文三字码
196 + if(!Objects.equals(detail.getDestinationCountryDic(),null)){
197 + result.setDestinationCountry(detail.getDestinationCountryDic().getExt3());
198 + }
199 + //检验检疫编码
200 + result.setCiqCode("");
201 + //申报货物英文名称
202 + result.setDeclGoodsEname(detail.getContentDescription());
203 + //目的地代码 有值传值,无值填空值
204 + if(!Objects.equals(detail.getOrigplacecodeMapping(),null)){
205 + result.setDestCode(detail.getOrigplacecodeMapping().getOrigplaceCode());
206 + }else{
207 + result.setDestCode("");
208 + }
209 + //境内目的地/境内货源地
210 + if(!Objects.equals(detail.getDomesticDestinationMapping(),null)){
211 + result.setDistrictCode(detail.getDomesticDestinationMapping().getDistrictCode());
212 + }
213 + result.setDetailId(detail.getDetailId());
214 + }catch (Exception e){
215 + log.error("convertToChmConsignmentDetail() error:"+e.getMessage());
216 + }
148 217
149 - 218 + return result;
219 + }
150 220
151 public List<ChmConsignmentDetail> findChmConsignmentDetailListByConsignmentCode(Long consignmentId){ 221 public List<ChmConsignmentDetail> findChmConsignmentDetailListByConsignmentCode(Long consignmentId){
152 List<ChmConsignmentDetail> result = new ArrayList<>(); 222 List<ChmConsignmentDetail> result = new ArrayList<>();
...@@ -158,28 +228,19 @@ public class ChmConsignmentDetailService { ...@@ -158,28 +228,19 @@ public class ChmConsignmentDetailService {
158 return result; 228 return result;
159 } 229 }
160 230
161 -
162 -
163 -
164 -
165 public void saveDetailList(List<ChmConsignmentDetail> chmConsignmentDetailList){ 231 public void saveDetailList(List<ChmConsignmentDetail> chmConsignmentDetailList){
166 chmConsignmentDetailRepository.saveAll(chmConsignmentDetailList); 232 chmConsignmentDetailRepository.saveAll(chmConsignmentDetailList);
167 } 233 }
168 234
169 -
170 public void saveChmConsignmentDetail(ChmConsignmentDetail consignmentDetail){ 235 public void saveChmConsignmentDetail(ChmConsignmentDetail consignmentDetail){
171 chmConsignmentDetailRepository.save(consignmentDetail); 236 chmConsignmentDetailRepository.save(consignmentDetail);
172 } 237 }
173 238
174 -
175 public void deleteChmConsignmentDetail(Long id){ 239 public void deleteChmConsignmentDetail(Long id){
176 chmConsignmentDetailRepository.deleteById(id); 240 chmConsignmentDetailRepository.deleteById(id);
177 } 241 }
178 242
179 -
180 public void deleteChmConsignmentDetailBatch(List<Long> idList){ 243 public void deleteChmConsignmentDetailBatch(List<Long> idList){
181 chmConsignmentDetailRepository.deleteChmConsignmentDetailByChnConIdList(idList); 244 chmConsignmentDetailRepository.deleteChmConsignmentDetailByChnConIdList(idList);
182 } 245 }
183 -
184 -
185 } 246 }
......
...@@ -50,7 +50,7 @@ public class IClearApiTask { ...@@ -50,7 +50,7 @@ public class IClearApiTask {
50 /** 50 /**
51 * TODO 定时任务:每分钟推送: 完整报文 51 * TODO 定时任务:每分钟推送: 完整报文
52 */ 52 */
53 - @Scheduled(cron = "${task.pushMawbTask}") 53 + //@Scheduled(cron = "${task.pushMawbTask}")
54 public void pushMawbTask(){ 54 public void pushMawbTask(){
55 try{ 55 try{
56 log.info("pushMawbTask start>>>>>>>>>>>>"); 56 log.info("pushMawbTask start>>>>>>>>>>>>");
......
1 +package com.erry.iclear.dateInterface.util;
2 +
3 +import java.math.BigDecimal;
4 +
5 +/**
6 + * 数值处理类
7 + * mt
8 + * 2021年8月5日16:31:02
9 + */
10 +public class NumberUtils {
11 + /**
12 + * 保留两位小数(四舍五入),0.00之后有数字全部保留位0.01
13 + * @param bdForMat
14 + * @return
15 + */
16 + public static BigDecimal bigDecimalFormat(BigDecimal bdForMat,int num){
17 + if(bdForMat != null){
18 + bdForMat = bdForMat.setScale(num, BigDecimal.ROUND_HALF_UP);
19 + if(bdForMat.compareTo(BigDecimal.ZERO) == 0){
20 + bdForMat = new BigDecimal(0.01).setScale(num,BigDecimal.ROUND_HALF_UP);
21 + }
22 + return bdForMat;
23 + }
24 + return null;
25 + }
26 +
27 + /**
28 + * 将Bigdecimal转换成Integer
29 + * @param bigDecimal
30 + * @return
31 + */
32 + public static Integer bigDecimalToIntger(BigDecimal bigDecimal){
33 + Integer integer = new Integer(0);
34 + if(bigDecimal != null){
35 + integer = bigDecimal.intValue();
36 + }
37 + return integer;
38 + }
39 +}
This diff is collapsed. Click to expand it.
...@@ -111,7 +111,7 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests { ...@@ -111,7 +111,7 @@ public class ChmConsignmentServiceTest extends IClearApiApplicationTests {
111 mawb.setFeeCurr("USD"); 111 mawb.setFeeCurr("USD");
112 mawb.setFeeMark("3"); 112 mawb.setFeeMark("3");
113 mawb.setFeeRate(BigDecimal.valueOf(100.58)); 113 mawb.setFeeRate(BigDecimal.valueOf(100.58));
114 - mawb.setGrossWet(500); 114 + mawb.setGrossWet(BigDecimal.valueOf(500));
115 mawb.setIePort("0101"); 115 mawb.setIePort("0101");
116 mawb.setInputerName(""); 116 mawb.setInputerName("");
117 mawb.setInsurCurr("MOP"); 117 mawb.setInsurCurr("MOP");
......
...@@ -148,7 +148,7 @@ public class HttpClientTest { ...@@ -148,7 +148,7 @@ public class HttpClientTest {
148 mawb.setFeeCurr("USD"); 148 mawb.setFeeCurr("USD");
149 mawb.setFeeMark("3"); 149 mawb.setFeeMark("3");
150 mawb.setFeeRate(BigDecimal.valueOf(100.58)); 150 mawb.setFeeRate(BigDecimal.valueOf(100.58));
151 - mawb.setGrossWet(500); 151 + mawb.setGrossWet(BigDecimal.valueOf(500));
152 mawb.setIePort("0101"); 152 mawb.setIePort("0101");
153 mawb.setInputerName(""); 153 mawb.setInputerName("");
154 mawb.setInsurCurr("MOP"); 154 mawb.setInsurCurr("MOP");
......