From ce432be4bd42bec343da76d4ed829da2bed08659 Mon Sep 17 00:00:00 2001 From: zhangyuan Date: Fri, 12 Aug 2022 17:44:49 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=96=B0=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/dao/CustomerAgencyDao.java | 8 +++ .../service/impl/IcWorkLogServiceImpl.java | 54 +++++++++++++------ .../db/migration/V0.0.43__alter_work_log.sql | 1 + .../resources/mapper/CustomerAgencyDao.xml | 14 +++++ 4 files changed, 61 insertions(+), 16 deletions(-) create mode 100644 epmet-module/gov-org/gov-org-server/src/main/resources/db/migration/V0.0.43__alter_work_log.sql diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 3059b5a1cf..b54b4a28b7 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -376,5 +376,13 @@ public interface CustomerAgencyDao extends BaseDao { CustomerAgencyEntity getAreaRootAgency(@Param("customerId") String customerId); + /** + * @Description 根据人查询所在组织 + * @Param userId + * @author zhy + * @date 2021/8/5 10:08 上午 + */ + CustomerAgencyEntity getAgencyByUserId(@Param("userId") String userId, @Param("customerId") String customerId); + } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcWorkLogServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcWorkLogServiceImpl.java index 49d3a2b73a..e5ea8300db 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcWorkLogServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcWorkLogServiceImpl.java @@ -12,6 +12,7 @@ import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.user.LoginUserUtil; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.dao.CustomerAgencyDao; import com.epmet.dao.CustomerGridDao; import com.epmet.dao.IcWorkLogDao; import com.epmet.dto.CustomerStaffDTO; @@ -19,6 +20,7 @@ import com.epmet.dto.IcWorkLogDTO; import com.epmet.dto.IcWorkLogFileDTO; import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.result.GridDetailResultDTO; +import com.epmet.entity.CustomerAgencyEntity; import com.epmet.entity.IcWorkLogEntity; import com.epmet.entity.IcWorkLogFileEntity; import com.epmet.feign.EpmetAdminOpenFeignClient; @@ -64,6 +66,9 @@ public class IcWorkLogServiceImpl extends BaseServiceImpl page(Map params) { @@ -132,14 +137,9 @@ public class IcWorkLogServiceImpl extends BaseServiceImpl + + + From 19563fee8a59d781f776c4b5c01598f000d0cdca Mon Sep 17 00:00:00 2001 From: zhangyuan Date: Mon, 15 Aug 2022 09:06:50 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=9B=9E=E6=98=BE=E7=BD=91=E6=A0=BC?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/service/impl/IcWorkLogServiceImpl.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcWorkLogServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcWorkLogServiceImpl.java index e5ea8300db..ca65ac3ba4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcWorkLogServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/IcWorkLogServiceImpl.java @@ -21,6 +21,7 @@ import com.epmet.dto.IcWorkLogFileDTO; import com.epmet.dto.form.CustomerGridFormDTO; import com.epmet.dto.result.GridDetailResultDTO; import com.epmet.entity.CustomerAgencyEntity; +import com.epmet.entity.CustomerGridEntity; import com.epmet.entity.IcWorkLogEntity; import com.epmet.entity.IcWorkLogFileEntity; import com.epmet.feign.EpmetAdminOpenFeignClient; @@ -115,6 +116,11 @@ public class IcWorkLogServiceImpl extends BaseServiceImpl params = new HashMap<>(2); params.put("logId", id); List files = icWorkLogFileService.list(params); From bb2a54bdf5d254f326d2f953593c7c34efc61522 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 16 Aug 2022 15:36:08 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E7=BC=93=E5=AD=98=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/commons/tools/redis/RedisKeys.java | 7 ++++ .../impl/CustomerStaffServiceImpl.java | 36 ++++++++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 76585fa96f..5dc667d21f 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -849,4 +849,11 @@ public class RedisKeys { public static String getServiceOrgNameKey(String customerId,String serviceOrgType,String serviceOrgId){ return rootPrefix.concat("serviceOrgName:").concat(serviceOrgType).concat(":").concat(customerId).concat(":").concat(serviceOrgId); } + + public static String getUserBaseInfoKey(String userId) { + if (StringUtils.isBlank(userId)){ + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误"); + } + return rootPrefix.concat("userId"); + } } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java index 0acbb46a51..1889fc659e 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/CustomerStaffServiceImpl.java @@ -29,6 +29,8 @@ import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.RedisKeys; +import com.epmet.commons.tools.redis.RedisUtils; import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.redis.common.bean.AgencyInfoCache; @@ -60,16 +62,16 @@ import com.epmet.service.UserService; import com.epmet.util.ModuleConstant; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.apache.ibatis.annotations.Param; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.jetbrains.annotations.Nullable; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; -import org.springframework.web.bind.annotation.RequestBody; import java.util.*; +import java.util.concurrent.ExecutorService; import java.util.stream.Collectors; /** @@ -100,6 +102,10 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl page(Map params) { @@ -739,7 +745,28 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl selectStaffBasicInfo(String userId, String customerId) { - StaffBasicInfoResultDTO resultDTO = baseDao.selectStaffBasicInfo(userId); + StaffBasicInfoResultDTO resultDTO = null; + String userBaseInfoKey = RedisKeys.getUserBaseInfoKey(userId); + resultDTO = (StaffBasicInfoResultDTO)redisUtils.get(userBaseInfoKey); + if(resultDTO == null){ + resultDTO = getStaffBasicInfoResultDTO(userId, customerId, userBaseInfoKey); + } + //启用线程去查询 并替换redis + executorService.submit(() -> { + try { + getStaffBasicInfoResultDTO(userId, customerId, userBaseInfoKey); + } catch (Exception e) { + log.error("selectStaffBasicInfo exception", e); + } + }); + + return new Result().ok(resultDTO); + } + + @Nullable + private StaffBasicInfoResultDTO getStaffBasicInfoResultDTO(String userId, String customerId, String userBaseInfoKey) { + StaffBasicInfoResultDTO resultDTO; + resultDTO = baseDao.selectStaffBasicInfo(userId); if (null != resultDTO) { resultDTO.setRoleList(baseDao.selectStaffRoles(userId, resultDTO.getCustomerId())); CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(customerId, userId); @@ -767,7 +794,8 @@ public class CustomerStaffServiceImpl extends BaseServiceImpl().ok(resultDTO); + redisUtils.set(userBaseInfoKey,resultDTO); + return resultDTO; } /** From 2b67d821dff4906ddcc76659bc819958dc16967c Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 16 Aug 2022 15:45:15 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E8=8E=B7=E5=8F=96=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E7=BC=93=E5=AD=98=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/commons/tools/redis/RedisKeys.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java index 5dc667d21f..b39bb7fa47 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/redis/RedisKeys.java @@ -854,6 +854,6 @@ public class RedisKeys { if (StringUtils.isBlank(userId)){ throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),"参数错误"); } - return rootPrefix.concat("userId"); + return rootPrefix.concat("staffbaseinfo:")+userId; } }