组织管理,移动树接口提交
This commit is contained in:
parent
87372be17f
commit
9610361733
|
|
@ -0,0 +1,74 @@
|
|||
package com.engine.organization.entity.chart;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2023/07/25
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@Builder
|
||||
public class MovingTree {
|
||||
public static final String SUB_COMPANY = "subCompany";
|
||||
public static final String DEPARTMENT = "department";
|
||||
|
||||
private String key;
|
||||
private String id;
|
||||
private String title;
|
||||
private String type;
|
||||
private List<MovingTree> children;
|
||||
|
||||
public List<MovingTree> getChildren() {
|
||||
if (null != children) {
|
||||
return children;
|
||||
}
|
||||
children = new ArrayList<>();
|
||||
RecordSet rs = new RecordSet();
|
||||
if (SUB_COMPANY.equals(type)) {
|
||||
String sql = "select id ,subcompanyname from hrmsubcompany where (canceled is null or canceled != 1) and supsubcomid = ? order by showorder desc";
|
||||
rs.executeQuery(sql, key);
|
||||
while (rs.next()) {
|
||||
children.add(MovingTree.builder().key(rs.getString("id")).title(rs.getString("subcompanyname")).type(SUB_COMPANY).build());
|
||||
}
|
||||
sql = "select id,departmentname from hrmdepartment where (canceled is null or canceled != 1) and (supdepid is null or supdepid =0) and subcompanyid1 = ? order by showorder desc";
|
||||
rs.executeQuery(sql, key);
|
||||
while (rs.next()) {
|
||||
children.add(MovingTree.builder().key(rs.getString("id")).title(rs.getString("departmentname")).type(DEPARTMENT).build());
|
||||
}
|
||||
} else if (DEPARTMENT.equals(type)) {
|
||||
String sql = "select id,departmentname from hrmdepartment where (canceled is null or canceled != 1) and supdepid = ? order by showorder desc";
|
||||
rs.executeQuery(sql, key);
|
||||
while (rs.next()) {
|
||||
children.add(MovingTree.builder().key(rs.getString("id")).title(rs.getString("departmentname")).type(DEPARTMENT).build());
|
||||
}
|
||||
}
|
||||
return CollectionUtils.isEmpty(children) ? null : children;
|
||||
}
|
||||
|
||||
public String getKey() {
|
||||
switch (type) {
|
||||
case SUB_COMPANY:
|
||||
return "s" + key;
|
||||
case DEPARTMENT:
|
||||
return "d" + key;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
|
|
@ -55,4 +55,12 @@ public interface ChartService {
|
|||
* @return 树结构
|
||||
*/
|
||||
Map<String, Object> getDepartmentTree(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 可移动树接口
|
||||
*
|
||||
* @param params 前端参数
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> getMovingTree(Map<String, Object> params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.engine.common.util.ServiceUtil;
|
|||
import com.engine.core.impl.Service;
|
||||
import com.engine.organization.entity.chart.ChartPO;
|
||||
import com.engine.organization.entity.chart.CompanyTreePO;
|
||||
import com.engine.organization.entity.chart.MovingTree;
|
||||
import com.engine.organization.mapper.hrmresource.SystemDataMapper;
|
||||
import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
|
||||
import com.engine.organization.service.ChartService;
|
||||
|
|
@ -471,6 +472,20 @@ public class ChartServiceImpl extends Service implements ChartService {
|
|||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getMovingTree(Map<String, Object> params) {
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select id,subcompanyname from hrmsubcompany where (canceled is null or canceled != 1) and (supsubcomid is null or supsubcomid = 0)");
|
||||
List<MovingTree> movingTrees = new ArrayList<>();
|
||||
while(rs.next()){
|
||||
movingTrees.add(MovingTree.builder().key(rs.getString("id")).title(rs.getString("subcompanyname")).type(MovingTree.SUB_COMPANY).build());
|
||||
}
|
||||
Map<String, Object> result = new HashMap<>(2);
|
||||
result.put("movingTree", movingTrees);
|
||||
result.put("api_status", true);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void trueDimension(RecordSetTrans recordSetTrans,String versionId,String currentUser,String currentDate){
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.execute("delete from jcl_chart_subcompany where versionid = "+versionId);
|
||||
|
|
|
|||
|
|
@ -138,6 +138,26 @@ public class OrgChartController {
|
|||
return JSONObject.toJSONString(apidatas);
|
||||
}
|
||||
|
||||
@GET
|
||||
@Path("/getMovingTree")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public String getMovingTree(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
Map<String, Object> apidatas = new HashMap<>();
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
//实例化Service 并调用业务类处理
|
||||
apidatas = getOrgChartWrapper(user).getMovingTree(ParamUtil.request2Map(request), user);
|
||||
apidatas.put("api_status", true);
|
||||
} catch (Exception e) {
|
||||
//异常处理
|
||||
e.printStackTrace();
|
||||
apidatas.put("api_status", false);
|
||||
apidatas.put("api_errormsg", "catch exception : " + e.getMessage());
|
||||
}
|
||||
//数据转换
|
||||
return JSONObject.toJSONString(apidatas);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组织架构数据
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -72,4 +72,8 @@ public class OrgChartWrapper extends Service {
|
|||
public Map<String, Object> getDepartmentTree(Map<String, Object> request2Map, User user) {
|
||||
return getChartService(user).getDepartmentTree(request2Map);
|
||||
}
|
||||
|
||||
public Map<String, Object> getMovingTree(Map<String, Object> request2Map, User user) {
|
||||
return getChartService(user).getMovingTree(request2Map);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue