pull/200/head
dxfeng 2 years ago
commit 647f692920

@ -0,0 +1,16 @@
package com.engine.organization.entity.department.param;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class DepartmentDragParam {
private Integer dropPosition;
private String sourcekey;
private String targetkey;
}

@ -160,4 +160,11 @@ public interface DepartmentService {
*/
int moveDepartment(DepartmentMoveParam moveParam);
/**
*
* @param params
* @return
*/
int dragDepartment(DepartmentDragParam departmentDragParam);
}

@ -425,29 +425,30 @@ public class ChartServiceImpl extends Service implements ChartService {
String currentUser = String.valueOf(user.getUID());
//版本记录表数据存储
getOrgChartService(user).insertChartVersion(Integer.valueOf(dimension),description);
String versionId = "";
String createDate = OrganizationDateUtil.getFormatLocalDate(LocalDate.now());
rs.executeQuery("select id from JCL_ORG_CHARTVERSION where fclass = ? and createtime = ?",dimension,createDate);
if (rs.next()) {
versionId = Util.null2String(rs.getString("id"));
}
synchronized (this) {
getOrgChartService(user).insertChartVersion(Integer.valueOf(dimension), description);
String versionId = "";
String createDate = OrganizationDateUtil.getFormatLocalDate(LocalDate.now());
rs.executeQuery("select id from JCL_ORG_CHARTVERSION where fclass = ? and createtime = ?", dimension, createDate);
if (rs.next()) {
versionId = Util.null2String(rs.getString("id"));
}
RecordSetTrans recordSetTrans = new RecordSetTrans();
try {
recordSetTrans.setAutoCommit(false);
if ("0".equals(dimension)) {
//实体维度
trueDimension(recordSetTrans,versionId,currentUser,currentDate);
} else {
virtualDimension(recordSetTrans,versionId,currentUser,currentDate,dimension);
RecordSetTrans recordSetTrans = new RecordSetTrans();
try {
recordSetTrans.setAutoCommit(false);
if ("0".equals(dimension)) {
//实体维度
trueDimension(recordSetTrans, versionId, currentUser, currentDate);
} else {
virtualDimension(recordSetTrans, versionId, currentUser, currentDate, dimension);
}
recordSetTrans.commit();
} catch (Exception e) {
recordSetTrans.rollback();
e.printStackTrace();
}
recordSetTrans.commit();
} catch (Exception e) {
recordSetTrans.rollback();
e.printStackTrace();
}
Map<String, Object> result = new HashMap<>();
result.put("api_status", true);
return result;

@ -570,10 +570,17 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
}
// 原部门删除
// DepartmentPO mergeDepartment = getDepartmentMapper().getDeptById(mergeParam.getId());
// 删除部门(先更改原部门名称,释放原部门名称,然后删除)
DepartmentPO sourceDepartmentPO = getDepartmentMapper().getDeptById(mergeParam.getId());
sourceDepartmentPO.setDepartmentName(sourceDepartmentPO.getDepartmentName() + "_被合并");
sourceDepartmentPO.setDepartmentMark(sourceDepartmentPO.getDepartmentMark() + "_被合并");
updateEcDepartment(sourceDepartmentPO);
Map<String, Object> map = new HashMap<>();
map.put("id", Util.null2String(mergeParam.getId()));
// 删除部门
ServiceUtil.getService(OrganizationServiceImpl.class, user).doDepartmentCancel(map, user);
// 删除原部门下的岗位
// 更新组织架构图
// new DepartmentTriggerRunnable(mergeDepartment).run();
// 更新部门合并后名称
@ -658,6 +665,85 @@ public class DepartmentServiceImpl extends Service implements DepartmentService
return 1;
}
@Override
public int dragDepartment(DepartmentDragParam departmentDragParam) {
// OrganizationAssert.notNull(params.get("sourcekey"), "请选择一个拖拽源");
// OrganizationAssert.notNull(params.get("targetkey"), "请选择一个拖拽目的地");
String sourceKey = Util.null2String(departmentDragParam.getSourcekey());// 原目标
String targetKey = Util.null2String(departmentDragParam.getTargetkey());// 目的地
String dragPostion = Util.null2String(departmentDragParam.getDropPosition());// 0:目的里面 1目的外边
DepartmentPO deptById = getDepartmentMapper().getDeptById(Util.getIntValue(sourceKey.substring(1)));
RecordSet recordSet = new RecordSet();
// 部门不能到集团下
String targetType = targetKey.substring(0, 1);
String targetId = targetKey.substring(1);
String supComId = "";
String supId = "";
String querySupIdSql;
if ("s".equals(targetType)) {// 分部
querySupIdSql = "select companyId as supComId,supsubcomid as supId from hrmsubcompany where id = ?";
}else {
querySupIdSql = "select subcompanyid1 as supComId,supdepid as supId from hrmdepartment where id = ?";
}
if ("1".equals(dragPostion)) {
recordSet.executeQuery(querySupIdSql, targetId);
if (recordSet.next()) {
supId = Util.null2String(recordSet.getString("supId"));
supComId = Util.null2String(recordSet.getString("supComId"));
}
if ("s".equals(targetType)) {
OrganizationAssert.isFalse("0".equals(supId), "部门不能直接拖拽至集团下");
// 转移到分部外
deptById.setSubCompanyId1(Util.getIntValue(supId));
deptById.setSupDepId(null);
} else {
// 转移到部门外
List<DepartmentPO> deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(supId));
Set<Integer> disableIds = new HashSet<>();
disableIds.add(Util.getIntValue(sourceKey.substring(1)));
if (CollectionUtils.isNotEmpty(deptListByPId)) {
addDisableIds(disableIds, deptListByPId);
}
// OrganizationAssert.isFalse(disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门");
deptById.setSupDepId(Util.getIntValue(supId));
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(supId)==0 ? Util.getIntValue(supComId) : Util.getIntValue(supId));
deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1());
}
} else {
if ("s".equals(targetType)) {
//转移到分部下
deptById.setSubCompanyId1(Util.getIntValue(targetId));
deptById.setSupDepId(null);
} else {
//转移到部门下
List<DepartmentPO> deptListByPId = getDepartmentMapper().getDeptListByPId(Util.getIntValue(targetId));
Set<Integer> disableIds = new HashSet<>();
disableIds.add(Util.getIntValue(sourceKey.substring(1)));
if (CollectionUtils.isNotEmpty(deptListByPId)) {
addDisableIds(disableIds, deptListByPId);
}
OrganizationAssert.isFalse(disableIds.contains(Util.getIntValue(targetId)), "请勿选择当前部门本身及其子部门");
deptById.setSupDepId(Util.getIntValue(targetId));
DepartmentPO parentDepartment = getDepartmentMapper().getDeptById(Util.getIntValue(targetId));
deptById.setSubCompanyId1(parentDepartment.getSubCompanyId1());
}
}
// 更新EC部门
updateEcDepartment(deptById);
// 刷新岗位分部
List<DepartmentPO> deptList = getDepartmentMapper().getDeptListByPId(deptById.getId());
forbiddenChildTag(deptById.getSubCompanyId1(), deptList);
return 1;
}
/**
* id
*

@ -0,0 +1,104 @@
package com.engine.organization.util;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import weaver.conn.RecordSet;
import java.lang.reflect.Method;
import java.sql.Blob;
import java.sql.Clob;
import java.util.ArrayList;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class QueryObjUtil<T> {
/**
*
*/
private String querySQL;
/**
* Bean
*/
private Class<?> cla;
private T obj;
@SuppressWarnings("unchecked")
public List<T> query() {
RecordSet rs = new RecordSet();
List<T> list = null;
int cols;
try {
rs.executeQuery(querySQL);
cols = rs.getColCounts();
list = new ArrayList<T>();
while (rs.next()) {
// 并实例化成对象
obj = (T) cla.newInstance();
for (int j = 1; j <= cols; j++) {
String colName = iniStr(rs.getColumnName(j).toLowerCase());
try {
// 通过getter确定bean属性的数据类型
Method met = cla.getMethod("get" + colName);
// 取得属性的数据类型
Class<?> p = met.getReturnType();
// 获取set
met = obj.getClass().getMethod("set" + colName, p);
// 根据属性的数据类型来判断该用哪种数据类型取值,并将值存入对象属性中
if (p == String.class) {
met.invoke(obj, rs.getString(j));
} else if (p == Long.class || p == long.class) {
met.invoke(obj, rs.getInt(j));//rs未封装long
} else if (p == Double.class || p == double.class) {
met.invoke(obj, rs.getDouble(j));
} else if (p == Integer.class || p == int.class) {
met.invoke(obj, rs.getInt(j));
} else if (p == Blob.class) {
met.invoke(obj, rs.getBlobStr(j));
} else if (p == Boolean.class || p == boolean.class) {
met.invoke(obj, rs.getBoolean(j));
}
// else if (p == Byte.class || p == byte.class) {
// met.invoke(obj, rs.getByte(j));
// }
// else if (p == Short.class || p == short.class) {
// met.invoke(obj, rs.getShort(j));
// }
else if (p == Object.class) {
met.invoke(obj, rs.getString(j)); //未封装obj
} else if (p == Float.class || p == float.class) {
met.invoke(obj, rs.getFloat(j));
} else if (p == java.sql.Date.class) {
met.invoke(obj, rs.getDate(j));
} else if (p == java.util.Date.class) {
met.invoke(obj, rs.getDate(j));
} else if (p == Clob.class) {
met.invoke(obj, rs.getString(j));
}
} catch (NoSuchMethodException e) {
}
}
list.add(obj);
}
}catch (Exception e){
e.printStackTrace();
}
return list;
}
/**
* set
* @param old
* @return
*/
public String iniStr(String old) {
return old.substring(0, 1).toUpperCase() + old.substring(1);
}
}

@ -332,5 +332,17 @@ public class DepartmentController {
return ReturnResult.exceptionHandle(e);
}
}
@POST
@Path("/dragDepartment")
@Produces(MediaType.APPLICATION_JSON)
public ReturnResult dragDepartment(@Context HttpServletRequest request, @Context HttpServletResponse response, @RequestBody DepartmentDragParam departmentDragParam) {
try {
User user = HrmUserVarify.getUser(request, response);
Map<String, Object> params = ParamUtil.request2Map(request);
return ReturnResult.successed(getDepartmentWrapper(user).dragDepartment(departmentDragParam));
} catch (Exception e) {
return ReturnResult.exceptionHandle(e);
}
}
}

@ -21,6 +21,7 @@ import com.engine.organization.util.db.MapperProxyFactory;
import com.engine.organization.util.page.PageInfo;
import com.engine.organization.util.response.ReturnResult;
import org.apache.commons.lang.StringUtils;
import weaver.general.Util;
import weaver.hrm.User;
import java.util.Collection;
@ -259,4 +260,19 @@ public class DepartmentWrapper extends OrganizationWrapper {
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(moveParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
return moveDepartment;
}
/**
*
*
* @param moveParam
* @return
*/
@Log(operateType = OperateTypeEnum.MOVE, operateDesc = "拖拽转移部门", operateModule = LogModuleNameEnum.DEPARTMENT)
public int dragDepartment(DepartmentDragParam departmentDragParam) {
DepartmentPO departmentPO = getDepartmentMapper().getDeptById(Util.getIntValue(Util.null2String(departmentDragParam.getSourcekey()).substring(1)));
int moveDepartment = getDepartmentService(user).dragDepartment(departmentDragParam);
writeOperateLog(new Object() {
}.getClass(), departmentPO.getDepartmentName(), JSON.toJSONString(departmentDragParam), departmentPO, getDepartmentMapper().getDeptById(departmentPO.getId()));
return moveDepartment;
}
}

Loading…
Cancel
Save