瀏覽代碼

调拨单 结算单

chenchuang 2 年之前
父節點
當前提交
61b78e0036

+ 3 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/mapper/PurchaseWarehousingMapper.java

@@ -119,7 +119,9 @@ public interface PurchaseWarehousingMapper extends BaseMapper<PurchaseWarehousin
      * @Param [rowmId]
      * @return java.math.BigDecimal
      */
-    Map<String,Object> getRdrecords01WriteQuantity(@Param("rowmId")String rowmId);
+    BigDecimal getRdrecords01WriteQuantity(@Param("rowmId")String rowmId);
+
+    List<Map<String,Object>> getRdrecords01Entity(@Param("rowmId")String rowmId);
 
     /**
      * @Author chenchuang

+ 14 - 4
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/mapper/xml/PurchaseWarehousingMapper.xml

@@ -268,7 +268,7 @@
         iRdsID,<!--蓝字入库单子表id-->
         bAccount,
         crdcvencode,<!--入库单供应商编码-->
-        cUpSoType,<!--入库单单据类型-->
+        cUpSoType<!--入库单单据类型-->
         )
         VALUES(
         #{map.cPIVCode},
@@ -283,7 +283,7 @@
         #{map.iRdsID},
         0,
         #{map.crdcvencode},
-        '01',
+        '01'
         )
     </insert>
 
@@ -291,9 +291,19 @@
         select cVenCode,cVenDefine1,cVenDefine2,cVenAbbName from Vendor where cVenCode=#{cVenCode}
     </select>
 
-    <select id="getRdrecords01WriteQuantity" resultType="java.util.HashMap" parameterType="java.lang.String">
+    <select id="getRdrecords01WriteQuantity" resultType="java.math.BigDecimal" parameterType="java.lang.String">
         SELECT SUM
-                   ( rs.iQuantity ) - SUM ( rs.iSumBillQuantity ) as iQuantity,rs.AutoID as AutoID
+                   ( rs.iQuantity ) - SUM ( rs.iSumBillQuantity ) as iQuantity
+        FROM
+            rdrecords01 rs
+                LEFT JOIN RdRecord01 r ON rs.ID= r.ID
+        WHERE
+            r.bredvouch= 0
+          AND (rs.iPOsID= #{rowmId} or rs.iOMoDID= #{rowmId})
+    </select>
+
+    <select id="getRdrecords01Entity" resultType="java.util.HashMap" parameterType="java.lang.String">
+        SELECT rs.*
         FROM
             rdrecords01 rs
                 LEFT JOIN RdRecord01 r ON rs.ID= r.ID

+ 8 - 10
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/service/impl/PurchaseWarehousingServiceImpl.java

@@ -250,7 +250,7 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
                         //如果是红字入库则处理是否需要做结算单
                         if(map.get("cVouchType").toString().equals("1")){
                             //保存结算单
-//                            savePurSettleVouch(map,itemMap,rowmId);
+                            savePurSettleVouch(map,itemMap,rowmId);
                             itemMap.put("iQuantity","-"+itemMap.get("iQuantity"));
                         }
 
@@ -382,11 +382,11 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
     //保存结算单
     public void savePurSettleVouch(Map<String,Object> map,Map<String,Object> itemMap,String rowmId){
         BigDecimal rdiQuantity=getDecimalNew(String.valueOf(itemMap.get("iQuantity")));
-        Map<String,Object> Rdrecords01WriteQuantityMap=this.baseMapper.getRdrecords01WriteQuantity(rowmId);
-        if(Rdrecords01WriteQuantityMap==null){
+        List<Map<String,Object>> Rdrecords01WriteQuantityMapList=this.baseMapper.getRdrecords01Entity(rowmId);
+        if(Rdrecords01WriteQuantityMapList==null||Rdrecords01WriteQuantityMapList.size()<=0){
             throw new RuntimeException("结算业务:未找到对应蓝字入库单");
         }
-        BigDecimal decimal=getDecimalNew(String.valueOf(Rdrecords01WriteQuantityMap.get("iQuantity")));//蓝字未结算数量
+        BigDecimal decimal=this.baseMapper.getRdrecords01WriteQuantity(rowmId);//蓝字未结算数量
         //根据红字查询对应的蓝字入库的未做发票的数量判断是否有且是否大于红字入库数量
         if(decimal!=null&&decimal.doubleValue()>0.0&&decimal.doubleValue()>rdiQuantity.doubleValue()){
             Map<String,Object> mapPurSettleVouch=new HashMap<>();
@@ -435,7 +435,7 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
             mapPurSettleVouchs.put("iSVAPrice",money.doubleValue());//暂估金额
             mapPurSettleVouchs.put("ID",oConvertUtils.addOne(getMaxId("ID","PurSettleVouchs")));//ID
             mapPurSettleVouchs.put("PSVID",mapPurSettleVouch.get("PSVID"));//主表id
-            mapPurSettleVouchs.put("iRdsID",mapPurSettleVouch.get("PSVID"));//蓝字入库单id ???
+            mapPurSettleVouchs.put("iRdsID",Rdrecords01WriteQuantityMapList.get(0).get("AutoID"));//蓝字入库单子表id ???
             mapPurSettleVouchs.put("crdcvencode",map.get("cVenCode"));//入库单单据类型
             this.baseMapper.savePurSettleVouch(mapPurSettleVouch);
             this.baseMapper.savePurSettleVouchs(mapPurSettleVouchs);
@@ -541,11 +541,8 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
                 //根据存货与自由项找对应子件
 
 
-                System.out.println(vouchsMap.toString());
-                System.out.println(vouchsMap.get("MoDetailsID")+"-"+vouchsMap.get("cInvCode"));
-                System.out.println(JSONObject.fromObject(vouchsMap).toString());
+
                 List<Map<String,Object>> OM_MOMaterialsList= this.baseMapper.getOM_MOMaterials(vouchsMap);
-                System.out.println(OM_MOMaterialsList.toString());
                 if(OM_MOMaterialsList!=null&&OM_MOMaterialsList.size()>0){
                     if(OM_MOMaterialsList.size()==1){
                         vouchsMap.put("iomids",OM_MOMaterialsList.get(0).get("MOMaterialsID"));//委外订单自件id
@@ -557,8 +554,9 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
 //                        if(iSendQTY.doubleValue()>fTransQty.doubleValue()){
                             //调拨数量回写到对应委外子件
                             Map<String,Object> updateOM_MOMaterials=new HashMap<>();
-                            updateOM_MOMaterials.put("map.MOMaterialsID",OM_MOMaterialsList.get(0).get("MOMaterialsID"));//委外订单子件id
+                            updateOM_MOMaterials.put("MOMaterialsID",OM_MOMaterialsList.get(0).get("MOMaterialsID"));//委外订单子件id
                             updateOM_MOMaterials.put("fTransQty",fTransQty.doubleValue());//调拨数量
+                        System.out.println("调拨数量:"+fTransQty.doubleValue());
                             this.baseMapper.updateOM_MOMaterialsfTransQty(updateOM_MOMaterials);
 //                        }else{
 //                            throw new RuntimeException("第"+vI+"调拨数量不能大于子件已领数量");