|
|
@ -17,24 +17,47 @@ |
|
|
|
|
|
|
|
package com.epmet.dataaggre.service.epmettduck.impl; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage; |
|
|
|
import com.epmet.commons.dynamic.datasource.annotation.DataSource; |
|
|
|
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; |
|
|
|
import com.epmet.commons.tools.constant.FieldConstant; |
|
|
|
import com.epmet.commons.tools.constant.NumConstant; |
|
|
|
import com.epmet.commons.tools.constant.StrConstant; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.dataaggre.constant.DataSourceConstant; |
|
|
|
import com.epmet.dataaggre.dao.epmettduck.PrUserProjectDao; |
|
|
|
import com.epmet.dataaggre.dao.epmettduck.PrVistRecordDao; |
|
|
|
import com.epmet.dataaggre.dto.epmettduck.PrUserProjectDTO; |
|
|
|
import com.epmet.dataaggre.dto.epmettduck.result.ProjectProfileResultDTO; |
|
|
|
import com.epmet.dataaggre.dto.epmettduck.ProjectItemTypeEnum; |
|
|
|
import com.epmet.dataaggre.dto.epmettduck.form.ItemResDetailFormDTO; |
|
|
|
import com.epmet.dataaggre.dto.epmettduck.form.ProjectKeyCommonDTO; |
|
|
|
import com.epmet.dataaggre.dto.epmettduck.form.TDuckHeaderInfoFormDTO; |
|
|
|
import com.epmet.dataaggre.dto.epmettduck.form.TDuckListFormDTO; |
|
|
|
import com.epmet.dataaggre.dto.epmettduck.result.*; |
|
|
|
import com.epmet.dataaggre.dto.epmettduck.struct.*; |
|
|
|
import com.epmet.dataaggre.entity.epmettduck.PrUserProjectEntity; |
|
|
|
import com.epmet.dataaggre.entity.epmettduck.PrUserProjectResultEntity; |
|
|
|
import com.epmet.dataaggre.service.epmettduck.PrPublishRangeService; |
|
|
|
import com.epmet.dataaggre.service.epmettduck.PrUserProjectService; |
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
|
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.util.*; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
/** |
|
|
|
* 项目表 |
|
|
@ -42,9 +65,16 @@ import java.util.Map; |
|
|
|
* @author generator generator@elink-cn.com |
|
|
|
* @since v1.0.0 2021-09-15 |
|
|
|
*/ |
|
|
|
@Slf4j |
|
|
|
@DataSource(DataSourceConstant.EPMETTDUCK) |
|
|
|
@Service |
|
|
|
public class PrUserProjectServiceImpl extends BaseServiceImpl<PrUserProjectDao, PrUserProjectEntity> implements PrUserProjectService { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private PrVistRecordDao visitRecordDao; |
|
|
|
@Resource |
|
|
|
private PrPublishRangeService prPublishRangeService; |
|
|
|
|
|
|
|
@Override |
|
|
|
public PageData<PrUserProjectDTO> page(Map<String, Object> params) { |
|
|
|
IPage<PrUserProjectEntity> page = baseDao.selectPage( |
|
|
@ -110,4 +140,531 @@ public class PrUserProjectServiceImpl extends BaseServiceImpl<PrUserProjectDao, |
|
|
|
return baseDao.queryProjectProfile(projectKey); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 问卷调查列表 |
|
|
|
* @Param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2021/9/18 10:29 上午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<TDuckListResultDTO> queryProjectList(TDuckListFormDTO formDTO) { |
|
|
|
List<String> projectKeys = baseDao.selectProjectKey(formDTO.getOrgIds()); |
|
|
|
if (CollectionUtils.isEmpty(projectKeys)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
PageInfo<TDuckListResultDTO> projectPageInfo = PageHelper.startPage(formDTO.getPageNo(), formDTO.getPageSize()).doSelectPageInfo(() -> baseDao.queryProjectList(projectKeys, formDTO.getStatus(), formDTO.getClient())); |
|
|
|
List<TDuckListResultDTO> result = projectPageInfo.getList(); |
|
|
|
List<String> records = visitRecordDao.selectVisitRecordByUserId(formDTO.getUserId()); |
|
|
|
if (!CollectionUtils.isEmpty(records)){ |
|
|
|
for (String r : records) { |
|
|
|
for (TDuckListResultDTO t : result) { |
|
|
|
if (r.equals(t.getKey())){ |
|
|
|
t.setFillStatus(true); |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 分析报告 |
|
|
|
* |
|
|
|
* @param projectKey |
|
|
|
* @return com.epmet.dataaggre.dto.epmettduck.result.AnalysisReportResDTO |
|
|
|
* @author yinzuomei |
|
|
|
* @date 2021/9/16 5:57 下午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<AnalysisReportResDTO> queryAnalysisReport(String projectKey) { |
|
|
|
List<AnalysisReportResDTO> itemList=baseDao.selectItems(projectKey); |
|
|
|
if(CollectionUtils.isEmpty(itemList)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
List<PrUserProjectResultEntity> resultList=baseDao.selectResults(projectKey); |
|
|
|
if(CollectionUtils.isEmpty(resultList)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
for(AnalysisReportResDTO item:itemList){ |
|
|
|
String currentType=item.getType(); |
|
|
|
String key="field".concat(item.getFormItemId()); |
|
|
|
log.info("key="+key); |
|
|
|
|
|
|
|
Map<String, Object> detail=new HashMap<>(); |
|
|
|
//总采集数
|
|
|
|
detail.put("collectionTotal",resultList.size()); |
|
|
|
//有效记录
|
|
|
|
int validTotal=0; |
|
|
|
|
|
|
|
//1、联系人组件统一用一个统计显示多少条,点击查看更多显示汇总列表,如有非必填项没有填写显示空(手机号验证不需要统计)
|
|
|
|
//2、单行文本、多行文本、时间选择、时间范围、日期选择、日期范围,统计填写人数,点击查看列表
|
|
|
|
if(ProjectItemTypeEnum.INPUT.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.PROVINCE_CITY.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.INPUT_MAP.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.TEXTAREA.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.TIME.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.TIME_RANGE.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.DATE.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.DATE_RANGE.getValue().equals(currentType)){ |
|
|
|
|
|
|
|
for(PrUserProjectResultEntity res:resultList){ |
|
|
|
|
|
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
|
//手机号、邮箱、身份证、单行文本: INPUT
|
|
|
|
//多行文本
|
|
|
|
//时间选择
|
|
|
|
//日期选择
|
|
|
|
if(ProjectItemTypeEnum.INPUT.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.TEXTAREA.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.TIME.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.DATE.getValue().equals(currentType)){ |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
if(StringUtils.isNotBlank(originalData.get(key).toString())){ |
|
|
|
validTotal+=1; |
|
|
|
} |
|
|
|
}else{ |
|
|
|
log.warn("没有当前的key:,可能用户没填写吧"+key); |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
//省市联动: PROVINCE_CITY
|
|
|
|
//时间范围选择
|
|
|
|
//日期范围选择
|
|
|
|
if(ProjectItemTypeEnum.PROVINCE_CITY.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.TIME_RANGE.getValue().equals(currentType) |
|
|
|
||ProjectItemTypeEnum.DATE_RANGE.getValue().equals(currentType)){ |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
List<String> provinceCityList= (List<String>) originalData.get(key); |
|
|
|
if(!CollectionUtils.isEmpty(provinceCityList)){ |
|
|
|
validTotal+=1; |
|
|
|
} |
|
|
|
} |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//地理位置:INPUT_MAP
|
|
|
|
if(ProjectItemTypeEnum.INPUT_MAP.getValue().equals(currentType)){ |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
List<String> provinceCityList= (List<String>) originalData.get(key); |
|
|
|
log.info("地理位置:"+JSON.toJSONString(provinceCityList,true)); |
|
|
|
if (!CollectionUtils.isEmpty(provinceCityList) && provinceCityList.size() == 3) { |
|
|
|
validTotal += 1; |
|
|
|
} |
|
|
|
} |
|
|
|
//不加也行,后面也没有代码块了
|
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
detail.put("validTotal",validTotal); |
|
|
|
item.setDetail(detail); |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 3、下拉选择、级联选择、单选框组、多选框组显示不同选项选择次数、所占比例
|
|
|
|
//3.1、下拉选择
|
|
|
|
if (ProjectItemTypeEnum.SELECT.getValue().equals(currentType)) { |
|
|
|
SelectExpandStruct selectExpandStruct = JSON.parseObject(item.getExpand(), SelectExpandStruct.class); |
|
|
|
List<OptionDTO> options = new ArrayList<>(); |
|
|
|
if (null != selectExpandStruct) { |
|
|
|
options = ConvertUtils.sourceToTarget(selectExpandStruct.getOptions(), OptionDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
//共选择了多少次,每道题相加
|
|
|
|
int totalCount = 0; |
|
|
|
for (OptionDTO optionDTO : options) { |
|
|
|
//currentCount:每道题,被选了多少次?
|
|
|
|
int currentCount = 0; |
|
|
|
for (PrUserProjectResultEntity res : resultList) { |
|
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
|
if (selectExpandStruct.getMultiple()) { |
|
|
|
//多选
|
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
List<Integer> answers = (List<Integer>) originalData.get(key); |
|
|
|
if (!CollectionUtils.isEmpty(answers) && answers.contains(optionDTO.getValue())) { |
|
|
|
currentCount += 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
//单选
|
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
Integer answer = (Integer) originalData.get(key); |
|
|
|
if (null != answer && optionDTO.getValue() == answer) { |
|
|
|
currentCount += 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
optionDTO.setCurrentCount(currentCount); |
|
|
|
totalCount += currentCount; |
|
|
|
} |
|
|
|
detail.put("totalCount", totalCount); |
|
|
|
detail.put("options", options); |
|
|
|
item.setDetail(detail); |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 3.2 单选
|
|
|
|
if (ProjectItemTypeEnum.RADIO.getValue().equals(currentType)) { |
|
|
|
RadioExpandStruct radioExpandStruct = JSON.parseObject(item.getExpand(), RadioExpandStruct.class); |
|
|
|
List<OptionDTO> options = new ArrayList<>(); |
|
|
|
if (null != radioExpandStruct) { |
|
|
|
options = ConvertUtils.sourceToTarget(radioExpandStruct.getOptions(), OptionDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
//共选择了多少次,每道题相加
|
|
|
|
int totalCount = 0; |
|
|
|
for (OptionDTO optionDTO : options) { |
|
|
|
//currentCount:每道题,被选了多少次?
|
|
|
|
int currentCount = 0; |
|
|
|
for (PrUserProjectResultEntity res : resultList) { |
|
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
|
//单选
|
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
Integer answer = (Integer) originalData.get(key); |
|
|
|
if (null != answer && optionDTO.getValue() == answer) { |
|
|
|
currentCount += 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
optionDTO.setCurrentCount(currentCount); |
|
|
|
totalCount += currentCount; |
|
|
|
} |
|
|
|
detail.put("totalCount", totalCount); |
|
|
|
detail.put("options", options); |
|
|
|
item.setDetail(detail); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
// 3.3多选
|
|
|
|
if (ProjectItemTypeEnum.CHECKBOX.getValue().equals(currentType)) { |
|
|
|
CheckboxExpandStruct checkboxExpandStruct = JSON.parseObject(item.getExpand(), CheckboxExpandStruct.class); |
|
|
|
List<OptionDTO> options = new ArrayList<>(); |
|
|
|
if (null != checkboxExpandStruct) { |
|
|
|
options = ConvertUtils.sourceToTarget(checkboxExpandStruct.getOptions(), OptionDTO.class); |
|
|
|
} |
|
|
|
|
|
|
|
//共选择了多少次,每道题相加
|
|
|
|
int totalCount = 0; |
|
|
|
for (OptionDTO optionDTO : options) { |
|
|
|
//currentCount:每道题,被选了多少次?
|
|
|
|
int currentCount = 0; |
|
|
|
for (PrUserProjectResultEntity res : resultList) { |
|
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
|
//多选
|
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
List<Integer> answers = (List<Integer>) originalData.get(key); |
|
|
|
if (!CollectionUtils.isEmpty(answers) && answers.contains(optionDTO.getValue())) { |
|
|
|
currentCount += 1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
optionDTO.setCurrentCount(currentCount); |
|
|
|
totalCount += currentCount; |
|
|
|
} |
|
|
|
detail.put("totalCount", totalCount); |
|
|
|
detail.put("options", options); |
|
|
|
item.setDetail(detail); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//3.4级联 todo
|
|
|
|
if(ProjectItemTypeEnum.CASCADER.getValue().equals(currentType)){ |
|
|
|
//目前cascaderExpandStruct 没啥用
|
|
|
|
CascaderExpandStruct cascaderExpandStruct = JSON.parseObject(item.getExpand(), CascaderExpandStruct.class); |
|
|
|
//共选择了多少次,每道题相加
|
|
|
|
int totalCount = 0; |
|
|
|
Map<String, Integer> resMap = new HashMap<>(); |
|
|
|
for (PrUserProjectResultEntity res : resultList) { |
|
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
List<CascaderDTO> dtoList = JSON.parseArray(originalData.get(key).toString(), CascaderDTO.class); |
|
|
|
if(CollectionUtils.isEmpty(dtoList)){ |
|
|
|
log.info(String.format("当前userId:%s,没有填写本题itemId:%s",res.getUserId(),key)); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
for (CascaderDTO cascaderDTO : dtoList) { |
|
|
|
if (null != cascaderDTO && !CollectionUtils.isEmpty(cascaderDTO.getLabels())) { |
|
|
|
totalCount += 1; |
|
|
|
String pathName = StringUtils.join(cascaderDTO.getLabels(), StringUtils.isNotBlank(cascaderExpandStruct.getSeparator()) ? cascaderExpandStruct.getSeparator() : StrConstant.HYPHEN); |
|
|
|
Integer count = resMap.get(pathName); |
|
|
|
resMap.put(pathName, count == null ? 1 : count + 1); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
detail.put("totalCount", totalCount); |
|
|
|
detail.put("profile", resMap); |
|
|
|
item.setDetail(detail); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//4、计数器显示所有填写者选择的数字总和
|
|
|
|
if(ProjectItemTypeEnum.NUMBER_INPUT.getValue().equals(currentType)){ |
|
|
|
int sumTotal=0; |
|
|
|
for(PrUserProjectResultEntity res:resultList){ |
|
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
Integer score= (Integer) originalData.get(key); |
|
|
|
if(null!=score){ |
|
|
|
sumTotal+=score; |
|
|
|
validTotal+=1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
detail.put("validTotal",validTotal); |
|
|
|
detail.put("sumTotal",sumTotal); |
|
|
|
item.setDetail(detail); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//5、开关统计开有多少、关有多少
|
|
|
|
if(ProjectItemTypeEnum.SWITCH.getValue().equals(currentType)){ |
|
|
|
int openTotal=0; |
|
|
|
int closedTotal=0; |
|
|
|
for(PrUserProjectResultEntity res:resultList){ |
|
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
Boolean result= (Boolean) originalData.get(key); |
|
|
|
if(null!=result){ |
|
|
|
validTotal+=1; |
|
|
|
if(result){ |
|
|
|
openTotal+=1; |
|
|
|
}else{ |
|
|
|
closedTotal+=1; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
detail.put("validTotal",validTotal); |
|
|
|
detail.put("openTotal",openTotal); |
|
|
|
detail.put("closedTotal",closedTotal); |
|
|
|
item.setDetail(detail); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
//6、滑块、颜色选择、上传不统计
|
|
|
|
|
|
|
|
//7、评分统计1星几人,2星几人,3星几人......,显示平均分
|
|
|
|
if (ProjectItemTypeEnum.RATE.getValue().equals(currentType)) { |
|
|
|
// 1、标签设置的满星是几个星星?
|
|
|
|
RateExpandStruct rateExpandStruct = JSON.parseObject(item.getExpand(), RateExpandStruct.class); |
|
|
|
if (null != rateExpandStruct && null != rateExpandStruct.getMax()) { |
|
|
|
detail.put("maxStarNum", rateExpandStruct.getMax()); |
|
|
|
} else { |
|
|
|
log.warn(String.format("当前评分组件未设置最大值,默认赋值5,projectKey:%s,itemId:%s",projectKey,item.getFormItemId())); |
|
|
|
detail.put("maxStarNum", NumConstant.FIVE); |
|
|
|
} |
|
|
|
|
|
|
|
//总分
|
|
|
|
int totalStarNum = 0; |
|
|
|
Map<Integer, Integer> starMap = new HashMap<>(); |
|
|
|
for (PrUserProjectResultEntity res : resultList) { |
|
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
Integer starNum = (Integer) originalData.get(key); |
|
|
|
if (null != starNum) { |
|
|
|
validTotal += 1; |
|
|
|
totalStarNum += starNum; |
|
|
|
Integer count = starMap.get(starNum); |
|
|
|
starMap.put(starNum, count == null ? 1 : count + 1); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//按照星星大小升序排列
|
|
|
|
this.sortMap(starMap, true); |
|
|
|
//2、平均分
|
|
|
|
detail.put("avgStarNum", new BigDecimal((float)totalStarNum / validTotal).setScale(0, BigDecimal.ROUND_HALF_UP)); |
|
|
|
//3、几条有效记录
|
|
|
|
detail.put("validTotal", validTotal); |
|
|
|
//4、得分列表
|
|
|
|
detail.put("starProfile", starMap); |
|
|
|
item.setDetail(detail); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
return itemList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 查询问卷调查的头部信息 |
|
|
|
* @Param formDTO |
|
|
|
* @author zxc |
|
|
|
* @date 2021/9/18 10:35 上午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public PrUserProjectEntity headerInfo(TDuckHeaderInfoFormDTO formDTO) { |
|
|
|
PrUserProjectEntity prUserProjectEntity = baseDao.selectOne(new QueryWrapper<PrUserProjectEntity>().lambda().eq(PrUserProjectEntity::getKey, formDTO.getProjectKey())); |
|
|
|
return prUserProjectEntity; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param projectKey |
|
|
|
* @Description 获取发布范围 |
|
|
|
* @Param projectKey |
|
|
|
* @Return {@link GetRangeResultDTO} |
|
|
|
* @Author zhaoqifeng |
|
|
|
* @Date 2021/9/18 15:18 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public GetRangeResultDTO getRange(String projectKey) { |
|
|
|
GetRangeResultDTO result = new GetRangeResultDTO(); |
|
|
|
LambdaQueryWrapper<PrUserProjectEntity> wrapper = new LambdaQueryWrapper<>(); |
|
|
|
wrapper.eq(PrUserProjectEntity :: getKey, projectKey); |
|
|
|
PrUserProjectEntity entity = baseDao.selectOne(wrapper); |
|
|
|
result.setClient(entity.getClient()); |
|
|
|
result.setOrgList(prPublishRangeService.getRangeOrgList(projectKey)); |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
private List<Map.Entry<Integer, Integer>> sortMap(Map<Integer, Integer> map, boolean asc) { |
|
|
|
|
|
|
|
Stream<Map.Entry<Integer, Integer>> stream = null; |
|
|
|
if (asc) { |
|
|
|
stream = map.entrySet().stream().sorted(Map.Entry.comparingByValue()); |
|
|
|
} else { |
|
|
|
stream = map.entrySet().stream().sorted(Collections.reverseOrder(Map.Entry.comparingByValue())); |
|
|
|
} |
|
|
|
return stream.collect(Collectors.toList()); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查看详情 |
|
|
|
* 1、联系人组件统一用一个统计显示多少条,点击查看更多显示汇总列表,如有非必填项没有填写显示空(手机号验证不需要统计) |
|
|
|
* 2、单行文本、多行文本、时间选择、时间范围、日期选择、日期范围,统计填写人数,点击查看列表 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return com.epmet.commons.tools.utils.Result |
|
|
|
* @author yinzuomei |
|
|
|
* @date 2021/9/22 1:37 下午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public List<String> queryItemResDetail(ItemResDetailFormDTO formDTO) { |
|
|
|
List<PrUserProjectResultEntity> resultList=baseDao.selectResults(formDTO.getProjectKey()); |
|
|
|
if(CollectionUtils.isEmpty(resultList)){ |
|
|
|
return new ArrayList<>(); |
|
|
|
} |
|
|
|
List<String> stringList=new ArrayList<>(); |
|
|
|
String key="field".concat(formDTO.getFormItemId()); |
|
|
|
for(PrUserProjectResultEntity res:resultList){ |
|
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
|
if(ProjectItemTypeEnum.INPUT.getValue().equals(formDTO.getType()) |
|
|
|
||ProjectItemTypeEnum.TEXTAREA.getValue().equals(formDTO.getType()) |
|
|
|
||ProjectItemTypeEnum.TIME.getValue().equals(formDTO.getType()) |
|
|
|
||ProjectItemTypeEnum.DATE.getValue().equals(formDTO.getType())){ |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
stringList.add((String) originalData.get(key)); |
|
|
|
continue; |
|
|
|
} |
|
|
|
}else if(ProjectItemTypeEnum.TIME_RANGE.getValue().equals(formDTO.getType()) |
|
|
|
||ProjectItemTypeEnum.DATE_RANGE.getValue().equals(formDTO.getType())){ |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
List<String> originalList= (List<String>) originalData.get(key); |
|
|
|
if(!CollectionUtils.isEmpty(originalList)){ |
|
|
|
String rangeStr=StringUtils.join(originalList,StrConstant.COMMA); |
|
|
|
stringList.add(rangeStr); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return stringList; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 联系人组件 |
|
|
|
* |
|
|
|
* @param formDTO |
|
|
|
* @return com.epmet.dataaggre.dto.epmettduck.result.ItemResDetailConcatResultDTO |
|
|
|
* @author yinzuomei |
|
|
|
* @date 2021/9/22 2:57 下午 |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
public ItemResDetailConcatResultDTO queryItemResDetailConcat(ProjectKeyCommonDTO formDTO) { |
|
|
|
// 联系人题目
|
|
|
|
List<AnalysisReportResDTO> itemList=baseDao.selectCocatItems(formDTO.getProjectKey()); |
|
|
|
if(CollectionUtils.isEmpty(itemList)){ |
|
|
|
return new ItemResDetailConcatResultDTO(); |
|
|
|
} |
|
|
|
//答案
|
|
|
|
List<PrUserProjectResultEntity> resultList=baseDao.selectResults(formDTO.getProjectKey()); |
|
|
|
if(CollectionUtils.isEmpty(resultList)){ |
|
|
|
return new ItemResDetailConcatResultDTO(); |
|
|
|
} |
|
|
|
|
|
|
|
ItemResDetailConcatResultDTO resultDTO=new ItemResDetailConcatResultDTO(); |
|
|
|
|
|
|
|
List<ConcatTableHeaderDTO> tableHeaderList=new ArrayList<>(); |
|
|
|
for(AnalysisReportResDTO item:itemList){ |
|
|
|
ConcatTableHeaderDTO headerDTO=new ConcatTableHeaderDTO(); |
|
|
|
headerDTO.setFormItemId(item.getFormItemId()); |
|
|
|
headerDTO.setLabel(item.getLabel()); |
|
|
|
headerDTO.setType(item.getType()); |
|
|
|
tableHeaderList.add(headerDTO); |
|
|
|
} |
|
|
|
|
|
|
|
List<List<String>> dataList=new ArrayList<>(); |
|
|
|
for(PrUserProjectResultEntity res:resultList){ |
|
|
|
List<String> userAnswer=new ArrayList<>(); |
|
|
|
JSONObject originalData = JSON.parseObject(res.getOriginalData()); |
|
|
|
|
|
|
|
for(ConcatTableHeaderDTO header:tableHeaderList){ |
|
|
|
String key="field".concat(header.getFormItemId()); |
|
|
|
|
|
|
|
//手机号、邮箱、身份证、单行文本: INPUT
|
|
|
|
if(ProjectItemTypeEnum.INPUT.getValue().equals(header.getType())){ |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
if(StringUtils.isNotBlank(originalData.get(key).toString())){ |
|
|
|
userAnswer.add((String) originalData.get(key)); |
|
|
|
}else{ |
|
|
|
userAnswer.add(StrConstant.EPMETY_STR); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
log.warn("没有当前的key:,可能用户没填写吧"+key); |
|
|
|
userAnswer.add(StrConstant.HYPHEN); |
|
|
|
} |
|
|
|
} |
|
|
|
//省市联动: PROVINCE_CITY
|
|
|
|
if(ProjectItemTypeEnum.PROVINCE_CITY.getValue().equals(header.getType())){ |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
List<String> provinceCityList= (List<String>) originalData.get(key); |
|
|
|
if(!CollectionUtils.isEmpty(provinceCityList)){ |
|
|
|
userAnswer.add(StringUtils.join(provinceCityList,StrConstant.HYPHEN)); |
|
|
|
}else{ |
|
|
|
userAnswer.add(StrConstant.EPMETY_STR); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
log.warn("没有当前的key:,可能用户没填写吧"+key); |
|
|
|
userAnswer.add(StrConstant.HYPHEN); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
//地理位置:INPUT_MAP
|
|
|
|
if(ProjectItemTypeEnum.INPUT_MAP.getValue().equals(header.getType())){ |
|
|
|
if(originalData.containsKey(key)){ |
|
|
|
List<String> inputMap= (List<String>) originalData.get(key); |
|
|
|
log.info("地理位置:"+JSON.toJSONString(inputMap,true)); |
|
|
|
if (!CollectionUtils.isEmpty(inputMap) && inputMap.size() == 3) { |
|
|
|
userAnswer.add(inputMap.get(2)); |
|
|
|
}else{ |
|
|
|
userAnswer.add(StrConstant.EPMETY_STR); |
|
|
|
} |
|
|
|
}else{ |
|
|
|
log.warn("没有当前的key:,可能用户没填写吧"+key); |
|
|
|
userAnswer.add(StrConstant.HYPHEN); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
dataList.add(userAnswer); |
|
|
|
} |
|
|
|
resultDTO.setTableHeaderList(tableHeaderList); |
|
|
|
resultDTO.setDataList(dataList); |
|
|
|
return resultDTO; |
|
|
|
} |
|
|
|
} |