From b9e2c1619cf61bcd5f24b858fff738244d20566e Mon Sep 17 00:00:00 2001
From: zss <zss@example.com>
Date: 星期二, 05 九月 2023 17:04:29 +0800
Subject: [PATCH] 过程检验修改9-5
---
inspect-server/src/main/java/com/yuanchu/mom/service/impl/FinishedInspectServiceImpl.java | 181 +++++++++++++++++++++++++++++++++++++++++----
1 files changed, 165 insertions(+), 16 deletions(-)
diff --git a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/FinishedInspectServiceImpl.java b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/FinishedInspectServiceImpl.java
index ffb04db..b7466c0 100644
--- a/inspect-server/src/main/java/com/yuanchu/mom/service/impl/FinishedInspectServiceImpl.java
+++ b/inspect-server/src/main/java/com/yuanchu/mom/service/impl/FinishedInspectServiceImpl.java
@@ -3,26 +3,25 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.yuanchu.mom.mapper.ImportRepertoryMapper;
-import com.yuanchu.mom.mapper.InspectUnacceptedMapper;
-import com.yuanchu.mom.mapper.RepertoryMapper;
-import com.yuanchu.mom.pojo.FinishedInspect;
-import com.yuanchu.mom.mapper.FinishedInspectMapper;
-import com.yuanchu.mom.pojo.ImportRepertory;
-import com.yuanchu.mom.pojo.InspectUnaccepted;
-import com.yuanchu.mom.pojo.Repertory;
-import com.yuanchu.mom.service.FinishedInspectService;
+import com.yuanchu.mom.mapper.*;
+import com.yuanchu.mom.pojo.*;
+import com.yuanchu.mom.pojo.vo.FinishedInspectVo1;
+import com.yuanchu.mom.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import com.yuanchu.mom.service.InspectionItemService;
-import com.yuanchu.mom.service.ProductService;
+import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
+import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.Objects;
+import java.util.stream.Collectors;
/**
* <p>
@@ -38,11 +37,23 @@
@Resource
private FinishedInspectMapper finishedInspectMapper;
+ @Resource
+ MaterialMapper materialMapper;
+
+ @Resource
+ StandardService standardService;
+
+ @Resource
+ SpecificationsService specificationsService;
+
+ @Resource
+ InspectionItemService inspectionItemService;
+
@Autowired
private ProductService productService;
- @Autowired
- private InspectionItemService inspectionItemService;
+ @Resource
+ UserMapper userMapper;
@Resource
InspectUnacceptedMapper inspectUnacceptedMapper;
@@ -53,13 +64,19 @@
@Resource
ImportRepertoryMapper importRepertoryMapper;
+ @Resource
+ TechnologyMapper technologyMapper;
+
+ @Resource
+ TechniqueMapper techniqueMapper;
+
@Override
public Integer addProcessInspectionSheet(FinishedInspect finishedInspect) {
finishedInspect.setType(0);
int insert = finishedInspectMapper.insert(finishedInspect);
if (insert == 1) {
- List<Map<String, Object>> maps = productService.selectProductList(finishedInspect.getSpecificationsId());
- inspectionItemService.insertList(finishedInspect.getId(), maps);
+ /*List<Map<String, Object>> maps = productService.selectProductList(finishedInspect.getSpecificationsId());
+ inspectionItemService.insertList(finishedInspect.getId(), maps);*/
return insert;
}
return 0;
@@ -167,7 +184,7 @@
}
}
//濡傛灉鏄繃绋嬫楠屽悎鏍�,闇�瑕佹柊澧炲崐鎴愬搧(1)搴撳瓨,妫�楠岀粨鏋滀负鍚堟牸1
- if (finishedInspect.getType()==1) {
+ if (finishedInspect.getType() == 1) {
/*鏂板鍗婃垚鍝�(1)搴撳瓨*/
//濡傛灉鍏ュ簱鐨勪俊鎭竴鏍峰彧鏈夊簱瀛樹笉涓�鏍�,鍒欏湪鍘熸潵鐨勫簱瀛樻暟閲忎笂鍔犱笂鐩稿簲鐨勬暟閲�
LambdaQueryWrapper<Repertory> queryWrapper = new LambdaQueryWrapper<>();
@@ -208,4 +225,136 @@
public IPage<Map<String, Object>> selectFinishedInspectPage(Page<Object> page, Integer inspectResult, String inspectDate, String inspectUsername) {
return finishedInspectMapper.selectFinishedInspectPage(page, inspectResult, inspectDate, inspectUsername);
}
+
+ //鏂板杩囩▼妫�楠屽崟-->鏍规嵁璁㈠崟鍙烽�夋嫨浜у搧淇℃伅
+ @Override
+ public List<Map<String, Object>> chooseMater(String orderNumber) {
+ return finishedInspectMapper.chooseMater(orderNumber);
+ }
+
+ //鏂板杩囩▼妫�楠屽崟
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public String addProcess(String userId, FinishedInspectVo1 finishedInspectVo1) {
+ /*鏂板杩囩▼妫�楠屽崟*/
+ FinishedInspect finishedInspect = new FinishedInspect();
+ finishedInspect.setType(1);
+ finishedInspect.setUserId(Integer.parseInt(userId));
+ BeanUtils.copyProperties(finishedInspectVo1, finishedInspect);
+ finishedInspectMapper.insert(finishedInspect);
+ /*鎵归噺鏂板杩囩▼妫�楠岄」鐩〃*/
+ //鑾峰彇鍨嬪彿id
+ Integer specificationId = getSpecificationId(finishedInspectVo1.getMaterial(), finishedInspectVo1.getMaterialCode(), finishedInspectVo1.getSpecificationsModel());
+ //鏌ヨ鏍囧噯BOM鎶�鏈寚鏍囦腑璇ュ瀷鍙峰伐鑹轰笅鏈�鏂扮増鏈殑妫�楠岄」鐩�
+ Integer ver = productService.selectVerByPro(specificationId).get(0);//璇ュ瀷鍙蜂笅鎶�鏈寚鏍囨渶鏂扮増鏈�
+ List<Product> productList = productService.selProByVerSpe(finishedInspectVo1.getTechnologyId(), ver);
+ List<InspectionItem> inspectionItemList = productList.stream().map(product -> {
+ InspectionItem inspectionItem = new InspectionItem();
+ BeanUtils.copyProperties(product, inspectionItem);
+ inspectionItem.setFinishInspectId(finishedInspect.getId());
+ //濡傛灉鏂板鏃惰繕濉啓浜嗘楠屽�煎垯瑕佽繘琛屽垽鏂楠岀粨鏋�
+ if (ObjectUtils.isNotEmpty(finishedInspectVo1.getInspectionValue())) {
+ inspectionItem.setInspectionValue(finishedInspectVo1.getInspectionValue());
+ //鍒ゆ柇妫�娴嬪�兼槸鍚︽弧瓒虫爣鍑嗗�煎拰鍐呮帶鍊肩殑瑕佹眰,濡傛灉涓嶆弧瓒冲垯妫�楠岀粨璁轰负涓嶅悎鏍�0
+ String required = product.getRequired();//鏍囧噯鍊�
+ String internal = product.getInternal();//鍐呮帶鍊�
+ String testValue = finishedInspectVo1.getInspectionValue();//妫�娴嬪��
+ List<Integer> list = Arrays.stream(testValue.split(",")).map(s -> {
+ int values = checkValues(required, internal, s);
+ return values;
+ }).collect(Collectors.toList());
+ if (list.contains(0)) {
+ //濡傛灉鍏朵腑涓�涓楠屽�间笉鍚堟牸鍒欒椤圭洰妫�楠屼笉鍚堟牸
+ inspectionItem.setResult(0);
+ } else {
+ inspectionItem.setResult(1);
+ }
+ inspectionItem.setUsername(userMapper.selectById(userId).getName());
+ }
+ return inspectionItem;
+ }).collect(Collectors.toList());
+ inspectionItemService.saveBatch(inspectionItemList);
+ return "鏂板杩囩▼妫�楠屽崟"+finishedInspect.getId()+"鎴愬姛!";
+ }
+
+ //鏂板杩囩▼妫�楠屽崟-->閫夋嫨璁惧
+ @Override
+ public List<Map<String, Object>> chooseDev(Integer technologyId, String father, String name) {
+ //璇ュ伐鑹篿d涓嬬敓浜у伐鑹烘渶鏂扮増鏈�
+ Integer ver = techniqueMapper.selectVerByTeId(technologyId).get(0);
+ return techniqueMapper.selDevByVerTecIdFaNam(technologyId,father,name,ver);
+ }
+
+
+ /*鏍规嵁鏍峰搧鍚嶇О,鏍峰搧缂栧彿,鍨嬪彿瑙勬牸鑾峰彇鍨嬪彿id*/
+ private Integer getSpecificationId(String name, String mcode, String specification) {
+ //鑾峰彇鐗╂枡id
+ Material material = materialMapper.selectOne(Wrappers.<Material>query()
+ .eq("name", name)
+ .eq("code", mcode));
+ if (Objects.isNull(material)) {
+ return null;
+ }
+ //鑾峰彇瑙勬牸鍚嶇О鍜屽瀷鍙峰悕绉�
+ String[] split = specification.split("-");
+ String stName = split[0];
+ String spName = split[1];
+ //鑾峰彇瑙勬牸id
+ Standard standard = standardService.getOne(Wrappers.<Standard>query()
+ .eq("name", stName)
+ .eq("material_id", material.getId()));
+ //鑾峰彇鍨嬪彿id
+ Specifications specifications = specificationsService.getOne(Wrappers.<Specifications>query()
+ .eq("name", spName)
+ .eq("standard_id", standard.getId()));
+ return specifications.getId();
+ }
+
+ /*鍒ゆ柇妫�娴嬪�兼槸鍚︽弧瓒虫爣鍑嗗�煎拰鍐呮帶鍊肩殑瑕佹眰,濡傛灉涓嶆弧瓒冲垯妫�楠岀粨璁轰负涓嶅悎鏍�*/
+ private int checkValues(String standardValueStr, String controlValueStr, String detectionValueStr) {
+ boolean isStandardValueSatisfied = isValueSatisfied(standardValueStr, detectionValueStr);
+ boolean isControlValueSatisfied = isValueSatisfied(controlValueStr, detectionValueStr);
+
+ if (isStandardValueSatisfied && isControlValueSatisfied) {
+ return 1;
+ } else {
+ return 0;
+ }
+ }
+
+ private boolean isValueSatisfied(String valueStr, String detectionValueStr) {
+ String substring = valueStr.substring(1, 2);
+ if (substring.equals("=")) {
+ String operator = valueStr.substring(0, 2);
+ Double standardValue = Double.parseDouble(valueStr.substring(2));
+ Double detectionValue = Double.parseDouble(detectionValueStr);
+ switch (operator) {
+ case ">=":
+ return detectionValue >= standardValue;
+ case "<=":
+ return detectionValue <= standardValue;
+ default:
+ return false;
+ }
+ } else {
+ String operator = valueStr.substring(0, 1);
+ Double standardValue = Double.parseDouble(valueStr.substring(1));
+ Double detectionValue = Double.parseDouble(detectionValueStr);
+ switch (operator) {
+ case ">":
+ return detectionValue > standardValue;
+ case "鈮�":
+ return detectionValue >= standardValue;
+ case "鈮�":
+ return detectionValue <= standardValue;
+ case "<":
+ return detectionValue < standardValue;
+ case "=":
+ return detectionValue.equals(standardValue);
+ default:
+ return false;
+ }
+ }
+ }
+
}
--
Gitblit v1.9.3