| | |
| | | import com.gkhy.common.exception.ServiceException; |
| | | import com.gkhy.common.utils.SecurityUtils; |
| | | import com.gkhy.system.domain.DailySafetyInspection; |
| | | import com.gkhy.system.domain.DailySafetyInspectionDept; |
| | | import com.gkhy.system.domain.DailySafetyInspectionUser; |
| | | import com.gkhy.system.mapper.DailySafetyInspectionDeptMapper; |
| | | import com.gkhy.system.mapper.DailySafetyInspectionMapper; |
| | | import com.gkhy.system.mapper.DailySafetyInspectionUserMapper; |
| | | import com.gkhy.system.mapper.SysDeptMapper; |
| | |
| | | private DailySafetyInspectionUserMapper dailySafetyInspectionUserMapper; |
| | | |
| | | @Autowired |
| | | private DailySafetyInspectionDeptMapper dailySafetyInspectionDeptMapper; |
| | | |
| | | @Autowired |
| | | private SysDeptMapper sysDeptMapper; |
| | | |
| | | @Override |
| | |
| | | // if (ObjectUtil.isEmpty(dailySafetyInspectionUsers)) { |
| | | // throw new ServiceException("参检人员不能为空"); |
| | | // } |
| | | Long researchGroup = inspection.getResearchGroup(); |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(researchGroup); |
| | | if (sysDept == null) { |
| | | throw new ServiceException("部门不存在"); |
| | | } |
| | | if (!"1".equals(sysDept.getSafety())){ |
| | | throw new ServiceException("所选部门未开启安全检查"); |
| | | } |
| | | // Long researchGroup = inspection.getResearchGroup(); |
| | | // SysDept sysDept = sysDeptMapper.selectDeptById(researchGroup); |
| | | // if (sysDept == null) { |
| | | // throw new ServiceException("部门不存在"); |
| | | // } |
| | | // if (!"1".equals(sysDept.getSafety())){ |
| | | // throw new ServiceException("所选部门未开启安全检查"); |
| | | // } |
| | | |
| | | int i = 0; |
| | | if (inspection.getId() == null) { |
| | |
| | | inspection.setUpdateTime(LocalDateTime.now()); |
| | | inspection.setUpdateBy(SecurityUtils.getUsername()); |
| | | i = dailySafetyInspectionMapper.updateById(inspection); |
| | | } |
| | | if (i > 0){ |
| | | saveDailySafetyInspectionDept(inspection.getDailySafetyInspectionDepts(),inspection.getId()); |
| | | } |
| | | // if (i > 0) { |
| | | // saveDailySafetyInspectionUser(dailySafetyInspectionUsers, inspection.getId()); |
| | |
| | | }); |
| | | |
| | | } |
| | | private void saveDailySafetyInspectionDept(List<DailySafetyInspectionDept> dailySafetyInspectionDepts, Long id) { |
| | | |
| | | DailySafetyInspectionDept dept = new DailySafetyInspectionDept(); |
| | | dept.setDailySafetyInspectionId(id); |
| | | dailySafetyInspectionDeptMapper.deleteById(dept); |
| | | dailySafetyInspectionDepts.forEach(dept1 -> { |
| | | dept1.setDailySafetyInspectionId(id); |
| | | dailySafetyInspectionDeptMapper.insert(dept1); |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public int deleteDailySafetyInspection(Long id) { |