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

fengcang
x_z 3 years ago
parent 46de56195e
commit 9c037bd480

@ -3,18 +3,15 @@ package com.glxp.api.admin.controller.thrsys;
import cn.hutool.core.util.StrUtil;
import com.github.pagehelper.PageInfo;
import com.glxp.api.admin.dao.basic.BasicThirdSysDao;
import com.glxp.api.admin.entity.basic.BasicThirdSysEntity;
import com.glxp.api.admin.entity.thrsys.ThrInvWarehouseEntity;
import com.glxp.api.admin.req.inout.DeleteRequest;
import com.glxp.api.admin.req.thrsys.FilterThrInvWarehouseRequest;
import com.glxp.api.admin.res.PageSimpleResponse;
import com.glxp.api.admin.res.thrsys.ThrInvWarehouseResponse;
import com.glxp.api.admin.service.thrsys.ThrInvWarehouseService;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -23,7 +20,6 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -109,15 +105,10 @@ 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());
}
/**

@ -1,7 +1,6 @@
package com.glxp.api.admin.dao.thrsys;
import com.glxp.api.admin.entity.thrsys.ThrSubInvWarehouseEntity;
import com.glxp.api.admin.req.thrsys.FilterThrInvWarehouseRequest;
import com.glxp.api.admin.req.thrsys.FilterThrSubInvWarehouseRequest;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -22,4 +21,12 @@ public interface ThrSubInvWarehouseDao {
boolean deleteById(@Param("id") String id);
/**
*
*
* @param parentId
* @return
*/
int countSubInvByParentInvId(String parentInvId);
}

@ -37,4 +37,12 @@ public interface ThrInvWarehouseService {
* @return
*/
BaseResponse downloadThirdWarehouse(String thirdSysFk);
/**
*
*
* @param id
* @return
*/
BaseResponse deleteInvById(String id);
}

@ -1,8 +1,8 @@
package com.glxp.api.admin.service.thrsys.impl;
import com.github.pagehelper.PageHelper;
import com.glxp.api.admin.dao.basic.BasicThirdSysDao;
import com.glxp.api.admin.dao.thrsys.ThrInvWarehouseDao;
import com.glxp.api.admin.dao.thrsys.ThrSubInvWarehouseDao;
import com.glxp.api.admin.entity.thrsys.ThrInvWarehouseEntity;
import com.glxp.api.admin.httpclient.ErpBasicClient;
import com.glxp.api.admin.req.erp.UdiwmsWarehouseRequest;
@ -29,7 +29,7 @@ public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService {
@Resource
private ErpBasicClient erpBasicClient;
@Resource
private BasicThirdSysDao basicThirdSysDao;
private ThrSubInvWarehouseDao thrSubInvWarehouseDao;
@Override
public ThrInvWarehouseEntity findDefault(Boolean advaceType, Boolean isDefault) {
@ -100,6 +100,10 @@ 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);
}
@ -147,4 +151,14 @@ public class ThrInvWarehouseServiceImpl implements ThrInvWarehouseService {
return ResultVOUtils.success("下载结束!");
}
@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.api.admin.entity.thrsys.ThrSubInvWarehouseEntity">

Loading…
Cancel
Save