|
|
|
@ -4,13 +4,20 @@ import cn.hutool.http.HttpRequest;
|
|
|
|
|
import cn.hutool.http.HttpResponse; |
|
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; |
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils; |
|
|
|
|
import com.logpm.factory.comfac.constant.FactoryConstant; |
|
|
|
|
import com.logpm.factory.comfac.dto.OrderStatusDTO; |
|
|
|
|
import com.logpm.factory.comfac.service.IAsyncDataService; |
|
|
|
|
import com.logpm.factory.oupai.entity.*; |
|
|
|
|
import com.logpm.factory.oupai.mapper.ReceivingOrderMapper; |
|
|
|
|
import com.logpm.factory.oupai.service.*; |
|
|
|
|
import com.logpm.factory.props.OuPaiProperties; |
|
|
|
|
import com.logpm.factory.snm.bean.Resp; |
|
|
|
|
import com.logpm.oldproject.feign.IAdvanceClient; |
|
|
|
|
import com.logpm.oldproject.feign.IAdvanceDetailClient; |
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
|
import org.apache.commons.fileupload.FileItem; |
|
|
|
|
import org.apache.commons.fileupload.disk.DiskFileItemFactory; |
|
|
|
@ -22,6 +29,7 @@ import org.springblade.common.utils.CommonUtil;
|
|
|
|
|
import org.springblade.common.utils.FileLogsUtil; |
|
|
|
|
import org.springblade.core.oss.model.BladeFile; |
|
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
|
import org.springblade.core.tool.utils.StringUtil; |
|
|
|
|
import org.springblade.resource.feign.IOssClient; |
|
|
|
|
import org.springframework.amqp.rabbit.core.RabbitTemplate; |
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
@ -69,6 +77,15 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
@Autowired |
|
|
|
|
private IOssClient ossClient; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IAdvanceClient advanceClient; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IAdvanceDetailClient advanceDetailClient; |
|
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
private IOpPackagePushLogService opPackagePushLogService; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String saveOuPaiFactoryOrderDTOByCarCarNumber(String code) { |
|
|
|
@ -136,14 +153,14 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
QueryWrapper<FactoryPackageEntity> queryWrapper = new QueryWrapper<>(); |
|
|
|
|
queryWrapper.eq("oid", key); |
|
|
|
|
FactoryPackageEntity packageEntity = factoryPackageService.getOne(queryWrapper); |
|
|
|
|
String code=null; |
|
|
|
|
String code = null; |
|
|
|
|
String endWarehouseName = null; |
|
|
|
|
String opShipNo=null; |
|
|
|
|
String orderSelfNum =null; |
|
|
|
|
String carNumber=null; |
|
|
|
|
String opShipNo = null; |
|
|
|
|
String orderSelfNum = null; |
|
|
|
|
String carNumber = null; |
|
|
|
|
String siteName = null; |
|
|
|
|
String packageDetailNames = null; |
|
|
|
|
String firstPackName,secondPackName,thirdPackName = null; |
|
|
|
|
String firstPackName, secondPackName, thirdPackName = null; |
|
|
|
|
if (Objects.isNull(packageEntity)) { |
|
|
|
|
log.warn("############oid 查询数据失败: {}", key); |
|
|
|
|
// 查询欧派系统的的数据
|
|
|
|
@ -160,31 +177,31 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
secondPackName = jsonObject.getString("SecondPackName"); |
|
|
|
|
thirdPackName = jsonObject.getString("ThirdPackName"); |
|
|
|
|
|
|
|
|
|
if(isInventory){ |
|
|
|
|
if (isInventory) { |
|
|
|
|
log.warn("############库存品数据 不进行推送: {}", code); |
|
|
|
|
return key; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject order = jsonObject.getJSONObject("Order"); |
|
|
|
|
if (order != null){ |
|
|
|
|
if (order != null) { |
|
|
|
|
orderSelfNum = order.getString("SelfCode"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONArray ls = jsonObject.getJSONArray("ReceivingOrders"); |
|
|
|
|
if(ls!=null&& !ls.isEmpty()){ |
|
|
|
|
if (ls != null && !ls.isEmpty()) { |
|
|
|
|
JSONObject t = ls.getJSONObject(0); |
|
|
|
|
if(t!=null){ |
|
|
|
|
if (t != null) { |
|
|
|
|
opShipNo = t.getString("Code"); |
|
|
|
|
JSONObject endWarehouse = t.getJSONObject("EndWarehouse"); |
|
|
|
|
log.info("############仓库对象: endWarehouse={}",endWarehouse); |
|
|
|
|
log.info("############仓库对象: endWarehouse={}", endWarehouse); |
|
|
|
|
endWarehouseName = endWarehouse.getString("Name"); |
|
|
|
|
|
|
|
|
|
JSONObject fromWarehouse = t.getJSONObject("FromWarehouse"); |
|
|
|
|
log.info("############基地对象: fromWarehouse={}",fromWarehouse); |
|
|
|
|
log.info("############基地对象: fromWarehouse={}", fromWarehouse); |
|
|
|
|
siteName = fromWarehouse.getString("Name"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
}else{ |
|
|
|
|
} else { |
|
|
|
|
log.warn("############没有收货单oid:{}", key); |
|
|
|
|
return key; |
|
|
|
|
} |
|
|
|
@ -193,7 +210,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
packageEntity.setPackageStatus(5); |
|
|
|
|
factoryPackageService.updateById(packageEntity); |
|
|
|
|
code = packageEntity.getCode(); |
|
|
|
|
packageDetailNames =packageEntity.getPackageDetailNames(); |
|
|
|
|
packageDetailNames = packageEntity.getPackageDetailNames(); |
|
|
|
|
|
|
|
|
|
firstPackName = packageEntity.getFirstClassName(); |
|
|
|
|
secondPackName = packageEntity.getSecondClassName(); |
|
|
|
@ -293,6 +310,89 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
return orderCode; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public R handleStatusData(OrderStatusDTO orderStatusDTO) { |
|
|
|
|
|
|
|
|
|
// 推送数据
|
|
|
|
|
String status = orderStatusDTO.getStatus(); |
|
|
|
|
String unitNo = orderStatusDTO.getUnitNo(); |
|
|
|
|
String operationTime = orderStatusDTO.getOperationTime(); |
|
|
|
|
if ("1".equals(status) || "2".equals(status) || "3".equals(status) || "5".equals(status) || "6".equals(status) || "7".equals(status) || "8".equals(status) || "9".equals(status)) { |
|
|
|
|
log.warn(FactoryConstant.OUPAI,"#############oupai-handleStatusData: 当前数据的状态不推送 status={}", status); |
|
|
|
|
return Resp.fail(400, "当前数据的状态不推送"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
//继续判断是否到达目的仓
|
|
|
|
|
String currentWarehouseId = orderStatusDTO.getCurrentWarehouse();//当前仓Id
|
|
|
|
|
//查询destinationWarehouse logiBillNo plantId数据
|
|
|
|
|
log.info("oupai-handleStatusData >>> unitNo={}", unitNo); |
|
|
|
|
Map<String, String> 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(FactoryConstant.OUPAI,"##############oupai-handleStatusData: 仓库数据有问题currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId); |
|
|
|
|
return Resp.fail(400, "仓库数据有误"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!currentWarehouseId.equals(destinationWarehouseId)) { |
|
|
|
|
log.info(FactoryConstant.OUPAI,"##############oupai-handleStatusData: 不用处理的状态 currentWarehouseId={} destinationWarehouseId={}", currentWarehouseId, destinationWarehouseId); |
|
|
|
|
return Resp.fail(400, "不是目的仓"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 查询这个包件对应到新系统的订单
|
|
|
|
|
FactoryOrderEntity factoryOrder = factoryOrderService.selectEntityByOrderPackageCode(unitNo); |
|
|
|
|
|
|
|
|
|
if (Objects.isNull(factoryOrder)) { |
|
|
|
|
return Resp.fail(400, "未查询到该单据推送订单信息"); |
|
|
|
|
} |
|
|
|
|
// 如何判断这个包间是非干仓配的数据
|
|
|
|
|
|
|
|
|
|
if (!"经销商".equals(factoryOrder.getBusinessModel())) { |
|
|
|
|
log.info(FactoryConstant.OUPAI,"oupai- 该包条为干仓配的数据类型 不进行推送 >>> unitNo={} businessModel:{}", unitNo, factoryOrder.getBusinessModel()); |
|
|
|
|
return Resp.fail(400, "包条为干仓配的数据类型"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 通过仓库编码查询
|
|
|
|
|
ReceivingOrderEntity receivingOrderEntity = receivingOrderMapper.selectById(factoryOrder.getReceivingId()); |
|
|
|
|
|
|
|
|
|
if (Objects.isNull(receivingOrderEntity)) { |
|
|
|
|
log.info(FactoryConstant.OUPAI,"oupai- 该订单为没有收货单 不进行推送 >>> receivingId={} ", factoryOrder.getReceivingId()); |
|
|
|
|
return Resp.fail(400, "未查询到该单据推送收货单信息"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
JSONObject detailObject = new JSONObject(); |
|
|
|
|
detailObject.put("WarehouseOid", receivingOrderEntity.getEndWarehouseOid()); |
|
|
|
|
detailObject.put("WarehouseBelong", "oppein"); |
|
|
|
|
detailObject.put("Creator", orderStatusDTO.getUsername()); |
|
|
|
|
detailObject.put("PackageCode", unitNo); |
|
|
|
|
detailObject.put("Operate", "到货"); |
|
|
|
|
|
|
|
|
|
// 查询系统的包件对象
|
|
|
|
|
LambdaQueryWrapper<FactoryPackageEntity> lambdaQueryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
lambdaQueryWrapper.eq(FactoryPackageEntity::getCode,unitNo); |
|
|
|
|
FactoryPackageEntity factoryPackageEntity = factoryPackageService.getOne(lambdaQueryWrapper); |
|
|
|
|
if(ObjectUtils.isNotNull(factoryPackageEntity)){ |
|
|
|
|
// 推送数据
|
|
|
|
|
String url = ouPaiProperties.getUri()+"tims_odata_api/api/odata/PackageFeedbackRecord"; |
|
|
|
|
OpPackagePushLogEntity opPackagePushLogEntity = sendPushOuPaiData(factoryPackageEntity.getId(), url, 1, detailObject); |
|
|
|
|
// 需要盘点这个对象的
|
|
|
|
|
String resp = opPackagePushLogEntity.getResp(); |
|
|
|
|
// 转换为json
|
|
|
|
|
// JSONObject respJson = JSONObject.parseObject(resp);
|
|
|
|
|
log.info(FactoryConstant.OUPAI,">>>>>>>>>>>>>>>>>>>>>>> 推送欧派返回数据 {}", resp); |
|
|
|
|
// TODO: 2023/10/25 不知道返回成功的状态是多少
|
|
|
|
|
|
|
|
|
|
// 需要修改包件对应的状态
|
|
|
|
|
factoryPackageEntity.setPushStatus(1); |
|
|
|
|
factoryPackageService.updateById(factoryPackageEntity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return Resp.success("物流状态传递成功"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void handleSignBillData(String url, Integer event) { |
|
|
|
|
OpOrderStatusLogEntity opOrderStatusLogEntity = sendRequestData(url, event); |
|
|
|
|
|
|
|
|
@ -319,7 +419,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
try { |
|
|
|
|
rabbitTemplate.convertAndSend(RabbitConstant.OUPAI_SIGN_EXCHANGE, RabbitConstant.OUPAI_SIGN_ROUTING, map); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("############handlePackageData: {}", e.getMessage()); |
|
|
|
|
log.error(FactoryConstant.OUPAI,"############handlePackageData: {}", e.getMessage()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -368,15 +468,12 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
|
|
|
|
|
private OpOrderStatusLogEntity sendRequestData(String url, Integer event) { |
|
|
|
|
// log.info("#################sendRequestData: 请求地址 url={}", url);
|
|
|
|
|
|
|
|
|
|
String token = buildToken(); |
|
|
|
|
// log.info(">>> Authorization token {}",token);
|
|
|
|
|
|
|
|
|
|
HttpResponse httpResponse = HttpRequest.get(url).header("Authorization", token).execute(); |
|
|
|
|
|
|
|
|
|
String result = httpResponse.body(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
OpOrderStatusLogEntity orderStatusLog = new OpOrderStatusLogEntity(); |
|
|
|
|
orderStatusLog.setArgs(url); |
|
|
|
|
orderStatusLog.setStatus(1); |
|
|
|
@ -387,10 +484,29 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
orderStatusLog.setResponseUrl(uploadFile(result)); |
|
|
|
|
opOrderStatusLogService.save(orderStatusLog); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return orderStatusLog; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发送请求 |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
private OpPackagePushLogEntity sendPushOuPaiData(Long refId, String url, Integer pushType, JSONObject data) { |
|
|
|
|
OpPackagePushLogEntity opPackagePushLogEntity = new OpPackagePushLogEntity(); |
|
|
|
|
opPackagePushLogEntity.setArgs(data.toJSONString()); |
|
|
|
|
opPackagePushLogEntity.setPushType(pushType); |
|
|
|
|
opPackagePushLogEntity.setUrl(url); |
|
|
|
|
opPackagePushLogEntity.setRefId(refId); |
|
|
|
|
|
|
|
|
|
String token = buildToken(); |
|
|
|
|
HttpResponse httpResponse = HttpRequest.post(url).header("Authorization", token).body(data.toJSONString()).execute(); |
|
|
|
|
String result = httpResponse.body(); |
|
|
|
|
opPackagePushLogEntity.setResp(result); |
|
|
|
|
opPackagePushLogService.save(opPackagePushLogEntity); |
|
|
|
|
return opPackagePushLogEntity; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 处理返回的JSON数据 |
|
|
|
@ -448,14 +564,17 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
receivingOrderEntity.setType(0); |
|
|
|
|
} |
|
|
|
|
if (!Objects.isNull(currentWarehouse)) { |
|
|
|
|
receivingOrderEntity.setCurrentWarehouseOid(currentWarehouse.getString("Oid")); |
|
|
|
|
receivingOrderEntity.setCurrentWarehouseCode(currentWarehouse.getString("Code")); |
|
|
|
|
receivingOrderEntity.setCurrentWarehouseName(currentWarehouse.getString("Name")); |
|
|
|
|
} |
|
|
|
|
if (!Objects.isNull(fromWarehouse)) { |
|
|
|
|
receivingOrderEntity.setFromWarehouseOid(fromWarehouse.getString("Oid")); |
|
|
|
|
receivingOrderEntity.setFromWarehouseCode(fromWarehouse.getString("Code")); |
|
|
|
|
receivingOrderEntity.setCurrentWarehouseName(fromWarehouse.getString("Name")); |
|
|
|
|
receivingOrderEntity.setFromWarehouseName(fromWarehouse.getString("Name")); |
|
|
|
|
} |
|
|
|
|
if (!Objects.isNull(endWarehouse)) { |
|
|
|
|
receivingOrderEntity.setEndWarehouseOid(endWarehouse.getString("Oid")); |
|
|
|
|
receivingOrderEntity.setEndWarehouseCode(endWarehouse.getString("Code")); |
|
|
|
|
receivingOrderEntity.setEndWarehouseName(endWarehouse.getString("Name")); |
|
|
|
|
} |
|
|
|
@ -552,6 +671,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
if (!Objects.isNull(shop)) { |
|
|
|
|
factoryOrderEntity.setShopCode(shop.getString("Code")); |
|
|
|
|
factoryOrderEntity.setShopName(shop.getString("Name")); |
|
|
|
|
factoryOrderEntity.setBusinessModel(shop.getString("BusinessModel")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
@ -736,7 +856,7 @@ public class OuPaiFactoryServiceImpl implements IOuPaiFactoryService {
|
|
|
|
|
"&$expand=PackageDetails($select=Code,Name,Type,Unit,OrgCode)" + |
|
|
|
|
"&$expand=CurrentWarehouse($select=Name,Code)" + |
|
|
|
|
"&$expand=SendWarehouse($select=Name,Code)" + |
|
|
|
|
")&$expand=FromWarehouse($select=Name,Code)&$expand=CurrentWarehouse($select=Name,Code)&$expand=EndWarehouse($select=Name,Code)"; |
|
|
|
|
")&$expand=FromWarehouse($select=Oid,Name,Code)&$expand=CurrentWarehouse($select=Oid,Name,Code)&$expand=EndWarehouse($select=Oid,Name,Code)"; |
|
|
|
|
|
|
|
|
|
// log.info(">>> findOurPaiDataByCarNumber url {}", url);
|
|
|
|
|
|
|
|
|
|