Merge branch 'dev' into kone_dev
This commit is contained in:
commit
e9bc9e8257
|
|
@ -35,6 +35,14 @@
|
|||
<version>20160810</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.ruoyi</groupId>
|
||||
<artifactId>ruoyi-system</artifactId>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,165 @@
|
|||
package com.ruoyi.test.conrtroller;
|
||||
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.domain.entity.SysDept;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.system.domain.EcologyDept;
|
||||
import com.ruoyi.system.mapper.SysDeptMapper;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@RestController
|
||||
public class GetEcologyInfoTestController extends BaseController {
|
||||
@Autowired
|
||||
private SysDeptMapper deptMapper;
|
||||
@Autowired
|
||||
private ISysUserService userService;
|
||||
|
||||
@RequestMapping("/anon/getEcologyDept")
|
||||
public String getEcologyDept() throws Exception {
|
||||
String url="http://192.168.2.85:90/api/hrm/resful/getHrmdepartmentWithPage";
|
||||
String params="{\"params\":{\"pagesize\":1000}}";
|
||||
//return sendPost(url,params);
|
||||
return deptSync(HttpUtils.sendPostWithRest(url,params));
|
||||
|
||||
}
|
||||
|
||||
@RequestMapping("/anon/getEcologyUser")
|
||||
public String getEcologyUser(){
|
||||
String url="http://192.168.2.85:90/api/hrm/resful/getHrmUserInfoWithPage";
|
||||
String params="{\"params\":{\"pagesize\":999999}}";
|
||||
int result = userService.syncEcologyUser(url,params);
|
||||
if(result==200){
|
||||
return "同步成功";
|
||||
}
|
||||
return "同步失败";
|
||||
}
|
||||
|
||||
/*public Map<String,String> sendPostWithRest(String url,String params){
|
||||
RestTemplate restTemplate=new RestTemplate();
|
||||
ResponseEntity<String> result=null;
|
||||
int statusCode=0;
|
||||
try{
|
||||
result=restTemplate.postForEntity(url,params,String.class);
|
||||
statusCode=result.getStatusCode().value();
|
||||
}catch (RestClientException e){
|
||||
System.out.println("POST Request uri: "+url+", params:"+params+" error:"+e.getMessage());
|
||||
}
|
||||
Map<String,String> map=new HashMap<>();
|
||||
map.put("statusCode",String.valueOf(statusCode));
|
||||
if(statusCode== 200){
|
||||
map.put("result",result.getBody());
|
||||
} else{
|
||||
map.put("result",String.valueOf(statusCode));
|
||||
}
|
||||
|
||||
return map;
|
||||
}*/
|
||||
|
||||
public SysDept insertEcologyDept(EcologyDept ecologyDept){
|
||||
SysDept dept=new SysDept();
|
||||
dept.setDeptId(Long.parseLong(ecologyDept.getId()));
|
||||
dept.setParentId(Long.parseLong(ecologyDept.getSupdepid()) == 0 ? 999999 : Long.parseLong(ecologyDept.getSupdepid()));
|
||||
dept.setDeptName(ecologyDept.getDepartmentname());
|
||||
//dept.setAncestors(pAncestors);
|
||||
dept.setOrderNum("0");
|
||||
dept.setStatus("0");
|
||||
dept.setCreateBy("Admin");
|
||||
deptMapper.insertDept(dept);
|
||||
return dept;
|
||||
}
|
||||
|
||||
public void updateAncestors(List<SysDept> sysDeptList)
|
||||
{
|
||||
if(sysDeptList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<SysDept> list =new ArrayList<>();
|
||||
for(SysDept dept:sysDeptList){
|
||||
SysDept info = deptMapper.selectDeptById(dept.getParentId());
|
||||
if(StringUtils.isNotEmpty(info.getAncestors())) {
|
||||
dept.setAncestors(info.getAncestors()+","+dept.getParentId());
|
||||
deptMapper.updateDept(dept);
|
||||
}else{
|
||||
list.add(dept);
|
||||
}
|
||||
}
|
||||
updateAncestors(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String deptSync(Map<String,String> mapResult){
|
||||
//如果接口返回状态码不为200,则不做同步处理
|
||||
String statusCode=mapResult.get("statusCode");
|
||||
String result= mapResult.get("result");
|
||||
if(!statusCode.equals("200"))
|
||||
{
|
||||
return mapResult.get("result");
|
||||
}
|
||||
//取Ecology返回信息中的部门信息
|
||||
Map<String,Object> map = (Map) JSON.parse(result);
|
||||
Map<String,Object> o= (Map<String, Object>) map.get("data");
|
||||
JSONArray json = (JSONArray) o.get("dataList");
|
||||
List<EcologyDept> depts = JSONArray.parseArray(json.toJSONString(), EcologyDept.class);
|
||||
|
||||
//清空部门表,并插入顶级部门
|
||||
SysDept sysDept=deptMapper.selectDeptById(Long.parseLong("999999"));
|
||||
deptMapper.truncateDept();
|
||||
deptMapper.insertDept(sysDept);
|
||||
List<SysDept> list=new ArrayList<>();
|
||||
//同步Ecology部门信息
|
||||
for(EcologyDept ecologyDept:depts){
|
||||
if(ecologyDept.getSubcompanyid1().equals("1")) { //只取分部ID为“1”的部门,排除代理商
|
||||
/* String pAncestors=null;
|
||||
if(ecologyDept.getSupdepid().equals("0")){ //如果Ecology部门为一级部门,则设定ancestors="0,999999"
|
||||
pAncestors="0,999999";
|
||||
}*/
|
||||
SysDept dept= insertEcologyDept(ecologyDept);
|
||||
list.add(dept);
|
||||
}
|
||||
}
|
||||
//更新祖级信息
|
||||
updateAncestors(list);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/* public String sendPost(String url,String params) throws Exception {
|
||||
RestTemplate restTemplate=new RestTemplate();
|
||||
ResponseEntity<String> result = null;
|
||||
int statusCode = 0;
|
||||
try {
|
||||
result = restTemplate.postForEntity(url, params, String.class);
|
||||
statusCode = result.getStatusCode().value();
|
||||
} catch (RestClientException e) {
|
||||
//logger.error("POST Request uri: {}, params: {}, error: {}", url, params, e.getMessage());
|
||||
}
|
||||
if (statusCode == 200) {
|
||||
|
||||
return result.getBody();
|
||||
}
|
||||
if (statusCode >= 300 || statusCode < 200) {
|
||||
throw new Exception("Response code is " + statusCode);
|
||||
}
|
||||
//return ResponseCreator.writeJsonErr(result.getStatusCode().toString());
|
||||
|
||||
return result.getStatusCode().toString();
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
2
pom.xml
2
pom.xml
|
|
@ -26,7 +26,7 @@
|
|||
<mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version>
|
||||
<pagehelper.boot.version>1.3.1</pagehelper.boot.version>
|
||||
<fastjson.version>1.2.76</fastjson.version>
|
||||
<oshi.version>5.7.4</oshi.version>
|
||||
<oshi.version>5.7.5</oshi.version>
|
||||
<jna.version>5.8.0</jna.version>
|
||||
<commons.io.version>2.10.0</commons.io.version>
|
||||
<commons.fileupload.version>1.4</commons.fileupload.version>
|
||||
|
|
|
|||
|
|
@ -204,4 +204,22 @@ public class SysDeptController extends BaseController
|
|||
List<Ztree> ztrees = deptService.roleDeptTreeData(role);
|
||||
return ztrees;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ecology部门信息同步
|
||||
*/
|
||||
@Log(title = "部门同步", businessType = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:dept:sync")
|
||||
@PostMapping("/syncDept")
|
||||
@ResponseBody
|
||||
public AjaxResult syncDept()
|
||||
{
|
||||
String url="http://192.168.2.85:90/api/hrm/resful/getHrmdepartmentWithPage";
|
||||
String params="{\"params\":{\"pagesize\":999999}}";
|
||||
int result = deptService.syncEcologyDept(url,params);
|
||||
if(result==200){
|
||||
return AjaxResult.success("同步Ecology部门成功,返回状态码:"+result);
|
||||
}
|
||||
return AjaxResult.error("同步Ecology部门失败,返回状态码:"+result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -285,4 +285,22 @@ public class SysUserController extends BaseController
|
|||
userService.checkUserAllowed(user);
|
||||
return toAjax(userService.changeStatus(user));
|
||||
}
|
||||
|
||||
/**
|
||||
* Ecology人员信息同步
|
||||
*/
|
||||
@Log(title = "人员同步", businessType = BusinessType.UPDATE)
|
||||
@RequiresPermissions("system:user:sync")
|
||||
@PostMapping("/syncUser")
|
||||
@ResponseBody
|
||||
public AjaxResult syncDept()
|
||||
{
|
||||
String url="http://192.168.2.85:90/api/hrm/resful/getHrmUserInfoWithPage";
|
||||
String params="{\"params\":{\"pagesize\":999999}}";
|
||||
int result = userService.syncEcologyUser(url,params);
|
||||
if(result==200){
|
||||
return AjaxResult.success("Ecology人员同步成功,返回状态码:"+result);
|
||||
}
|
||||
return AjaxResult.error("Ecology人员同步失败,返回状态码:"+result);
|
||||
}
|
||||
}
|
||||
|
|
@ -248,7 +248,7 @@ var closeItem = function(dataId){
|
|||
|
||||
/** 创建选项卡 */
|
||||
function createMenuItem(dataUrl, menuName, isRefresh) {
|
||||
var panelUrl = window.frameElement.getAttribute('data-id');
|
||||
var panelUrl = window.frameElement.getAttribute('data-id'),
|
||||
dataIndex = $.common.random(1, 100),
|
||||
flag = true;
|
||||
if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false;
|
||||
|
|
|
|||
|
|
@ -219,10 +219,10 @@
|
|||
<!-- 顶部菜单列表 -->
|
||||
<th:block th:each="menu : ${menus}">
|
||||
<li role="presentation" th:id="|tab_${menu.menuId}|">
|
||||
<a th:if="${#lists.isEmpty(menu.children)}" data-toggle="tab" th:class="@{${!#strings.isEmpty(menu.target) && menu.target == 'menuBlank'} ? 'menuBlank' : 'menuItem noactive'}" th:href="${menu.url}">
|
||||
<a th:if="${#lists.isEmpty(menu.children)}" data-toggle="tab" th:class="@{${!#strings.isEmpty(menu.target) && menu.target == 'menuBlank'} ? 'menuBlank' : 'menuItem noactive'}" th:href="@{${menu.url}}">
|
||||
<i th:class="${menu.icon}"></i> <span>[[${menu.menuName}]]</span>
|
||||
</a>
|
||||
<a th:if="${not #lists.isEmpty(menu.children)}" data-toggle="tab" th:class="@{${!#strings.isEmpty(menu.target) && menu.target == 'menuBlank'} ? 'menuBlank'}" th:href="@{${!#strings.isEmpty(menu.target) && menu.target == 'menuBlank'} ? ${menu.url} : |#menu_${menu.menuId}|}">
|
||||
<a th:if="${not #lists.isEmpty(menu.children)}" data-toggle="tab" th:class="@{${!#strings.isEmpty(menu.target) && menu.target == 'menuBlank'} ? 'menuBlank'}" th:href="@{${!#strings.isEmpty(menu.target) && menu.target == 'menuBlank'} ? @{${menu.url}} : |#menu_${menu.menuId}|}">
|
||||
<i th:class="${menu.icon}"></i> <span>[[${menu.menuName}]]</span>
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,10 @@
|
|||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-success" onclick="$.operate.add(100)" shiro:hasPermission="system:dept:add">
|
||||
<a class="btn btn-success" onclick="syncDept()" shiro:hasPermission="system:dept:sync">
|
||||
<i class="fa fa-plus"></i> 同步
|
||||
</a>
|
||||
<a class="btn btn-success" onclick="addDept()" shiro:hasPermission="system:dept:add" >
|
||||
<i class="fa fa-plus"></i> 新增
|
||||
</a>
|
||||
<a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="system:dept:edit">
|
||||
|
|
@ -50,6 +53,7 @@
|
|||
var editFlag = [[${@permission.hasPermi('system:dept:edit')}]];
|
||||
var removeFlag = [[${@permission.hasPermi('system:dept:remove')}]];
|
||||
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
||||
var deptSyncType = [[${#strings.defaultString(@config.getKey('sys.dept.sync'), 0)}]];
|
||||
var prefix = ctx + "system/dept"
|
||||
|
||||
$(function() {
|
||||
|
|
@ -107,6 +111,33 @@
|
|||
};
|
||||
$.treeTable.init(options);
|
||||
});
|
||||
|
||||
|
||||
function addDept(){
|
||||
|
||||
if(deptSyncType =="0") {
|
||||
$.operate.add(999999);
|
||||
}else {
|
||||
alert("系统参数已启用同步Ecology部门信息,禁止手动新增部门!")
|
||||
}
|
||||
}
|
||||
function syncDept() {
|
||||
if(deptSyncType =="1") {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ctx + "system/dept/syncDept",
|
||||
data: JSON.stringify(""), //beauty是字符串
|
||||
contentType: "application/json",
|
||||
dataType: "json",
|
||||
success: function (message) {
|
||||
alert(JSON.stringify(message)); //将JSON对象转换为字符串
|
||||
}
|
||||
});
|
||||
}else {
|
||||
alert("系统参数未启用同步Ecology部门!")
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -62,6 +62,9 @@
|
|||
</div>
|
||||
|
||||
<div class="btn-group-sm" id="toolbar" role="group">
|
||||
<a class="btn btn-success" onclick="syncUser()" shiro:hasPermission="system:user:sync">
|
||||
<i class="fa fa-plus"></i> 同步
|
||||
</a>
|
||||
<a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:user:add">
|
||||
<i class="fa fa-plus"></i> 新增
|
||||
</a>
|
||||
|
|
@ -262,6 +265,19 @@
|
|||
$.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 0 });
|
||||
})
|
||||
}
|
||||
|
||||
function syncUser() {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: ctx + "system/user/syncUser",
|
||||
data: JSON.stringify(""),
|
||||
contentType: "application/json",
|
||||
dataType: "json",
|
||||
success: function (message) {
|
||||
alert(JSON.stringify(message)); //将JSON对象转换为字符串
|
||||
}
|
||||
});
|
||||
};
|
||||
</script>
|
||||
</body>
|
||||
<!-- 导入区域 -->
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ import java.net.SocketTimeoutException;
|
|||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import javax.net.ssl.HostnameVerifier;
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
|
|
@ -19,6 +21,9 @@ import javax.net.ssl.X509TrustManager;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import com.ruoyi.common.constant.Constants;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* 通用http发送方法
|
||||
|
|
@ -259,4 +264,32 @@ public class HttpUtils
|
|||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 向指定 Restful接口 发送POST方法的请求
|
||||
*
|
||||
* @param url 发送请求的 URL
|
||||
* @param params 请求参数,请求参数为json的形式。例:params="{\"params\":{\"pagesize\":1000}}"
|
||||
* @return 返回Map, Key="statusCode",接口访问返回状态, key="result":接口返回接果
|
||||
*/
|
||||
public static Map<String,String> sendPostWithRest(String url, String params){
|
||||
RestTemplate restTemplate=new RestTemplate();
|
||||
ResponseEntity<String> result=null;
|
||||
int statusCode=0;
|
||||
try{
|
||||
result=restTemplate.postForEntity(url,params,String.class);
|
||||
statusCode=result.getStatusCode().value();
|
||||
}catch (RestClientException e){
|
||||
System.out.println("POST Request uri: "+url+", params:"+params+" error:"+e.getMessage());
|
||||
}
|
||||
Map<String,String> map=new HashMap<>();
|
||||
map.put("statusCode",String.valueOf(statusCode));
|
||||
if(statusCode== 200){
|
||||
map.put("result",result.getBody());
|
||||
} else{
|
||||
map.put("result",String.valueOf(statusCode));
|
||||
}
|
||||
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
|
@ -48,20 +48,24 @@ public class GlobalExceptionHandler
|
|||
* 请求方式不支持
|
||||
*/
|
||||
@ExceptionHandler({ HttpRequestMethodNotSupportedException.class })
|
||||
public AjaxResult handleException(HttpRequestMethodNotSupportedException e)
|
||||
public AjaxResult handleException(HttpRequestMethodNotSupportedException e, HttpServletRequest request)
|
||||
{
|
||||
log.error(e.getMessage(), e);
|
||||
return AjaxResult.error("不支持' " + e.getMethod() + "'请求");
|
||||
String requestURI = request.getRequestURI();
|
||||
String msg = String.format("访问的URL[%s]不支持%s请求", requestURI, e.getMethod());
|
||||
log.error(msg, e);
|
||||
return AjaxResult.error(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* 拦截未知的运行时异常
|
||||
*/
|
||||
@ExceptionHandler(RuntimeException.class)
|
||||
public AjaxResult notFount(RuntimeException e)
|
||||
public AjaxResult notFount(RuntimeException e, HttpServletRequest request)
|
||||
{
|
||||
log.error("运行时异常:", e);
|
||||
return AjaxResult.error("运行时异常:" + e.getMessage());
|
||||
String requestURI = request.getRequestURI();
|
||||
String msg = String.format("访问的URL[%s]发生异常%s", requestURI, e.getMessage());
|
||||
log.error(msg, e);
|
||||
return AjaxResult.error(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -52,6 +52,9 @@
|
|||
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:job:export">
|
||||
<i class="fa fa-download"></i> 导出
|
||||
</a>
|
||||
<a class="btn btn-danger" onclick="closeItem()">
|
||||
<i class="fa fa-reply-all"></i> 关闭
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-sm-12 select-table table-striped">
|
||||
|
|
|
|||
|
|
@ -0,0 +1,110 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
public class EcologyDept {
|
||||
String Canceled;
|
||||
String supdepid;
|
||||
String departmentmark;
|
||||
String departmentname;
|
||||
String created;
|
||||
String departmentcode;
|
||||
String modified;
|
||||
String id;
|
||||
String subcompanyid1;
|
||||
String showorder;
|
||||
|
||||
public String getCanceled() {
|
||||
return Canceled;
|
||||
}
|
||||
|
||||
public void setCanceled(String canceled) {
|
||||
Canceled = canceled;
|
||||
}
|
||||
|
||||
public String getSupdepid() {
|
||||
return supdepid;
|
||||
}
|
||||
|
||||
public void setSupdepid(String supdepid) {
|
||||
this.supdepid = supdepid;
|
||||
}
|
||||
|
||||
public String getDepartmentmark() {
|
||||
return departmentmark;
|
||||
}
|
||||
|
||||
public void setDepartmentmark(String departmentmark) {
|
||||
this.departmentmark = departmentmark;
|
||||
}
|
||||
|
||||
public String getDepartmentname() {
|
||||
return departmentname;
|
||||
}
|
||||
|
||||
public void setDepartmentname(String departmentname) {
|
||||
this.departmentname = departmentname;
|
||||
}
|
||||
|
||||
public String getCreated() {
|
||||
return created;
|
||||
}
|
||||
|
||||
public void setCreated(String created) {
|
||||
this.created = created;
|
||||
}
|
||||
|
||||
public String getDepartmentcode() {
|
||||
return departmentcode;
|
||||
}
|
||||
|
||||
public void setDepartmentcode(String departmentcode) {
|
||||
this.departmentcode = departmentcode;
|
||||
}
|
||||
|
||||
public String getModified() {
|
||||
return modified;
|
||||
}
|
||||
|
||||
public void setModified(String modified) {
|
||||
this.modified = modified;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getSubcompanyid1() {
|
||||
return subcompanyid1;
|
||||
}
|
||||
|
||||
public void setSubcompanyid1(String subcompanyid1) {
|
||||
this.subcompanyid1 = subcompanyid1;
|
||||
}
|
||||
|
||||
public String getShoworder() {
|
||||
return showorder;
|
||||
}
|
||||
|
||||
public void setShoworder(String showorder) {
|
||||
this.showorder = showorder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EcologyDept{" +
|
||||
"Canceled='" + Canceled + '\'' +
|
||||
", supdepid='" + supdepid + '\'' +
|
||||
", departmentmark='" + departmentmark + '\'' +
|
||||
", departmentname='" + departmentname + '\'' +
|
||||
", created='" + created + '\'' +
|
||||
", departmentcode='" + departmentcode + '\'' +
|
||||
", modified='" + modified + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", subcompanyid1='" + subcompanyid1 + '\'' +
|
||||
", showorder='" + showorder + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,110 @@
|
|||
package com.ruoyi.system.domain;
|
||||
|
||||
public class EcologyUser {
|
||||
String subcompanyid1;
|
||||
String password;
|
||||
String id;
|
||||
String loginid;
|
||||
String lastname;
|
||||
String departmentid;
|
||||
String mobile;
|
||||
String email;
|
||||
String sex;
|
||||
String Status;
|
||||
|
||||
public String getSubcompanyid1() {
|
||||
return subcompanyid1;
|
||||
}
|
||||
|
||||
public void setSubcompanyid1(String subcompanyid1) {
|
||||
this.subcompanyid1 = subcompanyid1;
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
public void setPassword(String password) {
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getLoginid() {
|
||||
return loginid;
|
||||
}
|
||||
|
||||
public void setLoginid(String loginid) {
|
||||
this.loginid = loginid;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public String getDepartmentid() {
|
||||
return departmentid;
|
||||
}
|
||||
|
||||
public void setDepartmentid(String departmentid) {
|
||||
this.departmentid = departmentid;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
||||
public void setMobile(String mobile) {
|
||||
this.mobile = mobile;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public String getSex() {
|
||||
return sex;
|
||||
}
|
||||
|
||||
public void setSex(String sex) {
|
||||
this.sex = sex;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return Status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
Status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "EcologyUser{" +
|
||||
"subcompanyid1='" + subcompanyid1 + '\'' +
|
||||
", password='" + password + '\'' +
|
||||
", id='" + id + '\'' +
|
||||
", loginid='" + loginid + '\'' +
|
||||
", lastname='" + lastname + '\'' +
|
||||
", departmentid='" + departmentid + '\'' +
|
||||
", mobile='" + mobile + '\'' +
|
||||
", email='" + email + '\'' +
|
||||
", sex='" + sex + '\'' +
|
||||
", Status='" + Status + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
|
@ -114,4 +114,9 @@ public interface SysDeptMapper
|
|||
* @return 子部门数
|
||||
*/
|
||||
public int selectNormalChildrenDeptById(Long deptId);
|
||||
|
||||
/**
|
||||
* Truncate部门表,用于与Ecology部门同步
|
||||
*/
|
||||
public void truncateDept();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,4 +121,9 @@ public interface SysUserMapper
|
|||
* @return 结果
|
||||
*/
|
||||
public SysUser checkEmailUnique(String email);
|
||||
|
||||
/**
|
||||
* 删除Ecology同步过来的用户
|
||||
*/
|
||||
public void deleteEcologySyncUser();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,4 +107,9 @@ public interface ISysDeptService
|
|||
* @return 结果
|
||||
*/
|
||||
public String checkDeptNameUnique(SysDept dept);
|
||||
|
||||
/**
|
||||
* Ecology部门信息同步
|
||||
*/
|
||||
public int syncEcologyDept(String url,String params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -204,4 +204,9 @@ public interface ISysUserService
|
|||
* @return 结果
|
||||
*/
|
||||
public int changeStatus(SysUser user);
|
||||
|
||||
/**
|
||||
* Ecology人员信息同步
|
||||
*/
|
||||
public int syncEcologyUser(String url,String params);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.system.domain.EcologyDept;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
|
|
@ -17,13 +22,15 @@ import com.ruoyi.common.exception.BusinessException;
|
|||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.system.mapper.SysDeptMapper;
|
||||
import com.ruoyi.system.service.ISysDeptService;
|
||||
import org.springframework.web.client.RestClientException;
|
||||
import org.springframework.web.client.RestTemplate;
|
||||
|
||||
/**
|
||||
* 部门管理 服务实现
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
@Service("sysDeptServiceImpl")
|
||||
public class SysDeptServiceImpl implements ISysDeptService
|
||||
{
|
||||
@Autowired
|
||||
|
|
@ -308,4 +315,80 @@ public class SysDeptServiceImpl implements ISysDeptService
|
|||
}
|
||||
return UserConstants.DEPT_NAME_UNIQUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Ecology部门信息同步
|
||||
*/
|
||||
@Override
|
||||
public int syncEcologyDept(String url,String params) {
|
||||
int result= deptSync(HttpUtils.sendPostWithRest(url,params));
|
||||
return result;
|
||||
}
|
||||
|
||||
public int deptSync(Map<String,String> mapResult){
|
||||
//如果接口返回状态码不为200,则不做同步处理
|
||||
String statusCode=mapResult.get("statusCode");
|
||||
String result= mapResult.get("result");
|
||||
if(!statusCode.equals("200"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//取Ecology返回信息中的部门信息
|
||||
Map<String,Object> map = (Map) JSON.parse(result);
|
||||
Map<String,Object> o= (Map<String, Object>) map.get("data");
|
||||
JSONArray json = (JSONArray) o.get("dataList");
|
||||
List<EcologyDept> depts = JSONArray.parseArray(json.toJSONString(), EcologyDept.class);
|
||||
//清空部门表,并插入顶级部门
|
||||
SysDept sysDept=deptMapper.selectDeptById(Long.parseLong("999999"));
|
||||
deptMapper.truncateDept();
|
||||
deptMapper.insertDept(sysDept);
|
||||
List<SysDept> list=new ArrayList<>();
|
||||
//同步Ecology部门信息
|
||||
for(EcologyDept ecologyDept:depts){
|
||||
if(ecologyDept.getSubcompanyid1().equals("1")) { //只取分部ID为“1”的部门,排除代理商
|
||||
SysDept dept= insertEcologyDept(ecologyDept);
|
||||
list.add(dept);
|
||||
}
|
||||
}
|
||||
//更新祖级列表信息
|
||||
updateAncestors(list);
|
||||
|
||||
return 200;
|
||||
}
|
||||
|
||||
//将Ecology部门转化为系统部门,并更新到部门表sys_dept
|
||||
public SysDept insertEcologyDept(EcologyDept ecologyDept){
|
||||
SysDept dept=new SysDept();
|
||||
dept.setDeptId(Long.parseLong(ecologyDept.getId()));
|
||||
dept.setParentId(Long.parseLong(ecologyDept.getSupdepid()) == 0 ? 999999 : Long.parseLong(ecologyDept.getSupdepid()));
|
||||
dept.setDeptName(ecologyDept.getDepartmentname());
|
||||
dept.setOrderNum("0");
|
||||
dept.setStatus("0");
|
||||
dept.setCreateBy("Admin");
|
||||
deptMapper.insertDept(dept);
|
||||
return dept;
|
||||
}
|
||||
|
||||
//更新祖级列表信息
|
||||
public void updateAncestors(List<SysDept> sysDeptList)
|
||||
{
|
||||
if(sysDeptList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
List<SysDept> list =new ArrayList<>();
|
||||
for(SysDept dept:sysDeptList){
|
||||
SysDept info = deptMapper.selectDeptById(dept.getParentId());
|
||||
if(StringUtils.isNotEmpty(info.getAncestors())) {
|
||||
dept.setAncestors(info.getAncestors()+","+dept.getParentId());
|
||||
deptMapper.updateDept(dept);
|
||||
}else{
|
||||
list.add(dept);
|
||||
}
|
||||
}
|
||||
updateAncestors(list);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,7 @@
|
|||
package com.ruoyi.system.service.impl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.ruoyi.common.annotation.DataScope;
|
||||
import com.ruoyi.common.constant.UserConstants;
|
||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
||||
|
|
@ -14,24 +9,31 @@ import com.ruoyi.common.core.domain.entity.SysUser;
|
|||
import com.ruoyi.common.core.text.Convert;
|
||||
import com.ruoyi.common.exception.BusinessException;
|
||||
import com.ruoyi.common.utils.StringUtils;
|
||||
import com.ruoyi.common.utils.http.HttpUtils;
|
||||
import com.ruoyi.common.utils.security.Md5Utils;
|
||||
import com.ruoyi.system.domain.EcologyUser;
|
||||
import com.ruoyi.system.domain.SysPost;
|
||||
import com.ruoyi.system.domain.SysUserPost;
|
||||
import com.ruoyi.system.domain.SysUserRole;
|
||||
import com.ruoyi.system.mapper.SysPostMapper;
|
||||
import com.ruoyi.system.mapper.SysRoleMapper;
|
||||
import com.ruoyi.system.mapper.SysUserMapper;
|
||||
import com.ruoyi.system.mapper.SysUserPostMapper;
|
||||
import com.ruoyi.system.mapper.SysUserRoleMapper;
|
||||
import com.ruoyi.system.mapper.*;
|
||||
import com.ruoyi.system.service.ISysConfigService;
|
||||
import com.ruoyi.system.service.ISysUserService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 用户 业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
*/
|
||||
@Service
|
||||
@Service("sysUserServiceImpl")
|
||||
public class SysUserServiceImpl implements ISysUserService
|
||||
{
|
||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||
|
|
@ -525,4 +527,51 @@ public class SysUserServiceImpl implements ISysUserService
|
|||
{
|
||||
return userMapper.updateUser(user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ecology人员信息同步
|
||||
*
|
||||
* @param url
|
||||
* @param params
|
||||
*/
|
||||
@Override
|
||||
public int syncEcologyUser(String url, String params) {
|
||||
int result= userSync(HttpUtils.sendPostWithRest(url,params));
|
||||
return result;
|
||||
}
|
||||
|
||||
public int userSync(Map<String,String> mapResult){
|
||||
//如果接口返回状态码不为200,则不做同步处理
|
||||
String statusCode=mapResult.get("statusCode");
|
||||
String result= mapResult.get("result");
|
||||
if(!statusCode.equals("200"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//取Ecology返回信息中的部门信息
|
||||
Map<String,Object> map = (Map) JSON.parse(result);
|
||||
Map<String,Object> o= (Map<String, Object>) map.get("data");
|
||||
JSONArray json = (JSONArray) o.get("dataList");
|
||||
List<EcologyUser> ecologyUserList = JSONArray.parseArray(json.toJSONString(), EcologyUser.class);
|
||||
|
||||
userMapper.deleteEcologySyncUser();
|
||||
SysUser user = new SysUser();
|
||||
//同步Ecology部门信息
|
||||
for(EcologyUser ecologyuser:ecologyUserList){
|
||||
if(ecologyuser.getSubcompanyid1().equals("1") && StringUtils.isNotEmpty(ecologyuser.getLoginid())) { //只取分部ID为“1”的员工
|
||||
user.setUserId(Long.parseLong(ecologyuser.getId()));
|
||||
user.setDeptId(Long.parseLong(ecologyuser.getDepartmentid()));
|
||||
user.setLoginName(ecologyuser.getLoginid());
|
||||
user.setUserName(ecologyuser.getLastname());
|
||||
user.setUserType("02");
|
||||
user.setEmail(ecologyuser.getEmail());
|
||||
user.setSex(ecologyuser.getSex());
|
||||
user.setPhonenumber(ecologyuser.getMobile());
|
||||
user.setStatus(ecologyuser.getStatus().equals("5")?"1":"0"); //Ecology为离职状态5,则无效
|
||||
user.setDelFlag("0");
|
||||
userMapper.insertUser(user);
|
||||
}
|
||||
}
|
||||
return 200;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -152,4 +152,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
</foreach>
|
||||
</update>
|
||||
|
||||
<update id="truncateDept">
|
||||
truncate table sys_dept
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
|
|
@ -224,4 +224,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteEcologySyncUser" >
|
||||
delete from sys_user where user_type ='02'
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue