diff --git a/base-buildpackage/src/main/java/com/hzya/frame/voucher/ae/push/service/impl/AePushVoucherLogServiceImpl.java b/base-buildpackage/src/main/java/com/hzya/frame/voucher/ae/push/service/impl/AePushVoucherLogServiceImpl.java index 32b0d36c..781ef1a6 100644 --- a/base-buildpackage/src/main/java/com/hzya/frame/voucher/ae/push/service/impl/AePushVoucherLogServiceImpl.java +++ b/base-buildpackage/src/main/java/com/hzya/frame/voucher/ae/push/service/impl/AePushVoucherLogServiceImpl.java @@ -48,210 +48,210 @@ public class AePushVoucherLogServiceImpl extends BaseService queryBill(AePushVoucherLogEntity entity) { - Assert.notNull(entity.getMdmId(), "mdmId不能为空"); - - // 1. 查询原始数据 - CreateVoucherVO createVoucherVO = new CreateVoucherVO(); - createVoucherVO.setMdmId(entity.getMdmId()); - createVoucherVO.setTimeStart(entity.getTimeStart()); - createVoucherVO.setTimeEnd(entity.getTimeEnd()); - - List> mapList = coreService.queryDataByMdmId(createVoucherVO); - List allList = transData(entity.getMdmId(), mapList); - - // 2. 查询已推送数据,并构建 billCode -> entity 的映射 - AePushVoucherLogEntity queryEntity = new AePushVoucherLogEntity(); - queryEntity.setMdmId(entity.getMdmId()); - List pushData = aePushVoucherLogDao.query(queryEntity); - - Map pushMap = pushData.stream() - .collect(Collectors.toMap( - AePushVoucherLogEntity::getBillCode, - e -> e, - (e1, e2) -> e1 // 如果有重复 billCode,保留第一个 - )); - - // 3. 设置 billStatus 和 pushInfo - for (AePushVoucherLogEntity allEntity : allList) { - AePushVoucherLogEntity pushEntity = pushMap.get(allEntity.getBillCode()); - if (pushEntity != null) { - allEntity.setBillStatus("Y"); - allEntity.setPushInfo(pushEntity.getPushInfo()); - } else { - allEntity.setBillStatus("N"); - // pushInfo 保持 null 或设为默认值 - } - } - - // 4. 过滤数据 - List filteredList = filterByConditions(allList, entity.getBillCode(), entity.getBillStatus()); - - // 5. 增强数据:调用 Y 状态专用查询和模板类型查询 - enhanceData(filteredList); - - // 6. 返回结果 - return filteredList; - } - - // 过滤逻辑抽离 - private List filterByConditions(List list, String billCode, String billStatus) { - return list.stream().filter(entity -> { - // 单据号匹配 - if (billCode != null && !billCode.isEmpty()) { - if (entity.getBillCode() == null || !entity.getBillCode().contains(billCode)) { - return false; - } - } - // 状态匹配 - if (billStatus != null && !billStatus.isEmpty()) { - if (!billStatus.equals(entity.getBillStatus())) { - return false; - } - } - return true; - }).collect(Collectors.toList()); - } - - // 数据增强逻辑抽离 - private void enhanceData(List list) { - list.forEach(entity -> { - if ("Y".equals(entity.getBillStatus())) { - queryByBillCodeAndStatueY(entity); - } - }); - queryTempType(list); - } - - // @Override // public List queryBill(AePushVoucherLogEntity entity) { // Assert.notNull(entity.getMdmId(), "mdmId不能为空"); // +// // 1. 查询原始数据 // CreateVoucherVO createVoucherVO = new CreateVoucherVO(); // createVoucherVO.setMdmId(entity.getMdmId()); -// if (entity.getTimeStart() != null && !"".equals(entity.getTimeStart())) { -// createVoucherVO.setTimeStart(entity.getTimeStart()); -// } -// if (entity.getTimeEnd() != null && !"".equals(entity.getTimeEnd())) { -// createVoucherVO.setTimeEnd(entity.getTimeEnd()); -// } -// -// List> mapList = coreService.queryDataByMdmId(createVoucherVO);//已被去重 +// createVoucherVO.setTimeStart(entity.getTimeStart()); +// createVoucherVO.setTimeEnd(entity.getTimeEnd()); // +// List> mapList = coreService.queryDataByMdmId(createVoucherVO); // List allList = transData(entity.getMdmId(), mapList); -// AePushVoucherLogEntity aePushVoucherLogEntity1 = new AePushVoucherLogEntity(); -// aePushVoucherLogEntity1.setMdmId(entity.getMdmId()); -// List pushData = aePushVoucherLogDao.query(aePushVoucherLogEntity1); // +// // 2. 查询已推送数据,并构建 billCode -> entity 的映射 +// AePushVoucherLogEntity queryEntity = new AePushVoucherLogEntity(); +// queryEntity.setMdmId(entity.getMdmId()); +// List pushData = aePushVoucherLogDao.query(queryEntity); +// +// Map pushMap = pushData.stream() +// .collect(Collectors.toMap( +// AePushVoucherLogEntity::getBillCode, +// e -> e, +// (e1, e2) -> e1 // 如果有重复 billCode,保留第一个 +// )); +// +// // 3. 设置 billStatus 和 pushInfo // for (AePushVoucherLogEntity allEntity : allList) { -// for (AePushVoucherLogEntity pushEntity : pushData) { -// if (allEntity.getBillCode().equals(pushEntity.getBillCode())) { -// allEntity.setBillStatus("Y"); -// allEntity.setPushInfo(pushEntity.getPushInfo()); -// break; -// } else { -// allEntity.setBillStatus("N"); -//// allEntity.setPushInfo(pushEntity.getPushInfo()); -// } -// } -// -// } -// -// List resList = new ArrayList<>(); -// -// String billCode = entity.getBillCode(); -// String status = entity.getBillStatus(); -// -// //单据号 -// if (billCode != null && status == null) { -// for (AePushVoucherLogEntity aePushVoucherLogEntity : allList) { -// if (aePushVoucherLogEntity.getBillCode().contains(billCode)) { -// resList.add(aePushVoucherLogEntity); -// } -// } -// if (entity.getBillStatus() != null && !"".equals(entity.getBillStatus())) { -// List statusList = new ArrayList<>(); -// for (AePushVoucherLogEntity aePushVoucherLogEntity : resList) { -// if (status.equals(aePushVoucherLogEntity.getBillStatus())) { -// statusList.add(aePushVoucherLogEntity); -// } -// } -// -// for (AePushVoucherLogEntity aePushVoucherLogEntity : statusList) { -// queryByBillCodeAndStatueY(aePushVoucherLogEntity); -// } -// queryTempType(statusList); -// return statusList; -// } -// -// for (AePushVoucherLogEntity aePushVoucherLogEntity : resList) { -// queryByBillCodeAndStatueY(aePushVoucherLogEntity); -// } -// -// -// queryTempType(resList); -// return resList; -// -// } -// //状态 -// if (billCode == null && status != null) { -// if (entity.getBillStatus() != null && !"".equals(entity.getBillStatus())) { -// List statusList = new ArrayList<>(); -// for (AePushVoucherLogEntity aePushVoucherLogEntity : allList) { -// if (status.equals(aePushVoucherLogEntity.getBillStatus())) { -// statusList.add(aePushVoucherLogEntity); -// } -// } -// -// for (AePushVoucherLogEntity aePushVoucherLogEntity : statusList) { -// queryByBillCodeAndStatueY(aePushVoucherLogEntity); -// } -// queryTempType(statusList); -// return statusList; -// } -// -// for (AePushVoucherLogEntity aePushVoucherLogEntity : allList) { -// queryByBillCodeAndStatueY(aePushVoucherLogEntity); -// } -// -// -// queryTempType(allList); -// return allList; -// -// } -// //单据号+状态 -// if (billCode != null && status != null) { -// for (AePushVoucherLogEntity aePushVoucherLogEntity : allList) { -// if (aePushVoucherLogEntity.getBillCode().contains(billCode)) { -// resList.add(aePushVoucherLogEntity); -// } -// } -// -// if (entity.getBillStatus() != null && !"".equals(entity.getBillStatus())) { -// List statusList = new ArrayList<>(); -// for (AePushVoucherLogEntity aePushVoucherLogEntity : resList) { -// if (status.equals(aePushVoucherLogEntity.getBillStatus())) { -// statusList.add(aePushVoucherLogEntity); -// } -// } -// for (AePushVoucherLogEntity aePushVoucherLogEntity : statusList) { -// queryByBillCodeAndStatueY(aePushVoucherLogEntity); -// } -// queryTempType(statusList); -// return statusList; +// AePushVoucherLogEntity pushEntity = pushMap.get(allEntity.getBillCode()); +// if (pushEntity != null) { +// allEntity.setBillStatus("Y"); +// allEntity.setPushInfo(pushEntity.getPushInfo()); +// } else { +// allEntity.setBillStatus("N"); +// // pushInfo 保持 null 或设为默认值 // } // } // +// // 4. 过滤数据 +// List filteredList = filterByConditions(allList, entity.getBillCode(), entity.getBillStatus()); // -// for (AePushVoucherLogEntity aePushVoucherLogEntity : allList) { -// queryByBillCodeAndStatueY(aePushVoucherLogEntity); -// } +// // 5. 增强数据:调用 Y 状态专用查询和模板类型查询 +// enhanceData(filteredList); // -// queryTempType(allList); -// return allList; +// // 6. 返回结果 +// return filteredList; // } +// +// // 过滤逻辑抽离 +// private List filterByConditions(List list, String billCode, String billStatus) { +// return list.stream().filter(entity -> { +// // 单据号匹配 +// if (billCode != null && !billCode.isEmpty()) { +// if (entity.getBillCode() == null || !entity.getBillCode().contains(billCode)) { +// return false; +// } +// } +// // 状态匹配 +// if (billStatus != null && !billStatus.isEmpty()) { +// if (!billStatus.equals(entity.getBillStatus())) { +// return false; +// } +// } +// return true; +// }).collect(Collectors.toList()); +// } +// +// // 数据增强逻辑抽离 +// private void enhanceData(List list) { +// list.forEach(entity -> { +// if ("Y".equals(entity.getBillStatus())) { +// queryByBillCodeAndStatueY(entity); +// } +// }); +// queryTempType(list); +// } + + + @Override + public List queryBill(AePushVoucherLogEntity entity) { + Assert.notNull(entity.getMdmId(), "mdmId不能为空"); + + CreateVoucherVO createVoucherVO = new CreateVoucherVO(); + createVoucherVO.setMdmId(entity.getMdmId()); + if (entity.getTimeStart() != null && !"".equals(entity.getTimeStart())) { + createVoucherVO.setTimeStart(entity.getTimeStart()); + } + if (entity.getTimeEnd() != null && !"".equals(entity.getTimeEnd())) { + createVoucherVO.setTimeEnd(entity.getTimeEnd()); + } + + List> mapList = coreService.queryDataByMdmId(createVoucherVO);//已被去重 + + List allList = transData(entity.getMdmId(), mapList); + AePushVoucherLogEntity aePushVoucherLogEntity1 = new AePushVoucherLogEntity(); + aePushVoucherLogEntity1.setMdmId(entity.getMdmId()); + List pushData = aePushVoucherLogDao.query(aePushVoucherLogEntity1); + + for (AePushVoucherLogEntity allEntity : allList) { + for (AePushVoucherLogEntity pushEntity : pushData) { + if (allEntity.getBillCode().equals(pushEntity.getBillCode())) { + allEntity.setBillStatus("Y"); + allEntity.setPushInfo(pushEntity.getPushInfo()); + break; + } else { + allEntity.setBillStatus("N"); +// allEntity.setPushInfo(pushEntity.getPushInfo()); + } + } + + } + + List resList = new ArrayList<>(); + + String billCode = entity.getBillCode(); + String status = entity.getBillStatus(); + + //单据号 + if (billCode != null && status == null) { + for (AePushVoucherLogEntity aePushVoucherLogEntity : allList) { + if (aePushVoucherLogEntity.getBillCode().contains(billCode)) { + resList.add(aePushVoucherLogEntity); + } + } + if (entity.getBillStatus() != null && !"".equals(entity.getBillStatus())) { + List statusList = new ArrayList<>(); + for (AePushVoucherLogEntity aePushVoucherLogEntity : resList) { + if (status.equals(aePushVoucherLogEntity.getBillStatus())) { + statusList.add(aePushVoucherLogEntity); + } + } + + for (AePushVoucherLogEntity aePushVoucherLogEntity : statusList) { + queryByBillCodeAndStatueY(aePushVoucherLogEntity); + } + queryTempType(statusList); + return statusList; + } + + for (AePushVoucherLogEntity aePushVoucherLogEntity : resList) { + queryByBillCodeAndStatueY(aePushVoucherLogEntity); + } + + + queryTempType(resList); + return resList; + + } + //状态 + if (billCode == null && status != null) { + if (entity.getBillStatus() != null && !"".equals(entity.getBillStatus())) { + List statusList = new ArrayList<>(); + for (AePushVoucherLogEntity aePushVoucherLogEntity : allList) { + if (status.equals(aePushVoucherLogEntity.getBillStatus())) { + statusList.add(aePushVoucherLogEntity); + } + } + + for (AePushVoucherLogEntity aePushVoucherLogEntity : statusList) { + queryByBillCodeAndStatueY(aePushVoucherLogEntity); + } + queryTempType(statusList); + return statusList; + } + + for (AePushVoucherLogEntity aePushVoucherLogEntity : allList) { + queryByBillCodeAndStatueY(aePushVoucherLogEntity); + } + + + queryTempType(allList); + return allList; + + } + //单据号+状态 + if (billCode != null && status != null) { + for (AePushVoucherLogEntity aePushVoucherLogEntity : allList) { + if (aePushVoucherLogEntity.getBillCode().contains(billCode)) { + resList.add(aePushVoucherLogEntity); + } + } + + if (entity.getBillStatus() != null && !"".equals(entity.getBillStatus())) { + List statusList = new ArrayList<>(); + for (AePushVoucherLogEntity aePushVoucherLogEntity : resList) { + if (status.equals(aePushVoucherLogEntity.getBillStatus())) { + statusList.add(aePushVoucherLogEntity); + } + } + for (AePushVoucherLogEntity aePushVoucherLogEntity : statusList) { + queryByBillCodeAndStatueY(aePushVoucherLogEntity); + } + queryTempType(statusList); + return statusList; + } + } + + + for (AePushVoucherLogEntity aePushVoucherLogEntity : allList) { + queryByBillCodeAndStatueY(aePushVoucherLogEntity); + } + + queryTempType(allList); + return allList; + } @Override public List queryDetailsByBillCode(AePushVoucherLogEntity entity) {