| @@ -259,7 +259,7 @@ public class TtMerchantPoiController extends DouyinBaseController { | |||
| //return addLocationInfo(mFile,false); | |||
| throw new MallinkException(Result.ERROR,"当前版本无需补齐地理位置信息"); | |||
| }else { | |||
| addLocationInfo(mFile,true,"1bdc087fc6f72820dc5c848a033de7f9",request,response); | |||
| addLocationInfo(this.getTenantInfo(),mFile,true,"1bdc087fc6f72820dc5c848a033de7f9",request,response); | |||
| } | |||
| } catch (Exception e) { | |||
| logger.error("addLocationInfo error.",e); | |||
| @@ -267,7 +267,7 @@ public class TtMerchantPoiController extends DouyinBaseController { | |||
| } | |||
| } | |||
| private void addLocationInfo(MultipartFile mFile,boolean isNew,String gaodeKey, | |||
| private void addLocationInfo(TenantEntity tenantEntity,MultipartFile mFile,boolean isNew,String gaodeKey, | |||
| HttpServletRequest request, HttpServletResponse response) throws Exception{ | |||
| if (mFile.isEmpty()) { | |||
| throw new MallinkException(Result.ERROR, "上传文件不能为空"); | |||
| @@ -319,7 +319,7 @@ public class TtMerchantPoiController extends DouyinBaseController { | |||
| } | |||
| } | |||
| if (isNew) { | |||
| asyncTask.exportExcelPoiDataAddLocationForNew(gaodeKey,lFile,request,response); | |||
| asyncTask.exportExcelPoiDataAddLocationForNew(tenantEntity,gaodeKey,lFile,request,response); | |||
| }else { | |||
| } | |||
| @@ -11,7 +11,10 @@ import cn.afterturn.easypoi.handler.inter.IExcelDataHandler; | |||
| import com.aliyun.openservices.shade.org.apache.commons.lang3.StringUtils; | |||
| import com.iformall.common.ErrorCode; | |||
| import com.iformall.domain.po.MallUserInfo; | |||
| import com.iformall.domain.po.TtMerchantPoi; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxTags; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.vo.CUserBaseInfoT; | |||
| import com.iformall.domain.vo.GaoDePoiInfo; | |||
| import com.iformall.domain.vo.MerchantPoiT; | |||
| @@ -21,6 +24,7 @@ import com.iformall.exception.MallinkException; | |||
| import com.iformall.service.TtMerchantPoiService; | |||
| import com.iformall.service.WxCUserBasicInfoService; | |||
| import com.iformall.service.WxCouponPasswordService; | |||
| import com.iformall.service.WxMerchantService; | |||
| import com.iformall.service.WxTagsService; | |||
| import org.apache.poi.hssf.usermodel.HSSFWorkbook; | |||
| @@ -36,7 +40,9 @@ import org.springframework.stereotype.Component; | |||
| import java.io.File; | |||
| import java.io.OutputStream; | |||
| import java.util.ArrayList; | |||
| import java.util.HashMap; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import java.util.concurrent.TimeUnit; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| @@ -60,6 +66,9 @@ public class AsyncTask { | |||
| @Autowired | |||
| StringRedisTemplate stringRedisTemplate; | |||
| @Autowired | |||
| private WxMerchantService wxMerchantService; | |||
| private class UserExcelHandler extends ExcelDataHandlerDefaultImpl<CUserBaseInfoT> { | |||
| @Override | |||
| @@ -237,10 +246,10 @@ public class AsyncTask { | |||
| } | |||
| } | |||
| public void exportExcelPoiDataAddLocationForNew(String gaodeKey,File file,HttpServletRequest request, HttpServletResponse response) throws Exception { | |||
| public void exportExcelPoiDataAddLocationForNew(TenantEntity tenantEntity,String gaodeKey,File file,HttpServletRequest request, HttpServletResponse response) throws Exception { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| String[] headers = new String[]{"富茂系统商户ID", "富茂系统商户名称","门店名称", "门店ID", "城市", "详细地址","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度","高德匹配备注"}; | |||
| String[] headers = new String[]{"门店名称", "门店ID", "城市", "详细地址","富茂系统商户ID", "富茂系统商户名称","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度","高德匹配备注","管理员手机号"}; | |||
| params.setImportFields(headers); | |||
| IExcelDataHandler<MerchantPoiTNew> handler = new AsyncTask.PoiNewExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"门店名称", "门店ID", "城市", "详细地址"}); | |||
| @@ -266,7 +275,17 @@ public class AsyncTask { | |||
| List<MerchantPoiTNew> successList = datalist.getList(); | |||
| //List<MerchantPoiTNew> failList = datalist.getFailList(); | |||
| if(null != successList && successList.size() > 0 ) { | |||
| try { | |||
| //查询所有匹配了poi的 | |||
| TtMerchantPoi poiQ = new TtMerchantPoi(); | |||
| poiQ.updateTenantInfo(tenantEntity); | |||
| Map<String,Long> poiMerchantIdMap = ttMerchantPoiService.queryPoiMerchantIdMap(poiQ); | |||
| //查询所有商户 | |||
| WxMerchant merchantQ = new WxMerchant(); | |||
| merchantQ.updateTenantInfo(tenantEntity); | |||
| Map<Long,WxMerchant> merchantMap = wxMerchantService.findMerchantMap(merchantQ); | |||
| try { | |||
| successList.parallelStream().forEach(poiBase -> { | |||
| try { | |||
| if (StringUtils.isNotBlank(poiBase.getProvince()) && StringUtils.isNotBlank(poiBase.getCity()) | |||
| @@ -289,6 +308,18 @@ public class AsyncTask { | |||
| poiBase.setGaodeRemark("未匹配到信息"); | |||
| } | |||
| } | |||
| String poiId = poiBase.getPoiId(); | |||
| if (StringUtils.isNotBlank(poiId) && null != poiMerchantIdMap) { | |||
| Long merchantId = poiMerchantIdMap.get(poiId); | |||
| poiBase.setMerchantId(String.valueOf(merchantId)); | |||
| if (null != merchantMap && null != merchantId) { | |||
| WxMerchant m = merchantMap.get(merchantId); | |||
| if (null != m) { | |||
| poiBase.setMerchantName(m.getName()); | |||
| } | |||
| } | |||
| } | |||
| } catch (UnknownSessionException ue) { | |||
| logger.error("session :"+ue.getMessage()); | |||
| poiBase.setGaodeRemark("查询高德API失败"); | |||
| @@ -298,7 +329,7 @@ public class AsyncTask { | |||
| //exportParams.setCreateHeadRows(true); | |||
| //exportParams.setExclusions(headers); | |||
| Workbook workBook = ExcelExportUtil.exportExcel(exportParams, MerchantPoiTNew.class, successList); | |||
| exportExcel(request, response, workBook, "POI匹配模版-高德.xls"); | |||
| exportExcel(request, response, workBook, "POI匹配模版-高德.xlsx"); | |||
| } catch (Exception e) { | |||
| logger.error("更新地理信息失败:"+e.getMessage(),e); | |||
| } | |||
| @@ -321,10 +352,10 @@ public class AsyncTask { | |||
| public void importExcelPoiDataForNew(File file, MallUserInfo user, String importKey) { | |||
| ImportParams params = new ImportParams(); | |||
| // 需要验证 | |||
| String[] headers = new String[]{"富茂系统商户ID", "富茂系统商户名称","门店名称", "门店ID", "城市", "详细地址","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度","高德匹配备注"}; | |||
| String[] headers = new String[]{"门店名称", "门店ID", "城市", "详细地址","富茂系统商户ID", "富茂系统商户名称","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度","高德匹配备注","管理员手机号"}; | |||
| params.setImportFields(headers); | |||
| IExcelDataHandler<MerchantPoiTNew> handler = new AsyncTask.PoiNewExcelHandler(); | |||
| handler.setNeedHandlerFields(new String[]{"富茂系统商户ID","门店ID","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度"}); | |||
| handler.setNeedHandlerFields(new String[]{"门店ID","富茂系统商户ID","富茂系统省份", "富茂系统城市", "富茂系统地址","富茂系统经度", "富茂系统纬度"}); | |||
| params.setNeedVerify(true); | |||
| ExcelImportResult<MerchantPoiTNew> datalist = null; | |||
| @@ -66,5 +66,9 @@ public class MerchantPoiT implements Serializable { | |||
| @Excel(name = "其他信息", width = 20, orderNum = "15") | |||
| @io.swagger.annotations.ApiModelProperty(value="其他信息",name="extra") | |||
| private String extra; | |||
| @Excel(name = "管理员手机号", width = 20, orderNum = "16") | |||
| @io.swagger.annotations.ApiModelProperty(value="管理员手机号",name="extra") | |||
| private String phone; | |||
| } | |||
| @@ -12,25 +12,24 @@ import java.math.BigDecimal; | |||
| @Data | |||
| public class MerchantPoiTNew implements Serializable { | |||
| @Excel(name="富茂系统商户ID",width = 20,orderNum = "1") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统商户ID",name="merchantId") | |||
| private String merchantId; | |||
| @Excel(name="富茂系统商户名称",width = 20,orderNum = "2") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统商户名称",name="merchantName") | |||
| private String merchantName; | |||
| @Excel(name = "门店名称", width = 20, orderNum = "3") | |||
| @Excel(name = "门店名称", width = 20, orderNum = "1") | |||
| @io.swagger.annotations.ApiModelProperty(value="来客门店名称",name="poiName") | |||
| private String poiName; | |||
| @Excel(name="门店ID",width = 20,orderNum = "4") | |||
| @Excel(name="门店ID",width = 20,orderNum = "2") | |||
| @io.swagger.annotations.ApiModelProperty(value="来客门店ID",name="poiId") | |||
| private String poiId; | |||
| @Excel(name = "城市", width = 20, orderNum = "5") | |||
| @Excel(name = "城市", width = 20, orderNum = "3") | |||
| @io.swagger.annotations.ApiModelProperty(value="来客门店城市",name="poiCity") | |||
| private String poiCity; | |||
| @Excel(name = "详细地址", width = 20, orderNum = "6") | |||
| @Excel(name = "详细地址", width = 20, orderNum = "4") | |||
| @io.swagger.annotations.ApiModelProperty(value="来客门店详细地址",name="poiAddress") | |||
| private String poiAddress; | |||
| @Excel(name="富茂系统商户ID",width = 20,orderNum = "5") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统商户ID",name="merchantId") | |||
| private String merchantId; | |||
| @Excel(name="富茂系统商户名称",width = 20,orderNum = "6") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统商户名称",name="merchantName") | |||
| private String merchantName; | |||
| @Excel(name = "富茂系统省份", width = 20, orderNum = "7") | |||
| @io.swagger.annotations.ApiModelProperty(value="富茂系统省份",name="province") | |||
| private String province; | |||
| @@ -4,6 +4,7 @@ import com.iformall.common.CommonMapper; | |||
| import com.iformall.domain.po.TtMerchantPoi; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| public interface TtMerchantPoiMapper extends CommonMapper<TtMerchantPoi, Long> { | |||
| @@ -14,5 +15,7 @@ public interface TtMerchantPoiMapper extends CommonMapper<TtMerchantPoi, Long> { | |||
| List<TtMerchantPoi> findTaskIdList(TtMerchantPoi record); | |||
| int deleteByUpdate(Long id); | |||
| Map<String,Long> findMerchantIdMap(TtMerchantPoi record); | |||
| } | |||
| @@ -12,6 +12,7 @@ import com.iformall.douyin.web.api.goodlifesaas.TtGoodLifeSaasService; | |||
| import com.iformall.douyin.web.api.web.TtWebService; | |||
| import java.util.List; | |||
| import java.util.Map; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import javax.servlet.http.HttpServletResponse; | |||
| @@ -70,4 +71,6 @@ public interface TtMerchantPoiService { | |||
| void exportTemplate(HttpServletRequest request, HttpServletResponse response,boolean isNew); | |||
| GaoDePoiInfo queryGaoDePoiInfo(String gaodeKey,String address); | |||
| Map<String,Long> queryPoiMerchantIdMap(TtMerchantPoi merchantPoiQ); | |||
| } | |||
| @@ -775,6 +775,11 @@ public class TtMerchantPoiServiceImpl implements TtMerchantPoiService { | |||
| } | |||
| return null; | |||
| } | |||
| @Override | |||
| public Map<String, Long> queryPoiMerchantIdMap(TtMerchantPoi merchantPoiQ) { | |||
| return ttMerchantPoiMapper.findMerchantIdMap(merchantPoiQ); | |||
| } | |||
| // @Override | |||
| @@ -140,6 +140,17 @@ | |||
| from tt_merchant_poi | |||
| <include refid="dynamicWhereConditions"/> | |||
| </select> | |||
| <select id="findMerchantIdMap" parameterType="com.iformall.domain.po.TtMerchantPoi" resultType="Map"> | |||
| select `poi_id`,`id` | |||
| from tt_merchant_poi where poi_id is not null and poi_id != '' | |||
| <if test=" null != tenantId and '' != tenantId"> | |||
| and `tenant_id` = #{tenantId} | |||
| </if> | |||
| <if test=" null != parentTenantId and '' != parentTenantId"> | |||
| and `parent_tenant_id` = #{parentTenantId} | |||
| </if> | |||
| </select> | |||
| <update id="deleteByUpdate" parameterType="Long"> | |||
| update tt_merchant_poi set is_del = 1 | |||