| | |
| | | package com.ruoyi.app.patrolplan.service.impl; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import java.util.Map; |
| | | |
| | | 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.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; |
| | | |
| | |
| | | public class ArdAppPatrolplanServiceImpl implements IArdAppPatrolplanService { |
| | | @Resource |
| | | private ArdAppPatrolplanMapper ardAppPatrolplanMapper; |
| | | |
| | | @Resource |
| | | private ArdAppPatrolpointMapper ardAppPatrolpointMapper; |
| | | |
| | | @Resource |
| | | private ArdAppPatroluserMapper ardAppPatroluserMapper; |
| | | |
| | | /** |
| | | * 查询app巡检计划 |
| | |
| | | return ardAppPatrolplanMapper.updateArdAppPatrolplan(ardAppPatrolplan); |
| | | } |
| | | |
| | | /** |
| | | * 批量删除app巡检计划 |
| | | * |
| | | * @param patroEndTimes 需要删除的app巡检计划主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteArdAppPatrolplanByPatroEndTimes(String[] patroEndTimes) { |
| | | return ardAppPatrolplanMapper.deleteArdAppPatrolplanByPatroEndTimes(patroEndTimes); |
| | | } |
| | | |
| | | /** |
| | | * 删除app巡检计划信息 |
| | | * |
| | | * @param patroEndTime app巡检计划主键 |
| | | * @return 结果 |
| | | */ |
| | | @Override |
| | | public int deleteArdAppPatrolplanByPatroEndTime(String patroEndTime) { |
| | | return ardAppPatrolplanMapper.deleteArdAppPatrolplanByPatroEndTime(patroEndTime); |
| | | @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; |
| | | } |
| | | } |