refactor(buildpackage): 重构查询 U8C 客商档案逻辑

- 移除重复的查询逻辑,使用统一的模糊查询方法
- 优化错误处理,提高代码可读性和维护性
- 在 SoSaleOutPluginInitializerToC 中添加 dimension 参数,用于精确查询
This commit is contained in:
liuy 2024-10-31 16:07:13 +08:00
parent 382154edcf
commit 27b3318324
10 changed files with 224 additions and 119 deletions

View File

@ -600,16 +600,18 @@ public class ConsignmachiningIn extends PluginBaseEntity {
String shipFromCode = header.getShipFromCode();
Assert.notNull(shipFromCode, "O供应商编码不能为空没有办法完成业务逻辑请配置供应商编码(采退)");
Assert.state(!"".equals(shipFromCode.trim()), "O供应商编码不能为空没有办法完成业务逻辑请配置供应商编码");
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setDef1(shipFromCode);
List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
Assert.state(false, "根据OFS供应商业务编码{}(客商自定义项1记录O客商业务编码)无法查询到U8C客商档案信息(供应商)", shipFromCode);
} else if (bdCubasdocEntityList.size() >= 2) {
Assert.state(false, "根据OFS供应商业务编码{}(客商自定义项1记录O客商业务编码)查询到多个U8C客商档案信息(供应商)", shipFromCode);
}
// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
// bdCubasdocEntity.setDataSourceCode("lets_u8c");
// bdCubasdocEntity.setDr(0L);
// bdCubasdocEntity.setDef1(shipFromCode);
// List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
// if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
// Assert.state(false, "根据OFS供应商业务编码{}(客商自定义项1记录O客商业务编码)无法查询到U8C客商档案信息(供应商)", shipFromCode);
// } else if (bdCubasdocEntityList.size() >= 2) {
// Assert.state(false, "根据OFS供应商业务编码{}(客商自定义项1记录O客商业务编码)查询到多个U8C客商档案信息(供应商)", shipFromCode);
// }
BdCubasdocEntity fuzzyQueryCustomers = queryU8CEntityUtil.getFuzzyQueryCustomers(shipFromCode.trim());
Assert.notNull(fuzzyQueryCustomers, "根据O供应商编码{}无法查询到U8C客商基本档案 def1", shipFromCode.trim());
//客商管理档案
BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity();
@ -617,12 +619,12 @@ public class ConsignmachiningIn extends PluginBaseEntity {
bdCumandocEntity1.setDr(0L);
bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp());
bdCumandocEntity1.setCustflags(ProfilesActiveConstant.SUPPLIER);
bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc());
bdCumandocEntity1.setPkCubasdoc(fuzzyQueryCustomers.getPkCubasdoc());
List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1);
if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) {
Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
} else if (bdCumandocEntityList.size() >= 2) {
Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
}
//2024年8月25日 10:09:20 委外入库公司取委外订单上的公司已经和妮姐确认没有必要通过O的公司转换因为不存在跨组织的问题
@ -672,7 +674,7 @@ public class ConsignmachiningIn extends PluginBaseEntity {
consignmachiningInSonDto.setBdCalbodyEntity(bdCalbodyEntities.get(0));
// consignmachiningInSonDto.setBdStordocEntity(bdStordocEntityList.get(0));
consignmachiningInSonDto.setBdPurorgEntity(bdPurorgEntityList.get(0));
consignmachiningInSonDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0));
consignmachiningInSonDto.setBdCubasdocEntity(fuzzyQueryCustomers);
consignmachiningInSonDto.setBdCumandocEntity(bdCumandocEntityList.get(0));
// consignmachiningInSonDto.setHeader(header);
// consignmachiningInSonDto.setScOrderBEntityList(scOrderBEntityList);

View File

@ -651,16 +651,18 @@ public class ProxyPurchaseReturn extends PluginBaseEntity {
String shipFromCode = header1.getShipFromCode();
Assert.notNull(shipFromCode, "O供应商编码不能为空没有办法完成业务逻辑请配置供应商编码(采退)");
Assert.state(!"".equals(shipFromCode.trim()), "O供应商编码不能为空没有办法完成业务逻辑请配置供应商编码");
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setDef1(shipFromCode);
List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
Assert.state(false, "根据OFS供应商业务编码{}无法查询到U8C客商档案信息(供应商)", shipFromCode);
} else if (bdCubasdocEntityList.size() >= 2) {
Assert.state(false, "根据OFS供应商业务编码{}查询到多个U8C客商档案信息(供应商)", shipFromCode);
}
// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
// bdCubasdocEntity.setDataSourceCode("lets_u8c");
// bdCubasdocEntity.setDr(0L);
// bdCubasdocEntity.setDef1(shipFromCode);
// List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
// if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
// Assert.state(false, "根据OFS供应商业务编码{}无法查询到U8C客商档案信息(供应商)", shipFromCode);
// } else if (bdCubasdocEntityList.size() >= 2) {
// Assert.state(false, "根据OFS供应商业务编码{}查询到多个U8C客商档案信息(供应商)", shipFromCode);
// }
BdCubasdocEntity fuzzyQueryCustomers = queryU8CEntityUtil.getFuzzyQueryCustomers(shipFromCode.trim());
Assert.notNull(fuzzyQueryCustomers, "根据O供应商编码{}无法查询到U8C客商基本档案 def1", shipFromCode.trim());
//客商管理档案
BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity();
@ -668,12 +670,12 @@ public class ProxyPurchaseReturn extends PluginBaseEntity {
bdCumandocEntity1.setDr(0L);
bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp());
bdCumandocEntity1.setCustflags(ProfilesActiveConstant.SUPPLIER);
bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc());
bdCumandocEntity1.setPkCubasdoc(fuzzyQueryCustomers.getPkCubasdoc());
List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1);
if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) {
Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
} else if (bdCumandocEntityList.size() >= 2) {
Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
}
// 2024年8月20日 23:51:56 收货库存组织应该是通过收货公司查询得出收货库存组织目前收货公司和采购公司保持一致那么就以采购公司带出这个逻辑已经和佳妮确认
@ -707,7 +709,7 @@ public class ProxyPurchaseReturn extends PluginBaseEntity {
poOrderRerturnSonDto.setBdCorpEntity(bdCorpEntityList.get(0));
poOrderRerturnSonDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0));
poOrderRerturnSonDto.setBdPurorgEntity(bdPurorgEntityList.get(0));
poOrderRerturnSonDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0));
poOrderRerturnSonDto.setBdCubasdocEntity(fuzzyQueryCustomers);
poOrderRerturnSonDto.setBdCumandocEntity(bdCumandocEntityList.get(0));
poOrderRerturnSonDto.setBdCalbodyEntity(bdCalbodyEntities.get(0));
poOrderRerturnSonDto.setBdStordocEntity(bdStordocEntityList.get(0));

View File

@ -641,16 +641,18 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity {
// shipFromCode = "dy-off";
Assert.notNull(shipFromCode, "O供应商编码不能为空没有办法完成业务逻辑请配置供应商编码(采购)");
Assert.state(!"".equals(shipFromCode.trim()), "O供应商编码不能为空没有办法完成业务逻辑请配置供应商编码(采购)");
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setDef1(shipFromCode);
List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
Assert.state(false, "根据OFS供应商业务编码{}无法查询到U8C客商档案信息(供应商)", shipFromCode);
} else if (bdCubasdocEntityList.size() >= 2) {
Assert.state(false, "根据OFS供应商业务编码{}查询到多个U8C客商档案信息(供应商)", shipFromCode);
}
// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
// bdCubasdocEntity.setDataSourceCode("lets_u8c");
// bdCubasdocEntity.setDr(0L);
// bdCubasdocEntity.setDef1(shipFromCode);
// List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
// if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
// Assert.state(false, "根据OFS供应商业务编码{}无法查询到U8C客商档案信息(供应商)", shipFromCode);
// } else if (bdCubasdocEntityList.size() >= 2) {
// Assert.state(false, "根据OFS供应商业务编码{}查询到多个U8C客商档案信息(供应商)", shipFromCode);
// }
BdCubasdocEntity fuzzyQueryCustomers = queryU8CEntityUtil.getFuzzyQueryCustomers(shipFromCode.trim());
Assert.notNull(fuzzyQueryCustomers, "根据O供应商编码{}无法查询到U8C客商基本档案 def1", shipFromCode.trim());
//客商管理档案
BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity();
@ -658,12 +660,12 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity {
bdCumandocEntity1.setDr(0L);
bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp());
bdCumandocEntity1.setCustflags(ProfilesActiveConstant.SUPPLIER);
bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc());
bdCumandocEntity1.setPkCubasdoc(fuzzyQueryCustomers.getPkCubasdoc());
List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1);
if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) {
Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
} else if (bdCumandocEntityList.size() >= 2) {
Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
}
// 2024年8月20日 23:51:56 收货库存组织应该是通过收货公司查询得出收货库存组织目前收货公司和采购公司保持一致那么就以采购公司带出这个逻辑已经和佳妮确认
@ -697,7 +699,7 @@ public class ProxyPurchaseWarehousOrder extends PluginBaseEntity {
poOrderSonDto.setBdCorpEntity(bdCorpEntityList.get(0));
poOrderSonDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0));
poOrderSonDto.setBdPurorgEntity(bdPurorgEntityList.get(0));
poOrderSonDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0));
poOrderSonDto.setBdCubasdocEntity(fuzzyQueryCustomers);
poOrderSonDto.setBdCumandocEntity(bdCumandocEntityList.get(0));
// poOrderSonDto.setOfsPoOrderData(ofsPoOrderData);
poOrderSonDto.setBdCalbodyEntity(bdCalbodyEntities.get(0));

View File

@ -657,16 +657,18 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity {
// shipFromCode = "dy-off";
Assert.notNull(shipFromCode, "O供应商编码不能为空没有办法完成业务逻辑请配置供应商编码(采购)");
Assert.state(!"".equals(shipFromCode.trim()), "O供应商编码不能为空没有办法完成业务逻辑请配置供应商编码(采购)");
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setDef1(shipFromCode);
List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
Assert.state(false, "根据OFS供应商业务编码{}无法查询到U8C客商档案信息(供应商)", shipFromCode);
} else if (bdCubasdocEntityList.size() >= 2) {
Assert.state(false, "根据OFS供应商业务编码{}查询到多个U8C客商档案信息(供应商)", shipFromCode);
}
// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
// bdCubasdocEntity.setDataSourceCode("lets_u8c");
// bdCubasdocEntity.setDr(0L);
// bdCubasdocEntity.setDef1(shipFromCode);
// List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
// if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
// Assert.state(false, "根据OFS供应商业务编码{}无法查询到U8C客商档案信息(供应商)", shipFromCode);
// } else if (bdCubasdocEntityList.size() >= 2) {
// Assert.state(false, "根据OFS供应商业务编码{}查询到多个U8C客商档案信息(供应商)", shipFromCode);
// }
BdCubasdocEntity fuzzyQueryCustomers = queryU8CEntityUtil.getFuzzyQueryCustomers(shipFromCode.trim());
Assert.notNull(fuzzyQueryCustomers, "根据O供应商编码{}无法查询到U8C客商基本档案 def1", shipFromCode.trim());
//客商管理档案
BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity();
@ -674,12 +676,12 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity {
bdCumandocEntity1.setDr(0L);
bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp());
bdCumandocEntity1.setCustflags(ProfilesActiveConstant.SUPPLIER);
bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc());
bdCumandocEntity1.setPkCubasdoc(fuzzyQueryCustomers.getPkCubasdoc());
List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1);
if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) {
Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
} else if (bdCumandocEntityList.size() >= 2) {
Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},匹配到多个客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
}
// 2024年8月20日 23:51:56 收货库存组织应该是通过收货公司查询得出收货库存组织目前收货公司和采购公司保持一致那么就以采购公司带出这个逻辑已经和佳妮确认
@ -736,7 +738,7 @@ public class ProxyPurchaseWarehousWarehouse extends PluginBaseEntity {
poOrderSonDto.setBdCorpEntity(bdCorpEntityList.get(0));
poOrderSonDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0));
poOrderSonDto.setBdPurorgEntity(bdPurorgEntityList.get(0));
poOrderSonDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0));
poOrderSonDto.setBdCubasdocEntity(fuzzyQueryCustomers);
poOrderSonDto.setBdCumandocEntity(bdCumandocEntityList.get(0));
poOrderSonDto.setOfsPoOrderData(ofsPoOrderData);
poOrderSonDto.setBdCalbodyEntity(bdCalbodyEntities.get(0));

View File

@ -1110,16 +1110,18 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
// SaleOrderMessageDto ofsOrder = getOfsOrder(queryOfsSoSaleOutVo, 1L);
// String custName = "天猫intoyou旗舰店-自营";
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setDef1(memberId.trim());
List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
} else if (bdCubasdocEntityList.size() >= 2) {
Assert.state(false, "根据OFS会员id{}查询到U8C多个客商基本档案", memberId);
}
// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
// bdCubasdocEntity.setDataSourceCode("lets_u8c");
// bdCubasdocEntity.setDr(0L);
// bdCubasdocEntity.setDef1(memberId.trim());
// List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
// if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
// Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
// } else if (bdCubasdocEntityList.size() >= 2) {
// Assert.state(false, "根据OFS会员id{}查询到U8C多个客商基本档案", memberId);
// }
BdCubasdocEntity fuzzyQueryCustomers = queryU8CEntityUtil.getFuzzyQueryCustomers(memberId.trim());
Assert.notNull(fuzzyQueryCustomers, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId.trim());
//客商管理档案
BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity();
@ -1127,10 +1129,10 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
bdCumandocEntity1.setDr(0L);
bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp());
bdCumandocEntity1.setCustflags(ProfilesActiveConstant.CUSTOMER);
bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc());
bdCumandocEntity1.setPkCubasdoc(fuzzyQueryCustomers.getPkCubasdoc());
List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1);
if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) {
Assert.state(false, "根据客商基本档案主键{},没有办法查询到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},没有办法查询到客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
}
//查找平台
@ -1173,7 +1175,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
orderOutTobHeaderDto.setBdSalestruEntity(bdSalestruEntityList.get(0));
orderOutTobHeaderDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0));
orderOutTobHeaderDto.setBdCumandocEntity(bdCumandocEntityList.get(0));
orderOutTobHeaderDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0));
orderOutTobHeaderDto.setBdCubasdocEntity(fuzzyQueryCustomers);
orderOutTobHeaderDto.setDeliverGoodsCorp(bdCorpEntityList.get(0));
orderOutTobHeaderDto.setPlatformArchives(bdDefdocEntityList.get(0));
orderOutTobHeaderDto.setShopArchives(bdDefdocEntityList2.get(0));
@ -1669,16 +1671,18 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
// SaleOrderMessageDto ofsOrder = getOfsOrder(queryOfsSoSaleOutVo, 1L);
// String custName = "天猫intoyou旗舰店-自营";
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setDef1(memberId.trim());
List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
} else if (bdCubasdocEntityList.size() >= 2) {
Assert.state(false, "根据OFS会员id{}查询到U8C多个客商基本档案", memberId);
}
// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
// bdCubasdocEntity.setDataSourceCode("lets_u8c");
// bdCubasdocEntity.setDr(0L);
// bdCubasdocEntity.setDef1(memberId.trim());
// List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
// if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
// Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
// } else if (bdCubasdocEntityList.size() >= 2) {
// Assert.state(false, "根据OFS会员id{}查询到U8C多个客商基本档案", memberId);
// }
BdCubasdocEntity fuzzyQueryCustomers = queryU8CEntityUtil.getFuzzyQueryCustomers(memberId.trim());
Assert.notNull(fuzzyQueryCustomers, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId.trim());
//客商管理档案
BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity();
@ -1686,12 +1690,12 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
bdCumandocEntity1.setDr(0L);
bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp());
bdCumandocEntity1.setCustflags(ProfilesActiveConstant.CUSTOMER);
bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc());
bdCumandocEntity1.setPkCubasdoc(fuzzyQueryCustomers.getPkCubasdoc());
List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1);
if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) {
Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},无法匹配到客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
} else if (bdCumandocEntityList.size() >= 2) {
Assert.state(false, "根据客商基本档案主键{},匹配到{}哥客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc(), bdCumandocEntityList.size());
Assert.state(false, "根据客商基本档案主键{},匹配到{}哥客商管理档案", fuzzyQueryCustomers.getPkCubasdoc(), bdCumandocEntityList.size());
}
//查找平台
@ -1735,7 +1739,7 @@ public class SoSaleOutPluginInitializerToB extends PluginBaseEntity {
orderOutTobHeaderDto.setBdSalestruEntity(bdSalestruEntityList.get(0));
orderOutTobHeaderDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0));
orderOutTobHeaderDto.setBdCumandocEntity(bdCumandocEntityList.get(0));
orderOutTobHeaderDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0));
orderOutTobHeaderDto.setBdCubasdocEntity(fuzzyQueryCustomers);
orderOutTobHeaderDto.setDeliverGoodsCorp(bdCorpEntityList.get(0));
orderOutTobHeaderDto.setPlatformArchives(bdDefdocEntityList.get(0));
orderOutTobHeaderDto.setShopArchives(bdDefdocEntityList2.get(0));

View File

@ -852,7 +852,9 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
String sceneType = "stock";
List<SonDetailsDto> sonDetailsDtoList = queryBasicArchivesStock(headerDetailsDtos, sceneType);
// 分组汇总
Map<String, List<SonDetailsDto>> summaryDimensionMap = groupSummaryStock(sonDetailsDtoList);
// String dimension = "1001(*)dy-intoyou(*)B2CHA20240010(*)6973391735605(*)SALES(*)002";
String dimension = null;
Map<String, List<SonDetailsDto>> summaryDimensionMap = groupSummaryStock(sonDetailsDtoList, dimension);
// 查询U8C业务流程
BdBusitypeEntity bdBusitypeEntity = u8cOperationFlow();
// 查询销售收发类别
@ -1472,7 +1474,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
* filterType 0或者其他不过滤1 过滤交易成功红2过滤交易成功蓝
* @author liuyang
*/
private Map<String, List<SonDetailsDto>> groupSummaryStock(List<SonDetailsDto> sonDetailsDtoList) {
private Map<String, List<SonDetailsDto>> groupSummaryStock(List<SonDetailsDto> sonDetailsDtoList, String dimension) {
if (sonDetailsDtoList != null && sonDetailsDtoList.size() > 0) {
// switch (filterType) {
// case "1":
@ -1553,12 +1555,43 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
sonDetailsDto.setSummaryDimensionStr(summaryDimensionStr.toString());
}
logger.info("TOC{}个出库单对象需要汇总", sonDetailsDtoList.size());
return sonDetailsDtoList.stream().collect(Collectors.groupingBy(SonDetailsDto::getSummaryDimensionStr));
if (dimension == null) {
return sonDetailsDtoList.stream().collect(Collectors.groupingBy(SonDetailsDto::getSummaryDimensionStr));
} else {
Map<String, List<SonDetailsDto>> collect = sonDetailsDtoList.stream().collect(Collectors.groupingBy(SonDetailsDto::getSummaryDimensionStr));
keepOnlyNeededKeys(collect, dimension);
return collect;
}
}
logger.info("TOC0个对象需要汇总");
return null;
}
/**
* 移除不需要的键
*
* @author liuyang
*/
private static void keepOnlyNeededKeys(Map<String, List<SonDetailsDto>> map, String... neededKeys) {
Iterator<Map.Entry<String, List<SonDetailsDto>>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Map.Entry<String, List<SonDetailsDto>> entry = iterator.next();
// 如果不是需要的键则移除
if (!contains(neededKeys, entry.getKey())) {
iterator.remove();
}
}
}
private static boolean contains(String[] array, String targetValue) {
for (String value : array) {
if (value.equals(targetValue)) {
return true;
}
}
return false;
}
/**
* 2024年8月6日 10:59:03 查询U8C业务流程
*
@ -1814,7 +1847,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
String sceneType = "tran";
List<SonDetailsDto> sonDetailsDtoList = queryBasicArchivesStock(headerDetailsDtos, sceneType);
//分组汇总红蓝
Map<String, List<SonDetailsDto>> summaryDimensionMap = groupSummaryStock(sonDetailsDtoList);
Map<String, List<SonDetailsDto>> summaryDimensionMap = groupSummaryStock(sonDetailsDtoList, null);
//分组汇总
// Map<String, List<SonDetailsDto>> summaryDimensionMap2 = groupSummaryStock(sonDetailsDtoList, "2");

View File

@ -1054,27 +1054,29 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
//客商基本档案
// String custName = "天猫intoyou旗舰店-自营";
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setDef1(memberId.trim());
List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
} else if (bdCubasdocEntityList.size() >= 2) {
Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
}
// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
// bdCubasdocEntity.setDataSourceCode("lets_u8c");
// bdCubasdocEntity.setDr(0L);
// bdCubasdocEntity.setDef1(memberId.trim());
// List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
// if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
// Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
// } else if (bdCubasdocEntityList.size() >= 2) {
// Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
// }
BdCubasdocEntity fuzzyQueryCustomers = queryU8CEntityUtil.getFuzzyQueryCustomers(memberId.trim());
Assert.notNull(fuzzyQueryCustomers, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId.trim());
//客商管理档案
BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity();
bdCumandocEntity1.setDataSourceCode("lets_u8c");
bdCumandocEntity1.setDr(0L);
bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp());
bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc());
bdCumandocEntity1.setPkCubasdoc(fuzzyQueryCustomers.getPkCubasdoc());
bdCumandocEntity1.setCustflags(ProfilesActiveConstant.CUSTOMER);
List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1);
if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) {
Assert.state(false, "根据客商基本档案主键{},没有办法查询到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},没有办法查询到客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
}
//查找平台
@ -1118,7 +1120,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
orderOutTobHeaderDto.setBdSalestruEntity(bdSalestruEntityList.get(0));
orderOutTobHeaderDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0));
orderOutTobHeaderDto.setBdCumandocEntity(bdCumandocEntityList.get(0));
orderOutTobHeaderDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0));
orderOutTobHeaderDto.setBdCubasdocEntity(fuzzyQueryCustomers);
orderOutTobHeaderDto.setDeliverGoodsCorp(bdCorpEntityList.get(0));
orderOutTobHeaderDto.setPlatformArchives(bdDefdocEntityList.get(0));
orderOutTobHeaderDto.setShopArchives(bdDefdocEntityList2.get(0));
@ -1367,27 +1369,29 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
}
//客商基本档案
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setDef1(memberId.trim());
List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
} else if (bdCubasdocEntityList.size() >= 2) {
Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
}
// BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
// bdCubasdocEntity.setDataSourceCode("lets_u8c");
// bdCubasdocEntity.setDr(0L);
// bdCubasdocEntity.setDef1(memberId.trim());
// List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
// if (bdCubasdocEntityList == null || bdCubasdocEntityList.size() == 0) {
// Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
// } else if (bdCubasdocEntityList.size() >= 2) {
// Assert.state(false, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId);
// }
BdCubasdocEntity fuzzyQueryCustomers = queryU8CEntityUtil.getFuzzyQueryCustomers(memberId.trim());
Assert.notNull(fuzzyQueryCustomers, "根据OFS会员id{}无法查询到U8C客商基本档案", memberId.trim());
//客商管理档案
BdCumandocEntity bdCumandocEntity1 = new BdCumandocEntity();
bdCumandocEntity1.setDataSourceCode("lets_u8c");
bdCumandocEntity1.setDr(0L);
bdCumandocEntity1.setPkCorp(bdCorpEntityList.get(0).getPkCorp());
bdCumandocEntity1.setPkCubasdoc(bdCubasdocEntityList.get(0).getPkCubasdoc());
bdCumandocEntity1.setPkCubasdoc(fuzzyQueryCustomers.getPkCubasdoc());
bdCumandocEntity1.setCustflags(ProfilesActiveConstant.CUSTOMER);
List<BdCumandocEntity> bdCumandocEntityList = iBdCumandocDao.query(bdCumandocEntity1);
if (bdCumandocEntityList == null || bdCumandocEntityList.size() == 0) {
Assert.state(false, "根据客商基本档案主键{},没有办法查询到客商管理档案", bdCubasdocEntityList.get(0).getPkCubasdoc());
Assert.state(false, "根据客商基本档案主键{},没有办法查询到客商管理档案", fuzzyQueryCustomers.getPkCubasdoc());
}
//查找平台
@ -1444,7 +1448,7 @@ public class SoSaleReturnPluginInitializerToB extends PluginBaseEntity {
orderOutTobHeaderDto.setBdSalestruEntity(bdSalestruEntityList.get(0));
orderOutTobHeaderDto.setBdDeptdocEntity(bdDeptdocEntityList.get(0));
orderOutTobHeaderDto.setBdCumandocEntity(bdCumandocEntityList.get(0));
orderOutTobHeaderDto.setBdCubasdocEntity(bdCubasdocEntityList.get(0));
orderOutTobHeaderDto.setBdCubasdocEntity(fuzzyQueryCustomers);
orderOutTobHeaderDto.setDeliverGoodsCorp(bdCorpEntityList.get(0));
orderOutTobHeaderDto.setPlatformArchives(bdDefdocEntityList.get(0));
orderOutTobHeaderDto.setShopArchives(bdDefdocEntityList2.get(0));

View File

@ -8,6 +8,7 @@ import com.hzya.frame.plugin.lets.entity.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -358,4 +359,49 @@ public class QueryU8CEntityUtil {
return stringStringHashMap;
}
////////////////////////////////////////////////////////////////////////////////////////公司自定义档案查询
@Autowired
private IBdCubasdocDao iBdCubasdocDao;
/**
* 模糊匹配会员id在客商档案的自定义项1
* 1889,1888
* 188
* 和佳妮确认TOC对应的客商不会存在def1逗号的问题
*
* @author liuyang
*/
public BdCubasdocEntity getFuzzyQueryCustomers(String memberId) {
//拆分之后收集好
Map<String, BdCubasdocEntity> bdCubasdocEntityMap = new HashMap<>();
if (memberId != null && !"".equals(memberId.trim())) {
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
bdCubasdocEntity.setDef1(memberId.trim());//模糊查询客商档案
List<BdCubasdocEntity> bdCubasdocEntityList = iBdCubasdocDao.query(bdCubasdocEntity);
if (bdCubasdocEntityList != null && bdCubasdocEntityList.size() > 0) {
for (int i = 0; i < bdCubasdocEntityList.size(); i++) {
BdCubasdocEntity bdCubasdocEntity1 = bdCubasdocEntityList.get(i);
String def1 = bdCubasdocEntity1.getDef1();
if (def1 != null && !"".equals(def1)) {
if (def1.contains(",")) {
//存在逗号
String[] split = def1.split(",");
for (int j = 0; j < split.length; j++) {
String targetMemberId = split[j];
bdCubasdocEntityMap.put(targetMemberId, bdCubasdocEntity1);
}
} else {
//不存在逗号
bdCubasdocEntityMap.put(def1, bdCubasdocEntity1);
}
}
}
}
}
return bdCubasdocEntityMap.get(memberId);
}
}

View File

@ -109,10 +109,10 @@ class SoSaleOutPluginInitializerToCTest {
// String aaa = "LETS-SH2024101900022025";
// soSaleOutPluginInitializerToC.startImplementStockByCode(aaa, "tran");
String aaa = "LETS-SH2024102900016893";
soSaleOutPluginInitializerToC.startImplementStockByCode(aaa, "tran");
// String aaa = "LETS-SH2024102900016893";
// soSaleOutPluginInitializerToC.startImplementStockByCode(aaa, "tran");
// soSaleOutPluginInitializerToC.startImplementTranByTime("2024-10-26 18:20:09","2024-10-26 18:20:09");
soSaleOutPluginInitializerToC.startImplementStockByTime("2024-10-30 00:00:00", "2024-10-30 23:59:59");
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -62,7 +62,17 @@ public class QueryU8CEntityUtilTest {
// String s = queryU8CEntityUtil.queryBdDefDocByPkDefDocList("KS");
// System.out.println(s);
Map<String, String> stringStringMap = queryU8CEntityUtil.queryBdDefDocByPkDefDocAll();
System.out.println(JSON.toJSONString(stringStringMap));
// Map<String, String> stringStringMap = queryU8CEntityUtil.queryBdDefDocByPkDefDocAll();
// System.out.println(JSON.toJSONString(stringStringMap));
}
@Test
public void testGetFuzzyQueryCustomers() {
try {
String aaa = "188";
queryU8CEntityUtil.getFuzzyQueryCustomers(aaa);
} catch (Exception e) {
e.printStackTrace();
}
}
}