Browse Source

Merge remote-tracking branch 'remotes/origin/dev'

dev
jianjun 4 years ago
parent
commit
d8c3b8116e
  1. 57
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/controller/external/IndexCalculateController.java
  2. 5
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/IndexCalculateService.java
  3. 33
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcal/impl/IndexCalculateServiceImpl.java
  4. 3
      epmet-module/epmet-common-service/common-service-server/src/main/java/com/epmet/service/impl/ExternalAppServiceImpl.java
  5. 4
      epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml
  6. 4
      epmet-module/gov-issue/gov-issue-client/src/main/java/com/epmet/dto/form/ShiftProjectFormDTO.java
  7. 4
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java
  8. 3
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/IssueService.java
  9. 231
      epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/service/impl/IssueServiceImpl.java

57
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; package com.epmet.controller.external;
import com.alibaba.fastjson.JSON;
import com.epmet.commons.tools.enums.EnvEnum; import com.epmet.commons.tools.enums.EnvEnum;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.redis.RedisKeys; import com.epmet.commons.tools.redis.RedisKeys;
@ -40,7 +41,7 @@ import java.util.concurrent.*;
@RequestMapping("indexcalculate") @RequestMapping("indexcalculate")
public class IndexCalculateController { public class IndexCalculateController {
ThreadFactory namedThreadFactory = new ThreadFactoryBuilder() ThreadFactory namedThreadFactory = new ThreadFactoryBuilder()
.setNameFormat("indexcalculate-pool-%d").build(); .setNameFormat("manual_execute_indexcal-pool-%d").build();
ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1, ExecutorService singleThreadPool = new ThreadPoolExecutor(1, 1,
0L, TimeUnit.MILLISECONDS, 0L, TimeUnit.MILLISECONDS,
new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy()); new LinkedBlockingQueue<Runnable>(1024), namedThreadFactory, new ThreadPoolExecutor.AbortPolicy());
@ -68,7 +69,7 @@ public class IndexCalculateController {
CalculateFlagModel flag = (CalculateFlagModel) redisUtils.get(RedisKeys.getCustomerStatsCalFlag(customerId)); CalculateFlagModel flag = (CalculateFlagModel) redisUtils.get(RedisKeys.getCustomerStatsCalFlag(customerId));
flag.setStatus(CalculateStatus.PENDDING); flag.setStatus(CalculateStatus.PENDDING);
redisUtils.set(RedisKeys.getCustomerStatsCalFlag(customerId), flag); 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 * @param formDTO
* @return com.epmet.commons.tools.utils.Result * @return com.epmet.commons.tools.utils.Result
@ -112,6 +113,35 @@ public class IndexCalculateController {
return new Result<Boolean>().ok(true); return new Result<Boolean>().ok(true);
} }
@PostMapping("calSingle")
public Result<Boolean> 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<Boolean>().ok(true);
}
} catch (Exception e) {
return new Result<Boolean>().error(e.getMessage());
}
return new Result<Boolean>().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(); return new Result();
} }
@PostMapping("reAll")
public Result<Boolean> 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<Boolean>().ok(true);
}
} catch (Exception e) {
return new Result<Boolean>().error(e.getMessage());
}
return new Result<Boolean>().error("指标计算失败");
}
/** /**
* desc计算党员指标分数 * desc计算党员指标分数
* *
@ -343,12 +358,6 @@ public class IndexCalculateController {
return new Result(); return new Result();
}*/ }*/
@PostMapping("indexstatistics")
public Result indexStatistics(@RequestBody IndexStatisticsFormDTO formDTO){
indexCalculateService.indexStatistics(formDTO);
return new Result();
}
/** /**
* @return com.epmet.commons.tools.utils.Result * @return com.epmet.commons.tools.utils.Result
* @param formDTO * @param formDTO

5
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); Boolean indexCalculate(CalculateCommonFormDTO formDTO);
/**
* desc:异步 连续计算[指定或所有内部客户][多个月份]的指标得分入口
* @param formDTO
* @return
*/
Boolean indexStatistics(IndexStatisticsFormDTO formDTO); Boolean indexStatistics(IndexStatisticsFormDTO formDTO);
/** /**

33
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; package com.epmet.service.evaluationindex.indexcal.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.epmet.commons.dynamic.datasource.annotation.DataSource; 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.enums.EnvEnum;
import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.utils.DateUtils; 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.crm.CustomerRelationService;
import com.epmet.service.evaluationindex.indexcal.*; import com.epmet.service.evaluationindex.indexcal.*;
import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService; import com.epmet.service.evaluationindex.indexcoll.FactIndexCollectService;
import com.epmet.service.stats.DimCustomerService;
import com.epmet.util.DimIdGenerator; import com.epmet.util.DimIdGenerator;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.ArrayList; import java.util.*;
import java.util.Date;
import java.util.List;
/** /**
* @author liujianjun * @author liujianjun
@ -58,6 +60,8 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
private ScreenCustomerAgencyDao screenCustomerAgencyDao; private ScreenCustomerAgencyDao screenCustomerAgencyDao;
@Autowired @Autowired
private CustomerRelationService customerRelationService; private CustomerRelationService customerRelationService;
@Autowired
private DimCustomerService dimCustomerService;
@Override @Override
public Boolean indexCalculate(CalculateCommonFormDTO formDTO) { public Boolean indexCalculate(CalculateCommonFormDTO formDTO) {
@ -67,14 +71,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1))); formDTO.setMonthId(DimIdGenerator.getMonthDimId(DateUtils.addDateMonths(new Date(), -1)));
} }
//按照客户分组 //按照客户分组
List<String> customerIds = new ArrayList<>(); Set<String> customerIds = new HashSet<>();
if (StringUtils.isBlank(formDTO.getCustomerId())) { if (StringUtils.isBlank(formDTO.getCustomerId())) {
log.error("什么情况下走的这个方法,应该干掉他,因为...=====param:{}",JSON.toJSONString(formDTO));
Result<List<String>> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds(); Result<List<String>> externalCustomerIdsResult = epmetCommonServiceOpenFeignClient.getExternalCustomerIds();
if (!externalCustomerIdsResult.success()) { if (!externalCustomerIdsResult.success()) {
log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail"); log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail");
return false; return false;
} }
customerIds = externalCustomerIdsResult.getData(); customerIds.addAll(externalCustomerIdsResult.getData());
} else { } else {
customerIds.add(formDTO.getCustomerId()); customerIds.add(formDTO.getCustomerId());
} }
@ -95,8 +100,7 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
} }
return flag; return flag;
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); log.warn("indexCalculate late exception",e);
log.warn("indexCalculate exception:{}",e);
log.error("indexCalculate exception,param:{}", JSON.toJSONString(formDTO)); log.error("indexCalculate exception,param:{}", JSON.toJSONString(formDTO));
} finally { } finally {
//清除缓存 //清除缓存
@ -212,12 +216,15 @@ public class IndexCalculateServiceImpl implements IndexCalculateService {
public Boolean indexStatistics(IndexStatisticsFormDTO formDTO) { public Boolean indexStatistics(IndexStatisticsFormDTO formDTO) {
List<String> customerIds = new ArrayList<>(); List<String> customerIds = new ArrayList<>();
if (StringUtils.isEmpty(formDTO.getCustomerId())){ if (StringUtils.isEmpty(formDTO.getCustomerId())){
Result<List<String>> externalCustomerIds = epmetCommonServiceOpenFeignClient.getExternalCustomerIds(); int pageNo = NumConstant.ONE;
if (!externalCustomerIds.success()){ int pageSize = NumConstant.ONE_HUNDRED;
log.error("indexCalculate epmetCommonServiceOpenFeignClient.getExternalCustomerIds return fail"); List<String> customerIdList = null;
return false; do {
} customerIdList = dimCustomerService.selectCustomerIdPage(pageNo++, pageSize);
customerIds = externalCustomerIds.getData(); if (!CollectionUtils.isEmpty(customerIdList)){
customerIds.addAll(customerIdList);
}
} while (!CollectionUtil.isEmpty(customerIdList) && customerIdList.size() == pageSize);
}else { }else {
customerIds.add(formDTO.getCustomerId()); customerIds.add(formDTO.getCustomerId());
} }

3
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 @Override
public List<String> getCustomerIds() { public List<String> getCustomerIds() {
return externalAppDao.getCustomerIds(); return externalAppDao.getCustomerIds();
} }
@ -224,4 +223,4 @@ public class ExternalAppServiceImpl implements ExternalAppService {
return appIdInfoResultDTO; return appIdInfoResultDTO;
} }
} }

4
epmet-module/epmet-common-service/common-service-server/src/main/resources/mapper/ExternalAppDao.xml

@ -66,7 +66,7 @@
</select> </select>
<select id="getCustomerIds" resultType="java.lang.String"> <select id="getCustomerIds" resultType="java.lang.String">
SELECT CUSTOMER_ID FROM external_app WHERE DEL_FLAG = 0 SELECT ID FROM external_customer WHERE DEL_FLAG = 0
</select> </select>
<!-- 根据appId查询客户ID和密钥 --> <!-- 根据appId查询客户ID和密钥 -->
@ -84,4 +84,4 @@
</select> </select>
</mapper> </mapper>

4
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<IssueTagsDTO> tagList; private List<IssueTagsDTO> tagList;
/**
* token中客户Id
*/
private String customerId;
} }

4
epmet-module/gov-issue/gov-issue-server/src/main/java/com/epmet/controller/IssueManageController.java

@ -181,9 +181,9 @@ public class IssueManageController {
@PostMapping("shiftproject-v2") @PostMapping("shiftproject-v2")
public Result shiftProjectV2(@LoginUser TokenDto tokenDTO, @RequestBody ShiftProjectFormDTO formDTO) { public Result shiftProjectV2(@LoginUser TokenDto tokenDTO, @RequestBody ShiftProjectFormDTO formDTO) {
formDTO.setStaffId(tokenDTO.getUserId()); formDTO.setStaffId(tokenDTO.getUserId());
formDTO.setCustomerId(tokenDTO.getCustomerId());
ValidatorUtils.validateEntity(formDTO); ValidatorUtils.validateEntity(formDTO);
issueService.shiftProjectV2(formDTO); return issueService.shiftProjectV2(formDTO);
return new Result();
} }
/** /**

3
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.mybatis.service.BaseService;
import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.dto.IssueDTO; import com.epmet.dto.IssueDTO;
import com.epmet.dto.form.*; import com.epmet.dto.form.*;
import com.epmet.dto.result.*; import com.epmet.dto.result.*;
@ -219,7 +220,7 @@ public interface IssueService extends BaseService<IssueEntity> {
* @param formDTO * @param formDTO
* @return void * @return void
*/ */
void shiftProjectV2(ShiftProjectFormDTO formDTO); Result shiftProjectV2(ShiftProjectFormDTO formDTO);
/** /**
* @Description 已关闭列表 政府端 * @Description 已关闭列表 政府端

231
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.AppClientConstant;
import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.FieldConstant;
import com.epmet.commons.tools.constant.NumConstant; 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.dto.result.CustomerStaffInfoCacheResult;
import com.epmet.commons.tools.enums.AchievementTypeEnum;
import com.epmet.commons.tools.enums.EventEnum; import com.epmet.commons.tools.enums.EventEnum;
import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetErrorCode;
import com.epmet.commons.tools.exception.EpmetException; 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.IssueProcessEntity;
import com.epmet.entity.IssueProjectRelationEntity; import com.epmet.entity.IssueProjectRelationEntity;
import com.epmet.feign.*; import com.epmet.feign.*;
import com.epmet.commons.tools.enums.AchievementTypeEnum;
import com.epmet.redis.GovIssueRedis; import com.epmet.redis.GovIssueRedis;
import com.epmet.redis.IssueVoteDetailRedis; import com.epmet.redis.IssueVoteDetailRedis;
import com.epmet.resi.group.dto.group.form.AllIssueFormDTO; 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.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.redisson.api.RLock;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -136,6 +138,8 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
private GovProjectOpenFeignClient govProjectOpenFeignClient; private GovProjectOpenFeignClient govProjectOpenFeignClient;
@Autowired @Autowired
private IssueVoteDetailService issueVoteDetailService; private IssueVoteDetailService issueVoteDetailService;
@Autowired
private DistributedLock distributedLock;
@Value("${openapi.scan.server.url}") @Value("${openapi.scan.server.url}")
@ -957,127 +961,138 @@ public class IssueServiceImpl extends BaseServiceImpl<IssueDao, IssueEntity> imp
* @date 2020/12/9 10:01 * @date 2020/12/9 10:01
*/ */
@Override @Override
public void shiftProjectV2(ShiftProjectFormDTO formDTO) { public Result shiftProjectV2(ShiftProjectFormDTO formDTO) {
//1:查询议题数据 RLock lock = null;
IssueEntity entity = baseDao.selectById(formDTO.getIssueId()); try {
if (null == entity) { //获取锁,判断当前议题是否已处理
throw new RenException(IssueConstant.SELECT_EXCEPTION); lock = distributedLock.tryLock(formDTO.getCustomerId() + formDTO.getIssueId());
} //1:查询议题数据
if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) { IssueEntity entity = baseDao.selectById(formDTO.getIssueId());
throw new RenException(IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION); if (null == entity) {
} throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SELECT_EXCEPTION,IssueConstant.SELECT_EXCEPTION);
if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) { }
throw new RenException(IssueConstant.ISSUE_VOTING_EXCEPTION); if (IssueConstant.ISSUE_SHIFT_PROJECT.equals(entity.getIssueStatus())) {
} throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION,IssueConstant.ISSUE_SHIFT_PROJECT_EXCEPTION);
formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class)); }
if (!IssueConstant.ISSUE_VOTING.equals(entity.getIssueStatus())) {
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.ISSUE_VOTING_EXCEPTION,IssueConstant.ISSUE_VOTING_EXCEPTION);
}
formDTO.setIssueDTO(ConvertUtils.sourceToTarget(entity, IssueDTO.class));
//获取议题分类 //获取议题分类
List<IssueCategoryDTO> categoryList = issueCategoryService.getCategoryByIssue(formDTO.getIssueId()); List<IssueCategoryDTO> categoryList = issueCategoryService.getCategoryByIssue(formDTO.getIssueId());
if (CollectionUtils.isEmpty(categoryList)) { 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());
} }
//公开回复内容审核 //公开回复内容审核
if (StringUtils.isNotBlank(formDTO.getPublicReply())) { if (StringUtils.isNotBlank(formDTO.getPublicReply())) {
TextScanParamDTO textScanParamDTO = new TextScanParamDTO(); TextScanParamDTO textScanParamDTO = new TextScanParamDTO();
TextTaskDTO taskDTO = new TextTaskDTO(); TextTaskDTO taskDTO = new TextTaskDTO();
taskDTO.setDataId(UUID.randomUUID().toString().replace("-", "")); taskDTO.setDataId(UUID.randomUUID().toString().replace("-", ""));
taskDTO.setContent(formDTO.getPublicReply()); taskDTO.setContent(formDTO.getPublicReply());
textScanParamDTO.getTasks().add(taskDTO); textScanParamDTO.getTasks().add(taskDTO);
Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO); Result<SyncScanResult> textSyncScanResult = ScanContentUtils.textSyncScan(scanApiUrl.concat(textSyncScanMethod), textScanParamDTO);
if (!textSyncScanResult.success()) { 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 { } else {
if (!textSyncScanResult.getData().isAllPass()) { 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());
}
} }
} }
}
//因需要保证议题表中的转项目时间与创建项目时间一致 因此先新增项目数据再更新议题数据
//2:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用
Result<ResiTopicDTO> 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<IssueTagsDTO> tagList = issueTagsService.getTagsByIssue(formDTO.getIssueId());
formDTO.setTagList(tagList);
Result<IssueProjectResultDTO> 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:调用resi-group查询话题创建人数据(目前议题来源只有来自话题),为了到项目服务初始数据以及发送消息使用
//4.1:更新议题表数据 Result<ResiTopicDTO> resultTopicDTO = resiGroupFeignClient.getTopicById(entity.getSourceId());
entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); if (!resultTopicDTO.success() || null == resultTopicDTO.getData()) {
entity.setShiftedTime(issueProjectResultDTO.getShiftedTime()); throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.SELECT_TOPIC_EXCEPTION,IssueConstant.SELECT_TOPIC_EXCEPTION);
baseDao.updateById(entity); }
ResiTopicDTO topicDTO = resultTopicDTO.getData();
formDTO.setTopicDTO(topicDTO);
//3:调用gov-project服务,新增项目各业务表初始数据
formDTO.setCategoryList(categoryList);
List<IssueTagsDTO> tagList = issueTagsService.getTagsByIssue(formDTO.getIssueId());
formDTO.setTagList(tagList);
Result<IssueProjectResultDTO> resultDTO = govProjectFeignClient.issueShiftProject(formDTO);
if (!resultDTO.success() || null == resultDTO.getData()) {
logger.error(resultDTO.getInternalMsg());
throw new EpmetException(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(),IssueConstant.GOV_PRJECT_EXCEPTION,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:议题处理进展表新增数据 //4:更新议题相关业务表数据
IssueProcessEntity processEntity = new IssueProcessEntity(); //4.1:更新议题表数据
processEntity.setIssueId(entity.getId()); entity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT);
processEntity.setIssueStatus(IssueConstant.ISSUE_SHIFT_PROJECT); entity.setShiftedTime(issueProjectResultDTO.getShiftedTime());
processEntity.setOrgType(IssueConstant.ISSUE_GRID); baseDao.updateById(entity);
processEntity.setOrgId(entity.getGridId());
processEntity.setOrgName(issueProjectResultDTO.getOrgName()); //4.2:议题处理进展表新增数据
issueProcessDao.insert(processEntity); 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 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()) {
logger.error("议题转项目,推送微信订阅消息失败!");
}
//4.3:议题项目关系表新增数据 //6:缓存中网格下表决中的议题总数减1
IssueProjectRelationEntity relationEntity = new IssueProjectRelationEntity(); govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId());
relationEntity.setIssueId(entity.getId()); try{
relationEntity.setProjectId(issueProjectResultDTO.getProjectId()); issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null);
issueProjectRelationDao.insert(relationEntity); }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 //7:发送话题转议题积分事件
govIssueRedis.subtractWorkGrassrootsIssueRedDotValue(entity.getGridId()); TopicEventFormDTO eventParam = new TopicEventFormDTO();
try{ eventParam.setTopicId(entity.getSourceId());
issueVoteStatisticalService.syncVotingCacheToDbByParams(formDTO.getIssueId(),entity.getGridId(),null); eventParam.setEvent(EventEnum.TOPIC_SHIFTED_TO_PROJECT);
}catch(RenException e){ if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){
logger.error(e.getInternalMsg()); 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:发送话题转议题积分事件 //8.记录日志
TopicEventFormDTO eventParam = new TopicEventFormDTO(); //SendMqMsgUtil.build().openFeignClient(messageOpenFeignClient).sendProjectChangedMqMsg();
eventParam.setTopicId(entity.getSourceId()); return new Result();
eventParam.setEvent(EventEnum.TOPIC_SHIFTED_TO_PROJECT); } catch (Exception e) {
if(!resiGroupOpenFeignClient.sendEvent(eventParam).success()){ return new Result().error(e.getMessage());
logger.warn("com.epmet.service.impl.IssueServiceImpl.shiftProjectV2,话题被转为项目积分事件发送失败,参数:{}", JSON.toJSONString(formDTO)); } 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();
} }
/** /**

Loading…
Cancel
Save