Merge remote-tracking branch 'origin/dev_third_stage' into dev_third_stage

This commit is contained in:
gaosong
2022-08-10 23:32:27 +08:00
12 changed files with 270 additions and 84 deletions
@@ -1,15 +1,29 @@
package com.jero.modules.feishu.service.impl;
import cn.hutool.core.util.StrUtil;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jero.modules.feishu.service.IFeishuService;
import com.jero.modules.feishu.vo.FeishuMsgVo;
import com.jero.modules.problemKnowledgeBase.entity.ProblemKnowledgeBaseClassifyEO;
import com.jero.modules.problemKnowledgeBase.entity.ProblemKnowledgeBaseEO;
import com.jero.modules.problemKnowledgeBase.entity.ProblemKnowledgeBaseUserEO;
import com.jero.modules.problemKnowledgeBase.enums.ShowPermissionsEnum;
import com.jero.modules.problemKnowledgeBase.service.IProblemKnowledgeBaseClassifyEOService;
import com.jero.modules.problemKnowledgeBase.service.IProblemKnowledgeBaseEOService;
import com.jero.modules.problemKnowledgeBase.service.IProblemKnowledgeBaseUserEOService;
import com.jero.modules.project.enums.JumpLinkEnum;
import com.jero.modules.system.entity.SysUser;
import com.jero.modules.system.service.ISysUserService;
import com.jero.modules.system.util.HttpRequestUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
@@ -18,6 +32,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @Author: liyawei
@@ -42,6 +57,17 @@ public class FeishuServiceImpl implements IFeishuService {
@Value("${Feishu.translateTextUrl}")
private String translateTextUrl;
@Value(value = "${jero.backUrl}")
private String backUrl;
@Autowired
private IProblemKnowledgeBaseClassifyEOService problemKnowledgeBaseClassifyEOService;
@Autowired
private IProblemKnowledgeBaseEOService problemKnowledgeBaseEOService;
@Autowired
private IProblemKnowledgeBaseUserEOService problemKnowledgeBaseUserEOService;
@Autowired
private ISysUserService sysUserService;
/**
* 获取token
* @return
@@ -333,7 +359,8 @@ public class FeishuServiceImpl implements IFeishuService {
" \"title\": {\n" +
" \"tag\": \"plain_text\",\n" +
" \"content\": \"点击下方的分类查看常见问题\"\n" +
" }\n" +
" },\n" +
" \"template\": \"green\"\n" +
" }\n" +
"}";
JSONObject jsonObject = JSONObject.parseObject(sendJson);
@@ -342,56 +369,28 @@ public class FeishuServiceImpl implements IFeishuService {
element.put("tag","action");
element.put("layout","bisected");
JSONArray actions = new JSONArray();
//组装推送过去的点击按钮
for (int i=0; i<5; i++){
//获取分类
List<ProblemKnowledgeBaseClassifyEO> problemKnowledgeBaseClassifyEOList = this.problemKnowledgeBaseClassifyEOService.list();
JSONArray actions = new JSONArray();
//组装推送过去的点击按钮
for (ProblemKnowledgeBaseClassifyEO problemKnowledgeBaseClassifyEO : problemKnowledgeBaseClassifyEOList) {
JSONObject buttonObject = new JSONObject();
JSONObject text = new JSONObject();
JSONObject value = new JSONObject();
buttonObject.put("tag","button");
if(i==0){
text.put("tag","plain_text");
text.put("content","content1");
text.put("tag","plain_text");
text.put("content",problemKnowledgeBaseClassifyEO.getProblemLabel());
value.put("chosen",problemKnowledgeBaseClassifyEO.getId());
value.put("chosen","chosen1");
}
if(i==1){
text.put("tag","plain_text");
text.put("content","content2");
value.put("chosen","chosen2");
}
if(i==2){
text.put("tag","plain_text");
text.put("content","content3");
value.put("chosen","chosen3");
}
if(i==3){
text.put("tag","plain_text");
text.put("content","content4");
value.put("chosen","chosen4");
}
if(i==4){
text.put("tag","plain_text");
text.put("content","content5");
value.put("chosen","chosen5");
}
if(i==5){
text.put("tag","plain_text");
text.put("content","content6");
value.put("chosen","chosen6");
}
buttonObject.put("text",text);
buttonObject.put("type","primary");
buttonObject.put("value",value);
actions.add(buttonObject);
}
element.put("actions",actions);
@@ -423,12 +422,94 @@ public class FeishuServiceImpl implements IFeishuService {
String clickStr = JSONObject.toJSONString(JSONObject.parseObject(JSONObject.toJSONString(jsonObject.get("action"))).get("value"));
log.info("用户点击的数据: " + clickStr);
String sendJson = " ";
String sendJsonStr = "{\n" +
" \"config\": {\n" +
" \"wide_screen_mode\": true\n" +
" },\n" +
" \"header\": {\n" +
" \"title\": {\n" +
" \"tag\": \"plain_text\",\n" +
" \"content\": \"问题知识库信息,点击下方标题即可跳转至详情页查看\"\n" +
" },\n" +
" \"template\": \"green\"\n" +
" }\n" +
"}";
JSONObject sendJson = JSONObject.parseObject(sendJsonStr);
JSONArray elements = new JSONArray();
//分隔行对象。
JSONObject dividingLineJson = new JSONObject();
dividingLineJson.put("tag","hr");
JSONObject clickJson = JSONObject.parseObject(clickStr);
if(StringUtils.isNotEmpty(clickJson.getString("chosen"))){
sendJson = clickJson.getString("chosen");
String problemTypeId = clickJson.getString("chosen");
String thirdId = userIds[0];
SysUser currentOperatorUser = this.sysUserService.getBaseMapper().selectOne(
new QueryWrapper<SysUser>().lambda().eq(SysUser::getThirdId, thirdId)
);
if(ObjectUtils.isNotEmpty(currentOperatorUser)){
QueryWrapper<ProblemKnowledgeBaseUserEO> userPermissionQueryWrapper = new QueryWrapper<>();
userPermissionQueryWrapper.lambda().eq(ProblemKnowledgeBaseUserEO::getUserId,currentOperatorUser.getId());
List<ProblemKnowledgeBaseUserEO> problemKnowledgeBaseUserEOList = this.problemKnowledgeBaseUserEOService.list(userPermissionQueryWrapper);
List<String> problemKnowledgeBaseIdList = problemKnowledgeBaseUserEOList.stream().map(ProblemKnowledgeBaseUserEO::getProblemKnowledgeBaseId).distinct().collect(Collectors.toList());
QueryWrapper<ProblemKnowledgeBaseEO> problemKnowledgeBaseEOQueryWrapper = new QueryWrapper<>();
problemKnowledgeBaseEOQueryWrapper.lambda().eq(ProblemKnowledgeBaseEO::getProblemType,problemTypeId);
problemKnowledgeBaseEOQueryWrapper.lambda().and(query -> {
query.eq(ProblemKnowledgeBaseEO::getShowPermissions, ShowPermissionsEnum.OPEN.getValue()).
or(o -> {
o.eq(ProblemKnowledgeBaseEO::getShowPermissions,ShowPermissionsEnum.PRIVACY.getValue());
o.in(ProblemKnowledgeBaseEO::getId,problemKnowledgeBaseIdList);
});
});
//根据发布日期倒序 查询出(公开、私密且自己是权限用户)最新的五条数据
problemKnowledgeBaseEOQueryWrapper.orderByDesc("release_time");
Integer pageNo = 1;
Integer pageSize = 5;
Page<ProblemKnowledgeBaseEO> page = new Page<ProblemKnowledgeBaseEO>(pageNo, pageSize);
IPage<ProblemKnowledgeBaseEO> pageList = problemKnowledgeBaseEOService.page(page, problemKnowledgeBaseEOQueryWrapper);
List<ProblemKnowledgeBaseEO> records = pageList.getRecords();
JSONObject element = new JSONObject();
JSONArray actions = new JSONArray();
for (ProblemKnowledgeBaseEO record : records) {
String url = backUrl + JumpLinkEnum.PROBLEM_KNOWLEDGE_BASE_DETAIL.getLink() + "?id=" + record.getId();
JSONObject action = new JSONObject();
JSONObject text = new JSONObject();
action.put("tag","button");
text.put("tag","plain_text");
text.put("content",record.getTitle());
action.put("text",text);
action.put("type","primary");
action.put("url",url);
actions.add(action);
}
element.put("tag","action");
element.put("actions",actions);
elements.add(element);
//添加一个分隔线。
elements.add(dividingLineJson);
}
}
JSONObject textFinally = new JSONObject();
textFinally.put("tag","lark_md");
textFinally.put("content","[以上都不是>>]("+backUrl + JumpLinkEnum.PROBLEM_KNOWLEDGE_BASE.getLink()+")");
JSONObject elementFinally = new JSONObject();
elementFinally.put("tag","div");
elementFinally.put("text",textFinally);
elements.add(elementFinally);
sendJson.put("elements",elements);
String token = null;
try {
@@ -440,30 +521,13 @@ public class FeishuServiceImpl implements IFeishuService {
Map<String, String> headerMap = new HashMap<>();
headerMap.put("Authorization", "Bearer " + token);
headerMap.put("Content-Type", "application/json; charset=utf-8");
// 设置消息标题
JSONObject zh_cn = new JSONObject();
zh_cn.put("title", "title");
// 设置消息内容
// 第一行
JSONObject contentOne = new JSONObject();
contentOne.put("tag", "text");
contentOne.put("text", sendJson);
List<JSONObject> contentList = new ArrayList<>();
contentList.add(contentOne);
List<List<JSONObject>> list = new ArrayList<>();
list.add(contentList);
zh_cn.put("content", list);
JSONObject post = new JSONObject();
post.put("zh_cn", zh_cn);
JSONObject contentObj = new JSONObject();
contentObj.put("post", post);
// 设置请求参数
JSONObject paramsMap = new JSONObject();
paramsMap.put("user_ids", userIds);
paramsMap.put("msg_type", "post");
paramsMap.put("content", contentObj);
paramsMap.put("msg_type", "interactive");
paramsMap.put("card", sendJson);
// 发送请求给飞书
String response = null;
try {
@@ -471,7 +535,6 @@ public class FeishuServiceImpl implements IFeishuService {
} catch (IOException e) {
e.printStackTrace();
}
// 返回结果样例:{"code":0,"data":{"invalid_department_ids":[],"invalid_open_ids":[],"invalid_union_ids":[],"invalid_user_ids":[],"message_id":"bm-d595567e4f448fafe397bc916f0be646"},"msg":"ok"}
// 获取返回结果
JSONObject tokenJson = JSONObject.parseObject(response);
if(!tokenJson.get("code").toString().equals("0")) {
@@ -84,6 +84,10 @@ public class CountryCardManageReleaseDetailEO implements Serializable {
@ApiModelProperty(value = "内容")
private java.lang.String content;
/**如果是下拉选的话,把翻译后的值放到此字段中。*/
@TableField(exist = false)
private java.lang.String contentDropDownValue;
@TableField(exist = false)
private String cut;
@@ -72,12 +72,19 @@ public class ProblemKnowledgeBaseEO implements Serializable {
/**问题分类展示名称*/
@TableField(exist = false)
private java.lang.String problemTypeName;
/**问题分类查询条件字段 多个*/
@TableField(exist = false)
private java.lang.String problemTypes;
/**市场*/
@Dict(dicCode = "region")
/**市场*/
//@Dict(dicCode = "region")
@Excel(name = "市场", width = 15)
@ApiModelProperty(value = "市场")
private java.lang.String targetMarket;
/**市场展示字段**/
@TableField(exist = false)
private java.lang.String targetMarket_dicText;
/**文档库id*/
@Excel(name = "文档库id", width = 15)
@@ -148,6 +148,19 @@ public class CountryCardManageReleaseDetailEOServiceImpl extends ServiceImpl<Cou
}).collect(Collectors.toList());
data.setCountryCardTempItemEOList(collect);
if(StringUtils.isNotEmpty(data.getContent())){
String contentDropDownValue = countryCardTempItemEOList.stream().filter(countryCardTempItemEO -> {
boolean flag = false;
if (StringUtils.equals(data.getContent(), countryCardTempItemEO.getId())) {
flag = true;
}
return flag;
}).map(CountryCardTempItemEO::getItemText).collect(Collectors.joining(","));
//设置下拉框的value
data.setContentDropDownValue(contentDropDownValue);
}
}
});
@@ -1,7 +1,9 @@
package com.jero.modules.problemKnowledgeBase.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.system.query.QueryGenerator;
import com.jero.common.system.vo.DictModel;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.problemKnowledgeBase.entity.*;
import com.jero.modules.problemKnowledgeBase.enums.CollectStatusEnum;
@@ -9,6 +11,8 @@ import com.jero.modules.problemKnowledgeBase.enums.PraiseStatusEnum;
import com.jero.modules.problemKnowledgeBase.enums.ShowPermissionsEnum;
import com.jero.modules.problemKnowledgeBase.mapper.ProblemKnowledgeBaseEOMapper;
import com.jero.modules.problemKnowledgeBase.service.*;
import com.jero.modules.system.enums.DicCodeEnum;
import com.jero.modules.system.service.ISysDictService;
import com.jero.modules.system.util.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.shiro.SecurityUtils;
@@ -44,6 +48,8 @@ public class ProblemKnowledgeBaseEOServiceImpl extends ServiceImpl<ProblemKnowle
private IProblemKnowledgeBaseBrowsingHistoryEOService problemKnowledgeBaseBrowsingHistoryEOService;
@Autowired
private IProblemKnowledgeBaseClassifyEOService problemKnowledgeBaseClassifyEOService;
@Autowired
private ISysDictService sysDictService;
/**
* 保存
@@ -209,6 +215,7 @@ public class ProblemKnowledgeBaseEOServiceImpl extends ServiceImpl<ProblemKnowle
problemKnowledgeBaseClassifyEOList = this.problemKnowledgeBaseClassifyEOService.list(classifyEOQueryWrapper);
}
List<DictModel> regionList = sysDictService.queryDictItemsByCode(DicCodeEnum.REGION.getCode());
List<ProblemKnowledgeBaseClassifyEO> finalProblemKnowledgeBaseClassifyEOList = problemKnowledgeBaseClassifyEOList;
datas.forEach(data -> {
@@ -298,6 +305,30 @@ public class ProblemKnowledgeBaseEOServiceImpl extends ServiceImpl<ProblemKnowle
data.setProblemTypeName(problemTypeName);
}
String targetMarket = data.getTargetMarket();
if(StringUtils.isNotEmpty(targetMarket) && CollectionUtils.isNotEmpty(regionList)){
String targetMarket_dicText = "";
if(StringUtils.equals(cut, CutEnum.CN.getValue())){
targetMarket_dicText = regionList.stream().filter(region -> {
boolean flag = false;
if (StringUtils.equals(targetMarket, region.getValue())) {
flag = true;
}
return flag;
}).map(DictModel::getText).collect(Collectors.joining(","));
}else if(StringUtils.equals(cut, CutEnum.EN.getValue())){
targetMarket_dicText = regionList.stream().filter(region -> {
boolean flag = false;
if (StringUtils.equals(targetMarket, region.getValue())) {
flag = true;
}
return flag;
}).map(DictModel::getTextEn).collect(Collectors.joining(","));
}
data.setTargetMarket_dicText(targetMarket_dicText);
}
});
}
}
@@ -335,5 +366,21 @@ public class ProblemKnowledgeBaseEOServiceImpl extends ServiceImpl<ProblemKnowle
query.or().like(ProblemKnowledgeBaseEO::getContent,searchStr);
});
}
//根据分类查询 ,包含就查出来。
String problemTypes = problemKnowledgeBaseEO.getProblemTypes();
if(StringUtils.isNotEmpty(problemTypes)){
List<String> problemTypeList = Arrays.asList(problemTypes.split(","));
queryWrapper.and(query -> {
query.lambda().like(ProblemKnowledgeBaseEO::getProblemType,problemTypes);
if(CollectionUtils.isNotEmpty(problemTypeList)){
problemTypeList.forEach(type -> {
query.or(q -> {
q.lambda().like(ProblemKnowledgeBaseEO::getProblemType,type);
});
});
}
});
}
}
}
+1
View File
@@ -1255,4 +1255,5 @@ module.exports = {
deleteNode:'If there is any file information, the file will be deleted. Are you sure to delete this data?',
HaveReleased:'Have released',
forward:'Forward',
issuedBy:'Issued by',
}
+1
View File
@@ -1358,4 +1358,5 @@ module.exports = {
deleteNode:'若有文件信息将同步删除确认删除该条数据',
HaveReleased:'已发布',
forward:'转发',
issuedBy:'发布人',
}
@@ -190,7 +190,6 @@
})
})
})
console.log(this.contentList)
},
queryCountry(callback) {
this.loading = true
@@ -92,12 +92,11 @@
<span class="title-text-text" :title="$t('market')">{{$t('market')}}</span>
</div>
<a-form-model-item class="itemModel" prop="targetMarket">
<j-dict-select-tag class="box-input" v-model="formInline.targetMarket"
:disabled="disabled"
@input="handleInput('targetMarket')"
:placeholder="$t('PleaseSelect')+$t('market')"
:type="'select'"
:triggerChange="false" :dictCode="'region'"/>
<j-multi-select-tag class="box-input" v-model="formInline.targetMarket"
:disabled="disabled"
:placeholder="$t('PleaseSelect')+$t('market')"
:type="'select'"
:triggerChange="false" :dictCode="'region'"/>
</a-form-model-item>
</div>
</a-col>
@@ -110,6 +109,7 @@
</div>
<a-form-model-item class="itemModel" prop="standNumber">
<a-input class="box-input"
:title="formInline.standNumber"
:disabled="true"
v-model="formInline.standNumber"
:placeholder="$t('PleaseEnter')+$t('standardNo')"/>
@@ -133,11 +133,12 @@
<div class="title-text">
<span class="title-text-text">{{$t('content')}}</span>
</div>
<a-form-model-item class="itemModel" prop="vehiclePlatform">
<a-form-model-item style="height: 300px" class="itemModel" prop="content">
<quill-editor
style="height: 300px"
:content="formInline.content"
:options="editorOption"
@blur="quilleditorBlur"
@change="onEditorChange($event)"
/>
</a-form-model-item>
@@ -239,6 +240,13 @@
message: this.$t('market') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
content: [
{
max: 5000,
message: this.$t('content') + this.$t('cannotExceed') + 5000 + this.$t('Characters'),
trigger: 'change'
}
]
},
url: {
@@ -276,6 +284,9 @@
}
},
methods: {
quilleditorBlur() {
this.$refs.ruleForm.validateField('content')
},
getBase() {
getAction('/problemKnowledgeBase/problemKnowledgeBaseClassifyEO/list', {}).then((res) => {
if (res.success) {
@@ -340,7 +351,6 @@
}
,
onEditorChange({ quill, html, text }) {
console.log('editor change!', quill, html, text)
this.formInline.content = html
}
,
@@ -53,7 +53,7 @@
</a-tooltip>
</div>
<div class="text-content">
{{item.content}}
{{item.contentOne}}
</div>
</div>
</div>
@@ -130,6 +130,7 @@
? [...selectedTags, tag]
: selectedTags.filter(t => t !== tag)
this.selectedTags = nextSelectedTags
this.getList()
},
ResetSearch() {
this.searchStr = ''
@@ -160,16 +161,29 @@
this.pageSize = pageSize
this.getList()
},
getText(str) {
let words = str.replace(/<[^<>]+>/g, '').replace(/&nbsp;/gi, '') //这里是去除标签
return words.replace(/\s/g, '') //这里是去除空格
},
getList() {
let selectedTags = JSON.parse(JSON.stringify(this.selectedTags))
let query = {
pageNo: this.pageNo,
pageSize: this.pageSize,
searchStr: this.searchStr
searchStr: this.searchStr,
problemTypes: selectedTags.join(',')
}
this.loading = true
getAction(this.url.getInfoList, query).then((res) => {
if (res.success) {
this.conList = res.result.records
if (this.conList && this.conList.length > 0) {
this.conList.forEach(val => {
if (val.content) {
val.contentOne = this.getText(val.content)
}
})
}
this.total = res.result.total
this.loading = false
} else {
@@ -22,7 +22,7 @@
<a-button class="box-button" style="margin-left: 8px" @click="ResetSearch">{{$t('reset')}}</a-button>
</div>
</div>
<div v-if="conList.length > 0" style="height: calc(100vh - 180px);overflow:auto;">
<div v-if="conList.length > 0" style="height: calc(100vh - 240px);overflow:auto;">
<div v-for="(item,index) in conList" :key="item.id">
<div style="margin-bottom: 10px;position: relative;overflow: hidden">
<!-- <a-checkbox :value="item.id" class="checkbox-left"></a-checkbox>-->
@@ -36,7 +36,8 @@
<span class="text-header-text" style="cursor: pointer" v-html="item.title"></span>
</a-tooltip>
</div>
<div class="text-content" v-html="item.content">
<div class="text-content">
{{item.contentOne}}
</div>
<div class="text-text-right-text">
<a style="margin-right: 10px" @click="edit(item)">{{$t('edit')}}</a>
@@ -113,6 +114,10 @@
this.pageNo = 1
this.getList()
},
getText(str) {
let words = str.replace(/<[^<>]+>/g, '').replace(/&nbsp;/gi, '') //这里是去除标签
return words.replace(/\s/g, '') //这里是去除空格
},
getList() {
let query = {
pageNo: this.pageNo,
@@ -124,6 +129,13 @@
getAction(this.url.getInfoList, query).then((res) => {
if (res.success) {
this.conList = res.result.records
if (this.conList && this.conList.length > 0) {
this.conList.forEach(val => {
if (val.content) {
val.contentOne = this.getText(val.content)
}
})
}
this.total = res.result.total
this.loading = false
} else {
@@ -139,11 +151,9 @@
},
titleClick(item) {
let newUrl = this.$router.resolve({
path: '/docManage/library/detail',
path: '/problemKnowledgeBaseView',
query: {
id: item.id.slice(0, 32),
title: item.title,
serial_number: item.serial_number
id: item.id
}
})
window.open(newUrl.href, '_blank')
@@ -17,6 +17,14 @@
</div>
<div style="padding-top: 68px;background: #fff">
<div class="detail-content" style="padding: 24px">
<div class="content-text-top">
<span style="margin-right: 10px">
{{$t('issuedBy')}}:{{this.queryForm.createBy}}
</span>
<span>
{{$t('releaseDate')}}:{{this.queryForm.createTime}}
</span>
</div>
<div class="content-text">
<div class="text-field" v-for="(item,index) in standardContentList" :key="index">
<span class="text-field-left" :title="item.title">{{item.title}}</span>
@@ -104,11 +112,11 @@
standardContentList: [
{
title: this.$t('problemClassification'),
value: 'problemType'
value: 'problemTypeName'
},
{
title: this.$t('market'),
value: 'targetMarket'
value: 'targetMarket_dicText'
},
{
title: this.$t('standardNo'),
@@ -493,4 +501,13 @@
overflow: hidden;
text-align: right;
}
.content-text-top {
width: 100%;
text-align: right;
color: #040B29;
font-weight: 400;
font-size: 16px;
margin-bottom: 20px;
}
</style>