From f3a2e64d96e59bed492bb3eec8705a5f9ca269d7 Mon Sep 17 00:00:00 2001
From: chenhj <1263187585@qq.com>
Date: 星期四, 15 一月 2026 09:11:37 +0800
Subject: [PATCH] 设备校准修改
---
src/main/java/com/ruoyi/device/controller/DeviceRepairController.java | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 53 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/ruoyi/device/controller/DeviceRepairController.java b/src/main/java/com/ruoyi/device/controller/DeviceRepairController.java
index 44021a9..d9f4e5c 100644
--- a/src/main/java/com/ruoyi/device/controller/DeviceRepairController.java
+++ b/src/main/java/com/ruoyi/device/controller/DeviceRepairController.java
@@ -1,9 +1,11 @@
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.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;
@@ -11,19 +13,25 @@
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
-import java.util.ArrayList;
import java.util.Arrays;
+import java.util.List;
@Api(tags = "璁惧鎶ヤ慨绠$悊")
-@RequestMapping("/device/reppair")
+@RequestMapping("/device/repair")
@RestController
public class DeviceRepairController {
@Autowired
private IDeviceRepairService deviceRepairService;
+
+ @Autowired
+ private IDeviceLedgerService deviceLedgerService;
+ @Autowired
+ private IApproveProcessService approveProcessService;
@ApiModelProperty("璁惧鎶ヤ慨鍒楄〃")
@GetMapping("/page")
@@ -32,15 +40,37 @@
}
@PostMapping()
+ @Transactional(rollbackFor = Exception.class)
@ApiModelProperty("娣诲姞璁惧鎶ヤ慨")
- public AjaxResult add( @RequestBody DeviceRepair deviceRepair) {
- return deviceRepairService.saveDeviceRepair(deviceRepair);
+ public AjaxResult add( @RequestBody DeviceRepair deviceRepair) throws Exception {
+ deviceRepairService.saveDeviceRepair(deviceRepair);
+ // todo 鍓嶇浠g爜涓嶅尮閰嶏紝寰呭鐞�
+// ApproveProcessVO approveProcessVO = new ApproveProcessVO();
+// LoginUser loginUser = SecurityUtils.getLoginUser();
+// // 鑾峰彇褰撳墠鐧诲綍鍏徃
+// Long tenantId = loginUser.getTenantId();
+// if(null != tenantId){
+// //鑾峰彇褰撳墠鐧诲綍閮ㄩ棬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(deviceRepair.getId());
+// approveProcessVO.setMaintenancePrice(deviceRepair.getMaintenancePrice());
+// approveProcessService.addApprove(approveProcessVO);
+// }
+ return AjaxResult.success();
}
@ApiModelProperty("鏍规嵁id鏌ヨ璁惧鎶ヤ慨")
@GetMapping("/{id}")
public AjaxResult detail(@PathVariable Long id) {
- return AjaxResult.success(deviceRepairService.getById(id));
+ DeviceRepairDto byId = deviceRepairService.detailById(id);
+ return AjaxResult.success(byId);
}
@PutMapping ()
@@ -49,9 +79,26 @@
return deviceRepairService.updateDeviceRepair(deviceRepair);
}
+ @PostMapping ("repair")
+ @ApiModelProperty("璁惧缁翠慨")
+ public AjaxResult repair( @RequestBody DeviceRepair deviceRepair) {
+ return deviceRepairService.updateDeviceRepair(deviceRepair);
+ }
+
@DeleteMapping("/{ids}")
@ApiModelProperty("鍒犻櫎璁惧鎶ヤ慨")
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));
if (!b) {
return AjaxResult.error("鍒犻櫎澶辫触");
--
Gitblit v1.9.3