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

This commit was merged in pull request #152.
This commit is contained in:
2024-04-25 18:16:28 +08:00
committed by Gitea
8 changed files with 177 additions and 54 deletions
@@ -41,8 +41,7 @@ public class IdentityAuthenticationController extends BaseController {
@Anonymous
@GetMapping("/selectPCEIDtokenStatus")
public AjaxResult selectPCEIDtokenStatus(@RequestParam String eidToken) {
JSONObject tokenResult = identityAuthenticationService.selectPCEIDtokenStatus(eidToken);
return success(tokenResult);
return identityAuthenticationService.selectPCEIDtokenStatus(eidToken);
}
/**
@@ -250,7 +250,7 @@ public class MsCaseApplicationController extends BaseController {
* @return
*/
@GetMapping("/listMediator")
public AjaxResult listMediator( @RequestParam(value = "caseAppliId",required = false) Long caseAppliId) {
public AjaxResult listMediator( @RequestParam(value = "caseAppliId",required = true) Long caseAppliId) {
return caseApplicationService.listMediator(caseAppliId);
}
/**
@@ -310,7 +310,7 @@ public class MsCaseApplicationController extends BaseController {
*/
@PostMapping("/mediation")
public AjaxResult mediation(@RequestBody MsCaseApplicationReq req) throws EsignDemoException, InterruptedException {
if (req.getCaseFlowId() == null || req.getId() == null || req.getMediaResult()==null) {
if (req.getCaseFlowId() == null || req.getId() == null ) {
return error("参数校验失败");
}
@@ -175,7 +175,7 @@ identityAuthentication:
# 小程序端人脸核身商户id
merchantId: 0NSJ2309281116194321
# pc端人脸核身商户id
pcMerchantId: 0NSJ2309281116194321
pcMerchantId: 0NSJ2404231626029804
privateKeyHexDecodeinfo: 4c3b311bf7b98969994e85928e069574a1e95777f24d1c510679cc3c2f460faf
# 腾讯云即时通信相关配置
imConfig:
@@ -84,11 +84,11 @@ public class MsCaseApplicationVO extends MsCaseApplication {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "Asia/Shanghai")
private Date endTime;
/**
* 是否申请操作人,0-否,1-是
* 是否申请操作人签名按钮权限,0-否,1-是
*/
private Integer appOperatorFlag;
/**
* 是否被申请操作人,0-否,1-是
* 是否被申请操作人签名按钮权限,0-否,1-是
*/
private Integer resOperatorFlag;
/**
@@ -99,5 +99,9 @@ public class MsCaseApplicationVO extends MsCaseApplication {
* 调解书上传下载按钮权限,调解员,顾问在调节之后,送达之前显示,0-否,1-是
*/
private Integer mediationFileFlag=0;
/**
* 是否申请人被申请人签收按钮权限,0-否,1-是
*/
private Integer signFlag=0;
}
@@ -36,5 +36,5 @@ public interface IdentityAuthenticationService {
* H5轮询获取EIDtoken状态
* @return
*/
JSONObject selectPCEIDtokenStatus(String eidToken);
AjaxResult selectPCEIDtokenStatus(String eidToken);
}
@@ -231,10 +231,12 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
}
@Override
public JSONObject selectPCEIDtokenStatus(String eidToken) {
public AjaxResult selectPCEIDtokenStatus(String eidToken) {
// todo 送达时需要判断是否有pdf版的调解书,没有则不送达,签名完后下载pdf时不删除之前的doc调解书,上传调解书时,pdf的需要将类型设为13,异步发送短信邮件时将登录用户传参过来
// todo E证通审核过后将PC端的机器id在YML文件中改掉
JSONObject objJSON = null;
IdentityAuthentication authentication = new IdentityAuthentication();
try {
Credential cred = new Credential(credentialSecretId, credentialSecretKey);
// 实例化一个http选项,可选的,没有特殊需求可以跳过
@@ -254,11 +256,62 @@ public class IdentityAuthenticationServiceImpl implements IdentityAuthentication
String s = GetEidResultResponse.toJsonString(resp);
if(StrUtil.isNotEmpty(s)) {
objJSON = JSON.parseObject(s);
JSONObject text = objJSON.getJSONObject("Text");
if (text != null) {
Integer comparestatus = text.getInteger("Comparestatus");
if (comparestatus != null && comparestatus == 0) {
JSONObject eidInfo = objJSON.getJSONObject("EidInfo");
if (eidInfo != null) {
String desKey = eidInfo.getString("DesKey");
String userInfo = eidInfo.getString("UserInfo");
//1.解密用户的信息
JSONObject info = DecodeUserInfo(desKey, userInfo);
if (info != null) {
String idcardno = info.getString("idnum");
String name = info.getString("name");
//2.在用户认证表中插入用户认证记录
// LoginUser loginUser = SecurityUtils.getLoginUser();
/**
* 用户名
* 用户名id
* 姓名
* 身份证号
* 认证时间
* 认证状态0表示成功
* 请求id
*/
// authentication.setUserName(loginUser.getUsername());
// authentication.setUserId(loginUser.getUserId());
authentication.setIdentityNo(idcardno);
// 查询认证表是否已存在该身份证信息的认证,不存在则新增,存在不处理
IdentityAuthentication identityAuthentication = identityAuthenticationMapper.selectIdentityAuthentication(authentication);
if(identityAuthentication!=null) {
return AjaxResult.success(identityAuthentication);
}
authentication.setName(name);
authentication.setCertificationTime(new Date());
authentication.setCertificationStatus(0);
authentication.setCreateBy(name);
// authentication.setCreateBy(loginUser.getUsername());
try {
identityAuthenticationMapper.insertIdentityAuthentication(authentication);
authentication.setId(authentication.getId());
} catch (Exception e) {
System.out.println("认证记录新增失败");
}
}
}
}
}
return AjaxResult.success(authentication);
}
} catch (TencentCloudSDKException e) {
throw new ServiceException("获取E证通Token状态失败");
return AjaxResult.error(e.getMessage());
}
return objJSON;
return AjaxResult.error("认证失败");
}
@@ -316,10 +316,14 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
vo.setAppOperatorFlag(0);
}
}
// 签收按钮权限
if(affiliate.getUserId().equals(loginUserId) &&vo.getCaseStatusName().contains("签收")){
vo.setSignFlag(1);
}
}
if (vo.getResOperatorFlag() == null && (affiliate.getRoleType() == 3 || affiliate.getRoleType() == 4)) {
// 申请人操作人
// 被申请人操作人
if(Objects.equals(affiliate.getUserId(), loginUserId) &&!vo.getCaseStatusName().equals("待签名")){
vo.setResOperatorFlag(1);
}else if(vo.getCaseStatusName().equals("待签名")) {
@@ -329,7 +333,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
vo.setResOperatorFlag(0);
}
}
// 签收按钮权限
if(affiliate.getUserId().equals(loginUserId) &&vo.getCaseStatusName().contains("签收")){
vo.setSignFlag(1);
}
}
}
if(affiliate.getOrganizeFlag()==null || affiliate.getOrganizeFlag()!=1) {
@@ -387,7 +394,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
){
vo.setOtherFlag(1);
}
if(role.getRoleName().equals("法律顾问")){
if(role.getRoleName().equals("法律顾问") && mediatorSort!=null && sendSort!=null
&& null!=flowNameMap.get(vo.getCaseStatusName())
&& flowNameMap.get(vo.getCaseStatusName())>mediatorSort
&& flowNameMap.get(vo.getCaseStatusName())<=sendSort){
// 顾问可以上传下载调解书
vo.setMediationFileFlag(1);
}
@@ -1363,7 +1373,9 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
}
if(StrUtil.isNotEmpty(applicant.getIdCard())){
setBirthByIdentityNum(applicant);
}
affiliateVO.setApplicant(applicantList);
// 如果身份证不为空,设置生日和性别
@@ -1727,6 +1739,9 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
@Override
@Transactional
public void sendEmail(MsCaseApplication application, MsCaseAffiliate affiliate, String subject, String sendContent) {
if(StrUtil.isEmpty(affiliate.getEmail())){
return;
}
boolean emailFlag = emailOutUtil.sendMessage(affiliate.getEmail(), subject, sendContent, null, null);
SendMailRecord sendMailRecord = new SendMailRecord();
@@ -1897,18 +1912,22 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
if (CollectionUtil.isNotEmpty(caseApplicationList)) {
caseMap = caseApplicationList.stream().collect(Collectors.groupingBy(MsCaseApplication::getMediatorId, Collectors.toList()));
}
if(caseAppliId!=null) {
// 查询该用户是否是操作人,是申请操作人还是被申请操作人
List<MsCaseAffiliate> affiliates = msCaseAffiliateMapper.selectByCaseId(caseAppliId);
if(CollectionUtil.isEmpty(affiliates)){
return AjaxResult.error("未找到案件相关人员");
}
List<Long> affiliateUserIds=new ArrayList<>();
// 根据案件id和用户id查询已选择的调解员进行回显
Example example = new Example(MsCaseMediator.class);
Example.Criteria criteria = example.createCriteria();
LoginUser loginUser = SecurityUtils.getLoginUser();
for (MsCaseAffiliate affiliate : affiliates) {
if(affiliate.getUserId()!=null && affiliate.getUserId().equals(loginUser.getUser().getUserId())){
if(affiliate.getUserId()==null ){
continue;
}
affiliateUserIds.add(affiliate.getUserId());
if(affiliate.getUserId().equals(loginUser.getUser().getUserId())){
if( affiliate.getRoleType()==null){
continue;
}
@@ -1917,7 +1936,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
criteria.andEqualTo("type", YesOrNoEnum.NO.getCode());
}
if(affiliate.getRoleType()==3|| affiliate.getRoleType()==4){
// 申请人
// 被申请人
criteria.andEqualTo("type", YesOrNoEnum.YES.getCode());
}
}
@@ -1926,9 +1945,12 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
// 已选择的调解员
List<MsCaseMediator> selectedMediators = msCaseMediatorMapper.selectByExample(example);
selectedMediatorIds = selectedMediators.stream().map(MsCaseMediator::getMediatorId).collect(Collectors.toList());
}
for (SysUser user : users) {
if(affiliateUserIds.contains(user.getUserId())){
continue;
}
MediatorVO mediatorVO = new MediatorVO();
mediatorVO.setMediatorId(user.getUserId());
mediatorVO.setMediatorName(user.getNickName());
@@ -2079,7 +2101,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
if (caseMap.containsKey(userId)) {
List<MsCaseApplication> applications = caseMap.get(userId);
// 已办案件
long count = applications.stream().filter(caseApplication -> !caseApplication.getCaseStatusName().equals("结束")).count();
long count = applications.stream().filter(caseApplication -> caseApplication.getCaseStatusName().equals("结束")).count();
if(count>=maxCount){
maxCount=count;
application.setMediatorId(userId);
@@ -2135,6 +2157,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
*/
@Transactional
public void verifyMediator(MsCaseApplication application,BookingVO vo) {
Long userId = SecurityUtils.getUserId();
final List<MsCaseAffiliate>[] affiliates = new List[]{new ArrayList<>()};
ExecutorService executor = ThreadUtil.createThreadPool();
CompletableFuture<MsCaseApplication> cf1 = CompletableFuture.supplyAsync(() -> {
MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(vo.getCaseFlowId());
if (currentFlow == null) {
throw new ServiceException("未找到当前流程节点");
@@ -2145,7 +2171,6 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
if(vo.getMediatorId()!=null) {
// setMediatorAndDate(application,vo);
application.setMediatorId(vo.getMediatorId());
application.setMediatorName(vo.getMediatorName());
}
@@ -2160,23 +2185,34 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
if (caseApplication == null) {
throw new ServiceException("未找到案件");
}
affiliates[0] = selectAffliatesByCaseId(caseApplication.getId());
if(CollectionUtil.isEmpty(affiliates[0])){
throw new ServiceException("未找到案件相关人员");
}
// 新增日志
CaseLogUtils.insertCaseLog(caseApplication.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "",userId);
caseApplication.setHearDate(application.getHearDate());
ExecutorService executor = ThreadUtil.createThreadPool();
CompletableFuture.runAsync(() -> {
return caseApplication;
});
if (CollectionUtil.isNotEmpty(vo.getHerDates())) {
cf1.thenAcceptAsync((result) -> {
// 申请人发送开庭日期短信
sendHearDateSms(result, affiliates[0]);
}, executor);
cf1.thenAcceptAsync((result) -> {
// 发送开庭短信
if (CollectionUtil.isNotEmpty(vo.getHerDates())) {
List<MsCaseAffiliate> affiliates = selectAffliatesByCaseId(caseApplication.getId());
// 申请人发送开庭日期短信
sendHearDateSms(caseApplication, affiliates);
// 调解员发送开庭短信
sendMeditorHearDateSms(caseApplication,vo);
sendMeditorHearDateSms(result, vo);
}
}, executor);
}
// 新增日志
CaseLogUtils.insertCaseLog(caseApplication.getId(), currentFlow.getNodeId(), currentFlow.getCaseStatusName(), "");
}
@@ -2241,9 +2277,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
List<String> resPhones=new ArrayList<>();
List<String> appEmails=new ArrayList<>();
List<String> resEmails=new ArrayList<>();
ExecutorService executor = ThreadUtil.createThreadPool();
for (MsCaseAffiliate affiliate : affiliates) {
CompletableFuture.runAsync(() -> {
// 申请人
if (affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(1) || affiliate.getRoleType().equals(2))) {
// 获取短信链接uuid
@@ -2256,13 +2293,12 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
SmsUtils.sendSms(application,"2130103", affiliate.getPhone(),
new String[]{application.getCaseNum(),application.getHearDate(),"authId="+roomUuid});
} else if(StrUtil.isNotEmpty(affiliate.getEmail())&&!appEmails.contains(affiliate.getEmail())) {
} else if(StrUtil.isEmpty(affiliate.getPhone()) && StrUtil.isNotEmpty(affiliate.getEmail())&&!appEmails.contains(affiliate.getEmail())) {
appEmails.add(affiliate.getEmail());
// 发送邮件
caseApplicationService.sendEmail(application, affiliate, "开庭日期通知", content);
}
continue;
}
// 被申请人
if (affiliate.getOperatorFlag() == 1 && (affiliate.getRoleType().equals(3) || affiliate.getRoleType().equals(4))) {
@@ -2276,14 +2312,14 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
SmsUtils.sendSms(application,"2130103", affiliate.getPhone(),
new String[]{application.getCaseNum(),application.getHearDate(),"authId="+roomUuid});
} else if(StrUtil.isNotEmpty(affiliate.getEmail())&&!resEmails.contains(affiliate.getEmail())){
} else if(StrUtil.isEmpty(affiliate.getPhone()) && StrUtil.isNotEmpty(affiliate.getEmail())&&!resEmails.contains(affiliate.getEmail())){
resEmails.add(affiliate.getEmail());
// 发送邮件
caseApplicationService.sendEmail(application, affiliate, "开庭日期通知", content);
}
}
}}, executor);
}
}else {
// 申请人/被申通知, 线下调解 2077966 尊敬的用户,您的{1}案件,线下调解日期已确定为{2},请知晓,如非本人操作,请忽略本短信。
@@ -2322,7 +2358,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
SmsUtils.sendSms(application, applicantNotice.getTemplateId(), affiliate.getPhone(),
applicantNotice.getTemplateParamSet());
} else if(StrUtil.isNotEmpty(affiliate.getEmail())&&!appEmails.contains(affiliate.getEmail())) {
} else if(StrUtil.isEmpty(affiliate.getPhone()) && StrUtil.isNotEmpty(affiliate.getEmail())&&!appEmails.contains(affiliate.getEmail())) {
appEmails.add(affiliate.getEmail());
// 发送邮件
caseApplicationService.sendEmail(application, affiliate, applicantNotice.getSubject(), applicantNotice.getContent());
@@ -2340,7 +2376,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
SmsUtils.sendSms(application, resNotice.getTemplateId(), affiliate.getPhone(),
resNotice.getTemplateParamSet());
} else if(StrUtil.isNotEmpty(affiliate.getEmail())&&!resEmails.contains(affiliate.getEmail())){
} else if(StrUtil.isEmpty(affiliate.getPhone()) && StrUtil.isNotEmpty(affiliate.getEmail())&&!resEmails.contains(affiliate.getEmail())){
resEmails.add(affiliate.getEmail());
// 发送邮件
caseApplicationService.sendEmail(application, affiliate, resNotice.getSubject(), resNotice.getContent());
@@ -2485,9 +2521,11 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
return AjaxResult.error("未找到案件");
}
req.setSealFlag(application.getSealFlag());
if (StrUtil.isEmpty(application.getMediationMethod())) {
return AjaxResult.error("未选择调解方式");
}
// 查询当前流程节点
MsCaseFlow currentFlow = caseFlowMapper.selectByPrimaryKey(req.getCaseFlowId());
if (currentFlow == null) {
@@ -2505,12 +2543,12 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
if (!applicantAffiliateOpt.isPresent() || !resAffiliateOpt.isPresent()) {
throw new ServiceException("未找到案件操作人员");
}
// 调解结果
Integer mediaResult = req.getMediaResult();
if (application.getMediationMethod().equals("1")) {
Integer mediaResult = application.getMediaResult();
if (mediaResult == null) {
return AjaxResult.error("请选择调解结果");
}
if (application.getMediationMethod().equals("1")) {
// 线上调解
List<MsCaseAttach> attachList = req.getAttachList();
if (CollectionUtil.isNotEmpty(attachList)) {
@@ -3037,6 +3075,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
}
}
} else {
Integer mediaResult=req.getMediaResult();
if(mediaResult==null){
return AjaxResult.error("请选择调解结果");
}
// 线下调解
List<MsCaseAttach> attachList = req.getAttachList();
if (CollectionUtil.isEmpty(attachList)) {
@@ -3168,6 +3210,7 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
AjaxResult result = caseApplicationService.generateApplication(req);
// 修改案件结果
application.setMediaResult(req.getMediaResult());
application.setSealFlag(req.getSealFlag());
msCaseApplicationMapper.updateByPrimaryKeySelective(application);
return AjaxResult.success();
}
@@ -3501,10 +3544,10 @@ public class MsCaseApplicationServiceImpl implements MsCaseApplicationService {
caseAttach.setOtherSysFileId(caseFileInfo.getFileId());
}
}
}
caseAttach.setSuffix(getFileExtension(caseAttach.getAnnexPath()));
msCaseAttachMapper.save(caseAttach);
}
}
@@ -30,8 +30,12 @@ public class CaseLogUtils
*/
public static void insertCaseLog(@NotNull Long caseAppliId, @NotEmpty Integer caseNode,String caseStatusName, String notes ){
MsCaseLogRecord operLog = new MsCaseLogRecord();
// 获取当前的用户
LoginUser loginUser = SecurityUtils.getLoginUser();
LoginUser loginUser=null;
try {
loginUser = SecurityUtils.getLoginUser();
} catch (Exception e) {
loginUser=null;
}
if(loginUser!=null) {
SysUser sysUser = userMapper.selectUserById(loginUser.getUserId());
operLog.setCreateBy(sysUser.getUserName());
@@ -49,4 +53,24 @@ public class CaseLogUtils
operLog.setCreateTime(new Date());
caseLogRecordMapper.insert(operLog);
}
/**
* 新增案件日志
* @param caseAppliId 案件id,不能为空
* @param caseNode 案件节点,不能为空
* @param notes 备注
*/
public static void insertCaseLog(@NotNull Long caseAppliId, @NotEmpty Integer caseNode,String caseStatusName, String notes,Long userId ){
if(userId==null)
return;
MsCaseLogRecord operLog = new MsCaseLogRecord();
SysUser sysUser = userMapper.selectUserById(userId);
operLog.setCreateBy(sysUser.getUserName());
operLog.setCreateNickName(sysUser.getNickName());
operLog.setCaseStatusName(caseStatusName);
operLog.setCaseAppliId(caseAppliId);
operLog.setCaseNode(caseNode);
operLog.setNotes(notes);
operLog.setCreateTime(new Date());
caseLogRecordMapper.insert(operLog);
}
}