增加逻辑:删除仓库删除关联的商品的初始库存,删除仓库删除关联的商品的当前库存

This commit is contained in:
jishenghua
2024-08-29 00:14:37 +08:00
parent 6ab20c7baa
commit b0c0c18f3d
5 changed files with 42 additions and 14 deletions

View File

@@ -19,4 +19,6 @@ public interface MaterialCurrentStockMapperEx {
@Param("materialId") Long materialId); @Param("materialId") Long materialId);
BigDecimal getCurrentUnitPriceByMId(@Param("materialId") Long materialId); BigDecimal getCurrentUnitPriceByMId(@Param("materialId") Long materialId);
void batchDeleteByDepots(@Param("ids") String ids[]);
} }

View File

@@ -13,4 +13,5 @@ public interface MaterialInitialStockMapperEx {
List<MaterialInitialStock> getListExceptZero(); List<MaterialInitialStock> getListExceptZero();
void batchDeleteByDepots(@Param("ids") String ids[]);
} }

View File

@@ -5,10 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants; import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.*; import com.jsh.erp.datasource.entities.*;
import com.jsh.erp.datasource.mappers.DepotHeadMapperEx; import com.jsh.erp.datasource.mappers.*;
import com.jsh.erp.datasource.mappers.DepotItemMapperEx;
import com.jsh.erp.datasource.mappers.DepotMapper;
import com.jsh.erp.datasource.mappers.DepotMapperEx;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.exception.JshException; import com.jsh.erp.exception.JshException;
import com.jsh.erp.service.log.LogService; import com.jsh.erp.service.log.LogService;
@@ -35,7 +32,6 @@ public class DepotService {
@Resource @Resource
private DepotMapper depotMapper; private DepotMapper depotMapper;
@Resource @Resource
private DepotMapperEx depotMapperEx; private DepotMapperEx depotMapperEx;
@Resource @Resource
@@ -47,9 +43,11 @@ public class DepotService {
@Resource @Resource
private LogService logService; private LogService logService;
@Resource @Resource
private DepotHeadMapperEx depotHeadMapperEx;
@Resource
private DepotItemMapperEx depotItemMapperEx; private DepotItemMapperEx depotItemMapperEx;
@Resource
private MaterialInitialStockMapperEx materialInitialStockMapperEx;
@Resource
private MaterialCurrentStockMapperEx materialCurrentStockMapperEx;
public Depot getDepot(long id)throws Exception { public Depot getDepot(long id)throws Exception {
Depot result=null; Depot result=null;
@@ -214,6 +212,11 @@ public class DepotService {
User userInfo=userService.getCurrentUser(); User userInfo=userService.getCurrentUser();
//校验通过执行删除操作 //校验通过执行删除操作
try{ try{
//删除仓库关联的商品的初始库存
materialInitialStockMapperEx.batchDeleteByDepots(idArray);
//删除仓库关联的商品的当前库存
materialCurrentStockMapperEx.batchDeleteByDepots(idArray);
//删除仓库
result = depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray); result = depotMapperEx.batchDeleteDepotByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
}catch(Exception e){ }catch(Exception e){
JshException.writeFail(logger, e); JshException.writeFail(logger, e);

View File

@@ -31,4 +31,15 @@
select ifnull(mcs.current_unit_price,0) as current_unit_price from jsh_material_current_stock mcs where mcs.material_id=#{materialId} limit 1 select ifnull(mcs.current_unit_price,0) as current_unit_price from jsh_material_current_stock mcs where mcs.material_id=#{materialId} limit 1
</select> </select>
<update id="batchDeleteByDepots">
update jsh_material_current_stock
set delete_flag='1'
where 1=1
and depot_id in (
<foreach collection="ids" item="id" separator=",">
#{id}
</foreach>
)
</update>
</mapper> </mapper>

View File

@@ -15,4 +15,15 @@
and ifnull(delete_flag,'0') !='1' and ifnull(delete_flag,'0') !='1'
</select> </select>
<update id="batchDeleteByDepots">
update jsh_material_initial_stock
set delete_flag='1'
where 1=1
and depot_id in (
<foreach collection="ids" item="id" separator=",">
#{id}
</foreach>
)
</update>
</mapper> </mapper>