Browse Source

级联组件

master
yinzuomei 4 years ago
parent
commit
8668404a81
  1. 17
      epmet-module/data-aggregator/data-aggregator-client/src/main/java/com/epmet/dataaggre/dto/epmettduck/result/CascaderDTO.java
  2. 27
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmettduck/impl/PrUserProjectServiceImpl.java

17
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<String> labels;
private List<Integer> ids;
}

27
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<PrUserProjectDao,
continue;
}
//3.4级联 todo
//3.4级联
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());
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;
}

Loading…
Cancel
Save