koushanshan 2 лет назад
Родитель
Сommit
dcab68eb60
24 измененных файлов с 667 добавлено и 462 удалено
  1. 2 0
      src/main/java/com/dk/mdm/controller/ivt/inbound/InboundController.java
  2. 28 0
      src/main/java/com/dk/mdm/controller/ivt/inbound/InboundPurchaseController.java
  3. 8 0
      src/main/java/com/dk/mdm/infrastructure/convert/ivt/InboundItemConvert.java
  4. 1 1
      src/main/java/com/dk/mdm/mapper/common/CommonMapper.xml
  5. 14 2
      src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml
  6. 7 4
      src/main/java/com/dk/mdm/mapper/ivt/InboundMapper.xml
  7. 16 9
      src/main/java/com/dk/mdm/mapper/ivt/OutboundItemMapper.xml
  8. 10 3
      src/main/java/com/dk/mdm/mapper/ivt/OutboundMapper.xml
  9. 7 0
      src/main/java/com/dk/mdm/model/pojo/ivt/Inbound.java
  10. 21 0
      src/main/java/com/dk/mdm/model/pojo/ivt/InboundItem.java
  11. 9 0
      src/main/java/com/dk/mdm/model/pojo/ivt/Outbound.java
  12. 21 0
      src/main/java/com/dk/mdm/model/pojo/ivt/OutboundItem.java
  13. 19 0
      src/main/java/com/dk/mdm/model/response/ivt/InboundItemResponse.java
  14. 7 0
      src/main/java/com/dk/mdm/model/response/ivt/InboundResponse.java
  15. 22 0
      src/main/java/com/dk/mdm/model/response/ivt/OutboundItemResponse.java
  16. 8 0
      src/main/java/com/dk/mdm/model/response/ivt/OutboundResponse.java
  17. 7 0
      src/main/java/com/dk/mdm/model/vo/ivt/InOutRecordVO.java
  18. 29 0
      src/main/java/com/dk/mdm/model/vo/ivt/InboundItemVO.java
  19. 7 0
      src/main/java/com/dk/mdm/model/vo/ivt/InboundVO.java
  20. 21 0
      src/main/java/com/dk/mdm/model/vo/ivt/OutboundItemVO.java
  21. 9 0
      src/main/java/com/dk/mdm/model/vo/ivt/OutboundVO.java
  22. 0 13
      src/main/java/com/dk/mdm/service/ivt/inbound/InboundOtherService.java
  23. 0 320
      src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseReturnService.java
  24. 394 110
      src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseService.java

+ 2 - 0
src/main/java/com/dk/mdm/controller/ivt/inbound/InboundController.java

@@ -93,6 +93,8 @@ public class InboundController{
     public ResponseResultVO<?> purchaseInboundInsert(@Valid @RequestBody InboundVO inboundVO) {
         return inheritedPurchaseService.purchaseInboundInsert(inboundVO);
     }
+
+
     /**
      * @desc   : 采购入库办理
      * @date   : 2024/3/7 15:34

+ 28 - 0
src/main/java/com/dk/mdm/controller/ivt/inbound/InboundPurchaseController.java

@@ -110,6 +110,34 @@ public class InboundPurchaseController {
     }
 
     /**
+     * @desc   : 采购入库编辑
+     * @date   : 2024/3/26 9:51
+     * @author : 寇珊珊
+     */
+    @ApiOperation(
+            value = "采购入库编辑",
+            notes = "采购入库编辑"
+    )
+    @PostMapping({"inbound_update"})
+    public ResponseResultVO<?> purchaseInboundUpdate(@Valid @RequestBody InboundVO inboundVO) {
+        return inheritedPurchaseService.purchaseInboundUpdate(inboundVO);
+    }
+
+    /**
+     * @desc   : 采购入库作废
+     * @date   : 2024/3/26 9:51
+     * @author : 寇珊珊
+     */
+    @ApiOperation(
+            value = "采购入库作废",
+            notes = "采购入库作废"
+    )
+    @PostMapping({"repeal/{id}"})
+    public ResponseResultVO<?> purchaseInboundRepeal(@PathVariable String id) {
+        return inheritedPurchaseService.purchaseInboundRepeal(id);
+    }
+
+    /**
      * @desc   : 获取单据信息(编辑用)
      * @date   : 2024/3/14 16:37
      * @author : 寇珊珊

+ 8 - 0
src/main/java/com/dk/mdm/infrastructure/convert/ivt/InboundItemConvert.java

@@ -2,6 +2,7 @@ package com.dk.mdm.infrastructure.convert.ivt;
 
 import com.dk.mdm.model.pojo.ivt.Inbound;
 import com.dk.mdm.model.pojo.ivt.InboundItem;
+import com.dk.mdm.model.response.ivt.InboundItemResponse;
 import com.dk.mdm.model.vo.ivt.InboundItemVO;
 import com.dk.mdm.model.vo.ivt.InboundVO;
 import org.mapstruct.Mapper;
@@ -20,4 +21,11 @@ public interface InboundItemConvert {
      * @author : 寇珊珊
      */
     InboundItem convertToPo(InboundItemVO inboundItemVO);
+
+    /**
+     * @desc   : res转VO
+     * @date   : 2024/3/7 14:31
+     * @author : 寇珊珊
+     */
+    InboundItemVO  convertResTVO(InboundItemResponse inboundItemResponse);
 }

+ 1 - 1
src/main/java/com/dk/mdm/mapper/common/CommonMapper.xml

@@ -286,7 +286,7 @@
 
     <!--    函数查询单个系统参数-->
     <select id="getSettingValue" resultType="String">
-        select core.f_get_setting_value(#{code}, #{ftyId})
+        select dkic_b.f_get_setting_value(#{code}, #{ftyId})
     </select>
 
 

+ 14 - 2
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml

@@ -5,7 +5,11 @@
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <sql id="Base_Column_List">
-        item_id, into_id, into_type, from_id, from_item_id, item_index, sku_id, price_into, non_std_code, into_status, intoing_qty, intoing_amt, into_qty, into_amt, return_qty, return_amt, remarks, inv_id, cost_price, cost_amt, out_qty, inv_qty, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
+        item_id, into_id, into_type, from_id, from_item_id, item_index, sku_id, price_into, non_std_code,
+        into_status, intoing_qty, intoing_amt, into_qty, into_amt, return_qty, return_amt,
+        remarks, inv_id, cost_price, cost_amt, out_qty, inv_qty, flg_valid, cp_id, op_create_time,
+        op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user,
+        s_into_id,s_into_item_id,s_pur_id,s_pur_item_id
     </sql>
 
     <!-- response通用查询列 -->
@@ -13,7 +17,7 @@
         tpii.item_id, tpii.into_id, tpii.into_type, tpii.from_id, tpii.from_item_id, tpii.item_index, tpii.sku_id, tpii.price_into,
         tpii.non_std_code, tpii.into_status, tpii.intoing_qty, tpii.intoing_amt, tpii.into_qty, tpii.into_amt, tpii.return_qty,
         tpii.return_amt, tpii.remarks, tpii.inv_id, tpii.cost_price, tpii.cost_amt, tpii.out_qty, tpii.inv_qty, tpii.flg_valid,
-        tpii.cp_id
+        tpii.cp_id,tpii.s_into_id,tpii.s_into_item_id,tpii.s_pur_id,tpii.s_pur_item_id
     </sql>
 
 
@@ -50,6 +54,10 @@
                 <result column="op_app_code" property="opAppCode"/>
             <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
                 <result column="op_db_user" property="opDbUser"/>
+        <result column="s_into_id" property="sIntoId" typeHandler="UuidTypeHandler"/>
+        <result column="s_into_item_id" property="sIntoItemId" typeHandler="UuidTypeHandler"/>
+        <result column="s_pur_id" property="sPurId" typeHandler="UuidTypeHandler"/>
+        <result column="s_pur_item_id" property="sPurItemId" typeHandler="UuidTypeHandler"/>
     </resultMap>
 
 
@@ -79,6 +87,10 @@
         <result column="inv_qty" property="invQty"/>
         <result column="flg_valid" property="flgValid"/>
         <result column="cp_id" property="cpId"/>
+        <result column="s_into_id" property="sIntoId" typeHandler="UuidTypeHandler"/>
+        <result column="s_into_item_id" property="sIntoItemId" typeHandler="UuidTypeHandler"/>
+        <result column="s_pur_id" property="sPurId" typeHandler="UuidTypeHandler"/>
+        <result column="s_pur_item_id" property="sPurItemId" typeHandler="UuidTypeHandler"/>
     </resultMap>
 
     <!-- 通用条件列 -->

+ 7 - 4
src/main/java/com/dk/mdm/mapper/ivt/InboundMapper.xml

@@ -5,13 +5,12 @@
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <sql id="Base_Column_List">
-        into_id
-        , into_no, into_type, from_id, from_no, org_id, staff_id, cus_id, sup_id,
+        into_id ,into_no, into_type, from_id, from_no, org_id, staff_id, cus_id, sup_id,
         into_status, intoing_qty, intoing_amt, into_qty, into_amt, return_qty,
         return_amt, into_date, remarks, annex_paths, make_staff, make_time,
         receivable_id, payable_id, flg_valid, cp_id, op_create_time, op_create_user_id,
         op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user,wh_id,
-        into_reason
+        into_reason,flg_auto_handle,flg_handle_setting
     </sql>
 
 
@@ -21,7 +20,7 @@
         tpi.cus_id, tpi.sup_id, tpi.into_status, tpi.intoing_qty, tpi.intoing_amt, tpi.into_qty,
         tpi.into_amt, tpi.return_qty, tpi.return_amt, tpi.into_date, tpi.remarks, tpi.annex_paths,
         tpi.make_staff, tpi.make_time, tpi.receivable_id, tpi.payable_id, tpi.flg_valid, tpi.cp_id,
-        tpi.wh_id,tpi.into_reason
+        tpi.wh_id,tpi.into_reason,flg_auto_handle,flg_handle_setting
     </sql>
 
 
@@ -61,6 +60,8 @@
         <result column="op_db_user" property="opDbUser"/>
         <result column="into_reason" property="intoReason" typeHandler="UuidTypeHandler"/>
         <result column="wh_id" property="whId"/>
+        <result column="flg_auto_handle" property="flgAutoHandle"/>
+        <result column="flg_handle_setting" property="flgHandleSetting"/>
     </resultMap>
 
     <!-- response查询映射结果 -->
@@ -110,6 +111,8 @@
         <result column="return_address" property="returnAddress" />
         <result column="return_contact_name" property="returnContactName" />
         <result column="return_contact_phone" property="returnContactPhone" />
+        <result column="flg_auto_handle" property="flgAutoHandle"/>
+        <result column="flg_handle_setting" property="flgHandleSetting"/>
 
     </resultMap>
 

+ 16 - 9
src/main/java/com/dk/mdm/mapper/ivt/OutboundItemMapper.xml

@@ -5,14 +5,20 @@
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <sql id="Base_Column_List">
-        item_id, out_id, out_type, from_id, from_item_id, item_index, sku_id, price_out, non_std_code, out_status, outing_qty, outing_amt, out_qty, out_amt, return_qty, return_amt, remarks, inv_id, cost_price, cost_amt, flg_valid, cp_id, op_create_time, op_create_user_id, op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user
+        item_id, out_id, out_type, from_id, from_item_id, item_index, sku_id, price_out, non_std_code,
+        out_status, outing_qty, outing_amt, out_qty, out_amt, return_qty, return_amt, remarks,
+        inv_id, cost_price, cost_amt, flg_valid, cp_id, op_create_time, op_create_user_id,
+        op_update_time, op_update_user_id, op_app_code, op_timestamp, op_db_user,
+        s_out_id,s_out_item_id,s_order_id,s_order_item_id
     </sql>
 
     <sql id="Base_Column_List_Response">
         tpoi.item_id, tpoi.out_id, tpoi.out_type, tpoi.from_id, tpoi.from_item_id, tpoi.item_index,
         tpoi.sku_id, tpoi.price_out, tpoi.non_std_code, tpoi.out_status, tpoi.outing_qty, tpoi.outing_amt,
         tpoi.out_qty, tpoi.out_amt, tpoi.return_qty, tpoi.return_amt, tpoi.remarks, tpoi.inv_id,
-        tpoi.cost_price, tpoi.cost_amt, tpoi.flg_valid, tpoi.cp_id
+        tpoi.cost_price, tpoi.cost_amt, tpoi.flg_valid, tpoi.cp_id,
+        tpoi.s_out_id,tpoi.s_out_item_id,tpoi.s_order_id,tpoi.s_order_item_id
+
     </sql>
 
     <!-- 通用查询映射结果 -->
@@ -46,6 +52,10 @@
                 <result column="op_app_code" property="opAppCode"/>
             <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
                 <result column="op_db_user" property="opDbUser"/>
+                <result column="s_out_id" property="sOutId" typeHandler="UuidTypeHandler"/>
+                <result column="s_out_item_id" property="sOutItemId" typeHandler="UuidTypeHandler"/>
+                <result column="s_order_id" property="sOrderId" typeHandler="UuidTypeHandler"/>
+                <result column="s_order_item_id" property="sOrderItemId" typeHandler="UuidTypeHandler"/>
     </resultMap>
 
     <!-- 通用查询映射结果 -->
@@ -72,13 +82,10 @@
                 <result column="cost_amt" property="costAmt"/>
                 <result column="flg_valid" property="flgValid"/>
                 <result column="cp_id" property="cpId"/>
-            <result column="op_create_time" property="opCreateTime" typeHandler="TimestampTypeHandler"/>
-                <result column="op_create_user_id" property="opCreateUserId" typeHandler="UuidTypeHandler"/>
-            <result column="op_update_time" property="opUpdateTime" typeHandler="TimestampTypeHandler"/>
-                <result column="op_update_user_id" property="opUpdateUserId" typeHandler="UuidTypeHandler"/>
-                <result column="op_app_code" property="opAppCode"/>
-            <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
-                <result column="op_db_user" property="opDbUser"/>
+        <result column="s_out_id" property="sOutId" typeHandler="UuidTypeHandler"/>
+        <result column="s_out_item_id" property="sOutItemId" typeHandler="UuidTypeHandler"/>
+        <result column="s_order_id" property="sOrderId" typeHandler="UuidTypeHandler"/>
+        <result column="s_order_item_id" property="sOrderItemId" typeHandler="UuidTypeHandler"/>
     </resultMap>
 
     <!-- 通用条件列 -->

+ 10 - 3
src/main/java/com/dk/mdm/mapper/ivt/OutboundMapper.xml

@@ -5,14 +5,18 @@
     <!-- 通用设置 -->
     <!-- 通用查询列 -->
     <sql id="Base_Column_List">
-        out_id, out_no, out_type, from_id, from_no, org_id, staff_id, cus_id, sup_id, out_status, outing_qty, outing_amt, out_qty, out_amt, return_qty, return_amt, out_date, remarks, annex_paths, make_staff, make_time, receivable_id, payable_id, flg_valid, cp_id,out_reason
+        out_id, out_no, out_type, from_id, from_no, org_id, staff_id, cus_id, sup_id,
+        out_status, outing_qty, outing_amt, out_qty, out_amt, return_qty, return_amt,
+        out_date, remarks, annex_paths, make_staff, make_time, receivable_id,
+        payable_id, flg_valid, cp_id,out_reason,flg_auto_handle,flg_handle_setting
     </sql>
 
     <sql id="Base_Column_List_Response">
         tpo.out_id, tpo.out_no, tpo.out_type, tpo.from_id, tpo.from_no, tpo.org_id, tpo.staff_id,
         tpo.cus_id, tpo.sup_id, tpo.out_status, tpo.outing_qty, tpo.outing_amt, tpo.out_qty, tpo.out_amt,
         tpo.return_qty, tpo.return_amt, tpo.out_date, tpo.remarks, tpo.annex_paths, tpo.make_staff,
-        tpo.make_time, tpo.receivable_id, tpo.payable_id, tpo.flg_valid, tpo.cp_id,tpo.out_reason
+        tpo.make_time, tpo.receivable_id, tpo.payable_id, tpo.flg_valid, tpo.cp_id,tpo.out_reason,
+        tpo.flg_auto_handle,tpo.flg_handle_setting
     </sql>
 
     <!-- 通用查询映射结果 -->
@@ -50,6 +54,8 @@
             <result column="op_timestamp" property="opTimestamp" typeHandler="TimestampTypeHandler"/>
                 <result column="op_db_user" property="opDbUser"/>
         <result column="out_reason" property="outReason" typeHandler="UuidTypeHandler"/>
+        <result column="flg_auto_handle" property="flgAutoHandle"/>
+        <result column="flg_handle_setting" property="flgHandleSetting"/>
     </resultMap>
 
     <!-- 通用查询映射结果 -->
@@ -79,6 +85,8 @@
         <result column="payable_id" property="payableId" typeHandler="UuidTypeHandler"/>
         <result column="flg_valid" property="flgValid"/>
         <result column="cp_id" property="cpId"/>
+        <result column="flg_auto_handle" property="flgAutoHandle"/>
+        <result column="flg_handle_setting" property="flgHandleSetting"/>
 <!--        <result column="org_name" property="orgName"/>-->
 <!--        <result column="staff_name" property="staffName"/>-->
         <result column="cusCode" property="cusCode"/>
@@ -95,7 +103,6 @@
         <result column="cus_from_name" property="cusFromName"/>
         <result column="out_reason" property="outReason" typeHandler="UuidTypeHandler"/>
         <result column="out_reason_name" property="outReasonName" />
-
     </resultMap>
 
     <!-- 通用条件列 -->

+ 7 - 0
src/main/java/com/dk/mdm/model/pojo/ivt/Inbound.java

@@ -329,6 +329,13 @@ public class Inbound extends PageInfo<Inbound> implements Serializable {
     @TableField(typeHandler = UuidTypeHandler.class)
     private String intoReason;
 
+    @Excel(name = "自动办理标识")
+    @ApiModelProperty(value = "自动办理标识")
+    private Boolean flgAutoHandle;
+
+    @Excel(name = "自动办理参数")
+    @ApiModelProperty(value = "自动办理参数")
+    private Boolean flgHandleSetting;
 
 
     /*

+ 21 - 0
src/main/java/com/dk/mdm/model/pojo/ivt/InboundItem.java

@@ -8,6 +8,7 @@ import com.dk.common.infrastructure.annotaiton.ExportTitle;
 import com.dk.common.infrastructure.handler.*;
 import com.dk.common.model.pojo.PageInfo;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;
 import lombok.AllArgsConstructor;
 import lombok.NoArgsConstructor;
@@ -299,6 +300,26 @@ public class InboundItem  extends PageInfo<InboundItem> implements Serializable
     @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
     private String opDbUser;
 
+    @ApiModelProperty(value = "源入库单ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sIntoId;
+
+    @ApiModelProperty(value = "源入库单明细ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sIntoItemId;
+
+    @ApiModelProperty(value = "源采购订单ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sPurId;
+
+    @ApiModelProperty(value = "源采购明细ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sPurItemId;
+
 
     @Excel(name = "入库仓库")
     @TableField(typeHandler = UuidTypeHandler.class)

+ 9 - 0
src/main/java/com/dk/mdm/model/pojo/ivt/Outbound.java

@@ -323,6 +323,15 @@ public class Outbound extends PageInfo<Outbound> implements Serializable {
     @TableField(typeHandler = UuidTypeHandler.class)
     private String outReason;
 
+
+    @Excel(name = "自动办理标识")
+    @ApiModelProperty(value = "自动办理标识")
+    private Boolean flgAutoHandle;
+
+    @Excel(name = "自动办理参数")
+    @ApiModelProperty(value = "自动办理参数")
+    private Boolean flgHandleSetting;
+
     /*
      * 相关属性
      * @TableField(exist = false)

+ 21 - 0
src/main/java/com/dk/mdm/model/pojo/ivt/OutboundItem.java

@@ -8,6 +8,7 @@ import com.dk.common.infrastructure.annotaiton.ExportTitle;
 import com.dk.common.infrastructure.handler.*;
 import com.dk.common.model.pojo.PageInfo;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import lombok.Data;
 import lombok.AllArgsConstructor;
 import lombok.NoArgsConstructor;
@@ -284,6 +285,26 @@ public class OutboundItem extends PageInfo<OutboundItem> implements Serializable
     @ApiModelProperty(value = "数据操作数据库用户 (触发器自动处理)")
     private String opDbUser;
 
+    @ApiModelProperty(value = "源出库单ID")
+    @JsonProperty(value = "sOutId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOutId;
+
+    @ApiModelProperty(value = "源出库单明细ID")
+    @JsonProperty(value = "sOutItemId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOutItemId;
+
+    @ApiModelProperty(value = "源销售订单ID")
+    @JsonProperty(value = "sOrderId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOrderId;
+
+    @ApiModelProperty(value = "源销售明细ID")
+    @JsonProperty(value = "sOrderItemId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOrderItemId;
+
 
     /*
      * 相关属性

+ 19 - 0
src/main/java/com/dk/mdm/model/response/ivt/InboundItemResponse.java

@@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.annotation.Excel;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.dk.common.infrastructure.annotaiton.ExportTitle;
 import com.dk.common.infrastructure.handler.UuidTypeHandler;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
 import lombok.Data;
@@ -221,7 +222,25 @@ public class InboundItemResponse  {
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
 
+    @ApiModelProperty(value = "源入库单ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sIntoId;
+
+    @ApiModelProperty(value = "源入库单明细ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sIntoItemId;
 
+    @ApiModelProperty(value = "源采购订单ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sPurId;
+
+    @ApiModelProperty(value = "源采购明细ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sPurItemId;
     /**
      * 商品编号
      */

+ 7 - 0
src/main/java/com/dk/mdm/model/response/ivt/InboundResponse.java

@@ -270,6 +270,13 @@ public class InboundResponse  {
     private Integer cpId;
 
 
+    @ApiModelProperty(value = "自动办理标识")
+    private Boolean flgAutoHandle;
+
+    @ApiModelProperty(value = "自动办理参数")
+    private Boolean flgHandleSetting;
+
+
     @Excel(name = "入库原因")
     @ApiModelProperty(value = "入库原因")
     @TableField(typeHandler = UuidTypeHandler.class)

+ 22 - 0
src/main/java/com/dk/mdm/model/response/ivt/OutboundItemResponse.java

@@ -8,6 +8,7 @@ import com.dk.common.infrastructure.handler.TimestampTypeHandler;
 import com.dk.common.infrastructure.handler.UuidTypeHandler;
 import com.dk.common.model.pojo.PageInfo;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -208,6 +209,27 @@ public class OutboundItemResponse {
     private Integer cpId;
 
 
+    @ApiModelProperty(value = "源出库单ID")
+    @JsonProperty(value = "sOutId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOutId;
+
+    @ApiModelProperty(value = "源出库单明细ID")
+    @JsonProperty(value = "sOutItemId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOutItemId;
+
+    @ApiModelProperty(value = "源销售订单ID")
+    @JsonProperty(value = "sOrderId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOrderId;
+
+    @ApiModelProperty(value = "源销售明细ID")
+    @JsonProperty(value = "sOrderItemId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOrderItemId;
+
+
     @Excel(name = "商品编码")
     @ApiModelProperty(value = "商品编码")
     private String skuCode;

+ 8 - 0
src/main/java/com/dk/mdm/model/response/ivt/OutboundResponse.java

@@ -260,6 +260,14 @@ public class OutboundResponse extends PageInfo<OutboundResponse> implements Seri
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
 
+    @Excel(name = "自动办理标识")
+    @ApiModelProperty(value = "自动办理标识")
+    private Boolean flgAutoHandle;
+
+    @Excel(name = "自动办理参数")
+    @ApiModelProperty(value = "自动办理参数")
+    private Boolean flgHandleSetting;
+
 
     @ApiModelProperty(value = "出库原因")
     @TableField(typeHandler = UuidTypeHandler.class)

+ 7 - 0
src/main/java/com/dk/mdm/model/vo/ivt/InOutRecordVO.java

@@ -184,6 +184,13 @@ public class InOutRecordVO  {
     @ApiModelProperty(value = "成本单价")
     private BigDecimal costPrice;
 
+    @ApiModelProperty(value = "数量编辑之前")
+    private BigDecimal qtyBeforeUpdate;
+
+    @ApiModelProperty(value = "金额编辑之前")
+    private BigDecimal amtBeforeUpdate;
+
+
 
 
 

+ 29 - 0
src/main/java/com/dk/mdm/model/vo/ivt/InboundItemVO.java

@@ -2,6 +2,7 @@ package com.dk.mdm.model.vo.ivt;
 
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.dk.common.infrastructure.handler.UuidTypeHandler;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.experimental.Accessors;
@@ -198,6 +199,27 @@ public class InboundItemVO  {
     private String whId;
 
 
+    @ApiModelProperty(value = "源入库单ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sIntoId;
+
+    @ApiModelProperty(value = "源入库单明细ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sIntoItemId;
+
+    @ApiModelProperty(value = "源采购订单ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sPurId;
+
+    @ApiModelProperty(value = "源采购明细ID")
+    @JsonProperty(value = "sIntoId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sPurItemId;
+
+
     /*
      * 相关属性
      * @TableField(exist = false)
@@ -214,6 +236,13 @@ public class InboundItemVO  {
     @ApiModelProperty(value = "库存业务类型(入库4种,出库4中)")
     private String inventoryDocCode;
 
+    @ApiModelProperty(value = "已入库数量编辑之前")
+    private BigDecimal qtyBeforeUpdate;
+
+    @ApiModelProperty(value = "已入库金额编辑之前")
+    private BigDecimal amtBeforeUpdate;
+
+
     private static final long serialVersionUID = 1L;
 
 }

+ 7 - 0
src/main/java/com/dk/mdm/model/vo/ivt/InboundVO.java

@@ -239,6 +239,13 @@ public class InboundVO {
     private String intoReason;
 
 
+    @ApiModelProperty(value = "自动办理标识")
+    private Boolean flgAutoHandle;
+
+    @ApiModelProperty(value = "自动办理参数")
+    private Boolean flgHandleSetting;
+
+
 
     /*
      * 相关属性

+ 21 - 0
src/main/java/com/dk/mdm/model/vo/ivt/OutboundItemVO.java

@@ -8,6 +8,7 @@ import com.dk.common.infrastructure.handler.TimestampTypeHandler;
 import com.dk.common.infrastructure.handler.UuidTypeHandler;
 import com.dk.common.model.pojo.PageInfo;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.AllArgsConstructor;
@@ -190,6 +191,26 @@ public class OutboundItemVO {
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
 
+    @ApiModelProperty(value = "源出库单ID")
+    @JsonProperty(value = "sOutId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOutId;
+
+    @ApiModelProperty(value = "源出库单明细ID")
+    @JsonProperty(value = "sOutItemId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOutItemId;
+
+    @ApiModelProperty(value = "源销售订单ID")
+    @JsonProperty(value = "sOrderId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOrderId;
+
+    @ApiModelProperty(value = "源销售明细ID")
+    @JsonProperty(value = "sOrderItemId")
+    @TableField(typeHandler = UuidTypeHandler.class)
+    private String sOrderItemId;
+
 
     /*
      * 相关属性

+ 9 - 0
src/main/java/com/dk/mdm/model/vo/ivt/OutboundVO.java

@@ -227,6 +227,15 @@ public class OutboundVO{
     @ApiModelProperty(value = "企业ID")
     private Integer cpId;
 
+    @Excel(name = "自动办理标识")
+    @ApiModelProperty(value = "自动办理标识")
+    private Boolean flgAutoHandle;
+
+    @Excel(name = "自动办理参数")
+    @ApiModelProperty(value = "自动办理参数")
+    private Boolean flgHandleSetting;
+
+
 
     @ApiModelProperty(value = "明细")
     private List<OutboundItemVO> itemList;

+ 0 - 13
src/main/java/com/dk/mdm/service/ivt/inbound/InboundOtherService.java

@@ -215,9 +215,6 @@ public class InboundOtherService extends BaseService<Inbound> {
 						.setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
 						.setIntoingQty(BigDecimal.ZERO)
 						.setIntoingAmt(BigDecimal.ZERO)
-				//todo 2024年3月23日15:15:56  上午开会改了  改成 每次办理的时候  中数量清零
-//						.setIntoingQty(inboundItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoingQty()))
-//						.setIntoingAmt(inboundItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoingAmt()))
 				;
 				//入库状态
 				String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
@@ -241,7 +238,6 @@ public class InboundOtherService extends BaseService<Inbound> {
 						.setCostPrice(inboundItemVO.getPriceInto())
 						.setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
 						.setIntoType(Constant.IntoType.OTHER.getName())
-				//todo 这里添加  入库中数量和金额  改成0
 						.setIntoingQty(BigDecimal.ZERO)
 						.setIntoingAmt(BigDecimal.ZERO)
 				;
@@ -278,9 +274,6 @@ public class InboundOtherService extends BaseService<Inbound> {
 		BigDecimal sumIntoAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
 		inboundVO.setIntoQty(sumIntoQty);
 		inboundVO.setIntoAmt(sumIntoAmt);
-		//todo  2024年3月23日15:32:14  这里 改成清零
-//		inboundVO.setIntoingQty(inboundResponse.getIntoingQty().subtract(sumIntoQty));
-//		inboundVO.setIntoingAmt(inboundResponse.getIntoingAmt().subtract(sumIntoAmt));
 		inboundVO.setIntoingQty(BigDecimal.ZERO);
 		inboundVO.setIntoingAmt(BigDecimal.ZERO);
 		//入库状态
@@ -318,9 +311,6 @@ public class InboundOtherService extends BaseService<Inbound> {
 		inbound.setIntoId(inboundResponse.getIntoId())
 				.setIntoDate(null)
 				.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
-				//todo 2024年3月23日15:33:58  这里改成直接取已入库数量
-//				.setIntoingQty(inboundResponse.getIntoingQty().add(inboundResponse.getIntoQty()))
-//				.setIntoingAmt(inboundResponse.getIntoingAmt().add(inboundResponse.getIntoAmt()))
 				.setIntoingQty(inboundResponse.getIntoQty())
 				.setIntoingAmt(inboundResponse.getIntoAmt())
 				.setIntoQty(BigDecimal.ZERO)
@@ -344,9 +334,6 @@ public class InboundOtherService extends BaseService<Inbound> {
 			inboundItem
 					.setIntoId(inbound.getIntoId())
 					.setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
-					//todo  2024年3月23日15:34:51  改成直接取已入库数量
-//					.setIntoingQty(inboundItemResponse.getIntoingQty().add(inboundItemResponse.getIntoQty()))
-//					.setIntoingAmt(inboundItemResponse.getIntoingAmt().add(inboundItemResponse.getIntoAmt()))
 					.setIntoingQty(inboundItemResponse.getInvQty())
 					.setIntoingAmt(inboundItemResponse.getIntoAmt())
 					.setIntoQty(BigDecimal.ZERO)

+ 0 - 320
src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseReturnService.java

@@ -67,11 +67,6 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
     @Autowired
     private InboundItemConvert inboundItemConvert;
 
-    @Autowired
-    private IntoReturnMapper intoReturnMapper;
-
-    @Autowired
-    private IntoReturnItemMapper intoReturnItemMapper;
 
     @Autowired
     private CommonService commonService;
@@ -152,52 +147,6 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
         inboundMapper.insert(inbound);
         //endregion
 
-        //region 采购退货
-        if (inboundVO.getFromId() != null) {
-            //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
-            IntoReturn  intoReturn = new IntoReturn();
-            intoReturn.setReturnId(inboundVO.getFromId());
-            //根据id查询
-            IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(inboundVO.getFromId());
-            //已入库
-            if(Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())){
-//                //第一次已入库
-//                if(intoReturnResponse.getOutingQty().compareTo(inboundVO.getIntoingQty()) == 0){
-//                    intoReturn.setOutingQty(BigDecimal.ZERO);
-//                    intoReturn.setOutingAmt(BigDecimal.ZERO);
-//                }
-//                //多次已入库
-//                else{
-//                    intoReturn.setOutingQty(inboundVO.getIntoQty());
-//                    intoReturn.setOutingAmt(inboundVO.getIntoAmt());
-//                }
-                //todo  2024年3月23日16:39:50  已入库情况下  入库中数量赋值为零
-                intoReturn.setOutingQty(BigDecimal.ZERO);
-                intoReturn.setOutingAmt(BigDecimal.ZERO);
-                intoReturn.setOutQty(inboundVO.getIntoQty().abs());
-                intoReturn.setOutAmt(inboundVO.getIntoQty().abs());
-            }
-            //入库中
-            else{
-                intoReturn.setOutingQty(inboundVO.getIntoingQty().abs());
-                intoReturn.setOutingAmt(inboundVO.getIntoingAmt().abs());
-                intoReturn.setOutQty(BigDecimal.ZERO);
-                intoReturn.setOutAmt(BigDecimal.ZERO);
-            }
-            //入库状态
-            String outStatus = this.setOutStatus(intoReturnResponse.getOutingQty().add(intoReturn.getOutingQty()),
-                    intoReturnResponse.getOutQty().add(intoReturn.getOutQty()));
-            intoReturn.setOutStatus(outStatus);
-            //修改
-            int countRow = intoReturnMapper.updateById(intoReturn);
-            //数量超出
-            if (countRow == 0) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
-            }
-        }
-        //endregion
-
-
         //region 明细
         //校验明细
         if (inboundVO.getItemList().size() == 0) {
@@ -231,51 +180,6 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
             inboundItemMapper.insert(inboundItem);
             //endregion
 
-            //region 采购退货明细
-            if (inboundItemVO.getFromItemId() != null) {
-                //赋值 (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
-                IntoReturnItem intoReturnItem = new IntoReturnItem();
-                intoReturnItem.setItemId(inboundItemVO.getFromItemId());
-                //根据id查询
-                IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
-                //已入库
-                if(Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())){
-//                    //第一次已入库
-//                    if(intoReturnItemResponse.getOutingQty().compareTo(BigDecimal.ZERO)==0){
-//                        intoReturnItem.setOutingQty(BigDecimal.ZERO);
-//                        intoReturnItem.setOutingAmt(BigDecimal.ZERO);
-//                    }
-//                    //多次已入库
-//                    else{
-//                        intoReturnItem.setOutingQty(inboundItemVO.getIntoQty());
-//                        intoReturnItem.setOutingAmt(inboundItemVO.getIntoQty());
-//                    }
-                    //todo  2024年3月23日16:37:54  已入库情况下  入库中数量赋值为零
-                    intoReturnItem.setOutingQty(BigDecimal.ZERO);
-                    intoReturnItem.setOutingAmt(BigDecimal.ZERO);
-                    intoReturnItem.setOutQty(inboundItemVO.getIntoQty().abs());
-                    intoReturnItem.setOutAmt(inboundItemVO.getIntoQty().abs());
-                }
-                //入库中
-                else{
-                    intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty().abs());
-                    intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt().abs());
-                    intoReturnItem.setOutQty(BigDecimal.ZERO);
-                    intoReturnItem.setOutAmt(BigDecimal.ZERO);
-                }
-                //出库状态
-                String outStatus = this.setOutStatus(intoReturnItemResponse.getOutingQty().add(intoReturnItem.getOutingQty()),
-                        intoReturnItemResponse.getOutQty().add(intoReturnItem.getOutQty()));
-                intoReturnItem.setOutStatus(outStatus);
-                //修改
-                int countRow = intoReturnItemMapper.updateById(intoReturnItem);
-                //数量超出
-                if (countRow == 0) {
-                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
-                }
-            }
-            //endregion
-
         }
         //endregion
 
@@ -315,9 +219,6 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
                 inboundItemVO
                         .setIntoQty(inboundItemResponse.getIntoingQty().add(inboundItemVO.getIntoingQty()))
                         .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
-//                        .setIntoingQty(inboundItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoingQty()))
-//                        .setIntoingAmt(inboundItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoingAmt()))
-                        //todo  2024年3月23日16:55:23   赋值为0
                         .setIntoingQty(BigDecimal.ZERO)
                         .setIntoAmt(BigDecimal.ZERO)
                         .setCostPrice(inboundItemVO.getPriceInto())
@@ -332,89 +233,13 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
                         new UpdateWrapper<InboundItem>().lambda()
                                 .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
                 );
-                //region  采购退货明细
-                //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
-                IntoReturnItem intoReturnItem = new IntoReturnItem();
-                intoReturnItem.setItemId(inboundItemVO.getFromItemId());
-                intoReturnItem.setOutQty(inboundItemVO.getIntoQty().abs());
-                intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt().abs());
-                //todo 2024年3月23日17:04:50   赋值为0 并且把退货单上所有数量金额相关字段反写
-//                intoReturnItem.setOutingQty(inboundItemVO.getIntoQty());
-//                intoReturnItem.setOutingAmt(inboundItemVO.getIntoAmt());
-                intoReturnItem.setOutingQty(BigDecimal.ZERO);
-                intoReturnItem.setOutAmt(BigDecimal.ZERO);
-                //根据id查询
-                IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
-                //出库状态
-                String outStatus = this.setOutStatus(intoReturnItemResponse.getOutingQty().add(intoReturnItem.getOutingQty()),
-                        intoReturnItemResponse.getOutQty().add(intoReturnItem.getOutQty()));
-                intoReturnItem.setOutStatus(outStatus);
-                //修改
-                int countRow = intoReturnItemMapper.updateById(intoReturnItem);
-                //数量超出
-                if (countRow == 0) {
-                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
-                }
-                //endregion
             }
             //endregion
-
-//            //region todo  2024年3月23日17:26:02  采购退货入库是自动生成的 不会有下面这种情况 新建明细
-//            else {
-//                inboundItemVO
-//                        .setIntoQty(inboundItemVO.getIntoingQty())
-//                        .setIntoAmt(inboundItemVO.getIntoingAmt())
-//                        .setIntoId(inboundVO.getIntoId())
-//                        .setCostPrice(inboundItemVO.getPriceInto())
-//                        .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
-//                        .setIntoType(Constant.IntoType.PURRETURN_RETURN.getName());
-//                //入库状态
-//                String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
-//                inboundItemVO.setIntoStatus(intoStatus);
-//                //实体转换
-//                InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
-//                //新建
-//                inboundItemMapper.insert(inboundItem);
-//            }
-//            //endregion
-
-            //region  todo 2024年3月23日17:26:46  配合上面代码进行注释  采购退货明细
-//            if (inboundItemVO.getFromItemId() != null) {
-//                //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
-//                IntoReturnItem intoReturnItem = new IntoReturnItem();
-//                intoReturnItem.setItemId(inboundItemVO.getFromItemId());
-//                intoReturnItem.setOutQty(inboundItemVO.getIntoQty().abs());
-//                intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt().abs());
-//                //todo 2024年3月23日17:04:50   原数据+  -原的入库明细
-////                intoReturnItem.setOutingQty(inboundItemVO.getIntoQty());
-////                intoReturnItem.setOutingAmt(inboundItemVO.getIntoAmt());
-//                //根据id查询
-//                IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
-//                //出库状态
-//                String outStatus = this.setOutStatus(intoReturnItemResponse.getOutingQty().add(intoReturnItem.getOutingQty()),
-//                        intoReturnItemResponse.getOutQty().add(intoReturnItem.getOutQty()));
-//                intoReturnItem.setOutStatus(outStatus);
-//                //修改
-//                int countRow = intoReturnItemMapper.updateById(intoReturnItem);
-//                //数量超出
-//                if (countRow == 0) {
-//                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
-//                }
-//            }
-            //endregion
         }
         //endregion
 
         //region 删除明细
-//        BigDecimal sumDelIntoQty = BigDecimal.ZERO;
-//        BigDecimal sumDelIntoAmt = BigDecimal.ZERO;
-//        BigDecimal sumDelIntoingQty = BigDecimal.ZERO;
-//        BigDecimal sumDelIntoingAmt = BigDecimal.ZERO;
         if (inboundVO.getDeleteItemList() != null) {
-//            sumDelIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-//            sumDelIntoAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
-//            sumDelIntoingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-//            sumDelIntoingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
             for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
                 if (inboundItemVO.getItemId() != null) {
                     InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
@@ -425,47 +250,16 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
                                     .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
                     );
                 }
-                //region  采购退货明细
-                if (inboundItemVO.getFromItemId() != null) {
-                    //采购退货单明细
-                    //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
-                    IntoReturnItem intoReturnItem = new IntoReturnItem();
-                    intoReturnItem.setItemId(inboundItemVO.getFromItemId());
-                    intoReturnItem.setOutQty(inboundItemVO.getIntoQty());
-                    intoReturnItem.setOutAmt(inboundItemVO.getIntoAmt());
-                    intoReturnItem.setOutingQty(inboundItemVO.getIntoingQty());
-                    intoReturnItem.setOutingAmt(inboundItemVO.getIntoingAmt());
-                    //根据id查询
-                    IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemVO.getFromItemId());
-                    //出库状态
-                    String outStatus = this.setOutStatus(intoReturnItemResponse.getOutingQty().add(intoReturnItem.getOutingQty()),
-                            intoReturnItemResponse.getOutQty().add(intoReturnItem.getOutQty()));
-                    intoReturnItem.setOutStatus(outStatus);
-                    //修改
-                    int countRow = intoReturnItemMapper.updateById(intoReturnItem);
-                    //数量超出
-                    if (countRow == 0) {
-                        throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
-                    }
-
-                }
-                //endregion
 
             }
         }
         //endregion
 
         //region 编辑总单
-//        InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
         BigDecimal sumIntoQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
         BigDecimal sumIntoAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
-//        BigDecimal sumIntoingQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-//        BigDecimal sumIntoingAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
         inboundVO.setIntoQty(sumIntoQty);
         inboundVO.setIntoAmt(sumIntoAmt);
-        //todo 2024年3月25日08:50:04   直接赋值给0
-//        inboundVO.setIntoingQty(inboundResponse.getIntoingQty().subtract(sumIntoQty));
-//        inboundVO.setIntoingAmt(inboundResponse.getIntoingAmt().subtract(sumIntoAmt));
         inboundVO.setIntoingQty(BigDecimal.ZERO);
         inboundVO.setIntoingAmt(BigDecimal.ZERO);
         //入库状态
@@ -480,41 +274,6 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
         );
         //endregion
 
-        //region  修改采购退货订单
-        if (inboundVO.getFromId() != null) {
-            //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
-            IntoReturn intoReturn = new IntoReturn();
-            intoReturn.setReturnId(inboundVO.getFromId());
-
-            //region  todo 2024年3月20日13:13:05 这里可能用不到
-//            intoReturn.setOutQty((sumIntoQty.subtract(sumDelIntoQty)).abs());
-//            intoReturn.setOutAmt((sumIntoAmt.subtract(sumDelIntoAmt)).abs());
-//            intoReturn.setOutingQty(sumIntoQty.add(sumDelIntoingQty));
-//            intoReturn.setOutingAmt(sumIntoAmt.add(sumDelIntoingAmt));
-            //endregion
-
-            intoReturn.setOutQty(sumIntoQty.abs());
-            intoReturn.setOutAmt(sumIntoAmt.abs());
-            //todo  这里取次方法刚进入时候查询的入库总单上的数量
-//            intoReturn.setOutingQty(sumIntoQty);
-//            intoReturn.setOutingAmt(sumIntoAmt);
-            intoReturn.setOutingQty(inboundWriteBack.getIntoingQty());
-            intoReturn.setOutingAmt(inboundWriteBack.getIntoAmt());
-            //根据id查询
-            IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(inboundVO.getFromId());
-            //出库状态
-            String outStatus = this.setOutStatus(intoReturnResponse.getOutingQty().add(intoReturn.getOutingQty()),
-                    intoReturnResponse.getOutQty().add(intoReturn.getOutQty()));
-            intoReturn.setOutStatus(outStatus);
-            //修改
-            int countRow = intoReturnMapper.updateById(intoReturn);
-            //数量超出
-            if (countRow == 0) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
-            }
-        }
-        //endregion
-
         //todo 如果是已入库 调用库存  后续写库存这里补上
         //region 修改库存
 
@@ -534,30 +293,6 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
         InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
         //endregion
 
-        //region 修改订单数据信息
-        if (inboundVO.getFromId() != null) {
-            //赋值  (这里重写了更新方法,数量在更新方法中有数据库原始数量+本次数量)
-            IntoReturn intoReturn = new IntoReturn();
-            intoReturn.setReturnId(inboundVO.getFromId());
-            intoReturn.setOutQty(inboundResponse.getIntoQty());
-            intoReturn.setOutAmt(inboundResponse.getIntoAmt());
-            intoReturn.setOutingQty(inboundResponse.getIntoQty().abs());
-            intoReturn.setOutingAmt(inboundResponse.getIntoAmt().abs());
-            //根据id查询
-            IntoReturnResponse intoReturnResponse = intoReturnMapper.selectById(inboundVO.getFromId());
-            //出库状态
-            String outStatus = this.setOutStatus(intoReturnResponse.getOutingQty().add(intoReturn.getOutingQty()),
-                    intoReturnResponse.getOutQty().add(intoReturn.getOutQty()));
-            intoReturn.setOutStatus(outStatus);
-            //修改
-            int countRow = intoReturnMapper.updateById(intoReturn);
-            //数量超出
-            if (countRow == 0) {
-                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
-            }
-        }
-        //endregion
-
         //region 修改总单数据信息
         Inbound inbound = new Inbound();
         inbound.setIntoId(inboundVO.getIntoId());
@@ -579,38 +314,11 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
         //根据总单id查明细
         List<InboundItemResponse> orderEntryItemResponsesList = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inbound.getIntoId()));
         for (InboundItemResponse inboundItemResponse : orderEntryItemResponsesList) {
-            //region 修改采购退货明细数据信息
-            if (inboundItemResponse.getFromItemId() != null) {
-                //赋值  (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
-                IntoReturnItem intoReturnItem = new IntoReturnItem();
-                intoReturnItem.setItemId(inboundItemResponse.getFromItemId());
-                intoReturnItem.setOutQty(inboundItemResponse.getIntoQty());
-                intoReturnItem.setOutAmt(inboundItemResponse.getIntoAmt());
-                intoReturnItem.setOutingQty(inboundItemResponse.getIntoQty().abs());
-                intoReturnItem.setOutingAmt(inboundItemResponse.getIntoAmt().abs());
-                //根据id查询
-                IntoReturnItemResponse intoReturnItemResponse = intoReturnItemMapper.selectById(inboundItemResponse.getFromItemId());
-                //出库状态
-                String outStatus = this.setOutStatus(intoReturnItemResponse.getOutingQty().add(intoReturnItem.getOutingQty()),
-                        intoReturnItemResponse.getOutQty().add(intoReturnItem.getOutQty()));
-                intoReturnItem.setOutStatus(outStatus);
-                //修改
-                int countRow = intoReturnItemMapper.updateById(intoReturnItem);
-                //数量超出
-                if (countRow == 0) {
-                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
-                }
-            }
-            //endregion
-
             //region修改入库明细信息
             InboundItem inboundItem = new InboundItem();
             inboundItem
                     .setIntoId(inbound.getIntoId())
                     .setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
-                    //todo  2024年3月25日10:07:16 取数据库中已入库数量
-//                    .setIntoingQty(inboundItemResponse.getIntoingQty().add(inboundItemResponse.getIntoQty()))
-//                    .setIntoingAmt(inboundItemResponse.getIntoingAmt().add(inboundItemResponse.getIntoAmt()))
                     .setIntoQty(inboundItemResponse.getIntoQty())
                     .setIntoAmt(inboundItemResponse.getIntoAmt())
                     .setIntoQty(BigDecimal.ZERO)
@@ -666,34 +374,6 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
 
 
     /**
-     * @desc : 出库状态通用(目前本页面)
-     * @date : 2024/3/9 8:59
-     * @author : 寇珊珊
-     */
-    public String setOutStatus(BigDecimal outingQty, BigDecimal outQty) {
-        //出库状态
-        String outStatus = null;
-        //已出库数量>0 出库中数量>0
-        if (outQty.compareTo(BigDecimal.ZERO) >= 0 && outingQty.compareTo(BigDecimal.ZERO) > 0) {
-            //出库中
-            outStatus = Constant.OutStatus.CHUKUZHONG.getName();
-        }
-        //出入库数量=0 出库中数量=0
-        else if (outQty.compareTo(BigDecimal.ZERO) == 0 && outingQty.compareTo(BigDecimal.ZERO) == 0) {
-            //待出库
-            outStatus = Constant.OutStatus.DAICHUKU.getName();
-        }
-        //已出库数量>0 出库中数量=0
-        else if (outQty.compareTo(BigDecimal.ZERO) > 0 && outingQty.compareTo(BigDecimal.ZERO) == 0) {
-            //已出库
-            outStatus = Constant.OutStatus.YICHUKU.getName();
-        }
-        return outStatus;
-    }
-
-
-
-    /**
      * @desc   : 获取单据信息(编辑用)
      * @date   : 2024/3/16 16:28
      * @author : 寇珊珊

+ 394 - 110
src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseService.java

@@ -13,6 +13,7 @@ import com.dk.common.response.ResponseResultVO;
 import com.dk.common.service.BaseService;
 import com.dk.mdm.infrastructure.convert.ivt.InboundConvert;
 import com.dk.mdm.infrastructure.convert.ivt.InboundItemConvert;
+import com.dk.mdm.mapper.common.CommonMapper;
 import com.dk.mdm.mapper.ivt.InboundItemMapper;
 import com.dk.mdm.mapper.ivt.InboundMapper;
 import com.dk.mdm.mapper.pur.PurchaseItemMapper;
@@ -30,6 +31,7 @@ import com.dk.mdm.model.response.pur.PurchaseResponse;
 import com.dk.mdm.model.vo.ivt.InboundItemVO;
 import com.dk.mdm.model.vo.ivt.InboundVO;
 import com.dk.mdm.service.common.CommonService;
+import com.dk.mdm.service.ivt.inventory.InventoryService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -75,6 +77,12 @@ public class InboundPurchaseService extends BaseService<Inbound> {
     @Autowired
     private CommonService commonService;
 
+    @Autowired
+    private InventoryService inventoryService;
+
+    @Autowired
+    private CommonMapper commonMapper;
+
 
     /**
      * @desc : 条件查询
@@ -113,6 +121,18 @@ public class InboundPurchaseService extends BaseService<Inbound> {
      */
     @Transactional(rollbackFor = {Exception.class})
     public ResponseResultVO<?> purchaseInboundInsert(InboundVO inboundVO) {
+        //region  查询当前公司的系统参数  自动办理信息  并赋值
+        Map<String, Object> map = new HashMap<>();
+        map.put("cpId", inboundVO.getCpId());
+        map.put("code", "IVT_001");
+        //自动办理标识
+        String flgHandleSetting = commonMapper.getSettingValue(map);
+        //自动办理标识为1 自动办理入库
+        if(Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)){
+            inboundVO.setFlgHandleSetting(Constant.FlgHandleSetting.TRUE.getValue());
+        }
+        //endregion
+
         //region  总单
         //获取 id/单号
         Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.PURCASEINBOUND.getName(), false);
@@ -121,7 +141,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         //入库类型
         inboundVO.setIntoType(Constant.IntoType.SALE.getName());
         //自动入库标识
-        if (inboundVO.getAutomaticFlg()) {
+        if (inboundVO.getFlgAutoHandle()) {
             //已入库
             inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
         } else {
@@ -154,17 +174,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
             PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
             //已入库
             if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
-//				//直接已入库
-//				if(purchaseResponse.getIntoingQty().compareTo(BigDecimal.ZERO)==0){
-//					purchaseUpdate.setIntoingQty(BigDecimal.ZERO);
-//					purchaseUpdate.setIntoingAmt(BigDecimal.ZERO);
-//				}
-//				//多次已入库
-//				else{
-//					purchaseUpdate.setIntoingQty(inboundVO.getIntoQty().negate());
-//					purchaseUpdate.setIntoingAmt(inboundVO.getIntoAmt().negate());
-//				}
-                //todo  2024年3月25日11:31:52  这里直接赋值0
                 purchaseUpdate.setIntoingQty(BigDecimal.ZERO);
                 purchaseUpdate.setIntoingAmt(BigDecimal.ZERO);
                 purchaseUpdate.setIntoQty(inboundVO.getIntoQty());
@@ -198,6 +207,10 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                     ErrorCodeEnum.INBOUND_ITEM_NOT_EXIST.getMessage());
         }
         for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
+            //region 将库存需要的参数赋值
+            inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
+            inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
+            //endregion
             //总单id
             inboundItemVO.setIntoId(inboundVO.getIntoId());
             //入库类型
@@ -233,16 +246,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
                 //已入库
                 if (Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())) {
-//					//第一次已入库
-//					if(purchaseItemResponse.getIntoingQty().compareTo(BigDecimal.ZERO)==0){
-//						purchaseItem.setIntoingQty(BigDecimal.ZERO);
-//						purchaseItem.setIntoingAmt(BigDecimal.ZERO);
-//					}
-//					//多次已入库
-//					else{
-//						purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
-//						purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
-//					}
                     //2024年3月25日11:49:17  直接赋值为0
                     purchaseItem.setIntoingQty(BigDecimal.ZERO);
                     purchaseItem.setIntoingAmt(BigDecimal.ZERO);
@@ -270,16 +273,348 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         }
         //endregion
 
-        //todo 如果是已入库 调用库存  后续写库存这里补上
+        //region 已入库调用账款 todo
+//        if(Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus()){
+//
+//        }
+        //endregion
+
         //region 库存
+//        if(Constant.IntoStatus.YIRUKU.getName().equals(inboundVO.getIntoStatus())){
+//            Map<String, Object> invMap = new HashMap<>();
+//            invMap.put("intoDetail",inboundVO.getItemList());
+//            inventoryService.updateInventoryInformation(map);
+//        }
+        //endregion
 
 
+        return ResponseResultUtil.success(inboundVO);
+    }
+
+    /**
+     * @desc : 采购入库编辑
+     * @date : 2024/3/25 16:25
+     * @author : 寇珊珊
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<?> purchaseInboundUpdate(InboundVO inboundVO) {
+        //region 根据id查询 此条入库单的数据还未更改前的数据
+        InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
+        BigDecimal sumQty = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+        BigDecimal sumAmt = inboundVO.getItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
         //endregion
 
+        //region  自动办理参数为true  已入库编辑
+        //自动办理参数为true
+        if (Constant.FlgHandleSetting.TRUE.getValue().equals(inboundVO.getFlgHandleSetting())) {
+            //region   todo  退账 当单据红的账款id不为空说明有账, 要先退账才能进行操作
+            if (inboundVO.getReceivableId() != null) {
+
+            }
+            //endregion
+
+            //region 修改明细
+            List<InboundItemVO> itemList = inboundVO.getItemList();
+            for (InboundItemVO inboundItemVO : itemList) {
+                //根据id查询
+                InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
+                //region 将库存需要的参数赋值
+                inboundItemVO.setInventoryType(Constant.InventoryType.INBOUND.getName());
+                inboundItemVO.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
+                //编辑之前的数
+                inboundItemVO.setQtyBeforeUpdate(inboundItemResponse.getIntoQty());
+                inboundItemVO.setAmtBeforeUpdate(inboundItemResponse.getIntoAmt());
+                //编辑之后的数
+                inboundItemVO.setIntoQty(inboundItemVO.getIntoQty());
+                inboundItemVO.setIntoAmt(inboundItemVO.getIntoAmt());
+
+                //endregion
+
+                //赋值
+                InboundItem inboundItem = new InboundItem();
+                inboundItem.setItemId(inboundItemVO.getItemId());
+                inboundItem.setIntoQty(inboundItemVO.getIntoingQty());
+                inboundItem.setIntoAmt(inboundItemVO.getIntoingAmt());
+                //修改
+                inboundItemMapper.update(inboundItem,
+                        new UpdateWrapper<InboundItem>().lambda()
+                                .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                );
+
+                //region  销售明细
+                if (inboundItemVO.getFromItemId() != null) {
+                    //根据id查询
+                    PurchaseItem purchaseItem = new PurchaseItem();
+                    purchaseItem.setItemId(inboundItemVO.getFromItemId());
+                    purchaseItem.setIntoQty(inboundItemResponse.getIntoQty().negate().add(inboundItemVO.getIntoingQty()));
+                    purchaseItem.setIntoAmt(inboundItemResponse.getIntoAmt().negate().add(inboundItemVO.getIntoingAmt()));
+                    int countRow = purchaseItemMapper.updateById(purchaseItem);
+                    //数量超出
+                    if (countRow == 0) {
+                        throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+                    }
+                }
+                //endregion
+            }
+            //endregion
+
+            //region  修改入库总单
+            Inbound inbound = new Inbound();
+            inbound.setIntoId(inboundVO.getIntoId());
+            inbound.setIntoQty(sumQty);
+            inbound.setIntoAmt(sumAmt);
+            //修改
+            inboundMapper.update(inbound,
+                    new UpdateWrapper<Inbound>().lambda().eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
+            );
+            //endregion
+
+            //region 修改销售总单
+            Purchase purchase = new Purchase();
+            purchase.setPurId(inboundVO.getFromId());
+            purchase.setIntoQty(inboundResponse.getIntoQty().negate().add(sumQty));
+            purchase.setIntoAmt(inboundResponse.getIntoAmt().negate().add(sumAmt));
+            //修改
+            int countRow = purchaseMapper.updateById(purchase);
+            //数量超出
+            if (countRow == 0) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+            }
+            //endregion
+
+            //region   todo  入账 当单据红的账款id不为空说明有账, 最后要入账
+            if (inboundVO.getReceivableId() != null) {
+
+            }
+            //endregion
+
+            //region  todo调用库存
+//            if(Constant.IntoStatus.YIRUKU.getName().equals(inboundResponse.getIntoStatus())){
+//                Map<String, Object> map = new HashMap<>();
+//                map.put("intoDetail",inboundVO.getItemList());
+//                inventoryService.updateInventoryInformation(map);
+//            }
+            //endregion
+        }
+        //endregion
+
+        //region 自动办理参数false  入库中编辑
+        //自动办理标识为false 并且 自动办理参数为false  入库中
+        if (!inboundVO.getFlgAutoHandle() && Constant.FlgHandleSetting.FALSE.getValue().equals(inboundVO.getFlgHandleSetting())) {
+            //region 修改明细
+            List<InboundItemVO> itemList = inboundVO.getItemList();
+            for (InboundItemVO inboundItemVO : itemList) {
+                //根据id查询 获取到还未进行修改的数据
+                InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
+                //赋值
+                InboundItem inboundItem = new InboundItem();
+                inboundItem.setItemId(inboundItemVO.getItemId());
+                inboundItem.setIntoingQty(inboundItemVO.getIntoingQty());
+                inboundItem.setIntoingAmt(inboundItemVO.getIntoingAmt());
+                //修改
+                inboundItemMapper.update(inboundItem,
+                        new UpdateWrapper<InboundItem>().lambda()
+                                .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                );
+                //region  销售明细
+                if (inboundItemVO.getFromItemId() != null) {
+                    //根据id查询
+                    PurchaseItem purchaseItem = new PurchaseItem();
+                    purchaseItem.setItemId(inboundItemVO.getFromItemId());
+                    //本次修改几个传几个(负数)  sql中是原数据+本次修改数据
+                    purchaseItem.setIntoingQty(inboundItemResponse.getIntoingQty().negate().add(inboundItemVO.getIntoingQty()));
+                    purchaseItem.setIntoingAmt(inboundItemResponse.getIntoingAmt().negate().add(inboundItemVO.getIntoingAmt()));
+                    int countRow = purchaseItemMapper.updateById(purchaseItem);
+                    //数量超出
+                    if (countRow == 0) {
+                        throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+                    }
+                }
+                //endregion
+            }
+            //endregion
+            //region  修改入库总单
+            Inbound inbound = new Inbound();
+            inbound.setIntoId(inboundVO.getIntoId());
+            inbound.setIntoingQty(sumQty);
+            inbound.setIntoAmt(sumAmt);
+            //修改
+            inboundMapper.update(inbound,
+                    new UpdateWrapper<Inbound>().lambda().eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
+            );
+            //endregion
+            //region 修改销售总单
+            Purchase purchase = new Purchase();
+            purchase.setPurId(inboundVO.getFromId());
+            purchase.setIntoingQty(inboundResponse.getIntoingQty().negate().add(sumQty));
+            purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate().add(sumAmt));
+            //修改
+            int countRow = purchaseMapper.updateById(purchase);
+            //数量超出
+            if (countRow == 0) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+            }
+            //endregion
+        }
+        //endregion
 
         return ResponseResultUtil.success(inboundVO);
     }
 
+    /**
+     * @desc   : 采购入库作废
+     * @date   : 2024/3/26 9:24
+     * @author : 寇珊珊
+     */
+    @Transactional(rollbackFor = {Exception.class})
+    public ResponseResultVO<?> purchaseInboundRepeal(String intoId) {
+        //region  查询总单  查询明细
+        //根据id查询 此条入库单的数据还未更改前的数据
+        InboundResponse inboundResponse = inboundMapper.selectById(intoId);
+        //根据总单id查询
+        List<InboundItemResponse> inboundItemResponseList = inboundItemMapper.selectByCond(new InboundItemQuery().setIntoId(inboundResponse.getIntoId()));
+        //endregion
+
+        //region  自动办理参数为true  已入库编辑
+        //自动办理参数为true
+        if (Constant.FlgHandleSetting.TRUE.getValue().equals(inboundResponse.getFlgHandleSetting())) {
+            //region   todo  退账 当单据红的账款id不为空说明有账, 要先退账才能进行操作
+            if (inboundResponse.getReceivableId() != null) {
+
+            }
+            //endregion
+
+            //region 修改明细
+            for (InboundItemResponse inboundItemResponse : inboundItemResponseList) {
+                //region 将库存需要的参数赋值
+                inboundItemResponse.setInventoryType(Constant.InventoryType.INBOUND.getName());
+                inboundItemResponse.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
+                inboundItemResponse.setIntoQty(inboundItemResponse.getIntoQty().negate());
+                inboundItemResponse.setIntoAmt(inboundItemResponse.getIntoAmt().negate());
+                //endregion
+
+                //赋值
+                InboundItem inboundItem = new InboundItem();
+                inboundItem.setItemId(inboundItemResponse.getItemId());
+                inboundItem.setFlgValid(false);
+                //修改
+                inboundItemMapper.update(inboundItem,
+                        new UpdateWrapper<InboundItem>().lambda()
+                                .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                );
+
+                //region  销售明细
+                if (inboundItemResponse.getFromItemId() != null) {
+                    //根据id查询
+                    PurchaseItem purchaseItem = new PurchaseItem();
+                    purchaseItem.setItemId(inboundItemResponse.getFromItemId());
+                    purchaseItem.setIntoQty(BigDecimal.ZERO);
+                    purchaseItem.setIntoAmt(BigDecimal.ZERO);
+                    int countRow = purchaseItemMapper.updateById(purchaseItem);
+                    //数量超出
+                    if (countRow == 0) {
+                        throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+                    }
+                }
+                //endregion
+            }
+            //endregion
+
+            //region  修改入库总单
+            Inbound inbound = new Inbound();
+            inbound.setIntoId(inboundResponse.getIntoId());
+            inbound.setFlgValid(false);
+            //修改
+            inboundMapper.update(inbound,
+                    new UpdateWrapper<Inbound>().lambda().eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
+            );
+            //endregion
+
+            //region 修改销售总单
+            Purchase purchase = new Purchase();
+            purchase.setPurId(inboundResponse.getFromId());
+            purchase.setIntoQty(BigDecimal.ZERO);
+            purchase.setIntoQty(BigDecimal.ZERO);
+            //修改
+            int countRow = purchaseMapper.updateById(purchase);
+            //数量超出
+            if (countRow == 0) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+            }
+            //endregion
+
+            //region   todo  入账 当单据红的账款id不为空说明有账, 最后要入账
+            if (inboundResponse.getReceivableId() != null) {
+
+            }
+            //endregion
+
+            //region  todo 调用库存
+//                Map<String, Object> map = new HashMap<>();
+//                map.put("intoDetail",inboundItemResponseList);
+//                inventoryService.updateInventoryInformation(map);
+            //endregion
+        }
+        //endregion
+
+        //region 自动办理参数false  入库中编辑
+        //自动办理标识为false 并且 自动办理参数为false  入库中
+        if (!inboundResponse.getFlgAutoHandle() && Constant.FlgHandleSetting.FALSE.getValue().equals(inboundResponse.getFlgHandleSetting())) {
+            //region 修改明细
+            for (InboundItemResponse inboundItemResponse : inboundItemResponseList) {
+                //赋值
+                InboundItem inboundItem = new InboundItem();
+                inboundItem.setItemId(inboundItemResponse.getItemId());
+                inboundItem.setIntoingQty(BigDecimal.ZERO);
+                inboundItem.setIntoingAmt(BigDecimal.ZERO);
+                //修改
+                inboundItemMapper.update(inboundItem,
+                        new UpdateWrapper<InboundItem>().lambda()
+                                .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                );
+                //region  销售明细
+                if (inboundItemResponse.getFromItemId() != null) {
+                    //根据id查询
+                    PurchaseItem purchaseItem = new PurchaseItem();
+                    purchaseItem.setItemId(inboundItemResponse.getFromItemId());
+                    purchaseItem.setIntoingQty(inboundItemResponse.getIntoingQty().negate());
+                    purchaseItem.setIntoingAmt(inboundItemResponse.getIntoingAmt().negate());
+                    int countRow = purchaseItemMapper.updateById(purchaseItem);
+                    //数量超出
+                    if (countRow == 0) {
+                        throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+                    }
+                }
+                //endregion
+            }
+            //endregion
+            //region  修改入库总单
+            Inbound inbound = new Inbound();
+            inbound.setIntoId(inboundResponse.getIntoId());
+            inbound.setIntoingQty(BigDecimal.ZERO);
+            inbound.setIntoAmt(BigDecimal.ZERO);
+            //修改
+            inboundMapper.update(inbound,
+                    new UpdateWrapper<Inbound>().lambda().eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
+            );
+            //endregion
+            //region 修改销售总单
+            Purchase purchase = new Purchase();
+            purchase.setPurId(inboundResponse.getFromId());
+            purchase.setIntoingQty(inboundResponse.getIntoingQty().negate());
+            purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate());
+            //修改
+            int countRow = purchaseMapper.updateById(purchase);
+            //数量超出
+            if (countRow == 0) {
+                throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
+            }
+            //endregion
+        }
+        //endregion
+
+        return ResponseResultUtil.success();
+    }
 
     /**
      * @desc : 采购入库办理
@@ -288,16 +623,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
      */
     @Transactional(rollbackFor = {Exception.class})
     public ResponseResultVO<?> purchaseHandleInbound(InboundVO inboundVO) {
-        //region 根据订单id查询入库数据
-        List<InboundResponse> inboundResponses = inboundMapper.selectByCond(new InboundQuery().setFromId(inboundVO.getFromId()));
-        BigDecimal intoingQtyTotal = BigDecimal.ZERO;
-        BigDecimal intoingAmtTotal = BigDecimal.ZERO;
-        if (inboundResponses != null && inboundResponses.size() > 0) {
-            //入库中数据  汇总
-            intoingQtyTotal = inboundResponses.stream().map(InboundResponse::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-            intoingAmtTotal = inboundResponses.stream().map(InboundResponse::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-        }
-        //endregion
         //region 根据id查询 此条入库单的数据还未更改前的数据
         InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
         //endregion
@@ -312,15 +637,17 @@ public class InboundPurchaseService extends BaseService<Inbound> {
             //入库明细根据id查询
             InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
             if (inboundItemVO.getIntoId() != null) {
+                //region 将库存需要的参数赋值
+                inboundItemResponse.setInventoryType(Constant.InventoryType.INBOUND.getName());
+                inboundItemResponse.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
+                //endregion
+
                 //region 采购明细
                 //根据id查询
                 PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
                 //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
                 PurchaseItem purchaseItem = new PurchaseItem();
                 purchaseItem.setItemId(inboundItemVO.getFromItemId());
-                //todo 取入库单的入库中数据
-//                purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
-//                purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
                 purchaseItem.setIntoingQty(inboundItemResponse.getIntoingQty().negate());
                 purchaseItem.setIntoingAmt(inboundItemResponse.getIntoingAmt().negate());
                 purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
@@ -341,9 +668,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                         .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
                         .setIntoQty(inboundItemResponse.getOutQty().add(inboundItemVO.getIntoQty()))
                         .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoAmt()))
-//						.setIntoingQty(inboundItemResponse.getIntoingQty().subtract(inboundItemVO.getIntoingQty()))
-//						.setIntoingAmt(inboundItemResponse.getIntoingAmt().subtract(inboundItemVO.getIntoingAmt()))
-                        //todo  2024年3月25日12:57:07 直接赋值为0
                         .setIntoingQty(BigDecimal.ZERO)
                         .setIntoingAmt(BigDecimal.ZERO)
                         .setCostPrice(inboundItemVO.getPriceInto())
@@ -363,64 +687,9 @@ public class InboundPurchaseService extends BaseService<Inbound> {
             }
         }
         //endregion
-//			//region 新建明细 todo 注释掉
-//			else {
-//				inboundItemVO
-//						.setIntoQty(inboundItemVO.getIntoingQty())
-//						.setIntoAmt(inboundItemVO.getIntoingAmt())
-//						//todo 2024年3月25日12:58:01  赋值0
-//						.setIntoingQty(BigDecimal.ZERO)
-//						.setIntoAmt(BigDecimal.ZERO)
-//						.setIntoId(inboundVO.getIntoId())
-//						.setCostPrice(inboundItemVO.getPriceInto())
-//						.setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
-//						.setIntoType(Constant.IntoType.SALE.getName());
-//				//入库状态
-//				String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
-//				inboundItemVO.setIntoStatus(intoStatus);
-//				//实体转换
-//				InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
-//				//新建
-//				inboundItemMapper.insert(inboundItem);
-//			}
-//			//endregion
-
-        //region  采购 todo  注释掉
-        //采购明细
-//			if (inboundItemVO.getFromItemId() != null) {
-//				//赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
-//				PurchaseItem purchaseItem = new PurchaseItem();
-//				purchaseItem.setItemId(inboundItemVO.getFromItemId());
-//				purchaseItem.setIntoingQty(inboundItemVO.getIntoQty().negate());
-//				purchaseItem.setIntoingAmt(inboundItemVO.getIntoAmt().negate());
-//				purchaseItem.setIntoQty(inboundItemVO.getIntoQty());
-//				purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt());
-//				//根据id查询
-//				PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
-//				//入库状态
-//				String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
-//						purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()));
-//				purchaseItem.setIntoStatus(intoStatus);
-//				int countRow = purchaseItemMapper.updateById(purchaseItem);
-//				//数量超出
-//				if (countRow == 0) {
-//					throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
-//				}
-//			}
-        //endregion
-//    }
-        //endregion
 
-        //region 删除明细 todo 2024年3月20日13:14:20 这里可能用不到
-//        BigDecimal sumDelIntoQty = BigDecimal.ZERO;
-//        BigDecimal sumDelIntoAmt = BigDecimal.ZERO;
-//        BigDecimal sumDelIntoingQty = BigDecimal.ZERO;
-//        BigDecimal sumDelIntoingAmt = BigDecimal.ZERO;
+        //region 删除明细
         if (inboundVO.getDeleteItemList() != null) {
-//            sumDelIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-//            sumDelIntoAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
-//            sumDelIntoingQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
-//            sumDelIntoingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
             for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
                 if (inboundItemVO.getItemId() != null) {
                     InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
@@ -467,8 +736,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         inboundVO.setIntoAmt(sumIntoAmt);
         inboundVO.setIntoingQty(BigDecimal.ZERO);
         inboundVO.setIntoingAmt(BigDecimal.ZERO);
-//		inboundVO.setIntoingQty(inboundResponse.getIntoingQty());
-//		inboundVO.setIntoingAmt(inboundResponse.getIntoingAmt().subtract(sumIntoAmt));
         //入库状态
         String intoStatus = this.setIntoStatus(inboundVO.getIntoingQty(), inboundVO.getIntoQty());
         inboundVO.setIntoStatus(intoStatus);
@@ -485,12 +752,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
             //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
             Purchase purchase = new Purchase();
             purchase.setPurId(inboundVO.getFromId());
-            //region  todo 2024年3月20日13:14:51 这里可能用不到
-//			purchase.setIntoQty(sumIntoQty.subtract(sumDelIntoQty));
-//			purchase.setIntoAmt(sumIntoAmt.subtract(sumDelIntoAmt));
-//			purchase.setIntoingQty((sumIntoingQty.add(sumDelIntoingQty)).negate());
-//			purchase.setIntoingAmt((sumIntoingAmt.add(sumDelIntoingAmt)).negate());
-            //endregion
             purchase.setIntoQty(sumIntoQty);
             purchase.setIntoAmt(sumIntoAmt);
             //todo 2024年3月25日14:50:41  取
@@ -498,8 +759,6 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 purchase.setIntoingQty(inboundResponse.getIntoingQty().negate());
                 purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate());
             }
-//            purchase.setIntoingQty(sumIntoQty.negate());
-//            purchase.setIntoingAmt(sumIntoAmt.negate());
             //根据id查询
             PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
             //入库状态
@@ -515,8 +774,15 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         }
         //endregion
 
-        //todo 如果是已入库 调用库存  后续写库存这里补上
-        //region 修改库存
+        //region todo  调用账款
+
+        //endregion
+
+        //region  todo 调用库存
+//                Map<String, Object> map = new HashMap<>();
+//                map.put("intoDetail",inboundItemResponseList);
+//                inventoryService.updateInventoryInformation(map);
+        //endregion
 
         //endregion
         return ResponseResultUtil.success(inboundVO);
@@ -534,6 +800,12 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         InboundResponse inboundResponse = inboundMapper.selectById(inboundVO.getIntoId());
         //endregion
 
+        //region   todo  退账 当单据红的账款id不为空说明有账, 要先退账才能进行操作
+        if (inboundResponse.getReceivableId() != null) {
+
+        }
+        //endregion
+
         //region 修改订单数据信息
         if (inboundResponse.getFromId() != null) {
             //赋值  (这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
@@ -603,6 +875,14 @@ public class InboundPurchaseService extends BaseService<Inbound> {
 
             //region修改入库明细信息
             InboundItem inboundItem = new InboundItem();
+
+            //region 将库存需要的参数赋值
+            inboundItemResponse.setInventoryType(Constant.InventoryType.INBOUND.getName());
+            inboundItemResponse.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
+            inboundItemResponse.setIntoQty(inboundItemResponse.getIntoQty().negate());
+            inboundItemResponse.setIntoAmt(inboundItemResponse.getIntoAmt().negate());
+            //endregion
+
             inboundItem
                     .setIntoId(inbound.getIntoId())
                     .setIntoStatus(Constant.IntoStatus.RUKUZHONG.getName())
@@ -613,6 +893,9 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                     .setCostPrice(BigDecimal.ZERO)
                     .setCostAmt(BigDecimal.ZERO)
                     .setItemId(inboundItemResponse.getItemId());
+            //入库状态
+            String intoStatus = this.setIntoStatus(inboundItem.getIntoingQty(), inboundItem.getIntoQty());
+            inboundItem.setIntoStatus(intoStatus);
             //修改
             inboundItemMapper.update(inboundItem,
                     new UpdateWrapper<InboundItem>().lambda()
@@ -623,9 +906,10 @@ public class InboundPurchaseService extends BaseService<Inbound> {
         //endregion
 
 
-        //todo 调用库存  后续写库存这里补上
-        //region 修改库存
-
+        //region  todo 调用库存
+//                Map<String, Object> map = new HashMap<>();
+//                map.put("intoDetail",inboundItemResponseList);
+//                inventoryService.updateInventoryInformation(map);
         //endregion
 
         return ResponseResultUtil.success();