|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.engine.xmgsecond.util;
|
|
|
|
package com.engine.xmgsecond.util;
|
|
|
|
|
|
|
|
|
|
|
|
import com.engine.xmgsecond.entity.DeptCodeRule;
|
|
|
|
import com.engine.xmgsecond.entity.DeptCodeRule;
|
|
|
|
|
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
import weaver.conn.RecordSet;
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
import weaver.general.StringUtil;
|
|
|
|
import weaver.general.Util;
|
|
|
|
import weaver.general.Util;
|
|
|
@ -52,20 +53,25 @@ public class DepartmentCodeUtil {
|
|
|
|
return "";
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//2.获取该部门所有上级部门 (需求确认中 部门层级最多只有3级),并获取对应的流水号,若不存在为 00
|
|
|
|
//2.获取该部门所有上级部门 (需求确认 部门层级最多只有3级),并获取对应的流水号,若不存在为 00
|
|
|
|
|
|
|
|
//导入时缓存无法获取部门信息 String lastSupCode = deptInfo.getDepartmentCode(lastSupdepid);
|
|
|
|
DepartmentComInfo deptInfo = new DepartmentComInfo();
|
|
|
|
DepartmentComInfo deptInfo = new DepartmentComInfo();
|
|
|
|
|
|
|
|
|
|
|
|
//上级部门id
|
|
|
|
//上级部门id
|
|
|
|
if (StringUtil.isEmpty(lastSupdepid)) {
|
|
|
|
if (StringUtil.isEmpty(lastSupdepid)) {
|
|
|
|
lastSupdepid = deptInfo.getDepartmentsupdepid(deptId);
|
|
|
|
lastSupdepid = deptInfo.getDepartmentsupdepid(deptId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String lastSupCode = deptInfo.getDepartmentCode(lastSupdepid);
|
|
|
|
Map<String, String> lastData = getDepartmentCode(lastSupdepid);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String lastSupCode = lastData.get("departmentcode");
|
|
|
|
lastSupdepid = lastSupdepid == null || lastSupdepid.isEmpty() ? "0" : lastSupdepid;
|
|
|
|
lastSupdepid = lastSupdepid == null || lastSupdepid.isEmpty() ? "0" : lastSupdepid;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//上上级部门id
|
|
|
|
//上上级部门id
|
|
|
|
String lastTopSupdepid = deptInfo.getDepartmentsupdepid(lastSupdepid);
|
|
|
|
Map<String, String> lastTopData = getDepartmentCode(lastSupdepid);
|
|
|
|
|
|
|
|
String lastTopSupdepid = lastTopData.get("supdepid");
|
|
|
|
lastTopSupdepid = lastTopSupdepid == null || lastTopSupdepid.isEmpty() ? "0" : lastTopSupdepid;
|
|
|
|
lastTopSupdepid = lastTopSupdepid == null || lastTopSupdepid.isEmpty() ? "0" : lastTopSupdepid;
|
|
|
|
String lastTopSupCode = deptInfo.getDepartmentCode(lastTopSupdepid);
|
|
|
|
String lastTopSupCode = lastTopData.get("departmentcode");
|
|
|
|
|
|
|
|
|
|
|
|
// 例如一级部门 lastSupdepid="0",lastTopSupdepid="0"
|
|
|
|
// 例如一级部门 lastSupdepid="0",lastTopSupdepid="0"
|
|
|
|
// 例如二级部门 lastSupdepid="2726",lastTopSupdepid="0"
|
|
|
|
// 例如二级部门 lastSupdepid="2726",lastTopSupdepid="0"
|
|
|
@ -100,6 +106,11 @@ public class DepartmentCodeUtil {
|
|
|
|
if ("00".equals(serialnum)) {
|
|
|
|
if ("00".equals(serialnum)) {
|
|
|
|
departmentSerial.add(serialnum);
|
|
|
|
departmentSerial.add(serialnum);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//如果本身已经存在编码 需要移除该编号
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(deptId)) {
|
|
|
|
|
|
|
|
String code = getSubstringByLevel(deptInfo.getDepartmentCode(deptId),deptLevel);
|
|
|
|
|
|
|
|
departmentSerial.removeIf(element -> element.equals(code));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//List<String>中元素 ["01","02","03","06","05","24","08"] 如 01 - 24,若是连续且存在 则当前部门流水号 24+1;2.若不连续则使用跳号中最小的数字作为当前部门流水号
|
|
|
|
//List<String>中元素 ["01","02","03","06","05","24","08"] 如 01 - 24,若是连续且存在 则当前部门流水号 24+1;2.若不连续则使用跳号中最小的数字作为当前部门流水号
|
|
|
@ -118,7 +129,7 @@ public class DepartmentCodeUtil {
|
|
|
|
String newSerialnum = String.format("%02d", nextNumber);
|
|
|
|
String newSerialnum = String.format("%02d", nextNumber);
|
|
|
|
|
|
|
|
|
|
|
|
//4.更新部门规则表流水号
|
|
|
|
//4.更新部门规则表流水号
|
|
|
|
//检查是否存在跳号 如果是跳号则不更新
|
|
|
|
//检查是否存在跳号 如果是跳号则不更新 true为不是跳号
|
|
|
|
boolean isJump = nextNumber > Integer.parseInt(serialnum);
|
|
|
|
boolean isJump = nextNumber > Integer.parseInt(serialnum);
|
|
|
|
|
|
|
|
|
|
|
|
if (isJump) {
|
|
|
|
if (isJump) {
|
|
|
@ -127,7 +138,7 @@ public class DepartmentCodeUtil {
|
|
|
|
fieldMap.put("2", "ejbmls");
|
|
|
|
fieldMap.put("2", "ejbmls");
|
|
|
|
fieldMap.put("3", "sjbmls");
|
|
|
|
fieldMap.put("3", "sjbmls");
|
|
|
|
String field = fieldMap.get(deptLevel);
|
|
|
|
String field = fieldMap.get(deptLevel);
|
|
|
|
rs.executeUpdate("update uf_departmentcode_rules set "+field+" = ?",newSerialnum);
|
|
|
|
rs.executeUpdate("update uf_departmentcode_rules set "+field+" = ? where id = ?",newSerialnum,deptCodeRule.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return String.format(departmentCode,newSerialnum);
|
|
|
|
return String.format(departmentCode,newSerialnum);
|
|
|
@ -164,4 +175,17 @@ public class DepartmentCodeUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return "00";
|
|
|
|
return "00";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Map<String,String> getDepartmentCode(String deptId) {
|
|
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
|
|
|
|
|
Map<String,String> data = new HashMap<>();
|
|
|
|
|
|
|
|
rs.executeQuery("select departmentcode,supdepid from hrmdepartment where id = ?",deptId);
|
|
|
|
|
|
|
|
rs.next();
|
|
|
|
|
|
|
|
data.put("departmentcode",Util.null2String(rs.getString("departmentcode")));
|
|
|
|
|
|
|
|
data.put("supdepid",Util.null2String(rs.getString("supdepid")));
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|