From c1bbff15e4f64767d471de763613a54c9cb8d4b4 Mon Sep 17 00:00:00 2001
From: liyong <18434998025@163.com>
Date: 星期五, 24 四月 2026 14:28:15 +0800
Subject: [PATCH] feat(sales): 添加销售台账批量导入功能
---
src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java | 45 ++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 42 insertions(+), 3 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 55c9394..55bfdce 100644
--- a/src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java
+++ b/src/main/java/com/ruoyi/basic/service/impl/ProductModelServiceImpl.java
@@ -16,6 +16,7 @@
import com.ruoyi.basic.pojo.ProductModel;
import com.ruoyi.basic.service.IProductModelService;
import com.ruoyi.common.exception.ServiceException;
+import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
import com.ruoyi.common.utils.poi.ExcelUtil;
@@ -165,9 +166,47 @@
}
}
- public Boolean checkProductModelExist(ProductModelAnticlockwiseDto productModelDto, String uuid) {
+ //鍙嶅悜鏂板鎴愬搧浜у搧锛屽彧鏈夐攢鍞叧鑱旀柊澧炵殑鏃跺�欒皟鐢�
+ @Override
+ public Long productModelAnticlockwise(ProductModelAnticlockwiseDto productModelDto) {
+ ProductModel oldProductModel = productModelMapper.selectOldProductModel(productModelDto.getModel(), productModelDto.getProductName());
+ //瀛樺湪灏辨洿鏂�
+ if (oldProductModel != null) {
+ oldProductModel.setModel(productModelDto.getModel());
+ oldProductModel.setUnit(productModelDto.getUnit());
+ oldProductModel.setSubUnit(productModelDto.getSubUnit());
+ oldProductModel.setDeptId(SecurityUtils.getDeptId()[0]);
+ productModelMapper.updateById(oldProductModel);
+ Product product = productMapper.selectById(oldProductModel.getProductId());
+ product.setProductName(productModelDto.getProductName());
+ productMapper.updateById(product);
+ return oldProductModel.getId();
+ }else {
+ //鎵惧埌鐖惰妭鐐�
+ Product productParent = productMapper.selectOne(new QueryWrapper<Product>().lambda().eq(Product::getProductName, "鎴愬搧").last("limit 1"));
+ if (ObjectUtils.isEmpty(productParent)) {
+ Product product = new Product();
+ product.setProductName("鎴愬搧");
+ product.setDeptId(SecurityUtils.getDeptId()[0]);
+ productMapper.insert(product);
+ productParent.setId(product.getId());
+ }
+ //鏂板浜у搧澶х被
+ Product product = new Product();
+ product.setProductName(productModelDto.getProductName());
+ product.setParentId(productParent.getId());
+ product.setDeptId(SecurityUtils.getDeptId()[0]);
+ productMapper.insert( product);
+ //鏂板浜у搧瑙勬牸
+ ProductModel productModel = new ProductModel();
+ productModel.setProductId(product.getId());
+ productModel.setModel(productModelDto.getModel());
+ productModel.setUnit(productModelDto.getUnit());
+ productModel.setSubUnit(productModelDto.getSubUnit());
+ productModel.setDeptId(SecurityUtils.getDeptId()[0]);
+ productModelMapper.insert(productModel);
+ return productModel.getId();
-
- return true;
+ }
}
}
--
Gitblit v1.9.3