fix:库区删除增加校验,解决删除报错问题

This commit is contained in:
zhangxuanming 2024-12-20 11:45:59 +08:00
parent ccdc77f67e
commit dde4bbbb1d
6 changed files with 49 additions and 14 deletions

View File

@ -118,12 +118,12 @@ public class WmStorageLocationController extends BaseController
@DeleteMapping("/{locationIds}")
public AjaxResult remove(@PathVariable Long[] locationIds)
{
//TODO:库区删除之前的逻辑校验
for (Long locationId: locationIds
) {
wmStorageAreaService.deleteByLocationId(locationId);
}
return toAjax(wmStorageLocationService.deleteWmStorageLocationByLocationIds(locationIds));
// //TODO:库区删除之前的逻辑校验
//
// for (Long locationId: locationIds
// ) {
// wmStorageAreaService.deleteByLocationId(locationId);
// }
return wmStorageLocationService.deleteWmStorageLocationByLocationIds(locationIds);
}
}

View File

@ -2,6 +2,7 @@ package com.ktg.mes.wm.mapper;
import java.util.List;
import com.ktg.mes.wm.domain.WmStorageLocation;
import org.apache.ibatis.annotations.Param;
/**
* 库区设置Mapper接口
@ -78,4 +79,11 @@ public interface WmStorageLocationMapper
* @return
*/
public int deleteByWarehouseId(Long warehouseId);
/**
* 根据locationIds查询库区数据
* @param locationIds
* @return
*/
List<WmStorageLocation> selectByLocationIds(@Param("ids") Long[] locationIds);
}

View File

@ -1,6 +1,8 @@
package com.ktg.mes.wm.service;
import java.util.List;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.mes.wm.domain.WmStorageLocation;
/**
@ -73,7 +75,7 @@ public interface IWmStorageLocationService
* @param locationIds 需要删除的库区设置主键集合
* @return 结果
*/
public int deleteWmStorageLocationByLocationIds(Long[] locationIds);
public AjaxResult deleteWmStorageLocationByLocationIds(Long[] locationIds);
/**
* 删除库区设置信息

View File

@ -3,9 +3,10 @@ package com.ktg.mes.wm.service.impl;
import java.util.List;
import com.ktg.common.constant.UserConstants;
import com.ktg.common.core.domain.AjaxResult;
import com.ktg.common.utils.DateUtils;
import com.ktg.common.utils.StringUtils;
import org.apache.catalina.User;
import com.ktg.mes.wm.service.IWmStorageAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ktg.mes.wm.mapper.WmStorageLocationMapper;
@ -24,6 +25,9 @@ public class WmStorageLocationServiceImpl implements IWmStorageLocationService
@Autowired
private WmStorageLocationMapper wmStorageLocationMapper;
@Autowired
private IWmStorageAreaService wmStorageAreaService;
/**
* 查询库区设置
*
@ -106,9 +110,23 @@ public class WmStorageLocationServiceImpl implements IWmStorageLocationService
* @return 结果
*/
@Override
public int deleteWmStorageLocationByLocationIds(Long[] locationIds)
public AjaxResult deleteWmStorageLocationByLocationIds(Long[] locationIds)
{
return wmStorageLocationMapper.deleteWmStorageLocationByLocationIds(locationIds);
// 查询所有需要删除的数据
List<WmStorageLocation> list = wmStorageLocationMapper.selectByLocationIds(locationIds);
for (WmStorageLocation item : list) {
String locationCode = item.getLocationCode();
if (locationCode.contains("VIRTUAL")) {
return AjaxResult.error("线边库库区不能被删除");
}
}
for (Long locationId: locationIds
) {
wmStorageAreaService.deleteByLocationId(locationId);
}
wmStorageLocationMapper.deleteWmStorageLocationByLocationIds(locationIds);
return AjaxResult.success();
}
/**

View File

@ -144,7 +144,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</delete>
<delete id="deleteByLocationId" parameterType="Long">
delete form wm_storage_area where location_id = #{locationId}
delete from wm_storage_area where location_id = #{locationId}
</delete>
</mapper>

View File

@ -57,6 +57,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectWmStorageLocationVo"/>
where location_name = #{locationName} and warehouse_id = #{warehouseId} limit 1
</select>
<select id="selectByLocationIds" resultType="com.ktg.mes.wm.domain.WmStorageLocation">
<include refid="selectWmStorageLocationVo"/>
where location_id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</select>
<insert id="insertWmStorageLocation" parameterType="WmStorageLocation" useGeneratedKeys="true" keyProperty="locationId">
insert into wm_storage_location