Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
4f2dd92c
提交
4f2dd92c
authored
11月 10, 2021
作者:
zjm
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix(单位模块): 添加了单位修改的接口
添加了单位修改的接口
上级
6770ee0b
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
74 行增加
和
5 行删除
+74
-5
UnitsCache.java
.../main/java/com/tykj/dev/device/user/cache/UnitsCache.java
+8
-2
UnitsController.java
...j/dev/device/user/subject/controller/UnitsController.java
+9
-0
Units.java
...n/java/com/tykj/dev/device/user/subject/entity/Units.java
+7
-0
UnitsService.java
...om/tykj/dev/device/user/subject/service/UnitsService.java
+5
-1
UnitsServiceImpl.java
...ev/device/user/subject/service/impl/UnitsServiceImpl.java
+45
-2
没有找到文件。
dev-user/src/main/java/com/tykj/dev/device/user/cache/UnitsCache.java
浏览文件 @
4f2dd92c
...
@@ -14,17 +14,22 @@ public class UnitsCache {
...
@@ -14,17 +14,22 @@ public class UnitsCache {
private
Map
<
Integer
,
Units
>
idMap
;
private
Map
<
Integer
,
Units
>
idMap
;
private
Map
<
Integer
,
Units
>
areaIdMpa
;
public
UnitsCache
(
List
<
Units
>
unitsList
){
public
UnitsCache
(
List
<
Units
>
unitsList
){
this
.
idMap
=
unitsList
.
stream
().
collect
(
Collectors
.
toMap
(
Units:
:
getUnitId
,
Function
.
identity
()));
this
.
idMap
=
unitsList
.
stream
().
collect
(
Collectors
.
toMap
(
Units:
:
getUnitId
,
Function
.
identity
()));
this
.
areaIdMpa
=
unitsList
.
stream
().
collect
(
Collectors
.
toMap
(
Units:
:
getAreaId
,
Function
.
identity
()));
}
}
public
Map
<
Integer
,
Units
>
getIdMap
()
{
public
Map
<
Integer
,
Units
>
getIdMap
()
{
return
idMap
;
return
idMap
;
}
}
public
Units
findByAreaId
(
Integer
areaId
){
return
areaIdMpa
.
get
(
areaId
);
}
public
Units
findById
(
Integer
id
)
{
public
Units
findById
(
Integer
id
)
{
return
idMap
.
get
(
id
);
return
idMap
.
get
(
id
);
}
}
...
@@ -40,6 +45,7 @@ public class UnitsCache {
...
@@ -40,6 +45,7 @@ public class UnitsCache {
public
UnitsCache
refresh
(
List
<
Units
>
unitsList
){
public
UnitsCache
refresh
(
List
<
Units
>
unitsList
){
this
.
idMap
=
unitsList
.
stream
().
collect
(
Collectors
.
toMap
(
Units:
:
getUnitId
,
Function
.
identity
()));
this
.
idMap
=
unitsList
.
stream
().
collect
(
Collectors
.
toMap
(
Units:
:
getUnitId
,
Function
.
identity
()));
this
.
areaIdMpa
=
unitsList
.
stream
().
collect
(
Collectors
.
toMap
(
Units:
:
getAreaId
,
Function
.
identity
()));
return
this
;
return
this
;
}
}
}
}
dev-user/src/main/java/com/tykj/dev/device/user/subject/controller/UnitsController.java
浏览文件 @
4f2dd92c
...
@@ -180,4 +180,13 @@ public class UnitsController {
...
@@ -180,4 +180,13 @@ public class UnitsController {
return
ResponseEntity
.
ok
(
unitsService
.
belongsUnits
());
return
ResponseEntity
.
ok
(
unitsService
.
belongsUnits
());
}
}
/**
* 单位管理修改单位接口
*/
@PostMapping
(
"/updateUnits"
)
@ApiOperation
(
value
=
"[单位管理]单位管理修改单位接口"
,
notes
=
"单位管理修改单位接口"
)
public
ResponseEntity
updateUnit
(
@RequestBody
Units
units
){
return
ResponseEntity
.
ok
(
unitsService
.
updateUnit
(
units
));
}
}
}
dev-user/src/main/java/com/tykj/dev/device/user/subject/entity/Units.java
浏览文件 @
4f2dd92c
...
@@ -12,6 +12,7 @@ import lombok.NoArgsConstructor;
...
@@ -12,6 +12,7 @@ import lombok.NoArgsConstructor;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.SQLDelete
;
import
org.hibernate.annotations.Where
;
import
org.hibernate.annotations.Where
;
import
org.modelmapper.ModelMapper
;
import
org.modelmapper.ModelMapper
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
javax.persistence.*
;
import
javax.persistence.*
;
import
java.util.UUID
;
import
java.util.UUID
;
...
@@ -100,6 +101,11 @@ public class Units {
...
@@ -100,6 +101,11 @@ public class Units {
@ApiModelProperty
(
value
=
"展示区域id"
)
@ApiModelProperty
(
value
=
"展示区域id"
)
private
Integer
exhibitionId
;
private
Integer
exhibitionId
;
@Transient
@ApiModelProperty
(
value
=
"上级单位ID"
)
private
Integer
parentUnitId
;
/**
/**
* 区域对象
* 区域对象
*/
*/
...
@@ -121,6 +127,7 @@ public class Units {
...
@@ -121,6 +127,7 @@ public class Units {
null
,
null
,
null
,
null
,
null
,
null
,
null
,
null
null
);
);
}
}
...
...
dev-user/src/main/java/com/tykj/dev/device/user/subject/service/UnitsService.java
浏览文件 @
4f2dd92c
...
@@ -200,11 +200,15 @@ public interface UnitsService extends PublicService<Units> {
...
@@ -200,11 +200,15 @@ public interface UnitsService extends PublicService<Units> {
*/
*/
List
<
Units
>
saveUnits
(
UnitsAddVo
unitsAddVo
);
List
<
Units
>
saveUnits
(
UnitsAddVo
unitsAddVo
);
/**
/**
* 添加单位所有单位列表
* 添加单位所有单位列表
*/
*/
List
<
Units
>
belongsUnits
();
List
<
Units
>
belongsUnits
();
/**
* 更新单位对象
*/
Units
updateUnit
(
Units
units
);
}
}
dev-user/src/main/java/com/tykj/dev/device/user/subject/service/impl/UnitsServiceImpl.java
浏览文件 @
4f2dd92c
...
@@ -473,6 +473,11 @@ public class UnitsServiceImpl implements UnitsService {
...
@@ -473,6 +473,11 @@ public class UnitsServiceImpl implements UnitsService {
units
->
{
units
->
{
AreaExhibition
areaExhibition
=
areaExhibitionService
.
findById
(
units
.
getExhibitionId
());
AreaExhibition
areaExhibition
=
areaExhibitionService
.
findById
(
units
.
getExhibitionId
());
units
.
setAreaName
(
areaExhibition
.
getAreaName
());
units
.
setAreaName
(
areaExhibition
.
getAreaName
());
//查询当前单位的逻辑区域
Units
units1
=
findByParentUnit
(
units
);
if
(
units1
!=
null
){
units
.
setParentUnitId
(
units1
.
getUnitId
());
}
}
}
);
);
unitsList
=
unitsList
.
stream
().
sorted
(
Comparator
.
comparing
(
Units:
:
getShowOrder
)).
collect
(
Collectors
.
toList
());
unitsList
=
unitsList
.
stream
().
sorted
(
Comparator
.
comparing
(
Units:
:
getShowOrder
)).
collect
(
Collectors
.
toList
());
...
@@ -504,7 +509,45 @@ public class UnitsServiceImpl implements UnitsService {
...
@@ -504,7 +509,45 @@ public class UnitsServiceImpl implements UnitsService {
@Override
@Override
public
List
<
Units
>
belongsUnits
()
{
public
List
<
Units
>
belongsUnits
()
{
return
unitsDao
.
findAll
().
stream
().
filter
(
units
->
units
.
getLevel
()==
1
&&
units
.
getLevel
()==
2
).
sorted
(
Comparator
.
comparing
(
Units:
:
getShowOrder
)).
collect
(
Collectors
.
toList
());
return
unitsDao
.
findAll
().
stream
().
filter
(
units
->
units
.
getLevel
()==
1
||
units
.
getLevel
()==
2
).
sorted
(
Comparator
.
comparing
(
Units:
:
getShowOrder
)).
collect
(
Collectors
.
toList
());
}
private
Units
findByParentUnit
(
Units
units
){
Area
area
=
areaCache
.
findById
(
units
.
getAreaId
());
if
(
area
.
getFatherId
()!=
null
){
Area
area1
=
areaCache
.
findById
(
area
.
getFatherId
());
return
unitsCache
.
findByAreaId
(
area1
.
getId
());
}
else
{
return
null
;
}
}
@Override
public
Units
updateUnit
(
Units
units
)
{
Units
unitsOld
=
unitsCache
.
findById
(
units
.
getUnitId
());
if
(!
units
.
getLevel
().
equals
(
unitsOld
.
getLevel
())){
units
.
setType
(
levelToType
(
units
.
getLevel
()));
}
Units
parentUnitOld
=
findByParentUnit
(
units
);
if
(
units
.
getParentUnitId
()!=
null
){
if
(
parentUnitOld
==
null
||!
parentUnitOld
.
getUnitId
().
equals
(
units
.
getParentUnitId
())){
//查询需要修改的上级id
Units
parentUnitNow
=
unitsCache
.
findById
(
units
.
getParentUnitId
());
Area
newArea
=
areaCache
.
findById
(
parentUnitNow
.
getAreaId
());
Area
oldArea
=
areaCache
.
findById
(
unitsOld
.
getAreaId
());
oldArea
.
setFatherId
(
newArea
.
getId
());
areaDao
.
save
(
oldArea
);
}
}
else
{
if
(
parentUnitOld
!=
null
){
Area
oldArea
=
areaCache
.
findById
(
unitsOld
.
getAreaId
());
oldArea
.
setFatherId
(
null
);
areaDao
.
save
(
oldArea
);
}
}
unitsDao
.
save
(
units
);
unitsCache
.
refresh
(
unitsDao
.
findAll
());
areaCache
.
refresh
(
areaDao
.
findAll
());
return
units
;
}
}
/**
/**
...
@@ -516,7 +559,7 @@ public class UnitsServiceImpl implements UnitsService {
...
@@ -516,7 +559,7 @@ public class UnitsServiceImpl implements UnitsService {
case
0
:
case
0
:
return
3
;
return
3
;
case
1
:
case
1
:
return
1
;
return
2
;
case
2
:
case
2
:
return
1
;
return
1
;
case
3
:
case
3
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论