Commit f998e1c2 authored by caotao's avatar caotao

知识库代码提交

parent 5167791c
......@@ -21,6 +21,10 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</dependency>
<!-- 规则模块 -->
<dependency>
<groupId>com.yeejoin</groupId>
......@@ -74,20 +78,28 @@
<artifactId>html2pdf</artifactId>
<version>2.0.1</version>
</dependency>
<!-- 解析excel -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-elasticsearch</artifactId>
</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>
</project>
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import org.apache.ibatis.annotations.Param;
......@@ -9,7 +10,7 @@ import java.util.Map;
/**
* <p>
* 知识库文档存储 Mapper 接口
* 知识库文档存储 Mapper 接口
* </p>
*
* @author 子杨
......@@ -18,18 +19,24 @@ import java.util.Map;
public interface DocContentMapper extends BaseMapper<KnowledgeDocContent> {
List<Map<String,Long>> searchForDocIds(@Param("agencyCode") String agencyCode,
@Param("queryStr") String queryStr,
@Param("docStatus")String []docStatus,
@Param("auditStatus")String [] auditStatus,
@Param("userId")String userId,
@Param("orgCode")String orgCode,
@Param("offset") long offset,
@Param("length") long length);
List<Map<String, Long>> searchForDocIds(
@Param("agencyCode") String agencyCode,
@Param("queryStr") String queryStr,
@Param("docStatus") String[] docStatus,
@Param("auditStatus") String[] auditStatus,
@Param("userId") String userId,
@Param("orgCode") String orgCode,
@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);
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;
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;
public interface ESDocRepository extends ElasticsearchCrudRepository<ESDocEntity, Long> {
......
......@@ -2,7 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
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.Map;
......@@ -37,5 +39,21 @@ public interface StatisticsRecordMapper extends BaseMapper<KnowlegeStatisticsRec
* 按类型查询/按时间分段总计
*/
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;
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 org.apache.ibatis.annotations.Param;
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import java.util.Date;
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -2,9 +2,9 @@ package com.yeejoin.amos.knowledgebase.face.orm.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
/**
* <p>
......
......@@ -24,6 +24,29 @@
</exclusion>
</exclusions>
</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>
</project>
//package com.yeejoin.amos.knowledgebase.config;
//
//import com.baomidou.mybatisplus.core.toolkit.Sequence;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//
///**
// * @author 杨博超
// * @ClassName Config
// * @Deacription TODO
// **/
//@Configuration
//public class Config {
//
// @Bean
// public Sequence sequence() {
// return new Sequence();
// }
//}
package com.yeejoin.amos.knowledgebase.config;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* @author 杨博超
* @ClassName Config
* @Deacription TODO
**/
@Configuration
public class Config {
@Bean
public Sequence sequence() {
return new Sequence();
}
}
......@@ -2,12 +2,7 @@ package com.yeejoin.amos.knowledgebase.config;
import org.apache.commons.lang3.StringUtils;
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.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.nio.client.HttpAsyncClientBuilder;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
......@@ -21,31 +16,17 @@ public class ElasticSearchClientConfig {
@Value("${spring.elasticsearch.rest.uris}")
private String uris;
@Value("${elasticsearch.username}")
private String username;
@Value("${elasticsearch.password}")
private String password;
@Bean
@Qualifier("highLevelClient")
public RestHighLevelClient restHighLevelClient() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
try {
String url = uris.replace("http://", "");
final String[] parts = StringUtils.split(url, ":");
HttpHost httpHost = new HttpHost(parts[0], Integer.parseInt(parts[1]), "http");
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() {
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
@Override
......
......@@ -34,6 +34,7 @@ import java.util.List;
public class DocAnnotateResource {
private final Logger logger = LogManager.getLogger(DocAnnotateResource.class);
@Autowired
private DocAnnotateService docAnnotateService;
......
......@@ -86,7 +86,7 @@ public class DocCategoryResource {
return ResponseHelper.buildResponse(docCategoryService.queryForKnowledgeDocCategoryList(parentId));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(value = "文档分类树查询")
@RequestMapping(value = "/tree", method = RequestMethod.GET)
public ResponseModel<Collection<KnowledgeDocCategoryModel>> docCategoryTree() {
......
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.service.DocCommentsService;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.logging.log4j.LogManager;
......@@ -11,11 +10,11 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
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.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......
package com.yeejoin.amos.knowledgebase.controller;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
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.web.bind.annotation.PathVariable;
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.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
......@@ -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.ResponseModel;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocContentModel;
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 javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;
/**
* <p>
......@@ -129,7 +121,7 @@ public class DocContentResource {
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@ApiOperation(value = "查询单个文档内容信息")
@RequestMapping(value = "/{sequenceNbr}", method = RequestMethod.GET)
public ResponseModel<KnowledgeDocContentModel> seleteOne(@PathVariable("sequenceNbr") Long sequenceNbr) {
......@@ -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)
@ApiOperation(value = "分页查询文档信息")
@RequestMapping(value = "/page", method = RequestMethod.GET)
......@@ -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)
@ApiOperation(value = "文档被点赞/吐槽状态")
@RequestMapping(value = "/{sequenceNbr}/statistics/likes", method = RequestMethod.GET)
......@@ -227,12 +163,5 @@ public class DocContentResource {
@PathVariable(value = "sequenceNbr") Long 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;
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.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.web.bind.annotation.PathVariable;
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.bind.annotation.*;
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.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
......@@ -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.ResponseModel;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.knowledgebase.face.service.DocLibraryService;
import com.yeejoin.amos.knowledgebase.face.service.ESDocService;
import com.yeejoin.amos.knowledgebase.face.util.Constants;
import com.yeejoin.amos.knowledgebase.face.util.excel.ExcelImportConfig;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import java.io.IOException;
import java.util.List;
import java.util.Map;
/**
* <p>
......@@ -51,6 +48,8 @@ public class DocLibraryResource {
@Autowired
private DocLibraryService docLibraryService;
@Autowired
private DocContentService docContentService;
/**
* 下拉式查询文档信息
......@@ -66,21 +65,35 @@ public class DocLibraryResource {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "下拉式查询文档信息")
@RequestMapping(value = "/page", method = RequestMethod.GET)
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) {
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) {
Map requestMap = request.getParameterMap();
Page page = docLibraryService.queryDocList(offset, end, directoryId, docTitle, null, Constants.DOC_STATUS_PUBLISHED,
requestMap, createTimeLeft, createTimeRight, Boolean.parseBoolean(filterByCollection), false);
Page page = docLibraryService.queryDocList(offset, end, directoryId, docTitle, null, DocContentService.DOC_STATUS_PUBLISHED, requestMap, createTimeLeft, createTimeRight, Boolean.parseBoolean(filterByCollection), false);
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
......@@ -122,8 +135,7 @@ public class DocLibraryResource {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "搜索联想")
@RequestMapping(value = "/associate", method = RequestMethod.GET)
public ResponseModel worldAssociate(
@RequestParam(value = "queryStr") String queryStr) {
public ResponseModel worldAssociate(@RequestParam(value = "queryStr") String queryStr) {
if (ValidationUtil.isEmpty(queryStr)) {
queryStr = "";
}
......@@ -177,57 +189,35 @@ public class DocLibraryResource {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "根据文档标题和标签名称查询文档")
@RequestMapping(value = "/es/query", method = RequestMethod.GET)
public ResponseModel filter(@RequestParam(value = "queryStr", required = false) String queryStr,
@RequestParam(value = "current", defaultValue = "0") int current,
@RequestParam(value = "size", defaultValue = "10") int size) {
public ResponseModel filter(@RequestParam(value = "queryStr", required = false) String queryStr, @RequestParam(value = "current", defaultValue = "0") int current, @RequestParam(value = "size", defaultValue = "10") int size) {
return ResponseHelper.buildResponse(eSDocService.queryByKeys(queryStr, current, size));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "高级检索")
@RequestMapping(value = "/query/advanced", method = RequestMethod.POST)
public ResponseModel searchAdvanced(@RequestBody Map<String, Object> condition,
@RequestParam(value = "current", defaultValue = "0") int current,
@RequestParam(value = "size", defaultValue = "10") int size) {
public ResponseModel searchAdvanced(@RequestBody Map<String, Object> condition, @RequestParam(value = "current", defaultValue = "0") int current, @RequestParam(value = "size", defaultValue = "10") int 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)
@ApiOperation(value = "根据文档标题和标签名称查询文档-APP")
@RequestMapping(value = "/es/query1", method = RequestMethod.GET)
public ResponseModel filter1(@RequestParam(value = "queryStr", required = false) String queryStr,
@RequestParam(value = "current", defaultValue = "0") int current,
@RequestParam(value = "size", defaultValue = "10") int size) {
public ResponseModel filter1(@RequestParam(value = "queryStr", required = false) String queryStr, @RequestParam(value = "current", defaultValue = "0") int current, @RequestParam(value = "size", defaultValue = "10") int size) {
return ResponseHelper.buildResponse(eSDocService.queryAndDetail(queryStr, current, size));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "导出为word文档")
@RequestMapping(value = "/export/{id}/{type}", method = RequestMethod.GET)
public void export(@PathVariable(value = "id") Long id,
@PathVariable(value = "type") String type,
HttpServletResponse response) {
public void export(@PathVariable(value = "id") Long id, @PathVariable(value = "type") String type, HttpServletResponse response) {
if (ValidationUtil.isEmpty(type)) {
throw new BadRequest("参数有误");
}
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)
@ApiOperation(value = "导入excel文档")
@RequestMapping(value = "/import", method = RequestMethod.POST)
......@@ -241,4 +231,19 @@ public class DocLibraryResource {
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;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
......@@ -51,10 +50,12 @@ public class DocOuterResource {
public ResponseModel<Page> queryDocPage(@RequestParam(value = "current") Integer current,
@RequestParam(value = "size") Integer size,
@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);
return ResponseHelper.buildResponse(docLibraryService.queryDocPage(page, docTitle, code));
return ResponseHelper.buildResponse(docLibraryService.queryDocPage(page, docTitle, code,directoryId,orgCode));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
......
package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.service.StatisticsRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.Date;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -15,125 +10,86 @@ 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.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.ResponseModel;
import java.util.Date;
import java.util.List;
@RestController
@TycloudResource(module = "knowledgebase", value = "docstatistics")
//@TycloudResource(module = "knowledgebase", value = "docstatistics")
@RequestMapping(value = "/v1/doccontent/docstatistics")
@Api(tags = "knowledgebase-文档统计报表")
//@Api(tags = "knowledgebase-文档统计报表")
public class DocStatisticsResource {
@Autowired
private StatisticsRecordService statisticsRecordService;
/*
* @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
*
* @ApiOperation(value = "耗时* 刷新统计数据")
*
* @RequestMapping(value = "/record/init", method = RequestMethod.PUT) public
* ResponseModel init() { return
* ResponseHelper.buildResponse(statisticsRecordService.init()); }
*
*
* @TycloudOperation(ApiLevel = UserType.AGENCY)
*
* @ApiOperation(value = "灾情统计")
*
* @RequestMapping(value = "/count/disaster", method = RequestMethod.GET) public
* ResponseModel selectDisasterCount() { return
* ResponseHelper.buildResponse(statisticsRecordService.selectDisasterCount());
* }
*
* @TycloudOperation(ApiLevel = UserType.AGENCY)
*
* @ApiOperation(value = "燃烧物质统计分类")
*
* @RequestMapping(value = "/count/burning", method = RequestMethod.GET) public
* ResponseModel selectBurningCategory() { return
* ResponseHelper.buildResponse(statisticsRecordService.selectCategoryByName(
* StatisticsRecordService.STATISTICS_BURNING_CATEGORY)); }
*
* @TycloudOperation(ApiLevel = UserType.AGENCY)
*
* @ApiOperation(value = "到场时间统计分类")
*
* @RequestMapping(value = "/count/present", method = RequestMethod.GET) public
* ResponseModel selectPresentCategory() { return
* ResponseHelper.buildResponse(statisticsRecordService.selectCategoryByName(
* StatisticsRecordService.STATISTICS_PRESENT_CATEGORY)); }
*
* @TycloudOperation(ApiLevel = UserType.AGENCY)
*
* @ApiOperation(value = "伤亡人数趋势统计")
*
* @RequestMapping(value = "/count/casualties", method = RequestMethod.GET)
* public ResponseModel selectCasualtiesSum(@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_CASUALTIES_SUM)); }
*
* @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)); }
*/
@Autowired
private StatisticsRecordService statisticsRecordService;
/*@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "耗时* 刷新统计数据")
@RequestMapping(value = "/record/init", method = RequestMethod.PUT)
public ResponseModel init() {
return ResponseHelper.buildResponse(statisticsRecordService.init());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "灾情统计")
@RequestMapping(value = "/count/disaster", method = RequestMethod.GET)
public ResponseModel selectDisasterCount() {
return ResponseHelper.buildResponse(statisticsRecordService.selectDisasterCount());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "燃烧物质统计分类")
@RequestMapping(value = "/count/burning", method = RequestMethod.GET)
public ResponseModel selectBurningCategory() {
return ResponseHelper.buildResponse(statisticsRecordService.selectCategoryByName(StatisticsRecordService.STATISTICS_BURNING_CATEGORY));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "到场时间统计分类")
@RequestMapping(value = "/count/present", method = RequestMethod.GET)
public ResponseModel selectPresentCategory() {
return ResponseHelper.buildResponse(statisticsRecordService.selectCategoryByName(StatisticsRecordService.STATISTICS_PRESENT_CATEGORY));
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "伤亡人数趋势统计")
@RequestMapping(value = "/count/casualties", method = RequestMethod.GET)
public ResponseModel selectCasualtiesSum(@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_CASUALTIES_SUM));
}
@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, needAuth = false)
@ApiOperation(value = "标签总数统计")
@RequestMapping(value = "/tag/statistics", method = RequestMethod.GET)
......
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.yeejoin.amos.knowledgebase.face.service.MessageService;
import io.swagger.annotations.Api;
......@@ -42,7 +40,7 @@ public class MessageResource {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "查询用户的消息列表.")
@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)) {
messageType = null;
}
......@@ -129,7 +127,7 @@ public class MessageResource {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "分页查询查询用户的消息列表.")
@RequestMapping(value = "/list/page", method = RequestMethod.GET)
public ResponseModel<Page> list(
public ResponseModel<Page> listPage(
@RequestParam(value = "current", required = true) int current,
@RequestParam(value = "size", required = true) int size,
@RequestParam(value = "messageType", required = false) String messageType) {
......
......@@ -2,8 +2,6 @@ package com.yeejoin.amos.knowledgebase.controller;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagGroupModel;
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.ApiOperation;
import org.apache.logging.log4j.LogManager;
......@@ -11,10 +9,10 @@ import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
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.restful.doc.TycloudOperation;
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.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......
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.Logger;
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.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.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.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>
......@@ -41,25 +27,4 @@ public class TagInstanceResource {
private final Logger logger = LogManager.getLogger(TagInstanceResource.class);
@Autowired
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;
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.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
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.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.StringUtil;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
......@@ -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.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>
* 标签库 前端控制器
......@@ -107,7 +99,7 @@ public class TagResource {
@ApiOperation(value = "查询TOP15")
@RequestMapping(value = "/list/top", method = RequestMethod.GET)
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));
}
......@@ -123,14 +115,14 @@ public class TagResource {
@ApiOperation(value = "启用标签")
@RequestMapping(value = "status/activate/{ids}", method = RequestMethod.PUT)
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)
@ApiOperation(value = "停用标签")
@RequestMapping(value = "status/deactivate/{ids}", method = RequestMethod.PUT)
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)
......
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.Logger;
import org.springframework.beans.factory.annotation.Autowired;
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.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.ResponseModel;
import com.yeejoin.amos.knowledgebase.face.service.TagValueService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
/**
* <p>
......@@ -36,17 +27,5 @@ public class TagValueResource {
private final Logger logger = LogManager.getLogger(TagValueResource.class);
@Autowired
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;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Collection;
......
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.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
......
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
......
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
* 知识库系统动态选项配置的实例值
......
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
* 知识库内容交互计数表
......
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
* 知识库内容交互记录
......
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.EqualsAndHashCode;
import org.typroject.tyboot.core.foundation.utils.TreeNode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.Collection;
......
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.List;
......
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import java.util.List;
import java.util.Map;
......
package com.yeejoin.amos.knowledgebase.face.model;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
/**
* <p>
* 值标签的实例值
......
package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import org.apache.ibatis.annotations.Param;
......@@ -9,7 +10,7 @@ import java.util.Map;
/**
* <p>
* 知识库文档存储 Mapper 接口
* 知识库文档存储 Mapper 接口
* </p>
*
* @author 子杨
......@@ -18,18 +19,24 @@ import java.util.Map;
public interface DocContentMapper extends BaseMapper<KnowledgeDocContent> {
List<Map<String,Long>> searchForDocIds(@Param("agencyCode") String agencyCode,
@Param("queryStr") String queryStr,
@Param("docStatus")String []docStatus,
@Param("auditStatus")String [] auditStatus,
@Param("userId")String userId,
@Param("orgCode")String orgCode,
@Param("offset") long offset,
@Param("length") long length);
List<Map<String, Long>> searchForDocIds(
@Param("agencyCode") String agencyCode,
@Param("queryStr") String queryStr,
@Param("docStatus") String[] docStatus,
@Param("auditStatus") String[] auditStatus,
@Param("userId") String userId,
@Param("orgCode") String orgCode,
@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);
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;
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;
public interface ESDocRepository extends ElasticsearchCrudRepository<ESDocEntity, Long> {
......
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.knowledgebase.face.orm.dao;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowlegeStatisticsRecord;
import org.apache.ibatis.annotations.Param;
import java.util.Date;
import java.util.List;
......@@ -9,7 +10,7 @@ import java.util.Map;
/**
* <p>
* 标签分组 Mapper 接口
* 标签分组 Mapper 接口
* </p>
*
* @author 子杨
......@@ -17,43 +18,42 @@ import java.util.Map;
*/
public interface StatisticsRecordMapper extends BaseMapper<KnowlegeStatisticsRecord> {
/**
* 表清空
*
* @return
*/
void deleteAll();
/**
* 表清空
* @return
*/
void deleteAll();
/**
* 查询灾情总计
*
* @return
*/
Map<String, Object> selectDisasterCount();
/**
* 查询灾情总计
* @return
*/
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(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>> 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;
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 org.apache.ibatis.annotations.Param;
......
package com.yeejoin.amos.knowledgebase.face.service;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocAnnotateModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocAnnotateMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocAnnotate;
import com.yeejoin.amos.knowledgebase.face.util.RemoteData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
......@@ -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.rdbms.service.BaseService;
import com.yeejoin.amos.knowledgebase.face.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDocAnnotateModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocAnnotateMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocAnnotate;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
/**
......@@ -88,13 +87,12 @@ public class DocAnnotateService extends BaseService<KnowledgeDocAnnotateModel, K
**/
public List<KnowledgeDocAnnotateModel> queryForAnnotateList(String 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);
list.forEach(item -> {
item.setUsername(userMap.get(item.getUserId()));
item.setIsCurrentUser(ValidationUtil.equals(item.getUserId(),RequestContext.getExeUserId()));
});
return list;
}
}
package com.yeejoin.amos.knowledgebase.face.service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.rule.action.Topic;
import com.yeejoin.amos.component.rule.config.ClazzUtils;
import com.yeejoin.amos.component.rule.config.RuleConfig;
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.Logger;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -15,7 +25,6 @@ import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.exception.BaseException;
......@@ -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.RequestForbidden;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.component.rule.action.Topic;
import com.yeejoin.amos.component.rule.config.ClazzUtils;
import com.yeejoin.amos.component.rule.config.RuleConfig;
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.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;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
import java.util.stream.Collectors;
/**
......@@ -52,12 +53,32 @@ import com.yeejoin.amos.knowledgebase.face.util.QuoteCountFlushTiming;
@Component
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
private DocContentService service;
@Autowired
private ESDocService eSDocService;
// @Autowired
// @Autowired
// private StatisticsRecordService statisticsRecordService;
@Autowired
private DocLibraryService docLibraryService;
......@@ -65,6 +86,10 @@ public class DocAuditService {
private LoadBalancerClient loadBalancerClient;
@Autowired
private EmqKeeper emqKeeper;
@Autowired
private DynamicsValueService dynamicsValueService;
@Autowired
private DynamicsOptionService dynamicsOptionService;
@Autowired
private ConfigLoader configLoader;
......@@ -83,11 +108,49 @@ public class DocAuditService {
if (ValidationUtil.isEmpty(resList)) {
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) {
if (ValidationUtil.equals(oldDoc.getDocStatus(), Constants.DOC_STATUS_UNPUBLISHED)) {
oldDoc.setDocStatus(Constants.DOC_STATUS_PUBLISHED);
oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_PASSED);
if (ValidationUtil.equals(oldDoc.getDocStatus(), DocContentService.DOC_STATUS_UNPUBLISHED)) {
oldDoc.setDocStatus(DocContentService.DOC_STATUS_PUBLISHED);
oldDoc.setAuditStatus(DOC_AUDIT_STATUS_PASSED);
oldDoc.setAuditorUserId(RequestContext.getExeUserId());
service.updateWithModel(oldDoc);
} else {
......@@ -118,13 +181,13 @@ public class DocAuditService {
throw new DataNotFound("数据不存在");
}
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) {
throw new RequestForbidden("含被引用文档,不能取消发布");
}
oldDoc.setDocStatus(Constants.DOC_STATUS_UNPUBLISHED);
oldDoc.setAuditStatus(Constants.DOC_AUDIT_STATUS_SAVED);
oldDoc.setDocStatus(DocContentService.DOC_STATUS_UNPUBLISHED);
oldDoc.setAuditStatus(DOC_AUDIT_STATUS_SAVED);
oldDoc.setAuditorUserId(RequestContext.getExeUserId());
service.updateWithModel(oldDoc);
} else {
......@@ -155,9 +218,9 @@ public class DocAuditService {
throw new DataNotFound("数据不存在");
}
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);
} else {
throw new RequestForbidden("只允许对待提交状态的文档执行此操作");
......@@ -179,12 +242,12 @@ public class DocAuditService {
throw new DataNotFound("数据不存在");
}
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.setDocStatus(Constants.DOC_STATUS_PUBLISHED);
oldDoc.setDocStatus(DocContentService.DOC_STATUS_PUBLISHED);
service.updateWithModel(oldDoc);
} else {
throw new RequestForbidden("只允许对待审核状态的文档执行此操作");
......@@ -213,12 +276,12 @@ public class DocAuditService {
if (ValidationUtil.isEmpty(oldDoc)) {
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.setAuditorUserId(RequestContext.getExeUserId());
oldDoc.setDocStatus(Constants.DOC_STATUS_UNPUBLISHED);
oldDoc.setDocStatus(DocContentService.DOC_STATUS_UNPUBLISHED);
return service.updateWithModel(oldDoc);
} else {
throw new RequestForbidden("只允许对待审核状态的文档执行此操作");
......@@ -233,7 +296,7 @@ public class DocAuditService {
public void pushDeletedDocs2DigitalPlanByMQ(List<KnowledgeDocContentModel> resList) {
List<Long> ids = BaseUtil.getModelIds(resList);
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() + "取消发布,已推送消息至数字预案服务");
} catch (Exception e) {
logger.fatal("文档" + ids.toString() + "取消发布未能成功推送至数字预案服务", e);
......@@ -344,15 +407,15 @@ public class DocAuditService {
AtomicBoolean isRange = new AtomicBoolean(false);
AtomicReference<String> resRight = new AtomicReference<>("");
AtomicReference<String> unit = new AtomicReference<>("");
if (!ObjectUtils.isEmpty(values)) {
if (!ValidationUtil.isEmpty(values.isEmpty())) {
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());
} else {
resLeft.set(value.getTagValue());
}
if (Constants.VALUE_TAG_FIELD_RANGE_MAX.equals(value.getFieldName())
|| Constants.VALUE_TAG_FIELD_RANGE_MIN.equals(value.getFieldName())) {
if (TagValueService.VALUE_TAG_FIELD_RANGE_MAX.equals(value.getFieldName())
|| TagValueService.VALUE_TAG_FIELD_RANGE_MIN.equals(value.getFieldName())) {
isRange.set(true);
}
unit.set(ValidationUtil.isEmpty(value.getUnit()) || "null".equals(value.getUnit()) ? "" : value.getUnit());
......@@ -375,7 +438,7 @@ public class DocAuditService {
if (!ValidationUtil.isEmpty(frontEndConfig)) {
try {
JSONObject configObject = JSON.parseObject(frontEndConfig);
return (String) configObject.get(Constants.TAG_INSTANCE_LABEL);
return (String) configObject.get(TAG_INSTANCE_LABEL);
} catch (Exception e) {
}
}
......
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.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
......@@ -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.RequestForbidden;
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.Constants;
import com.yeejoin.amos.knowledgebase.face.util.TreeUtil;
import java.util.*;
/**
* <p>
......@@ -173,6 +171,16 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K
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) {
if (null == currentTagGroupModel) {
return;
......@@ -205,7 +213,7 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K
List<KnowledgeDocCategoryModel> allChildren = TreeUtil.getAllChildren(categoryTree);
if (!allChildren.isEmpty()) {
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());
}
}
......@@ -250,13 +258,4 @@ public class DocCategoryService extends BaseService<KnowledgeDocCategoryModel, K
List<KnowledgeDocCategoryModel> categoryModelList = this.queryForList(null, true, categoryName, parentId);
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;
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.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.KnowledgeInteractionRecordModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DocCommentsMapper;
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;
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.extension.plugins.pagination.Page;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
......@@ -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.KnowledgeRoleName;
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.orm.dao.DocContentMapper;
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.Constants;
import com.yeejoin.amos.knowledgebase.face.util.DataFillter;
import com.yeejoin.amos.knowledgebase.face.util.DocSortUtil;
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.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
......@@ -48,11 +47,10 @@ import java.util.*;
@Component
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(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();
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();
@Autowired
private DynamicsValueService dynamicsValueService;
......@@ -69,13 +67,11 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
@Autowired
private TagValueService tagValueService;
@Autowired
private
DocLibraryService docLibraryService;
private DocLibraryService docLibraryService;
@Autowired
private Sequence sequence;
public Page queryDocPage(int offset, int end, Map<String, String[]> paramMap, String[] auditStatus, String[] docStatus,
Date createTimeLeft, Date createTimeRight) {
public Page queryDocPage(int offset, int end, Map<String, String[]> paramMap, String[] auditStatus, String[] docStatus, Date createTimeLeft, Date createTimeRight) {
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
if (!ValidationUtil.isEmpty(auditStatus)) {
wrapper.in("audit_status", Arrays.asList(auditStatus));
......@@ -128,8 +124,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
docContentModel.setAgencyCode(RequestContext.getAgencyCode());
docContentModel.setUserId(RequestContext.getExeUserId());
docContentModel.setCreateTime(new Date());
docContentModel.setDocStatus(Constants.DOC_STATUS_UNPUBLISHED);
docContentModel.setAuditStatus(Constants.DOC_AUDIT_STATUS_SAVED);
docContentModel.setDocStatus(DOC_STATUS_UNPUBLISHED);
docContentModel.setAuditStatus(DocAuditService.DOC_AUDIT_STATUS_SAVED);
docContentModel.setSequenceNbr(sequenceNbr);
String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName());
if (ValidationUtil.isEmpty(inputerOrg)) {
......@@ -137,7 +133,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
}
docContentModel.setOrgCode(inputerOrg);
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())) {
docContentModel.setHaveAttachment(false);
}
......@@ -146,14 +142,14 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
dynamicsValueService.saveValueList(docContentModel.getDocBaseInfo(), sequenceNbr, DynamicsFunctional.DOC_BASEINFO, RequestContext.getAppKey());
// 保存标签实例
List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), sequenceNbr, Constants.MARKING_TYPE_DOC);
tagInstanceService.saveInstance(docContentModel.getDocContentTags(), sequenceNbr, Constants.MARKING_TYPE_CONTENT);
List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), sequenceNbr, TagInstanceService.MARKING_TYPE_DOC);
tagInstanceService.saveInstance(docContentModel.getDocContentTags(), sequenceNbr, TagInstanceService.MARKING_TYPE_CONTENT);
QuoteCountFlushTiming.needFlushTag();
//保存附件信息
saveAttachments(docContentModel.getAttachments(), sequenceNbr);
//生成排序字段信息
docContentModel.setSortStr(DocSortUtil.getSortStr(docTags));
docLibraryService.fillDirectoryName(Arrays.asList(docContentModel));
docLibraryService.fillDirectoryName(Collections.singletonList(docContentModel));
return this.createWithModel(docContentModel);
}
......@@ -185,44 +181,38 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("删除文件出错.");
throw new RuntimeException("删除文件出错." + e.getMessage());
}
return true;
}
private KnowledgeDocContentModel fillAttachments(KnowledgeDocContentModel docContentModel) {
try {
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<>();
for (FileInfoModel fileInfoModel : fileInfoModels) {
AttachmentModel attachmentModel = new AttachmentModel();
attachmentModel.setFilename(fileInfoModel.getFilename());
attachmentModel.setFileType(fileInfoModel.getFileType());
attachmentModel.setOriginalFileName(fileInfoModel.getOriginalFileName());
attachmentModel.setFileUrl(fileInfoModel.getFileUrl());
attachments.add(attachmentModel);
}
docContentModel.setAttachments(attachments);
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<>();
for (FileInfoModel fileInfoModel : fileInfoModels) {
AttachmentModel attachmentModel = new AttachmentModel();
attachmentModel.setFilename(fileInfoModel.getFilename());
attachmentModel.setFileType(fileInfoModel.getFileType());
attachmentModel.setOriginalFileName(fileInfoModel.getOriginalFileName());
attachmentModel.setFileUrl(fileInfoModel.getFileUrl());
attachments.add(attachmentModel);
}
} catch (Exception e) {
e.printStackTrace();
docContentModel.setAttachments(attachments);
}
return docContentModel;
}
private String seperotorStrCollection(Collection<Long> stringCollection) {
String returnStr = "";
StringBuilder returnStr = new StringBuilder();
if (!ValidationUtil.isEmpty(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
throw new DataNotFound("找不到指定的文档.");
}
//判断文档的可编辑状态。
if (Constants.DOC_STATUS_PUBLISHED.equals(oldModel.getDocStatus())
|| Constants.DOC_AUDIT_STATUS_PASSED.equals(oldModel.getAuditStatus())
|| Constants.DOC_AUDIT_STATUS_SUBMITTED.equals(oldModel.getAuditStatus())) {
if (DOC_STATUS_PUBLISHED.equals(oldModel.getDocStatus()) || DocAuditService.DOC_AUDIT_STATUS_PASSED.equals(oldModel.getAuditStatus()) || DocAuditService.DOC_AUDIT_STATUS_SUBMITTED.equals(oldModel.getAuditStatus())) {
throw new BadRequest("当前文档状态不可编辑.");
}
//如果文档为驳回状态,更改为待提交
if (ValidationUtil.equals(Constants.DOC_AUDIT_STATUS_REJECTED, oldModel.getAuditStatus())) {
oldModel.setAuditStatus(Constants.DOC_AUDIT_STATUS_SAVED);
if (ValidationUtil.equals(DocAuditService.DOC_AUDIT_STATUS_REJECTED, oldModel.getAuditStatus())) {
oldModel.setAuditStatus(DocAuditService.DOC_AUDIT_STATUS_SAVED);
}
if (!ValidationUtil.isEmpty(docContentModel.getHaveAttachment())) {
oldModel.setHaveAttachment(docContentModel.getHaveAttachment());
}
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());
// 保存标签实例
tagInstanceService.deleteByTargetSeq(oldModel.getSequenceNbr());//删除已有的标签
List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), oldModel.getSequenceNbr(), Constants.MARKING_TYPE_DOC);
tagInstanceService.saveInstance(docContentModel.getDocContentTags(), oldModel.getSequenceNbr(), Constants.MARKING_TYPE_CONTENT);
List<KnowledgeTagInstanceModel> docTags = tagInstanceService.saveInstance(docContentModel.getDocTags(), oldModel.getSequenceNbr(), TagInstanceService.MARKING_TYPE_DOC);
tagInstanceService.saveInstance(docContentModel.getDocContentTags(), oldModel.getSequenceNbr(), TagInstanceService.MARKING_TYPE_CONTENT);
// 重新保存附件信息
deleteAttachments(oldModel.getSequenceNbr());//删除已有的文件信息
saveAttachments(docContentModel.getAttachments(), oldModel.getSequenceNbr());//保存新的文件信息.
oldModel.setDocTitle(docContentModel.getDocTitle());
oldModel.setDirectoryId(docContentModel.getDirectoryId());
docLibraryService.fillDirectoryName(Arrays.asList(oldModel));
docLibraryService.fillDirectoryName(Collections.singletonList(oldModel));
oldModel.setHtmlContent(docContentModel.getHtmlContent());
//生成排序字段信息
oldModel.setSortStr(DocSortUtil.getSortStr(docTags));
docLibraryService.fillDirectoryName(Arrays.asList(oldModel));
docLibraryService.fillDirectoryName(Collections.singletonList(oldModel));
this.updateWithModel(oldModel);
return Bean.copyExistPropertis(oldModel, docContentModel);
}
......@@ -279,9 +267,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
if (ValidationUtil.isEmpty(docContentModel)) {
throw new BadRequest("指定的文档不存在.");
}
if (Constants.DOC_STATUS_PUBLISHED.equals(docContentModel.getDocStatus())
|| Constants.DOC_AUDIT_STATUS_PASSED.equals(docContentModel.getAuditStatus())
|| Constants.DOC_AUDIT_STATUS_SUBMITTED.equals(docContentModel.getAuditStatus())) {
if (DOC_STATUS_PUBLISHED.equals(docContentModel.getDocStatus()) || DocAuditService.DOC_AUDIT_STATUS_PASSED.equals(docContentModel.getAuditStatus()) || DocAuditService.DOC_AUDIT_STATUS_SUBMITTED.equals(docContentModel.getAuditStatus())) {
throw new BadRequest("当前文档状态不可删除.");
}
this.dynamicsValueService.deleteByInstanceId(docContentModel.getSequenceNbr());
......@@ -324,24 +310,24 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
}
});
tagInstanceModelList.forEach(instanceModel -> {
switch (instanceModel.getMarkingType()) {
case Constants.MARKING_TYPE_DOC:
docTags.add(instanceModel);
break;
default:
docContentTags.add(instanceModel);
if (TagInstanceService.MARKING_TYPE_DOC.equals(instanceModel.getMarkingType())) {
docTags.add(instanceModel);
} else {
docContentTags.add(instanceModel);
}
});
}
KnowledgeInteractionRecordModel recordModel = interactionRecordService.queryUniqueModel(RequestContext.getExeUserId(), KnowledgeDocContentModel.class.getSimpleName(),
String.valueOf(docContentModel.getSequenceNbr()), OperateType.COLLECT.name());
fillAttachments(docContentModel);
docContentModel.setDocTags(docTags);
docContentModel.setDocContentTags(docContentTags);
docContentModel.setCollected(!ValidationUtil.isEmpty(recordModel));
docContentModel.setUserName(RemoteData.getUserRealNamById(docContentModel.getUserId()));
docLibraryService.fillDirectoryName(Arrays.asList(docContentModel));
//开放接口不需要验证
try {
KnowledgeInteractionRecordModel recordModel = interactionRecordService.queryUniqueModel(RequestContext.getExeUserId(), KnowledgeDocContentModel.class.getSimpleName(), String.valueOf(docContentModel.getSequenceNbr()), OperateType.COLLECT.name());
fillAttachments(docContentModel);
docContentModel.setDocTags(docTags);
docContentModel.setDocContentTags(docContentTags);
docContentModel.setCollected(!ValidationUtil.isEmpty(recordModel));
docContentModel.setUserName(RemoteData.getUserRealNamById(docContentModel.getUserId()));
} catch (Exception ignored) {
}
docLibraryService.fillDirectoryName(Collections.singletonList(docContentModel));
}
return docContentModel;
}
......@@ -535,8 +521,8 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
case AUDITOR:
case INPUTER:
case VIEWER:
auditStatusSet.add(Constants.DOC_AUDIT_STATUS_PASSED);
docStatusSet.add(Constants.DOC_STATUS_PUBLISHED);
auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_PASSED);
docStatusSet.add(DocContentService.DOC_STATUS_PUBLISHED);
dataPrivilegemap.put(docStatus, docStatusSet.toArray(new String[docStatusSet.size()]));
dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()]));
break;
......@@ -616,7 +602,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
}
}
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));
}
});
......@@ -644,7 +630,7 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
return wrapper;
}
public List<Long> getAllPublishedDocIds(){
public List<Long> getAllPublishedDocIds() {
return this.baseMapper.getAllPublishedDocIds();
}
......@@ -654,23 +640,16 @@ public class DocContentService extends BaseService<KnowledgeDocContentModel, Kno
Set<Object> docCotentId = Bean.listToMap(refModelList, "sequenceNbr", KnowledgeDocContentModel.class).keySet();
return new ArrayList(docCotentId);
}
//根据分组id列表查询所有的关系
private List<KnowledgeDocContentModel> queryListByCategorySeqList(@Condition(Operator.in) List<Long> 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>();
idListString.stream().forEach(i->{
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);
}
/**
* 开放接口,根据文档分类查询分类下的列表数据,只查公开的标签文档
*/
public IPage<KnowledgeDocContent> pageByType(int offset, int size, Long typeId, Long tagId) {
return baseMapper.pageByType(new Page<>(offset, size), typeId, tagId);
}
}
package com.yeejoin.amos.knowledgebase.face.service;
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.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
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.knowledgebase.face.enumeration.DynamicsFunctional;
import com.yeejoin.amos.knowledgebase.face.enumeration.KnowledgeRoleName;
import com.yeejoin.amos.knowledgebase.face.enumeration.OperateType;
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.orm.entity.ESDocEntity;
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.orm.entity.*;
import com.yeejoin.amos.knowledgebase.face.util.*;
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.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.sql.BaseSqlCondition;
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.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
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.Value;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
......@@ -47,11 +46,10 @@ import org.typroject.tyboot.core.restful.exception.instance.DataNotFound;
import org.typroject.tyboot.core.restful.exception.instance.RequestForbidden;
import javax.servlet.http.HttpServletResponse;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.text.ParseException;
import java.time.format.DateTimeFormatter;
import java.time.temporal.TemporalAccessor;
import java.util.*;
import java.util.stream.Collectors;
......@@ -78,7 +76,7 @@ public class DocLibraryService {
private DynamicsValueService dynamicsValueService;
@Autowired
private InteractionCountService interactionCountService;
// @Autowired
// @Autowired
// private DynamicsGroupService dynamicsGroupService;
@Autowired
private DynamicsOptionService dynamicsOptionService;
......@@ -100,10 +98,15 @@ public class DocLibraryService {
private static final Integer BATCH_IMPORT_ONCE_NUM = 200;
private static final List auditStatusList;
@Value("${admin.all}")
boolean adminAll = false;
@Value("${admin.all.role}")
String adminAllRole;
static {
List<String> list = new ArrayList<>();
list.add(Constants.DOC_AUDIT_STATUS_SUBMITTED);
list.add(Constants.DOC_AUDIT_STATUS_PASSED);
list.add(DocAuditService.DOC_AUDIT_STATUS_SUBMITTED);
list.add(DocAuditService.DOC_AUDIT_STATUS_PASSED);
auditStatusList = Collections.unmodifiableList(list);
}
......@@ -124,7 +127,8 @@ public class DocLibraryService {
recordModel.setUserId(RequestContext.getExeUserId());
recordModel.setEntityType(KnowledgeDocContentModel.class.getSimpleName());
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 (ValidationUtil.isEmpty(oldModel)) {
recordModel.setAgencyCode(RequestContext.getAgencyCode());
......@@ -138,10 +142,18 @@ public class DocLibraryService {
return true;
}
public Page queryDocList(int offset, int end, Long directoryId, String docTitle, String[] auditStatus, String docStatus,
Map<String, String[]> requestMap, String createTimeLeft, String createTimeRight, boolean favor, boolean permission) {
public Page queryDocList(int offset, int end, Long directoryId, String docTitle, String[] auditStatus,
String docStatus, Map<String, String[]> requestMap, String createTimeLeft, String createTimeRight,
boolean favor, boolean permission) {
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("limit", end > offset ? end - offset + 1 : 50);
// 封装权限过滤条件
......@@ -150,11 +162,12 @@ public class DocLibraryService {
}
List<Long> directoryIdList = new ArrayList<>();
if (directoryId != null) {
Collection<KnowledgeDocCategoryModel> childCategoryModels = docCategoryService.queryDocCategoryTree(RequestContext.getAgencyCode(), directoryId);
Collection<KnowledgeDocCategoryModel> childCategoryModels = docCategoryService
.queryDocCategoryTree(RequestContext.getAgencyCode(), directoryId);
if (!childCategoryModels.isEmpty()) {
directoryIdList.addAll(BaseUtil.getModelIds(TreeUtil.getAllChildren(childCategoryModels)));
}
//获取所有子分类ID
// 获取所有子分类ID
directoryIdList.add(directoryId);
}
......@@ -171,18 +184,14 @@ public class DocLibraryService {
page.setTotal(total);
if (total > 0 && total > offset) {
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);
}
return page;
}
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)) {
return;
}
......@@ -194,7 +203,8 @@ public class DocLibraryService {
String fieldName = optionModel.getFieldName();
extraFields.add(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)) {
extraStrFilters.add(filterStr);
}
......@@ -233,11 +243,11 @@ public class DocLibraryService {
StringBuilder builder = new StringBuilder();
if (!ValidationUtil.isEmpty(values[0])) {
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 ");
}
}
if (values.length>1 && !ValidationUtil.isEmpty(values[1])) {
if (values.length > 1 && !ValidationUtil.isEmpty(values[1])) {
builder.append(fieldName).append(" <= \"").append(values[1]).append("\"");
}
return builder.toString();
......@@ -251,19 +261,34 @@ public class DocLibraryService {
paramsMap.put("permissionFilters", permissionFiltersMap);
String inputerOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.INPUTER.getRoleName());
String auditorOrg = RemoteData.getOrgWithCurUserAndRole(KnowledgeRoleName.AUDITOR.getRoleName());
boolean isAdmin = RemoteData.isAdmin(adminAllRole);
if (ValidationUtil.isEmpty(inputerOrg) && ValidationUtil.isEmpty(auditorOrg)) {
throw new RequestForbidden("用户角色错误");
}
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)) {
permissionFiltersMap.put("orgCode", auditorOrg);
if (RemoteData.isAdmin(adminAllRole)) {
if (!adminAll) {
permissionFiltersMap.put("orgCode", auditorOrg);
}
} else {
permissionFiltersMap.put("orgCode", auditorOrg);
}
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);
paramsMap.put("commonFilters", commonFiltersMap);
if (!ValidationUtil.isEmpty(directoryIdList)) {
......@@ -299,9 +324,7 @@ public class DocLibraryService {
*/
public Page searchAdvanced(Page page, Map<String, Object> queryParams) {
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.select("SEQUENCE_NBR")
.eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED)
.orderByAsc("SORT_STR");
wrapper.select("SEQUENCE_NBR").eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED).orderByAsc("SORT_STR");
BaseSqlCondition sqlCondition = BaseSqlCondition.getInstance(queryParams);
if (sqlCondition.getTotalStatement() > 0) {
......@@ -320,7 +343,8 @@ public class DocLibraryService {
}
});
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 {
return res;
}
//获取我的文档收藏列表
// 获取我的文档收藏列表
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<>();
for (KnowledgeInteractionRecordModel recordModel : recordModelList) {
idList.add(Long.valueOf(recordModel.getEntityId()));
......@@ -442,14 +468,16 @@ public class DocLibraryService {
return idList;
}
//获取文档被收藏总数
// 获取文档被收藏总数
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) {
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 {
List resList = new ArrayList<>();
List<KnowledgeTag> tagList = tagService.getBaseMapper().queryTagByNameInPublishedDoc(queryStr);
resList.addAll(Bean.listToMap(tagList, "tagName", KnowledgeTag.class).keySet());
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>()
.select("DOC_TITLE").eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED).like("DOC_TITLE", queryStr);
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<KnowledgeDocContent>().select("DOC_TITLE")
.eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED).like("DOC_TITLE", queryStr);
List<KnowledgeDocContent> docContentList = docContentService.list(wrapper);
docContentList.forEach(doc -> {
if (!resList.contains(doc.getDocTitle())) {
......@@ -481,7 +509,7 @@ public class DocLibraryService {
public Map<String, Integer> count(int days) {
Map<String, Integer> res = new HashMap<>();
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));
Date rightRange = new Date();
Date leftRange = getDateBeforeDays(rightRange, days - 1);
......@@ -497,7 +525,8 @@ public class DocLibraryService {
* @return
*/
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);
return fillDynamics(list, false);
}
......@@ -537,8 +566,10 @@ public class DocLibraryService {
}
contentModel.setHtmlContent(null);
Map contentMap = Bean.BeantoMap(contentModel);
List<KnowledgeDynamicsValueModel> listByInstance = dynamicsValueService.queryByInstanceId(contentModel.getSequenceNbr());
Map<Object, Object> returnMap = Bean.listToMap(listByInstance, "fieldName", "fieldValue", KnowledgeDynamicsValueModel.class);
List<KnowledgeDynamicsValueModel> listByInstance = dynamicsValueService
.queryByInstanceId(contentModel.getSequenceNbr());
Map<Object, Object> returnMap = Bean.listToMap(listByInstance, "fieldName", "fieldValue",
KnowledgeDynamicsValueModel.class);
if (!simple) {
returnMap.put("referenceNum", getReferenceCount(contentModel.getSequenceNbr()));
returnMap.put("collectionNum", getCollectionCount(contentModel.getSequenceNbr()));
......@@ -583,188 +614,7 @@ public class DocLibraryService {
FileExporter.exportFile(fileType, docTitle, bytes, response);
}
// @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 })
@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)) {
......@@ -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);
// 逐行解析
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);
excelParser.parseRow(row, directoryMap);
if (i % 500 == 0) {
batchInsertDocDataAll(excelParser.getAndFlushDatas());
}
}
batchInsertDocDataAll(excelParser.getAndFlushDatas());
QuoteCountFlushTiming.needFlushTag();
}
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());
dynamicsValueService.saveBatch(datas.getDynamicsValueList());
tagInstanceService.saveBatch(datas.getTagInstanceList());
......@@ -877,12 +759,15 @@ public class DocLibraryService {
}
List<KnowledgeDocContentModel> contentModelList = docContentService.queryByIds(docSeqList);
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()) {
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<KnowledgeDynamicsValueModel> dynamicsValueModelList = dynamicsValueService.queryByInstanceIds(docSeqList);
List<KnowledgeDynamicsValueModel> dynamicsValueModelList = dynamicsValueService
.queryByInstanceIds(docSeqList);
// 标签值组装到标签实例
tagValueModelList.forEach(tagValueModel -> {
KnowledgeTagInstanceModel instanceModel = tagInstanceModelMap.get(tagValueModel.getInstanceSeq());
......@@ -899,8 +784,9 @@ public class DocLibraryService {
tagInstanceModelList.forEach(tagInstanceModel -> {
KnowledgeDocContentModel docContentModel = docContentModelMap.get(tagInstanceModel.getTargetSeq());
if (null != docContentModel) {
boolean isDoc = Constants.MARKING_TYPE_DOC.equals(tagInstanceModel.getMarkingType());
List<KnowledgeTagInstanceModel> tagList = isDoc ? docContentModel.getDocTags() : docContentModel.getDocContentTags();
boolean isDoc = TagInstanceService.MARKING_TYPE_DOC.equals(tagInstanceModel.getMarkingType());
List<KnowledgeTagInstanceModel> tagList = isDoc ? docContentModel.getDocTags()
: docContentModel.getDocContentTags();
if (null == tagList) {
tagList = new ArrayList<>();
if (isDoc) {
......@@ -979,7 +865,8 @@ public class DocLibraryService {
*/
public Map<String, Map<String, String>> getBaseEnumMap() {
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) {
if ("Enum".equals(optionModel.getDataType())) {
String fieldName = optionModel.getFieldName();
......@@ -1013,13 +900,15 @@ public class DocLibraryService {
int finishNmu = 0;
int current = 0;
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);
List<KnowledgeDocContent> records = resPage.getRecords();
records.forEach(doc -> {
if (ValidationUtil.isEmpty(doc.getTextContent()) && ValidationUtil.isEmpty(doc.getSortStr())) {
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);
......@@ -1042,7 +931,8 @@ public class DocLibraryService {
if (ValidationUtil.isEmpty(categoryModelList)) {
return;
}
Map<Object, KnowledgeDocCategoryModel> categoryModelMap = Bean.listToMap(categoryModelList, "sequenceNbr", KnowledgeDocCategoryModel.class);
Map<Object, KnowledgeDocCategoryModel> categoryModelMap = Bean.listToMap(categoryModelList, "sequenceNbr",
KnowledgeDocCategoryModel.class);
docList.forEach(doc -> {
if (doc instanceof KnowledgeDocContentModel) {
KnowledgeDocContentModel doc1 = (KnowledgeDocContentModel) doc;
......@@ -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<>();
wrapper.eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED);
wrapper.eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED);
if (!ValidationUtil.isEmpty(docTitle)) {
wrapper.like("DOC_TITLE", docTitle);
}
if (!ValidationUtil.isEmpty(orgCode)) {
wrapper.like("ORG_CODE", orgCode);
}
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);
if (!page.getRecords().isEmpty()) {
ArrayList list = Bean.toModels(page.getRecords(), KnowledgeDocContentModel.class);
......@@ -1076,20 +985,19 @@ public class DocLibraryService {
public List selectByDirsRand(List<Long> directoryList, Integer total) {
Set<Long> directoryIdSet = new HashSet<>();
List<KnowledgeDocCategoryModel> categoryList = Bean.toModels(docCategoryService.list(), KnowledgeDocCategoryModel.class);
directoryList.forEach(
directoryId -> {
directoryIdSet.addAll(BaseUtil.getModelIds(TreeUtil.getAllChildren(TreeBuilder.bulid(categoryList, directoryId))));
if (!directoryId.equals(DocCategoryService.ROOT)) {
directoryIdSet.add(directoryId);
}
}
);
List<KnowledgeDocCategoryModel> categoryList = Bean.toModels(docCategoryService.list(),
KnowledgeDocCategoryModel.class);
directoryList.forEach(directoryId -> {
directoryIdSet.addAll(
BaseUtil.getModelIds(TreeUtil.getAllChildren(TreeBuilder.bulid(categoryList, directoryId))));
if (!directoryId.equals(DocCategoryService.ROOT)) {
directoryIdSet.add(directoryId);
}
});
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.eq("DOC_STATUS", Constants.DOC_STATUS_PUBLISHED)
.in("DIRECTORY_ID", directoryIdSet);
wrapper.eq("DOC_STATUS", DocContentService.DOC_STATUS_PUBLISHED).in("DIRECTORY_ID", directoryIdSet);
if (total != null) {
wrapper.last("ORDER BY RAND() LIMIT "+ total);
wrapper.last("ORDER BY RAND() LIMIT " + total);
}
List<KnowledgeDocContent> contentList = docContentService.list(wrapper);
List<KnowledgeDocContentModel> list = Bean.toModels(contentList, KnowledgeDocContentModel.class);
......
......@@ -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.orm.dao.DynamicsGroupMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDynamicsGroup;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.typroject.tyboot.core.rdbms.service.BaseService;
......
......@@ -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.KnowledgeRoleName;
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.KnowledgeDynamicsValueModel;
import com.yeejoin.amos.knowledgebase.face.orm.dao.DynamicsValueMapper;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -26,6 +24,7 @@ import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -148,8 +147,8 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode
}
switch (knowledgeRoleName) {
case AUDITOR:
auditStatusSet.add(Constants.DOC_AUDIT_STATUS_PASSED);
auditStatusSet.add(Constants.DOC_AUDIT_STATUS_SUBMITTED);
auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_PASSED);
auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_SUBMITTED);
dataPrivilegemap.put(DataFillter.orgCode, orgCode);
dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()]));
break;
......@@ -160,8 +159,8 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode
dataPrivilegemap.put(DataFillter.noData, true);
break;
case VIEWER:
auditStatusSet.add(Constants.DOC_AUDIT_STATUS_PASSED);
docStatusSet.add(Constants.DOC_STATUS_PUBLISHED);
auditStatusSet.add(DocAuditService.DOC_AUDIT_STATUS_PASSED);
docStatusSet.add(DocContentService.DOC_STATUS_PUBLISHED);
dataPrivilegemap.put(docStatus, docStatusSet.toArray(new String[docStatusSet.size()]));
dataPrivilegemap.put(auditStatus, auditStatusSet.toArray(new String[auditStatusSet.size()]));
break;
......@@ -370,4 +369,15 @@ public class DynamicsValueService extends BaseService<KnowledgeDynamicsValueMode
public List<KnowledgeDynamicsValueModel> queryByInstanceIds(@Condition(Operator.in) Collection<Long> 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;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.KnowledgeDynamicsValueModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
......@@ -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.ESTagEntity;
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.QueryBuilders;
import org.elasticsearch.search.fetch.subphase.highlight.HighlightBuilder;
......@@ -73,7 +71,7 @@ public class ESDocService {
* @return Page对象
*/
@SuppressWarnings("rawtypes")
public Page<ESDocEntity> findAll(int current, int size) {
public Page<ESDocEntity> findAll(int current, int size) {
// 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// 分页
......@@ -82,22 +80,18 @@ public class ESDocService {
.withSort(SortBuilders.fieldSort("sortStr.keyword").order(SortOrder.DESC));
List<ESDocEntity> list = new LinkedList<>();
try
{
SearchHits<ESDocEntity> searchHits =elasticsearchTemplate.search(queryBuilder.build(), ESDocEntity.class);
for (SearchHit searchHit : searchHits.getSearchHits())
{
ESDocEntity docEntity = (ESDocEntity)searchHit.getContent();
list.add(docEntity);
}
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), searchHits.getTotalHits());
}
catch (Exception e)
{
e.printStackTrace();
}
try {
SearchHits<ESDocEntity> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESDocEntity.class);
for (SearchHit searchHit : searchHits.getSearchHits()) {
ESDocEntity docEntity = (ESDocEntity) searchHit.getContent();
list.add(docEntity);
}
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), searchHits.getTotalHits());
} catch (Exception e) {
e.printStackTrace();
}
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), 0);
}
......@@ -119,8 +113,8 @@ public class ESDocService {
* @param size 页面大小
* @return
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
public Page<ESDocEntity> queryByKeys(String queryStr, int current, int size) {
@SuppressWarnings({"rawtypes", "unchecked"})
public Page<ESDocEntity> queryByKeys(String queryStr, int current, int size) {
List<String> keys = queryStr2List(queryStr);
if (ValidationUtil.isEmpty(keys)) {
return findAll(current, size);
......@@ -128,88 +122,83 @@ public class ESDocService {
// 条件构造,多条件循环匹配
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
for (String key : keys) {
boolMust.must(
QueryBuilders.boolQuery().minimumShouldMatch(1)
.should(QueryBuilders.matchPhraseQuery("docTitle", key))
.should(QueryBuilders.matchPhraseQuery("docInfo", key))
.should(QueryBuilders.matchPhraseQuery("author", key))
.should(QueryBuilders.matchPhraseQuery("textContent", key))
.should(QueryBuilders.matchPhraseQuery("docTags.tagInfo", key))
.should(QueryBuilders.matchPhraseQuery("contentTags.tagInfo", key))
boolMust.must(QueryBuilders.boolQuery().minimumShouldMatch(1)
.should(QueryBuilders.matchQuery("docTitle", key).boost(1f))
.should(QueryBuilders.matchQuery("docInfo", key).boost(0.3f))
.should(QueryBuilders.matchQuery("author", key).boost(0.3f))
.should(QueryBuilders.matchQuery("textContent", key).boost(0.5f))
.should(QueryBuilders.matchQuery("docTags.tagInfo", key).boost(0.8f))
.should(QueryBuilders.matchQuery("contentTags.tagInfo", key).boost(0.8f))
);
}
// 创建查询构造器
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder()
// 高亮字段
.withHighlightFields(
new HighlightBuilder.Field("docTitle").preTags("").postTags("").numOfFragments(0),
new HighlightBuilder.Field("textContent").preTags("").postTags("").numOfFragments(1).fragmentSize(200).noMatchSize(100).order("score"),
new HighlightBuilder.Field("docTitle").preTags("<em>").postTags("</em>").numOfFragments(0),
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("contentTags.tagInfo").preTags("").postTags("").numOfFragments(0)
)
// 分页
.withPageable(PageRequest.of(current, size))
// 排序
.withSort(SortBuilders.fieldSort("sortStr.keyword").order(SortOrder.ASC))
//过滤条件
.withQuery(boolMust);
// 对高亮词条进行操作
List<ESDocEntity> list = new ArrayList<>();
try
{
SearchHits<ESDocEntity> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESDocEntity.class);
for (SearchHit searchHit : searchHits.getSearchHits()) {
ESDocEntity docEntity = (ESDocEntity)searchHit.getContent();
searchHit.getHighlightFields();
// 文档标题
List<String> docTitle = searchHit.getHighlightField("docTitle");
if (!ValidationUtil.isEmpty(docTitle)) {
StringBuilder sb = new StringBuilder();
for (String fragment : docTitle) {
sb.append(fragment);
}
docEntity.setDocTitle(sb.toString());
}
// 文档内容
List<String> textContent = searchHit.getHighlightField("textContent");
if (!ValidationUtil.isEmpty(textContent)) {
StringBuilder sb = new StringBuilder();
for (String fragment : textContent) {
sb.append(fragment);
}
docEntity.setSummary(sb.toString());
}
Set<String> tagInfoSet = new HashSet<>();
// 文档标签
List<String> docTagsInfo = searchHit.getHighlightField("docTags.tagInfo");
if (!ValidationUtil.isEmpty(docTagsInfo)) {
for (String fragment : docTagsInfo) {
tagInfoSet.add(fragment);
}
}
List<String> contentTagsInfo = searchHit.getHighlightField("contentTags.tagInfo");
if (!ValidationUtil.isEmpty(contentTagsInfo)) {
for (String fragment : contentTagsInfo) {
tagInfoSet.add(fragment);
}
}
// 删除不匹配的和重复的标签
deleteRepeatedTags(docEntity.getDocTags(), tagInfoSet);
deleteRepeatedTags(docEntity.getContentTags(), tagInfoSet);
list.add(docEntity);
}
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), searchHits.getTotalHits());
}
catch (Exception e)
{
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), 0);
}
try {
SearchHits<ESDocEntity> searchHits = elasticsearchTemplate.search(queryBuilder.build(), ESDocEntity.class);
for (SearchHit searchHit : searchHits.getSearchHits()) {
ESDocEntity docEntity = (ESDocEntity) searchHit.getContent();
searchHit.getHighlightFields();
// 文档标题
List<String> docTitle = searchHit.getHighlightField("docTitle");
if (!ValidationUtil.isEmpty(docTitle)) {
StringBuilder sb = new StringBuilder();
for (String fragment : docTitle) {
sb.append(fragment);
}
docEntity.setDocTitle(sb.toString());
}
// 文档内容
List<String> textContent = searchHit.getHighlightField("textContent");
if (!ValidationUtil.isEmpty(textContent)) {
StringBuilder sb = new StringBuilder();
for (String fragment : textContent) {
sb.append(fragment);
}
docEntity.setSummary(sb.toString());
}
Set<String> tagInfoSet = new HashSet<>();
// 文档标签
List<String> docTagsInfo = searchHit.getHighlightField("docTags.tagInfo");
if (!ValidationUtil.isEmpty(docTagsInfo)) {
for (String fragment : docTagsInfo) {
tagInfoSet.add(fragment);
}
}
List<String> contentTagsInfo = searchHit.getHighlightField("contentTags.tagInfo");
if (!ValidationUtil.isEmpty(contentTagsInfo)) {
for (String fragment : contentTagsInfo) {
tagInfoSet.add(fragment);
}
}
// 删除不匹配的和重复的标签
deleteRepeatedTags(docEntity.getDocTags(), tagInfoSet);
deleteRepeatedTags(docEntity.getContentTags(), tagInfoSet);
list.add(docEntity);
}
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), searchHits.getTotalHits());
} catch (Exception e) {
return new AggregatedPageImpl<>(list, PageRequest.of(current, size), 0);
}
}
/**
......@@ -238,14 +227,16 @@ public class ESDocService {
* @param tagInfoSet 命中的tagInfo
*/
private static void deleteRepeatedTags(List<ESTagEntity> list, Set<String> tagInfoSet) {
Iterator<ESTagEntity> tagIterator = list.iterator();
while (tagIterator.hasNext()) {
ESTagEntity tag = tagIterator.next();
if (tagInfoSet.contains(tag.getTagInfo())) {
tagInfoSet.remove(tag.getTagInfo());
tag.setTagInfo(null);
} else {
tagIterator.remove();
if (!ValidationUtil.isEmpty(tagInfoSet)) {
Iterator<ESTagEntity> tagIterator = list.iterator();
while (tagIterator.hasNext()) {
ESTagEntity tag = tagIterator.next();
if (tagInfoSet.contains(tag.getTagInfo())) {
tagInfoSet.remove(tag.getTagInfo());
tag.setTagInfo(null);
} else {
tagIterator.remove();
}
}
}
}
......@@ -307,7 +298,7 @@ public class ESDocService {
Map<String, Map<String, String>> enumCnEnMap = docLibraryService.getBaseEnumMap();
List<ESDocEntity> esDocs = new ArrayList<>();
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> contentTags = buildESTagsByInstanceList(docDetail.getDocContentTags());
ESDocEntity esDocEntity = new ESDocEntity()
......@@ -387,7 +378,7 @@ public class ESDocService {
private String getTagInfoStr(KnowledgeTagInstanceModel instanceModel) {
StringBuilder infoStr = new StringBuilder();
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())) {
return infoStr.toString().trim();
}
......@@ -395,7 +386,7 @@ public class ESDocService {
String fieldName = valueModel.getFieldName();
String tagValue = valueModel.getTagValue();
switch (fieldName) {
case Constants.VALUE_TAG_FIELD_DATE_H:
case TagValueService.VALUE_TAG_FIELD_DATE_H:
infoStr.append(tagValue).append(" ");
try {
Date date = DateUtil.formatStringToDate(tagValue, null);
......@@ -445,7 +436,7 @@ public class ESDocService {
esDocRepository.deleteAll();
//保存所有已发布文档
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 finishNmu = 0;
int current = 0;
......
......@@ -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.entity.KnowledgeInteractionCount;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext;
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.rdbms.service.BaseService;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
/**
......
......@@ -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.update.UpdateWrapper;
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.orm.dao.MessageMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeMessage;
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.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
......@@ -36,7 +35,20 @@ import java.util.*;
@Component
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 userTypeGroup = "group";
......@@ -95,14 +107,14 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge
*/
@Transactional(rollbackFor = {BaseException.class, Exception.class})
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) {
//创建消息
if (ValidationUtil.isEmpty(doc) || ValidationUtil.isEmpty(doc.get("sequenceNbr"))) {
throw new BadRequest("分享内容缺失");
}
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<>();
userIdSet = parseUserMapToIdList(users, userIdSet);
//创建个人消息
......@@ -122,7 +134,7 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge
@Transactional(rollbackFor = {BaseException.class, Exception.class})
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<>();
userIdSet = parseUserMapToIdList(users, userIdSet);
//创建个人消息
......@@ -239,7 +251,7 @@ public class MessageService extends BaseService<KnowledgeMessageModel, Knowledge
* 获取用户的主题
*/
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;
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.orm.dao.StatisticsRecordMapper;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowledgeDocContent;
import com.yeejoin.amos.knowledgebase.face.orm.entity.KnowlegeStatisticsRecord;
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.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.restful.exception.instance.BadRequest;
import java.text.SimpleDateFormat;
import java.util.*;
/**
* <p>
* 标签分组 服务类
......@@ -37,219 +20,280 @@ import java.util.*;
* @since 2020-08-05
*/
@Component
public class StatisticsRecordService
extends BaseService<KnowlegeStatisticsRecordModel, KnowlegeStatisticsRecord, StatisticsRecordMapper> {
/*
* @Autowired private DocContentService docContentService;
*
* 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_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_CASUALTIES = "人员伤亡情况 含亡人"; public static
* final String STATISTICS_CASUALTIES_SUM = "CASUALTIES_RECORD";
*
*//**
* 灭火药剂统计
*/
/*
* public static final String TAG_NAME_EXTINGUISHING = "使用的灭火药剂数量"; public
* static final String STATISTICS_EXTINGUISHING_SUM = "EXTINGUISHING_RECORD";
*
*//**
* 过火面积统计
*/
/*
* public static final String TAG_NAME_AREA = "过火面积"; public static final String
* STATISTICS_AREA_COUNT = "FIRE_AREA_RECORD";
*
*//**
* 到场时间分类
*/
/*
* public static final String TAG_NAME_PICKUP = "接警时间"; public static final
* String TAG_NAME_PRESENT = "到场时间"; public static final String
* STATISTICS_PRESENT_CATEGORY = "PRESENT_TIME_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}") private boolean needRecord;
*
*//** 根据文档标签添加对应的记录 */
/*
* private void addRecordWithDocValueTag(List<KnowledgeTagInstanceModel>
* docTags, Long docSeq) { //找出预定义的所有标签 Map<Object, KnowledgeTagInstanceModel>
* tagMap = Bean.listToMap(docTags, "tagName", KnowledgeTagInstanceModel.class);
* KnowledgeTagInstanceModel tagTime = tagMap.get(TAG_NAME_TIME); if
* (ValidationUtil.isEmpty(tagTime)) { return; } Object timeObj =
* getValueFromTag(tagTime); if (ValidationUtil.isEmpty(timeObj) || !(timeObj
* instanceof Date)) { return; } Date disasterTime = (Date) timeObj; //记录灾情
* insertSumTypeRecord(docSeq, disasterTime, STATISTICS_DISASTER_COUNT, 1.0, 1);
* //记录燃烧物质 KnowledgeTagInstanceModel tagBurning = tagMap.get(TAG_NAME_BURNING);
* if (!ValidationUtil.isEmpty(tagBurning)) { insertCategoryTypeRecord(docSeq,
* disasterTime, STATISTICS_BURNING_CATEGORY, getValueFromTag(tagBurning)); }
* //记录参战车辆 KnowledgeTagInstanceModel tagPower = tagMap.get(TAG_NAME_POWER); if
* (!ValidationUtil.isEmpty(tagPower)) { 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 tagExtinguishing =
* tagMap.get(TAG_NAME_EXTINGUISHING); if
* (!ValidationUtil.isEmpty(tagExtinguishing)) { insertSumTypeRecord(docSeq,
* disasterTime, STATISTICS_EXTINGUISHING_SUM,
* getValueFromTag(tagExtinguishing), 1); } //记录过火面积 KnowledgeTagInstanceModel
* tagArea = tagMap.get(TAG_NAME_AREA); if (!ValidationUtil.isEmpty(tagArea)) {
* insertSumTypeRecord(docSeq, disasterTime, STATISTICS_AREA_COUNT,
* getValueFromTag(tagArea), 1); } //记录到场时间 KnowledgeTagInstanceModel tagPickup
* = tagMap.get(TAG_NAME_PICKUP); KnowledgeTagInstanceModel tagPresent =
* tagMap.get(TAG_NAME_PRESENT); if (!ValidationUtil.isEmpty(tagPickup) &&
* !ValidationUtil.isEmpty(tagPresent)) { Object pickTimeObj =
* getValueFromTag(tagPickup); Object presentTimeObj =
* getValueFromTag(tagPresent); if (!ValidationUtil.isEmpty(pickTimeObj) &&
* pickTimeObj instanceof Date && !ValidationUtil.isEmpty(presentTimeObj) &&
* presentTimeObj instanceof Date) { long presentTimeByMinute = (long)
* Math.ceil((((Date) presentTimeObj).getTime() - ((Date)
* pickTimeObj).getTime()) / 1000.0 / 60.0); insertCategoryTypeRecord(docSeq,
* disasterTime, STATISTICS_PRESENT_CATEGORY, presentTimeByMinute); } } }
*
*//** 获取标签值 */
/*
* private Object getValueFromTag(KnowledgeTagInstanceModel tag) { if
* (ValidationUtil.isEmpty(tag) || !ValidationUtil.equals(tag.getTagType(),
* 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
* DateUtil.formatStringToDate(tagValue, null); } catch (Exception e) {
* logger.error("报表统计:时间格式标签值解析出错"); return null; } case
* TagValueService.VALUE_TAG_FIELD_SINGLEVALUE: try { return
* Double.parseDouble(tagValue); } catch (Exception e) {
* logger.error("报表统计:数字格式标签值解析出错"); return null; } case
* TagValueService.VALUE_TAG_FIELD_TEXT: return tagValue; default: return null;
* } }
*
*//** 插入分类统计记录 */
/*
* private void insertCategoryTypeRecord(Long docSeq, Date disasterTime, String
* recordName, Object category) { KnowlegeStatisticsRecordModel recordModel =
* new KnowlegeStatisticsRecordModel(); recordModel.setDocSeq(docSeq);
* recordModel.setDisasterTime(disasterTime);
* recordModel.setRecordName(recordName);
* recordModel.setCategoryValue(String.valueOf(category));
* recordModel.setValueWeight(1); recordModel.setCountValue(1L);
* this.createWithModel(recordModel); }
*
*
*//** 插入数量统计记录 */
/*
* private void insertSumTypeRecord(Long docSeq, Date disasterTime, String
* recordName, Object numObj, Integer weight) { if
* (!ValidationUtil.isEmpty(numObj) && numObj instanceof Double) { Long num =
* ((Double) numObj).longValue(); KnowlegeStatisticsRecordModel recordModel =
* new KnowlegeStatisticsRecordModel(); recordModel.setDocSeq(docSeq);
* recordModel.setDisasterTime(disasterTime);
* recordModel.setRecordName(recordName); recordModel.setCountValue(num);
* recordModel.setValueWeight(weight); this.createWithModel(recordModel); } }
*
*//**
* 根据文档id删除相关记录
*/
/*
* public void deleteRecordsByDocIds(List<KnowledgeDocContentModel> docs) { if
* (!ValidationUtil.isEmpty(docs)) { Set ids = Bean.listToMap(docs,
* "sequenceNbr", KnowledgeDocContentModel.class).keySet();
* QueryWrapper<KnowlegeStatisticsRecord> wrapper = new QueryWrapper<>();
* wrapper.in("doc_seq", ids); this.getBaseMapper().delete(wrapper); } }
*
*//**
* 初始化统计数据记录
*
* @return
*/
/*
* @Transactional(rollbackFor = {Exception.class, BaseException.class}) public
* boolean init() { this.getBaseMapper().deleteAll(); //扫描所有已发布文档相关的统计型标签
* QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
* wrapper.eq("doc_status", DocContentService.DOC_STATUS_PUBLISHED); int count =
* docContentService.count(wrapper); int finishNmu = 0; int current = 0; while
* (count > finishNmu) { Page page = new Page(current++, 30); IPage resPage =
* docContentService.page(page, wrapper); List<KnowledgeDocContent> records =
* resPage.getRecords(); Set ids = Bean.listToMap(records, "sequenceNbr",
* KnowledgeDocContent.class).keySet(); saveRecordsByDocIds(ids); finishNmu +=
* records.size(); } return true; }
*
* 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 class StatisticsRecordService extends BaseService<KnowlegeStatisticsRecordModel, KnowlegeStatisticsRecord, StatisticsRecordMapper> {
/*@Autowired
private DocContentService docContentService;
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_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_CASUALTIES = "人员伤亡情况 含亡人";
public static final String STATISTICS_CASUALTIES_SUM = "CASUALTIES_RECORD";
*//**
* 灭火药剂统计
*//*
public static final String TAG_NAME_EXTINGUISHING = "使用的灭火药剂数量";
public static final String STATISTICS_EXTINGUISHING_SUM = "EXTINGUISHING_RECORD";
*//**
* 过火面积统计
*//*
public static final String TAG_NAME_AREA = "过火面积";
public static final String STATISTICS_AREA_COUNT = "FIRE_AREA_RECORD";
*//**
* 到场时间分类
*//*
public static final String TAG_NAME_PICKUP = "接警时间";
public static final String TAG_NAME_PRESENT = "到场时间";
public static final String STATISTICS_PRESENT_CATEGORY = "PRESENT_TIME_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}")
private boolean needRecord;
*//** 根据文档标签添加对应的记录 *//*
private void addRecordWithDocValueTag(List<KnowledgeTagInstanceModel> docTags, Long docSeq) {
//找出预定义的所有标签
Map<Object, KnowledgeTagInstanceModel> tagMap = Bean.listToMap(docTags, "tagName", KnowledgeTagInstanceModel.class);
KnowledgeTagInstanceModel tagTime = tagMap.get(TAG_NAME_TIME);
if (ValidationUtil.isEmpty(tagTime)) {
return;
}
Object timeObj = getValueFromTag(tagTime);
if (ValidationUtil.isEmpty(timeObj) || !(timeObj instanceof Date)) {
return;
}
Date disasterTime = (Date) timeObj;
//记录灾情
insertSumTypeRecord(docSeq, disasterTime, STATISTICS_DISASTER_COUNT, 1.0, 1);
//记录燃烧物质
KnowledgeTagInstanceModel tagBurning = tagMap.get(TAG_NAME_BURNING);
if (!ValidationUtil.isEmpty(tagBurning)) {
insertCategoryTypeRecord(docSeq, disasterTime, STATISTICS_BURNING_CATEGORY, getValueFromTag(tagBurning));
}
//记录参战车辆
KnowledgeTagInstanceModel tagPower = tagMap.get(TAG_NAME_POWER);
if (!ValidationUtil.isEmpty(tagPower)) {
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 tagExtinguishing = tagMap.get(TAG_NAME_EXTINGUISHING);
if (!ValidationUtil.isEmpty(tagExtinguishing)) {
insertSumTypeRecord(docSeq, disasterTime, STATISTICS_EXTINGUISHING_SUM, getValueFromTag(tagExtinguishing), 1);
}
//记录过火面积
KnowledgeTagInstanceModel tagArea = tagMap.get(TAG_NAME_AREA);
if (!ValidationUtil.isEmpty(tagArea)) {
insertSumTypeRecord(docSeq, disasterTime, STATISTICS_AREA_COUNT, getValueFromTag(tagArea), 1);
}
//记录到场时间
KnowledgeTagInstanceModel tagPickup = tagMap.get(TAG_NAME_PICKUP);
KnowledgeTagInstanceModel tagPresent = tagMap.get(TAG_NAME_PRESENT);
if (!ValidationUtil.isEmpty(tagPickup) && !ValidationUtil.isEmpty(tagPresent)) {
Object pickTimeObj = getValueFromTag(tagPickup);
Object presentTimeObj = getValueFromTag(tagPresent);
if (!ValidationUtil.isEmpty(pickTimeObj) && pickTimeObj instanceof Date
&& !ValidationUtil.isEmpty(presentTimeObj) && presentTimeObj instanceof Date) {
long presentTimeByMinute = (long) Math.ceil((((Date) presentTimeObj).getTime() - ((Date) pickTimeObj).getTime()) / 1000.0 / 60.0);
insertCategoryTypeRecord(docSeq, disasterTime, STATISTICS_PRESENT_CATEGORY, presentTimeByMinute);
}
}
}
*//** 获取标签值 *//*
private Object getValueFromTag(KnowledgeTagInstanceModel tag) {
if (ValidationUtil.isEmpty(tag)
|| !ValidationUtil.equals(tag.getTagType(), 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 DateUtil.formatStringToDate(tagValue, null);
} catch (Exception e) {
logger.error("报表统计:时间格式标签值解析出错");
return null;
}
case TagValueService.VALUE_TAG_FIELD_SINGLEVALUE:
try {
return Double.parseDouble(tagValue);
} catch (Exception e) {
logger.error("报表统计:数字格式标签值解析出错");
return null;
}
case TagValueService.VALUE_TAG_FIELD_TEXT:
return tagValue;
default:
return null;
}
}
*//** 插入分类统计记录 *//*
private void insertCategoryTypeRecord(Long docSeq, Date disasterTime, String recordName, Object category) {
KnowlegeStatisticsRecordModel recordModel = new KnowlegeStatisticsRecordModel();
recordModel.setDocSeq(docSeq);
recordModel.setDisasterTime(disasterTime);
recordModel.setRecordName(recordName);
recordModel.setCategoryValue(String.valueOf(category));
recordModel.setValueWeight(1);
recordModel.setCountValue(1L);
this.createWithModel(recordModel);
}
*//** 插入数量统计记录 *//*
private void insertSumTypeRecord(Long docSeq, Date disasterTime, String recordName, Object numObj, Integer weight) {
if (!ValidationUtil.isEmpty(numObj) && numObj instanceof Double) {
Long num = ((Double) numObj).longValue();
KnowlegeStatisticsRecordModel recordModel = new KnowlegeStatisticsRecordModel();
recordModel.setDocSeq(docSeq);
recordModel.setDisasterTime(disasterTime);
recordModel.setRecordName(recordName);
recordModel.setCountValue(num);
recordModel.setValueWeight(weight);
this.createWithModel(recordModel);
}
}
*//**
* 根据文档id删除相关记录
*//*
public void deleteRecordsByDocIds(List<KnowledgeDocContentModel> docs) {
if (!ValidationUtil.isEmpty(docs)) {
Set ids = Bean.listToMap(docs, "sequenceNbr", KnowledgeDocContentModel.class).keySet();
QueryWrapper<KnowlegeStatisticsRecord> wrapper = new QueryWrapper<>();
wrapper.in("doc_seq", ids);
this.getBaseMapper().delete(wrapper);
}
}
*//**
* 初始化统计数据记录
*
* @return
*//*
@Transactional(rollbackFor = {Exception.class, BaseException.class})
public boolean init() {
this.getBaseMapper().deleteAll();
//扫描所有已发布文档相关的统计型标签
QueryWrapper<KnowledgeDocContent> wrapper = new QueryWrapper<>();
wrapper.eq("doc_status", DocContentService.DOC_STATUS_PUBLISHED);
int count = docContentService.count(wrapper);
int finishNmu = 0;
int current = 0;
while (count > finishNmu) {
Page page = new Page(current++, 30);
IPage resPage = docContentService.page(page, wrapper);
List<KnowledgeDocContent> records = resPage.getRecords();
Set ids = Bean.listToMap(records, "sequenceNbr", KnowledgeDocContent.class).keySet();
saveRecordsByDocIds(ids);
finishNmu += records.size();
}
return true;
}
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) {
endDate = getLastDayOfMonth(endDate);
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
......
package com.yeejoin.amos.knowledgebase.face.service;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
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.stereotype.Component;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -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.service.BaseService;
import com.baomidou.mybatisplus.core.toolkit.Sequence;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeDynamicsValueModel;
import com.yeejoin.amos.knowledgebase.face.model.KnowledgeTagInstanceModel;
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 com.yeejoin.amos.knowledgebase.face.util.Constants;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/**
......@@ -36,6 +34,10 @@ import com.yeejoin.amos.knowledgebase.face.util.Constants;
@Component
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
private TagValueService tagValueService;
......@@ -72,11 +74,11 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K
instanceModel.setTagType(tagModel.getTagType());
//值标签保存标签的具体值
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());
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"));
List<KnowledgeTagValueModel> savedValues = this.tagValueService.saveInstanceValue(instanceSeq, valueModels,unit);
List<KnowledgeTagValueModel> savedValues = this.tagValueService.saveInstanceValue(instanceSeq, valueModels, unit);
instanceModel.setTagValues(savedValues);
}
this.createWithModel(instanceModel);
......@@ -111,7 +113,9 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K
// return this.queryCount(tagSeq, targetSeq);
// }
/** 根据标签ID统计标签实例数量 */
/**
* 根据标签ID统计标签实例数量
*/
public int queryCountByTagSeq(Long tagSeq) {
return this.queryCount(tagSeq);
}
......@@ -136,10 +140,10 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K
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)) {
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());
instanceModel.setTagValues(list);
}
......@@ -156,15 +160,7 @@ public class TagInstanceService extends BaseService<KnowledgeTagInstanceModel, K
return this.queryForList(null, false, targetSeq);
}
public KnowledgeTagInstance findById(Long id) {
return this.baseMapper.selectById(id);
}
public List<KnowledgeTagInstanceModel> queryListByTagName(String tagName) {
// TODO Auto-generated method stub
return this.queryForList(null, false, tagName);
}
public List<KnowledgeTagInstanceModel> queryTopTagListByUser(String recUserId) {
return this.queryForList("REC_DATE", true, recUserId);
}
}
......@@ -3,15 +3,14 @@ package com.yeejoin.amos.knowledgebase.face.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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.feign.RemoteData;
import com.yeejoin.amos.knowledgebase.face.model.*;
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.KnowledgeTag;
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.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
......@@ -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.RequestForbidden;
import java.io.Serializable;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
/**
......@@ -41,6 +43,27 @@ import java.util.*;
@Component
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
private TagGroupService tagGroupService;
@Autowired
......@@ -73,7 +96,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
}
Long sequenceNbr = sequence.nextId();
model.setSequenceNbr(sequenceNbr);
model.setTagStatus(Constants.TAG_STATUS_ACTIVATE);
model.setTagStatus(TAG_STATUS_DEACTIVATE);
model.setAgencyCode(RequestContext.getAgencyCode());
model.setCreator(RequestContext.getExeUserId());
//创建标签-分组关联关系
......@@ -101,7 +124,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
throw new BadRequest("标签名称不可重复");
}
//判断标签状态
if (ValidationUtil.equals(oldTagModel.getTagStatus(), Constants.TAG_STATUS_ACTIVATE)) {
if (ValidationUtil.equals(oldTagModel.getTagStatus(), TAG_STATUS_ACTIVATE)) {
throw new BadRequest("启用状态的标签不允许编辑");
}
Long sequenceNbr = oldTagModel.getSequenceNbr();
......@@ -115,12 +138,12 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
}
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();
if (!ValidationUtil.isEmpty(tagValues)) {
dynamicsValueService.saveValueList(tagValues, sequenceNbr,
DynamicsFunctional.VALUE_TAG_CONFIG,
Constants.APPKEY_ALL);
APPKEY_ALL);
}
}
}
......@@ -161,7 +184,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
* @param tagName 标签名称
* @param tagCode 标签代码
* @param tagStatus 标签状态
* @return Map<首字母String , 列表List>
* @return Map<首字母String, 列表List>
*/
public Map<String, List<KnowledgeTagModel>> queryTagMap(Long groupSeq, String tagName, String tagCode, String tagStatus) {
Map<String, List<KnowledgeTagModel>> resMap = new TreeMap<>();
......@@ -240,7 +263,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
tagIdList = StringUtil.String2LongList(tags);
}
for (KnowledgeTagModel tagModel : tagModels) {
if (ValidationUtil.equals(tagModel.getTagStatus(), Constants.TAG_STATUS_ACTIVATE)) {
if (ValidationUtil.equals(tagModel.getTagStatus(), TAG_STATUS_ACTIVATE)) {
throw new RequestForbidden("包含启用状态的标签,不允许删除");
}
if (tagIsQuoted(tagModel.getSequenceNbr())) {
......@@ -360,26 +383,41 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
*/
public List<KnowledgeTagModel> queryTopList(boolean isAll) {
List<KnowledgeTagModel> res = new LinkedList<>();
String operateType = isAll ? InteractionCountService.QUOTE_TYPE_ALL : InteractionCountService.QUOTE_TYPE_PUBLISH;
List<KnowledgeInteractionCountModel> countModels = interactionCountService.queryTop(15, operateType, InteractionCountService.QUOTE_ENTITY_TAG, RequestContext.getAgencyCode());
for (KnowledgeInteractionCountModel countModel : countModels) {
if (countModel.getOperateCount() > 0) {
KnowledgeTagModel tagModel = this.queryBySeq(Long.valueOf(countModel.getEntityId()));
if (!ValidationUtil.isEmpty(tagModel)) {
res.add(tagModel);
}
} else {
break;
}
List<? extends Serializable> tagSeqsCollect = new ArrayList<>();
List<KnowledgeTagModel> knowledgeTagTopList = new ArrayList<>();
//查询标签实例表,查询当前用户常用的标签
List<KnowledgeTagInstanceModel> knowledgeTagInstanceModels = tagInstanceService.queryTopTagListByUser(RequestContext.getExeUserId());
List<Long> tagSeqsByInstance = knowledgeTagInstanceModels.stream().map(KnowledgeTagInstanceModel::getTagSeq).collect(Collectors.toList());
if (ValidationUtil.isEmpty(tagSeqsByInstance) || tagSeqsByInstance.size() < 15) {
//查询标签使用统计表,查询当前机构常用的标签
String operateType = isAll ? InteractionCountService.QUOTE_TYPE_ALL : InteractionCountService.QUOTE_TYPE_PUBLISH;
List<KnowledgeInteractionCountModel> countModels = interactionCountService.queryTop(15, operateType, InteractionCountService.QUOTE_ENTITY_TAG, RequestContext.getAgencyCode());
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) {
tagAddDynamicsValues(tagModel);
if (!ValidationUtil.isEmpty(tagSeqsCollect)) {
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;
}
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<>();
for (KnowledgeTag tag : tagList) {
KnowledgeTagModel tagModel = new KnowledgeTagModel();
......@@ -393,7 +431,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
}
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());
if (!ValidationUtil.isEmpty(valueModels)) {
Map fieldsMap = Bean.listToMap(valueModels, "fieldName", KnowledgeDynamicsValueModel.class);
......@@ -417,7 +455,7 @@ public class TagService extends BaseService<KnowledgeTagModel, KnowledgeTag, Tag
throw new BadRequest("参数有误");
}
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);
return docContentService.list(wrapper);
}
......
package com.yeejoin.amos.knowledgebase.face.service;
import java.util.Arrays;
import java.util.Collection;
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 org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import org.typroject.tyboot.core.foundation.context.RequestContext;
......@@ -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.rdbms.service.BaseService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
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;
import java.util.Collection;
import java.util.List;
/**
......@@ -33,6 +27,15 @@ import net.bytebuddy.asm.Advice.This;
@Component
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})
public List<KnowledgeTagValueModel> saveInstanceValue(Long instanceSeq, List<KnowledgeTagValueModel> valueModels, String unit) {
......@@ -71,13 +74,4 @@ public class TagValueService extends BaseService<KnowledgeTagValueModel, Knowled
public List<KnowledgeTagValueModel> queryTagValuesByDocIds(Collection<Long> docSeqList) {
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 @@
</exclusion>
</exclusions>
</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>
<build>
......
......@@ -332,7 +332,7 @@ public class TzsAppService {
JSONObject object = JSON.parseObject(JSON.toJSONString(obj));
if (!ValidationUtil.isEmpty(object)) {
object.getString("url");
object.put("url", minioPath + object.getString("url"));
object.put("url",object.getString("url"));
json.add(object);
}
}
......@@ -378,7 +378,7 @@ public class TzsAppService {
Map<String, String> map = date.getResult();
Iterator<String> it = map.keySet().iterator();
String urlString = it.next();
jsonObject.put("fileUrl", minioPath + urlString);
jsonObject.put("fileUrl", urlString);
jsonObject.put("fileName", code);
}
} catch (IOException e) {
......
......@@ -21,6 +21,7 @@ import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
......@@ -47,6 +48,12 @@ public class CylinderFillingRecordServiceImpl extends BaseService<CylinderFillin
@Autowired
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
Page<ESCylinderFillingRecordDto> result = new Page<ESCylinderFillingRecordDto>(pageNum, pageSize);
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();
......
......@@ -129,6 +129,12 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
@Value("${cylinder-early-warning-packageId:气瓶消息预警/cylwarningmsg}")
private String cylPackageId;
@Value("${biz.elasticsearch.address}")
private String esAddress;
@Value("${biz.elasticsearch.port}")
private Integer esPort;
@Autowired
StartPlatformTokenService startPlatformTokenService;
......@@ -711,7 +717,7 @@ public class CylinderInfoServiceImpl extends BaseService<CylinderInfoDto, Cylind
Page<ESCylinderInfoDto> result = new Page<ESCylinderInfoDto>(pageNum, pageSize);
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();
......
......@@ -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
## ES properties:
biz.elasticsearch.port=9200
biz.elasticsearch.address=36.46.151.113
spring.data.elasticsearch.cluster-name=docker-cluster
spring.data.elasticsearch.cluster-nodes=${biz.elasticsearch.address}:9300
......
......@@ -294,7 +294,7 @@
<repository>
<id>Releases</id>
<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>
<id>com.e-iceblue</id>
......@@ -305,13 +305,13 @@
<repository>
<id>Snapshots</id>
<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>
<id>thirdparty</id>
<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>
</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