Commit 8ff78877 authored by 赵啸非's avatar 赵啸非

添加多级查询区域下站点

parent 9bcab233
package com.mortals.xhx.module.site.model; package com.mortals.xhx.module.site.model;
import com.mortals.xhx.module.site.model.vo.SiteBusinessVo;
/** /**
* 站点事项实体对象 * 站点事项实体对象
* *
......
package com.mortals.xhx.module.site.model; package com.mortals.xhx.module.site.model;
import java.util.List; import java.util.List;
import java.util.ArrayList;
import com.mortals.xhx.module.site.model.vo.SiteBusinessVo;
import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonInclude;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
......
package com.mortals.xhx.module.site.model.vo; package com.mortals.xhx.module.site.model;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.business.model.BusinessEntity; import com.mortals.xhx.module.business.model.BusinessEntity;
import com.mortals.xhx.module.site.model.SiteBusinessEntity; import com.mortals.xhx.module.site.model.SiteBusinessEntity;
......
package com.mortals.xhx.module.site.model; package com.mortals.xhx.module.site.model;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.site.model.vo.SiteVo;
/** /**
* 站点实体对象 * 站点实体对象
* *
......
package com.mortals.xhx.module.site.model; package com.mortals.xhx.module.site.model;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.site.model.vo.SiteMatterVo;
/** /**
* 站点事项实体对象 * 站点事项实体对象
* *
......
package com.mortals.xhx.module.site.model.vo; package com.mortals.xhx.module.site.model;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.site.model.SiteMatterEntity; import com.mortals.xhx.module.site.model.SiteMatterEntity;
import lombok.Data; import lombok.Data;
......
package com.mortals.xhx.module.site.model; package com.mortals.xhx.module.site.model;
import java.util.List;
import java.util.ArrayList;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.mortals.framework.annotation.Excel;
import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.site.model.vo.SiteModelVo;
/** /**
* 站点模块实体对象 * 站点模块实体对象
* *
......
package com.mortals.xhx.module.site.model.vo; package com.mortals.xhx.module.site.model;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.site.model.SiteModelEntity; import com.mortals.xhx.module.site.model.SiteModelEntity;
import lombok.Data; import lombok.Data;
......
package com.mortals.xhx.module.site.model.vo; package com.mortals.xhx.module.site.model;
import com.mortals.framework.model.BaseEntityLong; import com.mortals.framework.model.BaseEntityLong;
import com.mortals.xhx.module.site.model.SiteEntity; import com.mortals.xhx.module.site.model.SiteEntity;
import lombok.Data; import lombok.Data;
......
...@@ -199,7 +199,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE ...@@ -199,7 +199,7 @@ public class SiteServiceImpl extends AbstractCRUDCacheServiceImpl<SiteDao, SiteE
if (ObjectUtils.isEmpty(areaCode)) { if (ObjectUtils.isEmpty(areaCode)) {
throw new AppException("区域编码不能为空!"); throw new AppException("区域编码不能为空!");
} }
AreaEntity areaEntity = areaService.getCache(areaCode); AreaEntity areaEntity = areaService.getExtCache(areaCode);
if (ObjectUtils.isEmpty(areaEntity)) { if (ObjectUtils.isEmpty(areaEntity)) {
throw new AppException(String.format("区域不存在!区域编码:%s", areaCode)); throw new AppException(String.format("区域不存在!区域编码:%s", areaCode));
} }
......
...@@ -111,7 +111,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -111,7 +111,7 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
/** /**
* 根据区域id查询站点列表 * 根据区域id查询站点列表ids
*/ */
@PostMapping(value = "getFlatSitesByAreaIds") @PostMapping(value = "getFlatSitesByAreaIds")
public String getFlatSitesByAreaIds(@RequestBody SiteQuery site) { public String getFlatSitesByAreaIds(@RequestBody SiteQuery site) {
...@@ -119,9 +119,12 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic ...@@ -119,9 +119,12 @@ public class SiteController extends BaseCRUDJsonBodyMappingController<SiteServic
Map<String, Object> model = new HashMap<>(); Map<String, Object> model = new HashMap<>();
String busiDesc = "根据区域编码查询站点列表" + this.getModuleDesc(); String busiDesc = "根据区域编码查询站点列表" + this.getModuleDesc();
try { try {
List<SiteEntity> siteEntityList = this.service.getFlatSitesByAreaCode(site.getAreaCode(), getContext()); String siteIds = site.getAreaIDList().stream().flatMap(areaId ->
this.service.getFlatSitesByAreaCode(areaId, getContext()).stream()
).map(item -> item.getId().toString()).distinct().collect(Collectors.joining(","));
recordSysLog(request, busiDesc + " 【成功】"); recordSysLog(request, busiDesc + " 【成功】");
jsonObject.put(KEY_RESULT_DATA, siteEntityList); jsonObject.put(KEY_RESULT_DATA, siteIds);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS); jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
jsonObject.put(KEY_RESULT_MSG, "查询站点列表成功!"); jsonObject.put(KEY_RESULT_MSG, "查询站点列表成功!");
} catch (Exception e) { } catch (Exception e) {
......
package com.mortals.xhx.common.pdu;
import lombok.Data;
import java.util.List;
/**
* @author: zxfei
* @date: 2022/6/7 15:49
* @description:
**/
@Data
public class SitePdu {
/** 区域IdList */
private List<String> areaIDList;
}
...@@ -2,6 +2,7 @@ package com.mortals.xhx.feign.area; ...@@ -2,6 +2,7 @@ package com.mortals.xhx.feign.area;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.mortals.xhx.common.code.ApiRespCodeEnum; import com.mortals.xhx.common.code.ApiRespCodeEnum;
import com.mortals.xhx.common.pdu.SitePdu;
import com.mortals.xhx.feign.IFeign; import com.mortals.xhx.feign.IFeign;
import com.mortals.xhx.module.area.model.AreaEntity; import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.feign.rsp.ApiResp; import com.mortals.xhx.feign.rsp.ApiResp;
...@@ -59,6 +60,17 @@ public interface IApiAreaFeign extends IFeign { ...@@ -59,6 +60,17 @@ public interface IApiAreaFeign extends IFeign {
@PostMapping(value = "/area/treeselect") @PostMapping(value = "/area/treeselect")
String treeselect(); String treeselect();
/**
* 根据区域id查询站点列表ids
*
* @param query
* @return
*/
@PostMapping(value = "/site/getFlatSitesByAreaIds")
String getFlatSitesByAreaIds(@RequestBody SitePdu query);
} }
...@@ -105,6 +117,14 @@ class AreaFeignFallbackFactory implements FallbackFactory<IApiAreaFeign> { ...@@ -105,6 +117,14 @@ class AreaFeignFallbackFactory implements FallbackFactory<IApiAreaFeign> {
failResp.setMsg("暂时无法获取区域信息,请稍后再试!"); failResp.setMsg("暂时无法获取区域信息,请稍后再试!");
return JSON.toJSONString(failResp); return JSON.toJSONString(failResp);
} }
@Override
public String getFlatSitesByAreaIds(SitePdu query) {
ApiResp<String> failResp = new ApiResp<>();
failResp.setCode(ApiRespCodeEnum.FAILED.getValue());
failResp.setMsg("暂时无法获取站点列表,请稍后再试!");
return JSON.toJSONString(failResp);
}
}; };
} }
} }
......
...@@ -3,6 +3,7 @@ package com.mortals.xhx.module.area.service; ...@@ -3,6 +3,7 @@ package com.mortals.xhx.module.area.service;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDService; import com.mortals.framework.service.ICRUDService;
import com.mortals.xhx.module.area.model.AreaEntity; import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.model.AreaQuery;
import com.mortals.xhx.module.area.model.AreaTreeSelect; import com.mortals.xhx.module.area.model.AreaTreeSelect;
import java.util.List; import java.util.List;
...@@ -49,10 +50,18 @@ public interface AreaService extends ICRUDService<AreaEntity, Long> { ...@@ -49,10 +50,18 @@ public interface AreaService extends ICRUDService<AreaEntity, Long> {
/** /**
* 查询区域树(全节点) * 查询区域树(全节点)
* @param query
* @param context * @param context
* @return * @return
*/ */
String treeselect(Context context); String treeselect(Context context);
/**
* 查询区域列表下站点ids
* @param query
* @param context
* @return
*/
String getFlatSitesByAreaIds(AreaQuery query, Context context);
} }
\ No newline at end of file
...@@ -5,6 +5,7 @@ import com.mortals.framework.exception.AppException; ...@@ -5,6 +5,7 @@ import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.impl.AbstractCRUDServiceImpl; import com.mortals.framework.service.impl.AbstractCRUDServiceImpl;
import com.mortals.xhx.common.code.YesNoEnum; import com.mortals.xhx.common.code.YesNoEnum;
import com.mortals.xhx.common.pdu.SitePdu;
import com.mortals.xhx.feign.area.IApiAreaFeign; import com.mortals.xhx.feign.area.IApiAreaFeign;
import com.mortals.xhx.module.area.model.AreaEntity; import com.mortals.xhx.module.area.model.AreaEntity;
import com.mortals.xhx.module.area.model.AreaQuery; import com.mortals.xhx.module.area.model.AreaQuery;
...@@ -87,4 +88,18 @@ public class AreaServiceImpl extends AbstractCRUDServiceImpl<AreaDao, AreaEntity ...@@ -87,4 +88,18 @@ public class AreaServiceImpl extends AbstractCRUDServiceImpl<AreaDao, AreaEntity
return resp; return resp;
} }
@Override
public String getFlatSitesByAreaIds(AreaQuery query, Context context) {
log.info("getFlatSitesByAreaIds=={}",JSON.toJSONString(query));
SitePdu sitePdu = new SitePdu();
sitePdu.setAreaIDList(query.getIdList().stream().map(item->item.toString()).collect(Collectors.toList()));
String resp = apiAreaFeign.getFlatSitesByAreaIds(sitePdu);
ApiResp apiResp = JSON.parseObject(resp, ApiResp.class);
if (apiResp.getCode() != YesNoEnum.YES.getValue()) {
throw new AppException("获取区域列表树数据失败:" + apiResp.getMsg());
}
log.info("getFlatSitesByAreaIds=>{}", resp);
return resp;
}
} }
\ No newline at end of file
package com.mortals.xhx.module.area.web; package com.mortals.xhx.module.area.web;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.annotation.UnAuth;
import com.mortals.framework.model.Context; import com.mortals.framework.model.Context;
import com.mortals.framework.service.IAuthTokenService; import com.mortals.framework.service.IAuthTokenService;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController; import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
...@@ -122,4 +123,24 @@ public class AreaController extends BaseCRUDJsonBodyMappingController<AreaServic ...@@ -122,4 +123,24 @@ public class AreaController extends BaseCRUDJsonBodyMappingController<AreaServic
} }
@PostMapping(value = "getFlatSitesByAreaIds")
@UnAuth
public String getFlatSitesByAreaIds(@RequestBody AreaQuery query) {
JSONObject ret = new JSONObject();
Map<String, Object> model = new HashMap<>();
String busiDesc = "查询" + this.getModuleDesc() + "子节点";
try {
String retStr = this.service.getFlatSitesByAreaIds(query, getContext());
recordSysLog(request, busiDesc + "【成功】");
return retStr;
} catch (Exception e) {
log.error("查询站点信息错误", e);
this.doException(request, busiDesc, model, e);
ret.put(KEY_RESULT_CODE, VALUE_RESULT_FAILURE);
ret.put(KEY_RESULT_MSG, e.getMessage());
}
return ret.toJSONString();
}
} }
\ No newline at end of file
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