Sfoglia il codice sorgente

修改冻结功能

songyang 2 anni fa
parent
commit
b9b468a224

+ 0 - 9
src/main/java/com/dk/mdm/controller/ivt/FreezeController.java

@@ -51,15 +51,6 @@ public class FreezeController{
         return freezeService.selectById(id);
     }
 
-    /**
-     * @desc   : 查询明细信息
-     * @author : 宋扬
-     * @date   : 2024/3/13 16:01
-     */
-    @PostMapping({"select_freezeItem_by_id/{id}"})
-    public List<FreezeItemResponse> selectFreezeItemById(@PathVariable String id) {
-        return freezeService.selectFreezeItemById(id);
-    }
 
     /**
      * @desc   : 新建冻结单

+ 22 - 1
src/main/java/com/dk/mdm/controller/ivt/FreezeItemController.java

@@ -1,8 +1,15 @@
 package com.dk.mdm.controller.ivt;
 
+import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.model.pojo.ivt.FreezeItem;
 import com.dk.common.controller.BaseController;
 import com.dk.common.service.BaseService;
+import com.dk.mdm.model.query.ivt.FreezeItemQuery;
+import com.dk.mdm.model.response.ivt.FreezeItemResponse;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RestController;
@@ -11,7 +18,7 @@ import com.dk.mdm.service.ivt.FreezeItemService;
 
 @Api(tags = "冻结单明细API接口")
 @RestController
-@RequestMapping("/freezeItem")
+@RequestMapping("/ivt/freezeItem")
 public class FreezeItemController{
 
     public BaseService<FreezeItem> getService() {
@@ -21,4 +28,18 @@ public class FreezeItemController{
     @Autowired
     private FreezeItemService freezeItemService;
 
+    /**
+     * @desc   : 查询冻结明细
+     * @author : 宋扬
+     * @date   : 2024/3/18 17:08
+     */
+    @ApiOperation(
+            value = "分页、关联、条件查询",
+            notes = "分页、关联、条件查询"
+    )
+    @PostMapping({"list_by"})
+    public ResponseResultVO<PageList<FreezeItemResponse>> selectByCond(@RequestBody FreezeItemQuery freezeItemQuery) {
+        return freezeItemService.selectByCond(freezeItemQuery);
+    }
+
 }

+ 10 - 6
src/main/java/com/dk/mdm/mapper/ivt/FreezeItemMapper.xml

@@ -34,7 +34,7 @@
     <sql id="Condition">
         <where>
             <if test="freezeId != null and freezeId != ''">
-                AND freeze_id = #{freezeId}
+                AND freeze_id = #{freezeId}::uuid
             </if>
             <if test="itemIndex != null">
                 AND item_index = #{itemIndex}
@@ -93,9 +93,6 @@
         <include refid="Base_Column_List"/>
         FROM dkic_b.t_psi_freeze_item
         <include refid="Condition"/>
-        <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
-            limit #{end} offset #{start}
-        </if>
     </select>
 
     <!-- 查询表t_psi_freeze_item,(条件查询)个数 -->
@@ -114,13 +111,20 @@
         WHERE item_id = #{itemId}::uuid
     </select>
 
-
     <!-- 根据商品ID和仓库ID查询库存信息-->
     <select id="selectInvById" resultMap="BaseResultMap">
         SELECT
             inv.inv_qty,inv.freeze_qty,inv.usable_qty,inv.outing_qty
         FROM dkic_b.t_psi_inventory AS inv
-        WHERE  inv.inv_id=#{invId}
+        WHERE  inv.inv_id=#{invId}::uuid
         for update
     </select>
+
+    <!-- 根据库存ID修改库存表里的冻结量-->
+    <update id="updateInvFreezeQty">
+        update dkic_b.t_psi_inventory
+        set freeze_qty = freeze_qty + #{freezeQty}
+        where inv_id = #{invId} ::uuid
+    </update>
+
 </mapper>

+ 0 - 1
src/main/java/com/dk/mdm/model/pojo/ivt/Freeze.java

@@ -41,7 +41,6 @@ public class Freeze extends PageInfo<Freeze> implements Serializable {
     /**
      * 冻结ID
      */
-    @TableId(value = "freeze_id", type = IdType.AUTO)
     @ApiModelProperty(value = "冻结ID")
     @TableField(typeHandler = UuidTypeHandler.class)
     private String freezeId;

+ 5 - 6
src/main/java/com/dk/mdm/model/response/ivt/FreezeResponse.java

@@ -17,6 +17,7 @@ import lombok.experimental.Accessors;
 
 import java.io.Serializable;
 import java.math.BigDecimal;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 
 /**
@@ -93,9 +94,8 @@ public class FreezeResponse extends PageInfo<FreezeResponse> implements Serializ
      */
     @Excel(name = "冻结日期")
     @ApiModelProperty(value = "冻结日期")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime freezeDate;
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDate freezeDate;
 
 
     /**
@@ -103,9 +103,8 @@ public class FreezeResponse extends PageInfo<FreezeResponse> implements Serializ
      */
     @Excel(name = "自动解冻日期")
     @ApiModelProperty(value = "自动解冻日期")
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
-    @TableField(typeHandler = TimestampTypeHandler.class)
-    private LocalDateTime autoUnfreezeDate;
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    private LocalDate autoUnfreezeDate;
 
 
     /**

+ 15 - 0
src/main/java/com/dk/mdm/service/ivt/FreezeItemService.java

@@ -1,9 +1,14 @@
 package com.dk.mdm.service.ivt;
 
+import com.dk.common.infrastructure.annotaiton.Pagination;
+import com.dk.common.model.pojo.PageList;
+import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.model.pojo.ivt.FreezeItem;
 import com.dk.mdm.mapper.ivt.FreezeItemMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
+import com.dk.mdm.model.query.ivt.FreezeItemQuery;
+import com.dk.mdm.model.response.ivt.FreezeItemResponse;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
@@ -30,4 +35,14 @@ public class FreezeItemService extends BaseService<FreezeItem> {
 		return "item_id";
 	}
 
+	/**
+	 * @desc   : 查询冻结明细
+	 * @author : 宋扬
+	 * @date   : 2024/3/18 17:10
+	 */
+	@Pagination
+	public ResponseResultVO<PageList<FreezeItemResponse>> selectByCond(FreezeItemQuery freezeItemQuery) {
+		return super.mergeListWithCount(freezeItemMapper, freezeItemMapper.selectByCond(freezeItemQuery), freezeItemMapper.countByCond(freezeItemQuery));
+	}
+
 }

+ 16 - 25
src/main/java/com/dk/mdm/service/ivt/FreezeService.java

@@ -10,32 +10,25 @@ import com.dk.common.response.ResponseResultUtil;
 import com.dk.common.response.ResponseResultVO;
 import com.dk.mdm.infrastructure.convert.ivt.FreezeConvert;
 import com.dk.mdm.infrastructure.convert.ivt.FreezeItemConvert;
-import com.dk.mdm.infrastructure.convert.mst.SupplierConvert;
-import com.dk.mdm.infrastructure.convert.sale.OrderItemConvert;
 import com.dk.mdm.mapper.ivt.FreezeItemMapper;
-import com.dk.mdm.mapper.sale.OrderItemMapper;
 import com.dk.mdm.model.pojo.ivt.Freeze;
 import com.dk.mdm.mapper.ivt.FreezeMapper;
 import com.dk.common.service.BaseService;
 import com.dk.common.mapper.BaseMapper;
 import com.dk.mdm.model.pojo.ivt.FreezeItem;
-import com.dk.mdm.model.pojo.mst.Supplier;
-import com.dk.mdm.model.pojo.sale.OrderItem;
 import com.dk.mdm.model.query.ivt.FreezeItemQuery;
 import com.dk.mdm.model.query.ivt.FreezeQuery;
 import com.dk.mdm.model.response.ivt.FreezeItemResponse;
 import com.dk.mdm.model.response.ivt.FreezeResponse;
 import com.dk.mdm.model.vo.ivt.FreezeItemVO;
 import com.dk.mdm.model.vo.ivt.FreezeVO;
-import com.dk.mdm.model.vo.mst.SupplierVo;
-import com.dk.mdm.model.vo.sale.OrderItemVO;
 import com.dk.mdm.service.common.CommonService;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
-import java.util.ArrayList;
+import java.time.LocalDateTime;
 import java.util.List;
 import java.util.Map;
 
@@ -87,16 +80,6 @@ public class FreezeService extends BaseService<Freeze> {
 	}
 
 	/**
-	 * @desc   : 查询明细数据
-	 * @author : 宋扬
-	 * @date   : 2024/3/13 16:05
-	 */
-	@Pagination
-	public List<FreezeItemResponse> selectFreezeItemById(String id) {
-		return freezeItemMapper.selectByCond(new FreezeItemQuery().setFreezeId(id));
-	}
-
-	/**
 	 * @desc   : 新建冻结单
 	 * @author : 宋扬
 	 * @date   : 2024/3/15 10:33
@@ -109,29 +92,37 @@ public class FreezeService extends BaseService<Freeze> {
 			// 判断库存量和冻结量
 			if (freezeVO.getItemList() != null && freezeVO.getItemList().size() > 0) {
 				for (FreezeItemVO freezeItemVO : freezeVO.getItemList()) {
-					FreezeItemResponse freezeItem = freezeItemMapper.selectInvById(freezeItemVO.getInvId());
+					List<FreezeItemResponse> freezeItemList = freezeItemMapper.selectInvById(freezeItemVO.getInvId());
 					// 库存可售量不能小于冻结量
-					if (freezeItem.getUsableQty().compareTo(freezeItemVO.getFreezeQty() ) == -1){
+					if (freezeItemList.get(0).getUsableQty().compareTo(freezeItemVO.getFreezeQty() ) == -1){
 						throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.FREEZEQTY_NO_LESS_USABLEQTY.getMessage());
 					}
 				}
 			}
 			Map<String, Object> codeMap = commonService.getUniqueNoteCode(Constant.docNameConstant.Freeze.getName(), true);
-			freeze.setFreezeId(codeMap.get("outId").toString());
-			freeze.setFreezeNo(codeMap.get("outNote").toString());  //插入冻结表的实体
-			super.insert(freeze);// 先插入自己的冻结单
-
+			// 获取冻结状态 获取冻结日期(当前日期) 插入冻结表的实体
+			freeze.setFreezeStatus(Constant.FreezeStatusType.ALLFREEZE.getName()).setFreezeDate(LocalDateTime.now())
+					.setCusId(freezeVO.getCusId()).setMakeStaff(freezeVO.getMakeStaff()).setOrgId(freezeVO.getOrgId())
+					.setAutoUnfreezeDate(freezeVO.getAutoUnfreezeDate()).setMakeTime(LocalDateTime.now())
+					.setStaffId(freezeVO.getStaffId()).setFreezeId(codeMap.get("outId").toString()).setCpId(freezeVO.getCpId())
+					.setFreezeNo(codeMap.get("outNote").toString()).setSumQuantity(freezeVO.getSumQuantity());
+			// 先插入冻结单主表数据
+			super.insert(freeze);
 			// 插入冻结明细
 			if (freezeVO.getItemList() != null && freezeVO.getItemList().size() > 0) {
 				for (FreezeItemVO freezeItemVO : freezeVO.getItemList()) {
 					FreezeItem freezeItem = freezeItemConvert.convertToPo(freezeItemVO);
+					// 获取冻结主表uuid
+					freezeItem.setFreezeId(freeze.getFreezeId()).setCpId(freeze.getCpId());
+					// 插入冻结单明细数据
 					freezeItemMapper.insert(freezeItem);
+					// 修改库存冻结量
+					freezeItemMapper.updateInvFreezeQty(freezeItemVO);
 				}
 			}
 			return ResponseResultUtil.success();
 		} catch (Exception e) {
 			TransactionAspectSupport.currentTransactionStatus().setRollbackOnly(); // 手动回滚事务
-
 			return ResponseResultUtil.error("保存失败");
 		}