Jiaqi.xu

C类保存到业务表明细数量小数位两位;D类保存到业务表明细数量小数位五位

...@@ -145,7 +145,7 @@ public class ChmConsignmentDetailService { ...@@ -145,7 +145,7 @@ public class ChmConsignmentDetailService {
145 //商品编号 145 //商品编号
146 result.setSkuCode(mawbDetail.getCodeTS()); 146 result.setSkuCode(mawbDetail.getCodeTS());
147 //申报总价 147 //申报总价
148 - result.setAmount(mawbDetail.getDeclTotal()); 148 + result.setAmount(bigDecimalFormat(mawbDetail.getDeclTotal()));
149 //第一计量单位(法定单位) 149 //第一计量单位(法定单位)
150 DictionaryEntries firstUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getFirstUnit()); 150 DictionaryEntries firstUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getFirstUnit());
151 if(!Objects.equals(firstUnitDictionaryEntries,null)){ 151 if(!Objects.equals(firstUnitDictionaryEntries,null)){
...@@ -153,7 +153,7 @@ public class ChmConsignmentDetailService { ...@@ -153,7 +153,7 @@ public class ChmConsignmentDetailService {
153 result.setUnitLegalFirst(firstUnitDictionaryEntries.getChineseName()); 153 result.setUnitLegalFirst(firstUnitDictionaryEntries.getChineseName());
154 } 154 }
155 //第一法定数量 155 //第一法定数量
156 - result.setQtyLegalFirst(BigDecimal.valueOf(mawbDetail.getFirstQty().doubleValue())); 156 + result.setQtyLegalFirst(bigDecimalFormat(BigDecimal.valueOf(mawbDetail.getFirstQty().doubleValue())));
157 //成交计量单位 157 //成交计量单位
158 //2021年7月8日 成交单位有修改,原取值第一法定计量单位,先取值成交单位。xjq 158 //2021年7月8日 成交单位有修改,原取值第一法定计量单位,先取值成交单位。xjq
159 DictionaryEntries knockdownUnitEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getGunit()); 159 DictionaryEntries knockdownUnitEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getGunit());
...@@ -166,7 +166,7 @@ public class ChmConsignmentDetailService { ...@@ -166,7 +166,7 @@ public class ChmConsignmentDetailService {
166 //商品名称 166 //商品名称
167 result.setSkuName(mawbDetail.getGname()); 167 result.setSkuName(mawbDetail.getGname());
168 //成交数量 168 //成交数量
169 - result.setKnockdownNumber(BigDecimal.valueOf(mawbDetail.getGqty().doubleValue())); 169 + result.setKnockdownNumber(bigDecimalFormat(BigDecimal.valueOf(mawbDetail.getGqty().doubleValue())));
170 //第二计量单位 170 //第二计量单位
171 DictionaryEntries secondUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getSecondUnit()); 171 DictionaryEntries secondUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getSecondUnit());
172 if(!Objects.equals(secondUnitDictionaryEntries,null)){ 172 if(!Objects.equals(secondUnitDictionaryEntries,null)){
...@@ -174,14 +174,14 @@ public class ChmConsignmentDetailService { ...@@ -174,14 +174,14 @@ public class ChmConsignmentDetailService {
174 result.setUnitLegalSecond(secondUnitDictionaryEntries.getChineseName()); 174 result.setUnitLegalSecond(secondUnitDictionaryEntries.getChineseName());
175 } 175 }
176 //第二法定数量 176 //第二法定数量
177 - result.setQtyLegalSecond(BigDecimal.valueOf(mawbDetail.getSecondQty().doubleValue())); 177 + result.setQtyLegalSecond(bigDecimalFormat(BigDecimal.valueOf(mawbDetail.getSecondQty().doubleValue())));
178 //成交币制 178 //成交币制
179 DictionaryEntries currencyDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM+ mawbDetail.getTradeCurr()); 179 DictionaryEntries currencyDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM+ mawbDetail.getTradeCurr());
180 if(!Objects.equals(currencyDictionaryEntries,null)){ 180 if(!Objects.equals(currencyDictionaryEntries,null)){
181 result.setCurrencyDic(currencyDictionaryEntries); 181 result.setCurrencyDic(currencyDictionaryEntries);
182 result.setCurrency(currencyDictionaryEntries.getChineseName()); 182 result.setCurrency(currencyDictionaryEntries.getChineseName());
183 } 183 }
184 - result.setDeclaredWeight(mawbDetail.getDeclaredWeight()); 184 + result.setDeclaredWeight(bigDecimalFormat(mawbDetail.getDeclaredWeight()));
185 result.setDetailId(mawbDetail.getDetailId()); 185 result.setDetailId(mawbDetail.getDetailId());
186 }catch (Exception e){ 186 }catch (Exception e){
187 log.error("convertToChmConsignmentDetailBasf() error:"+e.getMessage()); 187 log.error("convertToChmConsignmentDetailBasf() error:"+e.getMessage());
...@@ -207,7 +207,7 @@ public class ChmConsignmentDetailService { ...@@ -207,7 +207,7 @@ public class ChmConsignmentDetailService {
207 //申报单价 小数点保留4位 207 //申报单价 小数点保留4位
208 result.setDeclPrice(NumberUtils.bigDecimalFormat(detail.getOriRegion(),4)); 208 result.setDeclPrice(NumberUtils.bigDecimalFormat(detail.getOriRegion(),4));
209 //申报总价 小数点保留2位 209 //申报总价 小数点保留2位
210 - result.setDeclTotal(NumberUtils.bigDecimalFormat(detail.getAmount(),2)); 210 + result.setDeclTotal(bigDecimalFormatD(NumberUtils.bigDecimalFormat(detail.getAmount(),2)));
211 //征免方式 数字一字码,0~9 211 //征免方式 数字一字码,0~9
212 if(!Objects.equals(detail.getLevyTypeDic(),null)){ 212 if(!Objects.equals(detail.getLevyTypeDic(),null)){
213 result.setDutyMode(detail.getLevyTypeDic().getExt2()); 213 result.setDutyMode(detail.getLevyTypeDic().getExt2());
...@@ -221,7 +221,7 @@ public class ChmConsignmentDetailService { ...@@ -221,7 +221,7 @@ public class ChmConsignmentDetailService {
221 result.setFirstUnit(detail.getUnitLegalFirstId().getExt2()); 221 result.setFirstUnit(detail.getUnitLegalFirstId().getExt2());
222 } 222 }
223 //第一法定数量 223 //第一法定数量
224 - result.setFirstQty(NumberUtils.bigDecimalToIntger(detail.getQtyLegalFirst())); 224 + result.setFirstQty(NumberUtils.bigDecimalToIntger(bigDecimalFormatD(detail.getQtyLegalFirst())));
225 //成交计量单位 数字三字码 225 //成交计量单位 数字三字码
226 if(!Objects.equals(detail.getKnockdownUnitDic(),null)){ 226 if(!Objects.equals(detail.getKnockdownUnitDic(),null)){
227 result.setGunit(detail.getKnockdownUnitDic().getExt2()); 227 result.setGunit(detail.getKnockdownUnitDic().getExt2());
...@@ -233,7 +233,7 @@ public class ChmConsignmentDetailService { ...@@ -233,7 +233,7 @@ public class ChmConsignmentDetailService {
233 //商品序号 233 //商品序号
234 result.setGno(gno); 234 result.setGno(gno);
235 //成交数量 235 //成交数量
236 - result.setGqty(detail.getKnockdownNumber()); 236 + result.setGqty(bigDecimalFormatD(detail.getKnockdownNumber()));
237 //原产国 英文三字码 237 //原产国 英文三字码
238 if(!Objects.equals(detail.getHabitatDic(),null)){ 238 if(!Objects.equals(detail.getHabitatDic(),null)){
239 result.setOriginCountry(detail.getHabitatDic().getExt3()); 239 result.setOriginCountry(detail.getHabitatDic().getExt3());
...@@ -243,7 +243,7 @@ public class ChmConsignmentDetailService { ...@@ -243,7 +243,7 @@ public class ChmConsignmentDetailService {
243 result.setSecondUnit(detail.getUnitLegalSecondId().getExt2()); 243 result.setSecondUnit(detail.getUnitLegalSecondId().getExt2());
244 } 244 }
245 //第二法定数量 245 //第二法定数量
246 - result.setSecondQty(NumberUtils.bigDecimalToIntger(detail.getQtyLegalSecond())); 246 + result.setSecondQty(NumberUtils.bigDecimalToIntger(bigDecimalFormatD(detail.getQtyLegalSecond())));
247 //成交币制 英文三字码 247 //成交币制 英文三字码
248 if(!Objects.equals(detail.getCurrencyDic(),null)){ 248 if(!Objects.equals(detail.getCurrencyDic(),null)){
249 result.setTradeCurr(detail.getCurrencyDic().getExt2()); 249 result.setTradeCurr(detail.getCurrencyDic().getExt2());
...@@ -278,6 +278,33 @@ public class ChmConsignmentDetailService { ...@@ -278,6 +278,33 @@ public class ChmConsignmentDetailService {
278 return result; 278 return result;
279 } 279 }
280 280
281 + public BigDecimal bigDecimalFormat(BigDecimal num){
282 + BigDecimal bdForMat = null;
283 + if(num !=null){
284 + bdForMat = num.setScale(2, BigDecimal.ROUND_HALF_UP);
285 + if(bdForMat.compareTo(BigDecimal.ZERO) == 0){
286 + bdForMat = new BigDecimal(0.01).setScale(2,BigDecimal.ROUND_HALF_UP);
287 + }
288 + }
289 + return bdForMat;
290 + }
291 +
292 + /**
293 + * D类运单小数处理
294 + * @param num
295 + * @return
296 + */
297 + public BigDecimal bigDecimalFormatD(BigDecimal num){
298 + BigDecimal bdForMat = null;
299 + if(num !=null){
300 + bdForMat = num.setScale(5, BigDecimal.ROUND_HALF_UP);
301 + /*if(bdForMat.compareTo(BigDecimal.ZERO) == 0){
302 + bdForMat = new BigDecimal(0.00001).setScale(5,BigDecimal.ROUND_HALF_UP);
303 + }*/
304 + }
305 + return bdForMat;
306 + }
307 +
281 public List<ChmConsignmentDetail> findChmConsignmentDetailListByConsignmentCode(Long consignmentId){ 308 public List<ChmConsignmentDetail> findChmConsignmentDetailListByConsignmentCode(Long consignmentId){
282 List<ChmConsignmentDetail> result = new ArrayList<>(); 309 List<ChmConsignmentDetail> result = new ArrayList<>();
283 try{ 310 try{
......