|
@@ -4,6 +4,7 @@ import cn.com.ty.lift.common.constants.ApiConstants;
|
|
|
import cn.com.ty.lift.common.utils.ProjectUtils;
|
|
|
import cn.com.ty.lift.common.utils.TreeUtil;
|
|
|
import cn.com.ty.lift.enterprise.common.mapper.CommonMapper;
|
|
|
+import cn.com.ty.lift.enterprise.organization.dao.entity.Organization;
|
|
|
import cn.com.ty.lift.enterprise.organization.dao.entity.Project;
|
|
|
import cn.com.ty.lift.enterprise.organization.dao.entity.model.OrganizationReq;
|
|
|
import cn.com.ty.lift.enterprise.organization.service.impl.ProjectServiceImpl;
|
|
@@ -11,6 +12,7 @@ import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.apache.commons.configuration.tree.TreeUtils;
|
|
|
+import org.apache.poi.ss.formula.functions.T;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
@@ -54,22 +56,23 @@ public class OrganizationService {
|
|
|
"where mt_company_id = " + organizationReq.getMtCompanyId() + " and project_id = " + organizationReq.getProjectId());
|
|
|
break;
|
|
|
}
|
|
|
- List<Project> projectss = projectService.list(new QueryWrapper<Project>()
|
|
|
- .select("province", "city", "district", "project_name", "num")
|
|
|
- .eq("mt_company_id", organizationReq.getMtCompanyId()));
|
|
|
- for (Map<String, Object> province : provinces) {
|
|
|
- for (Map<String, Object> city : cities) {
|
|
|
- for (Map<String, Object> district : districts) {
|
|
|
|
|
|
+
|
|
|
+ List<String> provinceTemp = new ArrayList<>();
|
|
|
+ List<String> cityTemp = new ArrayList<>();
|
|
|
+ List<String> districtTemp = new ArrayList<>();
|
|
|
+ List<String> p;
|
|
|
+ List<String> pu;
|
|
|
+ for (Map<String, Object> project : projects) {
|
|
|
+ districtTemp.add(project.get("district").toString());
|
|
|
+
|
|
|
+ for (String s : districtTemp) {
|
|
|
+ if (!s.equals(project.get("district").toString())) {
|
|
|
+// districts.add();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- treeData.put("province", provinces);
|
|
|
- treeData.put("city", cities);
|
|
|
- treeData.put("district", districts);
|
|
|
-
|
|
|
-
|
|
|
if (provinces.isEmpty()) {
|
|
|
return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
|
}
|
|
@@ -79,4 +82,71 @@ public class OrganizationService {
|
|
|
allData.put("districts", districts);
|
|
|
return RestResponse.ok(allData, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
}
|
|
|
+
|
|
|
+ public RestResponse organizationList(OrganizationReq req) {
|
|
|
+// List<Map<String, Object>> projects = mapper.list("province, city, district,id, project_name, num",
|
|
|
+// "project",
|
|
|
+// "where mt_company_id=" + req.getMtCompanyId());
|
|
|
+ List<Project> projects = projectService.list(new QueryWrapper<Project>()
|
|
|
+ .select("id", "province", "city", "district", "project_name", "num")
|
|
|
+ .eq("mt_company_id", req.getMtCompanyId()));
|
|
|
+// HashSet<Organization> provinces = new HashSet<>();
|
|
|
+ Map<String, Organization> provinces = new HashMap<>();
|
|
|
+// HashSet<Organization> cities = new HashSet<>();
|
|
|
+ Map<String, Organization> cities = new HashMap<>();
|
|
|
+// HashSet<Organization> districts = new HashSet<>();
|
|
|
+ Map<String, Organization> districts = new HashMap<>();
|
|
|
+ Organization province = new Organization();
|
|
|
+ Organization city = new Organization();
|
|
|
+ Organization district = new Organization();
|
|
|
+
|
|
|
+ //遍历项目
|
|
|
+ for (Project project : projects) {
|
|
|
+ //获取省
|
|
|
+ province.setAreaName(project.getProvince());
|
|
|
+ province.setParentName(project.getProvince());
|
|
|
+ //获取市
|
|
|
+ city.setAreaName(project.getCity());
|
|
|
+ city.setParentName(project.getProvince());
|
|
|
+ //获取区
|
|
|
+ district.setAreaName(project.getDistrict());
|
|
|
+ district.setParentName(project.getCity());
|
|
|
+
|
|
|
+ //新增区列表,区新增项目
|
|
|
+ Organization organization = districts.get(project.getDistrict());
|
|
|
+ if (organization != null) {
|
|
|
+ //如果区列表不为空
|
|
|
+ organization.getProjects().add(project);
|
|
|
+ } else {
|
|
|
+ //如果区列表为空
|
|
|
+ organization = new Organization();
|
|
|
+ organization.getProjects().add(project);
|
|
|
+ districts.put(project.getDistrict(), organization);
|
|
|
+ }
|
|
|
+
|
|
|
+ //区列表放入市中
|
|
|
+ city.setData(districts);
|
|
|
+
|
|
|
+ //市放入市列表中
|
|
|
+ city.setParentName(project.getProvince());
|
|
|
+ cities.putIfAbsent(project.getCity(), city);
|
|
|
+ //市列表放入省中
|
|
|
+ province.setData(cities);
|
|
|
+
|
|
|
+ //省放入省列表中
|
|
|
+ provinces.putIfAbsent(project.getCity(), province);
|
|
|
+
|
|
|
+
|
|
|
+ //遍历完一个项目,重新赋值变量
|
|
|
+ province = new Organization();
|
|
|
+ city = new Organization();
|
|
|
+ district = new Organization();
|
|
|
+
|
|
|
+ }
|
|
|
+ //输出地区信息
|
|
|
+ System.out.println(provinces);
|
|
|
+
|
|
|
+
|
|
|
+ return RestResponse.ok(districts, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
+ }
|
|
|
}
|