312
parent
ff228f6f88
commit
c79940ed34
|
|
@ -89,6 +89,8 @@ public class StudenController {
|
||||||
return new ResponseEntity<>(ApiResult.success(BAD_REQUEST.value(), "接口异常!", ""), HttpStatus.BAD_REQUEST);
|
return new ResponseEntity<>(ApiResult.success(BAD_REQUEST.value(), "接口异常!", ""), HttpStatus.BAD_REQUEST);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
|
|
||||||
|
System.out.println("resultJson:"+resultJson);
|
||||||
studenService.getOrderInfo(resultJson);//获取送货单
|
studenService.getOrderInfo(resultJson);//获取送货单
|
||||||
return new ResponseEntity<>(ApiResult.success(OK.value(), "", resultJson), HttpStatus.OK);
|
return new ResponseEntity<>(ApiResult.success(OK.value(), "", resultJson), HttpStatus.OK);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
@ -97,6 +99,24 @@ public class StudenController {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Log("导入点位")
|
@Log("导入点位")
|
||||||
@PostMapping(value = "/import_studen")
|
@PostMapping(value = "/import_studen")
|
||||||
@ApiOperation("导入点位")
|
@ApiOperation("导入点位")
|
||||||
|
|
|
||||||
|
|
@ -15,11 +15,15 @@
|
||||||
*/
|
*/
|
||||||
package com.youchain.basicdata.service.impl;
|
package com.youchain.basicdata.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.youchain.basicdata.domain.Studen;
|
import com.youchain.basicdata.domain.Studen;
|
||||||
import com.youchain.basicdata.repository.PointRepository;
|
import com.youchain.basicdata.repository.PointRepository;
|
||||||
|
import com.youchain.businessdata.domain.Order;
|
||||||
import com.youchain.businessdata.inputJson.OrderInfo;
|
import com.youchain.businessdata.inputJson.OrderInfo;
|
||||||
|
import com.youchain.businessdata.service.OrderService;
|
||||||
import com.youchain.utils.*;
|
import com.youchain.utils.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import com.youchain.basicdata.repository.StudenRepository;
|
import com.youchain.basicdata.repository.StudenRepository;
|
||||||
|
|
@ -32,12 +36,11 @@ import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.data.domain.Page;
|
import org.springframework.data.domain.Page;
|
||||||
import org.springframework.data.domain.Pageable;
|
import org.springframework.data.domain.Pageable;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.LinkedHashMap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @website https://eladmin.vip
|
* @website https://eladmin.vip
|
||||||
|
|
@ -51,6 +54,7 @@ public class StudenServiceImpl implements StudenService {
|
||||||
|
|
||||||
private final StudenRepository studenRepository;
|
private final StudenRepository studenRepository;
|
||||||
private final StudenMapper studenMapper;
|
private final StudenMapper studenMapper;
|
||||||
|
private final OrderService orderService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -130,7 +134,114 @@ public class StudenServiceImpl implements StudenService {
|
||||||
@Override
|
@Override
|
||||||
public void getOrderInfo(String resultJson) {
|
public void getOrderInfo(String resultJson) {
|
||||||
|
|
||||||
|
if (StringUtils.isEmpty(resultJson)) {
|
||||||
|
throw new RuntimeException("获取送货单接口失败!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JSONObject resulObject = JSON.parseObject(resultJson);
|
||||||
|
if (resulObject == null) {
|
||||||
|
throw new RuntimeException("获取送货单接口返回数据为空!");
|
||||||
|
}
|
||||||
|
String code = resulObject.getString("code") == null ? "" : resulObject.getString("code");
|
||||||
|
String msg = resulObject.getString("msg") == null ? "" : resulObject.getString("msg");
|
||||||
|
//判断接口是否成功
|
||||||
|
if (!"0".equals(code)) {
|
||||||
|
throw new RuntimeException("获取送货单接口异常信息:" + msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
String data = resulObject.getString("data") == null ? "" : resulObject.getString("data");
|
||||||
|
JSONObject dataObject = JSON.parseObject(data);
|
||||||
|
if (dataObject == null) {
|
||||||
|
throw new RuntimeException("获取送货单接口返回数据为空!");
|
||||||
|
}
|
||||||
|
JSONArray details = dataObject.getJSONArray("list");
|
||||||
|
//判断是否有送货单数据
|
||||||
|
if (details == null || details.size() == 0) {
|
||||||
|
throw new RuntimeException("没有获取到送货单数据!");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Order> ordersToCreate = new ArrayList<>();//新增订单集合
|
||||||
|
List<Order> ordersToUpdate = new ArrayList<>();//更新订单集合
|
||||||
|
//获取所有送货单条码号
|
||||||
|
Set<String> barcodeNumbers = details.stream()
|
||||||
|
.map(detail -> ((JSONObject) detail).getString("barcodeNumber"))
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
//获取已存在的订单
|
||||||
|
Map<String, Order> existingOrders = orderService.findByBarcodeNumbers(barcodeNumbers);
|
||||||
|
//循环处理每个送货单
|
||||||
|
for (int i = 0; i < details.size(); i++) {
|
||||||
|
JSONObject detail = details.getJSONObject(i);
|
||||||
|
String barcodeNumber = detail.getString("barcodeNumber");
|
||||||
|
//判断是否已存在订单
|
||||||
|
if (existingOrders.containsKey(barcodeNumber)) {
|
||||||
|
Order existingOrder = existingOrders.get(barcodeNumber);
|
||||||
|
//更新订单信息
|
||||||
|
ordersToUpdate.add(updateOrder(existingOrder, detail));
|
||||||
|
} else {
|
||||||
|
//新增订单
|
||||||
|
ordersToCreate.add(createOrder(detail));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//批量新增订单
|
||||||
|
if (!ordersToCreate.isEmpty()) {
|
||||||
|
orderService.batchCreateOrders(ordersToCreate);
|
||||||
|
}
|
||||||
|
//批量更新订单
|
||||||
|
if (!ordersToUpdate.isEmpty()) {
|
||||||
|
orderService.batchUpdateOrders(ordersToUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private Order createOrder(JSONObject detail) {
|
||||||
|
|
||||||
|
String barcodeNumber = detail.getString("barcodeNumber");//送货单条码号
|
||||||
|
String isCreatedLabel = detail.getString("isCreatedLabel");//是否已生成标签N
|
||||||
|
String itemCode = detail.getString("itemCode");//物料编码
|
||||||
|
String iqcResult = detail.getString("iqcResult");//检验结果(不合格:REJECT,合格:ACCEPT)
|
||||||
|
String supplierCode = detail.getString("supplierCode");//供应商编码
|
||||||
|
//String dispatchNumber=detail.getString("dispatchNumber");//文档没有该字段
|
||||||
|
String receivedLocationName = detail.getString("receivedLocationName");//LMES货位名称
|
||||||
|
String receivedInvCode = detail.getString("receivedInvCode");//LMES接收子库编码
|
||||||
|
//Integer deliveryNotifyLineId = detail.getInteger("deliveryNotifyLineId");//送货通知单行ID
|
||||||
|
String deliveryNumber = detail.getString("deliveryNumber");//送货单号
|
||||||
|
String receivedAreaCode = detail.getString("receivedAreaCode");//LMES接收货区编码
|
||||||
|
String supplierName = detail.getString("supplierName");//供应商名称
|
||||||
|
String isIqcInspected = detail.getString("isIqcInspected");//Y-已检验N-未检验
|
||||||
|
Double deliveryQty = detail.getDouble("deliveryQty") == null ? 0 : detail.getDouble("deliveryQty");//计划数量
|
||||||
|
//String deliveryType=detail.getString("deliveryType");//文档没有该字段
|
||||||
|
String receivedLocationCode = detail.getString("receivedLocationCode");//LMES货位编码
|
||||||
|
String mlsUpdateTime = detail.getString("updateTime");//更新时间
|
||||||
|
String receivedInvName = detail.getString("receivedInvName");//LMES接收子库名称
|
||||||
|
Double receivedQty = detail.getDouble("receivedQty") == null ? 0 : detail.getDouble("receivedQty");//实际接收数量
|
||||||
|
//Integer deliveryLineId = detail.getInteger("deliveryLineId");//送货单行ID
|
||||||
|
String inInspector = detail.getString("inInspector");//检验员
|
||||||
|
Integer deliveryHeaderId = detail.getInteger("deliveryHeaderId");//送货单头ID和003接口关联
|
||||||
|
String receivedAreaName = detail.getString("receivedAreaName");//mls接收货区名称
|
||||||
|
String deliveryStatus = detail.getString("deliveryStatus");//送货单状态
|
||||||
|
|
||||||
|
//创建
|
||||||
|
Order newOrder = new Order(deliveryHeaderId, null, null,
|
||||||
|
deliveryNumber, barcodeNumber, deliveryStatus, receivedInvCode, receivedInvName,
|
||||||
|
receivedAreaCode, receivedAreaName, receivedLocationCode, receivedLocationName,
|
||||||
|
itemCode, deliveryQty, inInspector, receivedQty, isIqcInspected, iqcResult, isCreatedLabel,
|
||||||
|
supplierCode, supplierName, mlsUpdateTime == null ? null : DateUtil.parse(mlsUpdateTime).toTimestamp()
|
||||||
|
);
|
||||||
|
|
||||||
|
return newOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private Order updateOrder(Order order, JSONObject detail) {
|
||||||
|
order.setReceivedQty(detail.getDouble("receivedQty") == null ? 0 : detail.getDouble("receivedQty"));
|
||||||
|
order.setDeliveryStatus(detail.getString("deliveryStatus"));
|
||||||
|
order.setMlsUpdateTime(detail.getString("updateTime") == null ? null : DateUtil.parse(detail.getString("updateTime")).toTimestamp());
|
||||||
|
return order;
|
||||||
|
}
|
||||||
|
|
||||||
public String getToKen() {
|
public String getToKen() {
|
||||||
String toKen = "";
|
String toKen = "";
|
||||||
String mlsUser = "WMS";
|
String mlsUser = "WMS";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue