package weaver.interfaces.dito.mq ;
import com.alibaba.fastjson.JSONArray ;
import com.alibaba.fastjson.JSONObject ;
import org.apache.commons.codec.digest.DigestUtils ;
import org.apache.commons.lang.StringUtils ;
import weaver.conn.RecordSet ;
import weaver.formmode.setup.ModeRightInfo ;
import weaver.general.BaseBean ;
import weaver.general.TimeUtil ;
import weaver.general.Util ;
import weaver.hrm.company.DepartmentComInfo ;
import weaver.hrm.resource.ResourceComInfo ;
import weaver.interfaces.dito.comInfo.PropBean ;
import java.text.SimpleDateFormat ;
import java.util.Date ;
import java.util.HashMap ;
import java.util.Map ;
import java.util.UUID ;
import java.util.concurrent.locks.Lock ;
import java.util.concurrent.locks.ReentrantLock ;
public class RocketmqUtil {
private Lock lock = new ReentrantLock ( ) ;
public int updateOrgData ( String data )
{
BaseBean bb = new BaseBean ( ) ;
int errcount = 0 ;
try {
lock . lock ( ) ;
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 ) ;
}
}
}
}
}
} 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 = 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" ;
// if("1100".equals(statusCd) || "1200".equals(statusCd) || "1300".equals(statusCd)){
// status = "5";
// }
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 ) ;
String loginid = "" ;
String sql = " select loginid 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" ) ) ;
}
// String lastname = "~`~`7 "+staffName+"`~`8 "+staffName+"`~`~";
String lastname = staffName ;
bb . writeLog ( "loginid:" + loginid ) ;
if ( StringUtils . isNotEmpty ( deptId ) )
{
if ( StringUtils . isNotEmpty ( loginid ) )
{
if ( "M" . equalsIgnoreCase ( actType ) )
{
String userUpdateSql = " update hrmresource set lastname=?,departmentid=?,subcompanyid1=?," +
" creater=?,email=?,mobile=?,jobtitle=?,status=?,dsporder=?,lastmoddate=?,modified=? where workcode=? " ;
bb . writeLog ( "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 ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "人员信息更新sql执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "人员离职更新sql执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 } ) ;
bb . writeLog ( "flag:" + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "人员新增sql执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
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 ) ;
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 ) ;
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 ) ;
boolean flag = rs . executeUpdate ( deptUpdateSql , new Object [ ] { departmentmark , departmentmark , subcompanyid1 , orgId , supdepid , orgCode } ) ;
bb . writeLog ( "flag:" + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "更新部门SQL语句执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
boolean flag = rs . executeUpdate ( deptUpdateSql , new Object [ ] { departmentmark , departmentmark , canceled , subcompanyid1 , orgId , supdepid , orgCode } ) ;
bb . writeLog ( "flag:" + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "封存部门SQL语句执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 deptInsertSql = " insert into hrmdepartment(departmentmark,departmentname,departmentcode,subcompanyid1,supdepid,showorder) values(?,?,?,?,?,?) " ;
bb . writeLog ( "deptInsertSql:" + deptInsertSql ) ;
boolean flag = rs . executeUpdate ( deptInsertSql , new Object [ ] { departmentmark , departmentmark , orgCode , subcompanyid1 , supdepid , orgId } ) ;
bb . writeLog ( "flag:" + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "新增部门SQL语句执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
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 ) ;
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 ) ;
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 systemUserCode = Util . null2String ( jsonObject . get ( "systemUserCode" ) ) ;
String systemUserName = Util . null2String ( jsonObject . get ( "systemUserName" ) ) ;
String actType = Util . null2String ( jsonObject . get ( "actType" ) ) ;
String statusCd = Util . null2String ( jsonObject . get ( "statusCd" ) ) ;
bb . writeLog ( "statusCd:" + statusCd + " actType:" + actType ) ;
try {
String userId = "" ;
String roleId = "" ;
if ( StringUtils . isNotEmpty ( systemUserCode ) ) {
String sql = " select id from hrmresource where loginid=?" ;
rs . executeQuery ( sql , new Object [ ] { systemUserCode } ) ;
if ( rs . next ( ) ) {
userId = Util . null2String ( rs . getString ( "id" ) ) ;
}
}
if ( StringUtils . isNotEmpty ( roleCode ) ) {
String queryRoleIdSql = "select id from hrmroles where ecology_pinyin_search=?" ;
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 ) ) {
String delHrmrolemembersSql = " delete from hrmrolemembers where id = ?" ;
boolean flag = rs . executeUpdate ( delHrmrolemembersSql , releationId ) ;
bb . writeLog ( "delHrmrolemembersSql : " + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "角色成员新增失败" ) ;
dataMap . put ( "systable" , tableName ) ;
recordErrorData ( dataMap ) ;
}
} else {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "角色成员系统已存在, 操作类型为A或者M" ) ;
dataMap . put ( "systable" , tableName ) ;
recordErrorData ( dataMap ) ;
}
} else {
if ( "A" . equals ( actType ) ) {
String insertHrmrolemembersSql = "insert into hrmrolemembers(roleid,resourceid,rolelevel,resourcetype,uuid) values(?,?,?,?,?)" ;
boolean flag = rs . executeUpdate ( insertHrmrolemembersSql , new Object [ ] { roleId , userId , rolelevel , resourcetype , UUID . randomUUID ( ) . toString ( ) } ) ;
bb . writeLog ( "insertHrmrolemembersSql : " + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "角色成员新增失败" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
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 ) ;
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 ) ;
recordErrorData ( dataMap ) ;
}
}
}
}
//{"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" ) ) ;
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 currentDateTime = TimeUtil . getCurrentTimeString ( ) ; //当前时间
String updateStaff = Util . null2String ( jsonObject . get ( "updateStaff" ) ) ;
if ( StringUtils . isEmpty ( updateStaff ) ) {
updateStaff = "1" ;
}
String userId = "" ;
String jobtitlesId = "" ;
String departmentId = "" ;
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 = rs . getString ( "id" ) ;
}
}
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 ) )
{
String updateUserJobSql = " update hrmresource set jobtitle=?,modified=?,modifier=? where id=? " ;
bb . writeLog ( "updateUserJobSql:" + updateUserJobSql ) ;
boolean flag = rs . executeUpdate ( updateUserJobSql , new Object [ ] { jobtitlesId , currentDateTime , updateStaff , userId } ) ;
bb . writeLog ( " updateUserJobFlag: " + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "更新人员岗位sql执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
recordErrorData ( dataMap ) ;
}
} else if ( "D" . equals ( actType ) ) {
jobtitlesId = "" ;
String updateUserJobSql = " update hrmresource set jobtitle=?,modified=?,modifier=? where id=? " ;
bb . writeLog ( "updateUserJobSql:" + updateUserJobSql ) ;
boolean flag = rs . executeUpdate ( updateUserJobSql , new Object [ ] { jobtitlesId , currentDateTime , updateStaff , userId } ) ;
bb . writeLog ( " updateUserJobFlag: " + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "删除人员岗位sql执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
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 ) ;
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 = sysRoleName ;
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 ecology_pinyin_search=?" ;
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=?" ;
boolean flag = rs . executeUpdate ( updateHrmrolesSql , new Object [ ] { sysRoleName , sysRoleName , rolesid } ) ;
bb . writeLog ( "updateHrmroles : " + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "系统角色更新SQL执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 = ?" ;
boolean flag = rs . executeUpdate ( deleteHrmRolesSql , rolesid ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "系统角色删除SQL执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
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" . equals ( actType ) ) { //新增
String insertHrmrolesSql = " insert into hrmroles(rolesmark,rolesname,type,subcompanyid,ecology_pinyin_search,uuid) values(?,?,?,?,?,?)" ;
boolean flag = rs . executeUpdate ( insertHrmrolesSql , new Object [ ] { rolesmark , rolesname , type , subcompanyid , sysRoleCode , uuid } ) ;
bb . writeLog ( "insertHrmroles : " + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "新增系统角色SQL执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
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 ) ;
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 = "" ;
if ( StringUtils . isNotEmpty ( orgCode ) ) {
String querDepartmentIdSql = "select id from hrmdepartment where departmentcode=?" ;
rs . executeQuery ( querDepartmentIdSql , new Object [ ] { orgCode } ) ;
if ( rs . next ( ) ) {
departmentId = rs . getString ( "id" ) ;
}
}
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 ) ) { //修改
String updateHrmjobactivitiesSql = "update hrmjobtitles set jobtitlemark=?,jobtitlename=?,modified=?,modifier=? where id=?" ;
boolean flag = rs . executeUpdate ( updateHrmjobactivitiesSql , new Object [ ] { jobtitlemark , jobtitlename , modified , modifier , jobtitleid } ) ;
bb . writeLog ( "insertHrmjobactivitiesSql flag:" + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "系统岗位更新SQL执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
recordErrorData ( dataMap ) ;
}
} else if ( "D" . equals ( actType ) ) {
String canceled = "1" ;
String updateHrmjobactivitiesSql = "update hrmjobtitles set jobtitlemark=?,jobtitlename=?,modified=?,modifier=?,canceled = ? where id=?" ;
boolean flag = rs . executeUpdate ( updateHrmjobactivitiesSql , new Object [ ] { jobtitlemark , jobtitlename , modified , modifier , canceled , jobtitleid } ) ;
bb . writeLog ( "insertHrmjobactivitiesSql flag:" + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "系统岗位封存SQL执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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" . equals ( actType ) ) { //新增
String uuid = UUID . randomUUID ( ) . toString ( ) ;
String insertHrmjobactivitiesSql = " insert into hrmjobtitles(jobtitlemark,jobtitlename,jobactivityid,jobdepartmentid,jobtitlecode,created,creater,modified,modifier,uuid) values(?,?,?,?,?,?,?,?,?,?)" ;
boolean flag = rs . executeUpdate ( insertHrmjobactivitiesSql , new Object [ ] { jobtitlemark , jobtitlename , jobactivitiesid , departmentId , sysPostCode , created , creater , modified , modifier , uuid } ) ;
bb . writeLog ( "insertHrmjobactivitiesSql flag:" + flag ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "系统岗位新增SQL执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
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 ) ;
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 = "1" ;
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 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" ) ) ;
String actType = Util . null2String ( jsonObject . get ( "actType" ) ) ;
String email = Util . null2String ( jsonObject . get ( "email" ) ) ;
String pwdSmsTel = Util . null2String ( jsonObject . get ( "pwdSmsTel" ) ) ;
String loginedNum = Util . null2String ( jsonObject . get ( "sysUserId" ) ) ;
String statusCd = Util . null2String ( jsonObject . get ( "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 = Util . null2String ( jsonObject . get ( "eId" ) ) ;
bb . writeLog ( "eId:" + eId ) ;
bb . writeLog ( "staffId:" + staffId ) ;
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 ) ;
String userid = "" ;
String loginid = "" ;
if ( StringUtils . isNotEmpty ( staffCode ) ) {
String sql = " select loginid,id 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" ) ) ;
}
}
bb . writeLog ( "loginid:" + loginid ) ;
if ( StringUtils . isNotEmpty ( deptId ) )
{
if ( StringUtils . isNotEmpty ( loginid ) )
{
if ( "M" . equalsIgnoreCase ( actType ) )
{
String userUpdateSql = " update hrmresource set lastname=?,departmentid=?,subcompanyid1=?," +
" creater=?,email=?,mobile=?,jobtitle=?,status=?,dsporder=?,lastmoddate=?,modified=? where workcode=? " ;
bb . writeLog ( "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 ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "人员更新SQL执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "人员离职SQL执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) )
{
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 ) ;
if ( ! flag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "人员新增SQL执行错误" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
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" ) ) ;
}
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 } ) ;
if ( ! deflag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "更新人员自定义信息失败" ) ;
dataMap . put ( "systable" , tableName ) ;
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 } ) ;
if ( ! deflag ) {
Map < String , String > dataMap = new HashMap < String , String > ( ) ;
dataMap . put ( "syndate" , nowDateTime ) ;
dataMap . put ( "reqmessage" , jsonObject . toJSONString ( ) ) ;
dataMap . put ( "errmessage" , "新增人员自定义信息失败" ) ;
dataMap . put ( "systable" , tableName ) ;
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 ) ;
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 ) ;
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" ) ) ;
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 } ) ;
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 ) ;
}
}
}