chenc пре 2 година
родитељ
комит
01e7be2a54

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

@@ -45,6 +45,8 @@ public interface PurchaseWarehousingMapper extends BaseMapper<PurchaseWarehousin
     */
     void saveRdrecords01One(@Param("list")List<Map<String,Object>> list);
 
+    void saveRdrecords01(@Param("map")Map<String,Object> map);
+
     /**
     * @Author chenchuang
     * @Description //TODO 根据人员编码查询部门编码
@@ -116,4 +118,40 @@ public interface PurchaseWarehousingMapper extends BaseMapper<PurchaseWarehousin
     * @return void
     */
     void savePurSettleVouchs(@Param("map")Map<String,Object> map);
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 根据采购订单行id获取采购订单行数据
+    * @Date 2022/4/27 21:23
+    * @Param [rowmId]
+    * @return java.util.Map<java.lang.String,java.lang.Object>
+    */
+    Map<String,Object> getPOPodetails(@Param("rowmId")String rowmId);
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 根据委外订单行id获取委外订单行数据
+    * @Date 2022/4/27 21:38
+    * @Param [rowmId]
+    * @return java.util.Map<java.lang.String,java.lang.Object>
+    */
+    Map<String,Object> getOMMODetails(@Param("rowmId")String rowmId);
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 回写采购订单行入库数量
+    * @Date 2022/4/27 22:48
+    * @Param [map]
+    * @return void
+    */
+    void updatePodetailsfreceivedqty(@Param("map")Map<String,Object> map);
+
+    /**
+    * @Author chenchuang
+    * @Description //TODO 回写委外订单行入库数量
+    * @Date 2022/4/27 22:49
+    * @Param [map]
+    * @return void
+    */
+    void updateOMMODetailsfreceivedqty(@Param("map")Map<String,Object> map);
 }

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

@@ -116,6 +116,103 @@
         </foreach>
     </insert>
 
+    <insert id="saveRdrecords01">
+            INSERT INTO rdrecords01
+            (
+            AutoID,
+            ID,
+            <!--cDefine22,
+            cDefine28,-->
+            cInvCode,
+            iQuantity,
+            cBatch,
+            <!--cFree1,-->
+            <!--cDefine30,-->
+            cbMemo,
+            iordercode,
+            irowno,
+            iFlag,<!--是否传递 -->
+            iMatSettleState,<!--结算状态 -->
+            iBillSettleCount,<!--结算次数 -->
+            iPOsID,
+            iOMoDID,
+            cPOID,
+            cDefine22,
+        cDefine23,
+        cDefine24,
+        cDefine25,
+        cDefine26,
+        cDefine27,
+        cDefine28,
+        cDefine29,
+        cDefine30,
+        cDefine31,
+        cDefine32,
+        cDefine33,
+        cDefine34,
+        cDefine35,
+        cDefine36,
+        cDefine37,
+        cFree1,
+        cFree2,
+        cFree3,
+        cFree4,
+        cFree5,
+        cFree6,
+        cFree7,
+        cFree8,
+        cFree9,
+        cFree10
+            )
+            VALUES
+            (
+            #{map.AutoID},
+            #{map.ID},
+            <!--#{map.cDefine22},
+            #{map.cDefine28},-->
+            #{map.cInvCode},
+            #{map.iQuantity},
+            #{map.cBatch},
+           <!-- #{map.colour},-->
+           <!-- #{map.cDefine30},-->
+            #{map.cbMemo},
+            #{map.iordercode},
+            #{map.irowno},
+            0,
+            0,
+            0,
+            #{map.iPOsID},
+            #{map.iOMoDID},
+            #{map.cPOID},
+        #{map.cDefine22},
+        #{map.cDefine23},
+        #{map.cDefine24},
+        #{map.cDefine25},
+        #{map.cDefine26},
+        #{map.cDefine27},
+        #{map.cDefine28},
+        #{map.cDefine29},
+        #{map.cDefine30},
+        #{map.cDefine31},
+        #{map.cDefine32},
+        #{map.cDefine33},
+        #{map.cDefine34},
+        #{map.cDefine35},
+        #{map.cDefine36},
+        #{map.cDefine37},
+        #{map.cFree1},
+        #{map.cFree2},
+        #{map.cFree3},
+        #{map.cFree4},
+        #{map.cFree5},
+        #{map.cFree6},
+        #{map.cFree7},
+        #{map.cFree8},
+        #{map.cFree9},
+        #{map.cFree10}
+            )
+    </insert>
+
     <insert id="savePurSettleVouch">
         INSERT INTO PurSettleVouch (
         cSVCode,
@@ -203,6 +300,21 @@
         select iNatUnitPrice,iPerTaxRate from PO_Podetails where ID=#{rowmId}
     </select>
 
+    <select id="getPOPodetails" parameterType="java.lang.String" resultType="java.util.HashMap">
+        select * from PO_Podetails where ID=#{rowmId}
+    </select>
+
+    <update id="updatePodetailsfreceivedqty" parameterType="java.util.HashMap">
+        update PO_Podetails set freceivedqty=#{map.freceivedqty} where ID=#{map.ID}
+    </update>
+
+    <select id="getOMMODetails" parameterType="java.lang.String" resultType="java.util.HashMap">
+        select * from OM_MODetails where MODetailsID=#{rowmId}
+    </select>
+    <update id="updateOMMODetailsfreceivedqty" parameterType="java.util.HashMap">
+        update OM_MODetails set iReceivedQTY=#{map.freceivedqty} where MODetailsID=#{map.ID}
+    </update>
+
     <insert id="saveTransVouch">
         INSERT INTO TransVouch(ID,cTVCode,dTVDate,cODepCode,cIDepCode,cOWhCode,cIWhCode,cORdCode,cIRdCode,cMPoCode,cDefine13,
         cPersonCode,<!--业务员-->

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

@@ -16,10 +16,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @Description: 采购入库
@@ -134,40 +131,122 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
                         String rowmId="";
                         //订单子表id
                         if(map.get("cRdCode").toString().equals("11")){
-                            itemMap.put("iPOsID",itemMap.get("moDetailId"));//采购订单行id
-                            itemMap.put("iOMoDID","");//委外订单行id
-                            rowmId=String.valueOf(itemMap.get("moDetailId"));
+                            if(itemMap.get("moDetailId")!=null&&StringUtils.isNotBlank(String.valueOf(itemMap.get("moDetailId")))) {
+                                itemMap.put("iPOsID", itemMap.get("moDetailId"));//采购订单行id
+                                itemMap.put("iOMoDID", "");//委外订单行id
+                                rowmId = String.valueOf(itemMap.get("moDetailId"));
+                                //获取订单行的数据
+                                Map<String,Object> mapPOPodetails= this.baseMapper.getPOPodetails(rowmId);
+                                if(mapPOPodetails!=null){
+                                    //获取订单行的自定义项数据
+                                    getcFree(itemMap,mapPOPodetails);
+                                    //回写入库数量到采购订单行
+                                    if(mapPOPodetails.get("freceivedqty")!=null){
+                                        BigDecimal freceivedqty=getDecimalNew(String.valueOf(mapPOPodetails.get("freceivedqty"))).add(getDecimalNew(String.valueOf(itemMap.get("iQuantity"))));
+                                        Map<String,Object> mapFreceivedqty=new HashMap<>();
+                                        mapFreceivedqty.put("freceivedqty",freceivedqty);//入库数量
+                                        mapFreceivedqty.put("ID",rowmId);//订单行id
+                                        //回写到采购订单对应行
+                                        this.baseMapper.updatePodetailsfreceivedqty(mapFreceivedqty);
+                                    }
 
+                                }else{
+                                    message=message+"第"+rowId+"未找到对应的采购订单行;";
+                                }
+                            }else{
+                                message=message+"第"+rowId+"缺少采购订单行id;";
+                            }
                         }else{//委外入库
-                            itemMap.put("iPOsID","");//采购订单行id
-                            itemMap.put("iOMoDID",itemMap.get("moDetailId"));//委外订单行id
-                            String moDetailId=String.valueOf(itemMap.get("moDetailId"));//委外订单行id
-                            if(itemMap.get("moDetailId")!=null){
+
+                            if(itemMap.get("moDetailId")!=null&&StringUtils.isNotBlank(String.valueOf(itemMap.get("moDetailId")))){
+                                itemMap.put("iPOsID","");//采购订单行id
+                                itemMap.put("iOMoDID",itemMap.get("moDetailId"));//委外订单行id
+                                String moDetailId=String.valueOf(itemMap.get("moDetailId"));//委外订单行id
                                 //获取来源订单号
                                 Map<String,Object> omMoDetails=this.baseMapper.getOMMoDetails(moDetailId);
                                 itemMap.put("iordercode",omMoDetails.get("csoordercode"));//来源订单号
+                                rowmId=String.valueOf(itemMap.get("moDetailId"));
+                                //获取订单行数据
+                                Map<String,Object> mapOMMODetails=this.baseMapper.getOMMODetails(rowmId);
+                                if(mapOMMODetails!=null){
+                                    //获取订单的自定义数据
+                                    getcFree(itemMap,mapOMMODetails);
+                                    //回写入库数量到委外订单行
+                                    if(mapOMMODetails.get("iReceivedQTY")!=null){
+                                        BigDecimal freceivedqty=getDecimalNew(String.valueOf(mapOMMODetails.get("iReceivedQTY"))).add(getDecimalNew(String.valueOf(itemMap.get("iQuantity"))));
+                                        Map<String,Object> mapFreceivedqty=new HashMap<>();
+                                        mapFreceivedqty.put("iReceivedQTY",freceivedqty);//入库数量
+                                        mapFreceivedqty.put("ID",rowmId);//订单行id
+                                        //回写到委外订单对应行
+                                        this.baseMapper.updateOMMODetailsfreceivedqty(mapFreceivedqty);
+                                    }
+                                }else{
+                                    message=message+"第"+rowId+"未找到对应的委外订单行;";
+                                }
                             }else{
-                                message=message+"缺少委外订单行id;";
+                                message=message+"第"+rowId+"缺少委外订单行id;";
                             }
-                            rowmId=String.valueOf(itemMap.get("moDetailId"));
                         }
                         //如果是红字入库则处理是否需要做结算单
                         if(map.get("cVouchType").toString().equals("1")){
                             //保存结算单
 //                            savePurSettleVouch(map,itemMap,rowmId);
+                            itemMap.put("iQuantity","-"+itemMap.get("iQuantity"));
                         }
 
                         rowId++;
+                        if(StringUtils.isEmpty(message)) {
+                            this.baseMapper.saveRdrecords01(itemMap);
+                        }
                     }
                     if(StringUtils.isNotBlank(message)){
                         throw new RuntimeException(message);
                     }
-                    this.baseMapper.saveRdrecords01One(itemList);
+//                    this.baseMapper.saveRdrecords01One(itemList);
                 }
             }
         }
     }
 
+    //获取采购订单行自定义项数据与存货自定义项数据
+    public void getcFree(Map<String,Object> itemMap,Map<String,Object> mapPOPodetails){
+        itemMap.put("cDefine22",setNull(mapPOPodetails.get("cDefine22")));
+        itemMap.put("cDefine23",setNull(mapPOPodetails.get("cDefine23")));
+        itemMap.put("cDefine24",setNull(mapPOPodetails.get("cDefine24")));
+        itemMap.put("cDefine25",setNull(mapPOPodetails.get("cDefine25")));
+        itemMap.put("cDefine26",setNull(mapPOPodetails.get("cDefine26")));
+        itemMap.put("cDefine27",setNull(mapPOPodetails.get("cDefine27")));
+        itemMap.put("cDefine28",setNull(mapPOPodetails.get("cDefine28")));
+        itemMap.put("cDefine29",setNull(mapPOPodetails.get("cDefine29")));
+        itemMap.put("cDefine30",setNull(mapPOPodetails.get("cDefine30")));
+        itemMap.put("cDefine31",setNull(mapPOPodetails.get("cDefine31")));
+        itemMap.put("cDefine32",setNull(mapPOPodetails.get("cDefine32")));
+        itemMap.put("cDefine33",setNull(mapPOPodetails.get("cDefine33")));
+        itemMap.put("cDefine34",setNull(mapPOPodetails.get("cDefine34")));
+        itemMap.put("cDefine35",setNull(mapPOPodetails.get("cDefine35")));
+        itemMap.put("cDefine36",setNull(mapPOPodetails.get("cDefine36")));
+        itemMap.put("cDefine37",setNull(mapPOPodetails.get("cDefine37")));
+        itemMap.put("cFree1",setNull(mapPOPodetails.get("cFree1")));
+        itemMap.put("cFree2",setNull(mapPOPodetails.get("cFree2")));
+        itemMap.put("cFree3",setNull(mapPOPodetails.get("cFree3")));
+        itemMap.put("cFree4",setNull(mapPOPodetails.get("cFree4")));
+        itemMap.put("cFree5",setNull(mapPOPodetails.get("cFree5")));
+        itemMap.put("cFree6",setNull(mapPOPodetails.get("cFree6")));
+        itemMap.put("cFree7",setNull(mapPOPodetails.get("cFree7")));
+        itemMap.put("cFree8",setNull(mapPOPodetails.get("cFree8")));
+        itemMap.put("cFree9",setNull(mapPOPodetails.get("cFree9")));
+        itemMap.put("cFree10",setNull(mapPOPodetails.get("cFree10")));
+    }
+    public Object setNull(Object o){
+        if(o==null){
+            return "";
+        }else{
+            return o;
+        }
+
+    }
+
+    //保存结算单
     public void savePurSettleVouch(Map<String,Object> map,Map<String,Object> itemMap,String rowmId){
         BigDecimal rdiQuantity=getDecimalNew(String.valueOf(itemMap.get("iQuantity")));
         BigDecimal decimal=this.baseMapper.getRdrecords01WriteQuantity(rowmId);
@@ -235,7 +314,7 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
     }
 
     //保存调拨单
-    public void saveTransVouch(Map<String,Object> rdRecord01Map){
+    public void saveTransVouch(Map<String,Object> rdRecord01Map,List<Map<String,Object>> rdRecords01List){
         Map<String,Object> transVouchMao=new HashMap<>();
         //获取主表最大ID
         transVouchMao.put("ID",oConvertUtils.addOne(getMaxId("ID","TransVouch")));
@@ -279,6 +358,24 @@ public class PurchaseWarehousingServiceImpl extends ServiceImpl<PurchaseWarehous
         //业务员
         transVouchMao.put("cPersonCode",rdRecord01Map.get("cPersonCode"));
         this.baseMapper.saveTransVouch(transVouchMao);
+        List<Map<String,Object>> transVouchsList=new ArrayList<>();
+        if(rdRecords01List!=null&&rdRecords01List.size()>0){
+            for(Map<String,Object> recordsMap:rdRecords01List){
+                Map<String,Object> vouchsMap=new HashMap<>();
+                vouchsMap.put("comcode",rdRecord01Map.get("cOrderCode"));//委外订单号
+                vouchsMap.put("cDefine22",recordsMap.get("cDefine22"));//款号
+                vouchsMap.put("cTVBatch",recordsMap.get("cBatch"));//批号
+                vouchsMap.put("cInvCode",recordsMap.get("cInvCode"));//存货编码
+                vouchsMap.put("iTVQuantity",recordsMap.get("iQuantity"));//数量
+                vouchsMap.put("cFree1",recordsMap.get(""));//颜色
+                vouchsMap.put("cFree2",recordsMap.get(""));//尺码
+                vouchsMap.put("cFree4",recordsMap.get(""));//光坯门幅
+                vouchsMap.put("cFree6",recordsMap.get(""));//克重/工艺
+                vouchsMap.put("cFree5",recordsMap.get(""));//品质/品种
+                vouchsMap.put("cDefine30",recordsMap.get(""));//染厂色号
+                vouchsMap.put("cbMemo",recordsMap.get(""));//备注
+            }
+        }
     }
 
     @Override