| | |
| | | |
| | | 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]+insOrder.getEntrustCode().split("-")[3]+"-"+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 (int i = 0; i < b.getNum(); i++) { |
| | | b.setId(null); |
| | | b.setInsOrderId(insOrder.getId()); |
| | | b.setParentId(a.getId()); |
| | | if (StrUtil.isEmpty(b.getSampleCode())) { |
| | | b.setSampleCode(giveCode.giveCode("", "ins_sample", "", "yyMMdd")); |
| | | } |
| | | insSampleMapper.insert(b); |
| | | if (ObjectUtil.isNotEmpty(b.getInsProduct())) { |
| | | addInsProductMethod(b.getId(), b.getInsProduct(), null, 0); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if (ObjectUtil.isNotEmpty(a.getBushing())) { |
| | | for (BushingDto bushingDto : a.getBushing()) { |
| | |
| | | } |
| | | } |
| | | } |
| | | }); |
| | | }) ; |
| | | 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); |