| | |
| | | inspectParams.add(params); |
| | | |
| | | }); |
| | | |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | //获取上报质检接口 |
| | | String url = remotesInfoProperties.getBaseUrl() + apiInfo.getNotifyInspect(); |
| | | // 设置请求参数 |
| | | params.add("params", JSONObject.toJSONString(inspectParams)); |
| | | log.info("请求地址:{},请求参数:{}", url, JSONObject.toJSONString(inspectParams)); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.add("Content-Type", "application/json"); |
| | | HttpEntity httpEntity = new HttpEntity<>(params, headers); |
| | | // 请求 |
| | | ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class); |
| | | log.info("下发任务 返回结果:{}", exchange); |
| | | if (Objects.isNull(exchange.getBody()) || exchange.getBody() == null) { |
| | | throw new CoolException("下发任务失败!!"); |
| | | } else { |
| | | CommonReponse reponse = (CommonReponse) JSON.parse(exchange.getBody()); |
| | | if (reponse.getCode() == 0) { |
| | | //修改asn上报状态 |
| | | Set<String> itemSets = items.stream().map(PoItemsDto::getId).collect(Collectors.toSet()); |
| | | Set<Long> longSet = new HashSet<>(); |
| | | itemSets.forEach(set -> { |
| | | longSet.add(Long.parseLong(set)); |
| | | }); |
| | | |
| | | List<AsnOrderItem> asnOrderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().in(AsnOrderItem::getPoDetlId, longSet)); |
| | | if (asnOrderItems.isEmpty()) { |
| | | throw new CoolException("ASN单据不存在!!"); |
| | | } |
| | | List<Long> list = asnOrderItems.stream().map(AsnOrderItem::getId).collect(Collectors.toList()); |
| | | |
| | | /************************** 修改ASN明细单状态 ******************************/ |
| | | |
| | | |
| | | if (!asnOrderItemService.update(new LambdaUpdateWrapper<AsnOrderItem>().in(AsnOrderItem::getId, list).set(AsnOrderItem::getStatus, 1))) { |
| | | throw new CoolException("ASN明细单据状态修改失败!!"); |
| | | } |
| | | |
| | | /************************** 修改ASN主单数据 ******************************/ |
| | | //获取ASN明细订单标识 |
| | | List<Long> ids = asnOrderItems.stream().map(AsnOrderItem::getAsnId).collect(Collectors.toList()); |
| | | //ASN明细单据分组 |
| | | Map<Long, List<AsnOrderItem>> asnIds = asnOrderItems.stream().collect(Collectors.groupingBy(AsnOrderItem::getAsnId)); |
| | | ids.forEach(id -> { |
| | | int count = asnOrderService.count(new LambdaQueryWrapper<AsnOrder>().in(AsnOrder::getId, id)); |
| | | if (count == asnIds.get(id).size()) { |
| | | if (!asnOrderService.update(new LambdaUpdateWrapper<AsnOrder>().eq(AsnOrder::getId, id).set(AsnOrder::getStatus, 1))) { |
| | | throw new CoolException("ASN主单状态修改失败!!"); |
| | | } |
| | | } else { |
| | | if (!asnOrderService.update(new LambdaUpdateWrapper<AsnOrder>().eq(AsnOrder::getId, id).set(AsnOrder::getStatus, 2))) { |
| | | throw new CoolException("ASN主单状态修改失败!!"); |
| | | } |
| | | } |
| | | }); |
| | | return true; |
| | | } else { |
| | | throw new CoolException(reponse.getMsg()); |
| | | CommonReponse reponse = new CommonReponse(); |
| | | if (!remotesInfoProperties.getHost().equals("http://127.0.0.1")){ |
| | | MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); |
| | | //获取上报质检接口 |
| | | String url = remotesInfoProperties.getBaseUrl() + apiInfo.getNotifyInspect(); |
| | | // 设置请求参数 |
| | | params.add("params", JSONObject.toJSONString(inspectParams)); |
| | | log.info("请求地址:{},请求参数:{}", url, JSONObject.toJSONString(inspectParams)); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.add("Content-Type", "application/json"); |
| | | HttpEntity httpEntity = new HttpEntity<>(params, headers); |
| | | // 请求 |
| | | ResponseEntity<String> exchange = restTemplate.exchange(url, HttpMethod.POST, httpEntity, String.class); |
| | | log.info("下发任务 返回结果:{}", exchange); |
| | | if (Objects.isNull(exchange.getBody()) || exchange.getBody() == null) { |
| | | throw new CoolException("下发任务失败!!"); |
| | | } |
| | | reponse = (CommonReponse) JSON.parse(exchange.getBody()); |
| | | }else { |
| | | reponse.setCode(0); |
| | | } |
| | | |
| | | |
| | | if (reponse.getCode() == 0) { |
| | | //修改asn上报状态 |
| | | Set<String> itemSets = items.stream().map(PoItemsDto::getId).collect(Collectors.toSet()); |
| | | Set<Long> longSet = new HashSet<>(); |
| | | itemSets.forEach(set -> { |
| | | longSet.add(Long.parseLong(set)); |
| | | }); |
| | | |
| | | List<AsnOrderItem> asnOrderItems = asnOrderItemService.list(new LambdaQueryWrapper<AsnOrderItem>().in(AsnOrderItem::getPoDetlId, longSet)); |
| | | if (asnOrderItems.isEmpty()) { |
| | | throw new CoolException("ASN单据不存在!!"); |
| | | } |
| | | List<Long> list = asnOrderItems.stream().map(AsnOrderItem::getId).collect(Collectors.toList()); |
| | | |
| | | /************************** 修改ASN明细单状态 ******************************/ |
| | | |
| | | |
| | | if (!asnOrderItemService.update(new LambdaUpdateWrapper<AsnOrderItem>().in(AsnOrderItem::getId, list).set(AsnOrderItem::getNtyStatus, 1))) { |
| | | throw new CoolException("ASN明细单据状态修改失败!!"); |
| | | } |
| | | |
| | | /************************** 修改ASN主单数据 ******************************/ |
| | | //获取ASN明细订单标识 |
| | | List<Long> ids = asnOrderItems.stream().map(AsnOrderItem::getAsnId).collect(Collectors.toList()); |
| | | //ASN明细单据分组 |
| | | Map<Long, List<AsnOrderItem>> asnIds = asnOrderItems.stream().collect(Collectors.groupingBy(AsnOrderItem::getAsnId)); |
| | | ids.forEach(id -> { |
| | | int count = asnOrderService.count(new LambdaQueryWrapper<AsnOrder>().in(AsnOrder::getId, id)); |
| | | if (count == asnIds.get(id).size()) { |
| | | if (!asnOrderService.update(new LambdaUpdateWrapper<AsnOrder>().eq(AsnOrder::getId, id).set(AsnOrder::getNtyStatus, 1))) { |
| | | throw new CoolException("ASN主单状态修改失败!!"); |
| | | } |
| | | } else { |
| | | if (!asnOrderService.update(new LambdaUpdateWrapper<AsnOrder>().eq(AsnOrder::getId, id).set(AsnOrder::getNtyStatus, 2))) { |
| | | throw new CoolException("ASN主单状态修改失败!!"); |
| | | } |
| | | } |
| | | }); |
| | | return true; |
| | | } else { |
| | | throw new CoolException(reponse.getMsg()); |
| | | } |
| | | } |
| | | } |