Commit 14bc5ff1 by guojuxing

Merge remote-tracking branch 'origin/developer' into developer

parents 2a00277c 4680f423
package com.gic.plug.web.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.constants.Constants;
import com.gic.enterprise.utils.UserDetailUtils;
import com.gic.goods.api.util.Constant;
import com.gic.plug.web.vo.WidgetValuesNewVO;
import com.gic.plug.web.vo.WidgetValuesOldVO;
import com.gic.widget.screening.api.dto.EsScreeningChainDetailDTO;
import com.gic.widget.screening.api.dto.EsScreeningEnterpriseCategorySceneInfoDTO;
import com.gic.widget.screening.api.dto.EsScreeningTemplateDTO;
import com.gic.widget.screening.api.service.EsScreeningInitService;
import com.gic.widget.screening.api.service.EsScreeningTemplateService;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -21,6 +27,7 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
......@@ -88,6 +95,12 @@ public class ScreeningController {
for (EsScreeningEnterpriseCategorySceneInfoDTO dto : list) {
String categoryId = dto.getSceneCategoryId();
EsScreeningChainDetailDTO item = this.esScreeningInitService.findRootChainByCategoryId(categoryId);
String widgetValues = item.getWidget().getWidgetValues();
if (StringUtils.isNotBlank(widgetValues)) {
List<WidgetValuesOldVO> oldVOS = JSONObject.parseArray(widgetValues, WidgetValuesOldVO.class);
List<WidgetValuesNewVO> newVOList = oldVOS.stream().map(data -> new WidgetValuesNewVO(data.getKey(), data.getValue(), data.getName())).collect(Collectors.toList());
item.getWidget().setWidgetValues(JSON.toJSONString(newVOList));
}
all.add(item);
}
return RestResponse.success(all);
......@@ -98,6 +111,15 @@ public class ScreeningController {
public RestResponse getScreeningData(String widgetChainId) {
List<EsScreeningChainDetailDTO> list = this.esScreeningInitService
.queryEsScreeningByParentChainId(widgetChainId);
if (CollectionUtils.isNotEmpty(list)) {
list = list.stream().peek(item -> {
if (StringUtils.isNotBlank(item.getWidget().getWidgetValues())) {
List<WidgetValuesOldVO> oldVOS = JSONObject.parseArray(item.getWidget().getWidgetValues(), WidgetValuesOldVO.class);
List<WidgetValuesNewVO> newVOList = oldVOS.stream().map(data -> new WidgetValuesNewVO(data.getKey(), data.getValue(), data.getName())).collect(Collectors.toList());
item.getWidget().setWidgetValues(JSON.toJSONString(newVOList));
}
}).collect(Collectors.toList());
}
return RestResponse.success(list);
}
......@@ -105,6 +127,11 @@ public class ScreeningController {
@ResponseBody
public RestResponse getScreeningChainDetail(String parentChainId, String widgetFieldKey) {
EsScreeningChainDetailDTO dto = this.esScreeningInitService.findChainDetail(parentChainId, widgetFieldKey);
if (dto != null && dto.getWidget() != null && StringUtils.isNotBlank(dto.getWidget().getWidgetValues())) {
List<WidgetValuesOldVO> oldVOS = JSONObject.parseArray(dto.getWidget().getWidgetValues(), WidgetValuesOldVO.class);
List<WidgetValuesNewVO> newVOList = oldVOS.stream().map(data -> new WidgetValuesNewVO(data.getKey(), data.getValue(), data.getName())).collect(Collectors.toList());
dto.getWidget().setWidgetValues(JSON.toJSONString(newVOList));
}
return RestResponse.success(dto);
}
......@@ -113,6 +140,11 @@ public class ScreeningController {
@ResponseBody
public Object getScreeningWidgetDetail(String widgetChainId) {
EsScreeningChainDetailDTO dto = this.esScreeningInitService.findChainDetail(widgetChainId);
if (dto != null && dto.getWidget() != null && StringUtils.isNotBlank(dto.getWidget().getWidgetValues())) {
List<WidgetValuesOldVO> oldVOS = JSONObject.parseArray(dto.getWidget().getWidgetValues(), WidgetValuesOldVO.class);
List<WidgetValuesNewVO> newVOList = oldVOS.stream().map(data -> new WidgetValuesNewVO(data.getKey(), data.getValue(), data.getName())).collect(Collectors.toList());
dto.getWidget().setWidgetValues(JSON.toJSONString(newVOList));
}
return RestResponse.success(dto);
}
}
package com.gic.plug.web.vo;
import java.io.Serializable;
/**
*
* @Description:
* @author zhiwj
* @date 2021-01-28 9:55
*/
public class WidgetValuesNewVO implements Serializable {
private String key;
private String label;
private String value;
public WidgetValuesNewVO() {
}
public WidgetValuesNewVO(String key, String label, String value) {
this.key = key;
this.label = label;
this.value = value;
}
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
}
package com.gic.plug.web.vo;
import java.io.Serializable;
/**
*
* @Description:
* @author zhiwj
* @date 2021-01-28 9:55
*/
public class WidgetValuesOldVO implements Serializable {
private String key;
private String value;
private String name;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getValue() {
return value;
}
public void setValue(String value) {
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment