|
@@ -1,23 +1,25 @@
|
|
|
package com.fdkankan.site.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fdkankan.site.common.PageInfo;
|
|
|
import com.fdkankan.site.common.RequestBase;
|
|
|
+import com.fdkankan.site.common.util.JwtUtil;
|
|
|
import com.fdkankan.site.entity.Project;
|
|
|
import com.fdkankan.site.entity.ProjectLog;
|
|
|
import com.fdkankan.site.mapper.IProjectLogMapper;
|
|
|
import com.fdkankan.site.response.ProjectLogVo;
|
|
|
+import com.fdkankan.site.response.SceneVo;
|
|
|
import com.fdkankan.site.service.IProjectLogService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.site.service.IProjectService;
|
|
|
+import com.fdkankan.site.service.ISceneService;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Set;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -33,6 +35,8 @@ public class ProjectLogServiceImpl extends ServiceImpl<IProjectLogMapper, Projec
|
|
|
|
|
|
@Autowired
|
|
|
IProjectService projectService;
|
|
|
+ @Autowired
|
|
|
+ ISceneService sceneService;
|
|
|
|
|
|
@Override
|
|
|
public PageInfo pageList(RequestBase param) {
|
|
@@ -40,6 +44,19 @@ public class ProjectLogServiceImpl extends ServiceImpl<IProjectLogMapper, Projec
|
|
|
List<ProjectLogVo> voList = new ArrayList<>();
|
|
|
Set<Integer> projectIds = page.getRecords().stream().map(ProjectLog::getProjectId).collect(Collectors.toSet());
|
|
|
HashMap<Integer,Project> projectHashMap = projectService.getByIds(projectIds);
|
|
|
+
|
|
|
+ Set<String> numSet = new HashSet<>();
|
|
|
+ Set<String> numListSet = page.getRecords().stream().map(ProjectLog::getNum).collect(Collectors.toSet());
|
|
|
+ for (String num : numListSet) {
|
|
|
+ List<String> list = JSONObject.parseObject(num, List.class);
|
|
|
+ numSet.addAll(list);
|
|
|
+ }
|
|
|
+ List<SceneVo> sceneVoList = sceneService.getListByNumList(new ArrayList<>(numSet));
|
|
|
+ HashMap<String,String> sceneNameMap = new HashMap<>();
|
|
|
+ for (SceneVo sceneVo : sceneVoList) {
|
|
|
+ sceneNameMap.put(sceneVo.getNum(),sceneVo.getSceneName());
|
|
|
+ }
|
|
|
+
|
|
|
for (ProjectLog record : page.getRecords()) {
|
|
|
ProjectLogVo vo = new ProjectLogVo();
|
|
|
BeanUtils.copyProperties(record,vo);
|
|
@@ -47,6 +64,24 @@ public class ProjectLogServiceImpl extends ServiceImpl<IProjectLogMapper, Projec
|
|
|
if(project != null){
|
|
|
vo.setProjectName(project.getProjectName());
|
|
|
}
|
|
|
+ if(StringUtils.isNotBlank(record.getNum())){
|
|
|
+ String nameList = null;
|
|
|
+ List<String> list = JSONObject.parseObject(record.getNum(), List.class);
|
|
|
+ List<String> sceneNameList = new ArrayList<>();
|
|
|
+ for (String num : list) {
|
|
|
+ String name = sceneNameMap.get(num);
|
|
|
+ if(StringUtils.isNotBlank(name)){
|
|
|
+ sceneNameList.add(name);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(sceneNameList.size() >0){
|
|
|
+ nameList = sceneNameList.stream().collect(Collectors.joining(","));
|
|
|
+ }
|
|
|
+ if(StringUtils.isNotBlank(nameList)){
|
|
|
+ record.setLogMsg(record.getLogMsg() + ":"+nameList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
voList.add(vo);
|
|
|
}
|
|
|
Page<ProjectLogVo> voPage = new Page<>(param.getPageNum(),param.getPageSize());
|
|
@@ -54,4 +89,19 @@ public class ProjectLogServiceImpl extends ServiceImpl<IProjectLogMapper, Projec
|
|
|
voPage.setTotal(page.getTotal());
|
|
|
return PageInfo.PageInfo(voPage);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void addLog(Integer projectId, String logMsg, String token, List<String> numList) {
|
|
|
+ try {
|
|
|
+ ProjectLog log = new ProjectLog();
|
|
|
+ log.setProjectId(projectId);
|
|
|
+ log.setUserName(JwtUtil.getUserName(token));
|
|
|
+ log.setLogMsg(logMsg);
|
|
|
+ log.setNum(JSONObject.toJSONString(numList));
|
|
|
+ this.save(log);
|
|
|
+ }catch (Exception e){
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|