From 0e215afa393fa86aba778f5363a9176b91809781 Mon Sep 17 00:00:00 2001 From: 18792927508 <1322446236@qq.com> Date: Mon, 29 Apr 2024 16:51:40 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8E=8B=E7=BC=A9=E5=8C=85=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=EF=BC=8C=E8=AF=A6=E6=83=85=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/SysUserServiceImpl.java | 18 +++ .../impl/CaseApplicationServiceImpl.java | 7 +- .../service/impl/CaseZipImportImpl.java | 125 ++++++++++-------- .../task/CaseZipImportTask.java | 10 +- .../ruoyi/wisdomarbitrate/utils/OCRUtils.java | 15 ++- .../wisdomarbitrate/CaseAffiliateMapper.xml | 32 +++-- .../wisdomarbitrate/CaseApplicationMapper.xml | 2 +- 7 files changed, 132 insertions(+), 77 deletions(-) diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java index 2f93110..5afffb9 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysUserServiceImpl.java @@ -6,6 +6,7 @@ import java.util.List; import java.util.stream.Collectors; import javax.validation.Validator; +import cn.hutool.core.util.StrUtil; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.system.mapper.*; @@ -259,6 +260,13 @@ public class SysUserServiceImpl implements ISysUserService { @Override @Transactional public AjaxResult insertUser(SysUser user) { + // 校验手机号是否重复 + if(StrUtil.isNotEmpty(user.getPhonenumber())){ + if(userMapper.checkPhoneUnique(user.getPhonenumber())!=null){ + return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在"); + } + } + Long deptId = user.getDeptId(); Long[] postIds = user.getPostIds(); if (deptId != null) { @@ -296,6 +304,11 @@ public class SysUserServiceImpl implements ISysUserService { */ @Override public boolean registerUser(SysUser user) { + if(StrUtil.isNotEmpty(user.getPhonenumber())){ + if(userMapper.checkPhoneUnique(user.getPhonenumber())!=null){ + throw new ServiceException("注册用户'" + user.getUserName() + "'失败,手机号码已存在"); + } + } return userMapper.insertUser(user) > 0; } @@ -524,6 +537,11 @@ public class SysUserServiceImpl implements ISysUserService { BeanValidators.validateWithException(validator, user); user.setPassword(SecurityUtils.encryptPassword(password)); user.setCreateBy(operName); + if(StrUtil.isNotEmpty(user.getPhonenumber())){ + if(userMapper.checkPhoneUnique(user.getPhonenumber())!=null){ + throw new ServiceException("导入用户'" + user.getUserName() + "'失败,手机号码已存在"); + } + } userMapper.insertUser(user); successNum++; successMsg.append("
" + successNum + "、账号 " + user.getUserName() + " 导入成功"); diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java index abb43de..c32fc1b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseApplicationServiceImpl.java @@ -218,6 +218,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { */ @Override public List selectCaseApplicationListByRole(CaseApplication caseApplication) { + // todo 案件列表查询Bug修复,需要看见已办案件 // 获取登录用户 LoginUser loginUser = getLoginUser(); SysUser user = loginUser.getUser(); @@ -236,7 +237,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { if (StrUtil.isEmpty(role.getRoleName())) { continue; } - // 超级管理员和仲裁委(部门长)案件,可查看所有案件 √ + // 超级管理员和仲裁委(部门长)案件,可查看所有案件 if ("超级管理员".equals(role.getRoleName()) ) { List caseApplicationlist = caseApplicationMapper.selectAdminCaseApplicationList(caseApplication); @@ -2265,7 +2266,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { caseAffiliate.setCaseAppliId(caseApplication.getId()); List caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); if (caseAffiliatListeselect != null) { - + caseAffiliatListeselect=new ArrayList<>(caseAffiliatListeselect.stream().collect(Collectors.toMap(CaseAffiliate::getContactTelphone ,Function.identity(), (k1, k2) -> k1)).values()); for (int i = 0; i < caseAffiliatListeselect.size(); i++) { CaseAffiliate caseAffiliateselect = caseAffiliatListeselect.get(i); int identityType = caseAffiliateselect.getIdentityType(); @@ -2315,6 +2316,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { if (CollectionUtil.isEmpty(caseAffiliates)) { return "申请人、被申请人不存在"; } + caseAffiliates=new ArrayList<>(caseAffiliates.stream().collect(Collectors.toMap(CaseAffiliate::getContactTelphone ,Function.identity(), (k1, k2) -> k1)).values()); CaseApplication caseApplication = new CaseApplication(); caseApplication.setId(messageVO.getId()); CaseApplication caseApplicationselect = caseApplicationMapper.selectCaseApplication(caseApplication); @@ -3628,7 +3630,6 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService { caseAffiliate.setCaseAppliId(caseApplication.getId()); List caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); if (caseAffiliatListeselect != null) { - for (int j = 0; j < caseAffiliatListeselect.size(); j++) { CaseAffiliate caseAffiliateselect = caseAffiliatListeselect.get(j); int identityType = caseAffiliateselect.getIdentityType(); diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseZipImportImpl.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseZipImportImpl.java index 2c568b0..36e9790 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseZipImportImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/service/impl/CaseZipImportImpl.java @@ -150,11 +150,10 @@ public class CaseZipImportImpl { String caseNum = "zc" + currentDay; maxCaseNum = caseApplicationMapper.selectCaseNumLike(caseNum, caseNum.length()); // 抓取内容 - Map fatchMap = new HashMap<>(); + // 从抓取规则表取字段和字典表取基本字段,字典表的字段名塞到基本表,is_default=1自定义字段塞到columnValue // 抓取规则,0-内置字段,1-自定义字段 Map> fatchRuleMap = fatchRuleList.stream().collect(Collectors.groupingBy(FatchRule::getFileName)); - File directory = new File(targetPath); if (!directory.exists()) { throw new ServiceException("文件不存在"); @@ -163,19 +162,26 @@ public class CaseZipImportImpl { if (!directory.isDirectory() || directory.listFiles() == null) { throw new ServiceException("未找到文件夹"); } - Integer batchNumber = caseApplicationMapper.selectBatchNumberLike(); - AtomicInteger maxBatchNumber = new AtomicInteger(); - if (batchNumber == null) { - maxBatchNumber.set(1); - } else { - maxBatchNumber.set(batchNumber+1); - - } File[] files = directory.listFiles(); +// List caseApplications = new ArrayList<>(); +// for (File file1 : files) { +// if (file1.isDirectory() && file1.listFiles() != null) { +// +// for (File file2 : file1.listFiles()) { +// CaseApplication caseApplication = buildCaseInfo(file2, templateId, fatchRuleList, fatchRuleMap, userMap, dictDataList, deptMap, SecurityUtils.getLoginUser()); +// if (caseApplication != null) { +// caseApplications.add(caseApplication); +// } +// } +// } +// } +// if(caseApplications.size()>0){ +// return success("导入成功"); +// } CaseZipImportTask caseZipImportTask = null; try { - caseZipImportTask = new CaseZipImportTask(this, templateId, fatchRuleList, fatchMap, fatchRuleMap, userMap, dictDataList, files , deptMap, SecurityUtils.getLoginUser(),maxBatchNumber.get()); + caseZipImportTask = new CaseZipImportTask(this, templateId, fatchRuleList, fatchRuleMap, userMap, dictDataList, files , deptMap, SecurityUtils.getLoginUser()); } catch (Exception e) { return error("导入失败"); } @@ -193,12 +199,23 @@ public class CaseZipImportImpl { } @Transactional - public CaseApplication buildCaseInfo(File file, Long templateId, List fatchRuleList, Map> fatchRuleMap, Map fatchMap, Map userMap, List dictDataList, Map deptMap,LoginUser loginUser, Integer maxBatchNumber) { + public CaseApplication buildCaseInfo(File file, Long templateId, List fatchRuleList, Map> fatchRuleMap, Map userMap, List dictDataList, Map deptMap,LoginUser loginUser) { // fileMap> + Map fatchMap = new HashMap<>(); + Integer batchNumber = caseApplicationMapper.selectBatchNumberLike(); + AtomicInteger maxBatchNumber = new AtomicInteger(); + if (batchNumber == null) { + maxBatchNumber.set(1); + + } else { + maxBatchNumber.set(batchNumber+1); + + } Map fileMap = findFile(file, fatchRuleList); if (fileMap != null && fileMap.size()> 0) { // 根据抓取规则循环抓取 for (Map.Entry> entry : fatchRuleMap.entrySet()) { + System.out.println("根据抓取规则循环抓取======"+entry.getKey()); getFatchContent(fileMap, entry.getKey(), fatchMap, entry.getValue()); } @@ -250,7 +267,7 @@ public class CaseZipImportImpl { caseApplication.setCaseAppliId(caseApplication.getId()); // 设置批号 - caseApplication.setBatchNumber(maxBatchNumber); + caseApplication.setBatchNumber(maxBatchNumber.get()); // 设置编号 String maxCaseNumStr = generateCaseNum(); caseApplication.setCaseNum(maxCaseNumStr); @@ -315,7 +332,9 @@ public class CaseZipImportImpl { sysDeptMapper.batchSave(sysDepts); } + if (CollectionUtil.isNotEmpty(caseApplication.getCaseAffiliates())) { + caseAffiliateMapper.batchCaseAffiliate(caseApplication.getCaseAffiliates()); caseAffiliateLogMapper.batchCaseAffiliate(caseApplication.getCaseAffiliates()); } @@ -331,25 +350,25 @@ public class CaseZipImportImpl { // 新增日志 CaseLogUtils.insertCaseLog(caseApplication.getId(), CaseApplicationConstants.CASE_APPLICATION, "",loginUser); // 发送短信 - if (CollectionUtil.isNotEmpty(smsRequestList)) { - Map sendRecordMap = null; - if (CollectionUtil.isNotEmpty(smsSendRecordList)) { - sendRecordMap = smsSendRecordList.stream().collect(Collectors.toMap(SmsSendRecord::getCaseId, Function.identity())); - for (SmsUtils.SendSmsRequest sendSmsRequest : smsRequestList) { - Boolean aBoolean = SmsUtils.sendSms(request); - if (sendRecordMap != null && sendRecordMap.containsKey(sendSmsRequest.getCaseId())) { - if (aBoolean) { - sendRecordMap.get(sendSmsRequest.getCaseId()).setSendStatus(1); - } else { - sendRecordMap.get(sendSmsRequest.getCaseId()).setSendStatus(0); - } - } - } - smsRecordMapper.batchSaveSmsSendRecord(smsSendRecordList); - } - - - } +// if (CollectionUtil.isNotEmpty(smsRequestList)) { +// Map sendRecordMap = null; +// if (CollectionUtil.isNotEmpty(smsSendRecordList)) { +// sendRecordMap = smsSendRecordList.stream().collect(Collectors.toMap(SmsSendRecord::getCaseId, Function.identity())); +// for (SmsUtils.SendSmsRequest sendSmsRequest : smsRequestList) { +// Boolean aBoolean = SmsUtils.sendSms(request); +// if (sendRecordMap != null && sendRecordMap.containsKey(sendSmsRequest.getCaseId())) { +// if (aBoolean) { +// sendRecordMap.get(sendSmsRequest.getCaseId()).setSendStatus(1); +// } else { +// sendRecordMap.get(sendSmsRequest.getCaseId()).setSendStatus(0); +// } +// } +// } +// smsRecordMapper.batchSaveSmsSendRecord(smsSendRecordList); +// } +// +// +// } } catch (Exception e) { e.printStackTrace(); throw new RuntimeException("导入失败,请检查抓取规则是否正确"); @@ -844,27 +863,27 @@ public class CaseZipImportImpl { insertAgentUserRole(agentUser, roleId, userRoleList); } - if (addUsers != null) { - SysUser finalAgentUser = agentUser; - if (CollectionUtil.isNotEmpty(smsRequestList) && smsRequestList.stream().noneMatch(smsSendRecord -> smsSendRecord.getPhone().equals(finalAgentUser.getPhonenumber()))) { - SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); - request.setTemplateId("1956159"); - request.setPhone(agentUser.getPhonenumber()); - request.setTemplateParamSet(new String[]{agentUser.getNickName()}); - smsRequestList.add(request); - SmsSendRecord smsSendRecord = new SmsSendRecord(); - smsSendRecord.setCaseId(caseApplication.getId()); - smsSendRecord.setCaseNum(caseApplication.getCaseNum()); - smsSendRecord.setPhone(request.getPhone()); - smsSendRecord.setSendTime(new Date()); - String content = "尊敬的" + agentUser.getNickName() + ",您的代理的案件已接入仲裁系统,复制访问https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 进入小程序进行认证注册。如非本人操作,请忽略本短信"; - smsSendRecord.setSendContent(content); - // smsSendRecord.setCreateBy(getUsername()); - smsSendRecords.add(smsSendRecord); - } - - - } +// if (addUsers != null) { +// SysUser finalAgentUser = agentUser; +// if (CollectionUtil.isNotEmpty(smsRequestList) && smsRequestList.stream().noneMatch(smsSendRecord -> smsSendRecord.getPhone().equals(finalAgentUser.getPhonenumber()))) { +// SmsUtils.SendSmsRequest request = new SmsUtils.SendSmsRequest(); +// request.setTemplateId("1956159"); +// request.setPhone(agentUser.getPhonenumber()); +// request.setTemplateParamSet(new String[]{agentUser.getNickName()}); +// smsRequestList.add(request); +// SmsSendRecord smsSendRecord = new SmsSendRecord(); +// smsSendRecord.setCaseId(caseApplication.getId()); +// smsSendRecord.setCaseNum(caseApplication.getCaseNum()); +// smsSendRecord.setPhone(request.getPhone()); +// smsSendRecord.setSendTime(new Date()); +// String content = "尊敬的" + agentUser.getNickName() + ",您的代理的案件已接入仲裁系统,复制访问https://miniapp-3gpama6l759911ef-1321289474.tcloudbaseapp.com/jump-mp.html 进入小程序进行认证注册。如非本人操作,请忽略本短信"; +// smsSendRecord.setSendContent(content); +// // smsSendRecord.setCreateBy(getUsername()); +// smsSendRecords.add(smsSendRecord); +// } +// +// +// } } break; diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/task/CaseZipImportTask.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/task/CaseZipImportTask.java index 74409fb..8c4373d 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/task/CaseZipImportTask.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/task/CaseZipImportTask.java @@ -25,27 +25,25 @@ public class CaseZipImportTask implements Callable> { private CaseZipImportImpl caseZipImportImpl; private Long templateId; private List fatchRuleList; - private Map fatchMap; private Map> fatchRuleMap; private Map userMap; private List dictDataList; private File[] files; private Map deptMap; private LoginUser loginUser; - private Integer maxBatchNumber; - public CaseZipImportTask(CaseZipImportImpl caseZipImportImpl, Long templateId, List fatchRuleList, Map fatchMap, Map> fatchRuleMap, Map userMap, List dictDataList, File[] files, Map deptMap, LoginUser loginUser,Integer maxBatchNumber) { + + public CaseZipImportTask(CaseZipImportImpl caseZipImportImpl, Long templateId, List fatchRuleList, Map> fatchRuleMap, Map userMap, List dictDataList, File[] files, Map deptMap, LoginUser loginUser) { this.caseZipImportImpl = caseZipImportImpl; this.templateId = templateId; this.fatchRuleList = fatchRuleList; - this.fatchMap = fatchMap; this.fatchRuleMap = fatchRuleMap; this.userMap = userMap; this.dictDataList = dictDataList; this.files = files; this.deptMap = deptMap; this.loginUser = loginUser; - this.maxBatchNumber = maxBatchNumber; + } @Override @@ -56,7 +54,7 @@ public class CaseZipImportTask implements Callable> { if (file1.isDirectory() && file1.listFiles() != null) { for (File file2 : file1.listFiles()) { - CaseApplication caseApplication = caseZipImportImpl.buildCaseInfo(file2, templateId, fatchRuleList, fatchRuleMap, fatchMap, userMap, dictDataList, deptMap, loginUser,maxBatchNumber); + CaseApplication caseApplication = caseZipImportImpl.buildCaseInfo(file2, templateId, fatchRuleList, fatchRuleMap, userMap, dictDataList, deptMap, loginUser); if (caseApplication != null) { caseApplications.add(caseApplication); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java index 4aff732..1135903 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java +++ b/ruoyi-system/src/main/java/com/ruoyi/wisdomarbitrate/utils/OCRUtils.java @@ -115,13 +115,24 @@ public class OCRUtils { if (StrUtil.isEmpty(ocrText) || CollectionUtil.isEmpty(fatchRules)) { return; } + // 将识别后的字符串英文标点符号全部转为中文标点符号 + String ocrTextReplace = ocrText.replace(",", ",") +// .replace(".", "。") + .replace(":", ":").replace(";", ";").replace("?", "?").replace("!", "!").replace("(", "(") + .replace(")", ")").replace("[", "【").replace("]", "】").replace("{", "{").replace("}", "}") + .replace("<", "《").replace(">", "》").replace("|", "|").replace("\\", "\").replace("_", "_") + .replace("-", "-").replace("+", "+").replace("=", "=").replace("~", "~").replace("`", "`") + .replace("^", "^").replace("$", "¥").replace("@", "@").replace("#", "#").replace("%", "%") + .replace("&", "&").replace("*", "*").replace("(", "(").replace(")", ")").replace("{", "{") + .replace("}", "}").replace("[", "【").replace("]", "】").replace("<", "《").replace(">", "》") + .replace("|", "|").replace("\\", "\").replace("_", "_"); for (FatchRule fatchRule : fatchRules) { // 从后往前抓取 if (fatchRule.getFatchOrder() != null && fatchRule.getFatchOrder() == 1) { - reverseSubstringText(ocrText, fatchRule, fatchMap,null); + reverseSubstringText(ocrTextReplace, fatchRule, fatchMap,null); } else { // 从前往后抓取 - substringText(ocrText, fatchRule, fatchMap,null); + substringText(ocrTextReplace, fatchRule, fatchMap,null); } } diff --git a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml index 1a29b3f..eece460 100644 --- a/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/wisdomarbitrate/CaseAffiliateMapper.xml @@ -37,19 +37,24 @@