From a8e4132c3e2e9c3b3fcb0360901b35571b6464ea Mon Sep 17 00:00:00 2001
From: hsy <1029150275@qq.com>
Date: 星期五, 28 八月 2026 10:13:01 +0800
Subject: [PATCH] feat: 综合业务模块功能补充与实体拓展
---
src/main/java/com/ruoyi/device/service/impl/DeviceRepairServiceImpl.java | 64 ++++++++++++++++++++++++++++++++
1 files changed, 64 insertions(+), 0 deletions(-)
diff --git a/src/main/java/com/ruoyi/device/service/impl/DeviceRepairServiceImpl.java b/src/main/java/com/ruoyi/device/service/impl/DeviceRepairServiceImpl.java
index e5a73ac..76d1a3a 100644
--- a/src/main/java/com/ruoyi/device/service/impl/DeviceRepairServiceImpl.java
+++ b/src/main/java/com/ruoyi/device/service/impl/DeviceRepairServiceImpl.java
@@ -6,6 +6,7 @@
import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
import com.ruoyi.basic.enums.RecordTypeEnum;
import com.ruoyi.basic.utils.FileUtil;
+import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.device.dto.DeviceDefectRecordDto;
@@ -21,6 +22,11 @@
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.measuringinstrumentledger.mapper.SparePartsMapper;
import com.ruoyi.measuringinstrumentledger.pojo.SpareParts;
+import com.ruoyi.approve.pojo.KnowledgeBase;
+import com.ruoyi.approve.service.KnowledgeBaseService;
+import com.ruoyi.device.pojo.DeviceRepairSparePart;
+import com.ruoyi.device.service.IDeviceRepairSparePartService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ruoyi.measuringinstrumentledger.pojo.SparePartsRequisitionRecord;
import com.ruoyi.measuringinstrumentledger.service.SparePartsRequisitionRecordService;
import jakarta.servlet.http.HttpServletResponse;
@@ -45,6 +51,8 @@
private final IDeviceLedgerService deviceLedgerService;
private final SparePartsMapper sparePartsMapper;
private final SparePartsRequisitionRecordService sparePartsRequisitionRecordService;
+ private final IDeviceRepairSparePartService deviceRepairSparePartService;
+ private final KnowledgeBaseService knowledgeBaseService;
private final FileUtil fileUtil;
private static final int STATUS_PENDING_REPAIR = 0;
@@ -92,6 +100,11 @@
|| oldDeviceRepair.getStatus() != STATUS_COMPLETED)) {
return AjaxResult.error("璇峰厛鎻愪氦楠屾敹瀹℃壒锛岄獙鏀堕�氳繃鍚庢墠鍙畬缁�");
}
+ // 娓呯悊鏃х殑澶囦欢浣跨敤璁板綍锛岄槻姝㈤噸澶嶇疮璁�
+ deviceRepairSparePartService.remove(new QueryWrapper<DeviceRepairSparePart>()
+ .eq("source_id", deviceRepairDto.getId())
+ .eq("source_type", 1));
+
// 澶勭悊澶囦欢浣跨敤鎯呭喌
if (CollectionUtils.isNotEmpty(deviceRepairDto.getSparePartsUseList())) {
List<Long> sparePartIds = new ArrayList<>();
@@ -114,6 +127,14 @@
record.setSparePartsId(sparePartUse.getId());
record.setQuantity(sparePartUse.getQuantity());
sparePartsRequisitionRecordService.save(record);
+
+ // 鎻掑叆璁板綍鍒� device_repair_spare_part
+ DeviceRepairSparePart partRecord = new DeviceRepairSparePart();
+ partRecord.setSourceId(deviceRepairDto.getId());
+ partRecord.setSourceType(1); // 1 鎶ヤ慨
+ partRecord.setSparePartId(sparePartUse.getId());
+ partRecord.setQuantity(sparePartUse.getQuantity());
+ deviceRepairSparePartService.save(partRecord);
} else {
return AjaxResult.error("澶囦欢 " + spareParts.getName() + " 鏁伴噺涓嶈冻");
}
@@ -194,6 +215,47 @@
update.setAcceptanceRemark(deviceRepairDto.getAcceptanceRemark());
update.setStatus(STATUS_COMPLETED);
if (this.updateById(update)) {
+ try {
+ DeviceLedger deviceLedger = deviceLedgerService.getById(oldDeviceRepair.getDeviceLedgerId());
+ List<DeviceRepairSparePart> parts = deviceRepairSparePartService.getListWithPartName(deviceRepairDto.getId(), 1);
+
+ String sparePartsInfo = "";
+ if (CollectionUtils.isNotEmpty(parts)) {
+ StringBuilder sb = new StringBuilder();
+ for (DeviceRepairSparePart p : parts) {
+ sb.append(p.getSparePartName()).append("(").append(p.getQuantity()).append("涓�) ");
+ }
+ sparePartsInfo = " 閰嶄欢浣跨敤鎯呭喌: " + sb.toString();
+ }
+
+ KnowledgeBase kb = new KnowledgeBase();
+ String typeName = deviceLedger.getType();
+ String deviceModel = deviceLedger.getDeviceModel();
+ String repairTypeStr = oldDeviceRepair.getRepairType();
+ String repairTypeLabel = DictUtils.getDictLabel("device_repair_type", repairTypeStr);
+ if (StringUtils.isBlank(repairTypeLabel)) {
+ repairTypeLabel = "缁翠慨";
+ }
+
+ kb.setTitle((typeName != null ? typeName : "璁惧") + "_" + (deviceModel != null ? deviceModel : "") + " 鐨� " + repairTypeLabel + "璁板綍");
+ kb.setScenario("璁惧缁翠慨");
+ kb.setType("瑙e喅鏂规");
+
+ String remarkStr = oldDeviceRepair.getRemark() == null ? "" : oldDeviceRepair.getRemark();
+ kb.setProblem(String.format("璁惧鍙�: %s, 璁惧鍚嶇О: %s, 鏁呴殰鎻忚堪: %s",
+ deviceLedger.getUniqueCode(), deviceLedger.getDeviceName(),
+ remarkStr));
+
+ String reasonStr = oldDeviceRepair.getReasonAnalysis() == null ? "" : oldDeviceRepair.getReasonAnalysis();
+ String handlingStr = oldDeviceRepair.getHandlingMeasures() == null ? "" : oldDeviceRepair.getHandlingMeasures();
+ kb.setSolution(String.format("鍘熷洜鍒嗘瀽: %s. 澶勭悊鎺柦: %s.%s",
+ reasonStr, handlingStr, sparePartsInfo));
+ kb.setCreator(oldDeviceRepair.getMaintenanceName());
+
+ knowledgeBaseService.save(kb);
+ } catch(Exception e) {
+ log.error("淇濆瓨鐭ヨ瘑搴撳け璐�", e);
+ }
return AjaxResult.success();
}
return AjaxResult.error("楠屾敹瀹℃壒澶辫触");
@@ -251,6 +313,8 @@
public DeviceRepairVo detailById(Long id) {
DeviceRepairVo vo = deviceRepairMapper.detailById(id);
vo.setStorageBlobVOs(fileUtil.getStorageBlobVOsByRecordTypeAndRecordId(RecordTypeEnum.DEVICE_REPAIR, id));
+ List<DeviceRepairSparePart> parts = deviceRepairSparePartService.getListWithPartName(id, 1);
+ vo.setSparePartsUseListDetails(parts);
return vo;
}
--
Gitblit v1.9.3