| | |
| | | package com.ruoyi.app.patrolplan.service.impl; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | 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.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.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.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.app.patrolplan.mapper.ArdAppPatrolplanMapper; |
| | | import com.ruoyi.app.patrolplan.domain.ArdAppPatrolplan; |
| | | import com.ruoyi.app.patrolplan.service.IArdAppPatrolplanService; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | |
| | | |
| | | @Resource |
| | | private ArdAppPatroluserMapper ardAppPatroluserMapper; |
| | | |
| | | @Resource |
| | | private ArdAlarmpointsWellMapper ardAlarmpointsWellMapper; |
| | | |
| | | @Resource |
| | | private SysUserMapper sysUserMapper; |
| | | |
| | | /** |
| | | * 查询app巡检计划 |
| | |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public Results deleteArdApp(String id) { |
| | | ardAppPatroluserMapper.deleteArdAppPatroluserByReserved1(id); |
| | | ardAppPatrolpointMapper.deleteArdAppPatrolpointById(id); |
| | | @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; |
| | | } catch (Exception e){ |
| | | e.printStackTrace(); |
| | | return 0; |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public int insertArdAppPatrolplan(Map<String, Object> para) { |
| | | String id = IdUtils.simpleUUID(); |
| | | ArdAppPatrolplan ardAppPatrolplan = new ArdAppPatrolplan(); |
| | | ardAppPatrolplan.setId(id); |
| | | ardAppPatrolplan.setPlanName((String) para.get("planName")); |
| | | ardAppPatrolplan.setPatroBeginTime((String) para.get("patroBeginTime")); |
| | | ardAppPatrolplan.setPatroEndTime((String) para.get("patroEndTime")); |
| | | String userId = SecurityUtils.getUserId(); |
| | | ardAppPatrolplan.setUserId(userId); |
| | | ardAppPatrolplan.setCycle((String) para.get("cycle")); |
| | | ardAppPatrolplan.setCreateTime(new Date()); |
| | | int result = ardAppPatrolplanMapper.insertArdAppPatrolplan(ardAppPatrolplan);//新增主表 |
| | | 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(id); |
| | | ardAppPatrolpoint.setAlarmpointsId(alarmpointId); |
| | | ardAppPatrolpoint.setType((String) para.get("type")); |
| | | ardAppPatrolpointList.add(ardAppPatrolpoint); |
| | | } |
| | | ardAppPatrolpointMapper.insertArdAppPatrolpointList(ardAppPatrolpointList);//新增关联兴趣点 |
| | | 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(id); |
| | | ardAppPatroluser.setAppUserId(appUserId); |
| | | ardAppPatroluserList.add(ardAppPatroluser); |
| | | } |
| | | ardAppPatroluserMapper.insertArdAppPatroluserList(ardAppPatroluserList);//新增关联人员 |
| | | return result; |
| | | } |
| | | |
| | | @Override |
| | | public Results oneById(String id) { |
| | | ArdAppPatrolplan ardAppPatrolplan = ardAppPatrolplanMapper.selectById(id); |
| | | List<ArdAlarmpointsWell> ardAlarmpointsWellList = ardAlarmpointsWellMapper.wellByPlanId(id); |
| | | List<SysUser> sysUserList = sysUserMapper.userByPlanId(id); |
| | | ardAppPatrolplan.setUserList(sysUserList); |
| | | ardAppPatrolplan.setWellList(ardAlarmpointsWellList); |
| | | return Results.succeed(ardAppPatrolplan); |
| | | } |
| | | |
| | | @Override |
| | | public Results allPlanUser(String id) { |
| | | return null; |
| | | } |
| | | } |