|
@@ -4,6 +4,8 @@ import cn.cslg.pas.common.dto.business.EventDTO;
|
|
|
import cn.cslg.pas.common.model.cronModel.*;
|
|
|
import cn.cslg.pas.common.model.request.*;
|
|
|
|
|
|
+import cn.cslg.pas.common.utils.CacheUtils;
|
|
|
+import cn.cslg.pas.common.utils.LoginUtils;
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.expressManager;
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.operateNode;
|
|
|
import cn.cslg.pas.common.utils.parseQueryToTree.treeNode;
|
|
@@ -12,6 +14,8 @@ import cn.cslg.pas.common.vo.business.EventVO;
|
|
|
import cn.cslg.pas.domain.business.AssoEventFile;
|
|
|
import cn.cslg.pas.domain.business.Event;
|
|
|
import cn.cslg.pas.domain.business.SystemDict;
|
|
|
+import cn.cslg.pas.exception.ConditionException;
|
|
|
+import cn.cslg.pas.exception.UnLoginException;
|
|
|
import cn.cslg.pas.exception.XiaoShiException;
|
|
|
import cn.cslg.pas.factorys.businessFactory.Business;
|
|
|
import cn.cslg.pas.factorys.reGroupFactory.QueryGroupFactory;
|
|
@@ -65,13 +69,21 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
@Autowired
|
|
|
private AssoProjectEventMapper assoProjectEventMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private CacheUtils cacheUtils;
|
|
|
+ @Autowired
|
|
|
+ private LoginUtils loginUtils;
|
|
|
+
|
|
|
public String getEvent(String sql) {
|
|
|
- eventMapper.getEvent(sql);
|
|
|
+// eventMapper.getEvent(sql);
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public Object queryMessage(QueryRequest queryRequest) throws Exception {
|
|
|
+ String sql1 ="";
|
|
|
+ String sql2="";
|
|
|
+ String sql3 ="";
|
|
|
//合成检索式
|
|
|
StringRequest stringRequest = null;
|
|
|
if (queryRequest instanceof MapRequest) {
|
|
@@ -81,16 +93,22 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
}
|
|
|
String condition = stringRequest.getSearchQuery();
|
|
|
|
|
|
- //将检索式转换为二叉树
|
|
|
- treeNode tree = expressManager.getInstance().Parse(condition, false);
|
|
|
-
|
|
|
- //格式化检索式
|
|
|
- String sql = formatQueryService.ToString((operateNode) tree);
|
|
|
+ if(condition!=null&&condition!="") {
|
|
|
+ try {
|
|
|
+ //将检索式转换为二叉树
|
|
|
+ treeNode tree = expressManager.getInstance().Parse(condition, false);
|
|
|
+ //格式化检索式
|
|
|
+ sql1 = formatQueryService.ToString((operateNode) tree);
|
|
|
+ }
|
|
|
+ catch (Exception e){
|
|
|
+ throw new ConditionException("检索式错误");
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
//格式化排序
|
|
|
if (queryRequest.getOrderDTOList() != null && queryRequest.getOrderDTOList().size() != 0) {
|
|
|
String orderSql = formatQueryService.orderToString(queryRequest.getOrderDTOList());
|
|
|
- sql += orderSql;
|
|
|
+ sql2= orderSql;
|
|
|
}
|
|
|
|
|
|
//格式化 分页信息
|
|
@@ -98,15 +116,23 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
Long size = queryRequest.getSize();
|
|
|
Long current = queryRequest.getCurrent();
|
|
|
String page = " limit " + ((current - 1) * size) + "," + size;
|
|
|
- sql += page;
|
|
|
+ sql3= page;
|
|
|
}
|
|
|
|
|
|
//根据sql查询事件信息
|
|
|
- List<EventVO> eventVOS = eventMapper.getEvent(sql);
|
|
|
+ List<EventVO> eventVOS = eventMapper.getEvent(sql1,sql2,sql3);
|
|
|
+
|
|
|
+ //查询总数
|
|
|
+ Long total = eventMapper.getEventCount(sql1);
|
|
|
|
|
|
//装载事件信息
|
|
|
this.loadEvent(eventVOS);
|
|
|
- return eventVOS;
|
|
|
+ Records records = new Records();
|
|
|
+ records.setCurrent(queryRequest.getCurrent());
|
|
|
+ records.setSize(queryRequest.getSize());
|
|
|
+ records.setData(eventVOS);
|
|
|
+ records.setTotal(total);
|
|
|
+ return records;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -117,6 +143,16 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
throw new XiaoShiException("参数错误");
|
|
|
}
|
|
|
|
|
|
+ //获取登录人信息
|
|
|
+ PersonnelVO personnelVO =new PersonnelVO();
|
|
|
+ try {
|
|
|
+ personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ throw new UnLoginException("未登录");
|
|
|
+ }
|
|
|
+
|
|
|
//根据名称查询是否重复
|
|
|
eventDTO.setName(eventDTO.getName().trim());
|
|
|
String name = eventDTO.getName();
|
|
@@ -130,18 +166,21 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
//事件入库
|
|
|
Event event = new Event();
|
|
|
BeanUtils.copyProperties(eventDTO, event);
|
|
|
+ event.setCreateId(personnelVO.getId());
|
|
|
+ event.setTenantId(personnelVO.getTenantId());
|
|
|
event.insert();
|
|
|
if (files != null && files.size() != 0) {
|
|
|
try {
|
|
|
List<String> guids = fileManagerService.uploadFileGetGuid(files);
|
|
|
List<AssoEventFile> assoEventFiles = new ArrayList<>();
|
|
|
- guids.forEach(item -> {
|
|
|
- AssoEventFile assoEventFile = new AssoEventFile();
|
|
|
- assoEventFile.setEventId(event.getId());
|
|
|
- assoEventFile.setFileGuid(item);
|
|
|
- assoEventFile.setCreateId(1);
|
|
|
- assoEventFiles.add(assoEventFile);
|
|
|
- });
|
|
|
+ for(String item:guids) {
|
|
|
+ AssoEventFile assoEventFile = new AssoEventFile();
|
|
|
+ assoEventFile.setEventId(event.getId());
|
|
|
+ assoEventFile.setFileGuid(item);
|
|
|
+ assoEventFile.setCreateId(personnelVO.getId());
|
|
|
+ assoEventFiles.add(assoEventFile);
|
|
|
+ }
|
|
|
+
|
|
|
if (assoEventFiles != null && assoEventFiles.size() != 0) {
|
|
|
assoEventFileService.saveBatch(assoEventFiles);
|
|
|
}
|
|
@@ -153,17 +192,20 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public Object deleteMessage(List<Integer> ids) {
|
|
|
- //根据事件id删除事件
|
|
|
- this.removeBatchByIds(ids);
|
|
|
+ public Object deleteMessage(List<Integer> ids) throws IOException {
|
|
|
//根据事件id删除事件和文件关联
|
|
|
LambdaQueryWrapper<AssoEventFile> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
- queryWrapper.in(AssoEventFile::getId, ids);
|
|
|
+ queryWrapper.in(AssoEventFile::getEventId, ids);
|
|
|
List<AssoEventFile> assoEventFiles = assoEventFileService.list(queryWrapper);
|
|
|
List<String> guids = assoEventFiles.stream().map(AssoEventFile::getFileGuid).collect(Collectors.toList());
|
|
|
//TODO 根据guid删除文件
|
|
|
+ if(guids.size()!=0) {
|
|
|
+ fileManagerService.deleteFileFromFMS(guids);
|
|
|
+ }
|
|
|
//删除事件和文件关联表
|
|
|
assoEventFiles.remove(queryWrapper);
|
|
|
+ //根据事件id删除事件
|
|
|
+ this.removeBatchByIds(ids);
|
|
|
return ids;
|
|
|
}
|
|
|
|
|
@@ -330,7 +372,7 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
//查询关联报告或专题库
|
|
|
|
|
|
//查询应用场景
|
|
|
- List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Arrays.asList("INVESTIGATION_TYPE"));
|
|
|
+ List<SystemDict> systemDictList = systemDictService.getSystemDictListByType(Arrays.asList("ENTERPRISE_APPLICATION_SCENARIO"));
|
|
|
|
|
|
//查询专题库数量
|
|
|
|
|
@@ -339,7 +381,7 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
//装载人员信息
|
|
|
Personnel personnel = personnels.stream().filter(item -> item.getId().equals(eventVO.getCreateId())).findFirst().orElse(null);
|
|
|
if (personnel != null) {
|
|
|
- eventVO.setName(personnel.getPersonnelName());
|
|
|
+ eventVO.setCreateName(personnel.getPersonnelName());
|
|
|
}
|
|
|
|
|
|
//装载客户信息
|