| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | |
| | | @Override |
| | | public List<DailySafetyInspection> selectDailySafetyInspectionList(DailySafetyInspection inspection) { |
| | | boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId()); |
| | | if (!admin){ |
| | | boolean sysAdmin = SecurityUtils.hasRole(Constants.SYS_ADMIN); |
| | | boolean placeSafetyOfficer = SecurityUtils.hasRole(Constants.PLACE_SAFETY_OFFICER); |
| | | if (!(sysAdmin || placeSafetyOfficer)) { |
| | | inspection.setCreateById(SecurityUtils.getUserId()); |
| | | } |
| | | } |
| | | return dailySafetyInspectionMapper.getDailySafetyInspectionList(inspection); |
| | | } |
| | | |
| | |
| | | // } |
| | | |
| | | int i = 0; |
| | | |
| | | if (inspection.getId() == null) { |
| | | inspection.setCreateTime(LocalDateTime.now()); |
| | | inspection.setCreateBy(SecurityUtils.getUsername()); |
| | | inspection.setCreateById(SecurityUtils.getUserId()); |
| | | i = dailySafetyInspectionMapper.insert(inspection); |
| | | } else { |
| | | inspection.setUpdateTime(LocalDateTime.now()); |
| | | inspection.setUpdateBy(SecurityUtils.getUsername()); |
| | | inspection.setUpdateById(SecurityUtils.getUserId()); |
| | | i = dailySafetyInspectionMapper.updateById(inspection); |
| | | } |
| | | if (i > 0){ |
| | | if (i > 0 && ObjectUtil.isNotEmpty(inspection.getDailySafetyInspectionDepts())){ |
| | | saveDailySafetyInspectionDept(inspection.getDailySafetyInspectionDepts(),inspection.getId()); |
| | | } |
| | | // if (i > 0) { |
| | |
| | | return dailySafetyInspectionMapper.update(new DailySafetyInspection(), |
| | | new LambdaUpdateWrapper<DailySafetyInspection>().eq(DailySafetyInspection::getId, id) |
| | | .set(DailySafetyInspection::getDelFlag, Constants.FAIL).set(DailySafetyInspection::getUpdateTime, LocalDateTime.now()) |
| | | .set(DailySafetyInspection::getUpdateBy, SecurityUtils.getUsername())); |
| | | .set(DailySafetyInspection::getUpdateBy, SecurityUtils.getUsername()).set(DailySafetyInspection::getUpdateById, SecurityUtils.getUserId())); |
| | | } |
| | | |
| | | @Override |
| | | public int getCheckCount() { |
| | | Long deptId = SecurityUtils.getDeptId(); |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(deptId); |
| | | if (sysDept == null){ |
| | | Long[] deptIds = SecurityUtils.getDeptIds(); |
| | | if (ObjectUtil.isEmpty(deptIds)){ |
| | | return 1; |
| | | }else { |
| | | if (!"1".equals(sysDept.getSafety())){ |
| | | return 1; |
| | | } |
| | | List<SysDept> sysDepts = sysDeptMapper.selectDeptByIds(deptIds); |
| | | if (ObjectUtil.isEmpty(sysDepts)){ |
| | | return 1; |
| | | } |
| | | List<Long> data = new ArrayList<>(); |
| | | for (SysDept sysDept : sysDepts) { |
| | | if ("1".equals(sysDept.getSafety())){ |
| | | data.add(sysDept.getDeptId()); |
| | | } |
| | | } |
| | | return dailySafetyInspectionMapper.getCheckCount(deptId); |
| | | if (ObjectUtil.isEmpty(data)){ |
| | | return 1; |
| | | } |
| | | return dailySafetyInspectionMapper.getCheckCountList(data); |
| | | |
| | | // Long deptId = SecurityUtils.getDeptId(); |
| | | // SysDept sysDept = sysDeptMapper.selectDeptById(deptId); |
| | | // if (sysDept == null){ |
| | | // return 1; |
| | | // }else { |
| | | // if (!"1".equals(sysDept.getSafety())){ |
| | | // return 1; |
| | | // } |
| | | // } |
| | | // return dailySafetyInspectionMapper.getCheckCount(deptId); |
| | | } |
| | | |
| | | |
| | | private void checkPer(){ |
| | | boolean admin = SecurityUtils.isAdmin(SecurityUtils.getUserId()); |
| | | if (!admin){ |
| | | boolean sysAdmin = SecurityUtils.hasRole(Constants.SYS_ADMIN); |
| | | if (!sysAdmin){ |
| | | throw new ServiceException("没有权限"); |
| | | } |
| | | boolean placeSafetyOfficer = SecurityUtils.hasRole(Constants.PLACE_SAFETY_OFFICER); |
| | | if (!placeSafetyOfficer){ |
| | | throw new ServiceException("没有权限"); |
| | | } |
| | | |
| | | } |
| | | |
| | | } |
| | | } |