Commit 693d08fb authored by 赵啸非's avatar 赵啸非

添加分类查询返回组

parent 493411c5
......@@ -12,6 +12,8 @@ import com.mortals.framework.util.ThreadPool;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.base.system.param.service.ParamService;
import com.mortals.xhx.base.system.user.model.UserEntity;
import com.mortals.xhx.common.code.AreaLevelEnum;
import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.common.utils.SyncDeptThread;
import com.mortals.xhx.common.utils.SyncGovMatterDetailThread;
......@@ -247,6 +249,58 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
return jsonObject.toJSONString();
}
/**
* 根据区域编码查询站点分组列表
*/
@PostMapping(value = "getFlatSitesGroupByAreaCode")
@UnAuth
public String getFlatSitesGroupByAreaCode(@RequestBody SiteQuery site) {
JSONObject jsonObject = new JSONObject();
String busiDesc = "根据区域编码查询站点列表" + this.getModuleDesc();
Map<String, List<SiteEntity>> collect = new HashMap<>();
try {
if (ObjectUtils.isEmpty(site.getAreaName()) && ObjectUtils.isEmpty(site.getAreaCode())) {
List<SiteEntity> siteEntities = this.service.find(new SiteQuery());
collect = siteEntities.stream().collect(Collectors.groupingBy(SiteEntity::getAreaName));
} else {
if (!ObjectUtils.isEmpty(site.getSiteName())) {
List<SiteEntity> siteEntities = this.service.find(new SiteQuery().siteName(site.getSiteName()));
if (!ObjectUtils.isEmpty(siteEntities)) {
site.setAreaCodeList(siteEntities.stream().map(i -> i.getAreaCode()).collect(Collectors.toList()));
}
}
if (!ObjectUtils.isEmpty(site.getAreaName())) {
List<AreaEntity> areaEntities = areaService.find(new AreaQuery().name(site.getAreaName()));
if (!ObjectUtils.isEmpty(areaEntities)) {
site.setAreaCodeList(areaEntities.stream().map(i -> i.getAreaCode()).collect(Collectors.toList()));
}
}
if (ObjectUtils.isEmpty(site.getAreaCodeList())) {
site.setAreaCodeList(Arrays.asList(site.getAreaCode()));
}
List<SiteEntity> siteEntityList = site.getAreaCodeList().stream()
.flatMap(areaCode -> this.service.getFlatSitesByAreaCode(areaCode, getContext()).stream())
.distinct()
.collect(Collectors.toList());
collect = siteEntityList.stream().collect(Collectors.groupingBy(x -> x.getAreaName()));
}
jsonObject.put(KEY_RESULT_DATA, collect);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "查询站点列表成功!");
if (!ObjectUtils.isEmpty(getContext()) && !ObjectUtils.isEmpty(getContext().getUser())) {
recordSysLog(request, busiDesc + " 【成功】");
}
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
/**
* 根据区域获取子站点数量
......@@ -312,6 +366,44 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
}
/**
* 根据区域等级查询当前区域所有站点
*/
@PostMapping(value = "getSitesGroupByAreaLevel")
@UnAuth
public String getSitesGroupByAreaLevel(@RequestBody SiteQuery site) {
JSONObject jsonObject = new JSONObject();
String busiDesc = "根据区域等级查询当前区域所有站点" + this.getModuleDesc();
Map<String, List<SiteEntity>> collect = new HashMap<>();
try {
if (ObjectUtils.isEmpty(site.getAreaLevel())) {
//全部
for (int i = 1; i <= 5; i++) {
site.setAreaLevel(i);
Rest<List<SiteEntity>> rest = this.service.getAreaSitesByAreaLevel(site, getContext());
String areaName = AreaLevelEnum.getByValue(i).getDesc();
collect.put(areaName, rest.getData());
}
} else {
Rest<List<SiteEntity>> rest = this.service.getAreaSitesByAreaLevel(site, getContext());
if (YesNoEnum.YES.getValue() == rest.getCode()) {
collect = rest.getData().stream().collect(Collectors.groupingBy(x -> x.getAreaName()));
jsonObject.put(KEY_RESULT_DATA, collect);
}
}
recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, busiDesc + "成功!");
} catch (Exception e) {
log.error("获取异常", e);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
jsonObject.put(KEY_RESULT_MSG, super.convertException(e));
}
return jsonObject.toJSONString();
}
@Override
protected int infoAfter(Long id, Map<String, Object> model, SiteEntity entity, Context context) throws AppException {
this.service.changeUrlPath(entity);
......
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