From 86adbb1544142dcfb48333dade822f81640607a6 Mon Sep 17 00:00:00 2001
From: XiaoRuby <3114200645@qq.com>
Date: 星期五, 01 九月 2023 13:50:16 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'
---
standard-server/src/main/java/com/yuanchu/mom/service/impl/StandardServiceImpl.java | 132 +++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 129 insertions(+), 3 deletions(-)
diff --git a/standard-server/src/main/java/com/yuanchu/mom/service/impl/StandardServiceImpl.java b/standard-server/src/main/java/com/yuanchu/mom/service/impl/StandardServiceImpl.java
index f52274f..647020d 100644
--- a/standard-server/src/main/java/com/yuanchu/mom/service/impl/StandardServiceImpl.java
+++ b/standard-server/src/main/java/com/yuanchu/mom/service/impl/StandardServiceImpl.java
@@ -1,10 +1,18 @@
package com.yuanchu.mom.service.impl;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.yuanchu.mom.pojo.Standard;
-import com.yuanchu.mom.service.StandardService;
-import com.yuanchu.mom.mapper.StandardMapper;
+import com.yuanchu.mom.mapper.*;
+import com.yuanchu.mom.pojo.*;
+import com.yuanchu.mom.pojo.dto.StandardDto;
+import com.yuanchu.mom.service.*;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.stream.Collectors;
/**
* @author Administrator
@@ -14,6 +22,124 @@
@Service
public class StandardServiceImpl extends ServiceImpl<StandardMapper, Standard> implements StandardService {
+ @Resource
+ MaterialMapper materialMapper;
+
+ @Resource
+ StandardMapper standardMapper;
+
+ @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;
+
+ //(3绾�)鏂板-->鏍囧噯,鍨嬪彿
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void addStandard(StandardDto standardDto) {
+ /*鏂板鏍囧噯琛�*/
+ Standard standard = new Standard();
+ standard.setMaterial_id(standardDto.getId());
+ standard.setName(standardDto.getStandard());
+ standardMapper.insert(standard);
+ /*鏂板鍨嬪彿琛�*/
+ Specifications specifications = new Specifications();
+ specifications.setStandardId(standard.getId());
+ specifications.setName(standardDto.getSpecifications());
+ specificationsMapper.insert(specifications);
+ /*鏂板鏍囧噯BOM-->宸ヨ壓璺嚎(鎵归噺娣诲姞)*/
+ //鏌ヨ鐗╂枡鐨勫ぇ绫�(鏍规嵁鐗╂枡id)
+ Material material = materialMapper.selectById(standardDto.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);
+ }
}
--
Gitblit v1.9.3