From e357fdd9ecbe295e0d5fdafa784df3d9b24adf18 Mon Sep 17 00:00:00 2001 From: pengjie <17373303529@163.com> Date: Fri, 21 Jun 2024 19:05:25 +0800 Subject: [PATCH] =?UTF-8?q?BUG=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../xz/controller/XzFlowController.java | 46 +++++++++++++++++++ .../XzRiskPredictionController.java | 39 ++++++++++------ 2 files changed, 70 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/zhgd/xmgl/modules/xz/controller/XzFlowController.java b/src/main/java/com/zhgd/xmgl/modules/xz/controller/XzFlowController.java index 391235101..49cd81bd1 100644 --- a/src/main/java/com/zhgd/xmgl/modules/xz/controller/XzFlowController.java +++ b/src/main/java/com/zhgd/xmgl/modules/xz/controller/XzFlowController.java @@ -11,6 +11,18 @@ import com.wflow.mapper.WflowModelsMapper; import com.wflow.workflow.bean.process.enums.ProcessResultEnum; import com.wflow.workflow.bean.vo.ProcessInstanceVo; import com.zhgd.jeecg.common.api.vo.Result; +import com.zhgd.xmgl.modules.basicdata.entity.SystemUser; +import com.zhgd.xmgl.modules.basicdata.service.ISystemUserService; +import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise; +import com.zhgd.xmgl.modules.project.entity.XzUserToSupplier; +import com.zhgd.xmgl.modules.project.service.IProjectEnterpriseService; +import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo; +import com.zhgd.xmgl.modules.worker.entity.WorkerInfo; +import com.zhgd.xmgl.modules.worker.service.IEnterpriseInfoService; +import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService; +import com.zhgd.xmgl.modules.xz.service.IXzUserToSupplierService; +import com.zhgd.xmgl.security.entity.UserInfo; +import com.zhgd.xmgl.security.util.SecurityUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -50,6 +62,17 @@ public class XzFlowController { @Autowired private WflowModelGroupsMapper wflowModelGroupsMapper; + @Autowired + private IXzUserToSupplierService xzUserToSupplierService; + + @Autowired + private ISystemUserService systemUserService; + + @Autowired + private IWorkerInfoService workerInfoService; + + @Autowired + private IProjectEnterpriseService projectEnterpriseService; @ApiOperation(value = "查询工作流统计信息", notes = "查询工作流统计信息", httpMethod = "GET") @ApiImplicitParams({ @@ -144,6 +167,29 @@ public class XzFlowController { list.addAll(instanceQuery.list()); } List processInstanceVos = getInstances(list); + // 人员数据权限 + UserInfo user = SecurityUtils.getUser(); + SystemUser systemUser = systemUserService.getById(user.getUserId()); + XzUserToSupplier xzUserToSupplier = xzUserToSupplierService.getOne(Wrappers.lambdaQuery() + .eq(XzUserToSupplier::getUserId, systemUser.getUserId())); + Long enterpriseId = xzUserToSupplier.getXzSupplierId(); + List allList = projectEnterpriseService.list(Wrappers.lambdaQuery() + .eq(ProjectEnterprise::getProjectSn, systemUser.getProjectSn())); + ProjectEnterprise projectEnterprise = projectEnterpriseService.getOne(Wrappers.lambdaQuery() + .eq(ProjectEnterprise::getProjectSn, systemUser.getProjectSn()) + .eq(ProjectEnterprise::getEnterpriseId, enterpriseId)); + List enterpriseIds = allList.stream().filter(a -> a.getAncestors().contains(projectEnterprise.getId().toString())).collect(Collectors.toList()) + .stream().map(p -> p.getEnterpriseId()).collect(Collectors.toList()); + enterpriseIds.add(enterpriseId); + List workerInfos = workerInfoService.list(Wrappers.lambdaQuery().in(WorkerInfo::getEnterpriseId, enterpriseIds)) + .stream().map(w -> w.getId()).collect(Collectors.toList()); + if (workerInfos.size() > 0) { + List systemUserList = systemUserService.list(Wrappers.lambdaQuery().in(SystemUser::getWorkerId, workerInfos)) + .stream().map(u -> u.getUserId()).collect(Collectors.toList()); + processInstanceVos = processInstanceVos.stream().filter(p -> systemUserList.contains(p.getStaterUserId())).collect(Collectors.toList()); + } else { + processInstanceVos = new ArrayList<>(); + } Map total = new HashMap<>(); total.put("running", processInstanceVos.stream().filter(l -> l.getFinishTime() == null).count()); total.put("complete", processInstanceVos.stream().filter(l -> l.getFinishTime() != null).count()); diff --git a/src/main/java/com/zhgd/xmgl/modules/xz/controller/XzRiskPredictionController.java b/src/main/java/com/zhgd/xmgl/modules/xz/controller/XzRiskPredictionController.java index cc9ad3bce..addcfdca8 100644 --- a/src/main/java/com/zhgd/xmgl/modules/xz/controller/XzRiskPredictionController.java +++ b/src/main/java/com/zhgd/xmgl/modules/xz/controller/XzRiskPredictionController.java @@ -58,6 +58,7 @@ import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections.MapUtils; +import org.apache.commons.math3.dfp.DfpField; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.*; @@ -138,7 +139,9 @@ public class XzRiskPredictionController { String projectSn = MapUtils.getString(param, "projectSn"); Map resultMap = new HashMap<>(); // 人员数量 - List list = workerInfoService.list(Wrappers.lambdaQuery().eq(WorkerInfo::getProjectSn, projectSn)); + List list = workerInfoService.list(Wrappers.lambdaQuery() + .eq(WorkerInfo::getProjectSn, projectSn) + .eq(WorkerInfo::getInserviceType, 1)); resultMap.put("total", list.size()); // 高龄人员 long ageCount = list.stream().filter(l -> StringUtils.isNotBlank(l.getBirthday()) && DateUtil.ageOfNow(l.getBirthday()) >= 50).count(); @@ -187,9 +190,10 @@ public class XzRiskPredictionController { // 安全检查隐患 List xzSecurityQualityInspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.lambdaQuery() .eq(XzSecurityQualityInspectionRecord::getRecordType, 1) - .eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn)); + .eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn) + .ne(XzSecurityQualityInspectionRecord::getStatus, 6)); if (xzSecurityQualityInspectionRecords.size() > 0) { - long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5 && x.getStatus() != 6).count(); + long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5).count(); resultMap.put("security", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP)); } else { resultMap.put("security", 0); @@ -621,10 +625,12 @@ public class XzRiskPredictionController { List allXzSecurityQualityInspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.lambdaQuery() .eq(XzSecurityQualityInspectionRecord::getRecordType, 1) - .eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn)); + .eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn) + .ne(XzSecurityQualityInspectionRecord::getStatus, 6)); List allWorkerList = workerInfoService.list(Wrappers.lambdaQuery() - .eq(WorkerInfo::getProjectSn, projectSn)); + .eq(WorkerInfo::getProjectSn, projectSn) + .eq(WorkerInfo::getInserviceType, 1)); WorkerType workerType = workerTypeService.getOne(Wrappers.lambdaQuery() .eq(WorkerType::getProjectSn, projectSn) @@ -642,7 +648,7 @@ public class XzRiskPredictionController { Map resultMap = new HashMap<>(); // 人员数量 List list = allWorkerList.stream().filter(a -> enterpriseIds.contains(a.getEnterpriseId())).collect(Collectors.toList()); - resultMap.put("total", list.size()); + resultMap.put("total", new BigDecimal(list.size()).divide(new BigDecimal(allWorkerList.size()), 2, BigDecimal.ROUND_HALF_UP)); // 高龄人员 long ageCount = list.stream().filter(l -> StringUtils.isNotBlank(l.getBirthday()) && DateUtil.ageOfNow(l.getBirthday()) >= 50).count(); resultMap.put("age", new BigDecimal(ageCount).divide(new BigDecimal(list.size()), 2, BigDecimal.ROUND_HALF_UP)); @@ -688,7 +694,7 @@ public class XzRiskPredictionController { List xzSecurityQualityInspectionRecords = allXzSecurityQualityInspectionRecords.stream() .filter(a -> enterpriseIds.contains(a.getEnterpriseId())).collect(Collectors.toList()); if (xzSecurityQualityInspectionRecords.size() > 0) { - long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5 && x.getStatus() != 6).count(); + long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5).count(); resultMap.put("security", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP)); } else { resultMap.put("security", 0); @@ -721,15 +727,16 @@ public class XzRiskPredictionController { // 安全检查隐患 List xzSecurityQualityInspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.lambdaQuery() .eq(XzSecurityQualityInspectionRecord::getRecordType, 1) - .eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn)); + .eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn) + .ne(XzSecurityQualityInspectionRecord::getStatus, 6)); if (xzSecurityQualityInspectionRecords.size() > 0) { - long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5 && x.getStatus() != 6).count(); + long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5).count(); resultMap.put("security", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP)); } else { resultMap.put("security", 0); } // 安全评分 - List list = workerInfoService.list(Wrappers.lambdaQuery().eq(WorkerInfo::getProjectSn, projectSn)); + List list = workerInfoService.list(Wrappers.lambdaQuery().eq(WorkerInfo::getProjectSn, projectSn).eq(WorkerInfo::getInserviceType, 1)); Double safeScore = list.stream().mapToDouble(e -> e.getSafeScore()).sum(); resultMap.put("safe", new BigDecimal(safeScore).divide(new BigDecimal(100)).divide(new BigDecimal(list.size()), 2, BigDecimal.ROUND_HALF_UP)); // 一级二级分险占比 @@ -741,7 +748,7 @@ public class XzRiskPredictionController { } // 超期未关闭 if (xzSecurityQualityInspectionRecords.size() > 0) { - long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5 && x.getStatus() != 6 && DateUtil.parseDate(x.getChangeLimitTime()).compareTo(new Date()) < 0).count(); + long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5 && DateUtil.parseDate(x.getChangeLimitTime()).compareTo(new Date()) < 0).count(); resultMap.put("limitTime", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP)); } else { resultMap.put("limitTime", 0); @@ -770,10 +777,12 @@ public class XzRiskPredictionController { List allXzSecurityQualityInspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.lambdaQuery() .eq(XzSecurityQualityInspectionRecord::getRecordType, 1) - .eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn)); + .eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn) + .ne(XzSecurityQualityInspectionRecord::getStatus, 6)); List allWorkerList = workerInfoService.list(Wrappers.lambdaQuery() - .eq(WorkerInfo::getProjectSn, projectSn)); + .eq(WorkerInfo::getProjectSn, projectSn) + .eq(WorkerInfo::getInserviceType, 1)); for (ProjectEnterprise projectEnterprise : parentList) { EnterpriseInfo enterpriseInfo = enterpriseInfoService.getById(projectEnterprise.getEnterpriseId()); @@ -785,7 +794,7 @@ public class XzRiskPredictionController { // 安全检查隐患 List xzSecurityQualityInspectionRecords = allXzSecurityQualityInspectionRecords.stream().filter(x -> enterpriseIds.contains(x.getEnterpriseId())).collect(Collectors.toList()); if (xzSecurityQualityInspectionRecords.size() > 0) { - long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5 && x.getStatus() != 6).count(); + long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5).count(); resultMap.put("security", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP)); } else { resultMap.put("security", 0); @@ -803,7 +812,7 @@ public class XzRiskPredictionController { } // 超期未关闭 if (xzSecurityQualityInspectionRecords.size() > 0) { - long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5 && x.getStatus() != 6 && DateUtil.parseDate(x.getChangeLimitTime()).compareTo(new Date()) < 0).count(); + long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5 && DateUtil.parseDate(x.getChangeLimitTime()).compareTo(new Date()) < 0).count(); resultMap.put("limitTime", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP)); } else { resultMap.put("limitTime", 0);