refactor(purchase): 重构采购公司编码匹配逻辑

- 在 ProxyPurchaseReturn、ProxyPurchaseWarehousOrder 和 ProxyPurchaseWarehousWarehouse 类中添加 QueryU8CEntityUtil 的自动注入
- 使用 queryU8CEntityUtil.queryBdDefDocByPkDefDocList 方法替换原有的公司编码匹配逻辑
- 优化了公司编码的查询和验证过程,提高了代码的可维护性和扩展性
- 修改了 application.yml 中的 profiles.active 配置,从 letsprod 改为 lets
- 更新了测试类中的测试用例,调整了实施时间和订单编号
This commit is contained in:
liuy 2024-10-29 15:05:19 +08:00
parent 7e89ad620d
commit cbaefcc1fb
9 changed files with 61 additions and 29 deletions

View File

@ -105,6 +105,9 @@ public class ProxyPurchaseReturn extends PluginBaseEntity {
@Autowired
private OffsetTimeTime offsetTimeTime;
@Autowired
private QueryU8CEntityUtil queryU8CEntityUtil;
@Override
public void initialize() {
logger.info(getPluginLabel() + "執行初始化方法initialize()");
@ -602,15 +605,18 @@ public class ProxyPurchaseReturn extends PluginBaseEntity {
//采购公司
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
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

@ -85,6 +85,9 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity {
@Autowired
private OfsStandardUtil ofsStandardUtil;
@Autowired
private QueryU8CEntityUtil queryU8CEntityUtil;
@Autowired
private OnlyImplementProxyOrderUtil onlyImplementProxyOrder;
@ -586,18 +589,22 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity {
continue;
}
//采购公司
//先完成采购公司编码的转换逻辑
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
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

@ -70,6 +70,9 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity {
@Autowired
private IBdInvmandocDao iBdInvmandocDao;
@Autowired
private QueryU8CEntityUtil queryU8CEntityUtil;
@Autowired
private IBdCalbodyDao iBdCalbodyDao;
@ -606,15 +609,18 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity {
//采购公司
String companyCode = header.getCompanyCode();
Assert.notNull(companyCode, "O表头公司不能为空");
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

@ -303,20 +303,31 @@ public class QueryU8CEntityUtil {
bdDefdocEntity.setPkDefdoclist(OverallConstant.getOverAllValue("u8c自定义项档案-公司对照"));
bdDefdocEntity.setDr(0);
bdDefdocEntity.setDataSourceCode(ProfilesActiveConstant.LETS_DATE_SOURCE);
bdDefdocEntity.setDoccode(corpCode.trim());
List<BdDefdocEntity> bdDefdocEntityList = iBdDefdocDao.query(bdDefdocEntity);
if (bdDefdocEntityList.size() == 0) {
Assert.state(false, "根据自定义档案列表编码GSDY主键[{}],未查询到自定义档案", OverallConstant.getOverAllValue("u8c自定义项档案-公司对照"));
}
List<String> corpCollect = bdDefdocEntityList.stream().map(BdDefdocEntity::getDoccode).collect(Collectors.toList());
if (corpCollect.contains(corpCode)) {
String memo = bdDefdocEntityList.get(0).getMemo();
String[] split = memo.split(",");
if (split.length > 0) {
corpCode = split[0];
if (bdDefdocEntityList != null && bdDefdocEntityList.size() == 1) {
// Assert.state(false, "根据自定义档案列表编码GSDY主键[{}],未查询到自定义档案", OverallConstant.getOverAllValue("u8c自定义项档案-公司对照"));
BdDefdocEntity bdDefdocEntity1 = bdDefdocEntityList.get(0);
String memo = bdDefdocEntity1.getMemo();
if (memo != null && !"".equals(memo)) {
String[] split = memo.split(",");
if (split.length > 0) {
return split[0];
}
}
} else if (bdDefdocEntityList != null && bdDefdocEntityList.size() >= 2) {
Assert.state(false, "存在歧义的匹配关系 公司编码:{}存在{}行对照关系!", corpCode);
}
return corpCode;
// List<String> corpCollect = bdDefdocEntityList.stream().map(BdDefdocEntity::getDoccode).collect(Collectors.toList());
// if (corpCollect.contains(corpCode)) {
// String memo = bdDefdocEntityList.get(0).getMemo();
// String[] split = memo.split(",");
// if (split.length > 0) {
// corpCode = split[0];
// }
// }
// return corpCode;
}
////////////////////////////////////////////////////////////////////////////////////////公司自定义档案查询
}

View File

@ -36,7 +36,7 @@ spring:
# use-suffix-pattern: true
profiles:
# active: @profileActive@
active: letsprod
active: lets
# active: @profile.active@
# active: dev
servlet:

View File

@ -25,7 +25,7 @@ public class ProxyPurchaseReturnTest {
@Test
public void startImplement() {
try {
// proxyPurchaseReturn.startImplement("LETS-SH2024082700000005");
proxyPurchaseReturn.startImplement("LETS-SH2024091200027580");
// proxyPurchaseReturn.startImplement("2024-01-01 00:00:00", "2024-08-07 23:59:59");
@ -33,7 +33,7 @@ public class ProxyPurchaseReturnTest {
// proxyPurchaseReturn.u8cOperationFlow();
proxyPurchaseReturn.startImplement("2024-09-24 13:49:15", "2024-09-24 13:49:17");
// proxyPurchaseReturn.startImplement("2024-09-24 13:49:15", "2024-09-24 13:49:17");
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -27,9 +27,9 @@ public class ProxyPurchaseWarehousOrderTest {
@Test
public void startImplementByCode() {
try {
// proxyPurchaseWarehousOrder.startImplementByCode("LETS-PO2024091800000002");
proxyPurchaseWarehousOrder.startImplementByCode("LETS-PO2024100100000001");
proxyPurchaseWarehousOrder.startImplementByTime("2024-09-24 13:49:15", "2024-09-24 13:49:17");
// proxyPurchaseWarehousOrder.startImplementByTime("2024-09-24 13:49:15", "2024-09-24 13:49:17");
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -26,6 +26,6 @@ public class ProxyPurchaseWarehousWarehouseTest {
@Test
public void startImplementByCode() {
proxyPurchaseWarehousWarehouse.startImplementByCode("LETS-RE2024091800000001");
proxyPurchaseWarehousWarehouse.startImplementByCode("LETS-RE2024080100000051");
}
}

View File

@ -56,7 +56,9 @@ public class QueryU8CEntityUtilTest {
System.out.println(JSON.toJSONString(bdCostsubjEntity));
}
// @Test
// public void queryBdCostsubj() {
// }
@Test
public void queryBdCostsubj() {
String s = queryU8CEntityUtil.queryBdDefDocByPkDefDocList("KS");
System.out.println(s);
}
}