保存抓取规则功能

This commit is contained in:
qitz
2023-12-06 17:30:37 +08:00
parent f9dbd8a010
commit a24b78473f
10 changed files with 251 additions and 9 deletions
@@ -4,6 +4,7 @@ import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
import com.ruoyi.wisdomarbitrate.domain.FatchRule;
import com.ruoyi.wisdomarbitrate.domain.SealManage;
import com.ruoyi.wisdomarbitrate.domain.TemplateManage;
import com.ruoyi.wisdomarbitrate.domain.vo.SealListVO;
@@ -51,4 +52,7 @@ public interface IDeptIdentifyService {
AjaxResult bindHandler(DeptIdentify deptIdentify);
List<FatchRule> getFatchRuleByTemplateid(TemplateManage templateManage);
AjaxResult saveFatchRules(TemplateManage templateManage);
}
@@ -18,15 +18,10 @@ import com.ruoyi.system.domain.SysUserPost;
import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.SysUserPostMapper;
import com.ruoyi.wisdomarbitrate.domain.CaseAttach;
import com.ruoyi.wisdomarbitrate.domain.DeptIdentify;
import com.ruoyi.wisdomarbitrate.domain.SealManage;
import com.ruoyi.wisdomarbitrate.domain.TemplateManage;
import com.ruoyi.wisdomarbitrate.domain.*;
import com.ruoyi.wisdomarbitrate.domain.vo.SealListVO;
import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
import com.ruoyi.wisdomarbitrate.mapper.DeptIdentifyMapper;
import com.ruoyi.wisdomarbitrate.mapper.SealManageMapper;
import com.ruoyi.wisdomarbitrate.mapper.TemplateManageMapper;
import com.ruoyi.wisdomarbitrate.domain.vo.TemplateFatchRule;
import com.ruoyi.wisdomarbitrate.mapper.*;
import com.ruoyi.wisdomarbitrate.service.IDeptIdentifyService;
import com.ruoyi.wisdomarbitrate.utils.SignAward;
import org.springframework.beans.BeanUtils;
@@ -34,11 +29,13 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import com.ruoyi.wisdomarbitrate.mapper.TemplateFatchRuleMapper;
import java.io.File;
import java.io.IOException;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import static com.ruoyi.common.utils.PageUtils.startPage;
import static com.ruoyi.common.utils.SecurityUtils.getUsername;
@@ -60,6 +57,10 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
private TemplateManageMapper templateManageMapper;
@Autowired
private SysUserPostMapper sysUserPostMapper;
@Autowired
private TemplateFatchRuleMapper templateFatchRuleMapper;
@Autowired
private FatchRuleMapper fatchRuleMapper;
@Override
@@ -530,6 +531,54 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
return null;
}
@Override
public List<FatchRule> getFatchRuleByTemplateid(TemplateManage templateManage) {
TemplateFatchRule templateFatchRule = new TemplateFatchRule();
templateFatchRule.setTemplateId(templateManage.getId());
List<FatchRule> fatchRules = new ArrayList<>();
int countTemplateFatchRule = templateFatchRuleMapper.selectTemplateFatchRulecount(templateFatchRule);
if(countTemplateFatchRule!=0){
FatchRule fatchRule = new FatchRule();
fatchRule.setTemplateId(templateManage.getId());
fatchRules = fatchRuleMapper.selectFatchRuleList(fatchRule);
return fatchRules;
}else {
FatchRule fatchRule = new FatchRule();
fatchRule.setIsDefault(1);
fatchRules = fatchRuleMapper.selectFatchRuleListIsDefault(fatchRule);
return fatchRules;
}
}
@Override
@Transactional
public AjaxResult saveFatchRules(TemplateManage templateManage) {
TemplateFatchRule templateFatchRule = new TemplateFatchRule();
templateFatchRule.setTemplateId(templateManage.getId());
List<TemplateFatchRule> templateFatchRulelist = templateFatchRuleMapper.selectTemplateFatchRuleList(templateFatchRule);
if(templateFatchRulelist!=null&&templateFatchRulelist.size()>0){
List<Long> fatchRuleIds = templateFatchRulelist.stream().map(TemplateFatchRule::getFatchRuleId).collect(Collectors.toList());
fatchRuleMapper.deletebatchFatchRule(fatchRuleIds);
templateFatchRuleMapper.deleteTemplateFatchRule(templateManage.getId());
}
List<FatchRule> fatchRules = templateManage.getFatchRules();
if(fatchRules!=null&&fatchRules.size()>0){
for (FatchRule fatchRule : fatchRules) {
//保存抓取规则数据
fatchRule.setIsDefault(0);
fatchRuleMapper.insertFatchRule(fatchRule);
//保存模板抓取规则关联关系
Long fatchRuleId = fatchRule.getId();
if(fatchRuleId!=null){
templateFatchRule.setFatchRuleId(fatchRuleId);
templateFatchRuleMapper.insertTemplateFatchRule(templateFatchRule);
}
}
return AjaxResult.success("新增成功");
}
return AjaxResult.error();
}
private String getFileExtension(String fileName) {
int lastDotIndex = fileName.lastIndexOf(".");
if (lastDotIndex > 0 && lastDotIndex < fileName.length() - 1) {