parent
e6fa8f9f9b
commit
1a82f55e41
|
@ -2,9 +2,12 @@ package com.hzya.frame.plugin.kjs.plugin;
|
|||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.base.PluginBaseEntity;
|
||||
import com.hzya.frame.plugin.kjs.service.IDeliveryOrderPluginService;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @Description
|
||||
|
@ -13,6 +16,8 @@ import org.slf4j.LoggerFactory;
|
|||
**/
|
||||
public class DeliveryOrderPluginInitializer extends PluginBaseEntity {
|
||||
Logger logger = LoggerFactory.getLogger(getClass());
|
||||
@Autowired
|
||||
private IDeliveryOrderPluginService deliveryOrderPluginService;
|
||||
/***
|
||||
* 插件初始化方法
|
||||
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||
|
@ -55,7 +60,7 @@ public class DeliveryOrderPluginInitializer extends PluginBaseEntity {
|
|||
**/
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "kjs发货单同步插件";
|
||||
return "kjs发货单同步WMS插件";
|
||||
}
|
||||
|
||||
/****
|
||||
|
@ -66,7 +71,7 @@ public class DeliveryOrderPluginInitializer extends PluginBaseEntity {
|
|||
**/
|
||||
@Override
|
||||
public String getPluginLabel() {
|
||||
return "kjs发货单同步插件";
|
||||
return "kjs发货单同步WMS插件";
|
||||
}
|
||||
|
||||
/***
|
||||
|
@ -90,7 +95,8 @@ public class DeliveryOrderPluginInitializer extends PluginBaseEntity {
|
|||
**/
|
||||
@Override
|
||||
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
|
||||
|
||||
return null;
|
||||
logger.info("开始执行"+getPluginName());
|
||||
String res = deliveryOrderPluginService.sync2wms(requestJson);
|
||||
return BaseResult.getSuccessMessageEntity("操作成功");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,103 @@
|
|||
package com.hzya.frame.plugin.kjs.plugin;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.base.PluginBaseEntity;
|
||||
import com.hzya.frame.plugin.kjs.service.IMomOrderPluginService;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* @Description u8生产订单同步wms
|
||||
* @Author xiangerlin
|
||||
* @Date 2024/8/23 09:17
|
||||
**/
|
||||
public class MomOrderPluginInitializer extends PluginBaseEntity {
|
||||
Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
@Autowired
|
||||
private IMomOrderPluginService momOrderPluginService;
|
||||
/***
|
||||
* 插件初始化方法
|
||||
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||
* @Date 2023-08-02 10:48
|
||||
* @Param []
|
||||
* @return void
|
||||
**/
|
||||
@Override
|
||||
public void initialize() {
|
||||
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||
}
|
||||
|
||||
/****
|
||||
* 插件销毁方法
|
||||
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||
* @date 2023-08-02 10:48
|
||||
* @return void
|
||||
**/
|
||||
@Override
|
||||
public void destroy() {
|
||||
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||
}
|
||||
|
||||
/****
|
||||
* 插件的ID
|
||||
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||
* @date 2023-08-02 10:48
|
||||
* @return void
|
||||
**/
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return "kjsMomOrderPlugin";
|
||||
}
|
||||
|
||||
/****
|
||||
* 插件的名称
|
||||
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||
* @date 2023-08-02 10:48
|
||||
* @return void
|
||||
**/
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "kjs生产订单同步WMS插件";
|
||||
}
|
||||
|
||||
/****
|
||||
* 插件的显示值
|
||||
* @author 👻👻👻👻👻👻👻👻 gjh
|
||||
* @date 2023-08-02 10:48
|
||||
* @return void
|
||||
**/
|
||||
@Override
|
||||
public String getPluginLabel() {
|
||||
return "kjs生产订单同步WMS插件";
|
||||
}
|
||||
|
||||
/***
|
||||
* 插件类型 1、场景插件
|
||||
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||
* @Date 2023-08-02 14:01
|
||||
* @Param []
|
||||
* @return java.lang.String
|
||||
**/
|
||||
@Override
|
||||
public String getPluginType() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
/***
|
||||
* 执行业务代码
|
||||
* @Author 👻👻👻👻👻👻👻👻 gjh
|
||||
* @Date 2023-08-07 11:20
|
||||
* @param requestJson 执行业务代码的参数
|
||||
* @return void
|
||||
**/
|
||||
@Override
|
||||
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
|
||||
logger.info("开始执行"+getPluginName());
|
||||
momOrderPluginService.sync2wms(requestJson);
|
||||
return BaseResult.getSuccessMessageEntity("执行成功");
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.hzya.frame.plugin.kjs.service;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
|
||||
/**
|
||||
* @Description 生产订单同步wsm
|
||||
* @Author xiangerlin
|
||||
* @Date 2024/8/23 09:21
|
||||
**/
|
||||
public interface IMomOrderPluginService {
|
||||
|
||||
/**
|
||||
* 生产订单单同步到wms
|
||||
* @param requestJson
|
||||
* @return
|
||||
*/
|
||||
String sync2wms(JSONObject requestJson);
|
||||
}
|
|
@ -1,9 +1,12 @@
|
|||
package com.hzya.frame.plugin.kjs.service.impl;
|
||||
|
||||
import cn.hutool.core.map.MapBuilder;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.plugin.kjs.service.IDeliveryOrderPluginService;
|
||||
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
|
||||
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
|
||||
import com.hzya.frame.u8.delivery.dto.DeliveryDetailDTO;
|
||||
import com.hzya.frame.u8.delivery.dto.DeliveryOrderDTO;
|
||||
import com.hzya.frame.u8.delivery.entity.DeliveryDetailEntity;
|
||||
|
@ -16,6 +19,8 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -30,7 +35,8 @@ public class DeliveryOrderPluginServiceImpl implements IDeliveryOrderPluginServi
|
|||
private IDeliveryOrderService deliveryOrderService;
|
||||
@Autowired
|
||||
private IDeliveryDetaiService deliveryDetaiService;
|
||||
|
||||
@Resource
|
||||
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
|
||||
/**
|
||||
* 发货单同步到wsm
|
||||
* @param requestJson
|
||||
|
@ -38,35 +44,61 @@ public class DeliveryOrderPluginServiceImpl implements IDeliveryOrderPluginServi
|
|||
*/
|
||||
@Override
|
||||
public String sync2wms(JSONObject requestJson) {
|
||||
//1 查询发货单主表
|
||||
DeliveryOrderEntity orderEntity = new DeliveryOrderEntity();
|
||||
orderEntity.setDataSourceCode("YONYOUU8");
|
||||
orderEntity.setDlid("1000000152");
|
||||
orderEntity.setbReturnFlag("0");
|
||||
List<DeliveryOrderEntity> orderList = deliveryOrderService.query(orderEntity);
|
||||
if (CollectionUtils.isNotEmpty(orderList)){
|
||||
for (DeliveryOrderEntity order : orderList) {
|
||||
//2 查询发货单明细表
|
||||
DeliveryDetailEntity detailEntity = new DeliveryDetailEntity();
|
||||
detailEntity.setDlid(order.getDlid());
|
||||
detailEntity.setDataSourceCode("YONYOUU8");
|
||||
List<DeliveryDetailEntity> detailList = deliveryDetaiService.query(detailEntity);
|
||||
//发货单表头entity转dto
|
||||
DeliveryOrderDTO deliveryOrderDTO = DeliveryMapper.INSTANCE.deliveryEntityToDto(order);
|
||||
//发货单表体entity转dto
|
||||
List<DeliveryDetailDTO> deliveryDetailList = DeliveryMapper.INSTANCE.deliveryDetailListToDto(detailList);
|
||||
deliveryOrderDTO.setItesm(deliveryDetailList);
|
||||
String reqParams = JSONObject.toJSONString(deliveryOrderDTO);
|
||||
logger.info("发货单请求参数:{}",reqParams);
|
||||
//调用wms接口
|
||||
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
|
||||
.put("apiCode", "")
|
||||
.put("publicKey","ZJYA1vBeY1ai53iNmbAEsw6DImjkXGBkdMailxcBdliFC85Ce7eDIk+3zDUT+v578prj")
|
||||
.put("secretKey","7Gp6OjHrIaQ6R3tXGPrI4morjQyWL+qu4JJschQnkBRtv26VDgGFVYKOy5kMZfd/j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
|
||||
.put("appId","")
|
||||
.build();
|
||||
String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(reqParams).timeout(60000).execute().body();
|
||||
return body;
|
||||
if (null != requestJson){
|
||||
//1 查询发货单主表
|
||||
DeliveryOrderEntity orderEntity = new DeliveryOrderEntity();
|
||||
String id = requestJson.getString("integration_task_living_details_id");
|
||||
if (StrUtil.isNotEmpty(id)){
|
||||
IntegrationTaskLivingDetailsEntity taskLivingDetails = taskLivingDetailsService.get(id);
|
||||
orderEntity.setDlid(taskLivingDetails.getRootAppPk());
|
||||
}
|
||||
orderEntity.setDataSourceCode("YONYOUU8");
|
||||
orderEntity.setDlid("1000000152");
|
||||
orderEntity.setbReturnFlag("0");
|
||||
List<DeliveryOrderEntity> orderList = deliveryOrderService.query(orderEntity);
|
||||
if (CollectionUtils.isNotEmpty(orderList)){
|
||||
for (DeliveryOrderEntity order : orderList) {
|
||||
try {
|
||||
//2 查询发货单明细表
|
||||
DeliveryDetailEntity detailEntity = new DeliveryDetailEntity();
|
||||
detailEntity.setDlid(order.getDlid());
|
||||
detailEntity.setDataSourceCode("YONYOUU8");
|
||||
List<DeliveryDetailEntity> detailList = deliveryDetaiService.query(detailEntity);
|
||||
//发货单表头entity转dto
|
||||
DeliveryOrderDTO deliveryOrderDTO = DeliveryMapper.INSTANCE.deliveryEntityToDto(order);
|
||||
//发货单表体entity转dto
|
||||
List<DeliveryDetailDTO> deliveryDetailList = DeliveryMapper.INSTANCE.deliveryDetailListToDto(detailList);
|
||||
deliveryOrderDTO.setItesm(deliveryDetailList);
|
||||
String reqParams = JSONObject.toJSONString(deliveryOrderDTO);
|
||||
logger.info("发货单请求参数:{}",reqParams);
|
||||
//调用wms接口
|
||||
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
|
||||
.put("apiCode", "")
|
||||
.put("publicKey","ZJYA1vBeY1ai53iNmbAEsw6DImjkXGBkdMailxcBdliFC85Ce7eDIk+3zDUT+v578prj")
|
||||
.put("secretKey","7Gp6OjHrIaQ6R3tXGPrI4morjQyWL+qu4JJschQnkBRtv26VDgGFVYKOy5kMZfd/j3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
|
||||
.put("appId","")
|
||||
.build();
|
||||
//String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(reqParams).timeout(60000).execute().body();
|
||||
//保存日志
|
||||
IntegrationTaskLivingDetailsEntity taskLivingDetail = new IntegrationTaskLivingDetailsEntity();
|
||||
taskLivingDetail.setCreate_time(new Date());
|
||||
taskLivingDetail.setModify_time(new Date());
|
||||
taskLivingDetail.setRootAppPk(order.getDlid());
|
||||
taskLivingDetail.setRootAppBill(order.getCdlcode());
|
||||
taskLivingDetail.setPluginId("kjsDeliveryOrderPlugin");
|
||||
taskLivingDetail.setRootAppNewData(reqParams);
|
||||
//判断,成功调用这个方法
|
||||
//taskLivingDetailsService.saveLogToSuccess(taskLivingDetail);
|
||||
//失败 调用这个方法
|
||||
//taskLivingDetailsService.saveLogToFail(taskLivingDetail);
|
||||
//如果是重试 成功调这个方法
|
||||
//taskLivingDetailsService.saveLogFailToSuccess(taskLivingDetail);
|
||||
//如果是重试 失败调这个方法
|
||||
// taskLivingDetailsService.updateLogFailToSuccess(taskLivingDetail);
|
||||
}catch(Exception e){
|
||||
logger.error("同步发货单到wsm出错:{}",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package com.hzya.frame.plugin.kjs.service.impl;
|
||||
|
||||
import cn.hutool.core.map.MapBuilder;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.plugin.kjs.service.IMomOrderPluginService;
|
||||
import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity;
|
||||
import com.hzya.frame.sysnew.integtationTaskLivingDetails.service.IIntegrationTaskLivingDetailsService;
|
||||
import com.hzya.frame.u8.production.dto.MomOrderDTO;
|
||||
import com.hzya.frame.u8.production.dto.MomOrderDetailDTO;
|
||||
import com.hzya.frame.u8.production.entity.MomOrderDetailEntity;
|
||||
import com.hzya.frame.u8.production.entity.MomOrderEntity;
|
||||
import com.hzya.frame.u8.production.service.IMomOrderDetailService;
|
||||
import com.hzya.frame.u8.production.service.IMomOrderService;
|
||||
import com.hzya.frame.u8.production.service.MomOrderMapper;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Description 生产订单同步wsm
|
||||
* @Author xiangerlin
|
||||
* @Date 2024/8/23 09:21
|
||||
**/
|
||||
public class MomOrderPluginServiceImpl implements IMomOrderPluginService {
|
||||
Logger logger = LoggerFactory.getLogger(getClass());
|
||||
@Autowired
|
||||
private IMomOrderService momOrderService;
|
||||
@Autowired
|
||||
private IMomOrderDetailService momOrderDetailService;
|
||||
@Resource
|
||||
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
|
||||
/**
|
||||
* 生产订单单同步到wms
|
||||
*
|
||||
* @param requestJson
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public String sync2wms(JSONObject requestJson) {
|
||||
if (null != requestJson){
|
||||
//1查询主表
|
||||
MomOrderEntity entity = new MomOrderEntity();
|
||||
String id = requestJson.getString("integration_task_living_details_id");
|
||||
//如果这个id不为空说明是重试
|
||||
if (StrUtil.isNotEmpty(id)){
|
||||
IntegrationTaskLivingDetailsEntity taskLivingDetails = taskLivingDetailsService.get(id);
|
||||
entity.setMoId(taskLivingDetails.getRootAppPk());
|
||||
}
|
||||
entity.setMoId("1000000001");
|
||||
entity.setDataSourceCode("YONYOUU8");
|
||||
List<MomOrderEntity> orderList = momOrderService.query(entity);
|
||||
if (CollectionUtils.isNotEmpty(orderList)){
|
||||
for (MomOrderEntity order : orderList) {
|
||||
try {
|
||||
//查询生产订单明细表
|
||||
MomOrderDetailEntity detailEntity = new MomOrderDetailEntity();
|
||||
detailEntity.setMoId(order.getMoId());
|
||||
detailEntity.setDataSourceCode("YONYOUU8");
|
||||
List<MomOrderDetailEntity> detailList = momOrderDetailService.query(detailEntity);
|
||||
//表头转换dto
|
||||
MomOrderDTO momOrderDTO = MomOrderMapper.INSTANCE.momOrderEntityToDto(order);
|
||||
//表体转换dto
|
||||
List<MomOrderDetailDTO> momOrderDetailList = MomOrderMapper.INSTANCE.momOrderDetailListToDto(detailList);
|
||||
momOrderDTO.setItesm(momOrderDetailList);
|
||||
String reqParam = JSONObject.toJSONString(momOrderDTO);
|
||||
logger.info("u8生产订单传wms请求参数:{}",reqParam);
|
||||
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
|
||||
.put("apiCode", "")
|
||||
.put("publicKey","ZJYAWb7lhAUTYqekPkU+uHJv1/ObJxb7dT7sD8HPRDGAgyhCe7eDIk+3zDUT+v578prj")
|
||||
.put("secretKey","fviZnLBsQUAGF8w8FSOdJi7XlIm/XAZclMxRagDLfTyJFlvnIBF3w66Hrpfzs8cYj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")
|
||||
.put("appId","")
|
||||
.build();
|
||||
//String body = HttpRequest.post("http://127.0.0.1:9999/kangarooDataCenterV3/entranceController/externalCallInterface").addHeaders(headerMap).body(reqParam).timeout(60000).execute().body();
|
||||
|
||||
//保存日志
|
||||
IntegrationTaskLivingDetailsEntity taskLivingDetail = new IntegrationTaskLivingDetailsEntity();
|
||||
taskLivingDetail.setCreate_time(new Date());
|
||||
taskLivingDetail.setModify_time(new Date());
|
||||
taskLivingDetail.setRootAppPk(order.getMoId());
|
||||
taskLivingDetail.setRootAppBill(order.getMocode());
|
||||
taskLivingDetail.setPluginId("kjsMomOrderPlugin");
|
||||
taskLivingDetail.setRootAppNewData(reqParam);
|
||||
//判断,成功调用这个方法
|
||||
//taskLivingDetailsService.saveLogToSuccess(taskLivingDetail);
|
||||
//失败 调用这个方法
|
||||
//taskLivingDetailsService.saveLogToFail(taskLivingDetail);
|
||||
//如果是重试 成功调这个方法
|
||||
//taskLivingDetailsService.saveLogFailToSuccess(taskLivingDetail);
|
||||
//如果是重试 失败调这个方法
|
||||
// taskLivingDetailsService.updateLogFailToSuccess(taskLivingDetail);
|
||||
}catch (Exception e){
|
||||
logger.error("生产订单同步wsm出错:{}",e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue