|
@@ -1,6 +1,7 @@
|
|
|
package cn.cslg.pas.service.business;
|
|
|
|
|
|
import cn.cslg.pas.common.dto.business.EventDTO;
|
|
|
+import cn.cslg.pas.common.dto.business.EventUpdateDTO;
|
|
|
import cn.cslg.pas.common.model.cronModel.*;
|
|
|
import cn.cslg.pas.common.model.request.*;
|
|
|
|
|
@@ -81,9 +82,9 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
|
|
|
@Override
|
|
|
public Object queryMessage(QueryRequest queryRequest) throws Exception {
|
|
|
- String sql1 ="";
|
|
|
- String sql2="";
|
|
|
- String sql3 ="";
|
|
|
+ String sql1 = "";
|
|
|
+ String sql2 = "";
|
|
|
+ String sql3 = "";
|
|
|
//合成检索式
|
|
|
StringRequest stringRequest = null;
|
|
|
if (queryRequest instanceof MapRequest) {
|
|
@@ -93,22 +94,21 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
}
|
|
|
String condition = stringRequest.getSearchQuery();
|
|
|
|
|
|
- if(condition!=null&&condition!="") {
|
|
|
+ if (condition != null && condition != "") {
|
|
|
try {
|
|
|
//将检索式转换为二叉树
|
|
|
treeNode tree = expressManager.getInstance().Parse(condition, false);
|
|
|
//格式化检索式
|
|
|
- sql1 = formatQueryService.ToString((operateNode) tree);
|
|
|
- }
|
|
|
- catch (Exception e){
|
|
|
+ sql1 = formatQueryService.ToString2((operateNode) tree, null);
|
|
|
+ } catch (Exception e) {
|
|
|
throw new ConditionException("检索式错误");
|
|
|
}
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
//格式化排序
|
|
|
if (queryRequest.getOrderDTOList() != null && queryRequest.getOrderDTOList().size() != 0) {
|
|
|
String orderSql = formatQueryService.orderToString(queryRequest.getOrderDTOList());
|
|
|
- sql2= orderSql;
|
|
|
+ sql2 = orderSql;
|
|
|
}
|
|
|
|
|
|
//格式化 分页信息
|
|
@@ -116,11 +116,11 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
Long size = queryRequest.getSize();
|
|
|
Long current = queryRequest.getCurrent();
|
|
|
String page = " limit " + ((current - 1) * size) + "," + size;
|
|
|
- sql3= page;
|
|
|
+ sql3 = page;
|
|
|
}
|
|
|
|
|
|
//根据sql查询事件信息
|
|
|
- List<EventVO> eventVOS = eventMapper.getEvent(sql1,sql2,sql3);
|
|
|
+ List<EventVO> eventVOS = eventMapper.getEvent(sql1, sql2, sql3);
|
|
|
|
|
|
//查询总数
|
|
|
Long total = eventMapper.getEventCount(sql1);
|
|
@@ -144,13 +144,11 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
}
|
|
|
|
|
|
//获取登录人信息
|
|
|
- PersonnelVO personnelVO =new PersonnelVO();
|
|
|
+ PersonnelVO personnelVO = new PersonnelVO();
|
|
|
try {
|
|
|
personnelVO = cacheUtils.getLoginUser(loginUtils.getId());
|
|
|
- }
|
|
|
- catch (Exception e)
|
|
|
- {
|
|
|
- throw new UnLoginException("未登录");
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new UnLoginException("未登录");
|
|
|
}
|
|
|
|
|
|
//根据名称查询是否重复
|
|
@@ -173,13 +171,13 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
try {
|
|
|
List<String> guids = fileManagerService.uploadFileGetGuid(files);
|
|
|
List<AssoEventFile> assoEventFiles = new ArrayList<>();
|
|
|
- for(String item:guids) {
|
|
|
- AssoEventFile assoEventFile = new AssoEventFile();
|
|
|
- assoEventFile.setEventId(event.getId());
|
|
|
- assoEventFile.setFileGuid(item);
|
|
|
- assoEventFile.setCreateId(personnelVO.getId());
|
|
|
- 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);
|
|
@@ -198,8 +196,8 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
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) {
|
|
|
+ // 根据guid删除文件
|
|
|
+ if (guids.size() != 0) {
|
|
|
fileManagerService.deleteFileFromFMS(guids);
|
|
|
}
|
|
|
//删除事件和文件关联表
|
|
@@ -209,22 +207,61 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
return ids;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新事件接口
|
|
|
+ * @param object
|
|
|
+ * @param files
|
|
|
+ * @return
|
|
|
+ */
|
|
|
@Override
|
|
|
public Object updateMessage(Object object, List<MultipartFile> files) {
|
|
|
- EventDTO eventDTO = (EventDTO) object;
|
|
|
- //检查事件格式 TODO
|
|
|
+
|
|
|
+ EventUpdateDTO eventUpdateDTO = (EventUpdateDTO) object;
|
|
|
+ //检查事件格式
|
|
|
+ if (eventUpdateDTO == null || eventUpdateDTO.getId() == null) {
|
|
|
+ throw new XiaoShiException("参数错误");
|
|
|
+
|
|
|
+ }
|
|
|
+ Event event = this.getById(eventUpdateDTO.getId());
|
|
|
//根据名称查询是否重复
|
|
|
- eventDTO.setName(eventDTO.getName().trim());
|
|
|
- String name = eventDTO.getName();
|
|
|
+ eventUpdateDTO.setName(eventUpdateDTO.getName().trim());
|
|
|
+ String name = eventUpdateDTO.getName();
|
|
|
LambdaQueryWrapper<Event> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
queryWrapper.eq(Event::getName, name);
|
|
|
List<Event> events = this.list(queryWrapper);
|
|
|
- if (events == null || events.size() == 0) {
|
|
|
- return null;
|
|
|
+ if (eventUpdateDTO.getName() != event.getName() && events.size() != 0) {
|
|
|
+ throw new XiaoShiException("名称重复");
|
|
|
}
|
|
|
- Event event = new Event();
|
|
|
- BeanUtils.copyProperties(eventDTO, event);
|
|
|
- event.insert();
|
|
|
+ BeanUtils.copyProperties(eventUpdateDTO, event);
|
|
|
+ event.updateById();
|
|
|
+
|
|
|
+ // 根据事件Id查询对应的附件Id
|
|
|
+ LambdaQueryWrapper<AssoEventFile> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(AssoEventFile::getEventId, eventUpdateDTO.getId());
|
|
|
+ List<AssoEventFile> assoReportFiles = assoEventFileService.list(wrapper);
|
|
|
+ List<String> fileGuIds = assoReportFiles.stream().map(AssoEventFile::getFileGuid).collect(Collectors.toList());
|
|
|
+ // 获得事件更新后的附件Id
|
|
|
+ List<String> updateFilGuId = new ArrayList<>();
|
|
|
+ if (eventUpdateDTO.getFileGuids() != null && eventUpdateDTO.getFileGuids().size() != 0) {
|
|
|
+ updateFilGuId = eventUpdateDTO.getFileGuids();
|
|
|
+ }
|
|
|
+ fileGuIds.retainAll(updateFilGuId);
|
|
|
+ //做差获得被删除的文件Id
|
|
|
+ if (fileGuIds.size() != 0) {
|
|
|
+ //根据文件Id删除报事件文件关联表记录
|
|
|
+ LambdaQueryWrapper<AssoEventFile> deleteWrapper = new LambdaQueryWrapper<>();
|
|
|
+ deleteWrapper.in(AssoEventFile::getFileGuid, fileGuIds);
|
|
|
+ assoEventFileService.remove(deleteWrapper);
|
|
|
+
|
|
|
+ //远程删除服务器上文件
|
|
|
+ try {
|
|
|
+ fileManagerService.deleteFileFromFMS(fileGuIds);
|
|
|
+ } catch (Exception e) {
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加文件
|
|
|
if (files != null && files.size() != 0) {
|
|
|
try {
|
|
|
List<String> guids = fileManagerService.uploadFileGetGuid(files);
|
|
@@ -254,7 +291,7 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
public GroupVO getGroup(GroupRequest groupRequest) throws Exception {
|
|
|
- String sql ="";
|
|
|
+ String sql = "";
|
|
|
|
|
|
//合成检索式
|
|
|
StringGroupRequest stringGroupRequest = null;
|
|
@@ -264,12 +301,12 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
stringGroupRequest = (StringGroupRequest) groupRequest;
|
|
|
}
|
|
|
String condition = stringGroupRequest.getSearchQuery();
|
|
|
- if(condition!=null) {
|
|
|
- //将检索式转换为二叉树
|
|
|
- treeNode tree = expressManager.getInstance().Parse(condition, false);
|
|
|
- //格式化检索式
|
|
|
- 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");
|
|
|
List<GroupConfig> groupConfigs = JSON.parseArray(json, GroupConfig.class);
|
|
@@ -413,30 +450,27 @@ public class EventService extends ServiceImpl<EventMapper, Event> implements Bus
|
|
|
if (eventCountVOS.size() != 0) {
|
|
|
//专题库数量
|
|
|
EventCountVO eventCountVO1 = eventCountVOS.stream().filter(item ->
|
|
|
- item.getEventId().equals(eventVO.getId())&&item.getProjectType().equals(1)).findFirst().orElse(null);
|
|
|
+ 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);
|
|
|
+ item.getEventId().equals(eventVO.getId()) && item.getProjectType().equals(2)).findFirst().orElse(null);
|
|
|
|
|
|
//设置专题库数量
|
|
|
- if(eventCountVO1!=null){
|
|
|
+ if (eventCountVO1 != null) {
|
|
|
eventVO.setPatentProjectNum(eventCountVO1.getProjectCount());
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
eventVO.setPatentProjectNum(0);
|
|
|
}
|
|
|
|
|
|
//设置报告数量
|
|
|
- if(eventCountVO2!=null){
|
|
|
+ if (eventCountVO2 != null) {
|
|
|
eventVO.setReportProjectNum(eventCountVO2.getProjectCount());
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
eventVO.setReportProjectNum(0);
|
|
|
}
|
|
|
|
|
|
- }
|
|
|
- else {
|
|
|
+ } else {
|
|
|
eventVO.setReportProjectNum(0);
|
|
|
eventVO.setPatentProjectNum(0);
|
|
|
}
|