From 91968cc6ee3fa8206201fd137f56a20ae4b6dff7 Mon Sep 17 00:00:00 2001
From: 吴羡 <16976746+Xian-TT3@user.noreply.gitee.com>
Date: 星期三, 23 九月 2026 15:19:46 +0800
Subject: [PATCH] feat: 销售台账手工录入品名/材质/规格型号自动注册产品层级,回退采购台账相关改动
---
src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java | 33 +++++++++++++++++----------------
1 files changed, 17 insertions(+), 16 deletions(-)
diff --git a/src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java b/src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java
index 263a52a..9c1937b 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java
@@ -17,7 +17,7 @@
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
-import com.ruoyi.framework.web.domain.R;
+import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.sales.dto.LossProductModelDto;
import com.ruoyi.sales.mapper.SalesLedgerProductMapper;
import com.ruoyi.sales.pojo.SalesLedgerProduct;
@@ -55,7 +55,8 @@
String productCode = StringUtils.trim(productModelDto.getProductCode());
productModelDto.setModel(model);
productModelDto.setProductCode(productCode);
- checkModelAndProductCodeUnique(model, productCode, productModelDto.getId());
+ // 浜у搧缂栧彿闈炲繀濉紝瑙勬牸鍨嬪彿鍦ㄥ悓涓�浜у搧涓嬪敮涓�
+ checkModelUnique(productModelDto.getProductId(), model, productModelDto.getId());
if (productModelDto.getId() == null) {
ProductModel productModel = new ProductModel();
@@ -66,18 +67,18 @@
}
}
- private void checkModelAndProductCodeUnique(String model, String productCode, Long currentId) {
- if (StringUtils.isEmpty(model) || StringUtils.isEmpty(productCode)) {
+ private void checkModelUnique(Long productId, String model, Long currentId) {
+ if (StringUtils.isEmpty(model)) {
return;
}
LambdaQueryWrapper<ProductModel> queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(ProductModel::getModel, model)
- .eq(ProductModel::getProductCode, productCode)
+ queryWrapper.eq(ProductModel::getProductId, productId)
+ .eq(ProductModel::getModel, model)
.ne(currentId != null, ProductModel::getId, currentId)
.last("limit 1");
ProductModel duplicateProductModel = productModelMapper.selectOne(queryWrapper);
if (duplicateProductModel != null) {
- throw new ServiceException("瀵瑰簲鐨勫瀷鍙�" + model + "鐨勪骇鍝佺紪鐮�" + productCode + "宸茬粡瀛樺湪");
+ throw new ServiceException("瀵瑰簲鐨勫瀷鍙�" + model + "宸茬粡瀛樺湪");
}
}
@@ -124,14 +125,14 @@
@Override
@Transactional(rollbackFor = Exception.class)
- public R<?> importProductModel(MultipartFile file, Integer productId) {
+ public AjaxResult importProductModel(MultipartFile file, Integer productId) {
if (productId == null) {
- return R.fail("璇峰厛閫夋嫨浜у搧鍐嶅鍏ヨ鏍煎瀷鍙�");
+ return AjaxResult.error("璇峰厛閫夋嫨浜у搧鍐嶅鍏ヨ鏍煎瀷鍙�");
}
Product product = productMapper.selectById(productId);
if (product == null) {
- return R.fail("閫夋嫨鐨勪骇鍝佷笉瀛樺湪");
+ return AjaxResult.error("閫夋嫨鐨勪骇鍝佷笉瀛樺湪");
}
try {
@@ -139,7 +140,7 @@
List<ProductModel> productModelList = productModelExcelUtil.importExcel(file.getInputStream());
if (CollectionUtils.isEmpty(productModelList)) {
- return R.fail("瀵煎叆鏁版嵁涓嶈兘涓虹┖");
+ return AjaxResult.error("瀵煎叆鏁版嵁涓嶈兘涓虹┖");
}
// 鑾峰彇褰撳墠浜у搧涓嬫墍鏈夌殑瑙勬牸鍨嬪彿鍚�
@@ -154,13 +155,13 @@
int rowNum = i + 2;
if (StringUtils.isEmpty(item.getProductCode())) {
- return R.fail("绗� " + rowNum + " 琛屽鍏ュけ璐�: [浜у搧缂栫爜] 涓嶈兘涓虹┖");
+ return AjaxResult.error("绗� " + rowNum + " 琛屽鍏ュけ璐�: [浜у搧缂栫爜] 涓嶈兘涓虹┖");
}
if (StringUtils.isEmpty(item.getModel())) {
- return R.fail("绗� " + rowNum + " 琛屽鍏ュけ璐�: [瑙勬牸鍨嬪彿] 涓嶈兘涓虹┖");
+ return AjaxResult.error("绗� " + rowNum + " 琛屽鍏ュけ璐�: [瑙勬牸鍨嬪彿] 涓嶈兘涓虹┖");
}
if (StringUtils.isEmpty(item.getUnit())) {
- return R.fail("绗� " + rowNum + " 琛屽鍏ュけ璐�: [鍗曚綅] 涓嶈兘涓虹┖");
+ return AjaxResult.error("绗� " + rowNum + " 琛屽鍏ュけ璐�: [鍗曚綅] 涓嶈兘涓虹┖");
}
// 鍘婚噸,濡傛灉宸插寘鍚鍨嬪彿,鍒欒烦杩�
@@ -180,9 +181,9 @@
}
if (skipCount == 0) {
- return R.ok(null, String.format("鎴愬姛瀵煎叆 %d 鏉℃暟鎹�", waitToSaveList.size()));
+ return AjaxResult.success(String.format("鎴愬姛瀵煎叆 %d 鏉℃暟鎹�", waitToSaveList.size()));
} else {
- return R.ok(null, String.format("鎴愬姛瀵煎叆 %d 鏉★紝璺宠繃宸插瓨鍦ㄦ暟鎹� %d 鏉�", waitToSaveList.size(), skipCount));
+ return AjaxResult.success(String.format("鎴愬姛瀵煎叆 %d 鏉★紝璺宠繃宸插瓨鍦ㄦ暟鎹� %d 鏉�", waitToSaveList.size(), skipCount));
}
} catch (Exception e) {
log.error("瀵煎叆浜у搧瑙勬牸寮傚父", e);
--
Gitblit v1.9.3