From a6ca2de18f549edc1e04c41a54d654adfc04bcde Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Fri, 25 Feb 2022 17:28:36 +0800 Subject: [PATCH 01/13] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E7=BB=93=E6=A1=88?= =?UTF-8?q?=E6=97=B6=E5=8F=AA=E6=9B=B4=E6=96=B0=E9=A1=B9=E7=9B=AE=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E4=B8=8E=E8=80=97=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ProjectServiceImpl.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java index e6e70e2c73..6a591d9e8d 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectServiceImpl.java @@ -453,10 +453,12 @@ public class ProjectServiceImpl extends BaseServiceImpl Date: Fri, 25 Feb 2022 17:37:22 +0800 Subject: [PATCH 02/13] =?UTF-8?q?=E9=A1=B9=E7=9B=AE=E5=8F=98=E5=8A=A8=20up?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/mq/ProjectChangedCustomListener.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java index c4c0138ad0..a096dc3307 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/mq/ProjectChangedCustomListener.java @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; import com.epmet.commons.rocketmq.constants.MQUserPropertys; import com.epmet.commons.rocketmq.messages.DisputeProcessMQMsg; import com.epmet.commons.rocketmq.messages.ProjectChangedMQMsg; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.exception.ExceptionUtils; import com.epmet.commons.tools.exception.RenException; @@ -111,12 +112,19 @@ public class ProjectChangedCustomListener implements MessageListenerConcurrently String customerId = msgObj.getCustomerId(); distributedLock = SpringContextUtils.getBean(DistributedLock.class); lock = distributedLock.getLock(String.format("lock:project_changed:%s:%s", customerId, msgObj.getProjectId()) - ,30L, 30L, TimeUnit.SECONDS); + ,60L, 60L, TimeUnit.SECONDS); if (StringUtils.isBlank(customerId)){ logger.error("consumer project_changed fail,msg:{}",customerId); return; } + //睡一秒 要不然那边执行不完 + try { + Thread.sleep(NumConstant.ONE_THOUSAND); + } catch (InterruptedException e) { + log.error("consumeMessage exception",e); + } + ExtractOriginFormDTO extractOriginFormDTO = new ExtractOriginFormDTO(); extractOriginFormDTO.setCustomerId(customerId); From 781c3d93bea5c93d2b6766d843e3655856b18123 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Fri, 25 Feb 2022 17:56:53 +0800 Subject: [PATCH 03/13] =?UTF-8?q?=E8=AE=AE=E9=A2=98=E8=BD=AC=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E5=8A=A0=E5=88=86=E5=B8=83=E5=BC=8F=E9=94=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/IssueManageController.java | 3 +- .../java/com/epmet/service/IssueService.java | 3 +- .../epmet/service/impl/IssueServiceImpl.java | 231 ++++++++++-------- 3 files changed, 126 insertions(+), 111 deletions(-) diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java index b11a2e960b..1c522d1afb 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java @@ -182,8 +182,7 @@ public class IssueManageController { public Result shiftProjectV2(@LoginUser TokenDto tokenDTO, @RequestBody ShiftProjectFormDTO formDTO) { formDTO.setStaffId(tokenDTO.getUserId()); ValidatorUtils.validateEntity(formDTO); - issueService.shiftProjectV2(formDTO); - return new Result(); + return issueService.shiftProjectV2(formDTO); } /** diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java index 4eca209b95..01e16471da 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java @@ -3,6 +3,7 @@ package com.epmet.service; import com.epmet.commons.mybatis.service.BaseService; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.Result; import com.epmet.dto.IssueDTO; import com.epmet.dto.form.*; import com.epmet.dto.result.*; @@ -219,7 +220,7 @@ public interface IssueService extends BaseService { * @param formDTO * @return void */ - void shiftProjectV2(ShiftProjectFormDTO formDTO); + Result shiftProjectV2(ShiftProjectFormDTO formDTO); /** * @Description 已关闭列表 政府端 diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java index a8c3188586..cebca254d9 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java @@ -9,7 +9,9 @@ import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; 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.distributedlock.DistributedLock; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; +import com.epmet.commons.tools.enums.AchievementTypeEnum; import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; @@ -41,7 +43,6 @@ import com.epmet.entity.IssueEntity; import com.epmet.entity.IssueProcessEntity; import com.epmet.entity.IssueProjectRelationEntity; import com.epmet.feign.*; -import com.epmet.commons.tools.enums.AchievementTypeEnum; import com.epmet.redis.GovIssueRedis; import com.epmet.redis.IssueVoteDetailRedis; import com.epmet.resi.group.dto.group.form.AllIssueFormDTO; @@ -62,6 +63,7 @@ import com.epmet.utils.ModuleConstants; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; import org.apache.commons.collections4.CollectionUtils; +import org.redisson.api.RLock; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -136,6 +138,8 @@ public class IssueServiceImpl extends BaseServiceImpl imp private GovProjectOpenFeignClient govProjectOpenFeignClient; @Autowired private IssueVoteDetailService issueVoteDetailService; + @Autowired + private DistributedLock distributedLock; @Value("${openapi.scan.server.url}") @@ -957,127 +961,138 @@ public class IssueServiceImpl extends BaseServiceImpl imp * @date 2020/12/9 10:01 */ @Override - public void shiftProjectV2(ShiftProjectFormDTO formDTO) { - //1:查询议题数据 - IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); - if (null == entity) { - throw new RenException(IssueConstant.SELECT_EXCEPTION); - } - if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) { - throw new RenException(IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION); - } - if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) { - throw new RenException(IssueConstant.ISSUE_VOTING_EXCEPTION); - } - formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class)); + public Result shiftProjectV2(ShiftProjectFormDTO formDTO) { + RLock lock = null; + try { + // 锁持有10分钟,等待10s + lock = distributedLock.tryLock(formDTO.getIssueId()); + //1:查询议题数据 + IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); + if (null == entity) { + throw new RenException(IssueConstant.SELECT_EXCEPTION); + } + if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) { + throw new RenException(IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION); + } + if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) { + throw new RenException(IssueConstant.ISSUE_VOTING_EXCEPTION); + } + formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class)); - //获取议题分类 - List categoryList = issueCategoryService.getCategoryByIssue(formDTO.getIssueId()); - if (CollectionUtils.isEmpty(categoryList)) { - throw new RenException(EpmetErrorCode.CATEGORY_IS_NULL.getCode()); - } + //获取议题分类 + List categoryList = issueCategoryService.getCategoryByIssue(formDTO.getIssueId()); + if (CollectionUtils.isEmpty(categoryList)) { + throw new RenException(EpmetErrorCode.CATEGORY_IS_NULL.getCode()); + } - //公开回复内容审核 - if (StringUtils.isNotBlank(formDTO.getPublicReply())) { - TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); - TextTaskDTO taskDTO = new TextTaskDTO(); - taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); - taskDTO.setContent(formDTO.getPublicReply()); - textScanParamDTO.getTasks().add(taskDTO); - Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); - if (!textSyncScanResult.success()) { - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); - } else { - if (!textSyncScanResult.getData().isAllPass()) { - throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); + //公开回复内容审核 + if (StringUtils.isNotBlank(formDTO.getPublicReply())) { + TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); + TextTaskDTO taskDTO = new TextTaskDTO(); + taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); + taskDTO.setContent(formDTO.getPublicReply()); + textScanParamDTO.getTasks().add(taskDTO); + Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); + if (!textSyncScanResult.success()) { + throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + } else { + if (!textSyncScanResult.getData().isAllPass()) { + throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); + } } } - } - - //因需要保证议题表中的转项目时间与创建项目时间一致 因此先新增项目数据再更新议题数据 - - //2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用 - Result resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId()); - if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) { - throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION); - } - ResiTopicDTO topicDTO = resultTopicDTO.getData(); - formDTO.setTopicDTO(topicDTO); - //3:调用gov-project服务,新增项目各业务表初始数据 - formDTO.setCategoryList(categoryList); - List tagList = issueTagsService.getTagsByIssue(formDTO.getIssueId()); - formDTO.setTagList(tagList); - Result resultDTO = govProjectFeignClient.issueShiftProject(formDTO); - if (!resultDTO.success() || null == resultDTO.getData()) { - logger.error(resultDTO.getInternalMsg()); - throw new RenException(IssueConstant.GOV_PRJECT_EXCEPTION); - } - IssueProjectResultDTO issueProjectResultDTO = resultDTO.getData(); - //更新项目对标签的引用次数 - if (CollectionUtils.isNotEmpty(tagList)) { - tagList.forEach(item -> { - IssueProjectTagDictDTO tag = issueProjectTagDictService.get(item.getTagId()); - tag.setProjectUseCount(tag.getProjectUseCount() + NumConstant.ONE); - issueProjectTagDictService.update(tag); - }); - } + //因需要保证议题表中的转项目时间与创建项目时间一致 因此先新增项目数据再更新议题数据 - //4:更新议题相关业务表数据 - //4.1:更新议题表数据 - entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); - entity.setShiftedTime(issueProjectResultDTO.getShiftedTime()); - baseDao.updateById(entity); + //2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用 + Result resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId()); + if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) { + throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION); + } + ResiTopicDTO topicDTO = resultTopicDTO.getData(); + formDTO.setTopicDTO(topicDTO); + + //3:调用gov-project服务,新增项目各业务表初始数据 + formDTO.setCategoryList(categoryList); + List tagList = issueTagsService.getTagsByIssue(formDTO.getIssueId()); + formDTO.setTagList(tagList); + Result resultDTO = govProjectFeignClient.issueShiftProject(formDTO); + if (!resultDTO.success() || null == resultDTO.getData()) { + logger.error(resultDTO.getInternalMsg()); + throw new RenException(IssueConstant.GOV_PRJECT_EXCEPTION); + } + IssueProjectResultDTO issueProjectResultDTO = resultDTO.getData(); + //更新项目对标签的引用次数 + if (CollectionUtils.isNotEmpty(tagList)) { + tagList.forEach(item -> { + IssueProjectTagDictDTO tag = issueProjectTagDictService.get(item.getTagId()); + tag.setProjectUseCount(tag.getProjectUseCount() + NumConstant.ONE); + issueProjectTagDictService.update(tag); + }); + } - //4.2:议题处理进展表新增数据 - IssueProcessEntity processEntity = new IssueProcessEntity(); - processEntity.setIssueId(entity.getId()); - processEntity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); - processEntity.setOrgType(IssueConstant.ISSUE_GRID); - processEntity.setOrgId(entity.getGridId()); - processEntity.setOrgName(issueProjectResultDTO.getOrgName()); - issueProcessDao.insert(processEntity); + //4:更新议题相关业务表数据 + //4.1:更新议题表数据 + entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); + entity.setShiftedTime(issueProjectResultDTO.getShiftedTime()); + baseDao.updateById(entity); + + //4.2:议题处理进展表新增数据 + IssueProcessEntity processEntity = new IssueProcessEntity(); + processEntity.setIssueId(entity.getId()); + processEntity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); + processEntity.setOrgType(IssueConstant.ISSUE_GRID); + processEntity.setOrgId(entity.getGridId()); + processEntity.setOrgName(issueProjectResultDTO.getOrgName()); + issueProcessDao.insert(processEntity); + + //4.3:议题项目关系表新增数据 + IssueProjectRelationEntity relationEntity = new IssueProjectRelationEntity(); + relationEntity.setIssueId(entity.getId()); + relationEntity.setProjectId(issueProjectResultDTO.getProjectId()); + issueProjectRelationDao.insert(relationEntity); + + //5:调用epmet-message服务,给居民端话题创建人、议题发起人以及政府端工作人员发送消息 + if (!shiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { + throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION); + } + //5-1:2020.10.26 添加给居民端话题创建人、议题发起人以及政府端工作人员推送微信订阅消息功能 sun + if (!wxmpShiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { + logger.error("议题转项目,推送微信订阅消息失败!"); + } - //4.3:议题项目关系表新增数据 - IssueProjectRelationEntity relationEntity = new IssueProjectRelationEntity(); - relationEntity.setIssueId(entity.getId()); - relationEntity.setProjectId(issueProjectResultDTO.getProjectId()); - issueProjectRelationDao.insert(relationEntity); + //6:缓存中网格下表决中的议题总数减1 + govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId()); + try{ + issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null); + }catch(RenException e){ + logger.error(e.getInternalMsg()); + } - //5:调用epmet-message服务,给居民端话题创建人、议题发起人以及政府端工作人员发送消息 - if (!shiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { - throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION); - } - //5-1:2020.10.26 添加给居民端话题创建人、议题发起人以及政府端工作人员推送微信订阅消息功能 sun - if (!wxmpShiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { - logger.error("议题转项目,推送微信订阅消息失败!"); - } - //6:缓存中网格下表决中的议题总数减1 - govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId()); - try{ - issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null); - }catch(RenException e){ - logger.error(e.getInternalMsg()); - } + //7:发送话题转议题积分事件 + TopicEventFormDTO eventParam = new TopicEventFormDTO(); + eventParam.setTopicId(entity.getSourceId()); + eventParam.setEvent(EventEnum.TOPIC_SHIFTED_TO_PROJECT); + if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){ + logger.warn("com.epmet.service.impl.IssueServiceImpl.shiftProjectV2,话题被转为项目积分事件发送失败,参数:{}", JSON.toJSONString(formDTO)); + } + // 8.数据库更新表决统计 + SelectIssueVotingDetailFormDTO dto = new SelectIssueVotingDetailFormDTO(); + dto.setGridId(entity.getGridId()); + dto.setIssueId(formDTO.getIssueId()); + issueVoteDetailService.updateVote(dto); - //7:发送话题转议题积分事件 - TopicEventFormDTO eventParam = new TopicEventFormDTO(); - eventParam.setTopicId(entity.getSourceId()); - eventParam.setEvent(EventEnum.TOPIC_SHIFTED_TO_PROJECT); - if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){ - logger.warn("com.epmet.service.impl.IssueServiceImpl.shiftProjectV2,话题被转为项目积分事件发送失败,参数:{}", JSON.toJSONString(formDTO)); + //8.记录日志 + //SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg(); + return new Result(); + } catch (Exception e) { + return new Result().error("议题数据正在处理中,请勿重复提交!"); + } finally { + distributedLock.unLock(lock); } - // 8.数据库更新表决统计 - SelectIssueVotingDetailFormDTO dto = new SelectIssueVotingDetailFormDTO(); - dto.setGridId(entity.getGridId()); - dto.setIssueId(formDTO.getIssueId()); - issueVoteDetailService.updateVote(dto); - - //8.记录日志 - //SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg(); } /** From 73ff7a02e6fa28586dcdde625c99da35c053031f Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Mon, 28 Feb 2022 11:50:57 +0800 Subject: [PATCH 04/13] =?UTF-8?q?=E8=AE=AE=E9=A2=98=E8=BD=AC=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=20=E5=88=86=E5=B8=83=E5=BC=8F=E9=94=81=20=E4=BB=A3?= =?UTF-8?q?=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/dto/form/ShiftProjectFormDTO.java | 4 ++++ .../controller/IssueManageController.java | 1 + .../epmet/service/impl/IssueServiceImpl.java | 24 +++++++++---------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java index b44cdb4acd..adb4ed7409 100644 --- a/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java +++ b/epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java @@ -52,6 +52,10 @@ public class ShiftProjectFormDTO implements Serializable { * 议题标签 */ private List tagList; + /** + * token中客户Id + */ + private String customerId; } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java index 1c522d1afb..a77e531b26 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java @@ -181,6 +181,7 @@ public class IssueManageController { @PostMapping("shiftproject-v2") public Result shiftProjectV2(@LoginUser TokenDto tokenDTO, @RequestBody ShiftProjectFormDTO formDTO) { formDTO.setStaffId(tokenDTO.getUserId()); + formDTO.setCustomerId(tokenDTO.getCustomerId()); ValidatorUtils.validateEntity(formDTO); return issueService.shiftProjectV2(formDTO); } diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java index cebca254d9..379eaf6444 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java @@ -964,25 +964,25 @@ public class IssueServiceImpl extends BaseServiceImpl imp public Result shiftProjectV2(ShiftProjectFormDTO formDTO) { RLock lock = null; try { - // 锁持有10分钟,等待10s - lock = distributedLock.tryLock(formDTO.getIssueId()); + //获取锁,判断当前议题是否已处理 + lock = distributedLock.tryLock(formDTO.getCustomerId() + formDTO.getIssueId()); //1:查询议题数据 IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); if (null == entity) { - throw new RenException(IssueConstant.SELECT_EXCEPTION); + throw new EpmetException(9999,IssueConstant.SELECT_EXCEPTION,IssueConstant.SELECT_EXCEPTION); } if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) { - throw new RenException(IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION); + throw new EpmetException(9999,IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION,IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION); } if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) { - throw new RenException(IssueConstant.ISSUE_VOTING_EXCEPTION); + throw new EpmetException(9999,IssueConstant.ISSUE_VOTING_EXCEPTION,IssueConstant.ISSUE_VOTING_EXCEPTION); } formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class)); //获取议题分类 List categoryList = issueCategoryService.getCategoryByIssue(formDTO.getIssueId()); if (CollectionUtils.isEmpty(categoryList)) { - throw new RenException(EpmetErrorCode.CATEGORY_IS_NULL.getCode()); + throw new EpmetException(EpmetErrorCode.CATEGORY_IS_NULL.getCode(),EpmetErrorCode.CATEGORY_IS_NULL.getMsg(),EpmetErrorCode.CATEGORY_IS_NULL.getMsg()); } //公开回复内容审核 @@ -994,10 +994,10 @@ public class IssueServiceImpl extends BaseServiceImpl imp textScanParamDTO.getTasks().add(taskDTO); Result textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); if (!textSyncScanResult.success()) { - throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode()); + throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(),EpmetErrorCode.SERVER_ERROR.getMsg(),EpmetErrorCode.SERVER_ERROR.getMsg()); } else { if (!textSyncScanResult.getData().isAllPass()) { - throw new RenException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode()); + throw new EpmetException(EpmetErrorCode.TEXT_SCAN_FAILED.getCode(),EpmetErrorCode.TEXT_SCAN_FAILED.getMsg(),EpmetErrorCode.TEXT_SCAN_FAILED.getMsg()); } } } @@ -1007,7 +1007,7 @@ public class IssueServiceImpl extends BaseServiceImpl imp //2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用 Result resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId()); if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) { - throw new RenException(IssueConstant.SELECT_TOPIC_EXCEPTION); + throw new EpmetException(9999,IssueConstant.SELECT_TOPIC_EXCEPTION,IssueConstant.SELECT_TOPIC_EXCEPTION); } ResiTopicDTO topicDTO = resultTopicDTO.getData(); formDTO.setTopicDTO(topicDTO); @@ -1019,7 +1019,7 @@ public class IssueServiceImpl extends BaseServiceImpl imp Result resultDTO = govProjectFeignClient.issueShiftProject(formDTO); if (!resultDTO.success() || null == resultDTO.getData()) { logger.error(resultDTO.getInternalMsg()); - throw new RenException(IssueConstant.GOV_PRJECT_EXCEPTION); + throw new EpmetException(9999,IssueConstant.GOV_PRJECT_EXCEPTION,IssueConstant.GOV_PRJECT_EXCEPTION); } IssueProjectResultDTO issueProjectResultDTO = resultDTO.getData(); //更新项目对标签的引用次数 @@ -1054,7 +1054,7 @@ public class IssueServiceImpl extends BaseServiceImpl imp //5:调用epmet-message服务,给居民端话题创建人、议题发起人以及政府端工作人员发送消息 if (!shiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { - throw new RenException(IssueConstant.SAVE_MSG_EXCEPTION); + throw new EpmetException(9999,IssueConstant.SAVE_MSG_EXCEPTION,IssueConstant.SAVE_MSG_EXCEPTION); } //5-1:2020.10.26 添加给居民端话题创建人、议题发起人以及政府端工作人员推送微信订阅消息功能 sun if (!wxmpShiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { @@ -1088,7 +1088,7 @@ public class IssueServiceImpl extends BaseServiceImpl imp //SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg(); return new Result(); } catch (Exception e) { - return new Result().error("议题数据正在处理中,请勿重复提交!"); + return new Result().error(e.getMessage()); } finally { distributedLock.unLock(lock); } From 162bbf97dafa83aec7e100ea73bab72809ebc67b Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 28 Feb 2022 15:34:39 +0800 Subject: [PATCH 05/13] =?UTF-8?q?=E6=8C=87=E6=A0=87=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E8=B0=83=E6=95=B4=20=E6=9A=82=E6=9C=AA=E5=8F=91=E7=8E=B0?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E8=AE=A1=E7=AE=97=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../external/IndexCalculateController.java | 57 +++++++++++-------- .../indexcal/IndexCalculateService.java | 5 ++ .../impl/IndexCalculateServiceImpl.java | 33 ++++++----- .../service/impl/ExternalAppServiceImpl.java | 3 +- .../main/resources/mapper/ExternalAppDao.xml | 4 +- .../epmet/service/impl/IssueServiceImpl.java | 12 ++-- 6 files changed, 67 insertions(+), 47 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java index 29267ca44e..247dc31d7f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java @@ -1,5 +1,6 @@ package com.epmet.controller.external; +import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.redis.RedisKeys; @@ -40,7 +41,7 @@ import java.util.concurrent.*; @RequestMapping("indexcalculate") public class IndexCalculateController { ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("indexcalculate-pool-%d").build(); + .setNameFormat("manual_execute_indexcal-pool-%d").build(); ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); @@ -68,7 +69,7 @@ public class IndexCalculateController { CalculateFlagModel flag = (CalculateFlagModel) redisUtils.get(RedisKeys.getCustomerStatsCalFlag(customerId)); flag.setStatus(CalculateStatus.PENDDING); redisUtils.set(RedisKeys.getCustomerStatsCalFlag(customerId), flag); - log.info("客户【%s】正在执行计算,实例发生重启,修改计算状态为:calculation->pendding", customerId); + log.error("客户【%s】正在执行计算,实例发生重启,修改计算状态为:calculation->pendding", customerId); }); } @@ -97,7 +98,7 @@ public class IndexCalculateController { } /** - * 按照客户计算所有指标(按照月份) + * 这个是外部客户主动调用的方法入口 按照客户计算所有指标(按照月份) * * @param formDTO * @return com.epmet.commons.tools.utils.Result @@ -112,6 +113,35 @@ public class IndexCalculateController { return new Result().ok(true); } + @PostMapping("calSingle") + public Result calculateSingle(@RequestBody CalculateCommonFormDTO formDTO) { + long start = System.currentTimeMillis(); + try { + ValidatorUtils.validateEntity(formDTO); + Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); + HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); + if (aBoolean) { + return new Result().ok(true); + } + } catch (Exception e) { + return new Result().error(e.getMessage()); + } + return new Result().error("指标计算失败"); + } + + /** + * desc:异步 连续计算[指定或所有内部客户][多个月份]的指标得分入口 适用于公式调整后或之前计算错误 统一计算 + * @param formDTO + * @return + * @remark:不要轻易调用 因为异步 怕有冲突 + */ + @PostMapping("warn/moreStats") + public Result indexStatistics(@RequestBody IndexStatisticsFormDTO formDTO){ + log.error("moreStats 不要轻易调用 因为异步 怕有冲突,参数:{}", JSON.toJSONString(formDTO)); + indexCalculateService.indexStatistics(formDTO); + return new Result(); + } + /** * 指标计算 * @@ -202,21 +232,6 @@ public class IndexCalculateController { return new Result(); } - @PostMapping("reAll") - public Result calculateAll(@RequestBody CalculateCommonFormDTO formDTO) { - long start = System.currentTimeMillis(); - try { - Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); - HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); - if (aBoolean) { - return new Result().ok(true); - } - } catch (Exception e) { - return new Result().error(e.getMessage()); - } - return new Result().error("指标计算失败"); - } - /** * desc:计算党员指标分数 * @@ -343,12 +358,6 @@ public class IndexCalculateController { return new Result(); }*/ - @PostMapping("indexstatistics") - public Result indexStatistics(@RequestBody IndexStatisticsFormDTO formDTO){ - indexCalculateService.indexStatistics(formDTO); - return new Result(); - } - /** * @return com.epmet.commons.tools.utils.Result * @param formDTO diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java index d5d41e48a3..cabc852377 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java @@ -19,6 +19,11 @@ public interface IndexCalculateService { */ Boolean indexCalculate(CalculateCommonFormDTO formDTO); + /** + * desc:异步 连续计算[指定或所有内部客户][多个月份]的指标得分入口 + * @param formDTO + * @return + */ Boolean indexStatistics(IndexStatisticsFormDTO formDTO); /** diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java index d1e449b4a0..b2d3c0b9d7 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java @@ -1,7 +1,9 @@ package com.epmet.service.evaluationindex.indexcal.impl; +import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSON; import com.epmet.commons.dynamic.datasource.annotation.DataSource; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.DateUtils; @@ -17,16 +19,16 @@ import com.epmet.redis.IndexCalRedis; import com.epmet.service.crm.CustomerRelationService; import com.epmet.service.evaluationindex.indexcal.*; import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; +import com.epmet.service.stats.DimCustomerService; import com.epmet.util.DimIdGenerator; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.scheduling.annotation.Async; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; +import java.util.*; /** * @author liujianjun @@ -58,6 +60,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { private ScreenCustomerAgencyDao screenCustomerAgencyDao; @Autowired private CustomerRelationService customerRelationService; + @Autowired + private DimCustomerService dimCustomerService; @Override public Boolean indexCalculate(CalculateCommonFormDTO formDTO) { @@ -67,14 +71,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1))); } //按照客户分组 - List customerIds = new ArrayList<>(); + Set customerIds = new HashSet<>(); if (StringUtils.isBlank(formDTO.getCustomerId())) { + log.error("什么情况下走的这个方法,应该干掉他,因为...=====param:{}",JSON.toJSONString(formDTO)); Result> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds(); if (!externalCustomerIdsResult.success()) { log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail"); return false; } - customerIds = externalCustomerIdsResult.getData(); + customerIds.addAll(externalCustomerIdsResult.getData()); } else { customerIds.add(formDTO.getCustomerId()); } @@ -95,8 +100,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { } return flag; } catch (Exception e) { - e.printStackTrace(); - log.warn("indexCalculate exception:{}",e); + log.warn("indexCalculate late exception",e); log.error("indexCalculate exception,param:{}", JSON.toJSONString(formDTO)); } finally { //清除缓存 @@ -212,12 +216,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService { public Boolean indexStatistics(IndexStatisticsFormDTO formDTO) { List customerIds = new ArrayList<>(); if (StringUtils.isEmpty(formDTO.getCustomerId())){ - Result> externalCustomerIds = epmetCommonServiceOpenFeignClient.getExternalCustomerIds(); - if (!externalCustomerIds.success()){ - log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail"); - return false; - } - customerIds = externalCustomerIds.getData(); + int pageNo = NumConstant.ONE; + int pageSize = NumConstant.ONE_HUNDRED; + List customerIdList = null; + do { + customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); + if (!CollectionUtils.isEmpty(customerIdList)){ + customerIds.addAll(customerIdList); + } + } while (!CollectionUtil.isEmpty(customerIdList) && customerIdList.size() == pageSize); }else { customerIds.add(formDTO.getCustomerId()); } diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java index 12f84f3456..b6dcf98dcf 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java +++ b/epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java @@ -187,7 +187,6 @@ public class ExternalAppServiceImpl implements ExternalAppService { @Override public List getCustomerIds() { - return externalAppDao.getCustomerIds(); } @@ -224,4 +223,4 @@ public class ExternalAppServiceImpl implements ExternalAppService { return appIdInfoResultDTO; } -} \ No newline at end of file +} diff --git a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml index fbc74db7ff..8f401cb0f5 100644 --- a/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml +++ b/epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml @@ -66,7 +66,7 @@ @@ -84,4 +84,4 @@ - \ No newline at end of file + diff --git a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java index 379eaf6444..70e8528491 100644 --- a/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java +++ b/epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java @@ -969,13 +969,13 @@ public class IssueServiceImpl extends BaseServiceImpl imp //1:查询议题数据 IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); if (null == entity) { - throw new EpmetException(9999,IssueConstant.SELECT_EXCEPTION,IssueConstant.SELECT_EXCEPTION); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SELECT_EXCEPTION,IssueConstant.SELECT_EXCEPTION); } if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) { - throw new EpmetException(9999,IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION,IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION,IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION); } if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) { - throw new EpmetException(9999,IssueConstant.ISSUE_VOTING_EXCEPTION,IssueConstant.ISSUE_VOTING_EXCEPTION); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.ISSUE_VOTING_EXCEPTION,IssueConstant.ISSUE_VOTING_EXCEPTION); } formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class)); @@ -1007,7 +1007,7 @@ public class IssueServiceImpl extends BaseServiceImpl imp //2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用 Result resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId()); if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) { - throw new EpmetException(9999,IssueConstant.SELECT_TOPIC_EXCEPTION,IssueConstant.SELECT_TOPIC_EXCEPTION); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SELECT_TOPIC_EXCEPTION,IssueConstant.SELECT_TOPIC_EXCEPTION); } ResiTopicDTO topicDTO = resultTopicDTO.getData(); formDTO.setTopicDTO(topicDTO); @@ -1019,7 +1019,7 @@ public class IssueServiceImpl extends BaseServiceImpl imp Result resultDTO = govProjectFeignClient.issueShiftProject(formDTO); if (!resultDTO.success() || null == resultDTO.getData()) { logger.error(resultDTO.getInternalMsg()); - throw new EpmetException(9999,IssueConstant.GOV_PRJECT_EXCEPTION,IssueConstant.GOV_PRJECT_EXCEPTION); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.GOV_PRJECT_EXCEPTION,IssueConstant.GOV_PRJECT_EXCEPTION); } IssueProjectResultDTO issueProjectResultDTO = resultDTO.getData(); //更新项目对标签的引用次数 @@ -1054,7 +1054,7 @@ public class IssueServiceImpl extends BaseServiceImpl imp //5:调用epmet-message服务,给居民端话题创建人、议题发起人以及政府端工作人员发送消息 if (!shiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { - throw new EpmetException(9999,IssueConstant.SAVE_MSG_EXCEPTION,IssueConstant.SAVE_MSG_EXCEPTION); + throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SAVE_MSG_EXCEPTION,IssueConstant.SAVE_MSG_EXCEPTION); } //5-1:2020.10.26 添加给居民端话题创建人、议题发起人以及政府端工作人员推送微信订阅消息功能 sun if (!wxmpShiftProjectMessage(issueProjectResultDTO, formDTO, entity).success()) { From 989e2ea8264abbdee7a3597c4b879e0bc50c59f0 Mon Sep 17 00:00:00 2001 From: sunyuchao Date: Mon, 28 Feb 2022 17:17:31 +0800 Subject: [PATCH 06/13] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E5=AF=B9=E5=BA=94=E7=9A=84=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E4=BA=BA=E5=91=98=E8=A7=92=E8=89=B2=E8=A1=A8=E7=9A=84orgId?= =?UTF-8?q?=E6=B0=B8=E8=BF=9C=E9=83=BD=E6=98=AF=E7=BB=84=E7=BB=87Id?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/com/epmet/service/impl/StaffServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java index b70354aceb..c6013c1332 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/StaffServiceImpl.java @@ -519,7 +519,7 @@ public class StaffServiceImpl implements StaffService { //2.调用user服务,新增用户信息 StaffSubmitFromDTO submitDTO = ConvertUtils.sourceToTarget(fromDTO, StaffSubmitFromDTO.class); - submitDTO.setAgencyId(fromDTO.getOrgId()); + submitDTO.setAgencyId(orgDTO.getAgencyId()); Result result = epmetUserFeignClient.addStaff(submitDTO); if (!result.success()) { if (result.getCode() != EpmetErrorCode.SERVER_ERROR.getCode()) { From 3e770e9a15e1106b1aadcb378b61033950064c08 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Tue, 1 Mar 2022 09:53:11 +0800 Subject: [PATCH 07/13] =?UTF-8?q?=E6=8E=92=E9=99=A4=E6=8A=A5=E4=BA=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/ProjectSatisfactionStatisticsServiceImpl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectSatisfactionStatisticsServiceImpl.java b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectSatisfactionStatisticsServiceImpl.java index f3925108f3..ec8d517c96 100644 --- a/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectSatisfactionStatisticsServiceImpl.java +++ b/epmet-module/gov-project/gov-project-server/src/main/java/com/epmet/service/impl/ProjectSatisfactionStatisticsServiceImpl.java @@ -140,8 +140,8 @@ public class ProjectSatisfactionStatisticsServiceImpl extends BaseServiceImpl Date: Tue, 1 Mar 2022 11:12:06 +0800 Subject: [PATCH 08/13] =?UTF-8?q?=E6=8C=87=E6=A0=87=E8=AE=A1=E7=AE=97?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E8=B0=83=E7=94=A8=20=E6=8C=AA=E5=88=B0?= =?UTF-8?q?=E5=8E=9F=E5=A7=8B=E6=95=B0=E6=8D=AE=E6=8A=BD=E5=8F=96=E5=AE=8C?= =?UTF-8?q?=E5=90=8E=E8=AE=A1=E7=AE=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/IndexOriginExtractServiceImpl.java | 102 +++++++++++------- .../impl/ScreenExtractServiceImpl.java | 14 --- 2 files changed, 63 insertions(+), 53 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java index 783b11feeb..20c44c46cf 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java @@ -4,11 +4,14 @@ import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSON; import com.epmet.commons.tools.constant.CustomerIdConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.enums.EnvEnum; +import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dto.extract.form.ExtractIndexFormDTO; +import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.service.evaluationindex.extract.dataToIndex.*; +import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; import com.epmet.service.stats.DimCustomerService; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -18,7 +21,8 @@ import org.springframework.util.CollectionUtils; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; /** * desc:指标原始数据抽取服务实现类 @@ -26,12 +30,13 @@ import java.util.concurrent.*; @Slf4j @Service public class IndexOriginExtractServiceImpl implements IndexOriginExtractService { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("indexOriginExtract-pool-%d").build(); + /*ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() + .setNameFormat("indexOriginExtractAndCal-pool-%d").build(); ExecutorService threadPool = new ThreadPoolExecutor(1, 1, 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); - + new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());*/ + @Autowired + private ExecutorService executorService; @Autowired private CalCpcIndexService calCpcIndexService; @Autowired @@ -45,7 +50,10 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService @Autowired private IndexCollDistrictService indexCollDistrictService; @Autowired - private IndexCollDistrictDepartmentService indexCollDistrictDepartmentService; + private IndexCollDistrictDepartmentService indexCollDistrictDepartmentService; + @Autowired + private IndexCalculateService indexCalculateService; + /** * desc:从统计库对象抽取指标数据 * @@ -56,7 +64,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService String monthId = formDTO.getMonthId(); String customerId = formDTO.getCustomerId(); if (StringUtils.isBlank(monthId)) { - monthId = LocalDate.now().minusMonths(NumConstant.ONE).toString().replace("-","").substring(NumConstant.ZERO,NumConstant.SIX); + monthId = LocalDate.now().minusMonths(NumConstant.ONE).toString().replace("-", "").substring(NumConstant.ZERO, NumConstant.SIX); } List customerIds = new ArrayList<>(); if (StringUtils.isNotBlank(customerId)) { @@ -67,7 +75,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService List customerIdList = null; do { customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize); - if (!CollectionUtils.isEmpty(customerIdList)){ + if (!CollectionUtils.isEmpty(customerIdList)) { customerIds.addAll(customerIdList); } } while (!CollectionUtil.isEmpty(customerIdList) && customerIdList.size() == pageSize); @@ -91,88 +99,104 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService private void submitJob(ExtractIndexFormDTO param) { - CountDownLatch countDownLatch = new CountDownLatch(2); + CountDownLatch countDownLatch = new CountDownLatch(NumConstant.SIX); long start = System.currentTimeMillis(); final String customerId = param.getCustomerId(); final String monthId = param.getMonthId(); - threadPool.submit(() -> { + executorService.submit(() -> { try { long startCpc = System.currentTimeMillis(); calCpcIndexService.calCpcPartyAbility(customerId, monthId); - log.error("党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startCpc, param.getCustomerId()); + log.error("党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, param.getCustomerId()); } catch (Exception e) { log.error("抽取【党员相关数据】发生异常,参数:" + JSON.toJSONString(param), e); - }finally { + } finally { countDownLatch.countDown(); } }); - threadPool.submit(() -> { + executorService.submit(() -> { try { long startGridGovern = System.currentTimeMillis(); calGridIndexService.calGridIndexGovernAbility(customerId, monthId); - log.error("网格相关-治理能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridGovern, param.getCustomerId()); + log.error("网格相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridGovern, param.getCustomerId()); } catch (Exception e) { log.error("抽取【网格治理能力数据】发生异常,参数:" + JSON.toJSONString(param), e); } try { long startGridParty = System.currentTimeMillis(); calGridIndexService.calGridIndexPartyAbility(customerId, monthId); - log.error("网格相关-党建能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridParty, param.getCustomerId()); + log.error("网格相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridParty, param.getCustomerId()); } catch (Exception e) { log.error("抽取【网格党建能力数据】发生异常,参数:" + JSON.toJSONString(param), e); } try { long startGridService = System.currentTimeMillis(); calGridIndexService.calGridIndexServiceAbility(customerId, monthId); - log.error("网格相关-服务能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startGridService, param.getCustomerId()); + log.error("网格相关-服务能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridService, param.getCustomerId()); } catch (Exception e) { log.error("抽取【网格服务能力数据】发生异常,参数:" + JSON.toJSONString(param), e); } - - try{ - //dimAgency + countDownLatch.countDown(); + }); + executorService.submit(() -> { + try { long startCommunity = System.currentTimeMillis(); indexCollCommunityService.saveCommunityAbility(customerId, monthId); - log.error("社区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startCommunity, param.getCustomerId()); - }catch (Exception e){ + log.error("社区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCommunity, param.getCustomerId()); + } catch (Exception e) { log.error("抽取【社区治理能力-社区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); } - try{ - //dimAgency + countDownLatch.countDown(); + }); + executorService.submit(() -> { + try { long startStreet = System.currentTimeMillis(); indexCollStreetService.saveStreetAbility(customerId, monthId); - log.error("街道相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startStreet, param.getCustomerId()); - }catch (Exception e){ + log.error("街道相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startStreet, param.getCustomerId()); + } catch (Exception e) { log.error("抽取【街道治理能力-街道党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); } - - - try{ - //dimAgency + countDownLatch.countDown(); + }); + executorService.submit(() -> { + try { long startDept = System.currentTimeMillis(); indexCollDistrictDepartmentService.saveDepartmentAbility(customerId, monthId); - log.error("区直部门相关-治理能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startDept, param.getCustomerId()); - }catch (Exception e){ + log.error("区直部门相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDept, param.getCustomerId()); + } catch (Exception e) { log.error("抽取【区直部门治理能力】发生异常,参数:" + JSON.toJSONString(param), e); } - - - try{ - //dimAgency + countDownLatch.countDown(); + }); + executorService.submit(() -> { + try { long startDistrict = System.currentTimeMillis(); indexCollDistrictService.saveDistrictAbility(customerId, monthId); - log.error("全区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-startDistrict, param.getCustomerId()); - }catch (Exception e){ + log.error("全区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDistrict, param.getCustomerId()); + } catch (Exception e) { log.error("抽取【全区治理能力-全区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); } countDownLatch.countDown(); }); try { + //等前面都执行完 再执行计算指标得分 countDownLatch.await(); + executorService.submit(() -> { + long startT = System.currentTimeMillis(); + CalculateCommonFormDTO formDTO1 = new CalculateCommonFormDTO(); + try { + formDTO1.setMonthId(monthId); + formDTO1.setCustomerId(customerId); + Boolean aBoolean = indexCalculateService.indexCalculate(formDTO1); + HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + customerId + ";monthId:" + monthId + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - startT) / 1000 + "秒"); + } catch (Exception e) { + log.error("extractMonthly 计算分数异常,参数:{}", JSON.toJSONString(formDTO1)); + } + }); } catch (InterruptedException e) { log.error("indexOriginExtractAll countDownLatch exception", e); } - log.error("indexOriginExtractAll执行完毕======总耗时:{}ms,customerId:{}",System.currentTimeMillis()-start, param.getCustomerId()); + log.info("indexOriginExtractAll及指标计算执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - start, param.getCustomerId()); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java index 76764c1322..193bebbdfc 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java @@ -474,20 +474,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { log.info("===== extractMonthly method end not contains shi bei:{}======", customerId); return; } - //此方法保持在最后即可 计算指标分数 todo 优化 手动创建线程池 控制任务数量 - ExecutorService pool = Executors.newSingleThreadExecutor(); - pool.submit(() -> { - long start = System.currentTimeMillis(); - CalculateCommonFormDTO formDTO1 = new CalculateCommonFormDTO(); - try { - formDTO1.setMonthId(monthId); - formDTO1.setCustomerId(customerId); - Boolean aBoolean = indexCalculateService.indexCalculate(formDTO1); - HttpClientManager.getInstance().sendAlarmMsg(EnvEnum.getCurrentEnv().getName() + "客户Id:" + formDTO.getCustomerId() + ";monthId:" + formDTO1.getMonthId() + ",calculateAll全部指标计算完成,是否成功:" + aBoolean + ",总耗时:" + (System.currentTimeMillis() - start) / 1000 + "秒"); - } catch (Exception e) { - log.error("extractMonthly 计算分数异常,参数:{}", JSON.toJSONString(formDTO1)); - } - }); log.info("===== extractMonthly method end ======"); } } From 36f7f9471d8b68bf2249ab895e890bfddb4276fa Mon Sep 17 00:00:00 2001 From: wangxianzhang Date: Tue, 1 Mar 2022 11:13:48 +0800 Subject: [PATCH 09/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=EF=BC=9A=201.ResultDat?= =?UTF-8?q?aResolver=E4=B8=AD=E7=9A=84=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/feign/ResultDataResolver.java | 55 ++++++++++++------- 1 file changed, 36 insertions(+), 19 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java index 1bfa31e96b..8a9bc6ad80 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/feign/ResultDataResolver.java @@ -1,9 +1,12 @@ package com.epmet.commons.tools.feign; 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.utils.Result; import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Feign请求结果解析器 @@ -12,30 +15,30 @@ public interface ResultDataResolver { /** * @Description 获取Result种的data,如果失败(返回result为null或者result.success为false),那么返回null - * @return + * @return data数据 * @author wxz * @date 2021.06.07 22:45 */ - //default R tryGetResultData(Result result, String targetServiceName) { - // Logger logger = LoggerFactory.getLogger(ResultDataResolver.class); - // if (result == null) { - // logger.error("调用{}服务发生错误,返回Result为null", targetServiceName); - // return null; - // } - // if (!result.success()) { - // logger.error("调用{}服务发生错误,错误信息:{}", targetServiceName, result.getInternalMsg()); - // return null; - // } - // return result.getData(); - //} + default R getResultDataOrReturnNull(Result result, String targetServiceName) { + Logger logger = LoggerFactory.getLogger(ResultDataResolver.class); + if (result == null) { + logger.error("调用{}服务发生错误,返回Result为null", targetServiceName); + return null; + } + if (!result.success()) { + logger.error("调用{}服务发生错误,内部信息:{},错误信息:{}", targetServiceName, result.getInternalMsg(), result.getMsg()); + return null; + } + return result.getData(); + } /** - * @Description - * @return + * @Description 解析Result中的结果,如果请求上游服务返回的结果不成功,则抛出异常 + * @return data数据 * @param targetServiceName 目标service名称 - * @param errorCode 错误码,可以为空,为空则使用上游服务抛出的错误码 - * @param errorInternalMsg 内部错误信息,可以为空,为空则使用上游服务抛出的异常信息 - * @param showMsg 展示给前端程序的错误信息,可以为空。为空则根据errorCode给定错误msg信息 + * @param errorCode 错误码,可以为空,为空则使用8000 + * @param errorInternalMsg 内部错误信息,可以为空,为空则internalMsg="" + * @param showMsg 展示给前端程序的错误信息,可以为空。为空则showMsg="" * @author wxz * @date 2021.06.07 22:45 */ @@ -43,11 +46,25 @@ public interface ResultDataResolver { if (result == null) { throw new RenException(EpmetErrorCode.SERVER_ERROR.getCode(), "调用{}服务发生错误,返回Result为null", targetServiceName); } - if (!result.success()) { + + // 考虑到:上游服务抛出的异常代码和错误消息并不一定适用于当前服务,并且上有服务的错误消息弹出之后可能给用户造成困扰, + // 因此,当前服务抛出异常的时候,不再继承上游服务返回的错误码和错误消息 + /*if (!result.success()) { Integer finalErrorCode = errorCode == null ? result.getCode() : errorCode; String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? result.getInternalMsg() : errorInternalMsg; throw new RenException(finalErrorCode, finalErrorInternalMsg, showMsg, RenException.MessageMode.CODE_INTERNAL_EXTERNAL); + }*/ + + if (!result.success()) { + + // 如果不通过参数指定code,则默认使用8000服务器开小差 + Integer finalErrorCode = errorCode == null ? EpmetErrorCode.SERVER_ERROR.getCode() : errorCode; + String finalErrorInternalMsg = StringUtils.isBlank(errorInternalMsg) ? "" : errorInternalMsg; + String finalShowMsg = StringUtils.isBlank(showMsg) ? "" : showMsg; + + throw new EpmetException(finalErrorCode, finalErrorInternalMsg, finalShowMsg); } + return result.getData(); } From c3cef2d4fb227044bd46a6ecbe2bbde80c8af4aa Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 1 Mar 2022 15:41:37 +0800 Subject: [PATCH 10/13] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E7=BA=A7=E5=88=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataToIndex/impl/CalCpcIndexServiceImpl.java | 2 +- .../impl/IndexOriginExtractServiceImpl.java | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java index 353c3ad882..b78ebc1588 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/CalCpcIndexServiceImpl.java @@ -311,7 +311,7 @@ public class CalCpcIndexServiceImpl implements CalCpcIndexService { //1、查询当前党员建了多少个组 List groupIdList = userCreatedGroups.get(partyMember.getUserId()); if (CollectionUtils.isEmpty(groupIdList)) { - log.info("当前党员userId="+partyMember.getUserId()+"没有创建过小组, 【党员相关-党员自建群活跃群众人数】赋值0"); + log.warn("当前党员userId="+partyMember.getUserId()+"没有创建过小组, 【党员相关-党员自建群活跃群众人数】赋值0"); map.put(partyMember.getUserId(), NumConstant.ZERO); continue; } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java index 20c44c46cf..16085858c8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java @@ -107,7 +107,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService try { long startCpc = System.currentTimeMillis(); calCpcIndexService.calCpcPartyAbility(customerId, monthId); - log.error("党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, param.getCustomerId()); + log.info("党员相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCpc, param.getCustomerId()); } catch (Exception e) { log.error("抽取【党员相关数据】发生异常,参数:" + JSON.toJSONString(param), e); } finally { @@ -118,21 +118,21 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService try { long startGridGovern = System.currentTimeMillis(); calGridIndexService.calGridIndexGovernAbility(customerId, monthId); - log.error("网格相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridGovern, param.getCustomerId()); + log.info("网格相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridGovern, param.getCustomerId()); } catch (Exception e) { log.error("抽取【网格治理能力数据】发生异常,参数:" + JSON.toJSONString(param), e); } try { long startGridParty = System.currentTimeMillis(); calGridIndexService.calGridIndexPartyAbility(customerId, monthId); - log.error("网格相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridParty, param.getCustomerId()); + log.info("网格相关-党建能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridParty, param.getCustomerId()); } catch (Exception e) { log.error("抽取【网格党建能力数据】发生异常,参数:" + JSON.toJSONString(param), e); } try { long startGridService = System.currentTimeMillis(); calGridIndexService.calGridIndexServiceAbility(customerId, monthId); - log.error("网格相关-服务能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridService, param.getCustomerId()); + log.info("网格相关-服务能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startGridService, param.getCustomerId()); } catch (Exception e) { log.error("抽取【网格服务能力数据】发生异常,参数:" + JSON.toJSONString(param), e); } @@ -142,7 +142,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService try { long startCommunity = System.currentTimeMillis(); indexCollCommunityService.saveCommunityAbility(customerId, monthId); - log.error("社区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCommunity, param.getCustomerId()); + log.info("社区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startCommunity, param.getCustomerId()); } catch (Exception e) { log.error("抽取【社区治理能力-社区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); } @@ -152,7 +152,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService try { long startStreet = System.currentTimeMillis(); indexCollStreetService.saveStreetAbility(customerId, monthId); - log.error("街道相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startStreet, param.getCustomerId()); + log.info("街道相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startStreet, param.getCustomerId()); } catch (Exception e) { log.error("抽取【街道治理能力-街道党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); } @@ -162,7 +162,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService try { long startDept = System.currentTimeMillis(); indexCollDistrictDepartmentService.saveDepartmentAbility(customerId, monthId); - log.error("区直部门相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDept, param.getCustomerId()); + log.info("区直部门相关-治理能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDept, param.getCustomerId()); } catch (Exception e) { log.error("抽取【区直部门治理能力】发生异常,参数:" + JSON.toJSONString(param), e); } @@ -172,7 +172,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService try { long startDistrict = System.currentTimeMillis(); indexCollDistrictService.saveDistrictAbility(customerId, monthId); - log.error("全区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDistrict, param.getCustomerId()); + log.info("全区相关-三大能力执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - startDistrict, param.getCustomerId()); } catch (Exception e) { log.error("抽取【全区治理能力-全区党建能力-服务能力】发生异常,参数:" + JSON.toJSONString(param), e); } From 5128a9202b86092d222ee8c177da72b31a4b8a15 Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 1 Mar 2022 16:11:29 +0800 Subject: [PATCH 11/13] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=97=A5=E5=BF=97?= =?UTF-8?q?=E4=BD=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataToIndex/impl/IndexOriginExtractServiceImpl.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java index 16085858c8..26c952ff79 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java @@ -178,7 +178,7 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService } countDownLatch.countDown(); }); - + log.info("indexOriginExtractAll======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - start, param.getCustomerId()); try { //等前面都执行完 再执行计算指标得分 countDownLatch.await(); @@ -197,6 +197,5 @@ public class IndexOriginExtractServiceImpl implements IndexOriginExtractService } catch (InterruptedException e) { log.error("indexOriginExtractAll countDownLatch exception", e); } - log.info("indexOriginExtractAll及指标计算执行完毕======总耗时:{}ms,customerId:{}", System.currentTimeMillis() - start, param.getCustomerId()); } } From 94ec1cceb97d33b029770803bb48dad9876f76bd Mon Sep 17 00:00:00 2001 From: jianjun Date: Tue, 1 Mar 2022 16:44:52 +0800 Subject: [PATCH 12/13] =?UTF-8?q?stats=20=E5=8E=BB=E6=8E=89=E7=BA=BF?= =?UTF-8?q?=E7=A8=8B=E6=B1=A0=E5=AE=9A=E4=B9=89=20=E7=9B=B4=E6=8E=A5?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E6=9C=8D=E5=8A=A1=E5=AE=9A=E4=B9=89=E7=9A=84?= =?UTF-8?q?=E7=BA=BF=E7=A8=8B=E6=B1=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/controller/DemoController.java | 14 ++----- .../ScreenExtractDailyController.java | 12 ++---- .../external/IndexCalculateController.java | 16 +++---- .../biz/impl/BizDataStatsServiceImpl.java | 7 ---- .../impl/IndexOriginExtractServiceImpl.java | 5 --- .../impl/FactOriginExtractServiceImpl.java | 29 +++++-------- .../impl/ScreenExtractServiceImpl.java | 42 +++++-------------- .../service/impl/TopicDraftServiceImpl.java | 28 ++++--------- 8 files changed, 41 insertions(+), 112 deletions(-) diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java index e7ba9b027f..a0abb1b2e2 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/DemoController.java @@ -1098,12 +1098,6 @@ public class DemoController { return new Result(); } - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("ScreenExtractServiceImpl-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(3, 6, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); - @Autowired private ScreenProjectCategoryGridAndOrgDailyService screenProjectCategoryGridAndOrgDailyService; @@ -1118,20 +1112,20 @@ public class DemoController { if (StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate)){ List daysBetween = DateUtils.getDaysBetween(startDate, endDate); daysBetween.forEach(d -> { - threadPool.submit(() -> { + executorService.submit(() -> { screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,d); }); - threadPool.submit(() -> { + executorService.submit(() -> { screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,d); }); result.add(d); redisUtils.hSet(RedisKeys.getBackDoorbizExcuteResult("gridandorgdailynew"),customerId,result,3*24*60*60L); }); }else { - threadPool.submit(() -> { + executorService.submit(() -> { screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectGridData(customerId,dateId); }); - threadPool.submit(() -> { + executorService.submit(() -> { screenProjectCategoryGridAndOrgDailyService.extractCategoryProjectOrgData(customerId,dateId); }); result.add(dateId); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java index 07919aa425..756ecc2d8a 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/ScreenExtractDailyController.java @@ -5,7 +5,6 @@ import com.epmet.commons.tools.utils.Result; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO; import com.epmet.service.evaluationindex.extract.toscreen.ScreenExtractService; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; @@ -13,7 +12,7 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; -import java.util.concurrent.*; +import java.util.concurrent.ExecutorService; /** * @Author zxc @@ -23,13 +22,10 @@ import java.util.concurrent.*; @RestController @RequestMapping("screenextract") public class ScreenExtractDailyController { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("ScreenExtractDailyController-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(1, 1, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); @Autowired private ScreenExtractService screenExtractService; + @Autowired + private ExecutorService executorService; /** * @param extractOriginFormDTO @@ -39,7 +35,7 @@ public class ScreenExtractDailyController { */ @PostMapping("extractdailyall") public Result screenExtractDaily(@RequestBody ExtractOriginFormDTO extractOriginFormDTO) { - threadPool.submit(() -> { + executorService.submit(() -> { log.info("screenExtractDaily start,param:{}", JSON.toJSONString(extractOriginFormDTO)); try { screenExtractService.extractDailyAll(extractOriginFormDTO); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java index 247dc31d7f..15f6cb77c8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java @@ -17,7 +17,6 @@ import com.epmet.model.CalculateFlagModel; import com.epmet.service.evaluationindex.indexcal.CpcIndexCalculateService; import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; import com.epmet.util.DimIdGenerator; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -28,7 +27,8 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; import java.util.Set; -import java.util.concurrent.*; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; /** * 指标计算controller @@ -40,13 +40,6 @@ import java.util.concurrent.*; @RestController @RequestMapping("indexcalculate") public class IndexCalculateController { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("manual_execute_indexcal-pool-%d").build(); - ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1, - 0L, TimeUnit.MILLISECONDS, - new LinkedBlockingQueue(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); - - @Autowired private IndexCalculateService indexCalculateService; @@ -55,6 +48,9 @@ public class IndexCalculateController { @Autowired private RedisUtils redisUtils; + @Autowired + private ExecutorService executorService; + // 计算同步锁 private Object statsCalLock = new Object(); @@ -172,7 +168,7 @@ public class IndexCalculateController { * @return */ private void submitCalculate(CalculateCommonFormDTO formDTO) { - Future future = singleThreadPool.submit(() -> { + Future future = executorService.submit(() -> { try { long start = System.currentTimeMillis(); Boolean aBoolean = indexCalculateService.indexCalculate(formDTO); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java index 0b0d0d5f1c..25dd3d764b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/biz/impl/BizDataStatsServiceImpl.java @@ -21,7 +21,6 @@ import com.epmet.service.stats.DimCustomerService; import com.epmet.service.user.StatsStaffPatrolService; import com.epmet.service.user.UserService; import com.epmet.util.DimIdGenerator; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -34,7 +33,6 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; -import java.util.concurrent.*; import java.util.stream.Collectors; /** @@ -47,11 +45,6 @@ import java.util.stream.Collectors; @Slf4j @Service public class BizDataStatsServiceImpl implements BizDataStatsService { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("bizDataStats-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(3, 6, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); @Autowired private CustomerStaffService customerStaffService; @Autowired diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java index 26c952ff79..b07c82ceb9 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/dataToIndex/impl/IndexOriginExtractServiceImpl.java @@ -30,11 +30,6 @@ import java.util.concurrent.ExecutorService; @Slf4j @Service public class IndexOriginExtractServiceImpl implements IndexOriginExtractService { - /*ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("indexOriginExtractAndCal-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(1, 1, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy());*/ @Autowired private ExecutorService executorService; @Autowired diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java index b650e906d3..6db437e591 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/todata/impl/FactOriginExtractServiceImpl.java @@ -7,13 +7,10 @@ import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.stats.form.CustomerIdAndDateIdFormDTO; -import com.epmet.service.StatsGroupService; -import com.epmet.service.StatsTopicService; import com.epmet.service.evaluationindex.extract.todata.*; import com.epmet.service.stats.DimCustomerPartymemberService; import com.epmet.service.stats.DimCustomerService; import com.epmet.util.DimIdGenerator; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -23,7 +20,9 @@ import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.Date; import java.util.List; -import java.util.concurrent.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; /** * desc:抽取业务数据 到 统计库 汇聚类 @@ -31,12 +30,6 @@ import java.util.concurrent.*; @Slf4j @Service public class FactOriginExtractServiceImpl implements FactOriginExtractService { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("factOriginExtract-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(3, 6, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); - @Autowired private IssueExtractService issueExtractService; @Autowired @@ -54,9 +47,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { @Autowired private FactGroupActDailyService factGroupActDailyService; @Autowired - private StatsGroupService statsGroupService; - @Autowired - private StatsTopicService statsTopicService; + private ExecutorService executorService; @Override @@ -106,7 +97,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { daysBetween = DateUtils.getDaysBetween(param.getStartDate(), param.getEndDate()); } List finalDaysBetween = daysBetween; - threadPool.submit(() -> { + executorService.submit(() -> { try { CustomerIdAndDateIdFormDTO formDTO = new CustomerIdAndDateIdFormDTO(); formDTO.setCustomerId(param.getCustomerId()); @@ -132,7 +123,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { countDownLatch.countDown(); } }); - threadPool.submit(() -> { + executorService.submit(() -> { try { ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); if (!isRange) { @@ -156,7 +147,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { countDownLatch.countDown(); } }); - threadPool.submit(() -> { + executorService.submit(() -> { try { log.debug("extractAll start param:{}", JSON.toJSONString(param)); ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); @@ -183,7 +174,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { countDownLatch.countDown(); } }); - threadPool.submit(() -> { + executorService.submit(() -> { try { ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); if (!isRange) { @@ -222,7 +213,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { } }); //小组活动 - threadPool.submit(() -> { + executorService.submit(() -> { try { ExtractOriginFormDTO extractOriginFormDTO = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); if (!isRange) { @@ -339,7 +330,7 @@ public class FactOriginExtractServiceImpl implements FactOriginExtractService { @Override public Future submitProjectRelationData(ExtractOriginFormDTO param, List finalDaysBetween) { - Future submit = threadPool.submit(() -> { + Future submit = executorService.submit(() -> { ExtractOriginFormDTO paramNew = ConvertUtils.sourceToTarget(param, ExtractOriginFormDTO.class); if (CollectionUtils.isEmpty(finalDaysBetween)) { try { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java index 193bebbdfc..e3ed39133b 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/extract/toscreen/impl/ScreenExtractServiceImpl.java @@ -7,22 +7,17 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.distributedlock.DistributedLock; import com.epmet.commons.tools.distributedlock.LockConstants; -import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.utils.DateUtils; -import com.epmet.commons.tools.utils.HttpClientManager; import com.epmet.dto.extract.form.ExtractFactGridGovernDailyFromDTO; import com.epmet.dto.extract.form.ExtractOriginFormDTO; import com.epmet.dto.extract.form.ExtractScreenFormDTO; -import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.screen.form.ScreenCentralZoneDataFormDTO; import com.epmet.service.evaluationindex.extract.todata.FactAgencyGovernDailyService; import com.epmet.service.evaluationindex.extract.todata.FactGridGovernDailyService; import com.epmet.service.evaluationindex.extract.todata.FactGridMemberStatisticsDailyService; import com.epmet.service.evaluationindex.extract.toscreen.*; -import com.epmet.service.evaluationindex.indexcal.IndexCalculateService; import com.epmet.service.evaluationindex.screen.*; import com.epmet.service.stats.DimCustomerService; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.redisson.api.RLock; @@ -33,7 +28,9 @@ import org.springframework.util.CollectionUtils; import java.time.LocalDate; import java.util.ArrayList; import java.util.List; -import java.util.concurrent.*; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.TimeUnit; /** * @Author zxc @@ -42,12 +39,6 @@ import java.util.concurrent.*; @Service @Slf4j public class ScreenExtractServiceImpl implements ScreenExtractService { - ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("ScreenExtractServiceImpl-pool-%d").build(); - ExecutorService threadPool = new ThreadPoolExecutor(3, 6, - 10L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); - @Autowired private DimCustomerService dimCustomerService; @Autowired @@ -65,8 +56,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { @Autowired private PublicPartiTotalDataExtractService publicPartiTotalDataExtractService; @Autowired - private IndexCalculateService indexCalculateService; - @Autowired private ScreenCentralZoneDataAbsorptionService screenCentralZoneDataAbsorptionService; @Autowired private ScreenGrassrootsGovernDataAbsorptionService screenGrassrootsGovernDataAbsorptionService; @@ -81,10 +70,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { @Autowired private ScreenProjectSettleService screenProjectSettleService; @Autowired - private ScreenProjectCategoryGridDailyService projectCategoryGridDailyService; - @Autowired - private ScreenProjectCategoryOrgDailyService projectCategoryOrgDailyService; - @Autowired private FactGridGovernDailyService factGridGovernDailyService; @Autowired private FactAgencyGovernDailyService factAgencyGovernDailyService; @@ -94,6 +79,9 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { private ScreenProjectCategoryGridAndOrgDailyService screenProjectCategoryGridAndOrgDailyService; @Autowired private DistributedLock distributedLock; + @Autowired + private ExecutorService executorService; + /** * @param extractOriginFormDTO @@ -183,7 +171,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { lock = distributedLock.getLock(LockConstants.SCREEN_DAILY, NumConstant.SIX_HUNDRED_L, NumConstant.TEN_L, TimeUnit.SECONDS); //等待3个线程执行完毕后再 继续执行下一个客户的 避免死锁 final CountDownLatch latch = new CountDownLatch(NumConstant.FOUR); - threadPool.submit(() -> { + executorService.submit(() -> { //党员基本情况screen_cpc_base_data try { try { @@ -215,7 +203,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { } }); - threadPool.submit(() -> { + executorService.submit(() -> { //公众参与排行(注册人数、参与人数、话题数、议题数、项目数)screen_public_party_total_data try { @@ -263,7 +251,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { log.info("extractDaily 2 thread run end ========= dateId:{},customerId:{}", dateId, customerId); } }); - threadPool.submit(() -> { + executorService.submit(() -> { try { try { @@ -283,7 +271,7 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { log.info("extractDaily 3 thread run end ========= dateId:{},customerId:{}", dateId, customerId); } }); - threadPool.submit(() -> { + executorService.submit(() -> { //治理能力排行screen_govern_rank_data try { try { @@ -447,16 +435,6 @@ public class ScreenExtractServiceImpl implements ScreenExtractService { } catch (Exception e) { log.error("党建引领抽取到大屏失败,参数为:" + JSON.toJSONString(formDTO), e); } - //已经挪到天抽取的抽取里了 - /* try { - //基层治理 - 热心市民 screen_party_user_rank_data - ScreenCentralZoneDataFormDTO param = new ScreenCentralZoneDataFormDTO(); - param.setCustomerId(customerId); - param.setDateId(monthId); - screenGrassrootsGovernDataAbsorptionService.userScoreDataHub(param); - } catch (Exception e) { - log.error("大屏热心市民/党员得分数据写入失败,参数为:{}" + JSON.toJSONString(formDTO), e); - }*/ try { // 项目(事件)数量分析按网格_按月统计 screenProjectQuantityGridMonthlyService.extractionProjectGridMonthly(customerId, monthId); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java index 0d681d7368..8706317b90 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/TopicDraftServiceImpl.java @@ -17,7 +17,6 @@ package com.epmet.modules.topic.service.impl; -import com.alibaba.fastjson.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; @@ -25,8 +24,8 @@ import com.epmet.commons.rocketmq.messages.GroupAchievementMQMsg; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.MqConstant; import com.epmet.commons.tools.constant.NumConstant; -import com.epmet.commons.tools.dto.form.mq.MqBaseMsgDTO; import com.epmet.commons.tools.dto.form.mq.eventmsg.BasePointEventMsg; +import com.epmet.commons.tools.enums.AchievementTypeEnum; import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; @@ -37,19 +36,18 @@ import com.epmet.commons.tools.scan.result.AsyncScanTaskDTO; import com.epmet.commons.tools.scan.result.SyncScanResult; import com.epmet.commons.tools.scan.result.VoiceResultDTO; import com.epmet.commons.tools.security.dto.TokenDto; -import com.epmet.commons.tools.utils.*; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.ScanContentUtils; import com.epmet.constant.SystemMessageType; import com.epmet.dto.form.CommonGridIdFormDTO; import com.epmet.dto.form.SystemMsgFormDTO; import com.epmet.dto.result.AllGridsByUserIdResultDTO; -import com.epmet.dto.result.UserInfoResultDTO; import com.epmet.dto.result.CommonDataFilterResultDTO; -import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.dto.result.UserInfoResultDTO; +import com.epmet.feign.EpmetMessageOpenFeignClient; import com.epmet.feign.GovOrgOpenFeignClient; -import com.epmet.commons.tools.enums.AchievementTypeEnum; -import com.epmet.modules.feign.EpmetUserFeignClient; -import com.epmet.modules.group.dao.GroupMessageDao; import com.epmet.modules.feign.GovOrgFeignClient; import com.epmet.modules.group.dao.GroupMessageDao; import com.epmet.modules.group.dao.ResiGroupDao; @@ -58,7 +56,6 @@ import com.epmet.modules.group.entity.GroupMessageEntity; import com.epmet.modules.group.entity.ResiGroupEntity; import com.epmet.modules.group.entity.ResiGroupStatisticalEntity; import com.epmet.modules.group.redis.ResiGroupRedis; -import com.epmet.modules.member.dao.ResiGroupMemberDao; import com.epmet.modules.member.redis.ResiGroupMemberRedis; import com.epmet.modules.member.service.ResiGroupMemberService; import com.epmet.modules.topic.dao.ResiTopicAttachmentDao; @@ -84,7 +81,6 @@ import com.epmet.resi.group.dto.topic.result.MyAuditingListResultDTO; import com.epmet.resi.group.dto.topic.result.TopicAuditResultDTO; import com.epmet.send.SendMqMsgUtil; import com.google.common.base.CharMatcher; -import com.google.common.util.concurrent.ThreadFactoryBuilder; import lombok.extern.slf4j.Slf4j; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringUtils; @@ -97,7 +93,6 @@ import org.springframework.transaction.annotation.Transactional; import java.text.SimpleDateFormat; import java.util.*; -import java.util.concurrent.*; import java.util.stream.Collectors; /** @@ -111,11 +106,6 @@ import java.util.stream.Collectors; public class TopicDraftServiceImpl extends BaseServiceImpl implements TopicDraftService { private static Logger logger = LoggerFactory.getLogger(TopicDraftServiceImpl.class); - private ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() - .setNameFormat("TopicDraftService-pool-%d").build(); - private ExecutorService threadPool = new ThreadPoolExecutor(1, 1, - 1L, TimeUnit.MINUTES, - new LinkedBlockingQueue<>(500), namedThreadFactory, new ThreadPoolExecutor.CallerRunsPolicy()); @Autowired private GovOrgOpenFeignClient govOrgOpenFeignClient; @Autowired @@ -125,12 +115,8 @@ public class TopicDraftServiceImpl extends BaseServiceImpl Date: Tue, 1 Mar 2022 17:42:17 +0800 Subject: [PATCH 13/13] =?UTF-8?q?=E9=AA=8C=E8=AF=81=E7=A0=81=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E7=BA=AF=E5=B0=8F=E5=86=99=E5=AD=97=E6=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/StringRandomUtils.java | 32 +++++++++++++++++++ .../com/epmet/controller/LoginController.java | 24 -------------- .../com/epmet/service/CaptchaService.java | 10 ------ .../service/impl/CaptchaServiceImpl.java | 20 +++--------- 4 files changed, 37 insertions(+), 49 deletions(-) create mode 100644 epmet-auth/src/main/java/com/epmet/StringRandomUtils.java diff --git a/epmet-auth/src/main/java/com/epmet/StringRandomUtils.java b/epmet-auth/src/main/java/com/epmet/StringRandomUtils.java new file mode 100644 index 0000000000..fbac601c41 --- /dev/null +++ b/epmet-auth/src/main/java/com/epmet/StringRandomUtils.java @@ -0,0 +1,32 @@ +package com.epmet; + +import com.epmet.commons.tools.constant.StrConstant; + +/** + * desc:随机生成字母 + * + * @author: LiuJanJun + * @date: 2022/3/1 5:16 下午 + * @version: 1.0 + */ +public class StringRandomUtils { + + public static String getRandomStr(int length){ + String result = StrConstant.EPMETY_STR; + //小写字母范围: 97~122 + for (int i = 0; i < length; i++) { + int randomNumber = 97 + (int) (Math.random()* (122+1-97)); + result += (char)randomNumber; + } + return result; + } + + public static void main(String[] args) { + StringRandomUtils test = new StringRandomUtils(); + //测试 + for (int i = 0; i < 1000000; i++) { + System.out.println(getRandomStr(5)); + } + } + +} diff --git a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java index c9df95100b..c1fdb8a045 100644 --- a/epmet-auth/src/main/java/com/epmet/controller/LoginController.java +++ b/epmet-auth/src/main/java/com/epmet/controller/LoginController.java @@ -68,30 +68,6 @@ public class LoginController { } } - /** - * @description 基层治理平台登录验证码 - * - * @param response - * @return - * @author wxz - * @date 2021.10.25 14:19:40 - */ - @GetMapping("ic-login-captcha") - public void icLoginCaptcha(HttpServletResponse response, String uuid) throws IOException { - try { - //生成图片验证码 - BufferedImage image = captchaService.createIcLoginCaptcha(uuid); - response.reset(); - response.setHeader("Cache-Control", "no-store, no-cache"); - response.setContentType("image/jpeg"); - ServletOutputStream out = response.getOutputStream(); - ImageIO.write(image, "jpg", out); - out.close(); - } catch (IOException e) { - log.error("获取登陆验证码异常", e); - } - } - /** * @param formDTO * @return com.epmet.commons.tools.utils.Result diff --git a/epmet-auth/src/main/java/com/epmet/service/CaptchaService.java b/epmet-auth/src/main/java/com/epmet/service/CaptchaService.java index 812a586dcb..d6f8573e65 100644 --- a/epmet-auth/src/main/java/com/epmet/service/CaptchaService.java +++ b/epmet-auth/src/main/java/com/epmet/service/CaptchaService.java @@ -23,16 +23,6 @@ public interface CaptchaService { */ BufferedImage create(String uuid); - /** - * @description 基层治理平台登录验证码 - * - * @param - * @return - * @author wxz - * @date 2021.10.25 14:15:30 - */ - BufferedImage createIcLoginCaptcha(String uuid); - /** * 验证码效验 * @param uuid uuid diff --git a/epmet-auth/src/main/java/com/epmet/service/impl/CaptchaServiceImpl.java b/epmet-auth/src/main/java/com/epmet/service/impl/CaptchaServiceImpl.java index 115009f9e9..fbdf85b00b 100644 --- a/epmet-auth/src/main/java/com/epmet/service/impl/CaptchaServiceImpl.java +++ b/epmet-auth/src/main/java/com/epmet/service/impl/CaptchaServiceImpl.java @@ -8,16 +8,17 @@ package com.epmet.service.impl; -import com.google.code.kaptcha.Producer; +import com.epmet.StringRandomUtils; +import com.epmet.commons.tools.constant.NumConstant; import com.epmet.redis.CaptchaRedis; import com.epmet.service.CaptchaService; +import com.google.code.kaptcha.Producer; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.awt.image.BufferedImage; -import java.util.UUID; /** * 验证码 @@ -35,8 +36,8 @@ public class CaptchaServiceImpl implements CaptchaService { @Override public BufferedImage create(String uuid) { - //生成验证码 - String captcha = producer.createText(); + //生成验证码 //producer.createText(); + String captcha = StringRandomUtils.getRandomStr(NumConstant.FIVE); //logger.info("uuid:"+uuid+",生成的验证码:"+captcha); //保存验证码 captchaRedis.set(uuid, captcha); @@ -44,17 +45,6 @@ public class CaptchaServiceImpl implements CaptchaService { return producer.createImage(captcha); } - @Override - public BufferedImage createIcLoginCaptcha(String uuid) { - //生成验证码 - String captchaText = producer.createText(); - //logger.info("uuid:"+uuid+",生成的验证码:"+captcha); - //保存验证码 - captchaRedis.setIcLoginCaptcha(uuid, captchaText); - - return producer.createImage(captchaText); - } - @Override public boolean validate(String uuid, String code) { String captcha = captchaRedis.get(uuid);