| | |
| | | package org.springblade.modules.task.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import liquibase.repackaged.org.apache.commons.lang3.StringUtils; |
| | | import org.springblade.common.constant.CommonConstant; |
| | | import org.springblade.common.constant.DictConstant; |
| | | import org.springblade.common.exception.CustomException; |
| | | import org.springblade.common.param.CommonParamSet; |
| | | import org.springblade.common.utils.AuthUtils; |
| | | import org.springblade.common.utils.SpringUtils; |
| | |
| | | import org.springblade.core.tool.utils.SpringUtil; |
| | | import org.springblade.modules.system.entity.DictBiz; |
| | | import org.springblade.modules.system.service.IDictBizService; |
| | | import org.springblade.modules.task.service.ITaskService; |
| | | import org.springblade.modules.task.entity.TaskPlaceRecordEntity; |
| | | import org.springblade.modules.task.service.ITaskPlaceRecordService; |
| | | import org.springblade.modules.task.vo.TaskPlaceRecordVO; |
| | | import org.springblade.modules.task.dto.TaskPlaceSelfCheckDTO; |
| | | import org.springblade.modules.task.entity.TaskEntity; |
| | | import org.springblade.modules.task.entity.TaskPlaceRecordEntity; |
| | | import org.springblade.modules.task.entity.TaskPlaceSelfCheckEntity; |
| | | import org.springblade.modules.task.excel.TaskPlaceSelfCheckExcel; |
| | | import org.springblade.modules.task.vo.TaskPlaceSelfCheckVO; |
| | | import org.springblade.modules.task.mapper.TaskPlaceSelfCheckMapper; |
| | | import org.springblade.modules.task.service.ITaskPlaceRecordService; |
| | | import org.springblade.modules.task.service.ITaskPlaceSelfCheckService; |
| | | import org.springblade.modules.task.service.ITaskService; |
| | | import org.springblade.modules.task.vo.TaskPlaceRecordVO; |
| | | import org.springblade.modules.task.vo.TaskPlaceSelfCheckVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.concurrent.atomic.AtomicBoolean; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean savePlace(TaskPlaceSelfCheckVO taskPlaceSelfCheck) throws Exception { |
| | | public Boolean savePlace(TaskPlaceSelfCheckVO taskPlaceSelfCheck) { |
| | | taskPlaceSelfCheck.setCreateUser(AuthUtil.getUserId()); |
| | | // 1.保存任务表 |
| | | ITaskService bean2 = SpringUtils.getBean(ITaskService.class); |
| | | Long aLong = bean2.saveTask(CommonConstant.NUMBER_ONE, DictConstant.FIRE_SELF_CHECK_NOTICE, 1, |
| | | "", AuthUtil.getUserId(), taskPlaceSelfCheck.getHouseCode(), CommonConstant.NUMBER_TWO, 1); |
| | | if (aLong <= 0) { |
| | | return false; |
| | | ITaskService iTaskService = SpringUtils.getBean(ITaskService.class); |
| | | Long restults; |
| | | AtomicBoolean isState = new AtomicBoolean(false); |
| | | List<TaskPlaceRecordVO> taskPlaceRecordList = taskPlaceSelfCheck.getTaskPlaceRecordVOList(); |
| | | for (TaskPlaceRecordVO taskPlaceRecordVO : taskPlaceRecordList) { |
| | | // 判断类型 |
| | | if (StringUtils.isNotBlank(taskPlaceSelfCheck.getType()) && taskPlaceSelfCheck.getType().equals("2")) { |
| | | taskPlaceRecordVO.setType("3"); |
| | | } else { |
| | | taskPlaceRecordVO.setType("1"); |
| | | } |
| | | // 判断是否有隐患 |
| | | if (taskPlaceRecordVO.getState().equals(0)) { |
| | | isState.set(true); |
| | | } |
| | | } |
| | | taskPlaceSelfCheck.setTaskId(aLong); |
| | | if (taskPlaceSelfCheck.getTaskId() == null) { |
| | | if (StringUtils.isNotBlank(taskPlaceSelfCheck.getType()) && taskPlaceSelfCheck.getType().equals("2")) { |
| | | // 不存在隐患。状态直接为已审核 |
| | | if (!isState.get()) { |
| | | taskPlaceSelfCheck.setStatus(2); |
| | | taskPlaceSelfCheck.setRectificationFlag(3); |
| | | } else { |
| | | taskPlaceSelfCheck.setStatus(1); |
| | | taskPlaceSelfCheck.setRectificationFlag(1); |
| | | } |
| | | restults = iTaskService.saveTask(CommonConstant.NUMBER_ONE, DictConstant.FIRE_SCHOOL_CHECK_NOTICE, 1, |
| | | "", AuthUtil.getUserId(), taskPlaceSelfCheck.getHouseCode(), CommonConstant.NUMBER_FOUR, taskPlaceSelfCheck.getStatus()); |
| | | } else { |
| | | restults = iTaskService.saveTask(CommonConstant.NUMBER_ONE, DictConstant.FIRE_SELF_CHECK_NOTICE, 1, |
| | | "", AuthUtil.getUserId(), taskPlaceSelfCheck.getHouseCode(), CommonConstant.NUMBER_SEVEN, 1); |
| | | } |
| | | if (restults <= 0) { |
| | | return false; |
| | | } |
| | | taskPlaceSelfCheck.setTaskId(restults); |
| | | } else { |
| | | iTaskService.update(Wrappers.<TaskEntity>lambdaUpdate() |
| | | .set(TaskEntity::getStatus, taskPlaceSelfCheck.getStatus()) |
| | | .eq(TaskEntity::getId, taskPlaceSelfCheck.getTaskId())); |
| | | } |
| | | |
| | | // 2.保存任务详情 |
| | | boolean save = save(taskPlaceSelfCheck); |
| | | boolean save = saveOrUpdate(taskPlaceSelfCheck); |
| | | if (save) { |
| | | // 3.保存题目记录 |
| | | List<TaskPlaceRecordVO> taskPlaceRecordList = taskPlaceSelfCheck.getTaskPlaceRecordVOList(); |
| | | ITaskPlaceRecordService bean = SpringUtil.getBean(ITaskPlaceRecordService.class); |
| | | taskPlaceRecordList.stream().forEach(item -> { |
| | | item.setTaskPlaceSelfCheckId(taskPlaceSelfCheck.getId()); |
| | | item.setCreateUser(AuthUtil.getUserId()); |
| | | }); |
| | | List<TaskPlaceRecordEntity> collect = taskPlaceRecordList.stream().filter(item -> item.getState().equals(0)).collect(Collectors.toList()); |
| | | ITaskPlaceRecordService taskPlaceRecordService = SpringUtil.getBean(ITaskPlaceRecordService.class); |
| | | List<TaskPlaceRecordEntity> collect = taskPlaceRecordList.stream().collect(Collectors.toList()); |
| | | if (collect.size() > 0) { |
| | | bean.saveBatch(collect); |
| | | taskPlaceRecordService.saveBatch(collect); |
| | | } |
| | | updateById(taskPlaceSelfCheck); |
| | | return save; |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public Boolean updateTaskPlaceSelfCheck(TaskPlaceSelfCheckVO taskPlaceSelfCheck) throws Exception { |
| | | @Transactional |
| | | public Boolean updateTaskPlaceSelfCheck(TaskPlaceSelfCheckVO taskPlaceSelfCheck) { |
| | | // 1.更新任务表 |
| | | ITaskService taskService = SpringUtils.getBean(ITaskService.class); |
| | | Long aLong = taskService.updateTask(null, null, null, taskPlaceSelfCheck.getReasonFailure(), AuthUtil.getUserId(), taskPlaceSelfCheck.getTaskId(), taskPlaceSelfCheck.getStatus()); |
| | |
| | | List<TaskPlaceRecordVO> taskPlaceRecordList = taskPlaceSelfCheck.getTaskPlaceRecordVOList(); |
| | | if (taskPlaceRecordList != null && taskPlaceRecordList.size() > 0) { |
| | | ITaskPlaceRecordService bean = SpringUtil.getBean(ITaskPlaceRecordService.class); |
| | | List<TaskPlaceRecordEntity> copy = BeanUtil.copy(taskPlaceRecordList, TaskPlaceRecordEntity.class); |
| | | boolean b = bean.saveOrUpdateBatch(copy); |
| | | if (b) { |
| | | return b; |
| | | List<TaskPlaceRecordEntity> placeRecordEntityList = BeanUtil.copy(taskPlaceRecordList, TaskPlaceRecordEntity.class); |
| | | boolean updateBatch = bean.saveOrUpdateBatch(placeRecordEntityList); |
| | | if (updateBatch) { |
| | | return updateBatch; |
| | | } |
| | | throw new Exception("保存失败!"); |
| | | throw new CustomException("保存失败!"); |
| | | } |
| | | return save; |
| | | } |
| | | throw new Exception("保存失败!"); |
| | | throw new CustomException("保存失败!"); |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | |
| | | @Override |
| | | public Integer getCount(String neiCode, int i) { |
| | | public Integer getCount(String neiCode, int status, int type) { |
| | | // 获取请求头中的角色别名 |
| | | String roleName = SpringUtils.getRequestParam("roleName"); |
| | | if (AuthUtils.isMj(roleName)) { |
| | | return baseMapper.getCount(neiCode, i, AuthUtil.getUserId()); |
| | | return baseMapper.getCount(neiCode, status, AuthUtil.getUserId(), type); |
| | | } |
| | | return 0; |
| | | } |
| | | |
| | | @Override |
| | | public TaskPlaceSelfCheckEntity getDetailByTaskId(Long taskId) { |
| | | return baseMapper.getDetailByTaskId(taskId); |
| | | } |
| | | } |