风险预测
This commit is contained in:
parent
49f352f94e
commit
93c2e9b974
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.video.mapper;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareRecord;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
@ -22,4 +23,6 @@ public interface AiAnalyseHardWareRecordMapper extends BaseMapper<AiAnalyseHardW
|
||||
List<String> getUserIdsByAiAnalyseHardId(String aiAnalyseHardId);
|
||||
|
||||
List<String> getUserIdsByQualityRegionId(String qualityRegionId);
|
||||
|
||||
List<JSONObject> getEnterpriseIdAndAiAnalyseHardIdsByProjectSn(String projectSn);
|
||||
}
|
||||
|
||||
@ -29,4 +29,17 @@
|
||||
from quality_region_to_user
|
||||
where quality_region_id = #{qualityRegionId}
|
||||
</select>
|
||||
|
||||
<select id="getEnterpriseIdAndAiAnalyseHardIdsByProjectSn" resultType="com.alibaba.fastjson.JSONObject">
|
||||
select
|
||||
distinct
|
||||
qrtaah.ai_analyse_hard_ware_record_id,
|
||||
qrte.enterprise_id,
|
||||
aahwr.hardware_id
|
||||
from
|
||||
quality_region_to_ai_analyse_hard qrtaah
|
||||
join quality_region_to_enterprise qrte on qrte.quality_region_id = qrtaah.quality_region_id
|
||||
join ai_analyse_hard_ware_record aahwr on aahwr.id = qrtaah.ai_analyse_hard_ware_record_id
|
||||
where aahwr.project_sn = #{projectSn}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package com.zhgd.xmgl.modules.video.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareRecord;
|
||||
|
||||
@ -42,4 +43,6 @@ public interface IAiAnalyseHardWareRecordService extends IService<AiAnalyseHardW
|
||||
* @return
|
||||
*/
|
||||
List<String> getAiAnalyseHardIdsByEnterpriseId(Long enterpriseId);
|
||||
|
||||
List<JSONObject> getEnterpriseIdAndAiAnalyseHardIdsByProjectSn(String projectSn);
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package com.zhgd.xmgl.modules.video.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
@ -105,4 +106,9 @@ public class AiAnalyseHardWareRecordServiceImpl extends ServiceImpl<AiAnalyseHar
|
||||
return baseMapper.getAiAnalyseHardIdsByEnterpriseId(enterpriseId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> getEnterpriseIdAndAiAnalyseHardIdsByProjectSn(String projectSn) {
|
||||
return baseMapper.getEnterpriseIdAndAiAnalyseHardIdsByProjectSn(projectSn);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -241,5 +241,9 @@ public class EnterpriseInfo implements Serializable {
|
||||
@TableField(exist = false)
|
||||
@ApiModelProperty(value = "项目劳务公司关联")
|
||||
private ProjectEnterprise projectEnterprise;
|
||||
@TableField(exist = false)
|
||||
private String ancestors;
|
||||
@TableField(exist = false)
|
||||
private java.lang.Long parentProjectEnterpriseId;
|
||||
|
||||
}
|
||||
|
||||
@ -19,7 +19,10 @@
|
||||
b.project_director_phone,
|
||||
b.parent_enterprise_id,
|
||||
b.enterprise_id,
|
||||
b.department_type
|
||||
b.department_type,
|
||||
b.ancestors,
|
||||
b.parent_project_enterprise_id,
|
||||
b.id as project_enterprise_id
|
||||
from enterprise_info a
|
||||
INNER JOIN project_enterprise b ON a.id = b.enterprise_id
|
||||
LEFT JOIN enterprise_type c ON b.enterprise_type_id = c.id
|
||||
|
||||
@ -896,7 +896,8 @@
|
||||
JOIN project_enterprise pe on pe.enterprise_id=t.enterprise_id and pe.project_sn=t.project_sn
|
||||
JOIN enterprise_info mei ON mei.id =
|
||||
IF( pe.parent_enterprise_id = 0,ei.id, (SELECT enterprise_id from project_enterprise WHERE id = substring_index(
|
||||
substring_index( pe.ancestors, ',', 2 ), ',', - 1 ))) LEFT JOIN worker_attendance_presence p ON t.person_sn =
|
||||
substring_index( pe.ancestors, ',', 2 ), ',', - 1 )))
|
||||
LEFT JOIN worker_attendance_presence p ON t.person_sn =
|
||||
p.person_sn
|
||||
LEFT JOIN worker_attendance a ON t.person_sn = a.person_sn and a.create_time >= CURRENT_DATE
|
||||
LEFT JOIN worker_attendance a1 ON t.person_sn = a1.person_sn
|
||||
|
||||
@ -8,6 +8,7 @@ import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
||||
import com.zhgd.xmgl.modules.worker.entity.dto.GetWorkerInfoByDevDto;
|
||||
import com.zhgd.xmgl.modules.worker.entity.vo.*;
|
||||
import com.zhgd.xmgl.modules.xz.entity.vo.RiskTrendByMainEnterpriseVo;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@ -169,4 +170,5 @@ public interface IWorkerInfoService extends IService<WorkerInfo> {
|
||||
void deleteBatch(String ids);
|
||||
|
||||
double getAvgSafeScore(String enterpriseId, String projectSn);
|
||||
|
||||
}
|
||||
|
||||
@ -45,6 +45,7 @@ import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
@ -69,36 +70,52 @@ import static com.zhgd.xmgl.config.FaceRunner.faceEngine;
|
||||
@Slf4j
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public class WorkerAttendanceServiceImpl extends ServiceImpl<WorkerAttendanceMapper, WorkerAttendance> implements IWorkerAttendanceService {
|
||||
@Lazy
|
||||
@Autowired
|
||||
WorkerAttendanceServiceImpl workerAttendanceService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private UploadFileService uploadFileService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IWorkerInfoService workerInfoService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerAttendancePresenceServiceImpl workerAttendancePresenceService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerAttendanceMapper workerAttendanceMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerInfoMapper workerInfoMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerAttendanceRuleMapper workerAttendanceRuleMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private UfaceDevMapper ufaceDevMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IWorkerMonthAttendanceStatisticsService workerMonthAttendanceStatisticsService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ProjectUfaceConfigMapper projectUfaceConfigMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private WorkerStrangerAttendanceMapper workerStrangerAttendanceMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private AsyncSendAttendance asyncSendAttendance;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private VisitorManageRecordMapper visitorManageRecordMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private GovtOpenApiService govtOpenApiService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private EnvironmentUtil environmentUtil;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ICompanyService companyService;
|
||||
@Value("${serverUrl}")
|
||||
|
||||
@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.gexin.fastjson.JSONArray;
|
||||
import com.zhgd.exception.CustomException;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.execption.OpenAlertException;
|
||||
@ -31,8 +32,10 @@ import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
|
||||
import com.zhgd.xmgl.call.HikvisionCall;
|
||||
import com.zhgd.xmgl.constant.Cts;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.Company;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemAreas;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.CompanyMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.SystemAreasMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.ICompanyService;
|
||||
import com.zhgd.xmgl.modules.basicdata.service.IDictionaryItemService;
|
||||
@ -46,8 +49,10 @@ import com.zhgd.xmgl.modules.inspection.mapper.InspectTaskRecordMapper;
|
||||
import com.zhgd.xmgl.modules.project.entity.Project;
|
||||
import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise;
|
||||
import com.zhgd.xmgl.modules.project.entity.bo.ProjectStatisticsCountBo;
|
||||
import com.zhgd.xmgl.modules.project.entity.vo.ProjectInfoExtVo;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectEnterpriseMapper;
|
||||
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectService;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectUfaceConfigService;
|
||||
import com.zhgd.xmgl.modules.video.mapper.AiAnalyseHardWareAlarmRecordMapper;
|
||||
import com.zhgd.xmgl.modules.worker.entity.*;
|
||||
@ -57,8 +62,12 @@ import com.zhgd.xmgl.modules.worker.enums.EduTypeEnum;
|
||||
import com.zhgd.xmgl.modules.worker.mapper.*;
|
||||
import com.zhgd.xmgl.modules.worker.service.*;
|
||||
import com.zhgd.xmgl.modules.xz.entity.XzHikvisionSync;
|
||||
import com.zhgd.xmgl.modules.xz.entity.vo.RiskTrendByMainEnterpriseVo;
|
||||
import com.zhgd.xmgl.modules.xz.mapper.XzHikvisionSyncMapper;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityQualityInspectionRecord;
|
||||
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityQualityInspectionRecordService;
|
||||
import com.zhgd.xmgl.modules.xz.service.impl.XzSupplierQualificationApplyServiceImpl;
|
||||
import com.zhgd.xmgl.modules.xz.special.service.IXzBlindPlatePlugSafeService;
|
||||
import com.zhgd.xmgl.security.entity.UserInfo;
|
||||
import com.zhgd.xmgl.security.util.SecurityUtils;
|
||||
import com.zhgd.xmgl.util.*;
|
||||
@ -76,6 +85,7 @@ import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@ -2127,24 +2137,6 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
return rtList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SpecialWorkerStaticsVo getSpecialWorkerStatics(HashMap<String, Object> map) {
|
||||
SpecialWorkerStaticsVo vo = workerInfoMapper.getSpecialWorkerStatics(map);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkerAgeVo statisticsWorkerAge(Map<String, Object> map) {
|
||||
map = companyService.getCompanyType(map);
|
||||
WorkerManageStatisticsVo.WorkerCount workerCount = workerInfoMapper.getProjectWorkerStatistics(map);
|
||||
//查询在场的人员按照人员类型、年龄、岗位等统计人员数
|
||||
WorkerManageStatisticsVo.PresenceCount presencecount = workerInfoMapper.getWorkerPresenceStatistics(map);
|
||||
WorkerAgeVo vo = new WorkerAgeVo();
|
||||
vo.setWorkercount(workerCount);
|
||||
vo.setPresencecount(presencecount);
|
||||
return vo;
|
||||
}
|
||||
|
||||
///*
|
||||
//全量和增量更新
|
||||
// */
|
||||
@ -2194,6 +2186,24 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
|
||||
// return JSON.toJSONString(getWorkerInfoByDevVo);
|
||||
//}
|
||||
|
||||
@Override
|
||||
public SpecialWorkerStaticsVo getSpecialWorkerStatics(HashMap<String, Object> map) {
|
||||
SpecialWorkerStaticsVo vo = workerInfoMapper.getSpecialWorkerStatics(map);
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WorkerAgeVo statisticsWorkerAge(Map<String, Object> map) {
|
||||
map = companyService.getCompanyType(map);
|
||||
WorkerManageStatisticsVo.WorkerCount workerCount = workerInfoMapper.getProjectWorkerStatistics(map);
|
||||
//查询在场的人员按照人员类型、年龄、岗位等统计人员数
|
||||
WorkerManageStatisticsVo.PresenceCount presencecount = workerInfoMapper.getWorkerPresenceStatistics(map);
|
||||
WorkerAgeVo vo = new WorkerAgeVo();
|
||||
vo.setWorkercount(workerCount);
|
||||
vo.setPresencecount(presencecount);
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 只需要实现全量更新,设备这边是全量更新的,人员删除后直接从白名单中删除就行,现在不是通过del这个标志判断的,这个标志应该是后面加的,设备最早不是按这个标志判断的,
|
||||
* 比如之前有3个人,后面xxx人员退场了,白名单就返回剩下的两个人就行,因为默认都是全量的,增量更新需要专门开启,实现了全量就可以了
|
||||
|
||||
@ -241,6 +241,9 @@ public class XzSecurityQualityInspectionRecord implements Serializable {
|
||||
private Long enterpriseId;
|
||||
@ApiModelProperty(value = "危大工程记录ID")
|
||||
private Long engineeringId;
|
||||
/**
|
||||
* 1危大2动火3受限空间4盲板抽堵5高出6吊装7临时用电8动土9断路
|
||||
*/
|
||||
@ApiModelProperty(value = "1危大2动火3受限空间4盲板抽堵5高出6吊装7临时用电8动土9断路")
|
||||
private Integer type;
|
||||
|
||||
|
||||
@ -6,6 +6,7 @@ import com.zhgd.annotation.DataScope;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.base.entity.vo.SectorOneVo;
|
||||
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
|
||||
import com.zhgd.xmgl.modules.xz.entity.vo.RiskTrendByMainEnterpriseVo;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityQualityInspectionRecord;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.dto.XzSecurityDepartmentRectifiedRankDto;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.vo.*;
|
||||
|
||||
@ -6,6 +6,7 @@ import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
||||
import com.zhgd.xmgl.base.entity.vo.SectorVo;
|
||||
import com.zhgd.xmgl.base.entity.vo.TrendOneVo;
|
||||
import com.zhgd.xmgl.modules.xz.entity.vo.RiskTrendByMainEnterpriseVo;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityQualityInspectionRecord;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.dto.XzSecurityDepartmentRectifiedRankDto;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.vo.*;
|
||||
|
||||
@ -1,40 +1,64 @@
|
||||
package com.zhgd.xmgl.modules.xz.controller;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.wflow.workflow.bean.vo.ProcessInstanceVo;
|
||||
import com.gexin.fastjson.JSON;
|
||||
import com.gexin.fastjson.JSONArray;
|
||||
import com.zhgd.jeecg.common.api.vo.Result;
|
||||
import com.zhgd.xmgl.modules.basicdata.entity.SystemAreas;
|
||||
import com.zhgd.xmgl.modules.basicdata.mapper.SystemAreasMapper;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.DangerousEngineeringRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.DangerousEngineeringSideStation;
|
||||
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IDangerousEngineeringSideStationService;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
|
||||
import com.zhgd.xmgl.modules.dangerous.service.impl.DangerousEngineeringRecordServiceImpl;
|
||||
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.entity.vo.ProjectInfoExtVo;
|
||||
import com.zhgd.xmgl.modules.project.service.IProjectEnterpriseService;
|
||||
import com.zhgd.xmgl.modules.project.service.impl.ProjectServiceImpl;
|
||||
import com.zhgd.xmgl.modules.video.entity.AiAnalyseHardWareAlarmRecord;
|
||||
import com.zhgd.xmgl.modules.video.service.IAiAnalyseHardWareAlarmRecordService;
|
||||
import com.zhgd.xmgl.modules.video.service.IAiAnalyseHardWareRecordService;
|
||||
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;
|
||||
import com.zhgd.xmgl.modules.worker.service.impl.EnterpriseInfoServiceImpl;
|
||||
import com.zhgd.xmgl.modules.xz.entity.vo.RiskTrendByMainEnterpriseVo;
|
||||
import com.zhgd.xmgl.modules.xz.entity.vo.SpecialTrendVo;
|
||||
import com.zhgd.xmgl.modules.xz.security.controller.XzSecurityQualityInspectionRecordController;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityInspectTaskItemRecord;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityInspectTaskRecord;
|
||||
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityQualityInspectionRecord;
|
||||
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityInspectTaskItemRecordService;
|
||||
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityInspectTaskRecordService;
|
||||
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityQualityInspectionRecordService;
|
||||
import com.zhgd.xmgl.util.AqiUtil;
|
||||
import com.zhgd.xmgl.util.MapBuilder;
|
||||
import com.zhgd.xmgl.util.NumberUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
@ -47,30 +71,60 @@ import java.util.stream.Collectors;
|
||||
@Slf4j
|
||||
@Api(tags = "星纵-风险预测")
|
||||
public class XzRiskPredictionController {
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
ProjectServiceImpl projectService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
EnterpriseInfoServiceImpl enterpriseInfoService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
DangerousEngineeringRecordServiceImpl dangerousEngineeringRecordService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
IAiAnalyseHardWareAlarmRecordService aiAnalyseHardWareAlarmRecordService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
XzSecurityQualityInspectionRecordController securityQualityInspectionRecordController;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IWorkerInfoService workerInfoService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IWorkerTypeService workerTypeService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ITeamInfoService teamInfoService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IExamTrainService examTrainService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IExamTrainRecordService examTrainRecordService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IProjectEnterpriseService projectEnterpriseService;
|
||||
|
||||
@Autowired
|
||||
private IEnterpriseInfoService enterpriseInfoService;
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IXzSecurityQualityInspectionRecordService xzSecurityQualityInspectionRecordService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private SystemAreasMapper systemAreasMapper;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IXzSecurityInspectTaskRecordService xzSecurityInspectTaskRecordService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IAiAnalyseHardWareRecordService aiAnalyseHardWareRecordService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IHiddenDangerInspectRecordService hiddenDangerInspectRecordService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IDangerousEngineeringSideStationService dangerousEngineeringSideStationService;
|
||||
@Lazy
|
||||
@Autowired
|
||||
private IXzSecurityInspectTaskItemRecordService xzSecurityInspectTaskItemRecordService;
|
||||
|
||||
@ApiOperation(value = "查询总项目的人员风险趋势分析", notes = "查询总项目的人员风险趋势分析", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ -155,6 +209,390 @@ public class XzRiskPredictionController {
|
||||
return Result.success(resultMap);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "总包(含下面分包)事故风险预测趋势by总包", notes = "总包(含下面分包)事故风险预测趋势by总包", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
|
||||
})
|
||||
@PostMapping(value = "/riskTrendByMainEnterprise")
|
||||
public Result<List<RiskTrendByMainEnterpriseVo>> riskTrendByMainEnterprise(@ApiIgnore @RequestBody Map<String, Object> param) {
|
||||
List<RiskTrendByMainEnterpriseVo> rtList = new ArrayList<>();
|
||||
String projectSn = MapUtils.getString(param, "projectSn");
|
||||
ProjectInfoExtVo project = projectService.getProjectInfoBySn(projectSn);
|
||||
List<EnterpriseInfo> enterpriseInfos = BeanUtil.copyToList(enterpriseInfoService.getEnterpriseInfoList(new MapBuilder<String, Object>()
|
||||
.put("projectSn", projectSn)
|
||||
.build()), EnterpriseInfo.class);
|
||||
List<EnterpriseInfo> mainEnterprises = enterpriseInfos.stream().filter(enterpriseInfo -> Objects.equals(enterpriseInfo.getParentEnterpriseId(), 0L)).collect(Collectors.toList());
|
||||
List<XzSecurityQualityInspectionRecord> inspectionRecords = xzSecurityQualityInspectionRecordService.list(new LambdaQueryWrapper<XzSecurityQualityInspectionRecord>()
|
||||
.ne(XzSecurityQualityInspectionRecord::getStatus, 6)
|
||||
.in(XzSecurityQualityInspectionRecord::getProjectSn, projectSn)
|
||||
);
|
||||
Double severeWeatherRate = this.getSevereWeatherRate(project);
|
||||
Date date = new Date();
|
||||
List<XzSecurityQualityInspectionRecord> safeInspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.<XzSecurityQualityInspectionRecord>lambdaQuery()
|
||||
.eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn)
|
||||
.eq(XzSecurityQualityInspectionRecord::getRecordType, 1)
|
||||
.between(XzSecurityQualityInspectionRecord::getCreateTime, DateUtil.beginOfMonth(date), DateUtil.endOfMonth(date)));
|
||||
List<XzSecurityInspectTaskRecord> taskRecords = xzSecurityInspectTaskRecordService.list(Wrappers.<XzSecurityInspectTaskRecord>lambdaQuery()
|
||||
.eq(XzSecurityInspectTaskRecord::getSn, projectSn)
|
||||
.between(XzSecurityInspectTaskRecord::getCreateTime, DateUtil.beginOfMonth(date), DateUtil.endOfMonth(date)));
|
||||
List<DangerousEngineeringRecord> dangerousEngineeringRecords = dangerousEngineeringRecordService.list(Wrappers.<DangerousEngineeringRecord>lambdaQuery()
|
||||
.eq(DangerousEngineeringRecord::getProjectSn, projectSn)
|
||||
.between(DangerousEngineeringRecord::getCreateTime, DateUtil.beginOfMonth(date), DateUtil.endOfMonth(date)));
|
||||
List<HiddenDangerInspectRecord> hiddenDangerInspectRecords = hiddenDangerInspectRecordService.list(Wrappers.<HiddenDangerInspectRecord>lambdaQuery()
|
||||
.eq(HiddenDangerInspectRecord::getProjectSn, projectSn)
|
||||
.between(HiddenDangerInspectRecord::getCreateTime, DateUtil.beginOfMonth(date), DateUtil.endOfMonth(date)));
|
||||
List<DangerousEngineeringSideStation> dangerousEngineeringSideStations = dangerousEngineeringSideStationService.list(Wrappers.<DangerousEngineeringSideStation>lambdaQuery()
|
||||
.eq(DangerousEngineeringSideStation::getType, 1)
|
||||
.between(DangerousEngineeringSideStation::getCreateTime, DateUtil.beginOfMonth(date), DateUtil.endOfMonth(date)));
|
||||
List<XzSecurityQualityInspectionRecord> safeInspections = xzSecurityQualityInspectionRecordService.list(Wrappers.<XzSecurityQualityInspectionRecord>lambdaQuery()
|
||||
.eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn)
|
||||
.between(XzSecurityQualityInspectionRecord::getCreateTime, DateUtil.beginOfMonth(date), DateUtil.endOfMonth(date)));
|
||||
List<AiAnalyseHardWareAlarmRecord> aiAnalyseHardWareAlarmRecords = aiAnalyseHardWareAlarmRecordService.list(Wrappers.<AiAnalyseHardWareAlarmRecord>lambdaQuery()
|
||||
.eq(AiAnalyseHardWareAlarmRecord::getProjectSn, projectSn)
|
||||
.between(AiAnalyseHardWareAlarmRecord::getCreateTime, DateUtil.beginOfMonth(date), DateUtil.endOfMonth(date)));
|
||||
List<JSONObject> enterpriseIdAndAiAnalyseHardIds = aiAnalyseHardWareRecordService.getEnterpriseIdAndAiAnalyseHardIdsByProjectSn(projectSn);
|
||||
Date time = DateUtil.offsetMonth(date, -1);
|
||||
List<AiAnalyseHardWareAlarmRecord> aiAnalyseHardWareAlarmRecordLastMonths = aiAnalyseHardWareAlarmRecordService.list(Wrappers.<AiAnalyseHardWareAlarmRecord>lambdaQuery()
|
||||
.eq(AiAnalyseHardWareAlarmRecord::getProjectSn, projectSn)
|
||||
.between(AiAnalyseHardWareAlarmRecord::getCreateTime, DateUtil.beginOfMonth(time), DateUtil.endOfMonth(time)));
|
||||
for (EnterpriseInfo mainEnterprise : mainEnterprises) {
|
||||
List<Long> enterpriseIds = enterpriseInfos.stream().filter(enterpriseInfo -> enterpriseInfo.getAncestors().contains(mainEnterprise.getParentProjectEnterpriseId() + "")).map(EnterpriseInfo::getId).collect(Collectors.toList());
|
||||
enterpriseIds.add(mainEnterprise.getId());
|
||||
List<String> hardwareIds = enterpriseIdAndAiAnalyseHardIds.stream().filter(j -> enterpriseIds.contains(j.getLong("enterpriseId"))).map(j -> j.getString("hardwareId")).collect(Collectors.toList());
|
||||
|
||||
RiskTrendByMainEnterpriseVo oneVo = new RiskTrendByMainEnterpriseVo();
|
||||
oneVo.setSevereWeatherRate(severeWeatherRate);
|
||||
|
||||
long specialNotCount = inspectionRecords.stream().filter(r -> enterpriseIds.contains(r.getEnterpriseId()) && r.getStatus() != 6 && r.getStatus() != 5 && r.getType() != null).count();
|
||||
long specialCount = inspectionRecords.stream().filter(r -> enterpriseIds.contains(r.getEnterpriseId()) && r.getStatus() != 6 && r.getType() != null).count();
|
||||
oneVo.setTotalSpecialOperationsRiskRate(NumberUtils.occupyRate(specialNotCount, specialCount, 2));
|
||||
|
||||
BigDecimal hiddenDangerScore = this.getHiddenDangerScore(projectSn, date, safeInspectionRecords, enterpriseIds, taskRecords);
|
||||
BigDecimal dangerEngScore = this.getScore(projectSn, date, dangerousEngineeringRecords, enterpriseIds, hiddenDangerInspectRecords, dangerousEngineeringSideStations);
|
||||
BigDecimal riskScore = this.getRiskScore(projectSn, date, enterpriseIds, safeInspections);
|
||||
BigDecimal aiScore = this.getAiScore(projectSn, date, aiAnalyseHardWareAlarmRecords, enterpriseIds, hardwareIds, aiAnalyseHardWareAlarmRecordLastMonths);
|
||||
BigDecimal total = hiddenDangerScore.add(dangerEngScore).add(riskScore).add(aiScore).add(new BigDecimal(30)).setScale(0, RoundingMode.HALF_UP);
|
||||
oneVo.setMonthlySafetyScoreRate(total.doubleValue());
|
||||
|
||||
oneVo.setTotalPersonnelRiskRate(0.0D);
|
||||
|
||||
long inspectionCount = inspectionRecords.stream().filter(r -> enterpriseIds.contains(r.getEnterpriseId()) && r.getStatus() != 6).count();
|
||||
long inspectionNotCount = inspectionRecords.stream().filter(r -> enterpriseIds.contains(r.getEnterpriseId()) && r.getStatus() != 6 && r.getStatus() != 5).count();
|
||||
oneVo.setUnclosedHiddenDangersRate(NumberUtils.occupyRate(inspectionNotCount, inspectionCount, 2));
|
||||
oneVo.setEnterpriseId(mainEnterprise.getId());
|
||||
oneVo.setEnterpriseName(mainEnterprise.getEnterpriseName());
|
||||
rtList.add(oneVo);
|
||||
}
|
||||
return Result.success(rtList);
|
||||
}
|
||||
|
||||
private BigDecimal getAiScore(String projectSn, Date date, List<AiAnalyseHardWareAlarmRecord> aiAnalyseHardWareAlarmRecords, List<Long> enterpriseIds, List<String> hardwareIds, List<AiAnalyseHardWareAlarmRecord> aiAnalyseHardWareAlarmRecordLastMonths) {
|
||||
long num1 = aiAnalyseHardWareAlarmRecords.stream().filter(e -> hardwareIds.contains(e.getHardwareId())).count();
|
||||
if (num1 != 0) {
|
||||
Date time = DateUtil.offsetMonth(date, -1);
|
||||
long num2 = aiAnalyseHardWareAlarmRecordLastMonths.stream().filter(e -> hardwareIds.contains(e.getHardwareId())).count();
|
||||
if (num2 == 0) {
|
||||
return new BigDecimal(0);
|
||||
}
|
||||
BigDecimal bigDecimal = new BigDecimal(num1);
|
||||
BigDecimal bigDecimal1 = new BigDecimal(num2);
|
||||
BigDecimal bigDecimal2 = new BigDecimal(1);
|
||||
BigDecimal bigDecimal3 = new BigDecimal(100);
|
||||
BigDecimal subtract = bigDecimal.subtract(bigDecimal1);
|
||||
subtract = subtract.divide(bigDecimal1, 2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal subtract1 = bigDecimal2.subtract(subtract);
|
||||
subtract1 = subtract1.multiply(bigDecimal3);
|
||||
if (subtract1.compareTo(new BigDecimal(0)) < 0) {
|
||||
return new BigDecimal(0);
|
||||
}
|
||||
if (subtract1.compareTo(new BigDecimal(20)) > 0) {
|
||||
return new BigDecimal(20);
|
||||
}
|
||||
return subtract1.multiply(new BigDecimal(20)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
return new BigDecimal(20);
|
||||
|
||||
}
|
||||
|
||||
private BigDecimal getRiskScore(String projectSn, Date date, List<Long> enterpriseIds, List<XzSecurityQualityInspectionRecord> safeInspections) {
|
||||
List<XzSecurityQualityInspectionRecord> list = safeInspections.stream().filter(r -> enterpriseIds.contains(r.getEnterpriseId())).collect(Collectors.toList());
|
||||
if (list.size() > 0) {
|
||||
int num1 = list.stream().filter(l -> l.getRecordType() == 1).map(x -> x.getDangerItemContent()).collect(Collectors.toSet()).size();
|
||||
int num2 = list.stream().filter(l -> l.getRecordType() == 2).map(x -> x.getDangerItemContent()).collect(Collectors.toSet()).size();
|
||||
BigDecimal bigDecimal = new BigDecimal(num1);
|
||||
BigDecimal bigDecimal1 = new BigDecimal(num2);
|
||||
BigDecimal result1 = new BigDecimal(0);
|
||||
if (num2 != 0) {
|
||||
result1 = bigDecimal1.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP);
|
||||
if (result1.compareTo(new BigDecimal(1)) > 0) {
|
||||
result1 = new BigDecimal(1);
|
||||
}
|
||||
result1 = result1.multiply(new BigDecimal(0.99)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
Set<String> stringSet = list.stream().map(x -> x.getDangerItemContent()).collect(Collectors.toSet());
|
||||
BigDecimal result2 = new BigDecimal(0);
|
||||
if (stringSet.size() >= 3) {
|
||||
result2 = new BigDecimal(0.01);
|
||||
}
|
||||
BigDecimal total = result1.add(result2);
|
||||
return total.multiply(new BigDecimal(0)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
return new BigDecimal(0);
|
||||
}
|
||||
|
||||
private BigDecimal getScore(String projectSn, Date date, List<DangerousEngineeringRecord> dangerousEngineeringRecords, List<Long> enterpriseIds, List<HiddenDangerInspectRecord> hiddenDangerInspectRecords, List<DangerousEngineeringSideStation> dangerousEngineeringSideStations) {
|
||||
List<DangerousEngineeringRecord> list = dangerousEngineeringRecords.stream().filter(dangerousEngineeringRecord -> enterpriseIds.contains(dangerousEngineeringRecord.getResponsibilityCompanyId())).collect(Collectors.toList());
|
||||
if (list.size() > 0) {
|
||||
List<DangerousEngineeringRecord> list1 = list.stream().filter(l -> DateUtil.compare(DateUtil.parseDate(l.getPlanEndTime()), date, "yyyy-MM-dd") >= 0
|
||||
&& DateUtil.compare(date, DateUtil.parseDate(l.getPlanStartTime()), "yyyy-MM-dd") <= 0).collect(Collectors.toList());
|
||||
int totalDay = 0;
|
||||
for (DangerousEngineeringRecord dangerousEngineeringRecord : list1) {
|
||||
Date planEndTime = DateUtil.parseDate(dangerousEngineeringRecord.getPlanEndTime());
|
||||
if (planEndTime.compareTo(DateUtil.endOfMonth(date)) > 0) {
|
||||
planEndTime = DateUtil.endOfMonth(date);
|
||||
}
|
||||
Long betweenDay = DateUtil.betweenDay(DateUtil.parseDate(dangerousEngineeringRecord.getPlanStartTime()), planEndTime, false);
|
||||
totalDay = totalDay + Integer.parseInt(betweenDay.toString());
|
||||
}
|
||||
List<HiddenDangerInspectRecord> list2 = hiddenDangerInspectRecords.stream().filter(h -> enterpriseIds.contains(Convert.toLong(h.getEnterpriseId()))).collect(Collectors.toList());
|
||||
Set<String> insList = new HashSet<>();
|
||||
for (HiddenDangerInspectRecord hiddenDangerInspectRecord : list2) {
|
||||
insList.add(hiddenDangerInspectRecord.getEngineeringId() + "-" + DateUtil.format(DateUtil.parseDateTime(hiddenDangerInspectRecord.getInspectTime()), "yyyy-MM-dd"));
|
||||
}
|
||||
BigDecimal bigDecimal = new BigDecimal(insList.size());
|
||||
BigDecimal bigDecimal1 = new BigDecimal(totalDay);
|
||||
BigDecimal result1 = new BigDecimal(0);
|
||||
if (totalDay != 0) {
|
||||
result1 = bigDecimal.divide(bigDecimal1, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(0.6));
|
||||
}
|
||||
List<Long> deis = list.stream().map(l -> l.getId()).collect(Collectors.toList());
|
||||
List<DangerousEngineeringSideStation> list3 = dangerousEngineeringSideStations.stream().filter(d -> deis.contains(d.getDangerousEngineeringId())).collect(Collectors.toList());
|
||||
Set<String> sideList = new HashSet<>();
|
||||
for (DangerousEngineeringSideStation dangerousEngineeringSideStation : list3) {
|
||||
sideList.add(dangerousEngineeringSideStation.getDangerousEngineeringId() + "-" + DateUtil.format(DateUtil.parseDateTime(dangerousEngineeringSideStation.getCreateTime()), "yyyy-MM-dd"));
|
||||
}
|
||||
BigDecimal bigDecima2 = new BigDecimal(list3.size());
|
||||
BigDecimal result2 = new BigDecimal(0.4);
|
||||
if (totalDay != 0) {
|
||||
result2 = bigDecima2.divide(bigDecimal1, 2, BigDecimal.ROUND_HALF_UP);
|
||||
result2 = result2.multiply(new BigDecimal(0.4)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
BigDecimal total = result1.add(result2);
|
||||
return total.multiply(new BigDecimal(15)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
return new BigDecimal(15);
|
||||
|
||||
}
|
||||
|
||||
private BigDecimal getHiddenDangerScore(String projectSn, Date date, List<XzSecurityQualityInspectionRecord> safeInspectionRecords, List<Long> enterpriseIds, List<XzSecurityInspectTaskRecord> taskRecords) {
|
||||
List<XzSecurityQualityInspectionRecord> list = safeInspectionRecords.stream().filter(xzSecurityQualityInspectionRecord -> enterpriseIds.contains(xzSecurityQualityInspectionRecord.getEnterpriseId())).collect(Collectors.toList());
|
||||
if (list.size() > 0) {
|
||||
int num1 = list.stream().filter(l -> l.getStatus() != 2 && l.getStatus() != 6).collect(Collectors.toList()).size();
|
||||
BigDecimal bigDecimal = new BigDecimal(num1);
|
||||
BigDecimal bigDecimal1 = new BigDecimal(list.size());
|
||||
BigDecimal result1 = bigDecimal.divide(bigDecimal1, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(0.4)).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
int num2 = list.stream().filter(l -> org.apache.commons.lang3.StringUtils.isNotBlank(l.getCompleteTime()) && org.apache.commons.lang3.StringUtils.isNotBlank(l.getChangeLimitTime())
|
||||
&& (l.getStatus() != 2 || l.getStatus() != 6) && DateUtil.compare(DateUtil.parseDateTime(l.getChangeLimitTime()), DateUtil.parseDateTime(l.getCompleteTime())) > 0).collect(Collectors.toList()).size();
|
||||
BigDecimal bigDecima2 = new BigDecimal(num2);
|
||||
BigDecimal result2 = new BigDecimal(0.3);
|
||||
if (num1 != 0) {
|
||||
result2 = bigDecima2.divide(bigDecimal, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(0.3)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
int num3 = list.stream().filter(l -> (l.getStatus() == 5)).collect(Collectors.toList()).size();
|
||||
BigDecimal bigDecima4 = new BigDecimal(num3);
|
||||
BigDecimal result3 = bigDecima4.divide(bigDecimal1, 2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(0.3)).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
List<Long> ids = taskRecords.stream().filter(r -> enterpriseIds.contains(r.getEnterpriseId())).map(XzSecurityInspectTaskRecord::getId).collect(Collectors.toList());
|
||||
int checkSize = 0;
|
||||
if (ids.size() > 0) {
|
||||
checkSize = xzSecurityInspectTaskItemRecordService.list(Wrappers.<XzSecurityInspectTaskItemRecord>lambdaQuery().in(XzSecurityInspectTaskItemRecord::getTaskId, ids)).size();
|
||||
}
|
||||
BigDecimal bigDecimal6 = new BigDecimal(checkSize);
|
||||
BigDecimal bigDecimal7 = new BigDecimal(4);
|
||||
BigDecimal avg = bigDecimal6.divide(bigDecimal7, 2, BigDecimal.ROUND_HALF_UP);
|
||||
BigDecimal result4 = new BigDecimal(1);
|
||||
if (avg.compareTo(new BigDecimal(7)) < 0) {
|
||||
result4 = avg.divide(new BigDecimal(7), 2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
result4 = result4.multiply(new BigDecimal(0.2)).setScale(2, RoundingMode.HALF_UP);
|
||||
|
||||
BigDecimal total = result1.add(result2).add(result3)/*.add(result4)*/;
|
||||
return total.multiply(new BigDecimal(35)).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
return new BigDecimal(35);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "总包(含下面分包)事故风险预测趋势by项目", notes = "总包(含下面分包)事故风险预测趋势by项目", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
|
||||
})
|
||||
@PostMapping(value = "/riskTrendByProject")
|
||||
public Result<RiskTrendByMainEnterpriseVo> riskTrendByProject(@ApiIgnore @RequestBody Map<String, Object> param) {
|
||||
String projectSn = MapUtils.getString(param, "projectSn");
|
||||
ProjectInfoExtVo project = projectService.getProjectInfoBySn(projectSn);
|
||||
List<XzSecurityQualityInspectionRecord> inspectionRecords = xzSecurityQualityInspectionRecordService.list(new LambdaQueryWrapper<XzSecurityQualityInspectionRecord>()
|
||||
.ne(XzSecurityQualityInspectionRecord::getStatus, 6)
|
||||
.in(XzSecurityQualityInspectionRecord::getProjectSn, projectSn)
|
||||
);
|
||||
Double severeWeatherRate = this.getSevereWeatherRate(project);
|
||||
RiskTrendByMainEnterpriseVo vo = new RiskTrendByMainEnterpriseVo();
|
||||
vo.setSevereWeatherRate(severeWeatherRate);
|
||||
vo.setTotalPersonnelRiskRate(0.0D);
|
||||
long specialNotCount = inspectionRecords.stream().filter(r -> r.getStatus() != 6 && r.getStatus() != 5 && r.getType() != null).count();
|
||||
long specialCount = inspectionRecords.stream().filter(r -> r.getStatus() != 6 && r.getType() != null).count();
|
||||
vo.setTotalSpecialOperationsRiskRate(NumberUtils.occupyRate(specialNotCount, specialCount, 2));
|
||||
JSONObject ssJo = BeanUtil.toBean(securityQualityInspectionRecordController.getStatScore(projectSn), JSONObject.class);
|
||||
vo.setMonthlySafetyScoreRate(ssJo.getDouble("total"));
|
||||
long inspectionCount = inspectionRecords.stream().filter(r -> r.getStatus() != 6).count();
|
||||
long inspectionNotCount = inspectionRecords.stream().filter(r -> r.getStatus() != 6 && r.getStatus() != 5).count();
|
||||
vo.setUnclosedHiddenDangersRate(NumberUtils.occupyRate(inspectionNotCount, inspectionCount, 2));
|
||||
return Result.success(vo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "特殊作业预测趋势(按特殊作业类型分)", notes = "特殊作业预测趋势(按特殊作业类型分)", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目sn", paramType = "body", required = true, dataType = "String"),
|
||||
@ApiImplicitParam(name = "type", value = "1天气2隐患未销项占比", paramType = "body", required = true, dataType = "Integer"),
|
||||
})
|
||||
@PostMapping(value = "/getSpecialTrend")
|
||||
public Result<SpecialTrendVo> getSpecialTrend(@ApiIgnore @RequestBody Map<String, Object> param) {
|
||||
Integer type = MapUtils.getInteger(param, "type");
|
||||
SpecialTrendVo vo = new SpecialTrendVo();
|
||||
String projectSn = MapUtils.getString(param, "projectSn");
|
||||
ProjectInfoExtVo project = projectService.getProjectInfoBySn(projectSn);
|
||||
if (Objects.equals(type, 1)) {
|
||||
String areaId = project.getAreaCode();
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(areaId)) {
|
||||
QueryWrapper<SystemAreas> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SystemAreas::getAreaid, areaId);
|
||||
SystemAreas systemCities = systemAreasMapper.selectOne(queryWrapper);
|
||||
String weathercityid = null;
|
||||
if (systemCities != null) {
|
||||
weathercityid = systemCities.getWeathercityid();
|
||||
}
|
||||
String weatherData = AqiUtil.getWeatherData(weathercityid);
|
||||
JSONArray ja = JSON.parseArray(weatherData);
|
||||
int wind = 0;
|
||||
int yu = 0;
|
||||
int yuLei = 0;
|
||||
int yuLeiXue = 0;
|
||||
int temHigh = 0;
|
||||
int temLow = 0;
|
||||
int temHighLow = 0;
|
||||
for (int i = 0; i < 3; i++) {
|
||||
com.gexin.fastjson.JSONObject jo = ja.getJSONObject(i);
|
||||
String winSpeed = jo.getString("win_speed");
|
||||
String weaImg = jo.getString("wea_img");
|
||||
Double temDay = jo.getDouble("tem_day");
|
||||
Double temNight = jo.getDouble("tem_night");
|
||||
List<Integer> nums = NumberUtils.getIntegersInStr(winSpeed);
|
||||
if (nums.stream().anyMatch(integer -> NumberUtils.ge(integer, 5))) {
|
||||
wind++;
|
||||
}
|
||||
//xue、lei、shachen、wu、bingbao、yun、yu、yin、qing
|
||||
if ("yu".equals(weaImg)) {
|
||||
yu++;
|
||||
}
|
||||
if ("yu".equals(weaImg) || "lei".equals(weaImg)) {
|
||||
yuLei++;
|
||||
}
|
||||
if ("yu".equals(weaImg) || "lei".equals(weaImg) || "xue".equals(weaImg)) {
|
||||
yuLeiXue++;
|
||||
}
|
||||
if (NumberUtils.ge(temDay, 35D)) {
|
||||
temHigh++;
|
||||
}
|
||||
if (NumberUtils.le(temNight, 5D)) {
|
||||
temLow++;
|
||||
}
|
||||
if (NumberUtils.ge(temDay, 35D) || NumberUtils.le(temNight, 5D)) {
|
||||
temHighLow++;
|
||||
}
|
||||
}
|
||||
vo.setSpecialOperationFireSafety(NumberUtils.occupyRate(wind + yuLei, 6, 2));
|
||||
vo.setHighJobSafe(NumberUtils.occupyRate(wind + yuLeiXue, 6, 2));
|
||||
vo.setBlindPlatePlugSafe(NumberUtils.occupyRate(wind + yuLei, 6, 2));
|
||||
vo.setLimitSpaceSafe(NumberUtils.occupyRate(yu + temHighLow, 6, 2));
|
||||
vo.setOpenCircuitSafe(NumberUtils.occupyRate(wind + yuLei, 6, 2));
|
||||
vo.setTemporaryElectricitySafe(NumberUtils.occupyRate(yuLeiXue, 3, 2));
|
||||
vo.setHoistSafetyWork(NumberUtils.occupyRate(yuLeiXue, 3, 2));
|
||||
vo.setGroundSafet(NumberUtils.occupyRate(yu + temHigh, 6, 2));
|
||||
} else {
|
||||
vo.setBlindPlatePlugSafe(0.0D);
|
||||
vo.setGroundSafet(0.0D);
|
||||
vo.setHighJobSafe(0.0D);
|
||||
vo.setHoistSafetyWork(0.0D);
|
||||
vo.setLimitSpaceSafe(0.0D);
|
||||
vo.setOpenCircuitSafe(0.0D);
|
||||
vo.setSpecialOperationFireSafety(0.0D);
|
||||
vo.setTemporaryElectricitySafe(0.0D);
|
||||
}
|
||||
} else {
|
||||
List<XzSecurityQualityInspectionRecord> inspectionRecords = xzSecurityQualityInspectionRecordService.list(Wrappers.<XzSecurityQualityInspectionRecord>lambdaQuery()
|
||||
.eq(XzSecurityQualityInspectionRecord::getProjectSn, projectSn)
|
||||
.ne(XzSecurityQualityInspectionRecord::getStatus, 6)
|
||||
.eq(XzSecurityQualityInspectionRecord::getRecordType, 1));
|
||||
long nc1 = inspectionRecords.stream().filter(r -> !Objects.equals(r.getStatus(), 5) && Objects.equals(r.getType(), 2)).count();
|
||||
long c1 = inspectionRecords.stream().filter(r -> Objects.equals(r.getType(), 2)).count();
|
||||
vo.setSpecialOperationFireSafety(NumberUtils.occupyRate(nc1, c1, 2));
|
||||
long nc2 = inspectionRecords.stream().filter(r -> !Objects.equals(r.getStatus(), 5) && Objects.equals(r.getType(), 5)).count();
|
||||
long c2 = inspectionRecords.stream().filter(r -> Objects.equals(r.getType(), 5)).count();
|
||||
vo.setHighJobSafe(NumberUtils.occupyRate(nc2, c2, 2));
|
||||
long nc3 = inspectionRecords.stream().filter(r -> !Objects.equals(r.getStatus(), 5) && Objects.equals(r.getType(), 4)).count();
|
||||
long c3 = inspectionRecords.stream().filter(r -> Objects.equals(r.getType(), 4)).count();
|
||||
vo.setBlindPlatePlugSafe(NumberUtils.occupyRate(nc3, c3, 2));
|
||||
long nc4 = inspectionRecords.stream().filter(r -> !Objects.equals(r.getStatus(), 5) && Objects.equals(r.getType(), 3)).count();
|
||||
long c4 = inspectionRecords.stream().filter(r -> Objects.equals(r.getType(), 3)).count();
|
||||
vo.setLimitSpaceSafe(NumberUtils.occupyRate(nc4, c4, 2));
|
||||
long nc5 = inspectionRecords.stream().filter(r -> !Objects.equals(r.getStatus(), 5) && Objects.equals(r.getType(), 9)).count();
|
||||
long c5 = inspectionRecords.stream().filter(r -> Objects.equals(r.getType(), 9)).count();
|
||||
vo.setOpenCircuitSafe(NumberUtils.occupyRate(nc5, c5, 2));
|
||||
long nc6 = inspectionRecords.stream().filter(r -> !Objects.equals(r.getStatus(), 5) && Objects.equals(r.getType(), 7)).count();
|
||||
long c6 = inspectionRecords.stream().filter(r -> Objects.equals(r.getType(), 7)).count();
|
||||
vo.setTemporaryElectricitySafe(NumberUtils.occupyRate(nc6, c6, 2));
|
||||
long nc7 = inspectionRecords.stream().filter(r -> !Objects.equals(r.getStatus(), 5) && Objects.equals(r.getType(), 6)).count();
|
||||
long c7 = inspectionRecords.stream().filter(r -> Objects.equals(r.getType(), 6)).count();
|
||||
vo.setHoistSafetyWork(NumberUtils.occupyRate(nc7, c7, 2));
|
||||
long nc8 = inspectionRecords.stream().filter(r -> !Objects.equals(r.getStatus(), 5) && Objects.equals(r.getType(), 8)).count();
|
||||
long c8 = inspectionRecords.stream().filter(r -> Objects.equals(r.getType(), 8)).count();
|
||||
vo.setGroundSafet(NumberUtils.occupyRate(nc8, c8, 2));
|
||||
}
|
||||
return Result.success(vo);
|
||||
}
|
||||
|
||||
private Double getSevereWeatherRate(ProjectInfoExtVo project) {
|
||||
//1、未来三天恶劣天气占比(大风、暴雨),恶劣天气占比越高,发生事故的风险越高;
|
||||
//公式:获取未来三天的恶劣天气数量(大风、暴雨、大雪)/3
|
||||
//5级以上算强风、yu、xue
|
||||
int count = 0;
|
||||
String areaId = project.getAreaCode();
|
||||
if (org.apache.commons.lang3.StringUtils.isNotBlank(areaId)) {
|
||||
QueryWrapper<SystemAreas> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.lambda().eq(SystemAreas::getAreaid, areaId);
|
||||
SystemAreas systemCities = systemAreasMapper.selectOne(queryWrapper);
|
||||
String weathercityid = null;
|
||||
if (systemCities != null) {
|
||||
weathercityid = systemCities.getWeathercityid();
|
||||
}
|
||||
String weatherData = AqiUtil.getWeatherData(weathercityid);
|
||||
JSONArray ja = JSON.parseArray(weatherData);
|
||||
for (int i = 0; i < 3; i++) {
|
||||
com.gexin.fastjson.JSONObject jo = ja.getJSONObject(i);
|
||||
String winSpeed = jo.getString("win_speed");
|
||||
String weaImg = jo.getString("wea_img");
|
||||
List<Integer> nums = NumberUtils.getIntegersInStr(winSpeed);
|
||||
if (nums.stream().anyMatch(integer -> NumberUtils.ge(integer, 5))) {
|
||||
count++;
|
||||
}
|
||||
if ("yu".equals(weaImg) || "xue".equals(weaImg)) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return NumberUtils.occupyRate(count, 6, 2);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询项目下总包的人员风险趋势分析", notes = "查询项目下总包的人员风险趋势分析", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "projectSn", value = "项目SN", paramType = "query", required = true, dataType = "String"),
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
package com.zhgd.xmgl.modules.xz.entity.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RiskTrendByMainEnterpriseVo {
|
||||
//1、未来三天恶劣天气占比(大风、暴雨),恶劣天气占比越高,发生事故的风险越高;
|
||||
//公式:获取未来三天的恶劣天气数量(大风、暴雨、大雪)/3
|
||||
//
|
||||
//2、总包(含下面分包)单位人员发生风险总概率,概率越高风险越大;
|
||||
//公式:取总包(含下面分包)单位未来三天人员风险概率预测数值
|
||||
//
|
||||
//3、总包(含下面分包)单位特殊作业发生风险总概率,概率越高风险越大;
|
||||
//公式:取总包(含下面分包)单位八大特殊作业隐患未销项的概率=总包单位八大特殊作业隐患未销项/总包(含下面分包)单位八大特殊作业隐患条数
|
||||
//
|
||||
//4、总包(含下面分包)单位安全评分总分
|
||||
//公式:指挥部大屏上的月度安全评分分值按总包(含下面分包)单位计算
|
||||
//
|
||||
//5、总包(含下面分包)单位未闭合隐患占比
|
||||
@ApiModelProperty("恶劣天气占比")
|
||||
private Double severeWeatherRate;
|
||||
@ApiModelProperty("人员发生风险总概率")
|
||||
private Double totalPersonnelRiskRate;
|
||||
@ApiModelProperty("特殊作业发生风险总概率")
|
||||
private Double totalSpecialOperationsRiskRate;
|
||||
@ApiModelProperty("月度安全评分")
|
||||
private Double monthlySafetyScoreRate;
|
||||
@ApiModelProperty("未闭合隐患占比")
|
||||
private Double unclosedHiddenDangersRate;
|
||||
@ApiModelProperty("企业名称")
|
||||
private String enterpriseName;
|
||||
@ApiModelProperty("企业id")
|
||||
private Long enterpriseId;
|
||||
}
|
||||
@ -0,0 +1,48 @@
|
||||
package com.zhgd.xmgl.modules.xz.entity.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class SpecialTrendVo {
|
||||
/**
|
||||
* 盲板抽堵安全
|
||||
*/
|
||||
@ApiModelProperty("盲板抽堵安全")
|
||||
private Double blindPlatePlugSafe;
|
||||
/**
|
||||
* 动土安全作业票
|
||||
*/
|
||||
@ApiModelProperty("动土安全作业票")
|
||||
private Double groundSafet;
|
||||
/**
|
||||
* 高处作业安全票
|
||||
*/
|
||||
@ApiModelProperty("高处作业安全票")
|
||||
private Double highJobSafe;
|
||||
/**
|
||||
* 吊装安全作业票
|
||||
*/
|
||||
@ApiModelProperty("吊装安全作业票")
|
||||
private Double hoistSafetyWork;
|
||||
/**
|
||||
* 受限空间安全作业票
|
||||
*/
|
||||
@ApiModelProperty("受限空间安全作业票")
|
||||
private Double limitSpaceSafe;
|
||||
/**
|
||||
* 断路安全作业票
|
||||
*/
|
||||
@ApiModelProperty("断路安全作业票")
|
||||
private Double openCircuitSafe;
|
||||
/**
|
||||
* 动火安全
|
||||
*/
|
||||
@ApiModelProperty("动火安全")
|
||||
private Double specialOperationFireSafety;
|
||||
/**
|
||||
* 临时用电安全作业票
|
||||
*/
|
||||
@ApiModelProperty("临时用电安全作业票")
|
||||
private Double temporaryElectricitySafe;
|
||||
}
|
||||
@ -5,6 +5,8 @@ import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@ -41,11 +43,45 @@ public class NumberUtils {
|
||||
return NumberUtil.round((b1 - b2) / b2 * 100, scale).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* b1比b2占百分比
|
||||
*
|
||||
* @param b1
|
||||
* @param b2
|
||||
* @param scale
|
||||
* @return
|
||||
*/
|
||||
public static Double occupyRate(Integer b1, Integer b2, Integer scale) {
|
||||
if (b1 == null || b2 == null || b2.equals(0D)) {
|
||||
return null;
|
||||
}
|
||||
return NumberUtil.round((b1 + 0.0) / b2 * 100, scale).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* b1比b2占百分比
|
||||
*
|
||||
* @param b1
|
||||
* @param b2
|
||||
* @param scale
|
||||
* @return
|
||||
*/
|
||||
public static Double occupyRate(Long b1, Long b2, Integer scale) {
|
||||
if (b1 == null || b2 == null || b2.equals(0L)) {
|
||||
return null;
|
||||
}
|
||||
return NumberUtil.round((b1 + 0.0) / b2 * 100, scale).doubleValue();
|
||||
}
|
||||
|
||||
/**
|
||||
* 大于等于
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static boolean ge(Integer b1, Integer b2) {
|
||||
return b1 != null && b2 != null && b1 >= b2;
|
||||
}
|
||||
|
||||
public static boolean ge(Double b1, Double b2) {
|
||||
return b1 != null && b2 != null && b1 >= b2;
|
||||
}
|
||||
@ -200,7 +236,7 @@ public class NumberUtils {
|
||||
* @param str
|
||||
* @return
|
||||
*/
|
||||
public static int getFirstNumberInStr(String str) {
|
||||
public static Integer getFirstIntegerInStr(String str) {
|
||||
String regex = "\\d+"; // 匹配一个或多个数字
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
@ -209,6 +245,19 @@ public class NumberUtils {
|
||||
return Integer.parseInt(matcher.group());
|
||||
}
|
||||
|
||||
return -1;
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Integer> getIntegersInStr(String str) {
|
||||
String regex = "\\d+"; // 匹配一个或多个数字
|
||||
Pattern pattern = Pattern.compile(regex);
|
||||
Matcher matcher = pattern.matcher(str);
|
||||
List<Integer> list = new ArrayList<>();
|
||||
if (matcher.find()) {
|
||||
list.add(Integer.parseInt(matcher.group()));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -156,9 +156,9 @@ is-license=false
|
||||
#天气url
|
||||
tianqiUrl=http://v1.yiketianqi.com
|
||||
#天气appid
|
||||
tianqiAppid=21845649
|
||||
tianqiAppid=37328925
|
||||
#天气appsecret
|
||||
tianqiAppsecret=uX7zXSJA
|
||||
tianqiAppsecret=uu9bihuE
|
||||
spring.jackson.date-format=yyyy-MM-dd HH:mm:ss
|
||||
spring.jackson.time-zone=GMT+8
|
||||
#邮箱配置
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user