记得上下班打卡 | git大法好,push需谨慎

Commit 3f22e715 authored by 张国柄's avatar 张国柄

~api:导入:+log+锁主动释放;

parent bd07c790
...@@ -45,7 +45,8 @@ public class GoblinStoreMgtGoodsImportController { ...@@ -45,7 +45,8 @@ public class GoblinStoreMgtGoodsImportController {
if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) { if (!goblinRedisUtils.hasStoreId(currentUid, storeId)) {
return ResponseDto.failure(ErrorMapping.get("149002")); return ResponseDto.failure(ErrorMapping.get("149002"));
} }
if (!goblinRedisUtils.redisUtil.lock(GoblinRedisConst.BASIC_GOODS_SKU.concat("lk").concat(storeId), 1, 30)) { String lk = GoblinRedisConst.BASIC_GOODS_SKU.concat("lk").concat(storeId);
if (!goblinRedisUtils.redisUtil.lock(lk, 1, 30)) {
return ResponseDto.failure(ErrorMapping.get("140000")); return ResponseDto.failure(ErrorMapping.get("140000"));
} }
String analysisResultMsg; String analysisResultMsg;
...@@ -59,10 +60,13 @@ public class GoblinStoreMgtGoodsImportController { ...@@ -59,10 +60,13 @@ public class GoblinStoreMgtGoodsImportController {
return ResponseDto.failure(ErrorMapping.get("149001")); return ResponseDto.failure(ErrorMapping.get("149001"));
} }
} catch (LiquidnetServiceException e) { } catch (LiquidnetServiceException e) {
goblinRedisUtils.redisUtil.uLock(lk);
return ResponseDto.failure(e.getMessage()); return ResponseDto.failure(e.getMessage());
} catch (IOException e) { } catch (Exception e) {
log.warn("店铺商品管理:批量导入数据:异常[UID={},dataType={},fileName={}]", currentUid, dataType, file.getOriginalFilename(), e); log.warn("店铺商品管理:批量导入数据:异常[UID={},dataType={},fileName={}]", currentUid, dataType, file.getOriginalFilename(), e);
return ResponseDto.failure("数据有误,解析失败"); return ResponseDto.failure("数据有误,解析失败");
} finally {
goblinRedisUtils.redisUtil.uLock(lk);
} }
return ResponseDto.success(analysisResultMsg); return ResponseDto.success(analysisResultMsg);
} }
......
...@@ -60,6 +60,7 @@ public class GoblinStoreMgtGoodsImportService { ...@@ -60,6 +60,7 @@ public class GoblinStoreMgtGoodsImportService {
private static final String LAST_SKU_SPEC_VALUE_STR = "%#V1%#V2%#V3%#V4%#V5"; private static final String LAST_SKU_SPEC_VALUE_STR = "%#V1%#V2%#V3%#V4%#V5";
public String goodsInformationDataAnalysisProcessing(MultipartFile file, String uid, String storeId) throws IOException { public String goodsInformationDataAnalysisProcessing(MultipartFile file, String uid, String storeId) throws IOException {
String originalFilename = file.getOriginalFilename();
AnalysisEventListener<GoblinGoodsImportDto> analysisEventListener = new AnalysisEventListener<GoblinGoodsImportDto>() { AnalysisEventListener<GoblinGoodsImportDto> analysisEventListener = new AnalysisEventListener<GoblinGoodsImportDto>() {
List<GoblinGoodsSkuInfoVo> goodsSkuInfoVos; List<GoblinGoodsSkuInfoVo> goodsSkuInfoVos;
List<GoblinGoodsInfoVo> goodsInfoVos; List<GoblinGoodsInfoVo> goodsInfoVos;
...@@ -87,6 +88,7 @@ public class GoblinStoreMgtGoodsImportService { ...@@ -87,6 +88,7 @@ public class GoblinStoreMgtGoodsImportService {
} else if (approximateTotalRowNumber <= 1) { } else if (approximateTotalRowNumber <= 1) {
throw new LiquidnetServiceException("-1", "导入文件不能为空"); throw new LiquidnetServiceException("-1", "导入文件不能为空");
} }
log.info("DT-IN-BEGIN:[storeId={},uid={},fileName={},totalRow={}]", uid, storeId, originalFilename, approximateTotalRowNumber);
goodsSkuInfoVos = ObjectUtil.getGoblinGoodsSkuInfoVoArrayList(); goodsSkuInfoVos = ObjectUtil.getGoblinGoodsSkuInfoVoArrayList();
goodsInfoVos = ObjectUtil.goblinGoodsInfoVoArrayList(); goodsInfoVos = ObjectUtil.goblinGoodsInfoVoArrayList();
...@@ -144,10 +146,11 @@ public class GoblinStoreMgtGoodsImportService { ...@@ -144,10 +146,11 @@ public class GoblinStoreMgtGoodsImportService {
// } // }
// throw new LiquidnetServiceException("-1", String.format("规格条码与已添加商品条码重复,重复条码如下: %s", StringUtils.join(existGoodsSkuNoList, ","))); // throw new LiquidnetServiceException("-1", String.format("规格条码与已添加商品条码重复,重复条码如下: %s", StringUtils.join(existGoodsSkuNoList, ",")));
// } // }
log.info("DT-IN-ToMDB:[storeId={},uid={},fileName={},spuCount={},skuCount={}]", uid, storeId, originalFilename, goodsInfoVos.size(), goodsSkuInfoVos.size());
goblinMongoUtils.insertMgtGoodsInfoVos(goodsInfoVos); goblinMongoUtils.insertMgtGoodsInfoVos(goodsInfoVos);
goblinMongoUtils.insertMgtGoodsSkuInfoVos(goodsSkuInfoVos); goblinMongoUtils.insertMgtGoodsSkuInfoVos(goodsSkuInfoVos);
log.info("DT-IN-ToSQL1:[storeId={},uid={},fileName={}]", uid, storeId, originalFilename);
LinkedList<String> toMqSqls = CollectionUtil.linkedListString(); LinkedList<String> toMqSqls = CollectionUtil.linkedListString();
toMqSqls.add(SqlMapping.get("goblin_goods.insert")); toMqSqls.add(SqlMapping.get("goblin_goods.insert"));
LinkedList<Object[]> initGoodsObjs = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> initGoodsObjs = CollectionUtil.linkedListObjectArr();
...@@ -183,7 +186,7 @@ public class GoblinStoreMgtGoodsImportService { ...@@ -183,7 +186,7 @@ public class GoblinStoreMgtGoodsImportService {
if (initGoodsObjs.size() > 0) { if (initGoodsObjs.size() > 0) {
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_GOODS.getKey(), SqlMapping.gets(toMqSqls, initGoodsObjs, initGoodsImageObjs, initGoodsSpuSpecValueObjs)); queueUtils.sendMsgByRedis(MQConst.GoblinQueue.SQL_GOODS.getKey(), SqlMapping.gets(toMqSqls, initGoodsObjs, initGoodsImageObjs, initGoodsSpuSpecValueObjs));
} }
log.info("DT-IN-ToSQL2:[storeId={},uid={},fileName={}]", uid, storeId, originalFilename);
toMqSqls.clear(); toMqSqls.clear();
toMqSqls.add(SqlMapping.get("goblin_goods_sku.insert")); toMqSqls.add(SqlMapping.get("goblin_goods_sku.insert"));
LinkedList<Object[]> initGoodsSkuObjs = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> initGoodsSkuObjs = CollectionUtil.linkedListObjectArr();
...@@ -222,7 +225,7 @@ public class GoblinStoreMgtGoodsImportService { ...@@ -222,7 +225,7 @@ public class GoblinStoreMgtGoodsImportService {
long failureRows = readDtoList.stream().filter(r -> StringUtils.isNotEmpty(r.getFailureReason())).count(); long failureRows = readDtoList.stream().filter(r -> StringUtils.isNotEmpty(r.getFailureReason())).count();
String analysisResultMsg = String.format("导入成功%s条数据,导入失败%s条数据", readDtoList.size() - failureRows, failureRows); String analysisResultMsg = String.format("导入成功%s条数据,导入失败%s条数据", readDtoList.size() - failureRows, failureRows);
log.info("DT-IN:[storeId={},uid={},fileName={},readResult:{}]", uid, storeId, file.getOriginalFilename(), analysisResultMsg); log.info("DT-IN-END:[storeId={},uid={},fileName={},readResult:{}]", uid, storeId, originalFilename, analysisResultMsg);
return analysisResultMsg; return analysisResultMsg;
} }
......
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