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);
179 }catch(Exception ex){ 202 }catch(Exception ex){
180 ex.printStackTrace(); 203 ex.printStackTrace();
181 } 204 }
182 } 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 + }
251 + }catch(Exception ex){
252 + //接口响应时间
253 + declearTask.setResponseTime(new Date());
254 + declearTask.setResponseResults("接口调用失败!");
255 + declearTask.setResponseContent(ex.getMessage());
256 + declearTaskList.add(declearTask);
257 + ex.printStackTrace();
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 + });
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 }
......
...@@ -10,7 +10,9 @@ import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail; ...@@ -10,7 +10,9 @@ import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail;
10 import com.erry.iclear.dateInterface.entity.DictionaryEntries; 10 import com.erry.iclear.dateInterface.entity.DictionaryEntries;
11 import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository; 11 import com.erry.iclear.dateInterface.repository.ChmConsignmentRepository;
12 import com.erry.iclear.dateInterface.util.DateUtils; 12 import com.erry.iclear.dateInterface.util.DateUtils;
13 +import com.erry.iclear.dateInterface.util.NumberUtils;
13 import lombok.extern.slf4j.Slf4j; 14 import lombok.extern.slf4j.Slf4j;
15 +import org.apache.commons.lang3.StringUtils;
14 import org.springframework.beans.BeanUtils; 16 import org.springframework.beans.BeanUtils;
15 import org.springframework.beans.factory.annotation.Autowired; 17 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.stereotype.Service; 18 import org.springframework.stereotype.Service;
...@@ -59,7 +61,6 @@ public class ChmConsignmentService { ...@@ -59,7 +61,6 @@ public class ChmConsignmentService {
59 result.setConsignmentHeadCode(billNo[0]); 61 result.setConsignmentHeadCode(billNo[0]);
60 result.setConsignmentCode(billNo[1]); 62 result.setConsignmentCode(billNo[1]);
61 } 63 }
62 -
63 //合同号 64 //合同号
64 result.setContractCode(mawb.getContrNo()); 65 result.setContractCode(mawb.getContrNo());
65 //主管海关(申报地海关) 66 //主管海关(申报地海关)
...@@ -70,26 +71,19 @@ public class ChmConsignmentService { ...@@ -70,26 +71,19 @@ public class ChmConsignmentService {
70 result.setTaxNatureDic(levyTypeDictionaryEntries); 71 result.setTaxNatureDic(levyTypeDictionaryEntries);
71 result.setTaxNature(levyTypeDictionaryEntries.getChineseName()); 72 result.setTaxNature(levyTypeDictionaryEntries.getChineseName());
72 } 73 }
73 -
74 //报关/转关关系标志:固定值0 ,但数据字典里没有0 74 //报关/转关关系标志:固定值0 ,但数据字典里没有0
75 -
76 -
77 //经停港/指运港 75 //经停港/指运港
78 ChmCarryPort chmCarryPort =Constant.chmCarryPortCache.get(mawb.getDistinatePort()); 76 ChmCarryPort chmCarryPort =Constant.chmCarryPortCache.get(mawb.getDistinatePort());
79 if(!Objects.equals(chmCarryPort,null)){ 77 if(!Objects.equals(chmCarryPort,null)){
80 result.setThroughStopPortDic(chmCarryPort); 78 result.setThroughStopPortDic(chmCarryPort);
81 result.setThroughStopPort(chmCarryPort.getPortNo()); 79 result.setThroughStopPort(chmCarryPort.getPortNo());
82 } 80 }
83 -
84 -
85 //TODO 报关标志【待确认】 81 //TODO 报关标志【待确认】
86 DictionaryEntries declaredDocTypeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.DECLARED_DOC_TYPE + mawb.getEdiId()); 82 DictionaryEntries declaredDocTypeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.DECLARED_DOC_TYPE + mawb.getEdiId());
87 if(!Objects.equals(declaredDocTypeDictionaryEntries,null)){ 83 if(!Objects.equals(declaredDocTypeDictionaryEntries,null)){
88 result.setDeclaredDocTypeDic(declaredDocTypeDictionaryEntries); 84 result.setDeclaredDocTypeDic(declaredDocTypeDictionaryEntries);
89 result.setDeclaredDocType(declaredDocTypeDictionaryEntries.getChineseName()); 85 result.setDeclaredDocType(declaredDocTypeDictionaryEntries.getChineseName());
90 } 86 }
91 -
92 -
93 //海关编号 87 //海关编号
94 result.setCustomsNo(mawb.getEntryId()); 88 result.setCustomsNo(mawb.getEntryId());
95 //运费币制 89 //运费币制
...@@ -98,28 +92,20 @@ public class ChmConsignmentService { ...@@ -98,28 +92,20 @@ public class ChmConsignmentService {
98 result.setTransCurrencyDic(currencyDictionaryEntries); 92 result.setTransCurrencyDic(currencyDictionaryEntries);
99 result.setTransCurrency(currencyDictionaryEntries.getChineseName()); 93 result.setTransCurrency(currencyDictionaryEntries.getChineseName());
100 } 94 }
101 -
102 -
103 //TODO 运费标记:固定值 3 【iclear中, 和成交方式相关,只有成交方式 1、2 时,才能传 3 】 95 //TODO 运费标记:固定值 3 【iclear中, 和成交方式相关,只有成交方式 1、2 时,才能传 3 】
104 -
105 -
106 //运费总价 96 //运费总价
107 result.setTransCost(mawb.getFeeRate()); 97 result.setTransCost(mawb.getFeeRate());
108 //毛重 98 //毛重
109 - result.setGrossWeight(BigDecimal.valueOf(mawb.getGrossWet())); 99 + result.setGrossWeight(mawb.getGrossWet());
110 //出入境关闭:固定值 0101 100 //出入境关闭:固定值 0101
111 //录入人名称:固定值 必填项,但填的值是空值 101 //录入人名称:固定值 必填项,但填的值是空值
112 -
113 //保险费币制 102 //保险费币制
114 DictionaryEntries insuranceDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM+mawb.getInsurCurr()); 103 DictionaryEntries insuranceDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM+mawb.getInsurCurr());
115 if(!Objects.equals(insuranceDictionaryEntries,null)){ 104 if(!Objects.equals(insuranceDictionaryEntries,null)){
116 result.setInsuranceCostCurrencyDic(insuranceDictionaryEntries); 105 result.setInsuranceCostCurrencyDic(insuranceDictionaryEntries);
117 result.setInsuranceCostCurrency(insuranceDictionaryEntries.getChineseName()); 106 result.setInsuranceCostCurrency(insuranceDictionaryEntries.getChineseName());
118 } 107 }
119 -
120 -
121 //保险费标记 ,根据transMode决定 108 //保险费标记 ,根据transMode决定
122 -
123 //保险费/率 109 //保险费/率
124 result.setInsuranceCost(mawb.getInsurRate()); 110 result.setInsuranceCost(mawb.getInsurRate());
125 //备案号 111 //备案号
...@@ -132,7 +118,6 @@ public class ChmConsignmentService { ...@@ -132,7 +118,6 @@ public class ChmConsignmentService {
132 result.setOtherCurrencyDic(otherDictionaryEntries); 118 result.setOtherCurrencyDic(otherDictionaryEntries);
133 result.setOtherCurrency(otherDictionaryEntries.getChineseName()); 119 result.setOtherCurrency(otherDictionaryEntries.getChineseName());
134 } 120 }
135 -
136 //杂费/率 121 //杂费/率
137 result.setOtherCost(mawb.getOtherRate()); 122 result.setOtherCost(mawb.getOtherRate());
138 //杂费标志 123 //杂费标志
...@@ -140,8 +125,6 @@ public class ChmConsignmentService { ...@@ -140,8 +125,6 @@ public class ChmConsignmentService {
140 result.setOwnerCode(mawb.getOwnerCode()); 125 result.setOwnerCode(mawb.getOwnerCode());
141 //TODO 消费使用/生产销售单位名称 126 //TODO 消费使用/生产销售单位名称
142 result.setOwnerName(mawb.getOwnerName()); 127 result.setOwnerName(mawb.getOwnerName());
143 -
144 -
145 //件数 128 //件数
146 result.setCounts(mawb.getPackNo().longValue()); 129 result.setCounts(mawb.getPackNo().longValue());
147 //预录入编号 130 //预录入编号
...@@ -152,23 +135,18 @@ public class ChmConsignmentService { ...@@ -152,23 +135,18 @@ public class ChmConsignmentService {
152 result.setFromCountryDic(fromCountryDictionaryEntries); 135 result.setFromCountryDic(fromCountryDictionaryEntries);
153 result.setFromCountry(fromCountryDictionaryEntries.getChineseName()); 136 result.setFromCountry(fromCountryDictionaryEntries.getChineseName());
154 } 137 }
155 -
156 //运单类型 138 //运单类型
157 DictionaryEntries consType = Constant.dictionaryEntriesCache.get(Constant.consType_D); 139 DictionaryEntries consType = Constant.dictionaryEntriesCache.get(Constant.consType_D);
158 if(consType != null){ 140 if(consType != null){
159 result.setConsTypeId(consType); 141 result.setConsTypeId(consType);
160 result.setConsType(consType.getChineseName()); 142 result.setConsType(consType.getChineseName());
161 } 143 }
162 -
163 //监管方式 144 //监管方式
164 DictionaryEntries tradeModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.SUPERVISION_MODE+mawb.getTradeMode()); 145 DictionaryEntries tradeModeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.SUPERVISION_MODE+mawb.getTradeMode());
165 if(!Objects.equals(tradeModeDictionaryEntries,null)){ 146 if(!Objects.equals(tradeModeDictionaryEntries,null)){
166 result.setTradeModeDic(tradeModeDictionaryEntries); 147 result.setTradeModeDic(tradeModeDictionaryEntries);
167 result.setTradeMode(tradeModeDictionaryEntries.getChineseName()); 148 result.setTradeMode(tradeModeDictionaryEntries.getChineseName());
168 } 149 }
169 -
170 -
171 -
172 //境内收发货人编号 150 //境内收发货人编号
173 result.setTradeCoSCC(mawb.getTradeCode()); 151 result.setTradeCoSCC(mawb.getTradeCode());
174 //运输方式代码 152 //运输方式代码
...@@ -177,8 +155,6 @@ public class ChmConsignmentService { ...@@ -177,8 +155,6 @@ public class ChmConsignmentService {
177 result.setVehicleWay(vehicleWayDictionaryEntries); 155 result.setVehicleWay(vehicleWayDictionaryEntries);
178 result.setVehicleWayCode(vehicleWayDictionaryEntries.getCode()); 156 result.setVehicleWayCode(vehicleWayDictionaryEntries.getCode());
179 } 157 }
180 -
181 -
182 //境内收发货人名称 158 //境内收发货人名称
183 result.setOperateUnitName(mawb.getTradeName()); 159 result.setOperateUnitName(mawb.getTradeName());
184 //成交方式 160 //成交方式
...@@ -187,69 +163,49 @@ public class ChmConsignmentService { ...@@ -187,69 +163,49 @@ public class ChmConsignmentService {
187 result.setDealModeDic(dealModeDictionaryEntries); 163 result.setDealModeDic(dealModeDictionaryEntries);
188 result.setDealMode(dealModeDictionaryEntries.getChineseName()); 164 result.setDealMode(dealModeDictionaryEntries.getChineseName());
189 } 165 }
190 -
191 -
192 //包装种类 166 //包装种类
193 DictionaryEntries packageTypeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.NEW_PACKAGE_TYPE+mawb.getWrapType()); 167 DictionaryEntries packageTypeDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.NEW_PACKAGE_TYPE+mawb.getWrapType());
194 if(!Objects.equals(packageTypeDictionaryEntries,null)){ 168 if(!Objects.equals(packageTypeDictionaryEntries,null)){
195 result.setPackageTypeDic(packageTypeDictionaryEntries); 169 result.setPackageTypeDic(packageTypeDictionaryEntries);
196 result.setPackageType(packageTypeDictionaryEntries.getChineseName()); 170 result.setPackageType(packageTypeDictionaryEntries.getChineseName());
197 } 171 }
198 -
199 -
200 -
201 //TODO 生产核销单位统一信用代码---报关形式类型 172 //TODO 生产核销单位统一信用代码---报关形式类型
202 result.setTradeCoSCC(mawb.getTradeCodeScc()); 173 result.setTradeCoSCC(mawb.getTradeCodeScc());
203 -
204 -
205 //TODO 消费使用/生产销售单位单位统一编码 174 //TODO 消费使用/生产销售单位单位统一编码
206 result.setOwnerCodeScc(mawb.getOwnerCodeScc()); 175 result.setOwnerCodeScc(mawb.getOwnerCodeScc());
207 -
208 -
209 //贸易国别 176 //贸易国别
210 DictionaryEntries tradeAreaCodeDictionaryEntries=Constant.dictionaryEntriesCache.get(Constant.COUNTRY+mawb.getTradeAreaCode()); 177 DictionaryEntries tradeAreaCodeDictionaryEntries=Constant.dictionaryEntriesCache.get(Constant.COUNTRY+mawb.getTradeAreaCode());
211 if(!Objects.equals(tradeAreaCodeDictionaryEntries,null)){ 178 if(!Objects.equals(tradeAreaCodeDictionaryEntries,null)){
212 result.setTradeAreaCodeDic(tradeAreaCodeDictionaryEntries); 179 result.setTradeAreaCodeDic(tradeAreaCodeDictionaryEntries);
213 result.setTradeAreaCode(tradeAreaCodeDictionaryEntries.getChineseName()); 180 result.setTradeAreaCode(tradeAreaCodeDictionaryEntries.getChineseName());
214 } 181 }
215 -
216 -
217 //标记及号码 182 //标记及号码
218 result.setDeclaredRemark(mawb.getMarkNo()); 183 result.setDeclaredRemark(mawb.getMarkNo());
219 -
220 //入境口岸代码:固定值 310302 184 //入境口岸代码:固定值 310302
221 -
222 //存放地点:固定值 空值 185 //存放地点:固定值 空值
223 -
224 //申报人员姓名---报关员证号 186 //申报人员姓名---报关员证号
225 result.setDeclaredUnitName(mawb.getDeclareName()); 187 result.setDeclaredUnitName(mawb.getDeclareName());
226 //境外发货人代码 188 //境外发货人代码
227 -
228 //境外收货人编码 189 //境外收货人编码
229 result.setOverseasConsignorCode(mawb.getOverseasConsigneeCode()); 190 result.setOverseasConsignorCode(mawb.getOverseasConsigneeCode());
230 //境外收货人名称(外文) 191 //境外收货人名称(外文)
231 result.setOverseasConsignorFnCname(mawb.getOverseasConsigneeEname()); 192 result.setOverseasConsignorFnCname(mawb.getOverseasConsigneeEname());
232 -
233 -
234 //运单状态: 待申报海关 193 //运单状态: 待申报海关
235 DictionaryEntries transferWaybillStatusDictionaryEntries=Constant.dictionaryEntriesCache.get(Constant.TRANSFER_WAY_BILL_STATUS+"5"); 194 DictionaryEntries transferWaybillStatusDictionaryEntries=Constant.dictionaryEntriesCache.get(Constant.TRANSFER_WAY_BILL_STATUS+"5");
236 if(!Objects.equals(transferWaybillStatusDictionaryEntries,null)){ 195 if(!Objects.equals(transferWaybillStatusDictionaryEntries,null)){
237 result.setConsStatusDic(transferWaybillStatusDictionaryEntries); 196 result.setConsStatusDic(transferWaybillStatusDictionaryEntries);
238 result.setConsStatus(transferWaybillStatusDictionaryEntries.getChineseName()); 197 result.setConsStatus(transferWaybillStatusDictionaryEntries.getChineseName());
239 } 198 }
240 -
241 //添加TSN口岸 199 //添加TSN口岸
242 DictionaryEntries portTSN = Constant.dictionaryEntriesCache.get(Constant.PORT_TSN); 200 DictionaryEntries portTSN = Constant.dictionaryEntriesCache.get(Constant.PORT_TSN);
243 if (!Objects.equals(portTSN,null)){ 201 if (!Objects.equals(portTSN,null)){
244 result.setPortId(portTSN); 202 result.setPortId(portTSN);
245 result.setPortName(portTSN.getChineseName()); 203 result.setPortName(portTSN.getChineseName());
246 } 204 }
247 -
248 //西门子数据都为TSN口岸,可通过口岸查询查看 205 //西门子数据都为TSN口岸,可通过口岸查询查看
249 if (creator.equals("IDE")){ 206 if (creator.equals("IDE")){
250 result.setDeclaredPort("TSN"); 207 result.setDeclaredPort("TSN");
251 } 208 }
252 -
253 //推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据 209 //推送时间作为创建时间,可以用来校验数据的有序性,如果新的推送时间小于已有的创建时间,就不更新数据
254 result.setCreateTime(new Date()); 210 result.setCreateTime(new Date());
255 result.setUpdateTime(pushTime); 211 result.setUpdateTime(pushTime);
...@@ -263,6 +219,148 @@ public class ChmConsignmentService { ...@@ -263,6 +219,148 @@ public class ChmConsignmentService {
263 return result; 219 return result;
264 } 220 }
265 221
222 + /**
223 + * 运单转换主单
224 + * @return
225 + */
226 + public Mawb convertToChmConsignment(ChmConsignment consignment){
227 + Mawb result = new Mawb();
228 + try{
229 + //将运单ID赋值,作为排查数据依据
230 + result.setId(consignment.getId());
231 + //进出口标志:固定值 E
232 + result.setIeFlag("E");
233 + //申报类型:固定值 EX
234 + result.setType("EX");
235 + //申报单位代码:固定值 1111980005
236 + result.setAgentCode("1111980005");
237 + //申报单位名称:固定值 联邦快递(中国)有限公司
238 + result.setAgentName("联邦快递(中国)有限公司");
239 + //提单号:有总单号则取值“总单号_运单号”,没有总单号则取值“运单号”
240 + //总单号不为空
241 + if(StringUtils.isNotBlank(consignment.getConsignmentHeadCode())){
242 + result.setBillNo(consignment.getConsignmentHeadCode() + "_" + consignment.getConsignmentCode());
243 + }else{
244 + result.setBillNo(consignment.getConsignmentCode());
245 + }
246 + //合同号 最大长度32
247 + result.setContrNo(consignment.getContractCode());
248 + //主管海关(申报地海关) 固定值 0101
249 + result.setCustomMaster("0101");
250 + //征免性质 数字三字码
251 + if(!Objects.equals(consignment.getTaxNatureDic(),null)){
252 + result.setCutMode(consignment.getTaxNatureDic().getExt2());
253 + }
254 + //经停港/指运港 固定值:0
255 + result.setDeclTrnRel("0");
256 + //经停港/指运港 6位港口代码 ASM000、Mar-51、996102
257 + if(!Objects.equals(consignment.getThroughStopPortDic(),null)){
258 + result.setDistinatePort(consignment.getThroughStopPortDic().getPcCode());
259 + }
260 +
261 + //报关标志 数字三字码或英文二字码
262 + if(!Objects.equals(consignment.getDeclaredDocTypeDic(),null)){
263 + result.setEdiId(consignment.getDeclaredDocTypeDic().getExt2());
264 + }
265 + //海关编号
266 + result.setEntryId(consignment.getCustomsNo());
267 + //运费币制 英文三字码
268 + if(!Objects.equals(consignment.getTransCurrencyDic(),null)){
269 + result.setFeeCurr(consignment.getTransCurrencyDic().getExt2());
270 + }
271 + //TODO 运费标记:固定值 3 【iclear中, 和成交方式相关,只有成交方式 1、2 时,才能传 3 】
272 + result.setFeeMark("3");
273 + //运费总价 保留2位小数
274 + result.setFeeRate(NumberUtils.bigDecimalFormat(consignment.getTransCost(),2));
275 +
276 + //毛重 保留5位小数
277 + result.setGrossWet(NumberUtils.bigDecimalFormat(consignment.getGrossWeight(),5));
278 + //出入境关闭:固定值 0101
279 + result.setIePort("0101");
280 + //录入人名称:固定值 必填项,但填的值是空值
281 + result.setInputerName("");
282 + //保险费币制
283 + if(!Objects.equals(consignment.getInsuranceCostCurrencyDic(),null)){
284 + result.setInsurCurr(consignment.getInsuranceCostCurrencyDic().getExt2());
285 + }
286 + //保险费标记 ,根据transMode决定
287 + result.setInsurMark("");
288 + //保险费/率 保留2位小数
289 + result.setInsurRate(NumberUtils.bigDecimalFormat(consignment.getInsuranceCost(),2));
290 + //备案号
291 + result.setManualNo(consignment.getRecordCode());
292 + //净重 保留5位小数
293 + result.setNetWt(NumberUtils.bigDecimalFormat(consignment.getNetWeight(),5));
294 + //杂费币制 数字三字码
295 + if(!Objects.equals(consignment.getOtherCurrencyDic(),null)){
296 + result.setOtherCurr(consignment.getOtherCurrencyDic().getExt6());
297 + }
298 + //杂费/率
299 + result.setOtherRate(NumberUtils.bigDecimalFormat(consignment.getOtherCost(),2));
300 + //杂费标志
301 + result.setOtherMark("");
302 + //TODO 消费使用/生产销售单位代码
303 + result.setOwnerCode(consignment.getOwnerCode());
304 + //TODO 消费使用/生产销售单位名称
305 + result.setOwnerName(consignment.getOwnerName());
306 + //件数
307 + result.setPackNo(consignment.getCounts().intValue());
308 + //预录入编号
309 + result.setPreEntryId(consignment.getEnteringNo());
310 + //启运国/运抵国 英文三字码
311 + if(!Objects.equals(consignment.getFromCountryDic(),null)){
312 + result.setTradeCountry(consignment.getFromCountryDic().getExt3());
313 + }
314 + //监管方式 数字四字码
315 + if(!Objects.equals(consignment.getTradeModeDic(),null)){
316 + result.setTradeMode(consignment.getTradeModeDic().getExt2());
317 + }
318 + //境内收发货人编号
319 + result.setTradeCode(consignment.getTradeCoSCC());
320 + //运输方式代码 一字码,数字或大写英文字母
321 + if(!Objects.equals(consignment.getVehicleWay(),null)){
322 + result.setTrafMode(consignment.getVehicleWay().getExt2());
323 + }
324 + //境内收发货人名称
325 + result.setTradeName(consignment.getOperateUnitName());
326 + //成交方式 数字一字码,从1~4,共4个
327 + if(!Objects.equals(consignment.getDealModeDic(),null)){
328 + result.setTransMode(consignment.getDealModeDic().getExt6());
329 + }
330 + //包装种类 取值范围(0,1,4,6,22,29,32,33,39,92,93,99)
331 + if(!Objects.equals(consignment.getPackageTypeDic(),null)){
332 + result.setWrapType(consignment.getPackageTypeDic().getExt2());
333 + }
334 + //TODO 生产核销单位统一信用代码---报关形式类型
335 + result.setTradeCodeScc(consignment.getTradeCoSCC());
336 + //TODO 消费使用/生产销售单位单位统一编码
337 + result.setOwnerCodeScc(consignment.getOwnerCodeScc());
338 + //贸易国别 英文三字码
339 + if(!Objects.equals(consignment.getTradeAreaCodeDic(),null)){
340 + result.setTradeAreaCode(consignment.getTradeAreaCodeDic().getExt3());
341 + }
342 + //标记及号码
343 + result.setMarkNo(consignment.getDeclaredRemark());
344 + //入境口岸代码:固定值 310302
345 + result.setEntyPortCode("310302");
346 + //存放地点:固定值 空值
347 + result.setGoodsPlace("");
348 + //申报人员姓名---报关员证号
349 + result.setDeclareName(consignment.getDeclaredUnitName());
350 + //境外发货人代码
351 + result.setOverseasConsignorCode("");
352 + //境外收货人编码
353 + result.setOverseasConsigneeCode(consignment.getOverseasConsignorCode());
354 + //境外收货人名称(外文)
355 + result.setOverseasConsigneeEname(consignment.getOverseasConsignorFnCname());
356 + }catch (Exception e){
357 + result=null;
358 + e.printStackTrace();
359 + log.error("convertToChmConsignment() error:"+e.getMessage());
360 + }
361 + return result;
362 + }
363 +
266 364
267 /** 365 /**
268 * 保存主单 366 * 保存主单
...@@ -278,7 +376,6 @@ public class ChmConsignmentService { ...@@ -278,7 +376,6 @@ public class ChmConsignmentService {
278 return null; 376 return null;
279 } 377 }
280 378
281 -
282 /** 379 /**
283 * 保存主单 380 * 保存主单
284 * @param chmConsignment 381 * @param chmConsignment
...@@ -293,14 +390,6 @@ public class ChmConsignmentService { ...@@ -293,14 +390,6 @@ public class ChmConsignmentService {
293 return null; 390 return null;
294 } 391 }
295 392
296 -
297 -
298 -
299 -
300 -
301 -
302 -
303 -
304 /** 393 /**
305 * 根据运单号查找数据 394 * 根据运单号查找数据
306 * @param consignmentCode 395 * @param consignmentCode
...@@ -315,7 +404,6 @@ public class ChmConsignmentService { ...@@ -315,7 +404,6 @@ public class ChmConsignmentService {
315 return null; 404 return null;
316 } 405 }
317 406
318 -
319 /** 407 /**
320 * 保存或更新 iclear中的运单信息 408 * 保存或更新 iclear中的运单信息
321 * @param mawb 409 * @param mawb
...@@ -339,11 +427,9 @@ public class ChmConsignmentService { ...@@ -339,11 +427,9 @@ public class ChmConsignmentService {
339 }); 427 });
340 chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList); 428 chmConsignment.setChmConsignmentDetailList(chmConsignmentDetailList);
341 429
342 -
343 //2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入 430 //2、校验 7天+运单 ,如果有数据并且 还未报关就更新,如果数据就插入
344 ChmConsignment chmConsignmentDB=this.findChmConsignmentByConsignmentCode(chmConsignment.getConsignmentCode(), DateUtils.addDate(DateUtils.getCurrentDate(),-7)); 431 ChmConsignment chmConsignmentDB=this.findChmConsignmentByConsignmentCode(chmConsignment.getConsignmentCode(), DateUtils.addDate(DateUtils.getCurrentDate(),-7));
345 432
346 -
347 //3、新增或更新 433 //3、新增或更新
348 //新增:如果没有就插入 434 //新增:如果没有就插入
349 if (Objects.equals(chmConsignmentDB,null)){ 435 if (Objects.equals(chmConsignmentDB,null)){
...@@ -369,7 +455,6 @@ public class ChmConsignmentService { ...@@ -369,7 +455,6 @@ public class ChmConsignmentService {
369 //更新数据 455 //更新数据
370 log.info("更新主单"+ mawb.getBillNo()); 456 log.info("更新主单"+ mawb.getBillNo());
371 457
372 -
373 //由于订单明细中,无法确定唯一一条数据,所以无法做到update,只能先删除在插入 458 //由于订单明细中,无法确定唯一一条数据,所以无法做到update,只能先删除在插入
374 for(ChmConsignmentDetail newDetail:chmConsignment.getChmConsignmentDetailList()){ 459 for(ChmConsignmentDetail newDetail:chmConsignment.getChmConsignmentDetailList()){
375 for(ChmConsignmentDetail oldDetail: chmConsignmentDB.getChmConsignmentDetailList()){ 460 for(ChmConsignmentDetail oldDetail: chmConsignmentDB.getChmConsignmentDetailList()){
...@@ -396,26 +481,7 @@ public class ChmConsignmentService { ...@@ -396,26 +481,7 @@ public class ChmConsignmentService {
396 }catch (Exception e){ 481 }catch (Exception e){
397 log.error(""+e.getMessage()); 482 log.error(""+e.getMessage());
398 } 483 }
399 -
400 result.setSuccess(Boolean.TRUE); 484 result.setSuccess(Boolean.TRUE);
401 return result; 485 return result;
402 } 486 }
403 -
404 -
405 -
406 -
407 -
408 -
409 -
410 -
411 -
412 -
413 -
414 -
415 -
416 -
417 -
418 -
419 -
420 -
421 } 487 }
......
...@@ -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 +}
1 +package com.erry.iclear.dateInterface.util;
2 +
3 +import org.apache.commons.lang3.RandomStringUtils;
4 +import org.apache.commons.lang3.StringUtils;
5 +
6 +import javax.servlet.http.HttpServletRequest;
7 +import java.io.ByteArrayOutputStream;
8 +import java.io.IOException;
9 +import java.io.PrintStream;
10 +import java.io.UnsupportedEncodingException;
11 +import java.math.BigDecimal;
12 +import java.util.ArrayList;
13 +import java.util.List;
14 +import java.util.regex.Matcher;
15 +import java.util.regex.Pattern;
16 +
17 +
18 +public class StringUtil {
19 +
20 + /**
21 + * 正则表达式:验证邮箱
22 + */
23 + private static final String REGEX_EMAIL = "^([a-z0-9A-Z_]+[-|\\.]?)+[a-z0-9A-Z_]@([a-z0-9A-Z_]+(-[a-z0-9A-Z_]+)?\\.)+[a-zA-Z_]{2,}$";
24 +
25 + /**
26 + * 正则表达式:验证数字
27 + */
28 + private static final String REGEX_NUBMER = "\\d+\\.\\d+$|-\\d+\\.\\d+$";
29 +
30 + /**
31 + * 判断字符串是否为空
32 + *
33 + * @param src
34 + * @return
35 + */
36 + public static boolean isEmpty(String src) {
37 + return src == null || "".equals(src.trim());
38 + }
39 +
40 + /**
41 + * 判断字符串不为空
42 + *
43 + * @param src
44 + * @return
45 + */
46 + public static boolean isNotEmpty(String src) {
47 + return !isEmpty(src);
48 + }
49 +
50 + public static String toStringExcludeNull(Object obj) {
51 + return obj == null ? "" : obj.toString();
52 + }
53 +
54 + /**
55 + * 判断字符串是否为空
56 + *
57 + * @param src
58 + * @return
59 + */
60 + public static boolean isEmptyWithTrim(String src) {
61 + return src == null || "".equals(src.trim());
62 + }
63 +
64 +
65 + /**
66 + * 将字符串前补0到指定长度
67 + *
68 + * @param value
69 + * @param length
70 + * @return
71 + */
72 + public static String fillZero(String value, int length) {
73 + if (value == null) {
74 + return null;
75 + } else {
76 + while (value.length() < length) {
77 + value = "0" + value;
78 + }
79 + }
80 + return value;
81 + }
82 +
83 + /**
84 + * 截取指定长度的字符串
85 + *
86 + * @param str
87 + * @param length
88 + * @return
89 + */
90 + public static String truncate(String str, int length) {
91 + if (!isEmpty(str) && str.length() > length) {
92 + return str.substring(0, length);
93 + }
94 + return str;
95 + }
96 +
97 + /**
98 + * 将首字母大写
99 + *
100 + * @param str
101 + * @return
102 + */
103 + public static String upcaseFirstLetter(String str) {
104 + if (str == null) {
105 + return null;
106 + }
107 + String firstChar = str.substring(0, 1);
108 + return firstChar.toUpperCase() + str.substring(1, str.length());
109 + }
110 +
111 + /**
112 + * 按指定长度format数字long
113 + *
114 + * @param num
115 + * @param length
116 + * @return
117 + */
118 + public static String formatLong(long num, int length) {
119 + String number = Long.toString(num);
120 + while (number.length() < length) {
121 + number = "0" + number;
122 + }
123 + return number;
124 + }
125 +
126 + /**
127 + * 判断字符串是否为半角英文或数字
128 + *
129 + * @param str
130 + * @return
131 + */
132 + public static boolean isAllHalfWidth(String str) {
133 + char[] chars = str.toCharArray();
134 + for (int i = 0; i < chars.length; i++) {
135 + int ascii = chars[i];
136 + if ((ascii >= 48 && ascii <= 57) //0-9
137 + || (ascii >= 65 && ascii <= 90) //A-Z
138 + || (ascii >= 97 && ascii <= 122)) { //a-z
139 + } else {
140 + return false;
141 + }
142 + }
143 + return true;
144 + }
145 +
146 + /**
147 + * 判断字符串是否整数
148 + *
149 + * @param str
150 + * @return
151 + */
152 + public static boolean isNum(String str) {
153 + if (StringUtil.isEmptyWithTrim(str)) {
154 + return false;
155 + }
156 + char[] chars = str.toCharArray();
157 + for (int i = 0; i < chars.length; i++) {
158 + int ascii = chars[i];
159 + if ((ascii >= 48 && ascii <= 57)) //0-9)
160 + {
161 + } else {
162 + return false;
163 + }
164 + }
165 + return true;
166 + }
167 +
168 + /**
169 + * 判断字符串是否小数
170 + *
171 + * @param str
172 + * @return
173 + */
174 + public static boolean isNumeric(String str) {
175 + Pattern pattern = Pattern.compile(REGEX_NUBMER);
176 + Matcher isNum = pattern.matcher(str);
177 + if (!isNum.matches()) {
178 + return false;
179 + }
180 + return true;
181 + }
182 +
183 + public static String toString(String str) {
184 + return str == null ? "" : str;
185 + }
186 +
187 + public static String toString(Object obj) {
188 + return obj == null ? "" : obj.toString();
189 + }
190 +
191 + /**
192 + * 将字符串数组按指定分隔符转为字符串
193 + *
194 + * @param arr
195 + * @param seperator
196 + * @return
197 + */
198 + public static String convertArrayToString(String[] arr, String seperator) {
199 + StringBuffer sb = new StringBuffer();
200 + for (int i = 0; i < arr.length; i++) {
201 + sb.append(seperator + arr[i]);
202 + }
203 + if (sb.length() > 0) {
204 + sb.deleteCharAt(0);
205 + }
206 + return sb.toString();
207 + }
208 +
209 + /**
210 + * Return the string of exception
211 + *
212 + * @param t
213 + * @return
214 + * @throws IOException
215 + */
216 + public static String exceptionToString(Throwable t) throws IOException {
217 + if (t == null) {
218 + return null;
219 + }
220 + ByteArrayOutputStream baos = new ByteArrayOutputStream();
221 + try {
222 + t.printStackTrace(new PrintStream(baos));
223 + } finally {
224 + baos.close();
225 + }
226 +
227 + String sb = baos.toString();
228 + if (sb.length() > 5000) {
229 + return sb.substring(0, 5000);
230 + }
231 + return sb;
232 + }
233 +
234 + /**
235 + * 将字符串按指定的分隔符分隔成数组
236 + *
237 + * @param str
238 + * @param separator
239 + * @return
240 + */
241 + public static String[] split(String str, String separator) {
242 + return StringUtils.split(str, separator);
243 + }
244 +
245 + /**
246 + * 获取字符串被特定字符分割后的最后一个元素
247 + */
248 + public static String getLastSperator(String str, String sperator) {
249 + String[] ss = split(str, sperator);
250 + return ss[ss.length - 1];
251 + }
252 +
253 + /**
254 + * 判断传入的字符串是否可以被解析为数字
255 + */
256 + public static boolean isNumberString(String s) {
257 + try {
258 + if (isEmptyWithTrim(s) || s == null || "null".equals(s)) {
259 + return true;
260 + }
261 + Double.valueOf(s);
262 + return true;
263 + } catch (NumberFormatException e) {
264 + return false;
265 + }
266 + }
267 +
268 + public static String cutLastSperator(String s, String sperator) {
269 + return s.substring(0, s.length() - getLastSperator(s, sperator).length() - sperator.length());
270 + }
271 +
272 + /**
273 + * 截取字符串中以除某个字符串结尾的所有字符
274 + */
275 + public static String cutSperatorLast(String s, String sperator) {
276 + if (s == null || s.length() == 0) {
277 + return s;
278 + }
279 + if (s.substring(s.length() - sperator.length()).equals(sperator)) {
280 + return cutSperatorLast(s.substring(0, s.length() - 1), sperator);
281 + }
282 + return s;
283 + }
284 +
285 + public static String toUtf8String(String s) {
286 + StringBuffer sb = new StringBuffer();
287 + for (int i = 0; i < s.length(); i++) {
288 + char c = s.charAt(i);
289 + if (c >= 0 && c <= 255) {
290 + sb.append(c);
291 + } else {
292 + byte[] b;
293 + try {
294 + b = Character.toString(c).getBytes("utf-8");
295 + } catch (Exception ex) {
296 + ex.printStackTrace();
297 + b = new byte[0];
298 + }
299 + for (int j = 0; j < b.length; j++) {
300 + int k = b[j];
301 + if (k < 0) {
302 + k += 256;
303 + }
304 + sb.append("%" + Integer.toHexString(k).toUpperCase());
305 + }
306 + }
307 + }
308 + return sb.toString();
309 + }
310 +
311 + /**
312 + * 根据不同浏览器将文件名中的汉字转为UTF8编码的串,以便下载时能正确显示另存的文件名.
313 + *
314 + * @param s 原文件名
315 + * @return 重新编码后的文件名
316 + */
317 + public static String toUtf8String(HttpServletRequest request, String s) {
318 + String agent = request.getHeader("User-Agent");
319 + try {
320 + boolean isFireFox = (agent != null && agent.toLowerCase().indexOf("firefox") != -1);
321 + if (isFireFox) {
322 +// s = new String(s.getBytes("UTF-8"), "ISO8859-1");
323 + } else {
324 + s = StringUtil.toUtf8String(s);
325 + if ((agent != null && agent.indexOf("MSIE") != -1)) {
326 + if (s.length() > 150) {
327 + // 根据request的locale 得出可能的编码
328 + s = new String(s.getBytes("UTF-8"), "ISO8859-1");
329 + }
330 + }
331 + }
332 + } catch (UnsupportedEncodingException e) {
333 + e.printStackTrace();
334 + }
335 + return s;
336 + }
337 +
338 + /**
339 + * 把Json字符串中属性值为空字符串的值替换成null
340 + * 例如:"bespeakTakeTime": "", 替换成 "bespeakTakeTime": null,
341 + *
342 + * @param sourceString
343 + * @param properties
344 + * @return
345 + */
346 + public static String replaceByProperties(String sourceString, String properties) {
347 + String targetString = "";
348 + String[] stringArray = properties.split(",");
349 + for (int i = 0; i < stringArray.length; i++) {
350 + String s = stringArray[i];
351 + String sourceSubStr = "\"" + s + "\":\"\",";
352 + String targetSubStr = "\"" + s + "\": null,";
353 + targetString = sourceString.replace(sourceSubStr, targetSubStr);
354 + }
355 + return targetString;
356 + }
357 +
358 + /**
359 + * 把String List转成逗号分隔的String
360 + *
361 + * @param stringList
362 + * @return
363 + */
364 + public static String listToString(List<String> stringList) {
365 + if (stringList == null) {
366 + return null;
367 + }
368 + StringBuilder result = new StringBuilder();
369 + boolean flag = false;
370 + for (String string : stringList) {
371 + if (flag) {
372 + result.append(",");
373 + } else {
374 + flag = true;
375 + }
376 + result.append(string);
377 + }
378 + return result.toString();
379 + }
380 +
381 + /**
382 + * 校验邮箱
383 + *
384 + * @param email
385 + * @return 校验通过返回true,否则返回false
386 + */
387 + public static boolean isEmail(String email) {
388 + return Pattern.matches(REGEX_EMAIL, email);
389 + }
390 +
391 + /**
392 + * 校验邮箱
393 + *
394 + * @param emailMulti
395 + * @return 逗号分隔的多个邮件地址都校验通过返回true,否则返回false
396 + */
397 + public static boolean isEmailMulti(String emailMulti) {
398 + String[] emailAttr = emailMulti.split(",");
399 + boolean isEmail = true;
400 + for (String email : emailAttr) {
401 + if (!isEmail(email)) {
402 + isEmail = false;
403 + }
404 + }
405 + return isEmail;
406 + }
407 +
408 + /**
409 + * List<Long> 转String 用于sql
410 + *
411 + * @param lists
412 + * @return
413 + */
414 + public static String listLongToStr(List<Long> lists) {
415 + StringBuffer str = new StringBuffer("");
416 + for (Long value : lists) {
417 + str.append(value).append(",");
418 + }
419 + return str.toString().substring(0, str.toString().lastIndexOf(","));
420 + }
421 +
422 + /**
423 + * List<Integer> 转String 用于sql
424 + *
425 + * @param lists
426 + * @return
427 + */
428 + public String listIntegerToStr(List<Integer> lists) {
429 + StringBuffer str = new StringBuffer("");
430 + for (Integer value : lists) {
431 + str.append(value).append(",");
432 + }
433 + return str.toString().substring(0, str.toString().lastIndexOf(","));
434 + }
435 +
436 + /**
437 + * List<String> 转String 用于sql
438 + *
439 + * @param lists
440 + * @return
441 + */
442 + public String listStringToStr(List<String> lists) {
443 + StringBuffer srt = new StringBuffer("");
444 + for (String value : lists) {
445 + srt.append("'").append(value).append("'").append(",");
446 + }
447 + return srt.toString().substring(0, srt.toString().lastIndexOf(","));
448 + }
449 +
450 + public static String getRandomString(int length) {
451 + return RandomStringUtils.randomAlphanumeric(length);
452 + }
453 +
454 + public static String[] splitForList(String str, String regex) {
455 + ArrayList resultStr = new ArrayList();
456 + if (!isEmptyWithTrim(str)) {
457 + String[] strs = str.split(regex);
458 + for (String s : strs) {
459 + if (!isEmptyWithTrim(s)) {
460 + resultStr.add(s.trim());
461 + }
462 + }
463 + }
464 + return (String[]) resultStr.toArray(new String[resultStr.size()]);
465 + }
466 +
467 + /**
468 + * 获取固定字节长度字符串
469 + * @param original
470 + * @param length
471 + * @return
472 + */
473 + public static String formatStringLength(String original, int length) {
474 + if (original == null) {
475 + original = "";
476 + }
477 + int newLength = original.getBytes().length;
478 + while (newLength > length) {
479 + original = original.substring(0,original.length() - 1);
480 + newLength = original.getBytes().length;
481 + }
482 + return original;
483 + }
484 +
485 + /**
486 + * 获取固定字节长度字符串
487 + * @param original
488 + * @param length
489 + * @return
490 + */
491 + public static String formatStringLength(String original, long length) {
492 + if (original == null) {
493 + original = "";
494 + }
495 + long newLength = original.getBytes().length;
496 + while (newLength > length) {
497 + original = original.substring(0, original.length() - 1);
498 + newLength = original.getBytes().length;
499 + }
500 + return original;
501 + }
502 +
503 + public static String autoCompletionStringAfterByZero(String _orig, long _length) {
504 + if (_orig == null) {
505 + _orig = "";
506 + }
507 + while (_orig.length() < _length) {
508 + _orig += "0";
509 + }
510 + return _orig;
511 + }
512 +
513 + public static String formatInteger(int num, int length) {
514 + String number = (new Integer(num)).toString();
515 + while (number.length() < length) {
516 + number = "0" + number;
517 + }
518 + return number;
519 + }
520 +
521 + /**
522 + * String List 转 String[]
523 + *
524 + * @param strList
525 + * @return
526 + */
527 + public static String[] listRotationArray(List<String> strList) {
528 + if (strList == null || strList.size() == 0) {
529 + return new String[]{""};
530 + }
531 + return (String[]) strList.toArray(new String[strList.size()]);
532 + }
533 +
534 + //如果不足9位置,那么前面补充0
535 + private String strFormat(int length, String strOrign, boolean isAfter, String str) {
536 + if (strOrign == null) {
537 + strOrign = "000000000";
538 + } else {
539 + strOrign = strOrign.trim();
540 + }
541 + while (strOrign.getBytes().length > length) {
542 + strOrign = strOrign.substring(0, strOrign.length() - 1);
543 + }
544 +
545 + //不够9为前面补0
546 + while (strOrign.getBytes().length < 9) {
547 + strOrign = "0" + strOrign;
548 + }
549 + //9位之后补空格
550 + while (strOrign.getBytes().length < length) {
551 + strOrign += " ";
552 + }
553 + return strOrign;
554 + }
555 +
556 + /**
557 + * 后补空格
558 + *
559 + * @param length
560 + * @param strOrign
561 + * @return
562 + */
563 + public static String strFormat(int length, String strOrign) {
564 + if (strOrign == null) {
565 + strOrign = " ";
566 + } else {
567 + strOrign = strOrign.trim();
568 + }
569 + while (strOrign.getBytes().length > length) {
570 + strOrign = strOrign.substring(0, strOrign.length() - 1);
571 + }
572 + //9位之后补空格
573 + while (strOrign.getBytes().length < length) {
574 + strOrign += " ";
575 + }
576 + return strOrign;
577 + }
578 +
579 + /**
580 + * Java实现按字节长度截取字符串
581 + * @param s
582 + * @param length
583 + * @return
584 + * @throws Exception
585 + */
586 + public static String bSubstring(String s, int length) throws Exception {
587 +
588 + byte[] bytes = s.getBytes("Unicode");
589 + int n = 0; // 表示当前的字节数
590 + int i = 2; // 要截取的字节数,从第3个字节开始
591 + for (; i < bytes.length && n < length; i++) {
592 + // 奇数位置,如3、5、7等,为UCS2编码中两个字节的第二个字节
593 + if (i % 2 == 1) {
594 + n++; // 在UCS2第二个字节时n加1
595 + } else {
596 + // 当UCS2编码的第一个字节不等于0时,该UCS2字符为汉字,一个汉字算两个字节
597 + if (bytes[i] != 0) {
598 + n++;
599 + }
600 + }
601 + }
602 + // 如果i为奇数时,处理成偶数
603 + if (i % 2 == 1) {
604 + // 该UCS2字符是汉字时,去掉这个截一半的汉字
605 + if (bytes[i - 1] != 0) {
606 + i = i - 1;
607 + } else {
608 + // 该UCS2字符是字母或数字,则保留该字符
609 + i = i + 1;
610 + }
611 + }
612 + return new String(bytes, 0, i, "Unicode");
613 + }
614 +
615 + /**
616 + * 获取固定字节长度字符串
617 + * @param length
618 + * @param strOrign
619 + * @param strFix
620 + * @return
621 + */
622 + public static String strLengthFormatNew(int length, String strOrign, String strFix) {
623 + strOrign = strOrign == null ? strFix : strOrign.trim();
624 + StringBuffer resultStrBuffer = null;
625 + if (strOrign.getBytes().length > length) {
626 + strOrign = strOrign.substring(0, length);
627 + while (resultStrBuffer.toString().getBytes().length > length) {
628 +// strOrign = strOrign.substring(0, strOrign.length() - 1);
629 + strOrign = strOrign.substring(0, length);
630 + }
631 + resultStrBuffer = new StringBuffer(strOrign);
632 + } else {
633 + resultStrBuffer = new StringBuffer(strOrign);
634 + //9位之后补空格
635 + while (resultStrBuffer.toString().getBytes().length < length) {
636 + resultStrBuffer.append(strFix);
637 + }
638 + }
639 + return resultStrBuffer.toString();
640 + }
641 +
642 +
643 + /**
644 + * @param length
645 + * @param strOrign
646 + * @return
647 + */
648 + @Deprecated
649 + public static String strLengthFormat(int length, String strOrign, String strFix) {
650 + if (strOrign == null) {
651 + strOrign = " ";
652 + } else {
653 + strOrign = strOrign.trim();
654 + }
655 + while (strOrign.getBytes().length > length) {
656 +// strOrign = strOrign.substring(0, strOrign.length() - 1);
657 + strOrign = strOrign.substring(0, length);
658 + }
659 + //9位之后补空格
660 + while (strOrign.getBytes().length < length) {
661 + strOrign += strFix;
662 + }
663 + return strOrign;
664 + }
665 +
666 + /**
667 + * 前面补数据
668 + *
669 + * @param length
670 + * @param strOrign
671 + * @return
672 + */
673 + public static String strFrontFormat(int length, String strOrign, String strFix) {
674 + if (strOrign == null) {
675 + strOrign = " ";
676 + } else {
677 + strOrign = strOrign.trim();
678 + }
679 + while (strOrign.getBytes().length > length) {
680 +// strOrign = strOrign.substring(0, strOrign.length() - 1);
681 + strOrign = strOrign.substring(0, length);
682 + }
683 + //前面补零
684 + while (strOrign.getBytes().length < length) {
685 + strOrign = strFix + strOrign;
686 + }
687 + return strOrign;
688 + }
689 +
690 + /**
691 + * 前面补数据
692 + *
693 + * @param length
694 + * @param strOrign
695 + * @return
696 + */
697 + public static String strFrontFormatNew(int length, String strOrign, String strFix) {
698 + strOrign = strOrign == null ? strFix : strOrign.trim();
699 + if (strOrign == null) {
700 + strOrign = " ";
701 + } else {
702 + strOrign = strOrign.trim();
703 + }
704 + while (strOrign.getBytes().length > length) {
705 +// strOrign = strOrign.substring(0, strOrign.length() - 1);
706 + strOrign = strOrign.substring(0, length);
707 + }
708 + //前面补零
709 + while (strOrign.getBytes().length < length) {
710 + strOrign = strFix + strOrign;
711 + }
712 + return strOrign;
713 + }
714 +
715 + /**
716 + * sql in查询条件数量分割
717 + *
718 + * @param orignList
719 + * @param splitCount
720 + * @return
721 + */
722 + public static List<List> listSplit(List orignList, int splitCount) {
723 + List<List> resultList = new ArrayList<>();
724 + if (orignList == null || orignList.isEmpty()) {
725 + resultList = null;
726 + } else {
727 + int orignListSize = orignList.size();
728 + int cycleTimes = (orignListSize + splitCount - 1) / splitCount;
729 + for (int i = 1; i <= cycleTimes; i++) {
730 + List list = orignList.subList(splitCount * (i - 1), (splitCount * i > orignListSize ? orignListSize : splitCount * i));
731 + resultList.add(list);
732 + }
733 + }
734 + return resultList;
735 + }
736 +
737 + public static String valueOf(Object obj) {
738 + return (obj == null || obj.toString().trim().equals("")) ? null : obj.toString();
739 + }
740 +
741 + public static String formatStringLaterSpace(String original, long length) {
742 + String result = "";
743 + long bytes = 0;
744 + int index = 0;
745 + while (bytes < length) {
746 + String s = " ";
747 + if (index < original.length()) {
748 + s = original.substring(index, index + 1);
749 + }
750 + bytes += s.getBytes().length;
751 + if (bytes > length) {
752 + for (int i = 0; i < bytes - length; i++) {
753 + result += " ";
754 + }
755 + } else {
756 + result += s;
757 + }
758 + index++;
759 + }
760 + return result;
761 + }
762 +
763 + /**
764 + * BigDecimal 格式化
765 + * @param value
766 + * @param wholeLength --整数位
767 + * @param decimalLength --小数位
768 + * @return
769 + */
770 + public static String formatBigDecimal(BigDecimal value, long wholeLength, long decimalLength){
771 + String str = "" + value;
772 + if(!str.contains(".")){
773 + str = str + ".0" ;
774 + if(str.length() == 2){
775 + str = "0" + str;
776 + }
777 + }
778 + String[]arrays = str.split("\\.");
779 + //整数位格式化
780 + while (arrays[0].length() < wholeLength) {
781 + arrays[0] = "0" + arrays[0];
782 + }
783 + //小数位格式化
784 + while (arrays[1].length() < decimalLength) {
785 + arrays[1] = arrays[1] + "0";
786 + }
787 + return arrays[0] + "." + arrays[1];
788 + }
789 +
790 + /**
791 + * BigDecimal 格式化
792 + * @param value
793 + * @param type --小数位 舍入方式
794 + * @param wholeLength --整数位
795 + * @param decimalLength --小数位
796 + * @return
797 + */
798 + public static String formatBigDecimalNoPoint(BigDecimal value, int type,int wholeLength, int decimalLength){
799 + String str = value.setScale(decimalLength,type).toString();
800 + String[]arrays = str.split("\\.");
801 + //整数位格式化
802 + while (arrays[0].length() < wholeLength) {
803 + arrays[0] = "0" + arrays[0];
804 + }
805 + //小数位格式化
806 + while (arrays[1].length() < decimalLength) {
807 + arrays[1] = arrays[1] + "0";
808 + }
809 + return arrays[0] + arrays[1];
810 + }
811 +
812 + /**
813 + * BigDecimal 格式化
814 + * @param value
815 + * @param decimalLength --小数位
816 + * @return
817 + */
818 + public static String formatBigDecimalNew(BigDecimal value, int decimalLength){
819 + return formatBigDecimalNew(value,BigDecimal.ROUND_HALF_UP,19, decimalLength);
820 +
821 + }
822 +
823 + /**
824 + * BigDecimal 格式化
825 + * @param value
826 + * @param roundHalfType --小数位 舍入方式
827 + * @param wholeLength --整数位
828 + * @param decimalLength --小数位
829 + * @return
830 + */
831 + public static String formatBigDecimalNew(BigDecimal value, int roundHalfType,int wholeLength, int decimalLength){
832 + String result = "";
833 + if(value != null) {
834 + String valueNewStr = value.setScale(decimalLength,roundHalfType).toString();
835 + if(valueNewStr.length() > wholeLength){
836 + String[] valueNewArry = valueNewStr.split("\\.");
837 + if(valueNewArry[0].length() > wholeLength){
838 + result = valueNewArry[0].substring(wholeLength - 1) + "." + valueNewArry[1];
839 + } else {
840 + result = valueNewStr;
841 + }
842 + } else {
843 + result = valueNewStr;
844 + }
845 + }
846 + return result;
847 + }
848 +
849 + public static void main(String[] args){
850 + BigDecimal aa = new BigDecimal("111.9992440000600000");
851 + String valueNew = StringUtil.formatBigDecimalNew(aa,BigDecimal.ROUND_HALF_UP,3,5);
852 + String valueNew1 = StringUtil.formatBigDecimalNew(null,5);
853 + System.out.println(valueNew);
854 + System.out.println(valueNew1);
855 + }
856 +
857 +}
...@@ -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");
......