From 684e4306a08feeae188070f264148e6765da8dcf Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期日, 20 九月 2026 19:25:15 +0800
Subject: [PATCH] feat(account): 更新往来付款回款流水表及接口
---
src/main/java/com/ruoyi/device/service/impl/DeviceRepairServiceImpl.java | 60 +++++++++++++++++++++++++++++++++++++-----------------------
1 files changed, 37 insertions(+), 23 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 98f0d27..8af7912 100644
--- a/src/main/java/com/ruoyi/device/service/impl/DeviceRepairServiceImpl.java
+++ b/src/main/java/com/ruoyi/device/service/impl/DeviceRepairServiceImpl.java
@@ -18,10 +18,12 @@
import com.ruoyi.device.service.IDeviceLedgerService;
import com.ruoyi.device.service.IDeviceRepairService;
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.SparePartsRecord;
import com.ruoyi.measuringinstrumentledger.pojo.SparePartsRequisitionRecord;
+import com.ruoyi.measuringinstrumentledger.service.SparePartsRecordService;
import com.ruoyi.measuringinstrumentledger.service.SparePartsRequisitionRecordService;
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
@@ -45,6 +47,7 @@
private final IDeviceLedgerService deviceLedgerService;
private final SparePartsMapper sparePartsMapper;
private final SparePartsRequisitionRecordService sparePartsRequisitionRecordService;
+ private final SparePartsRecordService sparePartsRecordService;
private final FileUtil fileUtil;
private static final int STATUS_PENDING_REPAIR = 0;
@@ -63,7 +66,7 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public R<?> saveDeviceRepair(DeviceRepairDto deviceRepairDto) {
+ public AjaxResult saveDeviceRepair(DeviceRepairDto deviceRepairDto) {
DeviceLedger byId = deviceLedgerService.getById(deviceRepairDto.getDeviceLedgerId());
deviceRepairDto.setDeviceName(byId.getDeviceName());
deviceRepairDto.setDeviceModel(byId.getDeviceModel());
@@ -74,23 +77,23 @@
if (save) {
// 澶勭悊鍥剧墖涓婁紶
fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_REPAIR, deviceRepairDto.getId(), deviceRepairDto.getStorageBlobDTOs());
- return R.ok();
+ return AjaxResult.success();
}
- return R.fail("淇濆瓨澶辫触");
+ return AjaxResult.error("淇濆瓨澶辫触");
}
@Override
@Transactional(rollbackFor = Exception.class)
- public R<?> updateDeviceRepair(DeviceRepairDto deviceRepairDto) {
+ public AjaxResult updateDeviceRepair(DeviceRepairDto deviceRepairDto) {
DeviceRepair oldDeviceRepair = this.getById(deviceRepairDto.getId());
if (oldDeviceRepair == null) {
- return R.fail("鎶ヤ慨璁板綍涓嶅瓨鍦�");
+ return AjaxResult.error("鎶ヤ慨璁板綍涓嶅瓨鍦�");
}
if (deviceRepairDto.getStatus() != null
&& deviceRepairDto.getStatus() == STATUS_COMPLETED
&& (oldDeviceRepair.getStatus() == null
|| oldDeviceRepair.getStatus() != STATUS_COMPLETED)) {
- return R.fail("璇峰厛鎻愪氦楠屾敹瀹℃壒锛岄獙鏀堕�氳繃鍚庢墠鍙畬缁�");
+ return AjaxResult.error("璇峰厛鎻愪氦楠屾敹瀹℃壒锛岄獙鏀堕�氳繃鍚庢墠鍙畬缁�");
}
// 澶勭悊澶囦欢浣跨敤鎯呭喌
if (CollectionUtils.isNotEmpty(deviceRepairDto.getSparePartsUseList())) {
@@ -114,8 +117,19 @@
record.setSparePartsId(sparePartUse.getId());
record.setQuantity(sparePartUse.getQuantity());
sparePartsRequisitionRecordService.save(record);
+
+ // 杩藉姞澶囦欢鍑哄簱娴佹按锛�2 缁翠慨棰嗙敤锛�
+ SparePartsRecord outRecord = new SparePartsRecord();
+ outRecord.setSparePartsId(sparePartUse.getId());
+ outRecord.setDirection(2);
+ outRecord.setQuantity(new BigDecimal(sparePartUse.getQuantity()));
+ outRecord.setSourceType(2);
+ outRecord.setSourceId(deviceRepairDto.getId());
+ // 鎶ヤ慨鍗曟病鏈夊崟鍙凤紝鏉ユ簮鍗曞彿鐢ㄨ澶囧悕绉帮紝娴佹按椤垫墠鐪嬪緱鍑哄浠剁敤鍦ㄥ摢鍙拌澶囦笂
+ outRecord.setSourceNo(oldDeviceRepair.getDeviceName());
+ sparePartsRecordService.save(outRecord);
} else {
- return R.fail("澶囦欢 " + spareParts.getName() + " 鏁伴噺涓嶈冻");
+ return AjaxResult.error("澶囦欢 " + spareParts.getName() + " 鏁伴噺涓嶈冻");
}
}
}
@@ -142,23 +156,23 @@
if (deviceRepairDto.getStorageBlobDTOs() != null) {
fileUtil.saveStorageAttachmentByRecordTypeAndRecordId("file", RecordTypeEnum.DEVICE_REPAIR, id, deviceRepairDto.getStorageBlobDTOs());
}
- return R.ok();
+ return AjaxResult.success();
}
- return R.fail();
+ return AjaxResult.error();
}
@Override
@Transactional(rollbackFor = Exception.class)
- public R<?> confirmRepair(DeviceRepairDto deviceRepairDto) {
+ public AjaxResult confirmRepair(DeviceRepairDto deviceRepairDto) {
DeviceRepair oldDeviceRepair = this.getById(deviceRepairDto.getId());
if (oldDeviceRepair == null) {
- return R.fail("鎶ヤ慨璁板綍涓嶅瓨鍦�");
+ return AjaxResult.error("鎶ヤ慨璁板綍涓嶅瓨鍦�");
}
if (oldDeviceRepair.getStatus() != null && oldDeviceRepair.getStatus() == STATUS_COMPLETED) {
- return R.fail("璇ユ姤淇凡瀹岀粨锛屼笉鑳介噸澶嶇‘璁ょ淮淇�");
+ return AjaxResult.error("璇ユ姤淇凡瀹岀粨锛屼笉鑳介噸澶嶇‘璁ょ淮淇�");
}
if (oldDeviceRepair.getStatus() != null && oldDeviceRepair.getStatus() == STATUS_PENDING_ACCEPTANCE) {
- return R.fail("璇ユ姤淇凡鎻愪氦楠屾敹瀹℃壒");
+ return AjaxResult.error("璇ユ姤淇凡鎻愪氦楠屾敹瀹℃壒");
}
deviceRepairDto.setStatus(STATUS_PENDING_ACCEPTANCE);
return updateDeviceRepair(deviceRepairDto);
@@ -166,25 +180,25 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public R<?> approveRepairAcceptance(DeviceRepairDto deviceRepairDto) {
+ public AjaxResult approveRepairAcceptance(DeviceRepairDto deviceRepairDto) {
if (deviceRepairDto.getId() == null) {
- return R.fail("鎶ヤ慨璁板綍id涓嶈兘涓虹┖");
+ return AjaxResult.error("鎶ヤ慨璁板綍id涓嶈兘涓虹┖");
}
DeviceRepair oldDeviceRepair = this.getById(deviceRepairDto.getId());
if (oldDeviceRepair == null) {
- return R.fail("鎶ヤ慨璁板綍涓嶅瓨鍦�");
+ return AjaxResult.error("鎶ヤ慨璁板綍涓嶅瓨鍦�");
}
if (oldDeviceRepair.getStatus() == null || oldDeviceRepair.getStatus() != STATUS_PENDING_ACCEPTANCE) {
- return R.fail("璇ユ姤淇湭杩涘叆寰呴獙鏀剁姸鎬侊紝涓嶈兘瀹℃壒");
+ return AjaxResult.error("璇ユ姤淇湭杩涘叆寰呴獙鏀剁姸鎬侊紝涓嶈兘瀹℃壒");
}
if (StringUtils.isBlank(deviceRepairDto.getAcceptanceName())) {
- return R.fail("楠屾敹浜轰笉鑳戒负绌�");
+ return AjaxResult.error("楠屾敹浜轰笉鑳戒负绌�");
}
if (deviceRepairDto.getAcceptanceTime() == null) {
- return R.fail("楠屾敹鏃堕棿涓嶈兘涓虹┖");
+ return AjaxResult.error("楠屾敹鏃堕棿涓嶈兘涓虹┖");
}
if (StringUtils.isBlank(deviceRepairDto.getAcceptanceRemark())) {
- return R.fail("楠屾敹澶囨敞涓嶈兘涓虹┖");
+ return AjaxResult.error("楠屾敹澶囨敞涓嶈兘涓虹┖");
}
DeviceRepair update = new DeviceRepair();
@@ -194,9 +208,9 @@
update.setAcceptanceRemark(deviceRepairDto.getAcceptanceRemark());
update.setStatus(STATUS_COMPLETED);
if (this.updateById(update)) {
- return R.ok();
+ return AjaxResult.success();
}
- return R.fail("楠屾敹瀹℃壒澶辫触");
+ return AjaxResult.error("楠屾敹瀹℃壒澶辫触");
}
@Override
--
Gitblit v1.9.3