Commit 3db29f37 authored by suhuiguang's avatar suhuiguang

1,树过滤不对

parent 73180c07
......@@ -42,7 +42,7 @@ public interface IRegUnitInfoService {
* 获取管辖机构树
* @return 组织架构中单位级别为:省级、地市级、区县级的单位
*/
Collection<CompanyModel> getManagementUnitTree();
Collection getManagementUnitTree();
/**
* 单位注销
......
......@@ -84,8 +84,8 @@ public class RegUnitInfoController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@GetMapping(value = "/management-unit/tree")
@ApiOperation(httpMethod = "GET", value = "管辖机构树", notes = "管辖机构树")
public ResponseModel<Collection<CompanyModel>> managementUnitTree() {
Collection<CompanyModel> result = iRegUnitInfoService.getManagementUnitTree();
public ResponseModel<Collection> managementUnitTree() {
Collection result = iRegUnitInfoService.getManagementUnitTree();
return ResponseHelper.buildResponse(result);
}
......
......@@ -32,6 +32,7 @@ import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
......@@ -66,6 +67,9 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
@Autowired
TzBaseEnterpriseInfoServiceImpl tzBaseEnterpriseInfoService;
@Autowired
RestTemplate restTemplate;
/**
* 使用单位的类型,数据来源:cb_data_dictionary code = 1232
*/
......@@ -158,7 +162,18 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
RegUnitInfoDto regUnitInfoDto = new RegUnitInfoDto();
if (USE_UNIT_TYPE_CODE.equals(unitType)) {
// 2.1 使用单位调用行政许可系统接口进行查询工商信息
// MultiValueMap<String, String> headers = new HttpHeaders();
// headers.add("header-1","v1");
// headers.add("header-2","v2");
// RequestEntity requestEntity = new RequestEntity(
// null, //body部分数据
// headers, //头
// HttpMethod.GET,//请求方法
// URI.create("url"));
// ResponseEntity<JSONObject> responseEntity = restTemplate.exchange(requestEntity,JSONObject.class);
// JSONObject result = responseEntity.getBody();
// 2.2 工商信息组装
// regUnitInfoDto.setRegUnitIc();
} else {
RegUnitIc regUnitIc = regUnitIcService.getOne(new LambdaQueryWrapper<RegUnitIc>().eq(RegUnitIc::getUnitCode, unitCode));
regUnitInfoDto.setRegUnitIc(Bean.toModel(regUnitIc, new RegUnitIcDto()));
......@@ -175,12 +190,10 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
}
@Override
public Collection<CompanyModel> getManagementUnitTree() {
public Collection getManagementUnitTree() {
// 组织架构中单位级别为:省级、地市级、区县级的单位
Collection<CompanyModel> companyModels = Privilege.companyClient.companyTreeWithoutAuth().getResult();
return companyModels.stream().filter(c -> "headquarter".equals(c.getLevel()) || "prefecture-level".equals(c.getLevel()) || "county".equals(c.getLevel())).peek(n -> {
this.dealChildCompany(n.getChildren());
}).collect(Collectors.toList());
return companyModels.stream().filter(c -> "headquarter".equals(c.getLevel()) || "prefecture-level".equals(c.getLevel()) || "county".equals(c.getLevel())).map(this::dealChildCompany).collect(Collectors.toList());
}
@Override
......@@ -213,13 +226,26 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
return Boolean.TRUE;
}
private void dealChildCompany(Collection children) {
children.stream().filter(n -> {
private CompanyModel dealChildCompany(CompanyModel cm) {
cm.setChildren(this.getFilterChild(cm.getChildren()));
cm.getChildren().stream().filter(n -> {
CompanyModel c = JSONObject.parseObject(JSON.toJSONString(n), CompanyModel.class);
return "headquarter".equals(c.getLevel()) || "prefecture-level".equals(c.getLevel()) || "county".equals(c.getLevel());
}).peek(n -> {
}).map(n -> {
CompanyModel c = JSONObject.parseObject(JSON.toJSONString(n), CompanyModel.class);
return dealChildCompany(c);
}).collect(Collectors.toList());
return cm;
}
private List getFilterChild(Collection children) {
return (List)children.stream().filter(n -> {
CompanyModel c = JSONObject.parseObject(JSON.toJSONString(n), CompanyModel.class);
dealChildCompany(c.getChildren() != null ? new ArrayList() : c.getChildren());
return "headquarter".equals(c.getLevel()) || "prefecture-level".equals(c.getLevel()) || "county".equals(c.getLevel());
}).map(s->{
CompanyModel c = JSONObject.parseObject(JSON.toJSONString(s), CompanyModel.class);
c.setChildren(this.getFilterChild(c.getChildren() != null ? c.getChildren() : new ArrayList()));
return c;
}).collect(Collectors.toList());
}
......
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