|
|
@ -1,13 +1,17 @@ |
|
|
|
package com.epmet.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.AppClientConstant; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.constant.StrangerResiGuideConstant; |
|
|
|
import com.epmet.dao.StrangerAccessRecordDao; |
|
|
|
import com.epmet.dto.StrangerAccessRecordDTO; |
|
|
|
import com.epmet.dto.form.*; |
|
|
@ -18,17 +22,15 @@ import com.epmet.feign.EpmetUserFeignClient; |
|
|
|
import com.epmet.feign.GovOrgFeignClient; |
|
|
|
import com.epmet.feign.OperCustomizeFeignClient; |
|
|
|
import com.epmet.service.StrangerAccessRecordService; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.slf4j.Logger; |
|
|
|
import org.slf4j.LoggerFactory; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 陌生人记录访问表 |
|
|
|
* @ClassName ResiGuideServiceImpl |
|
|
@ -37,6 +39,8 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
|
*/ |
|
|
|
@Service |
|
|
|
public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAccessRecordDao, StrangerAccessRecordEntity> implements StrangerAccessRecordService { |
|
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(StrangerAccessRecordServiceImpl.class); |
|
|
|
@Autowired |
|
|
|
private StrangerAccessRecordDao strangerAccessRecordDao; |
|
|
|
@Autowired |
|
|
@ -45,8 +49,10 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc |
|
|
|
private EpmetUserFeignClient epmetUserFeignClient; |
|
|
|
@Autowired |
|
|
|
private OperCustomizeFeignClient operCustomizeFeignClient; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询陌生人访问记录 |
|
|
|
* |
|
|
|
* @param params |
|
|
|
* @return PageData<StrangerAccessRecordDTO> |
|
|
|
* @author yangshaoping |
|
|
@ -56,12 +62,13 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc |
|
|
|
public PageData<StrangerAccessRecordDTO> getStrangerAccessRecordPage(Map<String, Object> params) { |
|
|
|
|
|
|
|
IPage<StrangerAccessRecordEntity> page = baseDao.selectPage( |
|
|
|
getPage(params, "VISIT_TIME",false), |
|
|
|
getPage(params, "VISIT_TIME", false), |
|
|
|
getWrapper(params) |
|
|
|
); |
|
|
|
|
|
|
|
return getPageData(page,StrangerAccessRecordDTO.class); |
|
|
|
return getPageData(page, StrangerAccessRecordDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<StrangerAccessRecordDTO> page(Map<String, Object> params) { |
|
|
|
IPage<StrangerAccessRecordEntity> page = baseDao.selectPage( |
|
|
@ -81,20 +88,21 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc |
|
|
|
/** |
|
|
|
* sql语句条件查询拼接 |
|
|
|
* 陌生人访客记录,逻辑删除标识为0,访问时间为当前三天,按照访问时间降序排列 |
|
|
|
* |
|
|
|
* @param params |
|
|
|
* @return QueryWrapper<StrangerAccessRecordEntity> |
|
|
|
* @author |
|
|
|
* @date |
|
|
|
*/ |
|
|
|
private QueryWrapper<StrangerAccessRecordEntity> getWrapper(Map<String, Object> params){ |
|
|
|
String id = (String)params.get(FieldConstant.ID_HUMP); |
|
|
|
private QueryWrapper<StrangerAccessRecordEntity> getWrapper(Map<String, Object> params) { |
|
|
|
String id = (String) params.get(FieldConstant.ID_HUMP); |
|
|
|
|
|
|
|
QueryWrapper<StrangerAccessRecordEntity> wrapper = new QueryWrapper<>(); |
|
|
|
wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); |
|
|
|
Calendar before3daysDate = Calendar.getInstance(); |
|
|
|
before3daysDate.setTime(new Date()); |
|
|
|
before3daysDate.add(Calendar.DATE,-3); |
|
|
|
wrapper.between("VISIT_TIME", before3daysDate.getTime(),new Date()); |
|
|
|
before3daysDate.add(Calendar.DATE, -3); |
|
|
|
wrapper.between("VISIT_TIME", before3daysDate.getTime(), new Date()); |
|
|
|
return wrapper; |
|
|
|
} |
|
|
|
|
|
|
@ -127,9 +135,9 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @return Result<List < CustomerGridForStrangerResultDTO>> |
|
|
|
* @Description 陌生人根据地区编码查询附近网格数据具体实现 |
|
|
|
* @Param CustomerGridListFormDTO |
|
|
|
* @return Result<List<CustomerGridForStrangerResultDTO>> |
|
|
|
* @Author wangc |
|
|
|
* @Date 2020.03.19 14:28 |
|
|
|
**/ |
|
|
@ -152,7 +160,7 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc |
|
|
|
.getPageForStrangerGuideInterface(listCustomerGridFormDTO); |
|
|
|
|
|
|
|
//Feign调用成功
|
|
|
|
if(queryResult.success()) { |
|
|
|
if (queryResult.success()) { |
|
|
|
|
|
|
|
List<CustomerGridForStrangerResultDTO> queryList = queryResult.getData(); |
|
|
|
if (null != queryResult && queryList.size() > 0) { |
|
|
@ -179,9 +187,9 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc |
|
|
|
//没有查询出结果
|
|
|
|
return new Result<List<CustomerGridForStrangerResultDTO>>().ok(new ArrayList<>()); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
//Feign调用失败
|
|
|
|
return new Result<List<CustomerGridForStrangerResultDTO>>().error(queryResult.getCode(),queryResult.getMsg()); |
|
|
|
return new Result<List<CustomerGridForStrangerResultDTO>>().error(queryResult.getCode(), queryResult.getMsg()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -189,42 +197,44 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl<StrangerAcc |
|
|
|
|
|
|
|
/** |
|
|
|
* 居民端-网格链接获取客户首页配置 |
|
|
|
* |
|
|
|
* @return void |
|
|
|
* @author sun |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public Result<HomeDesignByCustomerResultDTO> getgridhome(TokenDto tokenDTO, StrangerFormDTO formDTO) throws Exception { |
|
|
|
public Result<HomeDesignByCustomerResultDTO> getGridHome(TokenDto tokenDTO, StrangerFormDTO strangerFormDTO) { |
|
|
|
//1.先判断参数
|
|
|
|
//居民端 所以参数必须是居民端的参数 否则就是参数错误s
|
|
|
|
/*if (!AppClientConstant.APP_RESI.equals(tokenDTO.getApp())) { |
|
|
|
return new Result<HomeDesignByCustomerResultDTO>().error(StrangerResiGuideConstant.PARAMETER_EXCEPTION); |
|
|
|
}*/ |
|
|
|
//token里边有所属端 userId这些参数 前台传递customerID和gridId
|
|
|
|
//1:调用epmet-user服务查询数据 新建网格记录数据
|
|
|
|
VisitedFormDTO vi = new VisitedFormDTO(); |
|
|
|
vi.setGridId(formDTO.getGridId()); |
|
|
|
vi.setCustomerId(formDTO.getCustomerId()); |
|
|
|
vi.setUserId(tokenDTO.getUserId());//token中获取userId
|
|
|
|
epmetUserFeignClient.saveLatestAndVisited(vi); |
|
|
|
|
|
|
|
//2:调用ope-customize服务 获取首页发布数据
|
|
|
|
Result<HomeDesignByCustomerResultDTO> res = getCustomerHomeData(formDTO.getCustomerId(),tokenDTO.getApp()); |
|
|
|
return res; |
|
|
|
|
|
|
|
//2:调用epmet-user服务查询数据 新建网格记录数据
|
|
|
|
VisitedFormDTO visitedFormDTO = new VisitedFormDTO(); |
|
|
|
visitedFormDTO.setGridId(strangerFormDTO.getGridId()); |
|
|
|
visitedFormDTO.setCustomerId(strangerFormDTO.getCustomerId()); |
|
|
|
visitedFormDTO.setUserId(tokenDTO.getUserId());//token中获取userId
|
|
|
|
Result re = epmetUserFeignClient.saveVisitedRecord(visitedFormDTO); |
|
|
|
if (!re.success()) { |
|
|
|
log.warn(StrangerResiGuideConstant.EPMET_USER_EXCEPTION); |
|
|
|
} |
|
|
|
//3:调用ope-customize服务 获取首页发布数据
|
|
|
|
Result<HomeDesignByCustomerResultDTO> result = getCustomerHomeData(strangerFormDTO.getCustomerId()); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 调用oper-customize服务 获取首页发布数据 |
|
|
|
* |
|
|
|
* @param customerId 客户Id |
|
|
|
* @param clientType 所属端 |
|
|
|
* @return |
|
|
|
* @author sun |
|
|
|
*/ |
|
|
|
public Result<HomeDesignByCustomerResultDTO> getCustomerHomeData(String customerId,String clientType) throws Exception { |
|
|
|
CustomerHomeFormDTO dto = new CustomerHomeFormDTO(); |
|
|
|
dto.setCustomerId(customerId); |
|
|
|
//居民端 所以参数必须是居民端的参数 否则就是参数错误s
|
|
|
|
if (AppClientConstant.APP_RESI.equals(clientType)){//居民端
|
|
|
|
dto.setClientType(NumConstant.ZERO_STR); |
|
|
|
}else { |
|
|
|
throw new Exception("参数异常,app端不是指定的居民端,请检查token信息!"); |
|
|
|
} |
|
|
|
return operCustomizeFeignClient.getHomeReleaseByCustomer(dto); |
|
|
|
public Result<HomeDesignByCustomerResultDTO> getCustomerHomeData(String customerId) { |
|
|
|
CustomerHomeFormDTO customerHomeFormDTO = new CustomerHomeFormDTO(); |
|
|
|
customerHomeFormDTO.setCustomerId(customerId); |
|
|
|
customerHomeFormDTO.setClientType(NumConstant.ZERO_STR); |
|
|
|
return operCustomizeFeignClient.getHomeReleaseByCustomer(customerHomeFormDTO); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|