丽知:存货分类接口

This commit is contained in:
zhengyf 2024-08-07 17:51:24 +08:00
parent fe0587f4c2
commit 72d28c2201
4 changed files with 288 additions and 130 deletions

View File

@ -1,159 +1,51 @@
package com.hzya.frame.plugin.lets.entity; package com.hzya.frame.plugin.lets.entity;
import com.hzya.frame.web.entity.BaseEntity; import com.hzya.frame.web.entity.BaseEntity;
import lombok.Data;
/** /**
* (BdInvcl)实体类 * (BdInvcl)实体类
* *
* @author makejava * @author makejava
* @since 2024-01-09 15:08:19 * @since 2024-01-09 15:08:19
*/ */
@Data
public class BdInvclEntity extends BaseEntity { public class BdInvclEntity extends BaseEntity {
/** 平均成本 */
private Double averagecost; private Double averagecost;
/** 平均生产提前期 */
private Integer averagemmahead; private Integer averagemmahead;
/** 平均采购提前期 */
private Integer averagepurahead; private Integer averagepurahead;
/** 平均采购提前期 */
private Double avgprice; private Double avgprice;
/** 删除标志 */
private Integer dr; private Integer dr;
/** 末级标志 */
private String endflag; private String endflag;
/** 外文名 */
private String forinvname; private String forinvname;
/** 分类编码 */
private String invclasscode; private String invclasscode;
/** 编码级次 */
private Integer invclasslev; private Integer invclasslev;
/** 类别名称 */
private String invclassname; private String invclassname;
/** 电子采购分类 */
private String iselectrans; private String iselectrans;
/** 是否红火台 */
private String ishuo; private String ishuo;
/** 公司主键 */
private String pkCorp; private String pkCorp;
private String pk_corp;
/** 存货分类主键 */
private String pkInvcl; private String pkInvcl;
/** 封存标志 */
private String sealdate; private String sealdate;
/** 时间戳 */
private String ts; 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;
}
} }

View File

@ -2,12 +2,25 @@ package com.hzya.frame.plugin.lets.plugin.base;
import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil; 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.alibaba.fastjson.JSONObject;
import com.hzya.frame.base.PluginBaseEntity; 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.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.hzya.frame.web.entity.JsonResultEntity;
import com.zaxxer.hikari.util.FastList;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
/** /**
* OFS->U8C货品档案分类 新增修改删除 * OFS->U8C货品档案分类 新增修改删除
@ -23,7 +36,9 @@ import org.slf4j.LoggerFactory;
* 二级AA001,自动识别为AA的下级 * 二级AA001,自动识别为AA的下级
* 三级AA00101自动识别为AA001的下级 * 三级AA00101自动识别为AA001的下级
*/ */
import java.util.Date; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
public class GoodsClassPluginInitializer extends PluginBaseEntity { public class GoodsClassPluginInitializer extends PluginBaseEntity {
@ -62,6 +77,13 @@ public class GoodsClassPluginInitializer extends PluginBaseEntity {
return "1"; return "1";
} }
@Autowired
private PushDataByU8cUtil pushDataByU8cUtil;
@Autowired
private IIntegrationTaskLivingDetailsDao iIntegrationTaskLivingDetailsDao;
@Autowired
private SaveOrUpdateBusinessLogUtil saveOrUpdateBusinessLogUtil;
@Override @Override
public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception { public JsonResultEntity executeBusiness(JSONObject requestJson) throws Exception {
return null; return null;
@ -89,6 +111,7 @@ public class GoodsClassPluginInitializer extends PluginBaseEntity {
*/ */
public void start(String className) { public void start(String className) {
try { try {
implement();
} catch (Exception e) { } catch (Exception e) {
logger.error("丽知OFS货品档案分类--->U8C货品档案分类,start(String className)方法报错:", 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<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);
}
}
} }

View File

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

View File

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