新增统计缓存

This commit is contained in:
wanggeng888 2021-04-06 21:16:33 +08:00
parent e6c7339c71
commit 1ce135f78e
7 changed files with 77 additions and 60 deletions

View File

@ -1,37 +1,14 @@
package com.cm.inspection;
import com.alibaba.fastjson.JSONArray;
import com.cm.common.config.properties.ApiPathProperties;
import com.cm.common.constants.ISystemConstant;
import com.cm.common.exception.AccessTokenException;
import com.cm.common.exception.SearchException;
import com.cm.common.plugin.IApiConsts;
import com.cm.common.plugin.oauth.service.user.IUserService;
import com.cm.common.plugin.oauth.token.ClientTokenManager;
import com.cm.common.plugin.pojo.bos.UserResourceBO;
import com.cm.common.plugin.utils.RestTemplateUtil;
import com.cm.inspection.pojo.dtos.check.CheckDTO;
import com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO;
import com.cm.inspection.service.check.ICheckService;
import com.cm.inspection.service.gridpersonnel.IGridPersonnelService;
import org.activiti.engine.*;
import org.activiti.engine.runtime.ProcessInstance;
import org.apache.commons.lang3.StringUtils;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import com.cm.inspection.service.count.ICountService;
import org.mybatis.spring.annotation.MapperScan;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.security.core.parameters.P;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.*;
/**
* 隐患排查系统
*
@ -48,4 +25,6 @@ public class InspectionApplication {
SpringApplication.run(InspectionApplication.class, args);
}
}

View File

@ -1,8 +1,11 @@
package com.cm.inspection.startup;
import com.cm.common.utils.DateUtil;
import com.cm.inspection.service.count.ICountService;
import com.cm.inspection.service.dingding.IDingDingMsgService;
import com.cm.inspection.service.dischargepermit.IDischargePermitService;
import com.cm.inspection.service.eiareport.IEiaReportService;
import com.cm.inspection.service.enterprise.IEnterpriseService;
import com.cm.inspection.service.process.IProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@ -11,6 +14,9 @@ import org.springframework.boot.ApplicationRunner;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
/**
* When you feel like quitting. Think about why you started
* 当你想要放弃的时候想想当初你为何开始
@ -34,17 +40,40 @@ public class StartUp implements ApplicationRunner {
private IDischargePermitService dischargePermitService;
@Value("${version:1}")
private Integer version;
@Autowired
private ICountService countService;
@Autowired
private IEnterpriseService enterpriseService;
@Override
public void run(ApplicationArguments args) throws Exception {
int startYear = 2020;
int currentYear = Integer.parseInt(DateUtil.getYear());
// 部署流程
processService.deployProcess("check-self", "网格员检查上报流程");
// 初始化统计防止第一次打开慢
Map<String, Object> params = new HashMap<>();
enterpriseService.countEnterpriseByNature(params);
for (int year = currentYear; year >= startYear; year--) {
final String yearStr = String.valueOf(year);
new Thread(() -> {
try {
countService.countCheckDetailTable("", 3, yearStr);
countService.countHiddenDangerReportDetail("", 3, yearStr);
} catch (Exception e) {
e.printStackTrace();
}
}).start();
}
}
/**
* 每天10点统计环评报告排污许可证
*/
@Scheduled(cron = "0 0/1 * * * ?")
@Scheduled(cron = "0 0 10 * * ?")
public void noticeReport() {
if (version == 1) {
return;

View File

@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cm.inspection.dao.check.ICheckDao">
<cache/>
<cache flushInterval="3600000"/>
<resultMap id="checkDTO" type="com.cm.inspection.pojo.dtos.check.CheckDTO">
<id column="check_id" property="checkId"/>

View File

@ -2,6 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cm.inspection.dao.checkplan.ICheckPlanDao">
<cache flushInterval="3600000"/>
<resultMap id="checkPlanDTO" type="com.cm.inspection.pojo.dtos.checkplan.CheckPlanDTO">
<id column="check_plan_id" property="checkPlanId"/>
<result column="check_plan_type" property="checkPlanType"/>
@ -12,7 +14,7 @@
</resultMap>
<!-- 新增检查计划 -->
<insert id="saveCheckPlan" parameterType="map">
<insert id="saveCheckPlan" parameterType="map" flushCache="true">
INSERT INTO gen_check_plan(
check_plan_id,
check_plan_type,
@ -41,7 +43,7 @@
</insert>
<!-- 删除检查计划 -->
<update id="removeCheckPlan" parameterType="map">
<update id="removeCheckPlan" parameterType="map" flushCache="true">
UPDATE
gen_check_plan
SET
@ -56,7 +58,7 @@
</update>
<!-- 修改检查计划 -->
<update id="updateCheckPlan" parameterType="map">
<update id="updateCheckPlan" parameterType="map" flushCache="true">
UPDATE
gen_check_plan
SET
@ -82,7 +84,7 @@
</update>
<!-- 检查计划详情 -->
<select id="getCheckPlan" parameterType="map" resultMap="checkPlanDTO">
<select id="getCheckPlan" parameterType="map" resultMap="checkPlanDTO" useCache="false">
SELECT
t1.check_plan_type,
t1.check_plan_year,
@ -112,7 +114,7 @@
</select>
<!-- 检查计划列表 -->
<select id="listCheckPlan" parameterType="map" resultMap="checkPlanDTO">
<select id="listCheckPlan" parameterType="map" resultMap="checkPlanDTO" useCache="true">
SELECT
t1.check_plan_type,
t1.check_plan_year,
@ -151,7 +153,7 @@
</select>
<!-- 统计计划总数 -->
<select id="countCheckPlan" parameterType="map" resultType="java.lang.Integer">
<select id="countCheckPlan" parameterType="map" resultType="java.lang.Integer" useCache="true">
SELECT
COUNT(*)
FROM
@ -184,7 +186,7 @@
</select>
<!-- 统计计划书总数 -->
<select id="countTotalCheckPlan" parameterType="map" resultType="java.lang.Integer">
<select id="countTotalCheckPlan" parameterType="map" resultType="java.lang.Integer" useCache="true">
SELECT
SUM(check_plan_count)
FROM

View File

@ -2,6 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cm.inspection.dao.enterpriseofgridoperator.IEnterpriseOfGridOperatorDao">
<cache flushInterval="3600000"/>
<resultMap id="enterpriseOfGridOperatorDTO" type="com.cm.inspection.pojo.dtos.enterpriseofgridoperator.EnterpriseOfGridOperatorDTO">
<id column="enterprise_of_grid_operator_id" property="enterpriseOfGridOperatorId"/>
<result column="user_id" property="userId"/>
@ -156,7 +158,7 @@
</select>
<!-- 网格员的企业列表 -->
<select id="listEnterpriseOfGridOperator" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
<select id="listEnterpriseOfGridOperator" parameterType="map" resultMap="enterpriseOfGridOperatorDTO" useCache="true">
SELECT
t1.user_id,
t1.enterprise_id,
@ -244,7 +246,7 @@
</select>
<!-- 网格员的企业列表通过用户ID,性能问题废弃 -->
<select id="listEnterpriseOfGridOperatorByUserIdDiscard" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
<select id="listEnterpriseOfGridOperatorByUserIdDiscard" parameterType="map" resultMap="enterpriseOfGridOperatorDTO" useCache="true">
SELECT
t1.enterprise_id,
t1.name name_join_by_enterprise_id,
@ -322,7 +324,7 @@
</select>
<!-- 网格员的企业列表通过用户ID -->
<select id="listEnterpriseOfGridOperatorByUserId" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
<select id="listEnterpriseOfGridOperatorByUserId" parameterType="map" resultMap="enterpriseOfGridOperatorDTO" useCache="true">
SELECT
t1.enterprise_id,
t1.name name_join_by_enterprise_id,
@ -416,7 +418,7 @@
</select>
<!-- 网格员的企业列表通过用户ID和企业ID -->
<select id="listEnterpriseOfGridOperatorByUserIdAndEnterpriseId" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
<select id="listEnterpriseOfGridOperatorByUserIdAndEnterpriseId" parameterType="map" resultMap="enterpriseOfGridOperatorDTO" useCache="true">
SELECT
user_id
enterprise_id
@ -429,7 +431,7 @@
</select>
<!-- 统计绑定的企业 -->
<select id="countEnterpriseOfGridOperator" parameterType="map" resultType="Integer">
<select id="countEnterpriseOfGridOperator" parameterType="map" resultType="Integer" useCache="true">
SELECT
COUNT(*)
FROM
@ -449,7 +451,7 @@
</select>
<!-- 网格员列表 -->
<select id="listGridPersonnel" parameterType="map" resultMap="gridPersonnelDTO">
<select id="listGridPersonnel" parameterType="map" resultMap="gridPersonnelDTO" useCache="true">
SELECT
jt1.user_id,
jt1.area1,
@ -478,7 +480,7 @@
</select>
<!-- 未认领企业列表 -->
<select id="listUnclaimedEnterprise" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
<select id="listUnclaimedEnterprise" parameterType="map" resultMap="enterpriseOfGridOperatorDTO" useCache="true">
SELECT
t1.enterprise_id,
t1.name name_join_by_enterprise_id,
@ -550,7 +552,7 @@
</select>
<!-- 统计未认领企业 -->
<select id="countUnclaimedEnterprise" parameterType="map" resultType="java.lang.Integer">
<select id="countUnclaimedEnterprise" parameterType="map" resultType="java.lang.Integer" useCache="true">
SELECT
COUNT(*)
FROM
@ -597,7 +599,7 @@
</select>
<!-- 统计认领企业 -->
<select id="countClaimedEnterprise" parameterType="map" resultType="java.lang.Integer">
<select id="countClaimedEnterprise" parameterType="map" resultType="java.lang.Integer" useCache="true">
SELECT
COUNT(*)
FROM
@ -644,7 +646,7 @@
</select>
<!-- 统计企业 -->
<select id="countEnterpriseOfGridOperatorSimple" parameterType="map" resultType="java.lang.Integer">
<select id="countEnterpriseOfGridOperatorSimple" parameterType="map" resultType="java.lang.Integer" useCache="true">
SELECT
COUNT(*)
FROM
@ -666,7 +668,7 @@
</select>
<!-- 企业网格员列表(简单格式) -->
<select id="listSimple" parameterType="map" resultMap="enterpriseOfGridOperatorDTO">
<select id="listSimple" parameterType="map" resultMap="enterpriseOfGridOperatorDTO" useCache="true">
SELECT
enterprise_of_grid_operator_id,
user_id,
@ -685,7 +687,7 @@
</select>
<!-- 企业ID列表 -->
<select id="listEnterpriseId" parameterType="map" resultType="java.lang.String">
<select id="listEnterpriseId" parameterType="map" resultType="java.lang.String" useCache="true">
SELECT
enterprise_id
FROM

View File

@ -2,6 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cm.inspection.dao.gridpersonnel.IGridPersonnelDao">
<cache flushInterval="3600000"/>
<resultMap id="gridPersonnelDTO" type="com.cm.inspection.pojo.dtos.gridpersonnel.GridPersonnelDTO">
<id column="grid_personnel_id" property="gridPersonnelId"/>
<result column="user_id" property="userId"/>
@ -32,7 +34,7 @@
</resultMap>
<!-- 新增网格人员 -->
<insert id="saveGridPersonnel" parameterType="map">
<insert id="saveGridPersonnel" parameterType="map" flushCache="true">
INSERT INTO gen_grid_personnel(
grid_personnel_id,
user_id,
@ -69,7 +71,7 @@
</insert>
<!-- 删除网格人员 -->
<update id="removeGridPersonnel" parameterType="map">
<update id="removeGridPersonnel" parameterType="map" flushCache="true">
UPDATE
gen_grid_personnel
SET
@ -84,7 +86,7 @@
</update>
<!-- 修改网格人员 -->
<update id="updateGridPersonnel" parameterType="map">
<update id="updateGridPersonnel" parameterType="map" flushCache="true">
UPDATE
gen_grid_personnel
SET
@ -154,7 +156,7 @@
</select>
<!-- 网格人员列表 -->
<select id="listGridPersonnel" parameterType="map" resultMap="gridPersonnelDTO">
<select id="listGridPersonnel" parameterType="map" resultMap="gridPersonnelDTO" useCache="true">
SELECT
t1.user_id,
t1.area1,
@ -278,7 +280,7 @@
</select>
<!-- 统计网格员 -->
<select id="countGridPersonnel" parameterType="map" resultType="java.lang.Integer">
<select id="countGridPersonnel" parameterType="map" resultType="java.lang.Integer" useCache="true">
SELECT
COUNT(*)
FROM
@ -292,7 +294,7 @@
</select>
<!-- 网格员列表 -->
<select id="listGridPersonnelSimple" parameterType="map" resultMap="gridPersonnelDTO">
<select id="listGridPersonnelSimple" parameterType="map" resultMap="gridPersonnelDTO" useCache="true">
SELECT
t1.user_id,
t1.area1,
@ -370,7 +372,7 @@
</select>
<!-- 更新网格员上级ID -->
<update id="updateGridPersonnelLeaderUserId" parameterType="map">
<update id="updateGridPersonnelLeaderUserId" parameterType="map" flushCache="true">
UPDATE
gen_grid_personnel
SET

View File

@ -2,6 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.cm.inspection.dao.hiddendangerreport.IHiddenDangerReportDao">
<cache flushInterval="3600000"/>
<resultMap id="hiddenDangerReportDTO" type="com.cm.inspection.pojo.dtos.hiddendangerreport.HiddenDangerReportDTO">
<id column="hidden_danger_report_id" property="hiddenDangerReportId"/>
<result column="check_id" property="checkId"/>
@ -27,7 +29,7 @@
</resultMap>
<!-- 新增隐患上报 -->
<insert id="saveHiddenDangerReport" parameterType="map">
<insert id="saveHiddenDangerReport" parameterType="map" flushCache="true">
INSERT INTO gen_hidden_danger_report(
hidden_danger_report_id,
check_id,
@ -60,7 +62,7 @@
</insert>
<!-- 删除隐患上报 -->
<update id="removeHiddenDangerReport" parameterType="map">
<update id="removeHiddenDangerReport" parameterType="map" flushCache="true">
UPDATE
gen_hidden_danger_report
SET
@ -75,7 +77,7 @@
</update>
<!-- 修改隐患上报 -->
<update id="updateHiddenDangerReport" parameterType="map">
<update id="updateHiddenDangerReport" parameterType="map" flushCache="true">
UPDATE
gen_hidden_danger_report
SET
@ -107,7 +109,7 @@
</update>
<!-- 隐患上报详情 -->
<select id="getHiddenDangerReport" parameterType="map" resultMap="hiddenDangerReportDTO">
<select id="getHiddenDangerReport" parameterType="map" resultMap="hiddenDangerReportDTO" useCache="false">
SELECT
t1.check_id,
t1.check_item_id,
@ -137,7 +139,7 @@
</select>
<!-- 隐患上报列表 -->
<select id="listHiddenDangerReport" parameterType="map" resultMap="hiddenDangerReportDTO">
<select id="listHiddenDangerReport" parameterType="map" resultMap="hiddenDangerReportDTO" useCache="false">
SELECT
t1.check_id,
t1.check_item_id,
@ -189,7 +191,7 @@
</select>
<!-- 检查未通过的检查项 -->
<select id="listCheckItemUnPass" parameterType="map" resultMap="checkItemDTO">
<select id="listCheckItemUnPass" parameterType="map" resultMap="checkItemDTO" useCache="false">
SELECT
jt1.name,
jt1.summary,
@ -231,7 +233,7 @@
</select>
<!-- 检查列表通过检查项ID -->
<select id="listCheckItemByCheckId" parameterType="map" resultMap="checkItemDTO">
<select id="listCheckItemByCheckId" parameterType="map" resultMap="checkItemDTO" useCache="false">
SELECT
jt1.name,
jt1.summary,
@ -265,7 +267,7 @@
</select>
<!-- 隐患上报简单列表 -->
<select id="listHiddenDangerReportSimple" parameterType="map" resultMap="hiddenDangerReportDTO">
<select id="listHiddenDangerReportSimple" parameterType="map" resultMap="hiddenDangerReportDTO" useCache="true">
SELECT
*
FROM