Commit f998e1c2 authored by caotao's avatar caotao

知识库代码提交

parent 5167791c
...@@ -21,6 +21,10 @@ ...@@ -21,6 +21,10 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<!-- 规则模块 --> <!-- 规则模块 -->
<dependency> <dependency>
<groupId>com.yeejoin</groupId> <groupId>com.yeejoin</groupId>
...@@ -74,20 +78,28 @@ ...@@ -74,20 +78,28 @@
<artifactId>html2pdf</artifactId> <artifactId>html2pdf</artifactId>
<version>2.0.1</version> <version>2.0.1</version>
</dependency> </dependency>
<!-- 解析excel --> <!-- 解析excel -->
<dependency> <dependency>
<groupId>org.apache.poi</groupId> <groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId> <artifactId>poi</artifactId>
<version>4.0.1</version> <version>4.1.2</version>
</dependency> </dependency>
<dependency> <!-- 针对2007以上版本的库 -->
<groupId>org.apache.poi</groupId> <dependency>
<artifactId>poi-ooxml</artifactId> <groupId>org.apache.poi</groupId>
<version>4.0.1</version> <artifactId>poi-ooxml</artifactId>
</dependency> <version>4.1.2</version>
<dependency> </dependency>
<groupId>org.springframework.boot</groupId> <!-- 针对2003版本的库 -->
<artifactId>spring-boot-starter-data-elasticsearch</artifactId> <dependency>
</dependency> <groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.poi.xwpf.converter.xhtml</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
package com.yeejoin.amos.knowledgebase.face.orm.dao; package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -9,7 +10,7 @@ import java.util.Map; ...@@ -9,7 +10,7 @@ import java.util.Map;
/** /**
* <p> * <p>
* 知识库文档存储 Mapper 接口 * 知识库文档存储 Mapper 接口
* </p> * </p>
* *
* @author 子杨 * @author 子杨
...@@ -18,18 +19,24 @@ import java.util.Map; ...@@ -18,18 +19,24 @@ import java.util.Map;
public interface DocContentMapper extends BaseMapper<KnowledgeDocContent> { public interface DocContentMapper extends BaseMapper<KnowledgeDocContent> {
List<Map<String,Long>> searchForDocIds(@Param("agencyCode") String agencyCode, List<Map<String, Long>> searchForDocIds(
@Param("queryStr") String queryStr, @Param("agencyCode") String agencyCode,
@Param("docStatus")String []docStatus, @Param("queryStr") String queryStr,
@Param("auditStatus")String [] auditStatus, @Param("docStatus") String[] docStatus,
@Param("userId")String userId, @Param("auditStatus") String[] auditStatus,
@Param("orgCode")String orgCode, @Param("userId") String userId,
@Param("offset") long offset, @Param("orgCode") String orgCode,
@Param("length") long length); @Param("offset") long offset,
@Param("length") long length);
List<Map<String,Object>> queryDocBaseInfoList(Map<String, Object> paramMap); List<Map<String, Object>> queryDocBaseInfoList(Map<String, Object> paramMap);
int queryDocBaseInfoTotal(Map<String, Object> paramMap); int queryDocBaseInfoTotal(Map<String, Object> paramMap);
List<Long> getAllPublishedDocIds(); List<Long> getAllPublishedDocIds();
IPage<KnowledgeDocContent> pageByType(
IPage<KnowledgeDocContent> page,
@Param("typeId") Long typeId,
@Param("tagId") Long tagId);
} }
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao; package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity; import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchCrudRepository; import org.springframework.data.elasticsearch.repository.ElasticsearchCrudRepository;
public interface ESDocRepository extends ElasticsearchCrudRepository<ESDocEntity, Long> { public interface ESDocRepository extends ElasticsearchCrudRepository<ESDocEntity, Long> {
......
...@@ -2,7 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.dao; ...@@ -2,7 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowlegeStatisticsRecord; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowlegeStatisticsRecord;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -37,5 +39,21 @@ public interface StatisticsRecordMapper extends BaseMapper<KnowlegeStatisticsRec ...@@ -37,5 +39,21 @@ public interface StatisticsRecordMapper extends BaseMapper<KnowlegeStatisticsRec
* 按类型查询/按时间分段总计 * 按类型查询/按时间分段总计
*/ */
List<Map<String, Object>> selectCountByNameAndDateRange(Map<String, Object> queryMap); List<Map<String, Object>> selectCountByNameAndDateRange(Map<String, Object> queryMap);
List<Map<String, Object>> tagStatisticsMonth(@Param("tag")String tag, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<Map<String, Object>> tagStatisticsYear(@Param("tag")String tag, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<Map<String, Object>> docStatisticsMonth(@Param("categoryName")String categoryName, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<Map<String, Object>> docStatisticsYear(@Param("categoryName")String categoryName, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<Map<String, Object>> tagChartStatistics(@Param("tag")String tag, @Param("startDate")Date startDate, @Param("endDate")Date endDate,@Param("splitSQL")String splitSQL);
List<Map<String, Object>> tagTimeChartStatistics(@Param("startDate")Date startDate, @Param("endDate")Date endDate,@Param("splitSQL")String splitSQL);
List<Map<String, Object>> docChartStatistics(@Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<Map<String, Object>> docBurnChartStatistics(@Param("startDate")Date startDate,@Param("endDate") Date endDate);
} }
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao; package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import java.util.Date; import java.util.Date;
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity; ...@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/** /**
* <p> * <p>
......
...@@ -24,6 +24,29 @@ ...@@ -24,6 +24,29 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<!-- 解析excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<!-- 针对2007以上版本的库 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- 针对2003版本的库 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.poi.xwpf.converter.xhtml</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
//package com.yeejoin.amos.knowledgebase.config; package com.yeejoin.amos.knowledgebase.config;
//
//import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
//import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
//
///** /**
// * @author 杨博超 * @author 杨博超
// * @ClassName Config * @ClassName Config
// * @Deacription TODO * @Deacription TODO
// **/ **/
//@Configuration @Configuration
//public class Config { public class Config {
//
// @Bean @Bean
// public Sequence sequence() { public Sequence sequence() {
// return new Sequence(); return new Sequence();
// } }
//} }
...@@ -2,12 +2,7 @@ package com.yeejoin.amos.knowledgebase.config; ...@@ -2,12 +2,7 @@ package com.yeejoin.amos.knowledgebase.config;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpHost; import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.config.RequestConfig; import org.apache.http.client.config.RequestConfig;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient; import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder; import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient; import org.elasticsearch.client.RestHighLevelClient;
...@@ -21,31 +16,17 @@ public class ElasticSearchClientConfig { ...@@ -21,31 +16,17 @@ public class ElasticSearchClientConfig {
@Value("${spring.elasticsearch.rest.uris}") @Value("${spring.elasticsearch.rest.uris}")
private String uris; private String uris;
@Value("${elasticsearch.username}")
private String username;
@Value("${elasticsearch.password}")
private String password;
@Bean @Bean
@Qualifier("highLevelClient") @Qualifier("highLevelClient")
public RestHighLevelClient restHighLevelClient() { public RestHighLevelClient restHighLevelClient() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
try { try {
String url = uris.replace("http://", ""); String url = uris.replace("http://", "");
final String[] parts = StringUtils.split(url, ":"); final String[] parts = StringUtils.split(url, ":");
HttpHost httpHost = new HttpHost(parts[0], Integer.parseInt(parts[1]), "http"); HttpHost httpHost = new HttpHost(parts[0], Integer.parseInt(parts[1]), "http");
RestClientBuilder builder = RestClient.builder(httpHost); RestClientBuilder builder = RestClient.builder(httpHost);
builder.setHttpClientConfigCallback(new RestClientBuilder.HttpClientConfigCallback() {
@Override
public HttpAsyncClientBuilder customizeHttpClient(HttpAsyncClientBuilder httpClientBuilder) {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
}
});
builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() { builder.setRequestConfigCallback(new RestClientBuilder.RequestConfigCallback() {
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。 // 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
@Override @Override
......
...@@ -34,6 +34,7 @@ import java.util.List; ...@@ -34,6 +34,7 @@ import java.util.List;
public class DocAnnotateResource { public class DocAnnotateResource {
private final Logger logger = LogManager.getLogger(DocAnnotateResource.class); private final Logger logger = LogManager.getLogger(DocAnnotateResource.class);
@Autowired @Autowired
private DocAnnotateService docAnnotateService; private DocAnnotateService docAnnotateService;
......
...@@ -86,7 +86,7 @@ public class DocCategoryResource { ...@@ -86,7 +86,7 @@ public class DocCategoryResource {
return ResponseHelper.buildResponse(docCategoryService.queryForKnowledgeDocCategoryList(parentId)); return ResponseHelper.buildResponse(docCategoryService.queryForKnowledgeDocCategoryList(parentId));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(value = "文档分类树查询") @ApiOperation(value = "文档分类树查询")
@RequestMapping(value = "/tree", method = RequestMethod.GET) @RequestMapping(value = "/tree", method = RequestMethod.GET)
public ResponseModel<Collection<KnowledgeDocCategoryModel>> docCategoryTree() { public ResponseModel<Collection<KnowledgeDocCategoryModel>> docCategoryTree() {
......
package com.yeejoin.amos.knowledgebase.controller; package com.yeejoin.amos.knowledgebase.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCommentsModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCommentsModel;
import com.yeejoin.amos.knowledgebase.face.service.DocCommentsService; import com.yeejoin.amos.knowledgebase.face.service.DocCommentsService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -11,11 +10,11 @@ import org.apache.logging.log4j.Logger; ...@@ -11,11 +10,11 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.StringUtil; import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource; import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
......
package com.yeejoin.amos.knowledgebase.controller; package com.yeejoin.amos.knowledgebase.controller;
import java.util.List; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.Map; import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
import javax.servlet.http.HttpServletRequest; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.service.DocContentService;
import com.yeejoin.amos.knowledgebase.face.service.DocLibraryService;
import com.yeejoin.amos.knowledgebase.face.service.DynamicsOptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.StringUtil; import org.typroject.tyboot.core.foundation.utils.StringUtil;
...@@ -22,16 +21,9 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -22,16 +21,9 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional; import java.util.List;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel; import java.util.Map;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.service.DocContentService;
import com.yeejoin.amos.knowledgebase.face.service.DocLibraryService;
import com.yeejoin.amos.knowledgebase.face.service.DynamicsOptionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/** /**
* <p> * <p>
...@@ -129,7 +121,7 @@ public class DocContentResource { ...@@ -129,7 +121,7 @@ public class DocContentResource {
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(value = "查询单个文档内容信息") @ApiOperation(value = "查询单个文档内容信息")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.GET) @RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.GET)
public ResponseModel<KnowledgeDocContentModel> seleteOne(@PathVariable("sequenceNbr") Long sequenceNbr) { public ResponseModel<KnowledgeDocContentModel> seleteOne(@PathVariable("sequenceNbr") Long sequenceNbr) {
...@@ -145,48 +137,6 @@ public class DocContentResource { ...@@ -145,48 +137,6 @@ public class DocContentResource {
} }
// @TycloudOperation(ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "分页查询文档信息")
// @RequestMapping(value = "/page", method = RequestMethod.GET)
// public ResponseModel<Page> queryDocPage(HttpServletRequest request) {
// Map paramMap = request.getParameterMap();
//
// String[] auditStatus = request.getParameterValues("auditStatus");
// String[] docStatus = request.getParameterValues("docStatus");
//
// if (!ValidationUtil.isEmpty(auditStatus) && auditStatus[0].length() == 0) {
// auditStatus = null;
// }
// if (!ValidationUtil.isEmpty(docStatus) && docStatus[0].length() == 0) {
// docStatus = null;
// }
// Date createTimeLeft = null;
// Date createTimeRight = null;
// try {
// if (!ValidationUtil.isEmpty(paramMap.get("createTimeLeft"))) {
// createTimeLeft = DateUtil.formatStringToDate(request.getParameterValues("createTimeLeft")[0], null);
// }
// if (!ValidationUtil.isEmpty(paramMap.get("createTimeRight"))) {
// createTimeRight = DateUtil.formatStringToDate(request.getParameterValues("createTimeRight")[0], null);
// }
// } catch (Exception e) {
// throw new BadRequest("时间范围参数格式有误");
// }
// int offset = Integer.parseInt(request.getParameterValues("offset")[0]);
// int end = Integer.parseInt(request.getParameterValues("end")[0]);
//
// paramMap.remove("offset");
// paramMap.remove("end");
// paramMap.remove("total");
// paramMap.remove("auditStatus");
// paramMap.remove("docStatus");
// paramMap.remove("createTimeLeft");
// paramMap.remove("createTimeRight");
//
// return ResponseHelper.buildResponse(docContentService.queryDocPage(offset, end, paramMap, auditStatus, docStatus, createTimeLeft, createTimeRight));
// }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分页查询文档信息") @ApiOperation(value = "分页查询文档信息")
@RequestMapping(value = "/page", method = RequestMethod.GET) @RequestMapping(value = "/page", method = RequestMethod.GET)
...@@ -206,20 +156,6 @@ public class DocContentResource { ...@@ -206,20 +156,6 @@ public class DocContentResource {
} }
// @TycloudOperation(ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "字符串模糊查询文档(搜索项为文档标题和标签名称)")
// @RequestMapping(value = "/title/tag", method = RequestMethod.GET)
// public ResponseModel searchForDocs(
// @RequestParam(value = "queryStr", defaultValue = "") String queryStr,
// @RequestParam(value = "current") int current,
// @RequestParam(value = "size") int size) {
// Page page = new Page();
// page.setCurrent(current);
// page.setSize(size);
// return ResponseHelper.buildResponse(docContentService.searchForDoc(page, queryStr));
// }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "文档被点赞/吐槽状态") @ApiOperation(value = "文档被点赞/吐槽状态")
@RequestMapping(value = "/{sequenceNbr}/statistics/likes", method = RequestMethod.GET) @RequestMapping(value = "/{sequenceNbr}/statistics/likes", method = RequestMethod.GET)
...@@ -227,12 +163,5 @@ public class DocContentResource { ...@@ -227,12 +163,5 @@ public class DocContentResource {
@PathVariable(value = "sequenceNbr") Long sequenceNbr) { @PathVariable(value = "sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(docContentService.queryLikeOrDis(sequenceNbr)); return ResponseHelper.buildResponse(docContentService.queryLikeOrDis(sequenceNbr));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取简单的预案信息")
@RequestMapping(value = "/getSimpleDetail/{sequenceNbr}", method = RequestMethod.GET)
public ResponseModel<List<Map<String, Object>>> getSimpleDetail(
@PathVariable(value = "sequenceNbr") String sequenceNbr) {
return ResponseHelper.buildResponse(docContentService.getSimpleDetail(sequenceNbr));
}
} }
package com.yeejoin.amos.knowledgebase.controller; package com.yeejoin.amos.knowledgebase.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.service.DocContentService;
import com.yeejoin.amos.knowledgebase.face.service.DocLibraryService;
import com.yeejoin.amos.knowledgebase.face.service.ESDocService;
import com.yeejoin.amos.knowledgebase.face.util.excel.ExcelImportConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.xmlbeans.XmlException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -25,15 +24,13 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -25,15 +24,13 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.alibaba.fastjson.JSON; import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import javax.servlet.http.HttpServletResponse;
import com.yeejoin.amos.knowledgebase.face.service.DocLibraryService; import javax.xml.parsers.ParserConfigurationException;
import com.yeejoin.amos.knowledgebase.face.service.ESDocService; import javax.xml.transform.TransformerException;
import com.yeejoin.amos.knowledgebase.face.util.Constants; import java.io.IOException;
import com.yeejoin.amos.knowledgebase.face.util.excel.ExcelImportConfig; import java.util.List;
import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/** /**
* <p> * <p>
...@@ -51,6 +48,8 @@ public class DocLibraryResource { ...@@ -51,6 +48,8 @@ public class DocLibraryResource {
@Autowired @Autowired
private DocLibraryService docLibraryService; private DocLibraryService docLibraryService;
@Autowired
private DocContentService docContentService;
/** /**
* 下拉式查询文档信息 * 下拉式查询文档信息
...@@ -66,21 +65,35 @@ public class DocLibraryResource { ...@@ -66,21 +65,35 @@ public class DocLibraryResource {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "下拉式查询文档信息") @ApiOperation(value = "下拉式查询文档信息")
@RequestMapping(value = "/page", method = RequestMethod.GET) @RequestMapping(value = "/page", method = RequestMethod.GET)
public ResponseModel<Page> queryDocPageNew(HttpServletRequest request, public ResponseModel<Page> queryDocPageNew(HttpServletRequest request, @RequestParam(value = "offset") Integer offset, @RequestParam(value = "end") Integer end, @RequestParam(value = "filterByCollection") String filterByCollection, @RequestParam(value = "directoryId", required = false) Long directoryId, @RequestParam(value = "docTitle", required = false) String docTitle, @RequestParam(value = "createTimeLeft", required = false) String createTimeLeft, @RequestParam(value = "createTimeRight", required = false) String createTimeRight) {
@RequestParam(value = "offset") Integer offset,
@RequestParam(value = "end") Integer end,
@RequestParam(value = "filterByCollection") String filterByCollection,
@RequestParam(value = "directoryId", required = false) Long directoryId,
@RequestParam(value = "docTitle", required = false) String docTitle,
@RequestParam(value = "createTimeLeft", required = false) String createTimeLeft,
@RequestParam(value = "createTimeRight", required = false) String createTimeRight) {
Map requestMap = request.getParameterMap(); Map requestMap = request.getParameterMap();
Page page = docLibraryService.queryDocList(offset, end, directoryId, docTitle, null, Constants.DOC_STATUS_PUBLISHED, Page page = docLibraryService.queryDocList(offset, end, directoryId, docTitle, null, DocContentService.DOC_STATUS_PUBLISHED, requestMap, createTimeLeft, createTimeRight, Boolean.parseBoolean(filterByCollection), false);
requestMap, createTimeLeft, createTimeRight, Boolean.parseBoolean(filterByCollection), false);
return ResponseHelper.buildResponse(page); return ResponseHelper.buildResponse(page);
} }
/** /**
* 开放接口,根据文档分类查询分类下的列表数据,只查公开的标签文档
*
* @param pageNumber 当前页码
* @param pageSize 每页数量
* @param directoryId 分类ID
* @return Page
*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "开放接口,根据文档分类查询分类下的列表数据")
@RequestMapping(value = "/pageByType", method = RequestMethod.GET)
public ResponseModel<IPage<KnowledgeDocContent>> pageByType(
@RequestParam(value = "pageNumber") int pageNumber,
@RequestParam(value = "pageSize") int pageSize,
@RequestParam(value = "directoryId", required = false) Long directoryId,
@RequestParam(value = "tagId", required = false) Long tagId
) {
int current = pageNumber * pageSize;
if (current < 0) current = 0;
return ResponseHelper.buildResponse(docContentService.pageByType(current, pageSize, directoryId, tagId));
}
/**
* 收藏文档 * 收藏文档
* *
* @param id * @param id
...@@ -122,8 +135,7 @@ public class DocLibraryResource { ...@@ -122,8 +135,7 @@ public class DocLibraryResource {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "搜索联想") @ApiOperation(value = "搜索联想")
@RequestMapping(value = "/associate", method = RequestMethod.GET) @RequestMapping(value = "/associate", method = RequestMethod.GET)
public ResponseModel worldAssociate( public ResponseModel worldAssociate(@RequestParam(value = "queryStr") String queryStr) {
@RequestParam(value = "queryStr") String queryStr) {
if (ValidationUtil.isEmpty(queryStr)) { if (ValidationUtil.isEmpty(queryStr)) {
queryStr = ""; queryStr = "";
} }
...@@ -177,57 +189,35 @@ public class DocLibraryResource { ...@@ -177,57 +189,35 @@ public class DocLibraryResource {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据文档标题和标签名称查询文档") @ApiOperation(value = "根据文档标题和标签名称查询文档")
@RequestMapping(value = "/es/query", method = RequestMethod.GET) @RequestMapping(value = "/es/query", method = RequestMethod.GET)
public ResponseModel filter(@RequestParam(value = "queryStr", required = false) String queryStr, public ResponseModel filter(@RequestParam(value = "queryStr", required = false) String queryStr, @RequestParam(value = "current", defaultValue = "0") int current, @RequestParam(value = "size", defaultValue = "10") int size) {
@RequestParam(value = "current", defaultValue = "0") int current,
@RequestParam(value = "size", defaultValue = "10") int size) {
return ResponseHelper.buildResponse(eSDocService.queryByKeys(queryStr, current, size)); return ResponseHelper.buildResponse(eSDocService.queryByKeys(queryStr, current, size));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "高级检索") @ApiOperation(value = "高级检索")
@RequestMapping(value = "/query/advanced", method = RequestMethod.POST) @RequestMapping(value = "/query/advanced", method = RequestMethod.POST)
public ResponseModel searchAdvanced(@RequestBody Map<String, Object> condition, public ResponseModel searchAdvanced(@RequestBody Map<String, Object> condition, @RequestParam(value = "current", defaultValue = "0") int current, @RequestParam(value = "size", defaultValue = "10") int size) {
@RequestParam(value = "current", defaultValue = "0") int current,
@RequestParam(value = "size", defaultValue = "10") int size) {
Page page = new Page(current, size); Page page = new Page(current, size);
return ResponseHelper.buildResponse(docLibraryService.searchAdvanced(page,condition)); return ResponseHelper.buildResponse(docLibraryService.searchAdvanced(page, condition));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据文档标题和标签名称查询文档-APP") @ApiOperation(value = "根据文档标题和标签名称查询文档-APP")
@RequestMapping(value = "/es/query1", method = RequestMethod.GET) @RequestMapping(value = "/es/query1", method = RequestMethod.GET)
public ResponseModel filter1(@RequestParam(value = "queryStr", required = false) String queryStr, public ResponseModel filter1(@RequestParam(value = "queryStr", required = false) String queryStr, @RequestParam(value = "current", defaultValue = "0") int current, @RequestParam(value = "size", defaultValue = "10") int size) {
@RequestParam(value = "current", defaultValue = "0") int current,
@RequestParam(value = "size", defaultValue = "10") int size) {
return ResponseHelper.buildResponse(eSDocService.queryAndDetail(queryStr, current, size)); return ResponseHelper.buildResponse(eSDocService.queryAndDetail(queryStr, current, size));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导出为word文档") @ApiOperation(value = "导出为word文档")
@RequestMapping(value = "/export/{id}/{type}", method = RequestMethod.GET) @RequestMapping(value = "/export/{id}/{type}", method = RequestMethod.GET)
public void export(@PathVariable(value = "id") Long id, public void export(@PathVariable(value = "id") Long id, @PathVariable(value = "type") String type, HttpServletResponse response) {
@PathVariable(value = "type") String type,
HttpServletResponse response) {
if (ValidationUtil.isEmpty(type)) { if (ValidationUtil.isEmpty(type)) {
throw new BadRequest("参数有误"); throw new BadRequest("参数有误");
} }
docLibraryService.export(id, type, response); docLibraryService.export(id, type, response);
} }
// @TycloudOperation(ApiLevel = UserType.AGENCY)
// @ApiOperation(value = "导入excel文档")
// @RequestMapping(value = "/import", method = RequestMethod.POST)
// public ResponseModel importExcel(@RequestPart(value = "file") MultipartFile file,
// @RequestPart(value = "module") String moduleStr) {
// ExcelImportConfig excelConfig;
// try {
// excelConfig = JSON.parseObject(moduleStr, ExcelImportConfig.class);
// } catch (Exception e) {
// throw new BadRequest("模板配置信息格式有误");
// }
// return ResponseHelper.buildResponse(docLibraryService.importExcel(file, excelConfig));
// }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导入excel文档") @ApiOperation(value = "导入excel文档")
@RequestMapping(value = "/import", method = RequestMethod.POST) @RequestMapping(value = "/import", method = RequestMethod.POST)
...@@ -241,4 +231,19 @@ public class DocLibraryResource { ...@@ -241,4 +231,19 @@ public class DocLibraryResource {
return ResponseHelper.buildResponse(docLibraryService.importExcel(file, excelConfigList)); return ResponseHelper.buildResponse(docLibraryService.importExcel(file, excelConfigList));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导入word文档")
@RequestMapping(value = "/importWord", method = RequestMethod.POST)
public ResponseModel importWordDocuments(@RequestParam("file") MultipartFile file) throws IOException, XmlException, ParserConfigurationException, TransformerException {
return ResponseHelper.buildResponse(docLibraryService.importWordOfSingle(file));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "批量导入word文档")
@RequestMapping(value = "/batch/importWord", method = RequestMethod.POST)
public ResponseModel batchImportWordDocuments(MultipartHttpServletRequest request){
List<MultipartFile> files = request.getFiles("files");
return ResponseHelper.buildResponse(docLibraryService.importWordOfBatch(files));
}
} }
...@@ -9,7 +9,6 @@ import io.swagger.annotations.ApiOperation; ...@@ -9,7 +9,6 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.StringUtil; import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
...@@ -51,10 +50,12 @@ public class DocOuterResource { ...@@ -51,10 +50,12 @@ public class DocOuterResource {
public ResponseModel<Page> queryDocPage(@RequestParam(value = "current") Integer current, public ResponseModel<Page> queryDocPage(@RequestParam(value = "current") Integer current,
@RequestParam(value = "size") Integer size, @RequestParam(value = "size") Integer size,
@RequestParam(value = "code", required = false) String code, @RequestParam(value = "code", required = false) String code,
@RequestParam(value = "docTitle", required = false) String docTitle) { @RequestParam(value = "docTitle", required = false) String docTitle,
@RequestParam(value = "directoryId", required = false) Long directoryId,
@RequestParam(value = "orgCode", required = false) String orgCode) {
Page page = new Page(current, size); Page page = new Page(current, size);
return ResponseHelper.buildResponse(docLibraryService.queryDocPage(page, docTitle, code)); return ResponseHelper.buildResponse(docLibraryService.queryDocPage(page, docTitle, code,directoryId,orgCode));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
......
package com.yeejoin.amos.knowledgebase.controller; package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.service.StatisticsRecordService; import com.yeejoin.amos.knowledgebase.face.service.StatisticsRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat; import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -15,125 +10,86 @@ import org.springframework.web.bind.annotation.RequestParam; ...@@ -15,125 +10,86 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.Date;
import java.util.List;
@RestController @RestController
@TycloudResource(module = "knowledgebase", value = "docstatistics") //@TycloudResource(module = "knowledgebase", value = "docstatistics")
@RequestMapping(value = "/v1/doccontent/docstatistics") @RequestMapping(value = "/v1/doccontent/docstatistics")
@Api(tags = "knowledgebase-文档统计报表") //@Api(tags = "knowledgebase-文档统计报表")
public class DocStatisticsResource { public class DocStatisticsResource {
@Autowired @Autowired
private StatisticsRecordService statisticsRecordService; private StatisticsRecordService statisticsRecordService;
/* /*@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
* @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @ApiOperation(value = "耗时* 刷新统计数据")
* @RequestMapping(value = "/record/init", method = RequestMethod.PUT)
* @ApiOperation(value = "耗时* 刷新统计数据") public ResponseModel init() {
* return ResponseHelper.buildResponse(statisticsRecordService.init());
* @RequestMapping(value = "/record/init", method = RequestMethod.PUT) public }
* ResponseModel init() { return
* ResponseHelper.buildResponse(statisticsRecordService.init()); }
* @TycloudOperation(ApiLevel = UserType.AGENCY)
* @ApiOperation(value = "灾情统计")
* @TycloudOperation(ApiLevel = UserType.AGENCY) @RequestMapping(value = "/count/disaster", method = RequestMethod.GET)
* public ResponseModel selectDisasterCount() {
* @ApiOperation(value = "灾情统计") return ResponseHelper.buildResponse(statisticsRecordService.selectDisasterCount());
* }
* @RequestMapping(value = "/count/disaster", method = RequestMethod.GET) public
* ResponseModel selectDisasterCount() { return @TycloudOperation(ApiLevel = UserType.AGENCY)
* ResponseHelper.buildResponse(statisticsRecordService.selectDisasterCount()); @ApiOperation(value = "燃烧物质统计分类")
* } @RequestMapping(value = "/count/burning", method = RequestMethod.GET)
* public ResponseModel selectBurningCategory() {
* @TycloudOperation(ApiLevel = UserType.AGENCY) return ResponseHelper.buildResponse(statisticsRecordService.selectCategoryByName(StatisticsRecordService.STATISTICS_BURNING_CATEGORY));
* }
* @ApiOperation(value = "燃烧物质统计分类")
* @TycloudOperation(ApiLevel = UserType.AGENCY)
* @RequestMapping(value = "/count/burning", method = RequestMethod.GET) public @ApiOperation(value = "到场时间统计分类")
* ResponseModel selectBurningCategory() { return @RequestMapping(value = "/count/present", method = RequestMethod.GET)
* ResponseHelper.buildResponse(statisticsRecordService.selectCategoryByName( public ResponseModel selectPresentCategory() {
* StatisticsRecordService.STATISTICS_BURNING_CATEGORY)); } return ResponseHelper.buildResponse(statisticsRecordService.selectCategoryByName(StatisticsRecordService.STATISTICS_PRESENT_CATEGORY));
* }
* @TycloudOperation(ApiLevel = UserType.AGENCY)
* @TycloudOperation(ApiLevel = UserType.AGENCY)
* @ApiOperation(value = "到场时间统计分类") @ApiOperation(value = "伤亡人数趋势统计")
* @RequestMapping(value = "/count/casualties", method = RequestMethod.GET)
* @RequestMapping(value = "/count/present", method = RequestMethod.GET) public public ResponseModel selectCasualtiesSum(@RequestParam(value = "dateType") String dateType,
* ResponseModel selectPresentCategory() { return @RequestParam(value = "dateRangeLeft", required = false) String dateRangeLeft,
* ResponseHelper.buildResponse(statisticsRecordService.selectCategoryByName( @RequestParam(value = "dateRangeRight", required = false) String dateRangeRight) {
* StatisticsRecordService.STATISTICS_PRESENT_CATEGORY)); } return ResponseHelper.buildResponse(statisticsRecordService.selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight, StatisticsRecordService.STATISTICS_CASUALTIES_SUM));
* }
* @TycloudOperation(ApiLevel = UserType.AGENCY)
* @TycloudOperation(ApiLevel = UserType.AGENCY)
* @ApiOperation(value = "伤亡人数趋势统计") @ApiOperation(value = "参战车辆数量统计")
* @RequestMapping(value = "/count/power", method = RequestMethod.GET)
* @RequestMapping(value = "/count/casualties", method = RequestMethod.GET) public ResponseModel selectPowerSum(@RequestParam(value = "dateType") String dateType,
* public ResponseModel selectCasualtiesSum(@RequestParam(value = "dateType") @RequestParam(value = "dateRangeLeft", required = false) String dateRangeLeft,
* String dateType, @RequestParam(value = "dateRangeRight", required = false) String dateRangeRight) {
* return ResponseHelper.buildResponse(statisticsRecordService.selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight, StatisticsRecordService.STATISTICS_POWER_SUM));
* @RequestParam(value = "dateRangeLeft", required = false) String }
* dateRangeLeft,
* @TycloudOperation(ApiLevel = UserType.AGENCY)
* @RequestParam(value = "dateRangeRight", required = false) String @ApiOperation(value = "过火面积统计")
* dateRangeRight) { return @RequestMapping(value = "/count/area", method = RequestMethod.GET)
* ResponseHelper.buildResponse(statisticsRecordService. public ResponseModel selectAreaSum(@RequestParam(value = "dateType") String dateType,
* selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight, @RequestParam(value = "dateRangeLeft", required = false) String dateRangeLeft,
* StatisticsRecordService.STATISTICS_CASUALTIES_SUM)); } @RequestParam(value = "dateRangeRight", required = false) String dateRangeRight) {
* return ResponseHelper.buildResponse(statisticsRecordService.selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight, StatisticsRecordService.STATISTICS_AREA_COUNT));
* @TycloudOperation(ApiLevel = UserType.AGENCY) }
*
* @ApiOperation(value = "参战车辆数量统计")
*
* @RequestMapping(value = "/count/power", method = RequestMethod.GET) public
* ResponseModel selectPowerSum(@RequestParam(value = "dateType") String
* dateType,
*
* @RequestParam(value = "dateRangeLeft", required = false) String
* dateRangeLeft,
*
* @RequestParam(value = "dateRangeRight", required = false) String
* dateRangeRight) { return
* ResponseHelper.buildResponse(statisticsRecordService.
* selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight,
* StatisticsRecordService.STATISTICS_POWER_SUM)); }
*
* @TycloudOperation(ApiLevel = UserType.AGENCY)
*
* @ApiOperation(value = "过火面积统计")
*
* @RequestMapping(value = "/count/area", method = RequestMethod.GET) public
* ResponseModel selectAreaSum(@RequestParam(value = "dateType") String
* dateType,
*
* @RequestParam(value = "dateRangeLeft", required = false) String
* dateRangeLeft,
*
* @RequestParam(value = "dateRangeRight", required = false) String
* dateRangeRight) { return
* ResponseHelper.buildResponse(statisticsRecordService.
* selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight,
* StatisticsRecordService.STATISTICS_AREA_COUNT)); }
*
* @TycloudOperation(ApiLevel = UserType.AGENCY)
*
* @ApiOperation(value = "灭火药剂统计")
*
* @RequestMapping(value = "/count/extinguishing", method = RequestMethod.GET)
* public ResponseModel selectExtinguishingSum(@RequestParam(value = "dateType")
* String dateType,
*
* @RequestParam(value = "dateRangeLeft", required = false) String
* dateRangeLeft,
*
* @RequestParam(value = "dateRangeRight", required = false) String
* dateRangeRight) { return
* ResponseHelper.buildResponse(statisticsRecordService.
* selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight,
* StatisticsRecordService.STATISTICS_EXTINGUISHING_SUM)); }
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "灭火药剂统计")
@RequestMapping(value = "/count/extinguishing", method = RequestMethod.GET)
public ResponseModel selectExtinguishingSum(@RequestParam(value = "dateType") String dateType,
@RequestParam(value = "dateRangeLeft", required = false) String dateRangeLeft,
@RequestParam(value = "dateRangeRight", required = false) String dateRangeRight) {
return ResponseHelper.buildResponse(statisticsRecordService.selectCountByTypeAndDateRange(dateType, dateRangeLeft, dateRangeRight, StatisticsRecordService.STATISTICS_EXTINGUISHING_SUM));
}*/
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "标签总数统计") @ApiOperation(value = "标签总数统计")
@RequestMapping(value = "/tag/statistics", method = RequestMethod.GET) @RequestMapping(value = "/tag/statistics", method = RequestMethod.GET)
......
package com.yeejoin.amos.knowledgebase.controller; package com.yeejoin.amos.knowledgebase.controller;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.service.MessageService; import com.yeejoin.amos.knowledgebase.face.service.MessageService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -42,7 +40,7 @@ public class MessageResource { ...@@ -42,7 +40,7 @@ public class MessageResource {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询用户的消息列表.") @ApiOperation(value = "查询用户的消息列表.")
@RequestMapping(value = "/list/owner", method = RequestMethod.GET) @RequestMapping(value = "/list/owner", method = RequestMethod.GET)
public ResponseModel list(@RequestParam(value = "messageType", required = false) String messageType) { public ResponseModel listOwner(@RequestParam(value = "messageType", required = false) String messageType) {
if (ValidationUtil.isEmpty(messageType)) { if (ValidationUtil.isEmpty(messageType)) {
messageType = null; messageType = null;
} }
...@@ -129,7 +127,7 @@ public class MessageResource { ...@@ -129,7 +127,7 @@ public class MessageResource {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分页查询查询用户的消息列表.") @ApiOperation(value = "分页查询查询用户的消息列表.")
@RequestMapping(value = "/list/page", method = RequestMethod.GET) @RequestMapping(value = "/list/page", method = RequestMethod.GET)
public ResponseModel<Page> list( public ResponseModel<Page> listPage(
@RequestParam(value = "current", required = true) int current, @RequestParam(value = "current", required = true) int current,
@RequestParam(value = "size", required = true) int size, @RequestParam(value = "size", required = true) int size,
@RequestParam(value = "messageType", required = false) String messageType) { @RequestParam(value = "messageType", required = false) String messageType) {
......
...@@ -2,8 +2,6 @@ package com.yeejoin.amos.knowledgebase.controller; ...@@ -2,8 +2,6 @@ package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagGroupModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagGroupModel;
import com.yeejoin.amos.knowledgebase.face.service.TagGroupService; import com.yeejoin.amos.knowledgebase.face.service.TagGroupService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
...@@ -11,10 +9,10 @@ import org.apache.logging.log4j.Logger; ...@@ -11,10 +9,10 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource; import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
......
package com.yeejoin.amos.knowledgebase.controller; package com.yeejoin.amos.knowledgebase.controller;
import java.util.List; import com.yeejoin.amos.knowledgebase.face.service.TagInstanceService;
import io.swagger.annotations.Api;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource; import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagInstance;
import com.yeejoin.amos.knowledgebase.face.service.TagInstanceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/** /**
* <p> * <p>
...@@ -41,25 +27,4 @@ public class TagInstanceResource { ...@@ -41,25 +27,4 @@ public class TagInstanceResource {
private final Logger logger = LogManager.getLogger(TagInstanceResource.class); private final Logger logger = LogManager.getLogger(TagInstanceResource.class);
@Autowired @Autowired
private TagInstanceService tagInstanceService; private TagInstanceService tagInstanceService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据主键查询实例标签")
@RequestMapping(value = "find/{id}", method = RequestMethod.GET)
public ResponseModel<KnowledgeTagInstance> findById(@PathVariable("id") Long id) {
return ResponseHelper.buildResponse(tagInstanceService.findById(id));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据targetSeq查询实例标签")
@RequestMapping(value = "targetSeq/{id}", method = RequestMethod.GET)
public ResponseModel<List<KnowledgeTagInstanceModel>> queryListByTargetSeq(@PathVariable("id") Long id) {
return ResponseHelper.buildResponse(tagInstanceService.queryListByTargetSeq(id));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据targetSeq查询实例标签")
@RequestMapping(value = "getTarget/byName", method = RequestMethod.GET)
public ResponseModel<List<KnowledgeTagInstanceModel>> queryListByTagName(@RequestParam String name) {
return ResponseHelper.buildResponse(tagInstanceService.queryListByTagName(name));
}
} }
package com.yeejoin.amos.knowledgebase.controller; package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagModel;
import com.yeejoin.amos.knowledgebase.face.service.TagService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.StringUtil; import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -18,13 +17,6 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -18,13 +17,6 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagModel;
import com.yeejoin.amos.knowledgebase.face.service.TagService;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/** /**
* <p> * <p>
* 标签库 前端控制器 * 标签库 前端控制器
...@@ -107,7 +99,7 @@ public class TagResource { ...@@ -107,7 +99,7 @@ public class TagResource {
@ApiOperation(value = "查询TOP15") @ApiOperation(value = "查询TOP15")
@RequestMapping(value = "/list/top", method = RequestMethod.GET) @RequestMapping(value = "/list/top", method = RequestMethod.GET)
public ResponseModel selectForList(@RequestParam(value = "quoteType", required = false) String quoteType) { public ResponseModel selectForList(@RequestParam(value = "quoteType", required = false) String quoteType) {
boolean isAll = ValidationUtil.equalsIgnoreCase(quoteType, Constants.APPKEY_ALL); boolean isAll = ValidationUtil.equalsIgnoreCase(quoteType, TagService.APPKEY_ALL);
return ResponseHelper.buildResponse(tagService.queryTopList(isAll)); return ResponseHelper.buildResponse(tagService.queryTopList(isAll));
} }
...@@ -123,14 +115,14 @@ public class TagResource { ...@@ -123,14 +115,14 @@ public class TagResource {
@ApiOperation(value = "启用标签") @ApiOperation(value = "启用标签")
@RequestMapping(value = "status/activate/{ids}", method = RequestMethod.PUT) @RequestMapping(value = "status/activate/{ids}", method = RequestMethod.PUT)
public ResponseModel batchActivate(@PathVariable(value = "ids") String ids) { public ResponseModel batchActivate(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(tagService.updateTagStatus(StringUtil.String2LongList(ids), Constants.TAG_STATUS_ACTIVATE)); return ResponseHelper.buildResponse(tagService.updateTagStatus(StringUtil.String2LongList(ids), TagService.TAG_STATUS_ACTIVATE));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "停用标签") @ApiOperation(value = "停用标签")
@RequestMapping(value = "status/deactivate/{ids}", method = RequestMethod.PUT) @RequestMapping(value = "status/deactivate/{ids}", method = RequestMethod.PUT)
public ResponseModel batchDeactivate(@PathVariable(value = "ids") String ids) { public ResponseModel batchDeactivate(@PathVariable(value = "ids") String ids) {
return ResponseHelper.buildResponse(tagService.updateTagStatus(StringUtil.String2LongList(ids), Constants.TAG_STATUS_DEACTIVATE)); return ResponseHelper.buildResponse(tagService.updateTagStatus(StringUtil.String2LongList(ids), TagService.TAG_STATUS_DEACTIVATE));
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
......
package com.yeejoin.amos.knowledgebase.controller; package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.service.TagValueService;
import io.swagger.annotations.Api;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.doc.TycloudResource; import org.typroject.tyboot.core.restful.doc.TycloudResource;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import com.yeejoin.amos.knowledgebase.face.service.TagValueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/** /**
* <p> * <p>
...@@ -36,17 +27,5 @@ public class TagValueResource { ...@@ -36,17 +27,5 @@ public class TagValueResource {
private final Logger logger = LogManager.getLogger(TagValueResource.class); private final Logger logger = LogManager.getLogger(TagValueResource.class);
@Autowired @Autowired
private TagValueService tagValueService; private TagValueService tagValueService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取所有当前系统的值标签的实例值")
@RequestMapping(value = "/getAll/tegartValue", method = RequestMethod.GET)
public ResponseModel<Object> getAllTegartValue(@RequestParam String value) {
return ResponseHelper.buildResponse(tagValueService.getAllTegartValue(value));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "获取所有当前系统的值标签的实例值")
@RequestMapping(value = "/getOne/", method = RequestMethod.GET)
public ResponseModel<Object> queryByInstance(@RequestParam Long id) {
return ResponseHelper.buildResponse(tagValueService.queryByInstance(id));
}
} }
package com.yeejoin.amos.knowledgebase.face.model; package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Collection; import java.util.Collection;
......
package com.yeejoin.amos.knowledgebase.face.model; package com.yeejoin.amos.knowledgebase.face.model;
import com.baomidou.mybatisplus.annotation.TableField;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/** /**
* <p> * <p>
......
package com.yeejoin.amos.knowledgebase.face.model; package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/** /**
* <p> * <p>
......
package com.yeejoin.amos.knowledgebase.face.model; package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/** /**
* <p> * <p>
* 知识库系统动态选项配置的实例值 * 知识库系统动态选项配置的实例值
......
package com.yeejoin.amos.knowledgebase.face.model; package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/** /**
* <p> * <p>
* 知识库内容交互计数表 * 知识库内容交互计数表
......
package com.yeejoin.amos.knowledgebase.face.model; package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/** /**
* <p> * <p>
* 知识库内容交互记录 * 知识库内容交互记录
......
package com.yeejoin.amos.knowledgebase.face.model; package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Collection; import java.util.Collection;
......
package com.yeejoin.amos.knowledgebase.face.model; package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.List; import java.util.List;
......
package com.yeejoin.amos.knowledgebase.face.model; package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
......
package com.yeejoin.amos.knowledgebase.face.model; package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/** /**
* <p> * <p>
* 值标签的实例值 * 值标签的实例值
......
package com.yeejoin.amos.knowledgebase.face.orm.dao; package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -9,7 +10,7 @@ import java.util.Map; ...@@ -9,7 +10,7 @@ import java.util.Map;
/** /**
* <p> * <p>
* 知识库文档存储 Mapper 接口 * 知识库文档存储 Mapper 接口
* </p> * </p>
* *
* @author 子杨 * @author 子杨
...@@ -18,18 +19,24 @@ import java.util.Map; ...@@ -18,18 +19,24 @@ import java.util.Map;
public interface DocContentMapper extends BaseMapper<KnowledgeDocContent> { public interface DocContentMapper extends BaseMapper<KnowledgeDocContent> {
List<Map<String,Long>> searchForDocIds(@Param("agencyCode") String agencyCode, List<Map<String, Long>> searchForDocIds(
@Param("queryStr") String queryStr, @Param("agencyCode") String agencyCode,
@Param("docStatus")String []docStatus, @Param("queryStr") String queryStr,
@Param("auditStatus")String [] auditStatus, @Param("docStatus") String[] docStatus,
@Param("userId")String userId, @Param("auditStatus") String[] auditStatus,
@Param("orgCode")String orgCode, @Param("userId") String userId,
@Param("offset") long offset, @Param("orgCode") String orgCode,
@Param("length") long length); @Param("offset") long offset,
@Param("length") long length);
List<Map<String,Object>> queryDocBaseInfoList(Map<String, Object> paramMap); List<Map<String, Object>> queryDocBaseInfoList(Map<String, Object> paramMap);
int queryDocBaseInfoTotal(Map<String, Object> paramMap); int queryDocBaseInfoTotal(Map<String, Object> paramMap);
List<Long> getAllPublishedDocIds(); List<Long> getAllPublishedDocIds();
IPage<KnowledgeDocContent> pageByType(
IPage<KnowledgeDocContent> page,
@Param("typeId") Long typeId,
@Param("tagId") Long tagId);
} }
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao; package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity; import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.annotations.Query;
import org.springframework.data.elasticsearch.repository.ElasticsearchCrudRepository; import org.springframework.data.elasticsearch.repository.ElasticsearchCrudRepository;
public interface ESDocRepository extends ElasticsearchCrudRepository<ESDocEntity, Long> { public interface ESDocRepository extends ElasticsearchCrudRepository<ESDocEntity, Long> {
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.knowledgebase.face.orm.dao; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowlegeStatisticsRecord; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowlegeStatisticsRecord;
import org.apache.ibatis.annotations.Param;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
...@@ -9,7 +10,7 @@ import java.util.Map; ...@@ -9,7 +10,7 @@ import java.util.Map;
/** /**
* <p> * <p>
* 标签分组 Mapper 接口 * 标签分组 Mapper 接口
* </p> * </p>
* *
* @author 子杨 * @author 子杨
...@@ -17,43 +18,42 @@ import java.util.Map; ...@@ -17,43 +18,42 @@ import java.util.Map;
*/ */
public interface StatisticsRecordMapper extends BaseMapper<KnowlegeStatisticsRecord> { public interface StatisticsRecordMapper extends BaseMapper<KnowlegeStatisticsRecord> {
/** /**
* 表清空 * 表清空
* * @return
* @return */
*/ void deleteAll();
void deleteAll();
/** /**
* 查询灾情总计 * 查询灾情总计
* * @return
* @return */
*/ Map<String, Object> selectDisasterCount();
Map<String, Object> selectDisasterCount();
/** /**
* 按类型分组查询 * 按类型分组查询
*/ */
List<Map<String, Object>> selectCategoryByName(String recordName); List<Map<String, Object>> selectCategoryByName(String recordName);
/** /**
* 按类型查询/按时间分段总计 * 按类型查询/按时间分段总计
*/ */
List<Map<String, Object>> selectCountByNameAndDateRange(Map<String, Object> queryMap); List<Map<String, Object>> selectCountByNameAndDateRange(Map<String, Object> queryMap);
List<Map<String, Object>> tagStatisticsMonth(@Param("tag")String tag, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<Map<String, Object>> tagStatisticsMonth(String tag, Date startDate, Date endDate); List<Map<String, Object>> tagStatisticsYear(@Param("tag")String tag, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<Map<String, Object>> tagStatisticsYear(String tag, Date startDate, Date endDate); List<Map<String, Object>> docStatisticsMonth(@Param("categoryName")String categoryName, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<Map<String, Object>> docStatisticsMonth(String categoryName, Date startDate, Date endDate); List<Map<String, Object>> docStatisticsYear(@Param("categoryName")String categoryName, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<Map<String, Object>> docStatisticsYear(String categoryName, Date startDate, Date endDate);
List<Map<String, Object>> tagChartStatistics(String tag, Date startDate, Date endDate,String splitSQL); List<Map<String, Object>> tagChartStatistics(@Param("tag")String tag, @Param("startDate")Date startDate, @Param("endDate")Date endDate,@Param("splitSQL")String splitSQL);
List<Map<String, Object>> tagTimeChartStatistics(Date startDate, Date endDate,String splitSQL); List<Map<String, Object>> tagTimeChartStatistics(@Param("startDate")Date startDate, @Param("endDate")Date endDate,@Param("splitSQL")String splitSQL);
List<Map<String, Object>> docChartStatistics(Date startDate, Date endDate); List<Map<String, Object>> docChartStatistics(@Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<Map<String, Object>> docBurnChartStatistics(Date startDate, Date endDate); List<Map<String, Object>> docBurnChartStatistics(@Param("startDate")Date startDate,@Param("endDate") Date endDate);
} }
\ No newline at end of file
package com.yeejoin.amos.knowledgebase.face.orm.dao; package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
......
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import java.util.Date; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocAnnotateModel;
import java.util.List; import com.yeejoin.amos.knowledgebase.face.orm.dao.DocAnnotateMapper;
import java.util.Map; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocAnnotate;
import java.util.Set; import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -16,10 +14,11 @@ import org.typroject.tyboot.core.foundation.utils.Bean; ...@@ -16,10 +14,11 @@ import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData; import java.util.Date;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocAnnotateModel; import java.util.List;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocAnnotateMapper; import java.util.Map;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocAnnotate; import java.util.Set;
import java.util.stream.Collectors;
/** /**
...@@ -88,13 +87,12 @@ public class DocAnnotateService extends BaseService<KnowledgeDocAnnotateModel, K ...@@ -88,13 +87,12 @@ public class DocAnnotateService extends BaseService<KnowledgeDocAnnotateModel, K
**/ **/
public List<KnowledgeDocAnnotateModel> queryForAnnotateList(String docSeq) { public List<KnowledgeDocAnnotateModel> queryForAnnotateList(String docSeq) {
List<KnowledgeDocAnnotateModel> list = this.queryForList("CREATE_TIME",true, docSeq); List<KnowledgeDocAnnotateModel> list = this.queryForList("CREATE_TIME",true, docSeq);
Set<String> userIds = list.stream().filter(item -> !ValidationUtil.isEmpty(item)).map(arg0 -> arg0.getUserId()).collect(Collectors.toSet()); Set<String> userIds = list.stream().filter(item -> !ValidationUtil.isEmpty(item)).map(KnowledgeDocAnnotateModel::getUserId).collect(Collectors.toSet());
Map<String, String> userMap = RemoteData.getUserMap(userIds); Map<String, String> userMap = RemoteData.getUserMap(userIds);
list.forEach(item -> { list.forEach(item -> {
item.setUsername(userMap.get(item.getUserId())); item.setUsername(userMap.get(item.getUserId()));
item.setIsCurrentUser(ValidationUtil.equals(item.getUserId(),RequestContext.getExeUserId())); item.setIsCurrentUser(ValidationUtil.equals(item.getUserId(),RequestContext.getExeUserId()));
}); });
return list; return list;
} }
} }
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import java.util.ArrayList; import com.alibaba.fastjson.JSON;
import java.util.Collection; import com.alibaba.fastjson.JSONObject;
import java.util.Iterator; import com.yeejoin.amos.component.rule.action.Topic;
import java.util.List; import com.yeejoin.amos.component.rule.config.ClazzUtils;
import java.util.concurrent.atomic.AtomicBoolean; import com.yeejoin.amos.component.rule.config.RuleConfig;
import java.util.concurrent.atomic.AtomicReference; import com.yeejoin.amos.component.rule.model.ConstantCategoryModel;
import com.yeejoin.amos.component.rule.model.ConstantModel;
import com.yeejoin.amos.component.rule.model.DefinitionModel;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsOptionModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsValue;
import com.yeejoin.amos.knowledgebase.face.util.BaseUtil;
import com.yeejoin.amos.knowledgebase.face.util.ConfigLoader;
import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -15,7 +25,6 @@ import org.springframework.cloud.client.ServiceInstance; ...@@ -15,7 +25,6 @@ import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient; import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper; import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
...@@ -24,21 +33,13 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil; ...@@ -24,21 +33,13 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.DataNotFound; import org.typroject.tyboot.core.restful.exception.instance.DataNotFound;
import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden; import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden;
import com.alibaba.fastjson.JSON; import java.util.ArrayList;
import com.alibaba.fastjson.JSONObject; import java.util.Collection;
import com.yeejoin.amos.component.rule.action.Topic; import java.util.Iterator;
import com.yeejoin.amos.component.rule.config.ClazzUtils; import java.util.List;
import com.yeejoin.amos.component.rule.config.RuleConfig; import java.util.concurrent.atomic.AtomicBoolean;
import com.yeejoin.amos.component.rule.model.ConstantCategoryModel; import java.util.concurrent.atomic.AtomicReference;
import com.yeejoin.amos.component.rule.model.ConstantModel; import java.util.stream.Collectors;
import com.yeejoin.amos.component.rule.model.DefinitionModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.util.BaseUtil;
import com.yeejoin.amos.knowledgebase.face.util.ConfigLoader;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming;
/** /**
...@@ -52,12 +53,32 @@ import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming; ...@@ -52,12 +53,32 @@ import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming;
@Component @Component
public class DocAuditService { public class DocAuditService {
/**
* 审核状态--待提交
*/
public static final String DOC_AUDIT_STATUS_SAVED = "SAVED";
/**
* 审核状态--待审核
*/
public static final String DOC_AUDIT_STATUS_SUBMITTED = "SUBMITTED";
/**
* 审核状态--通过
*/
public static final String DOC_AUDIT_STATUS_PASSED = "PASSED";
/**
* 审核状态--驳回
*/
public static final String DOC_AUDIT_STATUS_REJECTED = "REJECTED";
private static final String TAG_INSTANCE_LABEL = "label";
private static String DELETE_SYNC_PLAN_TOPIC = "DELETE_SYNC_PLAN_DOC";
@Autowired @Autowired
private DocContentService service; private DocContentService service;
@Autowired @Autowired
private ESDocService eSDocService; private ESDocService eSDocService;
// @Autowired // @Autowired
// private StatisticsRecordService statisticsRecordService; // private StatisticsRecordService statisticsRecordService;
@Autowired @Autowired
private DocLibraryService docLibraryService; private DocLibraryService docLibraryService;
...@@ -65,6 +86,10 @@ public class DocAuditService { ...@@ -65,6 +86,10 @@ public class DocAuditService {
private LoadBalancerClient loadBalancerClient; private LoadBalancerClient loadBalancerClient;
@Autowired @Autowired
private EmqKeeper emqKeeper; private EmqKeeper emqKeeper;
@Autowired
private DynamicsValueService dynamicsValueService;
@Autowired
private DynamicsOptionService dynamicsOptionService;
@Autowired @Autowired
private ConfigLoader configLoader; private ConfigLoader configLoader;
...@@ -83,11 +108,49 @@ public class DocAuditService { ...@@ -83,11 +108,49 @@ public class DocAuditService {
if (ValidationUtil.isEmpty(resList)) { if (ValidationUtil.isEmpty(resList)) {
throw new DataNotFound("数据不存在"); throw new DataNotFound("数据不存在");
} }
for (KnowledgeDocContentModel doc : resList) {
if (ValidationUtil.isEmpty(doc.getDirectoryId())) {
throw new DataNotFound("【" + doc.getDocTitle() + "】,文档所属分类为空");
}
}
int requiredNum = 0;
//查询必填项数量
List<KnowledgeDynamicsOptionModel> optionModels = dynamicsOptionService.queryByFunctional(RequestContext.getAppKey(), DynamicsFunctional.DOC_BASEINFO.name());
requiredNum = optionModels.stream().filter(x -> x.getFrontEndConfig().contains("\"required\":true")).collect(Collectors.toList()).size();
//查询文档必填项是否填写
List<KnowledgeDynamicsValue> requiredByFile = dynamicsValueService.isRequiredByFile(RequestContext.getAppKey(), DynamicsFunctional.DOC_BASEINFO.name(), docSeqList);
if (ValidationUtil.isEmpty(requiredByFile)) {
throw new DataNotFound("【" + resList.get(0).getDocTitle() + "】,信息填写不完整,请完善后发布!");
} else {
List<Long> filterDocs = null;
//筛选出没有记录的
List<Long> valueInsIds = requiredByFile.stream().map(KnowledgeDynamicsValue::getInstanceId).collect(Collectors.toList());
if (requiredByFile.size() != docSeqList.size() * requiredNum) {
filterDocs = docSeqList.stream().filter(x -> {
return !valueInsIds.contains(x);
}).distinct().collect(Collectors.toList());
} else {
//筛选出FieldValue为空的
List<KnowledgeDynamicsValue> fieldValueByNull = requiredByFile.stream().filter(x -> {
return ValidationUtil.isEmpty(x.getFieldValue());
}).collect(Collectors.toList());
filterDocs = fieldValueByNull.stream().map(KnowledgeDynamicsValue::getInstanceId).distinct().collect(Collectors.toList());
}
List<Long> finalFilterDocs = filterDocs;
if (!ValidationUtil.isEmpty(finalFilterDocs)) {
List<KnowledgeDocContentModel> filterFiles = resList.stream().filter(x -> {
return x.getSequenceNbr().equals(finalFilterDocs.get(0));
}).collect(Collectors.toList());
throw new DataNotFound("【" + filterFiles.get(0).getDocTitle() + "】,信息填写不完整,请完善后发布!");
}
}
//更新状态 //更新状态
for (KnowledgeDocContentModel oldDoc : resList) { for (KnowledgeDocContentModel oldDoc : resList) {
if (ValidationUtil.equals(oldDoc.getDocStatus(), Constants.DOC_STATUS_UNPUBLISHED)) { if (ValidationUtil.equals(oldDoc.getDocStatus(), DocContentService.DOC_STATUS_UNPUBLISHED)) {
oldDoc.setDocStatus(Constants.DOC_STATUS_PUBLISHED); oldDoc.setDocStatus(DocContentService.DOC_STATUS_PUBLISHED);
oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_PASSED); oldDoc.setAuditStatus(DOC_AUDIT_STATUS_PASSED);
oldDoc.setAuditorUserId(RequestContext.getExeUserId()); oldDoc.setAuditorUserId(RequestContext.getExeUserId());
service.updateWithModel(oldDoc); service.updateWithModel(oldDoc);
} else { } else {
...@@ -118,13 +181,13 @@ public class DocAuditService { ...@@ -118,13 +181,13 @@ public class DocAuditService {
throw new DataNotFound("数据不存在"); throw new DataNotFound("数据不存在");
} }
for (KnowledgeDocContentModel oldDoc : resList) { for (KnowledgeDocContentModel oldDoc : resList) {
if (ValidationUtil.equals(oldDoc.getDocStatus(), Constants.DOC_STATUS_PUBLISHED)) { if (ValidationUtil.equals(oldDoc.getDocStatus(), DocContentService.DOC_STATUS_PUBLISHED)) {
//判断文档是否被引用 //判断文档是否被引用
if (service.getReference(oldDoc.getSequenceNbr()) > 0) { if (service.getReference(oldDoc.getSequenceNbr()) > 0) {
throw new RequestForbidden("含被引用文档,不能取消发布"); throw new RequestForbidden("含被引用文档,不能取消发布");
} }
oldDoc.setDocStatus(Constants.DOC_STATUS_UNPUBLISHED); oldDoc.setDocStatus(DocContentService.DOC_STATUS_UNPUBLISHED);
oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_SAVED); oldDoc.setAuditStatus(DOC_AUDIT_STATUS_SAVED);
oldDoc.setAuditorUserId(RequestContext.getExeUserId()); oldDoc.setAuditorUserId(RequestContext.getExeUserId());
service.updateWithModel(oldDoc); service.updateWithModel(oldDoc);
} else { } else {
...@@ -155,9 +218,9 @@ public class DocAuditService { ...@@ -155,9 +218,9 @@ public class DocAuditService {
throw new DataNotFound("数据不存在"); throw new DataNotFound("数据不存在");
} }
for (KnowledgeDocContentModel oldDoc : resList) { for (KnowledgeDocContentModel oldDoc : resList) {
if (ValidationUtil.equals(oldDoc.getAuditStatus(), Constants.DOC_AUDIT_STATUS_SAVED)) { if (ValidationUtil.equals(oldDoc.getAuditStatus(), DOC_AUDIT_STATUS_SAVED)) {
//更新审核状态 //更新审核状态
oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_SUBMITTED); oldDoc.setAuditStatus(DOC_AUDIT_STATUS_SUBMITTED);
service.updateWithModel(oldDoc); service.updateWithModel(oldDoc);
} else { } else {
throw new RequestForbidden("只允许对待提交状态的文档执行此操作"); throw new RequestForbidden("只允许对待提交状态的文档执行此操作");
...@@ -179,12 +242,12 @@ public class DocAuditService { ...@@ -179,12 +242,12 @@ public class DocAuditService {
throw new DataNotFound("数据不存在"); throw new DataNotFound("数据不存在");
} }
for (KnowledgeDocContentModel oldDoc : resList) { for (KnowledgeDocContentModel oldDoc : resList) {
if (ValidationUtil.equals(oldDoc.getAuditStatus(), Constants.DOC_AUDIT_STATUS_SUBMITTED)) { if (ValidationUtil.equals(oldDoc.getAuditStatus(), DOC_AUDIT_STATUS_SUBMITTED)) {
//更新审核状态 //更新审核状态
oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_PASSED); oldDoc.setAuditStatus(DOC_AUDIT_STATUS_PASSED);
oldDoc.setAuditorUserId(RequestContext.getExeUserId()); oldDoc.setAuditorUserId(RequestContext.getExeUserId());
//更新文档发布状态 //更新文档发布状态
oldDoc.setDocStatus(Constants.DOC_STATUS_PUBLISHED); oldDoc.setDocStatus(DocContentService.DOC_STATUS_PUBLISHED);
service.updateWithModel(oldDoc); service.updateWithModel(oldDoc);
} else { } else {
throw new RequestForbidden("只允许对待审核状态的文档执行此操作"); throw new RequestForbidden("只允许对待审核状态的文档执行此操作");
...@@ -213,12 +276,12 @@ public class DocAuditService { ...@@ -213,12 +276,12 @@ public class DocAuditService {
if (ValidationUtil.isEmpty(oldDoc)) { if (ValidationUtil.isEmpty(oldDoc)) {
throw new DataNotFound("数据不存在"); throw new DataNotFound("数据不存在");
} }
if (ValidationUtil.equals(oldDoc.getAuditStatus(), Constants.DOC_AUDIT_STATUS_SUBMITTED)) { if (ValidationUtil.equals(oldDoc.getAuditStatus(), DOC_AUDIT_STATUS_SUBMITTED)) {
//更新审核状态&文档状态 //更新审核状态&文档状态
oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_REJECTED); oldDoc.setAuditStatus(DOC_AUDIT_STATUS_REJECTED);
oldDoc.setRejectionComment(rejectionComment); oldDoc.setRejectionComment(rejectionComment);
oldDoc.setAuditorUserId(RequestContext.getExeUserId()); oldDoc.setAuditorUserId(RequestContext.getExeUserId());
oldDoc.setDocStatus(Constants.DOC_STATUS_UNPUBLISHED); oldDoc.setDocStatus(DocContentService.DOC_STATUS_UNPUBLISHED);
return service.updateWithModel(oldDoc); return service.updateWithModel(oldDoc);
} else { } else {
throw new RequestForbidden("只允许对待审核状态的文档执行此操作"); throw new RequestForbidden("只允许对待审核状态的文档执行此操作");
...@@ -233,7 +296,7 @@ public class DocAuditService { ...@@ -233,7 +296,7 @@ public class DocAuditService {
public void pushDeletedDocs2DigitalPlanByMQ(List<KnowledgeDocContentModel> resList) { public void pushDeletedDocs2DigitalPlanByMQ(List<KnowledgeDocContentModel> resList) {
List<Long> ids = BaseUtil.getModelIds(resList); List<Long> ids = BaseUtil.getModelIds(resList);
try { try {
emqKeeper.getMqttClient().publish(Constants.DELETE_SYNC_PLAN_TOPIC, ClazzUtils.serializableObject(ids), RuleConfig.DEFAULT_QOS, false); emqKeeper.getMqttClient().publish(DELETE_SYNC_PLAN_TOPIC, ClazzUtils.serializableObject(ids), RuleConfig.DEFAULT_QOS, false);
logger.info("文档" + ids.toString() + "取消发布,已推送消息至数字预案服务"); logger.info("文档" + ids.toString() + "取消发布,已推送消息至数字预案服务");
} catch (Exception e) { } catch (Exception e) {
logger.fatal("文档" + ids.toString() + "取消发布未能成功推送至数字预案服务", e); logger.fatal("文档" + ids.toString() + "取消发布未能成功推送至数字预案服务", e);
...@@ -344,15 +407,15 @@ public class DocAuditService { ...@@ -344,15 +407,15 @@ public class DocAuditService {
AtomicBoolean isRange = new AtomicBoolean(false); AtomicBoolean isRange = new AtomicBoolean(false);
AtomicReference<String> resRight = new AtomicReference<>(""); AtomicReference<String> resRight = new AtomicReference<>("");
AtomicReference<String> unit = new AtomicReference<>(""); AtomicReference<String> unit = new AtomicReference<>("");
if (!ObjectUtils.isEmpty(values)) { if (!ValidationUtil.isEmpty(values.isEmpty())) {
values.forEach(value -> { values.forEach(value -> {
if (Constants.VALUE_TAG_FIELD_RANGE_MAX.equals(value.getFieldName())) { if (TagValueService.VALUE_TAG_FIELD_RANGE_MAX.equals(value.getFieldName())) {
resRight.set(value.getTagValue()); resRight.set(value.getTagValue());
} else { } else {
resLeft.set(value.getTagValue()); resLeft.set(value.getTagValue());
} }
if (Constants.VALUE_TAG_FIELD_RANGE_MAX.equals(value.getFieldName()) if (TagValueService.VALUE_TAG_FIELD_RANGE_MAX.equals(value.getFieldName())
|| Constants.VALUE_TAG_FIELD_RANGE_MIN.equals(value.getFieldName())) { || TagValueService.VALUE_TAG_FIELD_RANGE_MIN.equals(value.getFieldName())) {
isRange.set(true); isRange.set(true);
} }
unit.set(ValidationUtil.isEmpty(value.getUnit()) || "null".equals(value.getUnit()) ? "" : value.getUnit()); unit.set(ValidationUtil.isEmpty(value.getUnit()) || "null".equals(value.getUnit()) ? "" : value.getUnit());
...@@ -375,7 +438,7 @@ public class DocAuditService { ...@@ -375,7 +438,7 @@ public class DocAuditService {
if (!ValidationUtil.isEmpty(frontEndConfig)) { if (!ValidationUtil.isEmpty(frontEndConfig)) {
try { try {
JSONObject configObject = JSON.parseObject(frontEndConfig); JSONObject configObject = JSON.parseObject(frontEndConfig);
return (String) configObject.get(Constants.TAG_INSTANCE_LABEL); return (String) configObject.get(TAG_INSTANCE_LABEL);
} catch (Exception e) { } catch (Exception e) {
} }
} }
......
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import java.util.*; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCategoryModel;
import com.yeejoin.amos.knowledgebase.face.model.MultipleNodeModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocCategoryMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocCategory;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag;
import com.yeejoin.amos.knowledgebase.face.util.BaseUtil;
import com.yeejoin.amos.knowledgebase.face.util.TreeUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -17,16 +24,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -17,16 +24,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden; import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import java.util.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCategoryModel;
import com.yeejoin.amos.knowledgebase.face.model.MultipleNodeModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocCategoryMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocCategory;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag;
import com.yeejoin.amos.knowledgebase.face.util.BaseUtil;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
import com.yeejoin.amos.knowledgebase.face.util.TreeUtil;
/** /**
* <p> * <p>
...@@ -173,6 +171,16 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K ...@@ -173,6 +171,16 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K
return sequenceList; return sequenceList;
} }
public Map<String, Long> getGroupNameValue(List<Long> ids) {
List<KnowledgeDocCategoryModel> list = this.queryBatchSeq(ids);
Map<String, Long> result = new HashMap<>();
for(KnowledgeDocCategoryModel knowledgeDocCategoryModel: list) {
result.put(knowledgeDocCategoryModel.getCategoryName(), knowledgeDocCategoryModel.getSequenceNbr());
}
return result;
}
private void getAllChildList(KnowledgeDocCategoryModel currentTagGroupModel, List<KnowledgeDocCategoryModel> resList) { private void getAllChildList(KnowledgeDocCategoryModel currentTagGroupModel, List<KnowledgeDocCategoryModel> resList) {
if (null == currentTagGroupModel) { if (null == currentTagGroupModel) {
return; return;
...@@ -205,7 +213,7 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K ...@@ -205,7 +213,7 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K
List<KnowledgeDocCategoryModel> allChildren = TreeUtil.getAllChildren(categoryTree); List<KnowledgeDocCategoryModel> allChildren = TreeUtil.getAllChildren(categoryTree);
if (!allChildren.isEmpty()) { if (!allChildren.isEmpty()) {
List<Long> directoryIds = BaseUtil.getModelIds(allChildren); List<Long> directoryIds = BaseUtil.getModelIds(allChildren);
List<MultipleNodeModel> multipleNodeModels = this.baseMapper.queryDocAndCategoryTree(directoryIds, onlyPublish ? Constants.DOC_STATUS_PUBLISHED : null); List<MultipleNodeModel> multipleNodeModels = this.baseMapper.queryDocAndCategoryTree(directoryIds, onlyPublish ? DocContentService.DOC_STATUS_PUBLISHED : null);
return TreeBuilder.buildByRecursive(multipleNodeModels, null == rootCategory ? root : rootCategory.getParentId()); return TreeBuilder.buildByRecursive(multipleNodeModels, null == rootCategory ? root : rootCategory.getParentId());
} }
} }
...@@ -250,13 +258,4 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K ...@@ -250,13 +258,4 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K
List<KnowledgeDocCategoryModel> categoryModelList = this.queryForList(null, true, categoryName, parentId); List<KnowledgeDocCategoryModel> categoryModelList = this.queryForList(null, true, categoryName, parentId);
return categoryModelList.isEmpty() ? null : categoryModelList.get(0); return categoryModelList.isEmpty() ? null : categoryModelList.get(0);
} }
public Map<String, Long> getGroupNameValue(List<Long> ids) {
List<KnowledgeDocCategoryModel> list = this.queryBatchSeq(ids);
Map<String, Long> result = new HashMap<>();
for(KnowledgeDocCategoryModel knowledgeDocCategoryModel: list) {
result.put(knowledgeDocCategoryModel.getCategoryName(), knowledgeDocCategoryModel.getSequenceNbr());
}
return result;
}
} }
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType; import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCommentsModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocCommentsModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeInteractionRecordModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeInteractionRecordModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocCommentsMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.DocCommentsMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocComments; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocComments;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date;
import java.util.List;
/** /**
......
...@@ -2,6 +2,7 @@ package com.yeejoin.amos.knowledgebase.face.service; ...@@ -2,6 +2,7 @@ package com.yeejoin.amos.knowledgebase.face.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
...@@ -11,15 +12,13 @@ import com.yeejoin.amos.feign.systemctl.model.FileInfoModel; ...@@ -11,15 +12,13 @@ import com.yeejoin.amos.feign.systemctl.model.FileInfoModel;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional; import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName; import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName;
import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType; import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType;
import com.yeejoin.amos.knowledgebase.face.feign.DataFillter;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.*; import com.yeejoin.amos.knowledgebase.face.model.*;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocContentMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.DocContentMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue; import com.yeejoin.amos.knowledgebase.face.util.DataFillter;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
import com.yeejoin.amos.knowledgebase.face.util.DocSortUtil; import com.yeejoin.amos.knowledgebase.face.util.DocSortUtil;
import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming; import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -48,11 +47,10 @@ import java.util.*; ...@@ -48,11 +47,10 @@ import java.util.*;
@Component @Component
public class DocContentService extends BaseService<KnowledgeDocContentModel, KnowledgeDocContent, DocContentMapper> implements DataFillter { public class DocContentService extends BaseService<KnowledgeDocContentModel, KnowledgeDocContent, DocContentMapper> implements DataFillter {
public static final String DOC_STATUS_UNPUBLISHED = "UNPUBLISHED";//文档发布状态--未发布
public static final String DOC_STATUS_PUBLISHED = "PUBLISHED"; //文档发布状态--已发布
private final String orderBy = new StringBuilder().append("ORDER BY FIELD(audit_status, '").append(DocAuditService.DOC_AUDIT_STATUS_SAVED).append("', '").append(DocAuditService.DOC_AUDIT_STATUS_SUBMITTED).append("', '").append(DocAuditService.DOC_AUDIT_STATUS_REJECTED).append("', '").append(DocAuditService.DOC_AUDIT_STATUS_PASSED).append("') ASC, create_time DESC").toString();
private final String orderBy = new StringBuilder().append("ORDER BY FIELD(audit_status, '").append(Constants.DOC_AUDIT_STATUS_SAVED).append("', '")
.append(Constants.DOC_AUDIT_STATUS_SUBMITTED).append("', '").append(Constants.DOC_AUDIT_STATUS_REJECTED).append("', '")
.append(Constants.DOC_AUDIT_STATUS_PASSED).append("') ASC, create_time DESC").toString();
@Autowired @Autowired
private DynamicsValueService dynamicsValueService; private DynamicsValueService dynamicsValueService;
...@@ -69,13 +67,11 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -69,13 +67,11 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
@Autowired @Autowired
private TagValueService tagValueService; private TagValueService tagValueService;
@Autowired @Autowired
private private DocLibraryService docLibraryService;
DocLibraryService docLibraryService;
@Autowired @Autowired
private Sequence sequence; private Sequence sequence;
public Page queryDocPage(int offset, int end, Map<String, String[]> paramMap, String[] auditStatus, String[] docStatus, public Page queryDocPage(int offset, int end, Map<String, String[]> paramMap, String[] auditStatus, String[] docStatus, Date createTimeLeft, Date createTimeRight) {
Date createTimeLeft, Date createTimeRight) {
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
if (!ValidationUtil.isEmpty(auditStatus)) { if (!ValidationUtil.isEmpty(auditStatus)) {
wrapper.in("audit_status", Arrays.asList(auditStatus)); wrapper.in("audit_status", Arrays.asList(auditStatus));
...@@ -128,8 +124,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -128,8 +124,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
docContentModel.setAgencyCode(RequestContext.getAgencyCode()); docContentModel.setAgencyCode(RequestContext.getAgencyCode());
docContentModel.setUserId(RequestContext.getExeUserId()); docContentModel.setUserId(RequestContext.getExeUserId());
docContentModel.setCreateTime(new Date()); docContentModel.setCreateTime(new Date());
docContentModel.setDocStatus(Constants.DOC_STATUS_UNPUBLISHED); docContentModel.setDocStatus(DOC_STATUS_UNPUBLISHED);
docContentModel.setAuditStatus(Constants.DOC_AUDIT_STATUS_SAVED); docContentModel.setAuditStatus(DocAuditService.DOC_AUDIT_STATUS_SAVED);
docContentModel.setSequenceNbr(sequenceNbr); docContentModel.setSequenceNbr(sequenceNbr);
String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName()); String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName());
if (ValidationUtil.isEmpty(inputerOrg)) { if (ValidationUtil.isEmpty(inputerOrg)) {
...@@ -137,7 +133,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -137,7 +133,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
} }
docContentModel.setOrgCode(inputerOrg); docContentModel.setOrgCode(inputerOrg);
String textContent = String.valueOf(docContentModel.getTextContent()); String textContent = String.valueOf(docContentModel.getTextContent());
docContentModel.setSummary(textContent.substring(0,Math.min(300, textContent.length()))); docContentModel.setSummary(textContent.substring(0, Math.min(300, textContent.length())));
if (ValidationUtil.isEmpty(docContentModel.getHaveAttachment())) { if (ValidationUtil.isEmpty(docContentModel.getHaveAttachment())) {
docContentModel.setHaveAttachment(false); docContentModel.setHaveAttachment(false);
} }
...@@ -146,14 +142,14 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -146,14 +142,14 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
dynamicsValueService.saveValueList(docContentModel.getDocBaseInfo(), sequenceNbr, DynamicsFunctional.DOC_BASEINFO, RequestContext.getAppKey()); dynamicsValueService.saveValueList(docContentModel.getDocBaseInfo(), sequenceNbr, DynamicsFunctional.DOC_BASEINFO, RequestContext.getAppKey());
// 保存标签实例 // 保存标签实例
List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), sequenceNbr, Constants.MARKING_TYPE_DOC); List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), sequenceNbr, TagInstanceService.MARKING_TYPE_DOC);
tagInstanceService.saveInstance(docContentModel.getDocContentTags(), sequenceNbr, Constants.MARKING_TYPE_CONTENT); tagInstanceService.saveInstance(docContentModel.getDocContentTags(), sequenceNbr, TagInstanceService.MARKING_TYPE_CONTENT);
QuoteCountFlushTiming.needFlushTag(); QuoteCountFlushTiming.needFlushTag();
//保存附件信息 //保存附件信息
saveAttachments(docContentModel.getAttachments(), sequenceNbr); saveAttachments(docContentModel.getAttachments(), sequenceNbr);
//生成排序字段信息 //生成排序字段信息
docContentModel.setSortStr(DocSortUtil.getSortStr(docTags)); docContentModel.setSortStr(DocSortUtil.getSortStr(docTags));
docLibraryService.fillDirectoryName(Arrays.asList(docContentModel)); docLibraryService.fillDirectoryName(Collections.singletonList(docContentModel));
return this.createWithModel(docContentModel); return this.createWithModel(docContentModel);
} }
...@@ -185,44 +181,38 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -185,44 +181,38 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
} }
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
throw new RuntimeException("删除文件出错."); throw new RuntimeException("删除文件出错." + e.getMessage());
} }
return true; return true;
} }
private KnowledgeDocContentModel fillAttachments(KnowledgeDocContentModel docContentModel) { private KnowledgeDocContentModel fillAttachments(KnowledgeDocContentModel docContentModel) {
try { List<FileInfoModel> fileInfoModels = FeignUtil.remoteCall(() -> Systemctl.fileInfoClient.queryByEntity(RequestContext.getAgencyCode(), KnowledgeDocContentModel.class.getSimpleName(), String.valueOf(docContentModel.getSequenceNbr())));
List<FileInfoModel> fileInfoModels = FeignUtil.remoteCall(() -> Systemctl.fileInfoClient.queryByEntity(RequestContext.getAgencyCode(), KnowledgeDocContentModel.class.getSimpleName(), String.valueOf(docContentModel.getSequenceNbr()))); if (!ValidationUtil.isEmpty(fileInfoModels)) {
List<AttachmentModel> attachments = new ArrayList<>();
if (!ValidationUtil.isEmpty(fileInfoModels)) { for (FileInfoModel fileInfoModel : fileInfoModels) {
List<AttachmentModel> attachments = new ArrayList<>(); AttachmentModel attachmentModel = new AttachmentModel();
for (FileInfoModel fileInfoModel : fileInfoModels) { attachmentModel.setFilename(fileInfoModel.getFilename());
AttachmentModel attachmentModel = new AttachmentModel(); attachmentModel.setFileType(fileInfoModel.getFileType());
attachmentModel.setFilename(fileInfoModel.getFilename()); attachmentModel.setOriginalFileName(fileInfoModel.getOriginalFileName());
attachmentModel.setFileType(fileInfoModel.getFileType()); attachmentModel.setFileUrl(fileInfoModel.getFileUrl());
attachmentModel.setOriginalFileName(fileInfoModel.getOriginalFileName()); attachments.add(attachmentModel);
attachmentModel.setFileUrl(fileInfoModel.getFileUrl());
attachments.add(attachmentModel);
}
docContentModel.setAttachments(attachments);
} }
} catch (Exception e) { docContentModel.setAttachments(attachments);
e.printStackTrace();
} }
return docContentModel; return docContentModel;
} }
private String seperotorStrCollection(Collection<Long> stringCollection) { private String seperotorStrCollection(Collection<Long> stringCollection) {
String returnStr = ""; StringBuilder returnStr = new StringBuilder();
if (!ValidationUtil.isEmpty(stringCollection)) { if (!ValidationUtil.isEmpty(stringCollection)) {
for (Long seq : stringCollection) { for (Long seq : stringCollection) {
returnStr += String.valueOf(seq) + ","; returnStr.append(seq).append(",");
} }
returnStr = returnStr.substring(0, returnStr.length() - 1); returnStr = new StringBuilder(returnStr.substring(0, returnStr.length() - 1));
} }
return returnStr; return returnStr.toString();
} }
...@@ -235,39 +225,37 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -235,39 +225,37 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
throw new DataNotFound("找不到指定的文档."); throw new DataNotFound("找不到指定的文档.");
} }
//判断文档的可编辑状态。 //判断文档的可编辑状态。
if (Constants.DOC_STATUS_PUBLISHED.equals(oldModel.getDocStatus()) if (DOC_STATUS_PUBLISHED.equals(oldModel.getDocStatus()) || DocAuditService.DOC_AUDIT_STATUS_PASSED.equals(oldModel.getAuditStatus()) || DocAuditService.DOC_AUDIT_STATUS_SUBMITTED.equals(oldModel.getAuditStatus())) {
|| Constants.DOC_AUDIT_STATUS_PASSED.equals(oldModel.getAuditStatus())
|| Constants.DOC_AUDIT_STATUS_SUBMITTED.equals(oldModel.getAuditStatus())) {
throw new BadRequest("当前文档状态不可编辑."); throw new BadRequest("当前文档状态不可编辑.");
} }
//如果文档为驳回状态,更改为待提交 //如果文档为驳回状态,更改为待提交
if (ValidationUtil.equals(Constants.DOC_AUDIT_STATUS_REJECTED, oldModel.getAuditStatus())) { if (ValidationUtil.equals(DocAuditService.DOC_AUDIT_STATUS_REJECTED, oldModel.getAuditStatus())) {
oldModel.setAuditStatus(Constants.DOC_AUDIT_STATUS_SAVED); oldModel.setAuditStatus(DocAuditService.DOC_AUDIT_STATUS_SAVED);
} }
if (!ValidationUtil.isEmpty(docContentModel.getHaveAttachment())) { if (!ValidationUtil.isEmpty(docContentModel.getHaveAttachment())) {
oldModel.setHaveAttachment(docContentModel.getHaveAttachment()); oldModel.setHaveAttachment(docContentModel.getHaveAttachment());
} }
String textContent = String.valueOf(docContentModel.getTextContent()); String textContent = String.valueOf(docContentModel.getTextContent());
docContentModel.setSummary(textContent.substring(0,Math.min(300, textContent.length()))); docContentModel.setSummary(textContent.substring(0, Math.min(300, textContent.length())));
//保存基础信息 //保存基础信息
dynamicsValueService.saveValueList(docContentModel.getDocBaseInfo(), docContentModel.getSequenceNbr(), DynamicsFunctional.DOC_BASEINFO, RequestContext.getAppKey()); dynamicsValueService.saveValueList(docContentModel.getDocBaseInfo(), docContentModel.getSequenceNbr(), DynamicsFunctional.DOC_BASEINFO, RequestContext.getAppKey());
// 保存标签实例 // 保存标签实例
tagInstanceService.deleteByTargetSeq(oldModel.getSequenceNbr());//删除已有的标签 tagInstanceService.deleteByTargetSeq(oldModel.getSequenceNbr());//删除已有的标签
List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), oldModel.getSequenceNbr(), Constants.MARKING_TYPE_DOC); List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), oldModel.getSequenceNbr(), TagInstanceService.MARKING_TYPE_DOC);
tagInstanceService.saveInstance(docContentModel.getDocContentTags(), oldModel.getSequenceNbr(), Constants.MARKING_TYPE_CONTENT); tagInstanceService.saveInstance(docContentModel.getDocContentTags(), oldModel.getSequenceNbr(), TagInstanceService.MARKING_TYPE_CONTENT);
// 重新保存附件信息 // 重新保存附件信息
deleteAttachments(oldModel.getSequenceNbr());//删除已有的文件信息 deleteAttachments(oldModel.getSequenceNbr());//删除已有的文件信息
saveAttachments(docContentModel.getAttachments(), oldModel.getSequenceNbr());//保存新的文件信息. saveAttachments(docContentModel.getAttachments(), oldModel.getSequenceNbr());//保存新的文件信息.
oldModel.setDocTitle(docContentModel.getDocTitle()); oldModel.setDocTitle(docContentModel.getDocTitle());
oldModel.setDirectoryId(docContentModel.getDirectoryId()); oldModel.setDirectoryId(docContentModel.getDirectoryId());
docLibraryService.fillDirectoryName(Arrays.asList(oldModel)); docLibraryService.fillDirectoryName(Collections.singletonList(oldModel));
oldModel.setHtmlContent(docContentModel.getHtmlContent()); oldModel.setHtmlContent(docContentModel.getHtmlContent());
//生成排序字段信息 //生成排序字段信息
oldModel.setSortStr(DocSortUtil.getSortStr(docTags)); oldModel.setSortStr(DocSortUtil.getSortStr(docTags));
docLibraryService.fillDirectoryName(Arrays.asList(oldModel)); docLibraryService.fillDirectoryName(Collections.singletonList(oldModel));
this.updateWithModel(oldModel); this.updateWithModel(oldModel);
return Bean.copyExistPropertis(oldModel, docContentModel); return Bean.copyExistPropertis(oldModel, docContentModel);
} }
...@@ -279,9 +267,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -279,9 +267,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
if (ValidationUtil.isEmpty(docContentModel)) { if (ValidationUtil.isEmpty(docContentModel)) {
throw new BadRequest("指定的文档不存在."); throw new BadRequest("指定的文档不存在.");
} }
if (Constants.DOC_STATUS_PUBLISHED.equals(docContentModel.getDocStatus()) if (DOC_STATUS_PUBLISHED.equals(docContentModel.getDocStatus()) || DocAuditService.DOC_AUDIT_STATUS_PASSED.equals(docContentModel.getAuditStatus()) || DocAuditService.DOC_AUDIT_STATUS_SUBMITTED.equals(docContentModel.getAuditStatus())) {
|| Constants.DOC_AUDIT_STATUS_PASSED.equals(docContentModel.getAuditStatus())
|| Constants.DOC_AUDIT_STATUS_SUBMITTED.equals(docContentModel.getAuditStatus())) {
throw new BadRequest("当前文档状态不可删除."); throw new BadRequest("当前文档状态不可删除.");
} }
this.dynamicsValueService.deleteByInstanceId(docContentModel.getSequenceNbr()); this.dynamicsValueService.deleteByInstanceId(docContentModel.getSequenceNbr());
...@@ -324,24 +310,24 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -324,24 +310,24 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
} }
}); });
tagInstanceModelList.forEach(instanceModel -> { tagInstanceModelList.forEach(instanceModel -> {
switch (instanceModel.getMarkingType()) { if (TagInstanceService.MARKING_TYPE_DOC.equals(instanceModel.getMarkingType())) {
case Constants.MARKING_TYPE_DOC: docTags.add(instanceModel);
docTags.add(instanceModel); } else {
break; docContentTags.add(instanceModel);
default:
docContentTags.add(instanceModel);
} }
}); });
} }
KnowledgeInteractionRecordModel recordModel = interactionRecordService.queryUniqueModel(RequestContext.getExeUserId(), KnowledgeDocContentModel.class.getSimpleName(), //开放接口不需要验证
String.valueOf(docContentModel.getSequenceNbr()), OperateType.COLLECT.name()); try {
KnowledgeInteractionRecordModel recordModel = interactionRecordService.queryUniqueModel(RequestContext.getExeUserId(), KnowledgeDocContentModel.class.getSimpleName(), String.valueOf(docContentModel.getSequenceNbr()), OperateType.COLLECT.name());
fillAttachments(docContentModel); fillAttachments(docContentModel);
docContentModel.setDocTags(docTags); docContentModel.setDocTags(docTags);
docContentModel.setDocContentTags(docContentTags); docContentModel.setDocContentTags(docContentTags);
docContentModel.setCollected(!ValidationUtil.isEmpty(recordModel)); docContentModel.setCollected(!ValidationUtil.isEmpty(recordModel));
docContentModel.setUserName(RemoteData.getUserRealNamById(docContentModel.getUserId())); docContentModel.setUserName(RemoteData.getUserRealNamById(docContentModel.getUserId()));
docLibraryService.fillDirectoryName(Arrays.asList(docContentModel)); } catch (Exception ignored) {
}
docLibraryService.fillDirectoryName(Collections.singletonList(docContentModel));
} }
return docContentModel; return docContentModel;
} }
...@@ -535,8 +521,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -535,8 +521,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
case AUDITOR: case AUDITOR:
case INPUTER: case INPUTER:
case VIEWER: case VIEWER:
auditStatusSet.add(Constants.DOC_AUDIT_STATUS_PASSED); auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_PASSED);
docStatusSet.add(Constants.DOC_STATUS_PUBLISHED); docStatusSet.add(DocContentService.DOC_STATUS_PUBLISHED);
dataPrivilegemap.put(docStatus, docStatusSet.toArray(new String[docStatusSet.size()])); dataPrivilegemap.put(docStatus, docStatusSet.toArray(new String[docStatusSet.size()]));
dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()])); dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()]));
break; break;
...@@ -616,7 +602,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -616,7 +602,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
} }
} }
if (!ValidationUtil.isEmpty(auditorOrg)) { if (!ValidationUtil.isEmpty(auditorOrg)) {
String[] auditStatus = {Constants.DOC_AUDIT_STATUS_PASSED, Constants.DOC_AUDIT_STATUS_SUBMITTED}; String[] auditStatus = {DocAuditService.DOC_AUDIT_STATUS_PASSED, DocAuditService.DOC_AUDIT_STATUS_SUBMITTED};
w.likeRight("org_code", auditorOrg).in("audit_status", Arrays.asList(auditStatus)); w.likeRight("org_code", auditorOrg).in("audit_status", Arrays.asList(auditStatus));
} }
}); });
...@@ -644,7 +630,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -644,7 +630,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
return wrapper; return wrapper;
} }
public List<Long> getAllPublishedDocIds(){ public List<Long> getAllPublishedDocIds() {
return this.baseMapper.getAllPublishedDocIds(); return this.baseMapper.getAllPublishedDocIds();
} }
...@@ -654,23 +640,16 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno ...@@ -654,23 +640,16 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
Set<Object> docCotentId = Bean.listToMap(refModelList, "sequenceNbr", KnowledgeDocContentModel.class).keySet(); Set<Object> docCotentId = Bean.listToMap(refModelList, "sequenceNbr", KnowledgeDocContentModel.class).keySet();
return new ArrayList(docCotentId); return new ArrayList(docCotentId);
} }
//根据分组id列表查询所有的关系 //根据分组id列表查询所有的关系
private List<KnowledgeDocContentModel> queryListByCategorySeqList(@Condition(Operator.in) List<Long> directoryId) { private List<KnowledgeDocContentModel> queryListByCategorySeqList(@Condition(Operator.in) List<Long> directoryId) {
return this.queryForList(null, false, directoryId); return this.queryForList(null, false, directoryId);
} }
public List<Map<String, Object>> getSimpleDetail(String sequenceNbrs) { /**
String[] idStrings= sequenceNbrs.split(","); * 开放接口,根据文档分类查询分类下的列表数据,只查公开的标签文档
List<String> idListString= Arrays.asList(idStrings); */
List<Long> idList= new ArrayList<Long>(); public IPage<KnowledgeDocContent> pageByType(int offset, int size, Long typeId, Long tagId) {
idListString.stream().forEach(i->{ return baseMapper.pageByType(new Page<>(offset, size), typeId, tagId);
idList.add(Long.parseLong(i)); }
});
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>();
wrapper.eq("DOC_STATUS", "PUBLISHED");
wrapper.in("SEQUENCE_NBR",idList);
wrapper.select("SEQUENCE_NBR","DOC_TITLE","REC_DATE");
return this.baseMapper.selectMaps(wrapper);
}
} }
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel; import com.yeejoin.amos.feign.systemctl.model.DictionarieValueModel;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional; import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName; import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName;
import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType; import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType;
import com.yeejoin.amos.knowledgebase.face.enumeration.OptionDataType; import com.yeejoin.amos.knowledgebase.face.enumeration.OptionDataType;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.*; import com.yeejoin.amos.knowledgebase.face.model.*;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity; import com.yeejoin.amos.knowledgebase.face.orm.entity.*;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESTagEntity;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag;
import com.yeejoin.amos.knowledgebase.face.util.*; import com.yeejoin.amos.knowledgebase.face.util.*;
import com.yeejoin.amos.knowledgebase.face.util.FileExporter.FileType; import com.yeejoin.amos.knowledgebase.face.util.FileExporter.FileType;
import com.yeejoin.amos.knowledgebase.face.util.excel.ExcelImportConfig; import com.yeejoin.amos.knowledgebase.face.util.excel.ExcelImportConfig;
import com.yeejoin.amos.knowledgebase.face.util.excel.ExcelParser; import com.yeejoin.amos.knowledgebase.face.util.excel.ExcelParser;
import com.yeejoin.amos.knowledgebase.face.util.excel.ExcelParserOld;
import com.yeejoin.amos.knowledgebase.face.util.pdf.PdfBuilder; import com.yeejoin.amos.knowledgebase.face.util.pdf.PdfBuilder;
import com.yeejoin.amos.knowledgebase.face.util.sql.BaseSqlCondition; import com.yeejoin.amos.knowledgebase.face.util.sql.BaseSqlCondition;
import com.yeejoin.amos.knowledgebase.face.util.word.DocxBuilder; import com.yeejoin.amos.knowledgebase.face.util.word.DocxBuilder;
import com.yeejoin.amos.knowledgebase.face.util.word.wordToHtml;
import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.apache.xmlbeans.XmlException;
import org.jsoup.Jsoup;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
...@@ -47,11 +46,10 @@ import org.typroject.tyboot.core.restful.exception.instance.DataNotFound; ...@@ -47,11 +46,10 @@ import org.typroject.tyboot.core.restful.exception.instance.DataNotFound;
import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden; import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.IOException; import java.io.IOException;
import java.text.ParseException;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -78,7 +76,7 @@ public class DocLibraryService { ...@@ -78,7 +76,7 @@ public class DocLibraryService {
private DynamicsValueService dynamicsValueService; private DynamicsValueService dynamicsValueService;
@Autowired @Autowired
private InteractionCountService interactionCountService; private InteractionCountService interactionCountService;
// @Autowired // @Autowired
// private DynamicsGroupService dynamicsGroupService; // private DynamicsGroupService dynamicsGroupService;
@Autowired @Autowired
private DynamicsOptionService dynamicsOptionService; private DynamicsOptionService dynamicsOptionService;
...@@ -100,10 +98,15 @@ public class DocLibraryService { ...@@ -100,10 +98,15 @@ public class DocLibraryService {
private static final Integer BATCH_IMPORT_ONCE_NUM = 200; private static final Integer BATCH_IMPORT_ONCE_NUM = 200;
private static final List auditStatusList; private static final List auditStatusList;
@Value("${admin.all}")
boolean adminAll = false;
@Value("${admin.all.role}")
String adminAllRole;
static { static {
List<String> list = new ArrayList<>(); List<String> list = new ArrayList<>();
list.add(Constants.DOC_AUDIT_STATUS_SUBMITTED); list.add(DocAuditService.DOC_AUDIT_STATUS_SUBMITTED);
list.add(Constants.DOC_AUDIT_STATUS_PASSED); list.add(DocAuditService.DOC_AUDIT_STATUS_PASSED);
auditStatusList = Collections.unmodifiableList(list); auditStatusList = Collections.unmodifiableList(list);
} }
...@@ -124,7 +127,8 @@ public class DocLibraryService { ...@@ -124,7 +127,8 @@ public class DocLibraryService {
recordModel.setUserId(RequestContext.getExeUserId()); recordModel.setUserId(RequestContext.getExeUserId());
recordModel.setEntityType(KnowledgeDocContentModel.class.getSimpleName()); recordModel.setEntityType(KnowledgeDocContentModel.class.getSimpleName());
recordModel.setEntityId(String.valueOf(id)); recordModel.setEntityId(String.valueOf(id));
KnowledgeInteractionRecordModel oldModel = interactionRecordService.queryUniqueModel(recordModel.getUserId(), recordModel.getEntityType(), recordModel.getEntityId(), recordModel.getOperateType()); KnowledgeInteractionRecordModel oldModel = interactionRecordService.queryUniqueModel(recordModel.getUserId(),
recordModel.getEntityType(), recordModel.getEntityId(), recordModel.getOperateType());
if (favor) { if (favor) {
if (ValidationUtil.isEmpty(oldModel)) { if (ValidationUtil.isEmpty(oldModel)) {
recordModel.setAgencyCode(RequestContext.getAgencyCode()); recordModel.setAgencyCode(RequestContext.getAgencyCode());
...@@ -138,10 +142,18 @@ public class DocLibraryService { ...@@ -138,10 +142,18 @@ public class DocLibraryService {
return true; return true;
} }
public Page queryDocList(int offset, int end, Long directoryId, String docTitle, String[] auditStatus, String docStatus, public Page queryDocList(int offset, int end, Long directoryId, String docTitle, String[] auditStatus,
Map<String, String[]> requestMap, String createTimeLeft, String createTimeRight, boolean favor, boolean permission) { String docStatus, Map<String, String[]> requestMap, String createTimeLeft, String createTimeRight,
boolean favor, boolean permission) {
Map<String, Object> paramsMap = new HashMap<>(); Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("userId", RequestContext.getExeUserId()); if (RemoteData.isAdmin(adminAllRole)) {
if (!adminAll) {
paramsMap.put("userId", RequestContext.getExeUserId());
}
} else {
paramsMap.put("userId", RequestContext.getExeUserId());
}
paramsMap.put("start", offset); paramsMap.put("start", offset);
paramsMap.put("limit", end > offset ? end - offset + 1 : 50); paramsMap.put("limit", end > offset ? end - offset + 1 : 50);
// 封装权限过滤条件 // 封装权限过滤条件
...@@ -150,11 +162,12 @@ public class DocLibraryService { ...@@ -150,11 +162,12 @@ public class DocLibraryService {
} }
List<Long> directoryIdList = new ArrayList<>(); List<Long> directoryIdList = new ArrayList<>();
if (directoryId != null) { if (directoryId != null) {
Collection<KnowledgeDocCategoryModel> childCategoryModels = docCategoryService.queryDocCategoryTree(RequestContext.getAgencyCode(), directoryId); Collection<KnowledgeDocCategoryModel> childCategoryModels = docCategoryService
.queryDocCategoryTree(RequestContext.getAgencyCode(), directoryId);
if (!childCategoryModels.isEmpty()) { if (!childCategoryModels.isEmpty()) {
directoryIdList.addAll(BaseUtil.getModelIds(TreeUtil.getAllChildren(childCategoryModels))); directoryIdList.addAll(BaseUtil.getModelIds(TreeUtil.getAllChildren(childCategoryModels)));
} }
//获取所有子分类ID // 获取所有子分类ID
directoryIdList.add(directoryId); directoryIdList.add(directoryId);
} }
...@@ -171,18 +184,14 @@ public class DocLibraryService { ...@@ -171,18 +184,14 @@ public class DocLibraryService {
page.setTotal(total); page.setTotal(total);
if (total > 0 && total > offset) { if (total > 0 && total > offset) {
List<Map<String, Object>> list = docContentService.getBaseMapper().queryDocBaseInfoList(paramsMap); List<Map<String, Object>> list = docContentService.getBaseMapper().queryDocBaseInfoList(paramsMap);
list.stream().map(x -> {
x.put("createTime", x.get("createTime").toString().replace("T", " "));
x.put("recDate", x.get("recDate").toString().replace("T", " "));
return x;
}).collect(Collectors.toList());
page.setRecords(list); page.setRecords(list);
} }
return page; return page;
} }
private void addExtraFieldsAndFilters(Map<String, Object> paramsMap, Map<String, String[]> requestMap) { private void addExtraFieldsAndFilters(Map<String, Object> paramsMap, Map<String, String[]> requestMap) {
List<KnowledgeDynamicsOptionModel> optionModels = dynamicsOptionService.queryByFunctional(RequestContext.getAppKey(), DynamicsFunctional.DOC_BASEINFO.name()); List<KnowledgeDynamicsOptionModel> optionModels = dynamicsOptionService
.queryByFunctional(RequestContext.getAppKey(), DynamicsFunctional.DOC_BASEINFO.name());
if (ValidationUtil.isEmpty(optionModels)) { if (ValidationUtil.isEmpty(optionModels)) {
return; return;
} }
...@@ -194,7 +203,8 @@ public class DocLibraryService { ...@@ -194,7 +203,8 @@ public class DocLibraryService {
String fieldName = optionModel.getFieldName(); String fieldName = optionModel.getFieldName();
extraFields.add(fieldName); extraFields.add(fieldName);
if (requestMap.containsKey(fieldName)) { if (requestMap.containsKey(fieldName)) {
String filterStr = buildFilterStr(fieldName, requestMap.get(fieldName), optionModel.getDataType(), optionModel.getQueryStrategy()); String filterStr = buildFilterStr(fieldName, requestMap.get(fieldName), optionModel.getDataType(),
optionModel.getQueryStrategy());
if (!ValidationUtil.isEmpty(filterStr)) { if (!ValidationUtil.isEmpty(filterStr)) {
extraStrFilters.add(filterStr); extraStrFilters.add(filterStr);
} }
...@@ -233,11 +243,11 @@ public class DocLibraryService { ...@@ -233,11 +243,11 @@ public class DocLibraryService {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
if (!ValidationUtil.isEmpty(values[0])) { if (!ValidationUtil.isEmpty(values[0])) {
builder.append(fieldName).append(" >= \"").append(values[0]).append("\""); builder.append(fieldName).append(" >= \"").append(values[0]).append("\"");
if (values.length>1 && !ValidationUtil.isEmpty(values[1])) { if (values.length > 1 && !ValidationUtil.isEmpty(values[1])) {
builder.append(" AND "); builder.append(" AND ");
} }
} }
if (values.length>1 && !ValidationUtil.isEmpty(values[1])) { if (values.length > 1 && !ValidationUtil.isEmpty(values[1])) {
builder.append(fieldName).append(" <= \"").append(values[1]).append("\""); builder.append(fieldName).append(" <= \"").append(values[1]).append("\"");
} }
return builder.toString(); return builder.toString();
...@@ -251,19 +261,34 @@ public class DocLibraryService { ...@@ -251,19 +261,34 @@ public class DocLibraryService {
paramsMap.put("permissionFilters", permissionFiltersMap); paramsMap.put("permissionFilters", permissionFiltersMap);
String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName()); String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName());
String auditorOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.AUDITOR.getRoleName()); String auditorOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.AUDITOR.getRoleName());
boolean isAdmin = RemoteData.isAdmin(adminAllRole);
if (ValidationUtil.isEmpty(inputerOrg) && ValidationUtil.isEmpty(auditorOrg)) { if (ValidationUtil.isEmpty(inputerOrg) && ValidationUtil.isEmpty(auditorOrg)) {
throw new RequestForbidden("用户角色错误"); throw new RequestForbidden("用户角色错误");
} }
if (!ValidationUtil.isEmpty(inputerOrg)) { if (!ValidationUtil.isEmpty(inputerOrg)) {
permissionFiltersMap.put("userId", RequestContext.getExeUserId()); if (RemoteData.isAdmin(adminAllRole)) {
if (!adminAll) {
permissionFiltersMap.put("userId", RequestContext.getExeUserId());
}
} else {
permissionFiltersMap.put("userId", RequestContext.getExeUserId());
}
} }
if (!ValidationUtil.isEmpty(auditorOrg)) { if (!ValidationUtil.isEmpty(auditorOrg)) {
permissionFiltersMap.put("orgCode", auditorOrg); if (RemoteData.isAdmin(adminAllRole)) {
if (!adminAll) {
permissionFiltersMap.put("orgCode", auditorOrg);
}
} else {
permissionFiltersMap.put("orgCode", auditorOrg);
}
permissionFiltersMap.put("auditStatusList", auditStatusList); permissionFiltersMap.put("auditStatusList", auditStatusList);
} }
} }
private void addCommonFilters(Map<String, Object> paramsMap, List<Long> directoryIdList, String docTitle, String docStatus, String[] auditStatus, String createTimeLeft, String createTimeRight) { private void addCommonFilters(Map<String, Object> paramsMap, List<Long> directoryIdList, String docTitle,
String docStatus, String[] auditStatus, String createTimeLeft, String createTimeRight) {
Map<String, Object> commonFiltersMap = new HashMap<>(16); Map<String, Object> commonFiltersMap = new HashMap<>(16);
paramsMap.put("commonFilters", commonFiltersMap); paramsMap.put("commonFilters", commonFiltersMap);
if (!ValidationUtil.isEmpty(directoryIdList)) { if (!ValidationUtil.isEmpty(directoryIdList)) {
...@@ -299,9 +324,7 @@ public class DocLibraryService { ...@@ -299,9 +324,7 @@ public class DocLibraryService {
*/ */
public Page searchAdvanced(Page page, Map<String, Object> queryParams) { public Page searchAdvanced(Page page, Map<String, Object> queryParams) {
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.select("SEQUENCE_NBR") wrapper.select("SEQUENCE_NBR").eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED).orderByAsc("SORT_STR");
.eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED)
.orderByAsc("SORT_STR");
BaseSqlCondition sqlCondition = BaseSqlCondition.getInstance(queryParams); BaseSqlCondition sqlCondition = BaseSqlCondition.getInstance(queryParams);
if (sqlCondition.getTotalStatement() > 0) { if (sqlCondition.getTotalStatement() > 0) {
...@@ -320,7 +343,8 @@ public class DocLibraryService { ...@@ -320,7 +343,8 @@ public class DocLibraryService {
} }
}); });
fillDirectoryName(esList); fillDirectoryName(esList);
return page.setRecords(esList).setCurrent(iPage.getCurrent()).setSize(iPage.getSize()).setTotal(iPage.getTotal()); return page.setRecords(esList).setCurrent(iPage.getCurrent()).setSize(iPage.getSize())
.setTotal(iPage.getTotal());
} }
/** /**
...@@ -432,9 +456,11 @@ public class DocLibraryService { ...@@ -432,9 +456,11 @@ public class DocLibraryService {
return res; return res;
} }
//获取我的文档收藏列表 // 获取我的文档收藏列表
private List<Long> getMyFavoriteDocIdList() { private List<Long> getMyFavoriteDocIdList() {
List<KnowledgeInteractionRecordModel> recordModelList = interactionRecordService.queryListByUser(RequestContext.getExeUserId(), OperateType.COLLECT.name(), KnowledgeDocContentModel.class.getSimpleName(), RequestContext.getAgencyCode()); List<KnowledgeInteractionRecordModel> recordModelList = interactionRecordService.queryListByUser(
RequestContext.getExeUserId(), OperateType.COLLECT.name(),
KnowledgeDocContentModel.class.getSimpleName(), RequestContext.getAgencyCode());
List<Long> idList = new ArrayList<>(); List<Long> idList = new ArrayList<>();
for (KnowledgeInteractionRecordModel recordModel : recordModelList) { for (KnowledgeInteractionRecordModel recordModel : recordModelList) {
idList.add(Long.valueOf(recordModel.getEntityId())); idList.add(Long.valueOf(recordModel.getEntityId()));
...@@ -442,14 +468,16 @@ public class DocLibraryService { ...@@ -442,14 +468,16 @@ public class DocLibraryService {
return idList; return idList;
} }
//获取文档被收藏总数 // 获取文档被收藏总数
public int getCollectionCount(Long sequenceNbr) { public int getCollectionCount(Long sequenceNbr) {
return interactionRecordService.countByInstance(OperateType.COLLECT.name(), KnowledgeDocContentModel.class.getSimpleName(), sequenceNbr.toString()); return interactionRecordService.countByInstance(OperateType.COLLECT.name(),
KnowledgeDocContentModel.class.getSimpleName(), sequenceNbr.toString());
} }
//获取文档被引用总数 // 获取文档被引用总数
public int getReferenceCount(Long sequenceNbr) { public int getReferenceCount(Long sequenceNbr) {
return interactionCountService.getOperateCount(InteractionCountService.QUOTE_TYPE_PUBLISH, InteractionCountService.QUOTE_ENTITY_DOCUMENT, sequenceNbr.toString()); return interactionCountService.getOperateCount(InteractionCountService.QUOTE_TYPE_PUBLISH,
InteractionCountService.QUOTE_ENTITY_DOCUMENT, sequenceNbr.toString());
} }
/** /**
...@@ -462,8 +490,8 @@ public class DocLibraryService { ...@@ -462,8 +490,8 @@ public class DocLibraryService {
List resList = new ArrayList<>(); List resList = new ArrayList<>();
List<KnowledgeTag> tagList = tagService.getBaseMapper().queryTagByNameInPublishedDoc(queryStr); List<KnowledgeTag> tagList = tagService.getBaseMapper().queryTagByNameInPublishedDoc(queryStr);
resList.addAll(Bean.listToMap(tagList, "tagName", KnowledgeTag.class).keySet()); resList.addAll(Bean.listToMap(tagList, "tagName", KnowledgeTag.class).keySet());
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>() QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>().select("DOC_TITLE")
.select("DOC_TITLE").eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED).like("DOC_TITLE", queryStr); .eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED).like("DOC_TITLE", queryStr);
List<KnowledgeDocContent> docContentList = docContentService.list(wrapper); List<KnowledgeDocContent> docContentList = docContentService.list(wrapper);
docContentList.forEach(doc -> { docContentList.forEach(doc -> {
if (!resList.contains(doc.getDocTitle())) { if (!resList.contains(doc.getDocTitle())) {
...@@ -481,7 +509,7 @@ public class DocLibraryService { ...@@ -481,7 +509,7 @@ public class DocLibraryService {
public Map<String, Integer> count(int days) { public Map<String, Integer> count(int days) {
Map<String, Integer> res = new HashMap<>(); Map<String, Integer> res = new HashMap<>();
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.eq("doc_status", Constants.DOC_STATUS_PUBLISHED); wrapper.eq("doc_status", DocContentService.DOC_STATUS_PUBLISHED);
res.put("totalAll", docContentService.count(wrapper)); res.put("totalAll", docContentService.count(wrapper));
Date rightRange = new Date(); Date rightRange = new Date();
Date leftRange = getDateBeforeDays(rightRange, days - 1); Date leftRange = getDateBeforeDays(rightRange, days - 1);
...@@ -497,7 +525,8 @@ public class DocLibraryService { ...@@ -497,7 +525,8 @@ public class DocLibraryService {
* @return * @return
*/ */
public List queryNewDocs(int top) { public List queryNewDocs(int top) {
List<KnowledgeDocContentModel> list = docContentService.queryNewDocsWithStatus(top, Constants.DOC_STATUS_PUBLISHED); List<KnowledgeDocContentModel> list = docContentService.queryNewDocsWithStatus(top,
DocContentService.DOC_STATUS_PUBLISHED);
fillDirectoryName(list); fillDirectoryName(list);
return fillDynamics(list, false); return fillDynamics(list, false);
} }
...@@ -537,8 +566,10 @@ public class DocLibraryService { ...@@ -537,8 +566,10 @@ public class DocLibraryService {
} }
contentModel.setHtmlContent(null); contentModel.setHtmlContent(null);
Map contentMap = Bean.BeantoMap(contentModel); Map contentMap = Bean.BeantoMap(contentModel);
List<KnowledgeDynamicsValueModel> listByInstance = dynamicsValueService.queryByInstanceId(contentModel.getSequenceNbr()); List<KnowledgeDynamicsValueModel> listByInstance = dynamicsValueService
Map<Object, Object> returnMap = Bean.listToMap(listByInstance, "fieldName", "fieldValue", KnowledgeDynamicsValueModel.class); .queryByInstanceId(contentModel.getSequenceNbr());
Map<Object, Object> returnMap = Bean.listToMap(listByInstance, "fieldName", "fieldValue",
KnowledgeDynamicsValueModel.class);
if (!simple) { if (!simple) {
returnMap.put("referenceNum", getReferenceCount(contentModel.getSequenceNbr())); returnMap.put("referenceNum", getReferenceCount(contentModel.getSequenceNbr()));
returnMap.put("collectionNum", getCollectionCount(contentModel.getSequenceNbr())); returnMap.put("collectionNum", getCollectionCount(contentModel.getSequenceNbr()));
...@@ -583,188 +614,7 @@ public class DocLibraryService { ...@@ -583,188 +614,7 @@ public class DocLibraryService {
FileExporter.exportFile(fileType, docTitle, bytes, response); FileExporter.exportFile(fileType, docTitle, bytes, response);
} }
// @Transactional(rollbackFor = { Exception.class, BaseException.class }) @Transactional(rollbackFor = {Exception.class, BaseException.class})
// public List importExcel(MultipartFile file, List<ExcelImportConfig> excelConfigList) {
// String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName());
// if (ValidationUtil.isEmpty(inputerOrg)) {
// throw new RequestForbidden("非录入者角色用户无权录入");
// }
// int finishedNum = 0;
//
// Set<Long> involvedTagIds = new HashSet<>();
// Set<String> enumNameList = new HashSet<>();
// Map<String, ExcelImportConfig> excelConfigMap = new HashMap();
// List<Long> directoryList = new ArrayList<>();
// for (ExcelImportConfig excelConfig : excelConfigList) {
// if (!excelConfig.check()) {
// throw new BadRequest("模板配置数据有误");
// }
// excelConfigMap.put(excelConfig.getDirectoryColumn(), excelConfig);
// Set<Long> involvedTags = excelConfig.getTagColumns().keySet();
// involvedTagIds.addAll(involvedTags);
// Set<String> enumNames = new HashSet<>(excelConfig.getEnumMap().values());
// enumNameList.addAll(enumNames);
// directoryList.add(Long.parseLong(excelConfig.getDirectoryColumn()));
// }
// Map<String, Long> directoryMap = docCategoryService.getGroupNameValue(directoryList);
// Workbook workbook = getBookWithFile(file);
// Sheet sheet = workbook.getSheetAt(0);
// if (sheet == null) {
// throw new BadRequest("文档sheet页为空");
// }
// int rowNumber = getRowNumber(sheet, excelConfigList.get(0));
// if (rowNumber <= 0) {
// throw new BadRequest("数据条目为零");
// }
//
// // 组装标签信息Map
// Map<Long, KnowledgeTagModel> tagMap = new HashMap();
// if (!ValidationUtil.isEmpty(involvedTagIds)) {
// List<KnowledgeTagModel> tagModelList = tagService.queryByIds(involvedTagIds);
// for (KnowledgeTagModel tagModel : tagModelList) {
// tagMap.put(tagModel.getSequenceNbr(), tagModel);
// }
// }
// // 组装文档动态字段数据类型Map
// Map<String, KnowledgeDynamicsOptionModel> fieldTypeMap = new HashMap<>();
// List<KnowledgeDynamicsOptionModel> optionModels = dynamicsOptionService
// .queryByFunctional(RequestContext.getAppKey(), DynamicsFunctional.DOC_BASEINFO.name());
// for (KnowledgeDynamicsOptionModel optionModel : optionModels) {
// fieldTypeMap.put(optionModel.getFieldName(), optionModel);
// }
//
// // 组装标签值类型Map
// Map<Long, String> tagValueTypeMap = new HashMap<>();
// if (!ValidationUtil.isEmpty(involvedTagIds)) {
// List<KnowledgeDynamicsValueModel> dynamicsValueList = dynamicsValueService.queryFieldValueByIds(new ArrayList(involvedTagIds), "valueType");
// for (KnowledgeDynamicsValueModel dynamicsValueModel : dynamicsValueList) {
// tagValueTypeMap.put(dynamicsValueModel.getInstanceId(), dynamicsValueModel.getFieldValue());
// }
// }
// // 组装字典中英文Map
// Map<String, Map<String, String>> enumCnEnMap = new HashMap<>();
// for (String enumName : enumNameList) {
// try {
// List<DictionarieValueModel> dictList = RemoteData.queryDict(enumName);
// Map<String, String> cnEnMap = new HashMap<>();
// for (DictionarieValueModel dictionarieValueModel : dictList) {
// cnEnMap.put(dictionarieValueModel.getDictDataValue(), dictionarieValueModel.getDictDataKey());
// }
// enumCnEnMap.put(enumName, cnEnMap);
// } catch (Exception e) {
// throw new RequestForbidden("获取字典数据出错,解析无法进行");
// }
// }
// // 组装标签单位Map
// Map<Long, String> tagUnitMap = new HashMap<>();
// if (!ValidationUtil.isEmpty(involvedTagIds)) {
// List<KnowledgeDynamicsValueModel> dynamicsValueList = dynamicsValueService.queryFieldValueByIds(new ArrayList(involvedTagIds), "unit");
// for (KnowledgeDynamicsValueModel dynamicsValueModel : dynamicsValueList) {
// tagUnitMap.put(dynamicsValueModel.getInstanceId(), dynamicsValueModel.getFieldValue());
// }
// }
//
// ExcelParser excelParser = new ExcelParser(tagMap, excelConfigMap, fieldTypeMap, tagValueTypeMap, enumCnEnMap,
// tagUnitMap, this.sequence, inputerOrg);
// // 逐行解析
// while (finishedNum < rowNumber) {
// for (int i = 0; i < BATCH_IMPORT_ONCE_NUM && finishedNum < rowNumber; i++, finishedNum++) {
// Row row = sheet.getRow(excelConfigList.get(0).getStartRowIndex() + finishedNum);
// excelParser.parseRow(row, directoryMap);
// if (i % 500 == 0) {
// batchInsertDocDataAll(excelParser.getAndFlushDatas());
// }
// }
// QuoteCountFlushTiming.needFlushTag();
// }
// return excelParser.getImportResults();
// }
// @Transactional(rollbackFor = {Exception.class, BaseException.class})
// public List importExcel(MultipartFile file, List<ExcelImportConfig> excelConfigList) {
// String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName());
// if (ValidationUtil.isEmpty(inputerOrg)) {
// throw new RequestForbidden("非录入者角色用户无权录入");
// }
// int finishedNum = 0;
// List<Object> list = new ArrayList<>();
// for (ExcelImportConfig excelConfig : excelConfigList) {
// if (!excelConfig.check()) {
// throw new BadRequest("模板配置数据有误");
// }
// Workbook workbook = getBookWithFile(file);
// Sheet sheet = workbook.getSheetAt(0);
// if (sheet == null) {
// throw new BadRequest("文档sheet页为空");
// }
// int rowNumber = getRowNumber(sheet, excelConfig);
// if (rowNumber <= 0) {
// throw new BadRequest("数据条目为零");
// }
// Set<Long> involvedTagIds = excelConfig.getTagColumns().keySet();
// // 组装标签信息Map
// Map<Long, KnowledgeTagModel> tagMap = new HashMap();
// if (!ValidationUtil.isEmpty(involvedTagIds)) {
// List<KnowledgeTagModel> tagModelList = tagService.queryByIds(involvedTagIds);
// for (KnowledgeTagModel tagModel : tagModelList) {
// tagMap.put(tagModel.getSequenceNbr(), tagModel);
// }
// }
// // 组装文档动态字段数据类型Map
// Map<String, KnowledgeDynamicsOptionModel> fieldTypeMap = new HashMap<>();
// List<KnowledgeDynamicsOptionModel> optionModels = dynamicsOptionService.queryByFunctional(RequestContext.getAppKey(), DynamicsFunctional.DOC_BASEINFO.name());
// for (KnowledgeDynamicsOptionModel optionModel : optionModels) {
// fieldTypeMap.put(optionModel.getFieldName(), optionModel);
// }
//
// // 组装标签值类型Map
// Map<Long, String> tagValueTypeMap = new HashMap<>();
// if (!ValidationUtil.isEmpty(involvedTagIds)) {
// List<KnowledgeDynamicsValueModel> dynamicsValueList = dynamicsValueService.queryFieldValueByIds(new ArrayList(involvedTagIds), "valueType");
// for (KnowledgeDynamicsValueModel dynamicsValueModel : dynamicsValueList) {
// tagValueTypeMap.put(dynamicsValueModel.getInstanceId(), dynamicsValueModel.getFieldValue());
// }
// }
// // 组装字典中英文Map
// Map<String, Map<String, String>> enumCnEnMap = new HashMap<>();
// Set<String> enumNameList = new HashSet<>(excelConfig.getEnumMap().values());
// for (String enumName : enumNameList) {
// try {
// List<DictionarieValueModel> dictList = RemoteData.queryDict(enumName);
// Map<String, String> cnEnMap = new HashMap<>();
// for (DictionarieValueModel dictionarieValueModel : dictList) {
// cnEnMap.put(dictionarieValueModel.getDictDataValue(), dictionarieValueModel.getDictDataKey());
// }
// enumCnEnMap.put(enumName, cnEnMap);
// } catch (Exception e) {
// throw new RequestForbidden("获取字典数据出错,解析无法进行");
// }
// }
// // 组装标签单位Map
// Map<Long, String> tagUnitMap = new HashMap<>();
// if (!ValidationUtil.isEmpty(involvedTagIds)) {
// List<KnowledgeDynamicsValueModel> dynamicsValueList = dynamicsValueService.queryFieldValueByIds(new ArrayList(involvedTagIds), "unit");
// for (KnowledgeDynamicsValueModel dynamicsValueModel : dynamicsValueList) {
// tagUnitMap.put(dynamicsValueModel.getInstanceId(), dynamicsValueModel.getFieldValue());
// }
// }
//
// ExcelParser excelParser = new ExcelParser(tagMap, excelConfig, fieldTypeMap, tagValueTypeMap, enumCnEnMap, tagUnitMap, this.sequence, inputerOrg);
// // 逐行解析
// while (finishedNum <= rowNumber) {
// for (int i = 0; i < BATCH_IMPORT_ONCE_NUM && finishedNum < rowNumber; i++, finishedNum++) {
// Row row = sheet.getRow(excelConfig.getStartRowIndex() + finishedNum);
// excelParser.parseRow(row);
// }
// batchInsertDocDataAll(excelParser.getAndFlushDatas());
// QuoteCountFlushTiming.needFlushTag();
// }
// list.add(excelParser.getImportResults());
// }
// return list;
// }
@Transactional(rollbackFor = { Exception.class, BaseException.class })
public List importExcel(MultipartFile file, List<ExcelImportConfig> excelConfigList) { public List importExcel(MultipartFile file, List<ExcelImportConfig> excelConfigList) {
String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName()); String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName());
if (ValidationUtil.isEmpty(inputerOrg)) { if (ValidationUtil.isEmpty(inputerOrg)) {
...@@ -847,24 +697,56 @@ public class DocLibraryService { ...@@ -847,24 +697,56 @@ public class DocLibraryService {
} }
} }
ExcelParserOld excelParser = new ExcelParserOld(tagMap, excelConfigMap, fieldTypeMap, tagValueTypeMap, enumCnEnMap, ExcelParser excelParser = new ExcelParser(tagMap, excelConfigMap, fieldTypeMap, tagValueTypeMap, enumCnEnMap,
tagUnitMap, this.sequence, inputerOrg); tagUnitMap, this.sequence, inputerOrg);
// 逐行解析 // 逐行解析
while (finishedNum < rowNumber) { while (finishedNum < rowNumber) {
for (int i = 1; i <= BATCH_IMPORT_ONCE_NUM && finishedNum < rowNumber; i++, finishedNum++) { for (int i = 0; i < BATCH_IMPORT_ONCE_NUM && finishedNum < rowNumber; i++, finishedNum++) {
Row row = sheet.getRow(excelConfigList.get(0).getStartRowIndex() + finishedNum); Row row = sheet.getRow(excelConfigList.get(0).getStartRowIndex() + finishedNum);
excelParser.parseRow(row, directoryMap); excelParser.parseRow(row, directoryMap);
if (i % 500 == 0) { if (i % 500 == 0) {
batchInsertDocDataAll(excelParser.getAndFlushDatas()); batchInsertDocDataAll(excelParser.getAndFlushDatas());
} }
} }
batchInsertDocDataAll(excelParser.getAndFlushDatas());
QuoteCountFlushTiming.needFlushTag(); QuoteCountFlushTiming.needFlushTag();
} }
return excelParser.getImportResults(); return excelParser.getImportResults();
} }
void batchInsertDocDataAll(ExcelParserOld.TablesDataList datas) { @Transactional(rollbackFor = {Exception.class, BaseException.class})
public String importWordOfSingle(MultipartFile file) throws IOException, XmlException, ParserConfigurationException, TransformerException {
String htmlString = wordToHtml.wordParase(file);
String resultHtml = wordToHtml.wordReplaceTag(htmlString, file.getOriginalFilename());
return resultHtml;
}
@Transactional(rollbackFor = {Exception.class, BaseException.class})
public boolean importWordOfBatch(List<MultipartFile> files) {
if (files.size() <= 0) {
throw new DataNotFound("文件为空!");
}
for (MultipartFile file : files) {
try {
String htmlString = wordToHtml.wordParase(file);
String resultHtml = wordToHtml.wordReplaceTag(htmlString, file.getOriginalFilename());
String wordText = Jsoup.parse(resultHtml).body().text();
KnowledgeDocContentModel knowledgeDocContentModel = new KnowledgeDocContentModel();
knowledgeDocContentModel.setHtmlContent(resultHtml);
knowledgeDocContentModel.setDocTitle(file.getOriginalFilename());
knowledgeDocContentModel.setTextContent(wordText);
docContentService.createDoc(knowledgeDocContentModel);
} catch (IOException | XmlException | ParserConfigurationException | TransformerException e) {
e.printStackTrace();
throw new DataNotFound("上传失败!");
}
}
return true;
}
void batchInsertDocDataAll(ExcelParser.TablesDataList datas) {
docContentService.saveBatch(datas.getDocContentList()); docContentService.saveBatch(datas.getDocContentList());
dynamicsValueService.saveBatch(datas.getDynamicsValueList()); dynamicsValueService.saveBatch(datas.getDynamicsValueList());
tagInstanceService.saveBatch(datas.getTagInstanceList()); tagInstanceService.saveBatch(datas.getTagInstanceList());
...@@ -877,12 +759,15 @@ public class DocLibraryService { ...@@ -877,12 +759,15 @@ public class DocLibraryService {
} }
List<KnowledgeDocContentModel> contentModelList = docContentService.queryByIds(docSeqList); List<KnowledgeDocContentModel> contentModelList = docContentService.queryByIds(docSeqList);
fillDirectoryName(contentModelList); fillDirectoryName(contentModelList);
Map<Object, KnowledgeDocContentModel> docContentModelMap = Bean.listToMap(contentModelList, "sequenceNbr", KnowledgeDocContentModel.class); Map<Object, KnowledgeDocContentModel> docContentModelMap = Bean.listToMap(contentModelList, "sequenceNbr",
KnowledgeDocContentModel.class);
if (!contentModelList.isEmpty()) { if (!contentModelList.isEmpty()) {
List<KnowledgeTagInstanceModel> tagInstanceModelList = tagInstanceService.queryListByTargetSeqs(docSeqList); List<KnowledgeTagInstanceModel> tagInstanceModelList = tagInstanceService.queryListByTargetSeqs(docSeqList);
Map<Object, KnowledgeTagInstanceModel> tagInstanceModelMap = Bean.listToMap(tagInstanceModelList, "sequenceNbr", KnowledgeTagInstanceModel.class); Map<Object, KnowledgeTagInstanceModel> tagInstanceModelMap = Bean.listToMap(tagInstanceModelList,
"sequenceNbr", KnowledgeTagInstanceModel.class);
List<KnowledgeTagValueModel> tagValueModelList = tagValueService.queryTagValuesByDocIds(docSeqList); List<KnowledgeTagValueModel> tagValueModelList = tagValueService.queryTagValuesByDocIds(docSeqList);
List<KnowledgeDynamicsValueModel> dynamicsValueModelList = dynamicsValueService.queryByInstanceIds(docSeqList); List<KnowledgeDynamicsValueModel> dynamicsValueModelList = dynamicsValueService
.queryByInstanceIds(docSeqList);
// 标签值组装到标签实例 // 标签值组装到标签实例
tagValueModelList.forEach(tagValueModel -> { tagValueModelList.forEach(tagValueModel -> {
KnowledgeTagInstanceModel instanceModel = tagInstanceModelMap.get(tagValueModel.getInstanceSeq()); KnowledgeTagInstanceModel instanceModel = tagInstanceModelMap.get(tagValueModel.getInstanceSeq());
...@@ -899,8 +784,9 @@ public class DocLibraryService { ...@@ -899,8 +784,9 @@ public class DocLibraryService {
tagInstanceModelList.forEach(tagInstanceModel -> { tagInstanceModelList.forEach(tagInstanceModel -> {
KnowledgeDocContentModel docContentModel = docContentModelMap.get(tagInstanceModel.getTargetSeq()); KnowledgeDocContentModel docContentModel = docContentModelMap.get(tagInstanceModel.getTargetSeq());
if (null != docContentModel) { if (null != docContentModel) {
boolean isDoc = Constants.MARKING_TYPE_DOC.equals(tagInstanceModel.getMarkingType()); boolean isDoc = TagInstanceService.MARKING_TYPE_DOC.equals(tagInstanceModel.getMarkingType());
List<KnowledgeTagInstanceModel> tagList = isDoc ? docContentModel.getDocTags() : docContentModel.getDocContentTags(); List<KnowledgeTagInstanceModel> tagList = isDoc ? docContentModel.getDocTags()
: docContentModel.getDocContentTags();
if (null == tagList) { if (null == tagList) {
tagList = new ArrayList<>(); tagList = new ArrayList<>();
if (isDoc) { if (isDoc) {
...@@ -979,7 +865,8 @@ public class DocLibraryService { ...@@ -979,7 +865,8 @@ public class DocLibraryService {
*/ */
public Map<String, Map<String, String>> getBaseEnumMap() { public Map<String, Map<String, String>> getBaseEnumMap() {
Map<String, Map<String, String>> resMap = new HashMap<>(); Map<String, Map<String, String>> resMap = new HashMap<>();
List<KnowledgeDynamicsOptionModel> optionModels = dynamicsOptionService.queryByFunctional(RequestContext.getAppKey(), DynamicsFunctional.DOC_BASEINFO.name()); List<KnowledgeDynamicsOptionModel> optionModels = dynamicsOptionService
.queryByFunctional(RequestContext.getAppKey(), DynamicsFunctional.DOC_BASEINFO.name());
for (KnowledgeDynamicsOptionModel optionModel : optionModels) { for (KnowledgeDynamicsOptionModel optionModel : optionModels) {
if ("Enum".equals(optionModel.getDataType())) { if ("Enum".equals(optionModel.getDataType())) {
String fieldName = optionModel.getFieldName(); String fieldName = optionModel.getFieldName();
...@@ -1013,13 +900,15 @@ public class DocLibraryService { ...@@ -1013,13 +900,15 @@ public class DocLibraryService {
int finishNmu = 0; int finishNmu = 0;
int current = 0; int current = 0;
while (count > finishNmu) { while (count > finishNmu) {
com.baomidou.mybatisplus.extension.plugins.pagination.Page page = new com.baomidou.mybatisplus.extension.plugins.pagination.Page(current++, 30); Page page = new Page(
current++, 30);
IPage resPage = docContentService.page(page); IPage resPage = docContentService.page(page);
List<KnowledgeDocContent> records = resPage.getRecords(); List<KnowledgeDocContent> records = resPage.getRecords();
records.forEach(doc -> { records.forEach(doc -> {
if (ValidationUtil.isEmpty(doc.getTextContent()) && ValidationUtil.isEmpty(doc.getSortStr())) { if (ValidationUtil.isEmpty(doc.getTextContent()) && ValidationUtil.isEmpty(doc.getSortStr())) {
doc.setTextContent(htmlContent2Text(doc.getHtmlContent())); doc.setTextContent(htmlContent2Text(doc.getHtmlContent()));
doc.setSortStr(DocSortUtil.getSortStr(tagInstanceService.queryByTargetAndType(null, doc.getSequenceNbr(), Constants.MARKING_TYPE_DOC))); doc.setSortStr(DocSortUtil.getSortStr(tagInstanceService.queryByTargetAndType(null,
doc.getSequenceNbr(), TagInstanceService.MARKING_TYPE_DOC)));
} }
}); });
docContentService.updateBatchById(records); docContentService.updateBatchById(records);
...@@ -1042,7 +931,8 @@ public class DocLibraryService { ...@@ -1042,7 +931,8 @@ public class DocLibraryService {
if (ValidationUtil.isEmpty(categoryModelList)) { if (ValidationUtil.isEmpty(categoryModelList)) {
return; return;
} }
Map<Object, KnowledgeDocCategoryModel> categoryModelMap = Bean.listToMap(categoryModelList, "sequenceNbr", KnowledgeDocCategoryModel.class); Map<Object, KnowledgeDocCategoryModel> categoryModelMap = Bean.listToMap(categoryModelList, "sequenceNbr",
KnowledgeDocCategoryModel.class);
docList.forEach(doc -> { docList.forEach(doc -> {
if (doc instanceof KnowledgeDocContentModel) { if (doc instanceof KnowledgeDocContentModel) {
KnowledgeDocContentModel doc1 = (KnowledgeDocContentModel) doc; KnowledgeDocContentModel doc1 = (KnowledgeDocContentModel) doc;
...@@ -1056,15 +946,34 @@ public class DocLibraryService { ...@@ -1056,15 +946,34 @@ public class DocLibraryService {
}); });
} }
public Page queryDocPage(Page page, String docTitle, String code) { public Page queryDocPage(Page page, String docTitle, String code, Long directoryId, String orgCode) {
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED); wrapper.eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED);
if (!ValidationUtil.isEmpty(docTitle)) { if (!ValidationUtil.isEmpty(docTitle)) {
wrapper.like("DOC_TITLE", docTitle); wrapper.like("DOC_TITLE", docTitle);
} }
if (!ValidationUtil.isEmpty(orgCode)) {
wrapper.like("ORG_CODE", orgCode);
}
if (!ValidationUtil.isEmpty(code)) { if (!ValidationUtil.isEmpty(code)) {
wrapper.inSql("SEQUENCE_NBR", "SELECT INSTANCE_ID FROM KNOWLEDGE_DYNAMICS_VALUE kdv WHERE kdv.FIELD_NAME = 'code' AND kdv.FIELD_VALUE LIKE '%" + code.replace("'", "''") + "%'"); wrapper.inSql("SEQUENCE_NBR",
"SELECT INSTANCE_ID FROM KNOWLEDGE_DYNAMICS_VALUE kdv WHERE kdv.FIELD_NAME = 'code' AND kdv.FIELD_VALUE LIKE '%"
+ code.replace("'", "''") + "%'");
}
if (!ValidationUtil.isEmpty(directoryId)) {
wrapper.and(e -> {
e.eq("DIRECTORY_ID", directoryId);
List<KnowledgeDocCategory> cList = docCategoryService
.list(new LambdaQueryWrapper<KnowledgeDocCategory>().eq(KnowledgeDocCategory::getParentId,
directoryId));
List<Long> ids = cList.stream().map(i -> i.getSequenceNbr()).collect(Collectors.toList());
if (ids.size() > 0) {
e.or().in("DIRECTORY_ID", ids);
}
});
} }
wrapper.orderByDesc("REC_DATE");
page = (Page) docContentService.page(page, wrapper); page = (Page) docContentService.page(page, wrapper);
if (!page.getRecords().isEmpty()) { if (!page.getRecords().isEmpty()) {
ArrayList list = Bean.toModels(page.getRecords(), KnowledgeDocContentModel.class); ArrayList list = Bean.toModels(page.getRecords(), KnowledgeDocContentModel.class);
...@@ -1076,20 +985,19 @@ public class DocLibraryService { ...@@ -1076,20 +985,19 @@ public class DocLibraryService {
public List selectByDirsRand(List<Long> directoryList, Integer total) { public List selectByDirsRand(List<Long> directoryList, Integer total) {
Set<Long> directoryIdSet = new HashSet<>(); Set<Long> directoryIdSet = new HashSet<>();
List<KnowledgeDocCategoryModel> categoryList = Bean.toModels(docCategoryService.list(), KnowledgeDocCategoryModel.class); List<KnowledgeDocCategoryModel> categoryList = Bean.toModels(docCategoryService.list(),
directoryList.forEach( KnowledgeDocCategoryModel.class);
directoryId -> { directoryList.forEach(directoryId -> {
directoryIdSet.addAll(BaseUtil.getModelIds(TreeUtil.getAllChildren(TreeBuilder.bulid(categoryList, directoryId)))); directoryIdSet.addAll(
if (!directoryId.equals(DocCategoryService.ROOT)) { BaseUtil.getModelIds(TreeUtil.getAllChildren(TreeBuilder.bulid(categoryList, directoryId))));
directoryIdSet.add(directoryId); if (!directoryId.equals(DocCategoryService.ROOT)) {
} directoryIdSet.add(directoryId);
} }
); });
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED) wrapper.eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED).in("DIRECTORY_ID", directoryIdSet);
.in("DIRECTORY_ID", directoryIdSet);
if (total != null) { if (total != null) {
wrapper.last("ORDER BY RAND() LIMIT "+ total); wrapper.last("ORDER BY RAND() LIMIT " + total);
} }
List<KnowledgeDocContent> contentList = docContentService.list(wrapper); List<KnowledgeDocContent> contentList = docContentService.list(wrapper);
List<KnowledgeDocContentModel> list = Bean.toModels(contentList, KnowledgeDocContentModel.class); List<KnowledgeDocContentModel> list = Bean.toModels(contentList, KnowledgeDocContentModel.class);
......
...@@ -4,7 +4,6 @@ package com.yeejoin.amos.knowledgebase.face.service; ...@@ -4,7 +4,6 @@ package com.yeejoin.amos.knowledgebase.face.service;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsGroupModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsGroupModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DynamicsGroupMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.DynamicsGroupMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsGroup; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
......
...@@ -5,13 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; ...@@ -5,13 +5,11 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional; import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName; import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName;
import com.yeejoin.amos.knowledgebase.face.enumeration.OptionDataType; import com.yeejoin.amos.knowledgebase.face.enumeration.OptionDataType;
import com.yeejoin.amos.knowledgebase.face.feign.DataFillter;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsOptionModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsOptionModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DynamicsValueMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.DynamicsValueMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsValue; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsValue;
import com.yeejoin.amos.knowledgebase.face.util.Constants; import com.yeejoin.amos.knowledgebase.face.util.DataFillter;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -26,6 +24,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService; ...@@ -26,6 +24,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
/** /**
...@@ -148,8 +147,8 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode ...@@ -148,8 +147,8 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode
} }
switch (knowledgeRoleName) { switch (knowledgeRoleName) {
case AUDITOR: case AUDITOR:
auditStatusSet.add(Constants.DOC_AUDIT_STATUS_PASSED); auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_PASSED);
auditStatusSet.add(Constants.DOC_AUDIT_STATUS_SUBMITTED); auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_SUBMITTED);
dataPrivilegemap.put(DataFillter.orgCode, orgCode); dataPrivilegemap.put(DataFillter.orgCode, orgCode);
dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()])); dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()]));
break; break;
...@@ -160,8 +159,8 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode ...@@ -160,8 +159,8 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode
dataPrivilegemap.put(DataFillter.noData, true); dataPrivilegemap.put(DataFillter.noData, true);
break; break;
case VIEWER: case VIEWER:
auditStatusSet.add(Constants.DOC_AUDIT_STATUS_PASSED); auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_PASSED);
docStatusSet.add(Constants.DOC_STATUS_PUBLISHED); docStatusSet.add(DocContentService.DOC_STATUS_PUBLISHED);
dataPrivilegemap.put(docStatus, docStatusSet.toArray(new String[docStatusSet.size()])); dataPrivilegemap.put(docStatus, docStatusSet.toArray(new String[docStatusSet.size()]));
dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()])); dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()]));
break; break;
...@@ -370,4 +369,15 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode ...@@ -370,4 +369,15 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode
public List<KnowledgeDynamicsValueModel> queryByInstanceIds(@Condition(Operator.in) Collection<Long> instanceId) { public List<KnowledgeDynamicsValueModel> queryByInstanceIds(@Condition(Operator.in) Collection<Long> instanceId) {
return this.queryForList("", false, instanceId); return this.queryForList("", false, instanceId);
} }
//查询文档发布时间是否为空
public List<KnowledgeDynamicsValue> isRequiredByFile(String appKey, String name, List<Long> docSeqList) {
String fineSeqs = docSeqList.stream().map(String::valueOf).collect(Collectors.joining(","));
QueryWrapper<KnowledgeDynamicsValue> wrapper = new QueryWrapper<>();
wrapper.inSql("OPTION_SEQ",
"SELECT kdo.SEQUENCE_NBR FROM `knowledge_dynamics_option` kdo WHERE kdo.FUNCTIONAL = '" + name + "' AND kdo.APP_KEY = '" + appKey + "' AND kdo.FRONT_END_CONFIG LIKE '%\"required\":true%'");
wrapper.and(wq -> wq.inSql("INSTANCE_ID", fineSeqs));
return this.list(wrapper);
}
} }
...@@ -3,7 +3,6 @@ package com.yeejoin.amos.knowledgebase.face.service; ...@@ -3,7 +3,6 @@ package com.yeejoin.amos.knowledgebase.face.service;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
...@@ -12,8 +11,7 @@ import com.yeejoin.amos.knowledgebase.face.orm.dao.ESDocRepository; ...@@ -12,8 +11,7 @@ import com.yeejoin.amos.knowledgebase.face.orm.dao.ESDocRepository;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity; import com.yeejoin.amos.knowledgebase.face.orm.entity.ESDocEntity;
import com.yeejoin.amos.knowledgebase.face.orm.entity.ESTagEntity; import com.yeejoin.amos.knowledgebase.face.orm.entity.ESTagEntity;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.util.Constants; import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders; import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder; import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
...@@ -73,7 +71,7 @@ public class ESDocService { ...@@ -73,7 +71,7 @@ public class ESDocService {
* @return Page对象 * @return Page对象
*/ */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public Page<ESDocEntity> findAll(int current, int size) { public Page<ESDocEntity> findAll(int current, int size) {
// 创建查询构造器 // 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder() NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// 分页 // 分页
...@@ -82,22 +80,18 @@ public class ESDocService { ...@@ -82,22 +80,18 @@ public class ESDocService {
.withSort(SortBuilders.fieldSort("sortStr.keyword").order(SortOrder.DESC)); .withSort(SortBuilders.fieldSort("sortStr.keyword").order(SortOrder.DESC));
List<ESDocEntity> list = new LinkedList<>(); List<ESDocEntity> list = new LinkedList<>();
try try {
{ SearchHits<ESDocEntity> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESDocEntity.class);
SearchHits<ESDocEntity> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESDocEntity.class);
for (SearchHit searchHit : searchHits.getSearchHits()) {
for (SearchHit searchHit : searchHits.getSearchHits()) ESDocEntity docEntity = (ESDocEntity) searchHit.getContent();
{ list.add(docEntity);
ESDocEntity docEntity = (ESDocEntity)searchHit.getContent(); }
list.add(docEntity);
} return new AggregatedPageImpl<>(list, PageRequest.of(current, size), searchHits.getTotalHits());
} catch (Exception e) {
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), searchHits.getTotalHits()); e.printStackTrace();
} }
catch (Exception e)
{
e.printStackTrace();
}
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), 0); return new AggregatedPageImpl<>(list, PageRequest.of(current, size), 0);
} }
...@@ -119,8 +113,8 @@ public class ESDocService { ...@@ -119,8 +113,8 @@ public class ESDocService {
* @param size 页面大小 * @param size 页面大小
* @return * @return
*/ */
@SuppressWarnings({ "rawtypes", "unchecked" }) @SuppressWarnings({"rawtypes", "unchecked"})
public Page<ESDocEntity> queryByKeys(String queryStr, int current, int size) { public Page<ESDocEntity> queryByKeys(String queryStr, int current, int size) {
List<String> keys = queryStr2List(queryStr); List<String> keys = queryStr2List(queryStr);
if (ValidationUtil.isEmpty(keys)) { if (ValidationUtil.isEmpty(keys)) {
return findAll(current, size); return findAll(current, size);
...@@ -128,88 +122,83 @@ public class ESDocService { ...@@ -128,88 +122,83 @@ public class ESDocService {
// 条件构造,多条件循环匹配 // 条件构造,多条件循环匹配
BoolQueryBuilder boolMust = QueryBuilders.boolQuery(); BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
for (String key : keys) { for (String key : keys) {
boolMust.must( boolMust.must(QueryBuilders.boolQuery().minimumShouldMatch(1)
QueryBuilders.boolQuery().minimumShouldMatch(1) .should(QueryBuilders.matchQuery("docTitle", key).boost(1f))
.should(QueryBuilders.matchPhraseQuery("docTitle", key)) .should(QueryBuilders.matchQuery("docInfo", key).boost(0.3f))
.should(QueryBuilders.matchPhraseQuery("docInfo", key)) .should(QueryBuilders.matchQuery("author", key).boost(0.3f))
.should(QueryBuilders.matchPhraseQuery("author", key)) .should(QueryBuilders.matchQuery("textContent", key).boost(0.5f))
.should(QueryBuilders.matchPhraseQuery("textContent", key)) .should(QueryBuilders.matchQuery("docTags.tagInfo", key).boost(0.8f))
.should(QueryBuilders.matchPhraseQuery("docTags.tagInfo", key)) .should(QueryBuilders.matchQuery("contentTags.tagInfo", key).boost(0.8f))
.should(QueryBuilders.matchPhraseQuery("contentTags.tagInfo", key))
); );
} }
// 创建查询构造器 // 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder() NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// 高亮字段 // 高亮字段
.withHighlightFields( .withHighlightFields(
new HighlightBuilder.Field("docTitle").preTags("").postTags("").numOfFragments(0), new HighlightBuilder.Field("docTitle").preTags("<em>").postTags("</em>").numOfFragments(0),
new HighlightBuilder.Field("textContent").preTags("").postTags("").numOfFragments(1).fragmentSize(200).noMatchSize(100).order("score"), new HighlightBuilder.Field("textContent").preTags("<em>").postTags("</em>").numOfFragments(1).fragmentSize(200).noMatchSize(100).order("score"),
new HighlightBuilder.Field("docTags.tagInfo").preTags("").postTags("").numOfFragments(0), new HighlightBuilder.Field("docTags.tagInfo").preTags("").postTags("").numOfFragments(0),
new HighlightBuilder.Field("contentTags.tagInfo").preTags("").postTags("").numOfFragments(0) new HighlightBuilder.Field("contentTags.tagInfo").preTags("").postTags("").numOfFragments(0)
) )
// 分页 // 分页
.withPageable(PageRequest.of(current, size)) .withPageable(PageRequest.of(current, size))
// 排序
.withSort(SortBuilders.fieldSort("sortStr.keyword").order(SortOrder.ASC))
//过滤条件 //过滤条件
.withQuery(boolMust); .withQuery(boolMust);
// 对高亮词条进行操作 // 对高亮词条进行操作
List<ESDocEntity> list = new ArrayList<>(); List<ESDocEntity> list = new ArrayList<>();
try try {
{ SearchHits<ESDocEntity> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESDocEntity.class);
SearchHits<ESDocEntity> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESDocEntity.class);
for (SearchHit searchHit : searchHits.getSearchHits()) {
for (SearchHit searchHit : searchHits.getSearchHits()) {
ESDocEntity docEntity = (ESDocEntity) searchHit.getContent();
ESDocEntity docEntity = (ESDocEntity)searchHit.getContent(); searchHit.getHighlightFields();
searchHit.getHighlightFields(); // 文档标题
// 文档标题 List<String> docTitle = searchHit.getHighlightField("docTitle");
List<String> docTitle = searchHit.getHighlightField("docTitle"); if (!ValidationUtil.isEmpty(docTitle)) {
if (!ValidationUtil.isEmpty(docTitle)) { StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder(); for (String fragment : docTitle) {
for (String fragment : docTitle) { sb.append(fragment);
sb.append(fragment); }
} docEntity.setDocTitle(sb.toString());
docEntity.setDocTitle(sb.toString()); }
} // 文档内容
// 文档内容 List<String> textContent = searchHit.getHighlightField("textContent");
List<String> textContent = searchHit.getHighlightField("textContent"); if (!ValidationUtil.isEmpty(textContent)) {
if (!ValidationUtil.isEmpty(textContent)) { StringBuilder sb = new StringBuilder();
StringBuilder sb = new StringBuilder(); for (String fragment : textContent) {
for (String fragment : textContent) { sb.append(fragment);
sb.append(fragment); }
} docEntity.setSummary(sb.toString());
docEntity.setSummary(sb.toString()); }
} Set<String> tagInfoSet = new HashSet<>();
Set<String> tagInfoSet = new HashSet<>(); // 文档标签
// 文档标签 List<String> docTagsInfo = searchHit.getHighlightField("docTags.tagInfo");
List<String> docTagsInfo = searchHit.getHighlightField("docTags.tagInfo"); if (!ValidationUtil.isEmpty(docTagsInfo)) {
if (!ValidationUtil.isEmpty(docTagsInfo)) { for (String fragment : docTagsInfo) {
for (String fragment : docTagsInfo) { tagInfoSet.add(fragment);
tagInfoSet.add(fragment); }
} }
} List<String> contentTagsInfo = searchHit.getHighlightField("contentTags.tagInfo");
List<String> contentTagsInfo = searchHit.getHighlightField("contentTags.tagInfo"); if (!ValidationUtil.isEmpty(contentTagsInfo)) {
if (!ValidationUtil.isEmpty(contentTagsInfo)) { for (String fragment : contentTagsInfo) {
for (String fragment : contentTagsInfo) { tagInfoSet.add(fragment);
tagInfoSet.add(fragment); }
} }
} // 删除不匹配的和重复的标签
// 删除不匹配的和重复的标签 deleteRepeatedTags(docEntity.getDocTags(), tagInfoSet);
deleteRepeatedTags(docEntity.getDocTags(), tagInfoSet); deleteRepeatedTags(docEntity.getContentTags(), tagInfoSet);
deleteRepeatedTags(docEntity.getContentTags(), tagInfoSet);
list.add(docEntity);
list.add(docEntity); }
}
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), searchHits.getTotalHits());
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), searchHits.getTotalHits()); } catch (Exception e) {
} return new AggregatedPageImpl<>(list, PageRequest.of(current, size), 0);
catch (Exception e) }
{
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), 0);
}
} }
/** /**
...@@ -238,14 +227,16 @@ public class ESDocService { ...@@ -238,14 +227,16 @@ public class ESDocService {
* @param tagInfoSet 命中的tagInfo * @param tagInfoSet 命中的tagInfo
*/ */
private static void deleteRepeatedTags(List<ESTagEntity> list, Set<String> tagInfoSet) { private static void deleteRepeatedTags(List<ESTagEntity> list, Set<String> tagInfoSet) {
Iterator<ESTagEntity> tagIterator = list.iterator(); if (!ValidationUtil.isEmpty(tagInfoSet)) {
while (tagIterator.hasNext()) { Iterator<ESTagEntity> tagIterator = list.iterator();
ESTagEntity tag = tagIterator.next(); while (tagIterator.hasNext()) {
if (tagInfoSet.contains(tag.getTagInfo())) { ESTagEntity tag = tagIterator.next();
tagInfoSet.remove(tag.getTagInfo()); if (tagInfoSet.contains(tag.getTagInfo())) {
tag.setTagInfo(null); tagInfoSet.remove(tag.getTagInfo());
} else { tag.setTagInfo(null);
tagIterator.remove(); } else {
tagIterator.remove();
}
} }
} }
} }
...@@ -307,7 +298,7 @@ public class ESDocService { ...@@ -307,7 +298,7 @@ public class ESDocService {
Map<String, Map<String, String>> enumCnEnMap = docLibraryService.getBaseEnumMap(); Map<String, Map<String, String>> enumCnEnMap = docLibraryService.getBaseEnumMap();
List<ESDocEntity> esDocs = new ArrayList<>(); List<ESDocEntity> esDocs = new ArrayList<>();
for (KnowledgeDocContentModel docDetail : docs) { for (KnowledgeDocContentModel docDetail : docs) {
if (ValidationUtil.equals(docDetail.getDocStatus(), Constants.DOC_STATUS_PUBLISHED)) { if (ValidationUtil.equals(docDetail.getDocStatus(), DocContentService.DOC_STATUS_PUBLISHED)) {
List<ESTagEntity> docTags = buildESTagsByInstanceList(docDetail.getDocTags()); List<ESTagEntity> docTags = buildESTagsByInstanceList(docDetail.getDocTags());
List<ESTagEntity> contentTags = buildESTagsByInstanceList(docDetail.getDocContentTags()); List<ESTagEntity> contentTags = buildESTagsByInstanceList(docDetail.getDocContentTags());
ESDocEntity esDocEntity = new ESDocEntity() ESDocEntity esDocEntity = new ESDocEntity()
...@@ -387,7 +378,7 @@ public class ESDocService { ...@@ -387,7 +378,7 @@ public class ESDocService {
private String getTagInfoStr(KnowledgeTagInstanceModel instanceModel) { private String getTagInfoStr(KnowledgeTagInstanceModel instanceModel) {
StringBuilder infoStr = new StringBuilder(); StringBuilder infoStr = new StringBuilder();
infoStr.append(instanceModel.getTagName()).append(" "); infoStr.append(instanceModel.getTagName()).append(" ");
if (Constants.TAG_TYPE_TEXT.equals(instanceModel.getTagType()) if (TagService.TAG_TYPE_TEXT.equals(instanceModel.getTagType())
|| ValidationUtil.isEmpty(instanceModel.getTagValues())) { || ValidationUtil.isEmpty(instanceModel.getTagValues())) {
return infoStr.toString().trim(); return infoStr.toString().trim();
} }
...@@ -395,7 +386,7 @@ public class ESDocService { ...@@ -395,7 +386,7 @@ public class ESDocService {
String fieldName = valueModel.getFieldName(); String fieldName = valueModel.getFieldName();
String tagValue = valueModel.getTagValue(); String tagValue = valueModel.getTagValue();
switch (fieldName) { switch (fieldName) {
case Constants.VALUE_TAG_FIELD_DATE_H: case TagValueService.VALUE_TAG_FIELD_DATE_H:
infoStr.append(tagValue).append(" "); infoStr.append(tagValue).append(" ");
try { try {
Date date = DateUtil.formatStringToDate(tagValue, null); Date date = DateUtil.formatStringToDate(tagValue, null);
...@@ -445,7 +436,7 @@ public class ESDocService { ...@@ -445,7 +436,7 @@ public class ESDocService {
esDocRepository.deleteAll(); esDocRepository.deleteAll();
//保存所有已发布文档 //保存所有已发布文档
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.eq("doc_status", Constants.DOC_STATUS_PUBLISHED); wrapper.eq("doc_status", DocContentService.DOC_STATUS_PUBLISHED);
int count = docContentService.count(wrapper); int count = docContentService.count(wrapper);
int finishNmu = 0; int finishNmu = 0;
int current = 0; int current = 0;
......
...@@ -6,19 +6,16 @@ import com.yeejoin.amos.knowledgebase.face.model.KnowledgeInteractionCountModel; ...@@ -6,19 +6,16 @@ import com.yeejoin.amos.knowledgebase.face.model.KnowledgeInteractionCountModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.InteractionCountMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.InteractionCountMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeInteractionCount; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeInteractionCount;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.exception.BaseException; import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Set;
/** /**
......
...@@ -4,12 +4,11 @@ package com.yeejoin.amos.knowledgebase.face.service; ...@@ -4,12 +4,11 @@ package com.yeejoin.amos.knowledgebase.face.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeMessageModel; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeMessageModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.MessageMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.MessageMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessage; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessage;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessagePersonal; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessagePersonal;
import com.yeejoin.amos.knowledgebase.face.util.Constants; import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import org.eclipse.paho.client.mqttv3.MqttException; import org.eclipse.paho.client.mqttv3.MqttException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
...@@ -36,7 +35,20 @@ import java.util.*; ...@@ -36,7 +35,20 @@ import java.util.*;
@Component @Component
public class MessageService extends BaseService<KnowledgeMessageModel, KnowledgeMessage, MessageMapper> { public class MessageService extends BaseService<KnowledgeMessageModel, KnowledgeMessage, MessageMapper> {
/**
* 消息类型-要点推送
*/
public static final String MESSAGE_TYPE_PUSH = "ESSENTIAL_PUSH";
/**
* 消息类型-战例分享
*/
public static final String MESSAGE_TYPE_SHARE = "DOC_SHARE";
/**
* 消息主题前缀
*/
public static final String TOPIC_PREFIX = "knowledge_message_";
public static final String SHARE_WAY_APP = "app";
private final String userTypeUser = "user"; private final String userTypeUser = "user";
private final String userTypeGroup = "group"; private final String userTypeGroup = "group";
...@@ -95,14 +107,14 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge ...@@ -95,14 +107,14 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge
*/ */
@Transactional(rollbackFor = {BaseException.class, Exception.class}) @Transactional(rollbackFor = {BaseException.class, Exception.class})
public boolean shareDoc(List<Map<String, Object>> users, List<Map<String, Object>> docs, String way) { public boolean shareDoc(List<Map<String, Object>> users, List<Map<String, Object>> docs, String way) {
if (ValidationUtil.equalsIgnoreCase(way, Constants.SHARE_WAY_APP)) { if (ValidationUtil.equalsIgnoreCase(way, SHARE_WAY_APP)) {
for (Map<String, Object> doc : docs) { for (Map<String, Object> doc : docs) {
//创建消息 //创建消息
if (ValidationUtil.isEmpty(doc) || ValidationUtil.isEmpty(doc.get("sequenceNbr"))) { if (ValidationUtil.isEmpty(doc) || ValidationUtil.isEmpty(doc.get("sequenceNbr"))) {
throw new BadRequest("分享内容缺失"); throw new BadRequest("分享内容缺失");
} }
String messageTitle = String.valueOf(doc.get("docTitle")); String messageTitle = String.valueOf(doc.get("docTitle"));
KnowledgeMessageModel message = createMessage(Constants.MESSAGE_TYPE_SHARE, Long.valueOf(doc.get("sequenceNbr").toString()), messageTitle, String.valueOf(doc.get("summary"))); KnowledgeMessageModel message = createMessage(MESSAGE_TYPE_SHARE, Long.valueOf(doc.get("sequenceNbr").toString()), messageTitle, String.valueOf(doc.get("summary")));
Set<String> userIdSet = new HashSet<>(); Set<String> userIdSet = new HashSet<>();
userIdSet = parseUserMapToIdList(users, userIdSet); userIdSet = parseUserMapToIdList(users, userIdSet);
//创建个人消息 //创建个人消息
...@@ -122,7 +134,7 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge ...@@ -122,7 +134,7 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge
@Transactional(rollbackFor = {BaseException.class, Exception.class}) @Transactional(rollbackFor = {BaseException.class, Exception.class})
public boolean pushEssential(List<Map<String, Object>> users, String messageTitle, String content, Long docSeq) { public boolean pushEssential(List<Map<String, Object>> users, String messageTitle, String content, Long docSeq) {
//创建消息 //创建消息
KnowledgeMessageModel message = createMessage(Constants.MESSAGE_TYPE_PUSH, docSeq, messageTitle, content); KnowledgeMessageModel message = createMessage(MESSAGE_TYPE_PUSH, docSeq, messageTitle, content);
Set<String> userIdSet = new HashSet<>(); Set<String> userIdSet = new HashSet<>();
userIdSet = parseUserMapToIdList(users, userIdSet); userIdSet = parseUserMapToIdList(users, userIdSet);
//创建个人消息 //创建个人消息
...@@ -239,7 +251,7 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge ...@@ -239,7 +251,7 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge
* 获取用户的主题 * 获取用户的主题
*/ */
private String getTopic(String userId) { private String getTopic(String userId) {
return Constants.TOPIC_PREFIX + String.valueOf(userId); return TOPIC_PREFIX + String.valueOf(userId);
} }
/** /**
......
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
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.ctc.wstx.util.StringUtil;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowlegeStatisticsRecordModel; import com.yeejoin.amos.knowledgebase.face.model.KnowlegeStatisticsRecordModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.StatisticsRecordMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.StatisticsRecordMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowlegeStatisticsRecord; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowlegeStatisticsRecord;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.exception.BaseException;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.DateUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
/** /**
* <p> * <p>
* 标签分组 服务类 * 标签分组 服务类
...@@ -37,219 +20,280 @@ import java.util.*; ...@@ -37,219 +20,280 @@ import java.util.*;
* @since 2020-08-05 * @since 2020-08-05
*/ */
@Component @Component
public class StatisticsRecordService public class StatisticsRecordService extends BaseService<KnowlegeStatisticsRecordModel, KnowlegeStatisticsRecord, StatisticsRecordMapper> {
extends BaseService<KnowlegeStatisticsRecordModel, KnowlegeStatisticsRecord, StatisticsRecordMapper> {
/*@Autowired
/* private DocContentService docContentService;
* @Autowired private DocContentService docContentService;
* private final Logger logger = LogManager.getLogger(StatisticsRecordService.class);
* private final Logger logger =
* LogManager.getLogger(StatisticsRecordService.class); *//**
* * 灾情标记
*//** *//*
* 灾情标记 public static final String TAG_NAME_TIME = "时间";
*/ public static final String STATISTICS_DISASTER_COUNT = "DISASTER_RECORD";
/*
* public static final String TAG_NAME_TIME = "时间"; public static final String *//**
* STATISTICS_DISASTER_COUNT = "DISASTER_RECORD"; * 燃烧物质分类
* *//*
*//** public static final String TAG_NAME_BURNING = "燃烧物质";
* 燃烧物质分类 public static final String STATISTICS_BURNING_CATEGORY = "BURNING_RECORD";
*/
/* *//**
* public static final String TAG_NAME_BURNING = "燃烧物质"; public static final * 参战车辆统计
* String STATISTICS_BURNING_CATEGORY = "BURNING_RECORD"; *//*
* public static final String TAG_NAME_POWER = "参战车辆";
*//** public static final String STATISTICS_POWER_SUM = "POWER_RECORD";
* 参战车辆统计
*/ *//**
/* * 伤亡人数统计
* public static final String TAG_NAME_POWER = "参战车辆"; public static final *//*
* String STATISTICS_POWER_SUM = "POWER_RECORD"; public static final String TAG_NAME_CASUALTIES = "人员伤亡情况 含亡人";
* public static final String STATISTICS_CASUALTIES_SUM = "CASUALTIES_RECORD";
*//**
* 伤亡人数统计 *//**
*/ * 灭火药剂统计
/* *//*
* public static final String TAG_NAME_CASUALTIES = "人员伤亡情况 含亡人"; public static public static final String TAG_NAME_EXTINGUISHING = "使用的灭火药剂数量";
* final String STATISTICS_CASUALTIES_SUM = "CASUALTIES_RECORD"; public static final String STATISTICS_EXTINGUISHING_SUM = "EXTINGUISHING_RECORD";
*
*//** *//**
* 灭火药剂统计 * 过火面积统计
*/ *//*
/* public static final String TAG_NAME_AREA = "过火面积";
* public static final String TAG_NAME_EXTINGUISHING = "使用的灭火药剂数量"; public public static final String STATISTICS_AREA_COUNT = "FIRE_AREA_RECORD";
* static final String STATISTICS_EXTINGUISHING_SUM = "EXTINGUISHING_RECORD";
* *//**
*//** * 到场时间分类
* 过火面积统计 *//*
*/ public static final String TAG_NAME_PICKUP = "接警时间";
/* public static final String TAG_NAME_PRESENT = "到场时间";
* public static final String TAG_NAME_AREA = "过火面积"; public static final String public static final String STATISTICS_PRESENT_CATEGORY = "PRESENT_TIME_RECORD";
* STATISTICS_AREA_COUNT = "FIRE_AREA_RECORD";
*
*//** public static final String DATE_GROUP_BY_DAY = "day";
* 到场时间分类 public static final String DATE_GROUP_BY_MONTH = "month";
*/
/* @Value("${diy-config.report.record-data}")
* public static final String TAG_NAME_PICKUP = "接警时间"; public static final private boolean needRecord;
* String TAG_NAME_PRESENT = "到场时间"; public static final String
* STATISTICS_PRESENT_CATEGORY = "PRESENT_TIME_RECORD"; *//** 根据文档标签添加对应的记录 *//*
* private void addRecordWithDocValueTag(List<KnowledgeTagInstanceModel> docTags, Long docSeq) {
* //找出预定义的所有标签
* public static final String DATE_GROUP_BY_DAY = "day"; public static final Map<Object, KnowledgeTagInstanceModel> tagMap = Bean.listToMap(docTags, "tagName", KnowledgeTagInstanceModel.class);
* String DATE_GROUP_BY_MONTH = "month"; KnowledgeTagInstanceModel tagTime = tagMap.get(TAG_NAME_TIME);
* if (ValidationUtil.isEmpty(tagTime)) {
* @Value("${diy-config.report.record-data}") private boolean needRecord; return;
* }
*//** 根据文档标签添加对应的记录 */ Object timeObj = getValueFromTag(tagTime);
/* if (ValidationUtil.isEmpty(timeObj) || !(timeObj instanceof Date)) {
* private void addRecordWithDocValueTag(List<KnowledgeTagInstanceModel> return;
* docTags, Long docSeq) { //找出预定义的所有标签 Map<Object, KnowledgeTagInstanceModel> }
* tagMap = Bean.listToMap(docTags, "tagName", KnowledgeTagInstanceModel.class); Date disasterTime = (Date) timeObj;
* KnowledgeTagInstanceModel tagTime = tagMap.get(TAG_NAME_TIME); if //记录灾情
* (ValidationUtil.isEmpty(tagTime)) { return; } Object timeObj = insertSumTypeRecord(docSeq, disasterTime, STATISTICS_DISASTER_COUNT, 1.0, 1);
* getValueFromTag(tagTime); if (ValidationUtil.isEmpty(timeObj) || !(timeObj //记录燃烧物质
* instanceof Date)) { return; } Date disasterTime = (Date) timeObj; //记录灾情 KnowledgeTagInstanceModel tagBurning = tagMap.get(TAG_NAME_BURNING);
* insertSumTypeRecord(docSeq, disasterTime, STATISTICS_DISASTER_COUNT, 1.0, 1); if (!ValidationUtil.isEmpty(tagBurning)) {
* //记录燃烧物质 KnowledgeTagInstanceModel tagBurning = tagMap.get(TAG_NAME_BURNING); insertCategoryTypeRecord(docSeq, disasterTime, STATISTICS_BURNING_CATEGORY, getValueFromTag(tagBurning));
* if (!ValidationUtil.isEmpty(tagBurning)) { insertCategoryTypeRecord(docSeq, }
* disasterTime, STATISTICS_BURNING_CATEGORY, getValueFromTag(tagBurning)); } //记录参战车辆
* //记录参战车辆 KnowledgeTagInstanceModel tagPower = tagMap.get(TAG_NAME_POWER); if KnowledgeTagInstanceModel tagPower = tagMap.get(TAG_NAME_POWER);
* (!ValidationUtil.isEmpty(tagPower)) { insertSumTypeRecord(docSeq, if (!ValidationUtil.isEmpty(tagPower)) {
* disasterTime, STATISTICS_POWER_SUM, getValueFromTag(tagPower), 1); } //记录伤亡人数 insertSumTypeRecord(docSeq, disasterTime, STATISTICS_POWER_SUM, getValueFromTag(tagPower), 1);
* KnowledgeTagInstanceModel tagCasualties = tagMap.get(TAG_NAME_CASUALTIES); if }
* (!ValidationUtil.isEmpty(tagCasualties)) { insertSumTypeRecord(docSeq, //记录伤亡人数
* disasterTime, STATISTICS_CASUALTIES_SUM, getValueFromTag(tagCasualties), 1); KnowledgeTagInstanceModel tagCasualties = tagMap.get(TAG_NAME_CASUALTIES);
* } //记录灭火药剂数量 KnowledgeTagInstanceModel tagExtinguishing = if (!ValidationUtil.isEmpty(tagCasualties)) {
* tagMap.get(TAG_NAME_EXTINGUISHING); if insertSumTypeRecord(docSeq, disasterTime, STATISTICS_CASUALTIES_SUM, getValueFromTag(tagCasualties), 1);
* (!ValidationUtil.isEmpty(tagExtinguishing)) { insertSumTypeRecord(docSeq, }
* disasterTime, STATISTICS_EXTINGUISHING_SUM, //记录灭火药剂数量
* getValueFromTag(tagExtinguishing), 1); } //记录过火面积 KnowledgeTagInstanceModel KnowledgeTagInstanceModel tagExtinguishing = tagMap.get(TAG_NAME_EXTINGUISHING);
* tagArea = tagMap.get(TAG_NAME_AREA); if (!ValidationUtil.isEmpty(tagArea)) { if (!ValidationUtil.isEmpty(tagExtinguishing)) {
* insertSumTypeRecord(docSeq, disasterTime, STATISTICS_AREA_COUNT, insertSumTypeRecord(docSeq, disasterTime, STATISTICS_EXTINGUISHING_SUM, getValueFromTag(tagExtinguishing), 1);
* getValueFromTag(tagArea), 1); } //记录到场时间 KnowledgeTagInstanceModel tagPickup }
* = tagMap.get(TAG_NAME_PICKUP); KnowledgeTagInstanceModel tagPresent = //记录过火面积
* tagMap.get(TAG_NAME_PRESENT); if (!ValidationUtil.isEmpty(tagPickup) && KnowledgeTagInstanceModel tagArea = tagMap.get(TAG_NAME_AREA);
* !ValidationUtil.isEmpty(tagPresent)) { Object pickTimeObj = if (!ValidationUtil.isEmpty(tagArea)) {
* getValueFromTag(tagPickup); Object presentTimeObj = insertSumTypeRecord(docSeq, disasterTime, STATISTICS_AREA_COUNT, getValueFromTag(tagArea), 1);
* getValueFromTag(tagPresent); if (!ValidationUtil.isEmpty(pickTimeObj) && }
* pickTimeObj instanceof Date && !ValidationUtil.isEmpty(presentTimeObj) && //记录到场时间
* presentTimeObj instanceof Date) { long presentTimeByMinute = (long) KnowledgeTagInstanceModel tagPickup = tagMap.get(TAG_NAME_PICKUP);
* Math.ceil((((Date) presentTimeObj).getTime() - ((Date) KnowledgeTagInstanceModel tagPresent = tagMap.get(TAG_NAME_PRESENT);
* pickTimeObj).getTime()) / 1000.0 / 60.0); insertCategoryTypeRecord(docSeq, if (!ValidationUtil.isEmpty(tagPickup) && !ValidationUtil.isEmpty(tagPresent)) {
* disasterTime, STATISTICS_PRESENT_CATEGORY, presentTimeByMinute); } } } Object pickTimeObj = getValueFromTag(tagPickup);
* Object presentTimeObj = getValueFromTag(tagPresent);
*//** 获取标签值 */ if (!ValidationUtil.isEmpty(pickTimeObj) && pickTimeObj instanceof Date
/* && !ValidationUtil.isEmpty(presentTimeObj) && presentTimeObj instanceof Date) {
* private Object getValueFromTag(KnowledgeTagInstanceModel tag) { if long presentTimeByMinute = (long) Math.ceil((((Date) presentTimeObj).getTime() - ((Date) pickTimeObj).getTime()) / 1000.0 / 60.0);
* (ValidationUtil.isEmpty(tag) || !ValidationUtil.equals(tag.getTagType(), insertCategoryTypeRecord(docSeq, disasterTime, STATISTICS_PRESENT_CATEGORY, presentTimeByMinute);
* TagService.TAG_TYPE_VALUE) || ValidationUtil.isEmpty(tag.getTagValues())) { }
* return null; } String fieldName = tag.getTagValues().get(0).getFieldName(); }
* String tagValue = tag.getTagValues().get(0).getTagValue(); if }
* (ValidationUtil.isEmpty(fieldName) || ValidationUtil.isEmpty(tagValue)) {
* return null; } switch (fieldName) { case *//** 获取标签值 *//*
* TagValueService.VALUE_TAG_FIELD_DATE_H: try { return private Object getValueFromTag(KnowledgeTagInstanceModel tag) {
* DateUtil.formatStringToDate(tagValue, null); } catch (Exception e) { if (ValidationUtil.isEmpty(tag)
* logger.error("报表统计:时间格式标签值解析出错"); return null; } case || !ValidationUtil.equals(tag.getTagType(), TagService.TAG_TYPE_VALUE)
* TagValueService.VALUE_TAG_FIELD_SINGLEVALUE: try { return || ValidationUtil.isEmpty(tag.getTagValues())) {
* Double.parseDouble(tagValue); } catch (Exception e) { return null;
* logger.error("报表统计:数字格式标签值解析出错"); return null; } case }
* TagValueService.VALUE_TAG_FIELD_TEXT: return tagValue; default: return null; String fieldName = tag.getTagValues().get(0).getFieldName();
* } } String tagValue = tag.getTagValues().get(0).getTagValue();
* if (ValidationUtil.isEmpty(fieldName)
*//** 插入分类统计记录 */ || ValidationUtil.isEmpty(tagValue)) {
/* return null;
* private void insertCategoryTypeRecord(Long docSeq, Date disasterTime, String }
* recordName, Object category) { KnowlegeStatisticsRecordModel recordModel = switch (fieldName) {
* new KnowlegeStatisticsRecordModel(); recordModel.setDocSeq(docSeq); case TagValueService.VALUE_TAG_FIELD_DATE_H:
* recordModel.setDisasterTime(disasterTime); try {
* recordModel.setRecordName(recordName); return DateUtil.formatStringToDate(tagValue, null);
* recordModel.setCategoryValue(String.valueOf(category)); } catch (Exception e) {
* recordModel.setValueWeight(1); recordModel.setCountValue(1L); logger.error("报表统计:时间格式标签值解析出错");
* this.createWithModel(recordModel); } return null;
* }
* case TagValueService.VALUE_TAG_FIELD_SINGLEVALUE:
*//** 插入数量统计记录 */ try {
/* return Double.parseDouble(tagValue);
* private void insertSumTypeRecord(Long docSeq, Date disasterTime, String } catch (Exception e) {
* recordName, Object numObj, Integer weight) { if logger.error("报表统计:数字格式标签值解析出错");
* (!ValidationUtil.isEmpty(numObj) && numObj instanceof Double) { Long num = return null;
* ((Double) numObj).longValue(); KnowlegeStatisticsRecordModel recordModel = }
* new KnowlegeStatisticsRecordModel(); recordModel.setDocSeq(docSeq); case TagValueService.VALUE_TAG_FIELD_TEXT:
* recordModel.setDisasterTime(disasterTime); return tagValue;
* recordModel.setRecordName(recordName); recordModel.setCountValue(num); default:
* recordModel.setValueWeight(weight); this.createWithModel(recordModel); } } return null;
* }
*//** }
* 根据文档id删除相关记录
*/ *//** 插入分类统计记录 *//*
/* private void insertCategoryTypeRecord(Long docSeq, Date disasterTime, String recordName, Object category) {
* public void deleteRecordsByDocIds(List<KnowledgeDocContentModel> docs) { if KnowlegeStatisticsRecordModel recordModel = new KnowlegeStatisticsRecordModel();
* (!ValidationUtil.isEmpty(docs)) { Set ids = Bean.listToMap(docs, recordModel.setDocSeq(docSeq);
* "sequenceNbr", KnowledgeDocContentModel.class).keySet(); recordModel.setDisasterTime(disasterTime);
* QueryWrapper<KnowlegeStatisticsRecord> wrapper = new QueryWrapper<>(); recordModel.setRecordName(recordName);
* wrapper.in("doc_seq", ids); this.getBaseMapper().delete(wrapper); } } recordModel.setCategoryValue(String.valueOf(category));
* recordModel.setValueWeight(1);
*//** recordModel.setCountValue(1L);
* 初始化统计数据记录 this.createWithModel(recordModel);
* }
* @return
*/
/* *//** 插入数量统计记录 *//*
* @Transactional(rollbackFor = {Exception.class, BaseException.class}) public private void insertSumTypeRecord(Long docSeq, Date disasterTime, String recordName, Object numObj, Integer weight) {
* boolean init() { this.getBaseMapper().deleteAll(); //扫描所有已发布文档相关的统计型标签 if (!ValidationUtil.isEmpty(numObj) && numObj instanceof Double) {
* QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>(); Long num = ((Double) numObj).longValue();
* wrapper.eq("doc_status", DocContentService.DOC_STATUS_PUBLISHED); int count = KnowlegeStatisticsRecordModel recordModel = new KnowlegeStatisticsRecordModel();
* docContentService.count(wrapper); int finishNmu = 0; int current = 0; while recordModel.setDocSeq(docSeq);
* (count > finishNmu) { Page page = new Page(current++, 30); IPage resPage = recordModel.setDisasterTime(disasterTime);
* docContentService.page(page, wrapper); List<KnowledgeDocContent> records = recordModel.setRecordName(recordName);
* resPage.getRecords(); Set ids = Bean.listToMap(records, "sequenceNbr", recordModel.setCountValue(num);
* KnowledgeDocContent.class).keySet(); saveRecordsByDocIds(ids); finishNmu += recordModel.setValueWeight(weight);
* records.size(); } return true; } this.createWithModel(recordModel);
* }
* public boolean addDocRecords(List<KnowledgeDocContentModel> docs) { if }
* (!ValidationUtil.isEmpty(docs)) { Set ids = Bean.listToMap(docs,
* "sequenceNbr", KnowledgeDocContentModel.class).keySet(); *//**
* saveRecordsByDocIds(ids); } return true; } * 根据文档id删除相关记录
* *//*
* private void saveRecordsByDocIds(Collection ids) { if (!needRecord) { return; public void deleteRecordsByDocIds(List<KnowledgeDocContentModel> docs) {
* } for (Object id : ids) { KnowledgeDocContentModel docContentModel = if (!ValidationUtil.isEmpty(docs)) {
* docContentService.queryOneDocDetail((Long) id); if Set ids = Bean.listToMap(docs, "sequenceNbr", KnowledgeDocContentModel.class).keySet();
* (ValidationUtil.isEmpty(docContentModel)) { continue; } QueryWrapper<KnowlegeStatisticsRecord> wrapper = new QueryWrapper<>();
* addRecordWithDocValueTag(docContentModel.getDocTags(), wrapper.in("doc_seq", ids);
* docContentModel.getSequenceNbr()); } } this.getBaseMapper().delete(wrapper);
* }
*//** }
* 查询灾情统计/同比/环比
* *//**
* @return * 初始化统计数据记录
*/ *
/* * @return
* public Map<String, Object> selectDisasterCount() { return *//*
* this.getBaseMapper().selectDisasterCount(); } @Transactional(rollbackFor = {Exception.class, BaseException.class})
* public boolean init() {
* public List<Map<String, Object>> selectCategoryByName(String recordName) { this.getBaseMapper().deleteAll();
* return this.getBaseMapper().selectCategoryByName(recordName); } //扫描所有已发布文档相关的统计型标签
* QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
*//** wrapper.eq("doc_status", DocContentService.DOC_STATUS_PUBLISHED);
* 分类汇总 int count = docContentService.count(wrapper);
*//* int finishNmu = 0;
* public List<Map<String, Object>> selectCountByTypeAndDateRange(String int current = 0;
* dateType, String dateRangeLeft, String dateRangeRight, String recordName) { while (count > finishNmu) {
* Map<String, Object> queryMap = new HashMap<>(); switch (dateType) { case Page page = new Page(current++, 30);
* DATE_GROUP_BY_MONTH: queryMap.put("format", "%Y-%m"); break; default: IPage resPage = docContentService.page(page, wrapper);
* queryMap.put("format", "%Y-%m-%d"); break; } List<KnowledgeDocContent> records = resPage.getRecords();
* if(!ValidationUtil.isEmpty(dateRangeLeft)){ try { Set ids = Bean.listToMap(records, "sequenceNbr", KnowledgeDocContent.class).keySet();
* queryMap.put("dateRangeLeft", DateUtil.formatStringToDate(dateRangeLeft, saveRecordsByDocIds(ids);
* null)); } catch (Exception e) { throw new BadRequest("时间参数格式有误"); } } finishNmu += records.size();
* if(!ValidationUtil.isEmpty(dateRangeRight)){ try { }
* queryMap.put("dateRangeRight", DateUtil.formatStringToDate(dateRangeRight, return true;
* null)); } catch (Exception e) { throw new BadRequest("时间参数格式有误"); } } }
* queryMap.put("recordName", recordName); return
* this.getBaseMapper().selectCountByNameAndDateRange(queryMap); } public boolean addDocRecords(List<KnowledgeDocContentModel> docs) {
*/ if (!ValidationUtil.isEmpty(docs)) {
Set ids = Bean.listToMap(docs, "sequenceNbr", KnowledgeDocContentModel.class).keySet();
saveRecordsByDocIds(ids);
}
return true;
}
private void saveRecordsByDocIds(Collection ids) {
if (!needRecord) {
return;
}
for (Object id : ids) {
KnowledgeDocContentModel docContentModel = docContentService.queryOneDocDetail((Long) id);
if (ValidationUtil.isEmpty(docContentModel)) {
continue;
}
addRecordWithDocValueTag(docContentModel.getDocTags(), docContentModel.getSequenceNbr());
}
}
*//**
* 查询灾情统计/同比/环比
*
* @return
*//*
public Map<String, Object> selectDisasterCount() {
return this.getBaseMapper().selectDisasterCount();
}
public List<Map<String, Object>> selectCategoryByName(String recordName) {
return this.getBaseMapper().selectCategoryByName(recordName);
}
*//**
* 分类汇总
*//*
public List<Map<String, Object>> selectCountByTypeAndDateRange(String dateType, String dateRangeLeft, String dateRangeRight, String recordName) {
Map<String, Object> queryMap = new HashMap<>();
switch (dateType) {
case DATE_GROUP_BY_MONTH:
queryMap.put("format", "%Y-%m");
break;
default:
queryMap.put("format", "%Y-%m-%d");
break;
}
if(!ValidationUtil.isEmpty(dateRangeLeft)){
try {
queryMap.put("dateRangeLeft", DateUtil.formatStringToDate(dateRangeLeft, null));
} catch (Exception e) {
throw new BadRequest("时间参数格式有误");
}
}
if(!ValidationUtil.isEmpty(dateRangeRight)){
try {
queryMap.put("dateRangeRight", DateUtil.formatStringToDate(dateRangeRight, null));
} catch (Exception e) {
throw new BadRequest("时间参数格式有误");
}
}
queryMap.put("recordName", recordName);
return this.getBaseMapper().selectCountByNameAndDateRange(queryMap);
}*/
public Map<String, Object> tagStatistics(String tag, Date startDate, Date endDate, String mode) { public Map<String, Object> tagStatistics(String tag, Date startDate, Date endDate, String mode) {
endDate = getLastDayOfMonth(endDate); endDate = getLastDayOfMonth(endDate);
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
......
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import java.util.ArrayList; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import java.util.Collection; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel;
import java.util.List; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
import java.util.Map; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.TagInstanceMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagInstance;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
...@@ -15,14 +17,10 @@ import org.typroject.tyboot.core.rdbms.annotation.Condition; ...@@ -15,14 +17,10 @@ import org.typroject.tyboot.core.rdbms.annotation.Condition;
import org.typroject.tyboot.core.rdbms.annotation.Operator; import org.typroject.tyboot.core.rdbms.annotation.Operator;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import java.util.ArrayList;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel; import java.util.Collection;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel; import java.util.List;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagModel; import java.util.Map;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.TagInstanceMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagInstance;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
/** /**
...@@ -36,6 +34,10 @@ import com.yeejoin.amos.knowledgebase.face.util.Constants; ...@@ -36,6 +34,10 @@ import com.yeejoin.amos.knowledgebase.face.util.Constants;
@Component @Component
public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, KnowledgeTagInstance, TagInstanceMapper> { public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, KnowledgeTagInstance, TagInstanceMapper> {
public static final String MARKING_TYPE_DOC = "DOC"; // 标记类型--文档标签
public static final String MARKING_TYPE_CONTENT = "CONTENT";// 标记类型--内容标签
@Autowired @Autowired
private TagValueService tagValueService; private TagValueService tagValueService;
...@@ -72,11 +74,11 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K ...@@ -72,11 +74,11 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K
instanceModel.setTagType(tagModel.getTagType()); instanceModel.setTagType(tagModel.getTagType());
//值标签保存标签的具体值 //值标签保存标签的具体值
List<KnowledgeTagValueModel> valueModels = instanceModel.getTagValues(); List<KnowledgeTagValueModel> valueModels = instanceModel.getTagValues();
if (Constants.TAG_TYPE_VALUE.equals(tagModel.getTagType()) && !ValidationUtil.isEmpty(valueModels)) { if (TagService.TAG_TYPE_VALUE.equals(tagModel.getTagType()) && !ValidationUtil.isEmpty(valueModels)) {
List<KnowledgeDynamicsValueModel> valueTagConfigs = dynamicsValueService.queryByInstanceId(tagModel.getSequenceNbr()); List<KnowledgeDynamicsValueModel> valueTagConfigs = dynamicsValueService.queryByInstanceId(tagModel.getSequenceNbr());
Map<String,Object> valueTagConfigMap = Bean.listToMap(valueTagConfigs,"fieldName","fieldValue",KnowledgeDynamicsValueModel.class); Map<String, Object> valueTagConfigMap = Bean.listToMap(valueTagConfigs, "fieldName", "fieldValue", KnowledgeDynamicsValueModel.class);
String unit = String.valueOf(valueTagConfigMap.get("unit")); String unit = String.valueOf(valueTagConfigMap.get("unit"));
List<KnowledgeTagValueModel> savedValues = this.tagValueService.saveInstanceValue(instanceSeq, valueModels,unit); List<KnowledgeTagValueModel> savedValues = this.tagValueService.saveInstanceValue(instanceSeq, valueModels, unit);
instanceModel.setTagValues(savedValues); instanceModel.setTagValues(savedValues);
} }
this.createWithModel(instanceModel); this.createWithModel(instanceModel);
...@@ -111,7 +113,9 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K ...@@ -111,7 +113,9 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K
// return this.queryCount(tagSeq, targetSeq); // return this.queryCount(tagSeq, targetSeq);
// } // }
/** 根据标签ID统计标签实例数量 */ /**
* 根据标签ID统计标签实例数量
*/
public int queryCountByTagSeq(Long tagSeq) { public int queryCountByTagSeq(Long tagSeq) {
return this.queryCount(tagSeq); return this.queryCount(tagSeq);
} }
...@@ -136,10 +140,10 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K ...@@ -136,10 +140,10 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K
public List<KnowledgeTagInstanceModel> queryByTargetAndType(String agencyCode, Long targetSeq, String markingType) { public List<KnowledgeTagInstanceModel> queryByTargetAndType(String agencyCode, Long targetSeq, String markingType) {
List<KnowledgeTagInstanceModel> instanceModels = this.queryForList(null, false, agencyCode, targetSeq,markingType); List<KnowledgeTagInstanceModel> instanceModels = this.queryForList(null, false, agencyCode, targetSeq, markingType);
if (!ValidationUtil.isEmpty(instanceModels)) { if (!ValidationUtil.isEmpty(instanceModels)) {
for (KnowledgeTagInstanceModel instanceModel : instanceModels) { for (KnowledgeTagInstanceModel instanceModel : instanceModels) {
if (Constants.TAG_TYPE_VALUE.equals(instanceModel.getTagType())) { if (TagService.TAG_TYPE_VALUE.equals(instanceModel.getTagType())) {
List<KnowledgeTagValueModel> list = this.tagValueService.queryByInstance(instanceModel.getSequenceNbr()); List<KnowledgeTagValueModel> list = this.tagValueService.queryByInstance(instanceModel.getSequenceNbr());
instanceModel.setTagValues(list); instanceModel.setTagValues(list);
} }
...@@ -156,15 +160,7 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K ...@@ -156,15 +160,7 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K
return this.queryForList(null, false, targetSeq); return this.queryForList(null, false, targetSeq);
} }
public List<KnowledgeTagInstanceModel> queryTopTagListByUser(String recUserId) {
public KnowledgeTagInstance findById(Long id) { return this.queryForList("REC_DATE", true, recUserId);
return this.baseMapper.selectById(id); }
}
public List<KnowledgeTagInstanceModel> queryListByTagName(String tagName) {
// TODO Auto-generated method stub
return this.queryForList(null, false, tagName);
}
} }
...@@ -3,15 +3,14 @@ package com.yeejoin.amos.knowledgebase.face.service; ...@@ -3,15 +3,14 @@ package com.yeejoin.amos.knowledgebase.face.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Sequence; import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional; import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.*; import com.yeejoin.amos.knowledgebase.face.model.*;
import com.yeejoin.amos.knowledgebase.face.orm.dao.TagMapper; import com.yeejoin.amos.knowledgebase.face.orm.dao.TagMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTag;
import com.yeejoin.amos.knowledgebase.face.util.ConfigLoader; import com.yeejoin.amos.knowledgebase.face.util.ConfigLoader;
import com.yeejoin.amos.knowledgebase.face.util.Constants; import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -27,7 +26,10 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest; ...@@ -27,7 +26,10 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.exception.instance.DataNotFound; import org.typroject.tyboot.core.restful.exception.instance.DataNotFound;
import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden; import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden;
import java.io.Serializable;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/** /**
...@@ -41,6 +43,27 @@ import java.util.*; ...@@ -41,6 +43,27 @@ import java.util.*;
@Component @Component
public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, TagMapper> { public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, TagMapper> {
/**
* 标签状态-激活
*/
public static final String TAG_STATUS_ACTIVATE = "ACTIVATED";
/**
* 标签状态-禁用
*/
public static final String TAG_STATUS_DEACTIVATE = "DEACTIVATED";
/**
* 标签类型-文本标签
*/
public static final String TAG_TYPE_TEXT = "TEXT_TAG";
/**
* 标签类型-值标签
*/
public static final String TAG_TYPE_VALUE = "VALUE_TAG";
public static final String APPKEY_ALL = "ALL";
@Autowired @Autowired
private TagGroupService tagGroupService; private TagGroupService tagGroupService;
@Autowired @Autowired
...@@ -73,7 +96,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -73,7 +96,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
} }
Long sequenceNbr = sequence.nextId(); Long sequenceNbr = sequence.nextId();
model.setSequenceNbr(sequenceNbr); model.setSequenceNbr(sequenceNbr);
model.setTagStatus(Constants.TAG_STATUS_ACTIVATE); model.setTagStatus(TAG_STATUS_DEACTIVATE);
model.setAgencyCode(RequestContext.getAgencyCode()); model.setAgencyCode(RequestContext.getAgencyCode());
model.setCreator(RequestContext.getExeUserId()); model.setCreator(RequestContext.getExeUserId());
//创建标签-分组关联关系 //创建标签-分组关联关系
...@@ -101,7 +124,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -101,7 +124,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
throw new BadRequest("标签名称不可重复"); throw new BadRequest("标签名称不可重复");
} }
//判断标签状态 //判断标签状态
if (ValidationUtil.equals(oldTagModel.getTagStatus(), Constants.TAG_STATUS_ACTIVATE)) { if (ValidationUtil.equals(oldTagModel.getTagStatus(), TAG_STATUS_ACTIVATE)) {
throw new BadRequest("启用状态的标签不允许编辑"); throw new BadRequest("启用状态的标签不允许编辑");
} }
Long sequenceNbr = oldTagModel.getSequenceNbr(); Long sequenceNbr = oldTagModel.getSequenceNbr();
...@@ -115,12 +138,12 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -115,12 +138,12 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
} }
private void restoreDynamicsValues(Long sequenceNbr, KnowledgeTagModel model) { private void restoreDynamicsValues(Long sequenceNbr, KnowledgeTagModel model) {
if (ValidationUtil.equals(Constants.TAG_TYPE_VALUE, model.getTagType())) { if (ValidationUtil.equals(TAG_TYPE_VALUE, model.getTagType())) {
Map<String, Object> tagValues = model.getTagValues(); Map<String, Object> tagValues = model.getTagValues();
if (!ValidationUtil.isEmpty(tagValues)) { if (!ValidationUtil.isEmpty(tagValues)) {
dynamicsValueService.saveValueList(tagValues, sequenceNbr, dynamicsValueService.saveValueList(tagValues, sequenceNbr,
DynamicsFunctional.VALUE_TAG_CONFIG, DynamicsFunctional.VALUE_TAG_CONFIG,
Constants.APPKEY_ALL); APPKEY_ALL);
} }
} }
} }
...@@ -161,7 +184,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -161,7 +184,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
* @param tagName 标签名称 * @param tagName 标签名称
* @param tagCode 标签代码 * @param tagCode 标签代码
* @param tagStatus 标签状态 * @param tagStatus 标签状态
* @return Map<首字母String , 列表List> * @return Map<首字母String, 列表List>
*/ */
public Map<String, List<KnowledgeTagModel>> queryTagMap(Long groupSeq, String tagName, String tagCode, String tagStatus) { public Map<String, List<KnowledgeTagModel>> queryTagMap(Long groupSeq, String tagName, String tagCode, String tagStatus) {
Map<String, List<KnowledgeTagModel>> resMap = new TreeMap<>(); Map<String, List<KnowledgeTagModel>> resMap = new TreeMap<>();
...@@ -240,7 +263,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -240,7 +263,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
tagIdList = StringUtil.String2LongList(tags); tagIdList = StringUtil.String2LongList(tags);
} }
for (KnowledgeTagModel tagModel : tagModels) { for (KnowledgeTagModel tagModel : tagModels) {
if (ValidationUtil.equals(tagModel.getTagStatus(), Constants.TAG_STATUS_ACTIVATE)) { if (ValidationUtil.equals(tagModel.getTagStatus(), TAG_STATUS_ACTIVATE)) {
throw new RequestForbidden("包含启用状态的标签,不允许删除"); throw new RequestForbidden("包含启用状态的标签,不允许删除");
} }
if (tagIsQuoted(tagModel.getSequenceNbr())) { if (tagIsQuoted(tagModel.getSequenceNbr())) {
...@@ -360,26 +383,41 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -360,26 +383,41 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
*/ */
public List<KnowledgeTagModel> queryTopList(boolean isAll) { public List<KnowledgeTagModel> queryTopList(boolean isAll) {
List<KnowledgeTagModel> res = new LinkedList<>(); List<KnowledgeTagModel> res = new LinkedList<>();
String operateType = isAll ? InteractionCountService.QUOTE_TYPE_ALL : InteractionCountService.QUOTE_TYPE_PUBLISH; List<? extends Serializable> tagSeqsCollect = new ArrayList<>();
List<KnowledgeInteractionCountModel> countModels = interactionCountService.queryTop(15, operateType, InteractionCountService.QUOTE_ENTITY_TAG, RequestContext.getAgencyCode()); List<KnowledgeTagModel> knowledgeTagTopList = new ArrayList<>();
for (KnowledgeInteractionCountModel countModel : countModels) { //查询标签实例表,查询当前用户常用的标签
if (countModel.getOperateCount() > 0) { List<KnowledgeTagInstanceModel> knowledgeTagInstanceModels = tagInstanceService.queryTopTagListByUser(RequestContext.getExeUserId());
KnowledgeTagModel tagModel = this.queryBySeq(Long.valueOf(countModel.getEntityId())); List<Long> tagSeqsByInstance = knowledgeTagInstanceModels.stream().map(KnowledgeTagInstanceModel::getTagSeq).collect(Collectors.toList());
if (!ValidationUtil.isEmpty(tagModel)) { if (ValidationUtil.isEmpty(tagSeqsByInstance) || tagSeqsByInstance.size() < 15) {
res.add(tagModel); //查询标签使用统计表,查询当前机构常用的标签
} String operateType = isAll ? InteractionCountService.QUOTE_TYPE_ALL : InteractionCountService.QUOTE_TYPE_PUBLISH;
} else { List<KnowledgeInteractionCountModel> countModels = interactionCountService.queryTop(15, operateType, InteractionCountService.QUOTE_ENTITY_TAG, RequestContext.getAgencyCode());
break; countModels = countModels.stream().filter(x -> x.getOperateCount() > 0).collect(Collectors.toList());
} List<String> tagSeqsByCount = countModels.stream().map(KnowledgeInteractionCountModel::getEntityId).collect(Collectors.toList());
tagSeqsCollect = Stream.of(tagSeqsByInstance, tagSeqsByCount).flatMap(Collection::stream).distinct().collect(Collectors.toList());
} }
for (KnowledgeTagModel tagModel : res) { if (!ValidationUtil.isEmpty(tagSeqsCollect)) {
tagAddDynamicsValues(tagModel); knowledgeTagTopList = this.queryByIds((Collection<Long>) tagSeqsCollect);
}
if (knowledgeTagTopList.size() < 15) {
//查询标签表
List<KnowledgeTagModel> knowledgeTagList = this.queryForPage(new Page(0, 15 - tagSeqsCollect.size()), "", false).getRecords();
knowledgeTagTopList.addAll(knowledgeTagList);
//去重
res = knowledgeTagTopList.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(KnowledgeTagModel::getSequenceNbr))), ArrayList::new));
} }
if (!ValidationUtil.isEmpty(res)) {
res = res.size() < 15 ? res : res.subList(0, 15);
for (KnowledgeTagModel tagModel : res) {
tagAddDynamicsValues(tagModel);
}
}
return res; return res;
} }
public List<KnowledgeTagModel> queryTagDetailList(String tagName) { public List<KnowledgeTagModel> queryTagDetailList(String tagName) {
List<KnowledgeTag> tagList = queryTagListWithGroup(null, tagName, null, Constants.TAG_STATUS_ACTIVATE); List<KnowledgeTag> tagList = queryTagListWithGroup(null, tagName, null, TAG_STATUS_ACTIVATE);
List<KnowledgeTagModel> res = new ArrayList<>(); List<KnowledgeTagModel> res = new ArrayList<>();
for (KnowledgeTag tag : tagList) { for (KnowledgeTag tag : tagList) {
KnowledgeTagModel tagModel = new KnowledgeTagModel(); KnowledgeTagModel tagModel = new KnowledgeTagModel();
...@@ -393,7 +431,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -393,7 +431,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
} }
private void tagAddDynamicsValues(KnowledgeTagModel tagModel) { private void tagAddDynamicsValues(KnowledgeTagModel tagModel) {
if (ValidationUtil.equals(Constants.TAG_TYPE_VALUE, tagModel.getTagType())) { if (ValidationUtil.equals(TAG_TYPE_VALUE, tagModel.getTagType())) {
List<KnowledgeDynamicsValueModel> valueModels = dynamicsValueService.queryByInstanceId(tagModel.getSequenceNbr()); List<KnowledgeDynamicsValueModel> valueModels = dynamicsValueService.queryByInstanceId(tagModel.getSequenceNbr());
if (!ValidationUtil.isEmpty(valueModels)) { if (!ValidationUtil.isEmpty(valueModels)) {
Map fieldsMap = Bean.listToMap(valueModels, "fieldName", KnowledgeDynamicsValueModel.class); Map fieldsMap = Bean.listToMap(valueModels, "fieldName", KnowledgeDynamicsValueModel.class);
...@@ -417,7 +455,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag ...@@ -417,7 +455,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
throw new BadRequest("参数有误"); throw new BadRequest("参数有误");
} }
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>() QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>()
.eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED) .eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED)
.inSql("SEQUENCE_NBR", "SELECT DISTINCT TARGET_SEQ FROM knowledge_tag_instance WHERE TAG_SEQ = " + sequenceNbr); .inSql("SEQUENCE_NBR", "SELECT DISTINCT TARGET_SEQ FROM knowledge_tag_instance WHERE TAG_SEQ = " + sequenceNbr);
return docContentService.list(wrapper); return docContentService.list(wrapper);
} }
......
package com.yeejoin.amos.knowledgebase.face.service; package com.yeejoin.amos.knowledgebase.face.service;
import java.util.Arrays; import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import java.util.Collection; import com.yeejoin.amos.knowledgebase.face.orm.dao.TagValueMapper;
import java.util.List; import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
...@@ -13,13 +12,8 @@ import org.typroject.tyboot.core.foundation.utils.Bean; ...@@ -13,13 +12,8 @@ import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import com.baomidou.mybatisplus.core.conditions.Wrapper; import java.util.Collection;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import java.util.List;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.TagValueMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeTagValue;
import net.bytebuddy.asm.Advice.This;
/** /**
...@@ -33,6 +27,15 @@ import net.bytebuddy.asm.Advice.This; ...@@ -33,6 +27,15 @@ import net.bytebuddy.asm.Advice.This;
@Component @Component
public class TagValueService extends BaseService<KnowledgeTagValueModel, KnowledgeTagValue, TagValueMapper> { public class TagValueService extends BaseService<KnowledgeTagValueModel, KnowledgeTagValue, TagValueMapper> {
public static final String VALUE_TAG_FIELD_SINGLEVALUE = "singleValue";//单值字段名
public static final String VALUE_TAG_FIELD_RANGE_MAX = "rangeMax";//范围值 上界
public static final String VALUE_TAG_FIELD_RANGE_MIN = "rangeMin";//范围值 下界
public static final String VALUE_TAG_FIELD_TEXT = "text";//文本值
public static final String VALUE_TAG_FIELD_DATE_H = "dateH";//时间,年月日时分秒
public static final String VALUE_TAG_FIELD_ENUM_NAME = "enumName";// 枚举类型字段名
@Transactional(rollbackFor = {Exception.class, BaseException.class}) @Transactional(rollbackFor = {Exception.class, BaseException.class})
public List<KnowledgeTagValueModel> saveInstanceValue(Long instanceSeq, List<KnowledgeTagValueModel> valueModels, String unit) { public List<KnowledgeTagValueModel> saveInstanceValue(Long instanceSeq, List<KnowledgeTagValueModel> valueModels, String unit) {
...@@ -71,13 +74,4 @@ public class TagValueService extends BaseService<KnowledgeTagValueModel, Knowled ...@@ -71,13 +74,4 @@ public class TagValueService extends BaseService<KnowledgeTagValueModel, Knowled
public List<KnowledgeTagValueModel> queryTagValuesByDocIds(Collection<Long> docSeqList) { public List<KnowledgeTagValueModel> queryTagValuesByDocIds(Collection<Long> docSeqList) {
return Bean.toModels(this.getBaseMapper().queryTagValuesByDocIds(docSeqList), KnowledgeTagValueModel.class); return Bean.toModels(this.getBaseMapper().queryTagValuesByDocIds(docSeqList), KnowledgeTagValueModel.class);
} }
public List<KnowledgeTagValue> getAllTegartValue(String value) {
String[] strings = value.split(",");
QueryWrapper<KnowledgeTagValue> wrapper = new QueryWrapper<KnowledgeTagValue>();
wrapper.eq("AGENCY_CODE", RequestContext.getAgencyCode());
wrapper.in("TAG_VALUE", Arrays.asList(strings));
return this.baseMapper.selectList(wrapper);
}
} }
...@@ -21,6 +21,29 @@ ...@@ -21,6 +21,29 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<!-- 解析excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<!-- 针对2007以上版本的库 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<!-- 针对2003版本的库 -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>fr.opensagres.xdocreport</groupId>
<artifactId>fr.opensagres.poi.xwpf.converter.xhtml</artifactId>
<version>2.0.2</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
...@@ -332,7 +332,7 @@ public class TzsAppService { ...@@ -332,7 +332,7 @@ public class TzsAppService {
JSONObject object = JSON.parseObject(JSON.toJSONString(obj)); JSONObject object = JSON.parseObject(JSON.toJSONString(obj));
if (!ValidationUtil.isEmpty(object)) { if (!ValidationUtil.isEmpty(object)) {
object.getString("url"); object.getString("url");
object.put("url", minioPath + object.getString("url")); object.put("url",object.getString("url"));
json.add(object); json.add(object);
} }
} }
...@@ -378,7 +378,7 @@ public class TzsAppService { ...@@ -378,7 +378,7 @@ public class TzsAppService {
Map<String, String> map = date.getResult(); Map<String, String> map = date.getResult();
Iterator<String> it = map.keySet().iterator(); Iterator<String> it = map.keySet().iterator();
String urlString = it.next(); String urlString = it.next();
jsonObject.put("fileUrl", minioPath + urlString); jsonObject.put("fileUrl", urlString);
jsonObject.put("fileName", code); jsonObject.put("fileName", code);
} }
} catch (IOException e) { } catch (IOException e) {
......
...@@ -21,6 +21,7 @@ import org.elasticsearch.index.query.QueryBuilders; ...@@ -21,6 +21,7 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder; import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
...@@ -47,6 +48,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -47,6 +48,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Autowired @Autowired
CylinderFillingRecordMapper cylinderFillingRecordMapper; CylinderFillingRecordMapper cylinderFillingRecordMapper;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
/** /**
* 分页查询 * 分页查询
*/ */
...@@ -178,7 +185,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin ...@@ -178,7 +185,7 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
Page<ESCylinderFillingRecordDto> result = new Page<ESCylinderFillingRecordDto>(pageNum, pageSize); Page<ESCylinderFillingRecordDto> result = new Page<ESCylinderFillingRecordDto>(pageNum, pageSize);
RestHighLevelClient esClient = new RestHighLevelClient( RestHighLevelClient esClient = new RestHighLevelClient(
RestClient.builder(new HttpHost("36.46.151.113", 9200, "http")) RestClient.builder(new HttpHost(esAddress, esPort, "http"))
); );
SearchRequest request = new SearchRequest(); SearchRequest request = new SearchRequest();
......
...@@ -129,6 +129,12 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -129,6 +129,12 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}") @Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId; private String cylPackageId;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Autowired @Autowired
StartPlatformTokenService startPlatformTokenService; StartPlatformTokenService startPlatformTokenService;
...@@ -711,7 +717,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind ...@@ -711,7 +717,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize); Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
RestHighLevelClient esClient = new RestHighLevelClient( RestHighLevelClient esClient = new RestHighLevelClient(
RestClient.builder(new HttpHost("36.46.151.113", 9200, "http")) RestClient.builder(new HttpHost(esAddress, esPort, "http"))
); );
SearchRequest request = new SearchRequest(); SearchRequest request = new SearchRequest();
......
...@@ -39,6 +39,7 @@ eureka.instance.metadata-map.management.api-docs=http://172.16.3.34:${server.por ...@@ -39,6 +39,7 @@ eureka.instance.metadata-map.management.api-docs=http://172.16.3.34:${server.por
eureka.instance.ip-address = 172.16.3.34 eureka.instance.ip-address = 172.16.3.34
## ES properties: ## ES properties:
biz.elasticsearch.port=9200
biz.elasticsearch.address=36.46.151.113 biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=docker-cluster spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300 spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
......
...@@ -294,7 +294,7 @@ ...@@ -294,7 +294,7 @@
<repository> <repository>
<id>Releases</id> <id>Releases</id>
<name>Releases</name> <name>Releases</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/releases/</url> <url>http://113.142.68.105:8081/nexus/content/repositories/releases/</url>
</repository> </repository>
<repository> <repository>
<id>com.e-iceblue</id> <id>com.e-iceblue</id>
...@@ -305,13 +305,13 @@ ...@@ -305,13 +305,13 @@
<repository> <repository>
<id>Snapshots</id> <id>Snapshots</id>
<name>Snapshots</name> <name>Snapshots</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/snapshots/</url> <url>http://113.142.68.105:8081/nexus/content/repositories/snapshots/</url>
</repository> </repository>
<repository> <repository>
<id>thirdparty</id> <id>thirdparty</id>
<name>thirdparty</name> <name>thirdparty</name>
<url>http://36.46.149.14:8081/nexus/content/repositories/thirdparty/</url> <url>http://113.142.68.105:8081/nexus/content/repositories/thirdparty/</url>
</repository> </repository>
</repositories> </repositories>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment