This commit is contained in:
18792927508
2023-10-17 13:50:15 +08:00
parent 4ee0dda38c
commit 371284d360
4 changed files with 99 additions and 15 deletions
@@ -49,6 +49,14 @@ public interface SysRoleMapper
*/
public SysRole selectRoleById(Long roleId);
/**
* 根据角色名称查询角色id
* @param roleName
* @return
*/
public Long selectRoleIdByName(String roleName);
/**
* 根据用户ID查询角色
*
@@ -28,7 +28,10 @@ import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.system.domain.SysUserRole;
import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
import com.ruoyi.common.utils.bean.BeanUtils;
@@ -81,6 +84,10 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
@Autowired
private SysUserMapper sysUserMapper;
@Autowired
private SysUserRoleMapper userRoleMapper;
@Autowired
private SysRoleMapper roleMapper;
@Autowired
private SealSignRecordMapper sealSignRecordMapper;
@Autowired
private CaseLogRecordMapper caseLogRecordMapper;
@@ -126,11 +133,14 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseStatusList.add(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL);
caseStatusList.add(CaseApplicationConstants.SIGN_ARBITRATION);
caseStatusList.add(CaseApplicationConstants.ARBITRATED_SEAL);
return caseApplicationMapper.selectDeptHeadCaseApplicationList(caseApplication,caseStatusList);
caseApplication.setDeptHeadStatus(caseStatusList);
}
if(role.getRoleName().equals("仲裁员")){
caseApplication.setUserId(String.valueOf(userId));
}
if(role.getRoleName().equals("财务")){
caseApplication.setFinanceStatus(CaseApplicationConstants.PENDING_PAYMENT_CONFIRM);
}
if(role.getRoleName().equals("法律顾问")){
// 查询角色有关的用户部门
List<Long> deptIds = sysDeptMapper.selectUserDeptListByRoleId(role.getRoleId());
@@ -174,10 +184,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
){
return caseApplicationMapper.selectAdminCaseToDoCount();
}
// 查看所有案件
if(role.getRoleName().equals("仲裁委")
||role.getRoleName().equals("部门长")){
caseStatusList.add(CaseApplicationConstants.CONFIRMDED_PENDING_TRIAL);
caseStatusList.add(CaseApplicationConstants.SIGN_ARBITRATION);
caseStatusList.add(CaseApplicationConstants.ARBITRATED_SEAL);
@@ -205,6 +214,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
// 根据条件查询申请人,被申请人,仲裁员,法律顾问案件
return caseApplicationMapper.selectTodoCountByRole(caseApplication);
}
@@ -264,7 +275,10 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
// 组装申请代理人信息
buildAgentInfo(caseAffiliate);
String agentInfoFlag = buildAgentInfo(caseAffiliate);
if(StrUtil.isNotEmpty(agentInfoFlag)){
throw new ServiceException(agentInfoFlag);
}
}
}
@@ -352,7 +366,10 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseAffiliate.setApplicationOrganId(String.valueOf(dept.getDeptId()));
}
buildAgentInfo(caseAffiliate);
String agentInfoFlag = buildAgentInfo(caseAffiliate);
if(StrUtil.isNotEmpty(agentInfoFlag)){
throw new ServiceException(agentInfoFlag);
}
}
@@ -376,12 +393,14 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
* 组装申请代理人信息
* @param caseAffiliate
*/
private void buildAgentInfo(CaseAffiliate caseAffiliate) {
if(StrUtil.isNotEmpty(caseAffiliate.getNameAgent())){
private String buildAgentInfo(CaseAffiliate caseAffiliate) {
if (caseAffiliate.getIdentityType()==1&&StrUtil.isNotEmpty(caseAffiliate.getNameAgent())) {
// 查询申请人角色id
Long roleId = roleMapper.selectRoleIdByName("申请人");
// 组装申请机构代理人信息,用户表新增并且和部门关联
// 根据代理人身份证去用户表查询,有修改,么有新增
SysUser agentUser = sysUserMapper.selectUserByIdCard(caseAffiliate.getIdentityNumAgent());
if(agentUser==null){
if (agentUser == null) {
agentUser = new SysUser();
agentUser.setIdCard(caseAffiliate.getIdentityNumAgent());
agentUser.setNickName(caseAffiliate.getNameAgent());
@@ -390,18 +409,46 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
agentUser.setPassword(SecurityUtils.encryptPassword(Constants.DEFAULT_PASSWORD));
agentUser.setDeptId(Long.valueOf(caseAffiliate.getApplicationOrganId()));
int insertUserRow = sysUserMapper.insertUser(agentUser);
if(insertUserRow>0) {
// 新增角色为申请人
ArrayList<SysUserRole> sysUserRoles = new ArrayList<>();
SysUserRole sysUserRole = new SysUserRole();
sysUserRole.setUserId(agentUser.getUserId());
sysUserRole.setRoleId(roleId);
sysUserRoles.add(sysUserRole);
if(CollectionUtil.isNotEmpty(sysUserRoles)) {
userRoleMapper.batchUserRole(sysUserRoles);
}
if (insertUserRow > 0) {
caseAffiliate.setApplicantAgentUserId(String.valueOf(agentUser.getUserId()));
// 发送短信 todo
}
}else {
} else if (null != agentUser.getDeptId() && !String.valueOf(agentUser.getDeptId()).equals(caseAffiliate.getApplicationOrganId())) {
return "申请机构与申请代理人不匹配";
} else if (null != agentUser.getDeptId() && String.valueOf(agentUser.getDeptId()).equals(caseAffiliate.getApplicationOrganId())){
// 同步用户表和案件关联人表的手机号和名称
caseAffiliate.setContactTelphoneAgent(agentUser.getPhonenumber());
caseAffiliate.setNameAgent(agentUser.getNickName());
caseAffiliate.setApplicantAgentUserId(String.valueOf(agentUser.getUserId()));
// 新增角色为申请人
if(agentUser.getRoleIds()!=null) {
List<Long> longList = Arrays.asList(agentUser.getRoleIds());
if(!longList.contains(roleId)) {
ArrayList<SysUserRole> sysUserRoles = new ArrayList<>();
SysUserRole sysUserRole = new SysUserRole();
sysUserRole.setUserId(agentUser.getUserId());
sysUserRole.setRoleId(roleId);
sysUserRoles.add(sysUserRole);
if (CollectionUtil.isNotEmpty(sysUserRoles)) {
userRoleMapper.batchUserRole(sysUserRoles);
}
}
}
}
}
return null;
}
@Override
@@ -529,7 +576,13 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
// }else {
// caseApplicationListinsert.add(caseApplication);
// }
caseApplicationListinsert.add(caseApplication);
if(StrUtil.isEmpty(caseApplication.getErrorMsg())) {
caseApplicationListinsert.add(caseApplication);
}else {
// 拼接错误信息
failureMsg.append("<br/>").append("第").append(i+2).append("行:").append(caseApplication.getErrorMsg().toString());
}
}else {
// 拼接错误信息
failureMsg.append("<br/>").append("第").append(i+2).append("行:").append(caseApplication.getErrorMsg().toString());
@@ -577,7 +630,6 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
if(caseAffiliates!=null&&caseAffiliates.size()>0){
for (CaseAffiliate caseAffiliate : caseAffiliates){
caseAffiliate.setCaseAppliId(caseApplicationItera.getId());
buildAgentInfo(caseAffiliate);
}
caseAffiliateMapper.batchCaseAffiliate(caseAffiliates);
@@ -1444,6 +1496,15 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
if(StrUtil.isNotEmpty(caseApplication.getName())){
setApplicantOrganization(caseAffiliate, caseApplication, deptMap);
}
String s = buildAgentInfo(caseAffiliate);
if(StrUtil.isNotEmpty(s)){
StringBuilder errorMsg = caseApplication.getErrorMsg();
if(StrUtil.isEmpty(errorMsg)){
errorMsg=new StringBuilder();
}
errorMsg.append(s);
caseApplication.setErrorMsg(errorMsg);
}
caseAffiliatesnew.add(caseAffiliate);
// 组装被申请人信息