From fa40e09b66af9d17b6d2dda1a3d4687ad72bf668 Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期四, 31 八月 2023 17:31:34 +0800
Subject: [PATCH] 标准BOM(展示+添加)
---
standard-server/src/main/java/com/yuanchu/mom/service/impl/SpecificationsServiceImpl.java | 123 ++++++++++++++++++++++++++++++++++++++--
1 files changed, 116 insertions(+), 7 deletions(-)
diff --git a/standard-server/src/main/java/com/yuanchu/mom/service/impl/SpecificationsServiceImpl.java b/standard-server/src/main/java/com/yuanchu/mom/service/impl/SpecificationsServiceImpl.java
index 75ea50f..1c418b5 100644
--- a/standard-server/src/main/java/com/yuanchu/mom/service/impl/SpecificationsServiceImpl.java
+++ b/standard-server/src/main/java/com/yuanchu/mom/service/impl/SpecificationsServiceImpl.java
@@ -3,18 +3,21 @@
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.yuanchu.mom.mapper.SpecificationsMapper;
-import com.yuanchu.mom.pojo.Specifications;
-import com.yuanchu.mom.service.SpecificationsService;
+import com.yuanchu.mom.mapper.*;
+import com.yuanchu.mom.pojo.*;
+import com.yuanchu.mom.pojo.dto.SpecificationsDto;
+import com.yuanchu.mom.service.*;
import com.yuanchu.mom.utils.MyUtil;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
+import java.util.ArrayList;
import java.util.List;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
/**
* @author Administrator
@@ -22,14 +25,120 @@
* @createDate 2023-07-26 16:01:49
*/
@Service
-public class SpecificationsServiceImpl extends ServiceImpl<SpecificationsMapper, Specifications>
- implements SpecificationsService {
+public class SpecificationsServiceImpl extends ServiceImpl<SpecificationsMapper, Specifications> implements SpecificationsService {
@Resource
- private SpecificationsMapper specificationsMapper;
+ MaterialMapper materialMapper;
+
+ @Resource
+ SpecificationsMapper specificationsMapper;
+
+ @Resource
+ TechnologyService technologyService;
+
+ @Resource
+ TechnologyTemplateMapper technologyTemplateMapper;
+
+ @Resource
+ ProductService productService;
+
+ @Resource
+ TechnicalModelMapper technicalModelMapper;
+
+ @Resource
+ MbomService mbomService;
+
+ @Resource
+ MbomModelMapper mbomModelMapper;
+
+ @Resource
+ TechniqueService techniqueService;
+
+ @Resource
+ TechniqueModelMapper techniqueModelMapper;
+
+ @Resource
+ DeviceMapper deviceMapper;
+
+ //(4绾�)鏂板-->鍨嬪彿
+ @Override
+ public void addSpecifications(SpecificationsDto specificationsDto) {
+ /*鏂板鍨嬪彿琛�*/
+ Specifications specifications = new Specifications();
+ specifications.setStandardId(specificationsDto.getId());
+ specifications.setName(specificationsDto.getSpecifications());
+ specificationsMapper.insert(specifications);
+ /*鏂板鏍囧噯BOM-->宸ヨ壓璺嚎(鎵归噺娣诲姞)*/
+ //鏍规嵁鏍囧噯id鏌ヨ鐗╂枡澶х被
+ Material material = materialMapper.selFath(specificationsDto.getId());
+ List<TechnologyTemplate> technologyTemplateList = technologyTemplateMapper.selectList(Wrappers.<TechnologyTemplate>query().eq("type", material.getFather()));
+ List<Technology> technologyList = technologyTemplateList.stream().map(technologyTemplate -> {
+ Technology technology = new Technology();
+ technology.setSpecificationsId(specifications.getId());
+ technology.setFather(technologyTemplate.getFather());
+ technology.setName(technologyTemplate.getName());
+ technology.setDeviceGroup(technologyTemplate.getDeviceGroup());
+ return technology;
+ }).collect(Collectors.toList());
+ technologyService.saveBatch(technologyList);
+ /*鏂板鏍囧噯BOM-->鎶�鏈寚鏍�(鎵归噺娣诲姞)*/
+ //鏂板鐨勫伐鑹鸿矾绾縤d闆嗗悎
+ List<Integer> technologyIds = technologyList.stream().map(Technology::getId).collect(Collectors.toList());
+ //鍩虹鏁版嵁涓伐鑹鸿矾绾縤d闆嗗悎
+ List<Integer> techTemIds = technologyTemplateList.stream().map(TechnologyTemplate::getId).collect(Collectors.toList());
+ //涓よ�呴暱搴︿竴瀹氫竴鏍�
+ List<Product> productList = new ArrayList<>();
+ for (int i = 0; i < technologyIds.size(); i++) {
+ List<TechnicalModel> technicalModelList = technicalModelMapper.selectList(Wrappers.<TechnicalModel>query().eq("tech_tem_id", techTemIds.get(i)));
+ for (TechnicalModel technicalModel : technicalModelList) {
+ Product product = new Product();
+ product.setFather(technicalModel.getFather());
+ product.setName(technicalModel.getName());
+ product.setUnit(technicalModel.getUnit());
+ product.setTechnologyId(technologyIds.get(i));
+ productList.add(product);
+ }
+ }
+ productService.saveBatch(productList);
+ /*鏂板鏍囧噯BOM-->鐗╂枡娓呭崟(鎵归噺娣诲姞)*/
+ List<Mbom> mbomList = new ArrayList<>();
+ for (int i = 0; i < technologyIds.size(); i++) {
+ List<MbomModel> mbomModelList = mbomModelMapper.selectList(Wrappers.<MbomModel>query().eq("tech_tem_id", techTemIds.get(i)));
+ for (MbomModel mbomModel : mbomModelList) {
+ Mbom mbom = new Mbom();
+ mbom.setUnit(mbomModel.getUnit());
+ mbom.setName(mbomModel.getName());
+ mbom.setSupplier(mbomModel.getSupplier());
+ mbom.setQualityTraceability(mbomModel.getQualityTraceability());
+ mbom.setSpecifications(mbomModel.getSpecifications());
+ mbom.setTechnologyId(technologyIds.get(i));
+ mbomList.add(mbom);
+ }
+ }
+ mbomService.saveBatch(mbomList);
+ /*鏂板鏍囧噯BOM-->鐢熶骇宸ヨ壓(鎵归噺娣诲姞)*/
+ List<Technique> techniqueList = new ArrayList<>();
+ for (int i = 0; i < technologyIds.size(); i++) {
+ List<TechniqueModel> techniqueModelList = techniqueModelMapper.selectList(Wrappers.<TechniqueModel>query().eq("tech_tem_id", techTemIds.get(i)));
+ for (TechniqueModel techniqueModel : techniqueModelList) {
+ //鏌ヨ璁惧鍚嶇О
+ Device device = deviceMapper.selectById(techniqueModel.getDeviceId());
+ //鏌ヨ鍩虹鐢熶骇宸ヨ壓涓瘡涓澶囩殑鍏蜂綋椤圭洰
+ TechnicalModel technicalModel = technicalModelMapper.selectById(techniqueModel.getTechnicalModelId());
+ Technique technique = new Technique();
+ technique.setTechnologyId(technologyIds.get(i));
+ technique.setDevice(device.getName());
+ technique.setProductFather(technicalModel.getFather());
+ technique.setProduct(technicalModel.getName());
+ technique.setUnit(technicalModel.getUnit());
+ techniqueList.add(technique);
+ }
+ }
+ techniqueService.saveBatch(techniqueList);
+ }
/**
- * 妫�楠屾ā鍧�-->OMS绠$悊-->鎴愬搧妫�楠�-->鏂板(闇�瑕佽鏍煎瀷鍙风殑Id涓庡悕绉�)
+ * 妫�楠屾ā鍧�-->QMS绠$悊-->鎴愬搧妫�楠�-->鏂板(闇�瑕佽鏍煎瀷鍙风殑Id涓庡悕绉�)
*/
@Override
public List<Map<String, Object>> selectSpecificationIdAndName(Integer materialId) {
--
Gitblit v1.9.3