| | |
| | | |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicReference; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 场所检查表 服务实现类 |
| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean savePlace(PlaceCheckVO placeCheck) throws Exception { |
| | | placeCheck.setCreateUser(AuthUtil.getUserId()); |
| | | List<PatrolRecord> patrolRecordVOList = placeCheck.getPatrolRecordVOList(); |
| | | AtomicReference<Integer> number = new AtomicReference<>(0); |
| | | patrolRecordVOList.stream().forEach(item -> { |
| | | if (item.getState().equals(0)) { |
| | | number.getAndSet(number.get() + 1); |
| | | } |
| | | }); |
| | | placeCheck.setHiddenDangerNumber(number.get()); |
| | | boolean save = save(placeCheck); |
| | | if (save) { |
| | | IPatrolRecordService bean = SpringUtil.getBean(IPatrolRecordService.class); |
| | | List<PatrolRecord> patrolRecordVOList = placeCheck.getPatrolRecordVOList(); |
| | | AtomicReference<Integer> number = new AtomicReference<>(0); |
| | | patrolRecordVOList.stream().forEach(item -> { |
| | | item.setPlaceCheckId(placeCheck.getId()); |
| | | item.setCreateUser(AuthUtil.getUserId()); |
| | | if (item.getState().equals(0)) { |
| | | number.getAndSet(number.get() + 1); |
| | | } |
| | | }); |
| | | boolean b = bean.saveBatch(patrolRecordVOList); |
| | | List<PatrolRecord> collect = patrolRecordVOList.stream().filter(item -> item.getState().equals(0)).collect(Collectors.toList()); |
| | | boolean b = bean.saveBatch(collect); |
| | | updateById(placeCheck); |
| | | if (b) { |
| | | // 隐患问题大于0 则创建任务 |
| | | try { |
| | |
| | | // 保存任务表 |
| | | ITaskService bean2 = SpringUtils.getBean(ITaskService.class); |
| | | Long aLong = bean2.saveTask(CommonConstant.NUMBER_FOUR, DictConstant.FIRE_RECTIFICATION_NOTICE, 1, |
| | | "", AuthUtil.getUserId(), placeCheck.getHouseCode(), CommonConstant.NUMBER_EIGHT); |
| | | "", AuthUtil.getUserId(), placeCheck.getHouseCode(), CommonConstant.NUMBER_EIGHT,4); |
| | | if (aLong > 0) { |
| | | // 保存任务详情表 |
| | | ITaskPlaceRectificationService bean1 = SpringUtil.getBean(ITaskPlaceRectificationService.class); |
| | |
| | | copy.setTaskId(aLong); |
| | | copy.setPlaceCheckId(placeCheck.getId()); |
| | | copy.setId(null); |
| | | copy.setStatus(4); |
| | | bean1.save(copy); |
| | | } |
| | | } |