Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
J
jgjy
Project
Project
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
Graph
比较
统计图
议题
0
议题
0
列表
看板
标记
Milestones
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
注册表
注册表
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
svn
jgjy
Commits
b344ac59
提交
b344ac59
authored
12月 22, 2020
作者:
zhouzhigang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
资源导入添加字段:目录、简介、分类
上级
f4ab1270
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
100 行增加
和
2 行删除
+100
-2
DiyTypeManage.java
...va/com/zrqx/bg/resource/manage/diytype/DiyTypeManage.java
+90
-1
PhyResourceServiceImpl.java
...rce/service/goods/phyresource/PhyResourceServiceImpl.java
+1
-1
ImportPhyResourceExcelVo.java
...source/bg/goods/phyresource/ImportPhyResourceExcelVo.java
+9
-0
没有找到文件。
com.zrqx.bg.resource/src/main/java/com/zrqx/bg/resource/manage/diytype/DiyTypeManage.java
浏览文件 @
b344ac59
...
...
@@ -6,6 +6,8 @@ import com.zrqx.core.exception.BaseException;
import
com.zrqx.core.model.resource.diytype.DiyType
;
import
com.zrqx.core.model.resource.diytype.GoodsDiyTypeRelation
;
import
com.zrqx.core.util.datatype.ArrayUtils
;
import
com.zrqx.core.util.datatype.StringUtil
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.springframework.beans.factory.annotation.Autowired
;
...
...
@@ -15,6 +17,8 @@ import java.util.Date;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
import
java.util.stream.Stream
;
@Component
public
class
DiyTypeManage
{
...
...
@@ -78,7 +82,7 @@ public class DiyTypeManage {
/**
* 添加商品自定义分类
* @param
goodsId
* @param
* @param diyTypeId
* @return
* @author lw
...
...
@@ -189,5 +193,90 @@ public class DiyTypeManage {
}
return
diyType
;
}
/**
* 功能描述: <br>
* 〈〉保存图书与自定义分类的关系
* @Param: [goodsIds, diyTypeIds]
* @Return: boolean
* @Author: zzg
* @Date: 2020/12/21 16:12
*/
public
boolean
saveDiyTypes
(
List
<
String
>
goodsIds
,
String
diyTypes
){
if
(
StringUtils
.
isEmpty
(
diyTypes
))
return
true
;
goodsIds
.
forEach
(
id
->
{
GoodsDiyTypeRelation
record
=
new
GoodsDiyTypeRelation
();
record
.
setGoodsid
(
id
);
List
<
GoodsDiyTypeRelation
>
list
=
goodsDiyTypeRelationMapper
.
select
(
record
);
if
(
list
!=
null
&&
list
.
size
()
>
0
){
goodsDiyTypeRelationMapper
.
delete
(
record
);
}
String
[]
types
=
diyTypes
.
split
(
"-"
);
List
<
String
>
vList
=
Stream
.
of
(
types
).
collect
(
Collectors
.
toList
());
String
str
=
vList
.
get
(
vList
.
size
()
-
1
);
//获取集合中的最后一个元素
DiyType
diyType
=
new
DiyType
();
diyType
.
setShowName
(
str
);
List
<
DiyType
>
voList
=
diyTypeMapper
.
select
(
diyType
);
if
(
1
==
voList
.
size
()){
//如果集合长度为1,则说明数据库中对应的自定义分类只有一个,直接进行绑定即可
GoodsDiyTypeRelation
entity
=
new
GoodsDiyTypeRelation
();
entity
.
setGoodsid
(
id
);
entity
.
setDiytypeid
(
voList
.
get
(
0
).
getId
());
entity
.
setCode
(
voList
.
get
(
0
).
getCode
());
entity
.
setId
(
null
);
entity
.
setUpdateTime
(
new
Date
());
goodsDiyTypeRelationMapper
.
insertSelective
(
entity
);
}
else
{
//集合长度大于1 说明数据库中的自定义分类有重复,需要根据它的上级分类去确定唯一值
String
val1
=
null
;
//分类
String
val2
=
null
;
//分类
String
val3
=
null
;
//分类
String
val4
=
null
;
//分类
for
(
int
i
=
0
;
i
<
voList
.
size
();
i
++)
{
StringBuffer
sb
=
new
StringBuffer
();
val1
=
voList
.
get
(
i
).
getShowName
();
if
(
voList
.
get
(
i
).
getParentId
()
!=
0
){
DiyType
diyType1
=
diyTypeMapper
.
selectByPrimaryKey
(
voList
.
get
(
i
).
getParentId
());
val2
=
diyType1
.
getShowName
();
if
(
diyType1
.
getParentId
()
!=
0
){
DiyType
diyType2
=
diyTypeMapper
.
selectByPrimaryKey
(
diyType1
.
getParentId
());
val3
=
diyType2
.
getShowName
();
if
(
diyType2
.
getParentId
()
!=
0
){
DiyType
diyType3
=
diyTypeMapper
.
selectByPrimaryKey
(
diyType2
.
getParentId
());
val4
=
diyType3
.
getShowName
();
}
}
}
if
(
StringUtils
.
isNotEmpty
(
val4
)){
sb
.
append
(
val4
);
sb
.
append
(
"-"
);
}
if
(
StringUtils
.
isNotEmpty
(
val3
)){
sb
.
append
(
val3
);
sb
.
append
(
"-"
);
}
if
(
StringUtils
.
isNotEmpty
(
val2
)){
sb
.
append
(
val2
);
sb
.
append
(
"-"
);
}
if
(
StringUtils
.
isNotEmpty
(
val1
)){
sb
.
append
(
val1
);
}
if
(
sb
.
toString
().
equals
(
diyTypes
)){
//判断导入的自定义分类跟拼接的自定义分类相同的话,进行绑定
GoodsDiyTypeRelation
entity
=
new
GoodsDiyTypeRelation
();
entity
.
setGoodsid
(
id
);
entity
.
setDiytypeid
(
voList
.
get
(
i
).
getId
());
entity
.
setCode
(
voList
.
get
(
i
).
getCode
());
entity
.
setId
(
null
);
entity
.
setUpdateTime
(
new
Date
());
goodsDiyTypeRelationMapper
.
insertSelective
(
entity
);
break
;
}
}
}
});
return
true
;
}
}
com.zrqx.bg.resource/src/main/java/com/zrqx/bg/resource/service/goods/phyresource/PhyResourceServiceImpl.java
浏览文件 @
b344ac59
...
...
@@ -613,7 +613,7 @@ public class PhyResourceServiceImpl extends BaseModelServiceImpl<PhyResource, St
List
<
Integer
>
diyTypeIds
=
new
ArrayList
<
Integer
>();
goodsIds
.
add
(
phyResource
.
getId
());
diyTypeIds
.
add
(
Integer
.
parseInt
(
diytypeId
));
diyTypeManage
.
updateDiyTypes
(
goodsIds
,
diyTypeIds
);
diyTypeManage
.
saveDiyTypes
(
goodsIds
,
importPhyResourceExcelVo
.
getDiyTypes
()
);
List
<
Integer
>
lables
=
formatLable
(
type
);
labelManage
.
updateLabels
(
goodsIds
,
lables
);
}
catch
(
Exception
e
)
{
...
...
com.zrqx.core/src/main/java/com/zrqx/core/vo/resource/bg/goods/phyresource/ImportPhyResourceExcelVo.java
浏览文件 @
b344ac59
...
...
@@ -72,4 +72,13 @@ public class ImportPhyResourceExcelVo {
private
String
keywords
;
@ExcelResources
(
title
=
"国家级技工教育规划教材"
,
order
=
18
)
private
String
countryStatus
;
@ExcelResources
(
title
=
"目录"
,
order
=
19
)
private
String
menu
;
@ExcelResources
(
title
=
"简介"
,
order
=
20
)
private
String
introduction
;
@ExcelResources
(
title
=
"分类"
,
order
=
21
)
private
String
diyTypes
;
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论