数据处理代码

This commit is contained in:
shuo.wang
2025-05-29 14:49:22 +08:00
parent b67654b6a9
commit 494dda498b
6 changed files with 132 additions and 5 deletions

View File

@@ -23,6 +23,8 @@ public enum FileTypeEnum {
ZXJP_OPEN_SHOP_REPORT("zxjpOpenShopReport","正新鸡排开店"), ZXJP_OPEN_SHOP_REPORT("zxjpOpenShopReport","正新鸡排开店"),
IMPORT_OA_OLD_SHOP_STAGE_DATA("importOaOldShopStageData", "导入OA旧阶段数据"), IMPORT_OA_OLD_SHOP_STAGE_DATA("importOaOldShopStageData", "导入OA旧阶段数据"),
IMPORT_OA_OLD_SHOP_STAGE_DATA_ERROR("OaOldShopStageDataError", "导入OA旧数据阶段错误列表"), IMPORT_OA_OLD_SHOP_STAGE_DATA_ERROR("OaOldShopStageDataError", "导入OA旧数据阶段错误列表"),
IMPORT_FITMENT_SHOP_STAGE("importFitmentShopStage", "导入装修阶段完成数据"),
IMPORT_FITMENT_SHOP_STAGE_DATA_ERROR_LIST("OaOldShopStageDataErrorList", "导入装修阶段完成数据错误列表 "),
; ;
private String fileType; private String fileType;
private String desc; private String desc;

View File

@@ -19,4 +19,13 @@ public class ImportOaOldShopDataErrorDTO {
@ExcelProperty(value = "错误原因", order = 2) @ExcelProperty(value = "错误原因", order = 2)
@ColumnWidth(40) @ColumnWidth(40)
private String errorReason; private String errorReason;
public ImportOaOldShopDataErrorDTO() {
}
public ImportOaOldShopDataErrorDTO(String shopCode, String errorReason) {
this.shopCode = shopCode;
this.errorReason = errorReason;
}
} }

View File

@@ -32,4 +32,8 @@ public interface DataHandlerServer {
Boolean dataHandlerV20241012(List<Map<String, Object>> dataMapList, String originalFilename, LoginUserInfo user, Boolean dataHandlerV20241012(List<Map<String, Object>> dataMapList, String originalFilename, LoginUserInfo user,
ImportTaskDO task); ImportTaskDO task);
Integer JingDongStageHandler(); Integer JingDongStageHandler();
//处理测量 设计 施工 验收 完成
Boolean dataHandlerV2025029(List<Map<String, Object>> dataMapList, String originalFilename, LoginUserInfo user,
ImportTaskDO task);
} }

View File

@@ -954,6 +954,94 @@ public class DataHandlerServerImpl implements DataHandlerServer {
} }
@Override
public Boolean dataHandlerV2025029(List<Map<String, Object>> dataMapList, String originalFilename, LoginUserInfo user, ImportTaskDO task) {
List<ImportOaOldShopDataDTO> list = new ArrayList<>();
List<ImportOaOldShopDataErrorDTO> errorList = new ArrayList<>();
ListUtils.emptyIfNull(dataMapList)
.forEach(data -> {
try {
ImportOaOldShopDataDTO importOaOldShopDataDTO = new ImportOaOldShopDataDTO();
importOaOldShopDataDTO.setShopCode(String.valueOf(data.get("门店编码")));
list.add(importOaOldShopDataDTO);
} catch (Exception e) {
log.info("dataHandlerV2025029 转化dto error:{}", JSONObject.toJSONString(data));
}
});
log.info("导入数据条数:{}", list.size());
if (CollectionUtils.isEmpty(list)) {
log.info("导入数据转化为空");
return false;
}
List<String> shopCodeList = list.stream().map(ImportOaOldShopDataDTO::getShopCode).collect(Collectors.toList());
List<ShopInfoDO> shopInfoList = shopInfoDAO.selectByShopCodeList(shopCodeList);
if (CollectionUtils.isEmpty(shopInfoList)) {
log.info("导入数据根据shopCode 未找到数据");
}
List<Long> shopIds = shopInfoList.stream().map(ShopInfoDO::getId).collect(Collectors.toList());
Map<String, List<ShopInfoDO>> shopMapByCode = shopInfoList.stream().collect(Collectors.groupingBy(ShopInfoDO::getShopCode));
//装修验收数据
List<AcceptanceInfoDO> acceptanceInfoDOList = acceptanceInfoDAO.selectByShopIds(shopIds);
Map<Long, AcceptanceInfoDO> acceptanceInfoMap = acceptanceInfoDOList.stream().collect(Collectors.toMap(AcceptanceInfoDO::getShopId, item -> item));
//合同阶段
List<ShopStageInfoDO> signFranchiseStageList = shopStageInfoDAO.getSubStageList(shopIds, ShopSubStageEnum.SHOP_STAGE_8.getShopSubStage());
Map<Long, ShopStageInfoDO> signFranchiseStageMap = signFranchiseStageList.stream().collect(Collectors.toMap(ShopStageInfoDO::getShopId, Function.identity()));
//装修阶段需要变更的shopId
List<Long> fitmentFhopIdList = new ArrayList<>();
//装修验收表需要初始化的门店
List<Long> initFitmentShopIdList = new ArrayList<>();
for (ImportOaOldShopDataDTO dto : list) {
String shopCode = dto.getShopCode();
List<ShopInfoDO> shopInfoDOS = shopMapByCode.get(shopCode);
if (CollectionUtils.isEmpty(shopInfoDOS)){
errorList.add(new ImportOaOldShopDataErrorDTO(dto.getShopCode(), "门店编码未找到"));
continue;
}
if (shopInfoDOS.size() > 1){
errorList.add(new ImportOaOldShopDataErrorDTO(dto.getShopCode(), "门店编码重复"));
continue;
}
ShopInfoDO shopInfoDO = shopInfoDOS.get(0);
Long shopId = shopInfoDO.getId();
ShopStageInfoDO signFranchiseStage = signFranchiseStageMap.get(shopId);
if (!signFranchiseStage.getShopSubStageStatus().equals(ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_84.getShopSubStageStatus())){
errorList.add(new ImportOaOldShopDataErrorDTO(dto.getShopCode(), "合同阶段未完成"));
continue;
}
AcceptanceInfoDO acceptanceInfoDO = acceptanceInfoMap.get(shopId);
if (Objects.isNull(acceptanceInfoDO)){
initFitmentShopIdList.add(shopId);
}
fitmentFhopIdList.add(shopId);
}
//装修stage
shopStageInfoDAO.dataUpdateStatus(fitmentFhopIdList, ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_863);
shopStageInfoDAO.dataUpdateStatus(fitmentFhopIdList, ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_91);
shopStageInfoDAO.dataUpdateStatus(fitmentFhopIdList, ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_112);
shopStageInfoDAO.dataUpdateStatus(fitmentFhopIdList, ShopSubStageStatusEnum.SHOP_SUB_STAGE_STATUS_123);
//装修表初始化
acceptanceInfoDAO.initAcceptanceInfo(initFitmentShopIdList);
if (!errorList.isEmpty()) {
task.setStatus(ImportTaskStatusEnum.ERROR.getCode());
String url = null;
try {
url = easyExcelUtil.exportExcel(ImportOaOldShopDataErrorDTO.class, errorList, null,
FileTypeEnum.IMPORT_FITMENT_SHOP_STAGE_DATA_ERROR_LIST.getDesc() + DateUtils.parseDateToStr(SPECIAL_DATE_START_1, new Date()),
FileTypeEnum.IMPORT_FITMENT_SHOP_STAGE_DATA_ERROR_LIST.getDesc() + DateUtils.parseDateToStr(SPECIAL_DATE_START_1, new Date()));
} catch (Exception e) {
log.info("导出失败列表失败 errorList:{}", JSONObject.toJSONString(errorList));
}
task.setFileUrl(url);
} else {
task.setStatus(ImportTaskStatusEnum.SUCCESS.getCode());
}
task.setTotalNum(dataMapList.size());
task.setSuccessNum(dataMapList.size() - errorList.size());
importTaskMapper.update(eid, task);
return null;
}
private static @NotNull ShopStageInfoDO getShopStageInfoDO(ShopSubStageEnum shopSubStageEnum, ShopStageInfoDO shopStageInfoDO, ShopSubStageStatusEnum shopSubStageStatus) { private static @NotNull ShopStageInfoDO getShopStageInfoDO(ShopSubStageEnum shopSubStageEnum, ShopStageInfoDO shopStageInfoDO, ShopSubStageStatusEnum shopSubStageStatus) {
ShopStageEnum shopStageEnum = shopSubStageEnum.getShopStageEnum(); ShopStageEnum shopStageEnum = shopSubStageEnum.getShopStageEnum();
ShopStageInfoDO shopStageInfo = new ShopStageInfoDO(); ShopStageInfoDO shopStageInfo = new ShopStageInfoDO();

View File

@@ -128,4 +128,28 @@ public class DataHandlerController {
public ResponseResult<Integer> JingDongStageHandler() { public ResponseResult<Integer> JingDongStageHandler() {
return ResponseResult.success(dataHandlerServer.JingDongStageHandler()); return ResponseResult.success(dataHandlerServer.JingDongStageHandler());
} }
@PostMapping("/dataHandlerV2025029")
@ApiOperation("导入OA2025029旧数据")
public ResponseResult<Boolean> dataHandlerV2025029(MultipartFile file) {
ExcelReader reader = null;
try {
reader = ExcelUtil.getReader(file.getInputStream());
} catch (IOException e) {
log.error("read file error:", e);
}
assert reader != null;
List<Map<String, Object>> dataMapList = reader.read(0, 1, Integer.MAX_VALUE);
ImportTaskDO importTaskDO = new ImportTaskDO();
importTaskDO.setFileName(file.getOriginalFilename());
importTaskDO.setFileType(FileTypeEnum.IMPORT_FITMENT_SHOP_STAGE.getFileType());
importTaskDO.setIsImport(true);
importTaskDO.setStatus(ImportTaskStatusEnum.PROGRESS.getCode());
importTaskDO.setCreateUserId(CurrentUserHolder.getUserId());
importTaskDO.setCreateName(CurrentUserHolder.getUser().getName());
importTaskDO.setCreateTime(System.currentTimeMillis());
importTaskMapper.insert(eid, importTaskDO);
dataHandlerServer.dataHandlerV2025029(dataMapList, file.getOriginalFilename(), CurrentUserHolder.getUser(), importTaskDO);
return ResponseResult.success(true);
}
} }

View File

@@ -62,10 +62,10 @@ public class LineAuditController {
return ResponseResult.success(bankService.repayment(request)); return ResponseResult.success(bankService.repayment(request));
} }
// @ApiOperation("结束跟进") @ApiOperation("结束跟进")
// @PostMapping("/close") @PostMapping("/close")
// public ResponseResult<Boolean> auditClose(@RequestBody AuditCloseRequest request){ public ResponseResult<Boolean> auditClose(@RequestBody AuditCloseRequest request){
// return ResponseResult.success(lineFlowService.auditClose(request, CurrentUserHolder.getUser())); return ResponseResult.success(lineFlowService.auditClose(request, CurrentUserHolder.getUser()));
// } }
} }