value
2024-04-29 ce7184b9b054e4cd98af2d747545d04ae85c2728
inspect-server/src/main/java/com/yuanchu/mom/service/impl/StandardProductListServiceImpl.java
@@ -10,10 +10,12 @@
import com.yuanchu.mom.service.StandardProductListService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.List;
import java.util.Objects;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
/**
@@ -29,6 +31,8 @@
    private StandardProductListMapper standardProductListMapper;
    private StandardTreeMapper standardTreeMapper;
    private StandardProductListService standardProductListService;
    @Override
    public int upStandardProductList(StandardProductList list) {
@@ -75,15 +79,42 @@
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public List<StandardProductList> selectStandardProductListByMethodId(Integer id, String tree) {
        String[] trees = tree.split(" - ");
        List<StandardProductList> list;
        if(tree.length() == 3){
            list = standardTreeMapper.selectStandardProductListByTree(trees[2], trees[3]);
        }else{
            list = standardTreeMapper.selectStandardProductListByTree(trees[2], null);
        StringBuffer str = new StringBuffer();
        if (trees.length == 3) {
            str.append("\"").append(trees[2]).append("\"");
        } else {
            str.append("\"").append(trees[2]).append("\",\"").append(trees[3]).append("\"");
        }
        List<StandardProductList> standardProductLists = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery().eq(StandardProductList::getStandardMethodListId, id));
        List<StandardProductList> list = standardTreeMapper.selectStandardProductListByTree(str + "");
        List<StandardProductList> standardProductLists = standardProductListMapper.selectList(Wrappers.<StandardProductList>lambdaQuery().eq(StandardProductList::getStandardMethodListId, id).eq(StandardProductList::getTree, tree));
        for (StandardProductList sp : standardProductLists) {
            for (StandardProductList pl : list) {
                if (sp.getInspectionItem().equals(pl.getInspectionItem()) && sp.getInspectionItemSubclass().equals(pl.getInspectionItemSubclass())) {
                    pl.setId(sp.getId());
                    pl.setState(sp.getState());
                    pl.setFactory(sp.getFactory());
                    pl.setLaboratory(sp.getLaboratory());
                    pl.setSampleType(sp.getSampleType());
                    pl.setSample(sp.getSample());
                    pl.setModel(sp.getModel());
                    pl.setMethodS(sp.getMethodS());
                    break;
                }
            }
        }
        CompletableFuture.supplyAsync(() -> {
            standardProductListMapper.delete(Wrappers.<StandardProductList>lambdaUpdate().eq(StandardProductList::getStandardMethodListId, id).eq(StandardProductList::getTree, tree));
            standardProductListService.saveBatch(list);
            return null;
        }).thenAccept(res -> {
        }).exceptionally(e -> {
            e.printStackTrace();
            return null;
        });
        ;
        return list;
    }
}