| | |
| | | import com.vincent.rsf.server.api.service.ReportMsgService; |
| | | import com.vincent.rsf.server.manager.entity.WkOrder; |
| | | import com.vincent.rsf.server.manager.entity.WkOrderItem; |
| | | import com.vincent.rsf.server.manager.mapper.AsnOrderMapper; |
| | | import com.vincent.rsf.server.manager.entity.Purchase; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderItemService; |
| | | import com.vincent.rsf.server.manager.service.AsnOrderService; |
| | | import com.vincent.rsf.server.manager.service.PurchaseService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.BeanUtils; |
| | |
| | | @Autowired |
| | | private RemotesInfoProperties remotesInfoProperties; |
| | | @Autowired |
| | | private AsnOrderService asnOrderService; |
| | | private AsnOrderMapper asnOrderMapper; |
| | | @Autowired |
| | | private AsnOrderItemService asnOrderItemService; |
| | | @Autowired |
| | |
| | | * @author Ryan |
| | | * @description 上报质检列表 |
| | | * @params [items 列表] |
| | | * |
| | | * @return boolean |
| | | * @time 2025/3/7 09:12 |
| | | * 11 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | |
| | | //ASN明细单据分组 |
| | | Map<Long, List<WkOrderItem>> asnIds = wkOrderItems.stream().collect(Collectors.groupingBy(WkOrderItem::getOrderId)); |
| | | ids.forEach(id -> { |
| | | int count = asnOrderService.count(new LambdaQueryWrapper<WkOrder>().in(WkOrder::getId, id)); |
| | | long count = Optional.ofNullable(asnOrderMapper.selectCount(new LambdaQueryWrapper<WkOrder>().in(WkOrder::getId, id))).orElse(0L); |
| | | if (count == asnIds.get(id).size()) { |
| | | if (!asnOrderService.update(new LambdaUpdateWrapper<WkOrder>().eq(WkOrder::getId, id).set(WkOrder::getNtyStatus, 1))) { |
| | | if (asnOrderMapper.update(null, new LambdaUpdateWrapper<WkOrder>().eq(WkOrder::getId, id).set(WkOrder::getNtyStatus, 1)) <= 0) { |
| | | throw new CoolException("ASN主单状态修改失败!!"); |
| | | } |
| | | } else { |
| | | if (!asnOrderService.update(new LambdaUpdateWrapper<WkOrder>().eq(WkOrder::getId, id).set(WkOrder::getNtyStatus, 2))) { |
| | | if (asnOrderMapper.update(null, new LambdaUpdateWrapper<WkOrder>().eq(WkOrder::getId, id).set(WkOrder::getNtyStatus, 2)) <= 0) { |
| | | throw new CoolException("ASN主单状态修改失败!!"); |
| | | } |
| | | } |
| | |
| | | if (result.getCode() == 200) { |
| | | return R.ok().add(result.getData()); |
| | | } else { |
| | | return R.ok(result.getMsg()).add(result.getData()); |
| | | // throw new CoolException("修改失败!!"); |
| | | } |
| | | } catch (JsonProcessingException e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 盘点库存数据修改 |
| | | * @param params |
| | | * @return |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R uploadCheckOrder(ReportParams params) { |
| | | if (Objects.isNull(params)) { |
| | | throw new CoolException("参数不能为空!!"); |
| | | } |
| | | /**WMS基础配置链接*/ |
| | | String rcsUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.CHECK_LOCITEM_UPDATE; |
| | | log.info("盘点库存修改:{}, 请求参数: {}", rcsUrl, JSONObject.toJSONString(params)); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.add("Content-Type", "application/json"); |
| | | headers.add("api-version", "v2.0"); |
| | | |
| | | params.setAction("Update").setOrderType("PD_stock"); |
| | | |
| | | HttpEntity httpEntity = new HttpEntity(params, headers); |
| | | ResponseEntity<String> exchange = restTemplate.exchange(rcsUrl, HttpMethod.POST, httpEntity, String.class); |
| | | log.info("盘点库存修改,返回结果: {}", exchange); |
| | | if (Objects.isNull(exchange.getBody())) { |
| | | throw new CoolException("修改失败!!"); |
| | | } else { |
| | | ObjectMapper objectMapper = new ObjectMapper(); |
| | | objectMapper.coercionConfigDefaults().setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty); |
| | | try { |
| | | CommonResponse result = objectMapper.readValue(exchange.getBody(), CommonResponse.class); |
| | | if (result.getCode() == 200) { |
| | | return R.ok().add(result.getData()); |
| | | } else { |
| | | throw new CoolException("修改失败!!"); |
| | | } |
| | | } catch (JsonProcessingException e) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |