提交 80e3742d 作者: 925993793@qq.com

【fix】研究中心-自定义专题新增时,增加默认分类的逻辑

上级 4d588d16
...@@ -102,12 +102,8 @@ public class MybatisInterceptor implements Interceptor { ...@@ -102,12 +102,8 @@ public class MybatisInterceptor implements Interceptor {
} }
private String getLoginUsername() { private String getLoginUsername() {
String username = null;
UserVo loginUser = UserUtil.getLoginUser(); UserVo loginUser = UserUtil.getLoginUser();
if(loginUser != null){ return loginUser.getUsername();
username = loginUser.getUsername();
}
return username;
} }
//修改对应字段的值 //修改对应字段的值
......
package com.zzsn.event.service.impl; package com.zzsn.event.service.impl;
import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson2.JSON; import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject; import com.alibaba.fastjson2.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
...@@ -13,6 +14,7 @@ import com.zzsn.event.es.EsService; ...@@ -13,6 +14,7 @@ import com.zzsn.event.es.EsService;
import com.zzsn.event.feign.api.RemoteModelService; import com.zzsn.event.feign.api.RemoteModelService;
import com.zzsn.event.service.*; import com.zzsn.event.service.*;
import com.zzsn.event.util.CodeGenerateUtil; import com.zzsn.event.util.CodeGenerateUtil;
import com.zzsn.event.util.CronUtil;
import com.zzsn.event.util.EsOpUtil; import com.zzsn.event.util.EsOpUtil;
import com.zzsn.event.util.PythonUtil; import com.zzsn.event.util.PythonUtil;
import com.zzsn.event.util.user.UserUtil; import com.zzsn.event.util.user.UserUtil;
...@@ -49,6 +51,8 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -49,6 +51,8 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
@Autowired @Autowired
private SubjectService subjectService; private SubjectService subjectService;
@Autowired @Autowired
private ISubjectTypeService subjectTypeService;
@Autowired
private IKeyWordsService keywordWordsService; private IKeyWordsService keywordWordsService;
@Autowired @Autowired
private IKeywordsTypeMapService keywordsTypeMapService; private IKeywordsTypeMapService keywordsTypeMapService;
...@@ -99,7 +103,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -99,7 +103,7 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
SubjectPage subjectPage = new SubjectPage(); SubjectPage subjectPage = new SubjectPage();
BeanUtils.copyProperties(subjectSimpleVO, subjectPage); BeanUtils.copyProperties(subjectSimpleVO, subjectPage);
subjectPage.setProjectId(PROJECT_ID); subjectPage.setProjectId(PROJECT_ID);
Subject subject = subjectService.saveMain(subjectPage); Subject subject = saveMain(subjectPage);
String subjectId = subject.getId(); String subjectId = subject.getId();
//关键词绑定 //关键词绑定
List<SearchWordVO> keywords = subjectSimpleVO.getKeywords(); List<SearchWordVO> keywords = subjectSimpleVO.getKeywords();
...@@ -135,6 +139,67 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService { ...@@ -135,6 +139,67 @@ public class SubjectSimpleServiceImpl implements SubjectSimpleService {
return subject; return subject;
} }
public Subject saveMain(SubjectPage subjectPage) {
Subject subject = new Subject();
//事件专题的默认分析规则参数-必填
BeanUtils.copyProperties(subjectPage, subject);
if (subject.getSubjectType() == null) {
subject.setSubjectType(1);
}
String subjectCode = codeGenerateUtil.geneCodeNo(CodePrefixEnum.SUBJECT_DEFAULT.getValue());
subject.setSubjectCode(subjectCode);
String cron = CronUtil.generateCron(subject.getUnit(), subject.getSpace());
subject.setCron(cron);
subject.setEstimateStatus("未启用");
subjectService.save(subject);
//插入专题-类别、项目的绑定关系
saveMapMain(subject, subjectPage);
return subject;
}
private void saveMapMain(Subject subject, SubjectPage subjectPage) {
String subjectTypeId = subjectPage.getSubjectTypeId();
String subjectTypeName = subjectPage.getSubjectTypeName();
if (StringUtils.isNotEmpty(subjectTypeId)) {
SubjectTypeMap subjectTypeMap = new SubjectTypeMap();
subjectTypeMap.setSubjectId(subject.getId());
subjectTypeMap.setSysOrgCode(subject.getSysOrgCode());
subjectTypeMap.setTypeId(subjectTypeId);
subjectTypeMapService.save(subjectTypeMap);
} else if (StringUtils.isNotEmpty(subjectTypeName)){
UserVo loginUser = UserUtil.getLoginUser();
LambdaQueryWrapper<SubjectType> queryWrapper = Wrappers.lambdaQuery();
queryWrapper.eq(SubjectType::getTypeName, subjectTypeName)
.eq(SubjectType::getCreateBy, loginUser.getUsername())
.eq(SubjectType::getSysOrgCode,"YJZX");
SubjectType one = subjectTypeService.getOne(queryWrapper);
if (ObjectUtil.isEmpty(one)) {
SubjectType subjectType = new SubjectType();
subjectType.setTypeName(subjectTypeName);
subjectType.setSysOrgCode("YJZX");
subjectType.setPid("0");
subjectType.setCategory(1);
subjectType.setStatus(1);
subjectType.setEnvironment(subjectPage.getEnvironment());
subjectTypeService.save(subjectType);
subjectTypeId = subjectType.getId();
} else {
subjectTypeId = one.getId();
}
SubjectTypeMap subjectTypeMap = new SubjectTypeMap();
subjectTypeMap.setSubjectId(subject.getId());
subjectTypeMap.setSysOrgCode(subject.getSysOrgCode());
subjectTypeMap.setTypeId(subjectTypeId);
subjectTypeMapService.save(subjectTypeMap);
}
if (StringUtils.isNotEmpty(subjectPage.getProjectId())) {
ProjectSubjectMap projectSubjectMap = new ProjectSubjectMap();
projectSubjectMap.setProjectId(subjectPage.getProjectId());
projectSubjectMap.setSubjectId(subject.getId());
projectSubjectMapService.save(projectSubjectMap);
}
}
@Override @Override
public Boolean configVerification(SubjectParamsCheckVO subjectParamsCheckVO) { public Boolean configVerification(SubjectParamsCheckVO subjectParamsCheckVO) {
SubjectSimpleVO subjectSimpleVO = subjectParamsCheckVO.getSubjectSimpleVO(); SubjectSimpleVO subjectSimpleVO = subjectParamsCheckVO.getSubjectSimpleVO();
......
...@@ -38,4 +38,6 @@ public class SubjectSimpleVO { ...@@ -38,4 +38,6 @@ public class SubjectSimpleVO {
private List<SearchWordVO> keywords; private List<SearchWordVO> keywords;
/** 环境 1-测试 2-正式 */ /** 环境 1-测试 2-正式 */
private String environment; private String environment;
public String subjectTypeName;
} }
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论