Merge remote-tracking branch 'origin/lets' into lets
This commit is contained in:
commit
30d5c9a4af
|
@ -0,0 +1,90 @@
|
|||
package com.hzya.frame.plugin.lets.constant;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* lets全局静态参数配置
|
||||
*
|
||||
*/
|
||||
public class OverallConstant {
|
||||
|
||||
private static final Map<String, String> devOverAll = new HashMap<>();
|
||||
|
||||
private static final Map<String, String> testOverAll = new HashMap<>();
|
||||
|
||||
private static final Map<String, String> prodOverAll = new HashMap<>();
|
||||
|
||||
private static final Map<String, String> 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");//存货分类删除
|
||||
//存货基本档案
|
||||
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");//存货基本档案取消封存
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -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";
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,23 +2,43 @@ 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货品档案分类 新增,修改,删除
|
||||
* 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.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
public class GoodsClassPluginInitializer extends PluginBaseEntity {
|
||||
|
@ -39,7 +59,7 @@ public class GoodsClassPluginInitializer extends PluginBaseEntity {
|
|||
|
||||
@Override
|
||||
public String getPluginId() {
|
||||
return "GoodsClassPluginInitializer";
|
||||
return "com.hzya.frame.plugin.lets.plugin.base.GoodsClassPluginInitializer";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -57,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;
|
||||
|
@ -84,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);
|
||||
}
|
||||
|
@ -104,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<BdInvclEntity> 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<String, Object> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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<IntegrationTaskLivingDetailsEntity> 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<IntegrationTaskLivingDetailsEntity> 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;
|
||||
}
|
||||
}
|
|
@ -5,5 +5,6 @@
|
|||
<bean name="soSaleOutPluginInitializerToC" class="com.hzya.frame.plugin.lets.plugin.sales.SoSaleOutPluginInitializerToC"/>
|
||||
|
||||
<!--基础档案-->
|
||||
<bean name="goodsPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.base.GoodsPluginInitializer"/>
|
||||
<bean name="goodsClassPluginInitializer" class="com.hzya.frame.plugin.lets.plugin.base.GoodsClassPluginInitializer"/>
|
||||
</beans>
|
|
@ -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");
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue