From 4b61f417607c539fa58a67fa61f9f35d7ddb6b88 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期六, 02 九月 2023 15:12:29 +0800
Subject: [PATCH] 雷达报警增加时间动态筛选
---
ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolplanServiceImpl.java | 93 ++++++++++++++++++++++++++++++++++++++++------
1 files changed, 81 insertions(+), 12 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolplanServiceImpl.java b/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolplanServiceImpl.java
index 69732dc..55a739f 100644
--- a/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolplanServiceImpl.java
+++ b/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolplanServiceImpl.java
@@ -1,5 +1,6 @@
package com.ruoyi.app.patrolplan.service.impl;
+import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@@ -14,8 +15,10 @@
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWellVo;
import com.ruoyi.alarmpoints.well.mapper.ArdAlarmpointsWellMapper;
import com.ruoyi.app.patrolplan.domain.ArdAppPatrolpoint;
+import com.ruoyi.app.patrolplan.domain.ArdAppPatrolpointRecord;
import com.ruoyi.app.patrolplan.domain.ArdAppPatroluser;
import com.ruoyi.app.patrolplan.mapper.ArdAppPatrolpointMapper;
+import com.ruoyi.app.patrolplan.mapper.ArdAppPatrolpointRecordMapper;
import com.ruoyi.app.patrolplan.mapper.ArdAppPatroluserMapper;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.domain.entity.SysUserVo;
@@ -57,6 +60,9 @@
@Resource
private SysUserMapper sysUserMapper;
+
+ @Resource
+ private ArdAppPatrolpointRecordMapper recordMapper;
/**
* 鏌ヨapp宸℃璁″垝
@@ -101,7 +107,7 @@
* @return 缁撴灉
*/
@Override
- public Results updateArdAppPatrolplan(Map<String,Object> para) {
+ public Results BeforeUpdateArdAppPatrolplan(Map<String,Object> para) {
if(para.get("id").toString().isEmpty()){
return Results.error("ID鏃犳晥锛�");
}
@@ -156,18 +162,46 @@
@Override
@Transactional
public int deleteArdApp(String id) {
- //ardAppPatroluserMapper.deleteArdAppPatroluserByReserved1(id);
- /*ardAppPatrolpointMapper.deleteArdAppPatrolpointById(id);
- if(ardAppPatrolplanMapper.deleteArdAppPatrolplanByPatroEndTime(id)>0){
- return Results.succeed("鍒犻櫎鎴愬姛锛�");
- }else {
- return Results.error("鍒犻櫎澶辫触锛�");
- }*/
try {
- int result = ardAppPatrolplanMapper.deleteArdAppPatrolplanById(id);//鍒犻櫎宸℃璁″垝
- ardAppPatrolpointMapper.deleteArdAppPatrolpointByPlanId(id);//鍒犻櫎宸℃璁″垝涓嬫寕鐐逛綅
- ardAppPatroluserMapper.deleteArdAppPatroluserByPlanId(id);//鍒犻櫎宸℃璁″垝涓嬫寕鐢ㄦ埛
- return result;
+ Boolean del = false;
+ //鏌ヨ璁″垝鏃堕棿鏄惁缁撴潫
+ ArdAppPatrolplan planList = ardAppPatrolplanMapper.selectById(id);
+ String cycle = planList.getCycle();
+ String end = planList.getPatroEndTime();
+ if(cycle.equals("day")){
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+ String date = dateFormat.format(new Date());
+ end = date +" "+end;
+ }
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ String toDay = dateFormat.format(new Date());
+ int once = toDay.compareTo(end);
+ if(once<0){
+ del = true;
+ }
+ if(!del){
+ //鏌ヨ鏄惁鏈夋墦鍗¤褰�
+ QueryWrapper<ArdAppPatrolpointRecord> recordQueryWrapper = new QueryWrapper<>();
+ recordQueryWrapper.eq("plan_id",id);
+ List<ArdAppPatrolpointRecord> recordList = recordMapper.selectList(recordQueryWrapper);
+ if(recordList.size()>0){
+ del = true;
+ }
+ }
+ if(del){
+ int result = ardAppPatrolplanMapper.deleteArdAppPatrolplanById(id);//鍒犻櫎宸℃璁″垝
+ ardAppPatrolpointMapper.deleteArdAppPatrolpointByPlanId(id);//鍒犻櫎宸℃璁″垝涓嬫寕鐐逛綅
+ ardAppPatroluserMapper.deleteArdAppPatroluserByPlanId(id);//鍒犻櫎宸℃璁″垝涓嬫寕鐢ㄦ埛
+ return result;
+ }else {
+ String userId = SecurityUtils.getUserId();
+ SysUser sysUser = sysUserMapper.selectUserById(userId);
+ String userName = sysUser.getNickName();
+ planList.setDelName(userName);
+ planList.setDelTime(dateFormat.format(new Date()));
+ int result = ardAppPatrolplanMapper.updateById(planList);
+ return result;
+ }
} catch (Exception e){
e.printStackTrace();
return 0;
@@ -243,4 +277,39 @@
return Results.succeed(jsonObject);
}
+ @Override
+ public Results updateArdAppPatrolplan(Map<String,Object> para){
+ if(para.get("id").toString().isEmpty()){
+ return Results.error("ID鏃犳晥锛�");
+ }
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+ //鏌ヨ璇ユ潯璁板綍
+ ArdAppPatrolplan planList = ardAppPatrolplanMapper.selectById(para.get("id").toString());
+ String userId = SecurityUtils.getUserId();
+ SysUser sysUser = sysUserMapper.selectUserById(userId);
+ String userName = sysUser.getNickName();
+ planList.setDelName(userName);
+ planList.setDelTime(dateFormat.format(new Date()));
+ int result = ardAppPatrolplanMapper.updateById(planList);
+ if(result<1){
+ return Results.error("淇敼澶辫触锛屽師鏁版嵁鍋滅敤鍑洪敊锛�");
+ }
+ int num = insertArdAppPatrolplan(para);
+ if(num==1){
+ return Results.succeed("淇敼鎴愬姛锛屽凡閲嶆柊閮ㄧ讲浠诲姟锛�");
+ }else {
+ return Results.error("淇敼澶辫触锛岄噸鏂伴儴缃蹭换鍔″け璐ワ紒");
+ }
+ }
+
+ @Override
+ public List<ArdAppPatrolplan> executeList(ArdAppPatrolplan ardAppPatrolplan) {
+ return ardAppPatrolplanMapper.executeList(ardAppPatrolplan);
+ }
+
+ @Override
+ public Results executeOneById(String id) {
+ return Results.succeed(ardAppPatrolplanMapper.selectById(id));
+ }
+
}
--
Gitblit v1.9.3