Merge branch 'dev' into kone_dev
This commit is contained in:
commit
e9bc9e8257
|
|
@ -35,6 +35,14 @@
|
||||||
<version>20160810</version>
|
<version>20160810</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-system</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</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>
|
<mybatis-spring-boot.version>2.1.4</mybatis-spring-boot.version>
|
||||||
<pagehelper.boot.version>1.3.1</pagehelper.boot.version>
|
<pagehelper.boot.version>1.3.1</pagehelper.boot.version>
|
||||||
<fastjson.version>1.2.76</fastjson.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>
|
<jna.version>5.8.0</jna.version>
|
||||||
<commons.io.version>2.10.0</commons.io.version>
|
<commons.io.version>2.10.0</commons.io.version>
|
||||||
<commons.fileupload.version>1.4</commons.fileupload.version>
|
<commons.fileupload.version>1.4</commons.fileupload.version>
|
||||||
|
|
|
||||||
|
|
@ -204,4 +204,22 @@ public class SysDeptController extends BaseController
|
||||||
List<Ztree> ztrees = deptService.roleDeptTreeData(role);
|
List<Ztree> ztrees = deptService.roleDeptTreeData(role);
|
||||||
return ztrees;
|
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);
|
userService.checkUserAllowed(user);
|
||||||
return toAjax(userService.changeStatus(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
|
* Copyright (c) 2019 ruoyi
|
||||||
*/
|
*/
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
// layer扩展皮肤
|
// layer扩展皮肤
|
||||||
if (window.layer !== undefined) {
|
if (window.layer !== undefined) {
|
||||||
layer.config({
|
layer.config({
|
||||||
extend: 'moon/style.css',
|
extend: 'moon/style.css',
|
||||||
skin: 'layer-ext-moon'
|
skin: 'layer-ext-moon'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// 回到顶部绑定
|
// 回到顶部绑定
|
||||||
if ($.fn.toTop !== undefined) {
|
if ($.fn.toTop !== undefined) {
|
||||||
$('#scroll-up').toTop();
|
$('#scroll-up').toTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
// select2复选框事件绑定
|
// select2复选框事件绑定
|
||||||
if ($.fn.select2 !== undefined) {
|
if ($.fn.select2 !== undefined) {
|
||||||
$.fn.select2.defaults.set( "theme", "bootstrap" );
|
$.fn.select2.defaults.set( "theme", "bootstrap" );
|
||||||
$("select.form-control:not(.noselect2)").each(function () {
|
$("select.form-control:not(.noselect2)").each(function () {
|
||||||
$(this).select2().on("change", function () {
|
$(this).select2().on("change", function () {
|
||||||
$(this).valid();
|
$(this).valid();
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// iCheck单选框及复选框事件绑定
|
// iCheck单选框及复选框事件绑定
|
||||||
if ($.fn.iCheck !== undefined) {
|
if ($.fn.iCheck !== undefined) {
|
||||||
$(".check-box:not(.noicheck),.radio-box:not(.noicheck)").each(function() {
|
$(".check-box:not(.noicheck),.radio-box:not(.noicheck)").each(function() {
|
||||||
$(this).iCheck({
|
$(this).iCheck({
|
||||||
checkboxClass: 'icheckbox-blue',
|
checkboxClass: 'icheckbox-blue',
|
||||||
radioClass: 'iradio-blue',
|
radioClass: 'iradio-blue',
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消回车自动提交表单
|
// 取消回车自动提交表单
|
||||||
$(document).on("keypress", ":input:not(textarea):not([type=submit])", function(event) {
|
$(document).on("keypress", ":input:not(textarea):not([type=submit])", function(event) {
|
||||||
if (event.keyCode == 13) {
|
if (event.keyCode == 13) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// laydate 时间控件绑定
|
// laydate 时间控件绑定
|
||||||
if ($(".select-time").length > 0) {
|
if ($(".select-time").length > 0) {
|
||||||
layui.use('laydate', function() {
|
layui.use('laydate', function() {
|
||||||
var laydate = layui.laydate;
|
var laydate = layui.laydate;
|
||||||
var startDate = laydate.render({
|
var startDate = laydate.render({
|
||||||
elem: '#startTime',
|
elem: '#startTime',
|
||||||
max: $('#endTime').val(),
|
max: $('#endTime').val(),
|
||||||
theme: 'molv',
|
theme: 'molv',
|
||||||
trigger: 'click',
|
trigger: 'click',
|
||||||
done: function(value, date) {
|
done: function(value, date) {
|
||||||
// 结束时间大于开始时间
|
// 结束时间大于开始时间
|
||||||
if (value !== '') {
|
if (value !== '') {
|
||||||
endDate.config.min.year = date.year;
|
endDate.config.min.year = date.year;
|
||||||
endDate.config.min.month = date.month - 1;
|
endDate.config.min.month = date.month - 1;
|
||||||
endDate.config.min.date = date.date;
|
endDate.config.min.date = date.date;
|
||||||
} else {
|
} else {
|
||||||
endDate.config.min.year = '';
|
endDate.config.min.year = '';
|
||||||
endDate.config.min.month = '';
|
endDate.config.min.month = '';
|
||||||
endDate.config.min.date = '';
|
endDate.config.min.date = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var endDate = laydate.render({
|
var endDate = laydate.render({
|
||||||
elem: '#endTime',
|
elem: '#endTime',
|
||||||
min: $('#startTime').val(),
|
min: $('#startTime').val(),
|
||||||
theme: 'molv',
|
theme: 'molv',
|
||||||
trigger: 'click',
|
trigger: 'click',
|
||||||
done: function(value, date) {
|
done: function(value, date) {
|
||||||
// 开始时间小于结束时间
|
// 开始时间小于结束时间
|
||||||
if (value !== '') {
|
if (value !== '') {
|
||||||
startDate.config.max.year = date.year;
|
startDate.config.max.year = date.year;
|
||||||
startDate.config.max.month = date.month - 1;
|
startDate.config.max.month = date.month - 1;
|
||||||
startDate.config.max.date = date.date;
|
startDate.config.max.date = date.date;
|
||||||
} else {
|
} else {
|
||||||
startDate.config.max.year = '2099';
|
startDate.config.max.year = '2099';
|
||||||
startDate.config.max.month = '12';
|
startDate.config.max.month = '12';
|
||||||
startDate.config.max.date = '31';
|
startDate.config.max.date = '31';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// laydate time-input 时间控件绑定
|
// laydate time-input 时间控件绑定
|
||||||
if ($(".time-input").length > 0) {
|
if ($(".time-input").length > 0) {
|
||||||
layui.use('laydate', function () {
|
layui.use('laydate', function () {
|
||||||
var com = layui.laydate;
|
var com = layui.laydate;
|
||||||
$(".time-input").each(function (index, item) {
|
$(".time-input").each(function (index, item) {
|
||||||
var time = $(item);
|
var time = $(item);
|
||||||
// 控制控件外观
|
// 控制控件外观
|
||||||
var type = time.attr("data-type") || 'date';
|
var type = time.attr("data-type") || 'date';
|
||||||
// 控制回显格式
|
// 控制回显格式
|
||||||
var format = time.attr("data-format") || 'yyyy-MM-dd';
|
var format = time.attr("data-format") || 'yyyy-MM-dd';
|
||||||
// 控制日期控件按钮
|
// 控制日期控件按钮
|
||||||
var buttons = time.attr("data-btn") || 'clear|now|confirm', newBtnArr = [];
|
var buttons = time.attr("data-btn") || 'clear|now|confirm', newBtnArr = [];
|
||||||
// 日期控件选择完成后回调处理
|
// 日期控件选择完成后回调处理
|
||||||
var callback = time.attr("data-callback") || {};
|
var callback = time.attr("data-callback") || {};
|
||||||
if (buttons) {
|
if (buttons) {
|
||||||
if (buttons.indexOf("|") > 0) {
|
if (buttons.indexOf("|") > 0) {
|
||||||
var btnArr = buttons.split("|"), btnLen = btnArr.length;
|
var btnArr = buttons.split("|"), btnLen = btnArr.length;
|
||||||
for (var j = 0; j < btnLen; j++) {
|
for (var j = 0; j < btnLen; j++) {
|
||||||
if ("clear" === btnArr[j] || "now" === btnArr[j] || "confirm" === btnArr[j]) {
|
if ("clear" === btnArr[j] || "now" === btnArr[j] || "confirm" === btnArr[j]) {
|
||||||
newBtnArr.push(btnArr[j]);
|
newBtnArr.push(btnArr[j]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ("clear" === buttons || "now" === buttons || "confirm" === buttons) {
|
if ("clear" === buttons || "now" === buttons || "confirm" === buttons) {
|
||||||
newBtnArr.push(buttons);
|
newBtnArr.push(buttons);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newBtnArr = ['clear', 'now', 'confirm'];
|
newBtnArr = ['clear', 'now', 'confirm'];
|
||||||
}
|
}
|
||||||
com.render({
|
com.render({
|
||||||
elem: item,
|
elem: item,
|
||||||
theme: 'molv',
|
theme: 'molv',
|
||||||
trigger: 'click',
|
trigger: 'click',
|
||||||
type: type,
|
type: type,
|
||||||
format: format,
|
format: format,
|
||||||
btns: newBtnArr,
|
btns: newBtnArr,
|
||||||
done: function (value, data) {
|
done: function (value, data) {
|
||||||
if (typeof window[callback] != 'undefined'
|
if (typeof window[callback] != 'undefined'
|
||||||
&& window[callback] instanceof Function) {
|
&& window[callback] instanceof Function) {
|
||||||
window[callback](value, data);
|
window[callback](value, data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// tree 关键字搜索绑定
|
// tree 关键字搜索绑定
|
||||||
if ($("#keyword").length > 0) {
|
if ($("#keyword").length > 0) {
|
||||||
$("#keyword").bind("focus", function focusKey(e) {
|
$("#keyword").bind("focus", function focusKey(e) {
|
||||||
if ($("#keyword").hasClass("empty")) {
|
if ($("#keyword").hasClass("empty")) {
|
||||||
$("#keyword").removeClass("empty");
|
$("#keyword").removeClass("empty");
|
||||||
}
|
}
|
||||||
}).bind("blur", function blurKey(e) {
|
}).bind("blur", function blurKey(e) {
|
||||||
if ($("#keyword").val() === "") {
|
if ($("#keyword").val() === "") {
|
||||||
$("#keyword").addClass("empty");
|
$("#keyword").addClass("empty");
|
||||||
}
|
}
|
||||||
$.tree.searchNode(e);
|
$.tree.searchNode(e);
|
||||||
}).bind("input propertychange", $.tree.searchNode);
|
}).bind("input propertychange", $.tree.searchNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
// tree表格树 展开/折叠
|
// tree表格树 展开/折叠
|
||||||
var expandFlag;
|
var expandFlag;
|
||||||
$("#expandAllBtn").click(function() {
|
$("#expandAllBtn").click(function() {
|
||||||
var dataExpand = $.common.isEmpty(table.options.expandAll) ? true : table.options.expandAll;
|
var dataExpand = $.common.isEmpty(table.options.expandAll) ? true : table.options.expandAll;
|
||||||
expandFlag = $.common.isEmpty(expandFlag) ? dataExpand : expandFlag;
|
expandFlag = $.common.isEmpty(expandFlag) ? dataExpand : expandFlag;
|
||||||
if (!expandFlag) {
|
if (!expandFlag) {
|
||||||
$.bttTable.bootstrapTreeTable('expandAll');
|
$.bttTable.bootstrapTreeTable('expandAll');
|
||||||
} else {
|
} else {
|
||||||
$.bttTable.bootstrapTreeTable('collapseAll');
|
$.bttTable.bootstrapTreeTable('collapseAll');
|
||||||
}
|
}
|
||||||
expandFlag = expandFlag ? false: true;
|
expandFlag = expandFlag ? false: true;
|
||||||
})
|
})
|
||||||
|
|
||||||
// 按下ESC按钮关闭弹层
|
// 按下ESC按钮关闭弹层
|
||||||
$('body', document).on('keyup', function(e) {
|
$('body', document).on('keyup', function(e) {
|
||||||
if (e.which === 27) {
|
if (e.which === 27) {
|
||||||
$.modal.closeAll();
|
$.modal.closeAll();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
(function ($) {
|
(function ($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
$.fn.toTop = function(opt) {
|
$.fn.toTop = function(opt) {
|
||||||
var elem = this;
|
var elem = this;
|
||||||
var win = (opt && opt.hasOwnProperty('win')) ? opt.win : $(window);
|
var win = (opt && opt.hasOwnProperty('win')) ? opt.win : $(window);
|
||||||
var doc = (opt && opt.hasOwnProperty('doc')) ? opt.doc : $('html, body');
|
var doc = (opt && opt.hasOwnProperty('doc')) ? opt.doc : $('html, body');
|
||||||
var options = $.extend({
|
var options = $.extend({
|
||||||
autohide: true,
|
autohide: true,
|
||||||
offset: 50,
|
offset: 50,
|
||||||
speed: 500,
|
speed: 500,
|
||||||
position: true,
|
position: true,
|
||||||
right: 15,
|
right: 15,
|
||||||
bottom: 5
|
bottom: 5
|
||||||
}, opt);
|
}, opt);
|
||||||
elem.css({
|
elem.css({
|
||||||
'cursor': 'pointer'
|
'cursor': 'pointer'
|
||||||
});
|
});
|
||||||
if (options.autohide) {
|
if (options.autohide) {
|
||||||
elem.css('display', 'none');
|
elem.css('display', 'none');
|
||||||
}
|
}
|
||||||
if (options.position) {
|
if (options.position) {
|
||||||
elem.css({
|
elem.css({
|
||||||
'position': 'fixed',
|
'position': 'fixed',
|
||||||
'right': options.right,
|
'right': options.right,
|
||||||
'bottom': options.bottom,
|
'bottom': options.bottom,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
elem.click(function() {
|
elem.click(function() {
|
||||||
doc.animate({
|
doc.animate({
|
||||||
scrollTop: 0
|
scrollTop: 0
|
||||||
}, options.speed);
|
}, options.speed);
|
||||||
});
|
});
|
||||||
win.scroll(function() {
|
win.scroll(function() {
|
||||||
var scrolling = win.scrollTop();
|
var scrolling = win.scrollTop();
|
||||||
if (options.autohide) {
|
if (options.autohide) {
|
||||||
if (scrolling > options.offset) {
|
if (scrolling > options.offset) {
|
||||||
elem.fadeIn(options.speed);
|
elem.fadeIn(options.speed);
|
||||||
} else elem.fadeOut(options.speed);
|
} else elem.fadeOut(options.speed);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
||||||
/** 刷新选项卡 */
|
/** 刷新选项卡 */
|
||||||
var refreshItem = function(){
|
var refreshItem = function(){
|
||||||
var topWindow = $(window.parent.document);
|
var topWindow = $(window.parent.document);
|
||||||
var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
|
var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
|
||||||
var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
|
var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
|
||||||
var url = target.attr('src');
|
var url = target.attr('src');
|
||||||
target.attr('src', url).ready();
|
target.attr('src', url).ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 关闭选项卡 */
|
/** 关闭选项卡 */
|
||||||
var closeItem = function(dataId){
|
var closeItem = function(dataId){
|
||||||
var topWindow = $(window.parent.document);
|
var topWindow = $(window.parent.document);
|
||||||
if($.common.isNotEmpty(dataId)){
|
if($.common.isNotEmpty(dataId)){
|
||||||
window.parent.$.modal.closeLoading();
|
window.parent.$.modal.closeLoading();
|
||||||
// 根据dataId关闭指定选项卡
|
// 根据dataId关闭指定选项卡
|
||||||
$('.menuTab[data-id="' + dataId + '"]', topWindow).remove();
|
$('.menuTab[data-id="' + dataId + '"]', topWindow).remove();
|
||||||
// 移除相应tab对应的内容区
|
// 移除相应tab对应的内容区
|
||||||
$('.mainContent .RuoYi_iframe[data-id="' + dataId + '"]', topWindow).remove();
|
$('.mainContent .RuoYi_iframe[data-id="' + dataId + '"]', topWindow).remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var panelUrl = window.frameElement.getAttribute('data-panel');
|
var panelUrl = window.frameElement.getAttribute('data-panel');
|
||||||
$('.page-tabs-content .active i', topWindow).click();
|
$('.page-tabs-content .active i', topWindow).click();
|
||||||
if($.common.isNotEmpty(panelUrl)){
|
if($.common.isNotEmpty(panelUrl)){
|
||||||
$('.menuTab[data-id="' + panelUrl + '"]', topWindow).addClass('active').siblings('.menuTab').removeClass('active');
|
$('.menuTab[data-id="' + panelUrl + '"]', topWindow).addClass('active').siblings('.menuTab').removeClass('active');
|
||||||
$('.mainContent .RuoYi_iframe', topWindow).each(function() {
|
$('.mainContent .RuoYi_iframe', topWindow).each(function() {
|
||||||
if ($(this).data('id') == panelUrl) {
|
if ($(this).data('id') == panelUrl) {
|
||||||
$(this).show().siblings('.RuoYi_iframe').hide();
|
$(this).show().siblings('.RuoYi_iframe').hide();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 创建选项卡 */
|
/** 创建选项卡 */
|
||||||
function createMenuItem(dataUrl, menuName, isRefresh) {
|
function createMenuItem(dataUrl, menuName, isRefresh) {
|
||||||
var panelUrl = window.frameElement.getAttribute('data-id');
|
var panelUrl = window.frameElement.getAttribute('data-id'),
|
||||||
dataIndex = $.common.random(1, 100),
|
dataIndex = $.common.random(1, 100),
|
||||||
flag = true;
|
flag = true;
|
||||||
if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false;
|
if (dataUrl == undefined || $.trim(dataUrl).length == 0) return false;
|
||||||
var topWindow = $(window.parent.document);
|
var topWindow = $(window.parent.document);
|
||||||
// 选项卡菜单已存在
|
// 选项卡菜单已存在
|
||||||
$('.menuTab', topWindow).each(function() {
|
$('.menuTab', topWindow).each(function() {
|
||||||
if ($(this).data('id') == dataUrl) {
|
if ($(this).data('id') == dataUrl) {
|
||||||
if (!$(this).hasClass('active')) {
|
if (!$(this).hasClass('active')) {
|
||||||
$(this).addClass('active').siblings('.menuTab').removeClass('active');
|
$(this).addClass('active').siblings('.menuTab').removeClass('active');
|
||||||
scrollToTab(this);
|
scrollToTab(this);
|
||||||
$('.page-tabs-content').animate({ marginLeft: ""}, "fast");
|
$('.page-tabs-content').animate({ marginLeft: ""}, "fast");
|
||||||
// 显示tab对应的内容区
|
// 显示tab对应的内容区
|
||||||
$('.mainContent .RuoYi_iframe', topWindow).each(function() {
|
$('.mainContent .RuoYi_iframe', topWindow).each(function() {
|
||||||
if ($(this).data('id') == dataUrl) {
|
if ($(this).data('id') == dataUrl) {
|
||||||
$(this).show().siblings('.RuoYi_iframe').hide();
|
$(this).show().siblings('.RuoYi_iframe').hide();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (isRefresh) {
|
if (isRefresh) {
|
||||||
refreshTab();
|
refreshTab();
|
||||||
}
|
}
|
||||||
flag = false;
|
flag = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 选项卡菜单不存在
|
// 选项卡菜单不存在
|
||||||
if (flag) {
|
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>';
|
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');
|
$('.menuTab', topWindow).removeClass('active');
|
||||||
|
|
||||||
// 添加选项卡对应的iframe
|
// 添加选项卡对应的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>';
|
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);
|
$('.mainContent', topWindow).find('iframe.RuoYi_iframe').hide().parents('.mainContent').append(str1);
|
||||||
|
|
||||||
window.parent.$.modal.loading("数据加载中,请稍后...");
|
window.parent.$.modal.loading("数据加载中,请稍后...");
|
||||||
$('.mainContent iframe:visible', topWindow).load(function () {
|
$('.mainContent iframe:visible', topWindow).load(function () {
|
||||||
window.parent.$.modal.closeLoading();
|
window.parent.$.modal.closeLoading();
|
||||||
});
|
});
|
||||||
|
|
||||||
// 添加选项卡
|
// 添加选项卡
|
||||||
$('.menuTabs .page-tabs-content', topWindow).append(str);
|
$('.menuTabs .page-tabs-content', topWindow).append(str);
|
||||||
scrollToTab($('.menuTab.active', topWindow));
|
scrollToTab($('.menuTab.active', topWindow));
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 刷新iframe
|
// 刷新iframe
|
||||||
function refreshTab() {
|
function refreshTab() {
|
||||||
var topWindow = $(window.parent.document);
|
var topWindow = $(window.parent.document);
|
||||||
var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
|
var currentId = $('.page-tabs-content', topWindow).find('.active').attr('data-id');
|
||||||
var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
|
var target = $('.RuoYi_iframe[data-id="' + currentId + '"]', topWindow);
|
||||||
var url = target.attr('src');
|
var url = target.attr('src');
|
||||||
target.attr('src', url).ready();
|
target.attr('src', url).ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
// 滚动到指定选项卡
|
// 滚动到指定选项卡
|
||||||
function scrollToTab(element) {
|
function scrollToTab(element) {
|
||||||
var topWindow = $(window.parent.document);
|
var topWindow = $(window.parent.document);
|
||||||
var marginLeftVal = calSumWidth($(element).prevAll()),
|
var marginLeftVal = calSumWidth($(element).prevAll()),
|
||||||
marginRightVal = calSumWidth($(element).nextAll());
|
marginRightVal = calSumWidth($(element).nextAll());
|
||||||
// 可视区域非tab宽度
|
// 可视区域非tab宽度
|
||||||
var tabOuterWidth = calSumWidth($(".content-tabs", topWindow).children().not(".menuTabs"));
|
var tabOuterWidth = calSumWidth($(".content-tabs", topWindow).children().not(".menuTabs"));
|
||||||
//可视区域tab宽度
|
//可视区域tab宽度
|
||||||
var visibleWidth = $(".content-tabs", topWindow).outerWidth(true) - tabOuterWidth;
|
var visibleWidth = $(".content-tabs", topWindow).outerWidth(true) - tabOuterWidth;
|
||||||
//实际滚动宽度
|
//实际滚动宽度
|
||||||
var scrollVal = 0;
|
var scrollVal = 0;
|
||||||
if ($(".page-tabs-content", topWindow).outerWidth() < visibleWidth) {
|
if ($(".page-tabs-content", topWindow).outerWidth() < visibleWidth) {
|
||||||
scrollVal = 0;
|
scrollVal = 0;
|
||||||
} else if (marginRightVal <= (visibleWidth - $(element).outerWidth(true) - $(element).next().outerWidth(true))) {
|
} else if (marginRightVal <= (visibleWidth - $(element).outerWidth(true) - $(element).next().outerWidth(true))) {
|
||||||
if ((visibleWidth - $(element).next().outerWidth(true)) > marginRightVal) {
|
if ((visibleWidth - $(element).next().outerWidth(true)) > marginRightVal) {
|
||||||
scrollVal = marginLeftVal;
|
scrollVal = marginLeftVal;
|
||||||
var tabElement = element;
|
var tabElement = element;
|
||||||
while ((scrollVal - $(tabElement).outerWidth()) > ($(".page-tabs-content", topWindow).outerWidth() - visibleWidth)) {
|
while ((scrollVal - $(tabElement).outerWidth()) > ($(".page-tabs-content", topWindow).outerWidth() - visibleWidth)) {
|
||||||
scrollVal -= $(tabElement).prev().outerWidth();
|
scrollVal -= $(tabElement).prev().outerWidth();
|
||||||
tabElement = $(tabElement).prev();
|
tabElement = $(tabElement).prev();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (marginLeftVal > (visibleWidth - $(element).outerWidth(true) - $(element).prev().outerWidth(true))) {
|
} else if (marginLeftVal > (visibleWidth - $(element).outerWidth(true) - $(element).prev().outerWidth(true))) {
|
||||||
scrollVal = marginLeftVal - $(element).prev().outerWidth(true);
|
scrollVal = marginLeftVal - $(element).prev().outerWidth(true);
|
||||||
}
|
}
|
||||||
$('.page-tabs-content', topWindow).animate({ marginLeft: 0 - scrollVal + 'px' }, "fast");
|
$('.page-tabs-content', topWindow).animate({ marginLeft: 0 - scrollVal + 'px' }, "fast");
|
||||||
}
|
}
|
||||||
|
|
||||||
//计算元素集合的总宽度
|
//计算元素集合的总宽度
|
||||||
function calSumWidth(elements) {
|
function calSumWidth(elements) {
|
||||||
var width = 0;
|
var width = 0;
|
||||||
$(elements).each(function() {
|
$(elements).each(function() {
|
||||||
width += $(this).outerWidth(true);
|
width += $(this).outerWidth(true);
|
||||||
});
|
});
|
||||||
return width;
|
return width;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 密码规则范围验证 */
|
/** 密码规则范围验证 */
|
||||||
function checkpwd(chrtype, password) {
|
function checkpwd(chrtype, password) {
|
||||||
if (chrtype == 1) {
|
if (chrtype == 1) {
|
||||||
if(!$.common.numValid(password)){
|
if(!$.common.numValid(password)){
|
||||||
$.modal.alertWarning("密码只能为0-9数字");
|
$.modal.alertWarning("密码只能为0-9数字");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (chrtype == 2) {
|
} else if (chrtype == 2) {
|
||||||
if(!$.common.enValid(password)){
|
if(!$.common.enValid(password)){
|
||||||
$.modal.alertWarning("密码只能为a-z和A-Z字母");
|
$.modal.alertWarning("密码只能为a-z和A-Z字母");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (chrtype == 3) {
|
} else if (chrtype == 3) {
|
||||||
if(!$.common.enNumValid(password)){
|
if(!$.common.enNumValid(password)){
|
||||||
$.modal.alertWarning("密码必须包含字母以及数字");
|
$.modal.alertWarning("密码必须包含字母以及数字");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else if (chrtype == 4) {
|
} else if (chrtype == 4) {
|
||||||
if(!$.common.charValid(password)){
|
if(!$.common.charValid(password)){
|
||||||
$.modal.alertWarning("密码必须包含字母、数字、以及特殊符号<font color='red'>~!@#$%^&*()-=_+</font>");
|
$.modal.alertWarning("密码必须包含字母、数字、以及特殊符号<font color='red'>~!@#$%^&*()-=_+</font>");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 日志打印封装处理
|
// 日志打印封装处理
|
||||||
var log = {
|
var log = {
|
||||||
log: function(msg) {
|
log: function(msg) {
|
||||||
console.log(msg);
|
console.log(msg);
|
||||||
},
|
},
|
||||||
info: function(msg) {
|
info: function(msg) {
|
||||||
console.info(msg);
|
console.info(msg);
|
||||||
},
|
},
|
||||||
warn: function(msg) {
|
warn: function(msg) {
|
||||||
console.warn(msg);
|
console.warn(msg);
|
||||||
},
|
},
|
||||||
error: function(msg) {
|
error: function(msg) {
|
||||||
console.error(msg);
|
console.error(msg);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 本地缓存处理
|
// 本地缓存处理
|
||||||
var storage = {
|
var storage = {
|
||||||
set: function(key, value) {
|
set: function(key, value) {
|
||||||
window.localStorage.setItem(key, value);
|
window.localStorage.setItem(key, value);
|
||||||
},
|
},
|
||||||
get: function(key) {
|
get: function(key) {
|
||||||
return window.localStorage.getItem(key);
|
return window.localStorage.getItem(key);
|
||||||
},
|
},
|
||||||
remove: function(key) {
|
remove: function(key) {
|
||||||
window.localStorage.removeItem(key);
|
window.localStorage.removeItem(key);
|
||||||
},
|
},
|
||||||
clear: function() {
|
clear: function() {
|
||||||
window.localStorage.clear();
|
window.localStorage.clear();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 主子表操作封装处理
|
// 主子表操作封装处理
|
||||||
var sub = {
|
var sub = {
|
||||||
editColumn: function() {
|
editColumn: function() {
|
||||||
var dataColumns = [];
|
var dataColumns = [];
|
||||||
for (var columnIndex = 0; columnIndex < table.options.columns.length; columnIndex++) {
|
for (var columnIndex = 0; columnIndex < table.options.columns.length; columnIndex++) {
|
||||||
if (table.options.columns[columnIndex].visible != false) {
|
if (table.options.columns[columnIndex].visible != false) {
|
||||||
dataColumns.push(table.options.columns[columnIndex]);
|
dataColumns.push(table.options.columns[columnIndex]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var params = new Array();
|
var params = new Array();
|
||||||
var data = $("#" + table.options.id).bootstrapTable('getData');
|
var data = $("#" + table.options.id).bootstrapTable('getData');
|
||||||
var count = data.length;
|
var count = data.length;
|
||||||
for (var dataIndex = 0; dataIndex < count; dataIndex++) {
|
for (var dataIndex = 0; dataIndex < count; dataIndex++) {
|
||||||
var columns = $('#' + table.options.id + ' tr[data-index="' + dataIndex + '"] td');
|
var columns = $('#' + table.options.id + ' tr[data-index="' + dataIndex + '"] td');
|
||||||
var obj = new Object();
|
var obj = new Object();
|
||||||
for (var i = 0; i < columns.length; i++) {
|
for (var i = 0; i < columns.length; i++) {
|
||||||
var inputValue = $(columns[i]).find('input');
|
var inputValue = $(columns[i]).find('input');
|
||||||
var selectValue = $(columns[i]).find('select');
|
var selectValue = $(columns[i]).find('select');
|
||||||
var textareaValue = $(columns[i]).find('textarea');
|
var textareaValue = $(columns[i]).find('textarea');
|
||||||
var key = dataColumns[i].field;
|
var key = dataColumns[i].field;
|
||||||
if ($.common.isNotEmpty(inputValue.val())) {
|
if ($.common.isNotEmpty(inputValue.val())) {
|
||||||
obj[key] = inputValue.val();
|
obj[key] = inputValue.val();
|
||||||
} else if ($.common.isNotEmpty(selectValue.val())) {
|
} else if ($.common.isNotEmpty(selectValue.val())) {
|
||||||
obj[key] = selectValue.val();
|
obj[key] = selectValue.val();
|
||||||
} else if ($.common.isNotEmpty(textareaValue.val())) {
|
} else if ($.common.isNotEmpty(textareaValue.val())) {
|
||||||
obj[key] = textareaValue.val();
|
obj[key] = textareaValue.val();
|
||||||
} else {
|
} else {
|
||||||
obj[key] = "";
|
obj[key] = "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
var item = data[dataIndex];
|
var item = data[dataIndex];
|
||||||
var extendObj = $.extend({}, item, obj);
|
var extendObj = $.extend({}, item, obj);
|
||||||
params.push({ index: dataIndex, row: extendObj });
|
params.push({ index: dataIndex, row: extendObj });
|
||||||
}
|
}
|
||||||
$("#" + table.options.id).bootstrapTable("updateRow", params);
|
$("#" + table.options.id).bootstrapTable("updateRow", params);
|
||||||
},
|
},
|
||||||
delColumn: function(column) {
|
delColumn: function(column) {
|
||||||
sub.editColumn();
|
sub.editColumn();
|
||||||
var subColumn = $.common.isEmpty(column) ? "index" : column;
|
var subColumn = $.common.isEmpty(column) ? "index" : column;
|
||||||
var ids = $.table.selectColumns(subColumn);
|
var ids = $.table.selectColumns(subColumn);
|
||||||
if (ids.length == 0) {
|
if (ids.length == 0) {
|
||||||
$.modal.alertWarning("请至少选择一条记录");
|
$.modal.alertWarning("请至少选择一条记录");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
$("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids });
|
$("#" + table.options.id).bootstrapTable('remove', { field: subColumn, values: ids });
|
||||||
},
|
},
|
||||||
addColumn: function(row, tableId) {
|
addColumn: function(row, tableId) {
|
||||||
var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
|
var currentId = $.common.isEmpty(tableId) ? table.options.id : tableId;
|
||||||
table.set(currentId);
|
table.set(currentId);
|
||||||
var count = $("#" + currentId).bootstrapTable('getData').length;
|
var count = $("#" + currentId).bootstrapTable('getData').length;
|
||||||
sub.editColumn();
|
sub.editColumn();
|
||||||
$("#" + currentId).bootstrapTable('insertRow', {
|
$("#" + currentId).bootstrapTable('insertRow', {
|
||||||
index: count + 1,
|
index: count + 1,
|
||||||
row: row
|
row: row
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// 动态加载css文件
|
// 动态加载css文件
|
||||||
function loadCss(file, headElem) {
|
function loadCss(file, headElem) {
|
||||||
var link = document.createElement('link');
|
var link = document.createElement('link');
|
||||||
link.href = file;
|
link.href = file;
|
||||||
link.rel = 'stylesheet';
|
link.rel = 'stylesheet';
|
||||||
link.type = 'text/css';
|
link.type = 'text/css';
|
||||||
if (headElem) headElem.appendChild(link);
|
if (headElem) headElem.appendChild(link);
|
||||||
else document.getElementsByTagName('head')[0].appendChild(link);
|
else document.getElementsByTagName('head')[0].appendChild(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 动态加载js文件
|
// 动态加载js文件
|
||||||
function loadJs(file, headElem) {
|
function loadJs(file, headElem) {
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = file;
|
script.src = file;
|
||||||
script.type = 'text/javascript';
|
script.type = 'text/javascript';
|
||||||
if (headElem) headElem.appendChild(script);
|
if (headElem) headElem.appendChild(script);
|
||||||
else document.getElementsByTagName('head')[0].appendChild(script);
|
else document.getElementsByTagName('head')[0].appendChild(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 设置全局ajax处理 */
|
/** 设置全局ajax处理 */
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
complete: function(XMLHttpRequest, textStatus) {
|
complete: function(XMLHttpRequest, textStatus) {
|
||||||
if (textStatus == 'timeout') {
|
if (textStatus == 'timeout') {
|
||||||
$.modal.alertWarning("服务器超时,请稍后再试!");
|
$.modal.alertWarning("服务器超时,请稍后再试!");
|
||||||
$.modal.enable();
|
$.modal.enable();
|
||||||
$.modal.closeLoading();
|
$.modal.closeLoading();
|
||||||
} else if (textStatus == "parsererror" || textStatus == "error") {
|
} else if (textStatus == "parsererror" || textStatus == "error") {
|
||||||
$.modal.alertWarning("服务器错误,请联系管理员!");
|
$.modal.alertWarning("服务器错误,请联系管理员!");
|
||||||
$.modal.enable();
|
$.modal.enable();
|
||||||
$.modal.closeLoading();
|
$.modal.closeLoading();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -219,10 +219,10 @@
|
||||||
<!-- 顶部菜单列表 -->
|
<!-- 顶部菜单列表 -->
|
||||||
<th:block th:each="menu : ${menus}">
|
<th:block th:each="menu : ${menus}">
|
||||||
<li role="presentation" th:id="|tab_${menu.menuId}|">
|
<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>
|
<i th:class="${menu.icon}"></i> <span>[[${menu.menuName}]]</span>
|
||||||
</a>
|
</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>
|
<i th:class="${menu.icon}"></i> <span>[[${menu.menuName}]]</span>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,10 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="btn-group-sm" id="toolbar" role="group">
|
<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> 新增
|
<i class="fa fa-plus"></i> 新增
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-primary" onclick="$.operate.edit()" shiro:hasPermission="system:dept:edit">
|
<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 editFlag = [[${@permission.hasPermi('system:dept:edit')}]];
|
||||||
var removeFlag = [[${@permission.hasPermi('system:dept:remove')}]];
|
var removeFlag = [[${@permission.hasPermi('system:dept:remove')}]];
|
||||||
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
var datas = [[${@dict.getType('sys_normal_disable')}]];
|
||||||
|
var deptSyncType = [[${#strings.defaultString(@config.getKey('sys.dept.sync'), 0)}]];
|
||||||
var prefix = ctx + "system/dept"
|
var prefix = ctx + "system/dept"
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
@ -107,6 +111,33 @@
|
||||||
};
|
};
|
||||||
$.treeTable.init(options);
|
$.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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
@ -62,6 +62,9 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="btn-group-sm" id="toolbar" role="group">
|
<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">
|
<a class="btn btn-success" onclick="$.operate.addTab()" shiro:hasPermission="system:user:add">
|
||||||
<i class="fa fa-plus"></i> 新增
|
<i class="fa fa-plus"></i> 新增
|
||||||
</a>
|
</a>
|
||||||
|
|
@ -262,6 +265,19 @@
|
||||||
$.operate.post(prefix + "/changeStatus", { "userId": userId, "status": 0 });
|
$.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>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
<!-- 导入区域 -->
|
<!-- 导入区域 -->
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ import java.net.SocketTimeoutException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLConnection;
|
import java.net.URLConnection;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
import javax.net.ssl.HostnameVerifier;
|
import javax.net.ssl.HostnameVerifier;
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
import javax.net.ssl.SSLContext;
|
import javax.net.ssl.SSLContext;
|
||||||
|
|
@ -19,6 +21,9 @@ import javax.net.ssl.X509TrustManager;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import com.ruoyi.common.constant.Constants;
|
import com.ruoyi.common.constant.Constants;
|
||||||
|
import org.springframework.http.ResponseEntity;
|
||||||
|
import org.springframework.web.client.RestClientException;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 通用http发送方法
|
* 通用http发送方法
|
||||||
|
|
@ -259,4 +264,32 @@ public class HttpUtils
|
||||||
return true;
|
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 })
|
@ExceptionHandler({ HttpRequestMethodNotSupportedException.class })
|
||||||
public AjaxResult handleException(HttpRequestMethodNotSupportedException e)
|
public AjaxResult handleException(HttpRequestMethodNotSupportedException e, HttpServletRequest request)
|
||||||
{
|
{
|
||||||
log.error(e.getMessage(), e);
|
String requestURI = request.getRequestURI();
|
||||||
return AjaxResult.error("不支持' " + e.getMethod() + "'请求");
|
String msg = String.format("访问的URL[%s]不支持%s请求", requestURI, e.getMethod());
|
||||||
|
log.error(msg, e);
|
||||||
|
return AjaxResult.error(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 拦截未知的运行时异常
|
* 拦截未知的运行时异常
|
||||||
*/
|
*/
|
||||||
@ExceptionHandler(RuntimeException.class)
|
@ExceptionHandler(RuntimeException.class)
|
||||||
public AjaxResult notFount(RuntimeException e)
|
public AjaxResult notFount(RuntimeException e, HttpServletRequest request)
|
||||||
{
|
{
|
||||||
log.error("运行时异常:", e);
|
String requestURI = request.getRequestURI();
|
||||||
return AjaxResult.error("运行时异常:" + e.getMessage());
|
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">
|
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="monitor:job:export">
|
||||||
<i class="fa fa-download"></i> 导出
|
<i class="fa fa-download"></i> 导出
|
||||||
</a>
|
</a>
|
||||||
|
<a class="btn btn-danger" onclick="closeItem()">
|
||||||
|
<i class="fa fa-reply-all"></i> 关闭
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-12 select-table table-striped">
|
<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 子部门数
|
* @return 子部门数
|
||||||
*/
|
*/
|
||||||
public int selectNormalChildrenDeptById(Long deptId);
|
public int selectNormalChildrenDeptById(Long deptId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Truncate部门表,用于与Ecology部门同步
|
||||||
|
*/
|
||||||
|
public void truncateDept();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,4 +121,9 @@ public interface SysUserMapper
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public SysUser checkEmailUnique(String email);
|
public SysUser checkEmailUnique(String email);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 删除Ecology同步过来的用户
|
||||||
|
*/
|
||||||
|
public void deleteEcologySyncUser();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -107,4 +107,9 @@ public interface ISysDeptService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public String checkDeptNameUnique(SysDept dept);
|
public String checkDeptNameUnique(SysDept dept);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ecology部门信息同步
|
||||||
|
*/
|
||||||
|
public int syncEcologyDept(String url,String params);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -204,4 +204,9 @@ public interface ISysUserService
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public int changeStatus(SysUser user);
|
public int changeStatus(SysUser user);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ecology人员信息同步
|
||||||
|
*/
|
||||||
|
public int syncEcologyUser(String url,String params);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,15 @@
|
||||||
package com.ruoyi.system.service.impl;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
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.apache.commons.lang3.ArrayUtils;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
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.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import com.ruoyi.common.annotation.DataScope;
|
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.common.utils.StringUtils;
|
||||||
import com.ruoyi.system.mapper.SysDeptMapper;
|
import com.ruoyi.system.mapper.SysDeptMapper;
|
||||||
import com.ruoyi.system.service.ISysDeptService;
|
import com.ruoyi.system.service.ISysDeptService;
|
||||||
|
import org.springframework.web.client.RestClientException;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 部门管理 服务实现
|
* 部门管理 服务实现
|
||||||
*
|
*
|
||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service("sysDeptServiceImpl")
|
||||||
public class SysDeptServiceImpl implements ISysDeptService
|
public class SysDeptServiceImpl implements ISysDeptService
|
||||||
{
|
{
|
||||||
@Autowired
|
@Autowired
|
||||||
|
|
@ -308,4 +315,80 @@ public class SysDeptServiceImpl implements ISysDeptService
|
||||||
}
|
}
|
||||||
return UserConstants.DEPT_NAME_UNIQUE;
|
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;
|
package com.ruoyi.system.service.impl;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import com.alibaba.fastjson.JSON;
|
||||||
import java.util.List;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
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.ruoyi.common.annotation.DataScope;
|
import com.ruoyi.common.annotation.DataScope;
|
||||||
import com.ruoyi.common.constant.UserConstants;
|
import com.ruoyi.common.constant.UserConstants;
|
||||||
import com.ruoyi.common.core.domain.entity.SysRole;
|
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.core.text.Convert;
|
||||||
import com.ruoyi.common.exception.BusinessException;
|
import com.ruoyi.common.exception.BusinessException;
|
||||||
import com.ruoyi.common.utils.StringUtils;
|
import com.ruoyi.common.utils.StringUtils;
|
||||||
|
import com.ruoyi.common.utils.http.HttpUtils;
|
||||||
import com.ruoyi.common.utils.security.Md5Utils;
|
import com.ruoyi.common.utils.security.Md5Utils;
|
||||||
|
import com.ruoyi.system.domain.EcologyUser;
|
||||||
import com.ruoyi.system.domain.SysPost;
|
import com.ruoyi.system.domain.SysPost;
|
||||||
import com.ruoyi.system.domain.SysUserPost;
|
import com.ruoyi.system.domain.SysUserPost;
|
||||||
import com.ruoyi.system.domain.SysUserRole;
|
import com.ruoyi.system.domain.SysUserRole;
|
||||||
import com.ruoyi.system.mapper.SysPostMapper;
|
import com.ruoyi.system.mapper.*;
|
||||||
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.service.ISysConfigService;
|
import com.ruoyi.system.service.ISysConfigService;
|
||||||
import com.ruoyi.system.service.ISysUserService;
|
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
|
* @author ruoyi
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service("sysUserServiceImpl")
|
||||||
public class SysUserServiceImpl implements ISysUserService
|
public class SysUserServiceImpl implements ISysUserService
|
||||||
{
|
{
|
||||||
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
private static final Logger log = LoggerFactory.getLogger(SysUserServiceImpl.class);
|
||||||
|
|
@ -525,4 +527,51 @@ public class SysUserServiceImpl implements ISysUserService
|
||||||
{
|
{
|
||||||
return userMapper.updateUser(user);
|
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>
|
</foreach>
|
||||||
</update>
|
</update>
|
||||||
|
|
||||||
|
<update id="truncateDept">
|
||||||
|
truncate table sys_dept
|
||||||
|
</update>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|
@ -223,5 +223,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||||
sysdate()
|
sysdate()
|
||||||
)
|
)
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
|
<delete id="deleteEcologySyncUser" >
|
||||||
|
delete from sys_user where user_type ='02'
|
||||||
|
</delete>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
Loading…
Reference in New Issue