优化OFS销售出库单处理逻辑

- 移除了不必要的注释代码,提高了代码的可读性
- 优化了OFS销售订单和销售出库单的关联逻辑
- 改进了店铺编码的处理方式,增加了去重逻辑
- 调整了部门信息的获取逻辑,提供了默认值处理
- 优化了存货和客商档案的查询逻辑
This commit is contained in:
liuy 2024-10-08 16:16:24 +08:00
parent 772e07467d
commit 467120fa5e
6 changed files with 121 additions and 55 deletions

View File

@ -887,7 +887,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
* @author liuyang
*/
private String createGenerateBusinessDateStock(com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.HeaderDto header) {
//TODO 测试
//测试
// header.setShipAt("2024-09-14");
if (header != null && header.getShipAt() != null) {
//TOC以出库日期作为业务日期
@ -960,20 +960,20 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
HeaderDto header = headerDetailsDto.getHeader();
List<com.hzya.frame.ttxofs.dto.ofssaleorderoutsearch.DetailsDto> details = headerDetailsDto.getDetails();
try {
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = header.getHeaderDetailsDto();
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader();
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details1 = headerDetailsDto1.getDetails();
// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = header.getHeaderDetailsDto();
// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader();
// List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details1 = headerDetailsDto1.getDetails();
//OFS销售订单
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto2 = header.getHeaderDetailsDto();
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header2 = headerDetailsDto2.getHeader();
// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto2 = header.getHeaderDetailsDto();
// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header2 = headerDetailsDto2.getHeader();
//TOCTOB业务已经和万确认如果没有则默认为SALES销售
if (header2.getSubOrderType() == null || "".equals(header2.getSubOrderType())) {
header2.setSubOrderType("SALES");
}
BdRdclEntity bdRdclEntity = cacheTocMapVo.getStringBdRdclEntityMap().get(header2.getSubOrderType());
Assert.notNull(bdRdclEntity, "根据业务类型({})没有匹配到U8C业务类型", header2.getSubOrderType());
// if (header2.getSubOrderType() == null || "".equals(header2.getSubOrderType())) {
// header2.setSubOrderType("SALES");
// }
// BdRdclEntity bdRdclEntity = cacheTocMapVo.getStringBdRdclEntityMap().get(header2.getSubOrderType());
// Assert.notNull(bdRdclEntity, "根据业务类型({})没有匹配到U8C业务类型", header2.getSubOrderType());
//表头公司通过名称匹配U8C公司
// String corpName = "上海丽知品牌管理有限公司";
@ -1006,24 +1006,26 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
Assert.notNull(bdSalestruEntity, "无匹配到销售组织 表头公司名称:{}", bdCorpEntity.getUnitname());
//业务部门暂定的部门名称业务部门2024年8月5日 15:39:42 已经和妮姐确认
BdDeptdocEntity bdDeptdocEntity = null;
if (header2.getDepartmentType() == null || "".equals(header2.getDepartmentType().trim())) {
//默认业务部门
logger.info("OFS销售订单号{} 不存在部门字段!", header2.getCode());
bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp());
Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:业务部门 对应公司主键:{}", bdCorpEntity.getPkCorp());
} else {
//使用O选定的部门字段
logger.info("OFS销售订单号{} 存在部门字段:{}", header2.getCode(), header2.getDepartmentType());
String deptCode = header2.getDepartmentType().trim();
bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMapByDeptCode().get(deptCode);
Assert.notNull(bdDeptdocEntity, "无法匹配到U8C部门档案 OFS销售订单-部门编码:{}", deptCode);
}
// BdDeptdocEntity bdDeptdocEntity = null;
// if (header2.getDepartmentType() == null || "".equals(header2.getDepartmentType().trim())) {
// //默认业务部门
// logger.info("OFS销售订单号{} 不存在部门字段!", header2.getCode());
// bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp());
// Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:业务部门 对应公司主键:{}", bdCorpEntity.getPkCorp());
// } else {
// //使用O选定的部门字段
// logger.info("OFS销售订单号{} 存在部门字段:{}", header2.getCode(), header2.getDepartmentType());
// String deptCode = header2.getDepartmentType().trim();
// bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMapByDeptCode().get(deptCode);
// Assert.notNull(bdDeptdocEntity, "无法匹配到U8C部门档案 OFS销售订单-部门编码:{}", deptCode);
// }
//客商基本档案
// 2024年8月8日 12:05:10 O店铺的业务编码=U8C客商自定义项1O没有店铺信息查询接口因此无法通过出库单的店铺编码查询到O店铺档案对应的业务编码接口上线之后需要补充这一部分逻辑
// String custName = "天猫intoyou旗舰店-自营";
String storeCode = header.getStoreCode();
//测试
// storeCode = "dy-off-01";
Assert.notNull(storeCode, "O店铺编码不能为空没有办法完成业务逻辑");
Assert.state(!"".equals(storeCode.trim()), "O店铺编码不能为空没有办法完成业务逻辑");
BdCubasdocEntity bdCubasdocEntity = cacheTocMapVo.getStringBdCubasdocEntityMap().get(storeCode);
@ -1033,7 +1035,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
//2024年8月5日 15:49:49 先根据O店铺编码得到店铺档案信息取到名称通过U8C接口查询出来
//目前O店铺信息查询接口还没有等待开发所以我这里先写所一个名字
BdCumandocEntity bdCumandocEntity = cacheTocMapVo.getStringBdCumandocEntityMap().get(bdCubasdocEntity.getPkCubasdoc() + bdCorpEntity.getPkCorp());
Assert.notNull(bdCumandocEntity, "无法匹配到客商档案 店铺名称:{}", "天猫intoyou旗舰店-自营");
Assert.notNull(bdCumandocEntity, "无法匹配到客商管理档案 店铺编码:{}", storeCode);
//查找平台
BdDefdocEntity bdDefdocEntity = cacheTocMapVo.getStringBdDefdocPlatformEntityMap().get(header.getSourcePlatformCode());
@ -1047,6 +1049,33 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
for (int j = 0; j < details.size(); j++) {
DetailsDto detailsDto = details.get(j);
//OFS销售订单
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto2 = detailsDto.getHeaderDetailsDto();
Assert.notNull(headerDetailsDto2, "根据出库单明细行对应的refOrderCode(OFS销售订单号)无法匹配到OFS销售订单", detailsDto.getRefOrderCode());
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header2 = headerDetailsDto2.getHeader();
//TOCTOB业务已经和万确认如果没有则默认为SALES销售
if (header2.getSubOrderType() == null || "".equals(header2.getSubOrderType())) {
header2.setSubOrderType("SALES");
}
BdRdclEntity bdRdclEntity = cacheTocMapVo.getStringBdRdclEntityMap().get(header2.getSubOrderType());
Assert.notNull(bdRdclEntity, "根据业务类型({})没有匹配到U8C业务类型", header2.getSubOrderType());
BdDeptdocEntity bdDeptdocEntity = null;
if (header2.getDepartmentType() == null || "".equals(header2.getDepartmentType().trim())) {
//默认业务部门
logger.info("OFS销售订单号{} 不存在部门字段!", header2.getCode());
bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMap().get(bdCorpEntity.getPkCorp());
Assert.notNull(bdDeptdocEntity, "无法匹配到业务部门 部门名称:业务部门 对应公司主键:{}", bdCorpEntity.getPkCorp());
} else {
//使用O选定的部门字段
logger.info("OFS销售订单号{} 存在部门字段:{}", header2.getCode(), header2.getDepartmentType());
String deptCode = header2.getDepartmentType().trim();
bdDeptdocEntity = cacheTocMapVo.getStringBdDeptdocEntityMapByDeptCode().get(deptCode);
Assert.notNull(bdDeptdocEntity, "无法匹配到U8C部门档案 OFS销售订单-部门编码:{}", deptCode);
}
//存货基本档案
BdInvbasdocEntity bdInvbasdocEntity = cacheTocMapVo.getStringBdInvbasdocEntityMap().get(detailsDto.getSkuCode());
Assert.notNull(bdInvbasdocEntity, "无法匹配到存货基本档案 存货管理主键:{} 公司:{}", detailsDto.getSkuCode(), bdCorpEntity.getPkCorp());
@ -1076,7 +1105,7 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
sonDetailsDto.setBdInvmandocEntity(bdInvmandocEntity);
sonDetailsDto.setBdInvbasdocEntity(bdInvbasdocEntity);
sonDetailsDto.setBdTaxitemsEntity(bdTaxitemsEntity);
sonDetailsDto.setHeaderDetailsDto(headerDetailsDto1);
sonDetailsDto.setHeaderDetailsDto(detailsDto.getHeaderDetailsDto());
sonDetailsDto.setBdRdclEntity(bdRdclEntity);
BeanUtil.copyPropertiesV2(detailsDto, sonDetailsDto);
@ -1335,8 +1364,10 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
for (int i = 0; i < sonDetailsDtoList.size(); i++) {
SonDetailsDto sonDetailsDto = sonDetailsDtoList.get(i);
//实付金额/实发数量
//OFS销售订单实付金额:totalPayAmount
//OFS销售出库单实付金额totalPayAmount
//是一样的字段目前暂时取销售出库单对应的totalPayAmount
Assert.notNull(sonDetailsDto.getTotalPayAmount(), "实付金额不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto));
Assert.notNull(sonDetailsDto.getShipQty(), "实发数量不能为空 明细行对象:{}", JSON.toJSONString(sonDetailsDto));
BigDecimal totalPayAmountBigDecimal = new BigDecimal(sonDetailsDto.getTotalPayAmount());
@ -2215,25 +2246,37 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
for (int i = 0; i < splitListByCount.size(); i++) {
List<HeaderDetailsDto> headerDetailsDtos = splitListByCount.get(i);
StringBuffer stringBuffer = new StringBuffer();
Set<String> refOrderCodeSet = new HashSet<>();
// StringBuffer stringBuffer = new StringBuffer();
if (headerDetailsDtos != null && headerDetailsDtos.size() > 0) {
for (int j = 0; j < headerDetailsDtos.size(); j++) {
HeaderDetailsDto headerDetailsDto = headerDetailsDtos.get(j);
HeaderDto header = headerDetailsDto.getHeader();
// List<DetailsDto> details = headerDetailsDto.getDetails();
List<DetailsDto> details = headerDetailsDto.getDetails();
for (int k = 0; k < details.size(); k++) {
DetailsDto detailsDto = details.get(k);
//考虑refOrderCode去除重复提升查询的效率
// stringBuffer.append("'");
// stringBuffer.append(detailsDto.getRefOrderCode());
// stringBuffer.append("'");
stringBuffer.append(header.getRefOrderCode());
// stringBuffer.append("'");
stringBuffer.append(",");
// stringBuffer.append(",");
refOrderCodeSet.add(detailsDto.getRefOrderCode());
}
}
}
String substring = stringBuffer.substring(0, stringBuffer.length());
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtoArrayList = new ArrayList<>();
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
queryOfsSoSaleOutVo.setCode(substring);
ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L);
allHeaderDetailsDtoArrayList.addAll(headerDetailsDtoArrayList);
if (refOrderCodeSet.size() > 0) {
//转换为逗号
StringJoiner joiner = new StringJoiner(",");
for (String str : refOrderCodeSet) {
joiner.add(str);
}
// String substring = stringBuffer.substring(0, stringBuffer.length());
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtoArrayList = new ArrayList<>();
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
queryOfsSoSaleOutVo.setCode(joiner.toString());
ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L);
allHeaderDetailsDtoArrayList.addAll(headerDetailsDtoArrayList);
}
}
}
} catch (Exception e) {
@ -2257,15 +2300,28 @@ public class SoSaleOutPluginInitializerToC extends PluginBaseEntity {
HeaderDto header = headerDetailsDto.getHeader();
List<DetailsDto> details = headerDetailsDto.getDetails();
String targetRefOrderCode = header.getRefOrderCode();
for (int j = 0; j < ofsSaleOrder.size(); j++) {
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = ofsSaleOrder.get(j);
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader();
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details1 = headerDetailsDto1.getDetails();
if (header1.getCode().equals(targetRefOrderCode)) {
header.setHeaderDetailsDto(headerDetailsDto1);
for (int j = 0; j < details.size(); j++) {
DetailsDto detailsDto = details.get(j);
String refOrderCode = detailsDto.getRefOrderCode();
for (int k = 0; k < ofsSaleOrder.size(); k++) {
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = ofsSaleOrder.get(k);
com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader();
// List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details1 = headerDetailsDto1.getDetails();
if (header1.getCode().equals(refOrderCode)) {
detailsDto.setHeaderDetailsDto(headerDetailsDto1);
}
}
}
// String targetRefOrderCode = header.getRefOrderCode();
// for (int j = 0; j < ofsSaleOrder.size(); j++) {
// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto1 = ofsSaleOrder.get(j);
// com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDto header1 = headerDetailsDto1.getHeader();
// List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.DetailsDto> details1 = headerDetailsDto1.getDetails();
// if (header1.getCode().equals(targetRefOrderCode)) {
// header.setHeaderDetailsDto(headerDetailsDto1);
// }
// }
}
} catch (Exception e) {
logger.error("findMatchingOfsOrder方法抛出异常", e);

View File

@ -1550,8 +1550,7 @@ public class SoSaleReturnPluginInitializerToC extends PluginBaseEntity {
for (int j = 0; j < stockinOrderList.size(); j++) {
StockinOrderSearchResponse.StockinOrder stockinOrder = stockinOrderList.get(j);
StockinOrderSearchResponse.StockinOrder.StockinH header = stockinOrder.getHeader();
List<StockinOrderSearchResponse.StockinOrder.StockinB> details = stockinOrder.getDetails();
// List<StockinOrderSearchResponse.StockinOrder.StockinB> details = stockinOrder.getDetails();
idStr.append(header.getRefOrderCode());
idStr.append(",");
}

View File

@ -228,7 +228,8 @@ public class TocOrderBasicArchivesCacheUtil {
for (int i = 0; i < splitListByCount.size(); i++) {
List<HeaderDto> headerDtoList1 = splitListByCount.get(i);
String codesStr = headerDtoList1.stream().map(HeaderDto::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
//测试
// codesStr = "'dy-off-01'";
BdCubasdocEntity bdCubasdocEntity = new BdCubasdocEntity();
bdCubasdocEntity.setDataSourceCode("lets_u8c");
bdCubasdocEntity.setDr(0L);
@ -281,6 +282,8 @@ public class TocOrderBasicArchivesCacheUtil {
for (int i = 0; i < splitListByCount.size(); i++) {
List<HeaderDto> headerDtoList1 = splitListByCount.get(i);
String codesStr = headerDtoList1.stream().map(HeaderDto::getStoreCode).map(id -> "'" + id + "'").collect(Collectors.joining(","));
//测试
// codesStr = "'dy-off-01'";
BdCumandocEntity bdCumandocEntity = new BdCumandocEntity();
bdCumandocEntity.setDataSourceCode("lets_u8c");

View File

@ -87,10 +87,14 @@ class SoSaleOutPluginInitializerToCTest {
// soSaleOutPluginInitializerToC.startImplementStockByTime("2024-09-24 16:35:43","2024-09-24 16:35:45");
List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtoArrayList = new ArrayList<>();
QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
queryOfsSoSaleOutVo.setCode("LETS-SO2024092500000018");
ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L);
System.out.println(headerDetailsDtoArrayList.get(0).getHeader().getDepartmentType());
// List<com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto> headerDetailsDtoArrayList = new ArrayList<>();
// QueryOfsSoSaleOutVo queryOfsSoSaleOutVo = new QueryOfsSoSaleOutVo();
// queryOfsSoSaleOutVo.setCode("LETS-SO2024092500000018");
// ofsStandardUtil.getOfsSaleOrder(queryOfsSoSaleOutVo, headerDetailsDtoArrayList, 1L);
// System.out.println(headerDetailsDtoArrayList.get(0).getHeader().getDepartmentType());
String s = "LETS-SH2024092900000029";
soSaleOutPluginInitializerToC.startImplementStockByCode(s, "stock");
}
}

View File

@ -53,4 +53,8 @@ public class DetailsDto {
* (销售)交易成功(TOB发票)是否成功
*/
private String newState4;
/**
* OFS销售订单
*/
private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto;
}

View File

@ -78,5 +78,5 @@ public class HeaderDto {
// private String subOrderType;
//OFS销售订单
private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto;
// private com.hzya.frame.ttxofs.dto.ofssalesordersearch.HeaderDetailsDto headerDetailsDto;
}