From 8668404a81df46706ede64bbee38a0bc4b358dcf Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Wed, 22 Sep 2021 12:06:38 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A7=E8=81=94=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dto/epmettduck/result/CascaderDTO.java | 17 +++++++++--- .../impl/PrUserProjectServiceImpl.java | 27 +++++++++++++++++-- 2 files changed, 39 insertions(+), 5 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmettduck/result/CascaderDTO.java b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmettduck/result/CascaderDTO.java index 1421c6b192..82904a64e9 100644 --- a/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmettduck/result/CascaderDTO.java +++ b/epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmettduck/result/CascaderDTO.java @@ -6,14 +6,14 @@ import java.io.Serializable; import java.util.List; /** - * @Description TODO + * @Description 级联选择组件答案参数格式 * @Author yinzuomei * @Date 2021/9/18 3:40 下午 */ @Data public class CascaderDTO implements Serializable { /** - * 选项id + * 当前选择的选项id */ private Integer id; /** @@ -21,8 +21,19 @@ public class CascaderDTO implements Serializable { */ private String label; + /** + * 选项名 + */ private String value; + + /** + * pid + */ + private String pid; + + /** + * 全路径名字 + */ private List labels; - private List ids; } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmettduck/impl/PrUserProjectServiceImpl.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmettduck/impl/PrUserProjectServiceImpl.java index 645b2dbd6a..d2e119198e 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmettduck/impl/PrUserProjectServiceImpl.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmettduck/impl/PrUserProjectServiceImpl.java @@ -26,6 +26,7 @@ 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; @@ -365,12 +366,34 @@ public class PrUserProjectServiceImpl extends BaseServiceImpl resMap = new HashMap<>(); + for (PrUserProjectResultEntity res : resultList) { + JSONObject originalData = JSON.parseObject(res.getOriginalData()); + List 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; }