Your Name
2023-03-24 08dc57afa20d215b763f23a40eaad74db20e9d66
service-user/src/main/java/com/java110/user/cmd/org/DeleteOrgCmd.java
@@ -19,7 +19,7 @@
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;
@@ -49,7 +49,7 @@
 * // 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
@@ -73,29 +73,26 @@
        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