|
@@ -2,53 +2,78 @@ package cn.com.ty.lift.enterprise.organization.service;
|
|
|
|
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
import cn.com.ty.lift.common.constants.ApiConstants;
|
|
import cn.com.ty.lift.enterprise.common.mapper.CommonMapper;
|
|
import cn.com.ty.lift.enterprise.common.mapper.CommonMapper;
|
|
|
|
+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.dao.entity.model.OrganizationReq;
|
|
|
|
+import cn.com.ty.lift.enterprise.organization.service.impl.ProjectServiceImpl;
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
import cn.com.xwy.boot.web.dto.RestResponse;
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import lombok.AllArgsConstructor;
|
|
import lombok.AllArgsConstructor;
|
|
|
|
+import org.apache.commons.configuration.tree.TreeUtils;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.List;
|
|
|
|
-import java.util.Map;
|
|
|
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
@AllArgsConstructor
|
|
@AllArgsConstructor
|
|
public class OrganizationService {
|
|
public class OrganizationService {
|
|
private final CommonMapper mapper;
|
|
private final CommonMapper mapper;
|
|
|
|
+ private final ProjectServiceImpl projectService;
|
|
|
|
|
|
//获取维保公司下的1省,2市,3区,4项目和电梯数量 5项目成员列表
|
|
//获取维保公司下的1省,2市,3区,4项目和电梯数量 5项目成员列表
|
|
public RestResponse datas(OrganizationReq organizationReq) {
|
|
public RestResponse datas(OrganizationReq organizationReq) {
|
|
- List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
|
|
|
|
|
|
+ Map<String, Object> treeData = new HashMap<>();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ List<Map<String, Object>> provinces = new ArrayList<>();
|
|
|
|
+ List<Map<String, Object>> cities = new ArrayList<>();
|
|
|
|
+ List<Map<String, Object>> districts = new ArrayList<>();
|
|
|
|
+ List<Map<String, Object>> projects = new ArrayList<>();
|
|
|
|
+ List<Map<String, Object>> projectUsers = new ArrayList<>();
|
|
switch (organizationReq.getListType()) {
|
|
switch (organizationReq.getListType()) {
|
|
case 1:
|
|
case 1:
|
|
- list = mapper.list("DISTINCT province",
|
|
|
|
|
|
+ provinces = mapper.list("DISTINCT province,province_code provinceCode",
|
|
"project",
|
|
"project",
|
|
"where mt_company_id= " + organizationReq.getMtCompanyId());
|
|
"where mt_company_id= " + organizationReq.getMtCompanyId());
|
|
- break;
|
|
|
|
- case 2:
|
|
|
|
- list = mapper.list("DISTINCT city",
|
|
|
|
|
|
+ cities = mapper.list("DISTINCT city,city_code cityCode",
|
|
"project",
|
|
"project",
|
|
"where mt_company_id= " + organizationReq.getMtCompanyId());
|
|
"where mt_company_id= " + organizationReq.getMtCompanyId());
|
|
- break;
|
|
|
|
- case 3:
|
|
|
|
- list = mapper.list("DISTINCT district",
|
|
|
|
|
|
+ districts = mapper.list("DISTINCT district,district_code districtCode",
|
|
"project",
|
|
"project",
|
|
"where mt_company_id= " + organizationReq.getMtCompanyId());
|
|
"where mt_company_id= " + organizationReq.getMtCompanyId());
|
|
break;
|
|
break;
|
|
case 4:
|
|
case 4:
|
|
- list = mapper.list("DISTINCT id,project_name,num",
|
|
|
|
|
|
+ projects = mapper.list("DISTINCT id,project_name,num",
|
|
"project",
|
|
"project",
|
|
"where mt_company_id= " + organizationReq.getMtCompanyId());
|
|
"where mt_company_id= " + organizationReq.getMtCompanyId());
|
|
break;
|
|
break;
|
|
case 5:
|
|
case 5:
|
|
- list = mapper.list(" pu.project_id,u.avatar_url,u.name,u.mobile,pu.is_monitor ",
|
|
|
|
|
|
+ projectUsers = mapper.list(" pu.project_id,u.avatar_url,u.name,u.mobile,pu.is_monitor ",
|
|
" project_user pu left join user_info u on u.user_id = pu.user_id ",
|
|
" project_user pu left join user_info u on u.user_id = pu.user_id ",
|
|
"where mt_company_id = " + organizationReq.getMtCompanyId() + " and project_id = " + organizationReq.getProjectId());
|
|
"where mt_company_id = " + organizationReq.getMtCompanyId() + " and project_id = " + organizationReq.getProjectId());
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- if (list.isEmpty()) {
|
|
|
|
|
|
+ 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) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ treeData.put("province", provinces);
|
|
|
|
+ treeData.put("city", cities);
|
|
|
|
+ treeData.put("district", districts);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (provinces.isEmpty()) {
|
|
return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
return RestResponse.ok(null, ApiConstants.RESULT_NO_DATA, "无数据");
|
|
}
|
|
}
|
|
- return RestResponse.ok(list, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
|
|
|
|
+ HashMap<String, Object> allData = new HashMap<>();
|
|
|
|
+ allData.put("provinces", provinces);
|
|
|
|
+ allData.put("cities", cities);
|
|
|
|
+ allData.put("districts", districts);
|
|
|
|
+ return RestResponse.ok(allData, ApiConstants.RESULT_SUCCESS, "查询成功");
|
|
}
|
|
}
|
|
}
|
|
}
|