|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
package com.logpm.factorydata.olo.service.impl; |
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
|
import cn.hutool.core.collection.CollUtil; |
|
|
|
|
import cn.hutool.core.convert.Convert; |
|
|
|
|
import cn.hutool.core.date.DateUtil; |
|
|
|
|
import cn.hutool.core.io.FileUtil; |
|
|
|
|
import cn.hutool.core.util.NumberUtil; |
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
import cn.hutool.core.util.StrUtil; |
|
|
|
|
import cn.hutool.http.HttpUtil; |
|
|
|
@ -16,10 +18,12 @@ import com.logpm.factorydata.enums.BrandEnums;
|
|
|
|
|
import com.logpm.factorydata.enums.SaxStatusEnums; |
|
|
|
|
import com.logpm.factorydata.feign.IFactoryDataClient; |
|
|
|
|
import com.logpm.factorydata.olo.entity.DeliveryNoteEntity; |
|
|
|
|
import com.logpm.factorydata.olo.entity.FactoryNodeAllPushEntity; |
|
|
|
|
import com.logpm.factorydata.olo.entity.FactoryOrderLogEntity; |
|
|
|
|
import com.logpm.factorydata.olo.mapper.DeliveryNoteMapper; |
|
|
|
|
import com.logpm.factorydata.olo.pros.OldProperties; |
|
|
|
|
import com.logpm.factorydata.olo.service.DeliveryNoteService; |
|
|
|
|
import com.logpm.factorydata.olo.service.FactoryNodeAllPushService; |
|
|
|
|
import com.logpm.factorydata.olo.service.FactoryOrderLogService; |
|
|
|
|
import com.logpm.factorydata.olo.vo.DeliveryNoteVO; |
|
|
|
|
import com.logpm.factorydata.vo.SendMsg; |
|
|
|
@ -54,8 +58,11 @@ import java.time.LocalDateTime;
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.Date; |
|
|
|
|
import java.util.HashMap; |
|
|
|
|
import java.util.HashSet; |
|
|
|
|
import java.util.List; |
|
|
|
|
import java.util.Map; |
|
|
|
|
import java.util.Set; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 发货单 业务实现类 |
|
|
|
@ -74,6 +81,7 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
|
|
|
|
|
private final IFactoryDataBaseClient baseClient; |
|
|
|
|
private final OldProperties oldProperties; |
|
|
|
|
private final RabbitTemplate rabbitTemplate; |
|
|
|
|
private final FactoryNodeAllPushService factoryNodeAllPushService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String order(List<DeliveryNoteVO> vo) { |
|
|
|
@ -213,7 +221,7 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
|
|
|
|
|
advanceDetailEntity.setQuantity(1); |
|
|
|
|
// 按老系统生成新的逻辑的包件号 OLO2312064418-20231226010129-1-001
|
|
|
|
|
// 标准台面全部使用新码,其他的数量大于 1 的使用新码
|
|
|
|
|
if (StrUtil.equals(orderPackageDTO.getType(),"标准台面") || anInt > 1) { |
|
|
|
|
if (StrUtil.equals(orderPackageDTO.getType(), "标准台面") || anInt > 1) { |
|
|
|
|
advanceDetailEntity.setOrderPackageCode("OLO" + orderPackageDTO.getSn() + "-" + DateUtil.format(new Date(), "yyyyMMddHHmmss") + "-" + num + "-" + StrUtil.padPre(String.valueOf(i + 1), 3, "0")); |
|
|
|
|
} else { |
|
|
|
|
advanceDetailEntity.setOrderPackageCode(orderPackageDTO.getSn()); |
|
|
|
@ -292,6 +300,148 @@ public class DeliveryNoteServiceImpl extends BaseServiceImpl<DeliveryNoteMapper,
|
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void rePushOloNodeData() { |
|
|
|
|
// 查出少推送的数据
|
|
|
|
|
FactoryNodeAllPushEntity entity = factoryNodeAllPushService.rePushOloNodeData(); |
|
|
|
|
if (ObjectUtil.isNotEmpty(entity)) { |
|
|
|
|
String content = entity.getContent(); |
|
|
|
|
Date createTime = entity.getCreateTime(); |
|
|
|
|
JSONObject entries = JSONUtil.parseObj(content); |
|
|
|
|
entries.set("snList", null); |
|
|
|
|
String packageCodes = entity.getPackageCode(); |
|
|
|
|
String[] split = packageCodes.split(","); |
|
|
|
|
Set<String> packageCodeSet = new HashSet<>(); |
|
|
|
|
for (String s : split) { |
|
|
|
|
if (StrUtil.contains(s, "补")) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
packageCodeSet.add(s); |
|
|
|
|
} |
|
|
|
|
String orderCode = entity.getOrderCode(); |
|
|
|
|
String shipmentCode = entity.getShipmentCode(); |
|
|
|
|
String shipmentSpitCode = entity.getShipmentSpitCode(); |
|
|
|
|
List<DeliveryNoteEntity> list = this.baseMapper.rePushOloNodeData(orderCode, shipmentCode, shipmentSpitCode); |
|
|
|
|
if (CollUtil.isNotEmpty(list)) { |
|
|
|
|
List<DeliveryNoteEntity> sns = list.stream().filter(s -> !packageCodeSet.contains(s.getSn())).map(deliveryNoteEntity -> { |
|
|
|
|
String sn = deliveryNoteEntity.getSn(); |
|
|
|
|
if (StrUtil.contains(sn, "补")) { |
|
|
|
|
sn = sn.split("-")[0]; |
|
|
|
|
} |
|
|
|
|
deliveryNoteEntity.setSn(sn); |
|
|
|
|
return deliveryNoteEntity; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
if (CollUtil.isNotEmpty(sns)) { |
|
|
|
|
JSONArray snArray = new JSONArray(); |
|
|
|
|
for (DeliveryNoteEntity sn : sns) { |
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
jsonObject.set("sn", sn.getSn()); |
|
|
|
|
jsonObject.set("qty", sn.getQty()); |
|
|
|
|
jsonObject.set("scanTime", DateUtil.formatDateTime(createTime)); |
|
|
|
|
snArray.add(jsonObject); |
|
|
|
|
} |
|
|
|
|
entries.set("snList", snArray); |
|
|
|
|
String post = HttpUtil.post(entity.getSendUrl(), JSONUtil.toJsonStr(entries)); |
|
|
|
|
FactoryNodeAllPushEntity pushAllEntity = new FactoryNodeAllPushEntity(); |
|
|
|
|
BeanUtil.copyProperties(entity, pushAllEntity); |
|
|
|
|
pushAllEntity.setId(null); |
|
|
|
|
try { |
|
|
|
|
JSONObject entries1 = JSONUtil.parseObj(post); |
|
|
|
|
Integer code = entries1.getInt("code"); |
|
|
|
|
String data = entries1.getStr("data"); |
|
|
|
|
// 成功
|
|
|
|
|
Integer successCode = code; |
|
|
|
|
String message = data; |
|
|
|
|
if (NumberUtil.equals(code, 200)) { |
|
|
|
|
if (StrUtil.isNotEmpty(data)) { |
|
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(data); |
|
|
|
|
Integer code1 = jsonObject.getInt("code"); |
|
|
|
|
successCode = code1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
pushAllEntity.setPackageCode(sns.stream().map(DeliveryNoteEntity::getSn).collect(Collectors.joining(","))); |
|
|
|
|
pushAllEntity.setSendStatus(successCode + ""); |
|
|
|
|
pushAllEntity.setContent(JSONUtil.toJsonStr(entries)); |
|
|
|
|
pushAllEntity.setResultContent(message); |
|
|
|
|
pushAllEntity.setReserve1(Convert.toStr(sns.size())); |
|
|
|
|
pushAllEntity.setReserve2(Convert.toStr(sns.size())); |
|
|
|
|
factoryNodeAllPushService.save(pushAllEntity); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("解析返回值失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
entity.setReserve1(entity.getReserve2()); |
|
|
|
|
factoryNodeAllPushService.updateById(entity); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void rePushOloNodeDataByCode(String param) { |
|
|
|
|
JSONObject entries = JSONUtil.parseObj(param); |
|
|
|
|
String orderCode = entries.getStr("orderCode"); |
|
|
|
|
String shipmentCode = entries.getStr("shipmentCode"); |
|
|
|
|
String shipmentSpitCode = entries.getStr("shipmentSpitCode"); |
|
|
|
|
List<DeliveryNoteEntity> list = this.baseMapper.rePushOloNodeData(orderCode, shipmentCode, shipmentSpitCode); |
|
|
|
|
if (CollUtil.isNotEmpty(list)) { |
|
|
|
|
List<DeliveryNoteEntity> sns = list.stream().map(deliveryNoteEntity -> { |
|
|
|
|
String sn = deliveryNoteEntity.getSn(); |
|
|
|
|
if (StrUtil.contains(sn, "补")) { |
|
|
|
|
sn = sn.split("-")[0]; |
|
|
|
|
} |
|
|
|
|
deliveryNoteEntity.setSn(sn); |
|
|
|
|
return deliveryNoteEntity; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
if (CollUtil.isNotEmpty(sns)) { |
|
|
|
|
JSONArray snArray = new JSONArray(); |
|
|
|
|
for (DeliveryNoteEntity sn : sns) { |
|
|
|
|
JSONObject jsonObject = new JSONObject(); |
|
|
|
|
jsonObject.set("sn", sn.getSn()); |
|
|
|
|
jsonObject.set("qty", sn.getQty()); |
|
|
|
|
jsonObject.set("scanTime", DateUtil.formatDateTime(new Date())); |
|
|
|
|
snArray.add(jsonObject); |
|
|
|
|
} |
|
|
|
|
entries.set("snList", snArray); |
|
|
|
|
String post = HttpUtil.post(oldProperties.getPushNodeUrl(), JSONUtil.toJsonStr(entries)); |
|
|
|
|
FactoryNodeAllPushEntity pushAllEntity = new FactoryNodeAllPushEntity(); |
|
|
|
|
pushAllEntity.setWarehouse(entries.getStr("nodeName")); |
|
|
|
|
pushAllEntity.setWorkBatch(orderCode); |
|
|
|
|
pushAllEntity.setSendUrl(oldProperties.getPushNodeUrl()); |
|
|
|
|
pushAllEntity.setOrderCode(orderCode); |
|
|
|
|
pushAllEntity.setShipmentCode(shipmentCode); |
|
|
|
|
pushAllEntity.setShipmentSpitCode(shipmentSpitCode); |
|
|
|
|
pushAllEntity.setType(entries.getStr("content")); |
|
|
|
|
pushAllEntity.setWaybillCode(entries.getStr("deliveryNo")); |
|
|
|
|
pushAllEntity.setTypeCode(entries.getInt("siteLevel")); |
|
|
|
|
try { |
|
|
|
|
JSONObject entries1 = JSONUtil.parseObj(post); |
|
|
|
|
Integer code = entries1.getInt("code"); |
|
|
|
|
String data = entries1.getStr("data"); |
|
|
|
|
// 成功
|
|
|
|
|
Integer successCode = code; |
|
|
|
|
String message = data; |
|
|
|
|
if (NumberUtil.equals(code, 200)) { |
|
|
|
|
if (StrUtil.isNotEmpty(data)) { |
|
|
|
|
JSONObject jsonObject = JSONUtil.parseObj(data); |
|
|
|
|
Integer code1 = jsonObject.getInt("code"); |
|
|
|
|
successCode = code1; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
pushAllEntity.setPackageCode(sns.stream().map(DeliveryNoteEntity::getSn).collect(Collectors.joining(","))); |
|
|
|
|
pushAllEntity.setSendStatus(successCode + ""); |
|
|
|
|
pushAllEntity.setContent(JSONUtil.toJsonStr(entries)); |
|
|
|
|
pushAllEntity.setResultContent(message); |
|
|
|
|
pushAllEntity.setReserve1(Convert.toStr(sns.size())); |
|
|
|
|
pushAllEntity.setReserve2(Convert.toStr(sns.size())); |
|
|
|
|
factoryNodeAllPushService.save(pushAllEntity); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("解析返回值失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private String uploadFile(String body) { |
|
|
|
|
// 文本内容和保存为本地文件 并上传
|
|
|
|
|
String logPath = FileLogsUtil.saveFileLogs(body); |
|
|
|
|