| | |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.LocalDateTime; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Objects; |
| | | import java.util.*; |
| | | import java.util.concurrent.atomic.AtomicInteger; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | public int addInsOrder(List<SampleProductDto> list, InsOrder insOrder, List<List<Integer>> pairing) { |
| | | insOrder.setState(0); |
| | | String code = customMapper.selectById(insOrder.getCompanyId()).getCode2(); |
| | | insOrder.setEntrustCode(giveCode.giveCode("JCZX-" + code + "-", "ins_order", "-", "yyyyMMdd")); |
| | | insOrder.setEntrustCode(giveCode.giveCode("JCZX-" + code + "-", "ins_order", "", "yyMMdd")); |
| | | insOrderMapper.insert(insOrder); |
| | | AtomicInteger count = new AtomicInteger(); |
| | | list.forEach(a -> { |
| | |
| | | a.setId(null); |
| | | a.setInsOrderId(insOrder.getId()); |
| | | if (StrUtil.isEmpty(a.getSampleCode())) { |
| | | a.setSampleCode(giveCode.giveCode("", "ins_sample", "", "yyMMdd")+"-"+count.get()); |
| | | a.setSampleCode(insOrder.getEntrustCode().split("-")[2]+"-"+count.get()); |
| | | } |
| | | insSampleMapper.insert(a); |
| | | if (ObjectUtil.isNotEmpty(a.getInsProduct())) { |
| | | 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++) { |
| | | ip2.addAll(a.getInsulating().getInsProduct()); |
| | | } |
| | | for (InsProduct product : ip2) { |
| | | product.setStandardMethodListId(a.getInsulating().getStandardMethodListId()); |
| | | } |
| | | 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); |
| | | } |
| | | if(ObjectUtil.isNotEmpty(a.getChildSampleList())){ |
| | | for (SampleProductDto b : a.getChildSampleList()) { |
| | |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | }) ; |
| | | for (List<Integer> i : pairing) { |
| | | SampleProductDto sample = JSON.parseObject(JSON.toJSONString(list.get(i.get(0))), SampleProductDto.class); |
| | | 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); |
| | | insSampleMapper.insert(sample); |
| | | InsProduct insProduct = sample.getInsProduct().stream().filter(a -> Objects.equals(a.getInspectionItem(), "熔接损耗")).findFirst().get(); |
| | | insProduct.setId(null); |
| | | insProduct.setInsSampleId(sample.getId()); |
| | | insProductMapper.insert(insProduct); |
| | | try { |
| | | InsProduct insProduct = sample.getInsProduct().stream().filter(a -> Objects.equals(a.getInspectionItem(), "熔接损耗")).findFirst().get(); |
| | | insProduct.setId(null); |
| | | insProduct.setInsSampleId(sample.getId()); |
| | | insProductMapper.insert(insProduct); |
| | | }catch (Exception e){} |
| | | } |
| | | return insOrder.getId(); |
| | | } |
| | | |
| | | private void addInsProductMethod(Integer sampleId, List<InsProduct> productList, Integer id, Integer type) { |
| | | for (InsProduct product : productList) { |
| | | /*if(product.getState()==1 && (product.getAsk().indexOf("D")>-1||product.getAsk().indexOf("W")>-1||product.getAsk().indexOf("X")>-1 |
| | | ||product.getAsk().indexOf("RTS")>-1||product.getAsk().indexOf("H")>-1||product.getAsk().indexOf("L")>-1)){ |
| | | throw new ErrorException("提交失败,存在未填写的变量:"+product.getInspectionItem()+" "+product.getInspectionItemSubclass()); |
| | | }*/ |
| | | if(product.getState()==1 && !product.getInspectionItem().equals("熔接损耗")){ |
| | | switch (type){ |
| | | case 1: |