Commit fb8bb1b1 authored by 鲁鸿波's avatar 鲁鸿波

监督检查统计开发

parent 26da2711
...@@ -48,4 +48,10 @@ public class THazardWorkPlanCheckParam extends THazardWorkPlanCheck { ...@@ -48,4 +48,10 @@ public class THazardWorkPlanCheckParam extends THazardWorkPlanCheck {
@ApiModelProperty(value = "检查结束时间") @ApiModelProperty(value = "检查结束时间")
private String endTime; private String endTime;
@ApiModelProperty(value = "本机构数据")
private boolean thisOrg;
@ApiModelProperty(value = "orgId(下钻条件传)")
private String orgId;
} }
...@@ -6,8 +6,11 @@ import com.alibaba.excel.EasyExcelFactory; ...@@ -6,8 +6,11 @@ import com.alibaba.excel.EasyExcelFactory;
import com.alibaba.excel.ExcelWriter; import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.write.metadata.WriteSheet; import com.alibaba.excel.write.metadata.WriteSheet;
import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.testor.biz.sys.org.model.domain.SysOrg;
import com.testor.biz.sys.org.service.SysOrgService;
import com.testor.module.emergency.model.vo.TContingencyPlanVO; import com.testor.module.emergency.model.vo.TContingencyPlanVO;
import com.testor.module.hazard.dao.THazardWorkPlanCheckDao; import com.testor.module.hazard.dao.THazardWorkPlanCheckDao;
import com.testor.module.hazard.model.domain.THazardWorkPlan; import com.testor.module.hazard.model.domain.THazardWorkPlan;
...@@ -19,11 +22,17 @@ import com.testor.module.hazard.model.vo.HazardWorkPlanCheckProblemTypeStatistic ...@@ -19,11 +22,17 @@ import com.testor.module.hazard.model.vo.HazardWorkPlanCheckProblemTypeStatistic
import com.testor.module.hazard.model.vo.HazardWorkPlanCheckVO; import com.testor.module.hazard.model.vo.HazardWorkPlanCheckVO;
import com.testor.module.hazard.service.THazardWorkPlanCheckService; import com.testor.module.hazard.service.THazardWorkPlanCheckService;
import com.testor.module.notice.dao.TSysOrgDao; import com.testor.module.notice.dao.TSysOrgDao;
import com.testor.module.safe.model.domain.TSafeHazardOrg;
import com.testor.module.safe.model.vo.TSafeHazardExportVO; import com.testor.module.safe.model.vo.TSafeHazardExportVO;
import com.testor.module.safe.model.vo.TSafeHazardOrgStatisticsVO;
import com.testor.module.safe.service.impl.TSafeHazardOrgServiceImpl; import com.testor.module.safe.service.impl.TSafeHazardOrgServiceImpl;
import com.tongtech.tfw.backend.common.biz.constants.BizConstants;
import com.tongtech.tfw.backend.common.context.ContextUtils;
import com.tongtech.tfw.backend.core.helper.IdHelper; import com.tongtech.tfw.backend.core.helper.IdHelper;
import com.tongtech.tfw.backend.core.helper.ObjectHelper; import com.tongtech.tfw.backend.core.helper.ObjectHelper;
import com.tongtech.tfw.backend.core.helper.StringHelper;
import com.tongtech.tfw.backend.core.helper.bean.BeanHelper; import com.tongtech.tfw.backend.core.helper.bean.BeanHelper;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -38,6 +47,7 @@ import java.net.URLEncoder; ...@@ -38,6 +47,7 @@ import java.net.URLEncoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* 危险作业计划监督检查Service业务层处理 * 危险作业计划监督检查Service业务层处理
...@@ -57,6 +67,9 @@ public class THazardWorkPlanCheckServiceImpl extends SuperServiceImpl<THazardWor ...@@ -57,6 +67,9 @@ public class THazardWorkPlanCheckServiceImpl extends SuperServiceImpl<THazardWor
@Autowired @Autowired
private TSysOrgDao orgDao; private TSysOrgDao orgDao;
@Autowired
private SysOrgService sysOrgService;
@Override @Override
public Page<THazardWorkPlanCheck> selectTHazardWorkPlanCheckList(THazardWorkPlanCheckParam tHazardWorkPlanCheckParam) { public Page<THazardWorkPlanCheck> selectTHazardWorkPlanCheckList(THazardWorkPlanCheckParam tHazardWorkPlanCheckParam) {
IPage<THazardWorkPlanCheck> page = new Page<>(Long.valueOf(tHazardWorkPlanCheckParam.getPage()), Long.valueOf(tHazardWorkPlanCheckParam.getLimit())); IPage<THazardWorkPlanCheck> page = new Page<>(Long.valueOf(tHazardWorkPlanCheckParam.getPage()), Long.valueOf(tHazardWorkPlanCheckParam.getLimit()));
...@@ -139,7 +152,55 @@ public class THazardWorkPlanCheckServiceImpl extends SuperServiceImpl<THazardWor ...@@ -139,7 +152,55 @@ public class THazardWorkPlanCheckServiceImpl extends SuperServiceImpl<THazardWor
@Override @Override
public List<HazardWorkPlanCheckComplianceStatisticsVO> selectCheckComplianceStatistics(THazardWorkPlanCheckParam tHazardWorkPlanCheckParam) { public List<HazardWorkPlanCheckComplianceStatisticsVO> selectCheckComplianceStatistics(THazardWorkPlanCheckParam tHazardWorkPlanCheckParam) {
return this.baseMapper.selectCheckComplianceStatistics(tHazardWorkPlanCheckParam);
String orgId = tHazardWorkPlanCheckParam.getOrgId();
if (StringHelper.isEmpty(orgId)) {
// 获取登录企业
orgId = ContextUtils.getLoginUser().getOrgId();
}
String finalOrgId = orgId;
List<String> orgIds = new ArrayList<>();
if (tHazardWorkPlanCheckParam.getOrgIdList() != null && tHazardWorkPlanCheckParam.getOrgIdList().size() > 0) {
orgIds = tHazardWorkPlanCheckParam.getOrgIdList();
}else {
//如果只查当前机构数据
if (tHazardWorkPlanCheckParam.isThisOrg()) {
orgIds.add(orgId);
} else {
List<String> ids = sysOrgService.list(new QueryWrapper<SysOrg>().eq(SysOrg.PARENT_ID, finalOrgId).ne(SysOrg.STATUS, BizConstants.STATUS_DELETE).eq(SysOrg.IS_DEPT, 0).orderByAsc("tree_sort")).stream().map(SysOrg::getOrgId).collect(Collectors.toList());
//如果下级机构为空
if (ids == null || ids.size() == 0) {
//存入当前机构
ids.add(finalOrgId);
}
orgIds.addAll(ids);
}
}
List<HazardWorkPlanCheckComplianceStatisticsVO> hazardWorkPlanCheckComplianceStatisticsVOS = new ArrayList<>();
orgIds.stream().forEach(item -> {
HazardWorkPlanCheckComplianceStatisticsVO hazardWorkPlanCheckComplianceStatisticsVO = new HazardWorkPlanCheckComplianceStatisticsVO();
List<String> ids = new ArrayList<>();
if (tHazardWorkPlanCheckParam.isThisOrg()){
ids.add(finalOrgId);
}else {
//如果下级机构为空
ids = sysOrgService.list(new QueryWrapper<SysOrg>().and(sysOrgQueryWrapper -> sysOrgQueryWrapper.like(SysOrg.PARENT_IDS, item).or().eq(SysOrg.ORG_ID,item))
.ne(SysOrg.STATUS, BizConstants.STATUS_DELETE).eq(SysOrg.IS_DEPT, 0).orderByAsc("tree_sort")).stream().map(SysOrg::getOrgId).collect(Collectors.toList());
if (ids == null || ids.size() == 0) {
//存入当前机构
ids.add(finalOrgId);
}
}
hazardWorkPlanCheckComplianceStatisticsVO = this.baseMapper.selectCheckComplianceStatistics(tHazardWorkPlanCheckParam).get(0);
hazardWorkPlanCheckComplianceStatisticsVO.setOrgId(item);
hazardWorkPlanCheckComplianceStatisticsVO.setOrgName(sysOrgService.getById(item).getOrgName());
tHazardWorkPlanCheckParam.setOrgIdList(ids);
hazardWorkPlanCheckComplianceStatisticsVOS.add(hazardWorkPlanCheckComplianceStatisticsVO);
});
return hazardWorkPlanCheckComplianceStatisticsVOS;
} }
@Override @Override
......
...@@ -53,8 +53,8 @@ spring: ...@@ -53,8 +53,8 @@ spring:
kingbase: kingbase:
driver-class-name: com.kingbase8.Driver driver-class-name: com.kingbase8.Driver
#部署用内网 #部署用内网
url: jdbc:kingbase8://172.31.0.2:54322/public?currentSchema=public&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8 #url: jdbc:kingbase8://172.31.0.2:54322/public?currentSchema=public&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
#开发用外网 #开发用外网
#url: jdbc:kingbase8://101.126.159.207:54322/public?currentSchema=public&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8 url: jdbc:kingbase8://101.126.159.207:54322/public?currentSchema=public&zeroDateTimeBehavior=convertToNull&useUnicode=true&characterEncoding=utf-8
username: system username: system
password: ZLmy654321 password: ZLmy654321
\ No newline at end of file
...@@ -184,15 +184,20 @@ ...@@ -184,15 +184,20 @@
<select id="selectCheckComplianceStatistics" resultType="com.testor.module.hazard.model.vo.HazardWorkPlanCheckComplianceStatisticsVO"> <select id="selectCheckComplianceStatistics" resultType="com.testor.module.hazard.model.vo.HazardWorkPlanCheckComplianceStatisticsVO">
SELECT SELECT
COUNT(*) AS checkCount, COALESCE(COUNT(*), 0) AS checkCount,
SUM(CASE WHEN hwpc.is_compliant = 1 THEN 1 ELSE 0 END) AS checkQualifiedCount, COALESCE(SUM(CASE WHEN hwpc.is_compliant = 1 THEN 1 ELSE 0 END), 0) AS checkQualifiedCount,
ROUND( COALESCE(ROUND(
SUM(CASE WHEN hwpc.is_compliant = 1 THEN 1 ELSE 0 END) * 100.0 / COUNT(*), CASE
2 WHEN COUNT(*) = 0 THEN 0
) AS complianceRatePercent ELSE SUM(CASE WHEN hwpc.is_compliant = 1 THEN 1 ELSE 0 END) * 100.0 / COUNT(*)
FROM t_hazard_work_plan_check hwpc END,
left join t_hazard_work_plan wpc on hwpc.plan_id = wpc.id 2
where hwpc.status = '0' ), 0) AS complianceRatePercent
FROM
t_hazard_work_plan_check hwpc
LEFT JOIN t_hazard_work_plan hwp ON hwpc.plan_id = hwp.id
WHERE
hwpc.status = '0'
<if test="param.orgIdList != null and param.orgIdList.size()>0"> <if test="param.orgIdList != null and param.orgIdList.size()>0">
and ( and (
<foreach item="id" collection="param.orgIdList" separator=" OR "> <foreach item="id" collection="param.orgIdList" separator=" OR ">
...@@ -218,6 +223,7 @@ ...@@ -218,6 +223,7 @@
select dd.dict_value problemName,count(*) problemCount select dd.dict_value problemName,count(*) problemCount
from t_sys_dict_data dd from t_sys_dict_data dd
left join t_hazard_work_plan_check hwpc on hwpc.problem_type = dd.dict_data_id left join t_hazard_work_plan_check hwpc on hwpc.problem_type = dd.dict_data_id
LEFT JOIN t_hazard_work_plan hwp ON hwpc.plan_id = hwp.id
where hwpc.status = '0' AND hwpc.is_compliant = 0 AND hwpc.problem_type IS NOT NULL where hwpc.status = '0' AND hwpc.is_compliant = 0 AND hwpc.problem_type IS NOT NULL
<if test="param.orgIdList != null and param.orgIdList.size()>0"> <if test="param.orgIdList != null and param.orgIdList.size()>0">
and ( and (
...@@ -251,12 +257,11 @@ ...@@ -251,12 +257,11 @@
#{param.endTime}::timestamp, #{param.endTime}::timestamp,
'1 day'::interval '1 day'::interval
)::date AS timeStr) dates )::date AS timeStr) dates
LEFT JOIN LEFT JOIN t_hazard_work_plan_check hwpc ON hwpc.check_time::date = dates.timeStr
t_hazard_work_plan_check hwpc
ON hwpc.check_time::date = dates.timeStr
AND hwpc.status = '0' AND hwpc.status = '0'
AND hwpc.is_compliant = 0 AND hwpc.is_compliant = 0
AND hwpc.problem_type IS NOT NULL AND hwpc.problem_type IS NOT NULL
LEFT JOIN t_hazard_work_plan hwp ON hwpc.plan_id = hwp.id
<if test="param.orgIdList != null and param.orgIdList.size()>0"> <if test="param.orgIdList != null and param.orgIdList.size()>0">
and ( and (
<foreach item="id" collection="param.orgIdList" separator=" OR "> <foreach item="id" collection="param.orgIdList" separator=" OR ">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment