Merge branch 'CY23-PI01-接口CN5000-01' into API-2023-07-30
Showing
4 changed files
with
80 additions
and
1 deletions
| 1 | package com.erry.iclear.dateInterface.api; | 1 | package com.erry.iclear.dateInterface.api; |
| 2 | 2 | ||
| 3 | +import com.erry.iclear.dateInterface.api.request.MawbDetail; | ||
| 3 | import com.erry.iclear.dateInterface.enums.ErrorCodeEnum; | 4 | import com.erry.iclear.dateInterface.enums.ErrorCodeEnum; |
| 4 | import com.erry.iclear.dateInterface.api.request.Mawb; | 5 | import com.erry.iclear.dateInterface.api.request.Mawb; |
| 5 | import com.erry.iclear.dateInterface.api.response.ResultRS; | 6 | import com.erry.iclear.dateInterface.api.response.ResultRS; |
| ... | @@ -115,6 +116,13 @@ public class CustomsDataInterface { | ... | @@ -115,6 +116,13 @@ public class CustomsDataInterface { |
| 115 | if(!result.getSuccess()){ | 116 | if(!result.getSuccess()){ |
| 116 | return result; | 117 | return result; |
| 117 | } | 118 | } |
| 119 | + | ||
| 120 | + //校验单据币制 | ||
| 121 | + result = mawbService.checkCurrency(mawb); | ||
| 122 | + if(!result.getSuccess()){ | ||
| 123 | + return result; | ||
| 124 | + } | ||
| 125 | + | ||
| 118 | sw.stop(); | 126 | sw.stop(); |
| 119 | 127 | ||
| 120 | // //3、TODO 校验子单 | 128 | // //3、TODO 校验子单 | ... | ... |
| ... | @@ -27,7 +27,8 @@ public enum ErrorCodeEnum { | ... | @@ -27,7 +27,8 @@ public enum ErrorCodeEnum { |
| 27 | ERROR_30102("30102","hscode编码字段长度超过2000字符"), | 27 | ERROR_30102("30102","hscode编码字段长度超过2000字符"), |
| 28 | ERROR_30103("30103","skuCode与skuName必须传递一项"), | 28 | ERROR_30103("30103","skuCode与skuName必须传递一项"), |
| 29 | ERROR_30104("30104","skuCode或skuName长度超出限制"), | 29 | ERROR_30104("30104","skuCode或skuName长度超出限制"), |
| 30 | - ERROR_30105("30105","skuCode编码最少输入4位字符,skuName最少输入2个字符"); | 30 | + ERROR_30105("30105","skuCode编码最少输入4位字符,skuName最少输入2个字符"), |
| 31 | + ERROR_30106("30106","此申报{columnName}币制不在海关要求的范围内 请修改!"); | ||
| 31 | 32 | ||
| 32 | 33 | ||
| 33 | ErrorCodeEnum(String code,String name){ | 34 | ErrorCodeEnum(String code,String name){ | ... | ... |
| 1 | package com.erry.iclear.dateInterface.service; | 1 | package com.erry.iclear.dateInterface.service; |
| 2 | 2 | ||
| 3 | //import cn.hutool.core.date.DateUtil; | 3 | //import cn.hutool.core.date.DateUtil; |
| 4 | +import com.erry.iclear.dateInterface.api.request.MawbDetail; | ||
| 4 | import com.erry.iclear.dateInterface.enums.ErrorCodeEnum; | 5 | import com.erry.iclear.dateInterface.enums.ErrorCodeEnum; |
| 5 | import com.erry.iclear.dateInterface.api.request.FedexMawb; | 6 | import com.erry.iclear.dateInterface.api.request.FedexMawb; |
| 6 | import com.erry.iclear.dateInterface.api.request.FedexReceipt; | 7 | import com.erry.iclear.dateInterface.api.request.FedexReceipt; |
| ... | @@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ... | @@ -19,6 +20,7 @@ import org.springframework.beans.factory.annotation.Autowired; |
| 19 | import org.springframework.stereotype.Service; | 20 | import org.springframework.stereotype.Service; |
| 20 | 21 | ||
| 21 | import javax.transaction.Transactional; | 22 | import javax.transaction.Transactional; |
| 23 | +import javax.validation.Valid; | ||
| 22 | import java.text.ParseException; | 24 | import java.text.ParseException; |
| 23 | import java.text.SimpleDateFormat; | 25 | import java.text.SimpleDateFormat; |
| 24 | import java.util.ArrayList; | 26 | import java.util.ArrayList; | ... | ... |
| 1 | package com.erry.iclear.dateInterface.service; | 1 | package com.erry.iclear.dateInterface.service; |
| 2 | 2 | ||
| 3 | +import com.erry.iclear.dateInterface.common.Constant; | ||
| 4 | +import com.erry.iclear.dateInterface.entity.DictionaryEntries; | ||
| 3 | import com.erry.iclear.dateInterface.enums.ErrorCodeEnum; | 5 | import com.erry.iclear.dateInterface.enums.ErrorCodeEnum; |
| 4 | import com.erry.iclear.dateInterface.api.request.Mawb; | 6 | import com.erry.iclear.dateInterface.api.request.Mawb; |
| 5 | import com.erry.iclear.dateInterface.api.request.MawbDetail; | 7 | import com.erry.iclear.dateInterface.api.request.MawbDetail; |
| ... | @@ -7,12 +9,14 @@ import com.erry.iclear.dateInterface.api.response.IClearCheckResult; | ... | @@ -7,12 +9,14 @@ import com.erry.iclear.dateInterface.api.response.IClearCheckResult; |
| 7 | import com.erry.iclear.dateInterface.api.response.ResultRS; | 9 | import com.erry.iclear.dateInterface.api.response.ResultRS; |
| 8 | import com.erry.iclear.dateInterface.entity.ChmConsignment; | 10 | import com.erry.iclear.dateInterface.entity.ChmConsignment; |
| 9 | import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail; | 11 | import com.erry.iclear.dateInterface.entity.ChmConsignmentDetail; |
| 12 | +import com.erry.iclear.dateInterface.repository.DictionaryEntriesRepository; | ||
| 10 | import com.erry.iclear.dateInterface.repository.MawbRepository; | 13 | import com.erry.iclear.dateInterface.repository.MawbRepository; |
| 11 | import com.erry.iclear.dateInterface.util.HttpUtils; | 14 | import com.erry.iclear.dateInterface.util.HttpUtils; |
| 12 | import com.erry.iclear.dateInterface.util.JsonToJava; | 15 | import com.erry.iclear.dateInterface.util.JsonToJava; |
| 13 | import com.erry.iclear.dateInterface.util.StringUtil; | 16 | import com.erry.iclear.dateInterface.util.StringUtil; |
| 14 | import com.google.gson.Gson; | 17 | import com.google.gson.Gson; |
| 15 | import lombok.extern.slf4j.Slf4j; | 18 | import lombok.extern.slf4j.Slf4j; |
| 19 | +import org.apache.commons.lang3.StringUtils; | ||
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 20 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | import org.springframework.beans.factory.annotation.Value; | 21 | import org.springframework.beans.factory.annotation.Value; |
| 18 | import org.springframework.stereotype.Service; | 22 | import org.springframework.stereotype.Service; |
| ... | @@ -40,6 +44,9 @@ public class MawbService { | ... | @@ -40,6 +44,9 @@ public class MawbService { |
| 40 | @Autowired | 44 | @Autowired |
| 41 | private ChmConsignmentDetailService consignmentDetailService; | 45 | private ChmConsignmentDetailService consignmentDetailService; |
| 42 | 46 | ||
| 47 | + @Autowired | ||
| 48 | + private DictionaryEntriesRepository dictionaryEntriesRepository; | ||
| 49 | + | ||
| 43 | /** | 50 | /** |
| 44 | * 保存主单Request | 51 | * 保存主单Request |
| 45 | * @param mawb | 52 | * @param mawb |
| ... | @@ -165,6 +172,67 @@ public class MawbService { | ... | @@ -165,6 +172,67 @@ public class MawbService { |
| 165 | } | 172 | } |
| 166 | return ""; | 173 | return ""; |
| 167 | } | 174 | } |
| 175 | + /** | ||
| 176 | + * 检查成交币制在系统中是否有效 Constant.CURRENCY_SYSTEM+ mawbDetail.getTradeCurr(); | ||
| 177 | + * 成交币制 TradeCurr | ||
| 178 | + * 杂费币制 OtherCurr | ||
| 179 | + * 运费币制 FeeCurr | ||
| 180 | + * 保费币制 InsurCurr | ||
| 181 | + * | ||
| 182 | + */ | ||
| 183 | + public ResultRS checkCurrency(Mawb mawb){ | ||
| 184 | + ResultRS result = new ResultRS(Boolean.TRUE,null,null,null); | ||
| 185 | + | ||
| 186 | + String feeCurr = mawb.getFeeCurr(); | ||
| 187 | + DictionaryEntries feeCurrDict = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM + feeCurr); | ||
| 188 | + | ||
| 189 | + String otherCurr = mawb.getOtherCurr(); | ||
| 190 | + DictionaryEntries otherCurrDict = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM + otherCurr); | ||
| 191 | + | ||
| 192 | + String insurCurr = mawb.getInsurCurr(); | ||
| 193 | + DictionaryEntries insurCurrDict = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM + insurCurr); | ||
| 194 | + | ||
| 195 | + //运费币制检查 | ||
| 196 | + if (StringUtils.isNotEmpty(feeCurr) && Objects.isNull(feeCurrDict) ){ | ||
| 197 | + result.setSuccess(Boolean.FALSE); | ||
| 198 | + result.setCode(ErrorCodeEnum.ERROR_30106.getCode()); | ||
| 199 | + result.setMsg(ErrorCodeEnum.ERROR_30106.getName().replace("{columnName}","运费")); | ||
| 200 | + return result; | ||
| 201 | + } | ||
| 202 | + | ||
| 203 | + //杂费币制检查 | ||
| 204 | + if (StringUtils.isNotEmpty(otherCurr) && Objects.isNull(otherCurrDict) ){ | ||
| 205 | + result.setSuccess(Boolean.FALSE); | ||
| 206 | + result.setCode(ErrorCodeEnum.ERROR_30106.getCode()); | ||
| 207 | + result.setMsg(ErrorCodeEnum.ERROR_30106.getName().replace("{columnName}","杂费")); | ||
| 208 | + return result; | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + //保费币制检查 | ||
| 212 | + if (StringUtils.isNotEmpty(insurCurr) && Objects.isNull(insurCurrDict) ){ | ||
| 213 | + result.setSuccess(Boolean.FALSE); | ||
| 214 | + result.setCode(ErrorCodeEnum.ERROR_30106.getCode()); | ||
| 215 | + result.setMsg(ErrorCodeEnum.ERROR_30106.getName().replace("{columnName}","保费")); | ||
| 216 | + return result; | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + //申报币制检查 | ||
| 220 | + List<MawbDetail> mawbDetailList = mawb.getMawbDetailList(); | ||
| 221 | + for (int i = 0, maxi = mawbDetailList.size(); i < maxi; i++) { | ||
| 222 | + MawbDetail mawbDetail = mawbDetailList.get(i); | ||
| 223 | + String tradeCurr = mawbDetail.getTradeCurr(); | ||
| 224 | + DictionaryEntries tradeCurrDict = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM + tradeCurr); | ||
| 225 | + if((StringUtils.isNotEmpty(tradeCurr) && Objects.isNull(tradeCurrDict))){ | ||
| 226 | + result.setSuccess(Boolean.FALSE); | ||
| 227 | + result.setCode(ErrorCodeEnum.ERROR_30106.getCode()); | ||
| 228 | + result.setMsg(ErrorCodeEnum.ERROR_30106.getName().replace("{columnName}","")); | ||
| 229 | + break; | ||
| 230 | + } | ||
| 231 | + } | ||
| 232 | + | ||
| 233 | + return result; | ||
| 234 | + } | ||
| 235 | + | ||
| 168 | 236 | ||
| 169 | /** | 237 | /** |
| 170 | * 校验主单 | 238 | * 校验主单 | ... | ... |
-
Please register or login to post a comment