Merge branch 'wq1' of SH-Arbitrate/Mediation-Backend into dev

This commit was merged in pull request #36.
This commit is contained in:
2024-01-22 17:56:38 +08:00
committed by Gitea
5 changed files with 121 additions and 22 deletions
@@ -29,6 +29,10 @@ public class MsCaseApplicationReq {
* 申请机构
*/
private String applicationOrganId;
/**
* 是否申请人,不为空则是申请人
*/
private Integer applicantFlag ;
/**
* 案件状态ID
*/
@@ -64,5 +68,13 @@ public class MsCaseApplicationReq {
* 模板类型,1调解书,2调解申请书
*/
private Integer templateType=2;
/**
* 被申请人身份证
*/
private String respondentIdentityNum;
/**
* 是否在线开庭,空-书面
*/
private Integer hearDateFlag ;
}
@@ -34,7 +34,7 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
* @param caseStatusNames
* @return
*/
@Select("<script> select t.* from (select c.id,c.mediation_method mediationMethod,0 AS pendingStatus,c.case_flow_id caseFlowId,c.batch_number batchNumber,c.case_num caseNum,c.case_subject_amount caseSubjectAmount," +
@Select("<script> select t.* from (select c.id,c.room_id roomId,c.mediation_method mediationMethod,0 AS pendingStatus,c.case_flow_id caseFlowId,c.batch_number batchNumber,c.case_num caseNum,c.case_subject_amount caseSubjectAmount," +
"a.application_organ_name applicationOrganName,a.respondent_name respondentName,c.mediator_name mediatorName," +
"c.hear_date hearDate,c.case_status_name caseStatusName,c.create_time createTime from ms_case_application c " +
"join ms_case_affiliate a on c.id=a.case_appli_id <where> " +
@@ -53,15 +53,23 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
" AND c.case_num = #{req.caseNum} " +
"</if> " +
"<if test=\"req.applicationOrganId != null and req.applicationOrganId != ''\">" +
"<if test=\"req.applicantFlag != null \">" +
" AND a.application_organ_id = #{req.applicationOrganId} " +
"</if> " +
"</if> "
+ "<if test=\"req.respondentIdentityNum != null and req.respondentIdentityNum != ''\">" +
" AND a.respondent_identity_num = #{req.respondentIdentityNum} " +
"</if> "
+
"<if test=\"req.hearDateFlag != null \">" +
" AND a.mediation_method = '1'" +
"</if> "
+
"<if test=\"req.startTime != null and req.startTime != ''\">" +
"and c.create_time &gt;= #{req.startTime}</if>" +
"<if test=\"req.endTime != null and req.endTime != ''\">" +
"and c.create_time &lt;= #{req.endTime}</if>" +
" </where> " +
"union select c.id id,c.mediation_method mediationMethod,1 AS pendingStatus,c.case_flow_id caseFlowId,c.batch_number batchNumber,c.case_num caseNum,c.case_subject_amount caseSubjectAmount," +
"union select c.id id,c.room_id roomId,c.mediation_method mediationMethod,1 AS pendingStatus,c.case_flow_id caseFlowId,c.batch_number batchNumber,c.case_num caseNum,c.case_subject_amount caseSubjectAmount," +
"a.application_organ_name applicationOrganName,a.respondent_name respondentName,c.mediator_name mediatorName," +
"c.hear_date hearDate,c.case_status_name caseStatusName,c.create_time createTime from ms_case_log_record r " +
"join ms_case_application c on r.case_appli_id=c.id and r.case_status_name!=c.case_status_name " +
@@ -83,9 +91,18 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
"<if test=\"req.caseNum != null and req.caseNum != ''\">" +
" AND c1.case_num = #{req.caseNum} " +
"</if> " +
"<if test=\"req.applicationOrganId != null and req.applicationOrganId != ''\">" +
"<if test=\"req.applicantFlag != null \">" +
" AND a1.application_organ_id = #{req.applicationOrganId} " +
"</if> " +
"</if> "
+ "<if test=\"req.respondentIdentityNum != null and req.respondentIdentityNum != ''\">" +
" AND a.respondent_identity_num = #{req.respondentIdentityNum} " +
"</if> "
+
"<if test=\"req.hearDateFlag != null \">" +
" AND a.mediation_method = '1'" +
"</if> "
+
"<if test=\"req.startTime != null and req.startTime != ''\">" +
"and c1.create_time &gt;= #{req.startTime}</if>" +
"<if test=\"req.endTime != null and req.endTime != ''\">" +
@@ -108,9 +125,18 @@ public interface MsCaseApplicationMapper extends Mapper<MsCaseApplication> {
"<if test=\"req.caseNum != null and req.caseNum != ''\">" +
" AND c.case_num = #{req.caseNum} " +
"</if> " +
"<if test=\"req.applicationOrganId != null and req.applicationOrganId != ''\">" +
"<if test=\"req.applicantFlag != null \">" +
" AND a.application_organ_id = #{req.applicationOrganId} " +
"</if> " +
"</if> "
+ "<if test=\"req.respondentIdentityNum != null and req.respondentIdentityNum != ''\">" +
" AND a.respondent_identity_num = #{req.respondentIdentityNum} " +
"</if> "
+
"<if test=\"req.hearDateFlag != null \">" +
" AND a.mediation_method = '1'" +
"</if> "
+
"<if test=\"req.startTime != null and req.startTime != ''\">" +
"and c.create_time &gt;= #{req.startTime}</if>" +
"<if test=\"req.endTime != null and req.endTime != ''\">" +
@@ -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("未找到模板");
@@ -1558,9 +1571,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";
@@ -1570,7 +1583,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();
@@ -1653,7 +1666,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)) {
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.wisdomarbitrate.mapper.mscase.MsCaseMediatorMapper">
<resultMap id="BaseResultMap" type="com.ruoyi.wisdomarbitrate.domain.entity.mscase.MsCaseMediator">
<!--
WARNING - @mbg.generated
-->
<id column="id" jdbcType="BIGINT" property="id" />
<result column="case_appli_id" jdbcType="BIGINT" property="caseAppliId" />
<result column="mediator_id" jdbcType="VARCHAR" property="mediatorId" />
<result column="mediator_name" jdbcType="VARCHAR" property="mediatorName" />
<result column="hear_date" jdbcType="VARCHAR" property="hearDate" />
<result column="identity_type" jdbcType="INTEGER" property="identityType" />
</resultMap>
</mapper>