@ -1,5 +1,6 @@
package com.kms.config.scheduled ;
import cn.hutool.core.collection.CollectionUtil ;
import com.alibaba.fastjson.JSONObject ;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper ;
import com.baomidou.mybatisplus.core.toolkit.Wrappers ;
@ -16,9 +17,11 @@ import com.kms.config.WaterResult;
import com.kms.config.singleDomain.SingleOrg ;
import com.kms.config.singleDomain.SingleRole ;
import com.kms.config.singleDomain.SingleUser ;
import com.kms.system.domain.SysXzqh ;
import com.kms.system.service.SysDeptService ;
import com.kms.system.service.SysRoleService ;
import com.kms.system.service.SysUserService ;
import com.kms.system.service.SysXzqhService ;
import com.kms.web.controller.system.SysRoleController ;
import org.slf4j.Logger ;
import org.slf4j.LoggerFactory ;
@ -48,9 +51,15 @@ public class WaterScheduled {
SysRoleController roleController ;
@Autowired
SysRoleService roleService ;
@Autowired
SysXzqhService xzqhService ;
private static String password = "Sgcjs@2024" ;
private final static String YW00112 = "20240322000004" ; //从业单位
private final static String YW00106 = "20240320000001" ; //省级管理员
private final static String YW00109 = "20240322000001" ; //市级管理员
private final static String YW00110 = "20240322000002" ; //区级管理员
private final static String password = "Sgcjs@2024" ; //默认密码
@Scheduled ( cron = "0 0/1 * * * ? " )
public void userScheduled ( ) {
@ -82,13 +91,45 @@ public class WaterScheduled {
}
}
SingleOrg org = singleUser . getOrg ( ) ;
List < String > collect = singleUser . getRoleList ( ) . stream ( ) . map ( singleRole - > singleRole . getId ( ) ) . collect ( Collectors . toList ( ) ) ;
List < SysRole > roles = roleService . listByIds ( collect ) ;
if ( org ! = null ) {
user . setDeptId ( org . getId ( ) ) ;
String type = org . getType ( ) ;
if ( type . equals ( "GA" ) ) {
if ( type . equals ( "GA" ) ) { //政务机构
user . setUserType ( "00" ) ;
} else if ( type . equals ( "SVA" ) ) {
if ( CollectionUtil . isEmpty ( roles ) ) {
String deptId = user . getDeptId ( ) ;
SysDept byId = deptService . getById ( deptId ) ;
if ( byId ! = null ) {
String xzqhId = byId . getXzqhId ( ) ;
SysXzqh xzqh = xzqhService . getById ( xzqhId ) ;
if ( xzqh ! = null ) {
Integer layer = xzqh . getLayer ( ) ;
if ( layer = = 1 ) {
collect . add ( YW00106 ) ;
} else if ( layer = = 2 ) {
collect . add ( YW00109 ) ;
} else {
collect . add ( YW00110 ) ;
}
} else {
collect . add ( YW00110 ) ;
}
} else {
collect . add ( YW00110 ) ;
}
}
} else if ( type . equals ( "SVA" ) ) { //服务机构
user . setUserType ( "01" ) ;
if ( CollectionUtil . isEmpty ( roles ) ) {
collect . add ( YW00112 ) ;
}
} else if ( type . equals ( "FIRM" ) ) { //厂商
user . setUserType ( "00" ) ;
if ( CollectionUtil . isEmpty ( roles ) ) {
collect . add ( YW00106 ) ;
}
}
}
user . setPhonenumber ( singleUser . getPhone ( ) ) ;
@ -104,7 +145,6 @@ public class WaterScheduled {
} else {
user . setStatus ( "1" ) ;
}
List < String > collect = singleUser . getRoleList ( ) . stream ( ) . map ( singleRole - > singleRole . getId ( ) ) . collect ( Collectors . toList ( ) ) ;
user . setRoleIds ( collect . toArray ( new String [ collect . size ( ) ] ) ) ;
if ( flag ) {
userService . singleInsertUser ( user ) ;