矩阵更新
commit
488fc00142
@ -0,0 +1,3 @@
|
||||
|
||||
## ???? DEV=????,TEST = ????,PROD = ????
|
||||
active = PROD
|
@ -0,0 +1,104 @@
|
||||
package weaver.interfaces.nl.job;
|
||||
|
||||
import com.wbi.util.Util;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.interfaces.nl.util.PropBean;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* 修改矩阵中的一级部门领导
|
||||
*/
|
||||
public class ModifyJobActivityJob extends BaseCronJob {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
new BaseBean();
|
||||
BaseBean bb = new BaseBean();
|
||||
|
||||
bb.writeLog("ModifyJobActivityJob Start");
|
||||
try {
|
||||
RecordSet rs = new RecordSet();
|
||||
//获取处级正职的职务ID
|
||||
String divisionalPosition = Util.null2String(PropBean.getUfPropValue("DivisionalPosition"), "-1");
|
||||
bb.writeLog("ModifyJobActivityJob divisionalPosition: " + divisionalPosition);
|
||||
|
||||
if (StringUtils.isNotBlank(divisionalPosition) && !"-1".equals(divisionalPosition)) {
|
||||
Map<String,String> map = new HashMap<>();
|
||||
String acqDeptSql = "select a.id, a.departmentid, d.departmentname " +
|
||||
"from hrmresource a " +
|
||||
"left join hrmjobtitles b " +
|
||||
"on a.jobtitle = b.id " +
|
||||
"left join hrmjobactivities c " +
|
||||
"on c.id = b.JOBACTIVITYid " +
|
||||
"left join hrmdepartment d " +
|
||||
"on d.id = a.departmentid " +
|
||||
"where a.status in (0,1,2,3) and c.id in (" + divisionalPosition + ")";
|
||||
bb.writeLog("ModifyJobActivityJob acqDeptSql: " + acqDeptSql);
|
||||
rs.executeQuery(acqDeptSql);
|
||||
while (rs.next()) {
|
||||
String resId = Util.null2String(rs.getString("id"));
|
||||
String departmentId = Util.null2String(rs.getString("departmentid"));
|
||||
if (map.containsKey(departmentId)) {
|
||||
String s = map.get(departmentId);
|
||||
s = s + "," + resId;
|
||||
map.put(departmentId, s);
|
||||
} else {
|
||||
map.put(departmentId, resId);
|
||||
}
|
||||
}
|
||||
bb.writeLog("ModifyJobActivityJob map: " + map);
|
||||
|
||||
if ( map != null && map.size() > 0) {
|
||||
List<String> firstDepts = new ArrayList<>();
|
||||
//获取需要更新的矩阵
|
||||
String matrixId = Util.null2String(PropBean.getUfPropValue("matrixId"), "-1");
|
||||
bb.writeLog("ModifyJobActivityJob matrixId: " + matrixId);
|
||||
|
||||
if (StringUtils.isNotBlank(matrixId) && !"-1".equals(matrixId)) {
|
||||
String acqMatSql = "select szyjbm from Matrixtable_" + matrixId + " ";
|
||||
bb.writeLog("ModifyJobActivityJob acqMatSql: " + acqMatSql);
|
||||
|
||||
rs.executeQuery(acqMatSql);
|
||||
while (rs.next()) {
|
||||
String szyjbm = Util.null2String(rs.getString("szyjbm"));
|
||||
if (StringUtils.isNotBlank(szyjbm)) {
|
||||
firstDepts.add(szyjbm);
|
||||
}
|
||||
}
|
||||
bb.writeLog("ModifyJobActivityJob firstDepts: " + firstDepts);
|
||||
|
||||
if( firstDepts != null && firstDepts.size() > 0) {
|
||||
String modifysql = "update Matrixtable_" + matrixId + " set bmld = ? where szyjbm = ? ";
|
||||
bb.writeLog("ModifyJobActivityJob modifysql: " + modifysql);
|
||||
|
||||
List<List> modifyList = new ArrayList<>();
|
||||
for( String depid : firstDepts) {
|
||||
String resId = Util.null2String(map.get(depid));
|
||||
List temp = new ArrayList();
|
||||
temp.add(resId);
|
||||
temp.add(depid);
|
||||
modifyList.add(temp);
|
||||
}
|
||||
bb.writeLog("ModifyJobActivityJob modifyList: " + modifyList);
|
||||
|
||||
if (modifyList != null && modifyList.size() > 0) {
|
||||
boolean modifyFlag = rs.executeBatchSql(modifysql, modifyList);
|
||||
bb.writeLog("ModifyJobActivityJob modifyFlag: " + modifyFlag);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}catch (Exception e) {
|
||||
bb.writeLog("ModifyJobActivityJob Exception: " + e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package weaver.interfaces.nl.util;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
|
||||
public class PropBean {
|
||||
|
||||
public static BaseBean bb = new BaseBean();
|
||||
public static String active = Util.null2String(bb.getPropValue("developProp","active")).toUpperCase();
|
||||
|
||||
/***
|
||||
*
|
||||
* @param pkey
|
||||
* @return
|
||||
*/
|
||||
public static String getUfPropValue(String pkey)
|
||||
{
|
||||
BaseBean baseBean = new BaseBean();
|
||||
if(StringUtils.isEmpty(pkey)){
|
||||
return "";
|
||||
}
|
||||
|
||||
if(StringUtils.isEmpty(active)){
|
||||
active = Util.null2String(baseBean.getPropValue("developProp","active")).toUpperCase();
|
||||
}
|
||||
|
||||
String pvalue = "";
|
||||
try{
|
||||
RecordSet rs = new RecordSet();
|
||||
String sql = " SELECT DEVVALUE,TESTVALUE,PRODVALUE FROM UF_PROP WHERE PKEY = ?";
|
||||
rs.executeQuery(sql,new Object[]{pkey.trim()});
|
||||
if(rs.next()){
|
||||
pvalue = Util.null2String(rs.getString(active+"VALUE"));
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
bb.writeLog("propbean-e:"+e);
|
||||
}
|
||||
return pvalue;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue