wms定时任务

master
mengjiao 8 months ago
parent dfc7627430
commit c924f6c467

@ -26,4 +26,7 @@ public interface RemoteWmsService {
@PostMapping("/area/removeDatasource")
public R removeDatasource(@RequestBody DataSourcePropertyDTO dataSourceProperty);
@PostMapping("/sellout/SynchronizationOfShippingDocuments")
public R SynchronizationOfShippingDocuments();
}

@ -33,6 +33,12 @@ public class RemoteWmsFallbackFactory implements FallbackFactory<RemoteWmsServic
public R removeDatasource(DataSourcePropertyDTO dataSourceProperty) {
return R.fail("mes数据源删除失败:" + throwable.getMessage());
}
@Override
public R SynchronizationOfShippingDocuments() {
return R.fail("装运单同步定时任务-同步失败:"+throwable.getMessage());
}
};
}
}

@ -37,6 +37,8 @@ public class RyTask {
@Autowired
private RemoteUserService remoteUserService;
@Autowired
private RemoteWmsService remoteWmsService;
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i) {
System.out.println(StringUtils.format("执行多参方法: 字符串类型{},布尔类型{},长整型{},浮点型{},整形{}", s, b, l, d, i));
@ -219,6 +221,12 @@ public class RyTask {
remoteUserService.sysDeptInfoTask();
}
/************部门基础数据定时任务开始*****************/
/************装运单同步定时任务*********************/
public void SynchronizationOfShippingDocuments(){
logger.info("++装运单同步定时任务+开始++SynchronizationOfShippingDocuments+++++");
remoteWmsService.SynchronizationOfShippingDocuments();
}
}

@ -3,6 +3,7 @@ package com.op.wms.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.op.common.core.domain.R;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -119,4 +120,10 @@ public class WmsSellOutEmbryoController extends BaseController {
public AjaxResult selectWmsSellOutByOrderCodeAndProductCode(@PathVariable("deliveryOrder") String deliveryOrder, @PathVariable("productCode") String productCode) {
return AjaxResult.success(wmsSellOutEmbryoService.selectWmsSellOutEmbryoByOrderCodeAndProductCode(deliveryOrder, productCode));
}
@PostMapping("/SynchronizationOfShippingDocuments")
public R SynchronizationOfShippingDocuments() {
wmsSellOutEmbryoService.SynchronizationOfShippingDocuments();
return R.ok();
}
}

@ -2,6 +2,7 @@ package com.op.wms.controller;
import com.op.common.core.domain.R;
import com.op.common.core.utils.StringUtils;
import com.op.common.core.web.domain.AjaxResult;
@ -36,7 +37,8 @@ public class WmsToWCSmissionController {
private IBaseAreaService baseAreaService;
@Autowired
private IOdsProcureOutOrderService odsProcureOutOrderService;
@Autowired
private IWmsSellOutEmbryoService wmsSellOutEmbryoService;
/**
* ---
*
@ -876,5 +878,9 @@ public class WmsToWCSmissionController {
List<OdsProcureOutOrder> list = odsProcureOutOrderService.listReturnSC(odsProcureOutOrder);
return success(list);
}
@PostMapping("/SynchronizationOfShippingDocuments")
public R SynchronizationOfShippingDocuments() {
wmsSellOutEmbryoService.SynchronizationOfShippingDocuments();
return R.ok();
}
}

@ -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;
}
}

@ -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;
}
/**
*
*/

@ -76,4 +76,6 @@ public interface IWmsSellOutEmbryoService {
* @return
*/
public WmsSellOutEmbryo selectWmsSellOutEmbryoByOrderCodeAndProductCode(String deliveryOrder, String productCode);
void SynchronizationOfShippingDocuments();
}

@ -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<String, String> 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<WmsSellOutEmbryo> wmsSellOutEmbryoList= dayin();
}
public List<WmsSellOutEmbryo> 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<ShipmentTDO> 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<WmsSellOutEmbryo> 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();
}
}
}

@ -99,7 +99,7 @@
<if test="userDefined8 != null and userDefined8 != ''">and wms_ods_mate_storage_news_sn.user_defined8 = #{userDefined8}</if>
<if test="userDefined9 != null and userDefined9 != ''">and wms_ods_mate_storage_news_sn.user_defined9 = #{userDefined9}</if>
<if test="userDefined10 != null and userDefined10 != ''">and wms_ods_mate_storage_news_sn.user_defined10 = #{userDefined10}</if>
<if test="gmtCreate != null ">and wms_ods_mate_storage_news_sn.gmt_create = #{gmtCreate}</if>
<if test="gmtCreate != null ">and CAST(wms_ods_mate_storage_news_sn.gmt_create AS DATE) = CAST(#{gmtCreate} AS DATE) </if>
<if test="lastModifiedBy != null and lastModifiedBy != ''">and wms_ods_mate_storage_news_sn.last_modified_by = #{lastModifiedBy}</if>
<if test="gmtModified != null ">and wms_ods_mate_storage_news_sn.gmt_modified = #{gmtModified}</if>
<if test="activeFlag != null and activeFlag != ''">and wms_ods_mate_storage_news_sn.active_flag = #{activeFlag}</if>

@ -183,6 +183,8 @@
<if test="attr8 != null">attr8,</if>
<if test="attr9 != null">attr9,</if>
<if test="attr10 != null">attr10,</if>
<if test="attr11 != null">attr11,</if>
<if test="attr12 != null">attr12,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
@ -221,6 +223,8 @@
<if test="attr8 != null">#{attr8},</if>
<if test="attr9 != null">#{attr9},</if>
<if test="attr10 != null">#{attr10},</if>
<if test="attr11 != null">#{attr11},</if>
<if test="attr12 != null">#{attr12},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>

Loading…
Cancel
Save