feat(项目仪表盘):#132587 项目仪表盘中知识库类型动态转换
This commit is contained in:
parent
6dc2dda918
commit
30daa7b00c
|
@ -7,10 +7,7 @@ import com.microservices.system.api.domain.SysLogininfor;
|
|||
import com.microservices.system.api.domain.SysOperLog;
|
||||
import com.microservices.system.api.factory.RemoteLogFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestHeader;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -45,10 +42,13 @@ public interface RemoteLogService
|
|||
/**
|
||||
* 获取操作日志列表
|
||||
*
|
||||
|
||||
* @param title 日志标题
|
||||
* @param operUrl 操作地址
|
||||
* @param status 操作状态
|
||||
* @param topN 获取最新N条
|
||||
* @return 操作日志列表
|
||||
*/
|
||||
@PostMapping("/latest")
|
||||
@GetMapping("/operlog/latest")
|
||||
R<List<SysOperLog>> getLatestOperLogList(@RequestParam(value = "title", required = false) String title,
|
||||
@RequestParam(value = "operUrl", required = false) String operUrl,
|
||||
@RequestParam(value = "status", required = false) Integer status,
|
||||
|
|
|
@ -42,7 +42,7 @@ public class RemoteLogFallbackFactory implements FallbackFactory<RemoteLogServic
|
|||
@Override
|
||||
public R<List<SysOperLog>> getLatestOperLogList(String title, String operUrl, Integer status, Integer topN, String source)
|
||||
{
|
||||
return null;
|
||||
return R.fail("获取最新操作日志失败:" + throwable.getMessage());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
|
|||
|
||||
public static String YYYY_MM_DD_HH_MM_SS = "yyyy-MM-dd HH:mm:ss";
|
||||
|
||||
public static String YYYY_MM_DD_HH_MM = "yyyy-MM-dd HH:mm";
|
||||
|
||||
private static String[] parsePatterns = {
|
||||
"yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
|
||||
"yyyy/MM/dd", "yyyy/MM/dd HH:mm:ss", "yyyy/MM/dd HH:mm", "yyyy/MM",
|
||||
|
|
|
@ -114,7 +114,9 @@ public class PmsDocumentController extends BaseController {
|
|||
@ApiOperation(value = "删除项目管理-文档库")
|
||||
public AjaxResult remove(@PathVariable Long[] ids,
|
||||
@ApiParam("企业id") @RequestParam(name = "enterpriseId") Long enterpriseId,
|
||||
@ApiParam("项目id") @RequestParam(name = "pmsProjectId", defaultValue = "0") Long pmsProjectId) {
|
||||
@ApiParam("项目id") @RequestParam(name = "pmsProjectId", defaultValue = "0") Long pmsProjectId,
|
||||
@ApiParam("文档名称,多个逗号分隔") @RequestParam(name = "names", required = false) String names,
|
||||
@ApiParam("文件类型 1-文档目录 2-文档 3-附件 4-wiki库,多个逗号分隔") @RequestParam(name = "docTypes", required = false) String docTypes) {
|
||||
return toAjax(pmsDocumentService.deletePmsDocumentByIds(ids, enterpriseId, pmsProjectId));
|
||||
}
|
||||
|
||||
|
|
|
@ -303,10 +303,10 @@ public class PmsProjectIssuesService {
|
|||
|
||||
private JSONObject genDeleteUserJsonObject() {
|
||||
SysUser deleteUser = SysUser.genDeleteUser();
|
||||
return getUserJsonObject(deleteUser.getGitlinkUserId(), deleteUser.getAvatar(), deleteUser.getUserName(), deleteUser.getNickName(), simpleSysUser);
|
||||
return getUserJsonObject(deleteUser.getGitlinkUserId(), deleteUser.getAvatar(), deleteUser.getUserName(), deleteUser.getNickName());
|
||||
}
|
||||
|
||||
public JSONObject getUserJsonObject(Long gitlinkUserId, String avatar, String userName, String nickName, SimpleSysUser simpleSysUser) {
|
||||
public JSONObject getUserJsonObject(Long gitlinkUserId, String avatar, String userName, String nickName) {
|
||||
JSONObject user = new JSONObject();
|
||||
user.put("id", gitlinkUserId);
|
||||
user.put("image_url", avatar);
|
||||
|
|
|
@ -109,10 +109,9 @@ public class PmsProjectServiceImpl implements IPmsProjectService {
|
|||
@Autowired
|
||||
private RemoteLogService remoteLogService;
|
||||
|
||||
@Resource
|
||||
private PmsDocumentMapper pmsDocumentMapper;
|
||||
|
||||
private static final Logger logger = LoggerFactory.getLogger(PmsProjectServiceImpl.class);
|
||||
@Autowired
|
||||
private PmsDocumentMapper pmsDocumentMapper;
|
||||
|
||||
/**
|
||||
* 查询项目
|
||||
|
@ -589,7 +588,7 @@ public class PmsProjectServiceImpl implements IPmsProjectService {
|
|||
String operUrl = String.format("/%s/document", pmsEnterprise.getEnterpriseIdentifier());
|
||||
|
||||
List<SysOperLog> sysOperLogList = FeignUtils.getReturnData(
|
||||
remoteLogService.getLatestOperLogList("项目管理-文档库", operUrl, 1, 10, SecurityConstants.INNER));
|
||||
remoteLogService.getLatestOperLogList("项目管理-文档库", operUrl, 0, 10, SecurityConstants.INNER));
|
||||
return sysOperLogList != null ? transferDocumentDynamics(sysOperLogList) : new JSONArray();
|
||||
}
|
||||
|
||||
|
@ -597,33 +596,46 @@ public class PmsProjectServiceImpl implements IPmsProjectService {
|
|||
JSONArray journals = new JSONArray();
|
||||
for (SysOperLog log : sysOperLogList) {
|
||||
JSONObject documentDynamics = new JSONObject();
|
||||
JSONObject user = buildUserJson(pmsCommonService.getSimpleSysUserByUsername(log.getOperName()));
|
||||
documentDynamics.put("user", user);
|
||||
|
||||
Date operTime = log.getOperTime();
|
||||
Long operTimeUnix = DateUtils.dateTimeToUnix(operTime);
|
||||
documentDynamics.put("created_at", operTime);
|
||||
documentDynamics.put("updated_at", operTime);
|
||||
documentDynamics.put("operate_time", operTimeUnix);
|
||||
documentDynamics.put("updated_time", operTimeUnix);
|
||||
|
||||
JSONObject operParam = JSONObject.parseObject(log.getOperParam());
|
||||
Integer pmsProjectId = operParam.getInteger("pmsProjectId");
|
||||
if (pmsProjectId == 0) {
|
||||
continue;
|
||||
}
|
||||
Long documentId = operParam.getLong("id");
|
||||
String docName = operParam.getString("name");
|
||||
Integer docType = operParam.getInteger("docType");
|
||||
Integer isTop = operParam.getInteger("isTop");
|
||||
Integer businessType = log.getBusinessType();
|
||||
String operateContent;
|
||||
|
||||
Date operTime = log.getOperTime();
|
||||
Long operTimeUnix = DateUtils.dateTimeToUnix(operTime);
|
||||
documentDynamics.put("created_at", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, operTime));
|
||||
documentDynamics.put("updated_at", DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM, operTime));
|
||||
documentDynamics.put("created_time", operTimeUnix);
|
||||
documentDynamics.put("updated_time", operTimeUnix);
|
||||
|
||||
JSONObject user = buildUserJson(pmsCommonService.getSimpleSysUserByUsername(log.getOperName()));
|
||||
documentDynamics.put("user", user);
|
||||
|
||||
if (BusinessType.DELETE.ordinal() == businessType) {
|
||||
String operUrl = log.getOperUrl();
|
||||
Long docId = Long.valueOf(operUrl.substring(operUrl.lastIndexOf("/") + 1));
|
||||
PmsDocument pmsDocument = pmsDocumentMapper.selectPmsDocumentById(docId);
|
||||
String docNames = operParam.getString("names");
|
||||
String docTypes = operParam.getString("docTypes");
|
||||
operateContent = generateBatchDeleteOperateContent(docNames, docTypes);
|
||||
} else {
|
||||
if (isTop != null && isTop == 1) {
|
||||
PmsDocument pmsDocument = pmsDocumentMapper.selectPmsDocumentById(documentId);
|
||||
if (pmsDocument != null) {
|
||||
docName = pmsDocument.getName();
|
||||
docType = pmsDocument.getDocType();
|
||||
}
|
||||
}
|
||||
String docTypeName = PmsDocumentType.getNameByKey(docType);
|
||||
if (docName == null || docType == null) {
|
||||
continue;
|
||||
}
|
||||
operateContent = generateOperateContent(businessType, docType, docName, isTop);
|
||||
}
|
||||
|
||||
String operateContent = generateOperateContent(businessType, docType, docName, docTypeName, isTop);
|
||||
if (operateContent != null) {
|
||||
documentDynamics.put("operate_content", operateContent);
|
||||
journals.add(documentDynamics);
|
||||
|
@ -632,13 +644,39 @@ public class PmsProjectServiceImpl implements IPmsProjectService {
|
|||
return journals;
|
||||
}
|
||||
|
||||
private String generateOperateContent(Integer businessType, Integer docType, String docName, String docTypeName, Integer isTop) {
|
||||
private String generateBatchDeleteOperateContent(String docNames, String docTypes) {
|
||||
if (docNames == null || docTypes == null) {
|
||||
return null;
|
||||
}
|
||||
String[] nameArray = docNames.split(",");
|
||||
String[] typeArray = docTypes.split(",");
|
||||
if (nameArray.length != typeArray.length) {
|
||||
return null;
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("在知识库删除了");
|
||||
for (int i = 0; i < nameArray.length; i++) {
|
||||
if (i > 0) {
|
||||
sb.append(" , ");
|
||||
}
|
||||
sb.append("<b>").append(nameArray[i]).append("</b>");
|
||||
sb.append(getNameByKey(Integer.parseInt(typeArray[i])));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private static String getNameByKey(Integer docType) {
|
||||
return PmsDocumentType.getNameByKey(docType);
|
||||
}
|
||||
|
||||
private String generateOperateContent(Integer businessType, Integer docType, String docName, Integer isTop) {
|
||||
String docTypeName = getNameByKey(docType);
|
||||
switch (businessType) {
|
||||
case 1: //新增
|
||||
return String.format("在知识库%s了<b>%s</b>%s",
|
||||
docType == PmsDocumentType.ATTACHMENT.getKey() ? "上传" : "新建", docName, docTypeName);
|
||||
case 2: //更新
|
||||
return String.format("在知识库%s了<b>%s</b>%s", isTop == 1 ? "置顶" : "更新", docName, docTypeName);
|
||||
return String.format("在知识库%s了<b>%s</b>%s", (isTop != null && isTop == 1) ? "置顶" : "更新", docName, docTypeName);
|
||||
case 3: //删除
|
||||
return String.format("在知识库删除了<b>%s</b>%s", docName, docTypeName);
|
||||
default:
|
||||
|
@ -647,7 +685,7 @@ public class PmsProjectServiceImpl implements IPmsProjectService {
|
|||
}
|
||||
|
||||
private JSONObject buildUserJson(SimpleSysUser simpleSysUser) {
|
||||
return pmsProjectIssuesService.getUserJsonObject(simpleSysUser.getGitlinkUserId(), simpleSysUser.getAvatar(), simpleSysUser.getUserName(), simpleSysUser.getNickName(), simpleSysUser);
|
||||
return pmsProjectIssuesService.getUserJsonObject(simpleSysUser.getGitlinkUserId(), simpleSysUser.getAvatar(), simpleSysUser.getUserName(), simpleSysUser.getNickName());
|
||||
}
|
||||
|
||||
private void getTopNOrderedDynamics(JSONArray projectDynamics, int limit) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.microservices.system.controller;
|
||||
|
||||
import com.microservices.common.core.domain.R;
|
||||
import com.microservices.common.core.utils.poi.ExcelUtil;
|
||||
import com.microservices.common.core.web.controller.BaseController;
|
||||
import com.microservices.common.core.web.domain.AjaxResult;
|
||||
|
@ -77,11 +78,11 @@ public class SysOperlogController extends BaseController
|
|||
*/
|
||||
@InnerAuth
|
||||
@GetMapping("/latest")
|
||||
public List<SysOperLog> list(@RequestParam(value = "title", required = false) String title,
|
||||
public R<List<SysOperLog>> latestList(@RequestParam(value = "title", required = false) String title,
|
||||
@RequestParam(value = "operUrl", required = false) String operUrl,
|
||||
@RequestParam(value = "status", required = false) Integer status,
|
||||
@RequestParam(value = "topN") Integer topN)
|
||||
{
|
||||
return operLogService.selectLatestOperLogList(title, operUrl, status, topN);
|
||||
return R.ok(operLogService.selectLatestOperLogList(title, operUrl, status, topN));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<include refid="selectOperLogVo"/>
|
||||
where oper_id = #{operId}
|
||||
</select>
|
||||
<select id="selectLatestOperLogList" resultType="com.microservices.system.api.domain.SysOperLog">
|
||||
<select id="selectLatestOperLogList" resultMap="SysOperLogResult">
|
||||
<include refid="selectOperLogVo"/>
|
||||
<where>
|
||||
<if test="title != null and title != ''">
|
||||
|
@ -84,7 +84,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<if test="status != null">
|
||||
AND status = #{status}
|
||||
</if>
|
||||
<if test="oper_url != null and oper_url != ''">
|
||||
<if test="operUrl != null and operUrl != ''">
|
||||
AND oper_url like concat(#{operUrl}, '%')
|
||||
</if>
|
||||
</where>
|
||||
|
|
Loading…
Reference in New Issue