| | |
| | | import com.java110.core.annotation.Java110Cmd; |
| | | import com.java110.core.annotation.Java110Transactional; |
| | | import com.java110.core.context.ICmdDataFlowContext; |
| | | import com.java110.core.event.cmd.AbstractServiceCmdListener; |
| | | import com.java110.core.event.cmd.Cmd; |
| | | import com.java110.core.event.cmd.CmdEvent; |
| | | import com.java110.dto.org.OrgDto; |
| | | import com.java110.dto.org.OrgStaffRelDto; |
| | |
| | | * // modify by 张三 at 2021-09-12 第10行在某种场景下存在某种bug 需要修复,注释10至20行 加入 20行至30行 |
| | | */ |
| | | @Java110Cmd(serviceCode = "org.deleteOrg") |
| | | public class DeleteOrgCmd extends AbstractServiceCmdListener { |
| | | public class DeleteOrgCmd extends Cmd { |
| | | private static Logger logger = LoggerFactory.getLogger(DeleteOrgCmd.class); |
| | | |
| | | @Autowired |
| | |
| | | |
| | | Assert.listOnlyOne(orgDtos, "不存在"); |
| | | |
| | | if (OrgDto.ORG_LEVEL_COMPANY.equals(orgDtos.get(0).getOrgLevel())) { |
| | | //查询是否存在部门 |
| | | orgDto = new OrgDto(); |
| | | orgDto.setParentOrgId(reqJson.getString("orgId")); |
| | | List<OrgDto> subOrgDtos = orgV1InnerServiceSMOImpl.queryOrgs(orgDto); |
| | | if (subOrgDtos != null && subOrgDtos.size() > 0) { |
| | | throw new CmdException("公司下存在部门 请先删除部门后再删除"); |
| | | } |
| | | }else if (OrgDto.ORG_LEVEL_DEPARTMENT.equals(orgDtos.get(0).getOrgLevel())) { |
| | | //查询是否存在部门 |
| | | OrgStaffRelDto orgStaffRelDto = new OrgStaffRelDto(); |
| | | orgStaffRelDto.setOrgId(reqJson.getString("orgId")); |
| | | List<OrgStaffRelDto> subOrgDtos = orgStaffRelV1InnerServiceSMOImpl.queryOrgStaffRels(orgStaffRelDto); |
| | | if (subOrgDtos == null || subOrgDtos.size() < 1) { |
| | | return; |
| | | } |
| | | UserDto userDto = new UserDto(); |
| | | userDto.setUserId(subOrgDtos.get(0).getStaffId()); |
| | | List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto); |
| | | if (userDtos != null && userDtos.size() > 0) { |
| | | throw new CmdException("部门下存在员工 请先删除员工后再删除"); |
| | | } |
| | | orgDto = new OrgDto(); |
| | | orgDto.setParentOrgId(reqJson.getString("orgId")); |
| | | List<OrgDto> subOrgDtos = orgV1InnerServiceSMOImpl.queryOrgs(orgDto); |
| | | if (subOrgDtos != null && subOrgDtos.size() > 0) { |
| | | throw new CmdException("存在子组织"); |
| | | } |
| | | |
| | | OrgStaffRelDto orgStaffRelDto = new OrgStaffRelDto(); |
| | | orgStaffRelDto.setOrgId(reqJson.getString("orgId")); |
| | | List<OrgStaffRelDto> orgStaffRelDtos = orgStaffRelV1InnerServiceSMOImpl.queryOrgStaffRels(orgStaffRelDto); |
| | | if (orgStaffRelDtos == null || orgStaffRelDtos.size() < 1) { |
| | | return; |
| | | } |
| | | UserDto userDto = new UserDto(); |
| | | userDto.setUserId(orgStaffRelDtos.get(0).getStaffId()); |
| | | List<UserDto> userDtos = userV1InnerServiceSMOImpl.queryUsers(userDto); |
| | | if (userDtos != null && userDtos.size() > 0) { |
| | | throw new CmdException("存在员工 请先删除员工后再删除"); |
| | | } |
| | | |
| | | } |
| | | |
| | | @Override |