Commit 99646c6e9ff3ce268f019b5221ba1a2bc5479616

Authored by wangqian
1 parent 2eb3e8df

库存修改

urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/material/vo/MaterialPageReqVO.java
... ... @@ -66,6 +66,6 @@ public class MaterialPageReqVO extends PageParam {
66 66 private String remark;
67 67  
68 68 @Schema(description = "是否关联工单:0-否,1-是")
69   - private Boolean isAssociatedOrder;
  69 + private Integer isAssociatedOrder;
70 70  
71   -}
72 71 \ No newline at end of file
  72 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/material/vo/MaterialRespVO.java
... ... @@ -86,6 +86,6 @@ public class MaterialRespVO {
86 86  
87 87 @Schema(description = "是否关联工单:0-否,1-是")
88 88 @ExcelProperty("是否关联工单:0-否,1-是")
89   - private Boolean isAssociatedOrder;
  89 + private Integer isAssociatedOrder;
90 90  
91   -}
92 91 \ No newline at end of file
  92 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/material/vo/MaterialSaveReqVO.java
... ... @@ -73,6 +73,6 @@ public class MaterialSaveReqVO {
73 73 private String remark;
74 74  
75 75 @Schema(description = "是否关联工单:0-否,1-是")
76   - private Boolean isAssociatedOrder;
  76 + private Integer isAssociatedOrder;
77 77  
78   -}
79 78 \ No newline at end of file
  79 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/controller/admin/materialinventory/MaterialInventoryController.java
... ... @@ -101,4 +101,15 @@ public class MaterialInventoryController {
101 101 BeanUtils.toBean(list, MaterialInventoryRespVO.class));
102 102 }
103 103  
104   -}
105 104 \ No newline at end of file
  105 + /**
  106 + * 物料库存-阈值更新
  107 + */
  108 + @Operation(summary = "物料库存-阈值更新")
  109 + @PreAuthorize("@ss.hasPermission('garden:material-inventory:update')")
  110 + @GetMapping("/updateByAlermNum")
  111 + public CommonResult updateInventoryAlermNum(@RequestParam("material_id") Long materialId, @RequestParam("alerm_num") Long alermNum) {
  112 + int count = materialInventoryService.updateInVentoryAlremNum(materialId, alermNum);
  113 + return success(count);
  114 + }
  115 +
  116 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/dataobject/material/MaterialDO.java
... ... @@ -94,7 +94,7 @@ public class MaterialDO extends BaseDO {
94 94 /**
95 95 * 是否关联工单:0-否,1-是
96 96 */
97   - private Boolean isAssociatedOrder;
  97 + private Integer isAssociatedOrder;
98 98  
99 99  
100   -}
101 100 \ No newline at end of file
  101 +}
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/dal/mysql/materialtype/MaterialTypeMapper.java
... ... @@ -18,7 +18,7 @@ public interface MaterialTypeMapper extends BaseMapperX<MaterialTypeDO> {
18 18 default PageResult<MaterialTypeDO> selectPage(MaterialTypePageReqVO reqVO) {
19 19 return selectPage(reqVO, new LambdaQueryWrapperX<MaterialTypeDO>()
20 20 .likeIfPresent(MaterialTypeDO::getTypeName, reqVO.getTypeName())
21   - .orderByDesc(MaterialTypeDO::getTypeName));
  21 + .orderByDesc(MaterialTypeDO::getId));
22 22 }
23 23  
24 24 }
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventory/MaterialInventoryService.java
... ... @@ -85,9 +85,17 @@ public interface MaterialInventoryService {
85 85  
86 86 /**
87 87 * 更新出库库库存信息
88   - * @param inventoryId
  88 + * @param materialInventory
89 89 * @param outNum 出库数量
90 90 * @return
91 91 */
92 92 int updateInVentoryByMaterialId(MaterialInventoryDO materialInventory, Long outNum);
  93 +
  94 + /**
  95 + * 更新出库库库存信息
  96 + * @param materialId
  97 + * @param alermNum 库存预警
  98 + * @return
  99 + */
  100 + int updateInVentoryAlremNum(Long materialId, Long alermNum);
93 101 }
... ...
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventory/MaterialInventoryServiceImpl.java
1 1 package com.zteits.urbanops.module.garden.service.materialinventory;
2 2  
  3 +import com.baomidou.mybatisplus.core.conditions.Wrapper;
3 4 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  5 +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
4 6 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
5 7 import com.zteits.urbanops.framework.common.pojo.PageResult;
6 8 import com.zteits.urbanops.framework.common.util.object.BeanUtils;
... ... @@ -14,7 +16,9 @@ import org.springframework.validation.annotation.Validated;
14 16  
15 17 import java.util.List;
16 18  
  19 +import static com.zteits.urbanops.framework.common.exception.enums.GlobalErrorCodeConstants.BAD_REQUEST;
17 20 import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception;
  21 +import static com.zteits.urbanops.framework.common.exception.util.ServiceExceptionUtil.exception0;
18 22 import static com.zteits.urbanops.module.garden.enums.ErrorCodeConstants.MATERIAL_INVENTORY_NOT_EXISTS;
19 23  
20 24 /**
... ... @@ -103,6 +107,9 @@ public class MaterialInventoryServiceImpl implements MaterialInventoryService {
103 107  
104 108 @Override
105 109 public MaterialInventoryDO selectTdMaterialInventoryByMaterialId(Long materialId) {
  110 + if (materialId == null) {
  111 + throw exception0(BAD_REQUEST.getCode(),"更新库存失败:materialId为空!");
  112 + }
106 113 LambdaQueryWrapper<MaterialInventoryDO> queryWrapper = Wrappers.lambdaQuery();
107 114 queryWrapper.eq(MaterialInventoryDO::getTypeDetailId, materialId);
108 115 return materialInventoryMapper.selectOne(queryWrapper);
... ... @@ -110,10 +117,32 @@ public class MaterialInventoryServiceImpl implements MaterialInventoryService {
110 117  
111 118 @Override
112 119 public int updateInVentoryByMaterialId(MaterialInventoryDO materialInventory, Long outNum) {
  120 + // 1. 入参空值校验(避免无效更新或SQL异常)
  121 + if (outNum == null) {
  122 + throw exception0(BAD_REQUEST.getCode(),"更新库存失败:outNum为空!");
  123 + }
113 124 MaterialInventoryDO out = new MaterialInventoryDO();
114 125 out.setInventoryId(materialInventory.getInventoryId());
115 126 out.setOutTotalNum(materialInventory.getInventoryTotalNum() + outNum);
116 127 out.setCurrentNum(materialInventory.getCurrentNum() - outNum);
117 128 return materialInventoryMapper.updateById(materialInventory);
118 129 }
  130 +
  131 + @Override
  132 + public int updateInVentoryAlremNum(Long materialId, Long alermNum) {
  133 + // 1. 入参空值校验(避免无效更新或SQL异常)
  134 + if (materialId == null || alermNum == null) {
  135 + throw exception0(BAD_REQUEST.getCode(),"更新库存预警数失败:materialId或alermNum为空!");
  136 + }
  137 +
  138 + // 2. 构造更新条件:用LambdaUpdateWrapper(专用于更新操作,语义更清晰)
  139 + LambdaUpdateWrapper<MaterialInventoryDO> updateWrapper = Wrappers.lambdaUpdate();
  140 + // 设置要更新的字段:inventoryAlremNum = alermNum
  141 + updateWrapper.set(MaterialInventoryDO::getInventoryAlermNum, alermNum)
  142 + // 设置更新条件:根据materialId匹配记录(若实际条件是typeDetailId,替换为getTypeDetailId即可)
  143 + .eq(MaterialInventoryDO::getMaterialId, materialId);
  144 +
  145 + // 3. 执行更新(MyBatis-Plus支持直接传wrapper,第一个参数为null即可)
  146 + return materialInventoryMapper.update(null, updateWrapper);
  147 + }
119 148 }
... ...