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);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,493 +1,493 @@
|
|||
/**
|
||||
* 通用方法封装处理
|
||||
* Copyright (c) 2019 ruoyi
|
||||
*/
|
||||
$(function() {
|
||||
|
||||
// layer扩展皮肤
|
||||
if (window.layer !== undefined) {
|
||||
layer.config({
|
||||
extend: 'moon/style.css',
|
||||
skin: 'layer-ext-moon'
|
||||
});
|
||||
}
|
||||
|
||||
// 回到顶部绑定
|
||||
if ($.fn.toTop !== undefined) {
|
||||
$('#scroll-up').toTop();
|
||||
}
|
||||
|
||||
// select2复选框事件绑定
|
||||
if ($.fn.select2 !== undefined) {
|
||||
$.fn.select2.defaults.set( "theme", "bootstrap" );
|
||||
$("select.form-control:not(.noselect2)").each(function () {
|
||||
$(this).select2().on("change", function () {
|
||||
$(this).valid();
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// iCheck单选框及复选框事件绑定
|
||||
if ($.fn.iCheck !== undefined) {
|
||||
$(".check-box:not(.noicheck),.radio-box:not(.noicheck)").each(function() {
|
||||
$(this).iCheck({
|
||||
checkboxClass: 'icheckbox-blue',
|
||||
radioClass: 'iradio-blue',
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 取消回车自动提交表单
|
||||
$(document).on("keypress", ":input:not(textarea):not([type=submit])", function(event) {
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// laydate 时间控件绑定
|
||||
if ($(".select-time").length > 0) {
|
||||
layui.use('laydate', function() {
|
||||
var laydate = layui.laydate;
|
||||
var startDate = laydate.render({
|
||||
elem: '#startTime',
|
||||
max: $('#endTime').val(),
|
||||
theme: 'molv',
|
||||
trigger: 'click',
|
||||
done: function(value, date) {
|
||||
// 结束时间大于开始时间
|
||||
if (value !== '') {
|
||||
endDate.config.min.year = date.year;
|
||||
endDate.config.min.month = date.month - 1;
|
||||
endDate.config.min.date = date.date;
|
||||
} else {
|
||||
endDate.config.min.year = '';
|
||||
endDate.config.min.month = '';
|
||||
endDate.config.min.date = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
var endDate = laydate.render({
|
||||
elem: '#endTime',
|
||||
min: $('#startTime').val(),
|
||||
theme: 'molv',
|
||||
trigger: 'click',
|
||||
done: function(value, date) {
|
||||
// 开始时间小于结束时间
|
||||
if (value !== '') {
|
||||
startDate.config.max.year = date.year;
|
||||
startDate.config.max.month = date.month - 1;
|
||||
startDate.config.max.date = date.date;
|
||||
} else {
|
||||
startDate.config.max.year = '2099';
|
||||
startDate.config.max.month = '12';
|
||||
startDate.config.max.date = '31';
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// laydate time-input 时间控件绑定
|
||||
if ($(".time-input").length > 0) {
|
||||
layui.use('laydate', function () {
|
||||
var com = layui.laydate;
|
||||
$(".time-input").each(function (index, item) {
|
||||
var time = $(item);
|
||||
// 控制控件外观
|
||||
var type = time.attr("data-type") || 'date';
|
||||
// 控制回显格式
|
||||
var format = time.attr("data-format") || 'yyyy-MM-dd';
|
||||
// 控制日期控件按钮
|
||||
var buttons = time.attr("data-btn") || 'clear|now|confirm', newBtnArr = [];
|
||||
// 日期控件选择完成后回调处理
|
||||
var callback = time.attr("data-callback") || {};
|
||||
if (buttons) {
|
||||
if (buttons.indexOf("|") > 0) {
|
||||
var btnArr = buttons.split("|"), btnLen = btnArr.length;
|
||||
for (var j = 0; j < btnLen; j++) {
|
||||
if ("clear" === btnArr[j] || "now" === btnArr[j] || "confirm" === btnArr[j]) {
|
||||
newBtnArr.push(btnArr[j]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("clear" === buttons || "now" === buttons || "confirm" === buttons) {
|
||||
newBtnArr.push(buttons);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newBtnArr = ['clear', 'now', 'confirm'];
|
||||
}
|
||||
com.render({
|
||||
elem: item,
|
||||
theme: 'molv',
|
||||
trigger: 'click',
|
||||
type: type,
|
||||
format: format,
|
||||
btns: newBtnArr,
|
||||
done: function (value, data) {
|
||||
if (typeof window[callback] != 'undefined'
|
||||
&& window[callback] instanceof Function) {
|
||||
window[callback](value, data);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// tree 关键字搜索绑定
|
||||
if ($("#keyword").length > 0) {
|
||||
$("#keyword").bind("focus", function focusKey(e) {
|
||||
if ($("#keyword").hasClass("empty")) {
|
||||
$("#keyword").removeClass("empty");
|
||||
}
|
||||
}).bind("blur", function blurKey(e) {
|
||||
if ($("#keyword").val() === "") {
|
||||
$("#keyword").addClass("empty");
|
||||
}
|
||||
$.tree.searchNode(e);
|
||||
}).bind("input propertychange", $.tree.searchNode);
|
||||
}
|
||||
|
||||
// tree表格树 展开/折叠
|
||||
var expandFlag;
|
||||
$("#expandAllBtn").click(function() {
|
||||
var dataExpand = $.common.isEmpty(table.options.expandAll) ? true : table.options.expandAll;
|
||||
expandFlag = $.common.isEmpty(expandFlag) ? dataExpand : expandFlag;
|
||||
if (!expandFlag) {
|
||||
$.bttTable.bootstrapTreeTable('expandAll');
|
||||
} else {
|
||||
$.bttTable.bootstrapTreeTable('collapseAll');
|
||||
}
|
||||
expandFlag = expandFlag ? false: true;
|
||||
})
|
||||
|
||||
// 按下ESC按钮关闭弹层
|
||||
$('body', document).on('keyup', function(e) {
|
||||
if (e.which === 27) {
|
||||
$.modal.closeAll();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
(function ($) {
|
||||
'use strict';
|
||||
$.fn.toTop = function(opt) {
|
||||
var elem = this;
|
||||
var win = (opt && opt.hasOwnProperty('win')) ? opt.win : $(window);
|
||||
var doc = (opt && opt.hasOwnProperty('doc')) ? opt.doc : $('html, body');
|
||||
var options = $.extend({
|
||||
autohide: true,
|
||||
offset: 50,
|
||||
speed: 500,
|
||||
position: true,
|
||||
right: 15,
|
||||
bottom: 5
|
||||
}, opt);
|
||||
elem.css({
|
||||
'cursor': 'pointer'
|
||||
});
|
||||
if (options.autohide) {
|
||||
elem.css('display', 'none');
|
||||
}
|
||||
if (options.position) {
|
||||
elem.css({
|
||||
'position': 'fixed',
|
||||
'right': options.right,
|
||||
'bottom': options.bottom,
|
||||
});
|
||||
}
|
||||
elem.click(function() {
|
||||
doc.animate({
|
||||
scrollTop: 0
|
||||
}, options.speed);
|
||||
});
|
||||
win.scroll(function() {
|
||||
var scrolling = win.scrollTop();
|
||||
if (options.autohide) {
|
||||
if (scrolling > options.offset) {
|
||||
elem.fadeIn(options.speed);
|
||||
} else elem.fadeOut(options.speed);
|
||||
}
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
/** 刷新选项卡 */
|
||||
var refreshItem = function(){
|
||||
var topWindow = $(window.parent.document);
|
||||
var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
|
||||
var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
|
||||
var url = target.attr('src');
|
||||
target.attr('src', url).ready();
|
||||
}
|
||||
|
||||
/** 关闭选项卡 */
|
||||
var closeItem = function(dataId){
|
||||
var topWindow = $(window.parent.document);
|
||||
if($.common.isNotEmpty(dataId)){
|
||||
window.parent.$.modal.closeLoading();
|
||||
// 根据dataId关闭指定选项卡
|
||||
$('.menuTab[data-id="' + dataId + '"]', topWindow).remove();
|
||||
// 移除相应tab对应的内容区
|
||||
$('.mainContent .RuoYi_iframe[data-id="' + dataId + '"]', topWindow).remove();
|
||||
return;
|
||||
}
|
||||
var panelUrl = window.frameElement.getAttribute('data-panel');
|
||||
$('.page-tabs-content .active i', topWindow).click();
|
||||
if($.common.isNotEmpty(panelUrl)){
|
||||
$('.menuTab[data-id="' + panelUrl + '"]', topWindow).addClass('active').siblings('.menuTab').removeClass('active');
|
||||
$('.mainContent .RuoYi_iframe', topWindow).each(function() {
|
||||
if ($(this).data('id') == panelUrl) {
|
||||
$(this).show().siblings('.RuoYi_iframe').hide();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** 创建选项卡 */
|
||||
function createMenuItem(dataUrl, menuName, isRefresh) {
|
||||
var panelUrl = window.frameElement.getAttribute('data-id');
|
||||
dataIndex = $.common.random(1, 100),
|
||||
flag = true;
|
||||
if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false;
|
||||
var topWindow = $(window.parent.document);
|
||||
// 选项卡菜单已存在
|
||||
$('.menuTab', topWindow).each(function() {
|
||||
if ($(this).data('id') == dataUrl) {
|
||||
if (!$(this).hasClass('active')) {
|
||||
$(this).addClass('active').siblings('.menuTab').removeClass('active');
|
||||
scrollToTab(this);
|
||||
$('.page-tabs-content').animate({ marginLeft: ""}, "fast");
|
||||
// 显示tab对应的内容区
|
||||
$('.mainContent .RuoYi_iframe', topWindow).each(function() {
|
||||
if ($(this).data('id') == dataUrl) {
|
||||
$(this).show().siblings('.RuoYi_iframe').hide();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isRefresh) {
|
||||
refreshTab();
|
||||
}
|
||||
flag = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
// 选项卡菜单不存在
|
||||
if (flag) {
|
||||
var str = '<a href="javascript:;" class="active menuTab noactive" data-id="' + dataUrl + '" data-panel="' + panelUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
|
||||
$('.menuTab', topWindow).removeClass('active');
|
||||
|
||||
// 添加选项卡对应的iframe
|
||||
var str1 = '<iframe class="RuoYi_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" data-panel="' + panelUrl + '" seamless></iframe>';
|
||||
$('.mainContent', topWindow).find('iframe.RuoYi_iframe').hide().parents('.mainContent').append(str1);
|
||||
|
||||
window.parent.$.modal.loading("数据加载中,请稍后...");
|
||||
$('.mainContent iframe:visible', topWindow).load(function () {
|
||||
window.parent.$.modal.closeLoading();
|
||||
});
|
||||
|
||||
// 添加选项卡
|
||||
$('.menuTabs .page-tabs-content', topWindow).append(str);
|
||||
scrollToTab($('.menuTab.active', topWindow));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 刷新iframe
|
||||
function refreshTab() {
|
||||
var topWindow = $(window.parent.document);
|
||||
var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
|
||||
var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
|
||||
var url = target.attr('src');
|
||||
target.attr('src', url).ready();
|
||||
}
|
||||
|
||||
// 滚动到指定选项卡
|
||||
function scrollToTab(element) {
|
||||
var topWindow = $(window.parent.document);
|
||||
var marginLeftVal = calSumWidth($(element).prevAll()),
|
||||
marginRightVal = calSumWidth($(element).nextAll());
|
||||
// 可视区域非tab宽度
|
||||
var tabOuterWidth = calSumWidth($(".content-tabs", topWindow).children().not(".menuTabs"));
|
||||
//可视区域tab宽度
|
||||
var visibleWidth = $(".content-tabs", topWindow).outerWidth(true) - tabOuterWidth;
|
||||
//实际滚动宽度
|
||||
var scrollVal = 0;
|
||||
if ($(".page-tabs-content", topWindow).outerWidth() < visibleWidth) {
|
||||
scrollVal = 0;
|
||||
} else if (marginRightVal <= (visibleWidth - $(element).outerWidth(true) - $(element).next().outerWidth(true))) {
|
||||
if ((visibleWidth - $(element).next().outerWidth(true)) > marginRightVal) {
|
||||
scrollVal = marginLeftVal;
|
||||
var tabElement = element;
|
||||
while ((scrollVal - $(tabElement).outerWidth()) > ($(".page-tabs-content", topWindow).outerWidth() - visibleWidth)) {
|
||||
scrollVal -= $(tabElement).prev().outerWidth();
|
||||
tabElement = $(tabElement).prev();
|
||||
}
|
||||
}
|
||||
} else if (marginLeftVal > (visibleWidth - $(element).outerWidth(true) - $(element).prev().outerWidth(true))) {
|
||||
scrollVal = marginLeftVal - $(element).prev().outerWidth(true);
|
||||
}
|
||||
$('.page-tabs-content', topWindow).animate({ marginLeft: 0 - scrollVal + 'px' }, "fast");
|
||||
}
|
||||
|
||||
//计算元素集合的总宽度
|
||||
function calSumWidth(elements) {
|
||||
var width = 0;
|
||||
$(elements).each(function() {
|
||||
width += $(this).outerWidth(true);
|
||||
});
|
||||
return width;
|
||||
}
|
||||
|
||||
/** 密码规则范围验证 */
|
||||
function checkpwd(chrtype, password) {
|
||||
if (chrtype == 1) {
|
||||
if(!$.common.numValid(password)){
|
||||
$.modal.alertWarning("密码只能为0-9数字");
|
||||
return false;
|
||||
}
|
||||
} else if (chrtype == 2) {
|
||||
if(!$.common.enValid(password)){
|
||||
$.modal.alertWarning("密码只能为a-z和A-Z字母");
|
||||
return false;
|
||||
}
|
||||
} else if (chrtype == 3) {
|
||||
if(!$.common.enNumValid(password)){
|
||||
$.modal.alertWarning("密码必须包含字母以及数字");
|
||||
return false;
|
||||
}
|
||||
} else if (chrtype == 4) {
|
||||
if(!$.common.charValid(password)){
|
||||
$.modal.alertWarning("密码必须包含字母、数字、以及特殊符号<font color='red'>~!@#$%^&*()-=_+</font>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 日志打印封装处理
|
||||
var log = {
|
||||
log: function(msg) {
|
||||
console.log(msg);
|
||||
},
|
||||
info: function(msg) {
|
||||
console.info(msg);
|
||||
},
|
||||
warn: function(msg) {
|
||||
console.warn(msg);
|
||||
},
|
||||
error: function(msg) {
|
||||
console.error(msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 本地缓存处理
|
||||
var storage = {
|
||||
set: function(key, value) {
|
||||
window.localStorage.setItem(key, value);
|
||||
},
|
||||
get: function(key) {
|
||||
return window.localStorage.getItem(key);
|
||||
},
|
||||
remove: function(key) {
|
||||
window.localStorage.removeItem(key);
|
||||
},
|
||||
clear: function() {
|
||||
window.localStorage.clear();
|
||||
}
|
||||
};
|
||||
|
||||
// 主子表操作封装处理
|
||||
var sub = {
|
||||
editColumn: function() {
|
||||
var dataColumns = [];
|
||||
for (var columnIndex = 0; columnIndex < table.options.columns.length; columnIndex++) {
|
||||
if (table.options.columns[columnIndex].visible != false) {
|
||||
dataColumns.push(table.options.columns[columnIndex]);
|
||||
}
|
||||
}
|
||||
var params = new Array();
|
||||
var data = $("#" + table.options.id).bootstrapTable('getData');
|
||||
var count = data.length;
|
||||
for (var dataIndex = 0; dataIndex < count; dataIndex++) {
|
||||
var columns = $('#' + table.options.id + ' tr[data-index="' + dataIndex + '"] td');
|
||||
var obj = new Object();
|
||||
for (var i = 0; i < columns.length; i++) {
|
||||
var inputValue = $(columns[i]).find('input');
|
||||
var selectValue = $(columns[i]).find('select');
|
||||
var textareaValue = $(columns[i]).find('textarea');
|
||||
var key = dataColumns[i].field;
|
||||
if ($.common.isNotEmpty(inputValue.val())) {
|
||||
obj[key] = inputValue.val();
|
||||
} else if ($.common.isNotEmpty(selectValue.val())) {
|
||||
obj[key] = selectValue.val();
|
||||
} else if ($.common.isNotEmpty(textareaValue.val())) {
|
||||
obj[key] = textareaValue.val();
|
||||
} else {
|
||||
obj[key] = "";
|
||||
}
|
||||
}
|
||||
var item = data[dataIndex];
|
||||
var extendObj = $.extend({}, item, obj);
|
||||
params.push({ index: dataIndex, row: extendObj });
|
||||
}
|
||||
$("#" + table.options.id).bootstrapTable("updateRow", params);
|
||||
},
|
||||
delColumn: function(column) {
|
||||
sub.editColumn();
|
||||
var subColumn = $.common.isEmpty(column) ? "index" : column;
|
||||
var ids = $.table.selectColumns(subColumn);
|
||||
if (ids.length == 0) {
|
||||
$.modal.alertWarning("请至少选择一条记录");
|
||||
return;
|
||||
}
|
||||
$("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids });
|
||||
},
|
||||
addColumn: function(row, tableId) {
|
||||
var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
|
||||
table.set(currentId);
|
||||
var count = $("#" + currentId).bootstrapTable('getData').length;
|
||||
sub.editColumn();
|
||||
$("#" + currentId).bootstrapTable('insertRow', {
|
||||
index: count + 1,
|
||||
row: row
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 动态加载css文件
|
||||
function loadCss(file, headElem) {
|
||||
var link = document.createElement('link');
|
||||
link.href = file;
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
if (headElem) headElem.appendChild(link);
|
||||
else document.getElementsByTagName('head')[0].appendChild(link);
|
||||
}
|
||||
|
||||
// 动态加载js文件
|
||||
function loadJs(file, headElem) {
|
||||
var script = document.createElement('script');
|
||||
script.src = file;
|
||||
script.type = 'text/javascript';
|
||||
if (headElem) headElem.appendChild(script);
|
||||
else document.getElementsByTagName('head')[0].appendChild(script);
|
||||
}
|
||||
|
||||
/** 设置全局ajax处理 */
|
||||
$.ajaxSetup({
|
||||
complete: function(XMLHttpRequest, textStatus) {
|
||||
if (textStatus == 'timeout') {
|
||||
$.modal.alertWarning("服务器超时,请稍后再试!");
|
||||
$.modal.enable();
|
||||
$.modal.closeLoading();
|
||||
} else if (textStatus == "parsererror" || textStatus == "error") {
|
||||
$.modal.alertWarning("服务器错误,请联系管理员!");
|
||||
$.modal.enable();
|
||||
$.modal.closeLoading();
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* 通用方法封装处理
|
||||
* Copyright (c) 2019 ruoyi
|
||||
*/
|
||||
$(function() {
|
||||
|
||||
// layer扩展皮肤
|
||||
if (window.layer !== undefined) {
|
||||
layer.config({
|
||||
extend: 'moon/style.css',
|
||||
skin: 'layer-ext-moon'
|
||||
});
|
||||
}
|
||||
|
||||
// 回到顶部绑定
|
||||
if ($.fn.toTop !== undefined) {
|
||||
$('#scroll-up').toTop();
|
||||
}
|
||||
|
||||
// select2复选框事件绑定
|
||||
if ($.fn.select2 !== undefined) {
|
||||
$.fn.select2.defaults.set( "theme", "bootstrap" );
|
||||
$("select.form-control:not(.noselect2)").each(function () {
|
||||
$(this).select2().on("change", function () {
|
||||
$(this).valid();
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// iCheck单选框及复选框事件绑定
|
||||
if ($.fn.iCheck !== undefined) {
|
||||
$(".check-box:not(.noicheck),.radio-box:not(.noicheck)").each(function() {
|
||||
$(this).iCheck({
|
||||
checkboxClass: 'icheckbox-blue',
|
||||
radioClass: 'iradio-blue',
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
// 取消回车自动提交表单
|
||||
$(document).on("keypress", ":input:not(textarea):not([type=submit])", function(event) {
|
||||
if (event.keyCode == 13) {
|
||||
event.preventDefault();
|
||||
}
|
||||
});
|
||||
|
||||
// laydate 时间控件绑定
|
||||
if ($(".select-time").length > 0) {
|
||||
layui.use('laydate', function() {
|
||||
var laydate = layui.laydate;
|
||||
var startDate = laydate.render({
|
||||
elem: '#startTime',
|
||||
max: $('#endTime').val(),
|
||||
theme: 'molv',
|
||||
trigger: 'click',
|
||||
done: function(value, date) {
|
||||
// 结束时间大于开始时间
|
||||
if (value !== '') {
|
||||
endDate.config.min.year = date.year;
|
||||
endDate.config.min.month = date.month - 1;
|
||||
endDate.config.min.date = date.date;
|
||||
} else {
|
||||
endDate.config.min.year = '';
|
||||
endDate.config.min.month = '';
|
||||
endDate.config.min.date = '';
|
||||
}
|
||||
}
|
||||
});
|
||||
var endDate = laydate.render({
|
||||
elem: '#endTime',
|
||||
min: $('#startTime').val(),
|
||||
theme: 'molv',
|
||||
trigger: 'click',
|
||||
done: function(value, date) {
|
||||
// 开始时间小于结束时间
|
||||
if (value !== '') {
|
||||
startDate.config.max.year = date.year;
|
||||
startDate.config.max.month = date.month - 1;
|
||||
startDate.config.max.date = date.date;
|
||||
} else {
|
||||
startDate.config.max.year = '2099';
|
||||
startDate.config.max.month = '12';
|
||||
startDate.config.max.date = '31';
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// laydate time-input 时间控件绑定
|
||||
if ($(".time-input").length > 0) {
|
||||
layui.use('laydate', function () {
|
||||
var com = layui.laydate;
|
||||
$(".time-input").each(function (index, item) {
|
||||
var time = $(item);
|
||||
// 控制控件外观
|
||||
var type = time.attr("data-type") || 'date';
|
||||
// 控制回显格式
|
||||
var format = time.attr("data-format") || 'yyyy-MM-dd';
|
||||
// 控制日期控件按钮
|
||||
var buttons = time.attr("data-btn") || 'clear|now|confirm', newBtnArr = [];
|
||||
// 日期控件选择完成后回调处理
|
||||
var callback = time.attr("data-callback") || {};
|
||||
if (buttons) {
|
||||
if (buttons.indexOf("|") > 0) {
|
||||
var btnArr = buttons.split("|"), btnLen = btnArr.length;
|
||||
for (var j = 0; j < btnLen; j++) {
|
||||
if ("clear" === btnArr[j] || "now" === btnArr[j] || "confirm" === btnArr[j]) {
|
||||
newBtnArr.push(btnArr[j]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ("clear" === buttons || "now" === buttons || "confirm" === buttons) {
|
||||
newBtnArr.push(buttons);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newBtnArr = ['clear', 'now', 'confirm'];
|
||||
}
|
||||
com.render({
|
||||
elem: item,
|
||||
theme: 'molv',
|
||||
trigger: 'click',
|
||||
type: type,
|
||||
format: format,
|
||||
btns: newBtnArr,
|
||||
done: function (value, data) {
|
||||
if (typeof window[callback] != 'undefined'
|
||||
&& window[callback] instanceof Function) {
|
||||
window[callback](value, data);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// tree 关键字搜索绑定
|
||||
if ($("#keyword").length > 0) {
|
||||
$("#keyword").bind("focus", function focusKey(e) {
|
||||
if ($("#keyword").hasClass("empty")) {
|
||||
$("#keyword").removeClass("empty");
|
||||
}
|
||||
}).bind("blur", function blurKey(e) {
|
||||
if ($("#keyword").val() === "") {
|
||||
$("#keyword").addClass("empty");
|
||||
}
|
||||
$.tree.searchNode(e);
|
||||
}).bind("input propertychange", $.tree.searchNode);
|
||||
}
|
||||
|
||||
// tree表格树 展开/折叠
|
||||
var expandFlag;
|
||||
$("#expandAllBtn").click(function() {
|
||||
var dataExpand = $.common.isEmpty(table.options.expandAll) ? true : table.options.expandAll;
|
||||
expandFlag = $.common.isEmpty(expandFlag) ? dataExpand : expandFlag;
|
||||
if (!expandFlag) {
|
||||
$.bttTable.bootstrapTreeTable('expandAll');
|
||||
} else {
|
||||
$.bttTable.bootstrapTreeTable('collapseAll');
|
||||
}
|
||||
expandFlag = expandFlag ? false: true;
|
||||
})
|
||||
|
||||
// 按下ESC按钮关闭弹层
|
||||
$('body', document).on('keyup', function(e) {
|
||||
if (e.which === 27) {
|
||||
$.modal.closeAll();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
(function ($) {
|
||||
'use strict';
|
||||
$.fn.toTop = function(opt) {
|
||||
var elem = this;
|
||||
var win = (opt && opt.hasOwnProperty('win')) ? opt.win : $(window);
|
||||
var doc = (opt && opt.hasOwnProperty('doc')) ? opt.doc : $('html, body');
|
||||
var options = $.extend({
|
||||
autohide: true,
|
||||
offset: 50,
|
||||
speed: 500,
|
||||
position: true,
|
||||
right: 15,
|
||||
bottom: 5
|
||||
}, opt);
|
||||
elem.css({
|
||||
'cursor': 'pointer'
|
||||
});
|
||||
if (options.autohide) {
|
||||
elem.css('display', 'none');
|
||||
}
|
||||
if (options.position) {
|
||||
elem.css({
|
||||
'position': 'fixed',
|
||||
'right': options.right,
|
||||
'bottom': options.bottom,
|
||||
});
|
||||
}
|
||||
elem.click(function() {
|
||||
doc.animate({
|
||||
scrollTop: 0
|
||||
}, options.speed);
|
||||
});
|
||||
win.scroll(function() {
|
||||
var scrolling = win.scrollTop();
|
||||
if (options.autohide) {
|
||||
if (scrolling > options.offset) {
|
||||
elem.fadeIn(options.speed);
|
||||
} else elem.fadeOut(options.speed);
|
||||
}
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
/** 刷新选项卡 */
|
||||
var refreshItem = function(){
|
||||
var topWindow = $(window.parent.document);
|
||||
var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
|
||||
var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
|
||||
var url = target.attr('src');
|
||||
target.attr('src', url).ready();
|
||||
}
|
||||
|
||||
/** 关闭选项卡 */
|
||||
var closeItem = function(dataId){
|
||||
var topWindow = $(window.parent.document);
|
||||
if($.common.isNotEmpty(dataId)){
|
||||
window.parent.$.modal.closeLoading();
|
||||
// 根据dataId关闭指定选项卡
|
||||
$('.menuTab[data-id="' + dataId + '"]', topWindow).remove();
|
||||
// 移除相应tab对应的内容区
|
||||
$('.mainContent .RuoYi_iframe[data-id="' + dataId + '"]', topWindow).remove();
|
||||
return;
|
||||
}
|
||||
var panelUrl = window.frameElement.getAttribute('data-panel');
|
||||
$('.page-tabs-content .active i', topWindow).click();
|
||||
if($.common.isNotEmpty(panelUrl)){
|
||||
$('.menuTab[data-id="' + panelUrl + '"]', topWindow).addClass('active').siblings('.menuTab').removeClass('active');
|
||||
$('.mainContent .RuoYi_iframe', topWindow).each(function() {
|
||||
if ($(this).data('id') == panelUrl) {
|
||||
$(this).show().siblings('.RuoYi_iframe').hide();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** 创建选项卡 */
|
||||
function createMenuItem(dataUrl, menuName, isRefresh) {
|
||||
var panelUrl = window.frameElement.getAttribute('data-id'),
|
||||
dataIndex = $.common.random(1, 100),
|
||||
flag = true;
|
||||
if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false;
|
||||
var topWindow = $(window.parent.document);
|
||||
// 选项卡菜单已存在
|
||||
$('.menuTab', topWindow).each(function() {
|
||||
if ($(this).data('id') == dataUrl) {
|
||||
if (!$(this).hasClass('active')) {
|
||||
$(this).addClass('active').siblings('.menuTab').removeClass('active');
|
||||
scrollToTab(this);
|
||||
$('.page-tabs-content').animate({ marginLeft: ""}, "fast");
|
||||
// 显示tab对应的内容区
|
||||
$('.mainContent .RuoYi_iframe', topWindow).each(function() {
|
||||
if ($(this).data('id') == dataUrl) {
|
||||
$(this).show().siblings('.RuoYi_iframe').hide();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
if (isRefresh) {
|
||||
refreshTab();
|
||||
}
|
||||
flag = false;
|
||||
return false;
|
||||
}
|
||||
});
|
||||
// 选项卡菜单不存在
|
||||
if (flag) {
|
||||
var str = '<a href="javascript:;" class="active menuTab noactive" data-id="' + dataUrl + '" data-panel="' + panelUrl + '">' + menuName + ' <i class="fa fa-times-circle"></i></a>';
|
||||
$('.menuTab', topWindow).removeClass('active');
|
||||
|
||||
// 添加选项卡对应的iframe
|
||||
var str1 = '<iframe class="RuoYi_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + dataUrl + '" frameborder="0" data-id="' + dataUrl + '" data-panel="' + panelUrl + '" seamless></iframe>';
|
||||
$('.mainContent', topWindow).find('iframe.RuoYi_iframe').hide().parents('.mainContent').append(str1);
|
||||
|
||||
window.parent.$.modal.loading("数据加载中,请稍后...");
|
||||
$('.mainContent iframe:visible', topWindow).load(function () {
|
||||
window.parent.$.modal.closeLoading();
|
||||
});
|
||||
|
||||
// 添加选项卡
|
||||
$('.menuTabs .page-tabs-content', topWindow).append(str);
|
||||
scrollToTab($('.menuTab.active', topWindow));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// 刷新iframe
|
||||
function refreshTab() {
|
||||
var topWindow = $(window.parent.document);
|
||||
var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
|
||||
var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
|
||||
var url = target.attr('src');
|
||||
target.attr('src', url).ready();
|
||||
}
|
||||
|
||||
// 滚动到指定选项卡
|
||||
function scrollToTab(element) {
|
||||
var topWindow = $(window.parent.document);
|
||||
var marginLeftVal = calSumWidth($(element).prevAll()),
|
||||
marginRightVal = calSumWidth($(element).nextAll());
|
||||
// 可视区域非tab宽度
|
||||
var tabOuterWidth = calSumWidth($(".content-tabs", topWindow).children().not(".menuTabs"));
|
||||
//可视区域tab宽度
|
||||
var visibleWidth = $(".content-tabs", topWindow).outerWidth(true) - tabOuterWidth;
|
||||
//实际滚动宽度
|
||||
var scrollVal = 0;
|
||||
if ($(".page-tabs-content", topWindow).outerWidth() < visibleWidth) {
|
||||
scrollVal = 0;
|
||||
} else if (marginRightVal <= (visibleWidth - $(element).outerWidth(true) - $(element).next().outerWidth(true))) {
|
||||
if ((visibleWidth - $(element).next().outerWidth(true)) > marginRightVal) {
|
||||
scrollVal = marginLeftVal;
|
||||
var tabElement = element;
|
||||
while ((scrollVal - $(tabElement).outerWidth()) > ($(".page-tabs-content", topWindow).outerWidth() - visibleWidth)) {
|
||||
scrollVal -= $(tabElement).prev().outerWidth();
|
||||
tabElement = $(tabElement).prev();
|
||||
}
|
||||
}
|
||||
} else if (marginLeftVal > (visibleWidth - $(element).outerWidth(true) - $(element).prev().outerWidth(true))) {
|
||||
scrollVal = marginLeftVal - $(element).prev().outerWidth(true);
|
||||
}
|
||||
$('.page-tabs-content', topWindow).animate({ marginLeft: 0 - scrollVal + 'px' }, "fast");
|
||||
}
|
||||
|
||||
//计算元素集合的总宽度
|
||||
function calSumWidth(elements) {
|
||||
var width = 0;
|
||||
$(elements).each(function() {
|
||||
width += $(this).outerWidth(true);
|
||||
});
|
||||
return width;
|
||||
}
|
||||
|
||||
/** 密码规则范围验证 */
|
||||
function checkpwd(chrtype, password) {
|
||||
if (chrtype == 1) {
|
||||
if(!$.common.numValid(password)){
|
||||
$.modal.alertWarning("密码只能为0-9数字");
|
||||
return false;
|
||||
}
|
||||
} else if (chrtype == 2) {
|
||||
if(!$.common.enValid(password)){
|
||||
$.modal.alertWarning("密码只能为a-z和A-Z字母");
|
||||
return false;
|
||||
}
|
||||
} else if (chrtype == 3) {
|
||||
if(!$.common.enNumValid(password)){
|
||||
$.modal.alertWarning("密码必须包含字母以及数字");
|
||||
return false;
|
||||
}
|
||||
} else if (chrtype == 4) {
|
||||
if(!$.common.charValid(password)){
|
||||
$.modal.alertWarning("密码必须包含字母、数字、以及特殊符号<font color='red'>~!@#$%^&*()-=_+</font>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// 日志打印封装处理
|
||||
var log = {
|
||||
log: function(msg) {
|
||||
console.log(msg);
|
||||
},
|
||||
info: function(msg) {
|
||||
console.info(msg);
|
||||
},
|
||||
warn: function(msg) {
|
||||
console.warn(msg);
|
||||
},
|
||||
error: function(msg) {
|
||||
console.error(msg);
|
||||
}
|
||||
};
|
||||
|
||||
// 本地缓存处理
|
||||
var storage = {
|
||||
set: function(key, value) {
|
||||
window.localStorage.setItem(key, value);
|
||||
},
|
||||
get: function(key) {
|
||||
return window.localStorage.getItem(key);
|
||||
},
|
||||
remove: function(key) {
|
||||
window.localStorage.removeItem(key);
|
||||
},
|
||||
clear: function() {
|
||||
window.localStorage.clear();
|
||||
}
|
||||
};
|
||||
|
||||
// 主子表操作封装处理
|
||||
var sub = {
|
||||
editColumn: function() {
|
||||
var dataColumns = [];
|
||||
for (var columnIndex = 0; columnIndex < table.options.columns.length; columnIndex++) {
|
||||
if (table.options.columns[columnIndex].visible != false) {
|
||||
dataColumns.push(table.options.columns[columnIndex]);
|
||||
}
|
||||
}
|
||||
var params = new Array();
|
||||
var data = $("#" + table.options.id).bootstrapTable('getData');
|
||||
var count = data.length;
|
||||
for (var dataIndex = 0; dataIndex < count; dataIndex++) {
|
||||
var columns = $('#' + table.options.id + ' tr[data-index="' + dataIndex + '"] td');
|
||||
var obj = new Object();
|
||||
for (var i = 0; i < columns.length; i++) {
|
||||
var inputValue = $(columns[i]).find('input');
|
||||
var selectValue = $(columns[i]).find('select');
|
||||
var textareaValue = $(columns[i]).find('textarea');
|
||||
var key = dataColumns[i].field;
|
||||
if ($.common.isNotEmpty(inputValue.val())) {
|
||||
obj[key] = inputValue.val();
|
||||
} else if ($.common.isNotEmpty(selectValue.val())) {
|
||||
obj[key] = selectValue.val();
|
||||
} else if ($.common.isNotEmpty(textareaValue.val())) {
|
||||
obj[key] = textareaValue.val();
|
||||
} else {
|
||||
obj[key] = "";
|
||||
}
|
||||
}
|
||||
var item = data[dataIndex];
|
||||
var extendObj = $.extend({}, item, obj);
|
||||
params.push({ index: dataIndex, row: extendObj });
|
||||
}
|
||||
$("#" + table.options.id).bootstrapTable("updateRow", params);
|
||||
},
|
||||
delColumn: function(column) {
|
||||
sub.editColumn();
|
||||
var subColumn = $.common.isEmpty(column) ? "index" : column;
|
||||
var ids = $.table.selectColumns(subColumn);
|
||||
if (ids.length == 0) {
|
||||
$.modal.alertWarning("请至少选择一条记录");
|
||||
return;
|
||||
}
|
||||
$("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids });
|
||||
},
|
||||
addColumn: function(row, tableId) {
|
||||
var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
|
||||
table.set(currentId);
|
||||
var count = $("#" + currentId).bootstrapTable('getData').length;
|
||||
sub.editColumn();
|
||||
$("#" + currentId).bootstrapTable('insertRow', {
|
||||
index: count + 1,
|
||||
row: row
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// 动态加载css文件
|
||||
function loadCss(file, headElem) {
|
||||
var link = document.createElement('link');
|
||||
link.href = file;
|
||||
link.rel = 'stylesheet';
|
||||
link.type = 'text/css';
|
||||
if (headElem) headElem.appendChild(link);
|
||||
else document.getElementsByTagName('head')[0].appendChild(link);
|
||||
}
|
||||
|
||||
// 动态加载js文件
|
||||
function loadJs(file, headElem) {
|
||||
var script = document.createElement('script');
|
||||
script.src = file;
|
||||
script.type = 'text/javascript';
|
||||
if (headElem) headElem.appendChild(script);
|
||||
else document.getElementsByTagName('head')[0].appendChild(script);
|
||||
}
|
||||
|
||||
/** 设置全局ajax处理 */
|
||||
$.ajaxSetup({
|
||||
complete: function(XMLHttpRequest, textStatus) {
|
||||
if (textStatus == 'timeout') {
|
||||
$.modal.alertWarning("服务器超时,请稍后再试!");
|
||||
$.modal.enable();
|
||||
$.modal.closeLoading();
|
||||
} else if (textStatus == "parsererror" || textStatus == "error") {
|
||||
$.modal.alertWarning("服务器错误,请联系管理员!");
|
||||
$.modal.enable();
|
||||
$.modal.closeLoading();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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>
|
||||
|
|
@ -223,5 +223,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
sysdate()
|
||||
)
|
||||
</insert>
|
||||
|
||||
<delete id="deleteEcologySyncUser" >
|
||||
delete from sys_user where user_type ='02'
|
||||
</delete>
|
||||
|
||||
</mapper>
|
||||
Loading…
Reference in New Issue