liuchaohui пре 2 година
родитељ
комит
2a8bc95ac4

+ 64 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/cost/service/impl/SyCostAllocationServiceImpl.java

@@ -194,6 +194,70 @@ public class SyCostAllocationServiceImpl extends ServiceImpl<SyCostAllocationMap
                 syCostAllocation.setProcessUnit(syCostAllocation.getProcessUnit()+","+objs.getProcessUnit());
             }
         }
+
+        //查询U8数据 面料
+        String sqlFabric = "SELECT cInvName as goodsName,sum(riQuantity) as usageQuantity,sum(biQuantity) as planQuantity,processUnit FROM (" +
+                "select c.cInvName ,sum(r.iQuantity) as riQuantity,r.cBatch ,b.cSource,b.cPOID,sum(b.iQuantity) as biQuantity,v.cVenName as processUnit" +
+                " FROM rdrecords11  r" +
+                "  JOIN (" +
+                "   SELECT od.MODetailsID,od.cInvCode,om.cVenCode  " +
+                "   FROM OM_MOMain om LEFT JOIN OM_MODetails od ON om.MOID = od.MOID " +
+                "   WHERE om.cState = 1 and om.cCode like '"+plannum+"%'" +
+                "   ) o ON r.iOMoDID  = o.MODetailsID " +
+                "  LEFT JOIN (SELECT * FROM  Inventory where (cInvCCode like '03%' or cInvCCode like '04%'  ) and cInvCCode != '0399' and cInvCCode != '0499') c on c.cInvCode=r.cInvCode" +
+                " LEFT JOIN Vendor v ON o.cVenCode= v.cVenCode "+
+                "  LEFT JOIN (" +
+                "    SELECT r1.cSource,rs1.cBatch,rs1.cInvCode ,rs1.cPOID,rs1.iQuantity" +
+                "    FROM rdrecords01 rs1 join rdrecord01 r1 on r1.id=rs1.id" +
+                "    ) b on r.cBatch = b.cBatch and b.cInvCode=r.cInvCode " +
+                "  GROUP BY c.cInvName,r.cBatch,b.cSource,b.cPOID,v.cVenName ) as ta GROUP BY cInvName,processUnit";
+        List<Map<String, Object>> list1  = senYuDataSourceOne.queryForList(sqlFabric);
+        List<JSONObject> jianSon1 = JsonChangeUtils.toJSONObject(list1);
+        List<SyCostAllocationFabric> list3 = new ArrayList<>();
+        for (int i=0;i<jianSon1.size();i++) {
+            SyCostAllocationFabric Fabric = JSONObject.toJavaObject(jianSon1.get(i), SyCostAllocationFabric.class);
+            list3.add(Fabric);
+        }
+
+
+        //查询U8数据 面料
+        String sqlIngredient = "SELECT cInvName as goodsName,sum(riQuantity) as usageQuantity,sum(biQuantity) as planQuantity,processUnit FROM (" +
+                "select c.cInvName ,sum(r.iQuantity) as riQuantity,r.cBatch ,b.cSource,b.cPOID,sum(b.iQuantity) as biQuantity,v.cVenName as processUnit" +
+                " FROM rdrecords11  r" +
+                "  JOIN (" +
+                "   SELECT od.MODetailsID,od.cInvCode,om.cVenCode " +
+                "   FROM OM_MOMain om LEFT JOIN OM_MODetails od ON om.MOID = od.MOID " +
+                "   WHERE om.cState = 1 and om.cCode like '"+plannum+"%'" +
+                "   ) o ON r.iOMoDID  = o.MODetailsID " +
+                "  LEFT JOIN (SELECT * FROM  Inventory where (cInvCCode like '05%' or cInvCCode like '06%' or cInvCCode like '07%' ) ) c on c.cInvCode=r.cInvCode" +
+                " LEFT JOIN Vendor v ON o.cVenCode= v.cVenCode "+
+                "  LEFT JOIN (" +
+                "    SELECT r1.cSource,rs1.cBatch,rs1.cInvCode ,rs1.cPOID,rs1.iQuantity" +
+                "    FROM rdrecords01 rs1 join rdrecord01 r1 on r1.id=rs1.id" +
+                "    ) b on r.cBatch = b.cBatch and b.cInvCode=r.cInvCode " +
+                "  GROUP BY c.cInvName,r.cBatch,b.cSource,b.cPOID,v.cVenName ) as ta GROUP BY cInvName,processUnit";
+        List<Map<String, Object>> list2  = senYuDataSourceOne.queryForList(sqlIngredient);
+        List<JSONObject> jianSon2 = JsonChangeUtils.toJSONObject(list2);
+        List<SyCostAllocationIngredient> list4 = new ArrayList<>();
+        for (int i=0;i<jianSon2.size();i++) {
+            SyCostAllocationIngredient Ingredient = JSONObject.toJavaObject(jianSon2.get(i), SyCostAllocationIngredient.class);
+            list4.add(Ingredient);
+        }
+
+        List<JSONObject> processUnitList=new ArrayList<>();//子表数据_加工单位集合
+        //获取主表加工单位,拆分获取对应数据
+        String[] processUnit=syCostAllocation.getProcessUnit().split(",");
+        for(int i=0;i<processUnit.length;i++){
+            String unit=processUnit[i];
+            JSONObject jSONObject=new JSONObject();
+            List<SyCostAllocationFabric> list3b = list3.stream().filter(t -> t.getProcessUnit().equals(unit)).collect(Collectors.toList());
+            List<SyCostAllocationIngredient> list4b = list4.stream().filter(t -> t.getProcessUnit().equals(unit)).collect(Collectors.toList());
+            jSONObject.put("syCostAllocationFabricList", list3b);
+            jSONObject.put("syCostAllocationIngredientList",list4b);
+            processUnitList.add(jSONObject);
+        }
+        syCostAllocation.setProcessUnitList(processUnitList);
+
         syCostAllocation.setPlanNum("");
         return syCostAllocation;
     }