|
@@ -566,7 +566,7 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
|
|
|
String cCode = "";
|
|
|
String cVouchID = "";
|
|
|
//获取单据号加1
|
|
|
- cCode= org.jeecg.modules.system.util.oConvertUtils.addOne(purchaseWarehousingMapper.getMaxCode("cSPVCode","SalePayVouch","dcreatesystime"));
|
|
|
+ cCode= org.jeecg.modules.system.util.oConvertUtils.addOne(purchaseWarehousingMapper.getMaxCode("cSPVCode","SalePayVouch","cSPVCode"));
|
|
|
//获取ID
|
|
|
id = org.jeecg.modules.system.util.oConvertUtils.addOne(purchaseWarehousingMapper.getMaxCode("ID","SalePayVouch","dcreatesystime"));
|
|
|
//单据id
|
|
@@ -598,14 +598,31 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
|
|
|
}
|
|
|
|
|
|
int ii = 0;
|
|
|
+ //记录运费总金额
|
|
|
+ Double sumMoney = 0.00;
|
|
|
+
|
|
|
+ Boolean boo = false;
|
|
|
+ //记录除以毛重的总金额
|
|
|
+ BigDecimal sumImoney = BigDecimal.ZERO;
|
|
|
|
|
|
try {
|
|
|
+ if(rmbList.size()!=0){
|
|
|
+ for (Map<String, Object> rmb : rmbList) {
|
|
|
+ sumMoney = sumMoney+Double.parseDouble(rmb.get("amount").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(usdList.size()!=0){
|
|
|
+ for (Map<String, Object> usd : usdList) {
|
|
|
+ sumMoney = sumMoney+Double.parseDouble(usd.get("amount").toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//业务场景
|
|
|
//一张托书有五个销售订单号,美元代币有三个,人民币代币有三个,此时需要生成30张销售费用支出单,每一个销售订单需要生成6个费用支出单,所以(5*6=30)
|
|
|
for(Map<String,Object> li: itemList){
|
|
|
|
|
|
if(rmbList.size()!=0) {
|
|
|
+
|
|
|
//人民币信息
|
|
|
for (Map<String, Object> rmb : rmbList) {
|
|
|
ii++;
|
|
@@ -650,8 +667,12 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
|
|
|
Map<String, Object> maps = new HashMap<>();
|
|
|
maps.put("cSPVCode", cCode);//销售支出单号
|
|
|
//金额 = 以销售订单号为维度计算对应销售订单号下的毛重合计数/总毛重“费用支出金额
|
|
|
- double money = Double.parseDouble(li.get("grossWeight").toString()) / Double.parseDouble(map1.get("totalGrossWeight").toString());
|
|
|
- maps.put("iMoney", money*Double.parseDouble(rmb.get("amount").toString()));
|
|
|
+ Double money = Double.parseDouble(li.get("grossWeight").toString()) / Double.parseDouble(map1.get("totalGrossWeight").toString());
|
|
|
+ BigDecimal imoney = new BigDecimal(money).multiply(new BigDecimal(rmb.get("amount").toString())).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ sumImoney = sumImoney.add(imoney);
|
|
|
+
|
|
|
+ // System.out.println("人民币:"+money);
|
|
|
+ maps.put("iMoney", imoney);
|
|
|
maps.put("cExpCode", rmb.get("itemColumn"));//项目编码
|
|
|
maps.put("ID", id);
|
|
|
maps.put("irowno", ii);//行号
|
|
@@ -703,8 +724,12 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
|
|
|
//添加子表信息
|
|
|
Map<String, Object> maps = new HashMap<>();
|
|
|
maps.put("cSPVCode", cCode);//销售支出单号
|
|
|
- double money = Double.parseDouble(li.get("grossWeight").toString()) / Double.parseDouble(map1.get("totalGrossWeight").toString());
|
|
|
- maps.put("iMoney", money*Double.parseDouble(usd.get("amount").toString()));
|
|
|
+ Double money = Double.parseDouble(li.get("grossWeight").toString()) / Double.parseDouble(map1.get("totalGrossWeight").toString());
|
|
|
+ BigDecimal imoney = new BigDecimal(money).multiply(new BigDecimal(usd.get("amount").toString())).setScale(2,BigDecimal.ROUND_HALF_UP);
|
|
|
+ sumImoney = sumImoney.add(imoney);
|
|
|
+
|
|
|
+ System.out.println("美元:"+money);
|
|
|
+ maps.put("iMoney", imoney);
|
|
|
maps.put("cExpCode",usd.get("itemColumn"));//项目编码
|
|
|
maps.put("ID", id);
|
|
|
maps.put("irowno", ii);//行号
|
|
@@ -713,6 +738,13 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ //判断算出来的金额是否跟运费合计金额相等
|
|
|
+ if(sumMoney - sumImoney.doubleValue() ==0){
|
|
|
+ }else{
|
|
|
+ BigDecimal mo = new BigDecimal(sumMoney).subtract(sumImoney).setScale(2,BigDecimal.ROUND_DOWN);
|
|
|
+ listmaps.get(listmaps.size()-1).put("iMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("iMoney").toString()).add(mo)));
|
|
|
+ }
|
|
|
+
|
|
|
//循环新增主表
|
|
|
for(Map<String,Object> ma:listmap){
|
|
|
syShippingOrderMapper.saveSalePayVouch(ma);
|