Browse Source

1.对接欧派数据推送

training
pref_mail@163.com 2 years ago
parent
commit
9e86bcdfdb
  1. 3
      blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java
  2. 55
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpOldReceivingDataHandler.java
  3. 51
      blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java
  4. 17
      blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java

3
blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java

@ -62,6 +62,9 @@ public class FactoryPackageEntity extends BaseEntity {
/** 三级品类名称 */
@ApiModelProperty(name = "三级品类名称",notes = "")
private String thirdClassName ;
@ApiModelProperty(name = "物料名称合集",notes = "")
private String packageDetailNames ;
/** 补进 */
@ApiModelProperty(name = "补进",notes = "")
private Integer buyin ;

55
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/receiver/OpOldReceivingDataHandler.java

@ -25,6 +25,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@ -63,6 +64,14 @@ public class OpOldReceivingDataHandler {
JSONObject object = JSONObject.parseObject(jsonStr);
String orderPackageCode = object.getString("orderPackageCode");
String warehouseName = object.getString("warehouse_name");
String opShipNo = object.getString("opShipNo");
String orderSelfNum = object.getString("orderSelfNum");
String carNumber = object.getString("carNumber");
String siteName = object.getString("siteName");
String packageDetailNames = object.getString("packageDetailNames");
String firstPackName = object.getString("firstPackName");
String secondPackName = object.getString("secondPackName");
String thirdPackName = object.getString("thirdPackName");
QueryWrapper warehouseQueryWrapper = new QueryWrapper();
@ -87,7 +96,35 @@ public class OpOldReceivingDataHandler {
String authCode = oldLogin(warehouseEntity.getId());
// 推送数据
if (StringUtil.isNotBlank(authCode)) {
boolean isSuccess = sendPackageData(authCode, orderPackageCode);
Map<String,Object> reqMap = new HashMap<>();
reqMap.put("authCode", authCode);
// 收货单
reqMap.put("op_shipNo", opShipNo);
//仓库ID
reqMap.put("warehouse_id", warehouseEntity.getId());
//订单自编号
reqMap.put("orderSelfNum", orderSelfNum);
//扫描时间
reqMap.put("scan_time", new Date());
//扫描人
reqMap.put("scan_user", "");
//车次号
reqMap.put("mctsTruck", carNumber);
//发货基地
reqMap.put("siteName", siteName);
//一级品类
reqMap.put("firstPackName", firstPackName);
//二级品类
reqMap.put("secondPackName", secondPackName);
//三级品类
reqMap.put("thirdPackName", thirdPackName);
//物料名称
reqMap.put("productname", packageDetailNames);
boolean isSuccess = sendPackageData(reqMap);
if (isSuccess) {
// 请求成功 修改推送数据的状态 修改未1
if (ObjectUtils.isNotNull(packageEntity)) {
@ -126,19 +163,15 @@ public class OpOldReceivingDataHandler {
}
private boolean sendPackageData(String authCode, String orderPackageCode) {
private boolean sendPackageData(Map<String,Object> map) {
// 构建请求头
Map<String, Object> map = new HashMap<>();
map.put("type", "1");
map.put("unitNo", orderPackageCode);
map.put("mctsTruckNo", "");
map.put("area", "");
map.put("user_id", oldSystemProperties.getUserId());
map.put("pick_up_id", "");
map.put("origin", "按件入库");
String authCode = map.get("authCode").toString();
log.info("##################sendPackageData: 请求老系统接口 start map {}", map);
String url = oldSystemProperties.getUrl() + "api/scan";
String url = oldSystemProperties.getUrl() + "openApi/newSystem.OptimsWarehouseScan/index";
String body = HttpRequest.post(url).form(map).header("token", authCode).execute().body();
log.info("##################sendPackageData: 请求老系统接口,url:{},body:{}", url, body);
if (StringUtil.isNotBlank(body)) {

51
blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/OuPaiFactoryServiceImpl.java

@ -141,22 +141,49 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
FactoryPackageEntity packageEntity = factoryPackageService.getOne(queryWrapper);
String code=null;
String endWarehouseName = null;
String opShipNo=null;
String orderSelfNum =null;
String carNumber=null;
String siteName = null;
String packageDetailNames = null;
String firstPackName,secondPackName,thirdPackName = null;
if (Objects.isNull(packageEntity)) {
log.error("############oid 查询数据失败: {}", key);
// 查询欧派系统的的数据
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/Package(" + key + ")?select=Code,PackageStatus,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,Length,Width,Height,Weight,IsInventory,SendTime,ReceivingTime,CreateTime,ShipTime,CarNumber,DeliveryMethod&$expand=ReceivingOrders($select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber;$expand=EndWarehouse($select=Name,Code))";
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event);
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/Package(" + key + ")?select=Code,PackageStatus,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,Length,Width,Height,Weight,IsInventory,SendTime,ReceivingTime,CreateTime,ShipTime,CarNumber,DeliveryMethod&$expand=ReceivingOrders($select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber;$expand=EndWarehouse($select=Name,Code))&$expand=Order($select=SelfCode,Code)"; OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event);
JSONObject jsonObject = JSONObject.parseObject(opOrderStatusLogEntity.getResponseBody());
code = jsonObject.getString("Code");
Boolean isInventory = jsonObject.getBoolean("IsInventory");
carNumber = jsonObject.getString("CarNumber");
packageDetailNames = jsonObject.getString("PackageDetailNames");
firstPackName = jsonObject.getString("FirstPackName");
secondPackName = jsonObject.getString("SecondPackName");
thirdPackName = jsonObject.getString("ThirdPackName");
if(isInventory){
log.error("############库存品数据 不进行推送: {}", code);
return key;
}
JSONObject order = jsonObject.getJSONObject("Order");
if (order != null){
orderSelfNum = order.getString("SelfCode");
}
JSONArray ls = jsonObject.getJSONArray("ReceivingOrders");
if(ls!=null&& !ls.isEmpty()){
JSONObject t = ls.getJSONObject(0);
if(t!=null){
opShipNo = t.getString("Code");
JSONObject endWarehouse = t.getJSONObject("EndWarehouse");
endWarehouseName = endWarehouse.getString("Name");
JSONObject fromWarehouse = t.getJSONObject("FromWarehouse");
siteName = fromWarehouse.getString("Name");
}
}else{
log.error("############没有收货单oid:{}", key);
return key;
@ -166,18 +193,28 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
packageEntity.setPackageStatus(5);
factoryPackageService.updateById(packageEntity);
code = packageEntity.getCode();
packageDetailNames =packageEntity.getPackageDetailNames();
firstPackName = packageEntity.getFirstClassName();
secondPackName = packageEntity.getSecondClassName();
thirdPackName = packageEntity.getThirdClassName();
Long orderId = packageEntity.getOrderId();
// 查询 订单
QueryWrapper<FactoryOrderEntity> queryWrapperFactoryOrderEntity = new QueryWrapper<>();
queryWrapperFactoryOrderEntity.eq("id", orderId);
FactoryOrderEntity orderEntity = factoryOrderService.getOne(queryWrapperFactoryOrderEntity);
orderSelfNum = orderEntity.getSelfCode();
// 查询 发货单
Long receivingId = orderEntity.getReceivingId();
ReceivingOrderEntity receivingEntity = receivingOrderMapper.selectById(receivingId);
endWarehouseName = receivingEntity.getEndWarehouseName();
}
opShipNo = receivingEntity.getCode();
carNumber = receivingEntity.getCarNumber();
// 发货基地
siteName = receivingEntity.getFromWarehouseName();
}
// 判断 作业仓库 和 收货仓库 是否一致
log.info(" >>>> 判断作业仓库 和 收货仓库 是否一致 >>>> 作业仓库:{},收货仓库:{}", warehouseName, endWarehouseName);
@ -189,6 +226,14 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
JSONObject jo = new JSONObject();
jo.put("orderPackageCode", code);
jo.put("warehouse_name", warehouseName);
jo.put("opShipNo", opShipNo);
jo.put("orderSelfNum", orderSelfNum);
jo.put("carNumber", carNumber);
jo.put("siteName", siteName);
jo.put("packageDetailNames", packageDetailNames);
jo.put("firstPackName", firstPackName);
jo.put("secondPackName", secondPackName);
jo.put("thirdPackName", thirdPackName);
//真正的处理需要的数据
Map<String, Object> map = new HashMap<>();

17
blade-service/logpm-factory/src/test/java/com/logpm/factory/TestService.java

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save