From 4f55d3cb4bc644e4534106336f2047af1a4db5df Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期五, 29 五月 2026 18:09:46 +0800
Subject: [PATCH] feat(config): 添加新环境配置并扩展设备台账功能
---
src/main/java/com/ruoyi/device/service/impl/DeviceMaintenanceServiceImpl.java | 34 ++++++++++++++++++++++++++--------
1 files changed, 26 insertions(+), 8 deletions(-)
diff --git a/src/main/java/com/ruoyi/device/service/impl/DeviceMaintenanceServiceImpl.java b/src/main/java/com/ruoyi/device/service/impl/DeviceMaintenanceServiceImpl.java
index 779714f..d1a9821 100644
--- a/src/main/java/com/ruoyi/device/service/impl/DeviceMaintenanceServiceImpl.java
+++ b/src/main/java/com/ruoyi/device/service/impl/DeviceMaintenanceServiceImpl.java
@@ -11,11 +11,13 @@
import com.ruoyi.device.dto.DeviceMaintenanceDto;
import com.ruoyi.device.execl.DeviceMaintenanceExeclDto;
import com.ruoyi.device.mapper.DeviceMaintenanceMapper;
+import com.ruoyi.device.pojo.DeviceLedger;
import com.ruoyi.device.pojo.DeviceMaintenance;
+import com.ruoyi.device.service.IDeviceLedgerService;
import com.ruoyi.device.service.IDeviceMaintenanceService;
import com.ruoyi.device.vo.DeviceMaintenanceVo;
import com.ruoyi.device.vo.DeviceRepairVo;
-import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.measuringinstrumentledger.mapper.SparePartsMapper;
import com.ruoyi.measuringinstrumentledger.pojo.SpareParts;
import com.ruoyi.measuringinstrumentledger.pojo.SparePartsRequisitionRecord;
@@ -36,6 +38,7 @@
public class DeviceMaintenanceServiceImpl extends ServiceImpl<DeviceMaintenanceMapper, DeviceMaintenance> implements IDeviceMaintenanceService {
private final DeviceMaintenanceMapper deviceMaintenanceMapper;
+ private final IDeviceLedgerService deviceLedgerService;
private final SparePartsMapper sparePartsMapper;
private final SparePartsRequisitionRecordService sparePartsRequisitionRecordService;
private final FileUtil fileUtil;
@@ -48,20 +51,35 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public R<?> saveDeviceRepair(DeviceMaintenanceDto deviceMaintenance) {
+ public AjaxResult saveDeviceRepair(DeviceMaintenanceDto deviceMaintenance) {
+ DeviceLedger byId = deviceLedgerService.getById(deviceMaintenance.getDeviceLedgerId());
+ if (byId != null) {
+ deviceMaintenance.setDeviceName(byId.getDeviceName());
+ deviceMaintenance.setDeviceModel(byId.getDeviceModel());
+ deviceMaintenance.setAreaId(byId.getAreaId());
+ }
boolean save = this.save(deviceMaintenance);
if (save){
// 澶勭悊鍥剧墖涓婁紶
fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_MAINTENANCE, deviceMaintenance.getId(), deviceMaintenance.getStorageBlobDTOs());
- return R.ok();
+ return AjaxResult.success();
}
- return R.fail();
+ return AjaxResult.error();
}
@Override
@Transactional(rollbackFor = Exception.class)
- public R<?> updateDeviceDeviceMaintenance(DeviceMaintenanceDto deviceMaintenance) {
+ public AjaxResult updateDeviceDeviceMaintenance(DeviceMaintenanceDto deviceMaintenance) {
DeviceMaintenance oldDeviceMaintenance = this.getById(deviceMaintenance.getId());
+ Long effectiveDeviceLedgerId = deviceMaintenance.getDeviceLedgerId() != null
+ ? deviceMaintenance.getDeviceLedgerId()
+ : oldDeviceMaintenance.getDeviceLedgerId();
+ DeviceLedger byId = deviceLedgerService.getById(effectiveDeviceLedgerId);
+ if (byId != null) {
+ deviceMaintenance.setDeviceName(byId.getDeviceName());
+ deviceMaintenance.setDeviceModel(byId.getDeviceModel());
+ deviceMaintenance.setAreaId(byId.getAreaId());
+ }
// 澶勭悊澶囦欢浣跨敤鎯呭喌
if (com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(deviceMaintenance.getSparePartsUseList())) {
List<Long> sparePartIds = new ArrayList<>();
@@ -85,7 +103,7 @@
record.setQuantity(sparePartUse.getQuantity());
sparePartsRequisitionRecordService.save(record);
} else {
- return R.fail("澶囦欢 " + spareParts.getName() + " 鏁伴噺涓嶈冻");
+ return AjaxResult.error("澶囦欢 " + spareParts.getName() + " 鏁伴噺涓嶈冻");
}
}
}
@@ -98,9 +116,9 @@
if (this.updateById(deviceMaintenance)) {
// 澶勭悊鍥剧墖涓婁紶
fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_MAINTENANCE, deviceMaintenance.getId(), deviceMaintenance.getStorageBlobDTOs());
- return R.ok();
+ return AjaxResult.success();
}
- return R.fail();
+ return AjaxResult.error();
}
@Override
--
Gitblit v1.9.3