diff --git a/blade-biz-common/src/main/java/org/springblade/common/constant/OldSystemDataPushConfig.java b/blade-biz-common/src/main/java/org/springblade/common/constant/OldSystemDataPushConfig.java
index c6351e1ae..68ad6deec 100644
--- a/blade-biz-common/src/main/java/org/springblade/common/constant/OldSystemDataPushConfig.java
+++ b/blade-biz-common/src/main/java/org/springblade/common/constant/OldSystemDataPushConfig.java
@@ -17,6 +17,8 @@ public class OldSystemDataPushConfig {
warehourseIds.add("30");
warehourseIds.add("38");
warehourseIds.add("124");
+ // 上海
+ warehourseIds.add("149");
}
diff --git a/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java b/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java
index c7453f07e..36511603c 100644
--- a/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java
+++ b/blade-biz-common/src/main/java/org/springblade/common/utils/FileLogsUtil.java
@@ -5,10 +5,9 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springblade.common.constant.CommonConstant;
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Writer;
+import java.io.*;
+import java.net.HttpURLConnection;
+import java.net.URL;
import java.util.Calendar;
import java.util.Date;
@@ -65,6 +64,28 @@ public class FileLogsUtil {
return imgPath + fileName;
}
+
+ public static String loadFileContent(String urlString) {
+ try {
+ log.info(">>>> 开始下载 {}",urlString);
+ URL url = new URL(urlString);
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
+ connection.setRequestMethod("GET");
+ BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
+ String inputLine;
+ StringBuilder content = new StringBuilder();
+ while ((inputLine = in.readLine()) != null) {
+ content.append(inputLine);
+ }
+ in.close();
+ log.info(">>>> 结束下载 {}",urlString);
+ return content.toString();
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+ }
+
private static String makeDateString(Date date) {
StringBuilder stringBuffer = new StringBuilder();
diff --git a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java
index fa35f4046..55fc89e7c 100644
--- a/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java
+++ b/blade-service-api/logpm-factory-api/src/main/java/com/logpm/factory/oupai/entity/FactoryPackageEntity.java
@@ -98,7 +98,7 @@ public class FactoryPackageEntity extends BaseEntity {
/** 入库单状态 0正常 1作废 */
@ApiModelProperty(name = "入库单状态 0正常 1作废",notes = "")
private Integer receiptStatus ;
- /** 推送状态 1推送 0未推送 */
+ /** 推送欧派 推送状态 1推送 0未推送 3 收货推送完成 4 出库推送完成*/
@ApiModelProperty(name = "推送状态 1推送 0未推送",notes = "")
private Integer pushStatus ;
@ApiModelProperty(name = "老系统推送状态 1推送 0未推送 2 推送失败",notes = "")
diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml
index 097ba42b4..2c08124d0 100644
--- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml
+++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/mapper/DistributionStockArticleMapper.xml
@@ -671,6 +671,13 @@
and ldsa.consignee_unit like concat('%',#{par.consigneeUnit},'%')
+
+
+ and ldsa.total_number = #{par.totalNumber}
+
+
+ and ldsa.customer_address like concat('%',#{par.customerAddress},'%')
+
+
+
+
+
diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.java
index 13dee3731..ce3342ad9 100644
--- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.java
+++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.java
@@ -44,6 +44,9 @@ public interface ReceivingOrderMapper extends BaseMapper {
List selectReceivingOrderPage(IPage page, ReceivingOrderVO receivingOrder);
+ String selectReceivingOrderByOrderId (@Param("orderId") Long orderId);
+
+
diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.xml b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.xml
index 52faf74e7..8d4bf42d3 100644
--- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.xml
+++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/mapper/ReceivingOrderMapper.xml
@@ -11,7 +11,11 @@
select * from op_receiving_order where is_deleted = 0
-
+
diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java
index 5f0b50784..633a3ef44 100644
--- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java
+++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/IOuPaiFactoryService.java
@@ -14,7 +14,9 @@ public interface IOuPaiFactoryService {
String saveOuPaiFactoryOrderDTOByCarCarNumber(String carNumber);
- String saveOuPaiPackageStatusByCode(String orderPackageCode,Integer event);
+ String saveOuPaiFactoryOrderDTOByCarCarNumberAgain(String code);
+
+ String saveOuPaiPackageStatusByCode(String orderPackageCode, Integer event);
Boolean checkReceivingOrder(String code);
diff --git a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/FactoryOrderServiceImpl.java b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/FactoryOrderServiceImpl.java
index cfafd5d1b..beed8b4bf 100644
--- a/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/FactoryOrderServiceImpl.java
+++ b/blade-service/logpm-factory/src/main/java/com/logpm/factory/oupai/service/impl/FactoryOrderServiceImpl.java
@@ -45,6 +45,7 @@ public class FactoryOrderServiceImpl extends BaseServiceImpl>>> 欧派数据解析报错", e);
+ opOrderStatusLogEntity.setDataStatus(2);
+
+ }
+ opOrderStatusLogService.saveOrUpdate(opOrderStatusLogEntity);
+ log.info("数据重新获取 end {}", code);
+ return code;
+ }
+
+ private OpOrderStatusLogEntity findOurPaiDataByCarNumberByLoal(String code) {
+
+ // 查询自己数据 判断这个收货单号是否存在
+
+ LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
+ lambdaQueryWrapper.eq(OpOrderStatusLogEntity::getType, 3);
+ lambdaQueryWrapper.like(OpOrderStatusLogEntity::getArgs, code);
+ lambdaQueryWrapper.orderByAsc(OpOrderStatusLogEntity::getCreateTime);
+ lambdaQueryWrapper.last("limit 1");
+ return opOrderStatusLogService.getOne(lambdaQueryWrapper);
+
+
+ }
+
@Override
public String saveOuPaiPackageStatusByCode(String orderPackageCode, Integer event) {
//
@@ -372,20 +417,20 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
String currentWarehouseId = orderStatusDTO.getCurrentWarehouse();//当前仓Id
//查询destinationWarehouse logiBillNo plantId数据
log.info("oupai-handleStatusData >>> unitNo={}", unitNo);
- Map supplyData = advanceDetailClient.getSupplyData(unitNo);
- if (ObjectUtils.isEmpty(supplyData)) {
- return Resp.fail(400, "未查询到该单据信息");
- }
- String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id
- if (StringUtil.isBlank(currentWarehouseId) || StringUtil.isBlank(destinationWarehouseId)) {
- log.warn("##############oupai-handleStatusData: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId);
- return Resp.fail(400, "仓库数据有误");
- }
-
- if (!currentWarehouseId.equals(destinationWarehouseId)) {
- log.info("##############oupai-handleStatusData: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId);
- return Resp.fail(400, "不是目的仓");
- }
+// Map supplyData = advanceDetailClient.getSupplyData(unitNo);
+// if (ObjectUtils.isEmpty(supplyData)) {
+// return Resp.fail(400, "未查询到该单据信息");
+// }
+// String destinationWarehouseId = supplyData.get("destinationWarehouseId");//目的仓id
+// if (StringUtil.isBlank(currentWarehouseId) || StringUtil.isBlank(destinationWarehouseId)) {
+// log.warn("##############oupai-handleStatusData: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId);
+// return Resp.fail(400, "仓库数据有误");
+// }
+//
+// if (!currentWarehouseId.equals(destinationWarehouseId)) {
+// log.info("##############oupai-handleStatusData: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId);
+// return Resp.fail(400, "不是目的仓");
+// }
// 查询这个包件对应到新系统的订单
FactoryOrderEntity factoryOrder = factoryOrderService.selectEntityByOrderPackageCode(unitNo);
@@ -451,21 +496,51 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
if (opPackagePushLogEntity == null) {
log.info(" >>>>>>>>>>>>>>>>>>>>>>> 包件 {} 已推送欧派 状态 {}", unitNo, detailObject.get("Operate"));
} else {
- // 需要盘点这个对象的
String resp = opPackagePushLogEntity.getResp();
// 转换为json
// JSONObject respJson = JSONObject.parseObject(resp);
log.info(" >>>>>>>>>>>>>>>>>>>>>>> 推送欧派返回数据 {}", resp);
// TODO: 2023/10/25 不知道返回成功的状态是多少
// 需要修改包件对应的状态
- factoryPackageEntity.setPushStatus(1);
- factoryPackageService.updateById(factoryPackageEntity);
+ checkOpFactoryPackagePushStatus(factoryPackageEntity);
}
}
return Resp.success("物流状态传递成功");
}
+ /**
+ * 根据推送类型修改包件上的状态
+ *
+ * @param factoryPackageEntity
+ */
+ void checkOpFactoryPackagePushStatus(FactoryPackageEntity factoryPackageEntity) {
+
+
+ // 查询推送记录 师傅包含 已收货 已出库
+ LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
+ lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, factoryPackageEntity.getId());
+ lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType, 1);// 查询包件
+
+ List list = opPackagePushLogService.list(lambdaQueryWrapper);
+
+ if (list != null && !list.isEmpty()) {
+ for (OpPackagePushLogEntity opPackagePushLogEntity : list) {
+ if ("收货".equals(opPackagePushLogEntity.getPushOupaiNode())) {
+ factoryPackageEntity.setPushStatus(3);
+ }
+ if ("发货".equals(opPackagePushLogEntity.getPushOupaiNode())) {
+ factoryPackageEntity.setPushStatus(4);
+ }
+ }
+ factoryPackageService.updateById(factoryPackageEntity);
+
+ } else {
+ log.info("包件推送记录未null 包条码{}", factoryPackageEntity.getCode());
+ }
+
+ }
+
/**
* 根据汇通业务提供是否操作欧派系统的商场 来决定是否会推数据
* 如果需要使用欧派系统 这里就需要不进行回传
@@ -594,6 +669,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getRefId, refId);
lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushOupaiNode, data.getString("Operate"));
+ lambdaQueryWrapper.eq(OpPackagePushLogEntity::getPushType, pushType);// 查询包件
List list = opPackagePushLogService.list(lambdaQueryWrapper);
if (ObjectUtils.isNull(list) || list.isEmpty()) {
OpPackagePushLogEntity opPackagePushLogEntity = new OpPackagePushLogEntity();
@@ -669,7 +745,8 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
lambdaQueryWrapper.eq(ReceivingOrderEntity::getCode, code);
List receivingOrderEntities = receivingOrderMapper.selectList(lambdaQueryWrapper);
if (ObjectUtils.isNotNull(receivingOrderEntities)) {
- log.info(">>>>>>>>>>>>>>>>>>>>>>> 收货单已存在 {} ", code);
+ log.info(">>>>>>>>>>>>>>>>>>>>>>> 收货单已存在 收货单下面的订单是否存在 包件是否存在{} ", code);
+ extractedOuPaiOrderPackageInfor(valueObject, receivingOrderEntities.get(0).getId(), code);
return;
}
@@ -729,246 +806,270 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
if (row == 1) {
log.info("############handleData: 保存发货单数据 成功成功成功成功 code={}", code);
Long receivingId = receivingOrderEntity.getId();//发货单id
- JSONArray packages = valueObject.getJSONArray("Packages");
- for (int j = 0; j < packages.size(); j++) {
- JSONObject packageEntity = packages.getJSONObject(j);//包件信息
- JSONObject orderEntity = packageEntity.getJSONObject("Order");//订单信息
- if (orderEntity == null) {
- log.info("包件数据没有订单信息 packageCode {}", packageEntity.getString("Code"));
- continue;
- }
- String selfCode = orderEntity.getString("SelfCode");//订单自编码
- //先查询是否存在订单自编码
-//
- FactoryOrderEntity factoryOrderEntity = factoryOrderService.selectEntityBySelfCode(selfCode, receivingId);
- if(Objects.isNull(factoryOrderEntity)){
- factoryOrderEntity = new FactoryOrderEntity();
- factoryOrderEntity.setCode(orderEntity.getString("Code"));
- factoryOrderEntity.setSelfCode(selfCode);
- factoryOrderEntity.setContractNumber(orderEntity.getString("ContractNumber"));
- factoryOrderEntity.setServiceNumber(orderEntity.getString("ServiceNumber"));
- factoryOrderEntity.setOrderClass(orderEntity.getString("OrderClass"));
- factoryOrderEntity.setOrderType(orderEntity.getString("OrderType"));
- String factoryStatus = orderEntity.getString("Status");
- if ("待送货".equals(factoryStatus)) {
- factoryOrderEntity.setFactoryStatus(0);
- } else if ("已签收".equals(factoryStatus)) {
- factoryOrderEntity.setFactoryStatus(2);
- } else if ("已取消".equals(factoryStatus)) {
- factoryOrderEntity.setFactoryStatus(3);
- } else if ("部分签收".equals(factoryStatus)) {
- factoryOrderEntity.setFactoryStatus(6);
- }
+ extractedOuPaiOrderPackageInfor(valueObject, receivingId, code);
+ } else {
+ log.error("############handleData: 保存发货单数据失败 code={}", code);
+ throw new CustomerException(403, "保存发货单数据失败");
+ }
+ Date end = new Date();
+ long startLong = start.getTime();
+ long endLong = end.getTime();
+ long l = endLong - startLong;
+ log.info("############handleData: 数据处理完成 耗时 {} 毫秒", l);
+ }
- String factoryShipStatus = orderEntity.getString("FactoryShipStatus");
- if ("工厂未发货".equals(factoryShipStatus)) {
- factoryOrderEntity.setFactoryShipStatus(0);
- } else if ("工厂部分发货".equals(factoryShipStatus)) {
- factoryOrderEntity.setFactoryShipStatus(1);
- } else if ("工厂齐套发货".equals(factoryShipStatus)) {
- factoryOrderEntity.setFactoryShipStatus(2);
- }
- factoryOrderEntity.setFactorySendQty(orderEntity.getInteger("FactorySendQty"));
-
- String warehouseReceiveStatus = orderEntity.getString("WarehouseReceiveStatus");
- if ("仓库未收货".equals(warehouseReceiveStatus)) {
- factoryOrderEntity.setWarehouseReceiveStatus(0);
- } else if ("仓库部分收货".equals(warehouseReceiveStatus)) {
- factoryOrderEntity.setWarehouseReceiveStatus(1);
- } else if ("仓库全部收货".equals(warehouseReceiveStatus)) {
- factoryOrderEntity.setWarehouseReceiveStatus(2);
- }
- factoryOrderEntity.setWarehouseReceiveQty(orderEntity.getInteger("WarehouseReceiveQty"));
+ }
- String reservationStatus = orderEntity.getString("ReservationStatus");
- if ("不可预约".equals(reservationStatus)) {
- factoryOrderEntity.setReservationStatus(0);
- } else if ("可预约".equals(reservationStatus)) {
- factoryOrderEntity.setReservationStatus(1);
- }
+ /**
+ * 欧派入库方法
+ *
+ * @param valueObject
+ * @param receivingId
+ * @param code
+ */
+ private void extractedOuPaiOrderPackageInfor(JSONObject valueObject, Long receivingId, String code) {
+ JSONArray packages = valueObject.getJSONArray("Packages");
+
+ log.info(">>> 获取的包件长度 {}", packages.size());
+ for (int j = 0; j < packages.size(); j++) {
+ JSONObject packageEntity = packages.getJSONObject(j);//包件信息
+ log.info(">>>>> 解析出欧派的包件信息 {}", packageEntity.getString("Code"));
+ JSONObject orderEntity = packageEntity.getJSONObject("Order");//订单信息
+ if (orderEntity == null) {
+ log.info("包件数据没有订单信息 packageCode {}", packageEntity.getString("Code"));
+ continue;
+ }
+ String selfCode = orderEntity.getString("SelfCode");//订单自编码
+ //先查询是否存在订单自编码
+//
+ FactoryOrderEntity factoryOrderEntity = factoryOrderService.selectEntityBySelfCode(selfCode, receivingId);
+ if (Objects.isNull(factoryOrderEntity)) {
+ log.info(" oupai 收货单ID{} 收货单下面的订单不存在 进行新增订单 {}", receivingId, selfCode);
+ factoryOrderEntity = new FactoryOrderEntity();
+ factoryOrderEntity.setCode(orderEntity.getString("Code"));
+ factoryOrderEntity.setSelfCode(selfCode);
+ factoryOrderEntity.setContractNumber(orderEntity.getString("ContractNumber"));
+ factoryOrderEntity.setServiceNumber(orderEntity.getString("ServiceNumber"));
+ factoryOrderEntity.setOrderClass(orderEntity.getString("OrderClass"));
+ factoryOrderEntity.setOrderType(orderEntity.getString("OrderType"));
+ String factoryStatus = orderEntity.getString("Status");
+ if ("待送货".equals(factoryStatus)) {
+ factoryOrderEntity.setFactoryStatus(0);
+ } else if ("已签收".equals(factoryStatus)) {
+ factoryOrderEntity.setFactoryStatus(2);
+ } else if ("已取消".equals(factoryStatus)) {
+ factoryOrderEntity.setFactoryStatus(3);
+ } else if ("部分签收".equals(factoryStatus)) {
+ factoryOrderEntity.setFactoryStatus(6);
+ }
- JSONObject store = orderEntity.getJSONObject("Store");
- if (!Objects.isNull(store)) {
- factoryOrderEntity.setStoreCode(store.getString("Code"));
- factoryOrderEntity.setStoreName(store.getString("Name"));
- JSONObject shop = store.getJSONObject("Shop");
- if (!Objects.isNull(shop)) {
- factoryOrderEntity.setShopCode(shop.getString("Code"));
- factoryOrderEntity.setShopName(shop.getString("Name"));
- factoryOrderEntity.setBusinessModel(shop.getString("BusinessModel"));
- }
+ String factoryShipStatus = orderEntity.getString("FactoryShipStatus");
+ if ("工厂未发货".equals(factoryShipStatus)) {
+ factoryOrderEntity.setFactoryShipStatus(0);
+ } else if ("工厂部分发货".equals(factoryShipStatus)) {
+ factoryOrderEntity.setFactoryShipStatus(1);
+ } else if ("工厂齐套发货".equals(factoryShipStatus)) {
+ factoryOrderEntity.setFactoryShipStatus(2);
+ }
+ factoryOrderEntity.setFactorySendQty(orderEntity.getInteger("FactorySendQty"));
+
+ String warehouseReceiveStatus = orderEntity.getString("WarehouseReceiveStatus");
+ if ("仓库未收货".equals(warehouseReceiveStatus)) {
+ factoryOrderEntity.setWarehouseReceiveStatus(0);
+ } else if ("仓库部分收货".equals(warehouseReceiveStatus)) {
+ factoryOrderEntity.setWarehouseReceiveStatus(1);
+ } else if ("仓库全部收货".equals(warehouseReceiveStatus)) {
+ factoryOrderEntity.setWarehouseReceiveStatus(2);
+ }
+ factoryOrderEntity.setWarehouseReceiveQty(orderEntity.getInteger("WarehouseReceiveQty"));
- }
+ String reservationStatus = orderEntity.getString("ReservationStatus");
+ if ("不可预约".equals(reservationStatus)) {
+ factoryOrderEntity.setReservationStatus(0);
+ } else if ("可预约".equals(reservationStatus)) {
+ factoryOrderEntity.setReservationStatus(1);
+ }
- factoryOrderEntity.setMatingCode(orderEntity.getString("MatingCode"));
- Boolean isMating = orderEntity.getBoolean("IsMating");
- if (isMating) {
- factoryOrderEntity.setIsMating(1);
- } else {
- factoryOrderEntity.setIsMating(0);
- }
- factoryOrderEntity.setFirstClassCode(orderEntity.getString("FirstClassCode"));
- Boolean leave = orderEntity.getBoolean("Leave");
- if (leave) {
- factoryOrderEntity.setLeaveStatus(1);
- } else {
- factoryOrderEntity.setLeaveStatus(0);
- }
- factoryOrderEntity.setCustomer(orderEntity.getString("Customer"));
- factoryOrderEntity.setProvince(orderEntity.getString("Province"));
- factoryOrderEntity.setCity(orderEntity.getString("City"));
- factoryOrderEntity.setCustomerAddress(orderEntity.getString("CustomerAddress"));
- factoryOrderEntity.setCustomerPhone(orderEntity.getString("CustomerPhone"));
- factoryOrderEntity.setShopReceiver(orderEntity.getString("ShopReceiver"));
- factoryOrderEntity.setBrandCode(orderEntity.getString("BrandCode"));
- factoryOrderEntity.setBrandName(orderEntity.getString("BrandName"));
- factoryOrderEntity.setFirstShipTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstShipTime")));
- factoryOrderEntity.setMatingShipTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingShipTime")));
- factoryOrderEntity.setFirstReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstReceiveTime")));
- factoryOrderEntity.setMatingReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingReceiveTime")));
- Boolean freeze = orderEntity.getBoolean("Freeze");
- if (freeze) {
- factoryOrderEntity.setFreeze(1);
- } else {
- factoryOrderEntity.setFreeze(0);
- }
- factoryOrderEntity.setOutGoingTime(CommonUtil.StringToDateByT(orderEntity.getString("OutGoingTime")));
- factoryOrderEntity.setStatus(0);
- factoryOrderEntity.setReceivingId(receivingId);
- factoryOrderEntity.setReceiptStatus(0);
- factoryOrderEntity.setPushStatus(0);
- factoryOrderEntity.setTurnStatus(0);
- //
- boolean save = factoryOrderService.save(factoryOrderEntity);
- if (!save) {
- log.error("############handleData: 保存订单失败 selfCode={}", selfCode);
- throw new CustomerException(403, "保存订单失败");
- }
+ JSONObject store = orderEntity.getJSONObject("Store");
+ if (!Objects.isNull(store)) {
+ factoryOrderEntity.setStoreCode(store.getString("Code"));
+ factoryOrderEntity.setStoreName(store.getString("Name"));
+ JSONObject shop = store.getJSONObject("Shop");
+ if (!Objects.isNull(shop)) {
+ factoryOrderEntity.setShopCode(shop.getString("Code"));
+ factoryOrderEntity.setShopName(shop.getString("Name"));
+ factoryOrderEntity.setBusinessModel(shop.getString("BusinessModel"));
}
- //保存订单成功,继续保存包件
- Long orderId = factoryOrderEntity.getId();
- String packageCode = packageEntity.getString("Code");
- LambdaQueryWrapper packageEntityQueryWrapper = new LambdaQueryWrapper<>();
- packageEntityQueryWrapper.eq(FactoryPackageEntity::getCode, packageCode);
-
- FactoryPackageEntity factoryPackageEntity = factoryPackageService.getOne(packageEntityQueryWrapper);
-
- if (Objects.isNull(factoryPackageEntity)) {
- factoryPackageEntity = new FactoryPackageEntity();
- factoryPackageEntity.setOrderId(orderId);
- factoryPackageEntity.setCode(packageCode);
- factoryPackageEntity.setOid(packageEntity.getString("Oid"));
- factoryPackageEntity.setFirstClassCode(packageEntity.getString("FirstClassCode"));
- factoryPackageEntity.setFirstClassName(packageEntity.getString("FirstClassName"));
- factoryPackageEntity.setSecondClassCode(packageEntity.getString("SecondClassCode"));
- factoryPackageEntity.setSecondClassName(packageEntity.getString("SecondClassName"));
- factoryPackageEntity.setThirdClassCode(packageEntity.getString("ThirdClassCode"));
- factoryPackageEntity.setThirdClassName(packageEntity.getString("ThirdClassName"));
- factoryPackageEntity.setPackageDetailNames(packageEntity.getString("PackageDetailNames"));
- factoryPackageEntity.setCarNumber(packageEntity.getString("CarNumber"));
- factoryPackageEntity.setReserve1(factoryOrderEntity.getCode());
- Boolean buyIn = packageEntity.getBoolean("BuyIn");
- if (buyIn) {
- factoryPackageEntity.setBuyin(1);
- } else {
- factoryPackageEntity.setBuyin(0);
- }
- factoryPackageEntity.setCosourcingCode(packageEntity.getString("CosourcingCode"));
- factoryPackageEntity.setCosourcingUnit(packageEntity.getString("CosourcingUnit"));
- String packageStatus = packageEntity.getString("PackageStatus");
- //未知:0 已调度:1 已装车:2 待收货:3 已收货:4 已在库:5 待理货:6 待上架:7 已上架:8 已下架:9 已发运:10 已签收:11 待返货:12 已提件:13 已拒收:14 异常:-1
- if ("已调度".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(1);
- } else if ("已装车".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(2);
- } else if ("待收货".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(3);
- } else if ("已收货".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(4);
- } else if ("已在库".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(5);
- } else if ("待理货".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(6);
- } else if ("待上架".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(7);
- } else if ("已上架".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(8);
- } else if ("已下架".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(9);
- } else if ("已发运".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(10);
- } else if ("已签收".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(11);
- } else if ("待返货".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(12);
- } else if ("已提件".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(13);
- } else if ("已拒收".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(14);
- } else if ("异常".equals(packageStatus)) {
- factoryPackageEntity.setPackageStatus(-1);
- } else {
- factoryPackageEntity.setPackageStatus(0);
- }
- factoryPackageEntity.setLength(packageEntity.getBigDecimal("Length"));
- factoryPackageEntity.setWidth(packageEntity.getBigDecimal("Width"));
- factoryPackageEntity.setHeight(packageEntity.getBigDecimal("Height"));
- factoryPackageEntity.setWeight(packageEntity.getBigDecimal("Weight"));
- Boolean isInventory = packageEntity.getBoolean("IsInventory");
- if (isInventory) {
- factoryPackageEntity.setIsInventory(1);
- } else {
- factoryPackageEntity.setIsInventory(0);
- }
- Boolean packageFreeze = packageEntity.getBoolean("Freeze");
- if (packageFreeze) {
- factoryPackageEntity.setFreeze(1);
- } else {
- factoryPackageEntity.setFreeze(0);
- }
+ }
- //保存包件信息
- factoryPackageEntity.setReceiptStatus(0);
- factoryPackageEntity.setPushStatus(0);
- factoryPackageEntity.setTurnStatus(0);
- boolean packageSave = factoryPackageService.save(factoryPackageEntity);
- if (packageSave) {
- Long packageId = factoryPackageEntity.getId();
- //保存物料信息
- JSONArray packageDetails = packageEntity.getJSONArray("PackageDetails");
- if (!Objects.isNull(packageDetails)) {
- for (int k = 0; k < packageDetails.size(); k++) {
- JSONObject packageDetailsJSONObject = packageDetails.getJSONObject(k);
- FactoryPackageDetailEntity factoryPackageDetailEntity = new FactoryPackageDetailEntity();
- factoryPackageDetailEntity.setPackageId(packageId);
- factoryPackageDetailEntity.setCode(packageDetailsJSONObject.getString("Code"));
- factoryPackageDetailEntity.setName(packageDetailsJSONObject.getString("Name"));
- factoryPackageDetailEntity.setType(packageDetailsJSONObject.getString("Type"));
- factoryPackageDetailEntity.setUnit(packageDetailsJSONObject.getString("Unit"));
- factoryPackageDetailEntity.setOrgCode(packageDetailsJSONObject.getString("OrgCode"));
- factoryPackageDetailService.save(factoryPackageDetailEntity);
- }
- }
- }
- } else {
+ factoryOrderEntity.setMatingCode(orderEntity.getString("MatingCode"));
+ Boolean isMating = orderEntity.getBoolean("IsMating");
+ if (isMating) {
+ factoryOrderEntity.setIsMating(1);
+ } else {
+ factoryOrderEntity.setIsMating(0);
+ }
+ factoryOrderEntity.setFirstClassCode(orderEntity.getString("FirstClassCode"));
+ Boolean leave = orderEntity.getBoolean("Leave");
+ if (leave) {
+ factoryOrderEntity.setLeaveStatus(1);
+ } else {
+ factoryOrderEntity.setLeaveStatus(0);
+ }
+ factoryOrderEntity.setCustomer(orderEntity.getString("Customer"));
+ factoryOrderEntity.setProvince(orderEntity.getString("Province"));
+ factoryOrderEntity.setCity(orderEntity.getString("City"));
+ factoryOrderEntity.setCustomerAddress(orderEntity.getString("CustomerAddress"));
+ factoryOrderEntity.setCustomerPhone(orderEntity.getString("CustomerPhone"));
+ factoryOrderEntity.setShopReceiver(orderEntity.getString("ShopReceiver"));
+ factoryOrderEntity.setBrandCode(orderEntity.getString("BrandCode"));
+ factoryOrderEntity.setBrandName(orderEntity.getString("BrandName"));
+ factoryOrderEntity.setFirstShipTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstShipTime")));
+ factoryOrderEntity.setMatingShipTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingShipTime")));
+ factoryOrderEntity.setFirstReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("FirstReceiveTime")));
+ factoryOrderEntity.setMatingReceiveTime(CommonUtil.StringToDateByT(orderEntity.getString("MatingReceiveTime")));
+ Boolean freeze = orderEntity.getBoolean("Freeze");
+ if (freeze) {
+ factoryOrderEntity.setFreeze(1);
+ } else {
+ factoryOrderEntity.setFreeze(0);
+ }
+ factoryOrderEntity.setOutGoingTime(CommonUtil.StringToDateByT(orderEntity.getString("OutGoingTime")));
+ factoryOrderEntity.setStatus(0);
+ factoryOrderEntity.setReceivingId(receivingId);
+ factoryOrderEntity.setReceiptStatus(0);
+ factoryOrderEntity.setPushStatus(0);
+ factoryOrderEntity.setTurnStatus(0);
+ //
+ boolean save = factoryOrderService.save(factoryOrderEntity);
+ if (!save) {
+ log.error("############handleData: 保存订单失败 selfCode={}", selfCode);
+ throw new CustomerException(403, "保存订单失败");
+ }
+ }
- log.error("############handleData: 包件码已存在 packageCode={} 收货单号 {}", packageCode,code);
+ //保存订单成功,继续保存包件
+ Long orderId = factoryOrderEntity.getId();
+ String packageCode = packageEntity.getString("Code");
+ LambdaQueryWrapper packageEntityQueryWrapper = new LambdaQueryWrapper<>();
+ packageEntityQueryWrapper.eq(FactoryPackageEntity::getCode, packageCode);
+
+ FactoryPackageEntity factoryPackageEntity = factoryPackageService.getOne(packageEntityQueryWrapper);
+
+ if (Objects.isNull(factoryPackageEntity)) {
+ log.info(" oupai 收货单ID{} 收货单下面的包件不存在 进行新增订单 {} 关联包件 {}", receivingId, selfCode, packageCode);
+
+ factoryPackageEntity = new FactoryPackageEntity();
+ factoryPackageEntity.setOrderId(orderId);
+ factoryPackageEntity.setCode(packageCode);
+ factoryPackageEntity.setOid(packageEntity.getString("Oid"));
+ factoryPackageEntity.setFirstClassCode(packageEntity.getString("FirstClassCode"));
+ factoryPackageEntity.setFirstClassName(packageEntity.getString("FirstClassName"));
+ factoryPackageEntity.setSecondClassCode(packageEntity.getString("SecondClassCode"));
+ factoryPackageEntity.setSecondClassName(packageEntity.getString("SecondClassName"));
+ factoryPackageEntity.setThirdClassCode(packageEntity.getString("ThirdClassCode"));
+ factoryPackageEntity.setThirdClassName(packageEntity.getString("ThirdClassName"));
+ factoryPackageEntity.setPackageDetailNames(packageEntity.getString("PackageDetailNames"));
+ factoryPackageEntity.setCarNumber(packageEntity.getString("CarNumber"));
+ factoryPackageEntity.setReserve1(factoryOrderEntity.getCode());
+ Boolean buyIn = packageEntity.getBoolean("BuyIn");
+ if (buyIn) {
+ factoryPackageEntity.setBuyin(1);
+ } else {
+ factoryPackageEntity.setBuyin(0);
+ }
+ factoryPackageEntity.setCosourcingCode(packageEntity.getString("CosourcingCode"));
+ factoryPackageEntity.setCosourcingUnit(packageEntity.getString("CosourcingUnit"));
+ String packageStatus = packageEntity.getString("PackageStatus");
+ //未知:0 已调度:1 已装车:2 待收货:3 已收货:4 已在库:5 待理货:6 待上架:7 已上架:8 已下架:9 已发运:10 已签收:11 待返货:12 已提件:13 已拒收:14 异常:-1
+ if ("已调度".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(1);
+ } else if ("已装车".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(2);
+ } else if ("待收货".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(3);
+ } else if ("已收货".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(4);
+ } else if ("已在库".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(5);
+ } else if ("待理货".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(6);
+ } else if ("待上架".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(7);
+ } else if ("已上架".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(8);
+ } else if ("已下架".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(9);
+ } else if ("已发运".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(10);
+ } else if ("已签收".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(11);
+ } else if ("待返货".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(12);
+ } else if ("已提件".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(13);
+ } else if ("已拒收".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(14);
+ } else if ("异常".equals(packageStatus)) {
+ factoryPackageEntity.setPackageStatus(-1);
+ } else {
+ factoryPackageEntity.setPackageStatus(0);
+ }
+ factoryPackageEntity.setLength(packageEntity.getBigDecimal("Length"));
+ factoryPackageEntity.setWidth(packageEntity.getBigDecimal("Width"));
+ factoryPackageEntity.setHeight(packageEntity.getBigDecimal("Height"));
+ factoryPackageEntity.setWeight(packageEntity.getBigDecimal("Weight"));
+ Boolean isInventory = packageEntity.getBoolean("IsInventory");
+ if (isInventory) {
+ factoryPackageEntity.setIsInventory(1);
+ } else {
+ factoryPackageEntity.setIsInventory(0);
+ }
+ Boolean packageFreeze = packageEntity.getBoolean("Freeze");
+ if (packageFreeze) {
+ factoryPackageEntity.setFreeze(1);
+ } else {
+ factoryPackageEntity.setFreeze(0);
+ }
- //throw new CustomerException(403, "包件码已存在");
+ //保存包件信息
+ factoryPackageEntity.setReceiptStatus(0);
+ factoryPackageEntity.setPushStatus(0);
+ factoryPackageEntity.setTurnStatus(0);
+ boolean packageSave = factoryPackageService.save(factoryPackageEntity);
+ if (packageSave) {
+ Long packageId = factoryPackageEntity.getId();
+ //保存物料信息
+ JSONArray packageDetails = packageEntity.getJSONArray("PackageDetails");
+ if (!Objects.isNull(packageDetails)) {
+ for (int k = 0; k < packageDetails.size(); k++) {
+ JSONObject packageDetailsJSONObject = packageDetails.getJSONObject(k);
+ FactoryPackageDetailEntity factoryPackageDetailEntity = new FactoryPackageDetailEntity();
+ factoryPackageDetailEntity.setPackageId(packageId);
+ factoryPackageDetailEntity.setCode(packageDetailsJSONObject.getString("Code"));
+ factoryPackageDetailEntity.setName(packageDetailsJSONObject.getString("Name"));
+ factoryPackageDetailEntity.setType(packageDetailsJSONObject.getString("Type"));
+ factoryPackageDetailEntity.setUnit(packageDetailsJSONObject.getString("Unit"));
+ factoryPackageDetailEntity.setOrgCode(packageDetailsJSONObject.getString("OrgCode"));
+ factoryPackageDetailService.save(factoryPackageDetailEntity);
+ }
}
}
} else {
- log.error("############handleData: 保存发货单数据失败 code={}", code);
- throw new CustomerException(403, "保存发货单数据失败");
+
+ String receiveCode = receivingOrderMapper.selectReceivingOrderByOrderId(factoryPackageEntity.getOrderId());
+
+ if(receiveCode.equals(code)){
+ log.error("############handleData: 包件码已存在 packageCode={} ,订单 id {} 收货单号 {}", packageCode, factoryPackageEntity.getOrderId(), code);
+
+ }else{
+ log.error("############handleData: 该包件存在于其它收货单 packageCode={} 订单ID {} 收货单号 {}", packageCode,factoryPackageEntity.getOrderId(), receiveCode);
+ }
+
+ //throw new CustomerException(403, "包件码已存在");
}
- Date end = new Date();
- long startLong = start.getTime();
- long endLong = end.getTime();
- long l = endLong - startLong;
- log.info("############handleData: 数据处理完成 耗时 {} 毫秒", l);
}
-
}
@@ -980,6 +1081,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
*/
private OpOrderStatusLogEntity findOurPaiDataByCarNumber(String code) {
+
String url = ouPaiProperties.getUri() + "tims_odata_api/api/odata/ReceivingOrder?$filter=Code eq '" + code + "'&select=Code,Type,Status,Plate,PackagesCount,ReceivePackageCount,PlateNum,CarNumber,CarrierCode,SendTime,ArrivalTime,ReceiveTime,CreateTime,ReturnNumber\n" +
"&$expand=" +
"Packages($select=Oid,Code,PdaNumber,FirstClassCode,FirstClassName,SecondClassCode,SecondClassName,ThirdClassCode,ThirdClassName,BuyIn,CosourcingCode,CosourcingUnit,SortingCenter,DistributionCenter,Length,Width,Height,Weight,OrderDetail,Order,PathIndex,PathDetail,DeliveryOrders,ReceivingOrders,LPN,LpnSerialNum,IsEntruck,ReservationOrder,OutGoingOrderDetail,SignBill,IsInventory,Inventories,InventoryInDetails,Freeze,OutGoingOrderDetailInventoryDetail,From,Creator,CreateTime,ShipTime,CarNumber,DeliveryMethod,DeliveryReceiver,DeliveryReceiverPhone,ReturnNumber,GroupType,CarrierCode,CarrierName,PackageDetailNames,ReceivingTime,SendTime,ExceptionSignRemark,Descript,SignTime,OutOrder,IsReceiveByHand,PackageStatus,PackageDetailNames;" +