diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java index c10aa81..963f31d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/wisdomarbitrate/DeptIdentifyController.java @@ -177,4 +177,31 @@ public class DeptIdentifyController extends BaseController { public AjaxResult bindHandler(DeptIdentify deptIdentify){ return deptIdentifyService.bindHandler(deptIdentify); } + + /** + * 根据模板id查询抓取规则 + * @param templateManage + * @return + */ + @PostMapping("/getFatchRuleByTemplateid") + public AjaxResult getFatchRuleByTemplateid(@RequestBody TemplateManage templateManage){ + List fatchRuleList = deptIdentifyService.getFatchRuleByTemplateid(templateManage); + return AjaxResult.success(fatchRuleList); + } + + /** + * 保存抓取规则 + * @param templateManage + * @return + */ + @PostMapping("/saveFatchRules") + public AjaxResult saveFatchRules(@RequestBody TemplateManage templateManage){ + return deptIdentifyService.saveFatchRules(templateManage); + } + + + + + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/FatchRule.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/FatchRule.java index 4cfd112..7efd1f1 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/FatchRule.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/FatchRule.java @@ -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; + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/TemplateManage.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/TemplateManage.java index 730582d..5f342ed 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/TemplateManage.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/TemplateManage.java @@ -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 fatchRules; + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/TemplateFatchRule.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/TemplateFatchRule.java new file mode 100644 index 0000000..b194085 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/domain/vo/TemplateFatchRule.java @@ -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; + + + +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/FatchRuleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/FatchRuleMapper.java index 9810c10..29a2082 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/FatchRuleMapper.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/FatchRuleMapper.java @@ -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 list(@Param("batchNumber")String batchNumber); + List selectFatchRuleList(FatchRule fatchRule); + + + List selectFatchRuleListIsDefault(FatchRule fatchRule); + + void deletebatchFatchRule(@Param("fatchRuleIds") List fatchRuleIds); + + int insertFatchRule(FatchRule fatchRule); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/TemplateFatchRuleMapper.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/TemplateFatchRuleMapper.java new file mode 100644 index 0000000..71c7b31 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/mapper/TemplateFatchRuleMapper.java @@ -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 selectTemplateFatchRuleList(TemplateFatchRule templateFatchRule); + + void deleteTemplateFatchRule(Long id); + + int insertTemplateFatchRule(TemplateFatchRule templateFatchRule); +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IDeptIdentifyService.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IDeptIdentifyService.java index 10493c0..a5f0fd8 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IDeptIdentifyService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/IDeptIdentifyService.java @@ -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 getFatchRuleByTemplateid(TemplateManage templateManage); + + AjaxResult saveFatchRules(TemplateManage templateManage); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java index 8b29ee2..5bb3e10 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/DeptIdentifyServiceImpl.java @@ -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 getFatchRuleByTemplateid(TemplateManage templateManage) { + TemplateFatchRule templateFatchRule = new TemplateFatchRule(); + templateFatchRule.setTemplateId(templateManage.getId()); + List 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 templateFatchRulelist = templateFatchRuleMapper.selectTemplateFatchRuleList(templateFatchRule); + if(templateFatchRulelist!=null&&templateFatchRulelist.size()>0){ + List fatchRuleIds = templateFatchRulelist.stream().map(TemplateFatchRule::getFatchRuleId).collect(Collectors.toList()); + fatchRuleMapper.deletebatchFatchRule(fatchRuleIds); + templateFatchRuleMapper.deleteTemplateFatchRule(templateManage.getId()); + } + List 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) { diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/FatchRuleMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/FatchRuleMapper.xml index 88fb0fd..07cb04e 100644 --- a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/FatchRuleMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/FatchRuleMapper.xml @@ -5,14 +5,71 @@ - + + + + + + + + + + delete from fatch_rule where id in + + #{item} + + + + + insert into fatch_rule( + file_name, + start_content, + end_content, + `column`, + columnName, + is_default + )values( + #{fileName}, + #{startContent}, + #{endContent}, + #{column}, + #{columnName}, + #{isDefault} + ) + + + + + + + \ No newline at end of file diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/TemplateFatchRuleMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/TemplateFatchRuleMapper.xml new file mode 100644 index 0000000..d243bde --- /dev/null +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/TemplateFatchRuleMapper.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + delete from template_fatch_rule where template_id=#{id} + + + + insert into template_fatch_rule( + template_id, + fatch_rule_id + )values( + #{templateId}, + #{fatchRuleId} + ) + + + + \ No newline at end of file