|
|
package weaver.interfaces.dito.mq;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.cloudstore.dev.api.bean.MessageBean;
|
|
|
import com.cloudstore.dev.api.bean.MessageType;
|
|
|
import com.cloudstore.dev.api.util.Util_Message;
|
|
|
import okhttp3.*;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import weaver.conn.RecordSet;
|
|
|
import weaver.formmode.setup.ModeRightInfo;
|
|
|
import weaver.general.BaseBean;
|
|
|
import weaver.general.LabelUtil;
|
|
|
import weaver.general.TimeUtil;
|
|
|
import weaver.general.Util;
|
|
|
import weaver.hrm.cachecenter.bean.RolemembersComInfo;
|
|
|
import weaver.hrm.company.DepartmentComInfo;
|
|
|
import weaver.hrm.definedfield.HrmFieldComInfo;
|
|
|
import weaver.hrm.job.JobTitlesComInfo;
|
|
|
import weaver.hrm.resource.ResourceComInfo;
|
|
|
import weaver.hrm.roles.RolesComInfo;
|
|
|
import weaver.interfaces.dito.comInfo.PropBean;
|
|
|
import weaver.matrix.MatrixUtil;
|
|
|
import weaver.systeminfo.systemright.CheckUserRight;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.locks.Lock;
|
|
|
import java.util.concurrent.locks.ReentrantLock;
|
|
|
|
|
|
public class RocketmqUtil {
|
|
|
private List<ConsumerBase> consumerBases;
|
|
|
|
|
|
{
|
|
|
consumerBases = new ArrayList<>();
|
|
|
consumerBases.add(new SignatureConsumer());
|
|
|
}
|
|
|
|
|
|
private Lock lock = new ReentrantLock();
|
|
|
public int updateOrgData(String data)
|
|
|
{
|
|
|
BaseBean bb = new BaseBean();
|
|
|
int errcount = 0;
|
|
|
lock.lock();
|
|
|
try{
|
|
|
JSONObject jsonObject = JSONObject.parseObject(data);
|
|
|
if(jsonObject.containsKey("requestObject"))
|
|
|
{
|
|
|
JSONArray requestArray = jsonObject.getJSONArray("requestObject");
|
|
|
for(int i=0;i<requestArray.size();i++)
|
|
|
{
|
|
|
JSONObject requestObject = requestArray.getJSONObject(i);
|
|
|
System.out.println(requestObject.toJSONString());
|
|
|
if(!requestObject.isEmpty()){
|
|
|
if(requestObject.containsKey("tableName") && requestObject.containsKey("content"))
|
|
|
{
|
|
|
String tableName = requestObject.getString("tableName");
|
|
|
JSONArray jsonArray = requestObject.getJSONArray("content");
|
|
|
bb.writeLog("tableName:"+tableName);
|
|
|
if("organization".equals(tableName)){
|
|
|
updasteSysOrgData(jsonArray,tableName);
|
|
|
}else if("system_user".equals(tableName)){
|
|
|
// updateSysUserData(jsonArray,tableName);
|
|
|
}else if("system_roles".equals(tableName)){
|
|
|
updasteSysRoleData(jsonArray,tableName);
|
|
|
}else if("system_post".equals(tableName)){
|
|
|
updasteSysPostData(jsonArray,tableName);
|
|
|
}else if("system_user_role".equals(tableName)){
|
|
|
updateSystemUserRoleData(jsonArray,tableName);
|
|
|
}else if("system_user_post".equals(tableName)){
|
|
|
updateSystemUserPostData(jsonArray,tableName);
|
|
|
}else if("staff".equals(tableName)){
|
|
|
updateStaffData(jsonArray,tableName);
|
|
|
}
|
|
|
for (ConsumerBase consumerBase :consumerBases){
|
|
|
if (consumerBase.support(tableName)){
|
|
|
consumerBase.consumer(jsonArray,tableName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
bb.writeLog("e:"+e);
|
|
|
}finally {
|
|
|
lock.unlock();
|
|
|
}
|
|
|
return errcount;
|
|
|
}
|
|
|
|
|
|
//{"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},
|
|
|
// "svcCode":"70300100030001","requestObject":[{"content":[
|
|
|
// {"statusDate":"2022-07-18 11:25:41","updateDate":"2022-07-22 10:52:56",
|
|
|
// "regionNbr":"1","expDate":"2999-12-31 23:59:59","userOrgId":"2",
|
|
|
// "password":"{bcrypt}$2a$10$wQrGr6zHlqaKbAZGaK7PC.VdmZdq4HJn6t7R4XpGsf/yKqPj6smHq",
|
|
|
// "effDate":"2021-07-13 10:33:57","orgCode":"2",
|
|
|
// "staffName":"zhouhan","pwdNewtime":"2022-05-18 14:42:15",
|
|
|
// "pwdContinErrCnt":"0","actType":"M","sysUserId":"14002","email":"2112@qq.com",
|
|
|
// "createDate":"2021-07-13 10:33:58","staffCode":"zhouhan",
|
|
|
// "sysUserCode":"zhouhan","pwdErrCnt":"0","pwdEffectDays":"90","statusCd":"1000",
|
|
|
// "systemInfoId":"-1","userName":"zhouhan","createStaff":"1","pwdStatus":"1100",
|
|
|
// "regionId":"731","pwdSmsTel":"21423523523","loginedNum":"78","staffId":"12002",
|
|
|
// "updateStaff":"1"}],"tableName":"system_user","primaryKey":"sysUserId"}],"key":"svcCont"}
|
|
|
/***
|
|
|
*
|
|
|
* @param jsonArray
|
|
|
*/
|
|
|
public void updateSysUserData(JSONArray jsonArray, String tableName){
|
|
|
// RecordSet rs = new RecordSet();
|
|
|
// BaseBean bb = new BaseBean();
|
|
|
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
// String nowDateTime = sdf.format(new Date());
|
|
|
// String locationid = "2" ;
|
|
|
// String seclevel = "20" ;
|
|
|
// String createrid = "1" ;
|
|
|
// String lastmodid = "1" ;
|
|
|
// String creator = "1";
|
|
|
// String systemlanguage = "8" ;
|
|
|
// String currentDate = TimeUtil.getCurrentDateString();//当前日期
|
|
|
// String currentDateTime = TimeUtil.getCurrentTimeString(); //当前时间
|
|
|
//
|
|
|
// String jobTitleId = "" ;
|
|
|
// String defaultJobCode = PropBean.getUfPropValue("defaultJobCode");
|
|
|
// if(StringUtils.isNotEmpty(defaultJobCode)){
|
|
|
// String sql = " select id from hrmjobtitles where jobtitlecode = ?" ;
|
|
|
// rs.executeQuery(sql,new Object[]{defaultJobCode});
|
|
|
// if(rs.next()){
|
|
|
// jobTitleId = Util.null2String(rs.getString("id"));
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// for(int i=0;i<jsonArray.size();i++)
|
|
|
// {
|
|
|
// JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
// String statusDate = Util.null2String(jsonObject.get("statusDate"));
|
|
|
// String updateDate = Util.null2String(jsonObject.get("updateDate"));
|
|
|
// String regionNbr = Util.null2String(jsonObject.get("regionNbr"));
|
|
|
// String userOrgId = Util.null2String(jsonObject.get("userOrgId"));
|
|
|
// String orgCode = Util.null2String(jsonObject.get("orgCode"));
|
|
|
//
|
|
|
// String staffId = Util.null2String(jsonObject.get("staffId"));
|
|
|
// String staffName = Util.null2String(jsonObject.get("staffName"));
|
|
|
// String staffCode = Util.null2String(jsonObject.get("staffCode"));
|
|
|
// String actType = Util.null2String(jsonObject.get("actType"));
|
|
|
//
|
|
|
// String email = "" ;
|
|
|
// if(jsonObject.containsKey("eMail")){
|
|
|
// email = Util.null2String(jsonObject.get("eMail"));
|
|
|
// }else if(jsonObject.containsKey("email")){
|
|
|
// email = Util.null2String(jsonObject.get("email"));
|
|
|
// }
|
|
|
//
|
|
|
// String sysUserId = Util.null2String(jsonObject.get("sysUserId"));
|
|
|
// String sysUserCode = Util.null2String(jsonObject.get("sysUserCode"));
|
|
|
// String userName = Util.null2String(jsonObject.get("userName"));
|
|
|
// String pwdSmsTel = Util.null2String(jsonObject.get("pwdSmsTel"));
|
|
|
//
|
|
|
// String loginedNum = Util.null2String(jsonObject.get("sysUserId"));
|
|
|
//
|
|
|
// String statusCd = Util.null2String(jsonObject.get("statusCd"));
|
|
|
// String status = "1";
|
|
|
//
|
|
|
// try{
|
|
|
// String subcompanyid1 = "" ;
|
|
|
// String deptId = "";
|
|
|
// if(StringUtils.isNotEmpty(orgCode)){
|
|
|
// String sql = " select id,subcompanyid1 from hrmdepartment where departmentcode = ?" ;
|
|
|
// rs.executeQuery(sql,new Object[]{orgCode});
|
|
|
// if(rs.next()){
|
|
|
// deptId = Util.null2String(rs.getString("id"));
|
|
|
// subcompanyid1 = Util.null2String(rs.getString("subcompanyid1"));
|
|
|
// }
|
|
|
// }
|
|
|
// bb.writeLog("deptId:"+deptId);
|
|
|
// bb.writeLog("subcompanyid1:"+subcompanyid1);
|
|
|
// bb.writeLog("currentDate:"+currentDate);
|
|
|
//
|
|
|
// int datacount = 0;
|
|
|
// String sql = " select id from hrmresource where workcode=?" ;
|
|
|
// bb.writeLog("sql:"+sql);
|
|
|
// bb.writeLog("staffCode:"+staffCode);
|
|
|
// rs.executeQuery(sql,new Object[]{staffCode});
|
|
|
// while (rs.next()){
|
|
|
// datacount++;
|
|
|
// }
|
|
|
// bb.writeLog("datacount:"+datacount);
|
|
|
// if(datacount <= 1){
|
|
|
//
|
|
|
// String loginid = "";
|
|
|
// String user_status = "" ;
|
|
|
// sql = " select loginid,status from hrmresource where workcode='"+staffCode+"' " ;
|
|
|
// bb.writeLog("sql:"+sql);
|
|
|
// rs.executeQuery(sql);
|
|
|
// if(rs.next()){
|
|
|
// loginid = Util.null2String(rs.getString("loginid"));
|
|
|
// user_status = Util.null2String(rs.getString("status"));
|
|
|
// bb.writeLog("loginid:"+loginid);
|
|
|
// bb.writeLog("user_status:"+user_status);
|
|
|
// if(StringUtils.isBlank(loginid)){
|
|
|
// if("5".equals(user_status)){
|
|
|
// loginid = staffCode;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// bb.writeLog("loginid:"+loginid);
|
|
|
// bb.writeLog("user_status2:"+user_status);
|
|
|
// bb.writeLog("statusCd2:"+statusCd);
|
|
|
//
|
|
|
// String lastname = staffName ;
|
|
|
// bb.writeLog("loginid2:"+loginid);
|
|
|
// if(StringUtils.isNotEmpty(deptId))
|
|
|
// {
|
|
|
// if(StringUtils.isNotEmpty(loginid))
|
|
|
// {
|
|
|
// if("M".equalsIgnoreCase(actType))
|
|
|
// {
|
|
|
// if("1000".equals(statusCd)){
|
|
|
// status = "1";
|
|
|
// }else if("1100".equals(statusCd) || "1240".equals(statusCd)){
|
|
|
// status = "5";
|
|
|
// }
|
|
|
// bb.writeLog("status2:"+status);
|
|
|
//
|
|
|
// String userUpdateSql = " update hrmresource set loginid=?,lastname=?,departmentid=?,subcompanyid1=?," +
|
|
|
// " creater=?,email=?,mobile=?,status=?,dsporder=?,lastmoddate=?,modified=? where workcode=? ";
|
|
|
// bb.writeLog("updateSysUserData-userUpdateSql:"+userUpdateSql);
|
|
|
//
|
|
|
// boolean flag = rs.executeUpdate(userUpdateSql,new Object[]{loginid,lastname,deptId,subcompanyid1,creator,email,
|
|
|
// pwdSmsTel,status,loginedNum,currentDate,currentDateTime,staffCode});
|
|
|
// bb.writeLog("flag:"+flag);
|
|
|
// Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
// dataMap.put("staffcodecount",datacount+"");
|
|
|
// dataMap.put("staffcode",staffCode);
|
|
|
// dataMap.put("syndate",nowDateTime);
|
|
|
// dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
// dataMap.put("systable",tableName);
|
|
|
// if(!flag){
|
|
|
// dataMap.put("errmessage","人员信息更新sql执行错误");
|
|
|
//
|
|
|
// }else {
|
|
|
// dataMap.put("errmessage","人员信息更新sql执行成功");
|
|
|
// }
|
|
|
// recordErrorData(dataMap);
|
|
|
// }else if("D".equals(actType)){
|
|
|
// status = "5";
|
|
|
// String userUpdateSql = " update hrmresource set status=? where workcode=? ";
|
|
|
// bb.writeLog("userUpdateSql:"+userUpdateSql);
|
|
|
// boolean flag = rs.executeUpdate(userUpdateSql,new Object[]{status,staffCode});
|
|
|
// bb.writeLog("flag:"+flag);
|
|
|
// Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
// dataMap.put("staffcodecount",datacount+"");
|
|
|
// dataMap.put("staffcode",staffCode);
|
|
|
// dataMap.put("syndate",nowDateTime);
|
|
|
// dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
// dataMap.put("systable",tableName);
|
|
|
// if(!flag){
|
|
|
// dataMap.put("errmessage","人员离职更新sql执行错误");
|
|
|
// }else {
|
|
|
// dataMap.put("errmessage","人员离职更新sql执行成功");
|
|
|
// }
|
|
|
// recordErrorData(dataMap);
|
|
|
// }else{
|
|
|
// Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
// dataMap.put("staffcodecount",datacount+"");
|
|
|
// dataMap.put("staffcode",staffCode);
|
|
|
// dataMap.put("syndate",nowDateTime);
|
|
|
// dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
// dataMap.put("errmessage","人员系统中已存在,操作类型为A");
|
|
|
// dataMap.put("systable",tableName);
|
|
|
// recordErrorData(dataMap);
|
|
|
//
|
|
|
// String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工在系统中已存在,操作类型为A,请检查数据" ;
|
|
|
// recordErrorMessage(staffCode,context);
|
|
|
// }
|
|
|
// }else{
|
|
|
// if("A".equalsIgnoreCase(actType))
|
|
|
// {
|
|
|
// int status1count = 0;
|
|
|
// sql = " select id from hrmresource where loginid = ? and status in(0,1,2,3) " ;
|
|
|
// bb.writeLog("sql:"+sql);
|
|
|
// rs.executeQuery(sql,new Object[]{staffCode});
|
|
|
// if(rs.next()){
|
|
|
// status1count++;
|
|
|
// }
|
|
|
// bb.writeLog("status1count:"+status1count);
|
|
|
//
|
|
|
// if(status1count == 0) {
|
|
|
// int status5count = 0;
|
|
|
// List<String> loginList = new ArrayList<String>();
|
|
|
// sql = " select id,status from hrmresource where loginid = ? and status = 5";
|
|
|
// rs.executeQuery(sql, new Object[]{staffCode});
|
|
|
// while (rs.next()) {
|
|
|
// String user_id = Util.null2String(rs.getString("id"));
|
|
|
// String upsql = " update hrmresource set loginid='" + staffCode + "_" + status5count + "' where id = " + user_id;
|
|
|
// bb.writeLog("upsql:" + upsql);
|
|
|
// loginList.add(upsql);
|
|
|
// status5count++;
|
|
|
// }
|
|
|
// bb.writeLog("status5count:"+status5count);
|
|
|
// if (status5count > 0) {
|
|
|
// for (String upsql : loginList) {
|
|
|
// boolean isTrue = rs.executeUpdate(upsql);
|
|
|
// bb.writeLog("isTrue:"+isTrue);
|
|
|
// }
|
|
|
// }
|
|
|
//
|
|
|
// String pwd = "1";
|
|
|
// String password = DigestUtils.md5Hex(pwd).toUpperCase(); //MD5加密
|
|
|
// bb.writeLog("password:"+password);
|
|
|
//
|
|
|
// rs.executeProc("HrmResourceMaxId_Get", "");
|
|
|
// rs.next();
|
|
|
// String id = "" + rs.getInt(1);
|
|
|
// bb.writeLog("id:"+id);
|
|
|
//
|
|
|
// if(StringUtils.isNotEmpty(id)){
|
|
|
// String userInsertSql = " insert into hrmresource(id,loginid,password,workcode,lastname,departmentid,subcompanyid1," +
|
|
|
// "creater,email,mobile,jobtitle,status,dsporder,systemlanguage,createdate,lastmoddate,created,modified," +
|
|
|
// "locationid,seclevel,createrid,lastmodid) " +
|
|
|
// " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
// bb.writeLog("userInsertSql:"+userInsertSql);
|
|
|
// boolean flag = rs.executeUpdate(userInsertSql,new Object[]{id,staffCode,password,staffCode,lastname,deptId,subcompanyid1,
|
|
|
// creator,email,pwdSmsTel,jobTitleId,status,loginedNum,systemlanguage,currentDate,currentDate,currentDateTime,currentDateTime,
|
|
|
// locationid,seclevel,createrid,lastmodid});
|
|
|
// bb.writeLog("flag:"+flag);
|
|
|
// Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
// dataMap.put("staffcodecount",datacount+"");
|
|
|
// dataMap.put("staffcode",staffCode);
|
|
|
// dataMap.put("syndate",nowDateTime);
|
|
|
// dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
// dataMap.put("systable",tableName);
|
|
|
// if(!flag){
|
|
|
// dataMap.put("errmessage","人员新增sql执行错误");
|
|
|
// }else {
|
|
|
// dataMap.put("errmessage","人员新增sql执行成功");
|
|
|
// }
|
|
|
// recordErrorData(dataMap);
|
|
|
// }
|
|
|
// }else{
|
|
|
//
|
|
|
// Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
// dataMap.put("staffcodecount",datacount+"");
|
|
|
// dataMap.put("staffcode",staffCode);
|
|
|
// dataMap.put("syndate",nowDateTime);
|
|
|
// dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
// dataMap.put("errmessage","人员:"+staffCode+"在系统中已存在,操作类型为A");
|
|
|
// dataMap.put("systable",tableName);
|
|
|
// recordErrorData(dataMap);
|
|
|
//
|
|
|
// String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工在系统中已存在,操作类型为A,请检查数据" ;
|
|
|
// recordErrorMessage(staffCode,context);
|
|
|
// }
|
|
|
// }else{
|
|
|
// Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
// dataMap.put("staffcodecount",datacount+"");
|
|
|
// dataMap.put("staffcode",staffCode);
|
|
|
// dataMap.put("syndate",nowDateTime);
|
|
|
// dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
// dataMap.put("errmessage","人员在系统中不存在,操作类型为M或者D");
|
|
|
// dataMap.put("systable",tableName);
|
|
|
// recordErrorData(dataMap);
|
|
|
//
|
|
|
// String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工在系统中不存在,操作类型为M或者D,请检查数据" ;
|
|
|
// recordErrorMessage(staffCode,context);
|
|
|
// }
|
|
|
// }
|
|
|
// }else{
|
|
|
// Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
// dataMap.put("staffcodecount",datacount+"");
|
|
|
// dataMap.put("staffcode",staffCode);
|
|
|
// dataMap.put("syndate",nowDateTime);
|
|
|
// dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
// dataMap.put("errmessage","人员所属部门为空");
|
|
|
// dataMap.put("systable",tableName);
|
|
|
// recordErrorData(dataMap);
|
|
|
//
|
|
|
// String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工所属部门为空,请检查数据" ;
|
|
|
// recordErrorMessage(staffCode,context);
|
|
|
// }
|
|
|
// }else{
|
|
|
//
|
|
|
// Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
// dataMap.put("staffcodecount",datacount+"");
|
|
|
// dataMap.put("staffcode",staffCode);
|
|
|
// dataMap.put("syndate",nowDateTime);
|
|
|
// dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
// dataMap.put("errmessage","工号:"+staffCode+"的员工现为在职"+datacount+"组数据,无法进行处理");
|
|
|
// dataMap.put("systable",tableName);
|
|
|
// recordErrorData(dataMap);
|
|
|
//
|
|
|
// String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工现为在职"+datacount+"组数据,请检查数据" ;
|
|
|
// recordErrorMessage(staffCode,context);
|
|
|
//
|
|
|
// }
|
|
|
//
|
|
|
// }catch (Exception e){
|
|
|
// Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
// dataMap.put("staffcodecount","");
|
|
|
// dataMap.put("staffcode",staffCode);
|
|
|
// dataMap.put("syndate",nowDateTime);
|
|
|
// dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
// dataMap.put("errmessage","人力资源异常:"+e.getMessage());
|
|
|
// dataMap.put("systable",tableName);
|
|
|
// recordErrorData(dataMap);
|
|
|
// }
|
|
|
// }
|
|
|
}
|
|
|
|
|
|
// {"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},"svcCode":
|
|
|
// "70300100030001","requestObject":[{"content":[{
|
|
|
// "updateDate":"2022-07-22 11:05:22","orgName":"testOrg722","parentOrgCode":"LNP000001",
|
|
|
// "regionNbr":"TST_PR_CSS","orgLevel":"2","statusCd":"1000",
|
|
|
// "parentOrgName":"Vivia","orgId":"17012",
|
|
|
// "createStaff":"1","orgType":"1000",
|
|
|
// "regionId":"36","parentOrgId":"1",
|
|
|
// "orgCode":"testOrg722",
|
|
|
// "pathCode":"-1.1.17012","actType":"A","partyId":"0",
|
|
|
// "parRegionNbr":"1",
|
|
|
// "createDate":"2022-07-22 11:05:22"
|
|
|
// }],"tableName":"organization","primaryKey":"orgId"}],"key":"svcCont"}
|
|
|
/****
|
|
|
*
|
|
|
* @param jsonArray
|
|
|
* @return
|
|
|
*/
|
|
|
public void updasteSysOrgData(JSONArray jsonArray, String tableName){
|
|
|
RecordSet rs = new RecordSet();
|
|
|
BaseBean bb = new BaseBean();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
String nowDateTime = sdf.format(new Date());
|
|
|
|
|
|
for(int i=0;i<jsonArray.size();i++)
|
|
|
{
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
String orgName = Util.null2String(jsonObject.get("orgName"));
|
|
|
String parentOrgCode = Util.null2String(jsonObject.get("parentOrgCode"));
|
|
|
String statusCd = Util.null2String(jsonObject.get("statusCd"));
|
|
|
String parentOrgName = Util.null2String(jsonObject.get("parentOrgName"));
|
|
|
String orgId = Util.null2String(jsonObject.get("orgId"));
|
|
|
String orgType = Util.null2String(jsonObject.get("orgType"));
|
|
|
String orgCode = Util.null2String(jsonObject.get("orgCode"));
|
|
|
String actType = Util.null2String(jsonObject.get("actType"));
|
|
|
String canceled = "";
|
|
|
try{
|
|
|
String supdepid = "0";
|
|
|
String subcompanyid1 = "" ;
|
|
|
if(StringUtils.isNotEmpty(parentOrgCode))
|
|
|
{
|
|
|
rs.executeQuery(" select id from hrmsubcompany where subcompanycode=? ",new Object[]{parentOrgCode});
|
|
|
if(rs.next()){
|
|
|
subcompanyid1 = Util.null2String(rs.getString("id"));
|
|
|
}
|
|
|
if("".equals(subcompanyid1)){
|
|
|
String sql = " select id,subcompanyid1 from hrmdepartment where departmentcode = ?" ;
|
|
|
rs.executeQuery(sql,new Object[]{parentOrgCode});
|
|
|
if(rs.next()){
|
|
|
supdepid = Util.null2String(rs.getString("id"));
|
|
|
subcompanyid1 = Util.null2String(rs.getString("subcompanyid1"));
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
bb.writeLog("actType:"+actType);
|
|
|
bb.writeLog("supdepid:"+supdepid);
|
|
|
bb.writeLog("subcompanyid1:"+subcompanyid1);
|
|
|
// String departmentmark = " ~`~`7 "+orgName+"`~`8 "+orgName+"`~`~";
|
|
|
String departmentmark = orgName;
|
|
|
if(StringUtils.isNotEmpty(subcompanyid1))
|
|
|
{
|
|
|
String deptid = "" ;
|
|
|
String sql = " select id from hrmdepartment where departmentcode=?" ;
|
|
|
rs.executeQuery(sql,new Object[]{orgCode});
|
|
|
if(rs.next()){
|
|
|
deptid = Util.null2String(rs.getString("id"));
|
|
|
}
|
|
|
bb.writeLog("deptid:"+deptid);
|
|
|
if(StringUtils.isNotEmpty(deptid))
|
|
|
{
|
|
|
if("M".equalsIgnoreCase(actType))
|
|
|
{
|
|
|
String deptUpdateSql = " update hrmdepartment set departmentmark=?,departmentname=?," +
|
|
|
" subcompanyid1=?,showorder=?, supdepid=? where departmentcode=? ";
|
|
|
bb.writeLog("deptUpdateSql:"+deptUpdateSql);
|
|
|
|
|
|
Object[] objects = new Object[]{departmentmark,departmentmark,subcompanyid1,orgId,supdepid,orgCode} ;
|
|
|
|
|
|
boolean flag = rs.executeUpdate(deptUpdateSql,objects);
|
|
|
bb.writeLog("flag:"+flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if(!flag){
|
|
|
dataMap.put("errmessage","更新部门SQL语句执行错误");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","更新部门SQL语句执行成功");
|
|
|
}
|
|
|
|
|
|
dataMap.put("zxyj",deptUpdateSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
dataMap.put("staffcode",orgCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}else if("D".equalsIgnoreCase(actType))
|
|
|
{
|
|
|
canceled = "1";
|
|
|
|
|
|
int hrmResourceCount = 0 ;
|
|
|
String queryHrmResourceSql = " select id from hrmresource where departmentid = ? and status !=5 " ;
|
|
|
rs.executeQuery(queryHrmResourceSql,new Object[]{deptid});
|
|
|
if(rs.next()){
|
|
|
hrmResourceCount++;
|
|
|
}
|
|
|
|
|
|
if(hrmResourceCount == 0 ){
|
|
|
String deptUpdateSql = " update hrmdepartment set departmentmark=?,departmentname=?,canceled=?," +
|
|
|
" subcompanyid1=?,showorder=?, supdepid=? where departmentcode=? ";
|
|
|
bb.writeLog("deptUpdateSql:"+deptUpdateSql);
|
|
|
|
|
|
Object[] objects = new Object[]{departmentmark,departmentmark,canceled,subcompanyid1,orgId,supdepid,orgCode};
|
|
|
|
|
|
boolean flag = rs.executeUpdate(deptUpdateSql,objects);
|
|
|
bb.writeLog("flag:"+flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if(!flag){
|
|
|
dataMap.put("errmessage","封存部门SQL语句执行错误");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","封存部门SQL语句执行成功");
|
|
|
}
|
|
|
|
|
|
dataMap.put("zxyj",deptUpdateSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
dataMap.put("staffcode",orgCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","部门在系统中已存在,操作类型为A");
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",orgCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}else{
|
|
|
if("A".equalsIgnoreCase(actType))
|
|
|
{
|
|
|
String deptInsertSql = " insert into hrmdepartment(departmentmark,departmentname,departmentcode,subcompanyid1,supdepid,showorder) values(?,?,?,?,?,?) ";
|
|
|
bb.writeLog("deptInsertSql:"+deptInsertSql);
|
|
|
|
|
|
Object[] objects = new Object[]{departmentmark,departmentmark,orgCode,subcompanyid1,supdepid,orgId};
|
|
|
|
|
|
boolean flag = rs.executeUpdate(deptInsertSql,objects);
|
|
|
bb.writeLog("flag:"+flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if(!flag){
|
|
|
dataMap.put("errmessage","新增部门SQL语句执行错误");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","新增部门SQL语句执行成功");
|
|
|
}
|
|
|
|
|
|
dataMap.put("zxyj",deptInsertSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
dataMap.put("staffcode",orgCode);
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","部门在系统中不存在,操作类型为M或者D");
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
dataMap.put("staffcode",orgCode);
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","部门所属分部在系统为空");
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
dataMap.put("staffcode",orgCode);
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","部门异常:"+e.getMessage());
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
dataMap.put("staffcode",orgCode);
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// {"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},"svcCode":
|
|
|
// "70300100030001","requestObject":[{"content":[{"sysUserRoleId":"23444","updateDate":"2022-07-22 11:08:33",
|
|
|
// "systemInfoCode":"TYMH","sysRoleId":"17013","statusCd":"1000",
|
|
|
// "systemInfoId":"727001","operType":"1000",
|
|
|
// "systemUserCode":"finaceManager",
|
|
|
// "expDate":"2120-01-01 00:00:00","orgId":"17012",
|
|
|
// "createStaff":"1","effDate":"2022-07-21 10:17:51",
|
|
|
// "systemUserName":"financeManager",
|
|
|
// "orgCode":"testOrg722","roleCode":"orgManager","manageClass":"1000","roleName":"orgManager",
|
|
|
// "actType":"A","sysUserId":"20047","createDate":"2022-07-22 11:08:33"}],
|
|
|
// "tableName":"system_user_role","primaryKey":"sysUserRoleId"}],"key":"svcCont"}
|
|
|
|
|
|
// {"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},"svcCode":"70300100030001",
|
|
|
// "requestObject":[{"content":[{"sysUserRoleId":"23503","updateDate":"2022-07-27 09:32:48","systemInfoCode":"TYMH",
|
|
|
// "hisId":"20182","sysRoleId":"17015","statusCd":"1100","hasUserRole":false,"systemInfoId":"727001",
|
|
|
// "operType":"1000","systemUserCode":"testQian722","expDate":"2120-01-01 00:00:00","orgId":"2","createStaff":"1",
|
|
|
// "effDate":"2022-07-25 13:59:59","systemUserName":"testQian722","orgCode":"2","roleCode":"testQian722",
|
|
|
// "manageClass":"1000","roleName":"testQian722","actType":"D","sysUserId":"20055",
|
|
|
// "createDate":"2022-07-25 15:43:24","updateStaff":"1"}],"tableName":"system_user_role",
|
|
|
// "primaryKey":"sysUserRoleId"}],"key":"svcCont"}
|
|
|
|
|
|
|
|
|
//{"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},"svcCode":"70300100030001",
|
|
|
// "requestObject":[{"content":[{"sysUserRoleId":"24031","updateDate":"2022-08-09 10:26:15","systemInfoCode":"TYMH",
|
|
|
// "sysRoleId":"17020","statusCd":"1000","systemInfoId":"727001","systemUserCode":"weaver12",
|
|
|
// "expDate":"2120-01-01 00:00:00","orgId":"11205","createStaff":"1","effDate":"2022-08-09 10:26:16",
|
|
|
// "systemUserName":"weaver12","orgCode":"GTR000593","roleCode":"weaver role","manageClass":"1000",
|
|
|
// "roleName":"weaver role","actType":"A","sysUserId":"20104","createDate":"2022-08-09 10:26:15"}],
|
|
|
// "tableName":"system_user_role","primaryKey":"sysUserRoleId"}],"key":"svcCont"}
|
|
|
|
|
|
|
|
|
// {"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},"svcCode":"70300100030001",
|
|
|
// "requestObject":[{"content":[{"sysUserRoleId":"32411","updateDate":"2022-10-24 19:10:40",
|
|
|
// "systemInfoCode":"TYMH","hisId":"30145","sysRoleId":"23005",
|
|
|
// "statusCd":"1100","hasUserRole":false,"systemInfoId":"727001",
|
|
|
// "systemUserCode":"weaver44","expDate":"2120-01-01 00:00:00","orgId":"17012","createStaff":"1",
|
|
|
// "effDate":"2022-10-24 19:10:11","systemUserName":"weaver44",
|
|
|
// "orgCode":"testOrg722","roleCode":"TestRole02","manageClass":"1000",
|
|
|
// "roleName":"TestRole02","actType":"D","sysUserId":"28025","createDate":"2022-10-24 19:10:19",
|
|
|
// "updateStaff":"1"}],"tableName":"system_user_role","primaryKey":"sysUserRoleId"}],"key":"svcCont"}
|
|
|
|
|
|
/***
|
|
|
*
|
|
|
* @param jsonArray
|
|
|
*/
|
|
|
public void updateSystemUserRoleData(JSONArray jsonArray, String tableName) {
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
String nowDateTime = sdf.format(new Date());
|
|
|
|
|
|
String rolelevel = "2" ; //总部=2;分部=1;部门=0
|
|
|
String resourcetype = "1"; //1=人力资源
|
|
|
|
|
|
RecordSet rs = new RecordSet();
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++)
|
|
|
{
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
String systemInfoCode = Util.null2String(jsonObject.get("systemInfoCode"));
|
|
|
if("PC_OA".equalsIgnoreCase(systemInfoCode))
|
|
|
{
|
|
|
String roleCode = Util.null2String(jsonObject.get("roleCode")).replace(" ", "");
|
|
|
String roleName = Util.null2String(jsonObject.get("roleName"));
|
|
|
|
|
|
String orgCode = Util.null2String(jsonObject.get("orgCode"));
|
|
|
|
|
|
String systemUserCode = Util.null2String(jsonObject.get("systemUserCode"));
|
|
|
String systemUserName = Util.null2String(jsonObject.get("systemUserName"));
|
|
|
String sysUserId = Util.null2String(jsonObject.get("sysUserId"));
|
|
|
|
|
|
//所有角色
|
|
|
Set<String> set = getSysRoles(sysUserId);
|
|
|
|
|
|
String actType = Util.null2String(jsonObject.get("actType"));
|
|
|
String statusCd = Util.null2String(jsonObject.get("statusCd"));
|
|
|
bb.writeLog("statusCd:" + statusCd + " actType:" + actType);
|
|
|
|
|
|
try {
|
|
|
|
|
|
String userId = "";
|
|
|
String departmentcode = "" ;
|
|
|
String roleId = "";
|
|
|
|
|
|
if (StringUtils.isNotEmpty(systemUserCode)) {
|
|
|
String sql =" select h.id,d.departmentcode from hrmresource h \n" +
|
|
|
" inner join hrmdepartment d on d.id = h.departmentid \n" +
|
|
|
" where loginid='"+systemUserCode+"'";
|
|
|
bb.writeLog("sql:"+sql);
|
|
|
rs.executeQuery(sql);
|
|
|
if (rs.next()) {
|
|
|
userId = Util.null2String(rs.getString("id"));
|
|
|
departmentcode = Util.null2String(rs.getString("departmentcode"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bb.writeLog("userId:"+userId);
|
|
|
bb.writeLog("departmentcode:"+departmentcode);
|
|
|
bb.writeLog("istrue:"+(StringUtils.isNotBlank(departmentcode) && departmentcode.equals(orgCode)));
|
|
|
|
|
|
// if(StringUtils.isNotBlank(departmentcode))
|
|
|
// {
|
|
|
if(StringUtils.isNotEmpty(roleCode)) {
|
|
|
|
|
|
String queryRoleIdSql = " select id from hrmroles where rolesmark=?";
|
|
|
rs.executeQuery(queryRoleIdSql, new Object[]{roleCode});
|
|
|
if (rs.next()) {
|
|
|
roleId = rs.getString("id");
|
|
|
}
|
|
|
}
|
|
|
bb.writeLog("userId:" + userId + " roleId:" + roleId);
|
|
|
|
|
|
if (StringUtils.isNotEmpty(userId) && StringUtils.isNotEmpty(roleId)) {
|
|
|
//查看是否已存在角色用户关系
|
|
|
String releationId = "";
|
|
|
String ifExistSql = "select id from hrmrolemembers where roleid=? and resourceid=?";
|
|
|
rs.executeQuery(ifExistSql,new Object[]{roleId, userId});
|
|
|
if (rs.next()) {
|
|
|
releationId = rs.getString("id");
|
|
|
}
|
|
|
bb.writeLog("userId:" + userId + " roleId:" + roleId + "releationId:" + releationId);
|
|
|
if (StringUtils.isNotEmpty(releationId)) {
|
|
|
if ("D".equals(actType)) {
|
|
|
// 不包含 角色
|
|
|
if(!set.contains(roleCode)){
|
|
|
|
|
|
String delHrmrolemembersSql = " delete from hrmrolemembers where id = ?";
|
|
|
bb.writeLog("delHrmrolemembersSql:"+delHrmrolemembersSql);
|
|
|
|
|
|
Object[] objects = new Object[]{releationId};
|
|
|
|
|
|
boolean flag = rs.executeUpdate(delHrmrolemembersSql, objects);
|
|
|
bb.writeLog("delHrmrolemembersSql : " + flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if (!flag) {
|
|
|
dataMap.put("errmessage","角色成员删除失败");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","角色成员删除成功");
|
|
|
}
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
|
|
|
dataMap.put("zxyj",delHrmrolemembersSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","角色成员系统已存在,操作类型为"+actType+",statusCd为:"+statusCd);
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}else if("M".equals(actType)){
|
|
|
if("1100".equals(statusCd)){
|
|
|
String delHrmrolemembersSql = " delete from hrmrolemembers where id = ?";
|
|
|
bb.writeLog("delHrmrolemembersSql:"+delHrmrolemembersSql);
|
|
|
|
|
|
Object[] objects = new Object[]{releationId};
|
|
|
|
|
|
boolean flag = rs.executeUpdate(delHrmrolemembersSql, objects);
|
|
|
bb.writeLog("delHrmrolemembersSql : " + flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
if (!flag) {
|
|
|
dataMap.put("errmessage","角色成员删除失败");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","角色成员删除成功");
|
|
|
}
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
|
|
|
dataMap.put("zxyj",delHrmrolemembersSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","角色成员系统已存在,操作类型为"+actType+",statusCd为:"+statusCd);
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","角色成员系统已存在,操作类型为A");
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
} else {
|
|
|
if ("A".equals(actType)) {
|
|
|
|
|
|
String insertHrmrolemembersSql = "insert into hrmrolemembers(roleid,resourceid,rolelevel,resourcetype,uuid) values(?,?,?,?,?)";
|
|
|
bb.writeLog("insertHrmrolemembersSql:"+insertHrmrolemembersSql);
|
|
|
Object[] objects = new Object[]{roleId, userId, rolelevel, resourcetype, UUID.randomUUID().toString()} ;
|
|
|
boolean flag = rs.executeUpdate(insertHrmrolemembersSql,objects);
|
|
|
|
|
|
bb.writeLog("insertHrmrolemembersSql : " + flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if (!flag) {
|
|
|
dataMap.put("errmessage","角色成员新增失败");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","角色成员新增成功");
|
|
|
}
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
|
|
|
dataMap.put("zxyj",insertHrmrolemembersSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}else if("M".equals(actType)){
|
|
|
if("1000".equals(statusCd)){
|
|
|
String insertHrmrolemembersSql = "insert into hrmrolemembers(roleid,resourceid,rolelevel,resourcetype,uuid) values(?,?,?,?,?)";
|
|
|
bb.writeLog("insertHrmrolemembersSql:"+insertHrmrolemembersSql);
|
|
|
|
|
|
Object[] objects = new Object[]{roleId, userId, rolelevel, resourcetype, UUID.randomUUID().toString()} ;
|
|
|
|
|
|
boolean flag = rs.executeUpdate(insertHrmrolemembersSql, objects);
|
|
|
bb.writeLog("insertHrmrolemembersSql : " + flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if (!flag) {
|
|
|
dataMap.put("errmessage","角色成员新增失败");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","角色成员新增成功");
|
|
|
}
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
|
|
|
dataMap.put("zxyj",insertHrmrolemembersSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","角色成员系统不存在,操作类型为"+actType+",statusCd为:"+statusCd);
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","角色成员系统不存在,操作类型为D");
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","人员角色数据,人员或者角色系统不存在");
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
// } else{
|
|
|
// Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
// dataMap.put("syndate",nowDateTime);
|
|
|
// dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
// dataMap.put("errmessage","数据中的orgCode:"+orgCode+"和"+systemUserName+"所属的部门编码不一致,无法更新数据");
|
|
|
// dataMap.put("systable",tableName);
|
|
|
// recordErrorData(dataMap);
|
|
|
// }
|
|
|
} catch (Exception e) {
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","角色成员异常:"+e.getMessage());
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
RolemembersComInfo RolemembersComInfo = new RolemembersComInfo();
|
|
|
RolemembersComInfo.removeCache();
|
|
|
|
|
|
CheckUserRight CheckUserRight = new CheckUserRight();
|
|
|
CheckUserRight.removeMemberRoleCache();
|
|
|
CheckUserRight.removeRoleRightdetailCache();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//{"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},"svcCode":"70300100030001",
|
|
|
// "requestObject":[{"content":[{"updateDate":"2022-07-27 09:32:48","systemInfoCode":"TYMH","relType":"1100","orgId":"2",
|
|
|
// "sysUserPostId":"123089","orgType":"1000","systemUserName":"testQian722","orgCode":"2","postName":"testXiao",
|
|
|
// "staffName":"testQian722","actType":"D","sysUserId":"20055","createDate":"2022-07-25 15:43:24","defaultFlag":"0",
|
|
|
// "staffCode":"testQian722","orgName":"Default Branch 1","sysPostId":"18007","hisId":"322425",
|
|
|
// "statusCd":"1100","systemInfoId":"727001","systemUserCode":"testQian722","createStaff":"1",
|
|
|
// "postCode":"testXiao","staffId":22021,"updateStaff":"1"}],"tableName":"system_user_post",
|
|
|
// "primaryKey":"sysUserPostId"}],"key":"svcCont"}
|
|
|
|
|
|
/***
|
|
|
*
|
|
|
* @param jsonArray
|
|
|
*/
|
|
|
public void updateSystemUserPostData(JSONArray jsonArray, String tableName) {
|
|
|
RecordSet rs = new RecordSet();
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
String nowDateTime = sdf.format(new Date());
|
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++) {
|
|
|
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
|
|
|
String postCode = Util.null2String(jsonObject.get("postCode"));
|
|
|
String postName = Util.null2String(jsonObject.get("postName"));
|
|
|
String DBName = PropBean.getUfPropValue("DBName");
|
|
|
Set<String> stringSet = getDeptMatrixColumns(DBName);
|
|
|
|
|
|
if(postCode.startsWith("MSS_CTO"))
|
|
|
{
|
|
|
String systemUserCode = Util.null2String(jsonObject.get("systemUserCode"));
|
|
|
String orgCode = Util.null2String(jsonObject.get("orgCode"));
|
|
|
String actType = Util.null2String(jsonObject.get("actType"));
|
|
|
String defaultFlag = Util.null2String(jsonObject.get("defaultFlag"));
|
|
|
String currentDateTime = TimeUtil.getCurrentTimeString(); //当前时间
|
|
|
String updateStaff = Util.null2String(jsonObject.get("updateStaff"));
|
|
|
if(StringUtils.isEmpty(updateStaff)){
|
|
|
updateStaff = "1";
|
|
|
}
|
|
|
String userId = "";
|
|
|
String jobtitlesId = "";
|
|
|
String departmentId = "-1";
|
|
|
try {
|
|
|
if(StringUtils.isNotEmpty(orgCode)){
|
|
|
String querDepartmentIdSql = " select id from hrmdepartment where departmentcode=? ";
|
|
|
bb.writeLog("querDepartmentIdSql:"+querDepartmentIdSql);
|
|
|
rs.executeQuery(querDepartmentIdSql,new Object[]{orgCode});
|
|
|
if (rs.next()){
|
|
|
departmentId = Util.null2String(rs.getString("id"),"null");
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(departmentId) && StringUtils.isNotEmpty(systemUserCode))
|
|
|
{
|
|
|
String sql = " select id from hrmresource where workcode=? and departmentid = ?";
|
|
|
bb.writeLog("sql:" + sql);
|
|
|
rs.executeQuery(sql, new Object[]{systemUserCode, departmentId});
|
|
|
if (rs.next()) {
|
|
|
userId = Util.null2String(rs.getString("id"));
|
|
|
}
|
|
|
}
|
|
|
if(StringUtils.isNotEmpty(postCode)) {
|
|
|
String queryRoleIdSql = " select id from hrmjobtitles where jobtitlecode=? ";
|
|
|
bb.writeLog("queryRoleIdSql:" + queryRoleIdSql);
|
|
|
rs.executeQuery(queryRoleIdSql, new Object[]{postCode});
|
|
|
if (rs.next()) {
|
|
|
jobtitlesId = rs.getString("id");
|
|
|
}
|
|
|
}
|
|
|
bb.writeLog("jobtitlesId:"+jobtitlesId);
|
|
|
|
|
|
if(StringUtils.isNotEmpty(jobtitlesId) && StringUtils.isNotEmpty(userId))
|
|
|
{
|
|
|
if("A".equals(actType) || "M".equals(actType))
|
|
|
{
|
|
|
if(StringUtils.isNotEmpty(postName)) {
|
|
|
postName = postName.toLowerCase().replaceAll("\\s+", "").replaceAll("_", "");
|
|
|
if(stringSet.contains(postName)){
|
|
|
String sql = "update matrixtable_2 set "+postName+"=? where id=?";
|
|
|
boolean bool = rs.executeUpdate(sql,new Object[]{userId,departmentId});
|
|
|
if(bool){
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","更新人员岗位同步到部门矩阵执行成功");
|
|
|
dataMapp.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}else{
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","更新人员岗位同步到部门矩阵执行错误");
|
|
|
dataMapp.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//当岗位为主岗位时才更新,1:主岗位
|
|
|
// if ("1".equals(defaultFlag)){
|
|
|
String updateUserJobSql = " update hrmresource set jobtitle=?,modified=?,modifier=? where id=? ";
|
|
|
bb.writeLog("updateUserJobSql:"+updateUserJobSql);
|
|
|
Object[] objects = new Object[]{jobtitlesId,currentDateTime,updateStaff,userId};
|
|
|
|
|
|
boolean flag = rs.executeUpdate(updateUserJobSql,objects);
|
|
|
bb.writeLog(" updateUserJobFlag: "+flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if(!flag){
|
|
|
dataMap.put("errmessage","更新人员岗位sql执行错误");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","更新人员岗位sql执行成功");
|
|
|
}
|
|
|
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
|
|
|
dataMap.put("zxyj",updateUserJobSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
// }
|
|
|
}else if("D".equals(actType)){
|
|
|
if(StringUtils.isNotEmpty(postName)) {
|
|
|
postName = postName.toLowerCase().replaceAll("\\s+", "");
|
|
|
if(stringSet.contains(postName)){
|
|
|
String sql = "update matrixtable_2 set "+postName+"=null where id=?";
|
|
|
boolean bool = rs.executeUpdate(sql,new Object[]{departmentId});
|
|
|
if(bool){
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","删除人员岗位同步到部门矩阵执行成功");
|
|
|
dataMapp.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}else{
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","删除人员岗位同步到部门矩阵执行错误");
|
|
|
dataMapp.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
jobtitlesId = null;
|
|
|
String updateUserJobSql = " update hrmresource set jobtitle=?,modified=?,modifier=? where id=? ";
|
|
|
bb.writeLog("updateUserJobSql:"+updateUserJobSql);
|
|
|
|
|
|
Object[] objects = new Object[]{jobtitlesId,currentDateTime,updateStaff,userId};
|
|
|
|
|
|
|
|
|
boolean flag = rs.executeUpdate(updateUserJobSql,objects);
|
|
|
bb.writeLog(" updateUserJobFlag: "+flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if(!flag){
|
|
|
dataMap.put("errmessage","删除人员岗位sql执行错误");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","删除人员岗位sql执行成功");
|
|
|
}
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
|
|
|
dataMap.put("zxyj",updateUserJobSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","人员岗位中岗位或者人员ID在系统中不存在");
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","人员岗位中岗位或者人员ID在系统中不存在同步到部门矩阵执行错误");
|
|
|
dataMapp.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","人员岗位异常:"+e.getMessage());
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",systemUserCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// {"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},"svcCode":"70300100030001",
|
|
|
// "requestObject":[{"content":[{"updateDate":"2022-08-09 10:24:01",
|
|
|
// "systemInfoCode":"TYMH","regionNbr":"TST_PR_CSS","sysRoleId":"17020",
|
|
|
// "sysRoleName":"weaver role","statusCd":"1000","systemInfoId":"727001","sysRoleCode":"weaver role",
|
|
|
// "createStaff":"1","regionId":"36","sysRoleType":"1000","actType":"A","createDate":"2022-08-09 10:24:01"}],
|
|
|
// "tableName":"system_roles","primaryKey":"sysRoleId"}],"key":"svcCont"}
|
|
|
|
|
|
|
|
|
// {"updateDate":"2022-08-09 10:24:01",
|
|
|
// "systemInfoCode":"TYMH","regionNbr":"TST_PR_CSS","sysRoleId":"17020",
|
|
|
// "sysRoleName":"weaver role","statusCd":"1000","systemInfoId":"727001","sysRoleCode":"weaver role",
|
|
|
// "createStaff":"1","regionId":"36","sysRoleType":"1000","actType":"A","createDate":"2022-08-09 10:24:01"}
|
|
|
|
|
|
// {"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},
|
|
|
// "svcCode":"70300100030001","requestObject":[{"content":[{"updateDate":"2022-07-27 11:04:19","systemInfoCode":
|
|
|
// "TYMH","regionNbr":"TST_PR_CSS","sysRoleId":"17016","sysRoleName":"role727",
|
|
|
// "statusCd":"1000","sysRoleDesc":"test727","systemInfoId":"727001","sysRoleCode":"role727",
|
|
|
// "createStaff":"1","regionId":"36","sysRoleType":"1000","actType":"A","createDate":"2022-07-27 11:04:19"}],
|
|
|
// "tableName":"system_roles","primaryKey":"sysRoleId"}],"key":"svcCont"}
|
|
|
|
|
|
/***
|
|
|
*
|
|
|
* @param jsonArray
|
|
|
*/
|
|
|
public void updasteSysRoleData(JSONArray jsonArray, String tableName) {
|
|
|
RecordSet rs = new RecordSet();
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
String nowDateTime = sdf.format(new Date());
|
|
|
|
|
|
String type = "0";
|
|
|
String subcompanyid = "0" ;
|
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++)
|
|
|
{
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
|
|
|
//角色标识
|
|
|
String sysRoleCode = Util.null2String(jsonObject.get("sysRoleCode")).replace(" ","");
|
|
|
//角色名称
|
|
|
String sysRoleName = Util.null2String(jsonObject.get("sysRoleName"));
|
|
|
//状态1000 有效,1100 无效
|
|
|
String statusCd = Util.null2String(jsonObject.get("statusCd"));
|
|
|
//角色描述
|
|
|
// String sysRoleDesc = Util.null2String(jsonObject.get("sysRoleDesc"));
|
|
|
//角色类型1100:管理角色,1000:普通角色
|
|
|
String sysRoleType = Util.null2String(jsonObject.get("sysRoleType"));
|
|
|
//A:新增,M:修改
|
|
|
String actType = Util.null2String(jsonObject.get("actType"));
|
|
|
|
|
|
|
|
|
bb.writeLog("sysRoleName:"+sysRoleName);
|
|
|
bb.writeLog("sysRoleCode:"+sysRoleCode);
|
|
|
|
|
|
// String rolesmark = "~`~`7 "+sysRoleName+"`~`8 "+sysRoleName+"`~`~" ;
|
|
|
// String rolesname = "~`~`7 "+sysRoleName+"`~`8 "+sysRoleName+"`~`~" ;
|
|
|
|
|
|
String rolesmark = sysRoleCode ;
|
|
|
String rolesname = sysRoleName ;
|
|
|
|
|
|
bb.writeLog("rolesmark:"+rolesmark);
|
|
|
bb.writeLog("rolesname:"+rolesname);
|
|
|
|
|
|
String systemInfoCode = Util.null2String(jsonObject.get("systemInfoCode"));
|
|
|
if("PC_OA".equalsIgnoreCase(systemInfoCode)){
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
String rolesid = "";
|
|
|
try{
|
|
|
if(StringUtils.isNotEmpty(sysRoleCode)){
|
|
|
String queryRoleSql = "select id from hrmroles where rolesmark=?";
|
|
|
rs.executeQuery(queryRoleSql,new Object[]{sysRoleCode});
|
|
|
bb.writeLog(queryRoleSql);
|
|
|
if (rs.next()){
|
|
|
rolesid = rs.getString("id");
|
|
|
}
|
|
|
}
|
|
|
bb.writeLog("rolesid:"+rolesid);
|
|
|
if (StringUtils.isNotEmpty(rolesid)){
|
|
|
if ("M".equals(actType)) { //修改
|
|
|
String updateHrmrolesSql = " update hrmroles set rolesmark=?,rolesname=? where id=?";
|
|
|
bb.writeLog("updateHrmrolesSql:"+updateHrmrolesSql);
|
|
|
|
|
|
Object[] objects = new Object[]{sysRoleCode, sysRoleName, rolesid} ;
|
|
|
|
|
|
boolean flag = rs.executeUpdate(updateHrmrolesSql, objects);
|
|
|
bb.writeLog("updateHrmroles : " + flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if (!flag) {
|
|
|
dataMap.put("errmessage","系统角色更新SQL执行错误");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","系统角色更新SQL执行成功");
|
|
|
}
|
|
|
|
|
|
dataMap.put("staffcode",sysRoleCode);
|
|
|
dataMap.put("zxyj",updateHrmrolesSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}else if("D".equals(actType)) {
|
|
|
int membercount = 0;
|
|
|
String queryHrmRolesSql = " select id from hrmrolemembers where roleid = ?";
|
|
|
rs.executeQuery(queryHrmRolesSql,new Object[]{rolesid});
|
|
|
while (rs.next()){
|
|
|
membercount++;
|
|
|
}
|
|
|
if(membercount == 0){
|
|
|
String deleteHrmRolesSql = " delete from hrmroles where id = ?";
|
|
|
|
|
|
Object[] objects = new Object[]{rolesid} ;
|
|
|
|
|
|
boolean flag = rs.executeUpdate(deleteHrmRolesSql,objects);
|
|
|
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if(!flag){
|
|
|
dataMap.put("errmessage","系统角色删除SQL执行错误");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","系统角色删除SQL执行成功");
|
|
|
}
|
|
|
|
|
|
dataMap.put("staffcode",sysRoleCode);
|
|
|
dataMap.put("zxyj",deleteHrmRolesSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","系统角色存在角色成员,无法删除系统角色");
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",sysRoleCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","角色成员系统已存在,操作类型为A");
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",sysRoleCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}else {
|
|
|
if ("A".equals(actType)){ //新增
|
|
|
String insertHrmrolesSql = " insert into hrmroles(rolesmark,rolesname,type,subcompanyid,ecology_pinyin_search,uuid) values(?,?,?,?,?,?)";
|
|
|
|
|
|
Object[] objects = new Object[]{rolesmark,rolesname,type,subcompanyid,sysRoleCode, uuid};
|
|
|
|
|
|
boolean flag = rs.executeUpdate(insertHrmrolesSql,objects);
|
|
|
bb.writeLog("insertHrmroles : "+flag);
|
|
|
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if(!flag){
|
|
|
dataMap.put("errmessage","新增系统角色SQL执行错误");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","新增系统角色SQL执行成功");
|
|
|
}
|
|
|
|
|
|
dataMap.put("zxyj",insertHrmrolesSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
dataMap.put("staffcode",sysRoleCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","系统角色系统不存在,操作类型为M或者D");
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",sysRoleCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
RolesComInfo RolesComInfo = new RolesComInfo();
|
|
|
RolesComInfo.removeRolesCache();
|
|
|
|
|
|
}catch (Exception e){
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","系统角色:"+e.getMessage());
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",sysRoleCode);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
//{"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},"svcCode":"70300100030001",
|
|
|
// "requestObject":[{"content":[{"updateDate":"2022-07-27 11:04:39","orgName":"Vivia","regionNbr":"TST_PR_CSS",
|
|
|
// "initFlag":"0","sysPostId":"18008","statusCd":"1000","systemInfoId":"727001",
|
|
|
// "sysPostType":"1000","orgId":"1","createStaff":"1","regionId":"36","orgCode":"LNP000001","sysPostCode":"position727",
|
|
|
// "actType":"A","sysPostDesc":"test727","sysPostName":"position727","createDate":"2022-07-27 11:04:39"}],
|
|
|
// "tableName":"system_post","primaryKey":"sysPostId"}],"key":"svcCont"}
|
|
|
|
|
|
// {"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},"svcCode":"70300100030001",
|
|
|
// "requestObject":[{"content":[{"updateDate":"2022-07-19 00:51:32",
|
|
|
// "orgName":"Default Company","regionNbr":"1","initFlag":"0",
|
|
|
// "sysPostId":"6006","statusCd":"1000","systemInfoId":"727001",
|
|
|
// "sysPostType":"1000","orgId":"1","createStaff":"1","regionId":"731","orgCode":"1",
|
|
|
// "sysPostCode":"CASH_ADMIN","actType":"M","sysPostDesc":"CASH_ADMIN","sysPostName":"CASH_ADMIN",
|
|
|
// "createDate":"2020-11-13 11:02:11","updateStaff":"1"}],"tableName":"system_post","primaryKey":"sysPostId"}],"key":"svcCont"}
|
|
|
|
|
|
|
|
|
/***
|
|
|
*
|
|
|
* @param jsonArray
|
|
|
*/
|
|
|
public void updasteSysPostData(JSONArray jsonArray, String tableName) {
|
|
|
RecordSet rs = new RecordSet();
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
String nowDateTime = sdf.format(new Date());
|
|
|
|
|
|
String creater ="1";
|
|
|
String modifier = "1" ;
|
|
|
String created = TimeUtil.getCurrentTimeString() ;
|
|
|
String modified = TimeUtil.getCurrentTimeString() ;
|
|
|
|
|
|
for (int i = 0; i < jsonArray.size(); i++)
|
|
|
{
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
//系统岗位编码
|
|
|
String sysPostType = Util.null2String(jsonObject.get("sysPostType"));
|
|
|
String sysPostCode = Util.null2String(jsonObject.get("sysPostCode"));
|
|
|
if("1300".equals(sysPostType) && sysPostCode.startsWith("MSS_CTO"))
|
|
|
{
|
|
|
//系统岗位名称
|
|
|
String sysPostName = Util.null2String(jsonObject.get("sysPostName"));
|
|
|
//部门编码
|
|
|
String orgCode = Util.null2String(jsonObject.get("orgCode"));
|
|
|
//系统岗位状态1000 有效 1100 无效
|
|
|
String statusCd = Util.null2String(jsonObject.get("statusCd"));
|
|
|
//修改时间
|
|
|
String updateDate = Util.null2String(jsonObject.get("updateDate"));
|
|
|
//修改人
|
|
|
String updateStaff = Util.null2String(jsonObject.get("updateStaff"));
|
|
|
//创建时间
|
|
|
String createDate = Util.null2String(jsonObject.get("createDate"));
|
|
|
//创建人
|
|
|
String createStaff = Util.null2String(jsonObject.get("createStaff"));
|
|
|
//A:新增,M:修改
|
|
|
String actType = Util.null2String(jsonObject.get("actType"));
|
|
|
|
|
|
//String allname = "~`~`7 " + sysPostName + "`~`8 " + sysPostName + "`~`~";
|
|
|
|
|
|
String jobtitlemark = sysPostName;
|
|
|
String jobtitlename = sysPostName;
|
|
|
|
|
|
try {
|
|
|
String departmentId = "-1";
|
|
|
if(StringUtils.isNotEmpty(orgCode)){
|
|
|
String querDepartmentIdSql = "select id from hrmdepartment where departmentcode=?";
|
|
|
rs.executeQuery(querDepartmentIdSql, new Object[]{orgCode});
|
|
|
if (rs.next()) {
|
|
|
departmentId = String.valueOf(Util.getIntValue(rs.getString("id"),-1));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String groupsid = "";
|
|
|
String jobgroupname = "DITO_MSS_LEADERSHIP";
|
|
|
String sql = " select * from hrmjobgroups where jobgroupname like '%"+jobgroupname+"%'";
|
|
|
rs.executeQuery(sql);
|
|
|
if (rs.next()) {
|
|
|
groupsid = Util.null2String(rs.getString("id"));
|
|
|
}
|
|
|
|
|
|
String jobactivitiesid = "";
|
|
|
String jobactivityname = "MSS_LEADERSHIP";
|
|
|
if (StringUtils.isNotEmpty(groupsid) && StringUtils.isNotEmpty(jobactivityname)) {
|
|
|
sql = " select id from hrmjobactivities where jobgroupid = ? and jobactivityname like '%" + jobactivityname + "%'";
|
|
|
rs.executeQuery(sql, new Object[]{groupsid});
|
|
|
if (rs.next()) {
|
|
|
jobactivitiesid = Util.null2String(rs.getString("id"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
String jobtitleid = "";
|
|
|
if (StringUtils.isNotEmpty(jobactivitiesid))
|
|
|
{
|
|
|
String queryRoleSql = " select id from hrmjobtitles where jobtitlecode =? and jobactivityid = ?";
|
|
|
rs.executeQuery(queryRoleSql, new Object[]{sysPostCode, jobactivitiesid});
|
|
|
if (rs.next()) {
|
|
|
jobtitleid = rs.getString("id");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if (StringUtils.isNotEmpty(jobtitleid))
|
|
|
{
|
|
|
if ("M".equals(actType)) { //修改
|
|
|
|
|
|
rs.executeQuery("select * from hrmjobtitles where id=?",jobtitleid);
|
|
|
rs.next();
|
|
|
String oldjobtitlename = Util.null2String(rs.getString("jobtitlename"));
|
|
|
|
|
|
String updateHrmjobactivitiesSql = "update hrmjobtitles set jobtitlemark=?,jobtitlename=?,modified=?,modifier=? where id=?";
|
|
|
|
|
|
Object[] objects = new Object[]{jobtitlemark, jobtitlename, modified, modifier, jobtitleid} ;
|
|
|
|
|
|
boolean flag = rs.executeUpdate(updateHrmjobactivitiesSql,objects);
|
|
|
bb.writeLog("insertHrmjobactivitiesSql flag:" + flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if (!flag) {
|
|
|
dataMap.put("errmessage","系统岗位更新SQL执行错误");
|
|
|
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","修改岗位同步到部门自定义字段以及部门矩阵执行错误");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}else {
|
|
|
dataMap.put("errmessage","系统岗位更新SQL执行成功");
|
|
|
|
|
|
//岗位修改同步到部门自定义字段以及部门矩阵
|
|
|
boolean bool = updateDeptMatrix(oldjobtitlename,jobtitlename);
|
|
|
if(bool){
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","修改岗位同步到部门自定义字段以及部门矩阵执行成功");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}else{
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","修改岗位同步到部门自定义字段以及部门矩阵执行错误");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dataMap.put("zxyj",updateHrmjobactivitiesSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
dataMap.put("staffcode",sysPostCode);
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
} else if ("D".equals(actType)) {
|
|
|
String canceled = "1";
|
|
|
String updateHrmjobactivitiesSql = "update hrmjobtitles set jobtitlemark=?,jobtitlename=?,modified=?,modifier=?,canceled = ? where id=?";
|
|
|
|
|
|
Object[] objects = new Object[]{jobtitlemark, jobtitlename, modified, modifier, canceled, jobtitleid} ;
|
|
|
|
|
|
boolean flag = rs.executeUpdate(updateHrmjobactivitiesSql,objects);
|
|
|
bb.writeLog("insertHrmjobactivitiesSql flag:" + flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if (!flag) {
|
|
|
dataMap.put("errmessage","系统岗位封存SQL执行错误");
|
|
|
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","删除岗位同步到部门自定义字段以及部门矩阵执行错误");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}else {
|
|
|
dataMap.put("errmessage","系统岗位封存SQL执行成功");
|
|
|
|
|
|
//岗位删除同步到部门自定义字段以及部门矩阵
|
|
|
boolean bool = deleteDeptMatrix(jobtitlename);
|
|
|
if(bool){
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","删除岗位同步到部门自定义字段以及部门矩阵执行成功");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}else{
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","删除岗位同步到部门自定义字段以及部门矩阵执行错误");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
dataMap.put("zxyj",updateHrmjobactivitiesSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
dataMap.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","系统岗位系统已存在,操作类型为A");
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","系统岗位不存在无法修改或者删除部门矩阵");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}
|
|
|
}else{
|
|
|
if ("A".equals(actType)) { //新增
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
String insertHrmjobactivitiesSql = " insert into hrmjobtitles(jobtitlemark,jobtitlename,jobactivityid,jobdepartmentid,jobtitlecode,created,creater,modified,modifier,uuid) values(?,?,?,?,?,?,?,?,?,?)";
|
|
|
|
|
|
Object[] objects = new Object[]{jobtitlemark, jobtitlename, jobactivitiesid, departmentId, sysPostCode, created, creater, modified, modifier, uuid} ;
|
|
|
|
|
|
boolean flag = rs.executeUpdate(insertHrmjobactivitiesSql,objects);
|
|
|
bb.writeLog("insertHrmjobactivitiesSql flag:" + flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
if (!flag) {
|
|
|
dataMap.put("errmessage","系统岗位新增SQL执行错误");
|
|
|
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","新增岗位同步到部门自定义字段以及部门矩阵执行错误");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}else {
|
|
|
dataMap.put("errmessage","系统岗位新增SQL执行成功");
|
|
|
JobTitlesComInfo jobTitlesComInfo = new JobTitlesComInfo();
|
|
|
jobTitlesComInfo.addCache(jobtitleid);
|
|
|
//岗位新增同步到部门自定义字段以及部门矩阵
|
|
|
boolean bool = insertDeptMatrix(jobtitlename);
|
|
|
if(bool){
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","新增岗位同步到部门自定义字段以及部门矩阵执行成功");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}else{
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","新增岗位同步到部门自定义字段以及部门矩阵执行错误");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}
|
|
|
}
|
|
|
dataMap.put("staffcode",sysPostCode);
|
|
|
|
|
|
dataMap.put("zxyj",insertHrmjobactivitiesSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","系统岗位系统不存在,操作类型为D或者M");
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
Map<String,String> dataMapp = new HashMap<String,String>();
|
|
|
dataMapp.put("syndate",nowDateTime);
|
|
|
dataMapp.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMapp.put("systable",tableName);
|
|
|
dataMapp.put("errmessage","系统岗位不存在无法修改或者删除部门矩阵");
|
|
|
dataMapp.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMapp);
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e) {
|
|
|
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","系统角色:"+e.getMessage());
|
|
|
dataMap.put("systable",tableName);
|
|
|
dataMap.put("staffcode",sysPostCode);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
// {"authenticationInfo":{"sysUserPostId":"37484","sysUserId":"1","key":"authenticationInfo"},"svcCode":"70300100030001",
|
|
|
// "requestObject":[{"content":[{"statusDate":"2022-08-09 09:47:54","updateDate":"2022-08-09 09:47:54",
|
|
|
// "staffCode":"fanweiceshi12","orgName":"yhwgfz","regionNbr":"TST_PR_CSS",
|
|
|
// "staffAccount":"fanweiceshi12","statusCd":"1000","staffType":"1000","orgId":"11205","createStaff":"1",
|
|
|
// "eMail":"123453243132312","mobilePhone":"44553321","commonRegionId":"36","orgCode":"GTR000593",
|
|
|
// "staffName":"fanweiceshi12","actType":"A","sysUserId":20102,"partyId":"-1","staffId":"22061",
|
|
|
// "createDate":"2022-08-09 09:47:54","updateStaff":"1"}],"tableName":"staff","primaryKey":"staffId"}],"key":"svcCont"}
|
|
|
|
|
|
public void updateStaffData(JSONArray jsonArray, String tableName){
|
|
|
RecordSet rs = new RecordSet();
|
|
|
BaseBean bb = new BaseBean();
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
String nowDateTime = sdf.format(new Date());
|
|
|
|
|
|
String locationid = "2" ;
|
|
|
String seclevel = "20" ;
|
|
|
String createrid = "1" ;
|
|
|
String lastmodid = "1" ;
|
|
|
String creator = "1";
|
|
|
String systemlanguage = "8" ;
|
|
|
|
|
|
String pwd = PropBean.getUfPropValue("user_pwd") ;
|
|
|
String password = DigestUtils.md5Hex(pwd).toUpperCase(); //MD5加密
|
|
|
|
|
|
bb.writeLog("password:"+password);
|
|
|
String scopeid = "-1";
|
|
|
String scope = "HrmCustomFieldByInfoType" ;
|
|
|
|
|
|
String cus_staff = PropBean.getUfPropValue("cus_staff") ;
|
|
|
String cus_eid = PropBean.getUfPropValue("cus_eid") ;
|
|
|
String cus_sysuserid = PropBean.getUfPropValue("cus_sysuserid") ;
|
|
|
|
|
|
String currentDate = TimeUtil.getCurrentDateString();//当前日期
|
|
|
String currentDateTime = TimeUtil.getCurrentTimeString(); //当前时间
|
|
|
bb.writeLog("currentDate:"+currentDate);
|
|
|
|
|
|
String jobTitleId = "" ;
|
|
|
String defaultJobCode = PropBean.getUfPropValue("defaultJobCode");
|
|
|
if(StringUtils.isNotEmpty(defaultJobCode)){
|
|
|
String sql = " select id from hrmjobtitles where jobtitlecode = ?" ;
|
|
|
rs.executeQuery(sql,new Object[]{defaultJobCode});
|
|
|
if(rs.next()){
|
|
|
jobTitleId = Util.null2String(rs.getString("id"));
|
|
|
}
|
|
|
}
|
|
|
|
|
|
for(int i=0;i<jsonArray.size();i++)
|
|
|
{
|
|
|
JSONObject jsonObject = jsonArray.getJSONObject(i);
|
|
|
String orgCode = Util.null2String(jsonObject.get("orgCode"));
|
|
|
|
|
|
String staffName = Util.null2String(jsonObject.get("staffName"));
|
|
|
String staffCode = Util.null2String(jsonObject.get("staffCode"));
|
|
|
bb.writeLog("staffCode:"+staffCode);
|
|
|
String actType = Util.null2String(jsonObject.get("actType"));
|
|
|
String email = "" ;
|
|
|
if(jsonObject.containsKey("eMail")){
|
|
|
email = Util.null2String(jsonObject.getString("eMail"),"null");
|
|
|
}else if(jsonObject.containsKey("email")){
|
|
|
email = Util.null2String(jsonObject.getString("email"),"null");
|
|
|
}
|
|
|
bb.writeLog("email:"+email);
|
|
|
|
|
|
String pwdSmsTel = Util.null2String(jsonObject.getString("mobilePhone"),"null");
|
|
|
bb.writeLog("pwdSmsTel:"+pwdSmsTel);
|
|
|
String loginedNum = Util.null2String(jsonObject.getString("sysUserId"),"null");
|
|
|
bb.writeLog("loginedNum:"+loginedNum);
|
|
|
|
|
|
String statusCd = Util.null2String(jsonObject.get("statusCd"));
|
|
|
bb.writeLog("statusCd:"+statusCd);
|
|
|
String staffType = Util.null2String(jsonObject.get("staffType"));
|
|
|
String status = "1";
|
|
|
// String lastname = " ~`~`7 "+staffName+"`~`8 "+staffName+"`~`~";
|
|
|
String lastname = staffName;
|
|
|
|
|
|
String staffId = Util.null2String(jsonObject.get("staffId"));
|
|
|
String eId = "" ;
|
|
|
if(jsonObject.containsKey("eid")){
|
|
|
eId = Util.null2String(jsonObject.get("eid"));
|
|
|
}else if(jsonObject.containsKey("eId")){
|
|
|
eId = Util.null2String(jsonObject.get("eId"));
|
|
|
}
|
|
|
String sysUserId = Util.null2String(jsonObject.get("sysUserId"));
|
|
|
bb.writeLog("eId:"+eId);
|
|
|
bb.writeLog("staffId:"+staffId);
|
|
|
bb.writeLog("sysUserId:"+sysUserId);
|
|
|
try {
|
|
|
String subcompanyid1 = "" ;
|
|
|
String deptId = "";
|
|
|
if(StringUtils.isNotEmpty(orgCode)){
|
|
|
String sql = " select id,subcompanyid1 from hrmdepartment where departmentcode = ?" ;
|
|
|
rs.executeQuery(sql,new Object[]{orgCode});
|
|
|
if(rs.next()){
|
|
|
deptId = Util.null2String(rs.getString("id"));
|
|
|
subcompanyid1 = Util.null2String(rs.getString("subcompanyid1"));
|
|
|
}
|
|
|
}
|
|
|
bb.writeLog("deptId:"+deptId);
|
|
|
bb.writeLog("subcompanyid1:"+subcompanyid1);
|
|
|
|
|
|
int datacount = 0;
|
|
|
String sql = " select id from hrmresource where workcode=?" ;
|
|
|
bb.writeLog("sql:"+sql);
|
|
|
rs.executeQuery(sql,new Object[]{staffCode});
|
|
|
while (rs.next()){
|
|
|
datacount++;
|
|
|
}
|
|
|
bb.writeLog("datacount:"+datacount);
|
|
|
if(datacount <=1)
|
|
|
{
|
|
|
String userid = "" ;
|
|
|
String loginid = "";
|
|
|
String user_status = "";
|
|
|
if(StringUtils.isNotEmpty(staffCode))
|
|
|
{
|
|
|
sql = " select loginid,id,status from hrmresource where workcode='"+staffCode+"'" ;
|
|
|
bb.writeLog("sql:"+sql);
|
|
|
rs.executeQuery(sql);
|
|
|
if(rs.next()){
|
|
|
loginid = Util.null2String(rs.getString("loginid"));
|
|
|
userid = Util.null2String(rs.getString("id"));
|
|
|
user_status = Util.null2String(rs.getString("status"));
|
|
|
|
|
|
bb.writeLog("loginid:"+loginid);
|
|
|
bb.writeLog("user_status:"+user_status);
|
|
|
|
|
|
if(StringUtils.isBlank(loginid)){
|
|
|
if("5".equals(user_status)){
|
|
|
loginid = staffCode;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
bb.writeLog("user_status:"+user_status);
|
|
|
bb.writeLog("loginid:"+loginid);
|
|
|
if(StringUtils.isNotEmpty(deptId))
|
|
|
{
|
|
|
if(StringUtils.isNotEmpty(loginid))
|
|
|
{
|
|
|
if("M".equalsIgnoreCase(actType))
|
|
|
{
|
|
|
if("1000".equals(statusCd)){
|
|
|
status = "1";
|
|
|
}else if("1100".equals(statusCd) || "1240".equals(statusCd)){
|
|
|
status = "5";
|
|
|
}
|
|
|
bb.writeLog("status:"+status);
|
|
|
|
|
|
String userUpdateSql = " update hrmresource set loginid=?,lastname=?,departmentid=?,subcompanyid1=?," +
|
|
|
" creater=?,email=?,mobile=?,status=?,dsporder=?,lastmoddate=?,modified=? where workcode=? ";
|
|
|
|
|
|
Object[] objects = new Object[]{loginid,lastname,deptId,subcompanyid1,creator,email,pwdSmsTel,status,loginedNum,currentDate,currentDateTime,staffCode};
|
|
|
|
|
|
bb.writeLog("updateSysUserData-userUpdateSql:"+userUpdateSql);
|
|
|
boolean flag = rs.executeUpdate(userUpdateSql,objects);
|
|
|
bb.writeLog("flag:"+flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
dataMap.put("zxyj",userUpdateSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
|
|
|
if(!flag){
|
|
|
dataMap.put("errmessage","人员更新SQL执行错误");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","人员更新SQL执行成功");
|
|
|
}
|
|
|
recordErrorData(dataMap);
|
|
|
}else if("D".equals(actType)){
|
|
|
status = "5";
|
|
|
String staffCodenew = loginid+"_cf_0";
|
|
|
String userUpdateSql = " update hrmresource set status=?,loginid=?,workcode=? where id=? ";
|
|
|
|
|
|
Object[] objects = new Object[]{status,staffCodenew,staffCodenew,userid};
|
|
|
bb.writeLog("userUpdateSql:"+userUpdateSql);
|
|
|
|
|
|
boolean flag = rs.executeUpdate(userUpdateSql,objects);
|
|
|
bb.writeLog("flag:"+flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
dataMap.put("zxyj",userUpdateSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
if(!flag){
|
|
|
dataMap.put("errmessage","人员离职SQL执行错误");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","人员离职SQL执行成功");
|
|
|
}
|
|
|
recordErrorData(dataMap);
|
|
|
}else{
|
|
|
|
|
|
int status1count = 0;
|
|
|
sql = " select id from hrmresource where loginid = '"+staffCode+"' and status in(0,1,2,3) " ;
|
|
|
bb.writeLog("loginidisnotnull-sql:"+sql);
|
|
|
rs.executeQuery(sql);
|
|
|
if(rs.next()){
|
|
|
status1count++;
|
|
|
}
|
|
|
bb.writeLog("loginidisnotnull-status1count:"+status1count);
|
|
|
if(status1count == 0) {
|
|
|
int status5count = 0;
|
|
|
List<String> loginList = new ArrayList<String>();
|
|
|
sql = " select id from hrmresource where loginid like '"+staffCode+"%' and status = 5" ;
|
|
|
// sql = " select id,status from hrmresource where (loginid = '"+staffCode+"' or loginid like '"+staffCode+"_cf%') and status = 5";
|
|
|
bb.writeLog("loginidisnotnull-sql:" + sql);
|
|
|
rs.executeQuery(sql);
|
|
|
while (rs.next()) {
|
|
|
String user_id = Util.null2String(rs.getString("id"));
|
|
|
String upsql = " update hrmresource set loginid='" + staffCode + "_cf_" + status5count + "',workcode='"+staffCode+"_cf_"+status5count+"' where id = " + user_id +" and status = 5 ";
|
|
|
bb.writeLog("loginidisnotnull-upsql:" + upsql);
|
|
|
loginList.add(upsql);
|
|
|
status5count++;
|
|
|
}
|
|
|
bb.writeLog("loginidisnotnull-status5count:" + status5count);
|
|
|
|
|
|
if (status5count > 0) {
|
|
|
for (String upsql : loginList) {
|
|
|
boolean isTrue = rs.executeUpdate(upsql);
|
|
|
bb.writeLog("loginidisnotnull-isTrue:" + isTrue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
rs.executeProc("HrmResourceMaxId_Get", "");
|
|
|
rs.next();
|
|
|
String id = "" + rs.getInt(1);
|
|
|
bb.writeLog("loginidisnotnull-id:"+id);
|
|
|
|
|
|
if(StringUtils.isNotEmpty(id))
|
|
|
{
|
|
|
String userInsertSql = " insert into hrmresource(id,loginid,password,workcode,lastname,departmentid,subcompanyid1," +
|
|
|
" creater,email,mobile,jobtitle,status,dsporder,systemlanguage,createdate,lastmoddate,created,modified," +
|
|
|
" locationid,seclevel,createrid,lastmodid,outkey) " +
|
|
|
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
|
|
|
Object[] objects = new Object[]{id,staffCode,password,staffCode,lastname,deptId,subcompanyid1,
|
|
|
creator,email,pwdSmsTel,jobTitleId,status,loginedNum,systemlanguage,currentDate,currentDate,currentDateTime,currentDateTime,
|
|
|
locationid,seclevel,createrid,lastmodid,staffId} ;
|
|
|
bb.writeLog("userInsertSql:"+userInsertSql);
|
|
|
|
|
|
|
|
|
boolean flag = rs.executeUpdate(userInsertSql,objects);
|
|
|
bb.writeLog("flag:"+flag);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
dataMap.put("zxyj",userInsertSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
if(flag){
|
|
|
userid = id+"";
|
|
|
dataMap.put("errmessage","人员新增SQL执行成功");
|
|
|
}else{
|
|
|
dataMap.put("errmessage","人员新增SQL执行错误");
|
|
|
}
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","人员在系统中已存在,操作类型为A");
|
|
|
dataMap.put("systable",tableName);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工在系统中已存在,操作类型为A,请检查数据" ;
|
|
|
recordErrorMessage(staffCode,context);
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
if("A".equalsIgnoreCase(actType))
|
|
|
{
|
|
|
int status1count = 0;
|
|
|
sql = " select id from hrmresource where loginid = '"+staffCode+"' and status in(0,1,2,3) " ;
|
|
|
bb.writeLog("staff-sql:"+sql);
|
|
|
rs.executeQuery(sql);
|
|
|
if(rs.next()){
|
|
|
status1count++;
|
|
|
}
|
|
|
bb.writeLog("staff-status1count:"+status1count);
|
|
|
if(status1count == 0)
|
|
|
{
|
|
|
int status5count = 0;
|
|
|
List<String> loginList = new ArrayList<String>();
|
|
|
sql = " select id from hrmresource where loginid like '"+staffCode+"%' and status = 5" ;
|
|
|
bb.writeLog("staff-sql:"+sql);
|
|
|
rs.executeQuery(sql);
|
|
|
while (rs.next()){
|
|
|
String user_id = Util.null2String(rs.getString("id")) ;
|
|
|
String upsql = " update hrmresource set loginid='" + staffCode + "_cf_" + status5count + "',workcode='"+staffCode+"_cf_"+status5count+"' where id = " + user_id +" and status = 5";
|
|
|
bb.writeLog("upsql:"+upsql);
|
|
|
loginList.add(upsql);
|
|
|
status5count ++ ;
|
|
|
}
|
|
|
bb.writeLog("staff-status5count:"+status5count);
|
|
|
|
|
|
if(status5count > 0){
|
|
|
for(String upsql : loginList){
|
|
|
boolean isTrue = rs.executeUpdate(upsql);
|
|
|
bb.writeLog("isTrue:"+isTrue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
rs.executeProc("HrmResourceMaxId_Get", "");
|
|
|
rs.next();
|
|
|
String id = "" + rs.getInt(1);
|
|
|
bb.writeLog("id:"+id);
|
|
|
|
|
|
if(StringUtils.isNotEmpty(id))
|
|
|
{
|
|
|
String userInsertSql = " insert into hrmresource(id,loginid,password,workcode,lastname,departmentid,subcompanyid1," +
|
|
|
" creater,email,mobile,jobtitle,status,dsporder,systemlanguage,createdate,lastmoddate,created,modified," +
|
|
|
" locationid,seclevel,createrid,lastmodid,outkey) " +
|
|
|
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
|
|
|
Object[] objects = new Object[]{id,staffCode,password,staffCode,lastname,deptId,subcompanyid1,
|
|
|
creator,email,pwdSmsTel,jobTitleId,status,loginedNum,systemlanguage,currentDate,currentDate,currentDateTime,currentDateTime,
|
|
|
locationid,seclevel,createrid,lastmodid,staffId} ;
|
|
|
bb.writeLog("userInsertSql:"+userInsertSql);
|
|
|
|
|
|
|
|
|
|
|
|
boolean flag = rs.executeUpdate(userInsertSql,objects);
|
|
|
bb.writeLog("flag:"+flag);
|
|
|
|
|
|
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
dataMap.put("zxyj",userInsertSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
if(flag){
|
|
|
userid = id+"";
|
|
|
dataMap.put("errmessage","人员新增SQL执行成功");
|
|
|
}else{
|
|
|
dataMap.put("errmessage","人员新增SQL执行错误");
|
|
|
}
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
bb.writeLog("staff-status1count22:"+status1count);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","工号:"+staffCode+"的员工现为在职,无法进行新增,操作类型为A");
|
|
|
dataMap.put("systable",tableName);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工在系统中已存在,操作类型为A,请检查数据" ;
|
|
|
recordErrorMessage(staffCode,context);
|
|
|
}
|
|
|
}else if("M".equalsIgnoreCase(actType)){
|
|
|
|
|
|
int status1count = 0;
|
|
|
sql = " select id from hrmresource where loginid = '"+staffCode+"' and status in(0,1,2,3) " ;
|
|
|
bb.writeLog("staff-M-sql:"+sql);
|
|
|
rs.executeQuery(sql);
|
|
|
if(rs.next()){
|
|
|
status1count++;
|
|
|
}
|
|
|
bb.writeLog("staff-M-status1count:"+status1count);
|
|
|
if(status1count == 0)
|
|
|
{
|
|
|
int status5count = 0;
|
|
|
List<String> loginList = new ArrayList<String>();
|
|
|
sql = " select id from hrmresource where loginid like '"+staffCode+"%' and status = 5" ;
|
|
|
bb.writeLog("staff-M-sql:"+sql);
|
|
|
rs.executeQuery(sql);
|
|
|
while (rs.next()){
|
|
|
String user_id = Util.null2String(rs.getString("id")) ;
|
|
|
String upsql = " update hrmresource set loginid='" + staffCode + "_cf_" + status5count + "',workcode='"+staffCode+"_cf_"+status5count+"' where id = " + user_id +" and status = 5 " ;
|
|
|
bb.writeLog("upsql-M:"+upsql);
|
|
|
loginList.add(upsql);
|
|
|
status5count ++ ;
|
|
|
}
|
|
|
bb.writeLog("staff-M-status5count:"+status5count);
|
|
|
|
|
|
if(status5count > 0){
|
|
|
for(String upsql : loginList){
|
|
|
boolean isTrue = rs.executeUpdate(upsql);
|
|
|
bb.writeLog("isTrue-M:"+isTrue);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
rs.executeProc("HrmResourceMaxId_Get", "");
|
|
|
rs.next();
|
|
|
String id = "" + rs.getInt(1);
|
|
|
bb.writeLog("id-M:"+id);
|
|
|
|
|
|
if(StringUtils.isNotEmpty(id))
|
|
|
{
|
|
|
String userInsertSql = " insert into hrmresource(id,loginid,password,workcode,lastname,departmentid,subcompanyid1," +
|
|
|
" creater,email,mobile,jobtitle,status,dsporder,systemlanguage,createdate,lastmoddate,created,modified," +
|
|
|
" locationid,seclevel,createrid,lastmodid,outkey) " +
|
|
|
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
|
|
|
Object[] objects = new Object[]{id,staffCode,password,staffCode,lastname,deptId,subcompanyid1,
|
|
|
creator,email,pwdSmsTel,jobTitleId,status,loginedNum,systemlanguage,currentDate,currentDate,currentDateTime,currentDateTime,
|
|
|
locationid,seclevel,createrid,lastmodid,staffId} ;
|
|
|
bb.writeLog("userInsertSql-M:"+userInsertSql);
|
|
|
|
|
|
|
|
|
|
|
|
boolean flag = rs.executeUpdate(userInsertSql,objects);
|
|
|
bb.writeLog("flag-M:"+flag);
|
|
|
|
|
|
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
dataMap.put("zxyj",userInsertSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
if(flag){
|
|
|
userid = id+"";
|
|
|
dataMap.put("errmessage","人员M新增SQL执行成功");
|
|
|
}else{
|
|
|
dataMap.put("errmessage","人员M新增SQL执行错误");
|
|
|
}
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}else{
|
|
|
bb.writeLog("staff-M-status1count:"+status1count);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","工号:"+staffCode+"的员工现为在职,无法进行M新增,操作类型为M");
|
|
|
dataMap.put("systable",tableName);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工在系统中已存在,操作类型为M新增,请检查数据" ;
|
|
|
recordErrorMessage(staffCode,context);
|
|
|
}
|
|
|
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","人员在系统中不存在,操作类型为D");
|
|
|
dataMap.put("systable",tableName);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工在系统中不存在,操作类型为M或者D,请检查数据" ;
|
|
|
recordErrorMessage(staffCode,context);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(StringUtils.isNotEmpty(userid))
|
|
|
{
|
|
|
String seqorder = "" ;
|
|
|
rs.executeQuery(" select seqorder from cus_fielddata where scopeid=? and scope = ? and id=? ",new Object[]{scopeid,scope,userid} );
|
|
|
if(rs.next()){
|
|
|
seqorder = Util.null2String(rs.getString("seqorder"));
|
|
|
}
|
|
|
if (StringUtils.isNotEmpty(seqorder)) {
|
|
|
String cusUpdateSql = " update cus_fielddata set "+cus_staff+"=?,"+cus_eid+"=? where scope=? and scopeid=? and id=?";
|
|
|
bb.writeLog(cusUpdateSql);
|
|
|
|
|
|
Object[] objects = new Object[]{staffId, eId, scope,scopeid,userid} ;
|
|
|
|
|
|
boolean deflag = rs.executeUpdate(cusUpdateSql, objects);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
dataMap.put("zxyj",cusUpdateSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
if(!deflag){
|
|
|
dataMap.put("errmessage","更新人员自定义信息失败");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","更新人员自定义信息成功");
|
|
|
}
|
|
|
recordErrorData(dataMap);
|
|
|
} else {
|
|
|
String cusInsertSql = " insert into cus_fielddata(scope,scopeid,id,"+cus_staff+","+cus_eid+","+cus_sysuserid+") values(?,?,?,?,?,?)";
|
|
|
bb.writeLog(cusInsertSql);
|
|
|
Object[] objects = new Object[]{scope, scopeid, userid, staffId, eId, sysUserId} ;
|
|
|
|
|
|
boolean deflag = rs.executeUpdate(cusInsertSql, objects);
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("systable",tableName);
|
|
|
|
|
|
dataMap.put("zxyj",cusInsertSql);
|
|
|
dataMap.put("zxcs",convertObject2String(objects));
|
|
|
|
|
|
if(!deflag){
|
|
|
dataMap.put("errmessage","新增人员自定义信息失败");
|
|
|
}else {
|
|
|
dataMap.put("errmessage","新增人员自定义信息成功");
|
|
|
}
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","人员所属部门为空");
|
|
|
dataMap.put("systable",tableName);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工所属部门为空,请检查数据" ;
|
|
|
recordErrorMessage(staffCode,context);
|
|
|
|
|
|
}
|
|
|
}else{
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcodecount",datacount+"");
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","工号:"+staffCode+"的员工现为在职"+datacount+"组数据,无法进行处理");
|
|
|
dataMap.put("systable",tableName);
|
|
|
recordErrorData(dataMap);
|
|
|
|
|
|
String context = "人员staffname:"+staffName+",staffcode:"+staffCode+"的员工现为在职"+datacount+"组数据,请检查数据" ;
|
|
|
recordErrorMessage(staffCode,context);
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
Map<String,String> dataMap = new HashMap<String,String>();
|
|
|
dataMap.put("staffcode",staffCode);
|
|
|
dataMap.put("staffcodecount","");
|
|
|
dataMap.put("syndate",nowDateTime);
|
|
|
dataMap.put("reqmessage",jsonObject.toJSONString());
|
|
|
dataMap.put("errmessage","人力资源异常:"+e.getMessage());
|
|
|
dataMap.put("systable",tableName);
|
|
|
recordErrorData(dataMap);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/***
|
|
|
*
|
|
|
*/
|
|
|
public void recordErrorData(Map<String,String> dataMap){
|
|
|
|
|
|
String uftable = "uf_orgmq" ;
|
|
|
RecordSet rs = new RecordSet();
|
|
|
BaseBean bb = new BaseBean();
|
|
|
ModeRightInfo mode=new ModeRightInfo();
|
|
|
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");//当前时间日期
|
|
|
SimpleDateFormat sdf2 = new SimpleDateFormat("HH:mm:ss");
|
|
|
|
|
|
int formmodeid = 0 ;
|
|
|
String modedatacreater = "1" ;
|
|
|
String modedatacreatertype = "0" ;
|
|
|
String modedatacreatedate = sdf1.format(new Date());
|
|
|
String modedatacreatetime = sdf2.format(new Date());
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
|
|
|
try {
|
|
|
|
|
|
String sql =" select k.id from modeinfo k \n" +
|
|
|
" inner join workflow_bill l on formid = l.id\n" +
|
|
|
" where l.tablename = ? " ;
|
|
|
rs.executeQuery(sql,new Object[]{uftable});
|
|
|
if(rs.next()){
|
|
|
formmodeid = Util.getIntValue(Util.null2String(rs.getString("id")));
|
|
|
}
|
|
|
|
|
|
String syndate = Util.null2String(dataMap.get("syndate"));
|
|
|
String reqmessage = Util.null2String(dataMap.get("reqmessage"));
|
|
|
String errmessage = Util.null2String(dataMap.get("errmessage"));
|
|
|
String systable = Util.null2String(dataMap.get("systable"));
|
|
|
String staffcodecount = Util.null2String(dataMap.get("staffcodecount"));
|
|
|
String staffcode = Util.null2String(dataMap.get("staffcode"));
|
|
|
|
|
|
String zxyj = Util.null2String(dataMap.get("zxyj"));
|
|
|
String zxcs = Util.null2String(dataMap.get("zxcs"));
|
|
|
|
|
|
int bool = 0;
|
|
|
sql =" insert into "+uftable+"(uuid,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime,syndate,reqmessage,errmessage,systable,staffcodecount,staffcode,zxyj,zxcs)" +
|
|
|
" values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)" ;
|
|
|
boolean flag = rs.executeUpdate(sql,new Object[]{uuid,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime,syndate,reqmessage,errmessage,systable,staffcodecount,staffcode,zxyj,zxcs});
|
|
|
bb.writeLog("sql;"+sql);
|
|
|
if(flag){
|
|
|
bool++;
|
|
|
}
|
|
|
bb.writeLog("bool;"+bool);
|
|
|
if(bool>0)
|
|
|
{
|
|
|
String dataid = "";
|
|
|
sql = " select * from "+uftable+" where uuid=? ";
|
|
|
bb.writeLog("sql:" + sql);
|
|
|
rs.executeQuery(sql,new Object[]{uuid});
|
|
|
if (rs.next()) {
|
|
|
dataid = Util.null2String(rs.getString("id"));
|
|
|
}
|
|
|
bb.writeLog("sql:" + sql);
|
|
|
bb.writeLog("dataid:" + dataid);
|
|
|
bb.writeLog("modeid:" + formmodeid);
|
|
|
if (StringUtils.isNotEmpty(dataid))
|
|
|
{
|
|
|
mode.setNewRight(true);
|
|
|
mode.editModeDataShare(Integer.valueOf(modedatacreater), formmodeid, Integer.parseInt(dataid));
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
bb.writeLog("e:"+e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/***
|
|
|
* 更新系统组织换成
|
|
|
*/
|
|
|
public void removeCache(){
|
|
|
ResourceComInfo resComInfo;
|
|
|
DepartmentComInfo deptComInfo;
|
|
|
try {
|
|
|
resComInfo = new ResourceComInfo();
|
|
|
resComInfo.removeResourceCache();
|
|
|
deptComInfo = new DepartmentComInfo();
|
|
|
deptComInfo.removeCompanyCache();
|
|
|
} catch (Exception e) {
|
|
|
new BaseBean().writeLog(e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
/***
|
|
|
*
|
|
|
* @param staffCode
|
|
|
* @param context
|
|
|
*/
|
|
|
public void recordErrorMessage(String staffCode,String context){
|
|
|
BaseBean bb = new BaseBean();
|
|
|
bb.writeLog("recordErrorMessage");
|
|
|
try{
|
|
|
int code = Util.getIntValue(PropBean.getUfPropValue("MQMessageType"),0);
|
|
|
if(code>0){
|
|
|
MessageType messageType = MessageType.newInstance(code); // 消息来源(见文档第四点补充 必填)
|
|
|
Set<String> userIdList = new HashSet<String>(); // 接收人id 必填
|
|
|
userIdList.add("1");
|
|
|
String title = "人员MQ消息同步"; // 标题
|
|
|
String detailtitle = "人员MQ消息同步数据异常"; // 标题
|
|
|
String linkUrl = "/bpm/spa/cube/index.html#/main/cube/search?customid=131&staffcode="+staffCode; // PC端链接
|
|
|
String linkMobileUrl = "/bpm/spa/cube/index.html#/main/cube/search?customid=131&staffcode="+staffCode; // 移动端链接
|
|
|
try {
|
|
|
MessageBean messageBean = Util_Message.createMessage(messageType, userIdList, title, context, linkUrl, linkMobileUrl);
|
|
|
messageBean.setCreater(1);// 创建人id
|
|
|
messageBean.setDetailTitle(detailtitle);
|
|
|
Util_Message.store(messageBean);
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
bb.writeLog("e"+e);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public static Set<String> getSysRoles(String sysUserId){
|
|
|
Set<String> set = new HashSet<>();
|
|
|
BaseBean bb = new BaseBean();
|
|
|
|
|
|
String dataJson = "{\"sysUserId\": "+ sysUserId +",\"pageNum\": 1,\"pageSize\": 5555}";
|
|
|
|
|
|
String getAllSysUserRolesUrl = PropBean.getUfPropValue("getAllSysUserRolesUrl");
|
|
|
String Authorization = PropBean.getUfPropValue("Authorization");
|
|
|
try {
|
|
|
OkHttpClient client = new OkHttpClient().newBuilder().build();
|
|
|
MediaType mediaType = MediaType.parse("application/json");
|
|
|
RequestBody body = RequestBody.create(mediaType, dataJson);
|
|
|
Request request = new Request.Builder()
|
|
|
.url(getAllSysUserRolesUrl)
|
|
|
.method("POST", body)
|
|
|
.addHeader("Authorization", Authorization)
|
|
|
.addHeader("Content-Type", "application/json")
|
|
|
.build();
|
|
|
|
|
|
Response response = client.newCall(request).execute();
|
|
|
int code = response.code();
|
|
|
String bodyMsg = response.body().string();
|
|
|
bb.writeLog("response.code():"+code);
|
|
|
bb.writeLog("response.body():"+bodyMsg);
|
|
|
if(code == 200){
|
|
|
JSONObject msgObject = JSONObject.parseObject(bodyMsg);
|
|
|
if(msgObject.containsKey("list")){
|
|
|
String roleList = msgObject.getString("list");
|
|
|
JSONArray roleArray = JSONArray.parseArray(roleList);
|
|
|
for(int i=0;i<roleArray.size();i++){
|
|
|
JSONObject roleObject = (JSONObject) roleArray.get(i);
|
|
|
String systemRoles = roleObject.getString("systemRoles");
|
|
|
JSONObject rolesObject = JSONObject.parseObject(systemRoles);
|
|
|
String sysRoleCode = rolesObject.getString("sysRoleCode");
|
|
|
set.add(sysRoleCode);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
} catch (IOException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
return set;
|
|
|
}
|
|
|
|
|
|
public static String convertObject2String(Object[] obj) {
|
|
|
String datas = "";
|
|
|
if (null != obj) {
|
|
|
for (int i = 0; i < obj.length; i++) {
|
|
|
String data = obj[i].toString();
|
|
|
System.out.println(data);
|
|
|
datas += StringUtils.isBlank(datas) ? data : "," + data;
|
|
|
}
|
|
|
}
|
|
|
return datas;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取 部门矩阵表列
|
|
|
* @return
|
|
|
* String DBName = PropBean.getUfPropValue("DBName");
|
|
|
*/
|
|
|
public static Set<String> getDeptMatrixColumns( String DBName){
|
|
|
Set<String> set = new HashSet<>();
|
|
|
RecordSet rs = new RecordSet();
|
|
|
rs.executeQuery("SELECT COLUMN_NAME FROM information_schema.COLUMNS " +
|
|
|
" WHERE TABLE_SCHEMA = '"+ DBName +"' " +
|
|
|
" AND TABLE_NAME = 'matrixtable_2'");
|
|
|
while(rs.next()){
|
|
|
String columnName = Util.null2String(rs.getString("COLUMN_NAME"));
|
|
|
// 全部转化为 小写存储
|
|
|
columnName = columnName.toLowerCase().replaceAll("\\s+", "");
|
|
|
set.add(columnName);
|
|
|
}
|
|
|
return set;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改岗位同步到部门自定义字段以及部门矩阵
|
|
|
* @param oldjobtitlename
|
|
|
* @param newjobtitlename
|
|
|
* @return
|
|
|
*/
|
|
|
public static boolean updateDeptMatrix(String oldjobtitlename,String newjobtitlename){
|
|
|
boolean bool = false;
|
|
|
RecordSet rs = new RecordSet();
|
|
|
try {
|
|
|
rs.executeUpdate("update htmllabelinfo set labelname='"+ newjobtitlename +"' where labelname='"+ oldjobtitlename +"'");
|
|
|
|
|
|
oldjobtitlename = oldjobtitlename.toLowerCase().replaceAll("\\s+", "").replaceAll("_", "");
|
|
|
newjobtitlename = newjobtitlename.toLowerCase().replaceAll("\\s+", "").replaceAll("_", "");
|
|
|
|
|
|
rs.executeQuery("select * from hrm_formfield where fieldname=?",oldjobtitlename);
|
|
|
rs.next();
|
|
|
String fieldid = Util.null2String(rs.getString("fieldid"));
|
|
|
|
|
|
if(!oldjobtitlename.equals(newjobtitlename)){
|
|
|
|
|
|
rs.writeLog("============ RocketmqUtil deleteDeptMatrix oldjobtitlename 111 ====================== " + oldjobtitlename);
|
|
|
rs.writeLog("============ RocketmqUtil deleteDeptMatrix oldjobtitlename 222 ====================== " + newjobtitlename);
|
|
|
HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo();
|
|
|
|
|
|
rs.executeUpdate("UPDATE hrm_formfield SET fieldname=? where fieldid=?",newjobtitlename,fieldid);
|
|
|
|
|
|
rs.execute("ALTER TABLE hrmdepartmentdefined CHANGE "+ oldjobtitlename + " "+ newjobtitlename +" TEXT");
|
|
|
|
|
|
HrmFieldComInfo.removeFieldCache();
|
|
|
//同步部门数据到矩阵
|
|
|
MatrixUtil.sysDepartmentData();
|
|
|
|
|
|
bool = true;
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
rs.writeLog(e);
|
|
|
bool = false;
|
|
|
}
|
|
|
return bool;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除岗位同步到部门自定义字段以及部门矩阵
|
|
|
* @param jobtitlename
|
|
|
* @return
|
|
|
*/
|
|
|
public static boolean deleteDeptMatrix(String jobtitlename){
|
|
|
boolean bool = false;
|
|
|
RecordSet rs = new RecordSet();
|
|
|
try {
|
|
|
jobtitlename = jobtitlename.toLowerCase().replaceAll("\\s+", "").replaceAll("_", "");
|
|
|
|
|
|
HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo();
|
|
|
rs.writeLog("============ RocketmqUtil deleteDeptMatrix jobtitlename 111 ====================== " + jobtitlename);
|
|
|
|
|
|
String htmlLabelInfoSql = "delete from htmllabelinfo where labelname=?";
|
|
|
rs.executeUpdate(htmlLabelInfoSql, new Object[]{jobtitlename});
|
|
|
|
|
|
String hrmFormFieldSql = "delete from hrm_formfield where fieldname=?";
|
|
|
rs.executeUpdate(hrmFormFieldSql, new Object[]{jobtitlename});
|
|
|
|
|
|
rs.execute("UPDATE hrmdepartmentdefined set "+ jobtitlename +"=null");
|
|
|
rs.execute("ALTER TABLE hrmdepartmentdefined DROP COLUMN " + jobtitlename + " ");
|
|
|
|
|
|
HrmFieldComInfo.removeFieldCache();
|
|
|
//同步部门数据到矩阵
|
|
|
MatrixUtil.sysDepartmentData();
|
|
|
|
|
|
bool = true;
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
rs.writeLog(e);
|
|
|
bool = false;
|
|
|
}
|
|
|
return bool;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 新增岗位同步到部门自定义字段以及部门矩阵
|
|
|
* @param jobtitlename
|
|
|
* @return
|
|
|
*/
|
|
|
public static boolean insertDeptMatrix(String jobtitlename){
|
|
|
boolean bool = false;
|
|
|
RecordSet rs = new RecordSet();
|
|
|
try {
|
|
|
HrmFieldComInfo HrmFieldComInfo = new HrmFieldComInfo();
|
|
|
rs.writeLog("============ RocketmqUtil InsertDeptMatrix jobtitlename 111 ====================== " + jobtitlename);
|
|
|
|
|
|
int lableid = new LabelUtil().getLabelId(jobtitlename);
|
|
|
|
|
|
int hrmfieldid = getMaxFieldId();
|
|
|
rs.writeLog("============ RocketmqUtil InsertDeptMatrix hrmfieldid ====================== " + hrmfieldid);
|
|
|
|
|
|
int hrmfieldorder = getMaxOrder();
|
|
|
rs.writeLog("============ RocketmqUtil InsertDeptMatrix hrmfieldorder ====================== " + hrmfieldorder);
|
|
|
|
|
|
jobtitlename = jobtitlename.toLowerCase().replaceAll("\\s+", "").replaceAll("_", "");
|
|
|
rs.writeLog("============ RocketmqUtil InsertDeptMatrix jobtitlename 222 ====================== " + jobtitlename);
|
|
|
|
|
|
String hrmFormFieldSql = "insert into hrm_formfield(fieldid,fielddbtype,fieldname,fieldlabel,fieldhtmltype,type,fieldorder,ismand,isuse,groupid,allowhide) " +
|
|
|
"values(?,?,?,?,?,?,?,?,?,?,?)";
|
|
|
rs.executeUpdate(hrmFormFieldSql, new Object[]{hrmfieldid, "text", jobtitlename, "" + lableid, "3", "17", hrmfieldorder, "0", "1", "7", "1"});
|
|
|
|
|
|
rs.execute("ALTER TABLE hrmdepartmentdefined ADD COLUMN " + jobtitlename + " TEXT ");
|
|
|
|
|
|
HrmFieldComInfo.removeFieldCache();
|
|
|
//同步部门数据到矩阵
|
|
|
MatrixUtil.sysDepartmentData();
|
|
|
|
|
|
bool = true;
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
rs.writeLog(e);
|
|
|
bool = false;
|
|
|
}
|
|
|
return bool;
|
|
|
}
|
|
|
|
|
|
public static int getMaxFieldId(){
|
|
|
RecordSet rs = new RecordSet();
|
|
|
rs.executeQuery("select max(fieldid)as ordee from hrm_formfield");
|
|
|
rs.next();
|
|
|
return rs.getInt("ordee") + 1;
|
|
|
}
|
|
|
|
|
|
public static int getMaxOrder(){
|
|
|
RecordSet rs = new RecordSet();
|
|
|
rs.executeQuery("select max(fieldorder)as ordee from hrm_formfield");
|
|
|
rs.next();
|
|
|
return rs.getInt("ordee") + 1;
|
|
|
}
|
|
|
|
|
|
public static int getMinLabelIndexId(){
|
|
|
RecordSet rs = new RecordSet();
|
|
|
rs.executeQuery("select min(indexid)as ordee from htmllabelinfo");
|
|
|
rs.next();
|
|
|
return rs.getInt("ordee") - 1;
|
|
|
}
|
|
|
|
|
|
}
|