Jiaqi.xu

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

......@@ -145,7 +145,7 @@ public class ChmConsignmentDetailService {
//商品编号
result.setSkuCode(mawbDetail.getCodeTS());
//申报总价
result.setAmount(mawbDetail.getDeclTotal());
result.setAmount(bigDecimalFormat(mawbDetail.getDeclTotal()));
//第一计量单位(法定单位)
DictionaryEntries firstUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getFirstUnit());
if(!Objects.equals(firstUnitDictionaryEntries,null)){
......@@ -153,7 +153,7 @@ public class ChmConsignmentDetailService {
result.setUnitLegalFirst(firstUnitDictionaryEntries.getChineseName());
}
//第一法定数量
result.setQtyLegalFirst(BigDecimal.valueOf(mawbDetail.getFirstQty().doubleValue()));
result.setQtyLegalFirst(bigDecimalFormat(BigDecimal.valueOf(mawbDetail.getFirstQty().doubleValue())));
//成交计量单位
//2021年7月8日 成交单位有修改,原取值第一法定计量单位,先取值成交单位。xjq
DictionaryEntries knockdownUnitEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getGunit());
......@@ -166,7 +166,7 @@ public class ChmConsignmentDetailService {
//商品名称
result.setSkuName(mawbDetail.getGname());
//成交数量
result.setKnockdownNumber(BigDecimal.valueOf(mawbDetail.getGqty().doubleValue()));
result.setKnockdownNumber(bigDecimalFormat(BigDecimal.valueOf(mawbDetail.getGqty().doubleValue())));
//第二计量单位
DictionaryEntries secondUnitDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.TRANSACTION_UNIT+ mawbDetail.getSecondUnit());
if(!Objects.equals(secondUnitDictionaryEntries,null)){
......@@ -174,14 +174,14 @@ public class ChmConsignmentDetailService {
result.setUnitLegalSecond(secondUnitDictionaryEntries.getChineseName());
}
//第二法定数量
result.setQtyLegalSecond(BigDecimal.valueOf(mawbDetail.getSecondQty().doubleValue()));
result.setQtyLegalSecond(bigDecimalFormat(BigDecimal.valueOf(mawbDetail.getSecondQty().doubleValue())));
//成交币制
DictionaryEntries currencyDictionaryEntries = Constant.dictionaryEntriesCache.get(Constant.CURRENCY_SYSTEM+ mawbDetail.getTradeCurr());
if(!Objects.equals(currencyDictionaryEntries,null)){
result.setCurrencyDic(currencyDictionaryEntries);
result.setCurrency(currencyDictionaryEntries.getChineseName());
}
result.setDeclaredWeight(mawbDetail.getDeclaredWeight());
result.setDeclaredWeight(bigDecimalFormat(mawbDetail.getDeclaredWeight()));
result.setDetailId(mawbDetail.getDetailId());
}catch (Exception e){
log.error("convertToChmConsignmentDetailBasf() error:"+e.getMessage());
......@@ -207,7 +207,7 @@ public class ChmConsignmentDetailService {
//申报单价 小数点保留4位
result.setDeclPrice(NumberUtils.bigDecimalFormat(detail.getOriRegion(),4));
//申报总价 小数点保留2位
result.setDeclTotal(NumberUtils.bigDecimalFormat(detail.getAmount(),2));
result.setDeclTotal(bigDecimalFormatD(NumberUtils.bigDecimalFormat(detail.getAmount(),2)));
//征免方式 数字一字码,0~9
if(!Objects.equals(detail.getLevyTypeDic(),null)){
result.setDutyMode(detail.getLevyTypeDic().getExt2());
......@@ -221,7 +221,7 @@ public class ChmConsignmentDetailService {
result.setFirstUnit(detail.getUnitLegalFirstId().getExt2());
}
//第一法定数量
result.setFirstQty(NumberUtils.bigDecimalToIntger(detail.getQtyLegalFirst()));
result.setFirstQty(NumberUtils.bigDecimalToIntger(bigDecimalFormatD(detail.getQtyLegalFirst())));
//成交计量单位 数字三字码
if(!Objects.equals(detail.getKnockdownUnitDic(),null)){
result.setGunit(detail.getKnockdownUnitDic().getExt2());
......@@ -233,7 +233,7 @@ public class ChmConsignmentDetailService {
//商品序号
result.setGno(gno);
//成交数量
result.setGqty(detail.getKnockdownNumber());
result.setGqty(bigDecimalFormatD(detail.getKnockdownNumber()));
//原产国 英文三字码
if(!Objects.equals(detail.getHabitatDic(),null)){
result.setOriginCountry(detail.getHabitatDic().getExt3());
......@@ -243,7 +243,7 @@ public class ChmConsignmentDetailService {
result.setSecondUnit(detail.getUnitLegalSecondId().getExt2());
}
//第二法定数量
result.setSecondQty(NumberUtils.bigDecimalToIntger(detail.getQtyLegalSecond()));
result.setSecondQty(NumberUtils.bigDecimalToIntger(bigDecimalFormatD(detail.getQtyLegalSecond())));
//成交币制 英文三字码
if(!Objects.equals(detail.getCurrencyDic(),null)){
result.setTradeCurr(detail.getCurrencyDic().getExt2());
......@@ -278,6 +278,33 @@ public class ChmConsignmentDetailService {
return result;
}
public BigDecimal bigDecimalFormat(BigDecimal num){
BigDecimal bdForMat = null;
if(num !=null){
bdForMat = num.setScale(2, BigDecimal.ROUND_HALF_UP);
if(bdForMat.compareTo(BigDecimal.ZERO) == 0){
bdForMat = new BigDecimal(0.01).setScale(2,BigDecimal.ROUND_HALF_UP);
}
}
return bdForMat;
}
/**
* D类运单小数处理
* @param num
* @return
*/
public BigDecimal bigDecimalFormatD(BigDecimal num){
BigDecimal bdForMat = null;
if(num !=null){
bdForMat = num.setScale(5, BigDecimal.ROUND_HALF_UP);
/*if(bdForMat.compareTo(BigDecimal.ZERO) == 0){
bdForMat = new BigDecimal(0.00001).setScale(5,BigDecimal.ROUND_HALF_UP);
}*/
}
return bdForMat;
}
public List<ChmConsignmentDetail> findChmConsignmentDetailListByConsignmentCode(Long consignmentId){
List<ChmConsignmentDetail> result = new ArrayList<>();
try{
......