From 61f0ed42abb8b3a270f3dcefeff988da5e73a5fe Mon Sep 17 00:00:00 2001 From: Fixiaobai <fixiaobai@163.com> Date: 星期六, 09 九月 2023 11:55:05 +0800 Subject: [PATCH] 修改bug --- standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/MaterialServiceImpl.java | 42 +++++++++++++++++++++++++----------------- 1 files changed, 25 insertions(+), 17 deletions(-) diff --git a/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/MaterialServiceImpl.java b/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/MaterialServiceImpl.java index 4e3721e..96d6a64 100644 --- a/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/MaterialServiceImpl.java +++ b/standard-server/src/main/java/com/yuanchu/limslaboratory/service/impl/MaterialServiceImpl.java @@ -1,30 +1,25 @@ package com.yuanchu.limslaboratory.service.impl; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; -import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.yuanchu.limslaboratory.mapper.ProductModelMapper; -import com.yuanchu.limslaboratory.pojo.Material; +import com.yuanchu.limslaboratory.pojo.*; import com.yuanchu.limslaboratory.mapper.MaterialMapper; -import com.yuanchu.limslaboratory.pojo.Product; -import com.yuanchu.limslaboratory.pojo.Specifications; -import com.yuanchu.limslaboratory.pojo.Standard; import com.yuanchu.limslaboratory.pojo.dto.AddMaterialDto; import com.yuanchu.limslaboratory.service.MaterialService; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.yuanchu.limslaboratory.service.ProductService; import com.yuanchu.limslaboratory.service.SpecificationsService; import com.yuanchu.limslaboratory.service.StandardService; -import com.yuanchu.limslaboratory.utils.MyUtil; -import org.springframework.beans.BeanUtils; +import com.yuanchu.limslaboratory.utils.ArrayListUtil; 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.ArrayList; import java.util.List; import java.util.Map; import java.util.stream.Collectors; @@ -85,9 +80,11 @@ @Override @Transactional(rollbackFor = Exception.class) public Integer addMaterialInformation(AddMaterialDto addMaterialDto) { - Material material = materialMapper.selectOne(Wrappers.<Material>query().eq("name", addMaterialDto.getMaterialName())); - material.setType(addMaterialDto.getType()); - int isInsertSuccess = materialMapper.updateById(material); + Material material = new Material() + .setCode("BZ" + IdWorker.getIdStr()) + .setName(addMaterialDto.getMaterialName()) + .setType(addMaterialDto.getType()); + int isInsertSuccess = materialMapper.insert(material); if (isInsertSuccess > 0) { Standard standard = new Standard() .setMaterialId(material.getId()) @@ -104,8 +101,12 @@ List<Product> productList = productModel.stream().map(stringObjectMap -> { Product product = new Product(); product.setName(stringObjectMap.get("name").toString()); - product.setFather(stringObjectMap.get("father").toString()); - product.setUnit(stringObjectMap.get("unit").toString()); + if (ObjectUtils.isNotEmpty(stringObjectMap.get("father"))) { + product.setFather(stringObjectMap.get("father").toString()); + } + if (ObjectUtils.isNotEmpty(stringObjectMap.get("unit"))) { + product.setUnit(stringObjectMap.get("unit").toString()); + } product.setSpecifications_id(specifications.getId()); return product; }).collect(Collectors.toList()); @@ -118,14 +119,21 @@ } @Override - public List<Map<String, Object>> getFourLevelInformation(String specificationName) { - return materialMapper.FourTree(specificationName); + public List<Map<String, Object>> getFourLevelInformation() { + return materialMapper.FourTree(); } //娣诲姞鎸囨爣-->閫夋嫨鏍峰搧鍚嶇О @Override public List<String> selectmater() { - return materialMapper.selectmater(); + return productModelMapper.selectmater(); + } + + @Override + public List<ProductModel> getSample() { + QueryWrapper<ProductModel>queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().select(ProductModel::getMaterial,ProductModel::getId).eq(ProductModel::getState,1); + return ArrayListUtil.oneObjectsDistinctByProperty(ProductModel::getMaterial,productModelMapper.selectList(queryWrapper)); } -- Gitblit v1.9.3