From 61f0ed42abb8b3a270f3dcefeff988da5e73a5fe Mon Sep 17 00:00:00 2001
From: Fixiaobai <fixiaobai@163.com>
Date: 星期六, 09 九月 2023 11:55:05 +0800
Subject: [PATCH] 修改bug
---
inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java | 58 ++++++++++++++++++++++++++++++++++++++++++++--------------
1 files changed, 44 insertions(+), 14 deletions(-)
diff --git a/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java b/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java
index f90a852..3431a35 100644
--- a/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java
+++ b/inspection-server/src/main/java/com/yuanchu/limslaboratory/service/impl/InspectionServiceImpl.java
@@ -3,24 +3,28 @@
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Snowflake;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.yuanchu.limslaboratory.exception.ApplicationException;
import com.yuanchu.limslaboratory.mapper.*;
import com.yuanchu.limslaboratory.pojo.*;
import com.yuanchu.limslaboratory.pojo.vo.InsProductVo;
import com.yuanchu.limslaboratory.pojo.vo.InspectDetailVo;
import com.yuanchu.limslaboratory.pojo.vo.InspectionVo;
import com.yuanchu.limslaboratory.service.*;
+import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.*;
+import java.util.concurrent.atomic.AtomicBoolean;
import java.util.stream.Collectors;
/**
@@ -30,6 +34,7 @@
* @since 2023-08-03 13:03:36
*/
@Service
+@Slf4j
public class InspectionServiceImpl extends ServiceImpl<InspectionMapper, Inspection> implements InspectionService {
@Resource
@@ -83,14 +88,13 @@
//鏂板妫�楠屽崟-->閫夋嫨妫�楠岄」鐩増鏈�
@Override
public List<Integer> chooseVer(String name, String mcode, String specifications) {
- Integer specificationId = getSpecificationId(name, mcode, specifications);
- return productMapper.chooseVersion(specificationId);
+ return productMapper.chooseVersion(Integer.parseInt(specifications));
}
//鏂板妫�楠屽崟-->閫夋嫨妫�楠岄」鐩増鏈�-->鏌ョ湅璇ョ増鏈笅鎴戜滑瑕佸仛鐨勯」鐩姹�
@Override
public List<Map<String, Object>> lookProByVer(String name, String mcode, String specifications, Integer version, String experiment) {
- Integer specificationId = getSpecificationId(name, mcode, specifications);
+ Integer specificationId = Integer.parseInt(specifications);
/*濡傛灉璇曢獙椤圭洰涓虹┖鍒欐槸鎴愬搧妫�楠屾垨鑰呭師鏉愭枡妫�楠屽垯鏄睍绀鸿鐗堟湰鐨勬墍鏈夐」鐩楠岃姹傚弬鏁�*/
if (ObjectUtils.isEmpty(experiment)) {
return productMapper.pageProductInformation(specificationId, version);
@@ -119,7 +123,8 @@
*/
@Override
@Transactional(rollbackFor = Exception.class)
- public Integer addInspect(Integer id, InspectionVo inspectionVo) {
+ public Integer addInspect(Integer id, InspectionVo inspectionVo) throws ApplicationException {
+ log.info(inspectionVo.toString());
/*鏂板妫�楠岀敵璇疯〃*/
Inspection inspection = Inspection.builder()
.startTime(inspectionVo.getStartTime())
@@ -152,19 +157,21 @@
.num(inspectionVo.getNum())
.unit(inspectionVo.getUnit())
.supplier(inspectionVo.getSupplier())
+ .specificationsId(inspectionVo.getSpecificationId())
.specifications(inspectionVo.getSpecifications())
.formTime(inspectionVo.getFormTime())
.inspectionId(inspection.getId())
+ .notes(inspectionVo.getNotes())
.build();
inspectionMaterialMapper.insert(inspectionMaterial);
/*鏂板妫�楠岄」鐩〃*/
//鏍规嵁鏍峰搧鍚嶇О缂栧彿浠ュ強鍨嬪彿瑙勬牸鑾峰彇鍨嬪彿id
- Integer specificationId = null;
- if(ObjectUtils.isNotEmpty(inspectionVo.getSpecificationId())){
- specificationId =Integer.parseInt(inspectionVo.getSpecificationId());
- }else{
- specificationId=getSpecificationId(inspectionVo.getName(), inspectionVo.getMcode(), inspectionVo.getSpecifications());
- }
+ Integer specificationId = Integer.parseInt(inspectionVo.getSpecificationId());
+ //if(ObjectUtils.isNotEmpty(inspectionVo.getSpecificationId())){
+ // specificationId =Integer.parseInt(inspectionVo.getSpecificationId());
+ //}else{
+ // specificationId=getSpecificationId(inspectionVo.getName(), inspectionVo.getMcode(), inspectionVo.getSpecifications());
+ //}
//濡傛灉璇曢獙椤圭洰瀛楁涓嶄负绌哄垯鎸夎瀛楁鐨勯」鐩繘琛屽尮閰�
if (ObjectUtils.isNotEmpty(inspectionVo.getExperiment())) {
//鑾峰彇璇曢獙椤圭洰淇℃伅(缁撴瀯,瀵肩嚎澶栧緞)
@@ -206,6 +213,16 @@
productMapper.selectList(Wrappers.<Product>query()
.eq("specifications_id", specificationId)
.eq("version",inspectionVo.getVersion()));
+ productList.stream().forEach(p->{
+ String internal = Optional.ofNullable(p)
+ .map(Product::getInternal)
+ .orElse("绌�");
+ String required = Optional.ofNullable(p)
+ .map(Product::getRequired).orElse("绌�");
+ if(Objects.equals("绌�",internal)||Objects.equals(required,"绌�")) {
+ throw new ApplicationException("椤圭洰鐗堟湰涓嶅彲鐢�");
+ }
+ });
//灏嗘煡璇㈢殑椤圭洰淇℃伅鏋勫缓鎴愭楠岄」鐩�
ArrayList<InspectionProduct> list = new ArrayList<>();
for (Product product : productList) {
@@ -254,13 +271,11 @@
BeanUtils.copyProperties(insProduct, insProductVo);
//鑾峰彇璁惧鍚�(鍓嶆彁鏄鏋滃瓨鍦�)
if (insProduct.getInstrumentId() != null) {
- String equipmentName = instrumentService.getById(insProduct.getInstrumentId()).getEquipmentName();
- insProductVo.setInstrumentName(equipmentName);
+ insProductVo.setInstrumentId(insProduct.getInstrumentId());
}
//鑾峰彇鐢ㄦ埛鍚�(鍓嶆彁鏄鏋滃瓨鍦�)
if (insProduct.getUserProId() != null) {
- String userName = userMapper.selectById(insProduct.getUserProId()).getName();
- insProductVo.setUserName(userName);
+ insProductVo.setUserId(insProduct.getUserProId());
}
//椤圭洰鍏宠仈鐗╂枡id
insProductVo.setInspectionMaterialId(inspectionMaterial.getId());
@@ -307,6 +322,21 @@
return inspectionProductMapper.update(null,inspectionProductUpdateWrapper)>0;
}
+ @Override
+ public List<Material> getMaterielTypeIsOne() {
+ QueryWrapper<Material>queryWrapper=new QueryWrapper<>();
+ queryWrapper.lambda()
+ .select(Material::getName,Material::getId,Material::getCode)
+ .eq(Material::getType,1)
+ .eq(Material::getState,1);
+ return materialMapper.selectList(queryWrapper);
+ }
+
+ @Override
+ public Map<String, Object> getSpecification(Integer id) {
+ return materialMapper.getTreeByMaterialId(id);
+ }
+
/*鏍规嵁鏍峰搧鍚嶇О,鏍峰搧缂栧彿,鍨嬪彿瑙勬牸鑾峰彇鍨嬪彿id*/
private Integer getSpecificationId(String name, String mcode, String specification) {
//鑾峰彇鐗╂枡id
--
Gitblit v1.9.3