¶Ô±ÈÐÂÎļþ |
| | |
| | | package com.ruoyi.basic.service.impl; |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | 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.ruoyi.basic.dto.PageTestObjectDto; |
| | | import com.ruoyi.basic.dto.TestItemDto; |
| | | import com.ruoyi.basic.mapper.*; |
| | | import com.ruoyi.basic.pojo.*; |
| | | import com.ruoyi.basic.service.CapacityScopeService; |
| | | import com.ruoyi.common.exception.base.BaseException; |
| | | import com.ruoyi.common.utils.QueryWrappers; |
| | | import com.ruoyi.basic.service.StandardProductListService; |
| | | import com.ruoyi.basic.service.StructureItemParameterService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * æ£éªé¡¹ç®åæ°(StructureItemParameter)表æå¡å®ç°ç±» |
| | | * |
| | | * @author makejava |
| | | * @since 2024-02-26 16:21:17 |
| | | */ |
| | | @Service |
| | | @AllArgsConstructor |
| | | public class CapacityScopeServiceImpl extends ServiceImpl<StructureItemParameterMapper, StructureItemParameter> implements CapacityScopeService { |
| | | |
| | | private LaboratoryMapper laboratoryMapper; |
| | | |
| | | private StructureItemParameterMapper structureItemParameterMapper; |
| | | |
| | | private StructureTestObjectMapper structureTestObjectMapper; |
| | | |
| | | private ProductMapper productMapper; |
| | | |
| | | private StandardProductListService standardProductListService; |
| | | |
| | | private StandardTreeMapper standardTreeMapper; |
| | | |
| | | private StructureItemParameterService structureItemParameterService; |
| | | |
| | | @Override |
| | | public IPage<StructureItemParameter> selectItemParameterList(Page page, StructureItemParameter itemParameter) { |
| | | return structureItemParameterMapper.selectItemParameterList(page, QueryWrappers.queryWrappers(itemParameter)); |
| | | } |
| | | |
| | | @Override |
| | | public int addItemParameter(StructureItemParameter itemParameter) { |
| | | if (itemParameter.getBsm().equals("")||itemParameter.getBsm()==null){ |
| | | itemParameter.setBsm("0"); |
| | | } |
| | | int insert = structureItemParameterMapper.insert(itemParameter); |
| | | return insert; |
| | | } |
| | | |
| | | @Override |
| | | public int delItemParameter(Integer id) { |
| | | return structureItemParameterMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public int upItemParameter(StructureItemParameter itemParameter) { |
| | | return structureItemParameterMapper.updateById(itemParameter); |
| | | } |
| | | |
| | | @Override |
| | | public IPage<PageTestObjectDto> selectTestObjectList(Page page, PageTestObjectDto pageTestObjectDto) { |
| | | return structureTestObjectMapper.selectTestObjectList(page, QueryWrappers.queryWrappers(pageTestObjectDto)); |
| | | } |
| | | |
| | | @Override |
| | | public int addTestObject(StructureTestObject testObject) { |
| | | Long count = structureTestObjectMapper.selectCount(Wrappers.<StructureTestObject>lambdaQuery().eq(StructureTestObject::getSpecimenName, testObject.getSpecimenName())); |
| | | if(count.compareTo(0L) > 0){ |
| | | throw new BaseException("æ£éªå¯¹è±¡ä¸è½éå¤"); |
| | | } |
| | | |
| | | return structureTestObjectMapper.insert(testObject); |
| | | } |
| | | |
| | | @Override |
| | | public int delTestObject(Integer id) { |
| | | // å é¤äº§åç»´æ¤çé¶ä»¶ç»å® |
| | | List<Product> products = productMapper.selectList(Wrappers.<Product>lambdaQuery() |
| | | .eq(Product::getObjectId, id)); |
| | | List<Integer> productIds = products.stream().map(Product::getId).collect(Collectors.toList()); |
| | | // å é¤äº§åç»´æ¤ |
| | | productMapper.delete(Wrappers.<Product>lambdaQuery() |
| | | .in(Product::getId, productIds)); |
| | | |
| | | return structureTestObjectMapper.deleteById(id); |
| | | } |
| | | |
| | | @Override |
| | | public int upTestObject(StructureTestObject testObject) { |
| | | // æ¥è¯¢æ§çæ£éªå¯¹è±¡ |
| | | StructureTestObject oldTestObject = structureTestObjectMapper.selectById(testObject.getId()); |
| | | |
| | | if (!oldTestObject.getSpecimenName().equals(testObject.getSpecimenName())) { |
| | | // æ¥è¯¢ææå¯¹è±¡ä¸æ ·çæ£éªé¡¹ç® |
| | | List<StandardProductList> standardProductLists = standardProductListService.list(Wrappers.<StandardProductList>lambdaUpdate() |
| | | .eq(StandardProductList::getSampleType, oldTestObject.getSpecimenName())); |
| | | if (CollectionUtils.isNotEmpty(standardProductLists)){ |
| | | for (StandardProductList standardProductList : standardProductLists) { |
| | | // ä¿®æ¹ææç对象åç§°åæ°åç»æ |
| | | standardProductList.setSampleType(testObject.getSpecimenName()); |
| | | // éè¦æªå第ä¸çº§, é¿å
ä¸å级åç§°ä¸æ ·ä¿®æ¹é误 |
| | | String[] trees = standardProductList.getTree().split(" - "); |
| | | trees[2] = testObject.getSpecimenName(); |
| | | List<String> list = CollUtil.newArrayList(trees); |
| | | String newName = CollUtil.join(list, " - "); |
| | | standardProductList.setTree(newName); |
| | | } |
| | | standardProductListService.updateBatchById(standardProductLists); |
| | | } |
| | | // ä¿®æ¹æ£éªé¡¹ç®åæ°çæ£éªå¯¹è±¡ |
| | | // æ¼æ¥ ["object", æ¥è¯¢æ£éªé¡¹ç®åæ°ä¿®æ¹ç»å®çæ£éªå¯¹è±¡ |
| | | String format = "[\"{}\","; |
| | | String sampleOld = StrUtil.format(format, oldTestObject.getSpecimenName()); |
| | | List<StructureItemParameter> itemParameterList = structureItemParameterService.list(Wrappers.<StructureItemParameter>lambdaQuery() |
| | | .like(StructureItemParameter::getSample, sampleOld)); |
| | | if (CollectionUtils.isNotEmpty(itemParameterList)) { |
| | | for (StructureItemParameter structureItemParameter : itemParameterList) { |
| | | // ä¿®æ¹ç»å®çæ ·ååç§° |
| | | String sampleNew = StrUtil.format(format, testObject.getSpecimenName()); |
| | | String sampleUp = structureItemParameter.getSample().replace(sampleOld, sampleNew); |
| | | structureItemParameter.setSample(sampleUp); |
| | | } |
| | | structureItemParameterService.updateBatchById(itemParameterList); |
| | | } |
| | | |
| | | // ä¿®æ¹æ çåå· |
| | | standardTreeMapper.update(null, Wrappers.<StandardTree>lambdaUpdate() |
| | | .eq(StandardTree::getSampleType, oldTestObject.getSpecimenName()) |
| | | .set(StandardTree::getSampleType, testObject.getSpecimenName())); |
| | | } |
| | | |
| | | Long count = structureTestObjectMapper.selectCount(Wrappers.<StructureTestObject>lambdaQuery() |
| | | .eq(StructureTestObject::getSpecimenName, testObject.getSpecimenName()) |
| | | .ne(StructureTestObject::getId, testObject.getId())); |
| | | if(count.compareTo(0L) > 0){ |
| | | throw new BaseException("æ£éªå¯¹è±¡ä¸è½éå¤"); |
| | | } |
| | | |
| | | return structureTestObjectMapper.updateById(testObject); |
| | | } |
| | | |
| | | @Override |
| | | public List<StructureTestObject> selectTestObjectByName() { |
| | | return structureTestObjectMapper.selectList(Wrappers.<StructureTestObject>lambdaQuery().select(StructureTestObject::getSpecimenName,StructureTestObject::getId)); |
| | | } |
| | | |
| | | //设å¤éé¢éæ©æ£éªé¡¹ç®(æ å½¢ç»æ) |
| | | @Override |
| | | public List<Map<String, Object>> getInsProduction() { |
| | | return structureItemParameterMapper.getInsProduction(); |
| | | } |
| | | |
| | | @Override |
| | | public List<TestItemDto> getItemTree() { |
| | | return structureItemParameterMapper.getItemTree(); |
| | | } |
| | | } |
| | | |