智能预警新增数据
This commit is contained in:
parent
b7409820d2
commit
920356bae2
39
inventory-dao/src/main/java/com/rzyc/enums/WarnTypeEnum.java
Normal file
39
inventory-dao/src/main/java/com/rzyc/enums/WarnTypeEnum.java
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
package com.rzyc.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author dong
|
||||||
|
* @date 2023-03-30 18:55
|
||||||
|
* @Version V1.0
|
||||||
|
*/
|
||||||
|
public enum WarnTypeEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
*110cfd4e-a754-11ed-b840-00163e0c1c62 企业重大隐患预警
|
||||||
|
*110d0072-a754-11ed-b840-00163e0c1c62 隐患未按期闭环预警
|
||||||
|
*110d018a-a754-11ed-b840-00163e0c1c62 企业清单未落实预警
|
||||||
|
*110d021b-a754-11ed-b840-00163e0c1c62 政府履职清单过期未履行预警
|
||||||
|
*110d0290-a754-11ed-b840-00163e0c1c62 下级未履行上级任务预警
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
HAZARD("110cfd4e-a754-11ed-b840-00163e0c1c62"),
|
||||||
|
TROUBLE("110d0072-a754-11ed-b840-00163e0c1c62"),
|
||||||
|
NET_LIST("110d018a-a754-11ed-b840-00163e0c1c62"),
|
||||||
|
GOV_LIST("110d021b-a754-11ed-b840-00163e0c1c62"),
|
||||||
|
TASK("110d0290-a754-11ed-b840-00163e0c1c62");
|
||||||
|
|
||||||
|
WarnTypeEnum(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String type;
|
||||||
|
|
||||||
|
public String getType() {
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(String type) {
|
||||||
|
this.type = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -152,5 +152,8 @@ public interface OATaskMapper extends BaseMapper<OATask> {
|
||||||
|
|
||||||
List<WorkStateVo> selectWorkState(@Param("id") String id);
|
List<WorkStateVo> selectWorkState(@Param("id") String id);
|
||||||
|
|
||||||
|
/*未完成履职任务*/
|
||||||
|
List<OATask> notCompleteTask();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.rzyc.mapper;
|
||||||
|
|
||||||
import com.rzyc.model.SysWarning;
|
import com.rzyc.model.SysWarning;
|
||||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -15,4 +16,7 @@ import org.springframework.stereotype.Repository;
|
||||||
@Repository
|
@Repository
|
||||||
public interface SysWarningMapper extends BaseMapper<SysWarning> {
|
public interface SysWarningMapper extends BaseMapper<SysWarning> {
|
||||||
|
|
||||||
|
/*查询预警数量*/
|
||||||
|
Integer countByTargetId(@Param("targetId") String targetId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,9 @@ public interface ChkPersonMapper {
|
||||||
/*通过检查id 查询检查人*/
|
/*通过检查id 查询检查人*/
|
||||||
List<ChkPerson> findByCheckId(@Param("bookEntCheckId") String bookEntCheckId);
|
List<ChkPerson> findByCheckId(@Param("bookEntCheckId") String bookEntCheckId);
|
||||||
|
|
||||||
|
/*查询所有检查人*/
|
||||||
|
List<ChkPerson> findByCheckIdAll(@Param("bookEntCheckId") String bookEntCheckId);
|
||||||
|
|
||||||
/*通过隐患id查询检查人员*/
|
/*通过隐患id查询检查人员*/
|
||||||
List<ChkPerson> findByBookEntHTId(@Param("bookEntHTId") String bookEntHTId);
|
List<ChkPerson> findByBookEntHTId(@Param("bookEntHTId") String bookEntHTId);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -30,6 +30,10 @@ public class SysWarning implements Serializable {
|
||||||
@TableField("send_id")
|
@TableField("send_id")
|
||||||
private String sendId;
|
private String sendId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "预警来源id")
|
||||||
|
@TableField("target_id")
|
||||||
|
private String targetId;
|
||||||
|
|
||||||
@ApiModelProperty(value = "预警内容")
|
@ApiModelProperty(value = "预警内容")
|
||||||
@TableField("warning_info")
|
@TableField("warning_info")
|
||||||
private String warningInfo;
|
private String warningInfo;
|
||||||
|
|
@ -62,6 +66,14 @@ public class SysWarning implements Serializable {
|
||||||
@TableField("modify_by")
|
@TableField("modify_by")
|
||||||
private String modifyBy;
|
private String modifyBy;
|
||||||
|
|
||||||
|
public String getTargetId() {
|
||||||
|
return targetId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTargetId(String targetId) {
|
||||||
|
this.targetId = targetId;
|
||||||
|
}
|
||||||
|
|
||||||
public String getTypeId() {
|
public String getTypeId() {
|
||||||
return typeId;
|
return typeId;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -653,5 +653,14 @@
|
||||||
where ot.OATaskId = #{id}
|
where ot.OATaskId = #{id}
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!--未完成履职任务-->
|
||||||
|
<select id="notCompleteTask" resultMap="BaseResultMap">
|
||||||
|
SELECT * FROM `oatask` ot
|
||||||
|
WHERE ot.`IsFinish` = '否'
|
||||||
|
AND ot.`PlanEndDate` < NOW()
|
||||||
|
AND YEAR(ot.`StartDate`) =YEAR(NOW())
|
||||||
|
AND ot.`TaskType` = '履职任务'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
<resultMap id="BaseResultMap" type="com.rzyc.model.SysWarning">
|
<resultMap id="BaseResultMap" type="com.rzyc.model.SysWarning">
|
||||||
<id column="warning_id" property="warningId" />
|
<id column="warning_id" property="warningId" />
|
||||||
<result column="send_id" property="sendId" />
|
<result column="send_id" property="sendId" />
|
||||||
|
<result column="target_id" property="targetId" />
|
||||||
<result column="warning_info" property="warningInfo" />
|
<result column="warning_info" property="warningInfo" />
|
||||||
<result column="warning_time" property="warningTime" />
|
<result column="warning_time" property="warningTime" />
|
||||||
<result column="type_id" property="typeId" />
|
<result column="type_id" property="typeId" />
|
||||||
|
|
@ -18,7 +19,13 @@
|
||||||
|
|
||||||
<!-- 通用查询结果列 -->
|
<!-- 通用查询结果列 -->
|
||||||
<sql id="Base_Column_List">
|
<sql id="Base_Column_List">
|
||||||
warning_id, send_id, warning_info, warning_time, type_id,del_state, create_time, create_by, modify_time, modify_by
|
warning_id, send_id, target_id,warning_info, warning_time, type_id,del_state, create_time, create_by, modify_time, modify_by
|
||||||
</sql>
|
</sql>
|
||||||
|
|
||||||
|
<!--查询是否预警-->
|
||||||
|
<select id="countByTargetId" resultType="java.lang.Integer">
|
||||||
|
SELECT COUNT(*) FROM`sys_warning` sw
|
||||||
|
WHERE sw.`target_id` = #{targetId}
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
|
||||||
|
|
@ -360,6 +360,12 @@
|
||||||
WHERE cp.BookEntCheckId = #{bookEntCheckId} AND cp.IsSign = 2
|
WHERE cp.BookEntCheckId = #{bookEntCheckId} AND cp.IsSign = 2
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!--通过检查id 查询所有检查人-->
|
||||||
|
<select id="findByCheckIdAll" resultMap="checkSignMap">
|
||||||
|
SELECT * FROM `ChkPerson` cp
|
||||||
|
WHERE cp.BookEntCheckId = #{bookEntCheckId}
|
||||||
|
</select>
|
||||||
|
|
||||||
<!--通过隐患id查询检查人员-->
|
<!--通过隐患id查询检查人员-->
|
||||||
<select id="findByBookEntHTId" resultMap="BaseResultMap">
|
<select id="findByBookEntHTId" resultMap="BaseResultMap">
|
||||||
SELECT cp.* FROM `BookEntHT` bh
|
SELECT cp.* FROM `BookEntHT` bh
|
||||||
|
|
|
||||||
|
|
@ -17,9 +17,9 @@ public class SaticScheduleTask {
|
||||||
private TaskService taskService;
|
private TaskService taskService;
|
||||||
|
|
||||||
|
|
||||||
@Scheduled(cron = "0 01 02 * * ?")
|
// @Scheduled(cron = "0 01 02 * * ?")
|
||||||
//或直接指定时间间隔,例如:5秒
|
//或直接指定时间间隔,例如:5秒
|
||||||
// @Scheduled(fixedRate=600000)
|
@Scheduled(fixedRate=600000)
|
||||||
private void configureTasks() {
|
private void configureTasks() {
|
||||||
taskService.task();
|
taskService.task();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,12 @@ import com.common.utils.RandomNumber;
|
||||||
import com.common.utils.encryption.MD5;
|
import com.common.utils.encryption.MD5;
|
||||||
import com.rzyc.bean.check.CheckPerform;
|
import com.rzyc.bean.check.CheckPerform;
|
||||||
import com.rzyc.controller.BaseController;
|
import com.rzyc.controller.BaseController;
|
||||||
|
import com.rzyc.enums.DelState;
|
||||||
|
import com.rzyc.enums.WarnTypeEnum;
|
||||||
import com.rzyc.model.*;
|
import com.rzyc.model.*;
|
||||||
import com.rzyc.model.check.BookEntHT;
|
import com.rzyc.model.check.BookEntHT;
|
||||||
import com.rzyc.model.check.BookenthtCompany;
|
import com.rzyc.model.check.BookenthtCompany;
|
||||||
|
import com.rzyc.model.check.ChkPerson;
|
||||||
import com.rzyc.model.ent.SysEnterprise;
|
import com.rzyc.model.ent.SysEnterprise;
|
||||||
import com.rzyc.model.user.SysUser;
|
import com.rzyc.model.user.SysUser;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
@ -26,20 +29,21 @@ public class TaskService extends BaseController {
|
||||||
* 定时任务
|
* 定时任务
|
||||||
*/
|
*/
|
||||||
public void task(){
|
public void task(){
|
||||||
|
|
||||||
|
System.err.println("--------------------定时任务 start --------------------------------");
|
||||||
try {
|
try {
|
||||||
//隐患
|
//隐患
|
||||||
configureTasks();
|
configureTasks();
|
||||||
//自查隐患
|
//自查隐患
|
||||||
configureTasksEditCompanySelfDangerState();
|
configureTasksEditCompanySelfDangerState();
|
||||||
|
|
||||||
//履职任务提醒
|
//履职任务提醒
|
||||||
performTask();
|
performTask();
|
||||||
|
|
||||||
//隐患超时
|
//隐患超时
|
||||||
configureTasksEditDanger();
|
configureTasksEditDanger();
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
System.err.println("--------------------定时任务 end --------------------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -48,8 +52,6 @@ public class TaskService extends BaseController {
|
||||||
*/
|
*/
|
||||||
private void configureTasks() {
|
private void configureTasks() {
|
||||||
try {
|
try {
|
||||||
System.err.println("--------------------定时任务 start --------------------------------");
|
|
||||||
|
|
||||||
//先查询
|
//先查询
|
||||||
List<BookEntHT> entHTs = bookEntHTMapper.findByHTStateByTime();
|
List<BookEntHT> entHTs = bookEntHTMapper.findByHTStateByTime();
|
||||||
|
|
||||||
|
|
@ -58,6 +60,9 @@ public class TaskService extends BaseController {
|
||||||
for (BookEntHT entHT : entHTs){
|
for (BookEntHT entHT : entHTs){
|
||||||
//添加通知
|
//添加通知
|
||||||
addNotice(entHT.getSysenterpriseid(),entHT.getHiddenarea());
|
addNotice(entHT.getSysenterpriseid(),entHT.getHiddenarea());
|
||||||
|
|
||||||
|
//新增预警
|
||||||
|
addTroubleWarn(entHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -67,7 +72,7 @@ public class TaskService extends BaseController {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
System.err.println("--------------------定时任务 end --------------------------------");
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
@ -113,7 +118,6 @@ public class TaskService extends BaseController {
|
||||||
|
|
||||||
private void configureTasksEditCompanySelfDangerState() {
|
private void configureTasksEditCompanySelfDangerState() {
|
||||||
try {
|
try {
|
||||||
System.err.println("--------------------定时任务 start --------------------------------");
|
|
||||||
|
|
||||||
//先查询
|
//先查询
|
||||||
List<BookenthtCompany> entHTs = bookenthtCompanyMapper.findByHTStateByTime();
|
List<BookenthtCompany> entHTs = bookenthtCompanyMapper.findByHTStateByTime();
|
||||||
|
|
@ -123,7 +127,6 @@ public class TaskService extends BaseController {
|
||||||
bookenthtCompanyMapper.changeHTStateByTime();
|
bookenthtCompanyMapper.changeHTStateByTime();
|
||||||
|
|
||||||
}
|
}
|
||||||
System.err.println("--------------------定时任务 end --------------------------------");
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
@ -134,9 +137,8 @@ public class TaskService extends BaseController {
|
||||||
* 机构隐患超过整改期限
|
* 机构隐患超过整改期限
|
||||||
*/
|
*/
|
||||||
public void configureTasksEditDanger(){
|
public void configureTasksEditDanger(){
|
||||||
System.err.println("--------------------定时任务 start --------------------------------");
|
|
||||||
orgDangerMapper.outDateOrgDanger();
|
orgDangerMapper.outDateOrgDanger();
|
||||||
System.err.println("--------------------定时任务 end --------------------------------");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -172,16 +174,11 @@ public class TaskService extends BaseController {
|
||||||
noticeMapper.insert(notice);
|
noticeMapper.insert(notice);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
@ -196,4 +193,69 @@ public class TaskService extends BaseController {
|
||||||
System.out.println("---------------------");
|
System.out.println("---------------------");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 隐患未整改预警
|
||||||
|
* @version v1.0
|
||||||
|
* @author dong
|
||||||
|
* @date 2023/3/30 19:38
|
||||||
|
*/
|
||||||
|
public void addTroubleWarn(BookEntHT entHT)throws Exception{
|
||||||
|
|
||||||
|
//查询是否预警
|
||||||
|
Integer warnNum = sysWarningMapper.countByTargetId(entHT.getBookenthtid());
|
||||||
|
if(0 == warnNum){
|
||||||
|
//未预警过就新增预警
|
||||||
|
List<ChkPerson> chkPeople = chkPersonMapper.findByCheckIdAll(entHT.getBookentcheckid());
|
||||||
|
if(null != chkPeople && chkPeople.size() > 0){
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
String warnInfo = "";
|
||||||
|
|
||||||
|
//企业信息
|
||||||
|
SysEnterprise sysEnterprise = sysEnterpriseMapper.selectByPrimaryKey(entHT.getSysenterpriseid());
|
||||||
|
if(null != sysEnterprise){
|
||||||
|
warnInfo = sysEnterprise.getEntname();
|
||||||
|
}
|
||||||
|
warnInfo = warnInfo + "的隐患<" + entHT.getHiddenarea() + ">超期未整改";
|
||||||
|
|
||||||
|
SysWarning warning = new SysWarning();
|
||||||
|
warning.setWarningId(RandomNumber.getUUid());
|
||||||
|
warning.setTargetId(entHT.getBookenthtid());
|
||||||
|
warning.setWarningInfo(warnInfo);
|
||||||
|
warning.setWarningTime(new Date());
|
||||||
|
warning.setTypeId(WarnTypeEnum.TROUBLE.getType());
|
||||||
|
warning.setDelState(DelState.NOT_DEL.getState());
|
||||||
|
warning.setCreateTime(new Date());
|
||||||
|
warning.setModifyTime(new Date());
|
||||||
|
sysWarningMapper.insert(warning);
|
||||||
|
|
||||||
|
for (ChkPerson chkPerson : chkPeople){
|
||||||
|
SysWarningUser warningUser = new SysWarningUser();
|
||||||
|
warningUser.setWarningUserId(RandomNumber.getUUid());
|
||||||
|
warningUser.setWarningId(warning.getWarningId());
|
||||||
|
warningUser.setUserId(chkPerson.getSysuserid());
|
||||||
|
warningUser.setTypeId(WarnTypeEnum.TROUBLE.getType());
|
||||||
|
warningUser.setState(1);
|
||||||
|
warningUser.setDelState(DelState.NOT_DEL.getState());
|
||||||
|
warningUser.setCreateTime(new Date());
|
||||||
|
warningUser.setModifyTime(new Date());
|
||||||
|
sysWarningUserMapper.insert(warningUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addTaskWarn()throws Exception{
|
||||||
|
|
||||||
|
//未完成履职任务
|
||||||
|
List<OATask> oaTasks = oaTaskMapper.notCompleteTask();
|
||||||
|
if(null != oaTasks && oaTasks.size() > 0){
|
||||||
|
for (OATask oaTask : oaTasks){
|
||||||
|
//查询是否预警
|
||||||
|
Integer warnNum = sysWarningMapper.countByTargetId(oaTask.getOataskid());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user