This commit is contained in:
qitz
2024-01-23 14:01:50 +08:00
5 changed files with 121 additions and 22 deletions
@@ -1,15 +1,19 @@
package com.ruoyi.wisdomarbitrate.service.miniprogress.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.SmsUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.wisdomarbitrate.domain.dto.miniprogress.IdentityAuthentication;
import com.ruoyi.wisdomarbitrate.domain.vo.miniprogress.WeChatUserVO;
import com.ruoyi.wisdomarbitrate.mapper.miniprogress.IdentityAuthenticationMapper;
@@ -18,6 +22,8 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.Objects;
import java.util.Random;
import java.util.concurrent.TimeUnit;
@@ -32,6 +38,10 @@ public class WeChatUserServiceImpl implements WeChatUserService {
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private SysUserRoleMapper userRoleMapper;
@Autowired
private IdentityAuthenticationMapper identityAuthenticationMapper;
@Override
@@ -112,6 +122,11 @@ public class WeChatUserServiceImpl implements WeChatUserService {
// 根据身份证查询系统用户表中是否存在该用户,存在则同步已认证的信息,不存在则新增
SysUser sysUser=sysUserMapper.selectUserByIdCard(ientityAuthentication.getIdentityNo());
// 查询角色
Long roleIdByName = roleMapper.selectRoleIdByName("被申请人");
if(roleIdByName==null){
return AjaxResult.warn("被申请人角色不存在,请联系系统管理员新增角色");
}
if(sysUser!=null){
sysUser.setIdCard(ientityAuthentication.getIdentityNo());
sysUser.setNickName(ientityAuthentication.getName());
@@ -121,6 +136,21 @@ public class WeChatUserServiceImpl implements WeChatUserService {
sysUser.setPassword(SecurityUtils.encryptPassword(ientityAuthentication.getPassWord()));
sysUserMapper.updateUser(sysUser);
ientityAuthentication.setUserId(sysUser.getUserId());
int count=0;
if(CollectionUtil.isNotEmpty(sysUser.getRoles()) ){
for (SysRole role : sysUser.getRoles()) {
if(Objects.equals(role.getRoleId(), roleIdByName)){
count++;
break;
}
}
}
if(CollectionUtil.isEmpty(sysUser.getRoles())||count==0){
// 用户未关联被申请人角色,关联角色
userRoleMapper.insertUserRole(sysUser.getUserId(), roleIdByName);
}
}else {
sysUser=new SysUser();
sysUser.setIdCard(ientityAuthentication.getIdentityNo());
@@ -134,12 +164,15 @@ public class WeChatUserServiceImpl implements WeChatUserService {
if(row<1) {
return AjaxResult.warn("注册失败");
}
// 用户关联被申请人角色
userRoleMapper.insertUserRole(sysUser.getUserId(), roleIdByName);
}
ientityAuthentication.setUserId(sysUser.getUserId());
ientityAuthentication.setUserName(sysUser.getUserName());
// 已经认证过的用户才能注册,认证表中已经有该数据
identityAuthenticationMapper.updateIdentityAuthentication(ientityAuthentication);
// 查询角色
return AjaxResult.success("注册成功");
}
@@ -150,7 +150,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
// 根据用户查询角色
LoginUser loginUser = SecurityUtils.getLoginUser();
List<SysRole> roles = loginUser.getUser().getRoles();
SysUser sysUser = loginUser.getUser();
List<SysRole> roles = sysUser.getRoles();
if (CollectionUtil.isEmpty(roles)) {
throw new ServiceException("该用户未指定角色");
}
@@ -169,6 +170,18 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
if (CollectionUtil.isEmpty(caseFlows)) {
throw new ServiceException("该角色为绑定案件流程");
}
for (SysRole role : roles) {
if(StrUtil.isNotEmpty(role.getRoleName())&&StrUtil.equals(role.getRoleName(),"申请人")){
if(loginUser.getDeptId()!=null) {
req.setApplicationOrganId(String.valueOf(loginUser.getDeptId()));
}
req.setApplicantFlag(1);
}
if(StrUtil.isNotEmpty(role.getRoleName())&&StrUtil.equals(role.getRoleName(),"被申请人")){
// todo 被申请人案件根据被申请人身份证号查询案件列表
req.setRespondentIdentityNum(sysUser.getIdCard());
}
}
startPage();
// 查询案件列表
List<MsCaseApplicationVO> caseApplicationList = msCaseApplicationMapper.list(req, caseFlows.stream().map(MsCaseFlow::getCaseStatusName).collect(Collectors.toList()));
@@ -264,7 +277,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
affiliate.setCaseAppliId(caseApplication.getId());
msCaseAffiliateMapper.insert(affiliate);
// 生成调解申请书
// 查询调解申请书模板id
TemplateManage templateManage=templateManageMapper.selectByType(2);
if(templateManage!=null) {
@@ -277,6 +289,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
// 压缩包导入
req.setBatchNumber(caseApplication.getBatchNumber());
}
// 生成调解申请书
req.setTemplateId(String.valueOf(templateManage.getId()));
generateApplication(req);
@@ -589,7 +602,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
List<Long> caseIds = caseApplicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList());
// 根据ids查询案件关联人员
Example afflicateExample = new Example(MsCaseAffiliate.class);
afflicateExample.createCriteria().andIn("case_appli_id", caseIds);
afflicateExample.createCriteria().andIn("caseAppliId", caseIds);
List<MsCaseAffiliate> affiliateList = msCaseAffiliateMapper.selectByExample(afflicateExample);
if(CollectionUtil.isEmpty(affiliateList)){
throw new ServiceException("该批次号下未找到案件关联人员");
@@ -712,7 +725,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
// 查询案件关联人员
Example example = new Example(MsCaseAffiliate.class);
example.createCriteria().andIn("case_appli_id", applicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList()));
example.createCriteria().andIn("caseAppliId", applicationList.stream().map(MsCaseApplication::getId).collect(Collectors.toList()));
List<MsCaseAffiliate> affiliateList = msCaseAffiliateMapper.selectByExample(example);
if (CollectionUtil.isEmpty(affiliateList)) {
return AjaxResult.error("该批次号下未找到案件");
@@ -841,10 +854,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
// 查询日志中是否有该节点的被申请人操作
Example example = new Example(MsCaseLogRecord.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("case_appli_id", vo.getId());
criteria.andEqualTo("case_node", nextFlow.getNodeId());
criteria.andEqualTo("case_status_name", nextFlow.getCaseStatusName());
criteria.andEqualTo("create_by", user.getUserName());
criteria.andEqualTo("caseAppliId", vo.getId());
criteria.andEqualTo("caseNode", nextFlow.getNodeId());
criteria.andEqualTo("caseStatusName", nextFlow.getCaseStatusName());
criteria.andEqualTo("createBy", user.getUserName());
int count = caseLogRecordMapper.selectCountByExample(example);
if(count>0){
// 被申请人已预约,更新流程节点
@@ -1092,8 +1105,8 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
// 查询调解书模板是否存在
Example example = new Example(MsCaseApplication.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("batch_number", req.getBatchNumber());
criteria.andIsNotNull("template_id");
criteria.andEqualTo("batchNumber", req.getBatchNumber());
criteria.andIsNotNull("templateId");
MsCaseApplication caseApplication = msCaseApplicationMapper.selectOneByExample(example);
if(caseApplication==null||caseApplication.getTemplateId()==null){
return AjaxResult.error("未找到模板");
@@ -1815,9 +1828,9 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
// todo
String saveFolderPath = RuoYiConfig.getUploadPath()+"/"+ year + "/" + month + "/" + day;
Integer annexType = AnnexTypeEnum.MEDIATION_APPLICATION.getCode();
String orgFileName = "调解申请书.docx";
String orgFileName = "调解申请书";
if(templateType!=null&&templateType==1) {
orgFileName = "调解书.docx";
orgFileName = "调解书";
annexType=AnnexTypeEnum.MEDIATE_BOOK.getCode();
}
String fileName = UUID.randomUUID().toString().replace("-", "")+orgFileName + ".docx";
@@ -1827,7 +1840,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
MsCaseAttach caseAttach = MsCaseAttach.builder()
.caseAppliId(application.getId())
.annexName(orgFileName)
.annexName(orgFileName+".docx")
.annexPath(resultFilePath.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX))
.annexType(annexType)
.build();
@@ -1910,7 +1923,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
// String filePath = RuoYiConfig.getUploadPath();
MsCaseAttach caseAttach = new MsCaseAttach();
caseAttach.setCaseAppliId(caseApplication.getId());
caseAttach.setAnnexPath(entry.getValue());
caseAttach.setAnnexPath(fileUrl.replace(RuoYiConfig.getProfile(),Constants.RESOURCE_PREFIX));
caseAttach.setAnnexName(entry.getKey());
// todo
// if (StrUtil.isNotEmpty(fileUrl)) {