koushanshan 2 年之前
父節點
當前提交
2f3fc6c01d

+ 3 - 4
src/main/java/com/dk/mdm/mapper/ivt/InboundItemMapper.xml

@@ -145,6 +145,7 @@
     <!-- 通用条件列 -->
     <sql id="Condition">
         <where>
+            tpii.flg_valid
             <if test="intoId != null and intoId != ''">
                 AND tpii.into_id = #{intoId}::uuid
             </if>
@@ -172,12 +173,8 @@
             <if test="invId != null and invId != ''">
                 AND tpii.inv_id = #{invId}
             </if>
-            <if test="flgValid != null">
-                AND tpii.flg_valid = #{flgValid}
-            </if>
             <if test="cpId != null">
                 AND tpii.cp_id = #{cpId}
-
             </if>
         </where>
     </sql>
@@ -407,6 +404,7 @@
         FROM dkic_b.t_psi_inbound_item tpii
         <include refid="Select_Inbound_Join_Table_Into"/>
         <where>
+            tpii.flg_valid
             <if test="intoId != null and intoId != ''">
                 AND tpii.into_id = #{intoId}::uuid
             </if>
@@ -424,6 +422,7 @@
         from dkic_b.t_psi_outbound_item tpoi
         <include refid="Select_Inbound_Join_Table_Out"/>
         <where>
+            tpoi.flg_valid
             <if test="intoId != null and intoId != ''">
                 AND tpoi.out_id = #{intoId}::uuid
             </if>

+ 37 - 0
src/main/java/com/dk/mdm/mapper/ivt/InboundMapper.xml

@@ -405,6 +405,7 @@
         left join dkic_b.t_mst_dictionary_data tmd on tmd.data_id = tpi.into_reason
         left join t_mac_account_item tmai on tmai.item_id = tpi.receivable_id
         WHERE tpi.into_id = #{intoId}::uuid
+        and tpi.flg_valid
     </select>
 
     <!-- 根据主键锁定表t_psi_inbound的一行数据 -->
@@ -719,6 +720,24 @@
                 AND tpi.make_time &gt;= #{makeTimeStart}::timestamp with time zone
                 AND tpi.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
             </if>
+            <if test="intoNo != null and intoNo != ''">
+                AND tpi.into_no LIKE concat('%',my_ex.likequery(#{intoNo}),'%')
+            </if>
+            <if test="cusPhone != null and cusPhone != ''">
+                AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
+            </if>
+            <if test="cusName != null and cusName != ''">
+                AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
+            </if>
+            <if test="supId != null and supId != ''">
+                AND tpi.sup_id = #{supId}::uuid
+            </if>
+            <if test="orgIdList != null and orgIdList.size() > 0">
+                AND tmo.org_id  =any(#{orgIdList, typeHandler=uuidListTypeHandler})
+            </if>
+            <if test="staffIdList != null and staffIdList.size() > 0">
+                AND tms.staff_id  =any(#{staffIdList, typeHandler=uuidListTypeHandler})
+            </if>
         </where>
         union all
         select
@@ -751,6 +770,24 @@
                 AND tpo.make_time &gt;= #{makeTimeStart}::timestamp with time zone
                 AND tpo.make_time &lt; #{makeTimeEnd}::timestamp with time zone + interval '1 day'
             </if>
+            <if test="intoNo != null and intoNo != ''">
+                AND tpo.out_no LIKE concat('%',my_ex.likequery(#{intoNo}),'%')
+            </if>
+            <if test="cusPhone != null and cusPhone != ''">
+                AND tmc.cus_phone LIKE concat('%',my_ex.likequery(#{cusPhone}),'%')
+            </if>
+            <if test="cusName != null and cusName != ''">
+                AND tmc.cus_name LIKE concat('%',my_ex.likequery(#{cusName}),'%')
+            </if>
+            <if test="supId != null and supId != ''">
+                AND tpo.sup_id = #{supId}::uuid
+            </if>
+            <if test="orgIdList != null and orgIdList.size() > 0">
+                AND tmo.org_id  =any(#{orgIdList, typeHandler=uuidListTypeHandler})
+            </if>
+            <if test="staffIdList != null and staffIdList.size() > 0">
+                AND tms.staff_id  =any(#{staffIdList, typeHandler=uuidListTypeHandler})
+            </if>
         </where>
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}

+ 6 - 5
src/main/java/com/dk/mdm/service/ivt/inbound/InboundCheckService.java

@@ -28,6 +28,7 @@ import java.math.BigDecimal;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 
 /**
@@ -70,7 +71,7 @@ public class InboundCheckService extends BaseService<Inbound> {
 	 * @author : 寇珊珊
 	 */
 	@Transactional(rollbackFor = {Exception.class})
-	public ResponseResultVO<?> checkInboundInsert(Map<String, Object> map) {
+	public InboundVO checkInboundInsert(Map<String, Object> map) {
 
 		//region map转json
 		JSONObject total = new JSONObject();
@@ -94,8 +95,9 @@ public class InboundCheckService extends BaseService<Inbound> {
 		Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.INVENTORYPROFITINBOUND.getName(), false);
 		inboundVO.setIntoId(codeMap.get("outId").toString()).
 				setIntoNo(codeMap.get("outNote").toString());
-		//入库类型
-		inboundVO.setIntoType(Constant.IntoType.PROFIT.getName());
+		//todo  入库类型可能是盘盈可能是库位移动 调用的时候传
+//		//入库类型
+//		inboundVO.setIntoType(Constant.IntoType.PROFIT.getName());
 		//已入库
 		inboundVO.setIntoStatus(Constant.IntoStatus.YIRUKU.getName());
 		//入库状态等于已入库 更新合计入库数量/金额 = 入库中数量/入库中金额
@@ -151,8 +153,7 @@ public class InboundCheckService extends BaseService<Inbound> {
 //		inventoryService.updateInventoryInformation(invMap);
 		//endregion
 
-
-		return ResponseResultUtil.success(inboundVO);
+		return inboundVO;
 	}
 
 }

+ 103 - 26
src/main/java/com/dk/mdm/service/ivt/inbound/InboundOtherService.java

@@ -274,18 +274,57 @@ public class InboundOtherService extends BaseService<Inbound> {
 
                     //endregion
 
-                    //赋值
-                    InboundItem inboundItem = new InboundItem();
-                    inboundItem.setItemId(inboundItemVO.getItemId());
-                    inboundItem.setIntoQty(inboundItemVO.getIntoingQty());
-                    inboundItem.setIntoAmt(inboundItemVO.getIntoingAmt());
-                    inboundItem.setCostPrice(inboundItemVO.getPriceInto());
-                    inboundItem.setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(6, BigDecimal.ROUND_HALF_UP));
-                    //修改
-                    inboundItemMapper.update(inboundItem,
-                            new UpdateWrapper<InboundItem>().lambda()
-                                    .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
-                    );
+                    //region 编辑明细赋值
+                    if (inboundItemVO.getItemId() != null) {
+                        InboundItem inboundItem = new InboundItem();
+                        inboundItem.setItemId(inboundItemVO.getItemId());
+                        inboundItem.setIntoQty(inboundItemVO.getIntoingQty());
+                        inboundItem.setIntoAmt(inboundItemVO.getIntoingAmt());
+                        inboundItem.setCostPrice(inboundItemVO.getPriceInto());
+                        inboundItem.setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(6, BigDecimal.ROUND_HALF_UP));
+                        //修改
+                        inboundItemMapper.update(inboundItem,
+                                new UpdateWrapper<InboundItem>().lambda()
+                                        .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                        );
+                    }
+                    //endregion
+
+                    //region 新建明细
+                    else {
+                        inboundItemVO
+                                .setIntoQty(inboundItemVO.getIntoingQty())
+                                .setIntoAmt(inboundItemVO.getIntoingAmt())
+                                .setIntoingQty(BigDecimal.ZERO)
+                                .setIntoingAmt(BigDecimal.ZERO)
+                                .setCostPrice(inboundItemVO.getPriceInto())
+                                .setCostAmt(inboundItemVO.getOutQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+                        ;
+                        inboundItemVO.setIntoId(inboundVO.getIntoId());
+                        //入库状态
+                        inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
+                        inboundItemVO.setIntoType(Constant.IntoType.OTHER.getName());
+                        //实体转换
+                        InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                        inboundItemMapper.insert(inboundItem);
+                    }
+                    //endregion
+                }
+                //endregion
+
+                //region 删除明细
+                if (inboundVO.getDeleteItemList() != null) {
+                    for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
+                        if (inboundItemVO.getItemId() != null) {
+                            InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                            inboundItem.setFlgValid(false);
+                            //修改
+                            inboundItemMapper.update(inboundItem,
+                                    new UpdateWrapper<InboundItem>().lambda()
+                                            .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                            );
+                        }
+                    }
                 }
                 //endregion
 
@@ -314,18 +353,56 @@ public class InboundOtherService extends BaseService<Inbound> {
                 //region 修改明细
                 List<InboundItemVO> itemList = inboundVO.getItemList();
                 for (InboundItemVO inboundItemVO : itemList) {
-                    //赋值
-                    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()))
-                    );
+                    if (inboundItemVO.getItemId() != null) {
+                        //region 编辑赋值
+                        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()))
+                        );
+                    }
+                    //endregion
+
+                    //region 新建明细
+                    else {
+                        inboundItemVO
+                                .setIntoQty(BigDecimal.ZERO)
+                                .setIntoAmt(BigDecimal.ZERO)
+                                .setCostPrice(inboundItemVO.getPriceInto())
+                                .setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+                        ;
+                        inboundItemVO.setIntoId(inboundVO.getIntoId());
+                        //入库状态
+                        inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
+                        inboundItemVO.setIntoType(Constant.IntoType.OTHER.getName());
+                        //实体转换
+                        InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                        inboundItemMapper.insert(inboundItem);
+                    }
+                    //endregion
                 }
                 //endregion
+
+                //region 删除明细
+                if (inboundVO.getDeleteItemList() != null) {
+                    for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
+                        if (inboundItemVO.getItemId() != null) {
+                            InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                            inboundItem.setFlgValid(false);
+                            //修改
+                            inboundItemMapper.update(inboundItem,
+                                    new UpdateWrapper<InboundItem>().lambda()
+                                            .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                            );
+                        }
+                    }
+                }
+                //endregion
+
                 //region  修改入库总单
                 Inbound inbound = new Inbound();
                 inbound.setIntoId(inboundVO.getIntoId());
@@ -543,8 +620,8 @@ public class InboundOtherService extends BaseService<Inbound> {
         String intoStatus = this.setIntoStatus(inboundVO.getIntoingQty(), inboundVO.getIntoQty());
         inboundVO.setIntoStatus(intoStatus);
         //实体转换
-        Inbound inbound = inboundConvert.convertToPo(inboundVO);
         //修改
+        Inbound inbound = inboundConvert.convertToPo(inboundVO);
         inboundMapper.update(inbound,
                 new UpdateWrapper<Inbound>().lambda()
                         .eq(Inbound::getIntoId, UUID.fromString(inbound.getIntoId()))
@@ -552,9 +629,9 @@ public class InboundOtherService extends BaseService<Inbound> {
         //endregion
 
         //region 修改库存
-        Map<String, Object> map = new HashMap<>();
-        map.put("intoDetail", inboundVO.getItemList());
-        inventoryService.updateInventoryInformation(map);
+//        Map<String, Object> map = new HashMap<>();
+//        map.put("intoDetail", inboundVO.getItemList());
+//        inventoryService.updateInventoryInformation(map);
         //endregion
         return ResponseResultUtil.success(inboundVO);
     }

+ 127 - 41
src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseReturnService.java

@@ -302,22 +302,61 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
 
                     //endregion
 
-                    //赋值
-                    InboundItem inboundItem = new InboundItem();
-                    inboundItem.setItemId(inboundItemVO.getItemId());
-                    inboundItem.setIntoQty(inboundItemVO.getIntoingQty());
-                    inboundItem.setIntoAmt(inboundItemVO.getIntoingAmt());
-                    inboundItem.setCostPrice(inboundItemVO.getPriceInto());
-                    inboundItem.setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(6, BigDecimal.ROUND_HALF_UP));
-                    //修改
-                    inboundItemMapper.update(inboundItem,
-                            new UpdateWrapper<InboundItem>().lambda()
-                                    .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
-                    );
+                    //region  编辑明细
+                    if (inboundItemVO.getItemId() != null) {
+                        InboundItem inboundItem = new InboundItem();
+                        inboundItem.setItemId(inboundItemVO.getItemId());
+                        inboundItem.setIntoQty(inboundItemVO.getIntoingQty());
+                        inboundItem.setIntoAmt(inboundItemVO.getIntoingAmt());
+                        inboundItem.setCostPrice(inboundItemVO.getPriceInto());
+                        inboundItem.setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(6, BigDecimal.ROUND_HALF_UP));
+                        //修改
+                        inboundItemMapper.update(inboundItem,
+                                new UpdateWrapper<InboundItem>().lambda()
+                                        .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                        );
+                    }
+                    //endregion
+
+                    //region  新建
+                    else {
+                        inboundItemVO
+                                .setIntoQty(inboundItemVO.getIntoingQty())
+                                .setIntoAmt(inboundItemVO.getIntoingAmt())
+                                .setIntoingQty(BigDecimal.ZERO)
+                                .setIntoingAmt(BigDecimal.ZERO)
+                                .setCostPrice(inboundItemVO.getPriceInto())
+                                .setCostAmt(inboundItemVO.getOutQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+                        ;
+                        inboundItemVO.setIntoId(inboundVO.getIntoId());
+                        //入库状态
+                        inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
+                        inboundItemVO.setIntoType(Constant.IntoType.PURRETURN_RETURN.getName());
+                        //实体转换
+                        InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                        inboundItemMapper.insert(inboundItem);
+                    }
+                    //endregion
 
                 }
                 //endregion
 
+                //region 删除明细
+                if (inboundVO.getDeleteItemList() != null) {
+                    for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
+                        if (inboundItemVO.getItemId() != null) {
+                            InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                            inboundItem.setFlgValid(false);
+                            //修改
+                            inboundItemMapper.update(inboundItem,
+                                    new UpdateWrapper<InboundItem>().lambda()
+                                            .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                            );
+                        }
+                    }
+                }
+                //endregion
+
                 //region  修改入库总单
                 Inbound inbound = new Inbound();
                 inbound.setIntoId(inboundVO.getIntoId());
@@ -356,19 +395,41 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
                     }
                     //endregion
 
-                    //region 赋值明细
-                    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.getItemId() != null) {
+                        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()))
+                        );
+                    }
+                    //endregion
+
+                    //region  新建
+                    else {
+                        inboundItemVO
+                                .setIntoQty(BigDecimal.ZERO)
+                                .setIntoAmt(BigDecimal.ZERO)
+                                .setCostPrice(inboundItemVO.getPriceInto())
+                                .setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+                        ;
+                        inboundItemVO.setIntoId(inboundVO.getIntoId());
+                        //入库状态
+                        inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
+                        inboundItemVO.setIntoType(Constant.IntoType.PURRETURN_RETURN.getName());
+                        //实体转换
+                        InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                        inboundItemMapper.insert(inboundItem);
+                    }
                     //endregion
+
                 }
                 //endregion
+
                 //region  修改入库总单
                 Inbound inbound = new Inbound();
                 inbound.setIntoId(inboundVO.getIntoId());
@@ -506,7 +567,7 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
         }
         for (InboundItemVO inboundItemVO : inboundVO.getItemList()) {
             //region  不能新建
-            if(inboundItemVO.getSPurItemId()==null){
+            if (inboundItemVO.getSPurItemId() == null) {
                 throw new BaseBusinessException(ErrorCodeEnum.ITEMS_THAT_ARE_NOT_AVAILABLE_HANDLE.getCode(),
                         ErrorCodeEnum.ITEMS_THAT_ARE_NOT_AVAILABLE_HANDLE.getMessage());
             }
@@ -520,28 +581,54 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
                         ErrorCodeEnum.CANNOT_EXCEED_THE_QUANTITY_IN_THE_OUTBOUND_SHIPMENT.getMessage());
             }
             //endregion
+
             //region 将库存需要的参数赋值
             inboundItemResponse.setInventoryType(Constant.InventoryType.INBOUND.getName());
             inboundItemResponse.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_RETURN.getValue());
             //endregion
+
             //region 编辑明细
-            inboundItemVO
-                    .setIntoQty(inboundItemResponse.getIntoingQty().add(inboundItemVO.getIntoingQty()))
-                    .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
-                    .setIntoingQty(BigDecimal.ZERO)
-                    .setIntoAmt(BigDecimal.ZERO)
-                    .setCostPrice(inboundItemVO.getPriceInto())
-                    .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP));
-            //入库状态
-            String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
-            inboundItemVO.setIntoStatus(intoStatus);
-            //实体转换
-            InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
-            //修改
-            inboundItemMapper.update(inboundItem,
-                    new UpdateWrapper<InboundItem>().lambda()
-                            .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
-            );
+            if (inboundItemVO.getItemId() != null) {
+                inboundItemVO
+                        .setIntoQty(inboundItemResponse.getIntoingQty().add(inboundItemVO.getIntoingQty()))
+                        .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
+                        .setIntoingQty(BigDecimal.ZERO)
+                        .setIntoAmt(BigDecimal.ZERO)
+                        .setCostPrice(inboundItemVO.getPriceInto())
+                        .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP));
+                //入库状态
+                String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
+                inboundItemVO.setIntoStatus(intoStatus);
+                //实体转换
+                InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                //修改
+                inboundItemMapper.update(inboundItem,
+                        new UpdateWrapper<InboundItem>().lambda()
+                                .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                );
+            }
+            //endregion
+
+            //region  新建
+            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())
+                        .setIntoingQty(BigDecimal.ZERO)
+                        .setIntoingAmt(BigDecimal.ZERO)
+                ;
+                //入库状态
+                String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
+                inboundItemVO.setIntoStatus(intoStatus);
+                //实体转换
+                InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                //新建
+                inboundItemMapper.insert(inboundItem);
+            }
             //endregion
         }
         //endregion
@@ -727,5 +814,4 @@ public class InboundPurchaseReturnService extends BaseService<Inbound> {
         return ResponseResultUtil.success(dataInfo);
     }
 
-
 }

+ 212 - 59
src/main/java/com/dk/mdm/service/ivt/inbound/InboundPurchaseService.java

@@ -194,7 +194,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
             }
             //入库状态
             String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchaseUpdate.getIntoingQty()),
-                    purchaseResponse.getIntoQty().add(purchaseUpdate.getIntoQty()),purchaseResponse.getSumQuantity());
+                    purchaseResponse.getIntoQty().add(purchaseUpdate.getIntoQty()), purchaseResponse.getSumQuantity());
             purchaseUpdate.setIntoStatus(intoStatus);
             //修改
             int countRow = purchaseMapper.updateById(purchaseUpdate);
@@ -265,7 +265,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 }
                 //入库状态
                 String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
-                        purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()),purchaseItemResponse.getItemQty());
+                        purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()), purchaseItemResponse.getItemQty());
                 purchaseItem.setIntoStatus(intoStatus);
                 int countRow = purchaseItemMapper.updateById(purchaseItem);
                 //数量超出
@@ -362,21 +362,43 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                     //编辑之后的数
                     inboundItemVO.setIntoQty(inboundItemVO.getIntoQty());
                     inboundItemVO.setIntoAmt(inboundItemVO.getIntoAmt());
+                    //endregion
 
+                    //region 编辑明细 赋值
+                    if (inboundItemVO.getItemId() != null) {
+                        InboundItem inboundItem = new InboundItem();
+                        inboundItem.setItemId(inboundItemVO.getItemId());
+                        inboundItem.setIntoQty(inboundItemVO.getIntoingQty());
+                        inboundItem.setIntoAmt(inboundItemVO.getIntoingAmt());
+                        inboundItem.setCostPrice(inboundItemVO.getPriceInto());
+                        inboundItem.setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(6, BigDecimal.ROUND_HALF_UP));
+                        //修改
+                        inboundItemMapper.update(inboundItem,
+                                new UpdateWrapper<InboundItem>().lambda()
+                                        .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                        );
+                    }
                     //endregion
 
-                    //赋值
-                    InboundItem inboundItem = new InboundItem();
-                    inboundItem.setItemId(inboundItemVO.getItemId());
-                    inboundItem.setIntoQty(inboundItemVO.getIntoingQty());
-                    inboundItem.setIntoAmt(inboundItemVO.getIntoingAmt());
-                    inboundItem.setCostPrice(inboundItemVO.getPriceInto());
-                    inboundItem.setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(6, BigDecimal.ROUND_HALF_UP));
-                    //修改
-                    inboundItemMapper.update(inboundItem,
-                            new UpdateWrapper<InboundItem>().lambda()
-                                    .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
-                    );
+                    //region 新建明细
+                    else {
+                        inboundItemVO
+                                .setIntoQty(inboundItemVO.getIntoingQty())
+                                .setIntoAmt(inboundItemVO.getIntoingAmt())
+                                .setIntoingQty(BigDecimal.ZERO)
+                                .setIntoingAmt(BigDecimal.ZERO)
+                                .setCostPrice(inboundItemVO.getPriceInto())
+                                .setCostAmt(inboundItemVO.getOutQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+                        ;
+                        inboundItemVO.setIntoId(inboundVO.getIntoId());
+                        //入库状态
+                        inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
+                        inboundItemVO.setIntoType(Constant.IntoType.SALE.getName());
+                        //实体转换
+                        InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                        inboundItemMapper.insert(inboundItem);
+                    }
+                    //endregion
 
                     //region  销售明细
                     if (inboundItemVO.getFromItemId() != null) {
@@ -395,6 +417,40 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 }
                 //endregion
 
+                //region 删除明细
+                BigDecimal delIntoQty = BigDecimal.ZERO;
+                BigDecimal delIntoAmt = BigDecimal.ZERO;
+                if (inboundVO.getDeleteItemList() != null) {
+                    delIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+                    delIntoAmt = 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);
+                            inboundItem.setFlgValid(false);
+                            //修改
+                            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(inboundItemVO.getIntoingQty().negate());
+                            purchaseItem.setIntoAmt(inboundItemVO.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(inboundVO.getIntoId());
@@ -409,8 +465,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 //region 修改销售总单
                 Purchase purchase = new Purchase();
                 purchase.setPurId(inboundVO.getFromId());
-                purchase.setIntoQty(inboundResponse.getIntoQty().negate().add(sumQty));
-                purchase.setIntoAmt(inboundResponse.getIntoAmt().negate().add(sumAmt));
+                purchase.setIntoQty(inboundResponse.getIntoQty().negate().add(sumQty).subtract(delIntoQty));
+                purchase.setIntoAmt(inboundResponse.getIntoAmt().negate().add(sumAmt).subtract(delIntoAmt));
                 //修改
                 int countRow = purchaseMapper.updateById(purchase);
                 //数量超出
@@ -449,16 +505,38 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                     }
                     //endregion
 
-                    //赋值
-                    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.getItemId() != null) {
+                        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()))
+                        );
+                    }
+                    //endregion
+
+                    //region 新建明细
+                    else {
+                        inboundItemVO
+                                .setIntoQty(BigDecimal.ZERO)
+                                .setIntoAmt(BigDecimal.ZERO)
+                                .setCostPrice(inboundItemVO.getPriceInto())
+                                .setCostAmt(inboundItemVO.getIntoingQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+                        ;
+                        inboundItemVO.setIntoId(inboundVO.getIntoId());
+                        //入库状态
+                        inboundItemVO.setIntoStatus(inboundVO.getIntoStatus());
+                        inboundItemVO.setIntoType(Constant.IntoType.SALE.getName());
+                        //实体转换
+                        InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                        inboundItemMapper.insert(inboundItem);
+                    }
+                    //endregion
+
                     //region  销售明细
                     if (inboundItemVO.getFromItemId() != null) {
                         //根据id查询
@@ -477,6 +555,44 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 }
                 //endregion
 
+                //region 删除明细
+                BigDecimal delIntoQty = BigDecimal.ZERO;
+                BigDecimal delIntoAmt = BigDecimal.ZERO;
+                if (inboundVO.getDeleteItemList() != null) {
+                    delIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+                    delIntoAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+                    for (InboundItemVO inboundItemVO : inboundVO.getDeleteItemList()) {
+                        //region 明细
+                        if (inboundItemVO.getItemId() != null) {
+                            InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                            inboundItem.setFlgValid(false);
+                            //修改
+                            inboundItemMapper.update(inboundItem,
+                                    new UpdateWrapper<InboundItem>().lambda()
+                                            .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                            );
+                        }
+                        //endregion
+
+                        //region  销售明细
+                        if (inboundItemVO.getFromItemId() != null) {
+                            //根据id查询
+                            PurchaseItem purchaseItem = new PurchaseItem();
+                            purchaseItem.setItemId(inboundItemVO.getFromItemId());
+                            purchaseItem.setIntoQty(inboundItemVO.getIntoingQty().negate());
+                            purchaseItem.setIntoAmt(inboundItemVO.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(inboundVO.getIntoId());
@@ -491,8 +607,8 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 //region 修改采购总单
                 Purchase purchase = new Purchase();
                 purchase.setPurId(inboundVO.getFromId());
-                purchase.setIntoingQty(inboundResponse.getIntoingQty().negate().add(sumQty));
-                purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate().add(sumAmt));
+                purchase.setIntoingQty(inboundResponse.getIntoingQty().negate().add(sumQty).subtract(delIntoQty));
+                purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate().add(sumAmt).subtract(delIntoAmt));
                 //修改
                 int countRow = purchaseMapper.updateById(purchase);
                 //数量超出
@@ -687,6 +803,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                         ErrorCodeEnum.ITEMS_THAT_ARE_NOT_AVAILABLE_HANDLE.getMessage());
             }
             //endregion
+
             //入库明细根据id查询
             InboundItemResponse inboundItemResponse = inboundItemMapper.selectById(inboundItemVO.getItemId());
             //region 校验数量是否超出
@@ -695,10 +812,12 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                         ErrorCodeEnum.CANNOT_EXCEED_THE_QUANTITY_IN_THE_OUTBOUND_SHIPMENT.getMessage());
             }
             //endregion
+
             //region 将库存需要的参数赋值
             inboundItemResponse.setInventoryType(Constant.InventoryType.INBOUND.getName());
             inboundItemResponse.setInventoryDocCode(Constant.InventoryDocCode.PURCHASE_ORDER.getValue());
             //endregion
+
             //region 采购明细
             //根据id查询
             PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
@@ -711,7 +830,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
             purchaseItem.setIntoAmt(inboundItemVO.getIntoAmt());
             //入库状态
             String purItemIntoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
-                    purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()),purchaseItemResponse.getItemQty());
+                    purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()), purchaseItemResponse.getItemQty());
             purchaseItem.setIntoStatus(purItemIntoStatus);
             int countRow = purchaseItemMapper.updateById(purchaseItem);
             //数量超出
@@ -719,31 +838,64 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.INVENTORY_QUANTITY_EXCEEDED.getMessage());
             }
             //endregion
+
             //region 编辑入库明细
-            inboundItemVO
-                    .setIntoQty(inboundItemResponse.getIntoQty().add(inboundItemVO.getIntoingQty()))
-                    .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
-                    .setIntoingQty(BigDecimal.ZERO)
-                    .setIntoingAmt(BigDecimal.ZERO)
-                    .setCostPrice(inboundItemVO.getPriceInto())
-                    .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
-            ;
-            //入库状态
-            String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
-            inboundItemVO.setIntoStatus(intoStatus);
-            //实体转换
-            InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
-            //修改
-            inboundItemMapper.update(inboundItem,
-                    new UpdateWrapper<InboundItem>().lambda()
-                            .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
-            );
+            if(inboundItemVO.getItemId()!=null){
+                inboundItemVO
+                        .setIntoQty(inboundItemResponse.getIntoQty().add(inboundItemVO.getIntoingQty()))
+                        .setIntoAmt(inboundItemResponse.getIntoAmt().add(inboundItemVO.getIntoingAmt()))
+                        .setIntoingQty(BigDecimal.ZERO)
+                        .setIntoingAmt(BigDecimal.ZERO)
+                        .setCostPrice(inboundItemVO.getPriceInto())
+                        .setCostAmt(inboundItemVO.getIntoQty().multiply(inboundItemVO.getPriceInto()).setScale(2, BigDecimal.ROUND_HALF_UP))
+                ;
+                //入库状态
+                String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
+                inboundItemVO.setIntoStatus(intoStatus);
+                //实体转换
+                InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                //修改
+                inboundItemMapper.update(inboundItem,
+                        new UpdateWrapper<InboundItem>().lambda()
+                                .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
+                );
+            }
+            //endregion
+
+            //region 新建明细
+            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.SALE.getName())
+                        .setIntoingQty(BigDecimal.ZERO)
+                        .setIntoingAmt(BigDecimal.ZERO)
+                ;
+                //入库状态
+                String intoStatus = this.setIntoStatus(inboundItemVO.getIntoingQty(), inboundItemVO.getIntoQty());
+                inboundItemVO.setIntoStatus(intoStatus);
+                //实体转换
+                InboundItem inboundItem = inboundItemConvert.convertToPo(inboundItemVO);
+                //新建
+                inboundItemMapper.insert(inboundItem);
+            }
             //endregion
         }
         //endregion
 
         //region 删除明细
+        BigDecimal delIntoingQty = BigDecimal.ZERO;
+        BigDecimal delIntoingAmt = BigDecimal.ZERO;
+        BigDecimal delIntoQty = BigDecimal.ZERO;
+        BigDecimal delIntoAmt = BigDecimal.ZERO;
         if (inboundVO.getDeleteItemList() != null) {
+            delIntoingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+            delIntoingAmt = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoingAmt).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, BigDecimal.ROUND_HALF_UP);
+            delIntoQty = inboundVO.getDeleteItemList().stream().map(InboundItemVO::getIntoQty).reduce(BigDecimal.ZERO, BigDecimal::add).setScale(6, BigDecimal.ROUND_HALF_UP);
+            delIntoAmt = 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);
@@ -754,6 +906,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                                     .eq(InboundItem::getItemId, UUID.fromString(inboundItem.getItemId()))
                     );
                 }
+
                 //region  采购
                 if (inboundItemVO.getFromItemId() != null) {
                     //region 采购订单明细
@@ -768,7 +921,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                     PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemVO.getFromItemId());
                     //入库状态
                     String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
-                            purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()),purchaseItemResponse.getItemQty());
+                            purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()), purchaseItemResponse.getItemQty());
                     purchaseItem.setIntoStatus(intoStatus);
                     int countRow = purchaseItemMapper.updateById(purchaseItem);
                     //数量超出
@@ -806,17 +959,17 @@ public class InboundPurchaseService extends BaseService<Inbound> {
             //赋值(这里重写了更新方法,数量在更新方法中有数据库院士数量+本次数量)
             Purchase purchase = new Purchase();
             purchase.setPurId(inboundVO.getFromId());
-            purchase.setIntoQty(sumIntoQty);
-            purchase.setIntoAmt(sumIntoAmt);
+            purchase.setIntoQty(sumIntoQty.subtract(delIntoQty));
+            purchase.setIntoAmt(sumIntoAmt.subtract(delIntoAmt));
             if (inboundResponse != null) {
-                purchase.setIntoingQty(inboundResponse.getIntoingQty().negate());
-                purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate());
+                purchase.setIntoingQty(inboundResponse.getIntoingQty().negate().subtract(delIntoingQty));
+                purchase.setIntoingAmt(inboundResponse.getIntoingAmt().negate().subtract(delIntoingAmt));
             }
             //根据id查询
             PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
             //入库状态
             String purIntoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
-                    purchaseResponse.getIntoQty().add(purchase.getIntoQty()),purchase.getSumQuantity());
+                    purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchase.getSumQuantity());
             purchase.setIntoStatus(purIntoStatus);
             //修改
             int countRow = purchaseMapper.updateById(purchase);
@@ -872,7 +1025,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
             PurchaseResponse purchaseResponse = purchaseMapper.selectById(inboundVO.getFromId());
             //入库状态
             String intoStatus = this.setIntoStatus(purchaseResponse.getIntoingQty().add(purchase.getIntoingQty()),
-                    purchaseResponse.getIntoQty().add(purchase.getIntoQty()),purchaseResponse.getSumQuantity());
+                    purchaseResponse.getIntoQty().add(purchase.getIntoQty()), purchaseResponse.getSumQuantity());
             purchase.setIntoStatus(intoStatus);
             int countRow = purchaseMapper.updateById(purchase);
             //数量超出
@@ -915,7 +1068,7 @@ public class InboundPurchaseService extends BaseService<Inbound> {
                 PurchaseItemResponse purchaseItemResponse = purchaseItemMapper.selectById(inboundItemResponse.getFromItemId());
                 //入库状态
                 String intoStatus = this.setIntoStatus(purchaseItemResponse.getIntoingQty().add(purchaseItem.getIntoingQty()),
-                        purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()),purchaseItemResponse.getItemQty());
+                        purchaseItemResponse.getIntoQty().add(purchaseItem.getIntoQty()), purchaseItemResponse.getItemQty());
                 purchaseItem.setIntoStatus(intoStatus);
                 //修改
                 int countRow = purchaseItemMapper.updateById(purchaseItem);
@@ -996,15 +1149,15 @@ public class InboundPurchaseService extends BaseService<Inbound> {
     }
 
     /**
-     * @desc   : 上游单据入库状态通用(目前本页面)
-     * @date   : 2024/4/1 17:14
+     * @desc : 上游单据入库状态通用(目前本页面)
+     * @date : 2024/4/1 17:14
      * @author : 寇珊珊
      */
-    public String setIntoStatus(BigDecimal intoingQty, BigDecimal intoQty,BigDecimal sumQty) {
+    public String setIntoStatus(BigDecimal intoingQty, BigDecimal intoQty, BigDecimal sumQty) {
         //入库状态
         String intoStatus = null;
         //入库中+已入库 小于 总数
-        if (intoingQty.add(intoingQty).compareTo(sumQty) < 0 ) {
+        if (intoingQty.add(intoingQty).compareTo(sumQty) < 0) {
             //入库中
             intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
         }

+ 7 - 1
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundCheckService.java

@@ -90,8 +90,9 @@ public class OutboundCheckService extends BaseService<Outbound> {
         Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.INVENTORYLOSEOUTBOUND.getName(), false);
         outboundVO.setOutId(codeMap.get("outId").toString()).
                 setOutNo(codeMap.get("outNote").toString());
+        //todo  出库类型可能是盘亏可能是库位移动 调用的时候传
         //出库类型
-        outboundVO.setOutType(Constant.OutType.INVENTORY_LOSS.getName());
+//        outboundVO.setOutType(Constant.OutType.INVENTORY_LOSS.getName());
         //已出库
         outboundVO.setOutStatus(Constant.OutStatus.YICHUKU.getName());
         //出库状态等于已出库 更新合计出库数量/金额 = 出库中数量/出库中金额
@@ -149,6 +150,11 @@ public class OutboundCheckService extends BaseService<Outbound> {
 //            inventoryService.updateInventoryInformation(invMap);
         //endregion
 
+        //1.入库需要的值 附上 掉用接口
+        //2.接收接口返回体
+
+
+
         return ResponseResultUtil.success(outboundVO);
     }
 

+ 45 - 10
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundSaleOrderService.java

@@ -182,7 +182,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                 order.setOutAmt(BigDecimal.ZERO);
             }
             //入库状态
-            String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()), orderResponse.getOutQty().add(order.getOutQty()));
+            String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
+                    orderResponse.getOutQty().add(order.getOutQty()),orderResponse.getSumQuantity());
             order.setOutStatus(outStatus);
             //修改
             int countRow = orderMapper.updateById(order);
@@ -252,7 +253,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     orderItem.setOutAmt(BigDecimal.ZERO);
                 }
                 //入库状态
-                String outStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()), orderItemResponse.getOutQty().add(orderItem.getOutQty()));
+                String outStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()),
+                        orderItemResponse.getOutQty().add(orderItem.getOutQty()),orderItemResponse.getItemQty());
                 orderItem.setOutStatus(outStatus);
                 //修改
                 int countRow = orderItemMapper.updateById(orderItem);
@@ -335,7 +337,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     OutboundItemResponse outboundItemResponse = outboundItemMapper.selectById(outboundItemVO.getItemId());
 
                     //region  不能新建
-                    if (outboundItemVO.getSOrderItemId() == null) {
+                    if (outboundItemVO.getFromItemId() == null) {
                         throw new BaseBusinessException(ErrorCodeEnum.ITEMS_THAT_ARE_NOT_AVAILABLE_HANDLE.getCode(),
                                 ErrorCodeEnum.ITEMS_THAT_ARE_NOT_AVAILABLE_HANDLE.getMessage());
                     }
@@ -431,7 +433,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     OutboundItemResponse outboundItemResponse = outboundItemMapper.selectById(outboundItemVO.getItemId());
 
                     //region  不能新建
-                    if (outboundItemVO.getSOrderItemId() == null) {
+                    if (outboundItemVO.getFromItemId() == null) {
                         throw new BaseBusinessException(ErrorCodeEnum.ITEMS_THAT_ARE_NOT_AVAILABLE_HANDLE.getCode(),
                                 ErrorCodeEnum.ITEMS_THAT_ARE_NOT_AVAILABLE_HANDLE.getMessage());
                     }
@@ -679,7 +681,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
         }
         for (OutboundItemVO outboundItemVO : outboundVO.getItemList()) {
             //region  不能新建
-            if (outboundItemVO.getSOutItemId() == null) {
+            if (outboundItemVO.getFromItemId() == null) {
                 throw new BaseBusinessException(ErrorCodeEnum.ITEMS_THAT_ARE_NOT_AVAILABLE_HANDLE.getCode(),
                         ErrorCodeEnum.ITEMS_THAT_ARE_NOT_AVAILABLE_HANDLE.getMessage());
             }
@@ -732,7 +734,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                 //根据id查询
                 OrderItemResponse orderItemResponse = orderItemMapper.selectById(outboundItemVO.getFromItemId());
                 //出库状态
-                String orderOutStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()), orderItemResponse.getOutQty().add(orderItem.getOutQty()));
+                String orderOutStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()),
+                        orderItemResponse.getOutQty().add(orderItem.getOutQty()),orderItemResponse.getItemQty());
                 orderItem.setOutStatus(orderOutStatus);
                 //修改
                 int countRow = orderItemMapper.updateById(orderItem);
@@ -771,7 +774,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                     //根据id查询
                     OrderItemResponse orderItemResponse = orderItemMapper.selectById(outboundItemVO.getFromItemId());
                     //出库状态
-                    String outStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()), orderItemResponse.getOutQty().add(orderItem.getOutQty()));
+                    String outStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()),
+                            orderItemResponse.getOutQty().add(orderItem.getOutQty()),orderItemResponse.getItemQty());
                     orderItem.setOutStatus(outStatus);
                     //修改
                     int countRow = orderItemMapper.updateById(orderItem);
@@ -819,7 +823,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
             //根据id查询
             OrderResponse orderResponse = orderMapper.selectById(outboundVO.getFromId());
             //出库状态
-            String orderOutStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()), orderResponse.getOutQty().add(order.getOutQty()));
+            String orderOutStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
+                    orderResponse.getOutQty().add(order.getOutQty()),orderResponse.getSumQuantity());
             order.setOutStatus(orderOutStatus);
             //修改
             int countRow = orderMapper.updateById(order);
@@ -872,7 +877,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
             //根据id查询
             OrderResponse orderResponse = orderMapper.selectById(outboundVO.getFromId());
             //出库状态
-            String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()), orderResponse.getOutQty().add(order.getOutQty()));
+            String outStatus = this.setOutStatus(orderResponse.getOutingQty().add(order.getOutingQty()),
+                    orderResponse.getOutQty().add(order.getOutQty()),orderResponse.getSumQuantity());
             order.setOutStatus(outStatus);
             //修改
             int countRow = orderMapper.updateById(order);
@@ -916,7 +922,8 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
                 //根据id查询
                 OrderItemResponse orderItemResponse = orderItemMapper.selectById(outboundItemResponse.getFromItemId());
                 //出库状态
-                String outStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()), orderItemResponse.getOutQty().add(orderItem.getOutQty()));
+                String outStatus = this.setOutStatus(orderItemResponse.getOutingQty().add(orderItem.getOutingQty()),
+                        orderItemResponse.getOutQty().add(orderItem.getOutQty()),orderItemResponse.getItemQty());
                 orderItem.setOutStatus(outStatus);
                 //修改
                 int countRow = orderItemMapper.updateById(orderItem);
@@ -993,6 +1000,34 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
 
 
     /**
+     * @desc   : 上游单据入库状态通用(目前本页面)
+     * @date   : 2024/4/1 17:14
+     * @author : 寇珊珊
+     */
+    public String setOutStatus(BigDecimal intoingQty, BigDecimal intoQty,BigDecimal sumQty) {
+        //入库状态
+        String intoStatus = null;
+        //入库中+已入库 小于 总数
+        if (intoingQty.add(intoingQty).compareTo(sumQty) < 0 ) {
+            //入库中
+            intoStatus = Constant.IntoStatus.RUKUZHONG.getName();
+        }
+        //已入库数量=0 入库中数量=0
+        else if (intoQty.compareTo(BigDecimal.ZERO) == 0 && intoingQty.compareTo(BigDecimal.ZERO) == 0) {
+            //待入库
+            intoStatus = Constant.IntoStatus.DAIRUKU.getName();
+        }
+        //入库中+已入库 等于 总数
+        else if (intoingQty.add(intoingQty).compareTo(sumQty) == 0) {
+            //已入库
+            intoStatus = Constant.IntoStatus.YIRUKU.getName();
+        }
+        return intoStatus;
+    }
+
+
+
+    /**
      * @desc : 获取单据信息(编辑用)
      * @date : 2024/3/16 16:28
      * @author : 寇珊珊