| | |
| | | import com.thhy.general.utils.UserInfoUtils; |
| | | import com.thhy.secure.modules.biz.regionInspection.entity.RegionInspectionEntity; |
| | | import com.thhy.secure.modules.biz.regionInspection.entity.RegionInspectionHazardInformEntity; |
| | | import com.thhy.secure.modules.biz.regionInspection.entity.RegionInspectionRecordEntity; |
| | | import com.thhy.secure.modules.biz.regionInspection.entity.RegionInspectionUserEntity; |
| | | import com.thhy.secure.modules.biz.regionInspection.mapper.RegionInspectionMapper; |
| | | import com.thhy.secure.modules.biz.regionInspection.mapper.RegionInspectionRecordMapper; |
| | | import com.thhy.secure.modules.biz.regionInspection.service.RegionInspectionRecordService; |
| | | import com.thhy.secure.modules.biz.regionInspection.service.RegionInspectionService; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | @Autowired |
| | | private RegionInspectionMapper regionInspectionMapper; |
| | | |
| | | @Autowired |
| | | private RegionInspectionRecordMapper regionInspectionRecordMapper; |
| | | |
| | | private static final Object lock = new Object(); |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | regionInspectionMapper.deleteUser(regionInspectId); |
| | | regionInspectionMapper.deleteInspectionHazardInform(regionInspectId); |
| | | } |
| | | //添加/修改区域巡检 |
| | | List<String> userIds = new ArrayList<>(); |
| | | List<String> regionIds = new ArrayList<>(); |
| | | synchronized (lock) { |
| | | regionInspectionEntity.setId(regionInspectId); |
| | | regionInspectionEntity.setCreateUser(userId); |
| | | regionInspectionMapper.insert(regionInspectionEntity); |
| | | //添加巡检人 |
| | | for (RegionInspectionUserEntity userEntity : regionInspectionEntity.getRegionUsersList()) { |
| | | userEntity.setId(UUIDUtils.create()); |
| | | String id = UUIDUtils.create(); |
| | | userIds.add(userEntity.getUserId()); |
| | | userEntity.setId(id); |
| | | userEntity.setRegionInspectionId(regionInspectId); |
| | | regionInspectionMapper.insertUser(userEntity); |
| | | } |
| | | //添加巡检的区域 |
| | | for (RegionInspectionHazardInformEntity region : regionInspectionEntity.getRegionList()) { |
| | | region.setId(UUIDUtils.create()); |
| | | String id = UUIDUtils.create(); |
| | | regionIds.add(region.getRegionHazardInformId()); |
| | | region.setId(id); |
| | | region.setRegionInspectionId(regionInspectId); |
| | | regionInspectionMapper.insertInspectionHazardInform(region); |
| | | } |
| | | |
| | | //添加任务的时候添加打卡记录 新增的是待打卡状态 |
| | | if (StringUtils.isBlank(regionInspectionEntity.getId())){ |
| | | for (String addUserId : userIds) { |
| | | for (String regionId : regionIds) { |
| | | RegionInspectionRecordEntity regionInspectionRecordEntity = |
| | | RegionInspectionRecordEntity |
| | | .builder() |
| | | .id(UUIDUtils.create()) |
| | | .userId(addUserId) |
| | | .regionHazardInformId(regionId) |
| | | .regionInspectionId(regionInspectId) |
| | | .createUser(userId) |
| | | .build(); |
| | | regionInspectionRecordMapper.insert(regionInspectionRecordEntity); |
| | | } |
| | | } |
| | | } |
| | | |
| | | //添加/修改区域巡检 |
| | | regionInspectionEntity.setId(regionInspectId); |
| | | regionInspectionEntity.setCreateUser(userId); |
| | | regionInspectionMapper.insert(regionInspectionEntity); |
| | | |
| | | } |
| | | |
| | | return BasicResult.success(); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public BasicResult delete(String id) { |
| | | regionInspectionMapper.delete(id); |
| | | regionInspectionMapper.deleteUser(id); |
| | | regionInspectionMapper.deleteInspectionHazardInform(id); |
| | | regionInspectionRecordMapper.deleteByRegionInspectionId(id); |
| | | return BasicResult.success(); |
| | | } |
| | | |