Commit bfdc4889 authored by chenzhao's avatar chenzhao

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

parents 18520d42 2005d359
...@@ -25,4 +25,7 @@ public class DropDown { ...@@ -25,4 +25,7 @@ public class DropDown {
@ApiModelProperty(value = "单位地址") @ApiModelProperty(value = "单位地址")
private String address; private String address;
@ApiModelProperty(value = "区域编码")
private String regionSeq;
} }
...@@ -39,7 +39,7 @@ public interface JpStationMapper extends BaseMapper<JpStation> { ...@@ -39,7 +39,7 @@ public interface JpStationMapper extends BaseMapper<JpStation> {
@UserEmpower(field ={"ORG_CODE"} ,dealerField ={"ORG_CODE"}, fieldConditions ={"in","in"} ,relationship="and",specific=false) @UserEmpower(field ={"ORG_CODE"} ,dealerField ={"ORG_CODE"}, fieldConditions ={"in","in"} ,relationship="and",specific=false)
List<DropDown> getRegion(String regionName, String address); List<DropDown> getRegion(String regionName, String address);
List<String> getRegionAddress(); List<String> getRegionAddress(@Param("regionSeqList") List<String> regionSeqList);
@UserEmpower(field ={"ORG_CODE"} ,dealerField ={"ORG_CODE"}, fieldConditions ={"in","in"} ,relationship="and",specific=false) @UserEmpower(field ={"ORG_CODE"} ,dealerField ={"ORG_CODE"}, fieldConditions ={"in","in"} ,relationship="and",specific=false)
List<DropDown> getRegionByProvince(@Param(value = "ids") List<String> ids); List<DropDown> getRegionByProvince(@Param(value = "ids") List<String> ids);
......
...@@ -245,9 +245,10 @@ ...@@ -245,9 +245,10 @@
</select> </select>
<select id="getRegion" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.DropDown"> <select id="getRegion" resultType="com.yeejoin.amos.boot.module.hygf.api.dto.DropDown">
SELECT privilege_company.ORG_CODE orgCode, SELECT privilege_company.ORG_CODE orgCode,
privilege_company.COMPANY_NAME name, privilege_company.COMPANY_NAME name,
privilege_company.ADDRESS address privilege_company.ADDRESS address,
privilege_company.REGION_SEQ regionSeq
FROM privilege_company FROM privilege_company
WHERE IS_DELETED = 0 WHERE IS_DELETED = 0
and privilege_company.COMPANY_TYPE = 'region' and privilege_company.COMPANY_TYPE = 'region'
...@@ -263,10 +264,36 @@ ...@@ -263,10 +264,36 @@
</select> </select>
<select id="getRegionAddress" resultType="String"> <select id="getRegionAddress" resultType="String">
SELECT DISTINCT IFNULL(privilege_company.address, '未知省份') AS address WITH RECURSIVE ParentTree AS (
FROM privilege_company -- 初始查询:选择根节点
WHERE IS_DELETED = 0 SELECT
and privilege_company.COMPANY_TYPE = 'region' SEQUENCE_NBR,
PARENT_ID,
REGION_NAME
FROM
systemctl_region sr
WHERE
sr.SEQUENCE_NBR in
<foreach collection="regionSeqList" item="regionSeq" index="index" open="(" close=")" separator=",">
#{regionSeq}
</foreach>
UNION ALL
-- 递归部分:选择父节点
SELECT
p.SEQUENCE_NBR,
p.PARENT_ID,
p.REGION_NAME
FROM
systemctl_region p
JOIN
ParentTree pt ON p.SEQUENCE_NBR = pt.PARENT_ID
)
SELECT
pt.REGION_NAME AS topLevelNodeName
FROM
ParentTree pt
WHERE
pt.PARENT_ID = 0;
</select> </select>
<select id="getRegionNode" resultType="string"> <select id="getRegionNode" resultType="string">
......
...@@ -444,14 +444,44 @@ public class JpStationController extends BaseController { ...@@ -444,14 +444,44 @@ public class JpStationController extends BaseController {
return ResponseHelper.buildResponse(result); return ResponseHelper.buildResponse(result);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "查询当前登录人权限区域公司地址", notes = "查询当前登录人权限区域公司地址") @ApiOperation(httpMethod = "GET", value = "查询当前登录人权限区域公司", notes = "查询当前登录人权限区域公司")
@GetMapping(value = "/getRegionCompanyByProvince")
@UserLimits
public ResponseModel<List<Map<String, String>>> getRegionCompanyByProvince(String province) {
List<DropDown> list = new ArrayList<>();
if (StringUtils.isEmpty(province)){
list = jpStationMapper.getRegion(null, null);
}else {
List<String> ids = jpStationMapper.getRegionNode(province);
list = jpStationMapper.getRegionByProvince(ids);
}
List<Map<String, String>> result = new ArrayList<>();
list.forEach(dropDown -> {
Map<String, String> item = new HashMap<>();
item.put("text", dropDown.getName());
item.put("value", dropDown.getOrgCode());
result.add(item);
});
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "查询当前登录人权限区域公司省份地址", notes = "查询当前登录人权限区域公司省份地址")
@GetMapping(value = "/getRegionAddress") @GetMapping(value = "/getRegionAddress")
@UserLimits @UserLimits
public ResponseModel<List<Map<String, String>>> getRegionAddress() { public ResponseModel<List<Map<String, String>>> getRegionAddress() {
List<String> list = jpStationMapper.getRegionAddress(); List<DropDown> list = jpStationMapper.getRegion(null, null);
List<String> regionSeqList = list.stream().map(DropDown::getRegionSeq).distinct().collect(Collectors.toList());
if(regionSeqList == null) {
regionSeqList = new ArrayList<>();
}
List<String> addressList = new ArrayList<>(new HashSet<>(jpStationMapper.getRegionAddress(regionSeqList)));
List<Map<String, String>> result = new ArrayList<>(); List<Map<String, String>> result = new ArrayList<>();
list.forEach(address -> { addressList.forEach(address -> {
Map<String, String> item = new HashMap<>(); Map<String, String> item = new HashMap<>();
item.put("text", address); item.put("text", address);
item.put("value", address); item.put("value", address);
......
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