zhuo
2025-03-29 e145f248db1bfee531fd095b43abf3725a365e57
删除无用标准方法列表
已修改10个文件
已删除4个文件
788 ■■■■ 文件已修改
basic-server/src/main/java/com/ruoyi/basic/controller/StandardMethodController.java 6 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/controller/StandardTreeController.java 54 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/mapper/StandardMethodListMapper.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/mapper/StandardMethodMapper.java 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/pojo/StandardMethodList.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/service/StandardMethodListService.java 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/service/StandardMethodService.java 7 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/service/StandardTreeService.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardMethodListServiceImpl.java 74 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardMethodServiceImpl.java 129 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardTreeServiceImpl.java 311 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/resources/mapper/StandardMethodListMapper.xml 81 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/resources/mapper/StandardMethodMapper.xml 35 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/resources/mapper/StructureItemParameterMapper.xml 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
basic-server/src/main/java/com/ruoyi/basic/controller/StandardMethodController.java
@@ -50,10 +50,4 @@
        return Result.success(standardMethodService.upStandardMethod(standardMethod));
    }
    @ApiOperation(value = "导入标准明细")
    @PostMapping("/importStandardDetails")
    public Result<?> importStandardDetails(@RequestPart("file") MultipartFile file) throws IOException {
        standardMethodService.inputExcel(file);
        return Result.success();
    }
}
basic-server/src/main/java/com/ruoyi/basic/controller/StandardTreeController.java
@@ -2,6 +2,7 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.ruoyi.basic.service.*;
import com.ruoyi.common.core.domain.Result;
import com.ruoyi.basic.dto.CopyStandardProductListDto;
import com.ruoyi.basic.dto.FactoryDto;
@@ -10,10 +11,6 @@
import com.ruoyi.basic.pojo.StandardProductList;
import com.ruoyi.basic.pojo.StandardProductListSupplierAsk;
import com.ruoyi.basic.pojo.StandardTree;
import com.ruoyi.basic.service.StandardMethodListService;
import com.ruoyi.basic.service.StandardProductListService;
import com.ruoyi.basic.service.StandardProductListSupplierAskService;
import com.ruoyi.basic.service.StandardTreeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
@@ -33,7 +30,7 @@
    private StandardTreeService standardTreeService;
    private StandardMethodListService standardMethodListService;
    private StandardMethodService standardMethodService;
    private StandardProductListService standardProductListService;
@@ -60,7 +57,7 @@
    @ApiOperation(value = "根据标准树进行标准查询")
    @GetMapping("/selectsStandardMethodByFLSSM")
    public Result selectsStandardMethodByFLSSM(String tree) {
        return Result.success(standardMethodListService.selectsStandardMethodByFLSSM(tree));
        return Result.success(standardMethodService.selectsStandardMethodByFLSSM(tree));
    }
    @ApiOperation(value = "修改标准库中的内容")
@@ -112,7 +109,7 @@
    @ApiOperation(value = "获取标准树下标准方法枚举")
    @GetMapping("/selectStandardMethodEnum")
    public Result selectStandardMethodEnum() {
        return Result.success(standardMethodListService.selectStandardMethodEnum());
        return Result.success(standardMethodService.selectStandardMethodEnum());
    }
    @ApiOperation(value = "获取产品架构")
@@ -131,49 +128,6 @@
        return Result.success(standardTreeService.upStandardProducts(product));
    }
    @ApiOperation("仅获取光纤的型号")
    @GetMapping("/getStandTreeBySampleType")
    public Result<?> getStandTreeBySampleType(String laboratory, String sampleType) {
        return Result.success(standardTreeService.getStandTreeBySampleType(laboratory, sampleType));
    }
    @ApiOperation("导入标准库")
    @PostMapping("/inExcelOfTree/{isEquipment}")
    public Result inExcelOfTree(@RequestParam("file") MultipartFile file, @PathVariable("isEquipment") Boolean isEquipment) {
        if (!isEquipment) {
            standardTreeService.inExcelOfTree(file);
        } else {
            standardTreeService.importWorkstationExcel(file);
        }
        return Result.success();
    }
    @ApiOperation("重置标准库单价")
    @PostMapping("/resetTreeOfPrice")
    public Result resetTreeOfPrice(@RequestBody Map<String, Object> map) {
        String tree = (String) map.get("tree");
        Integer standardId = (Integer) map.get("standardId");
        standardTreeService.resetTreeOfPrice(tree, standardId);
        return Result.success();
    }
    @ApiOperation("重置标准库工时系数")
    @PostMapping("/resetTreeOfHour")
    public Result resetTreeOfHour(@RequestBody Map<String, Object> map) {
        String tree = (String) map.get("tree");
        Integer standardId = (Integer) map.get("standardId");
        standardTreeService.resetTreeOfHour(tree, standardId);
        return Result.success();
    }
    @ApiOperation("重置标准库要求描述和要求值")
    @PostMapping("/resetTreeOfAsk")
    public Result resetTreeOfAsk(@RequestBody Map<String, Object> map) {
        String tree = (String) map.get("tree");
        Integer standardId = (Integer) map.get("standardId");
        standardTreeService.resetTreeOfAsk(tree, standardId);
        return Result.success();
    }
    @ApiOperation("标准库拖拽")
    @PostMapping("/resetTreeDrag")
basic-server/src/main/java/com/ruoyi/basic/mapper/StandardMethodListMapper.java
ÎļþÒÑɾ³ý
basic-server/src/main/java/com/ruoyi/basic/mapper/StandardMethodMapper.java
@@ -3,9 +3,12 @@
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.basic.pojo.StandardMethodList;
import com.ruoyi.framework.mybatis_config.MyBaseMapper;
import com.ruoyi.basic.pojo.StandardMethod;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @author Administrator
@@ -19,6 +22,17 @@
    StandardMethod selectStandMethodById(@Param("id") Integer id);
    List<StandardMethodList> selectStandardMethodLists(@Param("tree") String tree);
    List<StandardMethodList> selectStandardMethodListsByNull(@Param("tree") String tree);
    List<StandardMethodList> selectStandardMethodLists3(@Param("tree") String tree);
    List<StandardMethodList> selectListEnum();
    Integer getStandardMethodId(@Param("code") String code);
}
basic-server/src/main/java/com/ruoyi/basic/pojo/StandardMethodList.java
@@ -12,7 +12,6 @@
 * æ ‡å‡†æ ‘下的标准列表
 * @TableName standard_method_list
 */
@TableName(value ="standard_method_list")
@Data
public class StandardMethodList implements Serializable {
    /**
basic-server/src/main/java/com/ruoyi/basic/service/StandardMethodListService.java
ÎļþÒÑɾ³ý
basic-server/src/main/java/com/ruoyi/basic/service/StandardMethodService.java
@@ -4,10 +4,12 @@
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.basic.pojo.StandardMethod;
import com.ruoyi.basic.pojo.StandardMethodList;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* @author Administrator
@@ -26,5 +28,8 @@
    int upStandardMethod(StandardMethod standardMethod);
    void inputExcel(MultipartFile file) throws IOException;
    Map<String, List<?>> selectsStandardMethodByFLSSM(String tree);
    List<StandardMethodList> selectStandardMethodEnum();
}
basic-server/src/main/java/com/ruoyi/basic/service/StandardTreeService.java
@@ -27,18 +27,6 @@
    int upStandardProducts(Map<String, Object> product);
    List<StandardTree> getStandTreeBySampleType(String laboratory, String sampleType);
    void inExcelOfTree(MultipartFile file);
    void resetTreeOfPrice(String tree, Integer standardId);
    void resetTreeOfHour(String tree, Integer standardId);
    void resetTreeOfAsk(String tree, Integer standardId);
    void importWorkstationExcel(MultipartFile file);
    /**
     * æ ‡å‡†æ•°æŽ’序
     * @param list
basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardMethodListServiceImpl.java
ÎļþÒÑɾ³ý
basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardMethodServiceImpl.java
@@ -7,6 +7,7 @@
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.pojo.StandardMethodList;
import com.ruoyi.common.utils.QueryWrappers;
import com.ruoyi.basic.mapper.StandardMethodMapper;
import com.ruoyi.basic.mapper.StandardProductListMapper;
@@ -39,11 +40,11 @@
    private StandardMethodMapper standardMethodMapper;
    StandardProductListMapper standardProductListMapper;
    StandardProductListService standardProductListService;
    private StandardProductListMapper standardProductListMapper;
    private StandardProductListService standardProductListService;
    StructureItemParameterMapper structureItemParameterMapper;
    StructureItemParameterService structureItemParameterService;
    private StructureItemParameterMapper structureItemParameterMapper;
    private StructureItemParameterService structureItemParameterService;
    @Override
    public IPage<StandardMethod> selectStandardMethodList(Page page, StandardMethod standardMethod) {
@@ -128,26 +129,6 @@
        return "替换完毕!";
    }
    @Transactional(rollbackFor = Exception.class)
    @Override
    public void inputExcel(MultipartFile file) throws IOException {
        // å­˜å‚¨æ£€æµ‹å¯¹è±¡List
        List<Object> structureTestObjectIdList = new ArrayList<>();
        List<StandardMethod> result = new ArrayList<>();
        ExcelUtil.readBySax(file.getInputStream(), 0, (i, l, list) -> {
            // åŽ»é™¤ç¬¬ä¸€è¡Œè¡¨å¤´
            if (l == 0) {
                return;
            }
            // å­˜å‚¨å”¯ä¸€æ£€æµ‹å¯¹è±¡
            if (!structureTestObjectIdList.contains(list.get(2))) {
                structureTestObjectIdList.add(list.get(2));
            }
            StandardMethod standardMethod = formatData(list);
            result.add(standardMethod);
        });
        addStructureTest(structureTestObjectIdList, result);
    }
    // æ ¼å¼åŒ–数据
    public StandardMethod formatData(List<Object> list) {
@@ -185,74 +166,42 @@
        return standardMethod;
    }
    // æ–°å¢žæ•°æ®
    public void addStructureTest(List<Object> structureTestObjectIdList, List<StandardMethod> standardMethodList) {
        List<StandardMethod> updateList = new ArrayList<>();
        List<Integer> deleteListId = new ArrayList<>();
        List<StandardMethod> addList = new ArrayList<>();
        if (!structureTestObjectIdList.isEmpty()) {
            // å¾ªçޝexcel里面的分组
            structureTestObjectIdList.forEach(j -> {
                // ä»¥excel中的组名查询数据库中的分组
                List<StandardMethod> standardMethods = baseMapper.selectList(Wrappers.<StandardMethod>lambdaQuery()
                        .like(StandardMethod::getStructureTestObjectId, "\"" + j + "\""));
                // å°†ç»“果循环匹配
                for (int i = 0; i < standardMethods.size(); i++) {
                    boolean isExistence = false;
                    for (int i1 = 0; i1 < standardMethodList.size(); i1++) {
                        // æ›´æ–°
                        if (standardMethods.get(i).getStructureTestObjectId().equals(standardMethodList.get(i1).getStructureTestObjectId())
                                && standardMethods.get(i).getCode().equals(standardMethodList.get(i1).getCode())
                                && standardMethods.get(i).getField().equals(standardMethodList.get(i1).getField())) {
                            // ç»™excel数据赋值id做更新
                            standardMethodList.get(i1).setId(standardMethods.get(i).getId());
                            // æ›´æ–°
                            updateList.add(standardMethodList.get(i1));
                            isExistence = true;
                            break;
                        }
                    }
                    // åˆ é™¤
                    if (!isExistence) {
                        deleteListId.add(standardMethods.get(i).getId());
                    }
                }
                for (int i = 0; i < standardMethodList.size(); i++) {
                    if (standardMethodList.get(i).getStructureTestObjectId().contains("\"" + j + "\"")) {
                        boolean isExistence = false;
                        for (int i1 = 0; i1 < standardMethods.size(); i1++) {
                            if (standardMethods.get(i1).getStructureTestObjectId().equals(standardMethodList.get(i).getStructureTestObjectId())
                                    && standardMethods.get(i1).getCode().equals(standardMethodList.get(i).getCode())
                                    && standardMethods.get(i1).getField().equals(standardMethodList.get(i).getField())) {
                                isExistence = true;
                                break;
                            }
                        }
                        // æ–°å¢ž
                        if (!isExistence) {
                            addList.add(standardMethodList.get(i));
                        }
                    }
                }
            });
    @Override
    public Map<String, List<?>> selectsStandardMethodByFLSSM(String tree) {
        String[] trees = tree.split(" - ");
        Map<String, List<?>> map = new HashMap<>();
        String str = "";
        List<StandardMethodList> standardMethodLists = new ArrayList<>();
        switch (trees.length){
            case 5:
                str += "\"" + trees[2] + "\",\"" + trees[3] + "\",\"" + trees[4] + "\"";
                standardMethodLists.addAll(standardMethodMapper.selectStandardMethodLists(str));
                standardMethodLists.addAll(standardMethodMapper.selectStandardMethodLists("\"" + trees[2] + "\",\"" + trees[3] + "\""));
                standardMethodLists.addAll(standardMethodMapper.selectStandardMethodLists("\"" + trees[2] + "\""));
                break;
            case 4:
                str += "\"" + trees[2] + "\",\"" + trees[3] + "\"";
                standardMethodLists.addAll(standardMethodMapper.selectStandardMethodLists(str));
                standardMethodLists.addAll(standardMethodMapper.selectStandardMethodLists("\"" + trees[2] + "\""));
                break;
            case 3:
                str += "\"" + trees[2] + "\"";
                standardMethodLists.addAll(standardMethodMapper.selectStandardMethodLists3(str));
                break;
            default:
                map.put("standardMethodList", null);
                return map;
        }
        if (!addList.isEmpty()) {
            // æ–°å¢ž
            baseMapper.insertBatchSomeColumn(addList);
        }
        if (!deleteListId.isEmpty()) {
            // åˆ é™¤
            baseMapper.deleteBatchIds(deleteListId);
        }
        if (!updateList.isEmpty()) {
            // æ›´æ–°
            updateList.forEach(i -> {
                baseMapper.updateById(i);
            });
        }
        standardMethodLists.addAll(standardMethodMapper.selectStandardMethodListsByNull(str));
        map.put("standardMethodList", standardMethodLists);
        return map;
    }
    @Override
    public List<StandardMethodList> selectStandardMethodEnum() {
        return standardMethodMapper.selectListEnum();
    }
}
basic-server/src/main/java/com/ruoyi/basic/service/impl/StandardTreeServiceImpl.java
@@ -1,38 +1,32 @@
package com.ruoyi.basic.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.poi.excel.ExcelUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ruoyi.basic.dto.SampleDto;
import com.ruoyi.common.exception.base.BaseException;
import com.ruoyi.basic.dto.FactoryDto;
import com.ruoyi.basic.dto.LaboratoryDto;
import com.ruoyi.basic.dto.SampleTypeDto;
import com.ruoyi.basic.mapper.StandardProductListMapper;
import com.ruoyi.basic.mapper.StandardTreeMapper;
import com.ruoyi.basic.pojo.StandardProductList;
import com.ruoyi.basic.pojo.StandardTemplate;
import com.ruoyi.basic.pojo.StandardTree;
import com.ruoyi.basic.pojo.StructureTestObject;
import com.ruoyi.basic.service.*;
import com.ruoyi.basic.service.StandardProductListService;
import com.ruoyi.basic.service.StandardTreeService;
import com.ruoyi.basic.service.StructureTestObjectService;
import com.ruoyi.common.exception.base.BaseException;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.IOException;
import java.io.InputStream;
import java.util.*;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * @author Administrator
@@ -47,13 +41,9 @@
    private StandardTreeMapper standardTreeMapper;
    private StandardMethodListService standardMethodListService;
    private StandardProductListMapper standardProductListMapper;
    private StandardProductListService standardProductListService;
    private StandardTemplateService standardTemplateService;
    private StructureTestObjectService structureTestObjectService;
@@ -135,271 +125,6 @@
    }
    @Override
    public List<StandardTree> getStandTreeBySampleType(String laboratory, String sampleType) {
        return standardTreeMapper.selectList(Wrappers.<StandardTree>lambdaQuery()
                .eq(StandardTree::getLaboratory, laboratory)
                .eq(StandardTree::getSampleType, sampleType)
                .select(StandardTree::getModel, StandardTree::getSample));
    }
    /**
     * æ²³å£æ£€æµ‹ä¸­å¿ƒå¯¼å…¥
     * @param file
     */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void inExcelOfTree(MultipartFile file) {
        InputStream inputStream;
        try {
            inputStream = file.getInputStream();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        List<StandardProductList> lists = new ArrayList<>();
        AtomicReference<String> laboratory = new AtomicReference<>();
        ExcelUtil.readBySax(inputStream, 0, (i, l, list) -> {
            StandardProductList str = new StandardProductList();
            if (i == 0 && l == 1) {
                laboratory.set(standardTreeMapper.getLaboratory(list.get(1) + ""));
                if (laboratory.get() == null) {
                    throw new BaseException("检验对象不存在:" + list.get(1));
                }
            }
            if (i == 0 && l >= 1) {
                Integer standardMethodId = standardMethodListService.getStandardMethodId(list.get(0) + "");
                if (standardMethodId == null) {
                    throw new BaseException("标准编号不存在:" + list.get(0));
                }
                str.setStandardMethodListId(standardMethodId);
                str.setSampleType(list.get(1) + "");
                if (list.get(2) != null) {
                    String sample = baseMapper.selSample(list.get(2) + "");
                    if (sample == null) {
                        throw new BaseException("样品不存在:" + list.get(2));
                    }
                    str.setSample(list.get(2) + "");
                } else {
                    str.setSample(null);
                }
                if (list.get(3) != null) {
                    str.setModel(list.get(3) + "");
                    Long aLong = standardTreeMapper.selectCount(Wrappers.<StandardTree>lambdaQuery()
                            .eq(StandardTree::getModel, str.getModel())
                            .eq(StandardTree::getSampleType, list.get(1) + ""));
                    if (aLong == 0) {
                        StandardTree standardTree = new StandardTree();
                        standardTree.setFactory("中天科技检测中心");
                        standardTree.setLaboratory(laboratory.get());
                        standardTree.setSampleType(str.getSampleType());
                        standardTree.setSample(str.getSample());
                        standardTree.setModel(str.getModel());
                        standardTreeMapper.insert(standardTree);
                    }
                } else {
                    str.setModel(null);
                }
                str.setInspectionItem(list.get(4) + "");
                if (list.get(6) == null) {
                    str.setInspectionItemSubclass("");
                } else {
                    str.setInspectionItemSubclass(list.get(6).toString());
                }
                StandardProductList db_str;
                try {
                    db_str = standardProductListMapper.getOne(str.getStandardMethodListId(), str.getInspectionItem(), str.getSample(), str.getInspectionItemSubclass(), str.getModel(), str.getInspectionItemClass());
                } catch (Exception e) {
                    throw new BaseException("重复查询:" + str.getInspectionItem() + " " + str.getInspectionItemSubclass());
                }
                if (ObjectUtils.isNotEmpty(db_str)) {
                    str.setId(db_str.getId());
                    str.setStructureItemParameterId(db_str.getStructureItemParameterId());
                }
                if (list.get(8) != null) {
                    str.setMethodS(list.get(8) + "");
                }
                if (list.get(11) == null) {
                    str.setTell(null);
                } else {
                    str.setTell(list.get(11).toString());
                }
                if (list.get(12) == null) {
                    str.setAsk(null);
                } else {
                    str.setAsk(list.get(12).toString());
                }
                if (list.get(13) == null) {
                    str.setPrice(null);
                } else {
                    str.setPrice((list.get(13).toString()));
                }
                if (list.get(14) == null) {
                    str.setManHour(null);
                } else {
                    str.setManHour(list.get(14).toString());
                }
                StandardTemplate standTempIdByName = standardTemplateService.getStandTempIdByName(String.valueOf(list.get(21)));
                if (standTempIdByName != null) {
                    str.setTemplateId(standTempIdByName.getId());
                } else {
                    throw new BaseException("模板不存在:" + list.get(21));
                }
                str.setFactory("中天科技检测中心");
                str.setLaboratory(laboratory.get());
                str.setState(1);
                str.setTree(str.getFactory() + " - " + str.getLaboratory() + " - " + str.getSampleType() + " - " + str.getSample() + " - " + (str.getModel() == null ? "" : str.getModel()));
                try {
                    str.setStructureItemParameterId(standardTreeMapper.getStructureItemParameterId("\"" + str.getSampleType() + "\"", str.getInspectionItem(), str.getInspectionItemSubclass(), str.getInspectionItemClass()));
                } catch (Exception e) {
                    str.setStructureItemParameterId(standardTreeMapper.getStructureItemParameterId("\"" + str.getSampleType() + "\",\"" + str.getSample() + "\"", str.getInspectionItem(), str.getInspectionItemSubclass(), str.getInspectionItemClass()));
                }
                if (str.getStructureItemParameterId() == null) {
                    throw new BaseException("检验项目不存在:" + str.getInspectionItem() + " " + str.getInspectionItemSubclass());
                }
                lists.add(str);
            }
        });
        lists.forEach(a -> {
            if (a.getId() != null) {
                standardProductListMapper.updateById(a);
            } else {
                standardProductListMapper.insert(a);
            }
        });
    }
    @Override
    public void importWorkstationExcel(MultipartFile file) {
        InputStream inputStream;
        try {
            inputStream = file.getInputStream();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        List<StandardProductList> lists = new ArrayList<>();
        AtomicReference<String> laboratory = new AtomicReference<>();
        ExcelUtil.readBySax(inputStream, 0, (i, l, list) -> {
            StandardProductList str = new StandardProductList();
            if (i == 0 && l == 1) {
                laboratory.set(standardTreeMapper.getLaboratory(list.get(1) + ""));
                if (laboratory.get() == null) {
                    throw new BaseException("检验对象不存在:" + list.get(1));
                }
            }
            if (i == 0 && l >= 1) {
                Integer standardMethodId = standardMethodListService.getStandardMethodId(list.get(0) + "");
                if (standardMethodId == null) {
                    throw new BaseException("标准编号不存在:" + list.get(0));
                }
                str.setStandardMethodListId(standardMethodId);
                str.setSampleType(list.get(1) + "");
                if (list.get(2) != null) {
                    String sample = baseMapper.selSample(list.get(2) + "");
                    if (sample == null) {
                        throw new BaseException("样品不存在:" + list.get(2));
                    }
                    str.setSample(list.get(2) + "");
                } else {
                    str.setSample(null);
                }
                if (list.get(3) != null) {
                    str.setModel(list.get(3) + "");
                    Long aLong = standardTreeMapper.selectCount(Wrappers.<StandardTree>lambdaQuery()
                            .eq(StandardTree::getModel, str.getModel())
                            .eq(StandardTree::getSampleType, list.get(1) + ""));
                    if (aLong == 0) {
                        StandardTree standardTree = new StandardTree();
                        standardTree.setFactory("中天科技检测中心");
                        standardTree.setLaboratory(laboratory.get());
                        standardTree.setSampleType(str.getSampleType());
                        standardTree.setSample(str.getSample());
                        standardTree.setModel(str.getModel());
                        standardTreeMapper.insert(standardTree);
                    }
                } else {
                    str.setModel(null);
                }
                str.setInspectionItemClass(list.get(4).toString());
                str.setInspectionItemClassEn(list.get(5).toString());
                // å¼€å§‹åŠ 2
                str.setInspectionItem(list.get(6) + "");
                if (list.get(8) == null) {
                    str.setInspectionItemSubclass("");
                } else {
                    str.setInspectionItemSubclass(list.get(8).toString());
                }
                StandardProductList db_str;
                try {
                    db_str = standardProductListMapper.getOne(str.getStandardMethodListId(), str.getInspectionItem(), str.getSample(), str.getInspectionItemSubclass(), str.getModel(), str.getInspectionItemClass());
                } catch (Exception e) {
                    throw new BaseException("重复查询:" + str.getInspectionItem() + " " + str.getInspectionItemSubclass());
                }
                if (ObjectUtils.isNotEmpty(db_str)) {
                    str.setId(db_str.getId());
                    str.setStructureItemParameterId(db_str.getStructureItemParameterId());
                }
                if (list.get(10) != null) {
                    str.setMethodS(list.get(10) + "");
                }
                if (list.get(13) == null) {
                    str.setTell(null);
                } else {
                    str.setTell(list.get(13).toString());
                }
                if (list.get(14) == null) {
                    str.setAsk(null);
                } else {
                    str.setAsk(list.get(14).toString());
                }
                if (list.get(15) == null) {
                    str.setPrice(null);
                } else {
                    str.setPrice((list.get(15).toString()));
                }
                if (list.get(16) == null) {
                    str.setManHour(null);
                } else {
                    str.setManHour(list.get(16).toString());
                }
                StandardTemplate standTempIdByName = standardTemplateService.getStandTempIdByName(String.valueOf(list.get(23)));
                if (standTempIdByName != null) {
                    str.setTemplateId(standTempIdByName.getId());
                } else {
                    throw new BaseException("模板不存在:" + list.get(23));
                }
                str.setFactory("中天科技检测中心");
                str.setLaboratory(laboratory.get());
                str.setState(1);
                str.setTree(str.getFactory() + " - " + str.getLaboratory() + " - " + str.getSampleType() + " - " + str.getSample() + " - " + (str.getModel() == null ? "" : str.getModel()));
                try {
                    str.setStructureItemParameterId(standardTreeMapper.getStructureItemParameterId("\"" + str.getSampleType() + "\"", str.getInspectionItem(), str.getInspectionItemSubclass(), str.getInspectionItemClass()));
                } catch (Exception e) {
                    str.setStructureItemParameterId(standardTreeMapper.getStructureItemParameterId("\"" + str.getSampleType() + "\",\"" + str.getSample() + "\"", str.getInspectionItem(), str.getInspectionItemSubclass(), str.getInspectionItemClass()));
                }
                if (str.getStructureItemParameterId() == null) {
                    throw new BaseException("检验项目不存在:" + str.getInspectionItem() + " " + str.getInspectionItemSubclass());
                }
                lists.add(str);
            }
        });
        lists.forEach(a -> {
            if (a.getId() != null) {
                standardProductListMapper.updateById(a);
            } else {
                standardProductListMapper.insert(a);
            }
        });
    }
    @Override
    public boolean updateTreeSort(List<FactoryDto> list) {
        List<StructureTestObject> testObjects = new ArrayList<>();
        for (FactoryDto factoryDto : list) {
@@ -463,28 +188,6 @@
        return standardTreeMapper.update(null, wrapper);
    }
    @Override
    public void resetTreeOfPrice(String tree, Integer standardId) {
        standardProductListMapper.update(null, Wrappers.<StandardProductList>lambdaUpdate().like(StandardProductList::getTree, tree).eq(StandardProductList::getStandardMethodListId, standardId).set(StandardProductList::getPrice, null));
    }
    @Override
    public void resetTreeOfHour(String tree, Integer standardId) {
        standardProductListMapper.update(null, Wrappers.<StandardProductList>lambdaUpdate().like(StandardProductList::getTree, tree).eq(StandardProductList::getStandardMethodListId, standardId).set(StandardProductList::getManHour, null));
    }
    @Override
    public void resetTreeOfAsk(String tree, Integer standardId) {
        standardProductListMapper.update(null, Wrappers.<StandardProductList>lambdaUpdate().like(StandardProductList::getTree, tree).eq(StandardProductList::getStandardMethodListId, standardId)
                .set(StandardProductList::getAsk, null)
                .set(StandardProductList::getTell, null)
                .set(StandardProductList::getSection, null)
                .set(StandardProductList::getCores, null)
                .set(StandardProductList::getConductorMaterial, null)
                .set(StandardProductList::getConductorType, null)
                .set(StandardProductList::getPrice, null)
                .set(StandardProductList::getManHour, null));
    }
}
basic-server/src/main/resources/mapper/StandardMethodListMapper.xml
ÎļþÒÑɾ³ý
basic-server/src/main/resources/mapper/StandardMethodMapper.xml
@@ -64,4 +64,39 @@
                 left join structure_test_object sto on sm.structure_test_object_id = sto.id
        where sm.id = #{id}
    </select>
    <select id="selectStandardMethodLists" resultType="com.ruoyi.basic.pojo.StandardMethodList">
        select id, code, name, remark
        from standard_method
        where is_use = 1
          and is_product = 1
          and structure_test_object_id LIKE CONCAT('%[', #{tree}, ']%')
    </select>
    <select id="selectStandardMethodLists3" resultType="com.ruoyi.basic.pojo.StandardMethodList">
        select id, code, name, remark
        from standard_method
        where is_use = 1
          and is_product = 1
          and structure_test_object_id LIKE CONCAT('%', #{tree}, '%')
    </select>
    <select id="selectListEnum" resultType="com.ruoyi.basic.pojo.StandardMethodList">
        select id,code,name from standard_method
        where is_product = 1
          and is_use = 1
    </select>
    <select id="selectStandardMethodListsByNull" resultType="com.ruoyi.basic.pojo.StandardMethodList">
        select id, code, name, remark
        from standard_method
        where is_use = 1
          and is_product = 1
          and (
            structure_test_object_id is null
                OR structure_test_object_id = ''
                OR structure_test_object_id = '[]'
            )
    </select>
    <select id="getStandardMethodId" resultType="java.lang.Integer">
        select id from standard_method where code = #{code}
    </select>
</mapper>
basic-server/src/main/resources/mapper/StructureItemParameterMapper.xml
@@ -40,7 +40,8 @@
        inspection_item_class_en,
        code,
        radius_list,
        rates
        rates,
        device_ids
        from (select *,
        CASE
        WHEN INSTR(sample, ',') > 0 THEN