Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张雷
/
skboot-zhongye
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
构建
提交
问题看板
文件
提交
网络
比较
分支
标签
b5d77a45
由
康伟
编写于
2024-10-09 17:36:07 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
kangwei : 物料类别列表:根据是否药剂赛选集合
1 个父辈
f7392619
显示空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
114 行增加
和
12 行删除
sk-module-equipment/src/main/java/com/skua/modules/supplies/controller/web/EquipmentSparepartTypeController.java
sk-module-equipment/src/main/java/com/skua/modules/supplies/entity/EquipmentSparepartType.java
sk-module-equipment/src/main/java/com/skua/modules/supplies/mapper/EquipmentSparepartTypeMapper.java
sk-module-equipment/src/main/java/com/skua/modules/supplies/mapper/xml/EquipmentSparepartTypeMapper.xml
sk-module-equipment/src/main/java/com/skua/modules/supplies/service/IEquipmentSparepartTypeService.java
sk-module-equipment/src/main/java/com/skua/modules/supplies/service/impl/EquipmentSparepartTypeServiceImpl.java
sk-module-equipment/src/main/java/com/skua/modules/supplies/vo/EquipmentSparepartTypeVO.java
sk-module-equipment/src/main/java/com/skua/modules/supplies/controller/web/EquipmentSparepartTypeController.java
查看文件 @
b5d77a4
...
...
@@ -3,10 +3,7 @@ package com.skua.modules.supplies.controller.web;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.*
;
import
java.util.stream.Collectors
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -80,11 +77,14 @@ public class EquipmentSparepartTypeController {
if
(
StringUtils
.
isNotBlank
(
itemText
))
{
queryWrapper
.
like
(
"item_text"
,
itemText
);
}
if
(
equipmentSparepartType
.
isMedicament
())
{
//查询药剂类别
queryWrapper
.
eq
(
"is_medicament"
,
equipmentSparepartType
.
isMedicament
());
}
List
<
EquipmentSparepartType
>
equipmentSparepartTypeList
=
equipmentSparepartTypeService
.
list
(
queryWrapper
);
if
(
equipmentSparepartType
.
isMedicament
())
{
//查询药剂类别
queryWrapper
.
eq
(
"medicament"
,
equipmentSparepartType
.
isMedicament
());
//药剂的物料分类
List
<
EquipmentSparepartType
>
medicamentList
=
equipmentSparepartTypeService
.
list
(
queryWrapper
);
equipmentSparepartTypeList
=
this
.
equipmentSparepartTypeListByMedicament
(
equipmentSparepartTypeList
,
medicamentList
);
}
List
<
EquipmentSparepartTypeVO
>
voList
=
new
ArrayList
<>();
getTree
(
voList
,
equipmentSparepartTypeList
,
null
);
result
.
setSuccess
(
true
);
...
...
@@ -92,6 +92,12 @@ public class EquipmentSparepartTypeController {
return
result
;
}
/***
* 递归转换为tree结构
* @param voList
* @param entityList
* @param tmp
*/
private
void
getTree
(
List
<
EquipmentSparepartTypeVO
>
voList
,
List
<
EquipmentSparepartType
>
entityList
,
EquipmentSparepartTypeVO
tmp
)
{
for
(
EquipmentSparepartType
item
:
entityList
)
{
String
parentId
=
item
.
getParentId
();
...
...
@@ -110,6 +116,42 @@ public class EquipmentSparepartTypeController {
}
}
/***
* 拼装 药剂的物料分类
* @param allTypeList
* @param medicamentList
* @return
*/
private
List
<
EquipmentSparepartType
>
equipmentSparepartTypeListByMedicament
(
List
<
EquipmentSparepartType
>
allTypeList
,
List
<
EquipmentSparepartType
>
medicamentList
){
Set
<
EquipmentSparepartType
>
resultSet
=
new
HashSet
<>();
// List<EquipmentSparepartType> dataList = new ArrayList<>();
StringBuffer
ancestors
=
new
StringBuffer
();
for
(
EquipmentSparepartType
equipmentSparepartType
:
medicamentList
){
ancestors
.
append
(
equipmentSparepartType
.
getAncestors
()).
append
(
","
);
resultSet
.
add
(
equipmentSparepartType
);
for
(
EquipmentSparepartType
equipmentSparepartType2
:
allTypeList
){
// 添加下游数据
if
(
equipmentSparepartType2
.
getAncestors
().
contains
(
equipmentSparepartType
.
getAncestors
()
)){
resultSet
.
add
(
equipmentSparepartType2
);
}
}
// 将原始字符串按逗号分隔并放入LinkedHashSet中去重
Set
<
String
>
uniqueFruits
=
new
LinkedHashSet
<>(
Arrays
.
asList
(
ancestors
.
toString
().
split
(
","
)));
//添加上游数据
for
(
String
id
:
uniqueFruits
){
for
(
EquipmentSparepartType
equipmentSparepartType3
:
allTypeList
){
if
(
id
.
equals
(
equipmentSparepartType3
.
getId
()
)){
resultSet
.
add
(
equipmentSparepartType3
)
;
}
}
}
}
return
new
ArrayList
<>(
resultSet
);
}
/**
* 添加
*
...
...
@@ -168,6 +210,11 @@ public class EquipmentSparepartTypeController {
try
{
equipmentSparepartType
.
setDelFlag
(
0
);
equipmentSparepartTypeService
.
saveAndUpdateParent
(
equipmentSparepartType
);
if
(
StringUtils
.
isNotEmpty
(
equipmentSparepartType
.
getParentId
()
)){
EquipmentSparepartType
parentSparepartType
=
equipmentSparepartTypeService
.
getById
(
equipmentSparepartType
.
getParentId
()
);
equipmentSparepartType
.
setAncestors
(
parentSparepartType
.
getAncestors
()
+
","
+
equipmentSparepartType
.
getId
())
;
equipmentSparepartTypeService
.
updateById
(
equipmentSparepartType
);
}
result
.
success
(
"添加成功!"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
...
...
@@ -192,14 +239,26 @@ public class EquipmentSparepartTypeController {
if
(
equipmentSparepartTypeEntity
==
null
)
{
result
.
error500
(
"未找到对应实体"
);
}
else
{
if
(
StringUtils
.
isNotEmpty
(
equipmentSparepartType
.
getParentId
()
)){
EquipmentSparepartType
parentSparepartType
=
equipmentSparepartTypeService
.
getById
(
equipmentSparepartType
.
getParentId
()
);
equipmentSparepartType
.
setAncestors
(
parentSparepartType
.
getAncestors
()
+
","
+
equipmentSparepartType
.
getId
())
;
// 跟新父节点节点状态
if
(
parentSparepartType
.
getIsLeaf
()){
parentSparepartType
.
setIsLeaf
(
false
);
equipmentSparepartTypeService
.
updateById
(
parentSparepartType
);
}
}
boolean
ok
=
equipmentSparepartTypeService
.
updateById
(
equipmentSparepartType
);
//批量更改祖籍信息
equipmentSparepartTypeService
.
updateAncestors
(
equipmentSparepartTypeEntity
.
getAncestors
(),
equipmentSparepartType
.
getAncestors
()
);
//更新父级叶子节点状态
String
parentId
=
equipmentSparepartType
.
getParentId
();
/*
String parentId = equipmentSparepartType.getParentId();
if(StringUtils.isNotEmpty(parentId)) {
EquipmentSparepartType parentEquipmentSparepartTypeEntity = equipmentSparepartTypeService.getById(parentId);
parentEquipmentSparepartTypeEntity.putIsLeaf(false);
equipmentSparepartTypeService.updateById(parentEquipmentSparepartTypeEntity);
}
}
*/
if
(
ok
)
{
result
.
success
(
"修改成功!"
);
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/entity/EquipmentSparepartType.java
查看文件 @
b5d77a4
...
...
@@ -2,6 +2,7 @@ package com.skua.modules.supplies.entity;
import
java.util.Date
;
import
com.baomidou.mybatisplus.annotation.TableField
;
import
org.jeecgframework.poi.excel.annotation.Excel
;
import
org.springframework.format.annotation.DateTimeFormat
;
...
...
@@ -38,6 +39,9 @@ public class EquipmentSparepartType {
@Excel
(
name
=
"父ID"
,
width
=
15
)
@ApiModelProperty
(
value
=
"父ID"
)
private
String
parentId
;
@ApiModelProperty
(
value
=
"祖籍信息"
)
private
String
ancestors
;
/**
* 文本key
*/
...
...
@@ -71,7 +75,8 @@ public class EquipmentSparepartType {
@Excel
(
name
=
"是否药剂,1:是 0:不是"
,
width
=
15
)
@ApiModelProperty
(
value
=
"是否药剂,1:是 0:不是"
)
private
boolean
isMedicament
=
false
;
private
boolean
medicament
=
false
;
/**
* 创建人
*/
...
...
@@ -107,6 +112,14 @@ public class EquipmentSparepartType {
@ApiModelProperty
(
value
=
"删除状态 0正常 1已删除"
)
private
Integer
delFlag
;
public
boolean
getIsLeaf
()
{
return
isLeaf
;
}
public
void
setIsLeaf
(
boolean
isLeaf
)
{
this
.
isLeaf
=
isLeaf
;
}
public
void
putIsLeaf
(
Boolean
isLeaf
)
{
if
(
isLeaf
!=
null
)
{
this
.
isLeaf
=
isLeaf
;
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/mapper/EquipmentSparepartTypeMapper.java
查看文件 @
b5d77a4
...
...
@@ -2,10 +2,17 @@ package com.skua.modules.supplies.mapper;
import
com.baomidou.mybatisplus.core.mapper.BaseMapper
;
import
com.skua.modules.supplies.entity.EquipmentSparepartType
;
import
org.apache.ibatis.annotations.Param
;
/**
* 设备物资类型
*/
public
interface
EquipmentSparepartTypeMapper
extends
BaseMapper
<
EquipmentSparepartType
>
{
/***
* 批量更改祖籍信息
* @param oldAncestors
* @param newAncestors
*/
public
void
updateAncestors
(
@Param
(
"oldAncestors"
)
String
oldAncestors
,
@Param
(
"newAncestors"
)
String
newAncestors
);
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/mapper/xml/EquipmentSparepartTypeMapper.xml
查看文件 @
b5d77a4
...
...
@@ -2,4 +2,8 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper
namespace=
"com.skua.modules.supplies.mapper.EquipmentSparepartTypeMapper"
>
<!-- 批量更改祖籍信息 -->
<update
id=
"updateAncestors"
>
update equipment_sparepart_type set ancestors = REPLACE(ancestors,#{oldAncestors}, #{newAncestors});
</update>
</mapper>
\ No newline at end of file
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/service/IEquipmentSparepartTypeService.java
查看文件 @
b5d77a4
...
...
@@ -27,4 +27,10 @@ public interface IEquipmentSparepartTypeService extends IService<EquipmentSparep
*/
void
saveAndUpdateParent
(
EquipmentSparepartType
equipmentSparepartType
);
/***
* 批量更改祖籍信息
* @param oldAncestors
* @param newAncestors
*/
void
updateAncestors
(
String
oldAncestors
,
String
newAncestors
);
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/service/impl/EquipmentSparepartTypeServiceImpl.java
查看文件 @
b5d77a4
...
...
@@ -63,4 +63,13 @@ public class EquipmentSparepartTypeServiceImpl extends ServiceImpl<EquipmentSpar
}
}
/***
* 批量更改祖籍信息
* @param oldAncestors
* @param newAncestors
*/
public
void
updateAncestors
(
String
oldAncestors
,
String
newAncestors
){
this
.
baseMapper
.
updateAncestors
(
oldAncestors
,
newAncestors
);
}
}
...
...
sk-module-equipment/src/main/java/com/skua/modules/supplies/vo/EquipmentSparepartTypeVO.java
查看文件 @
b5d77a4
...
...
@@ -5,7 +5,9 @@ import java.util.List;
import
com.skua.modules.supplies.entity.EquipmentSparepartType
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.jeecgframework.poi.excel.annotation.Excel
;
/**
* @author sonin
...
...
@@ -22,6 +24,7 @@ public class EquipmentSparepartTypeVO {
private
String
itemValue
;
private
Boolean
medicament
=
false
;
private
String
remark
;
private
Integer
sort
;
...
...
@@ -37,8 +40,9 @@ public class EquipmentSparepartTypeVO {
this
.
itemValue
=
entity
.
getItemValue
();
this
.
remark
=
entity
.
getRemark
();
this
.
sort
=
entity
.
getSort
();
this
.
isLeaf
=
entity
.
isLeaf
();
if
(!
entity
.
isLeaf
())
{
this
.
isLeaf
=
entity
.
getIsLeaf
();
this
.
medicament
=
entity
.
isMedicament
();
if
(!
entity
.
getIsLeaf
())
{
this
.
children
=
new
ArrayList
<>();
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论