Merge branch 'wq' of SH-Arbitrate/Arbitrate-Backend into dev

This commit was merged in pull request #346.
This commit is contained in:
2024-04-29 16:52:36 +08:00
committed by Gitea
7 changed files with 132 additions and 77 deletions
@@ -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("<br/>" + successNum + "、账号 " + user.getUserName() + " 导入成功");
@@ -218,6 +218,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
*/
@Override
public List<CaseApplication> 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<CaseApplication> caseApplicationlist = caseApplicationMapper.selectAdminCaseApplicationList(caseApplication);
@@ -2265,7 +2266,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseAffiliate.setCaseAppliId(caseApplication.getId());
List<CaseAffiliate> 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<CaseAffiliate> caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
if (caseAffiliatListeselect != null) {
for (int j = 0; j < caseAffiliatListeselect.size(); j++) {
CaseAffiliate caseAffiliateselect = caseAffiliatListeselect.get(j);
int identityType = caseAffiliateselect.getIdentityType();
@@ -150,11 +150,10 @@ public class CaseZipImportImpl {
String caseNum = "zc" + currentDay;
maxCaseNum = caseApplicationMapper.selectCaseNumLike(caseNum, caseNum.length());
// 抓取内容
Map<String, String> fatchMap = new HashMap<>();
// 从抓取规则表取字段和字典表取基本字段,字典表的字段名塞到基本表,is_default=1自定义字段塞到columnValue
// 抓取规则,0-内置字段,1-自定义字段
Map<String, List<FatchRule>> 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<CaseApplication> 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<FatchRule> fatchRuleList, Map<String, List<FatchRule>> fatchRuleMap, Map<String, String> fatchMap, Map<String, SysUser> userMap, List<SysDictData> dictDataList, Map<String, Long> deptMap,LoginUser loginUser, Integer maxBatchNumber) {
public CaseApplication buildCaseInfo(File file, Long templateId, List<FatchRule> fatchRuleList, Map<String, List<FatchRule>> fatchRuleMap, Map<String, SysUser> userMap, List<SysDictData> dictDataList, Map<String, Long> deptMap,LoginUser loginUser) {
// fileMap<caseId, List<File>>
Map<String, String> fatchMap = new HashMap<>();
Integer batchNumber = caseApplicationMapper.selectBatchNumberLike();
AtomicInteger maxBatchNumber = new AtomicInteger();
if (batchNumber == null) {
maxBatchNumber.set(1);
} else {
maxBatchNumber.set(batchNumber+1);
}
Map<String, String> fileMap = findFile(file, fatchRuleList);
if (fileMap != null && fileMap.size()> 0) {
// 根据抓取规则循环抓取
for (Map.Entry<String, List<FatchRule>> 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<Long, SmsSendRecord> 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<Long, SmsSendRecord> 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;
@@ -25,27 +25,25 @@ public class CaseZipImportTask implements Callable<List<CaseApplication>> {
private CaseZipImportImpl caseZipImportImpl;
private Long templateId;
private List<FatchRule> fatchRuleList;
private Map<String, String> fatchMap;
private Map<String, List<FatchRule>> fatchRuleMap;
private Map<String, SysUser> userMap;
private List<SysDictData> dictDataList;
private File[] files;
private Map<String, Long> deptMap;
private LoginUser loginUser;
private Integer maxBatchNumber;
public CaseZipImportTask(CaseZipImportImpl caseZipImportImpl, Long templateId, List<FatchRule> fatchRuleList, Map<String, String> fatchMap, Map<String, List<FatchRule>> fatchRuleMap, Map<String, SysUser> userMap, List<SysDictData> dictDataList, File[] files, Map<String, Long> deptMap, LoginUser loginUser,Integer maxBatchNumber) {
public CaseZipImportTask(CaseZipImportImpl caseZipImportImpl, Long templateId, List<FatchRule> fatchRuleList, Map<String, List<FatchRule>> fatchRuleMap, Map<String, SysUser> userMap, List<SysDictData> dictDataList, File[] files, Map<String, Long> 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<List<CaseApplication>> {
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);
}
@@ -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);
}
}
@@ -37,19 +37,24 @@
</resultMap>
<select id="selectCaseAffiliate" parameterType="CaseAffiliate" resultMap="CaseAffiliateResult">
select distinct (c.id),
select c.id,
c.case_appli_id, c.identity_type,c.application_organ_id,c.application_organ_name,c.name,c.identity_num,c.contact_telphone,
c.contact_address,c.work_address,c.work_telphone ,c.name_agent,c.identity_num_agent,c.contact_telphone_agent,
c.comp_legal_person,c.comp_legalper_post,c.respon_sex ,c.respon_birth,
c.residen_affili,appli_agent_title,
c.contact_address_agent,c.email, c.send_email,c.track_num,c.applicant_agent_user_id,c.agent_email,s.user_id
from case_affiliate c
left join sys_user s on c.identity_num=s.id_card
<where>
<if test="caseAppliId != null ">
AND c.case_appli_id = #{caseAppliId}
</if>
</where>
left JOIN (
SELECT phonenumber,user_id, ROW_NUMBER() OVER(PARTITION BY phonenumber ORDER BY user_id ASC) as rn
FROM sys_user
) s ON c.contact_telphone = s.phonenumber
WHERE
s.rn = 1
<if test="caseAppliId != null ">
AND c.case_appli_id = #{caseAppliId}
</if>
</select>
<select id="selectCaseAffiliateByCaseIds" resultMap="CaseAffiliateResult">
select (c.id),
@@ -59,15 +64,18 @@
c.residen_affili,appli_agent_title,
c.contact_address_agent,c.email, c.send_email,c.track_num,c.applicant_agent_user_id,c.agent_email,s.user_id
from case_affiliate c
left join sys_user s on c.identity_num=s.id_card
<where>
<if test="ids != null ">
case_appli_id in
left JOIN (
SELECT phonenumber,user_id, ROW_NUMBER() OVER(PARTITION BY phonenumber ORDER BY user_id ASC) as rn
FROM sys_user
) s ON c.contact_telphone = s.phonenumber
WHERE
s.rn = 1
<if test="ids != null ">
and case_appli_id in
<foreach collection="ids" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>
<select id="selectCaseAffiliateByIdentityType" resultMap="CaseAffiliateResult">
select c.*
@@ -1379,7 +1379,7 @@
from reserved_conference ;
</select>
<select id="selectBatchNumberLike" resultType="java.lang.Integer">
select max(batch_number) as maxBatchNumber
select max(batch_number+0) as maxBatchNumber
from case_application ;
</select>