@ -2,6 +2,9 @@ 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 org.apache.commons.codec.digest.DigestUtils ;
import org.apache.commons.lang.StringUtils ;
import weaver.conn.RecordSet ;
@ -16,6 +19,7 @@ import weaver.hrm.roles.RolesComInfo;
import weaver.interfaces.dito.comInfo.PropBean ;
import weaver.systeminfo.systemright.CheckUserRight ;
import java.io.IOException ;
import java.text.SimpleDateFormat ;
import java.util.* ;
import java.util.concurrent.locks.Lock ;
@ -53,7 +57,7 @@ public class RocketmqUtil {
if ( "organization" . equals ( tableName ) ) {
updasteSysOrgData ( jsonArray , tableName ) ;
} else if ( "system_user" . equals ( tableName ) ) {
updateSysUserData ( jsonArray , tableName ) ;
// updateSysUserData(jsonArray,tableName);
} else if ( "system_roles" . equals ( tableName ) ) {
updasteSysRoleData ( jsonArray , tableName ) ;
} else if ( "system_post" . equals ( tableName ) ) {
@ -153,9 +157,7 @@ public class RocketmqUtil {
String statusCd = Util . null2String ( jsonObject . get ( "statusCd" ) ) ;
String status = "1" ;
// if("1100".equals(statusCd) || "1200".equals(statusCd) || "1300".equals(statusCd)){
// status = "5";
// }
try {
String subcompanyid1 = "" ;
String deptId = "" ;
@ -171,130 +173,228 @@ public class RocketmqUtil {
bb . writeLog ( "subcompanyid1:" + subcompanyid1 ) ;
bb . writeLog ( "currentDate:" + currentDate ) ;
String loginid = "" ;
String user_status = "" ;
String sql = " select loginid,status from hrmresource where workcode=?" ;
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 } ) ;
if ( rs . next ( ) ) {
loginid = Util . null2String ( rs . getString ( "loginid" ) ) ;
user_status = Util . null2String ( rs . getString ( "user_status" ) ) ;
while ( rs . next ( ) ) {
datacount + + ;
}
bb . writeLog ( "datacount:" + datacount ) ;
if ( datacount < = 1 ) {
bb . writeLog ( "user_status2:" + user_status ) ;
bb . writeLog ( "statusCd2:" + statusCd ) ;
// String lastname = "~`~`7 "+staffName+"`~`8 "+staffName+"`~`~";
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 ) )
String lastname = staffName ;
bb . writeLog ( "loginid2:" + loginid ) ;
if ( StringUtils . isNotEmpty ( deptId ) )
{
if ( "M" . equalsIgnoreCase ( actType ) )
if ( StringUtils . isNotEmpty ( loginid ) )
{
if ( "1000" . equals ( statusCd ) ) {
status = "1" ;
} else if ( "1100" . equals ( statusCd ) | | "1200" . equals ( statusCd ) | | "1300" . equals ( statusCd ) ) {
status = "5" ;
}
bb . writeLog ( "status2:" + status ) ;
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 lastname=?,departmentid=?,subcompanyid1=?," +
" creater=?,email=?,mobile=?,jobtitle=?,status=?,dsporder=?,lastmoddate=?,modified=? where workcode=? " ;
bb . writeLog ( "updateSysUserData-userUpdateSql:" + userUpdateSql ) ;
String userUpdateSql = " update hrmresource set loginid=?, lastname=?,departmentid=?,subcompanyid1=?," +
" creater=?,email=?,mobile=?,jobtitle=?,status=?,dsporder=?,lastmoddate=?,modified=? where workcode=? " ;
bb . writeLog ( "updateSysUserData-userUpdateSql:" + userUpdateSql ) ;
boolean flag = rs . executeUpdate ( userUpdateSql , new Object [ ] { lastname , deptId , subcompanyid1 , creator , email ,
pwdSmsTel , jobTitleId , status , loginedNum , currentDate , currentDateTime , staffCode } ) ;
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执行错误" ) ;
boolean flag = rs . executeUpdate ( userUpdateSql , new Object [ ] { loginid , lastname , deptId , subcompanyid1 , creator , email ,
pwdSmsTel , jobTitleId , 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 ( "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 ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "人员系统中已存在, 操作类型为A" ) ;
dataMap . put ( "systable" , tableName ) ;
recordErrorData ( dataMap ) ;
}
} else {
if ( "A" . equalsIgnoreCase ( actType ) )
{
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 } ) ;
} 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执行错误") ;
dataMap . put ( "errmessage" , "人员离职更新sql执行错误" ) ;
} else {
dataMap . put ( "errmessage" , "人员 新增 sql执行成功") ;
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 {
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 ) ;
recordErrorData ( dataMap ) ;
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" , "人员所属部门为空" ) ;
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 ( ) ) ;
@ -450,6 +550,8 @@ public class RocketmqUtil {
dataMap . put ( "errmessage" , "部门在系统中不存在, 操作类型为M或者D" ) ;
dataMap . put ( "systable" , tableName ) ;
recordErrorData ( dataMap ) ;
}
}
} else {
@ -585,9 +687,9 @@ public class RocketmqUtil {
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "systable" , tableName ) ;
if ( ! flag ) {
dataMap . put ( "errmessage" , "角色成员 新增 失败") ;
dataMap . put ( "errmessage" , "角色成员 删除 失败") ;
} else {
dataMap . put ( "errmessage" , "角色成员 新增 成功") ;
dataMap . put ( "errmessage" , "角色成员 删除 成功") ;
}
recordErrorData ( dataMap ) ;
} else {
@ -1225,163 +1327,333 @@ public class RocketmqUtil {
bb . writeLog ( "deptId:" + deptId ) ;
bb . writeLog ( "subcompanyid1:" + subcompanyid1 ) ;
String userid = "" ;
String loginid = "" ;
String user_status = "" ;
if ( StringUtils . isNotEmpty ( staffCode ) ) {
String sql = " select loginid,id,status from hrmresource where workcode=?" ;
bb . writeLog ( "sql:" + sql ) ;
rs . executeQuery ( sql , new Object [ ] { staffCode } ) ;
if ( rs . next ( ) ) {
loginid = Util . null2String ( rs . getString ( "loginid" ) ) ;
userid = Util . null2String ( rs . getString ( "id" ) ) ;
user_status = Util . null2String ( rs . getString ( "status" ) ) ;
}
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 ( "user_status:" + user_status ) ;
bb . writeLog ( "loginid:" + loginid ) ;
if ( StringUtils . isNotEmpty ( deptId ) )
bb . writeLog ( "datacount:" + datacount ) ;
if ( datacount < = 1 )
{
if ( StringUtils . isNotEmpty ( loginid ) )
String userid = "" ;
String loginid = "" ;
String user_status = "" ;
if ( StringUtils . isNotEmpty ( staffCode ) )
{
if ( "M" . equalsIgnoreCase ( actType ) )
{
if ( "1000" . equals ( statusCd ) ) {
status = "1" ;
} else if ( "1100" . equals ( statusCd ) ) {
status = "5" ;
}
bb . writeLog ( "status:" + status ) ;
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" ) ) ;
String userUpdateSql = " update hrmresource set lastname=?,departmentid=?,subcompanyid1=?," +
" creater=?,email=?,mobile=?,status=?,dsporder=?,lastmoddate=?,modified=? where workcode=? " ;
bb . writeLog ( "updateSysUserData-userUpdateSql:" + userUpdateSql ) ;
boolean flag = rs . executeUpdate ( userUpdateSql , new Object [ ] { 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 ( "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 ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "systable" , tableName ) ;
if ( ! flag ) {
dataMap . put ( "errmessage" , "人员离职SQL执行错误" ) ;
} else {
dataMap . put ( "errmessage" , "人员离职SQL执行成功" ) ;
bb . writeLog ( "loginid:" + loginid ) ;
bb . writeLog ( "user_status:" + user_status ) ;
if ( StringUtils . isBlank ( loginid ) ) {
if ( "5" . equals ( user_status ) ) {
loginid = staffCode ;
}
}
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 ) ;
recordErrorData ( dataMap ) ;
}
} else {
if ( "A" . equalsIgnoreCase ( actType ) )
{
rs . executeProc ( "HrmResourceMaxId_Get" , "" ) ;
rs . next ( ) ;
String id = "" + rs . getInt ( 1 ) ;
bb . writeLog ( "id:" + id ) ;
}
if ( StringUtils . isNotEmpty ( id ) )
bb . writeLog ( "user_status:" + user_status ) ;
bb . writeLog ( "loginid:" + loginid ) ;
if ( StringUtils . isNotEmpty ( deptId ) )
{
if ( StringUtils . isNotEmpty ( loginid ) )
{
if ( "M" . equalsIgnoreCase ( actType ) )
{
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 } ) ;
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=? " ;
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 ) {
userid = id + "" ;
dataMap . put ( "errmessage" , "人员新增SQL执行成功" ) ;
} else {
dataMap . put ( "errmessage" , "人员新增SQL执行错误" ) ;
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 {
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,status from hrmresource where loginid = '" + staffCode + "' 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 ;
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(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)" ;
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 , staffId } ) ;
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 ) {
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 {
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 ) ;
recordErrorData ( dataMap ) ;
}
}
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 = '" + 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 ;
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) " +
" 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 ) {
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 {
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 ) ;
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" ) ) ;
String context = "人员staffname:" + staffName + ",staffcode:" + staffCode + "的员工在系统中不存在, 操作类型为M或者D, 请检查数据" ;
recordErrorMessage ( staffCode , context ) ;
}
}
if ( StringUtils . isNotEmpty ( seqorder ) ) {
String cusUpdateSql = " update cus_fielddata set " + cus_staff + "=?," + cus_eid + "=? where scope=? and scopeid=? and id=?" ;
bb . writeLog ( cusUpdateSql ) ;
boolean deflag = rs . executeUpdate ( cusUpdateSql , new Object [ ] { staffId , eId , scope , scopeid , userid } ) ;
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "systable" , tableName ) ;
if ( ! deflag ) {
dataMap . put ( "errmessage" , "更新人员自定义信息失败" ) ;
} else {
dataMap . put ( "errmessage" , "更新人员自定义信息成功" ) ;
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" ) ) ;
}
recordErrorData ( dataMap ) ;
} else {
String cusInsertSql = " insert into cus_fielddata(scope,scopeid,id," + cus_staff + "," + cus_eid + ") values(?,?,?,?,?)" ;
bb . writeLog ( cusInsertSql ) ;
boolean deflag = rs . executeUpdate ( cusInsertSql , new Object [ ] { scope , scopeid , userid , staffId , eId } ) ;
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "systable" , tableName ) ;
if ( ! deflag ) {
dataMap . put ( "errmessage" , "新增人员自定义信息失败" ) ;
} else {
dataMap . put ( "errmessage" , "新增人员自定义信息成功" ) ;
if ( StringUtils . isNotEmpty ( seqorder ) ) {
String cusUpdateSql = " update cus_fielddata set " + cus_staff + "=?," + cus_eid + "=? where scope=? and scopeid=? and id=?" ;
bb . writeLog ( cusUpdateSql ) ;
boolean deflag = rs . executeUpdate ( cusUpdateSql , new Object [ ] { staffId , eId , scope , scopeid , userid } ) ;
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 ( ! deflag ) {
dataMap . put ( "errmessage" , "更新人员自定义信息失败" ) ;
} else {
dataMap . put ( "errmessage" , "更新人员自定义信息成功" ) ;
}
recordErrorData ( dataMap ) ;
} else {
String cusInsertSql = " insert into cus_fielddata(scope,scopeid,id," + cus_staff + "," + cus_eid + ") values(?,?,?,?,?)" ;
bb . writeLog ( cusInsertSql ) ;
boolean deflag = rs . executeUpdate ( cusInsertSql , new Object [ ] { scope , scopeid , userid , staffId , eId } ) ;
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 ( ! deflag ) {
dataMap . put ( "errmessage" , "新增人员自定义信息失败" ) ;
} else {
dataMap . put ( "errmessage" , "新增人员自定义信息成功" ) ;
}
recordErrorData ( dataMap ) ;
}
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" , "人员所属部门为空" ) ;
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 ( ) ) ;
@ -1425,11 +1697,13 @@ public class RocketmqUtil {
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" ) ) ;
int bool = 0 ;
sql = " insert into " + uftable + "(uuid,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime,syndate,reqmessage,errmessage,systable )" +
" values(?,?,?,?,?,?,?,?,?,? )" ;
boolean flag = rs . executeUpdate ( sql , new Object [ ] { uuid , formmodeid , modedatacreater , modedatacreatertype , modedatacreatedate , modedatacreatetime , syndate , reqmessage , errmessage , systable }) ;
sql = " insert into " + uftable + "(uuid,formmodeid,modedatacreater,modedatacreatertype,modedatacreatedate,modedatacreatetime,syndate,reqmessage,errmessage,systable ,staffcodecount,staffcode )" +
" values(?,?,?,?,?,?,?,?,?,? ,?,? )" ;
boolean flag = rs . executeUpdate ( sql , new Object [ ] { uuid , formmodeid , modedatacreater , modedatacreatertype , modedatacreatedate , modedatacreatetime , syndate , reqmessage , errmessage , systable ,staffcodecount , staffcode }) ;
bb . writeLog ( "sql;" + sql ) ;
if ( flag ) {
bool + + ;
@ -1474,4 +1748,38 @@ public class RocketmqUtil {
}
}
/ * * *
*
* @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 ( "MQError" ) , 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 ) ;
}
}
}