物料同步
This commit is contained in:
parent
a445194443
commit
e7cabc6f97
|
@ -18,6 +18,11 @@
|
|||
<artifactId>base-webapp</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.hzya.frame</groupId>
|
||||
<artifactId>fw-u8</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<profiles>
|
||||
|
|
|
@ -3,6 +3,9 @@ package com.hzya.frame.plugin.zjmaterielsynchronizationevent.dao;
|
|||
|
||||
import com.hzya.frame.basedao.dao.IBaseDao;
|
||||
import com.hzya.frame.plugin.zjmaterielsynchronizationevent.entity.ZjMaterielSynchronizationEventEntity;
|
||||
import com.hzya.frame.u8.base.inventory.entity.InventoryEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/****
|
||||
* 物料档案同步插件
|
||||
|
@ -14,5 +17,6 @@ import com.hzya.frame.plugin.zjmaterielsynchronizationevent.entity.ZjMaterielSyn
|
|||
**/
|
||||
public interface IZjMaterielSynchronizationEventDao extends IBaseDao<ZjMaterielSynchronizationEventEntity, String> {
|
||||
|
||||
List<InventoryEntity> queryInventoryEntity(List<ZjMaterielSynchronizationEventEntity> list,String dataSourceCode);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,13 @@
|
|||
package com.hzya.frame.plugin.zjmaterielsynchronizationevent.dao.impl;
|
||||
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.hzya.frame.basedao.dao.MybatisGenericDao;
|
||||
import com.hzya.frame.plugin.zjmaterielsynchronizationevent.dao.IZjMaterielSynchronizationEventDao;
|
||||
import com.hzya.frame.plugin.zjmaterielsynchronizationevent.entity.ZjMaterielSynchronizationEventEntity;
|
||||
import com.hzya.frame.seeyon.entity.SeeyonEntity;
|
||||
import com.hzya.frame.u8.base.inventory.entity.InventoryEntity;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/***
|
||||
* 物料档案同步
|
||||
|
@ -14,5 +19,10 @@ import com.hzya.frame.plugin.zjmaterielsynchronizationevent.entity.ZjMaterielSyn
|
|||
**/
|
||||
public class ZjMaterielSynchronizationEventDaoImpl extends MybatisGenericDao<ZjMaterielSynchronizationEventEntity, String> implements IZjMaterielSynchronizationEventDao {
|
||||
|
||||
@Override
|
||||
@DS("#dataSourceCode")
|
||||
public List<InventoryEntity> queryInventoryEntity(List<ZjMaterielSynchronizationEventEntity> list,String dataSourceCode) {
|
||||
return (List<InventoryEntity>) super.selectList(getSqlIdPrifx() + "queryInventoryEntity",list);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,5 +12,19 @@
|
|||
</trim>
|
||||
ORDER BY field0018code,field0043,field0007
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
<select id="queryInventoryEntity" resultType="com.hzya.frame.u8.base.inventory.entity.InventoryEntity"
|
||||
parameterType = "com.hzya.frame.plugin.zjmaterielsynchronizationevent.entity.ZjMaterielSynchronizationEventEntity">
|
||||
select
|
||||
*
|
||||
from Inventory
|
||||
where cInvCode in
|
||||
<foreach item="item" index="index" collection="list"
|
||||
open="(" separator="," close=")">
|
||||
#{item.field0043code}
|
||||
</foreach>
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ import com.hzya.frame.basedao.service.impl.BaseService;
|
|||
import com.hzya.frame.plugin.zjmaterielsynchronizationevent.dao.IZjMaterielSynchronizationEventDao;
|
||||
import com.hzya.frame.plugin.zjmaterielsynchronizationevent.entity.ZjMaterielSynchronizationEventEntity;
|
||||
import com.hzya.frame.plugin.zjmaterielsynchronizationevent.service.IZjMaterielSynchronizationEventService;
|
||||
import com.hzya.frame.u8.base.inventory.entity.InventoryEntity;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
|
@ -33,6 +34,8 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
|
|||
this.dao = zjMaterielSynchronizationEventDao;
|
||||
}
|
||||
|
||||
private String zjoa = "zjoa";
|
||||
private String zju8 = "zju8";
|
||||
|
||||
/**
|
||||
* @param requestJson
|
||||
|
@ -56,7 +59,8 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
|
|||
}
|
||||
ZjMaterielSynchronizationEventEntity entity = new ZjMaterielSynchronizationEventEntity();
|
||||
entity.setFormmain_id(formmain_id);
|
||||
List<ZjMaterielSynchronizationEventEntity> list = zjMaterielSynchronizationEventDao.queryBase(entity);
|
||||
entity.setDataSourceCode(zjoa);
|
||||
List<ZjMaterielSynchronizationEventEntity> list = zjMaterielSynchronizationEventDao.query(entity);
|
||||
if(list == null || list.size() == 0){
|
||||
return BaseResult.getFailureMessageEntity("onBeforeStart流程监听事件,未获取到明细数据");
|
||||
}
|
||||
|
@ -68,10 +72,22 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
|
|||
}
|
||||
ZjMaterielSynchronizationEventEntity entity1 = new ZjMaterielSynchronizationEventEntity();
|
||||
entity1.setFormmain_id(id);
|
||||
List<ZjMaterielSynchronizationEventEntity> list1 = zjMaterielSynchronizationEventDao.queryBase(entity1);
|
||||
entity1.setDataSourceCode(zjoa);
|
||||
List<ZjMaterielSynchronizationEventEntity> list1 = zjMaterielSynchronizationEventDao.query(entity1);
|
||||
if(list1 == null || list1.size() == 0){
|
||||
return BaseResult.getFailureMessageEntity("onProcessFinished流程监听事件,未获取到明细数据");
|
||||
}
|
||||
JsonResultEntity jsonResultEntity = checkData(list1,true);
|
||||
if(jsonResultEntity == null){
|
||||
return BaseResult.getFailureMessageEntity("onProcessFinished流程监听事件,校验发生系统错误");
|
||||
}
|
||||
if(!jsonResultEntity.isFlag()){
|
||||
return jsonResultEntity;
|
||||
}
|
||||
//组装数据,保存数据
|
||||
saveMaterielToU8(list1);
|
||||
//回写U8生成的编码
|
||||
updateOaCode(list1);
|
||||
return null;
|
||||
case "onStart"://流程发起 oa数据重新排序
|
||||
return BaseResult.getSuccessMessageEntity("排序暂不处理");
|
||||
|
@ -80,6 +96,26 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author lvleigang
|
||||
* @Description 回写U8生成的编码
|
||||
* @Date 10:04 上午 2025/3/19
|
||||
* @param list
|
||||
* @return void
|
||||
**/
|
||||
private void updateOaCode(List<ZjMaterielSynchronizationEventEntity> list) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author lvleigang
|
||||
* @Description 组装数据,保存数据
|
||||
* @Date 10:03 上午 2025/3/19
|
||||
* @param list
|
||||
* @return void
|
||||
**/
|
||||
private void saveMaterielToU8(List<ZjMaterielSynchronizationEventEntity> list) {
|
||||
}
|
||||
|
||||
/**
|
||||
* @Author lvleigang
|
||||
* @Description 解析参数id
|
||||
|
@ -198,7 +234,6 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
//判断存货分类里面如果有6或7,有一个必须有另一个
|
||||
if(num > 0){
|
||||
if(num1 == 0){
|
||||
|
@ -210,16 +245,25 @@ public class ZjMaterielSynchronizationEventServiceImpl extends BaseService<ZjMat
|
|||
return BaseResult.getFailureMessageEntity("存货分类存在7,不存在6");
|
||||
}
|
||||
}
|
||||
|
||||
//查询u8物料
|
||||
//zjMaterielSynchronizationEventDao
|
||||
List<InventoryEntity> inventoryEntities = zjMaterielSynchronizationEventDao.queryInventoryEntity(list,zju8);
|
||||
if(inventoryEntities == null || inventoryEntities.size() == 0){
|
||||
return BaseResult.getFailureMessageEntity("物料分类在U8中不存在");
|
||||
}
|
||||
//发起、保存判断物料分类是否在U8中存在
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
ZjMaterielSynchronizationEventEntity entity = list.get(i);
|
||||
|
||||
|
||||
boolean flags = false;
|
||||
for (int i1 = 0; i1 < inventoryEntities.size(); i1++) {
|
||||
if(entity.getField0043code().equals(inventoryEntities.get(i1).getcInvCode())){
|
||||
flags = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!flags){
|
||||
return BaseResult.getFailureMessageEntity("序号为"+entity.getField0004()+"明细行的物料分类在U8中不存在");
|
||||
}
|
||||
}
|
||||
|
||||
return BaseResult.getSuccessMessageEntity("校验成功");
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,128 @@
|
|||
package com.hzya.frame.plugin.ofs.plugin;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.base.PluginBaseEntity;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class OfsGetOrderInitializer extends PluginBaseEntity {
|
||||
Logger logger = LoggerFactory.getLogger(OfsGetOrderInitializer.class);
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return "ofsGetOrderInitializer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "数据库备份下发";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginLabel() {
|
||||
return "ofsGetOrderInitializer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginType() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Author lvleigang
|
||||
* @Description 获取ofs订单数据
|
||||
* @Date 3:12 下午 2024/10/24
|
||||
* @param requestJson
|
||||
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||
**/
|
||||
@Override
|
||||
public JsonResultEntity executeBusiness(JSONObject requestJson) {
|
||||
|
||||
//System.out.println("获取ofs订单数据");
|
||||
//System.out.println("获取ofs订单发送数据");
|
||||
//QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
|
||||
//queryOfsSoSaleOutVo.setPageNo(1L);
|
||||
//queryOfsSoSaleOutVo.setPageSize(200L);
|
||||
////queryOfsSoSaleOutVo.setCode("123123123");
|
||||
//queryOfsSoSaleOutVo.setCreated_start("2024-10-24 01:00:00");
|
||||
//queryOfsSoSaleOutVo.setCreated_end("2024-10-24 17:00:00");
|
||||
//queryOfsSoSaleOutVo.setClientCode("LETS");
|
||||
//String data = JSON.toJSONString(queryOfsSoSaleOutVo);
|
||||
////2024年7月30日 12:16:38生成签名
|
||||
//OfsHexUtil ofsHexUtil = new OfsHexUtil();
|
||||
//String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
//Map<String, String> params = new HashMap<>();
|
||||
//params.put("data", data);
|
||||
//String sign = ofsHexUtil.sign("ofs.salesOrder.search", data,"json", "1023142858", "1.0", "382e4a2584027a36ac9431103", timestamp);
|
||||
//String url = "http://39.98.58.229/api/edi/u8c/ofs/in?api=ofs.salesOrder.search&format=json&appKey=1023142858&v=1.0&sign="+sign+"×tamp="+timestamp;
|
||||
//
|
||||
//String returnData = postParams(url,params);
|
||||
|
||||
|
||||
return BaseResult.getSuccessMessageEntity("获取成功");
|
||||
|
||||
}
|
||||
//适用于post请求并传送form-data数据(同样适用于post的Raw类型的application-json格式)
|
||||
public String postParams(String url, Map<String, String> params) {
|
||||
//创建自定义的httpclient对象
|
||||
CloseableHttpClient client = HttpClients.custom().build();
|
||||
HttpPost post = new HttpPost(url);
|
||||
CloseableHttpResponse res = null;
|
||||
try {
|
||||
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
|
||||
Set<String> keySet = params.keySet();
|
||||
for (String key : keySet) {
|
||||
nvps.add(new BasicNameValuePair(key, params.get(key)));
|
||||
}
|
||||
post.setEntity(new UrlEncodedFormEntity(nvps, "utf-8"));
|
||||
res = client.execute(post);
|
||||
HttpEntity entity = res.getEntity();
|
||||
return EntityUtils.toString(entity, "utf-8");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
try {
|
||||
res.close();
|
||||
client.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
package com.hzya.frame.plugin.ofs.plugin;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.base.PluginBaseEntity;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class OfsRepushDataInitializer extends PluginBaseEntity {
|
||||
Logger logger = LoggerFactory.getLogger(OfsRepushDataInitializer.class);
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return "ofsRepushDataInitializer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "数据库备份下发";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginLabel() {
|
||||
return "ofsRepushDataInitializer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginType() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Author lvleigang
|
||||
* @Description 获取ofs订单重新推送数据
|
||||
* @Date 3:12 下午 2024/10/24
|
||||
* @param requestJson
|
||||
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||
**/
|
||||
@Override
|
||||
public JsonResultEntity executeBusiness(JSONObject requestJson) {
|
||||
|
||||
|
||||
System.out.println("获取ofs订单重新推送数据");
|
||||
|
||||
|
||||
return BaseResult.getSuccessMessageEntity("获取成功");
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,76 @@
|
|||
package com.hzya.frame.plugin.ofs.plugin;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.hzya.frame.base.PluginBaseEntity;
|
||||
import com.hzya.frame.web.entity.BaseResult;
|
||||
import com.hzya.frame.web.entity.JsonResultEntity;
|
||||
import org.apache.http.HttpEntity;
|
||||
import org.apache.http.NameValuePair;
|
||||
import org.apache.http.client.entity.UrlEncodedFormEntity;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.impl.client.CloseableHttpClient;
|
||||
import org.apache.http.impl.client.HttpClients;
|
||||
import org.apache.http.message.BasicNameValuePair;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class OfsSendDataInitializer extends PluginBaseEntity {
|
||||
Logger logger = LoggerFactory.getLogger(OfsSendDataInitializer.class);
|
||||
|
||||
@Override
|
||||
public void initialize() {
|
||||
logger.info(getPluginLabel() + "執行初始化方法initialize()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
logger.info(getPluginLabel() + "執行銷毀方法destroy()");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return "ofsSendDataInitializer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginName() {
|
||||
return "数据库备份下发";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginLabel() {
|
||||
return "ofsSendDataInitializer";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPluginType() {
|
||||
return "1";
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @Author lvleigang
|
||||
* @Description 获取ofs订单发送数据
|
||||
* @Date 3:12 下午 2024/10/24
|
||||
* @param requestJson
|
||||
* @return com.hzya.frame.web.entity.JsonResultEntity
|
||||
**/
|
||||
@Override
|
||||
public JsonResultEntity executeBusiness(JSONObject requestJson) {
|
||||
|
||||
return BaseResult.getSuccessMessageEntity("订单发送");
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<plugin>
|
||||
<id>ofsPlugin</id>
|
||||
<name>ofsPlugin插件</name>
|
||||
<category>20241024</category>
|
||||
</plugin>
|
|
@ -0,0 +1,7 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
|
||||
<beans default-autowire="byName">
|
||||
<bean name="ofsGetOrderInitializer" class="com.hzya.frame.plugin.ofs.plugin.OfsGetOrderInitializer" />
|
||||
<bean name="ofsRepushDataInitializer" class="com.hzya.frame.plugin.ofs.plugin.OfsRepushDataInitializer" />
|
||||
<bean name="ofsSendDataInitializer" class="com.hzya.frame.plugin.ofs.plugin.OfsSendDataInitializer" />
|
||||
</beans>
|
Loading…
Reference in New Issue