From 2d6a0cdcb1e31510a6f7776abab17cc5cb82fdcb Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期三, 13 九月 2023 17:50:04 +0800
Subject: [PATCH] 修改2.0   9.13

---
 standard-server/src/main/java/com/yuanchu/mom/service/impl/ProductServiceImpl.java |  127 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 113 insertions(+), 14 deletions(-)

diff --git a/standard-server/src/main/java/com/yuanchu/mom/service/impl/ProductServiceImpl.java b/standard-server/src/main/java/com/yuanchu/mom/service/impl/ProductServiceImpl.java
index 331d83d..c0424b4 100644
--- a/standard-server/src/main/java/com/yuanchu/mom/service/impl/ProductServiceImpl.java
+++ b/standard-server/src/main/java/com/yuanchu/mom/service/impl/ProductServiceImpl.java
@@ -1,39 +1,138 @@
 package com.yuanchu.mom.service.impl;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yuanchu.mom.mapper.TechniqueMapper;
+import com.yuanchu.mom.mapper.TechnologyMapper;
 import com.yuanchu.mom.pojo.Product;
 import com.yuanchu.mom.pojo.dto.ProductDto;
 import com.yuanchu.mom.service.ProductService;
 import com.yuanchu.mom.mapper.ProductMapper;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
 
 /**
-* @author Administrator
-* @description 閽堝琛ㄣ�恜roduct銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇
-* @createDate 2023-07-26 16:00:44
-*/
+ * @author Administrator
+ * @description 閽堝琛ㄣ�恜roduct銆戠殑鏁版嵁搴撴搷浣淪ervice瀹炵幇
+ * @createDate 2023-07-26 16:00:44
+ */
 @Service
-public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService{
+public class ProductServiceImpl extends ServiceImpl<ProductMapper, Product> implements ProductService {
 
     @Resource
     private ProductMapper productMapper;
 
-    @Override
-    public List<ProductDto> selectTreeProduct(String specifications, String project) {
-        return productMapper.selectTreeProduct(specifications, project);
-    }
+    @Resource
+    TechnologyMapper technologyMapper;
 
+    @Resource
+    TechniqueMapper techniqueMapper;
+
+    //鏍规嵁鍨嬪彿id鏌ヨ椤圭洰(鎶�鏈寚鏍�)
     @Override
     public List<Map<String, Object>> selectProductList(Integer specificationsId) {
-        LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
-        wrapper.eq(Product::getSpecificationsId, specificationsId);
-        wrapper.select(Product::getName, Product::getFather, Product::getRequired, Product::getInternal, Product::getUnit);
-        return productMapper.selectMaps(wrapper);
+        return productMapper.selectProductList(specificationsId);
+    }
+
+    //鏍规嵁鍨嬪彿id鏌ヨ鎵�鏈夌増鏈�
+    @Override
+    public List<Integer> selectVerByPro(Integer specificationsId) {
+        return productMapper.selectVerByPro(specificationsId);
+    }
+
+    //鍙充晶鏁版嵁灞曠ず-->鎶�鏈寚鏍�(妫�楠岄」鐩�)
+    @Override
+    public List<Map<String, Object>> selectAllPro(Integer specificationsId, Integer version, String message) {
+        return productMapper.selectAllPro(specificationsId, version, message);
+    }
+
+    //鍙充笂瑙掓柊澧�-->鎶�鏈寚鏍�-->閫夋嫨宸ュ簭,宸ヨ壓
+    @Override
+    public List<Map<String, Object>> chooseTech(Integer specificationsId) {
+        return technologyMapper.chooseTech(specificationsId);
+    }
+
+    //鍙充笂瑙掓柊澧�-->鎶�鏈寚鏍�-->閫夋嫨椤圭洰鐖剁被
+    @Override
+    public List<Map<String, Object>> chooseFather(Integer technologyId) {
+        return productMapper.chooseFather(technologyId);
+    }
+
+    //鍙充笂瑙掓柊澧�-->鎶�鏈寚鏍�
+    @Override
+    public String addProduct(ProductDto productDto) {
+        Product product = new Product();
+        String required = productDto.getRequired();
+        String internal = productDto.getInternal();
+        if (ObjectUtils.isNotEmpty(required)){
+            char requ = required.charAt(0);
+            if (requ != '>' && requ != '<' && requ != '=') {
+                return "鏍囧噯鍊艰緭鍏ユ牸寮忔湁闂!";
+            }
+        }
+        if (ObjectUtils.isNotEmpty(internal)){
+            char inter = internal.charAt(0);
+            if (inter != '>' && inter != '<' && inter != '=') {
+                return "鍐呮帶鍊艰緭鍏ユ牸寮忔湁闂!";
+            }
+        }
+        BeanUtils.copyProperties(productDto, product);
+        productMapper.insert(product);
+        return "鏂板鎴愬姛!";
+    }
+
+    //濉啓鏍囧噯鍊间笌鍐呮帶鍊�,榧犳爣绉诲紑淇濆瓨
+    @Override
+    public String write(Integer id, String required, String internal) {
+        //鏍¢獙鏍囧噯鍊�,鍐呮帶鍊兼牸寮�
+            char inter = internal.charAt(0);
+            char requ = required.charAt(0);
+            if (inter != '>' && inter != '<' && inter != '=') {
+                return "鍐呮帶鍊艰緭鍏ユ牸寮忔湁闂!";
+            }
+            if (requ != '>' && requ != '<' && requ != '=') {
+                return "鏍囧噯鍊艰緭鍏ユ牸寮忔湁闂!";
+            }
+        Product product = new Product();
+        product.setId(id);
+        product.setRequired(required);
+        product.setInternal(internal);
+        productMapper.updateById(product);
+        return "淇濆瓨鎴愬姛!";
+    }
+
+    //鍒犻櫎
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void delProById(Integer id) {
+        //鍒犻櫎鎶�鏈寚鏍�
+        Product product = new Product();
+        product.setId(id);
+        product.setState(0);
+        productMapper.updateById(product);
+        //鍒犻櫎鐢熶骇宸ヨ壓
+        techniqueMapper.delByProId(id);
+    }
+
+    //鎵归噺鍒犻櫎
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void delAllPro(String ids) {
+        //鎵归噺鍒犻櫎鎶�鏈寚鏍�
+        productMapper.delAllPro(ids);
+        //鍒犻櫎鐢熶骇宸ヨ壓
+        techniqueMapper.delAll(ids);
+    }
+
+    //鏌ヨ鏍囧噯BOM鎶�鏈寚鏍囦腑璇ュ瀷鍙峰伐鑹轰笅鏈�鏂扮増鏈殑妫�楠岄」鐩�
+    @Override
+    public List<Product> selProByVerSpe(Integer technologyId) {
+        return productMapper.selProByVerSpe(technologyId);
     }
 }
 

--
Gitblit v1.9.3