Compare commits
2 Commits
c7713e4bba
...
4a4fbb4823
Author | SHA1 | Date |
---|---|---|
|
4a4fbb4823 | 1 year ago |
|
8b5cc555c1 | 1 year ago |
20 changed files with 1778 additions and 7 deletions
@ -0,0 +1,265 @@ |
|||||
|
package com.kms.web.controller.system; |
||||
|
|
||||
|
import cn.hutool.core.collection.CollectionUtil; |
||||
|
import com.alibaba.fastjson.JSONArray; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import com.kms.system.domain.SysUserRole; |
||||
|
import com.kms.system.service.SysDeptService; |
||||
|
import com.kms.system.service.SysRoleService; |
||||
|
import com.kms.system.service.SysUserRoleService; |
||||
|
import com.kms.system.service.SysUserService; |
||||
|
import com.kms.web.utils.CallBackRequest; |
||||
|
import com.kms.web.utils.CallType; |
||||
|
import com.kms.web.utils.WaterResult; |
||||
|
import com.kms.web.utils.singleDomain.SingleOrg; |
||||
|
import com.kms.web.utils.singleDomain.SingleRole; |
||||
|
import com.kms.web.utils.singleDomain.SingleUser; |
||||
|
import com.shuili.common.core.domain.entity.SysDept; |
||||
|
import com.shuili.common.core.domain.entity.SysRole; |
||||
|
import com.shuili.common.core.domain.entity.SysUser; |
||||
|
import com.shuili.common.exception.CustomException; |
||||
|
import com.shuili.common.utils.password.PasswordUtil; |
||||
|
import com.shuili.common.utils.uuid.IdUtils; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.BeanUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Controller; |
||||
|
import org.springframework.web.bind.annotation.PostMapping; |
||||
|
import org.springframework.web.bind.annotation.RequestBody; |
||||
|
import org.springframework.web.bind.annotation.RequestMapping; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
@RequestMapping("/callBack") |
||||
|
@Controller |
||||
|
public class CmsCallBackController { |
||||
|
|
||||
|
@Autowired |
||||
|
SysUserService userService; |
||||
|
|
||||
|
@Autowired |
||||
|
SysDeptService deptService; |
||||
|
|
||||
|
@Autowired |
||||
|
SysRoleService roleService; |
||||
|
|
||||
|
@Autowired |
||||
|
SysUserRoleService userRoleService; |
||||
|
|
||||
|
|
||||
|
private static final Logger log = LoggerFactory.getLogger(CmsCallBackController.class); |
||||
|
|
||||
|
@PostMapping("/notify") |
||||
|
public WaterResult callBack(@RequestBody CallBackRequest callBackRequest){ |
||||
|
log.info("--------开启同步请求--------------,时间:{}",new Date()); |
||||
|
log.info("发起同步请求的参数为:{}",callBackRequest); |
||||
|
String type = callBackRequest.getType(); |
||||
|
String content = callBackRequest.getContent(); |
||||
|
if(type.equals(CallType.USER_ADD)){ |
||||
|
SingleUser singleUser = JSONObject.parseObject(content, SingleUser.class); |
||||
|
QueryWrapper<SysUser> query = Wrappers.query(); |
||||
|
query.eq("single_user_id",singleUser.getId()); |
||||
|
SysUser user = userService.getOne(query,false); |
||||
|
if(user!=null){ |
||||
|
throw new CustomException("该用户已存在,无法添加"); |
||||
|
} |
||||
|
user = new SysUser(); |
||||
|
user.preInsert(); |
||||
|
user.setCreateUid("1"); |
||||
|
user.setUpdateUid("1"); |
||||
|
user.setRemark("门户定时任务数据添加"); |
||||
|
user.setId(IdUtils.fastSimpleUUID()); |
||||
|
user.setIsPcUser("0"); |
||||
|
user.setDelFlag("0"); |
||||
|
user.setPhonenumber(singleUser.getPhone()); |
||||
|
user.setNickName(singleUser.getName()); |
||||
|
user.setUserName(singleUser.getUsername()); |
||||
|
user.setSingleUserSource(singleUser.getSource()); |
||||
|
user.setSingleUserType(singleUser.getType()); |
||||
|
user.setSingleUserId(singleUser.getId()); |
||||
|
user.setPassword(PasswordUtil.entryptPassword(singleUser.getUsername())); |
||||
|
user.setIsFirst(singleUser.getFirstSignIn().toString()); |
||||
|
if(singleUser.getStatus()==null||singleUser.getStatus().equals("1")){ |
||||
|
user.setStatus("0"); |
||||
|
}else { |
||||
|
user.setStatus("1"); |
||||
|
} |
||||
|
SingleOrg org = singleUser.getOrg(); |
||||
|
if(org!=null){ |
||||
|
user.setDeptId(org.getId()); |
||||
|
String orgType = org.getType(); |
||||
|
if(orgType.equals("GA")){ //政务
|
||||
|
user.setUserType("00"); |
||||
|
}else if(orgType.equals("SVA")){ //服务
|
||||
|
user.setUserType("01"); |
||||
|
} |
||||
|
} |
||||
|
if(CollectionUtil.isNotEmpty(singleUser.getRoleList())) { |
||||
|
List<String> collect = singleUser.getRoleList().stream().map(singleRole -> singleRole.getId()).collect(Collectors.toList()); |
||||
|
user.setRoleIds(collect.toArray(new String[collect.size()])); |
||||
|
} |
||||
|
userService.singleInsertUser(user); |
||||
|
}else if(type.equals(CallType.USER_UPDATE)){ |
||||
|
SingleUser singleUser = JSONObject.parseObject(content, SingleUser.class); |
||||
|
QueryWrapper<SysUser> query = Wrappers.query(); |
||||
|
query.eq("single_user_id",singleUser.getId()); |
||||
|
SysUser user = userService.getOne(query,false); |
||||
|
if(user==null){ |
||||
|
throw new CustomException("该用户不存在,无法修改"); |
||||
|
} |
||||
|
SingleOrg org = singleUser.getOrg(); |
||||
|
if(org!=null){ |
||||
|
user.setDeptId(org.getId()); |
||||
|
String orgType = org.getType(); |
||||
|
if(orgType.equals("GA")){ //政务
|
||||
|
user.setUserType("00"); |
||||
|
}else if(orgType.equals("SVA")){ //服务
|
||||
|
user.setUserType("01"); |
||||
|
} |
||||
|
} |
||||
|
user.setPhonenumber(singleUser.getPhone()); |
||||
|
user.setNickName(singleUser.getName()); |
||||
|
user.setUserName(singleUser.getUsername()); |
||||
|
user.setSingleUserSource(singleUser.getSource()); |
||||
|
user.setSingleUserType(singleUser.getType()); |
||||
|
user.setSingleUserId(singleUser.getId()); |
||||
|
user.setPassword(PasswordUtil.entryptPassword(singleUser.getUsername())); |
||||
|
user.setIsFirst(singleUser.getFirstSignIn().toString()); |
||||
|
if(singleUser.getStatus()==null||singleUser.getStatus().equals("1")){ |
||||
|
user.setStatus("0"); |
||||
|
}else { |
||||
|
user.setStatus("1"); |
||||
|
} |
||||
|
if(CollectionUtil.isNotEmpty(singleUser.getRoleList())) { |
||||
|
List<String> collect = singleUser.getRoleList().stream().map(singleRole -> singleRole.getId()).collect(Collectors.toList()); |
||||
|
user.setRoleIds(collect.toArray(new String[collect.size()])); |
||||
|
} |
||||
|
userService.updateUser(user); |
||||
|
}else if(type.equals(CallType.USER_DELETE)){ |
||||
|
SingleUser singleUser = JSONObject.parseObject(content, SingleUser.class); |
||||
|
QueryWrapper<SysUser> query = Wrappers.query(); |
||||
|
query.eq("single_user_id",singleUser.getId()); |
||||
|
SysUser one = userService.getOne(query, false); |
||||
|
if(one==null){ |
||||
|
throw new CustomException("该用户不存在,无法删除"); |
||||
|
} |
||||
|
userService.deleteUserById(one.getId()); |
||||
|
}else if(type.equals(CallType.ORG_ADD)){ |
||||
|
SingleOrg singleOrg = JSONObject.parseObject(content, SingleOrg.class); |
||||
|
SysDept dept = deptService.getById(singleOrg.getId()); |
||||
|
if(dept==null) { |
||||
|
dept = new SysDept(); |
||||
|
dept.setIsDownload("0"); |
||||
|
dept.setIsComment("0"); |
||||
|
dept.setDelFlag("0"); |
||||
|
dept.setCreateTime(new Date()); |
||||
|
BeanUtils.copyProperties(singleOrg,dept); |
||||
|
dept.setXzqhId(singleOrg.getArea()); |
||||
|
dept.setXzqhName(singleOrg.getAreaText()); |
||||
|
dept.setSingleCode(singleOrg.getCode()); |
||||
|
dept.setSingleSeq(singleOrg.getSeq()); |
||||
|
dept.setSingleType(singleOrg.getType()); |
||||
|
dept.setDeptName(singleOrg.getName()); |
||||
|
dept.setParentId(singleOrg.getParent()); |
||||
|
dept.setLeader(singleOrg.getDutyPerson()); |
||||
|
dept.setName(singleOrg.getName()); |
||||
|
dept.setAdminName(singleOrg.getName()); |
||||
|
dept.setUpdateTime(new Date()); |
||||
|
if(singleOrg.getStatus()==null||singleOrg.getStatus().equals("1")){ |
||||
|
dept.setStatus("0"); |
||||
|
}else { |
||||
|
dept.setStatus("1"); |
||||
|
} |
||||
|
deptService.save(dept); |
||||
|
} |
||||
|
}else if(type.equals(CallType.ORG_UPDATE)){ |
||||
|
SingleOrg singleOrg = JSONObject.parseObject(content, SingleOrg.class); |
||||
|
SysDept dept = deptService.getById(singleOrg.getId()); |
||||
|
if(dept!=null) { |
||||
|
BeanUtils.copyProperties(singleOrg, dept); |
||||
|
dept.setXzqhId(singleOrg.getArea()); |
||||
|
dept.setXzqhName(singleOrg.getAreaText()); |
||||
|
dept.setSingleCode(singleOrg.getCode()); |
||||
|
dept.setSingleSeq(singleOrg.getSeq()); |
||||
|
dept.setSingleType(singleOrg.getType()); |
||||
|
dept.setDeptName(singleOrg.getName()); |
||||
|
dept.setParentId(singleOrg.getParent()); |
||||
|
dept.setLeader(singleOrg.getDutyPerson()); |
||||
|
dept.setName(singleOrg.getName()); |
||||
|
dept.setAdminName(singleOrg.getName()); |
||||
|
dept.setUpdateTime(new Date()); |
||||
|
if(singleOrg.getStatus()==null||singleOrg.getStatus().equals("1")){ |
||||
|
dept.setStatus("0"); |
||||
|
}else { |
||||
|
dept.setStatus("1"); |
||||
|
} |
||||
|
deptService.updateById(dept); |
||||
|
} |
||||
|
}else if(type.equals(CallType.ROLE_ADD)){ |
||||
|
log.info("执行消息:角色添加,参数为:"+content); |
||||
|
SingleRole singleRole = JSONObject.parseObject(content, SingleRole.class); |
||||
|
SysRole sysRole = roleService.getById(singleRole.getId()); |
||||
|
if(sysRole==null){ |
||||
|
sysRole = new SysRole(); |
||||
|
sysRole.setStatus("0"); |
||||
|
if(sysRole.getStatus()==null||sysRole.getStatus()=="0"){ |
||||
|
sysRole.setStatus("1"); |
||||
|
} |
||||
|
sysRole.setDelFlag("0"); |
||||
|
sysRole.setRoleSort("0"); |
||||
|
sysRole.setCreateTime(new Date()); |
||||
|
BeanUtils.copyProperties(singleRole,sysRole); |
||||
|
sysRole.setRoleName(singleRole.getName()); |
||||
|
sysRole.setRoleKey(singleRole.getCode()); |
||||
|
sysRole.setUpdateTime(new Date()); |
||||
|
roleService.save(sysRole); |
||||
|
} |
||||
|
}else if(type.equals(CallType.ROLE_UPDATE)){ |
||||
|
SingleRole singleRole = JSONObject.parseObject(content, SingleRole.class); |
||||
|
SysRole sysRole = roleService.getById(singleRole.getId()); |
||||
|
if(sysRole!=null){ |
||||
|
if(sysRole.getStatus()==null||sysRole.getStatus()=="0"){ |
||||
|
sysRole.setStatus("1"); |
||||
|
}else{ |
||||
|
sysRole.setStatus("0"); |
||||
|
} |
||||
|
BeanUtils.copyProperties(singleRole,sysRole); |
||||
|
sysRole.setRoleName(singleRole.getName()); |
||||
|
sysRole.setRoleKey(singleRole.getCode()); |
||||
|
sysRole.setUpdateTime(new Date()); |
||||
|
roleService.updateById(sysRole); |
||||
|
} |
||||
|
}else if(type.equals(CallType.ROLE_DELETE)){ |
||||
|
SingleRole singleRole = JSONObject.parseObject(content, SingleRole.class); |
||||
|
roleService.deleteRoleById(singleRole.getId()); |
||||
|
}else if(type.equals(CallType.ROLE_USER_BIND)){ //绑定
|
||||
|
JSONObject jsonObject = JSONObject.parseObject(content); |
||||
|
String roleId = jsonObject.getString("roleId"); |
||||
|
JSONArray userIds = jsonObject.getJSONArray("userIds"); |
||||
|
List<String> list = userIds.toJavaList(String.class); |
||||
|
for (String id : list) { |
||||
|
SysUserRole sysUserRole = new SysUserRole(); |
||||
|
sysUserRole.preInsert(); |
||||
|
sysUserRole.setUserId(id); |
||||
|
sysUserRole.setRoleId(roleId); |
||||
|
userRoleService.save(sysUserRole); |
||||
|
} |
||||
|
}else if(type.equals(CallType.ROLE_USER_UNBIND)) { //解绑
|
||||
|
JSONObject jsonObject = JSONObject.parseObject(content); |
||||
|
String roleId = jsonObject.getString("roleId"); |
||||
|
JSONArray userIds = jsonObject.getJSONArray("userIds"); |
||||
|
List<String> list = userIds.toJavaList(String.class); |
||||
|
QueryWrapper<SysUserRole> query = Wrappers.query(); |
||||
|
query.eq("role_id",roleId).in("user_id",list); |
||||
|
userRoleService.remove(query); |
||||
|
} |
||||
|
log.info("--------同步请求结束--------------,时间:{}",new Date()); |
||||
|
return WaterResult.success(); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
package com.kms.web.utils; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class CallBackRequest { |
||||
|
|
||||
|
private String type; |
||||
|
private String content; |
||||
|
|
||||
|
} |
@ -0,0 +1,19 @@ |
|||||
|
package com.kms.web.utils; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
public class CallType { |
||||
|
|
||||
|
public final static String USER_ADD = "USER_ADD"; |
||||
|
public final static String USER_UPDATE = "USER_UPDATE"; |
||||
|
public static String USER_DELETE = "USER_DELETE"; |
||||
|
public static String ORG_UPDATE = "ORG_UPDATE"; |
||||
|
public static String ORG_ADD = "ORG_ADD"; |
||||
|
public static String ROLE_ADD = "ROLE_ADD"; |
||||
|
public static String ROLE_UPDATE = "ROLE_UPDATE"; |
||||
|
public static String ROLE_DELETE = "ROLE_DELETE"; |
||||
|
public static String ROLE_USER_BIND = "ROLE_USER_BIND";//用户角色关系绑定
|
||||
|
public static String ROLE_USER_UNBIND = "ROLE_USER_UNBIND";//用户角色关系解绑
|
||||
|
|
||||
|
} |
@ -0,0 +1,154 @@ |
|||||
|
package com.kms.web.utils; |
||||
|
|
||||
|
import org.apache.commons.codec.digest.DigestUtils; |
||||
|
import org.bouncycastle.jce.provider.BouncyCastleProvider; |
||||
|
import org.bouncycastle.util.encoders.Hex; |
||||
|
|
||||
|
import java.security.MessageDigest; |
||||
|
import java.security.Security; |
||||
|
|
||||
|
public abstract class SHACoder { |
||||
|
|
||||
|
/** |
||||
|
* SHA加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @return byte[] 消息摘要 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static byte[] encodeSHA(String data) throws Exception { |
||||
|
|
||||
|
// 执行消息摘要
|
||||
|
return DigestUtils.sha(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* SHAHex加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @return String 消息摘要 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static String encodeSHAHex(String data) throws Exception { |
||||
|
|
||||
|
// 执行消息摘要
|
||||
|
return DigestUtils.shaHex(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* SHA-224加密 |
||||
|
* |
||||
|
* @param data |
||||
|
* 待加密数据 |
||||
|
* @return byte[] 消息摘要 |
||||
|
* |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static byte[] encodeSHA224(byte[] data) throws Exception { |
||||
|
// 加入BouncyCastleProvider支持
|
||||
|
Security.addProvider(new BouncyCastleProvider()); |
||||
|
|
||||
|
// 初始化MessageDigest
|
||||
|
MessageDigest md = MessageDigest.getInstance("SHA-224"); |
||||
|
|
||||
|
// 执行消息摘要
|
||||
|
return md.digest(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* SHA-224加密 |
||||
|
* |
||||
|
* @param data |
||||
|
* 待加密数据 |
||||
|
* @return byte[] 消息摘要 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static String encodeSHA224Hex(byte[] data) throws Exception { |
||||
|
|
||||
|
// 执行消息摘要
|
||||
|
byte[] b = encodeSHA224(data); |
||||
|
|
||||
|
// 做十六进制编码处理
|
||||
|
return new String(Hex.encode(b)); |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* SHA256加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @return byte[] 消息摘要 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static byte[] encodeSHA256(String data) throws Exception { |
||||
|
|
||||
|
// 执行消息摘要
|
||||
|
return DigestUtils.sha256(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* SHA256Hex加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @return String 消息摘要 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static String encodeSHA256Hex(String data) throws Exception { |
||||
|
|
||||
|
// 执行消息摘要
|
||||
|
return DigestUtils.sha256Hex(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* SHA384加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @return byte[] 消息摘要 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static byte[] encodeSHA384(String data) throws Exception { |
||||
|
|
||||
|
// 执行消息摘要
|
||||
|
return DigestUtils.sha384(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* SHA384Hex加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @return String 消息摘要 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static String encodeSHA384Hex(String data) throws Exception { |
||||
|
|
||||
|
// 执行消息摘要
|
||||
|
return DigestUtils.sha384Hex(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* SHA512Hex加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @return byte[] 消息摘要 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static byte[] encodeSHA512(String data) throws Exception { |
||||
|
|
||||
|
// 执行消息摘要
|
||||
|
return DigestUtils.sha512(data); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* SHA512Hex加密 |
||||
|
* |
||||
|
* @param data 待加密数据 |
||||
|
* @return String 消息摘要 |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static String encodeSHA512Hex(String data) throws Exception { |
||||
|
|
||||
|
// 执行消息摘要
|
||||
|
return DigestUtils.sha512Hex(data); |
||||
|
} |
||||
|
|
||||
|
} |
@ -0,0 +1,291 @@ |
|||||
|
package com.kms.web.utils; |
||||
|
|
||||
|
import cn.hutool.core.util.IdUtil; |
||||
|
import cn.hutool.http.HttpRequest; |
||||
|
import cn.hutool.http.HttpResponse; |
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.shuili.common.exception.CustomException; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.HashMap; |
||||
|
|
||||
|
@Component |
||||
|
public class WaterRequestUtil { |
||||
|
|
||||
|
private static final Logger log = LoggerFactory.getLogger(WaterRequestUtil.class); |
||||
|
|
||||
|
@Value("${water.paasToken}") |
||||
|
public String paasToken; |
||||
|
@Value("${water.paasId}") |
||||
|
public String paasId; |
||||
|
//网关
|
||||
|
@Value("${water.url}") |
||||
|
public String url; |
||||
|
|
||||
|
//单点登录id
|
||||
|
@Value("${water.singOnServiceId}") |
||||
|
public String singOnServiceId; |
||||
|
//单点登录密钥
|
||||
|
@Value("${water.singOnAppsecret}") |
||||
|
public String singOnAppsecret; |
||||
|
@Value("${water.singOnUrl}") |
||||
|
public String singOnUrl; |
||||
|
|
||||
|
//验证用户登录
|
||||
|
@Value("${water.userUrl}") |
||||
|
public String userUrl; |
||||
|
@Value("${water.authUserServiceId}") |
||||
|
public String authUserServiceId; |
||||
|
@Value("${water.authUserAppsecret}") |
||||
|
public String authUserAppsecret; |
||||
|
@Value("${water.systemCode}") |
||||
|
public String systemCode; |
||||
|
@Value("${water.systemName}") |
||||
|
public String systemName; |
||||
|
|
||||
|
//获取部门信息
|
||||
|
@Value("${water.orgUrl}") |
||||
|
public String orgUrl; |
||||
|
@Value("${water.orgServiceId}") |
||||
|
public String orgServiceId; |
||||
|
@Value("${water.orgAppsecret}") |
||||
|
public String orgAppsecret; |
||||
|
|
||||
|
|
||||
|
//业务角色
|
||||
|
@Value("${water.roleUrl}") |
||||
|
public String roleUrl; |
||||
|
@Value("${water.roleServiceId}") |
||||
|
public String roleServiceId; |
||||
|
@Value("${water.roleAppsecret}") |
||||
|
public String roleAppsecret; |
||||
|
|
||||
|
|
||||
|
|
||||
|
@Value("${water.systemUrl}") |
||||
|
public String systemUrl; |
||||
|
@Value("${water.systemServiceId}") |
||||
|
public String systemServiceId; |
||||
|
@Value("${water.systemAppsecret}") |
||||
|
public String systemAppsecret; |
||||
|
|
||||
|
|
||||
|
@Value("${water.usersUrl}") |
||||
|
public String usersUrl; |
||||
|
@Value("${water.usersServiceId}") |
||||
|
public String usersServiceId; |
||||
|
@Value("${water.usersAppsecret}") |
||||
|
public String usersAppsecret; |
||||
|
|
||||
|
|
||||
|
@Value("${water.resourceUrl}") |
||||
|
public String resourceUrl; |
||||
|
@Value("${water.resourceServiceId}") |
||||
|
public String resourceServiceId; |
||||
|
@Value("${water.resourceAppsecret}") |
||||
|
public String resourceAppsecret; |
||||
|
|
||||
|
/** |
||||
|
* 设置 |
||||
|
* @param httpRequest |
||||
|
* @param serviceId |
||||
|
* @param appsecret |
||||
|
*/ |
||||
|
private void setHead(HttpRequest httpRequest,String serviceId,String appsecret){ |
||||
|
String timestamp = String.valueOf(new Date().getTime()); |
||||
|
String nonce = IdUtil.fastSimpleUUID(); |
||||
|
String signature = timestamp + paasToken + nonce + timestamp; |
||||
|
try { |
||||
|
signature = SHACoder.encodeSHA256Hex(signature).toUpperCase(); |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
httpRequest |
||||
|
.header("x-tsp-paasid",paasId) |
||||
|
.header("x-tsp-signature",signature) |
||||
|
.header("x-tsp-timestamp",timestamp) |
||||
|
.header("x-tsp-nonce", nonce) |
||||
|
.header("x-tsp-serviceid",serviceId) |
||||
|
.header("x-tsp-appsecret",appsecret); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public HttpRequest createGet(String url,String serviceId,String appsecret){ |
||||
|
HttpRequest httpRequest = HttpRequest.get(url); |
||||
|
setHead(httpRequest,serviceId,appsecret); |
||||
|
return httpRequest; |
||||
|
} |
||||
|
|
||||
|
public HttpRequest createPost(String url,String serviceId,String appsecret){ |
||||
|
HttpRequest httpRequest = HttpRequest.post(url); |
||||
|
setHead(httpRequest,serviceId,appsecret); |
||||
|
return httpRequest; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 业务系统 |
||||
|
* @return |
||||
|
*/ |
||||
|
public WaterResult systemPage(){ |
||||
|
log.info("查询业务系统-----------------"); |
||||
|
HttpRequest post = createPost(systemUrl, systemServiceId, systemAppsecret); |
||||
|
HashMap<String, String> query = new HashMap<>(); |
||||
|
query.put("code",systemCode); |
||||
|
query.put("name",systemName); |
||||
|
HttpResponse response = post.body(JSONObject.toJSONString(query)) |
||||
|
.execute(); |
||||
|
String body = response.body(); |
||||
|
WaterResult waterResult = JSONObject.parseObject(body, WaterResult.class); |
||||
|
isSuccess(waterResult); |
||||
|
//{
|
||||
|
// "msg": "操作成功",
|
||||
|
// "code": 200,
|
||||
|
// "data": {
|
||||
|
// "code": 200,
|
||||
|
// "message": "成功",
|
||||
|
// "success": true,
|
||||
|
// "data": "[{\"contractor\":\"数字广东网络建设有限公司\",\"code\":\"sgc-jg\",\"buildingLinkman\":\"张三\",\"contractorId\":\"1647768587123822593\",\"displayMobileFlag\":\"2\",\"manageUrl\":\"http://19.25.74.73:8001/\",\"type\":\"2\",\"building\":\"广东省水利厅\",\"developerId\":\"1732646766216482817\",\"developerPhone\":\"13333333333\",\"contractorPhone\":\"17324499124\",\"levelText\":\"省级\",\"buildingPhone\":\"13333333333\",\"id\":\"1732648267643097090\",\"manageImg\":\"{}\",\"area\":\"440000\",\"level\":\"1\",\"displayFlag\":\"1\",\"buildingId\":\"202206101718001\",\"createTime\":\"2023-12-07 06:28:33\",\"developerLinkman\":\"张三\",\"name\":\"水工程应用-水利工程建设管理模块\",\"publicUrl\":\"http://10.169.133.130:8001\",\"developer\":\"中通服建设有限公司\",\"contractorLinkman\":\"徐勇\",\"status\":\"1\"}]",
|
||||
|
// "timestamp": "1710140017747"
|
||||
|
// }
|
||||
|
//}
|
||||
|
return waterResult; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
// public static void main(String[] args) {
|
||||
|
// HttpRequest post = createPost("http://19.25.35.204:31190/data_center/gateway/api/usrc/open-api/system/list", "DGSP_1606199297580052481", "b26a1c7b95744369c00f65b7a0790b6");
|
||||
|
// HashMap<String, String> query = new HashMap<>();
|
||||
|
// query.put("code","sgc-jg");
|
||||
|
// query.put("name","水工程应用-水利工程建设管理模块");
|
||||
|
// HttpResponse response = post.body(JSONObject.toJSONString(query))
|
||||
|
// .execute();
|
||||
|
// String body = response.body();
|
||||
|
// WaterResult waterResult = JSONObject.parseObject(body, WaterResult.class);
|
||||
|
//
|
||||
|
// }
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 单点登录 |
||||
|
* @return |
||||
|
*/ |
||||
|
public WaterResult signOn(String userId){ |
||||
|
HttpRequest get = createGet(userUrl,singOnServiceId,singOnAppsecret); |
||||
|
HttpResponse response = get.header("x-tsp-target", paasId) |
||||
|
.header("x-tsp-uid-type", "id") |
||||
|
.header("x-tsp-uid", userId) |
||||
|
.execute(); |
||||
|
String body = response.body(); |
||||
|
return JSONObject.parseObject(body, WaterResult.class); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 验证用户登录 |
||||
|
* @param authorization |
||||
|
* @return |
||||
|
*/ |
||||
|
public WaterResult authUser(String authorization){ |
||||
|
log.info("--------请求统一门户用户验证,请求地址为:"+userUrl); |
||||
|
HttpRequest get = createGet(userUrl,authUserServiceId,authUserAppsecret); |
||||
|
HttpResponse response = get.header("Authorization", authorization) |
||||
|
.execute(); |
||||
|
String body = response.body(); |
||||
|
WaterResult waterResult = JSONObject.parseObject(body, WaterResult.class); |
||||
|
isSuccess(waterResult); |
||||
|
return waterResult; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public WaterResult getOrgPage(){ |
||||
|
log.info("--------请求获取门户组织信息,请求地址为:"+orgUrl); |
||||
|
HashMap<String, Object> hashMap = new HashMap<>(); |
||||
|
hashMap.put("page",1); |
||||
|
hashMap.put("size",100); |
||||
|
hashMap.put("systemCode",systemCode); |
||||
|
HttpRequest get = createPost(orgUrl,orgServiceId,orgAppsecret); |
||||
|
HttpResponse response = get.body(JSONObject.toJSONString(hashMap)) |
||||
|
.execute(); |
||||
|
String body = response.body(); |
||||
|
WaterResult waterResult = JSONObject.parseObject(body, WaterResult.class); |
||||
|
isSuccess(waterResult); |
||||
|
//{
|
||||
|
// "msg": "操作成功",
|
||||
|
// "code": 200,
|
||||
|
// "data": {
|
||||
|
// "code": 200,
|
||||
|
// "message": "成功",
|
||||
|
// "success": true,
|
||||
|
// "data": "{\"total\":4,\"size\":100,\"records\":[{\"parent\":\"202206101718001\",\"source\":\"tif\",\"type\":\"GA\",\"levelText\":\"省级\",\"id\":\"1646339896680984578\",\"area\":\"440000\",\"level\":\"1\",\"sourceText\":\"统一身份认证\",\"categoryText\":\"单位\",\"name\":\"水文局\",\"treeCode\":\"00030-00016\",\"status\":\"1\",\"code\":\"SJ0013\",\"orgId\":\"1646339896680984578\",\"tifld\":\"1232236\",\"seq\":18,\"areaText\":\"广东省\",\"updateTime\":\"2024-02-28 02:45:24\",\"createTime\":\"2023-04-13 02:29:54\",\"statusText\":\"启用\",\"category\":\"1\",\"crossParent\":\"\"},{\"parent\":\"0\",\"type\":\"FIRM\",\"levelText\":\"省级\",\"id\":\"1732646766216482817\",\"area\":\"440000\",\"level\":\"1\",\"categoryText\":\"单位\",\"name\":\"中通服建设有限公司\",\"treeCode\":\"00028\",\"status\":\"1\",\"code\":\"914400001903268010\",\"orgId\":\"1732646766216482817\",\"seq\":84,\"areaText\":\"广东省\",\"updateTime\":\"2023-12-11 18:05:29\",\"createTime\":\"2023-12-07 06:22:35\",\"statusText\":\"启用\",\"category\":\"1\"},{\"parent\":\"0\",\"natureText\":\"\",\"source\":\"input\",\"type\":\"GA\",\"levelText\":\"省级\",\"id\":\"202206101718001\",\"area\":\"440000\",\"level\":\"1\",\"sourceText\":\"手动创建\",\"categoryText\":\"单位\",\"name\":\"广东省水利厅\",\"treeCode\":\"00030\",\"status\":\"1\",\"code\":\"006941135\",\"abbrName\":\"水利厅\",\"uscc\":\"114400000069411352\",\"orgId\":\"202206101718001\",\"tifld\":\"114400000069411352\",\"seq\":67,\"nature\":\"1\",\"areaText\":\"广东省\",\"updateTime\":\"2024-02-28 02:45:24\",\"createTime\":\"2022-12-14 10:02:37\",\"statusText\":\"启用\",\"category\":\"1\",\"remarks\":\"默认机构,不可删除\"},{\"parent\":\"202206101718001\",\"source\":\"tif\",\"type\":\"GA\",\"deptTags\":\"noEntity\",\"levelText\":\"省级\",\"id\":\"1646339701234806785\",\"area\":\"440000\",\"level\":\"1\",\"sourceText\":\"统一身份认证\",\"categoryText\":\"部门\",\"name\":\"建设处\",\"treeCode\":\"00030-00044\",\"status\":\"1\",\"code\":\"SJ0001-024\",\"orgId\":\"1646339701234806785\",\"seq\":114,\"areaText\":\"广东省\",\"updateTime\":\"2024-01-08 18:47:31\",\"deptTagsText\":\"\",\"createTime\":\"2023-04-13 02:29:07\",\"statusText\":\"启用\",\"category\":\"2\",\"crossParent\":\"\"}],\"page\":1}",
|
||||
|
// "timestamp": "1710140677104"
|
||||
|
// }
|
||||
|
//}
|
||||
|
return waterResult; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public WaterResult getUserResource(String authorization){ |
||||
|
log.info("--------请求获取门户角色信息,请求地址为:"+resourceUrl); |
||||
|
HashMap<String, Object> hashMap = new HashMap<>(); |
||||
|
hashMap.put("systemCode",systemCode); |
||||
|
HttpRequest get = createPost(resourceUrl+"?systemCode="+systemCode,resourceServiceId,resourceAppsecret); |
||||
|
// HttpRequest get = createPost(resourceUrl,resourceServiceId,resourceAppsecret);
|
||||
|
get.header("Authorization",authorization); |
||||
|
HttpResponse response = get |
||||
|
.execute(); |
||||
|
String body = response.body(); |
||||
|
WaterResult waterResult = JSONObject.parseObject(body, WaterResult.class); |
||||
|
isSuccess(waterResult); |
||||
|
//{\"total\":1,\"size\":100,\"records\":[{\"area\":\"440000\",\"systemList\":[{\"area\":\"440000\",\"code\":\"sgc-jg\",\"name\":\"水工程应用-水利工程建设管理模块\",\"id\":\"1732648267643097090\"}],\"code\":\"YW00013\",\"level\":\"1d\",\"dataConfig\":\"none\",\"type\":\"BUSINESS\",\"posts\":[],\"users\":[{\"id\":\"20231225000006\"},{\"id\":\"20240119000002\"}],\"name\":\"水利工程应用-水利工程建设管理模块角色\",\"id\":\"20231213000001\",\"category\":\"BUSINESS\",\"businesses\":[{\"parent\":\"1762458920822599682\",\"businessCode\":\"YWSLGCJSGL0008\",\"parentName\":\"水利工程建设管理\",\"businessName\":\"水利工程建设管理\",\"description\":\"\",\"id\":\"1705128209926942721\",\"delFlag\":0}],\"status\":\"1\"}],\"page\":1}
|
||||
|
return waterResult; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public WaterResult getRolePage(){ |
||||
|
log.info("--------请求获取门户角色信息,请求地址为:"+roleUrl); |
||||
|
HashMap<String, Object> hashMap = new HashMap<>(); |
||||
|
hashMap.put("page",1); |
||||
|
hashMap.put("size",100); |
||||
|
hashMap.put("systemCode",systemCode); |
||||
|
HttpRequest get = createPost(roleUrl,roleServiceId,roleAppsecret); |
||||
|
HttpResponse response = get.body(JSONObject.toJSONString(hashMap)) |
||||
|
.execute(); |
||||
|
String body = response.body(); |
||||
|
WaterResult waterResult = JSONObject.parseObject(body, WaterResult.class); |
||||
|
isSuccess(waterResult); |
||||
|
//{\"total\":1,\"size\":100,\"records\":[{\"area\":\"440000\",\"systemList\":[{\"area\":\"440000\",\"code\":\"sgc-jg\",\"name\":\"水工程应用-水利工程建设管理模块\",\"id\":\"1732648267643097090\"}],\"code\":\"YW00013\",\"level\":\"1d\",\"dataConfig\":\"none\",\"type\":\"BUSINESS\",\"posts\":[],\"users\":[{\"id\":\"20231225000006\"},{\"id\":\"20240119000002\"}],\"name\":\"水利工程应用-水利工程建设管理模块角色\",\"id\":\"20231213000001\",\"category\":\"BUSINESS\",\"businesses\":[{\"parent\":\"1762458920822599682\",\"businessCode\":\"YWSLGCJSGL0008\",\"parentName\":\"水利工程建设管理\",\"businessName\":\"水利工程建设管理\",\"description\":\"\",\"id\":\"1705128209926942721\",\"delFlag\":0}],\"status\":\"1\"}],\"page\":1}
|
||||
|
return waterResult; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public WaterResult usersPage(){ |
||||
|
log.info("--------请求获取门户用户信息,请求地址为:"+usersUrl); |
||||
|
HashMap<String, Object> hashMap = new HashMap<>(); |
||||
|
hashMap.put("page",1); |
||||
|
hashMap.put("size",100); |
||||
|
hashMap.put("systemCode",systemCode); |
||||
|
HttpRequest get = createPost(usersUrl,usersServiceId,usersAppsecret); |
||||
|
HttpResponse response = get.body(JSONObject.toJSONString(hashMap)) |
||||
|
.execute(); |
||||
|
String body = response.body(); |
||||
|
WaterResult waterResult = JSONObject.parseObject(body, WaterResult.class); |
||||
|
isSuccess(waterResult); |
||||
|
return waterResult; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
private void isSuccess(WaterResult waterResult){ |
||||
|
if(waterResult==null){ |
||||
|
throw new CustomException("请求异常"); |
||||
|
} |
||||
|
if(waterResult.getCode()!=200||!waterResult.getSuccess()){ |
||||
|
throw new CustomException("请求失败,原因:"+waterResult.getMessage()); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,27 @@ |
|||||
|
package com.kms.web.utils; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
public class WaterResult { |
||||
|
|
||||
|
private int code; |
||||
|
private String message; |
||||
|
private Boolean success; |
||||
|
private String data; |
||||
|
private String timestamp; |
||||
|
|
||||
|
|
||||
|
public static WaterResult success(){ |
||||
|
WaterResult waterResult = new WaterResult(); |
||||
|
waterResult.setCode(200); |
||||
|
waterResult.setSuccess(true); |
||||
|
waterResult.setTimestamp(String.valueOf(System.currentTimeMillis())); |
||||
|
waterResult.setMessage("发布成功"); |
||||
|
return waterResult; |
||||
|
} |
||||
|
} |
@ -0,0 +1,215 @@ |
|||||
|
package com.kms.web.utils.scheduled; |
||||
|
|
||||
|
import com.alibaba.fastjson.JSONObject; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import com.kms.system.service.SysDeptService; |
||||
|
import com.kms.system.service.SysRoleService; |
||||
|
import com.kms.system.service.SysUserService; |
||||
|
import com.kms.web.controller.system.SysRoleController; |
||||
|
import com.kms.web.utils.WaterRequestUtil; |
||||
|
import com.kms.web.utils.WaterResult; |
||||
|
import com.kms.web.utils.singleDomain.SingleOrg; |
||||
|
import com.kms.web.utils.singleDomain.SingleRole; |
||||
|
import com.kms.web.utils.singleDomain.SingleUser; |
||||
|
import com.shuili.common.constant.UserConstants; |
||||
|
import com.shuili.common.core.domain.entity.SysDept; |
||||
|
import com.shuili.common.core.domain.entity.SysRole; |
||||
|
import com.shuili.common.core.domain.entity.SysUser; |
||||
|
import com.shuili.common.utils.password.MD5Util; |
||||
|
import com.shuili.common.utils.password.PasswordUtil; |
||||
|
import com.shuili.common.utils.uuid.IdUtils; |
||||
|
import org.slf4j.Logger; |
||||
|
import org.slf4j.LoggerFactory; |
||||
|
import org.springframework.beans.BeanUtils; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.context.annotation.Configuration; |
||||
|
import org.springframework.scheduling.annotation.Scheduled; |
||||
|
|
||||
|
import java.util.Date; |
||||
|
import java.util.List; |
||||
|
import java.util.stream.Collectors; |
||||
|
|
||||
|
@Configuration |
||||
|
public class WaterScheduled { |
||||
|
|
||||
|
private static final Logger log = LoggerFactory.getLogger(WaterScheduled.class); |
||||
|
|
||||
|
@Autowired |
||||
|
WaterRequestUtil waterRequestUtil; |
||||
|
|
||||
|
@Autowired |
||||
|
SysUserService userService; |
||||
|
@Autowired |
||||
|
SysDeptService deptService; |
||||
|
@Autowired |
||||
|
SysRoleController roleController; |
||||
|
@Autowired |
||||
|
SysRoleService roleService; |
||||
|
|
||||
|
|
||||
|
// @Scheduled(cron = "0 * * * * ?")
|
||||
|
@Scheduled(cron = "0 0/10 * * * ? ") |
||||
|
public void userScheduled(){ |
||||
|
log.info("----------------------开始执行用户同步功能----------------------------"); |
||||
|
WaterResult waterResult = waterRequestUtil.usersPage(); |
||||
|
String data = waterResult.getData(); |
||||
|
String records = JSONObject.parseObject(data).getString("records"); |
||||
|
List<SingleUser> singleUserList = JSONObject.parseArray(records, SingleUser.class); |
||||
|
for (SingleUser singleUser : singleUserList) { |
||||
|
String id = singleUser.getId(); |
||||
|
QueryWrapper<SysUser> query = Wrappers.query(); |
||||
|
query.eq("single_user_id",id); |
||||
|
SysUser user = userService.getOne(query,false); |
||||
|
Boolean flag = (user==null); |
||||
|
if(flag){ |
||||
|
user = new SysUser(); |
||||
|
user.preInsert(); |
||||
|
user.setCreateUid("1"); |
||||
|
user.setUpdateUid("1"); |
||||
|
user.setRemark("门户定时任务数据添加"); |
||||
|
user.setId(IdUtils.fastSimpleUUID()); |
||||
|
user.setIsPcUser("0"); |
||||
|
user.setDelFlag("0"); |
||||
|
// user.setUserType("00");
|
||||
|
user.setMd5(MD5Util.MD5Encode(singleUser.toString(), "utf-8")); |
||||
|
}else { |
||||
|
String md = MD5Util.MD5Encode(singleUser.toString(), "utf-8"); |
||||
|
if(user.getMd5()!=null&&md.equals(user.getMd5())){ |
||||
|
continue; |
||||
|
} |
||||
|
} |
||||
|
SingleOrg org = singleUser.getOrg(); |
||||
|
if(org!=null){ |
||||
|
user.setDeptId(org.getId()); |
||||
|
user.setDeptId(org.getId()); |
||||
|
String orgType = org.getType(); |
||||
|
if(orgType.equals("GA")){ //政务
|
||||
|
user.setUserType("00"); |
||||
|
}else if(orgType.equals("SVA")){ //服务
|
||||
|
user.setUserType("01"); |
||||
|
} |
||||
|
} |
||||
|
user.setPhonenumber(singleUser.getPhone()); |
||||
|
user.setNickName(singleUser.getName()); |
||||
|
user.setUserName(singleUser.getUsername()); |
||||
|
user.setSingleUserSource(singleUser.getSource()); |
||||
|
user.setSingleUserType(singleUser.getType()); |
||||
|
user.setSingleUserId(singleUser.getId()); |
||||
|
user.setPassword(PasswordUtil.entryptPassword(singleUser.getUsername())); |
||||
|
user.setIsFirst(singleUser.getFirstSignIn().toString()); |
||||
|
if(singleUser.getStatus()==null||singleUser.getStatus().equals("1")){ |
||||
|
user.setStatus("0"); |
||||
|
}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); |
||||
|
}else { |
||||
|
userService.updateUser(user); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
@Scheduled(cron = "0 0/10 * * * ? ") |
||||
|
public void orgScheduled(){ |
||||
|
log.info("----------------------开始执行部门同步功能----------------------------"); |
||||
|
WaterResult waterResult = waterRequestUtil.getOrgPage(); |
||||
|
String data = waterResult.getData(); |
||||
|
String records = JSONObject.parseObject(data).getString("records"); |
||||
|
List<SingleOrg> singleOrgs = JSONObject.parseArray(records, SingleOrg.class); |
||||
|
for (SingleOrg singleOrg : singleOrgs) { |
||||
|
SysDept dept = deptService.getById(singleOrg.getId()); |
||||
|
boolean flag = (dept!=null); |
||||
|
if(flag){ |
||||
|
String md = MD5Util.MD5Encode(singleOrg.toString(), "utf-8"); |
||||
|
if(dept.getMd5()!=null&&md.equals(dept.getMd5())){ |
||||
|
continue; |
||||
|
} |
||||
|
}else { |
||||
|
dept = new SysDept(); |
||||
|
dept.setCreateUid("1"); |
||||
|
dept.setUpdateUid("1"); |
||||
|
dept.setRemark("门户定时任务数据添加"); |
||||
|
dept.setIsDownload("0"); |
||||
|
dept.setIsComment("0"); |
||||
|
dept.setDelFlag("0"); |
||||
|
dept.setCreateTime(new Date()); |
||||
|
String md = MD5Util.MD5Encode(singleOrg.toString(), "utf-8"); |
||||
|
dept.setMd5(md); |
||||
|
} |
||||
|
dept.setMd5(MD5Util.MD5Encode(singleOrg.toString(), "utf-8")); |
||||
|
BeanUtils.copyProperties(singleOrg,dept); |
||||
|
dept.setXzqhId(singleOrg.getArea()); |
||||
|
dept.setXzqhName(singleOrg.getAreaText()); |
||||
|
dept.setSingleCode(singleOrg.getCode()); |
||||
|
dept.setSingleSeq(singleOrg.getSeq()); |
||||
|
dept.setSingleType(singleOrg.getType()); |
||||
|
dept.setDeptName(singleOrg.getName()); |
||||
|
dept.setParentId(singleOrg.getParent()); |
||||
|
dept.setLeader(singleOrg.getDutyPerson()); |
||||
|
dept.setName(singleOrg.getName()); |
||||
|
dept.setAdminName(singleOrg.getName()); |
||||
|
dept.setUpdateTime(new Date()); |
||||
|
if(singleOrg.getStatus()==null||singleOrg.getStatus().equals("1")){ |
||||
|
dept.setStatus("0"); |
||||
|
}else { |
||||
|
dept.setStatus("1"); |
||||
|
} |
||||
|
if (UserConstants.NOT_UNIQUE.equals(deptService.checkDeptNameUnique(dept))) |
||||
|
{ |
||||
|
log.error("新增部门'" + dept.getDeptName() + "'失败,部门名称已存在"); |
||||
|
} |
||||
|
if(flag){ |
||||
|
deptService.updateById(dept); |
||||
|
}else { |
||||
|
deptService.save(dept); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
@Scheduled(cron = "0 0/10 * * * ? ") |
||||
|
public void roleScheduled(){ |
||||
|
log.info("----------------------开始执行角色同步功能----------------------------"); |
||||
|
WaterResult rolePage = waterRequestUtil.getRolePage(); |
||||
|
String data = rolePage.getData(); |
||||
|
String records = JSONObject.parseObject(data).getString("records"); |
||||
|
List<SingleRole> singleRoles = JSONObject.parseArray(records, SingleRole.class); |
||||
|
for (SingleRole singleRole : singleRoles) { |
||||
|
SysRole sysRole = roleService.getById(singleRole.getId()); |
||||
|
if(sysRole!=null){ |
||||
|
String md = MD5Util.MD5Encode(singleRole.toString(), "utf-8"); |
||||
|
if(sysRole.getMd5()!=null&&md.equals(sysRole.getMd5())){ |
||||
|
continue; |
||||
|
} |
||||
|
sysRole.setMd5(MD5Util.MD5Encode(singleRole.toString(), "utf-8")); |
||||
|
BeanUtils.copyProperties(singleRole,sysRole); |
||||
|
sysRole.setRoleName(singleRole.getName()); |
||||
|
sysRole.setRoleKey(singleRole.getCode()); |
||||
|
sysRole.setUpdateTime(new Date()); |
||||
|
roleService.updateById(sysRole); |
||||
|
}else { |
||||
|
sysRole = new SysRole(); |
||||
|
sysRole.preInsert(); |
||||
|
sysRole.setStatus("0"); |
||||
|
sysRole.setDelFlag("0"); |
||||
|
sysRole.setRoleSort("0"); |
||||
|
sysRole.setCreateUid("1"); |
||||
|
sysRole.setUpdateUid("1"); |
||||
|
sysRole.setRemark("门户定时任务数据添加"); |
||||
|
sysRole.setMd5(MD5Util.MD5Encode(singleRole.toString(), "utf-8")); |
||||
|
BeanUtils.copyProperties(singleRole,sysRole); |
||||
|
sysRole.setRoleName(singleRole.getName()); |
||||
|
sysRole.setRoleKey(singleRole.getCode()); |
||||
|
roleService.save(sysRole); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.kms.web.utils.singleDomain; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Data |
||||
|
public class SingleMenu { |
||||
|
|
||||
|
private String systemId; |
||||
|
private String code; //菜单标识
|
||||
|
private String visible; //是否可见 1可见 0不可见
|
||||
|
private String icon; //菜单图标
|
||||
|
private String pid; |
||||
|
private String type; |
||||
|
private String path; //路径
|
||||
|
private String name; //资源名称
|
||||
|
private String id; |
||||
|
private String iframe;//是否外链
|
||||
|
private Integer seq; //排序
|
||||
|
private String status; //状态 1启用 0停用
|
||||
|
private String permissionCode; //权限标识
|
||||
|
private List<SingleMenu> children; |
||||
|
|
||||
|
} |
@ -0,0 +1,387 @@ |
|||||
|
package com.kms.web.utils.singleDomain; |
||||
|
|
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
@NoArgsConstructor |
||||
|
public class SingleOrg { |
||||
|
|
||||
|
private String address; //机构地址
|
||||
|
private String area; //机构区域
|
||||
|
private String areaText; //机构区域描述
|
||||
|
private String businessScope; //业务范围
|
||||
|
private String category;//机构类别(单位、部门)
|
||||
|
private String categoryText;//单位、部门
|
||||
|
private String code;//机构代码
|
||||
|
private String parent;//同级父级机构ID
|
||||
|
private String crossParent; //跨级父级机构ID
|
||||
|
private String donaQualif;//是否具有公开募捐资格(字典)
|
||||
|
private String name;//机构名称
|
||||
|
private String nature;//机构性质
|
||||
|
private String natureText;//机构性质描述
|
||||
|
private String level;//机构级别
|
||||
|
private String levelText;//机构级别名称
|
||||
|
private String record;//是否备案
|
||||
|
private String dutyPerson; //机构负责人
|
||||
|
private String foundDate; //成立时间
|
||||
|
private String registerDate;//登记日期
|
||||
|
private String manageOrg;//登记管理机关
|
||||
|
private String dutyPersonPhone;//负责人联系方式
|
||||
|
private String expiryDate;//机构有效期
|
||||
|
|
||||
|
private String target;//组织建设目标
|
||||
|
private String promoter;//发起人
|
||||
|
private String promoterPhone;//发起人联系方式
|
||||
|
private String source;//机构来源
|
||||
|
private String volunteerNum;//志愿者人数
|
||||
|
private String tel;//座机电话
|
||||
|
private String businessTime;//营业时间
|
||||
|
|
||||
|
private String map;//机构经纬度信息
|
||||
|
private String tifld;//统一社会信用代码
|
||||
|
private String uscc;//统一身份认证关联id
|
||||
|
|
||||
|
private String govOrgId;//监管部门/发起单位Id
|
||||
|
private String govOrgName;//监管部门/发起单位名称
|
||||
|
|
||||
|
private String legalPerson;//法定代表人
|
||||
|
private String legalPersonNo;//法定代表人身份证
|
||||
|
private String legalPersonPhone;//法定代表人联系电话
|
||||
|
|
||||
|
private String seq; |
||||
|
private String type; //类型
|
||||
|
private String id; |
||||
|
private String status; |
||||
|
|
||||
|
public String getAddress() { |
||||
|
return address; |
||||
|
} |
||||
|
|
||||
|
public void setAddress(String address) { |
||||
|
this.address = address; |
||||
|
} |
||||
|
|
||||
|
public String getArea() { |
||||
|
return area; |
||||
|
} |
||||
|
|
||||
|
public void setArea(String area) { |
||||
|
this.area = area; |
||||
|
} |
||||
|
|
||||
|
public String getAreaText() { |
||||
|
return areaText; |
||||
|
} |
||||
|
|
||||
|
public void setAreaText(String areaText) { |
||||
|
this.areaText = areaText; |
||||
|
} |
||||
|
|
||||
|
public String getBusinessScope() { |
||||
|
return businessScope; |
||||
|
} |
||||
|
|
||||
|
public void setBusinessScope(String businessScope) { |
||||
|
this.businessScope = businessScope; |
||||
|
} |
||||
|
|
||||
|
public String getCategory() { |
||||
|
return category; |
||||
|
} |
||||
|
|
||||
|
public void setCategory(String category) { |
||||
|
this.category = category; |
||||
|
} |
||||
|
|
||||
|
public String getCategoryText() { |
||||
|
return categoryText; |
||||
|
} |
||||
|
|
||||
|
public void setCategoryText(String categoryText) { |
||||
|
this.categoryText = categoryText; |
||||
|
} |
||||
|
|
||||
|
public String getCode() { |
||||
|
return code; |
||||
|
} |
||||
|
|
||||
|
public void setCode(String code) { |
||||
|
this.code = code; |
||||
|
} |
||||
|
|
||||
|
public String getParent() { |
||||
|
return parent; |
||||
|
} |
||||
|
|
||||
|
public void setParent(String parent) { |
||||
|
this.parent = parent; |
||||
|
} |
||||
|
|
||||
|
public String getCrossParent() { |
||||
|
return crossParent; |
||||
|
} |
||||
|
|
||||
|
public void setCrossParent(String crossParent) { |
||||
|
this.crossParent = crossParent; |
||||
|
} |
||||
|
|
||||
|
public String getDonaQualif() { |
||||
|
return donaQualif; |
||||
|
} |
||||
|
|
||||
|
public void setDonaQualif(String donaQualif) { |
||||
|
this.donaQualif = donaQualif; |
||||
|
} |
||||
|
|
||||
|
public String getName() { |
||||
|
return name; |
||||
|
} |
||||
|
|
||||
|
public void setName(String name) { |
||||
|
this.name = name; |
||||
|
} |
||||
|
|
||||
|
public String getNature() { |
||||
|
return nature; |
||||
|
} |
||||
|
|
||||
|
public void setNature(String nature) { |
||||
|
this.nature = nature; |
||||
|
} |
||||
|
|
||||
|
public String getNatureText() { |
||||
|
return natureText; |
||||
|
} |
||||
|
|
||||
|
public void setNatureText(String natureText) { |
||||
|
this.natureText = natureText; |
||||
|
} |
||||
|
|
||||
|
public String getLevel() { |
||||
|
return level; |
||||
|
} |
||||
|
|
||||
|
public void setLevel(String level) { |
||||
|
this.level = level; |
||||
|
} |
||||
|
|
||||
|
public String getLevelText() { |
||||
|
return levelText; |
||||
|
} |
||||
|
|
||||
|
public void setLevelText(String levelText) { |
||||
|
this.levelText = levelText; |
||||
|
} |
||||
|
|
||||
|
public String getRecord() { |
||||
|
return record; |
||||
|
} |
||||
|
|
||||
|
public void setRecord(String record) { |
||||
|
this.record = record; |
||||
|
} |
||||
|
|
||||
|
public String getDutyPerson() { |
||||
|
return dutyPerson; |
||||
|
} |
||||
|
|
||||
|
public void setDutyPerson(String dutyPerson) { |
||||
|
this.dutyPerson = dutyPerson; |
||||
|
} |
||||
|
|
||||
|
public String getFoundDate() { |
||||
|
return foundDate; |
||||
|
} |
||||
|
|
||||
|
public void setFoundDate(String foundDate) { |
||||
|
this.foundDate = foundDate; |
||||
|
} |
||||
|
|
||||
|
public String getRegisterDate() { |
||||
|
return registerDate; |
||||
|
} |
||||
|
|
||||
|
public void setRegisterDate(String registerDate) { |
||||
|
this.registerDate = registerDate; |
||||
|
} |
||||
|
|
||||
|
public String getManageOrg() { |
||||
|
return manageOrg; |
||||
|
} |
||||
|
|
||||
|
public void setManageOrg(String manageOrg) { |
||||
|
this.manageOrg = manageOrg; |
||||
|
} |
||||
|
|
||||
|
public String getDutyPersonPhone() { |
||||
|
return dutyPersonPhone; |
||||
|
} |
||||
|
|
||||
|
public void setDutyPersonPhone(String dutyPersonPhone) { |
||||
|
this.dutyPersonPhone = dutyPersonPhone; |
||||
|
} |
||||
|
|
||||
|
public String getExpiryDate() { |
||||
|
return expiryDate; |
||||
|
} |
||||
|
|
||||
|
public void setExpiryDate(String expiryDate) { |
||||
|
this.expiryDate = expiryDate; |
||||
|
} |
||||
|
|
||||
|
public String getTarget() { |
||||
|
return target; |
||||
|
} |
||||
|
|
||||
|
public void setTarget(String target) { |
||||
|
this.target = target; |
||||
|
} |
||||
|
|
||||
|
public String getPromoter() { |
||||
|
return promoter; |
||||
|
} |
||||
|
|
||||
|
public void setPromoter(String promoter) { |
||||
|
this.promoter = promoter; |
||||
|
} |
||||
|
|
||||
|
public String getPromoterPhone() { |
||||
|
return promoterPhone; |
||||
|
} |
||||
|
|
||||
|
public void setPromoterPhone(String promoterPhone) { |
||||
|
this.promoterPhone = promoterPhone; |
||||
|
} |
||||
|
|
||||
|
public String getSource() { |
||||
|
return source; |
||||
|
} |
||||
|
|
||||
|
public void setSource(String source) { |
||||
|
this.source = source; |
||||
|
} |
||||
|
|
||||
|
public String getVolunteerNum() { |
||||
|
return volunteerNum; |
||||
|
} |
||||
|
|
||||
|
public void setVolunteerNum(String volunteerNum) { |
||||
|
this.volunteerNum = volunteerNum; |
||||
|
} |
||||
|
|
||||
|
public String getTel() { |
||||
|
return tel; |
||||
|
} |
||||
|
|
||||
|
public void setTel(String tel) { |
||||
|
this.tel = tel; |
||||
|
} |
||||
|
|
||||
|
public String getBusinessTime() { |
||||
|
return businessTime; |
||||
|
} |
||||
|
|
||||
|
public void setBusinessTime(String businessTime) { |
||||
|
this.businessTime = businessTime; |
||||
|
} |
||||
|
|
||||
|
public String getMap() { |
||||
|
return map; |
||||
|
} |
||||
|
|
||||
|
public void setMap(String map) { |
||||
|
this.map = map; |
||||
|
} |
||||
|
|
||||
|
public String getTifld() { |
||||
|
return tifld; |
||||
|
} |
||||
|
|
||||
|
public void setTifld(String tifld) { |
||||
|
this.tifld = tifld; |
||||
|
} |
||||
|
|
||||
|
public String getUscc() { |
||||
|
return uscc; |
||||
|
} |
||||
|
|
||||
|
public void setUscc(String uscc) { |
||||
|
this.uscc = uscc; |
||||
|
} |
||||
|
|
||||
|
public String getGovOrgId() { |
||||
|
return govOrgId; |
||||
|
} |
||||
|
|
||||
|
public void setGovOrgId(String govOrgId) { |
||||
|
this.govOrgId = govOrgId; |
||||
|
} |
||||
|
|
||||
|
public String getGovOrgName() { |
||||
|
return govOrgName; |
||||
|
} |
||||
|
|
||||
|
public void setGovOrgName(String govOrgName) { |
||||
|
this.govOrgName = govOrgName; |
||||
|
} |
||||
|
|
||||
|
public String getLegalPerson() { |
||||
|
return legalPerson; |
||||
|
} |
||||
|
|
||||
|
public void setLegalPerson(String legalPerson) { |
||||
|
this.legalPerson = legalPerson; |
||||
|
} |
||||
|
|
||||
|
public String getLegalPersonNo() { |
||||
|
return legalPersonNo; |
||||
|
} |
||||
|
|
||||
|
public void setLegalPersonNo(String legalPersonNo) { |
||||
|
this.legalPersonNo = legalPersonNo; |
||||
|
} |
||||
|
|
||||
|
public String getLegalPersonPhone() { |
||||
|
return legalPersonPhone; |
||||
|
} |
||||
|
|
||||
|
public void setLegalPersonPhone(String legalPersonPhone) { |
||||
|
this.legalPersonPhone = legalPersonPhone; |
||||
|
} |
||||
|
|
||||
|
public String getSeq() { |
||||
|
return seq; |
||||
|
} |
||||
|
|
||||
|
public void setSeq(String seq) { |
||||
|
this.seq = seq; |
||||
|
} |
||||
|
|
||||
|
public String getType() { |
||||
|
return type; |
||||
|
} |
||||
|
|
||||
|
public void setType(String type) { |
||||
|
this.type = type; |
||||
|
} |
||||
|
|
||||
|
public String getId() { |
||||
|
return id; |
||||
|
} |
||||
|
|
||||
|
public void setId(String id) { |
||||
|
this.id = id; |
||||
|
} |
||||
|
|
||||
|
public String getStatus() { |
||||
|
return status; |
||||
|
} |
||||
|
|
||||
|
public void setStatus(String status) { |
||||
|
this.status = status; |
||||
|
} |
||||
|
} |
@ -0,0 +1,25 @@ |
|||||
|
package com.kms.web.utils.singleDomain; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
@Data |
||||
|
@AllArgsConstructor |
||||
|
public class SingleRole { |
||||
|
|
||||
|
private String id; |
||||
|
private String area; |
||||
|
private String systemList; |
||||
|
private String code; |
||||
|
private String level; |
||||
|
private String dataConfig; |
||||
|
private String type; |
||||
|
private String category; |
||||
|
|
||||
|
private String posts; |
||||
|
private String users; |
||||
|
private String name; |
||||
|
private String businesses; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,26 @@ |
|||||
|
package com.kms.web.utils.singleDomain; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
@Data |
||||
|
public class SingleUser { |
||||
|
|
||||
|
private String id; |
||||
|
private String source; |
||||
|
private String type; |
||||
|
private Long seq; |
||||
|
private Integer firstSignIn; |
||||
|
private SingleOrg org; |
||||
|
private Boolean isPartTimeUser; |
||||
|
private List<SingleRole> roleList; |
||||
|
private List<SingleOrg> deptList; |
||||
|
private List<SingleOrg> orgs; |
||||
|
private String phone; |
||||
|
private String name; |
||||
|
private String status; |
||||
|
private String username; |
||||
|
|
||||
|
|
||||
|
} |
@ -1,5 +1,6 @@ |
|||||
spring: |
spring: |
||||
profiles: |
profiles: |
||||
# include: dev,druid-dev |
# include: dev,druid-dev |
||||
include: sy,druid-sy |
# include: sy,druid-sy |
||||
# include: zhishiku,druid-zhishiku |
# include: zhishiku,druid-zhishiku |
||||
|
include: test,druid-test |
||||
|
Loading…
Reference in new issue