Lius
2025-08-25 2b9ff0c274a847af41b2f5a04de1b23ed6fbb9bb
lxzn-module-mdc/src/main/java/org/jeecg/modules/mdc/service/impl/MdcEfficiencyReportServiceImpl.java
@@ -115,56 +115,22 @@
            if ("2".equals(vo.getTypeTree())) {
                // 部门层级
                List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList());
                // 查询所有部门信息
                List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(SysDepart::getDepartOrder));
                for (MdcEquDepDto mdcEquDepDto : equipmentList) {
                    MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto();
                    mdcEfficiencyListDto.setEquipmentId(mdcEquDepDto.getEquipmentId());
                    mdcEfficiencyListDto.setEquipmentName(mdcEquDepDto.getEquipmentName());
                    mdcEfficiencyListDto.setEquipmentType(mdcEquDepDto.getEquipmentType());
                    switch (mdcEquDepDto.getOrgType()) {
                        case "1":
                            mdcEfficiencyListDto.setLevel1(mdcEquDepDto.getDepartName());
                            break;
                        case "2":
                            mdcEfficiencyListDto.setLevel2(mdcEquDepDto.getDepartName());
                            break;
                        case "3":
                            mdcEfficiencyListDto.setLevel3(mdcEquDepDto.getDepartName());
                            break;
                        default:
                    String orgCode = mdcEquDepDto.getOrgCode();
                    if (orgCode != null) {
                        if (orgCode.length() >= 3) {
                            mdcEfficiencyListDto.setLevel1(sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(SysDepart::getOrgCode, orgCode.substring(0, 3))).getDepartName());
                    }
                    SysDepart sysDepart = departList.stream().filter(depart -> depart.getId().equals(mdcEquDepDto.getParentId())).findAny().orElse(null);
                    if (sysDepart != null) {
                        switch (sysDepart.getOrgType()) {
                            case "1":
                                mdcEfficiencyListDto.setLevel1(sysDepart.getDepartName());
                                break;
                            case "2":
                                mdcEfficiencyListDto.setLevel2(sysDepart.getDepartName());
                                break;
                            case "3":
                                mdcEfficiencyListDto.setLevel3(sysDepart.getDepartName());
                                break;
                            default:
                        if (orgCode.length() >= 6) {
                            mdcEfficiencyListDto.setLevel2(sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(SysDepart::getOrgCode, orgCode.substring(0, 6))).getDepartName());
                        }
                        if (StringUtils.isNotEmpty(sysDepart.getParentId())) {
                            departList.stream().filter(depart -> depart.getId().equals(sysDepart.getParentId())).findAny().ifPresent(depart1 -> {
                                switch (depart1.getOrgType()) {
                                    case "1":
                                        mdcEfficiencyListDto.setLevel1(depart1.getDepartName());
                                        break;
                                    case "2":
                                        mdcEfficiencyListDto.setLevel2(depart1.getDepartName());
                                        break;
                                    case "3":
                                        mdcEfficiencyListDto.setLevel3(depart1.getDepartName());
                                        break;
                                    default:
                                }
                            });
                        if (orgCode.length() >= 9) {
                            mdcEfficiencyListDto.setLevel3(sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(SysDepart::getOrgCode, orgCode.substring(0, 9))).getDepartName());
                        }
                    }
                    List<MdcEfficiencyResultDto> list = new ArrayList<>();
@@ -204,55 +170,22 @@
            } else {
                // 产线层级
                List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList());
                // 查询所有产线信息
                List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder));
                for (MdcEquProDto mdcEquProDto : equipmentList) {
                    MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto();
                    mdcEfficiencyListDto.setEquipmentId(mdcEquProDto.getEquipmentId());
                    mdcEfficiencyListDto.setEquipmentName(mdcEquProDto.getEquipmentName());
                    mdcEfficiencyListDto.setEquipmentType(mdcEquProDto.getEquipmentType());
                    switch (mdcEquProDto.getOrgType()) {
                        case "1":
                            mdcEfficiencyListDto.setLevel1(mdcEquProDto.getProductionName());
                            break;
                        case "2":
                            mdcEfficiencyListDto.setLevel2(mdcEquProDto.getProductionName());
                            break;
                        case "3":
                            mdcEfficiencyListDto.setLevel3(mdcEquProDto.getProductionName());
                            break;
                        default:
                    String orgCode = mdcEquProDto.getOrgCode();
                    if (orgCode != null) {
                        if (orgCode.length() >= 3) {
                            mdcEfficiencyListDto.setLevel1(mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(MdcProduction::getOrgCode, orgCode.substring(0, 3))).getProductionName());
                    }
                    MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null);
                    if (mdcProduction != null) {
                        switch (mdcProduction.getOrgType()) {
                            case "1":
                                mdcEfficiencyListDto.setLevel1(mdcProduction.getProductionName());
                                break;
                            case "2":
                                mdcEfficiencyListDto.setLevel2(mdcProduction.getProductionName());
                                break;
                            case "3":
                                mdcEfficiencyListDto.setLevel3(mdcProduction.getProductionName());
                                break;
                            default:
                        if (orgCode.length() >= 6) {
                            mdcEfficiencyListDto.setLevel2(mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(MdcProduction::getOrgCode, orgCode.substring(0, 6))).getProductionName());
                        }
                        if (StringUtils.isNotEmpty(mdcProduction.getParentId())) {
                            productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> {
                                switch (production1.getOrgType()) {
                                    case "1":
                                        mdcEfficiencyListDto.setLevel1(production1.getProductionName());
                                        break;
                                    case "2":
                                        mdcEfficiencyListDto.setLevel2(production1.getProductionName());
                                        break;
                                    case "3":
                                        mdcEfficiencyListDto.setLevel3(production1.getProductionName());
                                        break;
                                    default:
                                }
                            });
                        if (orgCode.length() >= 9) {
                            mdcEfficiencyListDto.setLevel3(mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(MdcProduction::getOrgCode, orgCode.substring(0, 9))).getProductionName());
                        }
                    }
                    List<MdcEfficiencyResultDto> list = new ArrayList<>();
@@ -463,56 +396,22 @@
            if ("2".equals(vo.getTypeTree())) {
                // 部门层级
                List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList());
                // 查询所有部门信息
                List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(SysDepart::getDepartOrder));
                for (MdcEquDepDto mdcEquDepDto : equipmentList) {
                    MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto();
                    mdcEfficiencyListDto.setEquipmentId(mdcEquDepDto.getEquipmentId());
                    mdcEfficiencyListDto.setEquipmentName(mdcEquDepDto.getEquipmentName());
                    mdcEfficiencyListDto.setEquipmentType(mdcEquDepDto.getEquipmentType());
                    switch (mdcEquDepDto.getOrgType()) {
                        case "1":
                            mdcEfficiencyListDto.setLevel1(mdcEquDepDto.getDepartName());
                            break;
                        case "2":
                            mdcEfficiencyListDto.setLevel2(mdcEquDepDto.getDepartName());
                            break;
                        case "3":
                            mdcEfficiencyListDto.setLevel3(mdcEquDepDto.getDepartName());
                            break;
                        default:
                    String orgCode = mdcEquDepDto.getOrgCode();
                    if (orgCode != null) {
                        if (orgCode.length() >= 3) {
                            mdcEfficiencyListDto.setLevel1(sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(SysDepart::getOrgCode, orgCode.substring(0, 3))).getDepartName());
                    }
                    SysDepart sysDepart = departList.stream().filter(depart -> depart.getId().equals(mdcEquDepDto.getParentId())).findAny().orElse(null);
                    if (sysDepart != null) {
                        switch (sysDepart.getOrgType()) {
                            case "1":
                                mdcEfficiencyListDto.setLevel1(sysDepart.getDepartName());
                                break;
                            case "2":
                                mdcEfficiencyListDto.setLevel2(sysDepart.getDepartName());
                                break;
                            case "3":
                                mdcEfficiencyListDto.setLevel3(sysDepart.getDepartName());
                                break;
                            default:
                        if (orgCode.length() >= 6) {
                            mdcEfficiencyListDto.setLevel2(sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(SysDepart::getOrgCode, orgCode.substring(0, 6))).getDepartName());
                        }
                        if (StringUtils.isNotEmpty(sysDepart.getParentId())) {
                            departList.stream().filter(depart -> depart.getId().equals(sysDepart.getParentId())).findAny().ifPresent(depart1 -> {
                                switch (depart1.getOrgType()) {
                                    case "1":
                                        mdcEfficiencyListDto.setLevel1(depart1.getDepartName());
                                        break;
                                    case "2":
                                        mdcEfficiencyListDto.setLevel2(depart1.getDepartName());
                                        break;
                                    case "3":
                                        mdcEfficiencyListDto.setLevel3(depart1.getDepartName());
                                        break;
                                    default:
                                }
                            });
                        if (orgCode.length() >= 9) {
                            mdcEfficiencyListDto.setLevel3(sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(SysDepart::getOrgCode, orgCode.substring(0, 9))).getDepartName());
                        }
                    }
                    List<MdcEfficiencyResultDto> list = new ArrayList<>();
@@ -552,55 +451,22 @@
            } else {
                // 产线层级
                List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList());
                // 查询所有产线信息
                List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder));
                for (MdcEquProDto mdcEquProDto : equipmentList) {
                    MdcEfficiencyListDto mdcEfficiencyListDto = new MdcEfficiencyListDto();
                    mdcEfficiencyListDto.setEquipmentId(mdcEquProDto.getEquipmentId());
                    mdcEfficiencyListDto.setEquipmentName(mdcEquProDto.getEquipmentName());
                    mdcEfficiencyListDto.setEquipmentType(mdcEquProDto.getEquipmentType());
                    switch (mdcEquProDto.getOrgType()) {
                        case "1":
                            mdcEfficiencyListDto.setLevel1(mdcEquProDto.getProductionName());
                            break;
                        case "2":
                            mdcEfficiencyListDto.setLevel2(mdcEquProDto.getProductionName());
                            break;
                        case "3":
                            mdcEfficiencyListDto.setLevel3(mdcEquProDto.getProductionName());
                            break;
                        default:
                    String orgCode = mdcEquProDto.getOrgCode();
                    if (orgCode != null) {
                        if (orgCode.length() >= 3) {
                            mdcEfficiencyListDto.setLevel1(mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(MdcProduction::getOrgCode, orgCode.substring(0, 3))).getProductionName());
                    }
                    MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null);
                    if (mdcProduction != null) {
                        switch (mdcProduction.getOrgType()) {
                            case "1":
                                mdcEfficiencyListDto.setLevel1(mdcProduction.getProductionName());
                                break;
                            case "2":
                                mdcEfficiencyListDto.setLevel2(mdcProduction.getProductionName());
                                break;
                            case "3":
                                mdcEfficiencyListDto.setLevel3(mdcProduction.getProductionName());
                                break;
                            default:
                        if (orgCode.length() >= 6) {
                            mdcEfficiencyListDto.setLevel2(mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(MdcProduction::getOrgCode, orgCode.substring(0, 6))).getProductionName());
                        }
                        if (StringUtils.isNotEmpty(mdcProduction.getParentId())) {
                            productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> {
                                switch (production1.getOrgType()) {
                                    case "1":
                                        mdcEfficiencyListDto.setLevel1(production1.getProductionName());
                                        break;
                                    case "2":
                                        mdcEfficiencyListDto.setLevel2(production1.getProductionName());
                                        break;
                                    case "3":
                                        mdcEfficiencyListDto.setLevel3(production1.getProductionName());
                                        break;
                                    default:
                                }
                            });
                        if (orgCode.length() >= 9) {
                            mdcEfficiencyListDto.setLevel3(mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(MdcProduction::getOrgCode, orgCode.substring(0, 9))).getProductionName());
                        }
                    }
                    List<MdcEfficiencyResultDto> list = new ArrayList<>();
@@ -813,8 +679,6 @@
            if ("2".equals(vo.getTypeTree())) {
                // 部门层级
                List<MdcEquDepDto> equipmentList = mdcEquipmentService.findEquDepList(vo.getEquipmentIdList());
                // 查询所有部门信息
                List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(SysDepart::getDepartOrder));
                // 班次名称显示处理
                String shiftSubName = "";
                if (StringUtils.isBlank(vo.getShiftId())) {
@@ -842,48 +706,16 @@
                    mdcEfficiencyShiftListDto.setEquipmentName(mdcEquDepDto.getEquipmentName());
                    mdcEfficiencyShiftListDto.setEquipmentType(mdcEquDepDto.getEquipmentType());
                    mdcEfficiencyShiftListDto.setShiftSubName(shiftSubName);
                    switch (mdcEquDepDto.getOrgType()) {
                        case "1":
                            mdcEfficiencyShiftListDto.setLevel1(mdcEquDepDto.getDepartName());
                            break;
                        case "2":
                            mdcEfficiencyShiftListDto.setLevel2(mdcEquDepDto.getDepartName());
                            break;
                        case "3":
                            mdcEfficiencyShiftListDto.setLevel3(mdcEquDepDto.getDepartName());
                            break;
                        default:
                    String orgCode = mdcEquDepDto.getOrgCode();
                    if (orgCode != null) {
                        if (orgCode.length() >= 3) {
                            mdcEfficiencyShiftListDto.setLevel1(sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(SysDepart::getOrgCode, orgCode.substring(0, 3))).getDepartName());
                    }
                    SysDepart sysDepart = departList.stream().filter(depart -> depart.getId().equals(mdcEquDepDto.getParentId())).findAny().orElse(null);
                    if (sysDepart != null) {
                        switch (sysDepart.getOrgType()) {
                            case "1":
                                mdcEfficiencyShiftListDto.setLevel1(sysDepart.getDepartName());
                                break;
                            case "2":
                                mdcEfficiencyShiftListDto.setLevel2(sysDepart.getDepartName());
                                break;
                            case "3":
                                mdcEfficiencyShiftListDto.setLevel3(sysDepart.getDepartName());
                                break;
                            default:
                        if (orgCode.length() >= 6) {
                            mdcEfficiencyShiftListDto.setLevel2(sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(SysDepart::getOrgCode, orgCode.substring(0, 6))).getDepartName());
                        }
                        if (StringUtils.isNotEmpty(sysDepart.getParentId())) {
                            departList.stream().filter(depart -> depart.getId().equals(sysDepart.getParentId())).findAny().ifPresent(depart1 -> {
                                switch (depart1.getOrgType()) {
                                    case "1":
                                        mdcEfficiencyShiftListDto.setLevel1(depart1.getDepartName());
                                        break;
                                    case "2":
                                        mdcEfficiencyShiftListDto.setLevel2(depart1.getDepartName());
                                        break;
                                    case "3":
                                        mdcEfficiencyShiftListDto.setLevel3(depart1.getDepartName());
                                        break;
                                    default:
                                }
                            });
                        if (orgCode.length() >= 9) {
                            mdcEfficiencyShiftListDto.setLevel3(sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().ne(SysDepart::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(SysDepart::getOrgCode, orgCode.substring(0, 9))).getDepartName());
                        }
                    }
                    List<MdcEfficiencyShiftResultDto> list = new ArrayList<>();
@@ -923,8 +755,6 @@
            } else {
                // 产线层级
                List<MdcEquProDto> equipmentList = mdcEquipmentService.findEquProList(vo.getEquipmentIdList());
                // 查询所有产线信息
                List<MdcProduction> productionList = mdcProductionService.list(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).orderByAsc(MdcProduction::getProductionOrder));
                // 班次名称显示处理
                String shiftSubName = "";
@@ -953,47 +783,16 @@
                    mdcEfficiencyShiftListDto.setEquipmentName(mdcEquProDto.getEquipmentName());
                    mdcEfficiencyShiftListDto.setEquipmentType(mdcEquProDto.getEquipmentType());
                    mdcEfficiencyShiftListDto.setShiftSubName(shiftSubName);
                    switch (mdcEquProDto.getOrgType()) {
                        case "1":
                            mdcEfficiencyShiftListDto.setLevel1(mdcEquProDto.getProductionName());
                            break;
                        case "2":
                            mdcEfficiencyShiftListDto.setLevel2(mdcEquProDto.getProductionName());
                            break;
                        case "3":
                            mdcEfficiencyShiftListDto.setLevel3(mdcEquProDto.getProductionName());
                            break;
                        default:
                    String orgCode = mdcEquProDto.getOrgCode();
                    if (orgCode != null) {
                        if (orgCode.length() >= 3) {
                            mdcEfficiencyShiftListDto.setLevel1(mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(MdcProduction::getOrgCode, orgCode.substring(0, 3))).getProductionName());
                    }
                    MdcProduction mdcProduction = productionList.stream().filter(production -> production.getId().equals(mdcEquProDto.getParentId())).findAny().orElse(null);
                    if (mdcProduction != null) {
                        switch (mdcProduction.getOrgType()) {
                            case "1":
                                mdcEfficiencyShiftListDto.setLevel1(mdcProduction.getProductionName());
                                break;
                            case "2":
                                mdcEfficiencyShiftListDto.setLevel2(mdcProduction.getProductionName());
                                break;
                            case "3":
                                mdcEfficiencyShiftListDto.setLevel3(mdcProduction.getProductionName());
                                break;
                            default:
                        if (orgCode.length() >= 6) {
                            mdcEfficiencyShiftListDto.setLevel2(mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(MdcProduction::getOrgCode, orgCode.substring(0, 6))).getProductionName());
                        }
                        if (StringUtils.isNotEmpty(mdcProduction.getParentId())) {
                            productionList.stream().filter(production -> production.getId().equals(mdcProduction.getParentId())).findAny().ifPresent(production1 -> {
                                switch (production1.getOrgType()) {
                                    case "1":
                                        mdcEfficiencyShiftListDto.setLevel1(production1.getProductionName());
                                        break;
                                    case "2":
                                        mdcEfficiencyShiftListDto.setLevel2(production1.getProductionName());
                                        break;
                                    case "3":
                                        mdcEfficiencyShiftListDto.setLevel3(production1.getProductionName());
                                        break;
                                    default:
                                }
                            });
                        if (orgCode.length() >= 9) {
                            mdcEfficiencyShiftListDto.setLevel3(mdcProductionService.getOne(new LambdaQueryWrapper<MdcProduction>().ne(MdcProduction::getDelFlag, CommonConstant.DEL_FLAG_1.toString()).eq(MdcProduction::getOrgCode, orgCode.substring(0, 9))).getProductionName());
                        }
                    }
                    List<MdcEfficiencyShiftResultDto> list = new ArrayList<>();
@@ -1729,11 +1528,6 @@
        }
        return result;
    }
    @Override
    public List<BigDecimal> getEfficiencyRate(String equipmentId, String date) {
        return mdcEfficiencyReportMapper.getEfficiencyRate(equipmentId, date);
    }
    private MdcUtilizationResultDto utilizationRate(String equipmentId, String equipmentName, String equipmentType, Date startTime, Date endTime, String date, List<MdcUtilizationRate> mdcUtilizationRateList) {