| | |
| | | count.getAndIncrement(); |
| | | a.setId(null); |
| | | a.setInsOrderId(insOrder.getId()); |
| | | //样品编号 |
| | | if (StrUtil.isEmpty(a.getSampleCode())) { |
| | | a.setSampleCode("TX(WYQJ)-" + giveCode.split("-")[2] + "-" + count.get()); |
| | | } |
| | | insSampleMapper.insert(a); |
| | | //样品的检验项目 |
| | | if (ObjectUtil.isNotEmpty(a.getInsProduct())) { |
| | | addInsProductMethod(a.getId(), a.getInsProduct(), null, 0, false); |
| | | addInsProductMethod(a.getId(), a.getInsProduct(), null, 0); |
| | | } |
| | | //样品的检验标准 |
| | | if (ObjectUtil.isNotEmpty(a.getInsulating())) { |
| | | List<InsProduct> ip2 = new ArrayList<>(); |
| | | for (Integer i = 0; i < a.getInsulating().getNum(); i++) { |
| | |
| | | for (InsProduct product : ip2) { |
| | | product.setStandardMethodListId(a.getInsulating().getStandardMethodListId()); |
| | | } |
| | | addInsProductMethod(a.getId(), ip2, null, 0, false); |
| | | addInsProductMethod(a.getId(), ip2, null, 0); |
| | | } |
| | | //样品的检验标准 |
| | | if (ObjectUtil.isNotEmpty(a.getSheath())) { |
| | | for (InsProduct product : a.getSheath().getInsProduct()) { |
| | | product.setStandardMethodListId(a.getSheath().getStandardMethodListId()); |
| | | } |
| | | addInsProductMethod(a.getId(), a.getSheath().getInsProduct(), null, 0, false); |
| | | addInsProductMethod(a.getId(), a.getSheath().getInsProduct(), null, 0); |
| | | } |
| | | //子样品配置 |
| | | if (ObjectUtil.isNotEmpty(a.getChildSampleList())) { |
| | | for (SampleProductDto b : a.getChildSampleList()) { |
| | | for (int i = 0; i < b.getNum(); i++) { |
| | |
| | | } |
| | | insSampleMapper.insert(b); |
| | | if (ObjectUtil.isNotEmpty(b.getInsProduct())) { |
| | | addInsProductMethod(b.getId(), b.getInsProduct(), null, 0, false); |
| | | addInsProductMethod(b.getId(), b.getInsProduct(), null, 0); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (ObjectUtil.isEmpty(a.getInsProduct()) && 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); |
| | |
| | | for (FiberDto fiberDto : bushingDto.getFiber()) { |
| | | fiberDto.setInsBushingId(bushingDto.getId()); |
| | | insFiberMapper.insert(fiberDto); |
| | | addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2, false); |
| | | addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2); |
| | | } |
| | | } else { |
| | | for (FibersDto fibersDto : bushingDto.getFibers()) { |
| | |
| | | for (FiberDto fiberDto : fibersDto.getFiber()) { |
| | | fiberDto.setInsFibersId(fibersDto.getId()); |
| | | insFiberMapper.insert(fiberDto); |
| | | addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2, false); |
| | | addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2); |
| | | } |
| | | addInsProductMethod(a.getId(), fibersDto.getProductList(), fibersDto.getId(), 1, false); |
| | | addInsProductMethod(a.getId(), fibersDto.getProductList(), fibersDto.getId(), 1); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }*/ |
| | | }); |
| | | for (List<Integer> i : pairing) { |
| | | //多个样品就拼接 |
| | | /*for (List<Integer> i : pairing) { |
| | | SampleProductDto sample = JSON.parseObject(JSON.toJSONString(list.get(i.get(0) - 1)), SampleProductDto.class); |
| | | sample.setSampleCode(list.get(i.get(0) - 1).getSampleCode() + "/" + list.get(i.get(1) - 1).getSampleCode()); |
| | | sample.setId(null); |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | } |
| | | } |
| | | }*/ |
| | | //通信:如果是C类订单无需审核直接通过 |
| | | if (insOrder.getOrderType().equals("C")) { |
| | | insOrder.setState(1); |
| | |
| | | return insOrder.getId(); |
| | | } |
| | | |
| | | private void addInsProductMethod(Integer sampleId, List<InsProduct> productList, Integer id, Integer type, Boolean is) { |
| | | InsOrder insOrder = insOrderMapper.selectById(insSampleMapper.selectById(sampleId).getInsOrderId()); |
| | | String name = insSampleMapper.selMethodById(sampleId); |
| | | private void addInsProductMethod(Integer sampleId, List<InsProduct> productList, Integer id, Integer type) { |
| | | for (InsProduct product : productList) { |
| | | if (product.getState() == 1 && !product.getInspectionItem().equals("光纤接头损耗")) { |
| | | if (!is) { |
| | | switch (type) { |
| | | case 1: |
| | | product.setInsFibersId(id); |
| | | break; |
| | | case 2: |
| | | product.setInsFiberId(id); |
| | | break; |
| | | } |
| | | product.setId(null); |
| | | product.setCreateTime(null); |
| | | product.setCreateUser(null); |
| | | product.setUpdateTime(null); |
| | | product.setUpdateUser(null); |
| | | product.setInsSampleId(sampleId); |
| | | if (product.getInspectionItemSubclass() == null) { |
| | | product.setInspectionItemSubclass(""); |
| | | } |
| | | insProductMapper.insert(product); |
| | | if (product.getState() == 1 ) { |
| | | switch (type) { |
| | | case 1: |
| | | product.setInsFibersId(id); |
| | | break; |
| | | case 2: |
| | | product.setInsFiberId(id); |
| | | break; |
| | | } |
| | | product.setId(null); |
| | | product.setCreateTime(null); |
| | | product.setCreateUser(null); |
| | | product.setUpdateTime(null); |
| | | product.setUpdateUser(null); |
| | | product.setInsSampleId(sampleId); |
| | | if (product.getInspectionItemSubclass() == null) { |
| | | product.setInspectionItemSubclass(""); |
| | | } |
| | | insProductMapper.insert(product); |
| | | } |
| | | } |
| | | } |