Browse Source

预警规则生成数据修改

预警详情下转修改
v2
chenrui 2 years ago
parent
commit
b6df92b5d1
  1. 4
      lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/code/LawEnforcementWarningList/registrationDetail.html
  2. 4
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/LawEnforcementWarningListController.java
  3. 30
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/EnforceRegCount.java
  4. 27
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/LawEnforcementWarningList.java
  5. 8
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/mapper/EnforcementRegistrationMapper.java
  6. 68
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementRegistrationServiceImpl.java
  7. 18
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/task/EarlyWarningTask.java
  8. 12
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml
  9. 9
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/LawEnforcementWarningListMapper.xml
  10. 1
      lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/RuleItemListMapper.xml

4
lib/EmergencyService/zdxtEmergencyBootStart/src/main/resources/templates/project/code/LawEnforcementWarningList/registrationDetail.html

@ -13,8 +13,10 @@
<li> <li>
<p>执法部门:</p> <p>执法部门:</p>
<input type="text" name="lawEnforcement"/> <input type="text" name="lawEnforcement"/>
<input type="hidden" th:value="${time}" name="dateSearch"/> <!-- <input type="hidden" th:value="${time}" name="dateSearch"/>-->
<input type="hidden" th:value="${enterpriseNumber}" name="enterpriseNumber"/> <input type="hidden" th:value="${enterpriseNumber}" name="enterpriseNumber"/>
<input type="hidden" th:value="${beginTime}" name="params[beginTime]"/>
<input type="hidden" th:value="${endTime}" name="params[endTime]"/>
</li> </li>
<li> <li>
<p>执法人员:</p> <p>执法人员:</p>

4
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/controller/LawEnforcementWarningListController.java

@ -132,8 +132,10 @@ public class LawEnforcementWarningListController extends BaseController
{ {
LawEnforcementWarningList lawEnforcementWarningList = LawEnforcementWarningList lawEnforcementWarningList =
lawEnforcementWarningListService.selectLawEnforcementWarningListById(id); lawEnforcementWarningListService.selectLawEnforcementWarningListById(id);
mmp.put("time", DateUtils.parseDateToStr("yyyy-MM",lawEnforcementWarningList.getWarningTime())); // mmp.put("time", DateUtils.parseDateToStr("yyyy-MM",lawEnforcementWarningList.getWarningTime()));
mmp.put("enterpriseNumber", lawEnforcementWarningList.getEnterpriseNumber()); mmp.put("enterpriseNumber", lawEnforcementWarningList.getEnterpriseNumber());
mmp.put("beginTime", lawEnforcementWarningList.getBeginTime());
mmp.put("endTime", lawEnforcementWarningList.getEndTime());
return prefix + "/registrationDetail"; return prefix + "/registrationDetail";
} }

30
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/EnforceRegCount.java

@ -17,9 +17,9 @@ public class EnforceRegCount
{ {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 企业名称 */ /** 执法部门名称 */
private String lawEnforcement; private String lawEnforcement;
/** 企业id */ /** 执法部门ID */
private String lawEnforcementId; private String lawEnforcementId;
/** /**
* 企业统一信用代码 * 企业统一信用代码
@ -52,6 +52,16 @@ public class EnforceRegCount
*/ */
private String enforcementDepartmentId; private String enforcementDepartmentId;
/**
* 预警规则- 开始时间
*/
private String beginTime;
/**
* 预警规则-结束时间
*/
private String endTime;
public String getLawEnforcement() { public String getLawEnforcement() {
return lawEnforcement; return lawEnforcement;
} }
@ -122,4 +132,20 @@ public class EnforceRegCount
public void setEnterpriseName(String enterpriseName) { public void setEnterpriseName(String enterpriseName) {
this.enterpriseName = enterpriseName; this.enterpriseName = enterpriseName;
} }
public String getBeginTime() {
return beginTime;
}
public void setBeginTime(String beginTime) {
this.beginTime = beginTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
} }

27
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/domain/LawEnforcementWarningList.java

@ -57,6 +57,17 @@ public class LawEnforcementWarningList extends BaseDomain
*/ */
private String enforcementDepartmentId; private String enforcementDepartmentId;
/**
* 开始时间
*/
private String beginTime;
/**
* 结束时间
*/
private String endTime;
public void setId(String id) public void setId(String id)
{ {
this.id = id; this.id = id;
@ -157,6 +168,22 @@ public class LawEnforcementWarningList extends BaseDomain
this.enforcementDepartmentId = enforcementDepartmentId; this.enforcementDepartmentId = enforcementDepartmentId;
} }
public String getBeginTime() {
return beginTime;
}
public void setBeginTime(String beginTime) {
this.beginTime = beginTime;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

8
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/mapper/EnforcementRegistrationMapper.java

@ -71,14 +71,14 @@ public interface EnforcementRegistrationMapper
/** /**
* 执法预警-统计执法部门执法数量 * 执法预警-统计执法部门执法数量
* @param timeMonth * @param beginTime
* @return * @return
*/ */
public List<EnforceRegCount> countMentByTimeLawNew(@Param("timeMonth") Long timeMonth); public List<EnforceRegCount> countMentByTimeLawNew(@Param("beginTime") String beginTime,@Param("endTime") String endTime);
/** /**
* 执法预警-统计企业执法数量 * 执法预警-统计企业执法数量
* @param timeMonth * @param beginTime
* @return * @return
*/ */
public List<EnforceRegCount> countMentByTimeQyNew(@Param("timeMonth") Long timeMonth); public List<EnforceRegCount> countMentByTimeQyNew(@Param("beginTime") String beginTime,@Param("endTime") String endTime);
} }

68
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/service/impl/EnforcementRegistrationServiceImpl.java

@ -1,5 +1,8 @@
package com.zdxt.code.service.impl; package com.zdxt.code.service.impl;
import java.time.LocalDate;
import java.time.Month;
import java.time.temporal.TemporalAdjusters;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -258,9 +261,21 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat
for (RuleItemList rule : ruleItemLists) { for (RuleItemList rule : ruleItemLists) {
List<EnforceRegCount> tmpList = new ArrayList<>(); List<EnforceRegCount> tmpList = new ArrayList<>();
if(list.getRuleCode().equals("zf_warn")){ if(list.getRuleCode().equals("zf_warn")){
tmpList = enforcementRegistrationMapper.countMentByTimeLawNew(rule.getCycleTime()); String time = getTime(rule.getCycleTime().intValue());
String[] timeArr = time.split(",");
tmpList = enforcementRegistrationMapper.countMentByTimeLawNew(timeArr[0],timeArr[1]);
tmpList.forEach(res ->{
res.setBeginTime(timeArr[0]);
res.setEndTime(timeArr[1]);
});
}else if (list.getRuleCode().equals("qy_warn")){ }else if (list.getRuleCode().equals("qy_warn")){
tmpList = enforcementRegistrationMapper.countMentByTimeQyNew(rule.getCycleTime()); String time = getTime(rule.getCycleTime().intValue());
String[] timeArr = time.split(",");
tmpList = enforcementRegistrationMapper.countMentByTimeQyNew(timeArr[0],timeArr[1]);
tmpList.forEach(res ->{
res.setBeginTime(timeArr[0]);
res.setEndTime(timeArr[1]);
});
}else { }else {
tmpList = enforcementRegistrationMapper.countMentByTime2(rule.getCycleTime(), searchValue); tmpList = enforcementRegistrationMapper.countMentByTime2(rule.getCycleTime(), searchValue);
} }
@ -275,7 +290,7 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat
Collectors.maxBy(Comparator.comparingInt(EnforceRegCount::getNum)), Collectors.maxBy(Comparator.comparingInt(EnforceRegCount::getNum)),
Optional::get))); Optional::get)));
Date nowDate = DateUtils.getNowDate(); Date nowDate = DateUtils.getNowDate();
List<LawEnforcementWarningList> lawEnforcementWarningLists = new ArrayList<>(); // List<LawEnforcementWarningList> lawEnforcementWarningLists = new ArrayList<>();
Iterator<Map.Entry<String, EnforceRegCount>> iterator = maxItems.entrySet().iterator(); Iterator<Map.Entry<String, EnforceRegCount>> iterator = maxItems.entrySet().iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
@ -285,32 +300,31 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat
// if (reg.getNum() >= rule.getExistAlarm() && reg.getNum() <= rule.getExistAlarmEnd()) { // if (reg.getNum() >= rule.getExistAlarm() && reg.getNum() <= rule.getExistAlarmEnd()) {
if (reg.getNum() >= rule.getExistAlarm()) { if (reg.getNum() >= rule.getExistAlarm()) {
reg.setLevel(rule.getAlarmType()); reg.setLevel(rule.getAlarmType());
LawEnforcementWarningList lawEnforcementWarningList = new LawEnforcementWarningList(); // LawEnforcementWarningList lawEnforcementWarningList = new LawEnforcementWarningList();
lawEnforcementWarningList.setId(IdUtil.simpleUUID()); // lawEnforcementWarningList.setId(IdUtil.simpleUUID());
//获取执法次数 // //获取执法次数
lawEnforcementWarningList.setEnforcementNumber(reg.getNum()); // lawEnforcementWarningList.setEnforcementNumber(reg.getNum());
//企业名称 // //企业名称
lawEnforcementWarningList.setEnterpriseName(reg.getLawEnforcement()); // lawEnforcementWarningList.setEnterpriseName(reg.getLawEnforcement());
//企业统一信用代码 // //企业统一信用代码
lawEnforcementWarningList.setEnterpriseNumber(reg.getEnterpriseNumber()); // lawEnforcementWarningList.setEnterpriseNumber(reg.getEnterpriseNumber());
//预警原因 // //预警原因
lawEnforcementWarningList.setWarningCause(""+ reg.getNum() +""); // lawEnforcementWarningList.setWarningCause(""+ reg.getNum() +"");
//预警时间 // //预警时间
lawEnforcementWarningList.setWarningTime(nowDate); // lawEnforcementWarningList.setWarningTime(nowDate);
//创建时间 // //创建时间
lawEnforcementWarningList.setCreateTime(nowDate); // lawEnforcementWarningList.setCreateTime(nowDate);
if(list.getRuleCode().equals("zf_warn")){ if(list.getRuleCode().equals("zf_warn")){
reg.setWarnType(0); reg.setWarnType(0);
}else if (list.getRuleCode().equals("qy_warn")){ }else if (list.getRuleCode().equals("qy_warn")){
reg.setWarnType(1); reg.setWarnType(1);
} }
//存储告警信息 //存储告警信息
lawEnforcementWarningLists.add(lawEnforcementWarningList); // lawEnforcementWarningLists.add(lawEnforcementWarningList);
results.add(reg);
break; break;
} }
} }
results.add(reg);
} }
} }
return results; return results;
@ -373,4 +387,18 @@ public class EnforcementRegistrationServiceImpl implements IEnforcementRegistrat
} }
return result; return result;
} }
public static String getTime(Integer mouthTime){
int year = LocalDate.now().getYear();
int nowMonth = LocalDate.now().getMonth().getValue() - (mouthTime -1);
int month = LocalDate.now().getMonth().getValue();
// 获取x月的第一天
LocalDate firstDayOfMonth = LocalDate.of(year, nowMonth, 1);
// 获取x月的第一天
LocalDate lastLocalDate = LocalDate.of(year, month, 1);
// 获取当前月的最后一天
LocalDate lastDayOfMonth = lastLocalDate.with(TemporalAdjusters.lastDayOfMonth());
return firstDayOfMonth +"," + lastDayOfMonth;
}
} }

18
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/java/com/zdxt/code/task/EarlyWarningTask.java

@ -68,13 +68,25 @@ public class EarlyWarningTask {
warning.setId(IdUtil.simpleUUID()); warning.setId(IdUtil.simpleUUID());
warning.setCreateTime(DateUtils.getNowDate()); warning.setCreateTime(DateUtils.getNowDate());
if(StrUtil.isNotEmpty(warn.getLawEnforcementId())){ if(StrUtil.isNotEmpty(warn.getLawEnforcementId()) && warn.getWarnType() == 0){
warning.setEnforcementDepartment(warn.getEnforcementDepartment()); warning.setEnforcementDepartment(warn.getLawEnforcement());
warning.setEnforcementDepartmentId(warn.getEnforcementDepartmentId()); warning.setEnforcementDepartmentId(warn.getLawEnforcementId());
} }
//开始时间结束时间
warning.setBeginTime(warn.getBeginTime());
warning.setEndTime(warn.getEndTime());
//预警类型 //预警类型
warning.setWarnType(warn.getWarnType()); warning.setWarnType(warn.getWarnType());
lawEnforcementWarningListService.insertLawEnforcementWarningList(warning); lawEnforcementWarningListService.insertLawEnforcementWarningList(warning);
}else{
//如预警数据已存在,更新企业预警次数数值
for (LawEnforcementWarningList re : res) {
LawEnforcementWarningList warning = new LawEnforcementWarningList();
warning.setWarningCause("本月对该企业已检查" + warn.getNum() + "次");
warning.setEnforcementNumber(warn.getNum());
warning.setId(re.getId());
lawEnforcementWarningListService.updateLawEnforcementWarningList(warning);
}
} }
} }
}catch (Exception e){ }catch (Exception e){

12
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/EnforcementRegistrationMapper.xml

@ -129,6 +129,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 --> <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
and DATE_FORMAT(enforcement_time,'%Y-%m') &lt;= #{endTime} and DATE_FORMAT(enforcement_time,'%Y-%m') &lt;= #{endTime}
</if> </if>
<if test="params.beginTime != null and params.beginTime != ''"><!-- 开始时间检索 -->
and enforcement_time &gt;= #{params.beginTime}
</if>
<if test="params.endTime != null and params.endTime != ''"><!-- 结束时间检索 -->
and enforcement_time &lt;= #{params.endTime}
</if>
<!-- 数据范围过滤 --> <!-- 数据范围过滤 -->
${params.dataScope} ${params.dataScope}
</where> </where>
@ -314,7 +321,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM FROM
( SELECT enterprise_name, enterprise_number, law_enforcement_id,law_enforcement, unite_check, create_time , ( SELECT enterprise_name, enterprise_number, law_enforcement_id,law_enforcement, unite_check, create_time ,
count( enterprise_number ) AS total FROM enforcement_registration count( enterprise_number ) AS total FROM enforcement_registration
WHERE create_time >= DATE_SUB( CURDATE(), INTERVAL #{timeMonth} MONTH ) AND law_enforcement_id IS NOT NULL GROUP BY unite_check ,law_enforcement_id ) AS t1 WHERE <![CDATA[ create_time >= #{beginTime} AND create_time <= #{endTime} ]]> AND law_enforcement_id IS NOT NULL GROUP BY unite_check ,law_enforcement_id ) AS t1
GROUP BY t1.law_enforcement_id GROUP BY t1.law_enforcement_id
</select> </select>
<select id="countMentByTimeQyNew" resultMap="EnforceRegCountResult" <select id="countMentByTimeQyNew" resultMap="EnforceRegCountResult"
@ -327,7 +334,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
FROM FROM
( SELECT enterprise_name, enterprise_number, law_enforcement_id, unite_check, create_time , ( SELECT enterprise_name, enterprise_number, law_enforcement_id, unite_check, create_time ,
count( enterprise_number ) AS total FROM enforcement_registration count( enterprise_number ) AS total FROM enforcement_registration
WHERE create_time >= DATE_SUB( CURDATE(), INTERVAL #{timeMonth} MONTH ) AND law_enforcement_id IS NOT NULL WHERE <![CDATA[ create_time >= #{beginTime} AND create_time <= #{endTime} ]]>
AND law_enforcement_id IS NOT NULL
GROUP BY unite_check ,law_enforcement_id ) AS t1 GROUP BY unite_check ,law_enforcement_id ) AS t1
GROUP BY t1.enterprise_number GROUP BY t1.enterprise_number
</select> </select>

9
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/LawEnforcementWarningListMapper.xml

@ -16,12 +16,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="warnType" column="warn_type" /> <result property="warnType" column="warn_type" />
<result property="enforcementDepartment" column="enforcement_department" /> <result property="enforcementDepartment" column="enforcement_department" />
<result property="enforcementDepartmentId" column="enforcement_department_id" /> <result property="enforcementDepartmentId" column="enforcement_department_id" />
<result property="beginTime" column="begin_time" />
<result property="endTime" column="end_time" />
</resultMap> </resultMap>
<sql id="selectLawEnforcementWarningListVo"> <sql id="selectLawEnforcementWarningListVo">
select id, warning_time, warning_cause, warning_level, select id, warning_time, warning_cause, warning_level,
create_time, enterprise_name, enterprise_number,enforcement_number,warn_type, create_time, enterprise_name, enterprise_number,enforcement_number,warn_type,
enforcement_department,enforcement_department_id from law_enforcement_warning_list enforcement_department,enforcement_department_id,begin_time,end_time from law_enforcement_warning_list
</sql> </sql>
<select id="selectLawEnforcementWarningListList" parameterType="LawEnforcementWarningList" resultMap="LawEnforcementWarningListResult"> <select id="selectLawEnforcementWarningListList" parameterType="LawEnforcementWarningList" resultMap="LawEnforcementWarningListResult">
@ -70,6 +72,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test=" enforcementDepartment != null and enforcementDepartment != ''">enforcement_department,</if> <if test=" enforcementDepartment != null and enforcementDepartment != ''">enforcement_department,</if>
<if test=" enforcementDepartmentId != null and enforcementDepartmentId != ''">enforcement_department_id,</if> <if test=" enforcementDepartmentId != null and enforcementDepartmentId != ''">enforcement_department_id,</if>
<if test="warnType != null">warn_type,</if> <if test="warnType != null">warn_type,</if>
<if test="beginTime != null and beginTime != '' ">begin_time,</if>
<if test="endTime != null and endTime != '' ">end_time,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null and id != ''">#{id},</if> <if test="id != null and id != ''">#{id},</if>
@ -83,6 +87,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test=" enforcementDepartment != null and enforcementDepartment != ''">#{enforcementDepartment},</if> <if test=" enforcementDepartment != null and enforcementDepartment != ''">#{enforcementDepartment},</if>
<if test=" enforcementDepartmentId != null and enforcementDepartmentId != ''">#{enforcementDepartmentId},</if> <if test=" enforcementDepartmentId != null and enforcementDepartmentId != ''">#{enforcementDepartmentId},</if>
<if test="warnType != null">#{warnType},</if> <if test="warnType != null">#{warnType},</if>
<if test="beginTime != null and beginTime != '' ">#{beginTime},</if>
<if test="endTime != null and endTime != '' ">#{endTime},</if>
</trim> </trim>
</insert> </insert>
@ -95,6 +101,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="createTime != null ">create_time = #{createTime},</if> <if test="createTime != null ">create_time = #{createTime},</if>
<if test="enterpriseName != null and enterpriseName != ''">enterprise_name = #{enterpriseName},</if> <if test="enterpriseName != null and enterpriseName != ''">enterprise_name = #{enterpriseName},</if>
<if test="enterpriseNumber != null and enterpriseNumber != ''">enterprise_number = #{enterpriseNumber},</if> <if test="enterpriseNumber != null and enterpriseNumber != ''">enterprise_number = #{enterpriseNumber},</if>
<if test="enforcementNumber != null">enforcement_number = #{enforcementNumber},</if>
</trim> </trim>
where id = #{id} where id = #{id}
</update> </update>

1
lib/EmergencyService/zdxtLawEnforcementCodeService/src/main/resources/mapper/RuleItemListMapper.xml

@ -27,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="alarmType != null and alarmType != ''"> and alarm_type = #{alarmType}</if> <if test="alarmType != null and alarmType != ''"> and alarm_type = #{alarmType}</if>
<if test="status != null "> and status = #{status}</if> <if test="status != null "> and status = #{status}</if>
</where> </where>
order by exist_alarm desc
</select> </select>
<select id="selectRuleItemListById" parameterType="String" resultMap="RuleItemListResult"> <select id="selectRuleItemListById" parameterType="String" resultMap="RuleItemListResult">

Loading…
Cancel
Save