Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
yang_shj 2 years ago
parent
commit
1d4de0107b
  1. 57
      hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/aop/SysLogAspect.java
  2. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java
  3. 28
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java

57
hzims-biz-common/src/main/java/com/hnac/hzims/common/logs/aop/SysLogAspect.java

@ -18,6 +18,7 @@ import org.springblade.core.tool.constant.BladeConstant;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.WebUtil; import org.springblade.core.tool.utils.WebUtil;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.NamedThreadLocal;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.StopWatch; import org.springframework.util.StopWatch;
import org.springframework.web.context.request.RequestAttributes; import org.springframework.web.context.request.RequestAttributes;
@ -52,26 +53,10 @@ public class SysLogAspect {
@Autowired @Autowired
private SysLogQueue sysLogQueue; private SysLogQueue sysLogQueue;
/**
* 请求地址
*/
private String requestPath = null;
/**
* 操作人
*/
private String userName = null;
/**
* 请求
*/
private HttpServletRequest request = null;
//private StopWatch stopWatch = new StopWatch();
private Long userId = -1L; private static final ThreadLocal<Long> TIME_THREADLOCAL = new NamedThreadLocal<>("Cost Time");
private StopWatch stopWatch = new StopWatch();
/** /**
@ -87,7 +72,11 @@ public class SysLogAspect {
*/ */
@Before(value = "logPointCut()") @Before(value = "logPointCut()")
public void before(JoinPoint joinPoint) { public void before(JoinPoint joinPoint) {
stopWatch.start(); // if (!stopWatch.isRunning()) {
// stopWatch.start();
// }
//startTime = System.currentTimeMillis();
TIME_THREADLOCAL.set(System.currentTimeMillis());
log.info("前置通知"); log.info("前置通知");
} }
@ -98,8 +87,14 @@ public class SysLogAspect {
@AfterReturning(value = "logPointCut()", returning = "jsonResult") @AfterReturning(value = "logPointCut()", returning = "jsonResult")
public void after(JoinPoint joinPoint, Object jsonResult) { public void after(JoinPoint joinPoint, Object jsonResult) {
log.info("=========返回通知=============="); log.info("=========返回通知==============");
request = getHttpServletRequest(); try {
handleLog(joinPoint, jsonResult, null); handleLog(joinPoint, jsonResult, null);
} catch (Exception e) {
log.error("异常信息:{}", e.getMessage());
e.printStackTrace();
} finally {
TIME_THREADLOCAL.remove();
}
} }
@ -139,7 +134,14 @@ public class SysLogAspect {
@AfterThrowing(pointcut = "logPointCut()", throwing = "e") @AfterThrowing(pointcut = "logPointCut()", throwing = "e")
public void throwing(JoinPoint joinPoint, Exception e) { public void throwing(JoinPoint joinPoint, Exception e) {
log.info("=========异常通知=============="); log.info("=========异常通知==============");
try {
handleLog(joinPoint, null, e); handleLog(joinPoint, null, e);
} catch (Exception exception) {
log.error("异常信息:{}", exception.getMessage());
e.printStackTrace();
} finally {
TIME_THREADLOCAL.remove();
}
} }
@ -204,8 +206,8 @@ public class SysLogAspect {
// 获取请求的类名 // 获取请求的类名
String className = joinPoint.getTarget().getClass().getName(); String className = joinPoint.getTarget().getClass().getName();
methodName = className + "." + methodName; methodName = className + "." + methodName;
request = getHttpServletRequest(); HttpServletRequest request = getHttpServletRequest();
requestPath = request.getServletPath(); String requestPath = request.getServletPath();
OperationAnnotation annotation = method.getAnnotation(OperationAnnotation.class); OperationAnnotation annotation = method.getAnnotation(OperationAnnotation.class);
title = annotation.title(); title = annotation.title();
action = annotation.action(); action = annotation.action();
@ -213,8 +215,8 @@ public class SysLogAspect {
operatorType = annotation.operatorType().getValue(); operatorType = annotation.operatorType().getValue();
moduleName = annotation.moduleName(); moduleName = annotation.moduleName();
// 获取当前用户信息 // 获取当前用户信息
userName = AuthUtil.getUserAccount(request); String userName = AuthUtil.getUserAccount(request);
userId = AuthUtil.getUserId(request); Long userId = AuthUtil.getUserId(request);
SysLogTo sysLog = new SysLogTo(); SysLogTo sysLog = new SysLogTo();
if (StringUtils.isBlank(userName) && userId == -1) { if (StringUtils.isBlank(userName) && userId == -1) {
userName = "当前用户未登录"; userName = "当前用户未登录";
@ -224,8 +226,11 @@ public class SysLogAspect {
sysLog.setOperationUserId(userId); sysLog.setOperationUserId(userId);
sysLog.setTenantId(Func.toStr(AuthUtil.getTenantId(), BladeConstant.ADMIN_TENANT_ID)); sysLog.setTenantId(Func.toStr(AuthUtil.getTenantId(), BladeConstant.ADMIN_TENANT_ID));
sysLog.setLocalIp(WebUtil.getIP(request));// 请求IP sysLog.setLocalIp(WebUtil.getIP(request));// 请求IP
stopWatch.stop(); // if (stopWatch.isRunning()) {
sysLog.setCostTime(stopWatch.getTotalTimeMillis() + "ms"); // stopWatch.stop();
// }
long endTime = System.currentTimeMillis();
sysLog.setCostTime((endTime - TIME_THREADLOCAL.get()) + "ms");
sysLog.setPath(requestPath); sysLog.setPath(requestPath);
sysLog.setTitle(title); sysLog.setTitle(title);
sysLog.setAction(action); sysLog.setAction(action);

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/main/controller/web/AreaMonthlyDetailsController.java

@ -207,7 +207,7 @@ public class AreaMonthlyDetailsController {
@ApiParam(name = "size", value = "每页记录数", required = true) @PathVariable("size") Long size, @ApiParam(name = "size", value = "每页记录数", required = true) @PathVariable("size") Long size,
OperPhenomenonEntity entity, String taskIds, Date findTimeEnd) { OperPhenomenonEntity entity, String taskIds, Date findTimeEnd) {
Page<OperPhenomenonEntity> operDefectEntityPage = new Page<>(page, size); Page<OperPhenomenonEntity> operDefectEntityPage = new Page<>(page, size);
LambdaQueryWrapper<OperPhenomenonEntity> queryWrapper = Condition.getQueryWrapper(new OperPhenomenonEntity(), entity); LambdaQueryWrapper<OperPhenomenonEntity> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtil.isNotBlank(taskIds)) { if (StringUtil.isNotBlank(taskIds)) {
queryWrapper.in(OperPhenomenonEntity::getId, Lists.newArrayList(taskIds.split(","))); queryWrapper.in(OperPhenomenonEntity::getId, Lists.newArrayList(taskIds.split(",")));
} }
@ -222,7 +222,7 @@ public class AreaMonthlyDetailsController {
} }
// 区域Id // 区域Id
if (Func.isNotEmpty(entity.getAreaId())) { if (Func.isNotEmpty(entity.getAreaId())) {
queryWrapper.eq(OperPhenomenonEntity::getCreateDept, entity.getAreaId()); queryWrapper.eq(OperPhenomenonEntity::getCreateDept, Long.valueOf(entity.getAreaId()));
} }
// 年份 // 年份
if (Func.isNotEmpty(entity.getYearMonth())) { if (Func.isNotEmpty(entity.getYearMonth())) {

28
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/strategy/core/ProcessIdWorker.java

@ -184,32 +184,4 @@ public class ProcessIdWorker {
private AtomicInteger sequencing = new AtomicInteger(1); private AtomicInteger sequencing = new AtomicInteger(1);
} }
public static void main(String[] args) {
// TicketIdWorker standardTicketIdWorker = new TicketIdWorker();
// int count = 1;
// while (count <= 1000) {
//
// System.out.println("1 ===> " + standardTicketIdWorker.getTicketCode("aa", "bb", "2304"));
// System.out.println("=================================");
// //System.out.println("2 ===》" + standardTicketIdWorker.getTicketCode("aa", "bb", "2204"));
// count++;
//
// }
// NumberFormat numberFormatter = NumberFormat.getInstance();
// numberFormatter.setGroupingUsed(false);
// numberFormatter.setMinimumIntegerDigits(3);
// numberFormatter.setMaximumFractionDigits(3);
//
// String format = numberFormatter.format(2);
// System.out.println(format);
String msg = "2021";
String substring = msg.substring(msg.length() - 2);
System.out.println(substring);
}
} }

Loading…
Cancel
Save