添加机构信息管理功能
This commit is contained in:
310
erp_web/pages/manage/organization.html
Normal file
310
erp_web/pages/manage/organization.html
Normal file
@@ -0,0 +1,310 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>机构管理</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<!-- 指定以IE8的方式来渲染 -->
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
|
||||||
|
<meta http-equiv="Pragma" content="no-cache">
|
||||||
|
<meta http-equiv="Cache-Control" content="no-cache">
|
||||||
|
<meta http-equiv="Expires" content="-1">
|
||||||
|
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/>
|
||||||
|
<script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/default/easyui.css"/>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/icon.css"/>
|
||||||
|
<link type="text/css" rel="stylesheet" href="/css/common.css"/>
|
||||||
|
<script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/common/common.js"></script>
|
||||||
|
<script src="/js/My97DatePicker/WdatePicker.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- 数据显示table -->
|
||||||
|
<div id="tablePanel" class="easyui-panel" style="padding:1px;top:300px;" title="机构列表" iconCls="icon-list"
|
||||||
|
collapsible="true" closable="false">
|
||||||
|
<table id="tableData" style="top:300px;border-bottom-color:#FFFFFF">
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
<div id="organizationDlg" class="easyui-dialog" style="width:380px;padding:10px 20px"
|
||||||
|
closed="true" buttons="#dlg-buttons" modal="true" cache="false" collapsible="false" closable="true">
|
||||||
|
<form id="organizationFM" method="post" novalidate>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>上级机构</td>
|
||||||
|
<td style="padding:5px">
|
||||||
|
<input name="orgParentName" id="orgParentName" style="width: 200px;height: 20px" readonly="readonly"/>
|
||||||
|
<a href="javascript:void(0)" class="l-btn l-btn-plain" group="" id="lookForSelectOrganization">
|
||||||
|
<span class="l-btn-left"><span class="l-btn-text icon-search l-btn-icon-left"></span></span></a>
|
||||||
|
<input name="orgParentNo" id="orgParentNo" type="hidden"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>全称</td>
|
||||||
|
<td style="padding:5px">
|
||||||
|
<input name="orgFullName" id="orgFullName" class="easyui-validatebox"
|
||||||
|
data-options="required:true,validType:'length[2,30]'" style="width: 200px;height: 20px"/>
|
||||||
|
<input name="id" id="id" type="hidden"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>简称</td>
|
||||||
|
<td style="padding:5px">
|
||||||
|
<input name="orgAbr" id="orgAbr" class="easyui-validatebox"
|
||||||
|
data-options="required:true,validType:'length[2,30]'" style="width: 200px;height: 20px"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<!--<tr>
|
||||||
|
<td>类型</td>
|
||||||
|
<td style="padding:5px">
|
||||||
|
<input name="orgTpcd" id="orgTpcd" class="easyui-validatebox"
|
||||||
|
data-options="required:true,validType:'length[2,30]'" style="width: 200px;height: 20px"/>
|
||||||
|
</td>
|
||||||
|
</tr>-->
|
||||||
|
<tr>
|
||||||
|
<td>状态</td>
|
||||||
|
<td style="padding:5px">
|
||||||
|
<input name="orgStcd" id="orgStcd" class="easyui-validatebox"
|
||||||
|
data-options="required:true,validType:'length[2,30]'" style="width: 200px;height: 20px"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>编号</td>
|
||||||
|
<td style="padding:5px">
|
||||||
|
<input name="orgNo" id="orgNo" style="width: 200px;height: 20px"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>序号</td>
|
||||||
|
<td style="padding:5px">
|
||||||
|
<input name="sort" id="sort" style="width: 200px;height: 20px"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>开创时间</td>
|
||||||
|
<td style="padding:5px">
|
||||||
|
<input type="text" name="orgCreateTime" id="orgCreateTime"
|
||||||
|
onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="txt Wdate" style="width:200px;"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>停业时间</td>
|
||||||
|
<td style="padding:5px">
|
||||||
|
<input type="text" name="orgStopTime" id="orgStopTime"
|
||||||
|
onClick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" class="txt Wdate" style="width:200px;"/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>备注</td>
|
||||||
|
<td style="padding:5px">
|
||||||
|
<textarea name="remark" id="remark" placeholder="暂无备注信息"
|
||||||
|
style="width: 200px; height:40px;"></textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<div id="dlg-buttons">
|
||||||
|
<a href="javascript:void(0)" id="saveOrganization" class="easyui-linkbutton" iconCls="icon-ok">保存</a>
|
||||||
|
<a href="javascript:void(0)" id="cancelOrganization" class="easyui-linkbutton" iconCls="icon-cancel"
|
||||||
|
onclick="javascript:$('#organizationDlg').dialog('close')">取消</a>
|
||||||
|
</div>
|
||||||
|
<div id="forSelectOrganizationDlg" class="easyui-dialog" style="width:380px;padding:10px 20px"
|
||||||
|
closed="true" modal="true" cache="false" collapsible="false" closable="true">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
var url;
|
||||||
|
//初始化界面
|
||||||
|
$(function () {
|
||||||
|
var treeHeight=webH-35;
|
||||||
|
//初始化系统基础信息
|
||||||
|
$('#tableData').datagrid({
|
||||||
|
height: treeHeight,
|
||||||
|
toolbar: [
|
||||||
|
{
|
||||||
|
id: 'addOrganization',
|
||||||
|
text: '增加',
|
||||||
|
iconCls: 'icon-add',
|
||||||
|
handler: function () {
|
||||||
|
addOrganization();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'-',
|
||||||
|
{
|
||||||
|
id: 'deleteOrganization',
|
||||||
|
text: '删除',
|
||||||
|
iconCls: 'icon-remove',
|
||||||
|
handler: function () {
|
||||||
|
batDeleteOrganization();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
});
|
||||||
|
$('#tableData').prev('.datagrid-view2').find(".datagrid-body").append("<ul id='tt'><ul>");
|
||||||
|
$('#tt').tree({
|
||||||
|
url: '/organization/getOrganizationTree',
|
||||||
|
animate: true,
|
||||||
|
checkbox: true,
|
||||||
|
onDblClick: function(node){
|
||||||
|
//双击修改
|
||||||
|
editOrganization(node);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function addOrganization() {
|
||||||
|
$('#OrganizationFM').form('clear');
|
||||||
|
$('#organizationDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/edit_add.png"/> 增加机构信息');
|
||||||
|
$(".window-mask").css({width: webW, height: webH});
|
||||||
|
$("#orgAbr").val("").focus();
|
||||||
|
$("#orgParentName").val("");
|
||||||
|
$("#orgParentNo").val("");
|
||||||
|
$("#orgFullName").val("");
|
||||||
|
$("#orgTpcd").val("");
|
||||||
|
$("#orgStcd").val("");
|
||||||
|
$("#orgNo").val("");
|
||||||
|
$("#sort").val("");
|
||||||
|
$("#orgCreateTime").val("");
|
||||||
|
$("#orgStopTime").val("");
|
||||||
|
$("#remark").val("");
|
||||||
|
$("#id").val("");
|
||||||
|
url = '/organization/addOrganization';
|
||||||
|
}
|
||||||
|
function editOrganization(node) {
|
||||||
|
var id=node.id;
|
||||||
|
$.ajax({
|
||||||
|
type: "post",
|
||||||
|
url: '/organization/findById',
|
||||||
|
dataType: "json",
|
||||||
|
data: ({
|
||||||
|
id: id
|
||||||
|
}),
|
||||||
|
success: function(res) {
|
||||||
|
if(res) {
|
||||||
|
if(res.code!=200){
|
||||||
|
$.messager.alert('提示', res.msg, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('#organizationFM').form('clear');
|
||||||
|
$('#organizationDlg').dialog('open').dialog('setTitle', '<img src="/js/easyui-1.3.5/themes/icons/edit_add.png"/> 修改机构信息');
|
||||||
|
$(".window-mask").css({width: webW, height: webH});
|
||||||
|
$("#orgAbr").val(res.data.orgAbr).focus();
|
||||||
|
$("#orgParentName").val(res.data.orgParentName);
|
||||||
|
$("#orgParentNo").val(res.data.orgParentNo);
|
||||||
|
$("#orgFullName").val(res.data.orgFullName);
|
||||||
|
$("#orgTpcd").val(res.data.orgTpcd);
|
||||||
|
$("#orgStcd").val(res.data.orgStcd);
|
||||||
|
$("#orgNo").val(res.data.orgNo);
|
||||||
|
$("#orgFullName").val(res.data.orgFullName);
|
||||||
|
$("#sort").val(res.data.sort);
|
||||||
|
$("#orgCreateTime").val(res.data.orgCreateTime);
|
||||||
|
$("#orgStopTime").val(res.data.orgStopTime);
|
||||||
|
$("#remark").val(res.data.remark);
|
||||||
|
$("#id").val(res.data.id);
|
||||||
|
url = '/organization/editOrganization';
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//此处添加错误处理
|
||||||
|
error: function () {
|
||||||
|
$.messager.alert('提示', '修改机构信息异常,请稍后再试!', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//批量删除机构信息
|
||||||
|
function batDeleteOrganization() {
|
||||||
|
var nodes = $('#tt').tree('getChecked');
|
||||||
|
if (nodes.length == 0) {
|
||||||
|
$.messager.alert('删除提示', '没有记录被选中!', 'info');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (nodes.length > 0) {
|
||||||
|
$.messager.confirm('删除确认', '确定要删除选中的' + nodes.length + '条机构信息吗?', function (r) {
|
||||||
|
if (r) {
|
||||||
|
var ids = "";
|
||||||
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
|
if (i == nodes.length - 1) {
|
||||||
|
ids += nodes[i].id;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//alert(row[i].id);
|
||||||
|
ids += nodes[i].id + ",";
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
type: "post",
|
||||||
|
url: "/organization/batchDeleteOrganization",
|
||||||
|
dataType: "json",
|
||||||
|
async: false,
|
||||||
|
data: ({
|
||||||
|
ids: ids
|
||||||
|
}),
|
||||||
|
success: function (res) {
|
||||||
|
if(res.code!=200){
|
||||||
|
$.messager.alert('提示', res.msg, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('#tt').tree('reload');
|
||||||
|
},
|
||||||
|
//此处添加错误处理
|
||||||
|
error: function () {
|
||||||
|
$.messager.alert('删除提示', '删除机构信息异常,请稍后再试!', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//保存信息
|
||||||
|
$("#saveOrganization").off("click").on("click", function () {
|
||||||
|
if (!$("#orgAbr").val()) {
|
||||||
|
$.messager.alert('提示', '机构名称不能为空!', 'warning');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var objInfo = $("#organizationFM").serializeObject();
|
||||||
|
$.ajax({
|
||||||
|
type: "post",
|
||||||
|
url: url,
|
||||||
|
dataType: "json",
|
||||||
|
data: ({
|
||||||
|
info: JSON.stringify(objInfo)
|
||||||
|
}),
|
||||||
|
success: function(res) {
|
||||||
|
if(res) {
|
||||||
|
if(res.code!=200){
|
||||||
|
$.messager.alert('提示', res.msg, 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
$('#organizationDlg').dialog('close');
|
||||||
|
//加载完以后重新初始化
|
||||||
|
$('#tt').tree('reload');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
//此处添加错误处理
|
||||||
|
error: function () {
|
||||||
|
$.messager.alert('提示', '保存机构信息异常,请稍后再试!', 'error');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
//查询父级机构信息
|
||||||
|
$("#lookForSelectOrganization").on("click", function () {
|
||||||
|
$('#forSelectOrganizationDlg').dialog({
|
||||||
|
title: '机构选择',
|
||||||
|
width: webW/2,
|
||||||
|
height: webH/2,
|
||||||
|
closed: false,
|
||||||
|
cache: false,
|
||||||
|
href: '/pages/manage/organization_forselect.html',
|
||||||
|
modal: true,
|
||||||
|
resizable:true
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
45
erp_web/pages/manage/organization_forselect.html
Normal file
45
erp_web/pages/manage/organization_forselect.html
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>机构选择</title>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<!-- 指定以IE8的方式来渲染 -->
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8"/>
|
||||||
|
<link rel="shortcut icon" href="/images/favicon.ico" type="image/x-icon"/>
|
||||||
|
<script type="text/javascript" src="/js/jquery-1.8.0.min.js"></script>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/default/easyui.css"/>
|
||||||
|
<link rel="stylesheet" type="text/css" href="/js/easyui-1.3.5/themes/icon.css"/>
|
||||||
|
<link type="text/css" rel="stylesheet" href="/css/common.css"/>
|
||||||
|
<script type="text/javascript" src="/js/easyui-1.3.5/jquery.easyui.min.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/easyui-1.3.5/locale/easyui-lang-zh_CN.js"></script>
|
||||||
|
<script type="text/javascript" src="/js/common/common.js"></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<!-- 数据显示table -->
|
||||||
|
<div>
|
||||||
|
<ul id="ttForSelect"></ul>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
$(function () {
|
||||||
|
$('#ttForSelect').tree({
|
||||||
|
url: '/organization/getOrganizationTree',
|
||||||
|
animate: true,
|
||||||
|
onDblClick: function (node) {
|
||||||
|
//双击修改
|
||||||
|
forSelectOrganization(node);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function forSelectOrganization(node) {
|
||||||
|
console.log(node);
|
||||||
|
$("#orgParentName").val(node.text);
|
||||||
|
$("#orgParentNo").val(node.attributes);
|
||||||
|
$('#forSelectOrganizationDlg').dialog('close');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -1253,3 +1253,59 @@ where Id = 5;
|
|||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
alter table jsh_depot add principal bigint(20) DEFAULT null COMMENT '负责人';
|
alter table jsh_depot add principal bigint(20) DEFAULT null COMMENT '负责人';
|
||||||
|
|
||||||
|
-- ----------------------------
|
||||||
|
-- 时间:2019年3月6日
|
||||||
|
-- version:1.0.5
|
||||||
|
-- 此次更新
|
||||||
|
-- 1、添加机构表
|
||||||
|
-- 2、添加机构用户关系表
|
||||||
|
-- 特别提醒:之后的sql都是在之前基础上迭代,可以对已存在的系统进行数据保留更新
|
||||||
|
-- ----------------------------
|
||||||
|
-- ----------------------------
|
||||||
|
-- 添加机构表
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `jsh_organization`;
|
||||||
|
CREATE TABLE `jsh_organization` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`org_no` varchar(20) DEFAULT NULL COMMENT '机构编号',
|
||||||
|
`org_full_name` varchar(500) DEFAULT NULL COMMENT '机构全称',
|
||||||
|
`org_abr` varchar(20) DEFAULT NULL COMMENT '机构简称',
|
||||||
|
`org_tpcd` varchar(9) DEFAULT NULL COMMENT '机构类型',
|
||||||
|
`org_stcd` char(1) DEFAULT NULL COMMENT '机构状态,1未营业、2正常营业、3暂停营业、4终止营业、5已除名',
|
||||||
|
`org_parent_no` varchar(20) DEFAULT NULL COMMENT '机构父节点编号',
|
||||||
|
`sort` varchar(20) DEFAULT NULL COMMENT '机构显示顺序',
|
||||||
|
remark VARCHAR(500) DEFAULT null COMMENT '备注',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`creator` bigint(20) DEFAULT NULL COMMENT '创建人',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`updater` bigint(20) DEFAULT NULL COMMENT '更新人',
|
||||||
|
`org_create_time` datetime DEFAULT NULL COMMENT '机构创建时间',
|
||||||
|
`org_stop_time` datetime DEFAULT NULL COMMENT '机构停运时间',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='机构表';
|
||||||
|
-- ----------------------------
|
||||||
|
-- 添加机构用户关系表
|
||||||
|
-- ----------------------------
|
||||||
|
DROP TABLE IF EXISTS `jsh_orga_user_rel`;
|
||||||
|
CREATE TABLE `jsh_orga_user_rel` (
|
||||||
|
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||||
|
`orga_id` bigint(20) NOT NULL COMMENT '机构id',
|
||||||
|
`user_id` bigint(20) NOT NULL COMMENT '用户id',
|
||||||
|
`user_blng_orga_dspl_seq` varchar(20) DEFAULT NULL COMMENT '用户在所属机构中显示顺序',
|
||||||
|
`delete_flag` char(1) DEFAULT 0 COMMENT '删除标记,0未删除,1删除',
|
||||||
|
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||||
|
`creator` bigint(20) DEFAULT NULL COMMENT '创建人',
|
||||||
|
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||||
|
`updater` bigint(20) DEFAULT NULL COMMENT '更新人',
|
||||||
|
PRIMARY KEY (`id`)
|
||||||
|
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COMMENT='机构用户关系表';
|
||||||
|
-- ----------------------------
|
||||||
|
-- 添加机构管理菜单
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `jsh_functions`(`Number`, `Name`, `PNumber`, `URL`, `State`, `Sort`, `Enabled`, `Type`, `PushBtn`) VALUES ('000108', '机构管理', '0001', '../manage/organization.html', b'1', '0139', b'1', '电脑版', '');
|
||||||
|
-- ----------------------------
|
||||||
|
-- 添加根机构
|
||||||
|
-- ----------------------------
|
||||||
|
INSERT INTO `jsh_organization`(`org_no`, `org_full_name`, `org_abr`, `org_tpcd`, `org_stcd`, `org_parent_no`, `sort`, `remark`, `create_time`, `creator`, `update_time`, `updater`, `org_create_time`, `org_stop_time`) VALUES ('01', '根机构', '根机构', NULL, '2', '-1', '1', '根机构,初始化存在', NULL, NULL, NULL, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -3,8 +3,8 @@ package com.jsh.erp.constants;
|
|||||||
/**
|
/**
|
||||||
* @ClassName:BusinessConstants
|
* @ClassName:BusinessConstants
|
||||||
* @Description 业务字典类
|
* @Description 业务字典类
|
||||||
* @Author linshengming
|
* @Author qiankunpingtai
|
||||||
* @Date 2018-9-15 17:58
|
* @Date 2019-3-6 17:58
|
||||||
* @Version 1.0
|
* @Version 1.0
|
||||||
**/
|
**/
|
||||||
public class BusinessConstants {
|
public class BusinessConstants {
|
||||||
@@ -85,6 +85,21 @@ public class BusinessConstants {
|
|||||||
public static final String MATERIAL_CATEGORY_STATUS_DEFAULT = "0";
|
public static final String MATERIAL_CATEGORY_STATUS_DEFAULT = "0";
|
||||||
public static final String MATERIAL_CATEGORY_STATUS_ENABLE = "1";
|
public static final String MATERIAL_CATEGORY_STATUS_ENABLE = "1";
|
||||||
public static final String MATERIAL_CATEGORY_STATUS_DELETE = "2";
|
public static final String MATERIAL_CATEGORY_STATUS_DELETE = "2";
|
||||||
|
/**
|
||||||
|
* 机构状态
|
||||||
|
* 1未营业、2正常营业、3暂停营业、4终止营业,5已除名
|
||||||
|
* */
|
||||||
|
public static final String ORGANIZATION_STCD_NOT_OPEN = "1";
|
||||||
|
public static final String ORGANIZATION_STCD_OPEN = "2";
|
||||||
|
public static final String ORGANIZATION_STCD_BUSINESS_SUSPENDED = "3";
|
||||||
|
public static final String ORGANIZATION_STCD_BUSINESS_TERMINATED = "4";
|
||||||
|
public static final String ORGANIZATION_STCD_REMOVED = "5";
|
||||||
|
/**
|
||||||
|
* 根机构编号
|
||||||
|
* 根机构编号默认为01
|
||||||
|
* */
|
||||||
|
public static final String ORGANIZATION_ROOT_NO = "01";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -75,6 +75,28 @@ public class ExceptionConstants {
|
|||||||
//商品类别编号已存在
|
//商品类别编号已存在
|
||||||
public static final int MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE = 7500003;
|
public static final int MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_CODE = 7500003;
|
||||||
public static final String MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG = "商品类别编号已存在";
|
public static final String MATERIAL_CATEGORY_SERIAL_ALREADY_EXISTS_MSG = "商品类别编号已存在";
|
||||||
|
/**
|
||||||
|
* 机构
|
||||||
|
* type = 110
|
||||||
|
* */
|
||||||
|
//添加机构信息失败
|
||||||
|
public static final int ORGANIZATION_ADD_FAILED_CODE = 11000000;
|
||||||
|
public static final String ORGANIZATION_ADD_FAILED_MSG = "添加机构信息失败";
|
||||||
|
//删除机构信息失败
|
||||||
|
public static final int ORGANIZATION_DELETE_FAILED_CODE = 11000001;
|
||||||
|
public static final String ORGANIZATION_DELETE_FAILED_MSG = "删除机构信息失败";
|
||||||
|
//修改机构信息失败
|
||||||
|
public static final int ORGANIZATION_EDIT_FAILED_CODE = 11000002;
|
||||||
|
public static final String ORGANIZATION_EDIT_FAILED_MSG = "修改机构信息失败";
|
||||||
|
//机构编号已存在
|
||||||
|
public static final int ORGANIZATION_NO_ALREADY_EXISTS_CODE = 11000003;
|
||||||
|
public static final String ORGANIZATION_NO_ALREADY_EXISTS_MSG = "机构编号已存在";
|
||||||
|
//根机构不允许删除
|
||||||
|
public static final int ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_CODE = 11000004;
|
||||||
|
public static final String ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_MSG = "根机构不允许删除";
|
||||||
|
//根机构不允许修改
|
||||||
|
public static final int ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE = 11000005;
|
||||||
|
public static final String ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG = "根机构不允许修改";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 标准正常返回/操作成功返回
|
* 标准正常返回/操作成功返回
|
||||||
|
|||||||
@@ -137,8 +137,8 @@ public class MaterialCategoryController {
|
|||||||
MaterialCategory mc= JSON.parseObject(beanJson, MaterialCategory.class);
|
MaterialCategory mc= JSON.parseObject(beanJson, MaterialCategory.class);
|
||||||
int i= materialCategoryService.editMaterialCategory(mc);
|
int i= materialCategoryService.editMaterialCategory(mc);
|
||||||
if(i<1){
|
if(i<1){
|
||||||
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_ADD_FAILED_CODE,
|
throw new BusinessRunTimeException(ExceptionConstants.MATERIAL_CATEGORY_EDIT_FAILED_CODE,
|
||||||
ExceptionConstants.MATERIAL_CATEGORY_ADD_FAILED_MSG);
|
ExceptionConstants.MATERIAL_CATEGORY_EDIT_FAILED_MSG);
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
159
src/main/java/com/jsh/erp/controller/OrganizationController.java
Normal file
159
src/main/java/com/jsh/erp/controller/OrganizationController.java
Normal file
@@ -0,0 +1,159 @@
|
|||||||
|
package com.jsh.erp.controller;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONArray;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
|
import com.jsh.erp.datasource.entities.MaterialCategory;
|
||||||
|
import com.jsh.erp.datasource.entities.Organization;
|
||||||
|
import com.jsh.erp.datasource.vo.TreeNode;
|
||||||
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
|
import com.jsh.erp.service.materialCategory.MaterialCategoryService;
|
||||||
|
import com.jsh.erp.service.organization.OrganizationService;
|
||||||
|
import com.jsh.erp.utils.BaseResponseInfo;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create by: cjl
|
||||||
|
* description:
|
||||||
|
*
|
||||||
|
* create time: 2019/3/6 10:54
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping(value = "/organization")
|
||||||
|
public class OrganizationController {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(OrganizationController.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrganizationService organizationService;
|
||||||
|
/**
|
||||||
|
* 根据id来查询机构信息
|
||||||
|
* @param id
|
||||||
|
* @param request
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/findById")
|
||||||
|
public BaseResponseInfo findById(@RequestParam("id") Long id, HttpServletRequest request) throws Exception {
|
||||||
|
BaseResponseInfo res = new BaseResponseInfo();
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||||
|
try {
|
||||||
|
List<Organization> dataList = organizationService.findById(id);
|
||||||
|
JSONObject outer = new JSONObject();
|
||||||
|
if (null != dataList) {
|
||||||
|
for (Organization org : dataList) {
|
||||||
|
outer.put("id", org.getId());
|
||||||
|
outer.put("orgFullName", org.getOrgFullName());
|
||||||
|
outer.put("orgAbr", org.getOrgAbr());
|
||||||
|
outer.put("orgParentNo", org.getOrgParentNo());
|
||||||
|
List<Organization> dataParentList = organizationService.findByOrgNo(org.getOrgNo());
|
||||||
|
if(dataParentList!=null&&dataParentList.size()>0){
|
||||||
|
//父级机构名称显示简称
|
||||||
|
outer.put("orgParentName", dataParentList.get(0).getOrgAbr());
|
||||||
|
}
|
||||||
|
outer.put("orgTpcd", org.getOrgTpcd());
|
||||||
|
outer.put("orgStcd", org.getOrgStcd());
|
||||||
|
outer.put("orgNo", org.getOrgNo());
|
||||||
|
outer.put("sort", org.getSort());
|
||||||
|
outer.put("orgCreateTime", sdf.format(org.getOrgCreateTime()));
|
||||||
|
outer.put("orgStopTime", sdf.format(org.getOrgStopTime()));
|
||||||
|
outer.put("remark", org.getRemark());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.code = 200;
|
||||||
|
res.data = outer;
|
||||||
|
} catch(Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
res.code = 500;
|
||||||
|
res.data = "获取数据失败";
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* create by: cjl
|
||||||
|
* description:
|
||||||
|
* 获取机构树数据
|
||||||
|
* create time: 2019/2/19 11:49
|
||||||
|
* @Param:
|
||||||
|
* @return com.alibaba.fastjson.JSONArray
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/getOrganizationTree")
|
||||||
|
public JSONArray getOrganizationTree() throws Exception{
|
||||||
|
JSONArray arr=new JSONArray();
|
||||||
|
List<TreeNode> organizationTree= organizationService.getOrganizationTree();
|
||||||
|
if(organizationTree!=null&&organizationTree.size()>0){
|
||||||
|
for(TreeNode node:organizationTree){
|
||||||
|
String str=JSON.toJSONString(node);
|
||||||
|
JSONObject obj=JSON.parseObject(str);
|
||||||
|
arr.add(obj) ;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return arr;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* create by: cjl
|
||||||
|
* description:
|
||||||
|
* 新增机构信息
|
||||||
|
* create time: 2019/2/19 17:17
|
||||||
|
* @Param: beanJson
|
||||||
|
* @return java.lang.Object
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/addOrganization")
|
||||||
|
public Object addOrganization(@RequestParam("info") String beanJson) throws Exception {
|
||||||
|
JSONObject result = ExceptionConstants.standardSuccess();
|
||||||
|
Organization org= JSON.parseObject(beanJson, Organization.class);
|
||||||
|
int i= organizationService.addOrganization(org);
|
||||||
|
if(i<1){
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_ADD_FAILED_CODE,
|
||||||
|
ExceptionConstants.ORGANIZATION_ADD_FAILED_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* create by: cjl
|
||||||
|
* description:
|
||||||
|
* 修改机构信息
|
||||||
|
* create time: 2019/2/20 9:30
|
||||||
|
* @Param: beanJson
|
||||||
|
* @return java.lang.Object
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/editOrganization")
|
||||||
|
public Object editOrganization(@RequestParam("info") String beanJson) throws Exception {
|
||||||
|
JSONObject result = ExceptionConstants.standardSuccess();
|
||||||
|
Organization org= JSON.parseObject(beanJson, Organization.class);
|
||||||
|
int i= organizationService.editOrganization(org);
|
||||||
|
if(i<1){
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_EDIT_FAILED_CODE,
|
||||||
|
ExceptionConstants.ORGANIZATION_EDIT_FAILED_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* create by: cjl
|
||||||
|
* description:
|
||||||
|
* 批量删除机构信息
|
||||||
|
* create time: 2019/2/19 17:26
|
||||||
|
* @Param: ids
|
||||||
|
* @return java.lang.Object
|
||||||
|
*/
|
||||||
|
@RequestMapping(value = "/batchDeleteOrganization")
|
||||||
|
public Object batchDeleteOrganization(@RequestParam("ids") String ids) throws Exception {
|
||||||
|
JSONObject result = ExceptionConstants.standardSuccess();
|
||||||
|
int i= organizationService.batchDeleteOrganizationByIds(ids);
|
||||||
|
if(i<1){
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_DELETE_FAILED_CODE,
|
||||||
|
ExceptionConstants.ORGANIZATION_DELETE_FAILED_MSG);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.jsh.erp.datasource.mappers;
|
||||||
|
|
||||||
|
import com.jsh.erp.datasource.entities.MaterialCategory;
|
||||||
|
import com.jsh.erp.datasource.entities.Organization;
|
||||||
|
import com.jsh.erp.datasource.vo.TreeNode;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @Author: cjl
|
||||||
|
* @Date: 2019/3/6 15:51
|
||||||
|
*/
|
||||||
|
public interface OrganizationMapperEx {
|
||||||
|
|
||||||
|
|
||||||
|
List<TreeNode> getNodeTree();
|
||||||
|
List<TreeNode> getNextNodeTree(@Param("id") Long id);
|
||||||
|
|
||||||
|
int addOrganization(Organization org);
|
||||||
|
|
||||||
|
int batchDeleteOrganizationByIds(@Param("updateTime") Date updateTime, @Param("updater") Long updater, @Param("ids") String ids[]);
|
||||||
|
|
||||||
|
int editOrganization(Organization org);
|
||||||
|
List <Organization> getOrganizationRootByIds(@Param("ids") String ids[]);
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
package com.jsh.erp.service.organization;
|
||||||
|
|
||||||
|
import com.jsh.erp.service.ICommonQuery;
|
||||||
|
import com.jsh.erp.utils.Constants;
|
||||||
|
import com.jsh.erp.utils.QueryUtils;
|
||||||
|
import com.jsh.erp.utils.StringUtil;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @Author: cjl
|
||||||
|
* @Date: 2019/3/6 15:09
|
||||||
|
*/
|
||||||
|
@Service(value = "organization_component")
|
||||||
|
@OrganizationResource
|
||||||
|
public class OrganizationComponent implements ICommonQuery {
|
||||||
|
@Resource
|
||||||
|
private OrganizationService organizationService;
|
||||||
|
@Override
|
||||||
|
public Object selectOne(String condition) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<?> select(Map<String, String> parameterMap) {
|
||||||
|
return getOrganizationList(parameterMap);
|
||||||
|
}
|
||||||
|
private List<?> getOrganizationList(Map<String, String> map) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Long counts(Map<String, String> parameterMap) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int insert(String beanJson, HttpServletRequest request) {
|
||||||
|
return organizationService.insertOrganization(beanJson,request);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int update(String beanJson, Long id) {
|
||||||
|
return organizationService.updateOrganization(beanJson,id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int delete(Long id) {
|
||||||
|
return organizationService.deleteOrganization(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int batchDelete(String ids) {
|
||||||
|
return organizationService.batchDeleteOrganization(ids);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int checkIsNameExist(Long id, String name) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.jsh.erp.service.organization;
|
||||||
|
|
||||||
|
import com.jsh.erp.service.ResourceInfo;
|
||||||
|
|
||||||
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
* 机构
|
||||||
|
* @Author: cjl
|
||||||
|
* @Date: 2019/3/6 15:10
|
||||||
|
*/
|
||||||
|
@ResourceInfo(value = "organization", type = 110)
|
||||||
|
@Inherited
|
||||||
|
@Target(ElementType.TYPE)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface OrganizationResource {
|
||||||
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
package com.jsh.erp.service.organization;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.jsh.erp.constants.BusinessConstants;
|
||||||
|
import com.jsh.erp.constants.ExceptionConstants;
|
||||||
|
import com.jsh.erp.datasource.entities.Organization;
|
||||||
|
import com.jsh.erp.datasource.entities.OrganizationExample;
|
||||||
|
import com.jsh.erp.datasource.entities.User;
|
||||||
|
import com.jsh.erp.datasource.mappers.OrganizationMapper;
|
||||||
|
import com.jsh.erp.datasource.mappers.OrganizationMapperEx;
|
||||||
|
import com.jsh.erp.datasource.vo.TreeNode;
|
||||||
|
import com.jsh.erp.exception.BusinessRunTimeException;
|
||||||
|
import com.jsh.erp.service.user.UserService;
|
||||||
|
import com.jsh.erp.utils.StringUtil;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Description
|
||||||
|
*
|
||||||
|
* @Author: cjl
|
||||||
|
* @Date: 2019/3/6 15:10
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class OrganizationService {
|
||||||
|
private Logger logger = LoggerFactory.getLogger(OrganizationService.class);
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private OrganizationMapper organizationMapper;
|
||||||
|
@Resource
|
||||||
|
private OrganizationMapperEx organizationMapperEx;
|
||||||
|
@Resource
|
||||||
|
private UserService userService;
|
||||||
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
public int insertOrganization(String beanJson, HttpServletRequest request) {
|
||||||
|
Organization organization = JSONObject.parseObject(beanJson, Organization.class);
|
||||||
|
return organizationMapper.insertSelective(organization);
|
||||||
|
}
|
||||||
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
public int updateOrganization(String beanJson, Long id) {
|
||||||
|
Organization organization = JSONObject.parseObject(beanJson, Organization.class);
|
||||||
|
organization.setId(id);
|
||||||
|
return organizationMapper.updateByPrimaryKeySelective(organization);
|
||||||
|
}
|
||||||
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
public int deleteOrganization(Long id) {
|
||||||
|
return organizationMapper.deleteByPrimaryKey(id);
|
||||||
|
}
|
||||||
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
public int batchDeleteOrganization(String ids) {
|
||||||
|
List<Long> idList = StringUtil.strToLongList(ids);
|
||||||
|
OrganizationExample example = new OrganizationExample();
|
||||||
|
example.createCriteria().andIdIn(idList);
|
||||||
|
return organizationMapper.deleteByExample(example);
|
||||||
|
}
|
||||||
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
public int addOrganization(Organization org) throws Exception{
|
||||||
|
//新增时间
|
||||||
|
Date date=new Date();
|
||||||
|
User userInfo=userService.getCurrentUser();
|
||||||
|
org.setCreateTime(date);
|
||||||
|
//新增人
|
||||||
|
org.setCreator(userInfo==null?null:userInfo.getId());
|
||||||
|
//修改时间
|
||||||
|
org.setUpdateTime(date);
|
||||||
|
//修改人
|
||||||
|
org.setUpdater(userInfo==null?null:userInfo.getId());
|
||||||
|
/**
|
||||||
|
*添加的时候检测机构编号是否已存在
|
||||||
|
* */
|
||||||
|
if(StringUtil.isNotEmpty(org.getOrgNo())){
|
||||||
|
checkOrgNoIsExists(org.getOrgNo(),null);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 未指定父级机构的时候默认放在根机构下
|
||||||
|
* */
|
||||||
|
if(StringUtil.isEmpty(org.getOrgParentNo())){
|
||||||
|
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_NO);
|
||||||
|
}
|
||||||
|
return organizationMapperEx.addOrganization(org);
|
||||||
|
}
|
||||||
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
public int editOrganization(Organization org)throws Exception {
|
||||||
|
//修改时间
|
||||||
|
org.setUpdateTime(new Date());
|
||||||
|
User userInfo=userService.getCurrentUser();
|
||||||
|
//修改人
|
||||||
|
org.setUpdater(userInfo==null?null:userInfo.getId());
|
||||||
|
/**
|
||||||
|
* 修改的时候检测机构编号是否已存在
|
||||||
|
* */
|
||||||
|
if(StringUtil.isNotEmpty(org.getOrgNo())){
|
||||||
|
checkOrgNoIsExists(org.getOrgNo(),org.getId());
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 未指定父级机构的时候默认放在根机构下
|
||||||
|
* */
|
||||||
|
if(StringUtil.isEmpty(org.getOrgParentNo())){
|
||||||
|
org.setOrgParentNo(BusinessConstants.ORGANIZATION_ROOT_NO);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 添加一个限制,根机构不允许修改
|
||||||
|
* */
|
||||||
|
if(BusinessConstants.ORGANIZATION_ROOT_NO.equals(org.getOrgNo())){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],参数,orgNo[{}]",
|
||||||
|
ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE,ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG,org.getOrgNo());
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_CODE,
|
||||||
|
ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_EDIT_MSG);
|
||||||
|
}
|
||||||
|
return organizationMapperEx.editOrganization(org);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<TreeNode> getOrganizationTree()throws Exception {
|
||||||
|
return organizationMapperEx.getNodeTree();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Organization> findById(Long id) throws Exception{
|
||||||
|
OrganizationExample example = new OrganizationExample();
|
||||||
|
example.createCriteria().andIdEqualTo(id);
|
||||||
|
return organizationMapper.selectByExample(example);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Organization> findByOrgNo(String orgNo)throws Exception {
|
||||||
|
OrganizationExample example = new OrganizationExample();
|
||||||
|
example.createCriteria().andOrgNoEqualTo(orgNo).andOrgStcdNotEqualTo(BusinessConstants.ORGANIZATION_STCD_REMOVED);
|
||||||
|
return organizationMapper.selectByExample(example);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* create by: cjl
|
||||||
|
* description:
|
||||||
|
* 检查机构编号是否已经存在
|
||||||
|
* create time: 2019/3/7 10:01
|
||||||
|
* @Param: orgNo
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public void checkOrgNoIsExists(String orgNo,Long id)throws Exception {
|
||||||
|
List<Organization> orgList=findByOrgNo(orgNo);
|
||||||
|
if(orgList!=null&&orgList.size()>0){
|
||||||
|
if(orgList.size()>1){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],参数,orgNo[{}]",
|
||||||
|
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG,orgNo);
|
||||||
|
//获取的数据条数大于1,机构编号已存在
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,
|
||||||
|
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG);
|
||||||
|
}
|
||||||
|
if(id!=null){
|
||||||
|
if(!orgList.get(0).getId().equals(id)){
|
||||||
|
//数据条数等于1,但是和编辑的数据的id不相同
|
||||||
|
logger.error("异常码[{}],异常提示[{}],参数,orgNo[{}],id[{}]",
|
||||||
|
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG,orgNo,id);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,
|
||||||
|
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
logger.error("异常码[{}],异常提示[{}],参数,orgNo[{}]",
|
||||||
|
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG,orgNo);
|
||||||
|
//数据条数等于1,但此时是新增
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_CODE,
|
||||||
|
ExceptionConstants.ORGANIZATION_NO_ALREADY_EXISTS_MSG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
@Transactional(value = "transactionManager", rollbackFor = Exception.class)
|
||||||
|
public int batchDeleteOrganizationByIds(String ids) throws Exception{
|
||||||
|
User userInfo=userService.getCurrentUser();
|
||||||
|
String [] idArray=ids.split(",");
|
||||||
|
/**
|
||||||
|
* 添加一个限制,根机构不允许删除
|
||||||
|
* */
|
||||||
|
List<Organization> orgRootList=organizationMapperEx.getOrganizationRootByIds(idArray);
|
||||||
|
if(orgRootList!=null&&orgRootList.size()>0){
|
||||||
|
logger.error("异常码[{}],异常提示[{}],参数,ids[{}]",
|
||||||
|
ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_CODE,ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_MSG,ids);
|
||||||
|
throw new BusinessRunTimeException(ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_CODE,
|
||||||
|
ExceptionConstants.ORGANIZATION_ROOT_NOT_ALLOWED_DELETE_MSG);
|
||||||
|
}
|
||||||
|
|
||||||
|
return organizationMapperEx.batchDeleteOrganizationByIds(new Date(),userInfo==null?null:userInfo.getId(),idArray);
|
||||||
|
}
|
||||||
|
}
|
||||||
92
src/main/resources/mapper_xml/OrganizationMapperEx.xml
Normal file
92
src/main/resources/mapper_xml/OrganizationMapperEx.xml
Normal file
@@ -0,0 +1,92 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.jsh.erp.datasource.mappers.OrganizationMapperEx">
|
||||||
|
|
||||||
|
<resultMap id="BaseTreeResultMap" type="com.jsh.erp.datasource.vo.TreeNode">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="org_abr" property="text"/>
|
||||||
|
<result column="org_no" property="attributes"/>
|
||||||
|
<collection column="org_no" property="children" javaType="java.util.ArrayList"
|
||||||
|
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<resultMap id="NextTreeResultMap" type="com.jsh.erp.datasource.vo.TreeNode">
|
||||||
|
<result column="id" property="id"/>
|
||||||
|
<result column="org_abr" property="text"/>
|
||||||
|
<result column="org_no" property="attributes"/>
|
||||||
|
<collection column="org_no" property="children" javaType="java.util.ArrayList"
|
||||||
|
ofType="com.jsh.erp.datasource.vo.TreeNode" select="getNextNodeTree"/>
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<sql id="Base_Column_List">
|
||||||
|
id, org_abr,org_no
|
||||||
|
</sql>
|
||||||
|
|
||||||
|
<select id="getNextNodeTree" resultMap="NextTreeResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
FROM jsh_organization
|
||||||
|
WHERE org_parent_no = #{org_no}
|
||||||
|
and org_stcd !='5'
|
||||||
|
order by sort asc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getNodeTree" resultMap="BaseTreeResultMap">
|
||||||
|
SELECT
|
||||||
|
<include refid="Base_Column_List"/>
|
||||||
|
FROM jsh_organization
|
||||||
|
WHERE org_parent_no = -1
|
||||||
|
and org_stcd !='5'
|
||||||
|
order by sort asc
|
||||||
|
</select>
|
||||||
|
<insert id="addOrganization" parameterType="com.jsh.erp.datasource.entities.Organization"
|
||||||
|
useGeneratedKeys="true" keyProperty="id" keyColumn="id">
|
||||||
|
insert into jsh_organization
|
||||||
|
(org_no, org_full_name,
|
||||||
|
org_abr, org_tpcd, org_stcd,
|
||||||
|
org_parent_no, sort, remark,
|
||||||
|
create_time, creator, update_time,
|
||||||
|
updater, org_create_time, org_stop_time)
|
||||||
|
values
|
||||||
|
(#{orgNo,jdbcType=VARCHAR}, #{orgFullName,jdbcType=VARCHAR},
|
||||||
|
#{orgAbr,jdbcType=VARCHAR}, #{orgTpcd,jdbcType=VARCHAR}, #{orgStcd,jdbcType=CHAR},
|
||||||
|
#{orgParentNo,jdbcType=VARCHAR}, #{sort,jdbcType=VARCHAR}, #{remark,jdbcType=VARCHAR},
|
||||||
|
#{createTime,jdbcType=TIMESTAMP}, #{creator,jdbcType=BIGINT}, #{updateTime,jdbcType=TIMESTAMP},
|
||||||
|
#{updater,jdbcType=BIGINT}, #{orgCreateTime,jdbcType=TIMESTAMP}, #{orgStopTime,jdbcType=TIMESTAMP}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
<update id="batchDeleteOrganizationByIds">
|
||||||
|
update jsh_organization
|
||||||
|
set update_Time=#{updateTime},updater=#{updater},org_stcd='5'
|
||||||
|
where id in (
|
||||||
|
<foreach collection="ids" item="id" separator=",">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</update>
|
||||||
|
<update id="editOrganization">
|
||||||
|
update jsh_organization
|
||||||
|
set update_time=#{updateTime},updater=#{updater},
|
||||||
|
org_no = #{orgNo},org_full_name = #{orgFullName},
|
||||||
|
org_abr = #{orgAbr},org_tpcd = #{orgTpcd},
|
||||||
|
org_stcd = #{orgStcd},org_parent_no = #{orgParentNo},
|
||||||
|
sort = #{sort},remark = #{remark},
|
||||||
|
org_create_time = #{orgCreateTime},org_stop_time = #{orgStopTime}
|
||||||
|
where id =#{id}
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="getOrganizationRootByIds" resultMap="com.jsh.erp.datasource.mappers.OrganizationMapper.BaseResultMap">
|
||||||
|
select * from jsh_organization
|
||||||
|
where
|
||||||
|
1=1
|
||||||
|
and org_stcd!='5'
|
||||||
|
and org_parent_no='-1'
|
||||||
|
and org_abr='根机构'
|
||||||
|
and id in (
|
||||||
|
<foreach collection="ids" item="id" separator=",">
|
||||||
|
#{id}
|
||||||
|
</foreach>
|
||||||
|
)
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -48,7 +48,7 @@
|
|||||||
<table tableName="jsh_asset" domainObjectName="Asset"></table>
|
<table tableName="jsh_asset" domainObjectName="Asset"></table>
|
||||||
<table tableName="jsh_assetcategory" domainObjectName="AssetCategory"></table>
|
<table tableName="jsh_assetcategory" domainObjectName="AssetCategory"></table>
|
||||||
<table tableName="jsh_assetname" domainObjectName="AssetName"></table>-->
|
<table tableName="jsh_assetname" domainObjectName="AssetName"></table>-->
|
||||||
<table tableName="jsh_depot" domainObjectName="Depot"></table>
|
<!--<table tableName="jsh_depot" domainObjectName="Depot"></table>-->
|
||||||
<!--<table tableName="jsh_depothead" domainObjectName="DepotHead"></table>
|
<!--<table tableName="jsh_depothead" domainObjectName="DepotHead"></table>
|
||||||
<table tableName="jsh_depotitem" domainObjectName="DepotItem"></table>
|
<table tableName="jsh_depotitem" domainObjectName="DepotItem"></table>
|
||||||
<table tableName="jsh_functions" domainObjectName="Functions"></table>
|
<table tableName="jsh_functions" domainObjectName="Functions"></table>
|
||||||
@@ -65,5 +65,7 @@
|
|||||||
<table tableName="jsh_user" domainObjectName="User"></table>
|
<table tableName="jsh_user" domainObjectName="User"></table>
|
||||||
<table tableName="jsh_userbusiness" domainObjectName="UserBusiness"></table>-->
|
<table tableName="jsh_userbusiness" domainObjectName="UserBusiness"></table>-->
|
||||||
<!--<table tableName="jsh_serial_number" domainObjectName="SerialNumber"></table>-->
|
<!--<table tableName="jsh_serial_number" domainObjectName="SerialNumber"></table>-->
|
||||||
|
<table tableName="jsh_organization" domainObjectName="Organization"></table>
|
||||||
|
<!--<table tableName="jsh_orga_user_rel" domainObjectName="OrgaUserRel"></table>-->
|
||||||
</context>
|
</context>
|
||||||
</generatorConfiguration>
|
</generatorConfiguration>
|
||||||
|
|||||||
Reference in New Issue
Block a user