| | |
| | | import com.deepoove.poi.XWPFTemplate; |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.ruoyi.common.core.domain.entity.User; |
| | | import com.ruoyi.common.exception.ServiceException; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.device.dto.DeviceAccidentReportDto; |
| | |
| | | import com.ruoyi.device.pojo.Device; |
| | | import com.ruoyi.device.pojo.DeviceAccidentReport; |
| | | import com.ruoyi.device.service.DeviceAccidentReportService; |
| | | import com.ruoyi.device.util.DeviceFlowPermissionUtils; |
| | | import com.ruoyi.inspect.util.UserUtils; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | public boolean addDeviceAccidentReport(DeviceAccidentReport deviceAccidentReport) { |
| | | DeviceAccidentReport accidentReport = new DeviceAccidentReport(); |
| | | User user = userMapper.selectById(SecurityUtils.getUserId().intValue()); |
| | | checkFlowPermission(deviceAccidentReport, user); |
| | | switch (deviceAccidentReport.getFlowType()) { |
| | | case 0: |
| | | // 报告 |
| | |
| | | return true; |
| | | } |
| | | |
| | | private void checkFlowPermission(DeviceAccidentReport deviceAccidentReport, User user) { |
| | | Integer flowType = deviceAccidentReport.getFlowType(); |
| | | Integer accidentReportId = deviceAccidentReport.getAccidentReportId(); |
| | | if (flowType != null && flowType > 0) { |
| | | DeviceAccidentReport existing = baseMapper.selectById(accidentReportId); |
| | | if (existing == null) { |
| | | throw new ServiceException("单据不存在"); |
| | | } |
| | | DeviceFlowPermissionUtils.checkFinished(existing.getIsFinish()); |
| | | Integer expectedUserId; |
| | | switch (flowType) { |
| | | case 1: |
| | | expectedUserId = existing.getAssessorUserId(); |
| | | break; |
| | | case 2: |
| | | expectedUserId = existing.getDepartmentHeadUserId(); |
| | | break; |
| | | case 3: |
| | | expectedUserId = existing.getTechnicalDirectorUserId(); |
| | | break; |
| | | case 4: |
| | | expectedUserId = existing.getDirectorHeadUserId(); |
| | | break; |
| | | default: |
| | | expectedUserId = null; |
| | | break; |
| | | } |
| | | DeviceFlowPermissionUtils.checkResponsible(expectedUserId, user.getId()); |
| | | } else if (accidentReportId != null) { |
| | | DeviceAccidentReport existing = baseMapper.selectById(accidentReportId); |
| | | if (existing != null) { |
| | | DeviceFlowPermissionUtils.checkFinished(existing.getIsFinish()); |
| | | DeviceFlowPermissionUtils.checkResponsible(existing.getReportUserId(), user.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导出设备事故报告 |
| | | * @param accidentReportId 设备事故报告id |
| | |
| | | put("deviceAccidentReport", deviceAccidentReport); |
| | | put("device", finalDevice); |
| | | // 报告人签名 |
| | | put("reportUserUrl", UserUtils.getFinalUserSignatureUrl(deviceAccidentReport.getReportUserId())); |
| | | put("reportUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceAccidentReport.getReportUserId())); |
| | | // 评估人签名 |
| | | put("assessorUserUrl", UserUtils.getFinalUserSignatureUrl(deviceAccidentReport.getAssessorUserId())); |
| | | put("assessorUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceAccidentReport.getAssessorUserId())); |
| | | // 部门负责人签名 |
| | | put("departmentHeadUserUrl", UserUtils.getFinalUserSignatureUrl(deviceAccidentReport.getDepartmentHeadUserId())); |
| | | put("departmentHeadUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceAccidentReport.getDepartmentHeadUserId())); |
| | | // 技术负责人签名 |
| | | put("technicalDirectorUserUrl", UserUtils.getFinalUserSignatureUrl(deviceAccidentReport.getTechnicalDirectorUserId())); |
| | | put("technicalDirectorUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceAccidentReport.getTechnicalDirectorUserId())); |
| | | // 主任签名 |
| | | put("directorHeadUserUrl", UserUtils.getFinalUserSignatureUrl(deviceAccidentReport.getDepartmentHeadUserId())); |
| | | put("directorHeadUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceAccidentReport.getDirectorHeadUserId())); |
| | | }}); |
| | | |
| | | try { |