Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
M
mini-wms
概览
Overview
Details
Activity
Cycle Analytics
版本库
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
问题
0
Issues
0
列表
Board
标记
里程碑
合并请求
0
Merge Requests
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
Snippets
成员
Members
Collapse sidebar
Close sidebar
活动
图像
聊天
创建新问题
作业
提交
Issue Boards
Open sidebar
周海峰
mini-wms
Commits
dec88768
Commit
dec88768
authored
Dec 02, 2025
by
zhangtw
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
物料分类管理新增页面
parent
f3255ab9
全部展开
显示空白字符变更
内嵌
并排
正在显示
16 个修改的文件
包含
612 行增加
和
11 行删除
+612
-11
ruoyi-admin-vue/src/api/inventory/materials_category.js
+9
-0
ruoyi-admin-vue/src/views/inventory/materials/index.vue
+0
-0
ruoyi-admin-vue/src/views/inventory/materials_category/index.vue
+0
-0
ruoyi-admin-vue/src/views/inventory/materials_category/treeComponent.vue
+377
-0
ruoyi-admin-vue/src/views/system/user/index.vue
+10
-1
ruoyi-admin/src/main/java/com/ruoyi/web/controller/inventory/MaterialsCategoryController.java
+12
-1
ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java
+1
-0
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java
+17
-1
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/entity/MaterialsCategory.java
+49
-1
ruoyi-inventory/pom.xml
+2
-0
ruoyi-inventory/src/main/java/com/ruoyi/inventory/mapper/MaterialsCategoryMapper.java
+1
-2
ruoyi-inventory/src/main/java/com/ruoyi/inventory/mapper/MaterialsMapper.java
+6
-1
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/IMaterialsCategoryService.java
+27
-1
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/MaterialsCategoryServiceImpl.java
+89
-1
ruoyi-inventory/src/main/resources/mapper/inventory/MaterialsCategoryMapper.xml
+11
-1
ruoyi-inventory/src/main/resources/mapper/inventory/MaterialsMapper.xml
+1
-1
没有找到文件。
ruoyi-admin-vue/src/api/inventory/materials_category.js
View file @
dec88768
...
@@ -42,3 +42,11 @@ export function delMaterials_category(id) {
...
@@ -42,3 +42,11 @@ export function delMaterials_category(id) {
method
:
'delete'
method
:
'delete'
})
})
}
}
// 查询部门下拉树结构
export
function
categoryTreeSelect
()
{
return
request
({
url
:
'/inventory/materials_category/categoryTree'
,
method
:
'get'
})
}
\ No newline at end of file
ruoyi-admin-vue/src/views/inventory/materials/index.vue
View file @
dec88768
差异被折叠。
点击展开。
ruoyi-admin-vue/src/views/inventory/materials_category/index.vue
View file @
dec88768
差异被折叠。
点击展开。
ruoyi-admin-vue/src/views/inventory/materials_category/treeComponent.vue
0 → 100644
View file @
dec88768
<
template
>
<div
class=
"tree-container"
:style=
"containerStyle"
>
<!-- 搜索框 -->
<div
class=
"tree-header"
v-if=
"showSearch"
>
<el-input
v-model=
"searchText"
:placeholder=
"searchPlaceholder"
clearable
size=
"small"
prefix-icon=
"el-icon-search"
@
input=
"handleSearch"
style=
"width: 100%; margin-bottom: 10px;"
/>
</div>
<!-- 树组件 -->
<div
class=
"tree-body"
:style=
"treeBodyStyle"
>
<el-tree
v-if=
"treeData && treeData.length > 0"
ref=
"treeRef"
:data=
"filteredTreeData"
:props=
"treeProps"
:node-key=
"nodeKey"
:default-expand-all=
"defaultExpandAll"
:expand-on-click-node=
"expandOnClickNode"
:highlight-current=
"highlightCurrent"
:filter-node-method=
"filterNodeMethod"
:empty-text=
"emptyText"
:style=
"treeStyle"
@
node-click=
"handleNodeClick"
@
node-expand=
"handleNodeExpand"
@
node-collapse=
"handleNodeCollapse"
@
current-change=
"handleCurrentChange"
>
<!-- 自定义节点内容插槽 -->
<template
#
default=
"
{ node, data }">
<slot
name=
"node-content"
:node=
"node"
:data=
"data"
>
<span
class=
"custom-tree-node"
>
<span>
{{
node
.
label
}}
</span>
</span>
</slot>
</
template
>
</el-tree>
<!-- 空状态 -->
<div
v-else
class=
"tree-empty"
>
<slot
name=
"empty"
>
<div
style=
"padding: 20px; text-align: center; color: #999;"
>
{{ loading ? '加载中...' : '暂无数据' }}
</div>
</slot>
</div>
</div>
</div>
</template>
<
script
>
export
default
{
name
:
'TreeComponent'
,
props
:
{
// 树数据
treeData
:
{
type
:
Array
,
default
:
()
=>
[]
},
// 树配置
treeProps
:
{
type
:
Object
,
default
:
()
=>
({
children
:
'children'
,
label
:
'label'
,
value
:
'sid'
})
},
// 节点key
nodeKey
:
{
type
:
String
,
default
:
'sid'
},
// 是否显示搜索框
showSearch
:
{
type
:
Boolean
,
default
:
true
},
// 搜索框占位符
searchPlaceholder
:
{
type
:
String
,
default
:
'请输入搜索内容'
},
// 是否默认展开所有节点
defaultExpandAll
:
{
type
:
Boolean
,
default
:
true
},
// 是否点击节点时展开
expandOnClickNode
:
{
type
:
Boolean
,
default
:
false
},
// 是否高亮当前选中节点
highlightCurrent
:
{
type
:
Boolean
,
default
:
true
},
// 容器样式
containerStyle
:
{
type
:
Object
,
default
:
()
=>
({
height
:
'100%'
,
padding
:
'10px'
})
},
// 树容器样式
treeBodyStyle
:
{
type
:
Object
,
default
:
()
=>
({
height
:
'calc(100% - 50px)'
,
overflow
:
'auto'
})
},
// 树样式
treeStyle
:
{
type
:
Object
,
default
:
()
=>
({})
},
// 空状态文本
emptyText
:
{
type
:
String
,
default
:
'暂无数据'
},
// 加载状态
loading
:
{
type
:
Boolean
,
default
:
false
},
// 初始选中的节点key
defaultSelectedKey
:
{
type
:
[
String
,
Number
],
default
:
null
}
},
data
()
{
return
{
searchText
:
''
,
filteredTreeData
:
[],
selectedNode
:
null
}
},
watch
:
{
treeData
:
{
immediate
:
true
,
handler
(
newData
)
{
this
.
filteredTreeData
=
newData
this
.
$nextTick
(()
=>
{
if
(
this
.
defaultSelectedKey
&&
this
.
$refs
.
treeRef
)
{
this
.
$refs
.
treeRef
.
setCurrentKey
(
this
.
defaultSelectedKey
)
}
})
}
},
defaultSelectedKey
:
{
immediate
:
true
,
handler
(
newKey
)
{
if
(
newKey
&&
this
.
$refs
.
treeRef
)
{
this
.
$refs
.
treeRef
.
setCurrentKey
(
newKey
)
}
}
}
},
methods
:
{
/**
* 过滤节点方法
*/
filterNodeMethod
(
value
,
data
,
node
)
{
if
(
!
value
)
return
true
const
label
=
data
[
this
.
treeProps
.
label
]
||
''
return
label
.
toLowerCase
().
includes
(
value
.
toLowerCase
())
},
/**
* 处理搜索
*/
handleSearch
(
value
)
{
this
.
$refs
.
treeRef
.
filter
(
value
)
},
/**
* 节点点击事件
*/
handleNodeClick
(
data
,
node
,
component
)
{
this
.
selectedNode
=
{
data
,
node
,
component
}
this
.
$emit
(
'node-click'
,
data
,
node
,
component
)
},
/**
* 节点展开事件
*/
handleNodeExpand
(
data
,
node
,
component
)
{
this
.
$emit
(
'node-expand'
,
data
,
node
,
component
)
},
/**
* 节点折叠事件
*/
handleNodeCollapse
(
data
,
node
,
component
)
{
this
.
$emit
(
'node-collapse'
,
data
,
node
,
component
)
},
/**
* 当前节点变化事件
*/
handleCurrentChange
(
data
,
node
)
{
this
.
$emit
(
'current-change'
,
data
,
node
)
},
/**
* 重置树结构
*/
resetTree
()
{
// 修复:使用正确的 ref 名称 treeRef
if
(
this
.
$refs
.
treeRef
)
{
this
.
$refs
.
treeRef
.
setCurrentKey
(
null
);
this
.
searchText
=
''
;
this
.
$refs
.
treeRef
.
filter
(
''
);
// 清空搜索
}
},
/**
* 设置当前选中的节点
*/
setCurrentNode
(
node
)
{
this
.
$refs
.
treeRef
.
setCurrentNode
(
node
)
},
/**
* 设置当前选中的节点key
*/
setCurrentKey
(
key
)
{
this
.
$refs
.
treeRef
.
setCurrentKey
(
key
)
},
/**
* 获取当前选中的节点
*/
getCurrentNode
()
{
return
this
.
$refs
.
treeRef
.
getCurrentNode
()
},
/**
* 获取当前选中的节点key
*/
getCurrentKey
()
{
return
this
.
$refs
.
treeRef
.
getCurrentKey
()
},
/**
* 展开指定节点
*/
expandNode
(
node
)
{
this
.
$refs
.
treeRef
.
expandNode
(
node
)
},
/**
* 折叠指定节点
*/
collapseNode
(
node
)
{
this
.
$refs
.
treeRef
.
collapseNode
(
node
)
},
/**
* 展开所有节点
*/
expandAll
()
{
this
.
$refs
.
treeRef
.
expandAll
()
},
/**
* 折叠所有节点
*/
collapseAll
()
{
this
.
$refs
.
treeRef
.
collapseAll
()
},
/**
* 更新节点数据
*/
updateKeyChildren
(
key
,
data
)
{
this
.
$refs
.
treeRef
.
updateKeyChildren
(
key
,
data
)
},
/**
* 获取节点信息
*/
getNode
(
key
)
{
return
this
.
$refs
.
treeRef
.
getNode
(
key
)
},
/**
* 移除节点
*/
remove
(
key
)
{
this
.
$refs
.
treeRef
.
remove
(
key
)
},
/**
* 追加节点数据
*/
append
(
data
,
parentNode
)
{
this
.
$refs
.
treeRef
.
append
(
data
,
parentNode
)
},
/**
* 插入节点数据
*/
insertBefore
(
data
,
refNode
)
{
this
.
$refs
.
treeRef
.
insertBefore
(
data
,
refNode
)
},
/**
* 插入节点数据后
*/
insertAfter
(
data
,
refNode
)
{
this
.
$refs
.
treeRef
.
insertAfter
(
data
,
refNode
)
}
}
}
</
script
>
<
style
scoped
>
.tree-container
{
height
:
100%
;
display
:
flex
;
flex-direction
:
column
;
}
.tree-header
{
flex-shrink
:
0
;
}
.tree-body
{
flex
:
1
;
overflow
:
auto
;
}
.custom-tree-node
{
flex
:
1
;
display
:
flex
;
align-items
:
center
;
justify-content
:
space-between
;
font-size
:
14px
;
padding-right
:
8px
;
}
.tree-empty
{
height
:
100%
;
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
color
:
#999
;
}
</
style
>
\ No newline at end of file
ruoyi-admin-vue/src/views/system/user/index.vue
View file @
dec88768
...
@@ -9,7 +9,16 @@
...
@@ -9,7 +9,16 @@
<el-input
v-model=
"deptName"
placeholder=
"请输入部门名称"
clearable
size=
"small"
prefix-icon=
"el-icon-search"
style=
"margin-bottom: 20px"
/>
<el-input
v-model=
"deptName"
placeholder=
"请输入部门名称"
clearable
size=
"small"
prefix-icon=
"el-icon-search"
style=
"margin-bottom: 20px"
/>
</div>
</div>
<div
class=
"head-container"
>
<div
class=
"head-container"
>
<el-tree
:data=
"deptOptions"
:props=
"defaultProps"
:expand-on-click-node=
"false"
:filter-node-method=
"filterNode"
ref=
"tree"
node-key=
"id"
default-expand-all
highlight-current
@
node-click=
"handleNodeClick"
/>
<el-tree
:data=
"deptOptions"
:props=
"defaultProps"
:expand-on-click-node=
"false"
:filter-node-method=
"filterNode"
ref=
"tree"
node-key=
"id"
default-expand-all
highlight-current
@
node-click=
"handleNodeClick"
/>
</div>
</div>
</el-col>
</el-col>
</pane>
</pane>
...
...
ruoyi-admin/src/main/java/com/ruoyi/web/controller/inventory/MaterialsCategoryController.java
View file @
dec88768
...
@@ -3,6 +3,7 @@ package com.ruoyi.web.controller.inventory;
...
@@ -3,6 +3,7 @@ package com.ruoyi.web.controller.inventory;
import
java.util.List
;
import
java.util.List
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.servlet.http.HttpServletResponse
;
import
com.ruoyi.common.core.domain.entity.SysDept
;
import
com.ruoyi.common.utils.uuid.UUID
;
import
com.ruoyi.common.utils.uuid.UUID
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
@@ -18,7 +19,7 @@ import com.ruoyi.common.annotation.Log;
...
@@ -18,7 +19,7 @@ import com.ruoyi.common.annotation.Log;
import
com.ruoyi.common.core.controller.BaseController
;
import
com.ruoyi.common.core.controller.BaseController
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.core.domain.AjaxResult
;
import
com.ruoyi.common.enums.BusinessType
;
import
com.ruoyi.common.enums.BusinessType
;
import
com.ruoyi.
inventory.domain
.MaterialsCategory
;
import
com.ruoyi.
common.core.domain.entity
.MaterialsCategory
;
import
com.ruoyi.inventory.service.IMaterialsCategoryService
;
import
com.ruoyi.inventory.service.IMaterialsCategoryService
;
import
com.ruoyi.common.utils.poi.ExcelUtil
;
import
com.ruoyi.common.utils.poi.ExcelUtil
;
import
com.ruoyi.common.core.page.TableDataInfo
;
import
com.ruoyi.common.core.page.TableDataInfo
;
...
@@ -72,6 +73,16 @@ public class MaterialsCategoryController extends BaseController
...
@@ -72,6 +73,16 @@ public class MaterialsCategoryController extends BaseController
}
}
/**
/**
* 获取分类树结构
*/
@PreAuthorize
(
"@ss.hasPermi('inventory:materials_category:list')"
)
@GetMapping
(
"/categoryTree"
)
public
AjaxResult
categoryTree
(
MaterialsCategory
materialsCategory
)
{
return
success
(
materialsCategoryService
.
selectMaterialsCategoryTreeList
(
materialsCategory
));
}
/**
* 新增物料分类
* 新增物料分类
*/
*/
@PreAuthorize
(
"@ss.hasPermi('inventory:materials_category:add')"
)
@PreAuthorize
(
"@ss.hasPermi('inventory:materials_category:add')"
)
...
...
ruoyi-common/src/main/java/com/ruoyi/common/constant/UserConstants.java
View file @
dec88768
...
@@ -63,6 +63,7 @@ public class UserConstants
...
@@ -63,6 +63,7 @@ public class UserConstants
/** InnerLink组件标识 */
/** InnerLink组件标识 */
public
final
static
String
INNER_LINK
=
"InnerLink"
;
public
final
static
String
INNER_LINK
=
"InnerLink"
;
/** 校验是否唯一的返回标识 */
/** 校验是否唯一的返回标识 */
public
final
static
boolean
UNIQUE
=
true
;
public
final
static
boolean
UNIQUE
=
true
;
public
final
static
boolean
NOT_UNIQUE
=
false
;
public
final
static
boolean
NOT_UNIQUE
=
false
;
...
...
ruoyi-common/src/main/java/com/ruoyi/common/core/domain/TreeSelect.java
View file @
dec88768
...
@@ -5,6 +5,7 @@ import java.util.List;
...
@@ -5,6 +5,7 @@ import java.util.List;
import
java.util.stream.Collectors
;
import
java.util.stream.Collectors
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.fasterxml.jackson.annotation.JsonInclude
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.constant.UserConstants
;
import
com.ruoyi.common.core.domain.entity.MaterialsCategory
;
import
com.ruoyi.common.core.domain.entity.SysDept
;
import
com.ruoyi.common.core.domain.entity.SysDept
;
import
com.ruoyi.common.core.domain.entity.SysMenu
;
import
com.ruoyi.common.core.domain.entity.SysMenu
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.StringUtils
;
...
@@ -21,6 +22,8 @@ public class TreeSelect implements Serializable
...
@@ -21,6 +22,8 @@ public class TreeSelect implements Serializable
/** 节点ID */
/** 节点ID */
private
Long
id
;
private
Long
id
;
/** String节点ID */
private
String
sid
;
/** 节点名称 */
/** 节点名称 */
private
String
label
;
private
String
label
;
...
@@ -43,7 +46,12 @@ public class TreeSelect implements Serializable
...
@@ -43,7 +46,12 @@ public class TreeSelect implements Serializable
this
.
disabled
=
StringUtils
.
equals
(
UserConstants
.
DEPT_DISABLE
,
dept
.
getStatus
());
this
.
disabled
=
StringUtils
.
equals
(
UserConstants
.
DEPT_DISABLE
,
dept
.
getStatus
());
this
.
children
=
dept
.
getChildren
().
stream
().
map
(
TreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
this
.
children
=
dept
.
getChildren
().
stream
().
map
(
TreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
}
public
TreeSelect
(
MaterialsCategory
materialsCategory
){
this
.
sid
=
materialsCategory
.
getId
();
this
.
label
=
materialsCategory
.
getCategoryName
();
this
.
disabled
=
StringUtils
.
equals
(
String
.
valueOf
(
0
),
String
.
valueOf
(
materialsCategory
.
getIsUsed
()));
this
.
children
=
materialsCategory
.
getChildren
().
stream
().
map
(
TreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
public
TreeSelect
(
SysMenu
menu
)
public
TreeSelect
(
SysMenu
menu
)
{
{
this
.
id
=
menu
.
getMenuId
();
this
.
id
=
menu
.
getMenuId
();
...
@@ -90,4 +98,12 @@ public class TreeSelect implements Serializable
...
@@ -90,4 +98,12 @@ public class TreeSelect implements Serializable
{
{
this
.
children
=
children
;
this
.
children
=
children
;
}
}
public
String
getSid
()
{
return
sid
;
}
public
void
setSid
(
String
sid
)
{
this
.
sid
=
sid
;
}
}
}
ruoyi-
inventory/src/main/java/com/ruoyi/inventory/domain
/MaterialsCategory.java
→
ruoyi-
common/src/main/java/com/ruoyi/common/core/domain/entity
/MaterialsCategory.java
View file @
dec88768
package
com
.
ruoyi
.
inventory
.
domain
;
package
com
.
ruoyi
.
common
.
core
.
domain
.
entity
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringBuilder
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
org.apache.commons.lang3.builder.ToStringStyle
;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.annotation.Excel
;
import
com.ruoyi.common.core.domain.BaseEntity
;
import
com.ruoyi.common.core.domain.BaseEntity
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
/**
* 物料分类对象 materials_category
* 物料分类对象 materials_category
*
*
...
@@ -31,6 +34,15 @@ public class MaterialsCategory extends BaseEntity
...
@@ -31,6 +34,15 @@ public class MaterialsCategory extends BaseEntity
@Excel
(
name
=
"排序"
)
@Excel
(
name
=
"排序"
)
private
Long
sortNo
;
private
Long
sortNo
;
@Excel
(
name
=
"父级Code"
)
private
String
parentId
;
@Excel
(
name
=
"使用状态"
)
private
int
isUsed
;
private
String
parentName
;
private
List
<
MaterialsCategory
>
children
=
new
ArrayList
<
MaterialsCategory
>();
/** 创建日期 */
/** 创建日期 */
private
String
createUserCode
;
private
String
createUserCode
;
...
@@ -97,6 +109,38 @@ public class MaterialsCategory extends BaseEntity
...
@@ -97,6 +109,38 @@ public class MaterialsCategory extends BaseEntity
return
updateUserCode
;
return
updateUserCode
;
}
}
public
String
getParentId
()
{
return
parentId
;
}
public
void
setParentId
(
String
parentId
)
{
this
.
parentId
=
parentId
;
}
public
int
getIsUsed
()
{
return
isUsed
;
}
public
void
setIsUsed
(
int
isUsed
)
{
this
.
isUsed
=
isUsed
;
}
public
String
getParentName
()
{
return
parentName
;
}
public
void
setParentName
(
String
parentName
)
{
this
.
parentName
=
parentName
;
}
public
List
<
MaterialsCategory
>
getChildren
()
{
return
children
;
}
public
void
setChildren
(
List
<
MaterialsCategory
>
children
)
{
this
.
children
=
children
;
}
@Override
@Override
public
String
toString
()
{
public
String
toString
()
{
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
return
new
ToStringBuilder
(
this
,
ToStringStyle
.
MULTI_LINE_STYLE
)
...
@@ -108,6 +152,10 @@ public class MaterialsCategory extends BaseEntity
...
@@ -108,6 +152,10 @@ public class MaterialsCategory extends BaseEntity
.
append
(
"createUserCode"
,
getCreateUserCode
())
.
append
(
"createUserCode"
,
getCreateUserCode
())
.
append
(
"updateTime"
,
getUpdateTime
())
.
append
(
"updateTime"
,
getUpdateTime
())
.
append
(
"updateUserCode"
,
getUpdateUserCode
())
.
append
(
"updateUserCode"
,
getUpdateUserCode
())
.
append
(
"parentId"
,
getParentId
())
.
append
(
"isUsed"
,
getIsUsed
())
.
append
(
"parentName"
,
getParentName
())
.
append
(
"children"
,
getChildren
())
.
toString
();
.
toString
();
}
}
}
}
ruoyi-inventory/pom.xml
View file @
dec88768
...
@@ -22,5 +22,6 @@
...
@@ -22,5 +22,6 @@
<groupId>
com.ruoyi
</groupId>
<groupId>
com.ruoyi
</groupId>
<artifactId>
ruoyi-common
</artifactId>
<artifactId>
ruoyi-common
</artifactId>
</dependency>
</dependency>
</dependencies>
</dependencies>
</project>
</project>
\ No newline at end of file
ruoyi-inventory/src/main/java/com/ruoyi/inventory/mapper/MaterialsCategoryMapper.java
View file @
dec88768
package
com
.
ruoyi
.
inventory
.
mapper
;
package
com
.
ruoyi
.
inventory
.
mapper
;
import
java.util.List
;
import
java.util.List
;
import
com.ruoyi.
inventory.domain
.MaterialsCategory
;
import
com.ruoyi.
common.core.domain.entity
.MaterialsCategory
;
/**
/**
* 物料分类Mapper接口
* 物料分类Mapper接口
...
@@ -18,7 +18,6 @@ public interface MaterialsCategoryMapper
...
@@ -18,7 +18,6 @@ public interface MaterialsCategoryMapper
* @return 物料分类
* @return 物料分类
*/
*/
public
MaterialsCategory
selectMaterialsCategoryById
(
String
id
);
public
MaterialsCategory
selectMaterialsCategoryById
(
String
id
);
/**
/**
* 查询物料分类列表
* 查询物料分类列表
*
*
...
...
ruoyi-inventory/src/main/java/com/ruoyi/inventory/mapper/MaterialsMapper.java
View file @
dec88768
...
@@ -59,7 +59,12 @@ public interface MaterialsMapper
...
@@ -59,7 +59,12 @@ public interface MaterialsMapper
* @return 结果
* @return 结果
*/
*/
public
int
deleteMaterialsByIds
(
String
[]
ids
);
public
int
deleteMaterialsByIds
(
String
[]
ids
);
/**
* 批量删除,修改物料的使用状态
*
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public
int
updateMaterialsIsUsedByIds
(
String
[]
ids
);
public
int
updateMaterialsIsUsedByIds
(
String
[]
ids
);
}
}
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/IMaterialsCategoryService.java
View file @
dec88768
package
com
.
ruoyi
.
inventory
.
service
;
package
com
.
ruoyi
.
inventory
.
service
;
import
java.util.List
;
import
java.util.List
;
import
com.ruoyi.inventory.domain.MaterialsCategory
;
import
com.ruoyi.common.core.domain.TreeSelect
;
import
com.ruoyi.common.core.domain.entity.MaterialsCategory
;
/**
/**
* 物料分类Service接口
* 物料分类Service接口
...
@@ -28,6 +30,30 @@ public interface IMaterialsCategoryService
...
@@ -28,6 +30,30 @@ public interface IMaterialsCategoryService
public
List
<
MaterialsCategory
>
selectMaterialsCategoryList
(
MaterialsCategory
materialsCategory
);
public
List
<
MaterialsCategory
>
selectMaterialsCategoryList
(
MaterialsCategory
materialsCategory
);
/**
/**
* 查询分类树结构
*
* @param materialsCategory 物料分类
* @return 结果
*/
public
List
<
TreeSelect
>
selectMaterialsCategoryTreeList
(
MaterialsCategory
materialsCategory
);
/**
* 构建前端所需要树结构
*
* @param materialsCategorys 物料分类
* @return 结果
*/
public
List
<
MaterialsCategory
>
buildMaterialsCategoryTree
(
List
<
MaterialsCategory
>
materialsCategorys
);
/**
* 构建前端所需要下拉树结构
*
* @param materialsCategorys 物料分类
* @return 结果
*/
public
List
<
TreeSelect
>
buildTreeSelect
(
List
<
MaterialsCategory
>
materialsCategorys
);
/**
* 新增物料分类
* 新增物料分类
*
*
* @param materialsCategory 物料分类
* @param materialsCategory 物料分类
...
...
ruoyi-inventory/src/main/java/com/ruoyi/inventory/service/impl/MaterialsCategoryServiceImpl.java
View file @
dec88768
package
com
.
ruoyi
.
inventory
.
service
.
impl
;
package
com
.
ruoyi
.
inventory
.
service
.
impl
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Iterator
;
import
java.util.List
;
import
java.util.List
;
import
java.util.stream.Collectors
;
import
com.ruoyi.common.core.domain.TreeSelect
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.DateUtils
;
import
com.ruoyi.common.utils.StringUtils
;
import
com.ruoyi.common.utils.spring.SpringUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
com.ruoyi.inventory.mapper.MaterialsCategoryMapper
;
import
com.ruoyi.inventory.mapper.MaterialsCategoryMapper
;
import
com.ruoyi.
inventory.domain
.MaterialsCategory
;
import
com.ruoyi.
common.core.domain.entity
.MaterialsCategory
;
import
com.ruoyi.inventory.service.IMaterialsCategoryService
;
import
com.ruoyi.inventory.service.IMaterialsCategoryService
;
/**
/**
...
@@ -43,6 +51,86 @@ public class MaterialsCategoryServiceImpl implements IMaterialsCategoryService
...
@@ -43,6 +51,86 @@ public class MaterialsCategoryServiceImpl implements IMaterialsCategoryService
{
{
return
materialsCategoryMapper
.
selectMaterialsCategoryList
(
materialsCategory
);
return
materialsCategoryMapper
.
selectMaterialsCategoryList
(
materialsCategory
);
}
}
/**
* 查询分类树结构
*
* @param materialsCategory 物料分类
* @return 结果
*/
@Override
public
List
<
TreeSelect
>
selectMaterialsCategoryTreeList
(
MaterialsCategory
materialsCategory
)
{
List
<
MaterialsCategory
>
materialsCategorys
=
SpringUtils
.
getAopProxy
(
this
).
selectMaterialsCategoryList
(
materialsCategory
);
return
buildTreeSelect
(
materialsCategorys
);
}
/**
* 构建前端所需要树结构
*
* @param materialsCategorys 物料分类
* @return 结果
*/
@Override
public
List
<
MaterialsCategory
>
buildMaterialsCategoryTree
(
List
<
MaterialsCategory
>
materialsCategorys
)
{
List
<
MaterialsCategory
>
returnList
=
new
ArrayList
<
MaterialsCategory
>();
// List<String> tempList = materialsCategorys.stream().map(MaterialsCategory::getId).collect(Collectors.toList());
for
(
MaterialsCategory
materialsCategory
:
materialsCategorys
)
{
// 如果是顶级节点, 遍历该父节点的所有子节点
if
(
StringUtils
.
isNull
(
materialsCategory
.
getParentId
())
||
materialsCategory
.
getParentId
().
isEmpty
()){
recursionFn
(
materialsCategorys
,
materialsCategory
);
returnList
.
add
(
materialsCategory
);
}
}
if
(
returnList
.
isEmpty
()){
returnList
=
materialsCategorys
;
}
return
returnList
;
}
/**
* 递归列表
*/
private
void
recursionFn
(
List
<
MaterialsCategory
>
materialsCategoryList
,
MaterialsCategory
materialsCategory
)
{
// 得到子节点列表
List
<
MaterialsCategory
>
childList
=
getChildList
(
materialsCategoryList
,
materialsCategory
);
materialsCategory
.
setChildren
(
childList
);
// 如果有子节点,递归处理
if
(!
childList
.
isEmpty
())
{
for
(
MaterialsCategory
child
:
childList
)
{
recursionFn
(
materialsCategoryList
,
child
);
}
}
}
/**
* 得到子节点列表
*/
private
List
<
MaterialsCategory
>
getChildList
(
List
<
MaterialsCategory
>
list
,
MaterialsCategory
materialsCategory
){
List
<
MaterialsCategory
>
childList
=
new
ArrayList
<>();
Iterator
<
MaterialsCategory
>
iterator
=
list
.
iterator
();
while
(
iterator
.
hasNext
()){
MaterialsCategory
m
=
(
MaterialsCategory
)
iterator
.
next
();
if
(
StringUtils
.
equals
(
m
.
getParentId
(),
materialsCategory
.
getId
())){
childList
.
add
(
m
);
}
}
return
childList
;
}
/**
* 判断是否有子节点
*/
private
boolean
hasChild
(
List
<
MaterialsCategory
>
list
,
MaterialsCategory
m
){
return
getChildList
(
list
,
m
).
size
()
>
0
;
}
/**
* 构建前端所需要下拉树结构
*
* @param materialsCategorys 物料分类
* @return 结果
*/
@Override
public
List
<
TreeSelect
>
buildTreeSelect
(
List
<
MaterialsCategory
>
materialsCategorys
)
{
List
<
MaterialsCategory
>
materialsCategories
=
buildMaterialsCategoryTree
(
materialsCategorys
);
return
materialsCategories
.
stream
().
map
(
TreeSelect:
:
new
).
collect
(
Collectors
.
toList
());
}
/**
/**
* 新增物料分类
* 新增物料分类
...
...
ruoyi-inventory/src/main/resources/mapper/inventory/MaterialsCategoryMapper.xml
View file @
dec88768
...
@@ -13,20 +13,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -13,20 +13,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result
property=
"createUserCode"
column=
"create_user_code"
/>
<result
property=
"createUserCode"
column=
"create_user_code"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"updateTime"
column=
"update_time"
/>
<result
property=
"updateUserCode"
column=
"update_user_code"
/>
<result
property=
"updateUserCode"
column=
"update_user_code"
/>
<result
property=
"parentId"
column=
"parent_id"
/>
<result
property=
"isUsed"
column=
"is_used"
/>
</resultMap>
</resultMap>
<sql
id=
"selectMaterialsCategoryVo"
>
<sql
id=
"selectMaterialsCategoryVo"
>
select id, category_code, category_name, sort_no, create_time, create_user_code, update_time, update_user_code from materials_category
select id, category_code, category_name, sort_no, create_time, create_user_code, update_time, update_user_code
, parent_id, is_used
from materials_category
</sql>
</sql>
<select
id=
"selectMaterialsCategoryList"
parameterType=
"MaterialsCategory"
resultMap=
"MaterialsCategoryResult"
>
<select
id=
"selectMaterialsCategoryList"
parameterType=
"MaterialsCategory"
resultMap=
"MaterialsCategoryResult"
>
<include
refid=
"selectMaterialsCategoryVo"
/>
<include
refid=
"selectMaterialsCategoryVo"
/>
<where>
<where>
<if
test=
"id != null and id != ''"
>
and id = #{id}
</if>
<if
test=
"categoryCode != null and categoryCode != ''"
>
and category_code like concat('%', #{categoryCode}, '%')
</if>
<if
test=
"categoryCode != null and categoryCode != ''"
>
and category_code like concat('%', #{categoryCode}, '%')
</if>
<if
test=
"categoryName != null and categoryName != ''"
>
and category_name like concat('%', #{categoryName}, '%')
</if>
<if
test=
"categoryName != null and categoryName != ''"
>
and category_name like concat('%', #{categoryName}, '%')
</if>
<if
test=
"sortNo != null "
>
and sort_no = #{sortNo}
</if>
<if
test=
"sortNo != null "
>
and sort_no = #{sortNo}
</if>
<if
test=
"createTime != null "
>
and create_time like concat('%', #{createTime}, '%')
</if>
<if
test=
"createTime != null "
>
and create_time like concat('%', #{createTime}, '%')
</if>
<if
test=
"updateTime != null "
>
and update_time like concat('%', #{updateTime}, '%')
</if>
<if
test=
"updateTime != null "
>
and update_time like concat('%', #{updateTime}, '%')
</if>
<if
test=
"parentId != null "
>
and parent_id = #{parentId}
</if>
</where>
</where>
order by sort_no asc
order by sort_no asc
</select>
</select>
...
@@ -48,6 +52,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -48,6 +52,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"createUserCode != null"
>
create_user_code,
</if>
<if
test=
"createUserCode != null"
>
create_user_code,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"updateTime != null"
>
update_time,
</if>
<if
test=
"updateUserCode != null"
>
update_user_code,
</if>
<if
test=
"updateUserCode != null"
>
update_user_code,
</if>
<if
test=
"parentId != null"
>
parent_id,
</if>
<if
test=
"isUsed != null"
>
is_used,
</if>
</trim>
</trim>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<trim
prefix=
"values ("
suffix=
")"
suffixOverrides=
","
>
<if
test=
"id != null"
>
#{id},
</if>
<if
test=
"id != null"
>
#{id},
</if>
...
@@ -58,6 +64,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -58,6 +64,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"createUserCode != null"
>
#{createUserCode},
</if>
<if
test=
"createUserCode != null"
>
#{createUserCode},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"updateTime != null"
>
#{updateTime},
</if>
<if
test=
"updateUserCode != null"
>
#{updateUserCode},
</if>
<if
test=
"updateUserCode != null"
>
#{updateUserCode},
</if>
<if
test=
"parentId != null"
>
#{parentId},
</if>
<if
test=
"isUsed != null"
>
#{isUsed},
</if>
</trim>
</trim>
</insert>
</insert>
...
@@ -71,6 +79,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -71,6 +79,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"createUserCode != null"
>
create_user_code = #{createUserCode},
</if>
<if
test=
"createUserCode != null"
>
create_user_code = #{createUserCode},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"updateTime != null"
>
update_time = #{updateTime},
</if>
<if
test=
"updateUserCode != null"
>
update_user_code = #{updateUserCode},
</if>
<if
test=
"updateUserCode != null"
>
update_user_code = #{updateUserCode},
</if>
<if
test=
"parentId != null"
>
parent_id = #{parentId},
</if>
<if
test=
"isUsed != null"
>
is_used = #{isUsed},
</if>
</trim>
</trim>
where id = #{id}
where id = #{id}
</update>
</update>
...
...
ruoyi-inventory/src/main/resources/mapper/inventory/MaterialsMapper.xml
View file @
dec88768
...
@@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
...
@@ -46,7 +46,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if
test=
"materialName != null and materialName != ''"
>
and material_name like concat('%', #{materialName}, '%')
</if>
<if
test=
"materialName != null and materialName != ''"
>
and material_name like concat('%', #{materialName}, '%')
</if>
<if
test=
"sapNo != null and sapNo != ''"
>
and sap_no like concat('%', #{sapNo}, '%')
</if>
<if
test=
"sapNo != null and sapNo != ''"
>
and sap_no like concat('%', #{sapNo}, '%')
</if>
<if
test=
"tsCode != null and tsCode != ''"
>
and ts_code like concat('%', #{tsCode}, '%')
</if>
<if
test=
"tsCode != null and tsCode != ''"
>
and ts_code like concat('%', #{tsCode}, '%')
</if>
<if
test=
"categoryCode != null and categoryCode != ''"
>
and category_code
like concat('%', #{categoryCode}, '%')
</if>
<if
test=
"categoryCode != null and categoryCode != ''"
>
and category_code
= #{categoryCode}
</if>
<if
test=
"hazardId != null and hazardId != ''"
>
and hazard_id like concat('%', #{hazardId}, '%')
</if>
<if
test=
"hazardId != null and hazardId != ''"
>
and hazard_id like concat('%', #{hazardId}, '%')
</if>
<if
test=
"specification != null and specification != ''"
>
and specification like concat('%', #{specification}, '%')
</if>
<if
test=
"specification != null and specification != ''"
>
and specification like concat('%', #{specification}, '%')
</if>
<if
test=
"materialUnit != null and materialUnit != ''"
>
and material_unit like concat('%', #{materialUnit}, '%')
</if>
<if
test=
"materialUnit != null and materialUnit != ''"
>
and material_unit like concat('%', #{materialUnit}, '%')
</if>
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论