|
@ -20,6 +20,7 @@ package com.epmet.service.impl; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
|
|
import com.epmet.commons.tools.distributedlock.DistributedLock; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.EpmetErrorCode; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.exception.RenException; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
@ -32,16 +33,23 @@ import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
import com.epmet.commons.tools.utils.ScanContentUtils; |
|
|
import com.epmet.commons.tools.utils.ScanContentUtils; |
|
|
import com.epmet.constant.ProjectConstant; |
|
|
import com.epmet.constant.ProjectConstant; |
|
|
|
|
|
import com.epmet.dao.ProjectDao; |
|
|
import com.epmet.dao.ProjectSatisfactionDetailDao; |
|
|
import com.epmet.dao.ProjectSatisfactionDetailDao; |
|
|
|
|
|
import com.epmet.dao.ProjectSatisfactionStatisticsDao; |
|
|
import com.epmet.dto.ProjectSatisfactionDetailDTO; |
|
|
import com.epmet.dto.ProjectSatisfactionDetailDTO; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.form.*; |
|
|
import com.epmet.dto.result.*; |
|
|
import com.epmet.dto.result.*; |
|
|
|
|
|
import com.epmet.entity.ProjectEntity; |
|
|
import com.epmet.entity.ProjectSatisfactionDetailEntity; |
|
|
import com.epmet.entity.ProjectSatisfactionDetailEntity; |
|
|
|
|
|
import com.epmet.entity.ProjectSatisfactionStatisticsEntity; |
|
|
import com.epmet.feign.EpmetUserFeignClient; |
|
|
import com.epmet.feign.EpmetUserFeignClient; |
|
|
|
|
|
import com.epmet.feign.GovIssueOpenFeignClient; |
|
|
|
|
|
import com.epmet.redis.ProjectRedis; |
|
|
import com.epmet.redis.ProjectSatisfactionDetailRedis; |
|
|
import com.epmet.redis.ProjectSatisfactionDetailRedis; |
|
|
import com.epmet.service.ProjectSatisfactionDetailService; |
|
|
import com.epmet.service.ProjectSatisfactionDetailService; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.redisson.api.RLock; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.BeanUtils; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
|
import org.springframework.beans.factory.annotation.Value; |
|
@ -69,6 +77,16 @@ public class ProjectSatisfactionDetailServiceImpl extends BaseServiceImpl<Projec |
|
|
private String scanApiUrl; |
|
|
private String scanApiUrl; |
|
|
@Value("${openapi.scan.method.textSyncScan}") |
|
|
@Value("${openapi.scan.method.textSyncScan}") |
|
|
private String textSyncScanMethod; |
|
|
private String textSyncScanMethod; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private DistributedLock distributedLock; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ProjectSatisfactionStatisticsDao statisticsDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ProjectDao projectDao; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private ProjectRedis projectRedis; |
|
|
|
|
|
@Autowired |
|
|
|
|
|
private GovIssueOpenFeignClient govIssueOpenFeignClient; |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public PageData<ProjectSatisfactionDetailDTO> page(Map<String, Object> params) { |
|
|
public PageData<ProjectSatisfactionDetailDTO> page(Map<String, Object> params) { |
|
@ -216,6 +234,58 @@ public class ProjectSatisfactionDetailServiceImpl extends BaseServiceImpl<Projec |
|
|
throw new RenException(EpmetErrorCode.ALREADY_EVALUATE.getCode()); |
|
|
throw new RenException(EpmetErrorCode.ALREADY_EVALUATE.getCode()); |
|
|
} |
|
|
} |
|
|
baseDao.insert(entity); |
|
|
baseDao.insert(entity); |
|
|
|
|
|
|
|
|
|
|
|
RLock lock = null; |
|
|
|
|
|
try { |
|
|
|
|
|
lock = distributedLock.getLock("evaluate_project"); |
|
|
|
|
|
if (null != lock){ |
|
|
|
|
|
ProjectEntity projectEntity = projectDao.selectById(formDTO.getProjectId()); |
|
|
|
|
|
if (null == projectEntity){ |
|
|
|
|
|
throw new RenException("未查询到项目信息"); |
|
|
|
|
|
} |
|
|
|
|
|
VoteRedisFormDTO issueVoteDetail = projectRedis.getIssueVoteDetail(projectEntity.getOriginId()); |
|
|
|
|
|
// 应评价数 = 话题创建者 + 议题发起者 + 议题表决人 【去重】
|
|
|
|
|
|
// 议题发起者 和 议题表决人 和 话题创建者 查询
|
|
|
|
|
|
Result<List<String>> canEvaluateProjectCount = govIssueOpenFeignClient.canEvaluateProjectCount(projectEntity.getOriginId()); |
|
|
|
|
|
if (!canEvaluateProjectCount.success()){ |
|
|
|
|
|
throw new RenException("【查询项目应评价人数失败】,【"+canEvaluateProjectCount.getMsg()+"】"); |
|
|
|
|
|
} |
|
|
|
|
|
List<String> userIds = canEvaluateProjectCount.getData(); |
|
|
|
|
|
// 校验此项目记录是否存在
|
|
|
|
|
|
Integer count = statisticsDao.checkProjectExists(formDTO.getProjectId()); |
|
|
|
|
|
if (count == NumConstant.ZERO){ |
|
|
|
|
|
ProjectSatisfactionStatisticsEntity entity1 = new ProjectSatisfactionStatisticsEntity(); |
|
|
|
|
|
entity1.setShouldEvaluateCount(userIds.size()); |
|
|
|
|
|
entity1.setCustomerId(formDTO.getCustomerId()); |
|
|
|
|
|
entity1.setProjectId(formDTO.getProjectId()); |
|
|
|
|
|
entity1.setBadCount(NumConstant.ZERO); |
|
|
|
|
|
entity1.setGoodCount(NumConstant.ZERO); |
|
|
|
|
|
entity1.setPerfectCount(NumConstant.ZERO); |
|
|
|
|
|
switch (formDTO.getSatisfaction()){ |
|
|
|
|
|
case ProjectConstant.EVALUATE_BAD: |
|
|
|
|
|
entity1.setBadCount(NumConstant.ONE); |
|
|
|
|
|
break; |
|
|
|
|
|
case ProjectConstant.EVALUATE_GOOD: |
|
|
|
|
|
entity1.setGoodCount(NumConstant.ONE); |
|
|
|
|
|
break; |
|
|
|
|
|
case ProjectConstant .EVALUATE_PERFECT: |
|
|
|
|
|
entity1.setPerfectCount(NumConstant.ONE); |
|
|
|
|
|
default: |
|
|
|
|
|
} |
|
|
|
|
|
// 新添一条记录
|
|
|
|
|
|
statisticsDao.insert(entity1); |
|
|
|
|
|
}else { |
|
|
|
|
|
// 更新
|
|
|
|
|
|
statisticsDao.updateEvaluateData(formDTO.getProjectId(), formDTO.getSatisfaction(),userIds.size()); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}catch (Exception e){ |
|
|
|
|
|
throw new RenException(e.getMessage()); |
|
|
|
|
|
}finally { |
|
|
|
|
|
if (lock != null){ |
|
|
|
|
|
lock.unlock(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|