Commit 24d87ec3c8da90e298681c6e5631972dbe67b5c4
1 parent
808d0fbc
库存修改
Showing
5 changed files
with
47 additions
and
33 deletions
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/material/MaterialServiceImpl.java
| ... | ... | @@ -36,7 +36,7 @@ public class MaterialServiceImpl implements MaterialService { |
| 36 | 36 | QueryWrapper<MaterialDO> queryWrapper = new QueryWrapper<>(); |
| 37 | 37 | queryWrapper.lambda().eq(MaterialDO::getMaterialCode, createReqVO.getMaterialCode()) |
| 38 | 38 | .eq(MaterialDO::getSpecCode, createReqVO.getSpecCode()) |
| 39 | - .eq(MaterialDO::getMaterialTypeId, createReqVO.getTypeDetailId()); | |
| 39 | + .eq(MaterialDO::getTypeDetailId, createReqVO.getTypeDetailId()); | |
| 40 | 40 | List<MaterialDO> tdMaterials = materialMapper.selectList(queryWrapper); |
| 41 | 41 | if (null != tdMaterials && tdMaterials.size() > 0) { |
| 42 | 42 | MaterialDO material = tdMaterials.get(0); | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventory/MaterialInventoryService.java
| ... | ... | @@ -80,7 +80,7 @@ public interface MaterialInventoryService { |
| 80 | 80 | * @Date 2025/11/28 23:36 |
| 81 | 81 | * @Param materialId |
| 82 | 82 | */ |
| 83 | - MaterialInventoryDO selectTdMaterialInventoryByMaterialId(Long materialId); | |
| 83 | + MaterialInventoryDO selectMaterialInventoryByMaterialId(Long typeDetailId, Long companyId); | |
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 | /** |
| ... | ... | @@ -98,4 +98,13 @@ public interface MaterialInventoryService { |
| 98 | 98 | * @return |
| 99 | 99 | */ |
| 100 | 100 | int updateInVentoryAlremNum(Long materialId, Long alermNum); |
| 101 | + | |
| 102 | + /** | |
| 103 | + * @Author wangqian | |
| 104 | + * @Description 查询物料信息根据 | |
| 105 | + * @Date 2025/11/28 23:36 | |
| 106 | + * @Param materialId | |
| 107 | + */ | |
| 108 | + MaterialInventoryDO selectMaterialInventoryByMaterialId(Long materialId); | |
| 109 | + | |
| 101 | 110 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventory/MaterialInventoryServiceImpl.java
| ... | ... | @@ -98,8 +98,8 @@ public class MaterialInventoryServiceImpl implements MaterialInventoryService { |
| 98 | 98 | @Override |
| 99 | 99 | public int insertMaterialInventory(MaterialInventoryDO materialInventory) { |
| 100 | 100 | LambdaQueryWrapper<MaterialInventoryDO> queryWrapper = Wrappers.lambdaQuery(); |
| 101 | - queryWrapper.eq(MaterialInventoryDO::getBelongCompanyId, materialInventory.getBelongCompanyId()); | |
| 102 | - queryWrapper.eq(MaterialInventoryDO::getTypeDetailId, materialInventory.getTypeDetailId()); | |
| 101 | + //queryWrapper.eq(MaterialInventoryDO::getBelongCompanyId, materialInventory.getBelongCompanyId()); | |
| 102 | + queryWrapper.eq(MaterialInventoryDO::getMaterialId, materialInventory.getMaterialId()); | |
| 103 | 103 | MaterialInventoryDO object = materialInventoryMapper.selectOne(queryWrapper); |
| 104 | 104 | if(object != null){ |
| 105 | 105 | object.setInventoryTotalNum(object.getInventoryTotalNum()+ materialInventory.getCurrentNum()); |
| ... | ... | @@ -118,12 +118,13 @@ public class MaterialInventoryServiceImpl implements MaterialInventoryService { |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | @Override |
| 121 | - public MaterialInventoryDO selectTdMaterialInventoryByMaterialId(Long materialId) { | |
| 122 | - if (materialId == null) { | |
| 123 | - throw exception0(BAD_REQUEST.getCode(),"更新库存失败:materialId为空!"); | |
| 121 | + public MaterialInventoryDO selectMaterialInventoryByMaterialId(Long typeDetailId, Long companyId) { | |
| 122 | + if (typeDetailId == null) { | |
| 123 | + throw exception0(BAD_REQUEST.getCode(),"更新库存失败:typeDetailId为空!"); | |
| 124 | 124 | } |
| 125 | 125 | LambdaQueryWrapper<MaterialInventoryDO> queryWrapper = Wrappers.lambdaQuery(); |
| 126 | - queryWrapper.eq(MaterialInventoryDO::getTypeDetailId, materialId); | |
| 126 | + queryWrapper.eq(MaterialInventoryDO::getTypeDetailId, typeDetailId); | |
| 127 | + queryWrapper.eq(MaterialInventoryDO::getBelongCompanyId, companyId); | |
| 127 | 128 | return materialInventoryMapper.selectOne(queryWrapper); |
| 128 | 129 | } |
| 129 | 130 | |
| ... | ... | @@ -157,4 +158,14 @@ public class MaterialInventoryServiceImpl implements MaterialInventoryService { |
| 157 | 158 | // 3. 执行更新(MyBatis-Plus支持直接传wrapper,第一个参数为null即可) |
| 158 | 159 | return materialInventoryMapper.update(null, updateWrapper); |
| 159 | 160 | } |
| 161 | + | |
| 162 | + @Override | |
| 163 | + public MaterialInventoryDO selectMaterialInventoryByMaterialId(Long materialId) { | |
| 164 | + if (materialId == null) { | |
| 165 | + throw exception0(BAD_REQUEST.getCode(),"更新库存失败:materialId为空!"); | |
| 166 | + } | |
| 167 | + LambdaQueryWrapper<MaterialInventoryDO> queryWrapper = Wrappers.lambdaQuery(); | |
| 168 | + queryWrapper.eq(MaterialInventoryDO::getMaterialId, materialId); | |
| 169 | + return materialInventoryMapper.selectOne(queryWrapper); | |
| 170 | + } | |
| 160 | 171 | } | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventoryin/MaterialInventoryInServiceImpl.java
| ... | ... | @@ -74,8 +74,6 @@ public class MaterialInventoryInServiceImpl implements MaterialInventoryInServic |
| 74 | 74 | in.setTypeDetailId(material.getTypeDetailId()); |
| 75 | 75 | in.setTypeDetailName(material.getTypeDetailName()); |
| 76 | 76 | in.setSpecifications(material.getSpecifications()); |
| 77 | -// in.setBelongCompanyId(material.getBelongCompanyId()); | |
| 78 | -// in.setBelongCompanyName(material.getBelongCompanyName()); | |
| 79 | 77 | in.setBelongCompanyId(deptRespDTO.getId()); |
| 80 | 78 | in.setBelongCompanyName(deptRespDTO.getName()); |
| 81 | 79 | in.setInInventoryNum(createReqVO.getInInventoryNum()); |
| ... | ... | @@ -103,8 +101,6 @@ public class MaterialInventoryInServiceImpl implements MaterialInventoryInServic |
| 103 | 101 | inventory.setTypeDetailId(material.getTypeDetailId()); |
| 104 | 102 | inventory.setTypeDetailName(material.getTypeDetailName()); |
| 105 | 103 | inventory.setSpecifications(in.getSpecifications()); |
| 106 | - inventory.setBelongCompanyId(in.getBelongCompanyId()); | |
| 107 | - inventory.setBelongCompanyName(in.getBelongCompanyName()); | |
| 108 | 104 | inventory.setUnitId(in.getUnitId()); |
| 109 | 105 | inventory.setUnitName(in.getUnitName()); |
| 110 | 106 | inventory.setCurrentNum(in.getInInventoryNum()); |
| ... | ... | @@ -133,8 +129,8 @@ public class MaterialInventoryInServiceImpl implements MaterialInventoryInServic |
| 133 | 129 | updateObj.setMaterialTypeId(material.getMaterialTypeId()); |
| 134 | 130 | updateObj.setMaterialTypeName(material.getMaterialTypeName()); |
| 135 | 131 | updateObj.setSpecifications(material.getSpecifications()); |
| 136 | - updateObj.setBelongCompanyId(material.getBelongCompanyId()); | |
| 137 | - updateObj.setBelongCompanyName(material.getBelongCompanyName()); | |
| 132 | + //updateObj.setBelongCompanyId(material.getBelongCompanyId()); | |
| 133 | + //updateObj.setBelongCompanyName(material.getBelongCompanyName()); | |
| 138 | 134 | updateObj.setUnitId(material.getUnitId()); |
| 139 | 135 | updateObj.setUnitName(material.getUnitName()); |
| 140 | 136 | materialInventoryInMapper.updateById(updateObj); |
| ... | ... | @@ -148,20 +144,17 @@ public class MaterialInventoryInServiceImpl implements MaterialInventoryInServic |
| 148 | 144 | if (null == materialInventoryIn) { |
| 149 | 145 | throw exception(MATERIAL_INVENTORY_IN_NOT_EXISTS); |
| 150 | 146 | } |
| 151 | - MaterialInventoryDO materialInventory = materialInventoryService.selectTdMaterialInventoryByMaterialId(materialInventoryIn.getMaterialId()); | |
| 152 | - if(null == materialInventory){ | |
| 147 | + MaterialInventoryDO inventory = materialInventoryService.selectMaterialInventoryByMaterialId(materialInventoryIn.getMaterialId()); | |
| 148 | + if(null == inventory){ | |
| 153 | 149 | throw exception0(BAD_REQUEST.getCode(),"参数错误"); |
| 154 | 150 | } |
| 155 | 151 | //库存已使用 |
| 156 | - if(materialInventory.getCurrentNum() < materialInventoryIn.getInInventoryNum()){ | |
| 152 | + if(inventory.getCurrentNum() < materialInventoryIn.getInInventoryNum()){ | |
| 157 | 153 | throw exception0(BAD_REQUEST.getCode(),"库存已使用"); |
| 158 | 154 | } |
| 159 | 155 | //入库记录减扣 |
| 160 | - MaterialInventoryDO inventory = new MaterialInventoryDO(); | |
| 161 | - inventory.setInventoryId(materialInventory.getInventoryId()); | |
| 162 | - inventory.setMaterialId(materialInventory.getMaterialId()); | |
| 163 | - inventory.setCurrentNum(materialInventory.getCurrentNum() - materialInventoryIn.getInInventoryNum()); | |
| 164 | - inventory.setInventoryTotalNum(materialInventory.getInventoryTotalNum() - materialInventoryIn.getInInventoryNum()); | |
| 156 | + inventory.setCurrentNum(inventory.getCurrentNum() - materialInventoryIn.getInInventoryNum()); | |
| 157 | + inventory.setInventoryTotalNum(inventory.getInventoryTotalNum() - materialInventoryIn.getInInventoryNum()); | |
| 165 | 158 | materialInventoryService.updateTdMaterialInventory(inventory); |
| 166 | 159 | // 删除 |
| 167 | 160 | materialInventoryInMapper.deleteById(id); | ... | ... |
urbanops-module-garden/src/main/java/com/zteits/urbanops/module/garden/service/materialinventoryout/MaterialInventoryOutServiceImpl.java
| 1 | 1 | package com.zteits.urbanops.module.garden.service.materialinventoryout; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.util.RandomUtil; | |
| 3 | 4 | import com.zteits.urbanops.framework.common.pojo.PageResult; |
| 4 | 5 | import com.zteits.urbanops.framework.common.util.object.BeanUtils; |
| 5 | 6 | import com.zteits.urbanops.module.garden.controller.admin.materialinventoryout.vo.MaterialInventoryOutPageReqVO; |
| ... | ... | @@ -52,7 +53,7 @@ public class MaterialInventoryOutServiceImpl implements MaterialInventoryOutServ |
| 52 | 53 | if(null == material){ |
| 53 | 54 | throw exception0(BAD_REQUEST.getCode(), "无效参数-materialId"); |
| 54 | 55 | } |
| 55 | - MaterialInventoryDO materialInventory = materialInventoryService.selectTdMaterialInventoryByMaterialId(out.getMaterialId()); | |
| 56 | + MaterialInventoryDO materialInventory = materialInventoryService.selectMaterialInventoryByMaterialId(material.getMaterialId()); | |
| 56 | 57 | if(null == materialInventory){ |
| 57 | 58 | throw exception0(BAD_REQUEST.getCode(),createReqVO.getMaterialName()+"没有库存"); |
| 58 | 59 | } |
| ... | ... | @@ -64,6 +65,8 @@ public class MaterialInventoryOutServiceImpl implements MaterialInventoryOutServ |
| 64 | 65 | if(null == deptRespDTO){ |
| 65 | 66 | throw exception0(BAD_REQUEST.getCode(), "无效参数-登录人所属单位为空"); |
| 66 | 67 | } |
| 68 | + out.setInventoryOutNo(System.currentTimeMillis()+ RandomUtil.randomInt(10, 100000)+""); | |
| 69 | + out.setMaterialId(createReqVO.getMaterialId()); | |
| 67 | 70 | out.setMaterialName(material.getMaterialName()); |
| 68 | 71 | out.setMaterialTypeId(material.getMaterialTypeId()); |
| 69 | 72 | out.setMaterialTypeName(material.getMaterialTypeName()); |
| ... | ... | @@ -76,8 +79,10 @@ public class MaterialInventoryOutServiceImpl implements MaterialInventoryOutServ |
| 76 | 79 | // out.setBelongCompanyName(material.getBelongCompanyName()); |
| 77 | 80 | out.setBelongCompanyId(deptRespDTO.getId()); |
| 78 | 81 | out.setBelongCompanyName(deptRespDTO.getName()); |
| 82 | + out.setOutInventoryNum(createReqVO.getOutInventoryNum()); | |
| 79 | 83 | out.setUnitId(material.getUnitId()); |
| 80 | 84 | out.setUnitName(material.getUnitName()); |
| 85 | + out.setOutDate(createReqVO.getOutDate()); | |
| 81 | 86 | materialInventoryOutMapper.insert(out); |
| 82 | 87 | |
| 83 | 88 | //更新库存 |
| ... | ... | @@ -103,23 +108,19 @@ public class MaterialInventoryOutServiceImpl implements MaterialInventoryOutServ |
| 103 | 108 | throw exception(MATERIAL_INVENTORY_OUT_NOT_EXISTS); |
| 104 | 109 | } |
| 105 | 110 | |
| 106 | - //查询库存 | |
| 107 | - MaterialInventoryDO materialInventory = materialInventoryService.selectTdMaterialInventoryByMaterialId(materialInventoryOut.getMaterialId()); | |
| 108 | - if(null == materialInventory){ | |
| 111 | + MaterialInventoryDO inventory = materialInventoryService.selectMaterialInventoryByMaterialId(materialInventoryOut.getMaterialId()); | |
| 112 | + if(null == inventory){ | |
| 109 | 113 | throw exception0(BAD_REQUEST.getCode(),"参数错误"); |
| 110 | 114 | } |
| 111 | 115 | //库存已使用 |
| 112 | - if(materialInventory.getCurrentNum() < materialInventoryOut.getOutInventoryNum()){ | |
| 116 | + if(inventory.getCurrentNum() < materialInventoryOut.getOutInventoryNum()){ | |
| 113 | 117 | throw exception0(BAD_REQUEST.getCode(),"库存已使用"); |
| 114 | 118 | } |
| 115 | 119 | |
| 116 | 120 | //入库记录减扣 |
| 117 | - MaterialInventoryDO inventory = new MaterialInventoryDO(); | |
| 118 | - inventory.setInventoryId(materialInventory.getInventoryId()); | |
| 119 | - inventory.setMaterialId(materialInventory.getMaterialId()); | |
| 120 | - inventory.setCurrentNum(materialInventory.getCurrentNum() + materialInventoryOut.getOutInventoryNum()); | |
| 121 | - inventory.setInventoryTotalNum(materialInventory.getInventoryTotalNum() + materialInventoryOut.getOutInventoryNum()); | |
| 122 | - inventory.setOutTotalNum(materialInventory.getOutTotalNum() - materialInventoryOut.getOutInventoryNum()); | |
| 121 | + inventory.setCurrentNum(inventory.getCurrentNum() + materialInventoryOut.getOutInventoryNum()); | |
| 122 | + inventory.setInventoryTotalNum(inventory.getInventoryTotalNum() + materialInventoryOut.getOutInventoryNum()); | |
| 123 | + inventory.setOutTotalNum(inventory.getOutTotalNum() - materialInventoryOut.getOutInventoryNum()); | |
| 123 | 124 | materialInventoryService.updateTdMaterialInventory(inventory); |
| 124 | 125 | |
| 125 | 126 | // 删除 | ... | ... |