From fd8d287b9597868df9e36e5aadec86aacf052818 Mon Sep 17 00:00:00 2001 From: liuy <37787198+LiuyCodes@users.noreply.github.com> Date: Mon, 28 Oct 2024 16:57:49 +0800 Subject: [PATCH] =?UTF-8?q?refactor(sales):=20=E4=BC=98=E5=8C=96=E6=A1=A3?= =?UTF-8?q?=E6=A1=88=E6=9F=A5=E8=AF=A2=E4=B8=AD=E7=9A=84=E5=BA=93=E5=AD=98?= =?UTF-8?q?=E5=A4=84=E7=90=86=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 entityInsertOrUpdateBatchStock1V2 方法,用于更新出库状态的日志(适合档案转换部分的日志处理) - 在 SoSaleOutPluginInitializerToC 中实现 updateFailOrSuccessTocofsSaleoutDetailedArchiveInquiryV2 方法,用于批量修改成功或失败状态 - 更新相关 XML 文件,添加新的 SQL 语句 - 修改测试用例,注释掉部分代码并添加新的测试场景 --- .../ofs/dao/ITocofsSaleoutDetailedDao.java | 7 ++ .../impl/TocofsSaleoutDetailedDaoImpl.java | 5 ++ .../entity/TocofsSaleoutDetailedEntity.xml | 19 ++++++ .../sales/SoSaleOutPluginInitializerToC.java | 66 ++++++++++++++++++- .../SoSaleOutPluginInitializerToCTest.java | 10 ++- 5 files changed, 103 insertions(+), 4 deletions(-) diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/ITocofsSaleoutDetailedDao.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/ITocofsSaleoutDetailedDao.java index 2c3b40d6..a86c63a0 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/ITocofsSaleoutDetailedDao.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/ITocofsSaleoutDetailedDao.java @@ -26,6 +26,13 @@ public interface ITocofsSaleoutDetailedDao extends IBaseDao tocofsSaleoutDetailedEntities) throws Exception; + /** + * 更新出库状态的日志(适合档案转换部分的日志处理) + * + * @author liuyang + */ + void entityInsertOrUpdateBatchStock1V2(List tocofsSaleoutDetailedEntities) throws Exception; + /** * 更新出库状态的日志(适用库存推送) * diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/TocofsSaleoutDetailedDaoImpl.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/TocofsSaleoutDetailedDaoImpl.java index 267d9abf..30b687d8 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/TocofsSaleoutDetailedDaoImpl.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/dao/impl/TocofsSaleoutDetailedDaoImpl.java @@ -23,6 +23,11 @@ public class TocofsSaleoutDetailedDaoImpl extends MybatisGenericDao tocofsSaleoutDetailedEntities) throws Exception { insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStock", tocofsSaleoutDetailedEntities); } + + @Override + public void entityInsertOrUpdateBatchStock1V2(List tocofsSaleoutDetailedEntities) throws Exception { + insert("com.hzya.frame.plugin.lets.ofs.dao.impl.TocofsSaleoutDetailedDaoImpl.entityInsertOrUpdateBatchStockV2", tocofsSaleoutDetailedEntities); + } @Override public void entityInsertOrUpdateBatchStock2(List tocofsSaleoutDetailedEntities) throws Exception { diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml index 12981c31..ec8734bf 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/ofs/entity/TocofsSaleoutDetailedEntity.xml @@ -853,6 +853,25 @@ + + + insert into tocofs_saleout_detailed(id,def1,def2,newState2) + values + + ( + #{entity.id}, + #{entity.def1}, + #{entity.def2}, + #{entity.newstate2} + ) + + on duplicate key update + id = values(id), + def1 = values(def1), + def2 = values(def2), + newState2 = values(newState2) + + insert into tocofs_saleout_detailed(id,newPushDate,newTransmitInfo,newState,newSystemNumber,newSystemPrimary) diff --git a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java index fd8eeb02..333723c7 100644 --- a/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java +++ b/buildpackage/src/main/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToC.java @@ -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 errorHeaderDetailsDtoDtoList) { + Assert.notNull(errorHeaderDetailsDtoDtoList, "errorHeaderDetailsDtoDtoList不能为空!"); + + Thread thread = new Thread(new Runnable() { + @Override + public void run() { + try { + if (errorHeaderDetailsDtoDtoList != null && errorHeaderDetailsDtoDtoList.size() > 0) { + List tocofsSaleoutDetailedEntityList = new ArrayList<>(); + for (int i = 0; i < errorHeaderDetailsDtoDtoList.size(); i++) { + ErrorHeaderDetailsDtoDto errorHeaderDetailsDtoDto = errorHeaderDetailsDtoDtoList.get(i); + HeaderDto header = errorHeaderDetailsDtoDto.getHeader(); + List 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> splitListByCount = SplitListByCountUtil.splitListByCount(tocofsSaleoutDetailedEntityList, 50); + for (int i = 0; i < splitListByCount.size(); i++) { + List 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接口,抛出的异常,或者调用成功的记录 * diff --git a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java index 38120337..5ded7682 100644 --- a/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java +++ b/buildpackage/src/test/java/com/hzya/frame/plugin/lets/plugin/sales/SoSaleOutPluginInitializerToCTest.java @@ -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(); }