Quellcode durchsuchen

fix

release_toaliyun_real
lin vor 2 Jahren
Ursprung
Commit
52340015f0
2 geänderte Dateien mit 45 neuen und 44 gelöschten Zeilen
  1. +17
    -44
      mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java
  2. +28
    -0
      mallinkAdmin/src/main/java/com/iformall/controller/mem/AsyncTask.java

+ 17
- 44
mallinkAdmin/src/main/java/com/iformall/controller/basic/TtMerchantPoiController.java Datei anzeigen

@@ -183,7 +183,8 @@ public class TtMerchantPoiController extends DouyinBaseController {
//return addLocationInfo(mFile,false); //return addLocationInfo(mFile,false);
throw new MallinkException(Result.ERROR,"当前版本无需补齐地理位置信息"); throw new MallinkException(Result.ERROR,"当前版本无需补齐地理位置信息");
}else { }else {
addLocationInfo(this.getTenantInfo(),mFile,true,"1bdc087fc6f72820dc5c848a033de7f9",request,response);
File lFile = handlerImportFile(mFile,null,"poiAddLocation");
asyncTask.exportExcelPoiDataAddLocationForNew(this.getTenantInfo(),"1bdc087fc6f72820dc5c848a033de7f9",lFile,request,response);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("addLocationInfo error.",e); logger.error("addLocationInfo error.",e);
@@ -191,15 +192,6 @@ public class TtMerchantPoiController extends DouyinBaseController {
} }
} }
private void addLocationInfo(TenantEntity tenantEntity,MultipartFile mFile,boolean isNew,String gaodeKey,
HttpServletRequest request, HttpServletResponse response) throws Exception{
File lFile = handlerImportFile(mFile,null,"poiAddLocation");
if (isNew) {
asyncTask.exportExcelPoiDataAddLocationForNew(tenantEntity,gaodeKey,lFile,request,response);
}else {
}
}
private File handlerImportFile(MultipartFile mFile,String importKey,String fileNamePre) { private File handlerImportFile(MultipartFile mFile,String importKey,String fileNamePre) {
if (mFile.isEmpty()) { if (mFile.isEmpty()) {
throw new MallinkException(Result.ERROR, "上传文件不能为空"); throw new MallinkException(Result.ERROR, "上传文件不能为空");
@@ -286,32 +278,22 @@ public class TtMerchantPoiController extends DouyinBaseController {
public void importPoi(@RequestParam("file") MultipartFile mFile,HttpServletRequest request, HttpServletResponse response) { public void importPoi(@RequestParam("file") MultipartFile mFile,HttpServletRequest request, HttpServletResponse response) {
try { try {
boolean isSaas = this.isGoodLifeSaas(); boolean isSaas = this.isGoodLifeSaas();
if (!isSaas) {
processImport(mFile,false,request,response);
}else {
processImport(mFile,true,request,response);
}
//得到当前用户ID
final MallUserInfo user = getUser();
String userId = "" + user.getId();
String importKey = Constant.importPoiPrev + userId;
File lFile = handlerImportFile(mFile,importKey,"poi");
if (isSaas) {
asyncTask.importExcelPoiDataForNew(lFile, user, importKey,request,response);
}else {
asyncTask.importExcelPoiData(lFile, user, importKey,request,response);
}
} catch (Exception e) { } catch (Exception e) {
logger.error("allTreeList error.",e); logger.error("allTreeList error.",e);
throw new MallinkException(Result.ERROR,e.getMessage()); throw new MallinkException(Result.ERROR,e.getMessage());
} }
} }
private void processImport(MultipartFile mFile,boolean isNew,HttpServletRequest request, HttpServletResponse response) throws Exception {
logger.debug("[" + getIpAddr() + "] TtMerchantPoiController::importPoi");
//得到当前用户ID
final MallUserInfo user = getUser();
String userId = "" + user.getId();
String importKey = Constant.importPoiPrev + userId;
File lFile = handlerImportFile(mFile,importKey,"poi");
if (isNew) {
asyncTask.importExcelPoiDataForNew(lFile, user, importKey,request,response);
}else {
asyncTask.importExcelPoiData(lFile, user, importKey,request,response);
}

}
@TenantIgnore @TenantIgnore
@PostMapping(value = "/importMerchantInitByPoi", consumes = "multipart/*") @PostMapping(value = "/importMerchantInitByPoi", consumes = "multipart/*")
@SystemControllerLog(description = "poi-初始化商户商户") @SystemControllerLog(description = "poi-初始化商户商户")
@@ -321,25 +303,16 @@ public class TtMerchantPoiController extends DouyinBaseController {
if (!isSaas) { if (!isSaas) {
throw new MallinkException(Result.ERROR,"当前版本不支持"); throw new MallinkException(Result.ERROR,"当前版本不支持");
}else { }else {
importMerchantInit(mFile,true,request,response);
final MallUserInfo user = getUser();
String userId = "" + user.getId();
String importKey = Constant.importPoiMerchantPrev + userId;
File lFile = handlerImportFile(mFile,importKey,"poiMerchantInit");
asyncTask.importMerchantInit(lFile, user, importKey,request,response);
} }
} catch (Exception e) { } catch (Exception e) {
logger.error("importMerchantInitByPoi error.",e); logger.error("importMerchantInitByPoi error.",e);
throw new MallinkException(Result.ERROR,e.getMessage()); throw new MallinkException(Result.ERROR,e.getMessage());
} }
} }
private void importMerchantInit(MultipartFile mFile,boolean isNew,HttpServletRequest request, HttpServletResponse response) throws Exception {
final MallUserInfo user = getUser();
String userId = "" + user.getId();
String importKey = Constant.importPoiMerchantPrev + userId;
File lFile = handlerImportFile(mFile,importKey,"poiMerchant");
if (isNew) {
asyncTask.importExcelPoiDataForNew(lFile, user, importKey,request,response);
}else {
asyncTask.importExcelPoiData(lFile, user, importKey,request,response);
}

}


} }

+ 28
- 0
mallinkAdmin/src/main/java/com/iformall/controller/mem/AsyncTask.java Datei anzeigen

@@ -434,5 +434,33 @@ public class AsyncTask {
} }
} }
@Async
public void importMerchantInit(File file, MallUserInfo user, String importKey,HttpServletRequest request, HttpServletResponse response) {
// 需要验证
String[] needFields = new String[]{"门店ID","富茂系统商户ID","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度"};
ExcelImportResult<MerchantPoiTNew> datalist = handleImportFile(null,file,MerchantPoiTNew.class,poiImportFields,needFields,new AsyncTask.PoiNewExcelHandler());
if (null == datalist) {
return ;
}

List<MerchantPoiTNew> successList = datalist.getList();
if(successList.size() > 0) {
try {
successList.parallelStream().forEach(poiBase -> {
try {
ttMerchantPoiService.importOnePoiNew(user, poiBase);
} catch (UnknownSessionException ue) {
logger.error("session :"+ue.getMessage(),ue);
}
});
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS);
exportExcel(request, response, successList,MerchantPoiTNew.class, "POI导入-结果.xlsx");
} catch (Exception e) {
logger.error("导入模板失败:"+e.getMessage(),e);
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS);
}
}
}


} }

Laden…
Abbrechen
Speichern