refactor(buildpackage): 重构公司代码替换逻辑

- 在多个插件中统一使用 replaceCompanyCode替换 companyCode
- 优化公司代码替换的查询逻辑,减少冗余代码
- 调整错误信息提示,使用替换后的公司代码
- 移除不必要的注释代码
This commit is contained in:
liuy 2024-12-18 11:36:48 +08:00
parent cb95ad98a8
commit 46ffb9840c
10 changed files with 54 additions and 56 deletions

View File

@ -594,17 +594,17 @@ public class ConsignmachiningIn extends PluginBaseEntity {
//委外订单表头公司
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空(物理货主)");
// String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
BdCorpEntity bdCorpEntity = new BdCorpEntity();
bdCorpEntity.setDr(0);
bdCorpEntity.setDataSourceCode("lets_u8c");
bdCorpEntity.setUnitcode(companyCode);
bdCorpEntity.setUnitcode(replaceCompanyCode);
List<BdCorpEntity> bdCorpEntityList = iBdCorpDao.query(bdCorpEntity);
if (bdCorpEntityList.size() == 0) {
Assert.state(false, "根据O货主编码{}无法匹配到U8C委外订单公司", companyCode);
Assert.state(false, "根据O货主编码{}无法匹配到U8C委外订单公司", replaceCompanyCode);
} else if (bdCorpEntityList.size() >= 2) {
Assert.state(false, "根据O货主编码{}匹配到U8C委外订单公司{}个", companyCode, bdCorpEntityList.size());
Assert.state(false, "根据O货主编码{}匹配到U8C委外订单公司{}个", replaceCompanyCode, bdCorpEntityList.size());
}
//采购组织

View File

@ -580,13 +580,13 @@ public class ConsignmachiningInReturn extends PluginBaseEntity {
//得到原始的公司编码
BdCorpEntity bdCorpEntity1 = oldBdCorpEntityList.get(0);
String unitcode = bdCorpEntity1.getUnitcode();
// String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(unitcode.trim());
// Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(unitcode.trim());
Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
BdCorpEntity bdCorpEntity2 = new BdCorpEntity();
bdCorpEntity2.setDr(0);
bdCorpEntity2.setDataSourceCode("lets_u8c");
bdCorpEntity2.setUnitcode(unitcode);
bdCorpEntity2.setUnitcode(replaceCompanyCode);
List<BdCorpEntity> bdCorpEntityList = iBdCorpDao.query(bdCorpEntity2);
if (bdCorpEntityList.size() == 0) {
Assert.state(false, "(原始公司替换之后)根据委外订单公司主键:{},无法匹配到对应的公司", scOrderEntity.getPkCorp());

View File

@ -630,18 +630,18 @@ public class ProxyPurchaseReturn extends PluginBaseEntity {
//采购公司
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
// String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
// Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
BdCorpEntity bdCorpEntity = new BdCorpEntity();
bdCorpEntity.setDr(0);
bdCorpEntity.setDataSourceCode("lets_u8c");
bdCorpEntity.setUnitcode(companyCode);
bdCorpEntity.setUnitcode(replaceCompanyCode);
List<BdCorpEntity> bdCorpEntityList = iBdCorpDao.query(bdCorpEntity);
if (bdCorpEntityList.size() == 0) {
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", companyCode);
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", replaceCompanyCode);
} else if (bdCorpEntityList.size() >= 2) {
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size());
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", replaceCompanyCode, bdCorpEntityList.size());
}
//采购部门业务部门

View File

@ -619,19 +619,19 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity {
//先完成采购公司编码的转换逻辑
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
// String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
// Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
//采购公司
BdCorpEntity bdCorpEntity = new BdCorpEntity();
bdCorpEntity.setDr(0);
bdCorpEntity.setDataSourceCode("lets_u8c");
bdCorpEntity.setUnitcode(companyCode);
bdCorpEntity.setUnitcode(replaceCompanyCode);
List<BdCorpEntity> bdCorpEntityList = iBdCorpDao.query(bdCorpEntity);
if (bdCorpEntityList.size() == 0) {
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", companyCode);
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", replaceCompanyCode);
} else if (bdCorpEntityList.size() >= 2) {
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size());
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", replaceCompanyCode, bdCorpEntityList.size());
}
//采购部门业务部门

View File

@ -634,18 +634,18 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity {
//采购公司
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
// String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
// Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
BdCorpEntity bdCorpEntity = new BdCorpEntity();
bdCorpEntity.setDr(0);
bdCorpEntity.setDataSourceCode("lets_u8c");
bdCorpEntity.setUnitcode(companyCode);
bdCorpEntity.setUnitcode(replaceCompanyCode);
List<BdCorpEntity> bdCorpEntityList = iBdCorpDao.query(bdCorpEntity);
if (bdCorpEntityList.size() == 0) {
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", companyCode);
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", replaceCompanyCode);
} else if (bdCorpEntityList.size() >= 2) {
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size());
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", replaceCompanyCode, bdCorpEntityList.size());
}
//采购部门业务部门

View File

@ -1067,18 +1067,18 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
// 销售公司发货公司
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
// String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
// Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
BdCorpEntity bdCorpEntity = new BdCorpEntity();
bdCorpEntity.setDr(0);
bdCorpEntity.setDataSourceCode("lets_u8c");
bdCorpEntity.setUnitcode(companyCode);
bdCorpEntity.setUnitcode(replaceCompanyCode);
List<BdCorpEntity> bdCorpEntityList = iBdCorpDao.query(bdCorpEntity);
if (bdCorpEntityList.size() == 0) {
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", companyCode);
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", replaceCompanyCode);
} else if (bdCorpEntityList.size() >= 2) {
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size());
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", replaceCompanyCode, bdCorpEntityList.size());
}
// 发货库存组织
@ -1630,18 +1630,18 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
// header.setCompanyCode("SHLZ");
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
// String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
// Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
BdCorpEntity bdCorpEntity = new BdCorpEntity();
bdCorpEntity.setDr(0);
bdCorpEntity.setDataSourceCode("lets_u8c");
bdCorpEntity.setUnitcode(companyCode);
bdCorpEntity.setUnitcode(replaceCompanyCode);
List<BdCorpEntity> bdCorpEntityList = iBdCorpDao.query(bdCorpEntity);
if (bdCorpEntityList.size() == 0) {
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", companyCode);
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", replaceCompanyCode);
} else if (bdCorpEntityList.size() >= 2) {
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size());
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", replaceCompanyCode, bdCorpEntityList.size());
}
// 发货库存组织

View File

@ -1347,7 +1347,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//计算OFS销售订单邮费分摊
ofsOrderSalePostageFeeAllocationUtil.batchTocSalesPostageFeeAllocation(headerDetailsDtos);
//初始化公司档案对照关系
// Map<String, String> comparisonCompanyArchives = queryU8CEntityUtil.queryBdDefDocByPkDefDocAll();
Map<String, String> comparisonCompanyArchives = queryU8CEntityUtil.queryBdDefDocByPkDefDocAll();
for (int i = 0; i < headerDetailsDtoList.size(); i++) {
HeaderDetailsDto headerDetailsDto = headerDetailsDtoList.get(i);
@ -1375,10 +1375,10 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
Assert.notNull(companyCode, "O出库单表头货主不能为空");
//查找是否替换公司
// String targetCorp = comparisonCompanyArchives.get(companyCode);
// if (targetCorp != null) {
// companyCode = targetCorp;
// }
String targetCorp = comparisonCompanyArchives.get(companyCode);
if (targetCorp != null) {
companyCode = targetCorp;
}
BdCorpEntity bdCorpEntity = cacheTocMapVo.getStringBdCorpEntityMap().get(companyCode.trim());
Assert.notNull(bdCorpEntity, "根据公司编码({})没有匹配到U8C公司档案(公司编码=O货主)", companyCode);

View File

@ -1016,19 +1016,18 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
// 销售公司发货公司
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
// String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
// Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
BdCorpEntity bdCorpEntity = new BdCorpEntity();
bdCorpEntity.setDr(0);
bdCorpEntity.setDataSourceCode("lets_u8c");
bdCorpEntity.setUnitcode(companyCode);
bdCorpEntity.setUnitcode(replaceCompanyCode);
List<BdCorpEntity> bdCorpEntityList = iBdCorpDao.query(bdCorpEntity);
if (bdCorpEntityList.size() == 0) {
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", companyCode);
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", replaceCompanyCode);
} else if (bdCorpEntityList.size() >= 2) {
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size());
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", replaceCompanyCode, bdCorpEntityList.size());
}
// 发货库存组织
@ -1333,19 +1332,18 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
// 销售公司发货公司
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
// String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
// Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
String replaceCompanyCode = queryU8CEntityUtil.queryBdDefDocByPkDefDocList(companyCode.trim());
Assert.notNull(replaceCompanyCode, "replaceCompanyCode不能为空");
BdCorpEntity bdCorpEntity = new BdCorpEntity();
bdCorpEntity.setDr(0);
bdCorpEntity.setDataSourceCode("lets_u8c");
bdCorpEntity.setUnitcode(companyCode);
bdCorpEntity.setUnitcode(replaceCompanyCode);
List<BdCorpEntity> bdCorpEntityList = iBdCorpDao.query(bdCorpEntity);
if (bdCorpEntityList.size() == 0) {
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", companyCode);
Assert.state(false, "根据O货主编码{}无法匹配到U8C销售公司", replaceCompanyCode);
} else if (bdCorpEntityList.size() >= 2) {
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", companyCode, bdCorpEntityList.size());
Assert.state(false, "根据O货主编码{}匹配到U8C销售公司{}个", replaceCompanyCode, bdCorpEntityList.size());
}
// 发货库存组织

View File

@ -1294,7 +1294,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
//计算OFS销售订单优惠金额分摊到明细行
// ofsOrderAfterSalesAmountAllocationUtil.batchTocSalesAmountAllocation(rerturnGoodsOrderSearchData);
//初始化公司档案对照关系
// Map<String, String> comparisonCompanyArchives = queryU8CEntityUtil.queryBdDefDocByPkDefDocAll();
Map<String, String> comparisonCompanyArchives = queryU8CEntityUtil.queryBdDefDocByPkDefDocAll();
//测试
// StockinOrderSearchResponse.StockinOrder stockinOrder1 = returnGoodHeaderDetailsDataDtoList1.get(0);
@ -1330,10 +1330,10 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O货主编码不能为空");
//查找是否替换公司
// String targetCorp = comparisonCompanyArchives.get(companyCode);
// if (targetCorp != null) {
// companyCode = targetCorp;
// }
String targetCorp = comparisonCompanyArchives.get(companyCode);
if (targetCorp != null) {
companyCode = targetCorp;
}
BdCorpEntity bdCorpEntity = cacheTocMapVoV2.getStringBdCorpEntityMap().get(companyCode.trim());
Assert.notNull(bdCorpEntity, "根据O公司编码(货主编码)({})没有匹配到U8C公司档案", header.getCompanyCode());

View File

@ -112,7 +112,7 @@ class SoSaleOutPluginInitializerToCTest {
// String aaa = "LETS-SH2024102800021196";
// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-12-06 09:25:39", "2024-12-06 09:25:39");
// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-11-15 00:00:00", "2024-11-15 23:59:59");
soSaleOutPluginInitializerToC.startImplementStockByTime("2024-12-01 00:00:00", "2024-12-01 23:59:59");
} catch (Exception e) {
e.printStackTrace();
}
@ -120,7 +120,7 @@ class SoSaleOutPluginInitializerToCTest {
// soSaleOutPluginInitializerToC.sendU8CTOCOrder("123446");
try {
soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024113000012787", "stock");
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024113000012787", "stock");
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024110500013375", "tran");
// soSaleOutPluginInitializerToC.startImplementStockByCode("LETS-SH2024111700013756", "tran");