| | |
| | | package com.vincent.rsf.server.manager.schedules; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | |
| | | import com.vincent.rsf.server.api.service.ReportMsgService; |
| | | import com.vincent.rsf.server.api.utils.LocUtils; |
| | | import com.vincent.rsf.server.common.constant.Constants; |
| | | import com.vincent.rsf.server.manager.controller.params.LocSiteParams; |
| | | import com.vincent.rsf.server.manager.controller.params.LocToTaskParams; |
| | | import com.vincent.rsf.server.manager.enums.*; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | |
| | | if (!task.getTaskType().equals(TaskType.TASK_TYPE_LOC_MOVE.type)) { |
| | | BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, |
| | | task.getTaskStatus().equals(TaskStsType.GENERATE_IN.id) ? task.getOrgSite() : task.getTargSite())); |
| | | task.getTaskStatus().equals(TaskStsType.GENERATE_IN.id) ? task.getOrgSite() : task.getTargSite())); |
| | | if (station.getType().equals(StationTypeEnum.STATION_TYPE_MUTI.type)) { |
| | | continue; |
| | | } |
| | |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * @param |
| | | * @return |
| | |
| | | } |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | |
| | | for (TaskItem taskItem : taskItems) { |
| | | if (Objects.isNull(taskItem.getOrderId())) { |
| | | continue; |
| | | } |
| | | WkOrder order = asnOrderService.getById(taskItem.getOrderId()); |
| | | if (Objects.isNull(order)) { |
| | | continue; |
| | | } |
| | | //入库单任务明细上报 |
| | | if (order.getType().equals(OrderType.ORDER_IN.type)) { |
| | | //入库单据明细上报 |
| | | if (task.getTaskType() <= TaskType.TASK_TYPE_CHECK_IN.type) { |
| | | for (TaskItem taskItem : taskItems) { |
| | | if (Objects.isNull(taskItem.getOrderId())) { |
| | | continue; |
| | | } |
| | | WkOrder order = asnOrderService.getById(taskItem.getOrderId()); |
| | | if (Objects.isNull(order)) { |
| | | continue; |
| | | } |
| | | //入库单任务明细上报 |
| | | WkOrderItem wkOrderItem = asnOrderItemService.getOne(new LambdaQueryWrapper<WkOrderItem>() |
| | | .eq(WkOrderItem::getOrderId, order.getId()) |
| | | .eq(WkOrderItem::getFieldsIndex, taskItem.getFieldsIndex())); |
| | |
| | | } |
| | | /**入库单明细上报*/ |
| | | reportMsgService.reportOrderItem(wkOrderItem); |
| | | } |
| | | } else if (task.getTaskType() >= TaskType.TASK_TYPE_OUT.type && task.getTaskType() <= TaskType.TASK_TYPE_EMPITY_OUT.type) { |
| | | //出库单上报RCS修改库位状态 |
| | | try { |
| | | reportStationStatus(task); |
| | | } catch (Exception e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | } |
| | | |
| | |
| | | if (!taskItemLogService.saveBatch(itemLogs)) { |
| | | throw new CoolException("任务明细历史档保存失败!!"); |
| | | } |
| | | |
| | | if (!taskItemService.remove(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId()))) { |
| | | throw new CoolException("原始任务明细删除失败!!"); |
| | | } |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @author Ryan |
| | | * @date 2025/11/10 |
| | | * @description: 上报站点状态 |
| | | * @version 1.0 |
| | | */ |
| | | public CommonResponse reportStationStatus(Task task) { |
| | | if (Objects.isNull(task.getTargSite())) { |
| | | throw new CoolException("目标站点不能为空!!"); |
| | | } |
| | | BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>().eq(BasStation::getStationName, task.getTargSite())); |
| | | if (Objects.isNull(station)) { |
| | | throw new CoolException("数据错误,目标站点不存在!!"); |
| | | } |
| | | station.setUseStatus(LocStsType.LOC_STS_TYPE_O.type); |
| | | |
| | | if (!basStationService.updateById(station)) { |
| | | throw new CoolException("站点状态修改失败!!"); |
| | | } |
| | | |
| | | LocSiteParams locSiteParams = new LocSiteParams(); |
| | | locSiteParams.setStatus(LocStsType.getLocSts(LocStsType.LOC_STS_TYPE_O.type)) |
| | | .setType("site") |
| | | .setCode(station.getStationName()); |
| | | |
| | | /**WMS基础配置链接*/ |
| | | String rcsUrl = rcsApi.getHost() + ":" + rcsApi.getPort() + RcsConstant.REPORT_SITE_STATUS; |
| | | log.info("上报已完成订单:{}, 请求参数: {}", rcsUrl, JSONObject.toJSONString(locSiteParams)); |
| | | HttpHeaders headers = new HttpHeaders(); |
| | | headers.add("Content-Type", "application/json"); |
| | | headers.add("api-version", "v2.0"); |
| | | |
| | | HttpEntity httpEntity = new HttpEntity(locSiteParams, 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); |
| | | return result; |
| | | } catch (JsonProcessingException e) { |
| | | throw new CoolException(e.getMessage()); |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | } |