From 05248ded0723bf87f6f7b815d1f0adbbfc7795c7 Mon Sep 17 00:00:00 2001
From: Administrator <1144154118@qq.com>
Date: 星期一, 07 八月 2023 16:20:33 +0800
Subject: [PATCH] 巡检计划修改
---
ard-work/src/main/java/com/ruoyi/app/patrolplan/mapper/ArdAppPatrolplanMapper.java | 8 --
ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWellVo.java | 18 ++++++
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml | 2
ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolplanServiceImpl.java | 74 ++++++++++++++++++++++--
ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWell.java | 5 +
ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml | 10 ++
ard-work/src/main/java/com/ruoyi/app/patrolplan/domain/ArdAppPatrolplan.java | 12 ----
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUserVo.java | 18 ++++++
ard-work/src/main/java/com/ruoyi/app/patrolplan/controller/ArdAppPatrolplanController.java | 7 +-
ard-work/src/main/java/com/ruoyi/app/patrolplan/service/IArdAppPatrolplanService.java | 3
10 files changed, 123 insertions(+), 34 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWell.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWell.java
index 84b69d2..5d8528c 100644
--- a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWell.java
+++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWell.java
@@ -1,6 +1,8 @@
package com.ruoyi.alarmpoints.well.domain;
import java.util.Date;
+
+import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
@@ -96,4 +98,7 @@
/** 鍏宠仈鐩告満ID */
private String cameraId;
+
+ @TableField(exist = false)
+ private String type;
}
diff --git a/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWellVo.java b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWellVo.java
new file mode 100644
index 0000000..4068eed
--- /dev/null
+++ b/ard-work/src/main/java/com/ruoyi/alarmpoints/well/domain/ArdAlarmpointsWellVo.java
@@ -0,0 +1,18 @@
+package com.ruoyi.alarmpoints.well.domain;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class ArdAlarmpointsWellVo {
+ /** id */
+ private String id;
+
+ /** 浜曞彿 */
+ @Excel(name = "浜曞彿")
+ private String wellId;
+
+ @TableField(exist = false)
+ private String type;
+}
diff --git a/ard-work/src/main/java/com/ruoyi/app/patrolplan/controller/ArdAppPatrolplanController.java b/ard-work/src/main/java/com/ruoyi/app/patrolplan/controller/ArdAppPatrolplanController.java
index d16637b..18d3b7e 100644
--- a/ard-work/src/main/java/com/ruoyi/app/patrolplan/controller/ArdAppPatrolplanController.java
+++ b/ard-work/src/main/java/com/ruoyi/app/patrolplan/controller/ArdAppPatrolplanController.java
@@ -190,10 +190,11 @@
*/
@PreAuthorize("@ss.hasPermi('app:appPatrolplan:edit')")
@Log(title = "app宸℃璁″垝", businessType = BusinessType.UPDATE)
- @PutMapping
- public AjaxResult edit(@RequestBody ArdAppPatrolplan ardAppPatrolplan)
+ @ApiOperation("淇敼鍗曟潯鏁版嵁")
+ @PutMapping("upd")
+ public Results edit(@RequestBody Map<String,Object> para)
{
- return toAjax(ardAppPatrolplanService.updateArdAppPatrolplan(ardAppPatrolplan));
+ return ardAppPatrolplanService.updateArdAppPatrolplan(para);
}
diff --git a/ard-work/src/main/java/com/ruoyi/app/patrolplan/domain/ArdAppPatrolplan.java b/ard-work/src/main/java/com/ruoyi/app/patrolplan/domain/ArdAppPatrolplan.java
index a1598f1..f145c12 100644
--- a/ard-work/src/main/java/com/ruoyi/app/patrolplan/domain/ArdAppPatrolplan.java
+++ b/ard-work/src/main/java/com/ruoyi/app/patrolplan/domain/ArdAppPatrolplan.java
@@ -64,18 +64,6 @@
// @JsonInclude(JsonInclude.Include.NON_DEFAULT )
private String pUser;
- /**
- * 宸℃鐐归泦鍚�
- */
- @TableField(exist = false)
- private List<ArdAlarmpointsWell> wellList;
-
- /**
- * 宸℃浜洪泦鍚�
- */
- @TableField(exist = false)
- private List<SysUser> userList;
-
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
diff --git a/ard-work/src/main/java/com/ruoyi/app/patrolplan/mapper/ArdAppPatrolplanMapper.java b/ard-work/src/main/java/com/ruoyi/app/patrolplan/mapper/ArdAppPatrolplanMapper.java
index 034721b..a029411 100644
--- a/ard-work/src/main/java/com/ruoyi/app/patrolplan/mapper/ArdAppPatrolplanMapper.java
+++ b/ard-work/src/main/java/com/ruoyi/app/patrolplan/mapper/ArdAppPatrolplanMapper.java
@@ -38,14 +38,6 @@
public int insertArdAppPatrolplan(ArdAppPatrolplan ardAppPatrolplan);
/**
- * 淇敼app宸℃璁″垝
- *
- * @param ardAppPatrolplan app宸℃璁″垝
- * @return 缁撴灉
- */
- public int updateArdAppPatrolplan(ArdAppPatrolplan ardAppPatrolplan);
-
- /**
* 鍒犻櫎app宸℃璁″垝
*
* @param patroEndTime app宸℃璁″垝涓婚敭
diff --git a/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/IArdAppPatrolplanService.java b/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/IArdAppPatrolplanService.java
index cfe84ed..a63ef36 100644
--- a/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/IArdAppPatrolplanService.java
+++ b/ard-work/src/main/java/com/ruoyi/app/patrolplan/service/IArdAppPatrolplanService.java
@@ -41,10 +41,9 @@
/**
* 淇敼app宸℃璁″垝
*
- * @param ardAppPatrolplan app宸℃璁″垝
* @return 缁撴灉
*/
- public int updateArdAppPatrolplan(ArdAppPatrolplan ardAppPatrolplan);
+ public Results updateArdAppPatrolplan(Map<String,Object> para);
/**
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 f32ca60..04164c2 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
@@ -9,18 +9,21 @@
import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.alarmpoints.well.domain.ArdAlarmpointsWell;
+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.ArdAppPatroluser;
import com.ruoyi.app.patrolplan.mapper.ArdAppPatrolpointMapper;
import com.ruoyi.app.patrolplan.mapper.ArdAppPatroluserMapper;
import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.core.domain.entity.SysUserVo;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.utils.result.Results;
+import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.app.patrolplan.mapper.ArdAppPatrolplanMapper;
@@ -91,12 +94,54 @@
/**
* 淇敼app宸℃璁″垝
*
- * @param ardAppPatrolplan app宸℃璁″垝
* @return 缁撴灉
*/
@Override
- public int updateArdAppPatrolplan(ArdAppPatrolplan ardAppPatrolplan) {
- return ardAppPatrolplanMapper.updateArdAppPatrolplan(ardAppPatrolplan);
+ public Results updateArdAppPatrolplan(Map<String,Object> para) {
+ if(para.get("id").toString().isEmpty()){
+ return Results.error("ID鏃犳晥锛�");
+ }
+ //淇敼涓昏〃
+ ArdAppPatrolplan ardAppPatrolplan = new ArdAppPatrolplan();
+ ardAppPatrolplan.setId(para.get("id").toString());
+ ardAppPatrolplan.setUserId(para.get("userId").toString());
+ ardAppPatrolplan.setCycle(para.get("cycle").toString());
+ ardAppPatrolplan.setPatroBeginTime(para.get("patroBeginTime").toString());
+ ardAppPatrolplan.setPatroEndTime(para.get("patroEndTime").toString());
+ ardAppPatrolplan.setPlanName(para.get("planName").toString());
+ int num = ardAppPatrolplanMapper.updateById(ardAppPatrolplan);
+ //淇敼鍏磋叮鐐�
+ ardAppPatrolpointMapper.deleteArdAppPatrolpointByPlanId(para.get("id").toString());//鍒犻櫎宸℃璁″垝涓嬫寕鐐逛綅
+ List<String> alarmpointIdList = (List<String>) para.get("alarmpointIdList");
+ List<ArdAppPatrolpoint> ardAppPatrolpointList = new ArrayList();
+ for(String alarmpointId : alarmpointIdList){
+ String patrolpointId = IdUtils.simpleUUID();
+ ArdAppPatrolpoint ardAppPatrolpoint = new ArdAppPatrolpoint();
+ ardAppPatrolpoint.setId(patrolpointId);
+ ardAppPatrolpoint.setPatrolplanId(para.get("id").toString());
+ ardAppPatrolpoint.setAlarmpointsId(alarmpointId);
+ ardAppPatrolpoint.setType((String) para.get("type"));
+ ardAppPatrolpointList.add(ardAppPatrolpoint);
+ }
+ ardAppPatrolpointMapper.insertArdAppPatrolpointList(ardAppPatrolpointList);//鏂板鍏宠仈鍏磋叮鐐�
+ //淇敼鐢ㄦ埛
+ ardAppPatroluserMapper.deleteArdAppPatroluserByPlanId(para.get("id").toString());//鍒犻櫎宸℃璁″垝涓嬫寕鐢ㄦ埛
+ List<String> appUserIdList = (List<String>) para.get("appUserIdList");
+ List<ArdAppPatroluser> ardAppPatroluserList = new ArrayList();
+ for(String appUserId : appUserIdList){
+ String patroluserId = IdUtils.simpleUUID();
+ ArdAppPatroluser ardAppPatroluser = new ArdAppPatroluser();
+ ardAppPatroluser.setId(patroluserId);
+ ardAppPatroluser.setPatrolplanId(para.get("id").toString());
+ ardAppPatroluser.setAppUserId(appUserId);
+ ardAppPatroluserList.add(ardAppPatroluser);
+ }
+ ardAppPatroluserMapper.insertArdAppPatroluserList(ardAppPatroluserList);//鏂板鍏宠仈浜哄憳
+ if(num>0){
+ return Results.succeed("淇敼鎴愬姛锛�");
+ }else {
+ return Results.error("淇敼澶辫触锛�");
+ }
}
@@ -167,12 +212,29 @@
@Override
public Results oneById(String id) {
+ JSONObject jsonObject = new JSONObject();
ArdAppPatrolplan ardAppPatrolplan = ardAppPatrolplanMapper.selectById(id);
+ jsonObject.put("plan",ardAppPatrolplan);
List<ArdAlarmpointsWell> ardAlarmpointsWellList = ardAlarmpointsWellMapper.wellByPlanId(id);
+ List<ArdAlarmpointsWellVo> wellVos = new ArrayList<>();
+ for (ArdAlarmpointsWell ardAlarmpointsWell : ardAlarmpointsWellList) {
+ ArdAlarmpointsWellVo wellVo = new ArdAlarmpointsWellVo();
+ wellVo.setId(ardAlarmpointsWell.getId());
+ wellVo.setType(ardAlarmpointsWell.getType());
+ wellVo.setWellId(ardAlarmpointsWell.getWellId());
+ wellVos.add(wellVo);
+ }
+ jsonObject.put("well",wellVos);
List<SysUser> sysUserList = sysUserMapper.userByPlanId(id);
- ardAppPatrolplan.setUserList(sysUserList);
- ardAppPatrolplan.setWellList(ardAlarmpointsWellList);
- return Results.succeed(ardAppPatrolplan);
+ List<SysUserVo> sysUserVos = new ArrayList<>();
+ for (int i = 0; i < sysUserList.size(); i++) {
+ SysUserVo sysUserVo = new SysUserVo();
+ sysUserVo.setUserId(sysUserList.get(i).getUserId());
+ sysUserVo.setNickName(sysUserList.get(i).getNickName());
+ sysUserVos.add(sysUserVo);
+ }
+ jsonObject.put("user",sysUserVos);
+ return Results.succeed(jsonObject);
}
@Override
diff --git a/ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml b/ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml
index 823c329..2fd4c9e 100644
--- a/ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml
+++ b/ard-work/src/main/resources/mapper/alarmpoints/ArdAlarmpointsWellMapper.xml
@@ -31,6 +31,12 @@
<result property="cameraId" column="camera_id"/>
</resultMap>
+ <resultMap type="ArdAlarmpointsWell" id="wellResult">
+ <result property="id" column="id"/>
+ <result property="wellId" column="well_id"/>
+ <result property="type" column="type"/>
+ </resultMap>
+
<sql id="selectArdAlarmpointsWellVo">
select c.id,
c.well_id,
@@ -198,7 +204,7 @@
WHERE well_id = #{wellId}
</select>
- <select id="wellByPlanId" parameterType="String" resultMap="ArdAlarmpointsWellResult">
- select * from ard_alarmpoints_well where id in (select alarmpoints_id from ard_app_patrolpoint where patrolplan_id = #{id})
+ <select id="wellByPlanId" parameterType="String" resultMap="wellResult">
+ select ard_app_patrolpoint.alarmpoints_id as id,ard_alarmpoints_well.well_id, ard_app_patrolpoint."type" from ard_alarmpoints_well LEFT JOIN ard_app_patrolpoint on ard_app_patrolpoint.alarmpoints_id = ard_alarmpoints_well.id where ard_alarmpoints_well.id in (select alarmpoints_id from ard_app_patrolpoint where patrolplan_id = #{id})
</select>
</mapper>
\ No newline at end of file
diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUserVo.java b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUserVo.java
new file mode 100644
index 0000000..3e2313d
--- /dev/null
+++ b/ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/SysUserVo.java
@@ -0,0 +1,18 @@
+package com.ruoyi.common.core.domain.entity;
+
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.ruoyi.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class SysUserVo {
+ /**
+ * 鐢ㄦ埛ID
+ */
+ private String userId;
+
+ /**
+ * 鐢ㄦ埛鏄电О
+ */
+ private String nickName;
+}
diff --git a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
index a441840..49f1b86 100644
--- a/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
+++ b/ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml
@@ -293,6 +293,6 @@
</select>
<select id="userByPlanId" parameterType="String" resultMap="SysUserResult">
- select * from sys_user where user_id in (select app_user_id from ard_app_patroluser where patrolplan_id = #{id})
+ select user_id,nick_name from sys_user where user_id in (select app_user_id from ard_app_patroluser where patrolplan_id = #{id})
</select>
</mapper>
\ No newline at end of file
--
Gitblit v1.9.3