| | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public int addInsOrder(List<SampleProductDto> list, InsOrder insOrder, List<List<Integer>> pairing) { |
| | | insOrder.setState(0); |
| | | //判断选择的委托单位与制单人的委托单位是否一致 |
| | | Integer userId = getLook.selectPowerByMethodAndUserId(null).get("userId"); |
| | | String company = userMapper.selectById(userId).getCompany(); |
| | | if (!company.equals(insOrder.getCompanyId()+"")) { |
| | | //如果不一致那么委托人字段必填 |
| | | if (ObjectUtils.isEmpty(insOrder.getPrepareUser())){ |
| | | throw new ErrorException("委托人不能为空"); |
| | | } |
| | | }else { |
| | | //如果一致,那么制单人就是委托人 |
| | | insOrder.setPrepareUser(insOrder.getCustom()); |
| | | } |
| | | //客户代号 |
| | | Custom custom = customMapper.selectById(insOrder.getCompanyId()); |
| | | String code = custom.getCode2(); |
| | |
| | | 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()); |
| | |
| | | addInsProductMethod(a.getId(), a.getInsProduct(), fiberDto.getId(), 2, true); |
| | | addInsProductMethod(a.getId(), fiberDto.getProductList(), fiberDto.getId(), 2, false); |
| | | } |
| | | } else { |
| | | } |
| | | //光纤带不为空 |
| | | else if ( bushingDto.getFibers().size()!=0){ |
| | | for (FibersDto fibersDto : bushingDto.getFibers()) { |
| | | fibersDto.setInsBushingId(bushingDto.getId()); |
| | | fibersDto.setCode(this.giveCode.giveCode("", "ins_fibers", "", "yyMMdd")); |
| | |
| | | addInsProductMethod(a.getId(), fibersDto.getProductList(), fibersDto.getId(), 1, false); |
| | | } |
| | | } |
| | | //都为空 只配置了套管 这种情况只限于项目是含有松套管的 |
| | | // else { |
| | | // String collect = a.getInsProduct().stream().map(InsProduct::getInspectionItem).distinct().collect(Collectors.joining(",")); |
| | | // if (collect.contains("松套管")){ |
| | | // //获取检验项目中包含松套管的检验项目 |
| | | // List<InsProduct> products = a.getInsProduct().stream().filter(insProduct -> insProduct.getInspectionItem().contains("松套管")).collect(Collectors.toList()); |
| | | // |
| | | // }else { |
| | | // throw new ErrorException("样品的光纤配置信息里面没有配置光纤带信息也没有光纤信息,请重新配置保存再提交下单!!!"); |
| | | // } |
| | | // } |
| | | } |
| | | } |
| | | } |
| | |
| | | |
| | | 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); |
| | | for (InsProduct product : productList) { |
| | | if (product.getState() == 1 && !product.getInspectionItem().equals("光纤接头损耗")) { |
| | | //判断光缆的温度循环项目添加 |
| | | if (insOrder.getSampleType().equals("光缆") && product.getInspectionItem().equals("温度循环") && type != 0) { |
| | | //判断选择的标准方法是委托要求还是其他标准方法 |
| | | String name = insSampleMapper.selMethodById(sampleId); |
| | | if (!name.equals("委托要求")) { |
| | | //判断标准方法的温度循环的要求描述是否有填写 |
| | | if (ObjectUtils.isEmpty(product.getTell()) || product.getTell().equals("")) { |
| | |
| | | } |
| | | } |
| | | insProductService.saveBatch(insProductess); |
| | | } else { |
| | | } |
| | | else { |
| | | if (!is) { |
| | | switch (type) { |
| | | case 1: |
| | |
| | | if (StringUtils.isEmpty(code)) { |
| | | code = ""; |
| | | } |
| | | String code2 = customMapper.selectById(insOrder.getCompanyId()).getCode2(); |
| | | Custom custom = customMapper.selectById(insOrder.getCompanyId()); |
| | | String code2 = custom.getCode2(); |
| | | if (!custom.getCompany().equals(insOrder.getCompany())){ |
| | | Custom one = customMapper.selectOne(Wrappers.<Custom>lambdaQuery().eq(Custom::getCompany, insOrder.getCompany())); |
| | | insOrder.setCompanyId(one.getId()); |
| | | code2=one.getCode2(); |
| | | } |
| | | //String code2 = customMapper.selectById(insOrder.getCompanyId()).getCode2(); |
| | | insOrder.setEntrustCode(giveCode.giveCode2("JCZX/" + code + "-" + code2 + "-", insOrder.getCompanyId(), insOrder.getLaboratory(), "ins_order", "", "yyMM")); |
| | | } |
| | | return insOrderMapper.updateById(insOrder); |