From 0f30cca68bf9cdddb2519b8e13f6de9a1f80ce1f Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Thu, 23 Dec 2021 12:22:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9C=80=E8=BF=91=E9=A2=84=E7=BA=A6=E3=80=81?= =?UTF-8?q?=E9=9C=80=E6=B1=82=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/exception/EpmetErrorCode.java | 11 ---- .../IcResiDemandDictController.java | 7 --- .../com/epmet/dao/IcResiDemandDictDao.java | 8 --- .../impl/IcResiDemandDictServiceImpl.java | 38 ++++++++++-- .../impl/IcUserDemandRecServiceImpl.java | 60 +++++++++---------- .../resources/mapper/IcResiDemandDictDao.xml | 27 --------- 6 files changed, 63 insertions(+), 88 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java index fc74ea5977..c20f195c9e 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/exception/EpmetErrorCode.java @@ -85,17 +85,6 @@ public enum EpmetErrorCode { BUILDING_NAME_EXITED(8215,"楼栋名称已存在"), DOOR_NAME_EXITED(8216,"门牌号已存在"), NEIGHBOOR_NAME_EXITED(8217,"小区名称已存在"), - //需求相关的改用EpmetException - DEMAND_NAME_EXITED(8218, "分类名称已存在"), - DEMAND_CAN_NOT_CANCEL(8219, "当前状态,不可取消"), - DEMAND_CAN_NOT_ASSIGN(8220, "当前状态,不可指派"), - DEMAND_CAN_NOT_FINISH(8221, "当前状态,不能确认服务完成"), - DEMAND_FINISHED(8222,"需求已完成"), - DEMAND_CAN_NOT_UPDATE(8223,"当前状态,不可更新需求"), - DEMAND_NOT_EXITS(8224,"需求不存在"), - DEMAND_SERVICE_NOT_EXITS(8225,"服务记录不存在"), - DEMAND_CAN_NOT_TAKE_ORDER(8226, "当前状态,不可接单"), - DEMAND_CAN_NOT_EVALUATE(8227, "当前状态,不可评价"), REQUIRE_PERMISSION(8301, "您没有足够的操作权限"), THIRD_PLAT_REQUEST_ERROR(8302, "请求第三方平台错误"), diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java index b77618376b..4bb3a8c969 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcResiDemandDictController.java @@ -21,8 +21,6 @@ import com.epmet.commons.tools.annotation.LoginUser; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.dto.form.PageFormDTO; import com.epmet.commons.tools.dto.result.OptionResultDTO; -import com.epmet.commons.tools.exception.EpmetErrorCode; -import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.Result; @@ -33,7 +31,6 @@ import com.epmet.dto.result.demand.DemandCategoryResDTO; import com.epmet.dto.result.demand.DemandPageResDTO; import com.epmet.dto.result.demand.OptionDTO; import com.epmet.service.IcResiDemandDictService; -import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -185,10 +182,6 @@ public class IcResiDemandDictController { */ @PostMapping("category-list") public Result> queryCategoryList(@LoginUser TokenDto tokenDto){ - //测试EpmetEx - if(StringUtils.isNotBlank(tokenDto.getCustomerId())){ - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "internalMsg","用户看到的msg???"); - } return new Result>().ok(icResiDemandDictService.queryCategoryList(tokenDto.getCustomerId())); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java index 29bbd8454e..73ad65dcd6 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcResiDemandDictDao.java @@ -70,14 +70,6 @@ public interface IcResiDemandDictDao extends BaseDao { IcResiDemandDictEntity selectByCode(@Param("customerId") String customerId, @Param("categoryCode") String categoryCode); - /** - * 居民端-我有需求,分类列表 - * @param customerId - * @param parentCode - * @return - */ - List queryCategoryList(@Param("customerId") String customerId, @Param("parentCode")String parentCode); - /** * 查询分类信息,限制未被禁用的 * @param customerId diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java index e8ceed48a2..0e352910c6 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcResiDemandDictServiceImpl.java @@ -17,6 +17,7 @@ package com.epmet.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; @@ -24,8 +25,10 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.OptionResultDTO; import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.dao.IcResiDemandDictDao; import com.epmet.dto.form.demand.*; @@ -80,7 +83,7 @@ public class IcResiDemandDictServiceImpl extends BaseServiceImpl NumConstant.ZERO) { // 名称唯一 - throw new RenException(EpmetErrorCode.DEMAND_NAME_EXITED.getCode(), EpmetErrorCode.DEMAND_NAME_EXITED.getMsg()); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), String.format("【%s】已存在", formDTO.getCategoryName()), "分类名称已存在"); } IcResiDemandDictEntity entity = new IcResiDemandDictEntity(); @@ -107,7 +110,7 @@ public class IcResiDemandDictServiceImpl extends BaseServiceImpl NumConstant.ZERO) { // 名称唯一 - throw new RenException(EpmetErrorCode.DEMAND_NAME_EXITED.getCode(), EpmetErrorCode.DEMAND_NAME_EXITED.getMsg()); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), String.format("【%s】已存在", formDTO.getCategoryName()), "分类名称已存在"); } IcResiDemandDictEntity entity = new IcResiDemandDictEntity(); @@ -160,7 +163,7 @@ public class IcResiDemandDictServiceImpl extends BaseServiceImpl NumConstant.ZERO) { // 名称唯一 - throw new RenException(EpmetErrorCode.DEMAND_NAME_EXITED.getCode(), EpmetErrorCode.DEMAND_NAME_EXITED.getMsg()); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), String.format("【%s】已存在", formDTO.getCategoryName()), "分类名称已存在"); } origin.setCategoryName(formDTO.getCategoryName()); if (NumConstant.TWO == origin.getLevel()) { @@ -274,7 +277,34 @@ public class IcResiDemandDictServiceImpl extends BaseServiceImpl queryCategoryList(String customerId) { - return baseDao.queryCategoryList(customerId,NumConstant.ZERO_STR); + List list=new ArrayList<>(); + LambdaQueryWrapper wrapper=new LambdaQueryWrapper(); + wrapper.eq(IcResiDemandDictEntity::getCustomerId,customerId); + wrapper.eq(IcResiDemandDictEntity::getUsableFlag,true); + wrapper.eq(IcResiDemandDictEntity::getParentCode,NumConstant.ZERO_STR); + wrapper.orderByAsc(IcResiDemandDictEntity::getSort); + List first=baseDao.selectList(wrapper); + first.forEach(dto->{ + DemandCategoryResDTO resultDto= ConvertUtils.sourceToTarget(dto,DemandCategoryResDTO.class); + resultDto.setCategoryId(dto.getId()); + + LambdaQueryWrapper query=new LambdaQueryWrapper(); + query.eq(IcResiDemandDictEntity::getCustomerId,customerId); + query.eq(IcResiDemandDictEntity::getUsableFlag,true); + query.eq(IcResiDemandDictEntity::getParentCode,dto.getCategoryCode()); + query.orderByAsc(IcResiDemandDictEntity::getSort); + List sub=baseDao.selectList(query); + + List children=new ArrayList<>(); + sub.forEach(subDto->{ + DemandCategoryResDTO subDTO= ConvertUtils.sourceToTarget(subDto,DemandCategoryResDTO.class); + subDTO.setCategoryId(subDto.getId()); + children.add(subDTO); + }); + resultDto.setChildren(children); + list.add(resultDto); + }); + return list; } /** diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java index 5856a47206..7ddc7610f9 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcUserDemandRecServiceImpl.java @@ -26,7 +26,6 @@ import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.enums.DictTypeEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; -import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; @@ -105,17 +104,17 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl gridInfoRes=govOrgOpenFeignClient.getGridBaseInfoByGridId(customerGridFormDTO); if(!gridInfoRes.success()||null==gridInfoRes.getData()){ - throw new RenException("查询网格信息失败"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),"查询网格信息失败"); } IcUserDemandRecEntity updateEntity=ConvertUtils.sourceToTarget(dto,IcUserDemandRecEntity.class); updateEntity.setAgencyId(gridInfoRes.getData().getPid()); @@ -185,7 +184,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl gridInfoRes=govOrgOpenFeignClient.getGridBaseInfoByGridId(customerGridFormDTO); if(!gridInfoRes.success()||null==gridInfoRes.getData()){ - throw new RenException("查询网格信息失败"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),"查询网格信息失败"); } IcUserDemandRecEntity insertEntity=ConvertUtils.sourceToTarget(fromDTO,IcUserDemandRecEntity.class); insertEntity.setAgencyId(gridInfoRes.getData().getPid()); @@ -237,7 +236,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl pageList(UserDemandPageFormDTO formDTO) { CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(formDTO.getCustomerId(), formDTO.getCurrentStaffId()); if (null == staffInfo) { - throw new RenException("工作人员所属组织信息查询异常"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),"工作人员所属组织信息查询异常"); } if (StringUtils.isBlank(staffInfo.getAgencyPIds())|| NumConstant.ZERO_STR.equals(staffInfo.getAgencyPIds())) { //当前用户属于根组织下的人 @@ -267,7 +266,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(new ArrayList<>(userIdList)); if(!userInfoRes.success()||CollectionUtils.isEmpty(userInfoRes.getData())){ - throw new RenException("查询志愿者信息异常"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),"查询志愿者信息异常"); } userInfoMap=userInfoRes.getData().stream().collect(Collectors.toMap(UserBaseInfoResultDTO::getUserId, UserBaseInfoResultDTO::getRealName)); } @@ -316,11 +315,11 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl resiRes = epmetUserOpenFeignClient.findEpmetUser(resiUserFormDTO); if (!resiRes.success()) { - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "查询小程序用户异常"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "查询小程序用户异常"); } if (null != resiRes.getData() && CollectionUtils.isNotEmpty(resiRes.getData().getEpmetUserIdList())) { formDTO.setEpmetUserIdList(resiRes.getData().getEpmetUserIdList()); @@ -600,7 +599,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl userRes = epmetUserOpenFeignClient.findFamilyMem(formDTO.getIcResiUserId()); if (!userRes.success() || null == userRes.getData()) { - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取居民信息接口异常"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取居民信息接口异常"); } houseMemResDTO=ConvertUtils.sourceToTarget(userRes.getData(),HouseMemResDTO.class); } @@ -668,7 +667,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl epmetUserFamilyDTOResult=epmetUserOpenFeignClient.findIcUser(findIcUserFormDTO); if (!epmetUserFamilyDTOResult.success() || null == epmetUserFamilyDTOResult.getData()) { - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "根据小程序用户id,获取ic居民信息接口异常"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据小程序用户id,获取ic居民信息接口异常"); } houseMemResDTO=ConvertUtils.sourceToTarget(epmetUserFamilyDTOResult.getData(),HouseMemResDTO.class); formDTO.setEpmetUserIdList(epmetUserFamilyDTOResult.getData().getEpmetUserIdList()); @@ -688,7 +687,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl customerAgencyDTOResult=govOrgOpenFeignClient.getAgencyById(formDTO.getOrgId()); if(!customerAgencyDTOResult.success()||null==customerAgencyDTOResult.getData()){ - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取组织信息异常govOrgOpenFeignClient.getAgencyById"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取组织信息异常govOrgOpenFeignClient.getAgencyById"); } if(NumConstant.ZERO_STR.equals(customerAgencyDTOResult.getData().getPid())){ //当前传入的组织id=客户的根组织 @@ -726,7 +725,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(new ArrayList<>(userIdList)); if(!userInfoRes.success()||CollectionUtils.isEmpty(userInfoRes.getData())){ - throw new RenException("查询志愿者信息异常"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),"查询志愿者信息异常"); } userInfoMap=userInfoRes.getData().stream().collect(Collectors.toMap(UserBaseInfoResultDTO::getUserId, UserBaseInfoResultDTO::getRealName)); } @@ -784,7 +783,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl> serviceTypeRes=adminOpenFeignClient.dictMap(DictTypeEnum.USER_DEMAND_SERVICE_TYPE.getCode()); if(!serviceTypeRes.success()||MapUtils.isEmpty(serviceTypeRes.getData())){ - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"查询服务方类型异常,请检查是否已经配置字典信息"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),"查询服务方类型异常,请检查是否已经配置字典信息"); } List legend=new ArrayList<>(); serviceTypeRes.getData().forEach((code,name)->{ @@ -800,7 +799,7 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl customerAgencyDTOResult=govOrgOpenFeignClient.getAgencyById(formDTO.getOrgId()); if(!customerAgencyDTOResult.success()||null==customerAgencyDTOResult.getData()){ - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), "获取组织信息异常govOrgOpenFeignClient.getAgencyById"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "获取组织信息异常govOrgOpenFeignClient.getAgencyById"); } if(NumConstant.ZERO_STR.equals(customerAgencyDTOResult.getData().getPid())){ //当前传入的组织id=客户的根组织 @@ -950,11 +949,11 @@ public class IcUserDemandRecServiceImpl extends BaseServiceImpl> userInfoRes = epmetUserOpenFeignClient.queryUserBaseInfo(new ArrayList<>(userIdList)); if(!userInfoRes.success()||CollectionUtils.isEmpty(userInfoRes.getData())){ - throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"查询志愿者信息异常","服务方查询异常"); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),"查询志愿者信息异常"); } userInfoMap=userInfoRes.getData().stream().collect(Collectors.toMap(UserBaseInfoResultDTO::getUserId, o -> o, (o1, o2) -> o1)); } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcResiDemandDictDao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcResiDemandDictDao.xml index 0d75fda6db..37f21845e4 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcResiDemandDictDao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcResiDemandDictDao.xml @@ -256,33 +256,6 @@ - - - - - - - - - - - - -