| | |
| | | |
| | | import cn.hutool.core.collection.CollUtil; |
| | | import cn.hutool.core.util.StrUtil; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | |
| | | import com.ruoyi.basic.mapper.*; |
| | | import com.ruoyi.basic.pojo.*; |
| | | import com.ruoyi.basic.service.CapacityScopeService; |
| | | import com.ruoyi.common.core.domain.entity.SysDictData; |
| | | 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 com.ruoyi.system.mapper.SysDictTypeMapper; |
| | | import com.ruoyi.system.service.ISysDictTypeService; |
| | | import lombok.AllArgsConstructor; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | @AllArgsConstructor |
| | | public class CapacityScopeServiceImpl extends ServiceImpl<StructureItemParameterMapper, StructureItemParameter> implements CapacityScopeService { |
| | | |
| | | private LaboratoryMapper laboratoryMapper; |
| | | private StandardProductListMapper standardProductListMapper; |
| | | |
| | | private ThreadPoolTaskExecutor threadPoolTaskExecutor; |
| | | |
| | | private StructureItemParameterMapper structureItemParameterMapper; |
| | | |
| | |
| | | |
| | | private StructureItemParameterService structureItemParameterService; |
| | | |
| | | private ISysDictTypeService sysDictTypeService; |
| | | |
| | | @Override |
| | | public IPage<StructureItemParameter> selectItemParameterList(Page page, StructureItemParameter itemParameter) { |
| | | return structureItemParameterMapper.selectItemParameterList(page, QueryWrappers.queryWrappers(itemParameter)); |
| | | IPage<StructureItemParameter> parameterIPage = structureItemParameterMapper.selectItemParameterList(page, QueryWrappers.queryWrappers(itemParameter)); |
| | | //查询字典 |
| | | Map<String, List<SysDictData>> dictMaps = sysDictTypeService.selectEnumListByCategory(Arrays.asList("检验项类型", "是否", "检验值类型", "单位")); |
| | | parameterIPage.getRecords().forEach(ele->{ |
| | | ele.setInspectionItemTypeTwo(getLabelByValue(dictMaps.get("检验项类型"),ele.getInspectionItemType())); |
| | | ele.setUpdateBsm(getLabelByValue(dictMaps.get("是否"),ele.getBsm())); |
| | | ele.setInspectionValueTypeTwo(getLabelByValue(dictMaps.get("检验值类型"),ele.getInspectionValueType())); |
| | | }); |
| | | return parameterIPage; |
| | | } |
| | | |
| | | /** |
| | | * 根据value获取字典 |
| | | * @param dictList |
| | | * @param value |
| | | * @return |
| | | */ |
| | | private String getLabelByValue(List<SysDictData> dictList, String value){ |
| | | if(dictList.isEmpty()){ |
| | | return ""; |
| | | } |
| | | return dictList.stream().filter(ele-> Objects.equals(ele.getDictValue(),value)).map(SysDictData::getDictLabel).findFirst().orElse(""); |
| | | } |
| | | |
| | | @Override |
| | |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int upItemParameter(StructureItemParameter itemParameter) { |
| | | //能力范围更新,同时更新对应的标准库 |
| | | StructureItemParameter oldParameter = structureItemParameterMapper.selectById(itemParameter.getId()); |
| | | //判断检验项、检验子项、单位是否有修改,有就同时修改标准库对应的数据 |
| | | if( |
| | | !StringUtils.equals(itemParameter.getInspectionItem(),oldParameter.getInspectionItem()) || |
| | | !StringUtils.equals(itemParameter.getInspectionItemSubclass(),oldParameter.getInspectionItemSubclass()) || |
| | | !StringUtils.equals(itemParameter.getInspectionItemEn(),oldParameter.getInspectionItemEn()) || |
| | | !StringUtils.equals(itemParameter.getInspectionItemSubclassEn(),oldParameter.getInspectionItemSubclassEn()) || |
| | | !StringUtils.equals(itemParameter.getUnit(),oldParameter.getUnit()) |
| | | ){ |
| | | CompletableFuture.runAsync(() -> { |
| | | LambdaUpdateWrapper<StandardProductList> updateWrapper = Wrappers.<StandardProductList>lambdaUpdate() |
| | | .set(StandardProductList::getInspectionItem, itemParameter.getInspectionItem()) |
| | | .set(StandardProductList::getInspectionItemEn, itemParameter.getInspectionItemEn()) |
| | | .set(StandardProductList::getInspectionItemSubclass, itemParameter.getInspectionItemSubclass()) |
| | | .set(StandardProductList::getInspectionItemSubclassEn, itemParameter.getInspectionItemSubclassEn()) |
| | | .set(StandardProductList::getUnit, itemParameter.getUnit()) |
| | | .eq(StandardProductList::getStructureItemParameterId,itemParameter.getId()); |
| | | standardProductListMapper.update(null,updateWrapper); |
| | | },threadPoolTaskExecutor); |
| | | } |
| | | return structureItemParameterMapper.updateById(itemParameter); |
| | | } |
| | | |
| | |
| | | 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)); |
| | | |
| | | if (productIds.size()>0) { |
| | | productMapper.delete(Wrappers.<Product>lambdaQuery() |
| | | .in(Product::getId, productIds)); |
| | | } |
| | | return structureTestObjectMapper.deleteById(id); |
| | | } |
| | | |