| | |
| | | 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.DeviceBreakdownMaintenance; |
| | |
| | | import com.ruoyi.device.mapper.DeviceMapper; |
| | | import com.ruoyi.device.pojo.Device; |
| | | import com.ruoyi.device.service.DeviceBreakdownMaintenanceService; |
| | | import com.ruoyi.device.util.DeviceFlowPermissionUtils; |
| | | import com.ruoyi.inspect.util.UserUtils; |
| | | import com.ruoyi.system.mapper.UserMapper; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | DeviceBreakdownMaintenance breakdownMaintenance = new DeviceBreakdownMaintenance(); |
| | | //当前登录用户 |
| | | User user = userMapper.selectById(SecurityUtils.getUserId().intValue()); |
| | | checkFlowPermission(deviceBreakdownMaintenance, user); |
| | | |
| | | switch (deviceBreakdownMaintenance.getFlowType()) { |
| | | case 0: |
| | |
| | | breakdownMaintenance.setApplicantUserId(user.getId()); |
| | | breakdownMaintenance.setApplicantUser(user.getName()); |
| | | breakdownMaintenance.setRepairDate(deviceBreakdownMaintenance.getRepairDate()); |
| | | |
| | | // 处理人信息 |
| | | User departmentHeadUser = userMapper.selectById(deviceBreakdownMaintenance.getDepartmentHeadUserId()); |
| | | breakdownMaintenance.setApplicantUserId(departmentHeadUser.getId()); |
| | | breakdownMaintenance.setApplicantUser(departmentHeadUser.getName()); |
| | | |
| | | baseMapper.insert(breakdownMaintenance); |
| | | break; |
| | |
| | | break; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | private void checkFlowPermission(DeviceBreakdownMaintenance deviceBreakdownMaintenance, User user) { |
| | | Integer flowType = deviceBreakdownMaintenance.getFlowType(); |
| | | Integer maintenanceId = deviceBreakdownMaintenance.getMaintenanceId(); |
| | | if (flowType != null && flowType > 0) { |
| | | DeviceBreakdownMaintenance existing = baseMapper.selectById(maintenanceId); |
| | | if (existing == null) { |
| | | throw new ServiceException("单据不存在"); |
| | | } |
| | | DeviceFlowPermissionUtils.checkFinished(existing.getIsFinish()); |
| | | Integer expectedUserId; |
| | | switch (flowType) { |
| | | case 1: |
| | | expectedUserId = existing.getDepartmentHeadUserId(); |
| | | break; |
| | | case 2: |
| | | // 维修记录环节未单独指定责任人,由申请人填写维修结果 |
| | | expectedUserId = existing.getApplicantUserId(); |
| | | break; |
| | | default: |
| | | expectedUserId = null; |
| | | break; |
| | | } |
| | | DeviceFlowPermissionUtils.checkResponsible(expectedUserId, user.getId()); |
| | | } else if (maintenanceId != null) { |
| | | DeviceBreakdownMaintenance existing = baseMapper.selectById(maintenanceId); |
| | | if (existing != null) { |
| | | DeviceFlowPermissionUtils.checkFinished(existing.getIsFinish()); |
| | | DeviceFlowPermissionUtils.checkResponsible(existing.getApplicantUserId(), user.getId()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | put("deviceBreakdownMaintenance", deviceBreakdownMaintenance); |
| | | put("device", finalDevice); |
| | | // 申请人签名 |
| | | put("applicantUrl", UserUtils.getFinalUserSignatureUrl(deviceBreakdownMaintenance.getApplicantUserId())); |
| | | put("applicantUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceBreakdownMaintenance.getApplicantUserId())); |
| | | // 部门负责人签名 |
| | | put("headUrl", UserUtils.getFinalUserSignatureUrl(deviceBreakdownMaintenance.getDepartmentHeadUserId())); |
| | | put("headUrl", UserUtils.getFinalUserSignatureOrTransparent(deviceBreakdownMaintenance.getDepartmentHeadUserId())); |
| | | }}); |
| | | |
| | | try { |