日志注解简单开发 #53

Merged
wangqiong123 merged 1 commits from wq into dev 2023-10-10 14:42:12 +00:00
6 changed files with 213 additions and 12 deletions
@@ -2,6 +2,7 @@ package com.ruoyi.web.controller.wisdomarbitrate;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.annotation.Anonymous; import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.annotation.CaseLog;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
@@ -0,0 +1,34 @@
package com.ruoyi.common.annotation;
import java.lang.annotation.*;
/**
* 案件操作日志记录注解
*
* @author wangqiong
*
*/
@Target({ ElementType.PARAMETER, ElementType.METHOD })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface CaseLog
{
/**
* 案件申请人id
*/
public long caseAppliId() default 0L;
/**
* 案件节点
*/
public String caseNode() default "";
/**
* 备注
*/
public String notes() default "";
}
@@ -0,0 +1,87 @@
package com.ruoyi.framework.aspectj;
import com.ruoyi.common.annotation.CaseLog;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.wisdomarbitrate.domain.CaseLogRecord;
import com.ruoyi.wisdomarbitrate.mapper.CaseLogRecordMapper;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
* 案件操作日志记录处理
*
* @author wangqiong
*/
@Aspect
@Component
public class CaseLogAspect {
@Autowired
private CaseLogRecordMapper logRecordMapper;
private static final Logger log = LoggerFactory.getLogger(CaseLogAspect.class);
/**
* 处理请求前执行
*/
@Before(value = "@annotation(controllerLog)")
public void boBefore(JoinPoint joinPoint, CaseLog controllerLog) {
}
/**
* 处理完请求后执行
*
* @param joinPoint 切点
*/
@AfterReturning(pointcut = "@annotation(controllerLog)", returning = "jsonResult")
public void doAfterReturning(JoinPoint joinPoint, CaseLog controllerLog, Object jsonResult) {
handleLog(joinPoint, controllerLog, null, jsonResult);
}
protected void handleLog(final JoinPoint joinPoint, CaseLog controllerLog, final Exception e, Object jsonResult) {
try {
// 获取当前的用户
LoginUser loginUser = SecurityUtils.getLoginUser();
String nickName = loginUser.getUser().getNickName();
// *========数据库日志=========*//
CaseLogRecord operLog = new CaseLogRecord();
operLog.setCreateBy(nickName);
operLog.setUpdateBy(nickName);
// 处理设置注解上的参数
getControllerMethodDescription(joinPoint, controllerLog, operLog, jsonResult);
// 保存数据库
logRecordMapper.insertCaseLogRecord(operLog);
} catch (Exception exp) {
// 记录本地异常日志
log.error("异常信息:{}", exp.getMessage());
exp.printStackTrace();
}
}
/**
* 获取注解中对方法的描述信息 用于Controller层注解
*
* @param log 日志
* @param operLog 操作日志
* @throws Exception
*/
public void getControllerMethodDescription(JoinPoint joinPoint, CaseLog log, CaseLogRecord operLog, Object jsonResult) throws Exception {
// 设置案件id
operLog.setCaseAppliId(log.caseAppliId());
// 设置案件节点
operLog.setNotes(log.caseNode());
// 设置备注
operLog.setNotes(log.notes());
}
}
@@ -3,6 +3,7 @@ package com.ruoyi.wisdomarbitrate.service.impl;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.ruoyi.common.annotation.CaseLog;
import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.CaseApplicationConstants; import com.ruoyi.common.constant.CaseApplicationConstants;
import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysDept;
@@ -113,9 +114,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseAttach.setCaseAppliId(caseApplication.getId()); caseAttach.setCaseAppliId(caseApplication.getId());
caseAttachMapper.updateCaseAttach(caseAttach); caseAttachMapper.updateCaseAttach(caseAttach);
} }
} }
return rows; return rows;
} }
@@ -156,10 +155,38 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
int rows = caseApplicationMapper.updataCaseApplication(caseApplication); int rows = caseApplicationMapper.updataCaseApplication(caseApplication);
List<CaseAffiliate> caseAffiliates = caseApplication.getCaseAffiliates(); List<CaseAffiliate> caseAffiliates = caseApplication.getCaseAffiliates();
if(caseAffiliates!=null&&caseAffiliates.size()>0){ if(caseAffiliates!=null&&caseAffiliates.size()>0){
// 查询所有的组织机构,组装成map
List<SysDept> deptList = sysDeptMapper.selectDeptList(new SysDept());
if (CollectionUtil.isEmpty(deptList)) {
deptList = new ArrayList<>();
}
Map<String, Long> deptMap = deptList.stream().collect(Collectors.toMap(SysDept::getDeptName, SysDept::getDeptId,(oldV,newV)->newV));
for (CaseAffiliate caseAffiliate : caseAffiliates){ for (CaseAffiliate caseAffiliate : caseAffiliates){
caseAffiliate.setCaseAppliId(caseApplication.getId()); caseAffiliate.setCaseAppliId(caseApplication.getId());
if(caseAffiliate.getIdentityType()==1&&StrUtil.isNotEmpty(caseAffiliate.getName())) {
// 将组织机构id设为申请人名称
if (deptMap.containsKey(caseApplication.getName())) {
caseAffiliate.setName(String.valueOf(deptMap.get(caseAffiliate.getName())));
} else {
// 如果不存在则新增
SysDept dept = new SysDept();
dept.setParentId(0L);
dept.setDeptName(caseAffiliate.getName());
dept.setAncestors("0");
dept.setOrderNum(1);
dept.setStatus("0");
dept.setDelFlag("0");
dept.setCreateBy(getUsername());
dept.setUpdateBy(getUsername());
sysDeptMapper.insertDept(dept);
deptMap.put(dept.getDeptName(), dept.getDeptId());
caseAffiliate.setName(String.valueOf(dept.getDeptId()));
}
}
caseAffiliateMapper.updataCaseAffiliate(caseAffiliate); caseAffiliateMapper.updataCaseAffiliate(caseAffiliate);
} }
} }
List<CaseAttach> caseAttachList = caseApplication.getCaseAttachList(); List<CaseAttach> caseAttachList = caseApplication.getCaseAttachList();
if(caseAttachList!=null&&caseAttachList.size()>0){ if(caseAttachList!=null&&caseAttachList.size()>0){
@@ -458,11 +485,22 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseAffiliate.setCaseAppliId(caseApplication.getId()); caseAffiliate.setCaseAppliId(caseApplication.getId());
List<CaseAffiliate> caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); List<CaseAffiliate> caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
if(caseAffiliatListeselect!=null){ if(caseAffiliatListeselect!=null){
// 查询组织机构
List<SysDept> sysDepts = sysDeptMapper.selectDeptList(new SysDept());
Map<String,String> deptMap=new HashMap<>();
if(CollectionUtil.isNotEmpty(sysDepts)){
for (SysDept sysDept : sysDepts) {
deptMap.put(String.valueOf(sysDept.getDeptId()),sysDept.getDeptName());
}
}
StringBuffer applicantName = new StringBuffer(); StringBuffer applicantName = new StringBuffer();
for (int i = 0; i < caseAffiliatListeselect.size(); i++){ for (int i = 0; i < caseAffiliatListeselect.size(); i++){
CaseAffiliate caseAffiliateselect = caseAffiliatListeselect.get(i); CaseAffiliate caseAffiliateselect = caseAffiliatListeselect.get(i);
int identityType = caseAffiliateselect.getIdentityType(); int identityType = caseAffiliateselect.getIdentityType();
if(identityType==1){ if(identityType==1){
if(StrUtil.isNotEmpty(caseAffiliateselect.getName())&&deptMap.containsKey(caseAffiliateselect.getName())){
caseAffiliateselect.setName(deptMap.get(caseAffiliateselect.getName()));
}
applicantName.append(caseAffiliateselect.getName()).append(",");; applicantName.append(caseAffiliateselect.getName()).append(",");;
} }
} }
@@ -543,9 +581,23 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseAffiliate.setCaseAppliId(caseApplication.getId()); caseAffiliate.setCaseAppliId(caseApplication.getId());
List<CaseAffiliate> caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); List<CaseAffiliate> caseAffiliatListeselect = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
if(caseAffiliatListeselect!=null) { if(caseAffiliatListeselect!=null) {
// 查询组织机构
List<SysDept> sysDepts = sysDeptMapper.selectDeptList(new SysDept());
Map<String,String> deptMap=new HashMap<>();
if(CollectionUtil.isNotEmpty(sysDepts)){
for (SysDept sysDept : sysDepts) {
deptMap.put(String.valueOf(sysDept.getDeptId()),sysDept.getDeptName());
}
}
for (int j = 0; j < caseAffiliatListeselect.size(); j++) { for (int j = 0; j < caseAffiliatListeselect.size(); j++) {
CaseAffiliate caseAffiliateselect = caseAffiliatListeselect.get(j); CaseAffiliate caseAffiliateselect = caseAffiliatListeselect.get(j);
int identityType = caseAffiliateselect.getIdentityType(); int identityType = caseAffiliateselect.getIdentityType();
if(identityType==1){
if(StrUtil.isNotEmpty(caseAffiliateselect.getName())&&deptMap.containsKey(caseAffiliateselect.getName())){
caseAffiliateselect.setName(deptMap.get(caseAffiliateselect.getName()));
}
caseAffiliateselect.setName(caseAffiliateselect.getName());;
}
//给申请人、被申请人发送短信通知 //给申请人、被申请人发送短信通知
request.setPhone(caseAffiliateselect.getContactTelphone()); request.setPhone(caseAffiliateselect.getContactTelphone());
// 1947342 普通短信 开庭日期通知 尊敬的{1}用户,您的{2}仲裁案件,开庭日期已确定为{3},请知晓,如非本人操作,请忽略本短信。 // 1947342 普通短信 开庭日期通知 尊敬的{1}用户,您的{2}仲裁案件,开庭日期已确定为{3},请知晓,如非本人操作,请忽略本短信。
@@ -34,21 +34,50 @@ public class CaseLogRecordServiceImpl implements ICaseLogRecordService {
contentBuilder.append("提交立案申请"); contentBuilder.append("提交立案申请");
break; break;
case 2: case 2:
contentBuilder.append("提交立案审查"); contentBuilder.append("同意立案申请");
break; break;
case 3: case 3:
contentBuilder.append("创建立案申请"); contentBuilder.append("缴费成功");
break; break;
case 4: case 4:
contentBuilder.append("缴费成功"); contentBuilder.append("已确认缴费");
case 5: case 5:
contentBuilder.append("缴费成功"); contentBuilder.append("进行案件质证");
case 6: case 6:
contentBuilder.append("缴费成功"); contentBuilder.append("同意组庭审核");
case 7: case 7:
contentBuilder.append("缴费成功"); contentBuilder.append("组庭确认成功");
case 8: case 8:
contentBuilder.append("缴费成功"); contentBuilder.append("同意待开庭审理");
case 9:
contentBuilder.append("同意书面审理");
break;
case 10:
contentBuilder.append("已完成书面审理");
break;
case 11:
contentBuilder.append("已生成仲裁文书");
break;
case 12:
contentBuilder.append("已核查仲裁文书");
break;
case 13:
contentBuilder.append("已同意仲裁文书");
break;
case 14:
contentBuilder.append("已完成仲裁文书签名");
break;
case 15:
contentBuilder.append("已完成仲裁文书用印");
break;
case 16:
contentBuilder.append("已送达仲裁文书");
break;
case 17:
contentBuilder.append("已完成案件归档");
break;
case 26:
contentBuilder.append("已完成证据确认");
break; break;
} }
@@ -238,10 +238,8 @@
p.payment_status , p.payment_status ,
CASE p.payment_status when 1 then '已支付' when 0 then '未支付' CASE p.payment_status when 1 then '已支付' when 0 then '未支付'
ELSE '无支付状态' ELSE '无支付状态'
END paymentStatusName,d.dept_name as applicantName END paymentStatusName
from case_application c left join case_payment_record p on c.id = p.case_id from case_application c left join case_payment_record p on c.id = p.case_id
LEFT JOIN case_affiliate ca ON ca.case_appli_id = c.id and ca.identity_type=1
LEFT JOIN sys_dept d ON ca.NAME = d.dept_id and ca.name=d.dept_id
where c.case_status = 3 and p.payment_status = 1 where c.case_status = 3 and p.payment_status = 1
AND c.id = #{id} AND c.id = #{id}