风险分析
This commit is contained in:
parent
ecd74ef484
commit
b34658f2f3
@ -3,8 +3,10 @@ package com.zhgd.xmgl.modules.car.controller;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.zhgd.annotation.OperLog;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
@ -101,7 +103,7 @@ public class CarInfoController {
|
||||
@ApiOperation(value = "添加车辆黑白名单管理信息", notes = "添加车辆黑白名单管理信息", httpMethod = "POST")
|
||||
@PostMapping(value = "/save")
|
||||
public Result<CarInfo> save(@RequestBody Map<String, Object> map) {
|
||||
log.info("开始添加车辆" + map);
|
||||
log.info("开始添加车辆" + JSONObject.parseObject(JSON.toJSONString(map)));
|
||||
Object alarmPushWorkerId = map.get("alarmPushWorkerId");
|
||||
String userId = String.valueOf(map.get("enterpriseId"));
|
||||
Object driverWorkerName = map.get("driverWorkerName");
|
||||
|
||||
@ -9,9 +9,13 @@ import com.zhgd.xmgl.modules.exam.entity.ExamTrain;
|
||||
import com.zhgd.xmgl.modules.exam.entity.ExamTrainRecord;
|
||||
import com.zhgd.xmgl.modules.exam.service.IExamTrainRecordService;
|
||||
import com.zhgd.xmgl.modules.exam.service.IExamTrainService;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectEnterpriseService;
|
||||
import com.zhgd.xmgl.modules.worker.entity.EnterpriseInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.TeamInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerType;
|
||||
import com.zhgd.xmgl.modules.worker.service.IEnterpriseInfoService;
|
||||
import com.zhgd.xmgl.modules.worker.service.ITeamInfoService;
|
||||
import com.zhgd.xmgl.modules.worker.service.IWorkerInfoService;
|
||||
import com.zhgd.xmgl.modules.worker.service.IWorkerTypeService;
|
||||
@ -35,10 +39,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@RestController
|
||||
@ -62,6 +63,12 @@ public class XzRiskPredictionController {
|
||||
@Autowired
|
||||
private IExamTrainRecordService examTrainRecordService;
|
||||
|
||||
@Autowired
|
||||
private IProjectEnterpriseService projectEnterpriseService;
|
||||
|
||||
@Autowired
|
||||
private IEnterpriseInfoService enterpriseInfoService;
|
||||
|
||||
@Autowired
|
||||
private IXzSecurityQualityInspectionRecordService xzSecurityQualityInspectionRecordService;
|
||||
|
||||
@ -133,4 +140,193 @@ public class XzRiskPredictionController {
|
||||
return Result.success(resultMap);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询项目下总包的人员风险趋势分析", notes = "查询项目下总包的人员风险趋势分析", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
||||
})
|
||||
@GetMapping(value = "/getWorkerRiskByEnterprise")
|
||||
public Result<List<Map<String, Object>>> getWorkerRiskByEnterprise(@ApiIgnore @RequestParam HashMap<String, Object> param) {
|
||||
String projectSn = MapUtils.getString(param, "projectSn");
|
||||
List<ProjectEnterprise> allList = projectEnterpriseService.list(Wrappers.<ProjectEnterprise>lambdaQuery()
|
||||
.eq(ProjectEnterprise::getProjectSn, projectSn));
|
||||
List<ProjectEnterprise> parentList = allList.stream().filter(a -> a.getParentEnterpriseId().toString().equals("0")).collect(Collectors.toList());
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
|
||||
|
||||
List<XzSecurityQualityInspectionRecord> allXzSecurityQualityInspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.<XzSecurityQualityInspectionRecord>lambdaQuery()
|
||||
.eq(XzSecurityQualityInspectionRecord::getRecordType, 1)
|
||||
.eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn));
|
||||
|
||||
List<WorkerInfo> allWorkerList = workerInfoService.list(Wrappers.<WorkerInfo>lambdaQuery()
|
||||
.eq(WorkerInfo::getProjectSn, projectSn));
|
||||
|
||||
WorkerType workerType = workerTypeService.getOne(Wrappers.<WorkerType>lambdaQuery()
|
||||
.eq(WorkerType::getProjectSn, projectSn)
|
||||
.eq(WorkerType::getTypeName, "特殊工种"));
|
||||
|
||||
List<ExamTrain> examTrainList = examTrainService.list(Wrappers.<ExamTrain>lambdaQuery().eq(ExamTrain::getProjectSn, projectSn)
|
||||
.isNotNull(ExamTrain::getExamPaperId));
|
||||
|
||||
for (ProjectEnterprise projectEnterprise : parentList) {
|
||||
EnterpriseInfo enterpriseInfo = enterpriseInfoService.getById(projectEnterprise.getEnterpriseId());
|
||||
List<Long> enterpriseIds = allList.stream().filter(a -> a.getAncestors().contains(projectEnterprise.getId().toString())).collect(Collectors.toList())
|
||||
.stream().map(p -> p.getEnterpriseId()).collect(Collectors.toList());
|
||||
enterpriseIds.add(projectEnterprise.getEnterpriseId());
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
// 人员数量
|
||||
List<WorkerInfo> list = allWorkerList.stream().filter(a -> enterpriseIds.contains(a.getEnterpriseId())).collect(Collectors.toList());
|
||||
resultMap.put("total", list.size());
|
||||
// 高龄人员
|
||||
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));
|
||||
// 特殊工种人数
|
||||
if (workerType != null) {
|
||||
List<TeamInfo> allTeamInfoList = teamInfoService.list(Wrappers.<TeamInfo>lambdaQuery()
|
||||
.eq(TeamInfo::getWorkerTypeId, workerType.getId()));
|
||||
List<TeamInfo> teamInfoList = allTeamInfoList.stream().filter(a -> enterpriseIds.contains(a.getEnterpriseId())).collect(Collectors.toList());
|
||||
if (teamInfoList.size() > 0) {
|
||||
long workerTypeCount = list.stream().filter(l -> teamInfoList.stream().map(t -> t.getId()).collect(Collectors.toList()).contains(l.getTeamId())).count();
|
||||
resultMap.put("workerType", new BigDecimal(workerTypeCount).divide(new BigDecimal(list.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
resultMap.put("workerType", 0);
|
||||
}
|
||||
} else {
|
||||
resultMap.put("workerType", 0);
|
||||
}
|
||||
List<Long> ids = examTrainList.stream().map(e -> e.getId()).collect(Collectors.toList());
|
||||
if (ids.size() > 0) {
|
||||
List<ExamTrainRecord> examTrainRecordList = examTrainRecordService.list(Wrappers.<ExamTrainRecord>lambdaQuery().in(ExamTrainRecord::getTrainId, ids));
|
||||
for (ExamTrain record : examTrainList) {
|
||||
if (record.getExamPaperId() != null) {
|
||||
List<ExamTrainRecord> trainRecordList = examTrainRecordList.stream().filter(e ->
|
||||
e.getTrainId().toString().equals(record.getId().toString()) && enterpriseIds.contains(e.getEnterpriseId())).collect(Collectors.toList());
|
||||
if (trainRecordList.size() > 0) {
|
||||
int pass = trainRecordList.stream().filter(t -> t.getIsPass() == 1).collect(Collectors.toList()).size();
|
||||
record.setPassRadio(new BigDecimal(pass).divide(new BigDecimal(trainRecordList.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
record.setPassRadio(new BigDecimal(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
// 教育培训
|
||||
BigDecimal passRadio = examTrainList.stream().map(e -> e.getPassRadio()).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
resultMap.put("exam", new BigDecimal(1).subtract(passRadio.divide(new BigDecimal(examTrainList.size()), 2, BigDecimal.ROUND_HALF_UP)));
|
||||
} else {
|
||||
resultMap.put("exam", 0);
|
||||
}
|
||||
// 安全评分
|
||||
Double safeScore = list.stream().mapToDouble(e -> e.getSafeScore()).sum();
|
||||
resultMap.put("safe", new BigDecimal(1).subtract(new BigDecimal(safeScore).divide(new BigDecimal(100)).divide(new BigDecimal(list.size()), 2, BigDecimal.ROUND_HALF_UP)));
|
||||
// 安全检查隐患
|
||||
List<XzSecurityQualityInspectionRecord> 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();
|
||||
resultMap.put("security", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
resultMap.put("security", 0);
|
||||
}
|
||||
resultMap.put("enterpriseName", enterpriseInfo.getEnterpriseName());
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
return Result.success(resultList);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询总项目的安全隐患风险趋势分析", notes = "查询总项目的安全隐患风险趋势分析", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
||||
})
|
||||
@GetMapping(value = "/getSafetyRiskByProject")
|
||||
public Result<Map<String, Object>> getSafetyRiskByProject(@ApiIgnore @RequestParam HashMap<String, Object> param) {
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
String projectSn = MapUtils.getString(param, "projectSn");
|
||||
// 安全检查隐患
|
||||
List<XzSecurityQualityInspectionRecord> xzSecurityQualityInspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.<XzSecurityQualityInspectionRecord>lambdaQuery()
|
||||
.eq(XzSecurityQualityInspectionRecord::getRecordType, 1)
|
||||
.eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn));
|
||||
if (xzSecurityQualityInspectionRecords.size() > 0) {
|
||||
long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getStatus() != 5 && x.getStatus() != 6).count();
|
||||
resultMap.put("security", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
resultMap.put("security", 0);
|
||||
}
|
||||
// 安全评分
|
||||
List<WorkerInfo> list = workerInfoService.list(Wrappers.<WorkerInfo>lambdaQuery().eq(WorkerInfo::getProjectSn, projectSn));
|
||||
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));
|
||||
// 一级二级分险占比
|
||||
if (xzSecurityQualityInspectionRecords.size() > 0) {
|
||||
long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getLevel() == 1 || x.getLevel() == 2).count();
|
||||
resultMap.put("levelRisk", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
resultMap.put("levelRisk", 0);
|
||||
}
|
||||
// 超期未关闭
|
||||
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();
|
||||
resultMap.put("limitTime", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
resultMap.put("limitTime", 0);
|
||||
}
|
||||
return Result.success(resultMap);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询下项目总包的安全隐患风险趋势分析", notes = "查询下项目总包的安全隐患风险趋势分析", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
||||
})
|
||||
@GetMapping(value = "/getSafetyRiskByEnterprise")
|
||||
public Result<List<Map<String, Object>>> getSafetyRiskByEnterprise(@ApiIgnore @RequestParam HashMap<String, Object> param) {
|
||||
String projectSn = MapUtils.getString(param, "projectSn");
|
||||
List<ProjectEnterprise> allList = projectEnterpriseService.list(Wrappers.<ProjectEnterprise>lambdaQuery()
|
||||
.eq(ProjectEnterprise::getProjectSn, projectSn));
|
||||
List<ProjectEnterprise> parentList = allList.stream().filter(a -> a.getParentEnterpriseId().toString().equals("0")).collect(Collectors.toList());
|
||||
List<Map<String, Object>> resultList = new ArrayList<>();
|
||||
|
||||
List<XzSecurityQualityInspectionRecord> allXzSecurityQualityInspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.<XzSecurityQualityInspectionRecord>lambdaQuery()
|
||||
.eq(XzSecurityQualityInspectionRecord::getRecordType, 1)
|
||||
.eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn));
|
||||
|
||||
List<WorkerInfo> allWorkerList = workerInfoService.list(Wrappers.<WorkerInfo>lambdaQuery()
|
||||
.eq(WorkerInfo::getProjectSn, projectSn));
|
||||
|
||||
for (ProjectEnterprise projectEnterprise : parentList) {
|
||||
EnterpriseInfo enterpriseInfo = enterpriseInfoService.getById(projectEnterprise.getEnterpriseId());
|
||||
List<Long> enterpriseIds = allList.stream().filter(a -> a.getAncestors().contains(projectEnterprise.getId().toString())).collect(Collectors.toList())
|
||||
.stream().map(p -> p.getEnterpriseId()).collect(Collectors.toList());
|
||||
enterpriseIds.add(projectEnterprise.getEnterpriseId());
|
||||
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
// 安全检查隐患
|
||||
List<XzSecurityQualityInspectionRecord> 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();
|
||||
resultMap.put("security", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
resultMap.put("security", 0);
|
||||
}
|
||||
// 安全评分
|
||||
List<WorkerInfo> list = allWorkerList.stream().filter(a -> enterpriseIds.contains(a.getEnterpriseId())).collect(Collectors.toList());
|
||||
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));
|
||||
// 一级二级分险占比
|
||||
if (xzSecurityQualityInspectionRecords.size() > 0) {
|
||||
long inspectionCount = xzSecurityQualityInspectionRecords.stream().filter(x -> x.getLevel() == 1 || x.getLevel() == 2).count();
|
||||
resultMap.put("levelRisk", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
resultMap.put("levelRisk", 0);
|
||||
}
|
||||
// 超期未关闭
|
||||
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();
|
||||
resultMap.put("limitTime", new BigDecimal(inspectionCount).divide(new BigDecimal(xzSecurityQualityInspectionRecords.size()), 2, BigDecimal.ROUND_HALF_UP));
|
||||
} else {
|
||||
resultMap.put("limitTime", 0);
|
||||
}
|
||||
resultMap.put("enterpriseName", enterpriseInfo.getEnterpriseName());
|
||||
resultList.add(resultMap);
|
||||
}
|
||||
return Result.success(resultList);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user