diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java index 38a6c0d33a..e62ed4b7ce 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/constant/Constant.java @@ -35,6 +35,10 @@ public interface Constant { * 菜单根节点标识 */ Long MENU_ROOT = 0L; + /** + * 菜单根节点标识 + */ + String OPER_MENU_ROOT = "0"; /** * 部门根节点标识 */ diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/TreeUtils.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/TreeUtils.java index b78c8317ef..4272d9cfc6 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/TreeUtils.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/TreeUtils.java @@ -40,6 +40,23 @@ public class TreeUtils { return treeList; } + /** + * 根据pid,构建树节点 + */ + public static List buildTree(List treeNodes, String pid) { + //pid不能为空 + AssertUtils.isNull(pid, "pid"); + + List treeList = new ArrayList<>(); + for(T treeNode : treeNodes) { + if (pid.equals(treeNode.getPid())) { + treeList.add(findChildren(treeNodes, treeNode)); + } + } + + return treeList; + } + /** * 查找子节点 */ @@ -52,6 +69,18 @@ public class TreeUtils { return rootNode; } + /** + * 查找子节点 + */ + private static T findChildren(List treeNodes, T rootNode) { + for(T treeNode : treeNodes) { + if(rootNode.getId().equals(treeNode.getPid())) { + rootNode.getChildren().add(findChildren(treeNodes, treeNode)); + } + } + return rootNode; + } + /** * 构建树节点 */ diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java index 65aca7f594..7d90d3a060 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerGridController.java @@ -102,8 +102,8 @@ public class CustomerGridController { * @throws Exception */ @PostMapping("getcustomergridbygridid") - public Result getCustomerGridByGridId(@RequestBody CustomerGridFormDTO formDTO) { - return customerGridService.getCustomerGridByGridId(formDTO); + public Result getCustomerGridByGridId(@RequestBody CustomerGridFormDTO customerGridFormDTO) { + return customerGridService.getCustomerGridByGridId(customerGridFormDTO); } /** * @Description 陌生人导览模块调用 根据陌生揽客传入的地区码进行分页查询显示 diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java index 2ed4edcdae..cf1bcee971 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerGridDao.java @@ -60,5 +60,5 @@ public interface CustomerGridDao extends BaseDao { **/ List selectRestGridWithoutGivenAreaCode(Map paramsMap); - CustomerGridDTO getCustomerGridByGridId(CustomerGridFormDTO formDTO); + CustomerGridDTO selectCustomerGridByGridId(CustomerGridFormDTO customerGridFormDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java index 4d65c455a3..3da56bc4d2 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerGridService.java @@ -108,9 +108,9 @@ public interface CustomerGridService extends BaseService { Result> listGridByAreaCode(ListCustomerGridFormDTO listCustomerGridFormDTO); /** 根据网格Id查询用户数据 - * @param formDTO + * @param customerGridFormDTO * @return * @date 2020-03-17 */ - Result getCustomerGridByGridId(CustomerGridFormDTO formDTO); + Result getCustomerGridByGridId(CustomerGridFormDTO customerGridFormDTO); } \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java index cd6805cdd9..0c05d61870 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerGridServiceImpl.java @@ -148,8 +148,8 @@ public class CustomerGridServiceImpl extends BaseServiceImpl getCustomerGridByGridId(CustomerGridFormDTO formDTO) { - return new Result().ok(baseDao.getCustomerGridByGridId(formDTO)); - } + public Result getCustomerGridByGridId(CustomerGridFormDTO customerGridFormDTO) { + return new Result().ok(baseDao.selectCustomerGridByGridId(customerGridFormDTO)); +} } diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml index a9722bf3a4..80f430442c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerGridDao.xml @@ -65,7 +65,7 @@ LIMIT #{pageNo}, #{pageSize} - + - select resource_url, resource_method from oper_resource where resource_code = #{value} order by create_date asc + select resource_url, resource_method from oper_resource where resource_code = #{value} order by created_time asc + SELECT + f.id, + f.FUNCTION_NAME AS functionName + FROM + FUNCTION f + WHERE + f.DEL_FLAG = '0' + AND f.SHOPPING_STATUS = '1' + + diff --git a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/HomeComponentDao.xml b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/HomeComponentDao.xml index 10bfc66952..a9e006b145 100644 --- a/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/HomeComponentDao.xml +++ b/epmet-module/oper-customize/oper-customize-server/src/main/resources/mapper/HomeComponentDao.xml @@ -102,4 +102,29 @@ ORDER BY CONVERT ( hc.COMPONENT_NAME USING gbk ) ASC + + + diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/constant/StrangerResiGuideConstant.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/constant/StrangerResiGuideConstant.java new file mode 100644 index 0000000000..6d84665655 --- /dev/null +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/constant/StrangerResiGuideConstant.java @@ -0,0 +1,25 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.constant; + +/** + * 常量 + * @author sun + * @since 1.0.0 + */ +public interface StrangerResiGuideConstant { + /** + * 参数异常 + */ + String PARAMETER_EXCEPTION = "参数异常,app端不是指定的居民端,请检查token信息!"; + /** + * 服务调用异常 + */ + String EPMET_USER_EXCEPTION = "调用epmet-user服务保存网格记录表数据失败!"; +} diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java index 5f97343835..7c3b78194f 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerResiGuideController.java @@ -54,8 +54,8 @@ public class StrangerResiGuideController { * @Date 2020/3/16 **/ @PostMapping("getgridhome") - public Result getValidCustomerList( @LoginUser TokenDto tokenDTO, @RequestBody StrangerFormDTO formDTO) throws Exception { - return strangerAccessRecordService.getgridhome(tokenDTO, formDTO); + public Result getGridHome( @LoginUser TokenDto tokenDTO, @RequestBody StrangerFormDTO strangerFormDTO) throws Exception { + return strangerAccessRecordService.getGridHome(tokenDTO, strangerFormDTO); } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java index 0268ea99ec..31582eecd3 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/EpmetUserFeignClient.java @@ -19,8 +19,8 @@ public interface EpmetUserFeignClient { * @param * @Description **/ - @PostMapping("/epmetuser/gridvisited/savelatestandvisited") - Result saveLatestAndVisited(VisitedFormDTO formDTO); + @PostMapping("/epmetuser/gridvisited/savevisitedrecord") + Result saveVisitedRecord(VisitedFormDTO formDTO); diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java index 60688ad717..06b6ed803a 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/EpmetUserFeignClientFallBack.java @@ -16,8 +16,8 @@ import org.springframework.stereotype.Component; public class EpmetUserFeignClientFallBack implements EpmetUserFeignClient { @Override - public Result saveLatestAndVisited(VisitedFormDTO formDTO) { - return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "saveLatestAndVisited",formDTO); + public Result saveVisitedRecord(VisitedFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPMET_USER_SERVER, "savevisitedrecord",formDTO); } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java index 88c1d1d37d..b2d42505b3 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/StrangerAccessRecordService.java @@ -25,6 +25,7 @@ public interface StrangerAccessRecordService extends BaseService * @author yangshaoping @@ -41,6 +42,7 @@ public interface StrangerAccessRecordService extends BaseService page(Map params); + /** * 默认查询 * @@ -92,9 +94,9 @@ public interface StrangerAccessRecordService extends BaseService> * @Description 陌生人根据地区编码查询附近网格数据接口定义 * @Param CustomerGridListFormDTO - * @return Result> * @Author wangc * @Date 2020.03.19 14:28 **/ @@ -102,9 +104,10 @@ public interface StrangerAccessRecordService extends BaseService getgridhome(TokenDto tokenDTO, StrangerFormDTO formDTO) throws Exception; + Result getGridHome(TokenDto tokenDTO, StrangerFormDTO formDTO); } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java index 785815453c..b33c0dba05 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/service/impl/StrangerAccessRecordServiceImpl.java @@ -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.*; @@ -19,17 +23,15 @@ import com.epmet.feign.GovOrgFeignClient; import com.epmet.feign.OperCustomizeFeignClient; import com.epmet.service.StrangerAccessRecordService; import com.epmet.utils.ModuleConstant; +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 @@ -38,6 +40,8 @@ import org.springframework.transaction.annotation.Transactional; */ @Service public class StrangerAccessRecordServiceImpl extends BaseServiceImpl implements StrangerAccessRecordService { + + private static final Logger log = LoggerFactory.getLogger(StrangerAccessRecordServiceImpl.class); @Autowired private StrangerAccessRecordDao strangerAccessRecordDao; @Autowired @@ -46,6 +50,7 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl 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 page(Map params) { IPage page = baseDao.selectPage( @@ -88,15 +94,15 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper 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; } @@ -154,7 +160,7 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl queryList = queryResult.getData(); if (null != queryResult && queryList.size() > 0) { @@ -179,9 +185,9 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl>().ok(new ArrayList<>()); } - }else{ + } else { //Feign调用失败 - return new Result>().error(queryResult.getCode(),queryResult.getMsg()); + return new Result>().error(queryResult.getCode(), queryResult.getMsg()); } @@ -189,42 +195,44 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl getgridhome(TokenDto tokenDTO, StrangerFormDTO formDTO) throws Exception { + public Result getGridHome(TokenDto tokenDTO, StrangerFormDTO strangerFormDTO) { + //1.先判断参数 + //居民端 所以参数必须是居民端的参数 否则就是参数错误s + if (!AppClientConstant.APP_RESI.equals(tokenDTO.getApp())) { + return new Result().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 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 result = getCustomerHomeData(strangerFormDTO.getCustomerId()); + return result; } /** * 调用oper-customize服务 获取首页发布数据 - * @param customerId 客户Id - * @param clientType 所属端 + * + * @param customerId 客户Id * @return * @author sun */ - public Result 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 getCustomerHomeData(String customerId) { + CustomerHomeFormDTO customerHomeFormDTO = new CustomerHomeFormDTO(); + customerHomeFormDTO.setCustomerId(customerId); + customerHomeFormDTO.setClientType(NumConstant.ZERO_STR); + return operCustomizeFeignClient.getHomeReleaseByCustomer(customerHomeFormDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/GridVisitedConstant.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/GridVisitedConstant.java new file mode 100644 index 0000000000..c21ad1761e --- /dev/null +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/constant/GridVisitedConstant.java @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2018 人人开源 All rights reserved. + *

+ * https://www.renren.io + *

+ * 版权所有,侵权必究! + */ + +package com.epmet.constant; + +/** + * 常量 + * @author sun + * @since 1.0.0 + */ +public interface GridVisitedConstant { + /** + * 查询异常 + */ + String QUERY_EXCEPTION = "查询客户网格表数据失败!"; + /** + * 网格访问记录表新增数据失败 + */ + String SAVE_VISITED = "网格访问记录表新增数据失败!"; + /** + * 最近访问网格表新增数据失败 + */ + String SAVE_LATEST = "最近访问网格表新增数据失败!"; +} diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridVisitedController.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridVisitedController.java index 1f3d09d73c..140f673d74 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridVisitedController.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/controller/GridVisitedController.java @@ -46,24 +46,24 @@ import java.util.Map; @RestController @RequestMapping("gridvisited") public class GridVisitedController { - + @Autowired private GridVisitedService gridVisitedService; @GetMapping("page") - public Result> page(@RequestParam Map params){ + public Result> page(@RequestParam Map params) { PageData page = gridVisitedService.page(params); return new Result>().ok(page); } @GetMapping("{id}") - public Result get(@PathVariable("id") String id){ + public Result get(@PathVariable("id") String id) { GridVisitedDTO data = gridVisitedService.get(id); return new Result().ok(data); } @PostMapping - public Result save(@RequestBody GridVisitedDTO dto){ + public Result save(@RequestBody GridVisitedDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); gridVisitedService.save(dto); @@ -71,7 +71,7 @@ public class GridVisitedController { } @PutMapping - public Result update(@RequestBody GridVisitedDTO dto){ + public Result update(@RequestBody GridVisitedDTO dto) { //效验数据 ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); gridVisitedService.update(dto); @@ -79,7 +79,7 @@ public class GridVisitedController { } @DeleteMapping - public Result delete(@RequestBody String[] ids){ + public Result delete(@RequestBody String[] ids) { //效验数据 AssertUtils.isArrayEmpty(ids, "id"); gridVisitedService.delete(ids); @@ -96,11 +96,12 @@ public class GridVisitedController { * 网格访问记录表、最近访问网格表新增数据 * 网格访问记录表新增数据(一天一条) * 最近访问表更新访问时间字段 - * @param formDTO + * + * @param visitedFormDTO */ - @PostMapping("savelatestandvisited") - public void saveLatestAndVisited(@RequestBody VisitedFormDTO formDTO) throws Exception { - gridVisitedService.saveLatestAndVisited(formDTO); + @PostMapping("savevisitedrecord") + public Result saveVisitedRecord(@RequestBody VisitedFormDTO visitedFormDTO) { + return gridVisitedService.saveVisitedRecord(visitedFormDTO); } } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GridVisitedDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GridVisitedDao.java index b246bdabd5..5f37083bda 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GridVisitedDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/GridVisitedDao.java @@ -33,5 +33,5 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface GridVisitedDao extends BaseDao { - GridVisitedDTO getGridVisitedByIds(GridVisitedDTO formDTO); + GridVisitedDTO selectGridVisitedByGridIdAndUserId(GridVisitedDTO formDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java index 5625a3ee76..acbb5833f7 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -16,12 +16,12 @@ import org.springframework.web.bind.annotation.PostMapping; @FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignClientFallBack.class) public interface GovOrgFeignClient { - /** - * @param - * @Description 根据客户Id查询客户用户表数据 - * @Date 2020/3/17 - **/ - @PostMapping("/gov/org/customergrid/getcustomergridbygridid") - Result getCustomerGridByGridId(CustomerGridFormDTO formDTO); + /** + * @param + * @Description 根据客户Id查询客户用户表数据 + * @Date 2020/3/17 + **/ + @PostMapping("/gov/org/customergrid/getcustomergridbygridid") + Result getCustomerGridByGridId(CustomerGridFormDTO formDTO); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java index c5e04129bf..8b4d87717f 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignClientFallBack.java @@ -16,8 +16,8 @@ import org.springframework.stereotype.Component; @Component public class GovOrgFeignClientFallBack implements GovOrgFeignClient { - @Override - public Result getCustomerGridByGridId(CustomerGridFormDTO formDTO) { - return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getCustomerGridByGridId",formDTO); - } + @Override + public Result getCustomerGridByGridId(CustomerGridFormDTO formDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "getCustomerGridByGridId", formDTO); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridLatestService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridLatestService.java index 138f4c9483..41321a1e1c 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridLatestService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridLatestService.java @@ -99,5 +99,5 @@ public interface GridLatestService extends BaseService { * 最近访问网格表新增数据 * @param formDTO */ - void saveGridLatest(VisitedFormDTO formDTO, CustomerGridDTO cu); + boolean saveGridLatest(VisitedFormDTO formDTO, CustomerGridDTO cu); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridVisitedService.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridVisitedService.java index b324356f94..717edcb011 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridVisitedService.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/GridVisitedService.java @@ -19,6 +19,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.GridLatestDTO; import com.epmet.dto.GridVisitedDTO; import com.epmet.dto.form.VisitedFormDTO; @@ -95,23 +96,8 @@ public interface GridVisitedService extends BaseService { */ void delete(String[] ids); - - - - - - /** - * 网格访问记录表新增数据 - * @param formDTO - */ - //void saveGridVisited(GridVisitedDTO formDTO); - - - - - /** * @param formDTO */ - void saveLatestAndVisited(VisitedFormDTO formDTO) throws Exception; + Result saveVisitedRecord(VisitedFormDTO formDTO); } \ No newline at end of file diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java index ba4dcea6a1..f2f2b98555 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/GridLatestServiceImpl.java @@ -68,8 +68,8 @@ public class GridLatestServiceImpl extends BaseServiceImpl getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); @@ -106,28 +106,28 @@ public class GridLatestServiceImpl extends BaseServiceImpl implements GridVisitedService { + private static final Logger log = LoggerFactory.getLogger(GridVisitedServiceImpl.class); @Autowired private GovOrgFeignClient govOrgFeignClient; @Autowired @@ -73,8 +77,8 @@ public class GridVisitedServiceImpl extends BaseServiceImpl getWrapper(Map params){ - String id = (String)params.get(FieldConstant.ID_HUMP); + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); QueryWrapper wrapper = new QueryWrapper<>(); wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); @@ -111,63 +115,74 @@ public class GridVisitedServiceImpl extends BaseServiceImpl result = govOrgFeignClient.getCustomerGridByGridId(dto); - if(!result.success()){ - throw new Exception("查询客户网格表数据失败!"); + dto.setGridId(visitedFormDTO.getGridId()); + Result gridDTO = govOrgFeignClient.getCustomerGridByGridId(dto); + if (!gridDTO.success()) { + log.warn(GridVisitedConstant.QUERY_EXCEPTION); + result.error(GridVisitedConstant.QUERY_EXCEPTION); } - CustomerGridDTO cu = result.getData(); - + CustomerGridDTO customerGridDTO = gridDTO.getData(); //2:网格访问记录表新增数据 - saveGridVisited(formDTO,cu); - + if (!saveGridVisited(visitedFormDTO, customerGridDTO)) { + log.warn(GridVisitedConstant.SAVE_VISITED); + result.error(GridVisitedConstant.SAVE_VISITED); + } //3:最近访问网格表新增数据 - gridLatestService.saveGridLatest(formDTO,cu); - + if (!gridLatestService.saveGridLatest(visitedFormDTO, customerGridDTO)) { + log.warn(GridVisitedConstant.SAVE_LATEST); + result.error(GridVisitedConstant.SAVE_LATEST); + } + return result; } /** * 网格记录表和最近访问网格表新增数据 - * @param formDTO - * @param cu + * + * @param visitedFormDTO + * @param customerGridDTO */ - public void saveGridVisited(VisitedFormDTO formDTO,CustomerGridDTO cu) { + private boolean saveGridVisited(VisitedFormDTO visitedFormDTO, CustomerGridDTO customerGridDTO) { Date date = new Date(); - GridVisitedDTO vi = new GridVisitedDTO(); - vi.setIsRegister(getRegister("0"));//后续再其他服务中获取这个状态值 - vi.setCustomerId(cu.getCustomerId()); - vi.setGridId(cu.getId()); - vi.setCustomerUserId(formDTO.getUserId()); - vi.setVisitTime(date); - vi.setUpdatedTime(date); + GridVisitedDTO gridVisitedDTO = new GridVisitedDTO(); + //TODO:预留方法 根据userId查询用户是否认证(注册) + gridVisitedDTO.setIsRegister(getRegisterByUserId(visitedFormDTO.getUserId())); + gridVisitedDTO.setCustomerId(customerGridDTO.getCustomerId()); + gridVisitedDTO.setGridId(customerGridDTO.getId()); + gridVisitedDTO.setCustomerUserId(visitedFormDTO.getUserId()); + gridVisitedDTO.setVisitTime(date); + gridVisitedDTO.setUpdatedTime(date); //查询是否存在历史数据( 一个用户一天对一个网格只存在一条访问记录) - GridVisitedDTO dto = baseDao.getGridVisitedByIds(vi); + GridVisitedDTO dto = baseDao.selectGridVisitedByGridIdAndUserId(gridVisitedDTO); GridVisitedEntity entity = null; - if(dto==null||dto.getId()==null){ - entity = ConvertUtils.sourceToTarget(vi, GridVisitedEntity.class); - insert(entity); - }else{ + if (dto == null || dto.getId() == null) { + entity = ConvertUtils.sourceToTarget(gridVisitedDTO, GridVisitedEntity.class); + return insert(entity); + } else { entity = ConvertUtils.sourceToTarget(dto, GridVisitedEntity.class); + entity.setUpdatedBy(visitedFormDTO.getUserId()); entity.setUpdatedTime(date); - updateById(entity); + return updateById(entity); } } /** - * (预留方法)查询是否注册状态值 - * @param str + * (预留方法)查询是否注册的状态值 + * + * @param userId * @return */ - public Integer getRegister(String str){ + public Integer getRegisterByUserId(String userId) { return 0; } diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/GridVisitedDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/GridVisitedDao.xml index 12c9ebcfeb..222aed24ee 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/GridVisitedDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/GridVisitedDao.xml @@ -18,7 +18,7 @@ -