From a168126125641097d1de34b5eaa05e7b63adbddc Mon Sep 17 00:00:00 2001 From: wangchao Date: Thu, 19 Mar 2020 16:17:05 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E9=99=8C=E7=94=9F=E4=BA=BA?= =?UTF-8?q?=E5=AF=BC=E8=A7=88=E3=80=81=E6=94=BF=E5=BA=9C=E7=AB=AF=E7=BB=84?= =?UTF-8?q?=E7=BB=87=E4=BB=A3=E7=A0=81=E8=A7=84=E8=8C=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- epmet-module/gov-org/gov-org-client/pom.xml | 2 +- .../dto/form/ListCustomerGridFormDTO.java | 38 ++++++++++ ... => CustomerGridForStrangerResultDTO.java} | 8 +- .../controller/CustomerGridController.java | 18 +++-- .../java/com/epmet/dao/CustomerGridDao.java | 35 +++++++-- .../epmet/service/CustomerGridService.java | 10 ++- .../service/impl/CustomerGridServiceImpl.java | 33 +++------ .../main/resources/mapper/CustomerGridDao.xml | 60 +++++++++------ .../dto/form/CustomerGridListFormDTO.java | 61 +++++++++++++++ .../dto/result/CustomerGridListResultDTO.java | 26 ------- .../StrangerAccessRecordController.java | 37 ++++++---- .../entity/StrangerAccessRecordEntity.java | 9 +++ .../com/epmet/feign/GovOrgFeignClient.java | 24 +++--- .../feign/fallback/GovOrgFeignFallBack.java | 32 ++++++++ .../epmet/feign/impl/GovOrgFeginFallBack.java | 34 --------- .../service/StrangerAccessRecordService.java | 21 ++++-- .../impl/StrangerAccessRecordServiceImpl.java | 74 +++++++++++-------- 17 files changed, 333 insertions(+), 189 deletions(-) create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListCustomerGridFormDTO.java rename epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/{CustomerGridForStangerResultDTO.java => CustomerGridForStrangerResultDTO.java} (68%) create mode 100644 epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/form/CustomerGridListFormDTO.java delete mode 100644 epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/result/CustomerGridListResultDTO.java create mode 100644 epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignFallBack.java delete mode 100644 epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/impl/GovOrgFeginFallBack.java diff --git a/epmet-module/gov-org/gov-org-client/pom.xml b/epmet-module/gov-org/gov-org-client/pom.xml index e9c924f60d..59518f86e2 100644 --- a/epmet-module/gov-org/gov-org-client/pom.xml +++ b/epmet-module/gov-org/gov-org-client/pom.xml @@ -10,7 +10,7 @@ gov-org-client - + jar diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListCustomerGridFormDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListCustomerGridFormDTO.java new file mode 100644 index 0000000000..78aa62fd80 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/form/ListCustomerGridFormDTO.java @@ -0,0 +1,38 @@ +package com.epmet.dto.form;/** + * Created by 11 on 2020/3/19. + */ + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description 陌生人导览查询附近网格传参定义 + * @ClassName ListCustomerGridFormDTO + * @Author wangc + * @date 2020.03.19 15:00 + */ +@Data +public class ListCustomerGridFormDTO implements Serializable{ + + private static final long serialVersionUID = -1L; + + /** + * 地区编码(城市、区县) + * */ + @NotBlank(message = "地区码不能为空") + private String areaCode; + + /** + * 当前页 + * */ + @Min(value = 1) + private Integer pageNo; + + /** + * 每页显示数量 + * */ + private Integer pageSize = 20; +} diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridForStangerResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridForStrangerResultDTO.java similarity index 68% rename from epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridForStangerResultDTO.java rename to epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridForStrangerResultDTO.java index 2a8c4108d0..465db64595 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridForStangerResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/CustomerGridForStrangerResultDTO.java @@ -1,6 +1,4 @@ -package com.epmet.dto.result;/** - * Created by 11 on 2020/3/19. - */ +package com.epmet.dto.result; import lombok.Data; @@ -8,12 +6,12 @@ import java.io.Serializable; /** * @Description 陌生人搜索网格返回结果 - * @ClassName CustomerGridForStangerResultDTO + * @ClassName CustomerGridForStrangerResultDTO * @Author wangc * @date 2020.03.19 00:38 */ @Data -public class CustomerGridForStangerResultDTO implements Serializable { +public class CustomerGridForStrangerResultDTO implements Serializable { private static final long serialVersionUID = -1L; /** 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 8e0a07fbfd..782a2f1678 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 @@ -26,7 +26,8 @@ import com.epmet.commons.tools.validator.group.AddGroup; import com.epmet.commons.tools.validator.group.UpdateGroup; import com.epmet.commons.tools.validator.group.DefaultGroup; import com.epmet.dto.CustomerGridDTO; -import com.epmet.dto.result.CustomerGridForStangerResultDTO; +import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.excel.CustomerGridExcel; import com.epmet.service.CustomerGridService; import org.springframework.beans.factory.annotation.Autowired; @@ -93,10 +94,17 @@ public class CustomerGridController { } + /** + * @Description 陌生人导览模块调用 根据陌生揽客传入的地区码进行分页查询显示 + * @Param ListCustomerGridFormDTO + * @return Result> + * @Author wangc + * @Date 2020.03.19 15:23 + **/ + @PostMapping("queryListForStrangerByOrder") + public Result> queryListForStrangerByOrder(@RequestBody ListCustomerGridFormDTO listCustomerGridFormDTO ){ - @GetMapping("queryListForStrangerByOrder") - public Result> queryListForStrangerByOrder(@RequestParam("areaCode")String areaCode, @RequestParam("pageNo") Integer pageNo, Integer pageSize){ - - return customerGridService.ListGridForStrangerByOrder(areaCode, pageNo, pageSize); + ValidatorUtils.validateEntity(listCustomerGridFormDTO); + return customerGridService.listGridForStrangerByOrder(listCustomerGridFormDTO); } } \ No newline at end of file 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 90aaa87faa..243180f257 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 @@ -18,7 +18,7 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; -import com.epmet.dto.result.CustomerGridForStangerResultDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.entity.CustomerGridEntity; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -34,13 +34,34 @@ import java.util.List; @Mapper public interface CustomerGridDao extends BaseDao { - //查特定区的网格 - List selectGridByAreaCode(@Param("areaCode")String areaCode); - //查整个城市的网格 - List selectGridByCityLike(@Param("areaCode")String areaCode); + /** + * @Description 查特定区的网格 + * @Param areaCode + * @return CustomerGridForStrangerResultDTO + * @Author wangc + * @Date 2020.03.19 15:53 + **/ + List selectGridByAreaCode(@Param("areaCode")String areaCode); - //指定区时查询当前城市下除该区之外其余的网格 - List selectRestGridWithoutGivenAreaCode(@Param("areaCode")String areaCode , @Param("cityCode")String cityCode); + /** + * @Description 查整个城市的网格 + * @Param areaCode + * @return CustomerGridForStrangerResultDTO + * @Author wangc + * @Date 2020.03.19 15:53 + **/ + List selectGridByCityLike(@Param("areaCode")String areaCode); + + + /** + * @Description 指定区时查询当前城市下除该区之外其余的网格 + * @Param areaCode + * @Param cityCode + * @return CustomerGridForStrangerResultDTO + * @Author wangc + * @Date 2020.03.19 15:53 + **/ + List selectRestGridWithoutGivenAreaCode(@Param("areaCode")String areaCode , @Param("cityCode")String cityCode); } \ 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 fb07d7d585..4a682957c2 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 @@ -21,7 +21,8 @@ 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.CustomerGridDTO; -import com.epmet.dto.result.CustomerGridForStangerResultDTO; +import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.entity.CustomerGridEntity; import java.util.List; @@ -98,7 +99,10 @@ public interface CustomerGridService extends BaseService { /** * 陌生人查询附近网格数据 * 不管传递的areaCode是市级还是县级,都查询整个城市的网格信息,需要特定的排序 - * + * @param + * @return Result> + * @author wangc + * @date 2020-03-16 * */ - Result> ListGridForStrangerByOrder(String areaCode, Integer PageNo, Integer pageSize); + Result> listGridForStrangerByOrder(ListCustomerGridFormDTO listCustomerGridFormDTO); } \ 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 9dc2a5f126..a81e488a84 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 @@ -27,9 +27,10 @@ import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.CustomerGridDao; import com.epmet.dto.CustomerGridDTO; -import com.epmet.dto.result.CustomerGridForStangerResultDTO; +import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.entity.CustomerGridEntity; -import com.epmet.exception.ModuleErrorCode; + import com.epmet.redis.CustomerGridRedis; import com.epmet.service.CustomerGridService; import com.github.pagehelper.PageHelper; @@ -107,28 +108,18 @@ public class CustomerGridServiceImpl extends BaseServiceImpl> ListGridForStrangerByOrder(String areaCode, Integer pageNo, Integer pageSize) { + public Result> listGridForStrangerByOrder(ListCustomerGridFormDTO listCustomerGridFormDTO) { - //判断areaCode是市级还是县级 - if(StringUtils.isBlank(areaCode)){ - throw new RenException(ModuleErrorCode.ARGS_NOT_ALLOW_NULL_ERROR,"地区码不能为空!"); - } - if(areaCode.length() != 6){ - throw new RenException(ModuleErrorCode.NOT_STANDARD_AREA_CODE_ERROR,"无法识别的地区码!"); - } - if(null == pageNo){ - throw new RenException(ModuleErrorCode.ARGS_NOT_ALLOW_NULL_ERROR,"页码不能为空!"); - } - if(null == pageSize || pageSize <= 0 || pageSize >=100){ - pageSize = 20; - } + Result> result = new Result<>(); - Result> result = new Result<>(); + String areaCode = listCustomerGridFormDTO.getAreaCode(); + Integer pageNo = listCustomerGridFormDTO.getPageNo(); + Integer pageSize = listCustomerGridFormDTO.getPageSize(); if(areaCode.endsWith("00")){ //城市 - 查全部 PageHelper.startPage(pageNo,pageSize); - List gridList + List gridList = baseDao.selectGridByCityLike(areaCode.substring(0,areaCode.length()-2)); result.setData(gridList); @@ -136,11 +127,11 @@ public class CustomerGridServiceImpl extends BaseServiceImpl gridListArea + List gridListArea = baseDao.selectGridByAreaCode(areaCode); - List restGridListArea + List restGridListArea = baseDao.selectRestGridWithoutGivenAreaCode(areaCode,areaCode.substring(0,areaCode.length()-2)); - for(CustomerGridForStangerResultDTO obj : restGridListArea){ + for(CustomerGridForStrangerResultDTO obj : restGridListArea){ gridListArea.add(obj); } 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 cd1a2338f0..f38d18caeb 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 @@ -23,36 +23,52 @@ - + SELECT + id AS grid_id, + customer_id, + grid_name + FROM + CUSTOMER_GRID + WHERE + AREA_CODE = #{areaCode} + ORDER BY - customer_id, - CONVERT ( grid_name USING gbk ) ASC + customer_id, + CONVERT ( grid_name USING gbk ) ASC - + SELECT + id AS grid_id, + customer_id, + grid_name + FROM + CUSTOMER_GRID + WHERE + AREA_CODE LIKE CONCAT(#{areaCode},'%') + ORDER BY - customer_id, - CONVERT ( grid_name USING gbk ) ASC + customer_id, + CONVERT ( grid_name USING gbk ) ASC - + SELECT + id AS grid_id, + customer_id, + grid_name + FROM + CUSTOMER_GRID + WHERE + AREA_CODE LIKE CONCAT(#{cityCode},'%') + + AND #{areaCode} + ]]> ORDER BY - customer_id, - CONVERT ( grid_name USING gbk ) ASC + customer_id, + CONVERT ( grid_name USING gbk ) ASC \ No newline at end of file diff --git a/epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/form/CustomerGridListFormDTO.java b/epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/form/CustomerGridListFormDTO.java new file mode 100644 index 0000000000..93776cfa94 --- /dev/null +++ b/epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/form/CustomerGridListFormDTO.java @@ -0,0 +1,61 @@ +package com.epmet.dto.form; + +import lombok.Data; + +import javax.validation.constraints.Min; +import javax.validation.constraints.NotBlank; +import java.io.Serializable; + +/** + * @Description + * @ClassName CustomerGridListFormDTO + * @Author wangc + * @date 2020.03.19 14:19 + */ +@Data +public class CustomerGridListFormDTO implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 当前页 + * */ + @Min(value = 1) + private Integer pageNo; + + /** + * 每页数量 + * */ + private Integer pageSize = 20; + + /** + * 地区码 + * */ + private String areaCode; + + /** + * 选定地区编码 + * */ + private String selectedAreaCode; + + /** + * 是否首次位置授权(0:是 1:否) + */ + private Integer isAuthorized; + + /** + * 前端传递的省份 + * */ + @NotBlank(message = "省份信息不能为空") + private String province; + + /** + * 前端传递的城市 + * */ + @NotBlank(message = "城市信息不能为空") + private String city; + + /** + * 前端传递的地区 + * */ + private String area; +} diff --git a/epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/result/CustomerGridListResultDTO.java b/epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/result/CustomerGridListResultDTO.java deleted file mode 100644 index 0ee73173ca..0000000000 --- a/epmet-module/resi-guide/resi-guide-client/src/main/java/com/epmet/dto/result/CustomerGridListResultDTO.java +++ /dev/null @@ -1,26 +0,0 @@ -package com.epmet.dto.result;/** - * Created by 11 on 2020/3/17. - */ - -import java.io.Serializable; - -/** - * @Description - * @ClassName CustomerGridListResultDTO - * @Author wangc - * @date 2020.03.17 13:56 - */ -public class CustomerGridListResultDTO implements Serializable { - - private static final long serialVersionUID = 1L; - - //网格Id epmet_gov_org.customer_gird.id - private String gridId; - - //客户Id epmet_gov_org.customer_gird.customer_id - private String customerId; - - //网格名称 epmet_gov_org.customer_gird.grid_name - private String gridName; - -} diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerAccessRecordController.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerAccessRecordController.java index aef1f145ba..f4ed63960b 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerAccessRecordController.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/controller/StrangerAccessRecordController.java @@ -2,8 +2,8 @@ package com.epmet.controller; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; -import com.epmet.dto.CustomerGridListQueryDTO; -import com.epmet.dto.result.CustomerGridForStangerResultDTO; +import com.epmet.dto.form.CustomerGridListFormDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.service.StrangerAccessRecordService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -14,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController; import java.util.List; /** - * @Description + * @Description 陌生人导览模块 * @ClassName StrangerAccessRecordController * @Author wangc * @date 2020.03.17 11:33 @@ -28,26 +28,33 @@ public class StrangerAccessRecordController { /** - * 陌生访客授权位置获取附近网格数据 - * - * */ + * @Description 陌生访客根据自动定位获取附近网格数据 + * @Param CustomerGridListFormDTO + * @return Result> + * @Author wangc + * @Date 2020.03.19 14:13 + **/ @PostMapping("getlocationcustomergridlist") - Result> getLocationCustomerGridList(@RequestBody CustomerGridListQueryDTO customerGridListQueryDTO){ + Result> getLocationCustomerGridList(@RequestBody CustomerGridListFormDTO customerGridListFormDTO){ - ValidatorUtils.validateEntity(customerGridListQueryDTO); + ValidatorUtils.validateEntity(customerGridListFormDTO); - return new Result>().ok(strangerAccessRecordService.ListCustomerGrid(customerGridListQueryDTO)); + return strangerAccessRecordService.listCustomerGrid(customerGridListFormDTO); } + /** - * 陌生访客自动选定位置获取附近网格数据 - * - * */ + * @Description 陌生访客手动选定位置获取附近网格数据 + * @Param CustomerGridListFormDTO + * @return Result> + * @Author wangc + * @Date 2020.03.19 14:13 + **/ @PostMapping("getselectcdcustomergridlist") - Result> getSelectcdCustomerGridList(@RequestBody CustomerGridListQueryDTO customerGridListQueryDTO){ + Result> getSelectcdCustomerGridList(@RequestBody CustomerGridListFormDTO customerGridListFormDTO){ - ValidatorUtils.validateEntity(customerGridListQueryDTO); + ValidatorUtils.validateEntity(customerGridListFormDTO); - return new Result>().ok(strangerAccessRecordService.ListCustomerGrid(customerGridListQueryDTO)); + return strangerAccessRecordService.listCustomerGrid(customerGridListFormDTO); } } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/entity/StrangerAccessRecordEntity.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/entity/StrangerAccessRecordEntity.java index f707fd0b25..f9788d9b36 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/entity/StrangerAccessRecordEntity.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/entity/StrangerAccessRecordEntity.java @@ -63,10 +63,19 @@ public class StrangerAccessRecordEntity extends BaseEpmetEntity { */ private Date visitTime; + /** + * 省份 + * */ private String province; + /** + * 城市 + * */ private String city; + /** + * 地区 + * */ private String area; } diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java index fe9f1d879b..3442187ca8 100644 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/GovOrgFeignClient.java @@ -2,27 +2,25 @@ package com.epmet.feign; import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.CustomerGridListQueryDTO; -import com.epmet.dto.result.CustomerGridForStangerResultDTO; -import com.epmet.dto.result.CustomerGridListResultDTO; -import com.epmet.feign.impl.GovOrgFeginFallBack; +import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.feign.fallback.GovOrgFeignFallBack; import org.springframework.cloud.openfeign.FeignClient; -import org.springframework.http.MediaType; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestParam; import java.util.List; /** - * Feign调用gov-org-server模块 - * Created by 11 on 2020/3/17. + * @Description Feign调用gov-org-server模块下的CustomerGirdController + * @ClassName GovOrgFeginFallBack + * @Author wangc + * @date 2020.03.17 14:29 */ -@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeginFallBack.class, url="http://localhost:8092") +@FeignClient(name = ServiceConstant.GOV_ORG_SERVER, fallback = GovOrgFeignFallBack.class, url = "http://localhost:8092") public interface GovOrgFeignClient { /** @@ -31,8 +29,8 @@ public interface GovOrgFeignClient { * @Param pageNo 当前页 * @Param pageSize 每页数据量 * */ - @GetMapping("/gov/org/customergrid/queryListForStrangerByOrder") - Result> getPageForStrangerGuideInterface(@RequestParam("areaCode")String areaCode, @RequestParam("pageNo")Integer pageNo, @RequestParam("pageSize")Integer pageSize); + @PostMapping("/gov/org/customergrid/queryListForStrangerByOrder") + Result> getPageForStrangerGuideInterface(@RequestBody ListCustomerGridFormDTO listCustomerGridFormDTO); diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignFallBack.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignFallBack.java new file mode 100644 index 0000000000..0554f8be50 --- /dev/null +++ b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/fallback/GovOrgFeignFallBack.java @@ -0,0 +1,32 @@ +package com.epmet.feign.fallback; + +import com.epmet.commons.tools.constant.ServiceConstant; +import com.epmet.commons.tools.utils.ModuleUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; +import com.epmet.feign.GovOrgFeignClient; +import org.springframework.stereotype.Component; + + +import java.util.List; + +/** + * @Description Feign + * @ClassName GovOrgFeginFallBack + * @Author wangc + * @date 2020.03.17 14:29 + */ +@Component +public class GovOrgFeignFallBack implements GovOrgFeignClient { + + /** + * 根据地区编码获取附近网格数据 + * @Param ListCustomerGridFormDTO 包含:地区编码、页码、每页数据量 + * @return Result> + * */ + @Override + public Result> getPageForStrangerGuideInterface(ListCustomerGridFormDTO listCustomerGridFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "queryListForStrangerByOrder",listCustomerGridFormDTO); + } +} diff --git a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/impl/GovOrgFeginFallBack.java b/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/impl/GovOrgFeginFallBack.java deleted file mode 100644 index 2018edd626..0000000000 --- a/epmet-module/resi-guide/resi-guide-server/src/main/java/com/epmet/feign/impl/GovOrgFeginFallBack.java +++ /dev/null @@ -1,34 +0,0 @@ -package com.epmet.feign.impl;/** - * Created by 11 on 2020/3/17. - */ - -import com.epmet.commons.tools.constant.ServiceConstant; -import com.epmet.commons.tools.utils.ModuleUtils; -import com.epmet.commons.tools.utils.Result; -import com.epmet.dto.result.CustomerGridForStangerResultDTO; -import com.epmet.feign.GovOrgFeignClient; -import org.springframework.stereotype.Component; - - -import java.util.List; - -/** - * @Description - * @ClassName GovOrgFeginFallBack - * @Author wangc - * @date 2020.03.17 14:29 - */ -@Component -public class GovOrgFeginFallBack implements GovOrgFeignClient { - - /** - * 根据地区编码获取附近网格数据 - * @Param areaCode 地区编码 - * @Param pageNo 当前页 - * @Param pageSize 每页数据量 - * */ - @Override - public Result> getPageForStrangerGuideInterface(String areaCode, Integer pageNo, Integer pageSize) { - return ModuleUtils.feignConError(ServiceConstant.GOV_ORG_SERVER, "queryListForStrangerByOrder",areaCode,pageNo,pageSize); - } -} 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 956682fc98..553610ed4e 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 @@ -1,21 +1,28 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; -import com.epmet.dto.CustomerGridListQueryDTO; -import com.epmet.dto.result.CustomerGridForStangerResultDTO; +import com.epmet.commons.tools.utils.Result; +import com.epmet.dto.form.CustomerGridListFormDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.entity.StrangerAccessRecordEntity; import java.util.List; /** - * Created by 11 on 2020/3/17. + * @Description 陌生人记录访问表 + * @InterfaceName ResiGuideServiceImpl + * @Author wangc + * @date 2020.03.17 13:01 */ public interface StrangerAccessRecordService extends BaseService { /** - * - * 陌生人根据位置码获取附近网格数据,并且插入陌生人访客记录 - * */ - List ListCustomerGrid(CustomerGridListQueryDTO customerGridListQueryDTO); + * @Description 陌生人根据地区编码查询附近网格数据接口定义 + * @Param CustomerGridListFormDTO + * @return Result> + * @Author wangc + * @Date 2020.03.19 14:28 + **/ + Result> listCustomerGrid(CustomerGridListFormDTO customerGridListFormDTO); } 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 00d779cfad..aeca05bbe6 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 @@ -5,20 +5,21 @@ package com.epmet.service.impl;/** import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.StrangerAccessRecordDao; -import com.epmet.dto.CustomerGridListQueryDTO; -import com.epmet.dto.result.CustomerGridForStangerResultDTO; +import com.epmet.dto.form.CustomerGridListFormDTO; +import com.epmet.dto.form.ListCustomerGridFormDTO; +import com.epmet.dto.result.CustomerGridForStrangerResultDTO; import com.epmet.entity.StrangerAccessRecordEntity; import com.epmet.feign.GovOrgFeignClient; import com.epmet.service.StrangerAccessRecordService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.transaction.annotation.Transactional; +import java.util.ArrayList; import java.util.Date; import java.util.List; /** - * @Description + * @Description 陌生人记录访问表 * @ClassName ResiGuideServiceImpl * @Author wangc * @date 2020.03.17 13:01 @@ -29,48 +30,61 @@ public class StrangerAccessRecordServiceImpl extends BaseServiceImpl> + * @Author wangc + * @Date 2020.03.19 14:28 + **/ + @Override - public List ListCustomerGrid(CustomerGridListQueryDTO customerGridListQueryDTO) { + public Result> listCustomerGrid(CustomerGridListFormDTO customerGridListFormDTO) { + + + ListCustomerGridFormDTO listCustomerGridFormDTO = new ListCustomerGridFormDTO(); + listCustomerGridFormDTO.setAreaCode(0 == customerGridListFormDTO.getIsAuthorized() ? + customerGridListFormDTO.getSelectedAreaCode() : customerGridListFormDTO.getAreaCode()); - Result> queryResult = + listCustomerGridFormDTO.setPageNo(null == customerGridListFormDTO.getPageNo() ? 1 : customerGridListFormDTO.getPageNo()); + + listCustomerGridFormDTO.setPageSize(customerGridListFormDTO.getPageSize()); + + + Result> queryResult = govOrgFeignClient - .getPageForStrangerGuideInterface(customerGridListQueryDTO.getAreaCode(),customerGridListQueryDTO.getPageNo(),customerGridListQueryDTO.getPageSize()); - if(0 == queryResult.getCode()) { + .getPageForStrangerGuideInterface(listCustomerGridFormDTO); + //Feign调用成功 + if(queryResult.success()) { - List queryList = queryResult.getData(); + List queryList = queryResult.getData(); if (null != queryResult && queryList.size() > 0) { StrangerAccessRecordEntity strangerTrance = new StrangerAccessRecordEntity(); - //未授权,手动选择 locationAreaCode - if (0 == customerGridListQueryDTO.getIsAuthorized()) { - strangerTrance.setLocationAreaCode(customerGridListQueryDTO.getSelectedAreaCode()); - } else if (1 == customerGridListQueryDTO.getIsAuthorized()) { - //已授权,自动选择 selectedAreaCode - strangerTrance.setLocationAreaCode(customerGridListQueryDTO.getAreaCode()); + //未授权,手动选择 + if (0 == customerGridListFormDTO.getIsAuthorized()) { + strangerTrance.setSelectedAreaCode(customerGridListFormDTO.getSelectedAreaCode()); + } else if (1 == customerGridListFormDTO.getIsAuthorized()) { + //已授权,自动选择 + strangerTrance.setLocationAreaCode(customerGridListFormDTO.getAreaCode()); } - strangerTrance.setIsAuthorized(customerGridListQueryDTO.getIsAuthorized()); + strangerTrance.setIsAuthorized(customerGridListFormDTO.getIsAuthorized()); strangerTrance.setGridNumber(queryList.size()); strangerTrance.setVisitTime(new Date()); - strangerTrance.setDelFlag("1"); - strangerTrance.setRevision(0); - strangerTrance.setCreatedBy("陌生人访客"); - strangerTrance.setCreatedTime(new Date()); - strangerTrance.setProvince(customerGridListQueryDTO.getProvince()); - strangerTrance.setCity(customerGridListQueryDTO.getCity()); - strangerTrance.setArea(customerGridListQueryDTO.getArea()); + strangerTrance.setProvince(customerGridListFormDTO.getProvince()); + strangerTrance.setCity(customerGridListFormDTO.getCity()); + strangerTrance.setArea(customerGridListFormDTO.getArea()); insert(strangerTrance); - return queryList; + return new Result>().ok(queryList); } else { - - return null; + //没有查询出结果 + return new Result>().ok(new ArrayList<>()); } }else{ - return null; + //Feign调用失败 + return new Result>().error(queryResult.getCode(),queryResult.getMsg()); }