Commit cffbc86e by 王志超

feat: 导出变更工单

parent c1a3588c
Pipeline #86862 passed with stages
in 1 minute 35 seconds
......@@ -60,7 +60,6 @@ import com.netease.mail.yanxuan.change.dal.entity.ChangeSubFlowRecord;
import com.netease.mail.yanxuan.change.dal.entity.ChangeType;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeExecRecordMapper;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeRecordMapper;
import com.netease.mail.yanxuan.change.dal.mapper.ChangeSubFlowRecordMapper;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeCommanderPO;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeConfigPo;
import com.netease.mail.yanxuan.change.dal.meta.model.po.ChangeGoodsPrincipalPO;
......@@ -137,9 +136,6 @@ public class ChangeFlowBiz {
private ChangeExecRecordMapper changeExecRecordMapper;
@Autowired
private ChangeSubFlowRecordMapper changeSubFlowRecordMapper;
@Autowired
private ItemService itemService;
@Autowired
......@@ -924,7 +920,7 @@ public class ChangeFlowBiz {
* @return 所有子工单列表(包括已取消和已完成的)
*/
private List<ChangeSubFlowRecord> cancelAllSubFlows(Long changeRecordId, String cancelReason, String uid) {
List<ChangeSubFlowRecord> allSubFlows = changeSubFlowRecordMapper.selectByChangeRecordId(changeRecordId);
List<ChangeSubFlowRecord> allSubFlows = changeSubFlowRecordService.getByChangeRecordId(changeRecordId);
if (CollectionUtils.isEmpty(allSubFlows)) {
log.info("[cancelAllSubFlows] 主工单下没有行动工单,changeRecordId:{}", changeRecordId);
return allSubFlows;
......@@ -1868,7 +1864,7 @@ public class ChangeFlowBiz {
*/
private List<ChangeSubFlowRecord> validateAndFilterSubFlowsToReject(Long changeRecordId, List<String> rejectSubFlowIds) {
// 查询该主工单下所有子单(只查询一次)
List<ChangeSubFlowRecord> allSubFlows = changeSubFlowRecordMapper.selectByChangeRecordId(changeRecordId);
List<ChangeSubFlowRecord> allSubFlows = changeSubFlowRecordService.getByChangeRecordId(changeRecordId);
if (CollectionUtils.isEmpty(allSubFlows)) {
throw ExceptionFactory.createBiz(ResponseCode.BAD_REQUEST,
"主工单下没有子单,无法驳回");
......
......@@ -15,6 +15,8 @@ import java.util.Optional;
import java.util.stream.Collectors;
import com.netease.mail.yanxuan.change.biz.service.ChangeFlowExecService;
import com.netease.mail.yanxuan.change.biz.service.ChangeSubFlowRecordService;
import com.netease.mail.yanxuan.change.dal.entity.ChangeSubFlowRecord;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
......@@ -104,6 +106,9 @@ public class ChangeFlowExportCallback implements DesCallbackService {
@Autowired
private ChangeFlowExecService changeFlowExecService;
@Autowired
private ChangeSubFlowRecordService changeSubFlowRecordService;
@Override
public ExcelTitle queryExcelTitle(CallbackQueryReq req) {
log.info("[op: change flow export callback queryExcelTitle] req={}", JSON.toJSONString(req));
......@@ -229,6 +234,22 @@ public class ChangeFlowExportCallback implements DesCallbackService {
.queryGoodsPrincipalInfo(allItemList);
log.debug("[getExportList] spuTOS:{}", spuTOS.size());
}
// 批量查询所有变更行动工单,构建 Map<changeRecordId, List<subFlowId>>,提升性能
Map<Long, List<String>> subFlowIdsMap = new HashMap<>();
List<Long> changeRecordIds = changeRecords.stream()
.map(ChangeRecord::getId)
.collect(Collectors.toList());
List<ChangeSubFlowRecord> subFlowRecords = changeSubFlowRecordService.getByChangeRecordIds(changeRecordIds);
if (CollectionUtils.isNotEmpty(subFlowRecords)) {
subFlowIdsMap = subFlowRecords.stream()
.filter(record -> StringUtils.isNotBlank(record.getSubFlowId()))
.collect(Collectors.groupingBy(
ChangeSubFlowRecord::getChangeRecordId,
Collectors.mapping(ChangeSubFlowRecord::getSubFlowId, Collectors.toList())
));
}
List<ChangeFlowExcelDTO> changeFlowExcelDTOList = new ArrayList<>();
// 导出excel,按照商品/供应商和行动项,n*n重复拆分,例2个商品3个行动项,拆分成2*3=6行,其他属性一致
for (ChangeRecord record : changeRecords) {
......@@ -305,6 +326,9 @@ public class ChangeFlowExportCallback implements DesCallbackService {
// 组装行动项相关信息
obtainChangeExec(changeExecRecord, changeFlowExcelDTO, userListInfo);
this.obtainOther(record, changeFlowExcelDTO);
// 设置变更行动工单(用逗号分隔)
List<String> subFlowIds = subFlowIdsMap.getOrDefault(record.getId(), new ArrayList<>());
changeFlowExcelDTO.setSubFlowIds(CollectionUtils.isEmpty(subFlowIds) ? "/" : String.join(",", subFlowIds));
changeFlowExcelDTOList.add(changeFlowExcelDTO);
}
}
......@@ -342,6 +366,9 @@ public class ChangeFlowExportCallback implements DesCallbackService {
// 组装行动项相关信息
this.obtainChangeExec(changeExecRecord, changeFlowExcelDTO, userListInfo);
this.obtainOther(record, changeFlowExcelDTO);
// 设置变更行动工单(用逗号分隔)
List<String> subFlowIds = subFlowIdsMap.getOrDefault(record.getId(), new ArrayList<>());
changeFlowExcelDTO.setSubFlowIds(CollectionUtils.isEmpty(subFlowIds) ? "/" : String.join(",", subFlowIds));
changeFlowExcelDTOList.add(changeFlowExcelDTO);
}
break;
......
......@@ -223,4 +223,10 @@ public class ChangeFlowExcelDTO {
*/
@Excel(name = "变更完结时间")
private String changeEndTime;
/**
* 变更行动工单
*/
@Excel(name = "变更行动工单")
private String subFlowIds;
}
\ No newline at end of file
......@@ -229,6 +229,12 @@ public class ChangeFlowExcelVo {
@ExcelTitleName(title = "变更完结时间", order = 35)
private Integer changeEndTime;
/**
* 变更行动工单
*/
@ExcelTitleName(title = "变更行动工单", order = 36)
private String subFlowIds;
public static List<ExcelCell> init(ChangeFlowExcelDTO dto) {
List<ExcelCell> cellInfo = new ArrayList<>();
......@@ -373,6 +379,10 @@ public class ChangeFlowExcelVo {
excelCell = new ExcelCell();
excelCell.setValue(dto.getChangeEndTime());
cellInfo.add(excelCell);
// 35.变更行动工单
excelCell = new ExcelCell();
excelCell.setValue(dto.getSubFlowIds());
cellInfo.add(excelCell);
return cellInfo;
}
......
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