|
|
@@ -52,6 +52,8 @@ import java.util.HashMap; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
import java.util.Map; |
|
|
import java.util.Map; |
|
|
import java.util.concurrent.TimeUnit; |
|
|
import java.util.concurrent.TimeUnit; |
|
|
|
|
|
import java.util.regex.Matcher; |
|
|
|
|
|
import java.util.regex.Pattern; |
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
@@ -112,11 +114,28 @@ public class AsyncTask { |
|
|
if (value == null) { |
|
|
if (value == null) { |
|
|
value = ""; |
|
|
value = ""; |
|
|
} |
|
|
} |
|
|
|
|
|
//管理员手机号校验手机号格式 |
|
|
|
|
|
if ("管理员手机号".equals(name)) { |
|
|
|
|
|
String _v = (String)value; |
|
|
|
|
|
if (StringUtils.isNotBlank(_v) && (!isMobile(_v))) { |
|
|
|
|
|
throw new MallinkException(ErrorCode.SYS_SERVER_ERROR.getCode(),"管理员手机号必须是移动号码"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
return super.importHandler(obj, name, value); |
|
|
return super.importHandler(obj, name, value); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static boolean isMobile(String str) { |
|
|
|
|
|
Pattern p = null; |
|
|
|
|
|
Matcher m = null; |
|
|
|
|
|
boolean b = false; |
|
|
|
|
|
p = Pattern.compile("^[1][3,4,5,7,8][0-9]{9}$"); // 验证手机号 |
|
|
|
|
|
m = p.matcher(str); |
|
|
|
|
|
b = m.matches(); |
|
|
|
|
|
return b; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private class CardPriceExcelHandler extends ExcelDataHandlerDefaultImpl<WxCardPriceTemplate> { |
|
|
private class CardPriceExcelHandler extends ExcelDataHandlerDefaultImpl<WxCardPriceTemplate> { |
|
|
@Override |
|
|
@Override |
|
|
public Object importHandler(WxCardPriceTemplate obj, String name, Object value) { |
|
|
public Object importHandler(WxCardPriceTemplate obj, String name, Object value) { |
|
|
@@ -290,7 +309,7 @@ public class AsyncTask { |
|
|
return datalist; |
|
|
return datalist; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Async |
|
|
|
|
|
|
|
|
//@Async |
|
|
public void importExcelPoiData(File file, MallUserInfo user, String importKey,HttpServletRequest request, HttpServletResponse response) { |
|
|
public void importExcelPoiData(File file, MallUserInfo user, String importKey,HttpServletRequest request, HttpServletResponse response) { |
|
|
String[] importFields = new String[]{"服务商POI_ID", "POI名称", "省份", "城市", "地址", "经度", "纬度", "高德ID(非必填)", |
|
|
String[] importFields = new String[]{"服务商POI_ID", "POI名称", "省份", "城市", "地址", "经度", "纬度", "高德ID(非必填)", |
|
|
"已匹配POI_ID", "已匹配POI名称", "已匹配POI省份", "已匹配POI城市", "已匹配POI地址", "未匹配原因", "其他信息","POI导入结果"}; |
|
|
"已匹配POI_ID", "已匹配POI名称", "已匹配POI省份", "已匹配POI城市", "已匹配POI地址", "未匹配原因", "其他信息","POI导入结果"}; |
|
|
@@ -310,11 +329,15 @@ public class AsyncTask { |
|
|
logger.error("session :"+ue.getMessage()); |
|
|
logger.error("session :"+ue.getMessage()); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(importKey)) { |
|
|
|
|
|
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); |
|
|
|
|
|
} |
|
|
exportExcel(request, response, successList,MerchantPoiT.class, "POI导入-结果.xlsx"); |
|
|
exportExcel(request, response, successList,MerchantPoiT.class, "POI导入-结果.xlsx"); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
logger.error("导入模板失败:"+e.getMessage(),e); |
|
|
logger.error("导入模板失败:"+e.getMessage(),e); |
|
|
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(importKey)) { |
|
|
|
|
|
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@@ -455,7 +478,7 @@ public class AsyncTask { |
|
|
public void importExcelPoiDataForNew(File file, MallUserInfo user, String importKey,HttpServletRequest request, HttpServletResponse response) { |
|
|
public void importExcelPoiDataForNew(File file, MallUserInfo user, String importKey,HttpServletRequest request, HttpServletResponse response) { |
|
|
// 需要验证 |
|
|
// 需要验证 |
|
|
String[] needFields = new String[]{"门店ID","富茂系统商户ID","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度"}; |
|
|
String[] needFields = new String[]{"门店ID","富茂系统商户ID","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度"}; |
|
|
ExcelImportResult<MerchantPoiTNew> datalist = handleImportFile(null,file,MerchantPoiTNew.class,poiImportFields,needFields,new AsyncTask.PoiNewExcelHandler()); |
|
|
|
|
|
|
|
|
ExcelImportResult<MerchantPoiTNew> datalist = handleImportFile(importKey,file,MerchantPoiTNew.class,poiImportFields,needFields,new AsyncTask.PoiNewExcelHandler()); |
|
|
if (null == datalist) { |
|
|
if (null == datalist) { |
|
|
return ; |
|
|
return ; |
|
|
} |
|
|
} |
|
|
@@ -470,11 +493,15 @@ public class AsyncTask { |
|
|
logger.error("session :"+ue.getMessage(),ue); |
|
|
logger.error("session :"+ue.getMessage(),ue); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(importKey)) { |
|
|
|
|
|
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); |
|
|
|
|
|
} |
|
|
exportExcel(request, response, successList,MerchantPoiTNew.class, "POI导入-结果.xlsx"); |
|
|
exportExcel(request, response, successList,MerchantPoiTNew.class, "POI导入-结果.xlsx"); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
logger.error("导入模板失败:"+e.getMessage(),e); |
|
|
logger.error("导入模板失败:"+e.getMessage(),e); |
|
|
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); |
|
|
|
|
|
|
|
|
if (StringUtils.isNotBlank(importKey)) { |
|
|
|
|
|
stringRedisTemplate.expire(importKey,10, TimeUnit.SECONDS); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
@@ -539,7 +566,7 @@ public class AsyncTask { |
|
|
WxMerchant merchant = wxMerchantService.initMerchantByPoi(user,poiBase.getPoiName(), poiBase.getPoiId(),poiBase.getPhone()); |
|
|
WxMerchant merchant = wxMerchantService.initMerchantByPoi(user,poiBase.getPoiName(), poiBase.getPoiId(),poiBase.getPhone()); |
|
|
poiBase.setMerchantId(String.valueOf(merchant.getId())); |
|
|
poiBase.setMerchantId(String.valueOf(merchant.getId())); |
|
|
poiBase.setMerchantName(merchant.getName()); |
|
|
poiBase.setMerchantName(merchant.getName()); |
|
|
poiBase.setInitMerchantRemark("初始化商户成功."); |
|
|
|
|
|
|
|
|
poiBase.setInitMerchantRemark("初始化商户成功."+StringUtils.trimToEmpty(merchant.getInitLog())); |
|
|
}catch(Exception e) { |
|
|
}catch(Exception e) { |
|
|
poiBase.setInitMerchantRemark("初始化商户失败."+e.getMessage()); |
|
|
poiBase.setInitMerchantRemark("初始化商户失败."+e.getMessage()); |
|
|
} |
|
|
} |
|
|
|