组织架构图搜索条件优化

pull/165/head
dxfeng 2 years ago
parent 0148d99314
commit e8d6f2ea73

@ -0,0 +1,34 @@
package com.engine.organization.entity.chart;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import weaver.conn.RecordSet;
/**
* @author:dxfeng
* @createTime: 2023/06/26
* @version: 1.0
*/
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
public class CompanyTreePO {
private String id;
private String pId;
private String value;
private String title;
private boolean isLeaf;
public boolean getIsLeaf() {
RecordSet rs = new RecordSet();
rs.executeQuery("select id from hrmsubcompany where (canceled is null or canceled != '1') and supsubcomid = ?",id);
return rs.next();
}
public String getpId() {
return pId;
}
}

@ -21,6 +21,14 @@ public interface OrgChartService {
*/ */
Map<String, Object> getOptionCondition(Map<String, Object> request2Map, User user); Map<String, Object> getOptionCondition(Map<String, Object> request2Map, User user);
/**
*
* @param params [params]
* @return java.util.Map<java.lang.String,java.lang.Object>
*/
Map<String, Object> getSubCompanyTree(Map<String, Object> params);
/** /**
* @Description: * @Description:
* @Author: liang.cheng * @Author: liang.cheng

@ -3,6 +3,7 @@ package com.engine.organization.service.impl;
import cn.hutool.core.date.DateField; import cn.hutool.core.date.DateField;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import com.engine.core.impl.Service; import com.engine.core.impl.Service;
import com.engine.organization.entity.chart.CompanyTreePO;
import com.engine.organization.entity.map.JclOrgMap; import com.engine.organization.entity.map.JclOrgMap;
import com.engine.organization.entity.scheme.po.GradePO; import com.engine.organization.entity.scheme.po.GradePO;
import com.engine.organization.entity.scheme.po.LevelPO; import com.engine.organization.entity.scheme.po.LevelPO;
@ -46,13 +47,13 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
List<Map<String, Object>> fclasslist = new ArrayList<>(); List<Map<String, Object>> fclasslist = new ArrayList<>();
Map<String, Object> defaultItem = new HashMap<>(); Map<String, Object> defaultItem = new HashMap<>();
int fkey = 0; int fkey = 0;
defaultItem.put("key",fkey++); defaultItem.put("key", fkey++);
defaultItem.put("id", "0"); defaultItem.put("id", "0");
defaultItem.put("companyname", "行政维度"); defaultItem.put("companyname", "行政维度");
fclasslist.add(defaultItem); fclasslist.add(defaultItem);
while (rs.next()) { while (rs.next()) {
Map<String, Object> item = new HashMap<>(); Map<String, Object> item = new HashMap<>();
item.put("key",fkey++); item.put("key", fkey++);
item.put("id", rs.getString("id")); item.put("id", rs.getString("id"));
item.put("companyname", rs.getString("companyname")); item.put("companyname", rs.getString("companyname"));
fclasslist.add(item); fclasslist.add(item);
@ -80,9 +81,40 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
item.setFname(rs.getString("fname")); item.setFname(rs.getString("fname"));
companySet.add(item); companySet.add(item);
} }
List<CompanyTreePO> companyTree = new ArrayList<>();
sql = "select id as 'id', id as 'value', subcompanyname as 'title', supsubcomid as 'pId' from hrmsubcompany where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = '0'";
rs.executeQuery(sql);
while (rs.next()) {
companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).build());
}
result.put("api_status", true); result.put("api_status", true);
result.put("fclasslist", fclasslist); result.put("fclasslist", fclasslist);
result.put("companylist", companySet); result.put("companylist", companySet);
result.put("companyTree", companyTree);
return result;
}
@Override
public Map<String, Object> getSubCompanyTree(Map<String, Object> params) {
Map<String, Object> result = new HashMap<>(2);
RecordSet rs = new RecordSet();
List<CompanyTreePO> companyTree = new ArrayList<>();
String subcompany = Util.null2String(params.get("subcompany"));
if (StringUtils.isBlank(subcompany)) {
subcompany = "0";
}
String fclass = Util.null2String(params.get("fclass"));
String sql = "select id as 'id', id as 'value', subcompanyname as 'title', supsubcomid as 'pId' from hrmsubcompany where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = '" + subcompany + "'";
if (StringUtils.isNotBlank(fclass) && !"0".equals(fclass)) {
sql = "select id as 'id', id as 'value', subcompanyname as 'title', supsubcomid as 'pId' from hrmsubcompanyvirtual where (canceled is null or canceled != '1') and " + DBType.get(new RecordSet().getDBType()).ifNull("supsubcomid", "0") + " = '" + subcompany + "' and companyid = '" + fclass + "'";
}
rs.executeQuery(sql);
while (rs.next()) {
companyTree.add(CompanyTreePO.builder().id(rs.getString("id")).pId(rs.getString("pId")).value(rs.getString("value")).title(rs.getString("title")).build());
}
result.put("companyTree", companyTree);
return result; return result;
} }
@ -100,7 +132,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
String whereSql = " where 1 = 1 "; String whereSql = " where 1 = 1 ";
if (DBType.isOracle()) { if (DBType.isOracle()) {
whereSql += " and ((fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and fdateend >= to_date('" + date + "','yyyy-MM-DD')) or (fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and fdateend is null )) "; whereSql += " and ((fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and fdateend >= to_date('" + date + "','yyyy-MM-DD')) or (fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and fdateend is null )) ";
}else { } else {
whereSql += " and ((fdatebegin <= '" + date + "' and fdateend >= '" + date + "') or (fdatebegin <= '" + date + "' and fdateend is null )) "; whereSql += " and ((fdatebegin <= '" + date + "' and fdateend >= '" + date + "') or (fdatebegin <= '" + date + "' and fdateend is null )) ";
} }
whereSql += " and fclass = " + fclass + " "; whereSql += " and fclass = " + fclass + " ";
@ -227,7 +259,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
String whereSql = " where 1 = 1 "; String whereSql = " where 1 = 1 ";
if (DBType.isOracle()) { if (DBType.isOracle()) {
whereSql += " and ((t.fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and t.fdateend >= to_date('" + date + "','yyyy-MM-DD')) or (t.fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and t.fdateend is null )) "; whereSql += " and ((t.fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and t.fdateend >= to_date('" + date + "','yyyy-MM-DD')) or (t.fdatebegin <= to_date('" + date + "','yyyy-MM-DD') and t.fdateend is null )) ";
}else { } else {
whereSql += " and ((t.fdatebegin <= '" + date + "' and t.fdateend >= '" + date + "') or (t.fdatebegin <= '" + date + "' and t.fdateend is null )) "; whereSql += " and ((t.fdatebegin <= '" + date + "' and t.fdateend >= '" + date + "') or (t.fdatebegin <= '" + date + "' and t.fdateend is null )) ";
} }
whereSql += " and t.fclass = " + fclass + " "; whereSql += " and t.fclass = " + fclass + " ";

@ -47,6 +47,25 @@ public class OrgChartController {
return JSONObject.toJSONString(apidatas); return JSONObject.toJSONString(apidatas);
} }
@GET
@Path("/getSubCompanyTree")
@Produces(MediaType.APPLICATION_JSON)
public String getSubCompanyTree(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<>();
try {
User user = HrmUserVarify.getUser(request, response);
//实例化Service 并调用业务类处理
apidatas = getOrgChartWrapper(user).getSubCompanyTree(ParamUtil.request2Map(request), user);
} catch (Exception e) {
//异常处理
e.printStackTrace();
apidatas.put("api_status", false);
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
}
//数据转换
return JSONObject.toJSONString(apidatas);
}
/** /**
* *
*/ */

@ -24,6 +24,10 @@ public class OrgChartWrapper extends Service {
return getOrgChartService(user).getOptionCondition(request2Map, user); return getOrgChartService(user).getOptionCondition(request2Map, user);
} }
public Map<String, Object> getSubCompanyTree(Map<String, Object> request2Map, User user) {
return getOrgChartService(user).getSubCompanyTree(request2Map);
}
public Map<String, Object> getCompanyData(Map<String, Object> request2Map, User user) { public Map<String, Object> getCompanyData(Map<String, Object> request2Map, User user) {
return getOrgChartService(user).getCompanyData(request2Map, user); return getOrgChartService(user).getCompanyData(request2Map, user);
} }

Loading…
Cancel
Save