From efd594b160a4e35f499eb54ffa0c5b06326cbe1c Mon Sep 17 00:00:00 2001
From: gongchunyi <deslre0381@gmail.com>
Date: 星期四, 23 四月 2026 11:51:15 +0800
Subject: [PATCH] feat: 删除设备保修时也删除对应的上传附件
---
src/main/java/com/ruoyi/device/controller/DeviceRepairController.java | 116 +++++++++++++++++++++-------------------------------------
1 files changed, 42 insertions(+), 74 deletions(-)
diff --git a/src/main/java/com/ruoyi/device/controller/DeviceRepairController.java b/src/main/java/com/ruoyi/device/controller/DeviceRepairController.java
index 130e5df..6933851 100644
--- a/src/main/java/com/ruoyi/device/controller/DeviceRepairController.java
+++ b/src/main/java/com/ruoyi/device/controller/DeviceRepairController.java
@@ -1,31 +1,21 @@
package com.ruoyi.device.controller;
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.ruoyi.approve.pojo.ApproveProcess;
-import com.ruoyi.approve.service.IApproveProcessService;
-import com.ruoyi.approve.vo.ApproveProcessVO;
-import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.device.dto.DeviceRepairDto;
-import com.ruoyi.device.pojo.DeviceLedger;
import com.ruoyi.device.pojo.DeviceRepair;
import com.ruoyi.device.service.IDeviceLedgerService;
import com.ruoyi.device.service.IDeviceRepairService;
-import com.ruoyi.framework.security.LoginUser;
import com.ruoyi.framework.web.domain.AjaxResult;
-import com.ruoyi.project.system.domain.SysDept;
-import com.ruoyi.project.system.domain.SysUser;
+import com.ruoyi.sales.pojo.CommonFile;
import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiModelProperty;
+import io.swagger.annotations.ApiOperation;
+import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
-import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
import java.util.Arrays;
import java.util.List;
@@ -39,86 +29,42 @@
@Autowired
private IDeviceLedgerService deviceLedgerService;
- @Autowired
- private IApproveProcessService approveProcessService;
- @ApiModelProperty("璁惧鎶ヤ慨鍒楄〃")
+ @ApiOperation("璁惧鎶ヤ慨鍒楄〃")
@GetMapping("/page")
- public AjaxResult page(Page page , DeviceRepairDto deviceRepairDto) {
- return AjaxResult.success(deviceRepairService.queryPage(page,deviceRepairDto));
+ public AjaxResult page(Page page, DeviceRepairDto deviceRepairDto) {
+ return AjaxResult.success(deviceRepairService.queryPage(page, deviceRepairDto));
}
@PostMapping()
- @Transactional(rollbackFor = Exception.class)
- @ApiModelProperty("娣诲姞璁惧鎶ヤ慨")
- public AjaxResult add( @RequestBody DeviceRepair deviceRepair) throws Exception {
- deviceRepairService.saveDeviceRepair(deviceRepair);
- ApproveProcessVO approveProcessVO = new ApproveProcessVO();
- LoginUser loginUser = SecurityUtils.getLoginUser();
- SysUser user = loginUser.getUser();
- // 鑾峰彇褰撳墠鐧诲綍鍏徃
- Long tenantId = loginUser.getTenantId();
- if(null != tenantId){
- LambdaQueryWrapper<DeviceRepair> QueryWrapper = new LambdaQueryWrapper<>();
- QueryWrapper.eq(DeviceRepair::getDeviceLedgerId,deviceRepair.getDeviceLedgerId())
- .eq(DeviceRepair::getRemark,deviceRepair.getRemark())
- .eq(DeviceRepair::getDeviceName,deviceRepair.getDeviceName())
- .eq(DeviceRepair::getApproverId,deviceRepair.getApproverId())
- .eq(DeviceRepair::getRepairTime,deviceRepair.getRepairTime());
- DeviceRepair one = deviceRepairService.getOne(QueryWrapper);
- if(ObjectUtils.isEmpty(one)){
- return AjaxResult.error("璁惧鎶ヤ慨涓嶅瓨鍦�");
- }
- //鑾峰彇褰撳墠鐧诲綍閮ㄩ棬id
- approveProcessVO.setApproveDeptId(tenantId);
- //鑾峰彇褰撳墠鐧诲綍鐢ㄦ埛id
- approveProcessVO.setApproveUser(loginUser.getUserId());
- //鑾峰彇褰撳墠鏃堕棿
- approveProcessVO.setApproveTime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
- approveProcessVO.setApproveType(4);
- approveProcessVO.setApproveUserIds(deviceRepair.getApproverId().toString());
- approveProcessVO.setApproveReason(deviceRepair.getRemark());
- approveProcessVO.setDeviceRepairId(one.getId());
- approveProcessVO.setMaintenancePrice(deviceRepair.getMaintenancePrice());
- approveProcessService.addApprove(approveProcessVO);
- }
- return AjaxResult.success();
+ @ApiOperation("娣诲姞璁惧鎶ヤ慨")
+ public AjaxResult add(@RequestBody DeviceRepair deviceRepair) {
+ return deviceRepairService.saveDeviceRepair(deviceRepair);
}
- @ApiModelProperty("鏍规嵁id鏌ヨ璁惧鎶ヤ慨")
+ @ApiOperation("鏍规嵁id鏌ヨ璁惧鎶ヤ慨")
@GetMapping("/{id}")
public AjaxResult detail(@PathVariable Long id) {
DeviceRepairDto byId = deviceRepairService.detailById(id);
return AjaxResult.success(byId);
}
- @PutMapping ()
- @ApiModelProperty("淇敼璁惧鎶ヤ慨")
- public AjaxResult update( @RequestBody DeviceRepair deviceRepair) {
+ @PutMapping()
+ @ApiOperation("淇敼璁惧鎶ヤ慨")
+ public AjaxResult update(@RequestBody DeviceRepair deviceRepair) {
return deviceRepairService.updateDeviceRepair(deviceRepair);
}
- @PostMapping ("repair")
- @ApiModelProperty("璁惧缁翠慨")
- public AjaxResult repair( @RequestBody DeviceRepair deviceRepair) {
+ @PostMapping("repair")
+ @ApiOperation("璁惧缁翠慨")
+ public AjaxResult repair(@RequestBody DeviceRepair deviceRepair) {
return deviceRepairService.updateDeviceRepair(deviceRepair);
}
@DeleteMapping("/{ids}")
- @ApiModelProperty("鍒犻櫎璁惧鎶ヤ慨")
+ @ApiOperation("鍒犻櫎璁惧鎶ヤ慨")
public AjaxResult delete(@PathVariable("ids") Long[] ids) {
- LambdaQueryWrapper<ApproveProcess> QueryWrapper = new LambdaQueryWrapper<>();
- QueryWrapper.in(ApproveProcess::getDeviceRepairId,ids);
- List<ApproveProcess> approveProcessList = approveProcessService.list(QueryWrapper);
- if(!approveProcessList.isEmpty()){
- approveProcessList.forEach(approveProcess -> {
- if (approveProcess.getApproveStatus() != 0){
- //鎶涘嚭寮傚父
- throw new RuntimeException("鏈夋鍦ㄥ鐞嗕腑鐨勫鎵规祦绋嬶紝涓嶈兘鍒犻櫎");
- }
- });
- }
- boolean b = deviceRepairService.removeBatchByIds(Arrays.asList(ids));
+ boolean b = deviceRepairService.deleteRepairAndFiles(Arrays.asList(ids));
if (!b) {
return AjaxResult.error("鍒犻櫎澶辫触");
}
@@ -126,8 +72,30 @@
}
@PostMapping("export")
- @ApiModelProperty("瀵煎嚭璁惧鎶ヤ慨")
+ @ApiOperation("瀵煎嚭璁惧鎶ヤ慨")
public void export(HttpServletResponse response, Long[] ids) {
deviceRepairService.export(response, ids);
}
+
+ @PostMapping("/uploadFile")
+ @ApiOperation("璁惧淇濅慨-闄勪欢涓婁紶")
+ public AjaxResult uploadFile(MultipartFile file, Long deviceRepairId) {
+ deviceRepairService.uploadFile(file, deviceRepairId);
+ return AjaxResult.success();
+ }
+
+ @GetMapping("/file/{deviceRepairId}")
+ @ApiOperation("璁惧淇濅慨-鏂囦欢鍒楄〃")
+ public AjaxResult getFiles(@PathVariable("deviceRepairId") Long deviceRepairId) {
+ List<CommonFile> list = deviceRepairService.getFiles(deviceRepairId);
+ return AjaxResult.success(list);
+ }
+
+ @DeleteMapping("/file/{fileId}")
+ @ApiOperation("璁惧淇濅慨-鍒犻櫎鏂囦欢")
+ public AjaxResult deleteFile(@PathVariable("fileId") Long fileId) {
+ deviceRepairService.deleteFile(fileId);
+ return AjaxResult.success();
+ }
+
}
--
Gitblit v1.9.3