From a6756467f87688e8a2bc9c8f9a9bf55957847b37 Mon Sep 17 00:00:00 2001 From: zhaoqifeng Date: Mon, 26 Apr 2021 11:12:55 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E8=AF=9D=E9=A2=98=E8=BD=AC=E8=AE=AE?= =?UTF-8?q?=E9=A2=98=E7=A7=AF=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epmet/modules/topic/service/impl/ResiTopicServiceImpl.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java index dcffc24d99..74e775128d 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java @@ -1762,6 +1762,7 @@ public class ResiTopicServiceImpl extends BaseServiceImpl Date: Mon, 26 Apr 2021 13:58:13 +0800 Subject: [PATCH 2/4] =?UTF-8?q?id=E7=94=9F=E6=88=90=E5=99=A8=2024=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tools/utils/UniqueIdGenerator.java | 21 ++++++++------- .../epmet/model/IndexExcelDataListener.java | 26 +++++++++---------- .../screen/impl/IndexGroupServiceImpl.java | 6 ++--- 3 files changed, 28 insertions(+), 25 deletions(-) diff --git a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/UniqueIdGenerator.java b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/UniqueIdGenerator.java index fcefbdf2ca..a1c19557d1 100644 --- a/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/UniqueIdGenerator.java +++ b/epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/utils/UniqueIdGenerator.java @@ -11,6 +11,8 @@ import java.util.concurrent.atomic.AtomicLong; * 唯一ID生成器 */ public class UniqueIdGenerator { + public final static String FORMAT_DMDHS = "yyyyMMddHHmmss"; + private static UniqueValue uniqueValue = new UniqueValue(); private static String middle; @@ -25,7 +27,7 @@ public class UniqueIdGenerator { private static class UniqueValue { private AtomicLong uniqueValue = new AtomicLong(0L); - private volatile String currentTime = DateUtils.format(new Date(), DateUtils.DATE_TIME_NO_SPLIT); + private volatile String currentTime = DateUtils.format(new Date(), FORMAT_DMDHS); private volatile String lastTime = currentTime; /** @@ -35,7 +37,7 @@ public class UniqueIdGenerator { * @return */ public String getCurrentTime() { - currentTime = DateUtils.format(new Date(), DateUtils.DATE_TIME_NO_SPLIT); + currentTime = DateUtils.format(new Date(), FORMAT_DMDHS); if (!currentTime.equals(lastTime)) { lastTime = currentTime; Random random = new Random(); @@ -51,31 +53,32 @@ public class UniqueIdGenerator { /** * 生成一个24位唯一ID - * 15位时间+2位中间值(防止多服务冲突)+2个线程code+5位秒级递增值 + * 14位时间+2位中间值(防止多服务冲突)+3个线程code+5位秒级递增值 * * @return */ - public static String generate() { + public static String generate24() { StringBuilder builder = new StringBuilder(32); builder.append(uniqueValue.getCurrentTime()) .append(middle) - .append(getUniqueThreadCode()) + .append(getUniqueThreadCode(3)) .append(uniqueValue.getCurrentValue()); return builder.toString(); } - public static String getUniqueThreadCode() { - String threadCode = StringUtils.left(String.valueOf(Thread.currentThread().hashCode()), 2); - return StringUtils.leftPad(threadCode, 2, "0"); + public static String getUniqueThreadCode(Integer length) { + String threadCode = StringUtils.left(String.valueOf(Thread.currentThread().hashCode()), length); + return StringUtils.leftPad(threadCode, length, "0"); } public static void main(String[] args) throws InterruptedException { System.out.println(UniqueIdGenerator.uniqueValue.currentTime); System.out.println(UniqueIdGenerator.middle); - System.out.println(UniqueIdGenerator.getUniqueThreadCode()); + System.out.println(UniqueIdGenerator.getUniqueThreadCode(2)); System.out.println(uniqueValue.getCurrentValue()); + System.out.println(UniqueIdGenerator.generate24()); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java index 9870714357..3fe392276f 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/model/IndexExcelDataListener.java @@ -157,7 +157,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { group1 = new IndexGroupTemplateEntity(); group1.setIndexId(indexDictEntity.getId()); group1.setParentIndexGroupId("0"); - group1.setId(UniqueIdGenerator.generate()); + group1.setId(UniqueIdGenerator.generate24()); group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), true, 4)); group1.setAllIndexCodePath(index.getAllIndexCodePath(0)); indexGroupMap.put(index.getLevel1Index(), group1); @@ -173,7 +173,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { group2 = new IndexGroupTemplateEntity(); group2.setIndexId(indexDictEntity.getId()); group2.setParentIndexGroupId(group1.getId()); - group2.setId(UniqueIdGenerator.generate()); + group2.setId(UniqueIdGenerator.generate24()); group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); group2.setAllIndexCodePath(index.getAllIndexCodePath(3)); indexGroupMap.put(level4IndexDetailKey, group2); @@ -184,7 +184,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setIndexGroupId(group1.getId()); templateEntity.setIndexId(indexDictEntity.getId()); templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); - templateEntity.setId(UniqueIdGenerator.generate()); + templateEntity.setId(UniqueIdGenerator.generate24()); templateEntity.setCorrelation(index.getCorrelation()); templateEntity.setAllIndexCodePath(index.getAllIndexCodePath(3)); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 2); @@ -202,7 +202,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setIndexGroupId(group2.getId()); templateEntity.setIndexId(indexDictEntity.getId()); templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); - templateEntity.setId(UniqueIdGenerator.generate()); + templateEntity.setId(UniqueIdGenerator.generate24()); templateEntity.setCorrelation(index.getCorrelation()); templateEntity.setAllIndexCodePath(index.getAllIndexCodePath(4)); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 5); @@ -217,7 +217,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { group1 = new IndexGroupTemplateEntity(); group1.setIndexId(indexDictEntity.getId()); group1.setParentIndexGroupId("0"); - group1.setId(UniqueIdGenerator.generate()); + group1.setId(UniqueIdGenerator.generate24()); group1.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); group1.setAllIndexCodePath(index.getAllIndexCodePath(0)); indexGroupMap.put(index.getLevel1Index(), group1); @@ -232,7 +232,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { group2 = new IndexGroupTemplateEntity(); group2.setIndexId(indexDictEntity.getId()); group2.setParentIndexGroupId(group1.getId()); - group2.setId(UniqueIdGenerator.generate()); + group2.setId(UniqueIdGenerator.generate24()); group2.setIndexCode(Pinyin4jUtil.getSpellPinYin(indexDictEntity.getIndexName(), false, 4)); group2.setAllIndexCodePath(index.getAllIndexCodePath(1)); indexGroupMap.put(level2IndexGroupKey, group2); @@ -243,7 +243,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setIndexGroupId(group2.getId()); templateEntity.setIndexId(indexDictEntity.getId()); templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); - templateEntity.setId(UniqueIdGenerator.generate()); + templateEntity.setId(UniqueIdGenerator.generate24()); templateEntity.setCorrelation(index.getCorrelation()); templateEntity.setAllIndexCodePath(index.getAllIndexCodePath(1)); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 2); @@ -260,7 +260,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { templateEntity.setIndexGroupId(group2.getId()); templateEntity.setIndexId(indexDictEntity.getId()); templateEntity.setAllParentIndexCode(allIndexCodeSb.toString()); - templateEntity.setId(UniqueIdGenerator.generate()); + templateEntity.setId(UniqueIdGenerator.generate24()); templateEntity.setCorrelation(index.getCorrelation()); templateEntity.setAllIndexCodePath(index.getAllIndexCodePath(4)); buildIndexGroupDetail(templateEntity, indexDictEntity, index, 5); @@ -289,7 +289,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { private void buildIndexDicEntity(IndexModel data, IndexDictEntity entity, IndexDictEntity entity2, IndexDictEntity entity3, IndexDictEntity entity4, IndexDictEntity entity5) { if (!indexDicMap.containsKey(data.getLevel1Index())) { - entity.setId(UniqueIdGenerator.generate()); + entity.setId(UniqueIdGenerator.generate24()); entity.setIndexName(data.getLevel1Index()); entity.setCorrelation(data.getCorrelation()); entity.setLevel("1"); @@ -297,7 +297,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { indexDicMap.put(data.getLevel1Index(), entity); } if (!indexDicMap.containsKey(data.getLevel2Index())) { - entity2.setId(UniqueIdGenerator.generate()); + entity2.setId(UniqueIdGenerator.generate24()); entity2.setIndexName(data.getLevel2Index()); entity2.setCorrelation(data.getCorrelation()); entity2.setLevel("2"); @@ -305,7 +305,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { indexDicMap.put(data.getLevel2Index(), entity2); } if (!indexDicMap.containsKey(data.getLevel3Index())) { - entity3.setId(UniqueIdGenerator.generate()); + entity3.setId(UniqueIdGenerator.generate24()); entity3.setIndexName(data.getLevel3Index()); entity3.setCorrelation(data.getCorrelation()); entity3.setLevel("3"); @@ -313,7 +313,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { indexDicMap.put(data.getLevel3Index(), entity3); } if (!indexDicMap.containsKey(data.getLevel4Index())) { - entity4.setId(UniqueIdGenerator.generate()); + entity4.setId(UniqueIdGenerator.generate24()); entity4.setIndexName(data.getLevel4Index()); entity4.setCorrelation(data.getCorrelation()); entity4.setLevel("4"); @@ -321,7 +321,7 @@ public class IndexExcelDataListener extends AnalysisEventListener { indexDicMap.put(data.getLevel4Index(), entity4); } if (!indexDicMap.containsKey(data.getLevel5Index())) { - entity5.setId(UniqueIdGenerator.generate()); + entity5.setId(UniqueIdGenerator.generate24()); entity5.setIndexName(data.getLevel5Index()); entity5.setCorrelation(data.getCorrelation()); entity5.setLevel("5"); diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/IndexGroupServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/IndexGroupServiceImpl.java index 50092d64db..00c019e1ff 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/IndexGroupServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/screen/impl/IndexGroupServiceImpl.java @@ -80,7 +80,7 @@ private IndexGroupTemplateDao indexGroupTemplateDao; List insertGroupList = new ArrayList<>(); groupMap.forEach((oldGroupTempId, o) -> { IndexGroupEntity newGroupEntity = ConvertUtils.sourceToTarget(o, IndexGroupEntity.class); - String newGroupId = UniqueIdGenerator.generate(); + String newGroupId = UniqueIdGenerator.generate24(); newGroupEntity.setId(newGroupId); newGroupEntity.setCustomerId(customerId); groupNewIdMap.put(oldGroupTempId, newGroupId); @@ -99,7 +99,7 @@ private IndexGroupTemplateDao indexGroupTemplateDao; IndexGroupDetailEntity entity = ConvertUtils.sourceToTarget(groupDetailTemp, IndexGroupDetailEntity.class); - entity.setId(UniqueIdGenerator.generate()); + entity.setId(UniqueIdGenerator.generate24()); String newGroupId = groupNewIdMap.get(oldIndexGroupId); if (StringUtils.isBlank(newGroupId)){ log.error("新旧id映射关系有误"); @@ -134,4 +134,4 @@ private IndexGroupTemplateDao indexGroupTemplateDao; });*/ return true; } -} \ No newline at end of file +} From 01741a8892e12af8aaada36d9ec792e168edfee1 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 26 Apr 2021 14:08:27 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E5=88=9D=E5=A7=8B=E5=8C=96=E5=B0=8F?= =?UTF-8?q?=E7=BB=84=E6=88=90=E5=B0=B1=E9=85=8D=E7=BD=AE=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AbstractStatsAchievementService.java | 3 ++ .../migration/V0.0.18__groupAchievement.sql | 54 ++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/AbstractStatsAchievementService.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/AbstractStatsAchievementService.java index 03e6dbcb07..ff77d49289 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/AbstractStatsAchievementService.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/AbstractStatsAchievementService.java @@ -21,6 +21,7 @@ import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.RenException; +import com.epmet.commons.tools.utils.UniqueIdGenerator; import com.epmet.modules.enums.AchievementTypeEnum; import com.epmet.modules.group.entity.ResiGroupAchievementConfigEntity; import com.epmet.modules.group.entity.ResiGroupAchievementStatsEntity; @@ -83,6 +84,8 @@ public abstract class AbstractStatsAchievementService { for (int i = 0; i < 5; i++) { nextTargetValue = GroupAchievementUtils.getNextTargetValue(achievementType, preValue); ResiGroupAchievementConfigEntity next = new ResiGroupAchievementConfigEntity(); + //生成ID 自增 + next.setId(UniqueIdGenerator.generate24()); next.setCustomerId(lastOne.getCustomerId()); next.setAchievementName(oldName.replace(StrConstant.UNDER_LINE, String.valueOf(nextTargetValue))); preValue = nextTargetValue; diff --git a/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.18__groupAchievement.sql b/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.18__groupAchievement.sql index c7243bcfa8..2bb5dc4dd0 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.18__groupAchievement.sql +++ b/epmet-module/resi-group/resi-group-server/src/main/resources/db/migration/V0.0.18__groupAchievement.sql @@ -34,4 +34,56 @@ CREATE TABLE `resi_group_achievement_stats` ( ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='小组成就统计表'; ALTER TABLE `resi_group` - ADD COLUMN `LEVEL` int(11) DEFAULT '1' COMMENT '小组等级' AFTER `GROUP_TYPE`; \ No newline at end of file + ADD COLUMN `LEVEL` int(11) DEFAULT '1' COMMENT '小组等级' AFTER `GROUP_TYPE`; + +-- ---------------------------- +-- Records of resi_group_achievement_config +-- ---------------------------- +BEGIN; +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700001', 'default', '组内第1名成员加入', 1, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700002', 'default', '组内成员达到3人', 3, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700003', 'default', '组内成员达到10人', 10, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700004', 'default', '组内成员达到20人', 20, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700005', 'default', '组内成员达到50人', 50, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700006', 'default', '组内成员达到100人', 100, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700007', 'default', '组内成员达到200人', 200, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700008', 'default', '组内成员达到500人', 500, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700009', 'default', '组内成员达到1000人', 1000, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700010', 'default', '组内成员达到2000人', 2000, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700011', 'default', '组内成员达到5000人', 5000, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261402388211700012', 'default', '组内成员达到10000人', 10000, 'member', '0', 0, 'APP_USER', '2021-04-19 16:19:49', 'APP_USER', '2021-04-19 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700001', 'default', '组内第1条话题诞生', 1, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700002', 'default', '组内发布话题数3条', 3, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700003', 'default', '组内发布话题数5条', 5, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700004', 'default', '组内发布话题数10条', 10, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700005', 'default', '组内发布话题数20条', 20, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700006', 'default', '组内发布话题数50条', 50, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700007', 'default', '组内发布话题数100条', 100, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700008', 'default', '组内发布话题数200条', 200, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700009', 'default', '组内发布话题数500条', 500, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700010', 'default', '组内发布话题数1000条', 1000, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700011', 'default', '组内发布话题数1500条', 1500, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700012', 'default', '组内发布话题数2000条', 2000, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700013', 'default', '组内发布话题数2500条', 2500, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261403464411700014', 'default', '组内发布话题数3000条', 3000, 'topic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404210411700001', 'default', '组内第1次话题转议题', 1, 'toissue', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404210411700002', 'default', '组内话题转议题数3条', 3, 'toissue', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404210411700003', 'default', '组内话题转议题数5条', 5, 'toissue', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404210411700004', 'default', '组内话题转议题数10条', 10, 'toissue', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404210411700005', 'default', '组内话题转议题数20条', 20, 'toissue', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404210411700006', 'default', '组内话题转议题数50条', 50, 'toissue', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404210411700007', 'default', '组内话题转议题数100条', 100, 'toissue', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404210411700008', 'default', '组内话题转议题数150条', 150, 'toissue', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404210411700009', 'default', '组内话题转议题数200条', 200, 'toissue', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404543611700001', 'default', '组内话题第1次被解决', 1, 'resovletopic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404543611700002', 'default', '组内话题解决数3条', 3, 'resovletopic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404543611700003', 'default', '组内话题解决数5条', 5, 'resovletopic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404543611700004', 'default', '组内话题解决数10条', 10, 'resovletopic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404543611700005', 'default', '组内话题解决数30条', 30, 'resovletopic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404543611700006', 'default', '组内话题解决数50条', 50, 'resovletopic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404543611700007', 'default', '组内话题解决数100条', 100, 'resovletopic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404543611700008', 'default', '组内话题解决数200条', 200, 'resovletopic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +INSERT INTO `resi_group_achievement_config` VALUES ('202104261404543611700009', 'default', '组内话题解决数300条', 300, 'resovletopic', '0', 0, 'APP_USER', '2021-04-20 16:19:49', 'APP_USER', '2021-04-20 16:19:52'); +COMMIT; + +SET FOREIGN_KEY_CHECKS = 1; From 806006871071a024d79afb0cfc30cd8aebf12d13 Mon Sep 17 00:00:00 2001 From: jianjun Date: Mon, 26 Apr 2021 14:41:09 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=20?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=8B=E5=8A=A1=E6=8F=90=E4=BA=A4=E5=90=8E?= =?UTF-8?q?=E5=86=8D=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/epmet/send/SendMqMsgUtil.java | 2 +- .../service/impl/ResiGroupServiceImpl.java | 19 ++++++--- .../impl/StatsAchievementServiceImpl.java | 34 ++++++++-------- .../impl/ResiGroupMemberServiceImpl.java | 21 +++++++--- .../service/impl/ResiTopicServiceImpl.java | 39 ++++++++++++++----- .../service/impl/TopicDraftServiceImpl.java | 22 ++++++++--- 6 files changed, 94 insertions(+), 43 deletions(-) diff --git a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java index 13fcfa4367..1880cb8bac 100644 --- a/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java +++ b/epmet-module/epmet-message/epmet-message-client/src/main/java/com/epmet/send/SendMqMsgUtil.java @@ -50,7 +50,7 @@ public class SendMqMsgUtil { systemMsgFormDTO.setMessageType(SystemMessageType.GROUP_ACHIEVEMENT); systemMsgFormDTO.setContent(msgContent); Result sendMsgResult = null; - int retryTime = 1; + int retryTime = 0; do { sendMsgResult = epmetMessageOpenFeignClient.sendSystemMsgByMQ(systemMsgFormDTO); } while ((sendMsgResult == null || !sendMsgResult.success()) && retryTime++ < NumConstant.TWO); diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java index 4b3abfb464..a630569ebb 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/group/service/impl/ResiGroupServiceImpl.java @@ -665,11 +665,20 @@ public class ResiGroupServiceImpl extends BaseServiceImpl queryWrapper = new QueryWrapper<>(); - queryWrapper.lambda().eq(ResiGroupEntity::getDelFlag,'0'); - if (StringUtils.isNotBlank(customerId)){ - queryWrapper.lambda().eq(ResiGroupEntity::getCustomerId,customerId); - } - List groupEntities = resiGroupDao.selectList(queryWrapper); - groupEntities.forEach(group->{ - AchievementTypeEnum[] achievementTypeEnum = AchievementTypeEnum.values(); - for (AchievementTypeEnum anEnum : achievementTypeEnum) { - try { - Thread.sleep(2); - } catch (InterruptedException e) { - e.printStackTrace(); - } - calculateAcm(group.getCustomerId(),group.getId(),anEnum.getCode()); + //计算所有类型的 小组人数、话题数、转议题数、小组内问题解决数 + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.lambda().eq(ResiGroupEntity::getDelFlag, '0'); + if (StringUtils.isNotBlank(customerId)) { + queryWrapper.lambda().eq(ResiGroupEntity::getCustomerId, customerId); + } + List groupEntities = resiGroupDao.selectList(queryWrapper); + groupEntities.forEach(group -> { + AchievementTypeEnum[] achievementTypeEnum = AchievementTypeEnum.values(); + for (AchievementTypeEnum anEnum : achievementTypeEnum) { + try { + Thread.sleep(2); + } catch (InterruptedException e) { + e.printStackTrace(); } - }); + calculateAcm(group.getCustomerId(), group.getId(), anEnum.getCode()); + } + }); return true; } diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java index b4bd5cd4d5..18ccfbc2c8 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/member/service/impl/ResiGroupMemberServiceImpl.java @@ -86,6 +86,8 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionSynchronizationAdapter; +import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.util.CollectionUtils; import java.text.DateFormat; @@ -657,11 +659,20 @@ public class ResiGroupMemberServiceImpl extends BaseServiceImpl msgList = new ArrayList<>(); msgList.add(wxSubscribeMessageFormDTO); epmetMessageOpenFeignClient.sendWxSubscribeMessage(msgList); - //发送小组成就消息 - boolean flag = SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendGroupAchievementMqMsg(new GroupAchievementMQMsg(resiGroupMemberDTO.getCustomerId(), resiGroupMemberDTO.getResiGroupId(), AchievementTypeEnum.MEMBER.getCode())); - if (!flag) { - logger.error("发送(小组成就)系统消息到message服务失败"); - } + TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { + @Override + public void afterCommit() { + try { + //发送小组成就消息 + boolean flag = SendMqMsgUtil.build().openFeignClient(epmetMessageOpenFeignClient).sendGroupAchievementMqMsg(new GroupAchievementMQMsg(resiGroupMemberDTO.getCustomerId(), resiGroupMemberDTO.getResiGroupId(), AchievementTypeEnum.MEMBER.getCode())); + if (!flag) { + logger.error("发送(小组成就)系统消息到message服务失败"); + } + }catch (Exception e){ + logger.error("afterCommit",e); + } + } + }); } /** diff --git a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java index 74e775128d..e497e699c4 100644 --- a/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java +++ b/epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/service/impl/ResiTopicServiceImpl.java @@ -111,6 +111,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.transaction.support.TransactionSynchronizationAdapter; +import org.springframework.transaction.support.TransactionSynchronizationManager; import org.springframework.util.CollectionUtils; import java.text.SimpleDateFormat; @@ -777,10 +779,19 @@ public class ResiTopicServiceImpl extends BaseServiceImpl