From 06d9000c40a43c67089807db74b5094a445d4956 Mon Sep 17 00:00:00 2001 From: zhengyf Date: Wed, 7 Aug 2024 14:35:36 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E4=B8=BD=E7=9F=A5=EF=BC=9A=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E6=8E=A8=E9=80=81u8c=E5=B7=A5=E5=85=B7=E7=B1=BB?= =?UTF-8?q?=EF=BC=88pk/code=EF=BC=89=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/lets/constant/OverallConstant.java | 93 ++++++++++++ .../lets/constant/ProfilesActiveConstant.java | 26 ++++ .../plugin/lets/util/PushDataByU8cUtil.java | 137 ++++++++++++++++++ 3 files changed, 256 insertions(+) create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/ProfilesActiveConstant.java create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/PushDataByU8cUtil.java diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java new file mode 100644 index 00000000..f2bea2e7 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java @@ -0,0 +1,93 @@ +package com.hzya.frame.plugin.lets.constant; + +import java.util.HashMap; +import java.util.Map; + +/** + * lets全局静态参数配置 + * + */ +public class OverallConstant { + + private static final Map devOverAll = new HashMap<>(); + + private static final Map testOverAll = new HashMap<>(); + + private static final Map prodOverAll = new HashMap<>(); + + private static final Map prodOverPublic = new HashMap<>(); + + static { + //dev + loadDev(); + //prod + loadProd(); + //公共部分 + loadPublic(); + } + + private static void loadPublic() { + + //存货分类 + prodOverPublic.put("bdinvclSave", "/u8cloud/api/uapbd/bdinvcl/save");//存货分类新增 + prodOverPublic.put("bdinvclUpdate", "/u8cloud/api/uapbd/bdinvcl/update");//存货分类修改 + prodOverPublic.put("bdinvclDelete", "/u8cloud/api/uapbd/bdinvcl/delete");//存货分类删除 + //存货基本档案 + /** + * * 存货基本档案新增 /u8cloud/api/uapbd/invbasdoc/insert + * * 存货基本档案修改 /u8cloud/api/uapbd/invbasdoc/update + * * 存货基本档案封存 /u8cloud/api/uapbd/invbasdoc/seal + * * 存货基本档案取消封存 /u8cloud/api/uapbd/invbasdoc/unseal + */ + prodOverPublic.put("bdinvclSave", "/u8cloud/api/uapbd/bdinvcl/save");//存货分类新增 + + + + } + + private static void loadDev() { + + devOverAll.put("u8cApiUsercodePK", "admin"); + devOverAll.put("u8cApiPasswordPK", "21232f297a57a5a743894a0e4a801fc3"); + devOverAll.put("u8cApiTrantypePK", "pk"); + devOverAll.put("u8cApiSystemPK", "lz"); + devOverAll.put("u8cApiServiceNamePK", "http://39.170.109.90:9099");//测试U8C + devOverAll.put("u8cApiNeedStackTracePK", "Y"); + devOverAll.put("u8cApiZdrPK", "0001A210000000000GVS");//单据制单人---测试环境:郑一凡 + + devOverAll.put("u8cApiUsercodeCode", "admin1"); + devOverAll.put("u8cApiPasswordCode", "e00cf25ad42683b3df678c61f42c6bda"); + devOverAll.put("u8cApiTrantypeCode", "code"); + devOverAll.put("u8cApiSystemCode", "lz1"); + devOverAll.put("u8cApiServiceNameCode", "http://39.170.109.90:9099");//测试U8C + devOverAll.put("u8cApiNeedStackTraceCode", "Y"); + devOverAll.put("u8cApiZdrCode", "15932295350");//单据制单人---测试环境:郑一凡 + + } + + private static void loadProd() { + + + } + + /** + * 根据key获取全局变量值 + * + * @param key key值 + * @return 返回String + */ + public static String getOverAllValue(String key) { + String value = null; + if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals("dev")) { + value = devOverAll.get(key); + } else if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals("test")) { + value = testOverAll.get(key); + } else if (ProfilesActiveConstant.LETS_PROFILES_ACTIVE.equals("prod")) { + value = prodOverAll.get(key); + } + if (value == null) { + value = prodOverPublic.get(key); + } + return value; + } +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/ProfilesActiveConstant.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/ProfilesActiveConstant.java new file mode 100644 index 00000000..62f90ae2 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/ProfilesActiveConstant.java @@ -0,0 +1,26 @@ +package com.hzya.frame.plugin.lets.constant; + +/** + * lets项目公共参数 + * + */ +public class ProfilesActiveConstant { + + public static final String LETS_PROFILES_ACTIVE = "dev"; + + public static final String LOG_STATUS_Y = "Y"; + + public static final String LOG_STATUS_N = "N"; + + public static final String LOG_STATUS_Y_H = "'Y','H'"; + + public static final String TYPE_DATE = "date"; + + public static final String TYPE_VBILLCODE = "vbillcode"; + + public static final String TYPE_DETAIL_ERROR = "details_error"; + + public static final String TYPE_TIME_FRAME = "time_frame"; + + public static final String TYPE_OTHER = "other"; +} \ No newline at end of file diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/PushDataByU8cUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/PushDataByU8cUtil.java new file mode 100644 index 00000000..b5488581 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/PushDataByU8cUtil.java @@ -0,0 +1,137 @@ +package com.hzya.frame.plugin.lets.util; + +import cn.hutool.core.lang.Assert; + +import com.hzya.frame.plugin.lets.constant.OverallConstant; +import org.apache.http.HttpResponse; +import org.apache.http.client.config.RequestConfig; +import org.apache.http.client.methods.HttpPost; +import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.impl.client.CloseableHttpClient; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.util.EntityUtils; +import org.springframework.stereotype.Component; + +/** + * U8C推送工具类 + */ +@Component +public class PushDataByU8cUtil { + /** + * 发起post请求,传递json类型 + * + * @param url 地址 + * @param data 请求参数 + * @return 返回消息 + */ + public String pushU8CByPK(String url, String data) throws Exception { + Assert.notNull(url, "请求地址不能为空"); + Assert.notNull(data, "请求参数不能为空(需要JSON格式)"); + + // 创建HttpClientBuilder + HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); + // HttpClient + CloseableHttpClient closeableHttpClient = httpClientBuilder.build(); + + try { + // 设置连接超时和读取超时 + RequestConfig requestConfig = RequestConfig.custom() + .setConnectTimeout(300000) // 连接超时时间为60秒 + .setSocketTimeout(300000) // 读取超时时间为60秒 + .build(); + + HttpPost post = new HttpPost(OverallConstant.getOverAllValue("u8cApiServiceNamePK") + url); + post.setHeader("Content-Type", "application/json;charset=UTF-8"); + post.setHeader("usercode", OverallConstant.getOverAllValue("u8cApiUsercodePK")); + post.setHeader("password", OverallConstant.getOverAllValue("u8cApiPasswordPK")); + post.setHeader("trantype", OverallConstant.getOverAllValue("u8cApiTrantypePK")); + post.setHeader("system", OverallConstant.getOverAllValue("u8cApiSystemPK")); + post.setHeader("needStackTrace", OverallConstant.getOverAllValue("u8cApiNeedStackTracePK")); + post.setConfig(requestConfig); + //post.setHeader("charset", "utf-8"); + + ByteArrayEntity entity = new ByteArrayEntity(data.getBytes("UTF-8")); + entity.setContentType("application/json"); + post.setEntity(entity); + + HttpResponse response = closeableHttpClient.execute(post); + // 处理返回结果乱码问题 + if (response != null && response.getEntity() != null) { + String resultStr = EntityUtils.toString(response.getEntity(), "UTF-8"); + return resultStr; + } + } catch (Exception e) { + e.printStackTrace(); + Assert.state(false, "拉取/推送失败(pushU8CByPK),失败原因:{} 请求地址:{}", e.getMessage(), url); + } finally { + try { + if (closeableHttpClient != null) { + closeableHttpClient.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return null; + } + + /** + * 发起post请求,传递json类型 + * + * u8c code模式。 + * + * @param url 地址 + * @param data 请求参数 + * @return 返回消息 + */ + public String pushU8CByCode(String url, String data) throws Exception { + Assert.notNull(url, "请求地址不能为空"); + Assert.notNull(data, "请求参数不能为空(需要JSON格式)"); + + // 创建HttpClientBuilder + HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); + // HttpClient + CloseableHttpClient closeableHttpClient = httpClientBuilder.build(); + + try { + // 设置连接超时和读取超时 + RequestConfig requestConfig = RequestConfig.custom() + .setConnectTimeout(300000) // 连接超时时间为60秒 + .setSocketTimeout(300000) // 读取超时时间为60秒 + .build(); + + HttpPost post = new HttpPost(OverallConstant.getOverAllValue("u8cApiServiceNameCode") + url); + post.setHeader("Content-Type", "application/json;charset=UTF-8"); + post.setHeader("usercode", OverallConstant.getOverAllValue("u8cApiUsercodeCode")); + post.setHeader("password", OverallConstant.getOverAllValue("u8cApiPasswordCode")); + post.setHeader("trantype", OverallConstant.getOverAllValue("u8cApiTrantypeCode")); + post.setHeader("system", OverallConstant.getOverAllValue("u8cApiSystemCode")); + post.setHeader("needStackTrace", OverallConstant.getOverAllValue("u8cApiNeedStackTraceCode")); + post.setConfig(requestConfig); + //post.setHeader("charset", "utf-8"); + + ByteArrayEntity entity = new ByteArrayEntity(data.getBytes("UTF-8")); + entity.setContentType("application/json"); + post.setEntity(entity); + + HttpResponse response = closeableHttpClient.execute(post); + // 处理返回结果乱码问题 + if (response != null && response.getEntity() != null) { + String resultStr = EntityUtils.toString(response.getEntity(), "UTF-8"); + return resultStr; + } + } catch (Exception e) { + e.printStackTrace(); + Assert.state(false, "拉取/推送失败(pushU8CByCode),失败原因:{} 请求地址:{}", e.getMessage(), url); + } finally { + try { + if (closeableHttpClient != null) { + closeableHttpClient.close(); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + return null; + } +} From f9f333169f7e93eb4e4dc7e191d811881263f0de Mon Sep 17 00:00:00 2001 From: zhengyf Date: Wed, 7 Aug 2024 14:36:07 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E4=B8=BD=E7=9F=A5=EF=BC=9A=E8=B4=A7?= =?UTF-8?q?=E5=93=81=E5=88=86=E7=B1=BB=EF=BC=8C=E8=B4=A7=E5=93=81=E6=A1=A3?= =?UTF-8?q?=E6=A1=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../base/GoodsClassPluginInitializer.java | 15 ++- .../plugin/base/GoodsPluginInitializer.java | 108 ++++++++++++++++++ .../sowow/spring/spring-sowow-plugin.xml | 1 + 3 files changed, 119 insertions(+), 5 deletions(-) create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsPluginInitializer.java diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsClassPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsClassPluginInitializer.java index 71ec13e0..cf03a2f8 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsClassPluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsClassPluginInitializer.java @@ -13,10 +13,15 @@ import org.slf4j.LoggerFactory; * OFS->U8C货品档案分类 新增,修改,删除 * add by zyd 20240802 * - * 存货基本档案新增 /u8cloud/api/uapbd/invbasdoc/insert - * 存货基本档案修改 /u8cloud/api/uapbd/invbasdoc/update - * 存货基本档案封存 /u8cloud/api/uapbd/invbasdoc/seal - * 存货基本档案取消封存 /u8cloud/api/uapbd/invbasdoc/unseal + * 存货分类新增 /u8cloud/api/uapbd/bdinvcl/save + * 存货分类修改 /u8cloud/api/uapbd/bdinvcl/update + * 存货分类删除 /u8cloud/api/uapbd/bdinvcl/delete + * + * U8C分类规则 XX-XXX-XX,自动截断 + * eg: + * 一级:AA + * 二级:AA001,自动识别为AA的下级 + * 三级:AA00101自动识别为AA001的下级 */ import java.util.Date; import java.util.concurrent.locks.ReentrantLock; @@ -39,7 +44,7 @@ public class GoodsClassPluginInitializer extends PluginBaseEntity { @Override public String getPluginId() { - return "GoodsClassPluginInitializer"; + return "com.hzya.frame.plugin.lets.plugin.base.GoodsClassPluginInitializer"; } @Override diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsPluginInitializer.java new file mode 100644 index 00000000..4d0b284c --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsPluginInitializer.java @@ -0,0 +1,108 @@ +package com.hzya.frame.plugin.lets.plugin.base; + +import cn.hutool.core.date.DateField; +import cn.hutool.core.date.DateUtil; +import com.alibaba.fastjson.JSONObject; +import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.web.entity.JsonResultEntity; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.Date; +import java.util.concurrent.locks.ReentrantLock; + +/** + * OFS->U8C货品档案 新增,修改,删除 + * add by zyd 20240802 + * + * 存货基本档案新增 /u8cloud/api/uapbd/invbasdoc/insert + * 存货基本档案修改 /u8cloud/api/uapbd/invbasdoc/update + * 存货基本档案封存 /u8cloud/api/uapbd/invbasdoc/seal + * 存货基本档案取消封存 /u8cloud/api/uapbd/invbasdoc/unseal + */ +public class GoodsPluginInitializer extends PluginBaseEntity { + + Logger logger = LoggerFactory.getLogger(GoodsPluginInitializer.class); + + private static final ReentrantLock LOCK = new ReentrantLock(true); + + @Override + public void initialize() { + logger.info(getPluginLabel() + "執行初始化方法initialize()"); + } + + @Override + public void destroy() { + logger.info(getPluginLabel() + "執行銷毀方法destroy()"); + } + + @Override + public String getPluginId() { + return "com.hzya.frame.plugin.lets.plugin.base.GoodsPluginInitializer"; + } + + @Override + public String getPluginName() { + return "丽知:OFS货品档案--->U8C货品档案"; + } + + @Override + public String getPluginLabel() { + return "丽知:OFS货品档案--->U8C货品档案"; + } + + @Override + public String getPluginType() { + return "1"; + } + + @Override + public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { + return null; + } + + + /** + * 默认推送 + */ + public void start() { + try { + //获取当前时间 + Date currentDate = new Date(); + Date startTime = DateUtil.offset(currentDate, DateField.MINUTE, -10); + Date endTime = DateUtil.offset(currentDate, DateField.MINUTE, -2); + String startTimeStr = DateUtil.format(startTime, "yyyy-MM-dd HH:mm:ss" + ".000"); + String endTimeStr = DateUtil.format(endTime, "yyyy-MM-dd HH:mm:ss" + ".000"); + } catch (Exception e) { + logger.error("丽知:OFS货品档案--->U8C货品档案,start()方法报错:", e); + } + } + + /** + * 按分类名称 + */ + public void start(String goodsName) { + try { + } catch (Exception e) { + logger.error("丽知:丽知:OFS货品档案--->U8C货品档案,start(String goodsName)方法报错:", e); + } + + } + + /** + * 按时间区间 + */ + public void start(String startTime, String endTime) { + try { + Date business_start = DateUtil.parse(startTime); + Date business_end = DateUtil.parse(endTime); + String start = DateUtil.format(business_start, "yyyy-MM-dd") + " 00:00:00"; + String end = DateUtil.format(business_end, "yyyy-MM-dd") + " 23:59:59"; + } catch (Exception e) { + logger.error("丽知:丽知:OFS货品档案--->U8C货品档案,start(String startTime, String endTime)方法报错:", e); + } + } + + + +} diff --git a/buildpackage/src/main/resources/cfgHome/plugin/sowow/spring/spring-sowow-plugin.xml b/buildpackage/src/main/resources/cfgHome/plugin/sowow/spring/spring-sowow-plugin.xml index fb404807..c090e1d3 100644 --- a/buildpackage/src/main/resources/cfgHome/plugin/sowow/spring/spring-sowow-plugin.xml +++ b/buildpackage/src/main/resources/cfgHome/plugin/sowow/spring/spring-sowow-plugin.xml @@ -5,5 +5,6 @@ + \ No newline at end of file From fe0587f4c2212d40d5d8e01a1e11b1cc5f92ef2e Mon Sep 17 00:00:00 2001 From: zhengyf Date: Wed, 7 Aug 2024 14:38:30 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=B8=BD=E7=9F=A5=EF=BC=9A=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=AD=98=E8=B4=A7=E5=9F=BA=E6=9C=AC=E6=A1=A3=E6=A1=88?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../frame/plugin/lets/constant/OverallConstant.java | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java index f2bea2e7..fac1989c 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/constant/OverallConstant.java @@ -33,13 +33,10 @@ public class OverallConstant { prodOverPublic.put("bdinvclUpdate", "/u8cloud/api/uapbd/bdinvcl/update");//存货分类修改 prodOverPublic.put("bdinvclDelete", "/u8cloud/api/uapbd/bdinvcl/delete");//存货分类删除 //存货基本档案 - /** - * * 存货基本档案新增 /u8cloud/api/uapbd/invbasdoc/insert - * * 存货基本档案修改 /u8cloud/api/uapbd/invbasdoc/update - * * 存货基本档案封存 /u8cloud/api/uapbd/invbasdoc/seal - * * 存货基本档案取消封存 /u8cloud/api/uapbd/invbasdoc/unseal - */ - prodOverPublic.put("bdinvclSave", "/u8cloud/api/uapbd/bdinvcl/save");//存货分类新增 + prodOverPublic.put("bdinvclSave", "/u8cloud/api/uapbd/bdinvcl/save");//存货基本档案新增 + prodOverPublic.put("bdinvclUpdate", "/u8cloud/api/uapbd/invbasdoc/update");//存货基本档案修改 + prodOverPublic.put("bdinvclSeal", "/u8cloud/api/uapbd/invbasdoc/seal");//存货基本档案封存 + prodOverPublic.put("bdinvclUnseal", "/u8cloud/api/uapbd/invbasdoc/unseal");//存货基本档案取消封存 From 72d28c22014787b8289f738b60a7e98c8045b8f0 Mon Sep 17 00:00:00 2001 From: zhengyf Date: Wed, 7 Aug 2024 17:51:24 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E4=B8=BD=E7=9F=A5=EF=BC=9A=E5=AD=98?= =?UTF-8?q?=E8=B4=A7=E5=88=86=E7=B1=BB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../plugin/lets/entity/BdInvclEntity.java | 150 +++--------------- .../base/GoodsClassPluginInitializer.java | 121 +++++++++++++- .../util/SaveOrUpdateBusinessLogUtil.java | 126 +++++++++++++++ .../plugin/lets/plugin/base/BaseTest.java | 21 +++ 4 files changed, 288 insertions(+), 130 deletions(-) create mode 100644 buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/SaveOrUpdateBusinessLogUtil.java create mode 100644 buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/BaseTest.java diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdInvclEntity.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdInvclEntity.java index 3d2a2ea3..48612dc6 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdInvclEntity.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/entity/BdInvclEntity.java @@ -1,159 +1,51 @@ package com.hzya.frame.plugin.lets.entity; import com.hzya.frame.web.entity.BaseEntity; +import lombok.Data; + /** * (BdInvcl)实体类 * * @author makejava * @since 2024-01-09 15:08:19 */ +@Data public class BdInvclEntity extends BaseEntity { - + + /** 平均成本 */ private Double averagecost; + /** 平均生产提前期 */ private Integer averagemmahead; + /** 平均采购提前期 */ private Integer averagepurahead; + /** 平均采购提前期 */ private Double avgprice; + /** 删除标志 */ private Integer dr; + /** 末级标志 */ private String endflag; + /** 外文名 */ private String forinvname; + /** 分类编码 */ private String invclasscode; + /** 编码级次 */ private Integer invclasslev; + /** 类别名称 */ private String invclassname; + /** 电子采购分类 */ private String iselectrans; + /** 是否红火台 */ private String ishuo; + /** 公司主键 */ private String pkCorp; + private String pk_corp; + /** 存货分类主键 */ private String pkInvcl; + /** 封存标志 */ private String sealdate; + /** 时间戳 */ private String ts; - public Double getAveragecost() { - return averagecost; - } - - public void setAveragecost(Double averagecost) { - this.averagecost = averagecost; - } - - public Integer getAveragemmahead() { - return averagemmahead; - } - - public void setAveragemmahead(Integer averagemmahead) { - this.averagemmahead = averagemmahead; - } - - public Integer getAveragepurahead() { - return averagepurahead; - } - - public void setAveragepurahead(Integer averagepurahead) { - this.averagepurahead = averagepurahead; - } - - public Double getAvgprice() { - return avgprice; - } - - public void setAvgprice(Double avgprice) { - this.avgprice = avgprice; - } - - public Integer getDr() { - return dr; - } - - public void setDr(Integer dr) { - this.dr = dr; - } - - public String getEndflag() { - return endflag; - } - - public void setEndflag(String endflag) { - this.endflag = endflag; - } - - public String getForinvname() { - return forinvname; - } - - public void setForinvname(String forinvname) { - this.forinvname = forinvname; - } - - public String getInvclasscode() { - return invclasscode; - } - - public void setInvclasscode(String invclasscode) { - this.invclasscode = invclasscode; - } - - public Integer getInvclasslev() { - return invclasslev; - } - - public void setInvclasslev(Integer invclasslev) { - this.invclasslev = invclasslev; - } - - public String getInvclassname() { - return invclassname; - } - - public void setInvclassname(String invclassname) { - this.invclassname = invclassname; - } - - public String getIselectrans() { - return iselectrans; - } - - public void setIselectrans(String iselectrans) { - this.iselectrans = iselectrans; - } - - public String getIshuo() { - return ishuo; - } - - public void setIshuo(String ishuo) { - this.ishuo = ishuo; - } - - public String getPkCorp() { - return pkCorp; - } - - public void setPkCorp(String pkCorp) { - this.pkCorp = pkCorp; - } - - public String getPkInvcl() { - return pkInvcl; - } - - public void setPkInvcl(String pkInvcl) { - this.pkInvcl = pkInvcl; - } - - public String getSealdate() { - return sealdate; - } - - public void setSealdate(String sealdate) { - this.sealdate = sealdate; - } - - public String getTs() { - return ts; - } - - public void setTs(String ts) { - this.ts = ts; - } - } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsClassPluginInitializer.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsClassPluginInitializer.java index cf03a2f8..c9476da2 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsClassPluginInitializer.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/base/GoodsClassPluginInitializer.java @@ -2,12 +2,25 @@ package com.hzya.frame.plugin.lets.plugin.base; import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.Assert; +import cn.hutool.json.JSONUtil; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.hzya.frame.base.PluginBaseEntity; +import com.hzya.frame.plugin.lets.constant.OverallConstant; +import com.hzya.frame.plugin.lets.constant.ProfilesActiveConstant; +import com.hzya.frame.plugin.lets.entity.BdInvclEntity; import com.hzya.frame.plugin.lets.plugin.sales.SoSaleOutPluginInitializerToC; +import com.hzya.frame.plugin.lets.u8cdto.ReusltStrDto; +import com.hzya.frame.plugin.lets.util.PushDataByU8cUtil; +import com.hzya.frame.plugin.lets.util.SaveOrUpdateBusinessLogUtil; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; import com.hzya.frame.web.entity.JsonResultEntity; +import com.zaxxer.hikari.util.FastList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; /** * OFS->U8C货品档案分类 新增,修改,删除 @@ -23,7 +36,9 @@ import org.slf4j.LoggerFactory; * 二级:AA001,自动识别为AA的下级 * 三级:AA00101自动识别为AA001的下级 */ -import java.util.Date; +import java.text.SimpleDateFormat; +import java.time.LocalDate; +import java.util.*; import java.util.concurrent.locks.ReentrantLock; public class GoodsClassPluginInitializer extends PluginBaseEntity { @@ -62,6 +77,13 @@ public class GoodsClassPluginInitializer extends PluginBaseEntity { return "1"; } + @Autowired + private PushDataByU8cUtil pushDataByU8cUtil; + @Autowired + private IIntegrationTaskLivingDetailsDao iIntegrationTaskLivingDetailsDao; + @Autowired + private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil; + @Override public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { return null; @@ -89,6 +111,7 @@ public class GoodsClassPluginInitializer extends PluginBaseEntity { */ public void start(String className) { try { + implement(); } catch (Exception e) { logger.error("丽知:OFS货品档案分类--->U8C货品档案分类,start(String className)方法报错:", e); } @@ -109,6 +132,102 @@ public class GoodsClassPluginInitializer extends PluginBaseEntity { } } + public void filterGoodsClass() { + return; + } + + /** + * U8C分类规则 XX-XXX-XX,自动截断 + * eg: + * 一级:AA + * 二级:AA001,自动识别为AA的下级 + * 三级:AA00101自动识别为AA001的下级 + */ + public void implement() { + + //生成业务日期 + String businessFormat = ""; + String mapStr=""; + + + String invclasscode=null; + String invclassname=null; + try { + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); // 定义日期格式 + Date date = new Date(System.currentTimeMillis()); // 创建Date对象 + businessFormat = sdf.format(date); // 将Date对象格式化为字符串 + + + + + List bdInvclEntities = new ArrayList<>(); + + BdInvclEntity bdInvclEntity = new BdInvclEntity(); + + //分类编码-invclasscode + invclasscode = "AA004"; + bdInvclEntity.setInvclasscode(invclasscode); + + //分类名称-invclassname + invclassname = "分类名称:AA004"; + + bdInvclEntity.setInvclassname(invclassname); + //公司编码-pk_corp + String pk_corp = "1001"; + bdInvclEntity.setPk_corp(pk_corp); + //分类级别-invclasslevel + bdInvclEntities.add(bdInvclEntity); + + String jsonStr = JSONUtil.toJsonStr(bdInvclEntities); + + Map map = new HashMap<>(); + map.put("invcl", jsonStr); + mapStr = JSONUtil.toJsonStr(map); + + String response = pushDataByU8cUtil.pushU8CByPK(OverallConstant.getOverAllValue("bdinvclSave"), mapStr); + System.out.println(response); + boolean isSuccess = false; + if (response != null && !"".equals(response)) { + ReusltStrDto reusltStrDto = JSON.parseObject(response, ReusltStrDto.class); + if ("success".equals(reusltStrDto.getStatus())) { + isSuccess = true; + } + } + if (!isSuccess) { + Assert.state(false, "推送U8C-->丽知:OFS货品档案分类--->U8C货品档案分类失败 接口返回结果:{} 接口入参:{}", response, jsonStr); + } + //成功 + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_Y); + integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(response); + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat); + integrationTaskLivingDetailsEntity.setRootAppPk(invclasscode); + integrationTaskLivingDetailsEntity.setRootAppBill(invclassname); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); + + + } catch (Exception e) { + e.printStackTrace(); + logger.error("丽知:OFS货品档案分类--->U8C货品档案分类,implement()方法报错:", e); + //失败 + String ErrMessage = e.getMessage(); + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity.setNewState(ProfilesActiveConstant.LOG_STATUS_N); + integrationTaskLivingDetailsEntity.setRootAppNewData(mapStr); + integrationTaskLivingDetailsEntity.setNewTransmitInfo(ErrMessage); + integrationTaskLivingDetailsEntity.setNewPushDate(new Date()); + integrationTaskLivingDetailsEntity.setBusinessDate(businessFormat); + integrationTaskLivingDetailsEntity.setRootAppPk(invclasscode); + integrationTaskLivingDetailsEntity.setRootAppBill(invclassname); + integrationTaskLivingDetailsEntity.setPluginId(getPluginId()); + saveOrUpdateBusinessLogUtil.saveOrUpdate(integrationTaskLivingDetailsEntity); + } + + } } diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/SaveOrUpdateBusinessLogUtil.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/SaveOrUpdateBusinessLogUtil.java new file mode 100644 index 00000000..2afb5f00 --- /dev/null +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/util/SaveOrUpdateBusinessLogUtil.java @@ -0,0 +1,126 @@ +package com.hzya.frame.plugin.lets.util; + + +import cn.hutool.core.lang.Assert; + +import com.hzya.frame.sysnew.integtationTaskLivingDetails.dao.IIntegrationTaskLivingDetailsDao; +import com.hzya.frame.sysnew.integtationTaskLivingDetails.entity.IntegrationTaskLivingDetailsEntity; +import com.hzya.frame.uuid.UUIDLong; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * 保存或者更新业务日志 + * + * @author liuyang + */ +@Component +public class SaveOrUpdateBusinessLogUtil { + + @Autowired + private IIntegrationTaskLivingDetailsDao iIntegrationTaskLivingDetailsDao; + + private static final Object insertOrUpdateLock = new Object(); + + /** + * 保存或者更新 + * + * @param integrationTaskLivingDetailsEntity 提交参数 + */ + public void saveOrUpdate(IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity) { + Assert.notNull(integrationTaskLivingDetailsEntity, "integrationTaskLivingDetailsEntity不能为空"); + Assert.notNull(integrationTaskLivingDetailsEntity.getRootAppPk(), "源系统单号不能为空"); + Assert.notNull(integrationTaskLivingDetailsEntity.getPluginId(), "场景id不能为空"); + +// Thread thread = new Thread(new Runnable() { +// @Override +// public void run() { +// synchronized (insertOrUpdateLock) { +// IntegrationTaskLivingDetailsEntity integrationTaskLivingDetails = null; +// IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity1 = new IntegrationTaskLivingDetailsEntity(); +// integrationTaskLivingDetailsEntity1.setRoot_app_pk(integrationTaskLivingDetailsEntity.getRoot_app_pk()); +// integrationTaskLivingDetailsEntity1.setPlugin_id(integrationTaskLivingDetailsEntity.getPlugin_id()); +// List integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity1); +// if (integrationTaskLivingDetailsEntities != null && integrationTaskLivingDetailsEntities.size() > 0) { +// integrationTaskLivingDetails = integrationTaskLivingDetailsEntities.get(0); +// } +// +// if (integrationTaskLivingDetails != null) { +// //存在 +// integrationTaskLivingDetailsEntity.setId(integrationTaskLivingDetails.getId()); +// updateSuccessMessage(integrationTaskLivingDetailsEntity); +// iIntegrationTaskLivingDetailsDao.update("com.hzya.frame.sys.integrationtask.living.dao.impl.IntegrationTaskLivingDetailsDaoImpl.entity_updatebyid", integrationTaskLivingDetailsEntity); +// } else { +// //不存在 +// Long uuid = UUIDLong.longUUID(); +// integrationTaskLivingDetailsEntity.setId(String.valueOf(uuid)); +// updateSuccessMessage(integrationTaskLivingDetailsEntity); +// iIntegrationTaskLivingDetailsDao.save(integrationTaskLivingDetailsEntity); +// } +// } +// } +// }); +// thread.start(); +// try { +// thread.join(); +// } catch (Exception e) { +// e.printStackTrace(); +// } + + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetails = null; + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity1 = new IntegrationTaskLivingDetailsEntity(); + integrationTaskLivingDetailsEntity1.setRootAppPk(integrationTaskLivingDetailsEntity.getRootAppPk()); + integrationTaskLivingDetailsEntity1.setPluginId(integrationTaskLivingDetailsEntity.getPluginId()); + List integrationTaskLivingDetailsEntities = iIntegrationTaskLivingDetailsDao.query(integrationTaskLivingDetailsEntity1); + if (integrationTaskLivingDetailsEntities != null && integrationTaskLivingDetailsEntities.size() > 0) { + integrationTaskLivingDetails = integrationTaskLivingDetailsEntities.get(0); + } + if (integrationTaskLivingDetails != null) { + //存在 + synchronized (insertOrUpdateLock) { + integrationTaskLivingDetailsEntity.setId(integrationTaskLivingDetails.getId()); + updateSuccessMessage(integrationTaskLivingDetailsEntity); + iIntegrationTaskLivingDetailsDao.update("com.hzya.frame.sys.integrationtask.living.dao.impl.IntegrationTaskLivingDetailsDaoImpl.entity_updatebyid", integrationTaskLivingDetailsEntity); + } + } else { + //不存在 + Long uuid = UUIDLong.longUUID(); + integrationTaskLivingDetailsEntity.setId(String.valueOf(uuid)); + updateSuccessMessage(integrationTaskLivingDetailsEntity); + iIntegrationTaskLivingDetailsDao.save(integrationTaskLivingDetailsEntity); + } + } + + /** + * 修改成功消息 + * + * @author liuyang + */ + private void updateSuccessMessage(IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity) { + if (integrationTaskLivingDetailsEntity != null) { + if ("Y".equals(integrationTaskLivingDetailsEntity.getNewState())) { + //成功 + integrationTaskLivingDetailsEntity.setRootAppNewData("success"); + integrationTaskLivingDetailsEntity.setNewTransmitInfo("success"); + /** + * integrationTaskLivingDetailsEntity.setRoot_app_new_data(JSON.toJSONString(searchPurchaseReceiptOrder)); + * integrationTaskLivingDetailsEntity.setNew_transmit_info(cgrkApi); + */ + } + } + } + + /** + * 根据明细id查询明细信息 + * + * @author liuyang + */ + public IntegrationTaskLivingDetailsEntity queryIntegrationTaskLivingDetailsEntity(String integration_task_living_details_id) { + Assert.notNull(integration_task_living_details_id, "业务明细id不能为空"); + IntegrationTaskLivingDetailsEntity integrationTaskLivingDetailsEntity = iIntegrationTaskLivingDetailsDao.get(integration_task_living_details_id); + Assert.notNull(integrationTaskLivingDetailsEntity, "根据主键id没有查询到明细信息"); + return integrationTaskLivingDetailsEntity; + } +} \ No newline at end of file diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/BaseTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/BaseTest.java new file mode 100644 index 00000000..5c60217c --- /dev/null +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/base/BaseTest.java @@ -0,0 +1,21 @@ +package com.hzya.frame.plugin.lets.plugin.base; + +import com.hzya.frame.WebappApplication; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.junit4.SpringRunner; + +@RunWith(SpringRunner.class) +@SpringBootTest(classes = WebappApplication.class) +public class BaseTest { + + @Autowired + private GoodsClassPluginInitializer goodsClassPluginInitializer; + + @Test + public void t00(){ + goodsClassPluginInitializer.start("666"); + } +}