| | |
| | | import com.deepoove.poi.config.Configure; |
| | | import com.ruoyi.common.core.domain.Result; |
| | | 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.DeviceScrappedDto; |
| | |
| | | import com.ruoyi.device.pojo.Device; |
| | | import com.ruoyi.device.pojo.DeviceScrapped; |
| | | import com.ruoyi.device.service.DeviceScrappedService; |
| | | import com.ruoyi.device.util.DeviceFlowPermissionUtils; |
| | | import com.ruoyi.inspect.util.UserUtils; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | DeviceScrapped scrapped = new DeviceScrapped(); |
| | | // 当前登录用户信息和部门 |
| | | User user = userMapper.selectById(SecurityUtils.getUserId().intValue()); |
| | | checkFlowPermission(deviceScrapped, user); |
| | | switch (deviceScrapped.getFlowType()) { |
| | | case 0: |
| | | BeanUtils.copyProperties(deviceScrapped, scrapped); |
| | |
| | | scrapped.setApplicantUserId(user.getId()); |
| | | scrapped.setApplicantUser(user.getName()); |
| | | scrapped.setApplicantDate(LocalDate.now()); |
| | | |
| | | // 处理人信息 |
| | | User departmentHeadUser = userMapper.selectById(deviceScrapped.getDepartmentHeadUserId()); |
| | | scrapped.setApplicantUserId(departmentHeadUser.getId()); |
| | | scrapped.setApplicantUser(departmentHeadUser.getName()); |
| | | |
| | | baseMapper.insert(scrapped); |
| | | break; |
| | |
| | | return true; |
| | | } |
| | | |
| | | private void checkFlowPermission(DeviceScrapped deviceScrapped, User user) { |
| | | Integer flowType = deviceScrapped.getFlowType(); |
| | | Integer scrappedId = deviceScrapped.getScrappedId(); |
| | | if (flowType != null && flowType > 0) { |
| | | DeviceScrapped existing = baseMapper.selectById(scrappedId); |
| | | 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 (scrappedId != null) { |
| | | DeviceScrapped existing = baseMapper.selectById(scrappedId); |
| | | if (existing != null) { |
| | | DeviceFlowPermissionUtils.checkFinished(existing.getIsFinish()); |
| | | DeviceFlowPermissionUtils.checkResponsible(existing.getApplicantUserId(), user.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 导出设备报废申请 |
| | | * |
| | |
| | | put("deviceScrapped", deviceScrapped); |
| | | put("device", finalDevice); |
| | | // 申请人签名 |
| | | put("applicantUrl", UserUtils.getFinalUserSignatureUrl(deviceScrapped.getApplicantUserId())); |
| | | put("applicantUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceScrapped.getApplicantUserId())); |
| | | // 部门负责人签名 |
| | | put("headUrl", UserUtils.getFinalUserSignatureUrl(deviceScrapped.getDepartmentHeadUserId())); |
| | | put("headUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceScrapped.getDepartmentHeadUserId())); |
| | | // 计量室签名 |
| | | put("metrologyRoomUrl", UserUtils.getFinalUserSignatureUrl(deviceScrapped.getMeteringRoomUserId())); |
| | | put("metrologyRoomUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceScrapped.getMeteringRoomUserId())); |
| | | // 批准人签名 |
| | | put("approverUrl", UserUtils.getFinalUserSignatureUrl(deviceScrapped.getApproverUserId())); |
| | | put("approverUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceScrapped.getApproverUserId())); |
| | | }}); |
| | | |
| | | try { |