Commit a849f6a1 by “zcwang”

modify:导出完善,查询循环外置

parent a017b715
Pipeline #44159 passed with stages
in 2 minutes 23 seconds
...@@ -11,7 +11,6 @@ import java.util.Arrays; ...@@ -11,7 +11,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
...@@ -122,33 +121,60 @@ public class ChangeFlowExportCallback implements DesCallbackService { ...@@ -122,33 +121,60 @@ public class ChangeFlowExportCallback implements DesCallbackService {
if (CollectionUtils.isEmpty(changeRecords)) { if (CollectionUtils.isEmpty(changeRecords)) {
return Lists.newArrayList(); return Lists.newArrayList();
} }
List<ChangeFlowExcelDTO> changeFlowExcelDTOList = new ArrayList<>(); // 提前查询所有行动项用户名
// 导出excel,按照商品/供应商和行动项,n*n重复拆分,例2个商品3个行动项,拆分成2*3=6行,其他属性一致 List<String> allExecUserEmailList = new ArrayList<>();
for (ChangeRecord record : changeRecords) { for (ChangeRecord changeRecord : changeRecords) {
List<ChangeExecRecord> changeExecRecords = changeExecRecordMapper.selectByChangeRecordId(record.getId()); List<ChangeExecRecord> changeExecRecords = changeExecRecordMapper.selectByChangeRecordId(changeRecord.getId());
List<String> collect = changeExecRecords.stream()
.map(ChangeExecRecord::getChangeExecUserEmail)
.filter(StringUtils::isNotBlank).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(collect)) {
allExecUserEmailList.addAll(collect);
}
}
List<IusUserInfoRsp> userListInfo = new ArrayList<>(); List<IusUserInfoRsp> userListInfo = new ArrayList<>();
try { try {
Set<String> userEmail = changeExecRecords.stream().map(ChangeExecRecord::getChangeExecUserEmail).collect(Collectors.toSet()); if (CollectionUtils.isNotEmpty(allExecUserEmailList)) {
userListInfo = iusService.queryUserListInfo(UserQueryDTO.builder().uids(new ArrayList<>(userEmail)).build()); List<String> userEmailList = allExecUserEmailList.stream().distinct().collect(Collectors.toList());
} catch (Exception ex) { userListInfo = iusService.queryUserListInfo(UserQueryDTO.builder().uids(userEmailList).build());
log.info("query user info has ex", ex);
} }
ChangeSubjectEnum changeSubjectEnum = ChangeSubjectEnum.getChangeSubjectEnum(record.getChangeSubject()); } catch (Exception e) {
switch (changeSubjectEnum) { log.info("query user info has ex", e);
case PRODUCT: }
String changeItemJsonStr = record.getChangeItem(); // 提前查询所有商品
List<Long> allItemList = new ArrayList<>();
List<String> allChangeProduct = changeRecords.stream()
.filter(changeRecord -> changeRecord.getChangeSubject().equals(ChangeSubjectEnum.PRODUCT.getType()))
.map(ChangeRecord::getChangeItem).filter(StringUtils::isNotBlank).collect(Collectors.toList());
if (CollectionUtils.isNotEmpty(allChangeProduct)) {
for (String changeItemJsonStr : allChangeProduct) {
List<ItemVO> itemVOS = JSON.parseArray(changeItemJsonStr, ItemVO.class); List<ItemVO> itemVOS = JSON.parseArray(changeItemJsonStr, ItemVO.class);
List<Long> itemIds = itemVOS.stream().map(ItemVO::getItemId).collect(Collectors.toList()); List<Long> itemIds = itemVOS.stream().map(ItemVO::getItemId).collect(Collectors.toList());
allItemList.addAll(itemIds);
}
}
if (CollectionUtils.isNotEmpty(allItemList)) {
allItemList = allItemList.stream().distinct().collect(Collectors.toList());
}
// 批量查询spu信息 // 批量查询spu信息
List<SpuTO> spuTOS = itemService.batchQuerySpuInfo(BatchQuerySpuInfoParam.builder().ids(itemIds) List<SpuTO> spuTOS = itemService.batchQuerySpuInfo(BatchQuerySpuInfoParam.builder().ids(allItemList)
.commonProps(new ArrayList<>()).spuProps(Arrays.asList("itemSetupType", "businessForm")).build()); .commonProps(new ArrayList<>()).spuProps(Arrays.asList("itemSetupType", "businessForm")).build());
// 批量查询物理类目 // 批量查询物理类目
Map<Long, List<SimplePhyCateGoryResultCo>> categoryChain = itemService Map<Long, List<SimplePhyCateGoryResultCo>> categoryChain = itemService
.queryBySpuIds(CommonIdsParamQuery.builder().ids(itemIds).build()); .queryBySpuIds(CommonIdsParamQuery.builder().ids(allItemList).build());
// 查询商品对应负责人信息 // 查询商品对应负责人信息
Map<Long, ChangeGoodsPrincipalPO> longChangeGoodsPrincipalPOMap = interiorChangeConfigService Map<Long, ChangeGoodsPrincipalPO> longChangeGoodsPrincipalPOMap = interiorChangeConfigService
.queryGoodsPrincipalInfo(itemIds); .queryGoodsPrincipalInfo(allItemList);
log.debug("[detail] spuTOS:{}", JSON.toJSONString(spuTOS)); log.debug("[getExportList] spuTOS:{}", spuTOS.size());
List<ChangeFlowExcelDTO> changeFlowExcelDTOList = new ArrayList<>();
// 导出excel,按照商品/供应商和行动项,n*n重复拆分,例2个商品3个行动项,拆分成2*3=6行,其他属性一致
for (ChangeRecord record : changeRecords) {
List<ChangeExecRecord> changeExecRecords = changeExecRecordMapper.selectByChangeRecordId(record.getId());
ChangeSubjectEnum changeSubjectEnum = ChangeSubjectEnum.getChangeSubjectEnum(record.getChangeSubject());
switch (changeSubjectEnum) {
case PRODUCT:
String changeItemJsonStr = record.getChangeItem();
List<ItemVO> itemVOS = JSON.parseArray(changeItemJsonStr, ItemVO.class);
for (ItemVO itemVO : itemVOS) { for (ItemVO itemVO : itemVOS) {
for (ChangeExecRecord changeExecRecord : changeExecRecords) { for (ChangeExecRecord changeExecRecord : changeExecRecords) {
Long itemId = itemVO.getItemId(); Long itemId = itemVO.getItemId();
...@@ -210,40 +236,13 @@ public class ChangeFlowExportCallback implements DesCallbackService { ...@@ -210,40 +236,13 @@ public class ChangeFlowExportCallback implements DesCallbackService {
} }
break; break;
case SUPPLIER: case SUPPLIER:
// 供应商变更,以行动项循环
for (ChangeExecRecord changeExecRecord : changeExecRecords) {
// 组装通用信息,除商品信息,行动项以外其他字段一致
ChangeFlowExcelDTO changeFlowExcelDTO = this.obtainCommon(record, changeSubjectEnum);
changeFlowExcelDTO.setSupplier(record.getChangeSupplier());
changeFlowExcelDTO.setChangeItem(null);
changeFlowExcelDTO.setSPUId(null);
changeFlowExcelDTO.setQcCategory(null);
changeFlowExcelDTO.setPhyCategory(null);
changeFlowExcelDTO.setItemSetupType(null);
changeFlowExcelDTO.setBusinessForm(null);
changeFlowExcelDTO.setStatus(null);
changeFlowExcelDTO.setFunctionary(null);
changeFlowExcelDTO.setPurchase(null);
changeFlowExcelDTO.setGoodsSqe(null);
changeFlowExcelDTO.setGoodsProjectName(null);
// 组装行动项相关信息
this.obtainChangeExec(changeExecRecord, changeFlowExcelDTO, userListInfo);
ChangeResultEnum resultEnum = ChangeResultEnum.getByStatus(record.getChangeResult());
changeFlowExcelDTO.setChangeResult(resultEnum == null ? "": resultEnum.getDesc());
changeFlowExcelDTO
.setChangeEndTime(record.getState().equals(ChangeStatusEnum.END.getStatus())
? DateUtils.parseLongToString(record.getUpdateTime(), DateUtils.DATE_TIME_FORMAT)
: "");
changeFlowExcelDTOList.add(changeFlowExcelDTO);
}
break;
case OTHER: case OTHER:
default: default:
// 供应商变更,以行动项循环 // 供应商变更,以行动项循环
for (ChangeExecRecord changeExecRecord : changeExecRecords) { for (ChangeExecRecord changeExecRecord : changeExecRecords) {
// 组装通用信息,除商品信息,行动项以外其他字段一致 // 组装通用信息,除商品信息,行动项以外其他字段一致
ChangeFlowExcelDTO changeFlowExcelDTO = this.obtainCommon(record, changeSubjectEnum); ChangeFlowExcelDTO changeFlowExcelDTO = this.obtainCommon(record, changeSubjectEnum);
changeFlowExcelDTO.setSupplier(null); changeFlowExcelDTO.setSupplier(record.getChangeSupplier());
changeFlowExcelDTO.setChangeItem(null); changeFlowExcelDTO.setChangeItem(null);
changeFlowExcelDTO.setSPUId(null); changeFlowExcelDTO.setSPUId(null);
changeFlowExcelDTO.setQcCategory(null); changeFlowExcelDTO.setQcCategory(null);
...@@ -265,6 +264,7 @@ public class ChangeFlowExportCallback implements DesCallbackService { ...@@ -265,6 +264,7 @@ public class ChangeFlowExportCallback implements DesCallbackService {
: ""); : "");
changeFlowExcelDTOList.add(changeFlowExcelDTO); changeFlowExcelDTOList.add(changeFlowExcelDTO);
} }
break;
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment