|
@@ -1,24 +1,28 @@
|
|
package cn.cslg.pas.service.business;
|
|
package cn.cslg.pas.service.business;
|
|
|
|
|
|
import cn.cslg.pas.common.dto.business.EventDTO;
|
|
import cn.cslg.pas.common.dto.business.EventDTO;
|
|
-import cn.cslg.pas.common.model.cronModel.GroupConfig;
|
|
|
|
-import cn.cslg.pas.common.model.cronModel.GroupVO;
|
|
|
|
|
|
+import cn.cslg.pas.common.model.cronModel.*;
|
|
import cn.cslg.pas.common.model.request.*;
|
|
import cn.cslg.pas.common.model.request.*;
|
|
|
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
|
|
|
|
+import cn.cslg.pas.common.vo.business.EventCountVO;
|
|
import cn.cslg.pas.common.vo.business.EventVO;
|
|
import cn.cslg.pas.common.vo.business.EventVO;
|
|
import cn.cslg.pas.domain.business.AssoEventFile;
|
|
import cn.cslg.pas.domain.business.AssoEventFile;
|
|
import cn.cslg.pas.domain.business.Event;
|
|
import cn.cslg.pas.domain.business.Event;
|
|
|
|
+import cn.cslg.pas.domain.business.SystemDict;
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
import cn.cslg.pas.factorys.businessFactory.Business;
|
|
import cn.cslg.pas.factorys.businessFactory.Business;
|
|
import cn.cslg.pas.factorys.reGroupFactory.QueryGroupFactory;
|
|
import cn.cslg.pas.factorys.reGroupFactory.QueryGroupFactory;
|
|
import cn.cslg.pas.factorys.reGroupFactory.QueryGroupImp;
|
|
import cn.cslg.pas.factorys.reGroupFactory.QueryGroupImp;
|
|
|
|
+import cn.cslg.pas.mapper.AssoProjectEventMapper;
|
|
import cn.cslg.pas.mapper.EventMapper;
|
|
import cn.cslg.pas.mapper.EventMapper;
|
|
import cn.cslg.pas.service.common.FileManagerService;
|
|
import cn.cslg.pas.service.common.FileManagerService;
|
|
|
|
+import cn.cslg.pas.service.permissions.PermissionService;
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
import cn.cslg.pas.service.query.FormatQueryService;
|
|
import com.alibaba.fastjson.JSON;
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -28,7 +32,9 @@ import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
+import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
|
+import java.util.Arrays;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -50,6 +56,15 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
@Autowired
|
|
@Autowired
|
|
private QueryGroupFactory queryGroupFactory;
|
|
private QueryGroupFactory queryGroupFactory;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private PermissionService permissionService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private SystemDictService systemDictService;
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private AssoProjectEventMapper assoProjectEventMapper;
|
|
|
|
+
|
|
public String getEvent(String sql) {
|
|
public String getEvent(String sql) {
|
|
eventMapper.getEvent(sql);
|
|
eventMapper.getEvent(sql);
|
|
return "";
|
|
return "";
|
|
@@ -89,16 +104,16 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
//根据sql查询事件信息
|
|
//根据sql查询事件信息
|
|
List<EventVO> eventVOS = eventMapper.getEvent(sql);
|
|
List<EventVO> eventVOS = eventMapper.getEvent(sql);
|
|
|
|
|
|
- //装载事件信息
|
|
|
|
|
|
+ //装载事件信息
|
|
this.loadEvent(eventVOS);
|
|
this.loadEvent(eventVOS);
|
|
- return "";
|
|
|
|
|
|
+ return eventVOS;
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Integer addMessage(Object object, List<MultipartFile> files) {
|
|
public Integer addMessage(Object object, List<MultipartFile> files) {
|
|
EventDTO eventDTO = (EventDTO) object;
|
|
EventDTO eventDTO = (EventDTO) object;
|
|
//检查事件格式
|
|
//检查事件格式
|
|
- if(eventDTO.getScenarioId()==null){
|
|
|
|
|
|
+ if (eventDTO.getScenarioId() == null) {
|
|
throw new XiaoShiException("参数错误");
|
|
throw new XiaoShiException("参数错误");
|
|
}
|
|
}
|
|
|
|
|
|
@@ -109,7 +124,7 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
queryWrapper.eq(Event::getName, name);
|
|
queryWrapper.eq(Event::getName, name);
|
|
List<Event> events = this.list(queryWrapper);
|
|
List<Event> events = this.list(queryWrapper);
|
|
if (events != null && events.size() != 0) {
|
|
if (events != null && events.size() != 0) {
|
|
- throw new XiaoShiException("参数错误");
|
|
|
|
|
|
+ throw new XiaoShiException("参数错误");
|
|
}
|
|
}
|
|
|
|
|
|
//事件入库
|
|
//事件入库
|
|
@@ -191,11 +206,14 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
|
|
|
/**
|
|
/**
|
|
* 查询事件分组信息
|
|
* 查询事件分组信息
|
|
|
|
+ *
|
|
* @param groupRequest
|
|
* @param groupRequest
|
|
* @return
|
|
* @return
|
|
* @throws Exception
|
|
* @throws Exception
|
|
*/
|
|
*/
|
|
public GroupVO getGroup(GroupRequest groupRequest) throws Exception {
|
|
public GroupVO getGroup(GroupRequest groupRequest) throws Exception {
|
|
|
|
+ String sql ="";
|
|
|
|
+
|
|
//合成检索式
|
|
//合成检索式
|
|
StringGroupRequest stringGroupRequest = null;
|
|
StringGroupRequest stringGroupRequest = null;
|
|
if (groupRequest instanceof MapGroupRequest) {
|
|
if (groupRequest instanceof MapGroupRequest) {
|
|
@@ -204,13 +222,12 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
stringGroupRequest = (StringGroupRequest) groupRequest;
|
|
stringGroupRequest = (StringGroupRequest) groupRequest;
|
|
}
|
|
}
|
|
String condition = stringGroupRequest.getSearchQuery();
|
|
String condition = stringGroupRequest.getSearchQuery();
|
|
-
|
|
|
|
- //将检索式转换为二叉树
|
|
|
|
- treeNode tree = expressManager.getInstance().Parse(condition, false);
|
|
|
|
-
|
|
|
|
- //格式化检索式
|
|
|
|
- String sql = formatQueryService.ToString((operateNode) tree);
|
|
|
|
-
|
|
|
|
|
|
+ if(condition!=null) {
|
|
|
|
+ //将检索式转换为二叉树
|
|
|
|
+ treeNode tree = expressManager.getInstance().Parse(condition, false);
|
|
|
|
+ //格式化检索式
|
|
|
|
+ sql = formatQueryService.ToString((operateNode) tree);
|
|
|
|
+ }
|
|
//格式化 分组
|
|
//格式化 分组
|
|
String json = CommonService.readJsonFile("event_group.json");
|
|
String json = CommonService.readJsonFile("event_group.json");
|
|
List<GroupConfig> groupConfigs = JSON.parseArray(json, GroupConfig.class);
|
|
List<GroupConfig> groupConfigs = JSON.parseArray(json, GroupConfig.class);
|
|
@@ -244,15 +261,145 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
return groupVO;
|
|
return groupVO;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 装载事件返回类
|
|
|
|
+ *
|
|
|
|
+ * @param eventVOs
|
|
|
|
+ */
|
|
|
|
+ private void loadEvent(List<EventVO> eventVOs) throws IOException {
|
|
|
|
+ List<Integer> createIds = new ArrayList<>();
|
|
|
|
+ List<Integer> clientIds = new ArrayList<>();
|
|
|
|
+ List<Integer> ids = new ArrayList<>();
|
|
|
|
+ List<EventCountVO> eventCountVOS = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ //获得所有文件的guid
|
|
|
|
+ eventVOs.forEach(
|
|
|
|
+ item -> {
|
|
|
|
+ if (item.getClientId() != null) {
|
|
|
|
+ clientIds.add(item.getClientId());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (item.getCreateId() != null) {
|
|
|
|
+ createIds.add(item.getCreateId());
|
|
|
|
+ }
|
|
|
|
+ if (item.getId() != null) {
|
|
|
|
+ ids.add(item.getId());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+ List<Personnel> personnels = new ArrayList<>();
|
|
|
|
+ List<Client> clients = new ArrayList<>();
|
|
|
|
+ List<String> guids = new ArrayList<>();
|
|
|
|
+ List<SystemFile> systemFiles = new ArrayList<>();
|
|
|
|
+ List<AssoEventFile> assoEventFiles = new ArrayList<>();
|
|
|
|
|
|
- private void loadEvent(List<EventVO> eventVO){
|
|
|
|
- //查询创建人名称
|
|
|
|
|
|
+ if (ids.size() != 0) {
|
|
|
|
+ //根据事件id获得事件文件关联表
|
|
|
|
+ LambdaQueryWrapper<AssoEventFile> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.in(AssoEventFile::getEventId, ids);
|
|
|
|
+ assoEventFiles = assoEventFileService.list(queryWrapper);
|
|
|
|
+ guids = assoEventFiles.stream().map(AssoEventFile::getFileGuid).collect(Collectors.toList());
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //根据事件id分组查询事件关联专题库或报告数量
|
|
|
|
+ eventCountVOS = assoProjectEventMapper.getEventProjectCount(ids);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查询创建人名称
|
|
|
|
+ if (createIds.size() != 0) {
|
|
|
|
+ String res = permissionService.getPersonnelByIdsFromPCS(createIds);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
|
+ personnels = JSONObject.parseArray(jsonObject.getString("data"), Personnel.class);
|
|
|
|
+ }
|
|
|
|
|
|
//查询客户名称
|
|
//查询客户名称
|
|
|
|
+ if (clientIds.size() != 0) {
|
|
|
|
+ String res = permissionService.getClientByIdsFromPCS(clientIds);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
|
+ clients = JSONObject.parseArray(jsonObject.getString("data"), Client.class);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查询文件
|
|
|
|
+ if (guids.size() != 0) {
|
|
|
|
+ String res = fileManagerService.getSystemFileFromFMS(guids);
|
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(res);
|
|
|
|
+ systemFiles = JSONObject.parseArray(jsonObject.getString("data"), SystemFile.class);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //查询关联报告或专题库
|
|
|
|
|
|
//查询应用场景
|
|
//查询应用场景
|
|
|
|
+ List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Arrays.asList("INVESTIGATION_TYPE"));
|
|
|
|
+
|
|
|
|
+ //查询专题库数量
|
|
|
|
+
|
|
|
|
+ //装载信息
|
|
|
|
+ for (EventVO eventVO : eventVOs) {
|
|
|
|
+ //装载人员信息
|
|
|
|
+ Personnel personnel = personnels.stream().filter(item -> item.getId().equals(eventVO.getCreateId())).findFirst().orElse(null);
|
|
|
|
+ if (personnel != null) {
|
|
|
|
+ eventVO.setName(personnel.getPersonnelName());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //装载客户信息
|
|
|
|
+ Client client = clients.stream().filter(item -> item.getId().equals(eventVO.getClientId())).findFirst().orElse(null);
|
|
|
|
+ if (client != null) {
|
|
|
|
+ eventVO.setClientName(client.getName());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //装载场景
|
|
|
|
+ SystemDict systemDict = systemDictList.stream().filter(item -> item.getValue().equals(eventVO.getScenarioId().toString())).findFirst().orElse(null);
|
|
|
|
+ if (systemDict != null) {
|
|
|
|
+ eventVO.setScenarioName(systemDict.getLabel());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //装载文件信息
|
|
|
|
+ List<AssoEventFile> assoEventFileTemp = assoEventFiles.stream().filter(item -> item.getEventId().equals(eventVO.getId())).collect(Collectors.toList());
|
|
|
|
+ if (assoEventFileTemp.size() != 0) {
|
|
|
|
+ List<String> guidTemp = assoEventFileTemp.stream().map(AssoEventFile::getFileGuid).collect(Collectors.toList());
|
|
|
|
+ if (guidTemp.size() != 0) {
|
|
|
|
+ List<SystemFile> systemFileTemp = systemFiles.stream().filter(item -> guidTemp.contains(item.getGuid())).collect(Collectors.toList());
|
|
|
|
+ if (systemFileTemp.size() != 0) {
|
|
|
|
+ eventVO.setSystemFileList(systemFileTemp);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ //装载专题库或报告数量
|
|
|
|
+ if (eventCountVOS.size() != 0) {
|
|
|
|
+ //专题库数量
|
|
|
|
+ EventCountVO eventCountVO1 = eventCountVOS.stream().filter(item ->
|
|
|
|
+ item.getEventId().equals(eventVO.getId())&&item.getProjectType().equals(1)).findFirst().orElse(null);
|
|
|
|
+
|
|
|
|
+ //报告数量
|
|
|
|
+ EventCountVO eventCountVO2 = eventCountVOS.stream().filter(item ->
|
|
|
|
+ item.getEventId().equals(eventVO.getId())&&item.getProjectType().equals(2)).findFirst().orElse(null);
|
|
|
|
+
|
|
|
|
+ //设置专题库数量
|
|
|
|
+ if(eventCountVO1!=null){
|
|
|
|
+ eventVO.setPatentProjectNum(eventCountVO1.getProjectCount());
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ eventVO.setPatentProjectNum(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //设置报告数量
|
|
|
|
+ if(eventCountVO2!=null){
|
|
|
|
+ eventVO.setReportProjectNum(eventCountVO2.getProjectCount());
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ eventVO.setReportProjectNum(0);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ else {
|
|
|
|
+ eventVO.setReportProjectNum(0);
|
|
|
|
+ eventVO.setPatentProjectNum(0);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
|
|
- //装载文件信息
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|