From bd3916f68a3f8971bfe8c78b0b71e87fba643e11 Mon Sep 17 00:00:00 2001 From: Administrator <1144154118@qq.com> Date: 星期四, 10 八月 2023 09:24:58 +0800 Subject: [PATCH] 巡检日历及查询优化 --- ard-work/src/main/java/com/ruoyi/app/patrolplan/service/impl/ArdAppPatrolplanServiceImpl.java | 100 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 files changed, 95 insertions(+), 5 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 a34c489..69732dc 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,21 +1,31 @@ package com.ruoyi.app.patrolplan.service.impl; import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; +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; @@ -41,6 +51,12 @@ @Resource private ArdAppPatroluserMapper ardAppPatroluserMapper; + + @Resource + private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper; + + @Resource + private SysUserMapper sysUserMapper; /** * 鏌ヨapp宸℃璁″垝 @@ -73,19 +89,63 @@ @Override public int insertArdAppPatrolplan(ArdAppPatrolplan ardAppPatrolplan) { ardAppPatrolplan.setUserId(SecurityUtils.getUserId()); - ardAppPatrolplan.setCreateTime(DateUtils.getNowDate()); + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ardAppPatrolplan.setCreateTime(sdf.format(date)); return ardAppPatrolplanMapper.insertArdAppPatrolplan(ardAppPatrolplan); } /** * 淇敼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("淇敼澶辫触锛�"); + } } @@ -126,7 +186,9 @@ String userId = SecurityUtils.getUserId(); ardAppPatrolplan.setUserId(userId); ardAppPatrolplan.setCycle((String) para.get("cycle")); - ardAppPatrolplan.setCreateTime(new Date()); + Date date = new Date(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + ardAppPatrolplan.setCreateTime(sdf.format(date)); int result = ardAppPatrolplanMapper.insertArdAppPatrolplan(ardAppPatrolplan);//鏂板涓昏〃 List<String> alarmpointIdList = (List<String>) para.get("alarmpointIdList"); List<ArdAppPatrolpoint> ardAppPatrolpointList = new ArrayList(); @@ -153,4 +215,32 @@ ardAppPatroluserMapper.insertArdAppPatroluserList(ardAppPatroluserList);//鏂板鍏宠仈浜哄憳 return result; } + + @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); + 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); + } + } -- Gitblit v1.9.3