吴羡
7 小时以前 2f07589b54d56085af77b50d580890cd4130b444
cnas-device/src/main/java/com/ruoyi/device/service/impl/DeviceScrappedServiceImpl.java
@@ -7,6 +7,7 @@
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;
@@ -15,6 +16,7 @@
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;
@@ -66,6 +68,7 @@
        DeviceScrapped scrapped = new DeviceScrapped();
        // 当前登录用户信息和部门
        User user = userMapper.selectById(SecurityUtils.getUserId().intValue());
        checkFlowPermission(deviceScrapped, user);
        switch (deviceScrapped.getFlowType()) {
            case 0:
                BeanUtils.copyProperties(deviceScrapped, scrapped);
@@ -74,11 +77,6 @@
                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;
@@ -121,6 +119,40 @@
        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());
            }
        }
    }
    /**
     * 导出设备报废申请
     *
@@ -150,13 +182,13 @@
                    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 {