保存抓取规则功能

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
@@ -20,4 +20,10 @@ public class FatchRule extends BaseEntity {
private String startContent;
private String endContent;
private String column;
private String columnName;
private Integer isDefault;
private Long templateId;
}
@@ -3,6 +3,8 @@ package com.ruoyi.wisdomarbitrate.domain;
import com.ruoyi.common.core.domain.BaseEntity;
import lombok.Data;
import java.util.List;
@Data
public class TemplateManage extends BaseEntity {
private static final long serialVersionUID = 1L;
@@ -49,4 +51,7 @@ public class TemplateManage extends BaseEntity {
* 机构关联id
*/
private String identifyName;
List<FatchRule> fatchRules;
}
@@ -0,0 +1,17 @@
package com.ruoyi.wisdomarbitrate.domain.vo;
import lombok.Data;
/**
* 模板抓取规则关联表
*/
@Data
public class TemplateFatchRule {
private static final long serialVersionUID = 1L;
private Long id;
private Long templateId;
private Long fatchRuleId;
}
@@ -3,6 +3,7 @@ package com.ruoyi.wisdomarbitrate.mapper;
import com.ruoyi.wisdomarbitrate.domain.CaseAffiliate;
import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
import com.ruoyi.wisdomarbitrate.domain.FatchRule;
import com.ruoyi.wisdomarbitrate.domain.TemplateManage;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
@@ -16,4 +17,12 @@ public interface FatchRuleMapper {
*/
List<FatchRule> list(@Param("batchNumber")String batchNumber);
List<FatchRule> selectFatchRuleList(FatchRule fatchRule);
List<FatchRule> selectFatchRuleListIsDefault(FatchRule fatchRule);
void deletebatchFatchRule(@Param("fatchRuleIds") List<Long> fatchRuleIds);
int insertFatchRule(FatchRule fatchRule);
}
@@ -0,0 +1,19 @@
package com.ruoyi.wisdomarbitrate.mapper;
import com.ruoyi.wisdomarbitrate.domain.vo.TemplateFatchRule;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface TemplateFatchRuleMapper {
int selectTemplateFatchRulecount(TemplateFatchRule templateFatchRule);
List<TemplateFatchRule> selectTemplateFatchRuleList(TemplateFatchRule templateFatchRule);
void deleteTemplateFatchRule(Long id);
int insertTemplateFatchRule(TemplateFatchRule templateFatchRule);
}
@@ -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) {