1.删除第三方仓库,校验分仓数量

fencang
x_z 3 years ago
parent bcf552d948
commit b3a419db6b

@ -121,15 +121,11 @@ public class ThrInvWarehouseController {
@PostMapping("/spms/thrsys/warehouse/delete")
public BaseResponse delete(@RequestBody DeleteRequest deleteRequest) {
if (deleteRequest.getId() == null) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
boolean b = thrInvWarehouseService.deleteById(deleteRequest.getId());
if (!b) {
return ResultVOUtils.error(ResultEnum.NOT_NETWORK);
}
return ResultVOUtils.success();
return thrInvWarehouseService.deleteInvById(deleteRequest.getId());
}
}

@ -21,4 +21,12 @@ public interface ThrSubInvWarehouseDao {
boolean deleteById(@Param("id") String id);
/**
*
*
* @param parentId
* @return
*/
int countSubInvByParentInvId(String parentInvId);
}

@ -3,6 +3,7 @@ package com.glxp.sale.admin.service.thrsys;
import com.glxp.sale.admin.entity.thrsys.ThrInvWarehouseEntity;
import com.glxp.sale.admin.req.thrsys.FilterThrInvWarehouseRequest;
import com.glxp.sale.common.res.BaseResponse;
import java.util.List;
@ -28,4 +29,12 @@ public interface ThrInvWarehouseService {
boolean deleteById(String id);
ThrInvWarehouseEntity selectMaxCode(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest);
/**
*
*
* @param id
* @return
*/
BaseResponse deleteInvById(String id);
}

@ -2,9 +2,12 @@ package com.glxp.sale.admin.service.thrsys.impl;
import com.github.pagehelper.PageHelper;
import com.glxp.sale.admin.dao.thrsys.ThrInvWarehouseDao;
import com.glxp.sale.admin.dao.thrsys.ThrSubInvWarehouseDao;
import com.glxp.sale.admin.entity.thrsys.ThrInvWarehouseEntity;
import com.glxp.sale.admin.req.thrsys.FilterThrInvWarehouseRequest;
import com.glxp.sale.admin.service.thrsys.ThrInvWarehouseService;
import com.glxp.sale.common.res.BaseResponse;
import com.glxp.sale.common.util.ResultVOUtils;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
@ -16,7 +19,9 @@ public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService {
@Resource
ThrInvWarehouseDao thrInvWarehouseDao;
private ThrInvWarehouseDao thrInvWarehouseDao;
@Resource
private ThrSubInvWarehouseDao thrSubInvWarehouseDao;
@Override
public ThrInvWarehouseEntity findDefault(Boolean advaceType, Boolean isDefault) {
@ -86,6 +91,11 @@ public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService {
@Override
public boolean deleteById(String id) {
//查询有无子仓库
int count = thrSubInvWarehouseDao.countSubInvByParentInvId(id);
if (count > 0) {
return false;
}
return thrInvWarehouseDao.deleteById(id);
}
@ -93,4 +103,14 @@ public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService {
public ThrInvWarehouseEntity selectMaxCode(FilterThrInvWarehouseRequest filterThrInvWarehouseRequest) {
return thrInvWarehouseDao.selectMaxCode(filterThrInvWarehouseRequest);
}
@Override
public BaseResponse deleteInvById(String id) {
//查询有无子仓库
int count = thrSubInvWarehouseDao.countSubInvByParentInvId(id);
if (count > 0) {
return ResultVOUtils.error(500, "请先删除子仓库!");
}
return ResultVOUtils.success("删除成功");
}
}

@ -32,6 +32,10 @@
WHERE id = #{id}
</select>
<select id="countSubInvByParentInvId" resultType="java.lang.Integer">
select count(*) from thr_inv_warehouse_sub where
parentId = (select code from thr_inv_warehouse where id = #{parentInvId})
</select>
<insert id="insertThrInvWarehouse" keyProperty="id"
parameterType="com.glxp.sale.admin.entity.thrsys.ThrSubInvWarehouseEntity">

Loading…
Cancel
Save