2 커밋 a106c645b8 ... 90dae7f192

작성자 SHA1 메시지 날짜
  zengtx 90dae7f192 Merge branch 'master' of http://139.196.39.194:9021/chenc/sen-yu-new-service 1 년 전
  zengtx 2e7f161d8b 托书推送调整 1 년 전

+ 146 - 148
jeecg-boot-module-system/src/main/java/org/jeecg/modules/documents/syShippingOrder/service/impl/SyShippingOrderServiceImpl.java

@@ -672,94 +672,92 @@ 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){
+        //一张托书有五个销售订单号,美元代币有三个,人民币代币有三个,此时需要生成30张销售费用支出单,每一个销售订单需要生成6个费用支出单
+
 
             if(rmbList.size()!=0) {
 
                 //人民币信息
                 for (Map<String, Object> rmb : rmbList) {
 
-                    String redisId = redisUtil.get("salerID").toString();
-                    int addId = Integer.parseInt(redisId)+1;
-                    String id = String.valueOf(addId);
-                    redisUtil.set("salerID",id);
-                    ii++;
-                    Map<String, Object> map = new HashMap<>();
-                    Map<String, Object> mapPo;
-
-                    String orderId = li.get("orderId").toString();
-                    if(orderId.indexOf("-") > 0){
-                        String idsplit[] = orderId.split("-");
-                        orderId = idsplit[0];
-                    }
+                    //记录除以毛重的总金额
+                    BigDecimal sumImoney = BigDecimal.ZERO;
 
-                    mapPo = syShippingOrderMapper.querySOMain(orderId.substring(3, orderId.length()));//li.get("orderId").toString()
+                    for(Map<String,Object> li: itemList){
 
-                    if (ii > 1) {
-                        cCode = org.jeecg.modules.system.util.oConvertUtils.addOne(cCode);
-                        //id = org.jeecg.modules.system.util.oConvertUtils.addOne(id);
-                        map.put("cSPVCode", cCode);//单据号
-                        map.put("ID", id);//ID
-                    } else {
-                        map.put("cSPVCode", cCode);//单据号
-                        map.put("ID", id);//ID
+                        String redisId = redisUtil.get("salerID").toString();
+                        int addId = Integer.parseInt(redisId)+1;
+                        String id = String.valueOf(addId);
+                        redisUtil.set("salerID",id);
+                        ii++;
+                        Map<String, Object> map = new HashMap<>();
+                        Map<String, Object> mapPo;
+
+                        String orderId = li.get("orderId").toString();
+                        if(orderId.indexOf("-") > 0){
+                            String idsplit[] = orderId.split("-");
+                            orderId = idsplit[0];
+                        }
+
+                        mapPo = syShippingOrderMapper.querySOMain(orderId.substring(3, orderId.length()));//li.get("orderId").toString()
+
+                        if (ii > 1) {
+                            cCode = org.jeecg.modules.system.util.oConvertUtils.addOne(cCode);
+                            //id = org.jeecg.modules.system.util.oConvertUtils.addOne(id);
+                            map.put("cSPVCode", cCode);//单据号
+                            map.put("ID", id);//ID
+                        } else {
+                            map.put("cSPVCode", cCode);//单据号
+                            map.put("ID", id);//ID
+                        }
+                        map.put("dDate", sf.format(new Date()));//日期
+                        map.put("cPersonCode", mapPo.get("cPersonCode"));//业务员
+                        map.put("cDepCode", mapPo.get("cDepCode"));//部门
+                        map.put("cCusCode", mapPo.get("cCusCode"));//客户简称
+                        map.put("cDefine10", map1.get("shippingOrderNumber"));//外销发票号
+                        map.put("cMaker", "进出口平台管理员");//制单人
+                        map.put("iSourceId", mapPo.get("ID"));//来源ID、
+                        map.put("cSourceCode", li.get("orderNumber"));//订单号
+                        map.put("cSOCode", li.get("orderNumber"));//订单号
+                        map.put("cnextsystem", "其他应付单");//单据流向
+                        map.put("iexchrate", "1");//汇率
+                        map.put("Cexch_Name", "人民币");
+                        map.put("iVTid", "57");
+                        map.put("cvencode", rmb.get("freightForwarder"));
+                        map.put("cSysBarCode", "||SA09|"+cCode);
+
+                        //添加子表信息
+                        Map<String, Object> maps = new HashMap<>();
+                        maps.put("cSPVCode", cCode);//销售支出单号
+                         //金额 = 以销售订单号为维度计算对应销售订单号下的毛重合计数/总毛重“费用支出金额
+                         Double money = Double.parseDouble(li.get("grossWeight").toString()) / Double.parseDouble(map1.get("totalGrossWeight").toString());
+                        Double  imoney = money * Double.parseDouble(rmb.get("amount").toString());
+
+                        maps.put("iMoney", df.format(imoney));
+                        maps.put("INatMoney", df.format(imoney));
+                        maps.put("cExpCode", rmb.get("itemColumn"));//项目编码
+                        maps.put("ID", id);
+                        maps.put("irowno", "1");//行号
+                        maps.put("cbSysBarCode", "||SA09|"+cCode+"|"+ii);
+                        if(imoney >= 0.01){
+                            sumImoney = sumImoney.add(new BigDecimal(df.format(imoney)));
+                            listmap.add(map);
+                            listmaps.add(maps);
+                        }
                     }
-                    map.put("dDate", sf.format(new Date()));//日期
-                    map.put("cPersonCode", mapPo.get("cPersonCode"));//业务员
-                    map.put("cDepCode", mapPo.get("cDepCode"));//部门
-                    map.put("cCusCode", mapPo.get("cCusCode"));//客户简称
-                    map.put("cDefine10", map1.get("shippingOrderNumber"));//外销发票号
-                    map.put("cMaker", "进出口平台管理员");//制单人
-                    map.put("iSourceId", mapPo.get("ID"));//来源ID、
-                    map.put("cSourceCode", li.get("orderNumber"));//订单号
-                    map.put("cSOCode", li.get("orderNumber"));//订单号
-                    map.put("cnextsystem", "其他应付单");//单据流向
-                    map.put("iexchrate", "1");//汇率
-                    map.put("Cexch_Name", "人民币");
-                    map.put("iVTid", "57");
-                    map.put("cvencode", rmb.get("freightForwarder"));
-                    map.put("cSysBarCode", "||SA09|"+cCode);
-
-
-
-                    //添加子表信息
-                    Map<String, Object> maps = new HashMap<>();
-                    maps.put("cSPVCode", cCode);//销售支出单号
-                     //金额 = 以销售订单号为维度计算对应销售订单号下的毛重合计数/总毛重“费用支出金额
-                     Double money = Double.parseDouble(li.get("grossWeight").toString()) / Double.parseDouble(map1.get("totalGrossWeight").toString());
-                    Double  imoney = money * Double.parseDouble(rmb.get("amount").toString());
-
-                    maps.put("iMoney", df.format(imoney));
-                    maps.put("INatMoney", df.format(imoney));
-                    maps.put("cExpCode", rmb.get("itemColumn"));//项目编码
-                    maps.put("ID", id);
-                    maps.put("irowno", "1");//行号
-                    maps.put("cbSysBarCode", "||SA09|"+cCode+"|"+ii);
-                    if(imoney >= 0.01){
-                        sumImoney = sumImoney.add(new BigDecimal(df.format(imoney)));
-                        listmap.add(map);
-                        listmaps.add(maps);
+                    BigDecimal sumMoney = new BigDecimal(rmb.get("amount").toString());
+                    if(sumMoney.compareTo(sumImoney) > 0){
+                        BigDecimal mo = sumMoney.subtract(sumImoney).setScale(2,BigDecimal.ROUND_HALF_UP);
+                        listmaps.get(listmaps.size()-1).put("iMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("iMoney").toString()).add(mo)));
+                        listmaps.get(listmaps.size()-1).put("INatMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("INatMoney").toString()).add(mo)));
+                    }else{
+                        BigDecimal mo = sumImoney.subtract(sumMoney).setScale(2,BigDecimal.ROUND_HALF_UP);
+                        listmaps.get(listmaps.size()-1).put("iMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("iMoney").toString()).subtract(mo)));
+                        listmaps.get(listmaps.size()-1).put("INatMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("INatMoney").toString()).subtract(mo)));
                     }
 
                 }
@@ -769,82 +767,83 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
                 int index = 0;
                 //美元信息
                 for (Map<String, Object> usd : usdList) {
-                    String redisId = redisUtil.get("salerID").toString();
-                    int addId = Integer.parseInt(redisId)+1;
-                    String id = String.valueOf(addId);
-                    redisUtil.set("salerID",id);
-                    ii++;
-                    Map<String, Object> map = new HashMap<>();
-                    Map<String, Object> mapPo;
-
-                    String orderId = li.get("orderId").toString();
-                    if(orderId.indexOf("-") > 0){
-                        String idsplit[] = orderId.split("-");
-                        orderId = idsplit[0];
-                    }
-                    mapPo = syShippingOrderMapper.querySOMain(orderId.substring(3, orderId.length()));//li.get("orderId").toString()
-
-                    if (ii > 1) {
-                        cCode = org.jeecg.modules.system.util.oConvertUtils.addOne(cCode);
-                        //id = org.jeecg.modules.system.util.oConvertUtils.addOne(id);
-                        map.put("cSPVCode", cCode);//单据号
-                        map.put("ID", id);//ID
-                    } else {
-                        map.put("cSPVCode", cCode);//单据号
-                        map.put("ID", id);//ID
-                    }
+                    //记录除以毛重的总金额
+                    BigDecimal sumImoney = BigDecimal.ZERO;
+
+                    for(Map<String,Object> li: itemList){
+
+                        String redisId = redisUtil.get("salerID").toString();
+                        int addId = Integer.parseInt(redisId)+1;
+                        String id = String.valueOf(addId);
+                        redisUtil.set("salerID",id);
+                        ii++;
+                        Map<String, Object> map = new HashMap<>();
+                        Map<String, Object> mapPo;
+
+                        String orderId = li.get("orderId").toString();
+                        if(orderId.indexOf("-") > 0){
+                            String idsplit[] = orderId.split("-");
+                            orderId = idsplit[0];
+                        }
+                        mapPo = syShippingOrderMapper.querySOMain(orderId.substring(3, orderId.length()));//li.get("orderId").toString()
+
+                        if (ii > 1) {
+                            cCode = org.jeecg.modules.system.util.oConvertUtils.addOne(cCode);
+                            //id = org.jeecg.modules.system.util.oConvertUtils.addOne(id);
+                            map.put("cSPVCode", cCode);//单据号
+                            map.put("ID", id);//ID
+                        } else {
+                            map.put("cSPVCode", cCode);//单据号
+                            map.put("ID", id);//ID
+                        }
 
-                    map.put("dDate", sf.format(new Date()));//日期
-                    map.put("cPersonCode", mapPo.get("cPersonCode"));//业务员
-                    map.put("cDepCode", mapPo.get("cDepCode"));//部门
-                    map.put("cCusCode", mapPo.get("cCusCode"));//客户简称
-                    map.put("cDefine10", map1.get("shippingOrderNumber"));//外销发票号
-                    map.put("cMaker", "进出口平台管理员");//制单人
-                    map.put("iSourceId", mapPo.get("ID"));//来源ID、
-                    map.put("cSourceCode", li.get("orderNumber"));//订单号li.get("orderNumber")
-                    map.put("cSOCode", li.get("orderNumber"));//订单号
-                    map.put("cnextsystem", "其他应付单");//单据流向
-                    map.put("iexchrate", nflat);//汇率
-                    map.put("Cexch_Name", "美元");
-                    map.put("iVTid", "57");//单据模板号
-                    map.put("cvencode", usd.get("freightForwarder"));
-                    map.put("cSysBarCode", "||SA09|"+cCode);
-
-
-                    //添加子表信息
-                    Map<String, Object> maps = new HashMap<>();
-                    maps.put("cSPVCode", cCode);//销售支出单号
-                    Double money = Double.parseDouble(li.get("grossWeight").toString()) / Double.parseDouble(map1.get("totalGrossWeight").toString());
-                    Double  imoney = money * Double.parseDouble(usd.get("amount").toString());
-
-                    maps.put("cbSysBarCode", "||SA09|"+cCode+"|"+ii);
-                    Double usdMoney = Double.parseDouble(df.format(imoney))*Double.parseDouble(nflat);
-                    maps.put("INatMoney", df.format(usdMoney));
-//                    System.out.println("调整前:"+df.format(imoney*Double.parseDouble(nflat)));
-//                    System.out.println("调整后:"+df.format(usdMoney));
-                    maps.put("iMoney", df.format(imoney));
-                    maps.put("cExpCode",usd.get("itemColumn"));//项目编码
-                    maps.put("ID", id);
-                    maps.put("irowno", "1");//行号
-                    if(imoney >= 0.01){
-                        sumImoney = sumImoney.add(new BigDecimal(df.format(imoney)));
-                        listmap.add(map);
-                        listmaps.add(maps);
+                        map.put("dDate", sf.format(new Date()));//日期
+                        map.put("cPersonCode", mapPo.get("cPersonCode"));//业务员
+                        map.put("cDepCode", mapPo.get("cDepCode"));//部门
+                        map.put("cCusCode", mapPo.get("cCusCode"));//客户简称
+                        map.put("cDefine10", map1.get("shippingOrderNumber"));//外销发票号
+                        map.put("cMaker", "进出口平台管理员");//制单人
+                        map.put("iSourceId", mapPo.get("ID"));//来源ID、
+                        map.put("cSourceCode", li.get("orderNumber"));//订单号li.get("orderNumber")
+                        map.put("cSOCode", li.get("orderNumber"));//订单号
+                        map.put("cnextsystem", "其他应付单");//单据流向
+                        map.put("iexchrate", nflat);//汇率
+                        map.put("Cexch_Name", "美元");
+                        map.put("iVTid", "57");//单据模板号
+                        map.put("cvencode", usd.get("freightForwarder"));
+                        map.put("cSysBarCode", "||SA09|"+cCode);
+
+                        //添加子表信息
+                        Map<String, Object> maps = new HashMap<>();
+                        maps.put("cSPVCode", cCode);//销售支出单号
+                        Double money = Double.parseDouble(li.get("grossWeight").toString()) / Double.parseDouble(map1.get("totalGrossWeight").toString());
+                        Double  imoney = money * Double.parseDouble(usd.get("amount").toString());
+                        maps.put("cbSysBarCode", "||SA09|"+cCode+"|"+ii);
+                        Double usdMoney = Double.parseDouble(df.format(imoney))*Double.parseDouble(nflat);
+                        maps.put("INatMoney", df.format(usdMoney));
+                        maps.put("iMoney", df.format(imoney));
+                        maps.put("cExpCode",usd.get("itemColumn"));//项目编码
+                        maps.put("ID", id);
+                        maps.put("irowno", "1");//行号
+                        if(imoney >= 0.01){
+                            sumImoney = sumImoney.add(new BigDecimal(df.format(imoney)));
+                            listmap.add(map);
+                            listmaps.add(maps);
+                        }
+                    }
+                    BigDecimal sumMoney = new BigDecimal(usd.get("amount").toString());
+                    if(sumMoney.compareTo(sumImoney) > 0){
+                        BigDecimal mo = sumMoney.subtract(sumImoney).setScale(2,BigDecimal.ROUND_HALF_UP);
+                        listmaps.get(listmaps.size()-1).put("iMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("iMoney").toString()).add(mo)));
+                        listmaps.get(listmaps.size()-1).put("INatMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("INatMoney").toString()).add(mo)));
+                    }else{
+                        BigDecimal mo = sumImoney.subtract(sumMoney).setScale(2,BigDecimal.ROUND_HALF_UP);
+                        listmaps.get(listmaps.size()-1).put("iMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("iMoney").toString()).subtract(mo)));
+                        listmaps.get(listmaps.size()-1).put("INatMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("INatMoney").toString()).subtract(mo)));
                     }
-
-
-                }
             }
         }
 
-        //判断算出来的金额是否跟运费合计金额相等
-            if(sumMoney - sumImoney.doubleValue() ==0){
-            }else{
-                BigDecimal mo = new BigDecimal(sumMoney).subtract(sumImoney).setScale(2,BigDecimal.ROUND_HALF_UP);
-                listmaps.get(listmaps.size()-1).put("iMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("iMoney").toString()).add(mo)));
-                listmaps.get(listmaps.size()-1).put("INatMoney",(new BigDecimal(listmaps.get(listmaps.size()-1).get("INatMoney").toString()).add(mo)));
-            }
-
             //循环新增主表
             for(Map<String,Object> ma:listmap){
                 syShippingOrderMapper.saveSalePayVouch(ma);
@@ -858,8 +857,7 @@ public class SyShippingOrderServiceImpl extends ServiceImpl<SyShippingOrderMappe
             //修改最大编码
             purchaseWarehousingMapper.updateVoucherHistoryCNumber(cCode,"09");
 
-            //修改最大ID
-            //syShippingOrderMapper.updateUaIdentity(id,itemList.get(0).get("pkOrg").toString());
+
 
         }catch (Exception e){
             e.printStackTrace();