zss
2024-07-11 a3ba94e23fec4281502a94221f65cc0567eb02a8
inspect-server/src/main/java/com/yuanchu/mom/service/impl/InsOrderServiceImpl.java
@@ -21,6 +21,7 @@
import com.yuanchu.mom.vo.SampleDefectsFatherVo;
import lombok.AllArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -147,8 +148,35 @@
            }
            insSampleMapper.insert(a);
            if (ObjectUtil.isNotEmpty(a.getInsProduct())) {
                //普通检验项目(除了光纤接头损耗)的添加
                addInsProductMethod(a.getId(), a.getInsProduct(), null, 0);
                addInsProductMethod(a.getId(), a.getInsProduct(), null, 0, false);
                if (ObjectUtil.isNotEmpty(a.getBushing())) {
                    for (BushingDto bushingDto : a.getBushing()) {
                        bushingDto.setInsSampleId(a.getId());
                        insBushingMapper.insert(bushingDto);
                        if (bushingDto.getFiber().size() != 0) {
                            for (FiberDto fiberDto : bushingDto.getFiber()) {
                                fiberDto.setInsBushingId(bushingDto.getId());
                                insFiberMapper.insert(fiberDto);
                                addInsProductMethod(a.getId(), a.getInsProduct(), fiberDto.getId(), 2, true);
                                addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2, false);
                            }
                        } else {
                            for (FibersDto fibersDto : bushingDto.getFibers()) {
                                fibersDto.setInsBushingId(bushingDto.getId());
                                fibersDto.setCode(this.giveCode.giveCode("", "ins_fibers", "", "yyMMdd"));
                                insFibersMapper.insert(fibersDto);
                                for (FiberDto fiberDto : fibersDto.getFiber()) {
                                    fiberDto.setInsFibersId(fibersDto.getId());
                                    insFiberMapper.insert(fiberDto);
                                    addInsProductMethod(a.getId(), a.getInsProduct(), fiberDto.getId(), 2, true);
                                    addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2, false);
                                }
                                //addInsProductMethod(a.getId(), a.getInsProduct(), fibersDto.getId(), 1);
                                addInsProductMethod(a.getId(), fibersDto.getProductList(), fibersDto.getId(), 1, false);
                            }
                        }
                    }
                }
            }
            if (ObjectUtil.isNotEmpty(a.getInsulating())) {
                List<InsProduct> ip2 = new ArrayList<>();
@@ -158,13 +186,13 @@
                for (InsProduct product : ip2) {
                    product.setStandardMethodListId(a.getInsulating().getStandardMethodListId());
                }
                addInsProductMethod(a.getId(), ip2, null, 0);
                addInsProductMethod(a.getId(), ip2, null, 0, false);
            }
            if (ObjectUtil.isNotEmpty(a.getSheath())) {
                for (InsProduct product : a.getSheath().getInsProduct()) {
                    product.setStandardMethodListId(a.getSheath().getStandardMethodListId());
                }
                addInsProductMethod(a.getId(), a.getSheath().getInsProduct(), null, 0);
                addInsProductMethod(a.getId(), a.getSheath().getInsProduct(), null, 0, false);
            }
            if (ObjectUtil.isNotEmpty(a.getChildSampleList())) {
                for (SampleProductDto b : a.getChildSampleList()) {
@@ -177,12 +205,12 @@
                        }
                        insSampleMapper.insert(b);
                        if (ObjectUtil.isNotEmpty(b.getInsProduct())) {
                            addInsProductMethod(b.getId(), b.getInsProduct(), null, 0);
                            addInsProductMethod(b.getId(), b.getInsProduct(), null, 0, false);
                        }
                    }
                }
            }
            if (ObjectUtil.isNotEmpty(a.getBushing())) {
            if (ObjectUtil.isEmpty(a.getInsProduct()) && ObjectUtil.isNotEmpty(a.getBushing())) {
                for (BushingDto bushingDto : a.getBushing()) {
                    bushingDto.setInsSampleId(a.getId());
                    insBushingMapper.insert(bushingDto);
@@ -190,7 +218,7 @@
                        for (FiberDto fiberDto : bushingDto.getFiber()) {
                            fiberDto.setInsBushingId(bushingDto.getId());
                            insFiberMapper.insert(fiberDto);
                            addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2);
                            addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2, false);
                        }
                    } else {
                        for (FibersDto fibersDto : bushingDto.getFibers()) {
@@ -200,9 +228,9 @@
                            for (FiberDto fiberDto : fibersDto.getFiber()) {
                                fiberDto.setInsFibersId(fibersDto.getId());
                                insFiberMapper.insert(fiberDto);
                                addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2);
                                addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2, false);
                            }
                            addInsProductMethod(a.getId(), fibersDto.getProductList(), fibersDto.getId(), 1);
                            addInsProductMethod(a.getId(), fibersDto.getProductList(), fibersDto.getId(), 1, false);
                        }
                    }
                }
@@ -226,7 +254,7 @@
        return insOrder.getId();
    }
    private void addInsProductMethod(Integer sampleId, List<InsProduct> productList, Integer id, Integer type) {
    private void addInsProductMethod(Integer sampleId, List<InsProduct> productList, Integer id, Integer type, Boolean is) {
        InsOrder insOrder = insOrderMapper.selectById(insSampleMapper.selectById(sampleId).getInsOrderId());
        for (InsProduct product : productList) {
            if (product.getState() == 1 && !product.getInspectionItem().equals("光纤接头损耗")) {
@@ -235,7 +263,9 @@
                    List<InsProduct> insProductes = new ArrayList<>();
                    List<InsProduct> insProducts = new ArrayList<>();
                    String[] strings = product.getAsk().split(";");
                    for (int i = 0; i < strings.length; i++) {
                        int count = Integer.parseInt(strings[strings.length - 1]);
                        if (i != strings.length - 1) {
                            InsProduct insProduct = new InsProduct();
                            switch (type) {
@@ -247,23 +277,40 @@
                                    break;
                            }
                            String[] split = strings[i].split(",");
                            insProduct.setInspectionItem("1次");//检验项--循环次数
                            if (split[0].equals("20℃")) {
                                insProduct.setInspectionItem(count + "");//检验项--循环次数
                            } else {
                                insProduct.setInspectionItem("1");//检验项--循环次数
                            }
                            insProduct.setInspectionItemSubclass(split[0]);//检验项--温度
                            insProduct.setInspectionItemClass(split[1]);//检验项--光纤项目
                            insProduct.setAsk(split[2]);//检验要求
                            insProduct.setTell(strings[i]);//检验描述
                            insProduct.setInsSampleId(sampleId);
                            insProduct.setState(1);
                            insProduct.setFactory(product.getFactory());
                            insProduct.setLaboratory(product.getLaboratory());
                            insProduct.setSampleType(product.getSampleType());
                            insProduct.setSample(product.getSample());
                            insProduct.setModel(product.getModel());
                            insProduct.setSonLaboratory(product.getSonLaboratory());
                            insProduct.setUnit(product.getUnit());
                            insProduct.setManHourGroup(product.getManHourGroup());
                            insProduct.setInspectionItemType("0");
                            insProduct.setInspectionValueType("1");
                            insProducts.add(insProduct);
                            insProductes.add(insProduct);
                        } else {
                            //最后一个数据是说明会循环多少次
                            int count = Integer.parseInt(strings[i]);
                            if (count > 1) {
                                //循环超过1次
                                for (int j = 2; j <= count; j++) {
                                    for (InsProduct insProduct : insProducts) {
                                        if (!insProduct.getInspectionItemSubclass().equals("20℃")) {
                                            insProduct.setInspectionItem(j + "次");
                                            insProductes.add(insProduct);
                                        if (!insProduct.getInspectionItemSubclass().equals("20℃") && !insProduct.getInspectionItemSubclass().equals("20℃(常温)")) {
                                            InsProduct insProduct1 = new InsProduct();
                                            BeanUtils.copyProperties(insProduct, insProduct1);
                                            insProduct1.setInspectionItem(j + "");
                                            insProductes.add(insProduct1);
                                        }
                                    }
                                }
@@ -272,24 +319,26 @@
                    }
                    insProductService.saveBatch(insProductes);
                } else {
                    switch (type) {
                        case 1:
                            product.setInsFibersId(id);
                            break;
                        case 2:
                            product.setInsFiberId(id);
                            break;
                    if (!is) {
                        switch (type) {
                            case 1:
                                product.setInsFibersId(id);
                                break;
                            case 2:
                                product.setInsFiberId(id);
                                break;
                        }
                        product.setId(null);
                        product.setCreateTime(null);
                        product.setUpdateTime(null);
                        product.setUpdateTime(null);
                        product.setUpdateUser(null);
                        product.setInsSampleId(sampleId);
                        if (product.getInspectionItemSubclass() == null) {
                            product.setInspectionItemSubclass("");
                        }
                        insProductMapper.insert(product);
                    }
                    product.setId(null);
                    product.setCreateTime(null);
                    product.setUpdateTime(null);
                    product.setUpdateTime(null);
                    product.setUpdateUser(null);
                    product.setInsSampleId(sampleId);
                    if (product.getInspectionItemSubclass() == null) {
                        product.setInspectionItemSubclass("");
                    }
                    insProductMapper.insert(product);
                }
            }
        }