| | |
| | | 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.mapper.DeviceExternalApplyMapper; |
| | | import com.ruoyi.device.pojo.DeviceExternalApply; |
| | | import com.ruoyi.device.service.DeviceExternalApplyService; |
| | | import com.ruoyi.device.util.DeviceFlowPermissionUtils; |
| | | import com.ruoyi.inspect.util.UserUtils; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | DeviceExternalApply apply = new DeviceExternalApply(); |
| | | // 当前登录用户信息和部门 |
| | | User user = userMapper.selectById(SecurityUtils.getUserId().intValue()); |
| | | checkFlowPermission(deviceExternalApply, user); |
| | | switch (deviceExternalApply.getFlowType()) { |
| | | case 0: |
| | | BeanUtils.copyProperties(deviceExternalApply, apply); |
| | |
| | | apply.setApplicantUserId(user.getId()); |
| | | apply.setApplicantUser(user.getName()); |
| | | apply.setApplicantDate(LocalDate.now()); |
| | | |
| | | // 处理人信息 |
| | | User departmentHeadUser = userMapper.selectById(deviceExternalApply.getDepartmentHeadUserId()); |
| | | apply.setApplicantUserId(departmentHeadUser.getId()); |
| | | apply.setApplicantUser(departmentHeadUser.getName()); |
| | | |
| | | baseMapper.insert(apply); |
| | | break; |
| | |
| | | return true; |
| | | } |
| | | |
| | | private void checkFlowPermission(DeviceExternalApply deviceExternalApply, User user) { |
| | | Integer flowType = deviceExternalApply.getFlowType(); |
| | | Integer externalApplyId = deviceExternalApply.getExternalApplyId(); |
| | | if (flowType != null && flowType > 0) { |
| | | DeviceExternalApply existing = baseMapper.selectById(externalApplyId); |
| | | if (existing == null) { |
| | | throw new ServiceException("单据不存在"); |
| | | } |
| | | DeviceFlowPermissionUtils.checkFinished(existing.getIsFinish()); |
| | | Integer expectedUserId; |
| | | switch (flowType) { |
| | | case 1: |
| | | expectedUserId = existing.getDepartmentHeadUserId(); |
| | | break; |
| | | case 2: |
| | | expectedUserId = existing.getMeteringRoomUserId(); |
| | | break; |
| | | case 3: |
| | | expectedUserId = existing.getApproverUserId(); |
| | | break; |
| | | default: |
| | | expectedUserId = null; |
| | | break; |
| | | } |
| | | DeviceFlowPermissionUtils.checkResponsible(expectedUserId, user.getId()); |
| | | } else if (externalApplyId != null) { |
| | | DeviceExternalApply existing = baseMapper.selectById(externalApplyId); |
| | | if (existing != null) { |
| | | DeviceFlowPermissionUtils.checkFinished(existing.getIsFinish()); |
| | | DeviceFlowPermissionUtils.checkResponsible(existing.getApplicantUserId(), user.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导出利用外部设备申请 |
| | | * |
| | |
| | | new HashMap<String, Object>() {{ |
| | | put("deviceAccidentReport", deviceAccidentReport); |
| | | // 申请人签名 |
| | | put("applicantUserUrl", UserUtils.getFinalUserSignatureUrl(deviceAccidentReport.getApplicantUserId())); |
| | | put("applicantUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceAccidentReport.getApplicantUserId())); |
| | | // 部门负责人签名 |
| | | put("departmentHeadUserUrl", UserUtils.getFinalUserSignatureUrl(deviceAccidentReport.getDepartmentHeadUserId())); |
| | | put("departmentHeadUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceAccidentReport.getDepartmentHeadUserId())); |
| | | // 计量室人签名 |
| | | put("meteringRoomUserUrl", UserUtils.getFinalUserSignatureUrl(deviceAccidentReport.getMeteringRoomUserId())); |
| | | put("meteringRoomUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceAccidentReport.getMeteringRoomUserId())); |
| | | // 批准人签名 |
| | | put("approverUserUrl", UserUtils.getFinalUserSignatureUrl(deviceAccidentReport.getApproverUserId())); |
| | | put("approverUserUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceAccidentReport.getApproverUserId())); |
| | | }}); |
| | | |
| | | try { |