二次调整提交

This commit is contained in:
pengjie 2024-12-31 14:57:52 +08:00
parent 146aea1ac6
commit d2e8d9d18e
17 changed files with 570 additions and 46 deletions

View File

@ -14,6 +14,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* @Description: 账号 * @Description: 账号
@ -193,6 +194,18 @@ public class SystemUser implements Serializable {
@ApiModelProperty(value = "项目组织机构名称") @ApiModelProperty(value = "项目组织机构名称")
private java.lang.String projectOrgName; private java.lang.String projectOrgName;
@TableField(exist = false)
@ApiModelProperty(value = "项目组织机构ID")
private java.lang.String projectOrgId;
@TableField(exist = false)
@ApiModelProperty(value = "项目组织机构名称")
private java.lang.String ancestors;
@TableField(exist = false)
@ApiModelProperty(value = "项目组织机构名称")
private List<String> ancestorsName;
@TableField(exist = false) @TableField(exist = false)
private java.lang.Long enterpriseId; private java.lang.Long enterpriseId;

View File

@ -37,7 +37,9 @@
group_concat(distinct c.role_name) as role_name, group_concat(distinct c.role_name) as role_name,
group_concat(distinct b.role_id) as role_id, group_concat(distinct b.role_id) as role_id,
d.worker_name, d.worker_name,
po.id as projectOrgId,
po.dept_name as projectOrgName, po.dept_name as projectOrgName,
po.ancestors,
d.enterprise_id, d.enterprise_id,
d.person_mail, d.person_mail,
ei.enterprise_name ei.enterprise_name

View File

@ -54,11 +54,14 @@ import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper; import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
import com.zhgd.xmgl.modules.worker.service.IUserEnterpriseService; import com.zhgd.xmgl.modules.worker.service.IUserEnterpriseService;
import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl; import com.zhgd.xmgl.modules.worker.service.impl.WorkerInfoServiceImpl;
import com.zhgd.xmgl.modules.xz.entity.XzProjectOrg;
import com.zhgd.xmgl.modules.xz.entity.XzRegistry; import com.zhgd.xmgl.modules.xz.entity.XzRegistry;
import com.zhgd.xmgl.modules.xz.mapper.XzProjectOrgMapper;
import com.zhgd.xmgl.modules.xz.mapper.XzRegistryMapper; import com.zhgd.xmgl.modules.xz.mapper.XzRegistryMapper;
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityQualityInspectionRecord; import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityQualityInspectionRecord;
import com.zhgd.xmgl.modules.xz.security.enums.XzSecurityQualityInspectionRecordStatusEnum; import com.zhgd.xmgl.modules.xz.security.enums.XzSecurityQualityInspectionRecordStatusEnum;
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityQualityInspectionRecordService; import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityQualityInspectionRecordService;
import com.zhgd.xmgl.modules.xz.service.IXzProjectOrgService;
import com.zhgd.xmgl.modules.xz.service.impl.XzRegistryServiceImpl; import com.zhgd.xmgl.modules.xz.service.impl.XzRegistryServiceImpl;
import com.zhgd.xmgl.security.JwtTokenProvider; import com.zhgd.xmgl.security.JwtTokenProvider;
import com.zhgd.xmgl.security.entity.UserInfo; import com.zhgd.xmgl.security.entity.UserInfo;
@ -188,6 +191,8 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
private WflowModelsMapper wflowModelsMapper; private WflowModelsMapper wflowModelsMapper;
@Autowired @Autowired
private ISystemUserDestroyService systemUserDestroyService; private ISystemUserDestroyService systemUserDestroyService;
@Autowired
private XzProjectOrgMapper xzProjectOrgMapper;
@Override @Override
public Map<String, Object> getToken(Map<String, Object> map) { public Map<String, Object> getToken(Map<String, Object> map) {
@ -327,19 +332,20 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
} else { } else {
result.put("workerId", ""); result.put("workerId", "");
} }
result.put("styleType", null); CompanyConfig companyConfig1 = companyConfigMapper.getCompanyConfigByHeadquartersSn(systemUser.getHeadquartersSn());
result.put("styleType", companyConfig1.getStyleType());
result.put("accountType", systemUser.getAccountType()); result.put("accountType", systemUser.getAccountType());
result.put("headquartersSn", null); result.put("headquartersSn", companyConfig1.getHeadquartersSn());
result.put("companyName", null); result.put("companyName", companyConfig1.getCompanyName());
result.put("propagateFile", null); result.put("propagateFile", companyConfig1.getPropagateFile());
result.put("moduleShowType", null); result.put("moduleShowType", companyConfig1.getModuleShowType());
result.put("mobileAttendance", null); result.put("mobileAttendance", companyConfig1.getMobileAttendance());
result.put("customerServicePhone", null); result.put("customerServicePhone", companyConfig1.getCustomerServicePhone());
result.put("inputQrCode", null); result.put("inputQrCode", companyConfig1.getInputQrCode());
result.put("projectKanban", null); result.put("projectKanban", companyConfig1.getProjectKanban());
result.put("addProjectType", null); result.put("addProjectType", companyConfig1.getAddProjectType());
result.put("enterProjectBackType", null); result.put("enterProjectBackType", companyConfig1.getEnterProjectBackType());
result.put("companyBigScreen", null); result.put("companyBigScreen", companyConfig1.getCompanyBigScreen());
String projectSn = MapUtils.getString(map, "projectSn"); String projectSn = MapUtils.getString(map, "projectSn");
if (StrUtil.isNotBlank(projectSn)) { if (StrUtil.isNotBlank(projectSn)) {
CompanyConfig companyConfig = companyConfigMapper.getCompanyConfigByProject(projectSn); CompanyConfig companyConfig = companyConfigMapper.getCompanyConfigByProject(projectSn);
@ -942,7 +948,32 @@ public class SystemUserServiceImpl extends ServiceImpl<SystemUserMapper, SystemU
if (StrUtil.isNotBlank(enterpriseId)) { if (StrUtil.isNotBlank(enterpriseId)) {
map.put("enterpriseIdList", StrUtil.split(enterpriseId, ",")); map.put("enterpriseIdList", StrUtil.split(enterpriseId, ","));
} }
return systemUserMapper.getProjectChilderSystemUserList(map); return dealList(systemUserMapper.getProjectChilderSystemUserList(map));
}
private List<SystemUser> dealList(List<SystemUser> list) {
if (list.size() > 0) {
List<XzProjectOrg> xzProjectOrgList = xzProjectOrgMapper.selectList(null);
for (SystemUser systemUser : list) {
String ancestors = systemUser.getAncestors();
List<String> name = new ArrayList<>();
if (ancestors.equals("0")) {
name.add(systemUser.getProjectOrgName());
} else {
String[] split = ancestors.split(",");
for (int i = 1; i < split.length; i++) {
int finalI = i;
List<XzProjectOrg> collect = xzProjectOrgList.stream().filter(l -> l.getId().toString().equals(split[finalI])).collect(Collectors.toList());
if (collect.size() > 0) {
name.add(collect.get(0).getDeptName());
}
}
name.add(systemUser.getProjectOrgName());
}
systemUser.setAncestorsName(name);
}
}
return list;
} }
@Override @Override

View File

@ -215,6 +215,14 @@ public interface QualityInspectionRecordMapper extends BaseMapper<QualityInspect
*/ */
Page<StatsByInspectManVo> statsByInspectManVo(@Param("param") Map<String, Object> paramMap, Page page); Page<StatsByInspectManVo> statsByInspectManVo(@Param("param") Map<String, Object> paramMap, Page page);
/**
* 检查人统计
*
* @param paramMap
* @param page
* @return
*/
Page<StatsByInspectManVo> statsByParentInspectManVo(@Param("param") Map<String, Object> paramMap, Page page);
/** /**
* 按分包单位统计 * 按分包单位统计
* *
@ -224,6 +232,15 @@ public interface QualityInspectionRecordMapper extends BaseMapper<QualityInspect
*/ */
Page<StatsByEnterpriseVo> statsByEnterprise(@Param("param") Map<String, Object> paramMap, Page page); Page<StatsByEnterpriseVo> statsByEnterprise(@Param("param") Map<String, Object> paramMap, Page page);
/**
* 按总包单位统计
*
* @param paramMap
* @param page
* @return
*/
Page<StatsByEnterpriseVo> statsByParentEnterprise(@Param("param") Map<String, Object> paramMap, Page page);
/** /**
* 隐患类型分析 * 隐患类型分析
* *

View File

@ -674,6 +674,39 @@
order by rectifiedNum desc) t order by rectifiedNum desc) t
</select> </select>
<select id="statsByParentInspectManVo" resultType="com.zhgd.xmgl.modules.xz.security.entity.vo.StatsByInspectManVo">
select t.*,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100,
2) rectifiedNumRatio,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNumTimely, 0) / IFNULL(totalNum, 0), 4), 0) * 100, 2)
rectifiedNumRatioTimely
from (SELECT count(*) totalNum,
count(*) createDangerNum,
<include refid="selectShow">
</include>
su.real_name as workerName
from quality_inspection_record t
JOIN enterprise_info ei on ei.id=t.enterprise_id
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 system_user su on su.user_id = t.inspect_man_id
WHERE record_type = 1
and t.status != 6
and t.project_sn = #{param.projectSn}
<if test="param.inspectTime_begin != null and param.inspectTime_begin != ''">
and t.inspect_time <![CDATA[>=]]> #{param.inspectTime_begin}
</if>
<if test="param.inspectTime_end != null and param.inspectTime_end != ''">
and t.inspect_time <![CDATA[<=]]> if(LENGTH(#{param.inspectTime_end}) = 10,
CONCAT(DATE_FORMAT(#{param.inspectTime_end}, '%Y-%m-%d'), ' 23:59:59'),
#{param.inspectTime_end})
</if>
group by t.inspect_man_id
order by rectifiedNum desc) t
</select>
<select id="statsByEnterprise" resultType="com.zhgd.xmgl.modules.xz.security.entity.vo.StatsByEnterpriseVo"> <select id="statsByEnterprise" resultType="com.zhgd.xmgl.modules.xz.security.entity.vo.StatsByEnterpriseVo">
select t.*, select t.*,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100, round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100,
@ -695,6 +728,31 @@
order by rectifiedNum desc) t order by rectifiedNum desc) t
</select> </select>
<select id="statsByParentEnterprise" resultType="com.zhgd.xmgl.modules.xz.security.entity.vo.StatsByEnterpriseVo">
select t.*,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100,
2) rectifiedNumRatio,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNumTimely, 0) / IFNULL(totalNum, 0), 4), 0) * 100, 2)
rectifiedNumRatioTimely
from (SELECT count(*) as totalNum,
<include refid="selectShow">
</include>
mei.enterprise_name
from quality_inspection_record t
JOIN enterprise_info ei on ei.id=t.enterprise_id
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 )))
WHERE record_type = 1
and t.status != 6
and t.project_sn = #{param.projectSn}
<include refid="whereCondition">
</include>
group by mei.id
order by rectifiedNum desc) t
</select>
<select id="statsDangerType" resultType="com.zhgd.xmgl.base.entity.vo.SectorOneVo"> <select id="statsDangerType" resultType="com.zhgd.xmgl.base.entity.vo.SectorOneVo">
select count(*) count, SUBSTRING_INDEX(t.danger_item_content, '/', 1) as name select count(*) count, SUBSTRING_INDEX(t.danger_item_content, '/', 1) as name
from quality_inspection_record t from quality_inspection_record t

View File

@ -750,13 +750,24 @@ public class QualityInspectionRecordServiceImpl extends ServiceImpl<QualityInspe
@Override @Override
public Page<StatsByInspectManVo> statsByInspectMan(Map<String, Object> paramMap) { public Page<StatsByInspectManVo> statsByInspectMan(Map<String, Object> paramMap) {
Page page = PageUtil.getPage(paramMap); Page page = PageUtil.getPage(paramMap);
return baseMapper.statsByInspectManVo(paramMap, page); Integer isCountMainEnterprise = MapUtils.getInteger(paramMap, "isCountMainEnterprise");
if (Objects.equals(isCountMainEnterprise, 1)) {
return baseMapper.statsByParentInspectManVo(paramMap, page);
} else {
return baseMapper.statsByInspectManVo(paramMap, page);
}
} }
@Override @Override
public Page<StatsByEnterpriseVo> statsByEnterprise(Map<String, Object> paramMap) { public Page<StatsByEnterpriseVo> statsByEnterprise(Map<String, Object> paramMap) {
Page page = PageUtil.getPage(paramMap); Page page = PageUtil.getPage(paramMap);
return baseMapper.statsByEnterprise(paramMap, page); Integer isCountMainEnterprise = MapUtils.getInteger(paramMap, "isCountMainEnterprise");
if (Objects.equals(isCountMainEnterprise, 1)) {
return baseMapper.statsByParentEnterprise(paramMap, page);
} else {
return baseMapper.statsByEnterprise(paramMap, page);
}
} }
@Override @Override

View File

@ -109,6 +109,7 @@ public class SafetyHatDataServiceImpl extends ServiceImpl<SafetyHatDataMapper, S
} }
if (!Objects.equals(dev.getOnline(), 1)) { if (!Objects.equals(dev.getOnline(), 1)) {
dev.setOnline(1); dev.setOnline(1);
dev.setHeartbeatTime(safetyHatData.getUploadTime());
safetyHatDevMapper.updateById(dev); safetyHatDevMapper.updateById(dev);
} }
double zero = 0D; double zero = 0D;

View File

@ -157,6 +157,14 @@ public interface WorkerInfoMapper extends BaseMapper<WorkerInfo> {
*/ */
List<Map<String, Object>> selectEnterpriseWorkerGroupTotal(Map<String, Object> map); List<Map<String, Object>> selectEnterpriseWorkerGroupTotal(Map<String, Object> map);
/**
* 统计总包企业人员数量
*
* @param map
* @return
*/
List<Map<String, Object>> selectParentEnterpriseWorkerGroupTotal(Map<String, Object> map);
/** /**
* 查询在场人员信息 * 查询在场人员信息
* *
@ -206,6 +214,14 @@ public interface WorkerInfoMapper extends BaseMapper<WorkerInfo> {
*/ */
List<Map<String, Object>> selectEnterpriseAttendanceWorkerCount(Map<String, Object> map); List<Map<String, Object>> selectEnterpriseAttendanceWorkerCount(Map<String, Object> map);
/**
* 统计总包企业出勤人数
*
* @param map
* @return
*/
List<Map<String, Object>> selectParentEnterpriseAttendanceWorkerCount(Map<String, Object> map);
/** /**
* 统计各企业在册人数 * 统计各企业在册人数
* *
@ -214,6 +230,14 @@ public interface WorkerInfoMapper extends BaseMapper<WorkerInfo> {
*/ */
List<Map<String, Object>> selectProjectEnterpriseWorkerCount(Map<String, Object> map); List<Map<String, Object>> selectProjectEnterpriseWorkerCount(Map<String, Object> map);
/**
* 统计总包企业在册人数
*
* @param map
* @return
*/
List<Map<String, Object>> selectParentProjectEnterpriseWorkerCount(Map<String, Object> map);
/** /**
* 统计企业在场人数 * 统计企业在场人数
* *
@ -222,6 +246,14 @@ public interface WorkerInfoMapper extends BaseMapper<WorkerInfo> {
*/ */
List<Map<String, Object>> selectEnterprisePresenceWorkerCount(Map<String, Object> map); List<Map<String, Object>> selectEnterprisePresenceWorkerCount(Map<String, Object> map);
/**
* 统计企业在场人数
*
* @param map
* @return
*/
List<Map<String, Object>> selectParentEnterprisePresenceWorkerCount(Map<String, Object> map);
/** /**
* 分页查询项目下所有部门出勤人数列表 * 分页查询项目下所有部门出勤人数列表
* *
@ -699,6 +731,14 @@ public interface WorkerInfoMapper extends BaseMapper<WorkerInfo> {
*/ */
List<TrendOneVo> statsEnterprise(@Param("param") Map<String, Object> map); List<TrendOneVo> statsEnterprise(@Param("param") Map<String, Object> map);
/**
* 企业安全评分汇总
*
* @param map
* @return
*/
List<TrendOneVo> statsParentEnterprise(@Param("param") Map<String, Object> map);
/** /**
* 企业安全评分汇总表 * 企业安全评分汇总表
* *
@ -707,6 +747,14 @@ public interface WorkerInfoMapper extends BaseMapper<WorkerInfo> {
*/ */
List<StatsTrendVo> statsEnterpriseRisk(@Param("param") Map<String, Object> map); List<StatsTrendVo> statsEnterpriseRisk(@Param("param") Map<String, Object> map);
/**
* 企业安全评分汇总表
*
* @param map
* @return
*/
List<StatsTrendVo> statsParentEnterpriseRisk(@Param("param") Map<String, Object> map);
/** /**
* 根据企业ids和项目sn获取平均安全分数 * 根据企业ids和项目sn获取平均安全分数
* *

View File

@ -850,6 +850,9 @@
and create_time >= CURRENT_DATE and create_time >= CURRENT_DATE
group by person_sn) t1 on t1.person_sn=wi.person_sn group by person_sn) t1 on t1.person_sn=wi.person_sn
where wi.project_sn=#{param.projectSn} AND wi.inService_type = 1 where wi.project_sn=#{param.projectSn} AND wi.inService_type = 1
<if test="param.isCountMainEnterprise != null and param.isCountMainEnterprise != '' and param.isCountMainEnterprise == '1'.toString()">
and pe.parent_enterprise_id = 0
</if>
group by t.id group by t.id
</select> </select>

View File

@ -438,17 +438,21 @@
and w1.person_type = #{personType} and w1.person_type = #{personType}
</if> </if>
</select> </select>
<select id="selectWorkerPersonTypeTotal" resultType="java.util.Map" parameterType="java.util.Map"> <select id="selectWorkerPersonTypeTotal" resultType="java.util.Map" parameterType="java.util.Map">
SELECT COUNT(1) totalPerson, SELECT COUNT(1) totalPerson,
IFNULL(sum((CASE WHEN w1.person_type = 1 then 1 ELSE 0 END)), 0) lwPersonTotal, IFNULL(sum((CASE WHEN w1.person_type = 1 then 1 ELSE 0 END)), 0) lwPersonTotal,
IFNULL(sum((CASE WHEN w1.person_type = 2 then 1 ELSE 0 END)), 0) glPersonTotal, IFNULL(sum((CASE WHEN w1.person_type = 2 then 1 ELSE 0 END)), 0) glPersonTotal,
IFNULL(sum((CASE WHEN w1.person_type = 3 then 1 ELSE 0 END)), 0) lsPersonTotal, IFNULL(sum((CASE WHEN w1.person_type = 3 then 1 ELSE 0 END)), 0) lsPersonTotal,
COUNT(distinct w1.team_id) total_team_num COUNT(distinct w1.team_id) total_team_num
FROM worker_info w1 FROM worker_info w1
JOIN project_enterprise pe on pe.enterprise_id=w1.enterprise_id and pe.project_sn=w1.project_sn
<where> <where>
<if test="projectSn != null and projectSn != ''"> <if test="projectSn != null and projectSn != ''">
w1.project_sn = #{projectSn} w1.project_sn = #{projectSn}
</if> </if>
<if test="isCountMainEnterprise != null and isCountMainEnterprise != '' and isCountMainEnterprise == '1'.toString()">
and pe.parent_enterprise_id = 0
</if>
and w1.inService_type = 1 and w1.inService_type = 1
<if test="projectSnList != null and projectSnList != ''"> <if test="projectSnList != null and projectSnList != ''">
and w1.project_sn in and w1.project_sn in
@ -479,9 +483,13 @@
IFNULL(sum((CASE WHEN w1.person_type = 3 then 1 ELSE 0 END)), 0) lsPersonTotal, IFNULL(sum((CASE WHEN w1.person_type = 3 then 1 ELSE 0 END)), 0) lsPersonTotal,
COUNT(distinct g.worker_type_id) total_worker_type_num COUNT(distinct g.worker_type_id) total_worker_type_num
from worker_info w1 from worker_info w1
JOIN project_enterprise pe on pe.enterprise_id=w1.enterprise_id and pe.project_sn=w1.project_sn
INNER JOIN worker_attendance_presence p ON w1.person_sn = p.person_sn INNER JOIN worker_attendance_presence p ON w1.person_sn = p.person_sn
Left JOIN team_info g ON (w1.project_sn = g.project_sn and w1.team_id = g.id) Left JOIN team_info g ON (w1.project_sn = g.project_sn and w1.team_id = g.id)
<where> <where>
<if test="isCountMainEnterprise != null and isCountMainEnterprise != '' and isCountMainEnterprise == '1'.toString()">
pe.parent_enterprise_id = 0
</if>
<if test="supplierEnterpriseId != null and supplierEnterpriseId != ''"> <if test="supplierEnterpriseId != null and supplierEnterpriseId != ''">
AND (w1.enterprise_id = #{supplierEnterpriseId} OR w1.enterprise_id IN ( SELECT t.enterprise_id FROM AND (w1.enterprise_id = #{supplierEnterpriseId} OR w1.enterprise_id IN ( SELECT t.enterprise_id FROM
project_enterprise t WHERE find_in_set(#{projectEnterpriseId}, ancestors) )) project_enterprise t WHERE find_in_set(#{projectEnterpriseId}, ancestors) ))
@ -694,6 +702,50 @@
</if> </if>
</select> </select>
<select id="selectParentEnterpriseWorkerGroupTotal" resultType="java.util.Map" parameterType="java.util.Map">
SELECT mei.enterprise_name,
mei.id as enterpriseId,
COUNT(1) num
<if test="enterpriseType == '2'.toString()">
, IFNULL(sum((CASE WHEN w1.person_type = 1 then 1 ELSE 0 END)), 0) lwPersonTotal
, IFNULL(sum((CASE WHEN w1.person_type = 2 then 1 ELSE 0 END)), 0) glPersonTotal
</if>
from worker_info w1
INNER JOIN project a ON w1.project_sn = a.project_sn
INNER JOIN company cp ON a.company_sn = cp.company_sn
INNER JOIN company b ON cp.parent_id = b.company_id
INNER JOIN enterprise_info p ON p.id = w1.enterprise_id
Left JOIN company f ON b.parent_id = f.company_id
INNER JOIN project_enterprise pe ON pe.enterprise_id = p.id and a.project_sn = pe.project_sn
JOIN enterprise_info mei ON mei.id =
IF( pe.parent_enterprise_id = 0,p.id, (SELECT enterprise_id from project_enterprise WHERE id = substring_index(
substring_index( pe.ancestors, ',', 2 ), ',', - 1 )))
WHERE w1.inService_type = 1
<if test="projectName != null and projectName != ''">
and a.project_name like CONCAT(CONCAT('%', #{projectName}), '%')
</if>
<if test="companyType == '1'.toString()">
and f.headquarters_sn = #{sn}
</if>
<if test="companyType == '2'.toString()">
and f.company_sn = #{sn}
</if>
<if test="companyType == '3'.toString()">
and b.company_sn = #{sn}
</if>
<if test="companyType == '4'.toString()">
and w1.project_sn = #{sn}
</if>
<if test="companyType == '5'.toString()">
and cp.company_sn = #{sn}
</if>
GROUP BY mei.id
ORDER BY num desc
<if test="enterpriseType == '1'.toString()">
LIMIT 10
</if>
</select>
<select id="selectProjectPresentWorkerList" resultType="com.zhgd.jeecg.common.mybatis.EntityMap" <select id="selectProjectPresentWorkerList" resultType="com.zhgd.jeecg.common.mybatis.EntityMap"
parameterType="map"> parameterType="map">
SELECT a.*, SELECT a.*,
@ -867,6 +919,9 @@
<if test="userEnterpriseId != null and userEnterpriseId != ''"> <if test="userEnterpriseId != null and userEnterpriseId != ''">
and FIND_IN_SET(e.enterprise_id, #{userEnterpriseId}) and FIND_IN_SET(e.enterprise_id, #{userEnterpriseId})
</if> </if>
<if test="isCountMainEnterprise != null and isCountMainEnterprise != '' and isCountMainEnterprise == '1'.toString()">
and e.parent_enterprise_id = 0
</if>
</select> </select>
<select id="selectEnterpriseAttendanceWorkerCount" parameterType="map" resultType="map"> <select id="selectEnterpriseAttendanceWorkerCount" parameterType="map" resultType="map">
SELECT w1.enterprise_id enterpriseId, COUNT(DISTINCT w1.person_sn) personNum SELECT w1.enterprise_id enterpriseId, COUNT(DISTINCT w1.person_sn) personNum
@ -883,6 +938,26 @@
</if> </if>
group by w1.enterprise_id group by w1.enterprise_id
</select> </select>
<select id="selectParentEnterpriseAttendanceWorkerCount" parameterType="map" resultType="map">
SELECT mei.id enterpriseId, COUNT(DISTINCT w1.person_sn) personNum
from worker_info w1
JOIN enterprise_info ei on ei.id=w1.enterprise_id
JOIN project_enterprise pe on pe.enterprise_id=w1.enterprise_id and pe.project_sn=w1.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 )))
INNER JOIN worker_attendance p ON w1.person_sn = p.person_sn
WHERE p.create_time >= CONCAT(DATE_FORMAT(now(), "%Y-%m-%d"), ' 00:00:00')
and w1.inService_type = 1
and w1.project_sn = #{projectSn}
<if test="personType != null and personType != ''">
and w1.person_type = #{personType}
</if>
<if test="userEnterpriseId != null and userEnterpriseId != ''">
and FIND_IN_SET(w1.enterprise_id, #{userEnterpriseId})
</if>
group by enterpriseId
</select>
<select id="selectProjectEnterpriseWorkerCount" parameterType="map" resultType="map"> <select id="selectProjectEnterpriseWorkerCount" parameterType="map" resultType="map">
SELECT w1.enterprise_id enterpriseId, COUNT(DISTINCT w1.person_sn) personNum SELECT w1.enterprise_id enterpriseId, COUNT(DISTINCT w1.person_sn) personNum
FROM worker_info w1 FROM worker_info w1
@ -896,6 +971,24 @@
</if> </if>
group by w1.enterprise_id group by w1.enterprise_id
</select> </select>
<select id="selectParentProjectEnterpriseWorkerCount" parameterType="map" resultType="map">
SELECT mei.id enterpriseId, COUNT(DISTINCT w1.person_sn) personNum
FROM worker_info w1
JOIN enterprise_info ei on ei.id=w1.enterprise_id
JOIN project_enterprise pe on pe.enterprise_id=w1.enterprise_id and pe.project_sn=w1.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 )))
where w1.inService_type = 1
and w1.project_sn = #{projectSn}
<if test="personType != null and personType != ''">
and w1.person_type = #{personType}
</if>
<if test="userEnterpriseId != null and userEnterpriseId != ''">
and FIND_IN_SET(w1.enterprise_id, #{userEnterpriseId})
</if>
group by enterpriseId
</select>
<select id="selectEnterprisePresenceWorkerCount" parameterType="map" resultType="map"> <select id="selectEnterprisePresenceWorkerCount" parameterType="map" resultType="map">
SELECT w1.enterprise_id enterpriseId, SELECT w1.enterprise_id enterpriseId,
COUNT(DISTINCT w1.person_sn) personNum COUNT(DISTINCT w1.person_sn) personNum
@ -911,6 +1004,26 @@
</if> </if>
group by w1.enterprise_id group by w1.enterprise_id
</select> </select>
<select id="selectParentEnterprisePresenceWorkerCount" parameterType="map" resultType="map">
SELECT mei.id enterpriseId,
COUNT(DISTINCT w1.person_sn) personNum
from worker_info w1
JOIN enterprise_info ei on ei.id=w1.enterprise_id
JOIN project_enterprise pe on pe.enterprise_id=w1.enterprise_id and pe.project_sn=w1.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 )))
INNER JOIN worker_attendance_presence p ON w1.person_sn = p.person_sn
WHERE w1.project_sn = #{projectSn}
and w1.inService_type = 1
<if test="personType != null and personType != ''">
and w1.person_type = #{personType}
</if>
<if test="userEnterpriseId != null and userEnterpriseId != ''">
and FIND_IN_SET(w1.enterprise_id, #{userEnterpriseId})
</if>
group by enterpriseId
</select>
<select id="selectProjectTeamWorkTotalList" <select id="selectProjectTeamWorkTotalList"
resultType="com.zhgd.xmgl.modules.worker.entity.vo.ProjectTeamWorkTotalVo"> resultType="com.zhgd.xmgl.modules.worker.entity.vo.ProjectTeamWorkTotalVo">
SELECT e.team_name, SELECT e.team_name,
@ -1064,8 +1177,12 @@
from from
(SELECT DISTINCT w1.* (SELECT DISTINCT w1.*
from worker_info w1 from worker_info w1
JOIN project_enterprise pe on pe.enterprise_id=w1.enterprise_id and pe.project_sn=w1.project_sn
INNER JOIN worker_attendance p ON w1.person_sn = p.person_sn INNER JOIN worker_attendance p ON w1.person_sn = p.person_sn
<where> <where>
<if test="isCountMainEnterprise != null and isCountMainEnterprise != '' and isCountMainEnterprise == '1'.toString()">
pe.parent_enterprise_id = 0
</if>
<if test="supplierEnterpriseId != null and supplierEnterpriseId != ''"> <if test="supplierEnterpriseId != null and supplierEnterpriseId != ''">
AND (w1.enterprise_id = #{supplierEnterpriseId} OR w1.enterprise_id IN ( SELECT t.enterprise_id FROM AND (w1.enterprise_id = #{supplierEnterpriseId} OR w1.enterprise_id IN ( SELECT t.enterprise_id FROM
project_enterprise t WHERE find_in_set(#{projectEnterpriseId}, ancestors) )) project_enterprise t WHERE find_in_set(#{projectEnterpriseId}, ancestors) ))
@ -2559,6 +2676,20 @@
group by t.enterprise_id group by t.enterprise_id
</select> </select>
<select id="statsParentEnterprise" resultType="com.zhgd.xmgl.base.entity.vo.TrendOneVo">
select
mei.enterprise_name as x,
ifnull(round(avg(t.safe_score),2),0) as y
from worker_info t
JOIN enterprise_info ei on ei.id=t.enterprise_id
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 )))
where t.project_sn=#{param.projectSn} and t.inService_type = 1
group by mei.id
</select>
<select id="statsEnterpriseRisk" resultType="com.zhgd.xmgl.modules.worker.entity.vo.StatsTrendVo"> <select id="statsEnterpriseRisk" resultType="com.zhgd.xmgl.modules.worker.entity.vo.StatsTrendVo">
select select
ei.enterprise_name, ei.enterprise_name,
@ -2573,6 +2704,24 @@
group by t.enterprise_id group by t.enterprise_id
</select> </select>
<select id="statsParentEnterpriseRisk" resultType="com.zhgd.xmgl.modules.worker.entity.vo.StatsTrendVo">
select
mei.enterprise_name,
ifnull(round(sum(if(t.safe_score &lt; #{param.workerInfoRedScore},1,0)),2),0) as highRiskNum,
ifnull(round(sum(if(t.safe_score >= #{param.workerInfoRedScore} and t.safe_score &lt;
#{param.workerInfoGreenScore},1,0)),2),0) as mediumRiskNum,
ifnull(round(sum(if(t.safe_score >= #{param.workerInfoGreenScore},1,0)),2),0) as lowRiskNum,
count(*) as workerNum
from worker_info t
JOIN enterprise_info ei on ei.id=t.enterprise_id
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 )))
where t.project_sn=#{param.projectSn} and t.inService_type = 1
group by mei.id
</select>
<select id="getAvgSafeScore" resultType="double"> <select id="getAvgSafeScore" resultType="double">
select ifnull(round(avg(safe_score),2),0) select ifnull(round(avg(safe_score),2),0)
from worker_info from worker_info

View File

@ -1164,7 +1164,6 @@ status 状态码 String 1表示成功其余表示失败
List<ProjectCompanyWorkTotal> list = baseMapper.queryAttendanceOfEachCompanyForMain(map); List<ProjectCompanyWorkTotal> list = baseMapper.queryAttendanceOfEachCompanyForMain(map);
vo.setAttendanceNum(list.stream().mapToInt(ProjectCompanyWorkTotal::getAttendancePersonNum).sum()); vo.setAttendanceNum(list.stream().mapToInt(ProjectCompanyWorkTotal::getAttendancePersonNum).sum());
vo.setProjectCompanyWorkTotalList(list); vo.setProjectCompanyWorkTotalList(list);
} else { } else {
//统计各企业出勤人数 //统计各企业出勤人数
List<ProjectCompanyWorkTotal> projectCompanyWorkTotals = workerInfoService.selectProjectComapnyWorkTotalList(map); List<ProjectCompanyWorkTotal> projectCompanyWorkTotals = workerInfoService.selectProjectComapnyWorkTotalList(map);
@ -1221,20 +1220,23 @@ status 状态码 String 1表示成功其余表示失败
SafetyPerformanceAnalysisVo vo = new SafetyPerformanceAnalysisVo(); SafetyPerformanceAnalysisVo vo = new SafetyPerformanceAnalysisVo();
vo.setList(vos); vo.setList(vos);
setTotalCount(vos, vo); setTotalCount(vos, vo);
List<SafetyPerformanceAnalysisVo> mains = vos.stream().filter(o -> o.getParentProjectEnterpriseId() == 0).collect(Collectors.toList()); Integer isCountMainEnterprise = MapUtils.getInteger(paramMap, "isCountMainEnterprise");
for (SafetyPerformanceAnalysisVo main : mains) { if (Objects.equals(isCountMainEnterprise, 1)) {
List<SafetyPerformanceAnalysisVo> subs = vos.stream().filter(o -> o.getAncestors().contains(main.getProjectEnterpriseId() + "")).collect(Collectors.toList()); List<SafetyPerformanceAnalysisVo> mains = vos.stream().filter(o -> o.getParentProjectEnterpriseId() == 0).collect(Collectors.toList());
for (SafetyPerformanceAnalysisVo sub : subs) { for (SafetyPerformanceAnalysisVo main : mains) {
main.setNotPerformNum(main.getNotPerformNum() + sub.getNotPerformNum()); List<SafetyPerformanceAnalysisVo> subs = vos.stream().filter(o -> o.getAncestors().contains(main.getProjectEnterpriseId() + "")).collect(Collectors.toList());
main.setInServiceNum(main.getInServiceNum() + sub.getInServiceNum()); for (SafetyPerformanceAnalysisVo sub : subs) {
main.setXmjlNotPerformNum(main.getXmjlNotPerformNum() + sub.getXmjlNotPerformNum()); main.setNotPerformNum(main.getNotPerformNum() + sub.getNotPerformNum());
main.setXmjlInServiceNum(main.getXmjlInServiceNum() + sub.getXmjlInServiceNum()); main.setInServiceNum(main.getInServiceNum() + sub.getInServiceNum());
main.setAqyNotPerformNum(main.getAqyNotPerformNum() + sub.getAqyNotPerformNum()); main.setXmjlNotPerformNum(main.getXmjlNotPerformNum() + sub.getXmjlNotPerformNum());
main.setAqyInServiceNum(main.getAqyInServiceNum() + sub.getAqyInServiceNum()); main.setXmjlInServiceNum(main.getXmjlInServiceNum() + sub.getXmjlInServiceNum());
main.setZlyNotPerformNum(main.getZlyNotPerformNum() + sub.getZlyNotPerformNum()); main.setAqyNotPerformNum(main.getAqyNotPerformNum() + sub.getAqyNotPerformNum());
main.setZlyInServiceNum(main.getZlyInServiceNum() + sub.getZlyInServiceNum()); main.setAqyInServiceNum(main.getAqyInServiceNum() + sub.getAqyInServiceNum());
main.setJlNotPerformNum(main.getJlNotPerformNum() + sub.getJlNotPerformNum()); main.setZlyNotPerformNum(main.getZlyNotPerformNum() + sub.getZlyNotPerformNum());
main.setJlInServiceNum(main.getJlInServiceNum() + sub.getJlInServiceNum()); main.setZlyInServiceNum(main.getZlyInServiceNum() + sub.getZlyInServiceNum());
main.setJlNotPerformNum(main.getJlNotPerformNum() + sub.getJlNotPerformNum());
main.setJlInServiceNum(main.getJlInServiceNum() + sub.getJlInServiceNum());
}
} }
} }
return vo; return vo;

View File

@ -996,12 +996,23 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
public Map<String, Object> selectWorkerManageEnterpriseStatistics(Map<String, Object> map) { public Map<String, Object> selectWorkerManageEnterpriseStatistics(Map<String, Object> map) {
Map<String, Object> data = new HashMap<>(16); Map<String, Object> data = new HashMap<>(16);
map = getCompanyParam(map); map = getCompanyParam(map);
map.put("enterpriseType", "1"); Integer isCountMainEnterprise = MapUtils.getInteger(map, "isCountMainEnterprise");
List<Map<String, Object>> enterpriseList = this.selectEnterpriseWorkerGroupTotal(map); if (Objects.equals(isCountMainEnterprise, 1)) {
map.put("enterpriseType", "2"); map.put("enterpriseType", "1");
List<Map<String, Object>> enterpriseManageList = workerInfoMapper.selectEnterpriseWorkerGroupTotal(map); List<Map<String, Object>> enterpriseList = this.selectParentEnterpriseWorkerGroupTotal(map);
data.put("enterpriseList", enterpriseList); map.put("enterpriseType", "2");
data.put("enterpriseManageList", enterpriseManageList); List<Map<String, Object>> enterpriseManageList = workerInfoMapper.selectParentEnterpriseWorkerGroupTotal(map);
data.put("enterpriseList", enterpriseList);
data.put("enterpriseManageList", enterpriseManageList);
} else {
map.put("enterpriseType", "1");
List<Map<String, Object>> enterpriseList = this.selectEnterpriseWorkerGroupTotal(map);
map.put("enterpriseType", "2");
List<Map<String, Object>> enterpriseManageList = workerInfoMapper.selectEnterpriseWorkerGroupTotal(map);
data.put("enterpriseList", enterpriseList);
data.put("enterpriseManageList", enterpriseManageList);
}
return data; return data;
} }
@ -1014,6 +1025,16 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
return mapList; return mapList;
} }
private List<Map<String, Object>> selectParentEnterpriseWorkerGroupTotal(Map<String, Object> map) {
List<Map<String, Object>> mapList = workerInfoMapper.selectParentEnterpriseWorkerGroupTotal(map);
int total = mapList.stream().mapToInt(m -> MapUtils.getInteger(m, "num")).sum();
for (Map<String, Object> m : mapList) {
m.put("ratio", NumberUtils.div(MapUtils.getInteger(m, "num") * 100.0, total * 1.0, 2));
}
return mapList;
}
@Override @Override
public Map<String, Object> selectWorkerManagePresenceStatistics(Map<String, Object> map) { public Map<String, Object> selectWorkerManagePresenceStatistics(Map<String, Object> map) {
Map<String, Object> data = new HashMap<>(16); Map<String, Object> data = new HashMap<>(16);
@ -1258,11 +1279,21 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
List<EntityMap> list = workerInfoMapper.selectProjectEnterpriseList(map); List<EntityMap> list = workerInfoMapper.selectProjectEnterpriseList(map);
if (list != null && list.size() > 0) { if (list != null && list.size() > 0) {
//统计各企业出勤人数 //统计各企业出勤人数
List<Map<String, Object>> attendancCountList = workerInfoMapper.selectEnterpriseAttendanceWorkerCount(map); List<Map<String, Object>> attendancCountList = new ArrayList<>();
//统计各企业在册人数 //统计各企业在册人数
List<Map<String, Object>> workerCountList = workerInfoMapper.selectProjectEnterpriseWorkerCount(map); List<Map<String, Object>> workerCountList = new ArrayList<>();
//统计企业在场人数 //统计企业在场人数
List<Map<String, Object>> presenceList = workerInfoMapper.selectEnterprisePresenceWorkerCount(map); List<Map<String, Object>> presenceList = new ArrayList<>();
Integer isCountMainEnterprise = MapUtils.getInteger(map, "isCountMainEnterprise");
if (Objects.equals(isCountMainEnterprise, 1)) {
attendancCountList = workerInfoMapper.selectParentEnterpriseAttendanceWorkerCount(map);
workerCountList = workerInfoMapper.selectParentProjectEnterpriseWorkerCount(map);
presenceList = workerInfoMapper.selectParentEnterprisePresenceWorkerCount(map);
} else {
attendancCountList = workerInfoMapper.selectEnterpriseAttendanceWorkerCount(map);
workerCountList = workerInfoMapper.selectProjectEnterpriseWorkerCount(map);
presenceList = workerInfoMapper.selectEnterprisePresenceWorkerCount(map);
}
Map<String, Object> attendancMap = getEnterpriseToMap(attendancCountList); Map<String, Object> attendancMap = getEnterpriseToMap(attendancCountList);
Map<String, Object> workerMap = getEnterpriseToMap(workerCountList); Map<String, Object> workerMap = getEnterpriseToMap(workerCountList);
Map<String, Object> presenceMap = getEnterpriseToMap(presenceList); Map<String, Object> presenceMap = getEnterpriseToMap(presenceList);
@ -2372,14 +2403,24 @@ public class WorkerInfoServiceImpl extends ServiceImpl<WorkerInfoMapper, WorkerI
@Override @Override
public List<TrendOneVo> statsEnterprise(Map<String, Object> map) { public List<TrendOneVo> statsEnterprise(Map<String, Object> map) {
return baseMapper.statsEnterprise(map); Integer isCountMainEnterprise = MapUtils.getInteger(map, "isCountMainEnterprise");
if (Objects.equals(isCountMainEnterprise, 1)) {
return baseMapper.statsParentEnterprise(map);
} else {
return baseMapper.statsEnterprise(map);
}
} }
@Override @Override
public List<StatsTrendVo> statsEnterpriseRisk(Map<String, Object> map) { public List<StatsTrendVo> statsEnterpriseRisk(Map<String, Object> map) {
map.put("workerInfoRedScore", PropertiesUtil.getWorkerInfoRedScore()); map.put("workerInfoRedScore", PropertiesUtil.getWorkerInfoRedScore());
map.put("workerInfoGreenScore", PropertiesUtil.getWorkerInfoGreenScore()); map.put("workerInfoGreenScore", PropertiesUtil.getWorkerInfoGreenScore());
return baseMapper.statsEnterpriseRisk(map); Integer isCountMainEnterprise = MapUtils.getInteger(map, "isCountMainEnterprise");
if (Objects.equals(isCountMainEnterprise, 1)) {
return baseMapper.statsParentEnterpriseRisk(map);
} else {
return baseMapper.statsEnterpriseRisk(map);
}
} }
@Override @Override

View File

@ -103,4 +103,7 @@ public class XzProjectOrg implements Serializable {
@TableField(exist = false) @TableField(exist = false)
private List<XzProjectOrg> children; private List<XzProjectOrg> children;
@TableField(exist = false)
private List<String> childrenName;
} }

View File

@ -197,6 +197,14 @@ public interface XzSecurityQualityInspectionRecordMapper extends BaseMapper<XzSe
*/ */
Page<StatsByChangeIdVo> statsByChangeId(@Param("param") Map<String, Object> paramMap, Page page); Page<StatsByChangeIdVo> statsByChangeId(@Param("param") Map<String, Object> paramMap, Page page);
/**
* 整改人统计
*
* @param paramMap
* @param page
* @return
*/
Page<StatsByChangeIdVo> statsByParentChangeId(@Param("param") Map<String, Object> paramMap, Page page);
/** /**
* 统计隐患等级 * 统计隐患等级
* *
@ -214,6 +222,15 @@ public interface XzSecurityQualityInspectionRecordMapper extends BaseMapper<XzSe
*/ */
Page<StatsByInspectManVo> statsByInspectManVo(@Param("param") Map<String, Object> paramMap, Page page); Page<StatsByInspectManVo> statsByInspectManVo(@Param("param") Map<String, Object> paramMap, Page page);
/**
* 检查人统计
*
* @param paramMap
* @param page
* @return
*/
Page<StatsByInspectManVo> statsByParentInspectManVo(@Param("param") Map<String, Object> paramMap, Page page);
/** /**
* 按分包单位统计 * 按分包单位统计
* *
@ -223,6 +240,15 @@ public interface XzSecurityQualityInspectionRecordMapper extends BaseMapper<XzSe
*/ */
Page<StatsByEnterpriseVo> statsByEnterprise(@Param("param") Map<String, Object> paramMap, Page page); Page<StatsByEnterpriseVo> statsByEnterprise(@Param("param") Map<String, Object> paramMap, Page page);
/**
* 按总包单位统计
*
* @param paramMap
* @param page
* @return
*/
Page<StatsByEnterpriseVo> statsByParentEnterprise(@Param("param") Map<String, Object> paramMap, Page page);
/** /**
* 隐患类型分析 * 隐患类型分析
* *

View File

@ -664,6 +664,32 @@
order by rectifiedNum desc) t order by rectifiedNum desc) t
</select> </select>
<select id="statsByParentChangeId" resultType="com.zhgd.xmgl.modules.xz.security.entity.vo.StatsByChangeIdVo">
select t.*,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100,
2) rectifiedNumRatio,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNumTimely, 0) / IFNULL(totalNum, 0), 4), 0) * 100, 2)
rectifiedNumRatioTimely
from (SELECT count(*) totalNum,
<include refid="selectShow">
</include>
su.real_name as workerName
from xz_security_quality_inspection_record t
JOIN enterprise_info ei on ei.id=t.enterprise_id
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 )))
join system_user su on su.user_id = t.change_id
WHERE record_type = 1
and t.status != 6
and t.project_sn = #{param.projectSn}
<include refid="whereCondition">
</include>
group by t.change_id
order by rectifiedNum desc) t
</select>
<select id="countDangerLevel" resultType="com.zhgd.xmgl.base.entity.vo.SectorOneVo"> <select id="countDangerLevel" resultType="com.zhgd.xmgl.base.entity.vo.SectorOneVo">
select count(*) count, t.level as enumType select count(*) count, t.level as enumType
from xz_security_quality_inspection_record t from xz_security_quality_inspection_record t
@ -696,6 +722,32 @@
order by rectifiedNum desc) t order by rectifiedNum desc) t
</select> </select>
<select id="statsByParentInspectManVo" resultType="com.zhgd.xmgl.modules.xz.security.entity.vo.StatsByInspectManVo">
select t.*,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100,2) as rectifiedNumRatio,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNumTimely, 0) / IFNULL(totalNum, 0), 4), 0) * 100, 2) as
rectifiedNumRatioTimely
from (SELECT count(*) totalNum,
count(*) createDangerNum,
<include refid="selectShow">
</include>
su.real_name as workerName
from xz_security_quality_inspection_record t
JOIN enterprise_info ei on ei.id=t.enterprise_id
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 system_user su on su.user_id = t.inspect_man_id
WHERE record_type = 1
and t.status != 6
and t.project_sn = #{param.projectSn}
<include refid="whereCondition">
</include>
group by t.inspect_man_id
order by rectifiedNum desc) t
</select>
<select id="statsByEnterprise" resultType="com.zhgd.xmgl.modules.xz.security.entity.vo.StatsByEnterpriseVo"> <select id="statsByEnterprise" resultType="com.zhgd.xmgl.modules.xz.security.entity.vo.StatsByEnterpriseVo">
select t.*, select t.*,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100, round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100,
@ -717,6 +769,31 @@
order by rectifiedNum desc) t order by rectifiedNum desc) t
</select> </select>
<select id="statsByParentEnterprise" resultType="com.zhgd.xmgl.modules.xz.security.entity.vo.StatsByEnterpriseVo">
select t.*,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNum, 0) / IFNULL(totalNum, 0), 4), 0) * 100,
2) rectifiedNumRatio,
round(IFNULL(TRUNCATE(IFNULL(t.rectifiedNumTimely, 0) / IFNULL(totalNum, 0), 4), 0) * 100, 2)
rectifiedNumRatioTimely
from (SELECT count(*) as totalNum,
<include refid="selectShow">
</include>
mei.enterprise_name
from xz_security_quality_inspection_record t
JOIN enterprise_info ei on ei.id=t.enterprise_id
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 )))
WHERE record_type = 1
and t.status != 6
and t.project_sn = #{param.projectSn}
<include refid="whereCondition">
</include>
group by mei.id
order by rectifiedNum desc) t
</select>
<select id="statsDangerType" resultType="com.zhgd.xmgl.base.entity.vo.SectorOneVo"> <select id="statsDangerType" resultType="com.zhgd.xmgl.base.entity.vo.SectorOneVo">
select count(*) count, SUBSTRING_INDEX(t.danger_item_content, '/', 1) as name select count(*) count, SUBSTRING_INDEX(t.danger_item_content, '/', 1) as name
from xz_security_quality_inspection_record t from xz_security_quality_inspection_record t

View File

@ -548,7 +548,13 @@ public class XzSecurityQualityInspectionRecordServiceImpl extends ServiceImpl<Xz
@Override @Override
public Page<StatsByChangeIdVo> statsByChangeId(Map<String, Object> paramMap) { public Page<StatsByChangeIdVo> statsByChangeId(Map<String, Object> paramMap) {
Page page = PageUtil.getPage(paramMap); Page page = PageUtil.getPage(paramMap);
return baseMapper.statsByChangeId(paramMap, page); Integer isCountMainEnterprise = MapUtils.getInteger(paramMap, "isCountMainEnterprise");
if (Objects.equals(isCountMainEnterprise, 1)) {
return baseMapper.statsByParentChangeId(paramMap, page);
} else {
return baseMapper.statsByChangeId(paramMap, page);
}
} }
@Override @Override
@ -657,13 +663,24 @@ public class XzSecurityQualityInspectionRecordServiceImpl extends ServiceImpl<Xz
@Override @Override
public Page<StatsByInspectManVo> statsByInspectMan(Map<String, Object> paramMap) { public Page<StatsByInspectManVo> statsByInspectMan(Map<String, Object> paramMap) {
Page page = PageUtil.getPage(paramMap); Page page = PageUtil.getPage(paramMap);
return baseMapper.statsByInspectManVo(paramMap, page); Integer isCountMainEnterprise = MapUtils.getInteger(paramMap, "isCountMainEnterprise");
if (Objects.equals(isCountMainEnterprise, 1)) {
return baseMapper.statsByParentInspectManVo(paramMap, page);
} else {
return baseMapper.statsByInspectManVo(paramMap, page);
}
} }
@Override @Override
public Page<StatsByEnterpriseVo> statsByEnterprise(Map<String, Object> paramMap) { public Page<StatsByEnterpriseVo> statsByEnterprise(Map<String, Object> paramMap) {
Page page = PageUtil.getPage(paramMap); Page page = PageUtil.getPage(paramMap);
return baseMapper.statsByEnterprise(paramMap, page); Integer isCountMainEnterprise = MapUtils.getInteger(paramMap, "isCountMainEnterprise");
if (Objects.equals(isCountMainEnterprise, 1)) {
return baseMapper.statsByParentEnterprise(paramMap, page);
} else {
return baseMapper.statsByEnterprise(paramMap, page);
}
} }
@Override @Override

View File

@ -2,6 +2,7 @@ package com.zhgd.xmgl.task;
import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
@ -18,9 +19,11 @@ import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatData;
import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev; import com.zhgd.xmgl.modules.safetyhat.entity.SafetyHatDev;
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDataMapper; import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDataMapper;
import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDevMapper; import com.zhgd.xmgl.modules.safetyhat.mapper.SafetyHatDevMapper;
import com.zhgd.xmgl.modules.safetyhat.service.ISafetyHatDevService;
import com.zhgd.xmgl.util.RundeSafeyHatUtils; import com.zhgd.xmgl.util.RundeSafeyHatUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.javacrumbs.shedlock.core.SchedulerLock; import net.javacrumbs.shedlock.core.SchedulerLock;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -50,6 +53,8 @@ public class SafetyHatTask {
@Autowired @Autowired
SafetyHatDevMapper safetyHatDevMapper; SafetyHatDevMapper safetyHatDevMapper;
@Autowired @Autowired
ISafetyHatDevService safetyHatDevService;
@Autowired
SafetyHatDataMapper safetyHatDataMapper; SafetyHatDataMapper safetyHatDataMapper;
@Autowired @Autowired
WebSocketContainer webSocketContainer; WebSocketContainer webSocketContainer;
@ -284,5 +289,25 @@ public class SafetyHatTask {
return client; return client;
} }
/**
* 定时2分钟修改安全帽状态
*/
@Scheduled(cron = "0 */2 * * * ?")
@SchedulerLock(name = "updateHelmetState", lockAtMostFor = 1000 * 60 * 2, lockAtLeastFor = 1000 * 10)
@RequestMapping("updateHelmetState")
public void updateHelmetState() {
List<SafetyHatDev> safetyHatDevs = safetyHatDevMapper.selectList(null);
for (SafetyHatDev safetyHatDev : safetyHatDevs) {
if (safetyHatDev.getOnline() == 1) {
if (safetyHatDev.getHeartbeatTime() == null) {
safetyHatDev.setOnline(0);
} else {
if (DateUtil.between(safetyHatDev.getHeartbeatTime(), new Date(), DateUnit.MINUTE) > 10) {
safetyHatDev.setOnline(0);
}
}
}
}
safetyHatDevService.updateBatchById(safetyHatDevs);
}
} }