From c924f6c467bbc6e58b39df6a81cf850e2970a064 Mon Sep 17 00:00:00 2001 From: mengjiao <3338049200@qq,com> Date: Wed, 16 Oct 2024 13:16:01 +0800 Subject: [PATCH] =?UTF-8?q?wms=E5=AE=9A=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/op/system/api/RemoteWmsService.java | 3 + .../api/factory/RemoteWmsFallbackFactory.java | 6 + .../src/main/java/com/op/job/task/RyTask.java | 8 + .../WmsSellOutEmbryoController.java | 7 + .../controller/WmsToWCSmissionController.java | 10 +- .../java/com/op/wms/domain/ShipmentTDO.java | 187 ++++++++++++++++++ .../com/op/wms/domain/WmsSellOutEmbryo.java | 23 ++- .../wms/service/IWmsSellOutEmbryoService.java | 2 + .../impl/WmsSellOutEmbryoServiceImpl.java | 112 ++++++++++- .../wms/WmsOdsMateStorageNewsSnMapper.xml | 2 +- .../mapper/wms/WmsSellOutEmbryoMapper.xml | 4 + 11 files changed, 358 insertions(+), 6 deletions(-) create mode 100644 op-modules/op-wms/src/main/java/com/op/wms/domain/ShipmentTDO.java diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteWmsService.java b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteWmsService.java index 12f7f808d..20215bb74 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/RemoteWmsService.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/RemoteWmsService.java @@ -26,4 +26,7 @@ public interface RemoteWmsService { @PostMapping("/area/removeDatasource") public R removeDatasource(@RequestBody DataSourcePropertyDTO dataSourceProperty); + + @PostMapping("/sellout/SynchronizationOfShippingDocuments") + public R SynchronizationOfShippingDocuments(); } diff --git a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteWmsFallbackFactory.java b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteWmsFallbackFactory.java index 4b74eaa59..2257c0b96 100644 --- a/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteWmsFallbackFactory.java +++ b/op-api/op-api-system/src/main/java/com/op/system/api/factory/RemoteWmsFallbackFactory.java @@ -33,6 +33,12 @@ public class RemoteWmsFallbackFactory implements FallbackFactory list = odsProcureOutOrderService.listReturnSC(odsProcureOutOrder); return success(list); } - + @PostMapping("/SynchronizationOfShippingDocuments") + public R SynchronizationOfShippingDocuments() { + wmsSellOutEmbryoService.SynchronizationOfShippingDocuments(); + return R.ok(); + } } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/domain/ShipmentTDO.java b/op-modules/op-wms/src/main/java/com/op/wms/domain/ShipmentTDO.java new file mode 100644 index 000000000..65f141190 --- /dev/null +++ b/op-modules/op-wms/src/main/java/com/op/wms/domain/ShipmentTDO.java @@ -0,0 +1,187 @@ +package com.op.wms.domain; + +import java.io.Serializable; + +public class ShipmentTDO implements Serializable { + private static final long serialVersionUID = 155333829342519626L; + private String shipmentNo; + private String deliveryNo; + private String materialCode; + private String materialName; + private String num; + private String unit; + private String logistics; + private String logisticsCode; + private String deliveryDate; + private String batch; + private String receiverName; + private String receiverCode; + private String saleName; + private String saleCode; + private String channelType; + private String shippingPointName; + private String shippingPointCode; + private String receiverAddr; + private String createUserId; + private String createUser; + + public String getShipmentNo() { + return shipmentNo; + } + + public void setShipmentNo(String shipmentNo) { + this.shipmentNo = shipmentNo; + } + + public String getDeliveryNo() { + return deliveryNo; + } + + public void setDeliveryNo(String deliveryNo) { + this.deliveryNo = deliveryNo; + } + + public String getMaterialCode() { + return materialCode; + } + + public void setMaterialCode(String materialCode) { + this.materialCode = materialCode; + } + + public String getMaterialName() { + return materialName; + } + + public void setMaterialName(String materialName) { + this.materialName = materialName; + } + + public String getNum() { + return num; + } + + public void setNum(String num) { + this.num = num; + } + + public String getUnit() { + return unit; + } + + public void setUnit(String unit) { + this.unit = unit; + } + + public String getLogistics() { + return logistics; + } + + public void setLogistics(String logistics) { + this.logistics = logistics; + } + + public String getLogisticsCode() { + return logisticsCode; + } + + public void setLogisticsCode(String logisticsCode) { + this.logisticsCode = logisticsCode; + } + + public String getDeliveryDate() { + return deliveryDate; + } + + public void setDeliveryDate(String deliveryDate) { + this.deliveryDate = deliveryDate; + } + + public String getBatch() { + return batch; + } + + public void setBatch(String batch) { + this.batch = batch; + } + + public String getReceiverName() { + return receiverName; + } + + public void setReceiverName(String receiverName) { + this.receiverName = receiverName; + } + + public String getReceiverCode() { + return receiverCode; + } + + public void setReceiverCode(String receiverCode) { + this.receiverCode = receiverCode; + } + + public String getSaleName() { + return saleName; + } + + public void setSaleName(String saleName) { + this.saleName = saleName; + } + + public String getSaleCode() { + return saleCode; + } + + public void setSaleCode(String saleCode) { + this.saleCode = saleCode; + } + + public String getChannelType() { + return channelType; + } + + public void setChannelType(String channelType) { + this.channelType = channelType; + } + + public String getShippingPointName() { + return shippingPointName; + } + + public void setShippingPointName(String shippingPointName) { + this.shippingPointName = shippingPointName; + } + + public String getShippingPointCode() { + return shippingPointCode; + } + + public void setShippingPointCode(String shippingPointCode) { + this.shippingPointCode = shippingPointCode; + } + + public String getReceiverAddr() { + return receiverAddr; + } + + public void setReceiverAddr(String receiverAddr) { + this.receiverAddr = receiverAddr; + } + + public String getCreateUserId() { + return createUserId; + } + + public void setCreateUserId(String createUserId) { + this.createUserId = createUserId; + } + + public String getCreateUser() { + return createUser; + } + + public void setCreateUser(String createUser) { + this.createUser = createUser; + } +} diff --git a/op-modules/op-wms/src/main/java/com/op/wms/domain/WmsSellOutEmbryo.java b/op-modules/op-wms/src/main/java/com/op/wms/domain/WmsSellOutEmbryo.java index d3ebfd06c..be1571776 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/domain/WmsSellOutEmbryo.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/domain/WmsSellOutEmbryo.java @@ -142,7 +142,7 @@ public class WmsSellOutEmbryo extends BaseEntity { * 出库时间 */ @JsonFormat(pattern = "yyyy-MM-dd") - @Excel(name = "出库时间", width = 30, dateFormat = "yyyy-MM-dd") + // @Excel(name = "出库时间", width = 30, dateFormat = "yyyy-MM-dd") private Date outDate; /** @@ -204,6 +204,27 @@ public class WmsSellOutEmbryo extends BaseEntity { */ @Excel(name = "预留字段10") private String attr10; + @Excel(name = "预留字段10") + private String attr11; + @Excel(name = "预留字段10") + private String attr12; + + public String getAttr11() { + return attr11; + } + + public void setAttr11(String attr11) { + this.attr11 = attr11; + } + + public String getAttr12() { + return attr12; + } + + public void setAttr12(String attr12) { + this.attr12 = attr12; + } + /** * 有效标记 */ diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/IWmsSellOutEmbryoService.java b/op-modules/op-wms/src/main/java/com/op/wms/service/IWmsSellOutEmbryoService.java index 93d21352f..70ff03227 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/IWmsSellOutEmbryoService.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/IWmsSellOutEmbryoService.java @@ -76,4 +76,6 @@ public interface IWmsSellOutEmbryoService { * @return */ public WmsSellOutEmbryo selectWmsSellOutEmbryoByOrderCodeAndProductCode(String deliveryOrder, String productCode); + + void SynchronizationOfShippingDocuments(); } diff --git a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/WmsSellOutEmbryoServiceImpl.java b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/WmsSellOutEmbryoServiceImpl.java index 0faf6f69d..92636a45e 100644 --- a/op-modules/op-wms/src/main/java/com/op/wms/service/impl/WmsSellOutEmbryoServiceImpl.java +++ b/op-modules/op-wms/src/main/java/com/op/wms/service/impl/WmsSellOutEmbryoServiceImpl.java @@ -1,12 +1,23 @@ package com.op.wms.service.impl; -import java.util.List; +import java.io.IOException; +import java.math.BigDecimal; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; +import com.alibaba.fastjson2.JSON; +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.dynamic.datasource.toolkit.DynamicDataSourceContextHolder; import com.op.common.core.utils.DateUtils; import com.op.common.core.utils.uuid.IdUtils; +import com.op.wms.domain.OdsProcureOrder; +import com.op.wms.domain.ShipmentTDO; +import okhttp3.*; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.ValueOperations; import org.springframework.stereotype.Service; @@ -27,7 +38,8 @@ public class WmsSellOutEmbryoServiceImpl implements IWmsSellOutEmbryoService { @Autowired private RedisTemplate redisTemplate; - + @Value("${dayin.url2}") + private String dayinUrl2; /** * 查询成品销售出库 * @@ -136,4 +148,100 @@ public class WmsSellOutEmbryoServiceImpl implements IWmsSellOutEmbryoService { opsForValue.set("productCode", productCode); return wmsSellOutEmbryoMapper.selectWmsSellOutEmbryoByOrderCodeAndProductCode(deliveryOrder, productCode); } + + @Override + public void SynchronizationOfShippingDocuments() { + DynamicDataSourceContextHolder.push("ds_1000"); + List wmsSellOutEmbryoList= dayin(); + } + + + + + public List dayin( ) { + // 定义请求的URL地址 + String url = dayinUrl2; + // 打印输出url的值 + System.out.println(url); + // 创建OkHttpClient实例,用于发送HTTP请求 + OkHttpClient client = new OkHttpClient(); + + // 定义请求体的媒体类型为json + MediaType mediaType = MediaType.parse("application/json"); + try { + // 创建POST请求 + Request request = new Request.Builder() + .url(url) + .post(RequestBody.create("", MediaType.parse("application/json; charset=utf-8"))) + .build(); + // 执行请求并获取响应 + List shipmentList = new ArrayList<>(); + Response response = client.newCall(request).execute(); + // 获取响应数据并转换为JSON对象 + String responseData = response.body().string(); + shipmentList = JSON.parseArray(responseData, ShipmentTDO.class); + System.out.println("Response Data: " + responseData); // 打印响应数据以进行调试 + + for (ShipmentTDO shipmentTDO:shipmentList){ + WmsSellOutEmbryo wmsSellOutEmbryo=new WmsSellOutEmbryo(); + wmsSellOutEmbryo.setLotNumber(shipmentTDO.getBatch());//批次号---唯一 + List wmsSellOutEmbryoList= wmsSellOutEmbryoMapper.selectWmsSellOutEmbryoList(wmsSellOutEmbryo); + if (wmsSellOutEmbryoList.size()>0){ + continue; + } + + wmsSellOutEmbryo.setId(IdUtils.fastSimpleUUID()); + wmsSellOutEmbryo.setDeliveryOrder(shipmentTDO.getShipmentNo());//运输单号- + wmsSellOutEmbryo.setItemNumber(shipmentTDO.getDeliveryNo());// 交货单号- + wmsSellOutEmbryo.setFactoryCode("1000");//工厂编码 + wmsSellOutEmbryo.setWhCode("0021");//仓库编码 +// wmsSellOutEmbryo.setWaCode();//库区编码 +// wmsSellOutEmbryo.setWlCode();//库位编码 +// wmsSellOutEmbryo.setDeliveryPlace();//出库地点 + wmsSellOutEmbryo.setProductName(shipmentTDO.getMaterialName());//产品名称- + wmsSellOutEmbryo.setProductCode(shipmentTDO.getMaterialCode());//产品编码- +// wmsSellOutEmbryo.setProductSort();//产品分类 +// wmsSellOutEmbryo.setSpecification();//规格型号 + wmsSellOutEmbryo.setUnitOfMeasure(shipmentTDO.getUnit());//单位- + + wmsSellOutEmbryo.setPlanQuantity(new BigDecimal(shipmentTDO.getNum()));//计划出库数量- + wmsSellOutEmbryo.setOutQuantity(new BigDecimal("0"));//出库数量 + wmsSellOutEmbryo.setStatus("0");//出库状态 + wmsSellOutEmbryo.setSapStatus("0");//过账SAP状态 + //wmsSellOutEmbryo.setSapMessage();//过账SAP凭证 + SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S"); + Date deliveryDate = formatter.parse(shipmentTDO.getDeliveryDate()); + wmsSellOutEmbryo.setOutDate(deliveryDate);//交货日期 +// wmsSellOutEmbryo.setAttr1();//预留字段1物流公司名称 +// wmsSellOutEmbryo.setAttr2();//预留字段2 物流编码 + wmsSellOutEmbryo.setAttr3(shipmentTDO.getReceiverName());//预留字段3收货人名称 + wmsSellOutEmbryo.setAttr4(shipmentTDO.getReceiverCode());//预留字段4收货人编码 + wmsSellOutEmbryo.setAttr5(shipmentTDO.getSaleName());//预留字段5销售单位名称 + wmsSellOutEmbryo.setAttr6(shipmentTDO.getSaleCode());//预留字段6销售单位编码 + wmsSellOutEmbryo.setAttr7(shipmentTDO.getChannelType());//预留字段7渠道类型 + wmsSellOutEmbryo.setAttr8(shipmentTDO.getShippingPointName());//预留字段8发货点名称 + wmsSellOutEmbryo.setAttr9(shipmentTDO.getShippingPointCode());//预留字段9发货点编码 + wmsSellOutEmbryo.setAttr10(shipmentTDO.getReceiverAddr());//预留字段10收货地址 + wmsSellOutEmbryo.setCreateTime(new Date()); + wmsSellOutEmbryo.setCreateBy("task"); + wmsSellOutEmbryo.setActiveFlag("1"); + wmsSellOutEmbryo.setAttr11(shipmentTDO.getCreateUserId()); + wmsSellOutEmbryo.setAttr12(shipmentTDO.getCreateUser()); + wmsSellOutEmbryoMapper.insertWmsSellOutEmbryo(wmsSellOutEmbryo); + } + + response.close(); + return null; + } catch (IOException e) { + // 捕获IOException并处理异常 + e.printStackTrace(); // 在控制台打印异常信息,建议记录到日志文件 + return null; // 返回异常信息 + } catch (ParseException e) { + e.printStackTrace(); + return null; // 返回异常信息 + } finally { + // 关闭OkHttpClient + client.dispatcher().executorService().shutdown(); + } + } } diff --git a/op-modules/op-wms/src/main/resources/mapper/wms/WmsOdsMateStorageNewsSnMapper.xml b/op-modules/op-wms/src/main/resources/mapper/wms/WmsOdsMateStorageNewsSnMapper.xml index cff95c759..81b9af081 100644 --- a/op-modules/op-wms/src/main/resources/mapper/wms/WmsOdsMateStorageNewsSnMapper.xml +++ b/op-modules/op-wms/src/main/resources/mapper/wms/WmsOdsMateStorageNewsSnMapper.xml @@ -99,7 +99,7 @@ and wms_ods_mate_storage_news_sn.user_defined8 = #{userDefined8} and wms_ods_mate_storage_news_sn.user_defined9 = #{userDefined9} and wms_ods_mate_storage_news_sn.user_defined10 = #{userDefined10} - and wms_ods_mate_storage_news_sn.gmt_create = #{gmtCreate} + and CAST(wms_ods_mate_storage_news_sn.gmt_create AS DATE) = CAST(#{gmtCreate} AS DATE) and wms_ods_mate_storage_news_sn.last_modified_by = #{lastModifiedBy} and wms_ods_mate_storage_news_sn.gmt_modified = #{gmtModified} and wms_ods_mate_storage_news_sn.active_flag = #{activeFlag} diff --git a/op-modules/op-wms/src/main/resources/mapper/wms/WmsSellOutEmbryoMapper.xml b/op-modules/op-wms/src/main/resources/mapper/wms/WmsSellOutEmbryoMapper.xml index d6d601e22..3a82d9e9b 100644 --- a/op-modules/op-wms/src/main/resources/mapper/wms/WmsSellOutEmbryoMapper.xml +++ b/op-modules/op-wms/src/main/resources/mapper/wms/WmsSellOutEmbryoMapper.xml @@ -183,6 +183,8 @@ attr8, attr9, attr10, + attr11, + attr12, create_by, create_time, update_by, @@ -221,6 +223,8 @@ #{attr8}, #{attr9}, #{attr10}, + #{attr11}, + #{attr12}, #{createBy}, #{createTime}, #{updateBy},