refactor(sales): 优化档案查询中的库存处理逻辑
- 新增 entityInsertOrUpdateBatchStock1V2 方法,用于更新出库状态的日志(适合档案转换部分的日志处理) - 在 SoSaleOutPluginInitializerToC 中实现 updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiryV2 方法,用于批量修改成功或失败状态 - 更新相关 XML 文件,添加新的 SQL 语句 - 修改测试用例,注释掉部分代码并添加新的测试场景
This commit is contained in:
parent
251930ad8f
commit
fd8d287b95
|
@ -26,6 +26,13 @@ public interface ITocofsSaleoutDetailedDao extends IBaseDao<TocofsSaleoutDetaile
|
|||
*/
|
||||
void entityInsertOrUpdateBatchStock1(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新出库状态的日志(适合档案转换部分的日志处理)
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
void entityInsertOrUpdateBatchStock1V2(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception;
|
||||
|
||||
/**
|
||||
* 更新出库状态的日志(适用库存推送)
|
||||
*
|
||||
|
|
|
@ -23,6 +23,11 @@ public class TocofsSaleoutDetailedDaoImpl extends MybatisGenericDao<TocofsSaleou
|
|||
public void entityInsertOrUpdateBatchStock1(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception {
|
||||
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock", tocofsSaleoutDetailedEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void entityInsertOrUpdateBatchStock1V2(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception {
|
||||
insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStockV2", tocofsSaleoutDetailedEntities);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void entityInsertOrUpdateBatchStock2(List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntities) throws Exception {
|
||||
|
|
|
@ -853,6 +853,25 @@
|
|||
</insert>
|
||||
|
||||
|
||||
<!-- 出库成功,更新推送状态(适合档案转啊)V2-->
|
||||
<insert id="entityInsertOrUpdateBatchStockV2" keyProperty="id" useGeneratedKeys="true" parameterType="com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity">
|
||||
insert into tocofs_saleout_detailed(id,def1,def2,newState2)
|
||||
values
|
||||
<foreach collection="list" item="entity" separator=",">
|
||||
(
|
||||
#{entity.id},
|
||||
#{entity.def1},
|
||||
#{entity.def2},
|
||||
#{entity.newstate2}
|
||||
)
|
||||
</foreach>
|
||||
on duplicate key update
|
||||
id = values(id),
|
||||
def1 = values(def1),
|
||||
def2 = values(def2),
|
||||
newState2 = values(newState2)
|
||||
</insert>
|
||||
|
||||
<!-- TOC更新推送状态(适合库存同步)-->
|
||||
<insert id="entityInsertOrUpdateBatchStock2" keyProperty="id" useGeneratedKeys="true" parameterType="com.hzya.frame.plugin.lets.ofs.entity.TocofsSaleoutDetailedEntity">
|
||||
insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary)
|
||||
|
|
|
@ -1403,7 +1403,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
|
||||
//批量把错误写入到日志信息表
|
||||
if (errorHeaderDetailsDtoDtoList.size() > 0) {
|
||||
updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiry(errorHeaderDetailsDtoDtoList);
|
||||
updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiryV2(errorHeaderDetailsDtoDtoList);
|
||||
}
|
||||
return sonDetailsDtoList;
|
||||
}
|
||||
|
@ -2286,7 +2286,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
}
|
||||
|
||||
/**
|
||||
* 批量修改成功、或者失败,适合档案查询的部分
|
||||
* 批量修改成功、或者失败,适合档案查询关于库存的部分
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
|
@ -2346,6 +2346,68 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量修改成功、或者失败,适合档案查询关于确认收入的部门
|
||||
*
|
||||
* @author liuyang
|
||||
*/
|
||||
private void updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiryV2(List<ErrorHeaderDetailsDtoDto> errorHeaderDetailsDtoDtoList) {
|
||||
Assert.notNull(errorHeaderDetailsDtoDtoList, "errorHeaderDetailsDtoDtoList不能为空!");
|
||||
|
||||
Thread thread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
if (errorHeaderDetailsDtoDtoList != null && errorHeaderDetailsDtoDtoList.size() > 0) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList = new ArrayList<>();
|
||||
for (int i = 0; i < errorHeaderDetailsDtoDtoList.size(); i++) {
|
||||
ErrorHeaderDetailsDtoDto errorHeaderDetailsDtoDto = errorHeaderDetailsDtoDtoList.get(i);
|
||||
HeaderDto header = errorHeaderDetailsDtoDto.getHeader();
|
||||
List<DetailsDto> details = errorHeaderDetailsDtoDto.getDetails();
|
||||
String newstate = errorHeaderDetailsDtoDto.getNewstate();
|
||||
String newPushDate = errorHeaderDetailsDtoDto.getNewPushDate();
|
||||
String newTransmitInfo = errorHeaderDetailsDtoDto.getNewTransmitInfo();
|
||||
|
||||
//如果报错内容太长了,则仅保留500个长度
|
||||
if (newTransmitInfo != null && !"".equals(newTransmitInfo.trim()) && newTransmitInfo.length() >= 400) {
|
||||
newTransmitInfo = newTransmitInfo.substring(0, 400);
|
||||
}
|
||||
|
||||
for (int j = 0; j < details.size(); j++) {
|
||||
DetailsDto detailsDto = details.get(j);
|
||||
|
||||
TocofsSaleoutDetailedEntity tocofsSaleoutDetailedEntity = new TocofsSaleoutDetailedEntity();
|
||||
tocofsSaleoutDetailedEntity.setId(detailsDto.getId());
|
||||
tocofsSaleoutDetailedEntity.setDef1(newPushDate);
|
||||
tocofsSaleoutDetailedEntity.setDef2(newTransmitInfo);
|
||||
tocofsSaleoutDetailedEntity.setNewstate2(newstate);
|
||||
tocofsSaleoutDetailedEntityList.add(tocofsSaleoutDetailedEntity);
|
||||
}
|
||||
}
|
||||
|
||||
//以50行为一个批次更新状态
|
||||
if (tocofsSaleoutDetailedEntityList.size() > 0) {
|
||||
List<List<TocofsSaleoutDetailedEntity>> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50);
|
||||
for (int i = 0; i < splitListByCount.size(); i++) {
|
||||
List<TocofsSaleoutDetailedEntity> tocofsSaleoutDetailedEntityList1 = splitListByCount.get(i);
|
||||
iTocofsSaleoutDetailedDao.entityInsertOrUpdateBatchStock1V2(tocofsSaleoutDetailedEntityList1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("填充出库明细日志抛出异常", e);
|
||||
}
|
||||
}
|
||||
});
|
||||
thread.start();
|
||||
try {
|
||||
thread.join();
|
||||
} catch (Exception e) {
|
||||
logger.error("updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiryV2方法现场抛出异常", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理调用U8C接口,抛出的异常,或者调用成功的记录
|
||||
*
|
||||
|
|
|
@ -103,8 +103,14 @@ class SoSaleOutPluginInitializerToCTest {
|
|||
|
||||
// soSaleOutPluginInitializerToC.startImplementStockByTimeAndTran("2024-10-22 00:00:00", "2024-10-22 23:59:59");
|
||||
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
soSaleOutPluginInitializerToC.executeBusiness(jsonObject);
|
||||
// JSONObject jsonObject = new JSONObject();
|
||||
// soSaleOutPluginInitializerToC.executeBusiness(jsonObject);
|
||||
|
||||
// String aaa = "LETS-SH2024101900022025";
|
||||
// soSaleOutPluginInitializerToC.startImplementStockByCode(aaa, "tran");
|
||||
|
||||
String aaa = "LETS-SH2024101800007483";
|
||||
soSaleOutPluginInitializerToC.startImplementStockByCode(aaa,"stock");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue