diff --git a/src/main/java/com/glxp/api/controller/auth/DeptController.java b/src/main/java/com/glxp/api/controller/auth/DeptController.java index ea098787..ad94a445 100644 --- a/src/main/java/com/glxp/api/controller/auth/DeptController.java +++ b/src/main/java/com/glxp/api/controller/auth/DeptController.java @@ -14,6 +14,7 @@ import com.glxp.api.entity.auth.AuthAdmin; import com.glxp.api.entity.auth.DeptEntity; import com.glxp.api.entity.auth.DeptUserEntity; import com.glxp.api.entity.auth.InvWarehouseEntity; +import com.glxp.api.entity.purchase.PurDeliveryDetailEntity; import com.glxp.api.entity.system.SystemParamConfigEntity; import com.glxp.api.req.auth.FilterDeptUserReqeust; import com.glxp.api.req.auth.FilterInvWarehouseRequest; @@ -30,6 +31,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.validation.Valid; import java.util.*; +import java.util.stream.Collectors; @RestController public class DeptController extends BaseController { @@ -246,6 +248,21 @@ public class DeptController extends BaseController { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); } + //判断状态 + String msg=isCheckStatus(deptEntity.getStatus(),deptEntity); + if(msg!=""){ + return ResultVOUtils.error(999,msg); + } + //判断供应商状态 + if(deptEntity.isSpUse()==false){ + FilterDeptUserReqeust filterDeptUserReqeust = new FilterDeptUserReqeust(); + filterDeptUserReqeust.setDeptId(deptEntity.getId().longValue()); + List deptUserEntities = deptUserService.selectDeptUser(filterDeptUserReqeust); + if (CollUtil.isNotEmpty(deptUserEntities)) { + return ResultVOUtils.error(500, "修改失败,请先移除该部门关联供应商信息!"); + } + } + List deptEntityList = deptService.selectByNameList(deptEntity.getName()); if (deptEntityList != null && deptEntityList.size() > 0) { for (DeptEntity obj : deptEntityList) { @@ -348,4 +365,25 @@ public class DeptController extends BaseController { return ResultVOUtils.success(list); } + public String isCheckStatus(Integer status,DeptEntity deptEntity){ + //启用的时候需要判断上级是不是被禁用 + if(status==1){ + //查询所有的上级 + List deptEntityList= deptService.selectupDeptAll(deptEntity.getPcode()); + for(DeptEntity obj:deptEntityList){ + if(obj.getStatus()==0){ + return "上级存在禁用的部门修改失败!"; + } + } + }else{ + List deptEntityList= deptService.selectLowDeptAll(deptEntity.getCode()); + for(DeptEntity obj:deptEntityList){ + if(obj.getStatus()==1){ + return "下级存在启用的部门修改失败!"; + } + } + } + return ""; + } + } diff --git a/src/main/java/com/glxp/api/controller/auth/InvWarehouseController.java b/src/main/java/com/glxp/api/controller/auth/InvWarehouseController.java index 2c4da505..ff8dd7b4 100644 --- a/src/main/java/com/glxp/api/controller/auth/InvWarehouseController.java +++ b/src/main/java/com/glxp/api/controller/auth/InvWarehouseController.java @@ -233,6 +233,11 @@ public class InvWarehouseController extends BaseController { return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL); } + Integer userCount = warehouseUserService.countUserBySubInvCode(invWarehouseEntity.getCode()); + if (userCount > 0) { + return ResultVOUtils.error(500, "修改失败,请先移除该仓库关联用户!"); + } + //更新仓库信息 invWarehouseEntity.setUpdateTime(new Date()); boolean b = invWarehouseService.updateInvSubWarehouse(invWarehouseEntity); diff --git a/src/main/java/com/glxp/api/dao/auth/DeptDao.java b/src/main/java/com/glxp/api/dao/auth/DeptDao.java index c6799186..55ebc8f6 100644 --- a/src/main/java/com/glxp/api/dao/auth/DeptDao.java +++ b/src/main/java/com/glxp/api/dao/auth/DeptDao.java @@ -69,4 +69,8 @@ public interface DeptDao { String selectNameByCode(@Param("code") String code); List selectByPcode(@Param("pcode") String pcode); + + List selectupDeptAll(@Param("pcode") String pCode); + + List selectLowDeptAll(@Param("pcode") String pCode); } diff --git a/src/main/java/com/glxp/api/service/auth/DeptService.java b/src/main/java/com/glxp/api/service/auth/DeptService.java index 61bf5e57..66e0d853 100644 --- a/src/main/java/com/glxp/api/service/auth/DeptService.java +++ b/src/main/java/com/glxp/api/service/auth/DeptService.java @@ -77,4 +77,8 @@ public interface DeptService { List selectByPcode(String pcode); + List selectupDeptAll(String pCode); + + List selectLowDeptAll(String pCode); + } diff --git a/src/main/java/com/glxp/api/service/auth/impl/DeptServiceImpl.java b/src/main/java/com/glxp/api/service/auth/impl/DeptServiceImpl.java index 507949e6..7a19c44d 100644 --- a/src/main/java/com/glxp/api/service/auth/impl/DeptServiceImpl.java +++ b/src/main/java/com/glxp/api/service/auth/impl/DeptServiceImpl.java @@ -183,5 +183,15 @@ public class DeptServiceImpl implements DeptService { return deptDao.selectByPcode(pcode); } + @Override + public List selectupDeptAll(String pCode) { + return deptDao.selectupDeptAll(pCode); + } + + @Override + public List selectLowDeptAll(String pCode) { + return deptDao.selectLowDeptAll(pCode); + } + } diff --git a/src/main/resources/mybatis/mapper/auth/DeptDao.xml b/src/main/resources/mybatis/mapper/auth/DeptDao.xml index 8c0dcf0a..d7e3ad76 100644 --- a/src/main/resources/mybatis/mapper/auth/DeptDao.xml +++ b/src/main/resources/mybatis/mapper/auth/DeptDao.xml @@ -312,4 +312,22 @@ + + + +