Commit 328358c7 authored by 温志超's avatar 温志超

Merge remote-tracking branch 'origin/master'

parents 2b956ed8 61f71cf7
...@@ -15,7 +15,7 @@ import javax.servlet.http.HttpServletResponse; ...@@ -15,7 +15,7 @@ import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
/** /**
* 操作日志记录 * 接口日志记录
* *
*/ */
@RestController @RestController
...@@ -50,4 +50,12 @@ public class SysApiLogController extends BaseController ...@@ -50,4 +50,12 @@ public class SysApiLogController extends BaseController
operLogService.cleanApiLog(); operLogService.cleanApiLog();
return AjaxResult.success(); return AjaxResult.success();
} }
@Log(title = "再次执行", businessType = BusinessType.OTHER)
@PreAuthorize("@ss.hasPermi('monitor:apilog:remove')")
@PostMapping("/execute")
public AjaxResult execute(Long[] logIds) throws Exception {
operLogService.executeByIds(logIds);
return AjaxResult.success();
}
} }
package com.ximai.mes.config; package com.ximai.mes.config;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.text.StrJoiner;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.google.common.base.Joiner;
import com.ximai.common.annotation.ApiLog; import com.ximai.common.annotation.ApiLog;
import com.ximai.common.annotation.Log; import com.ximai.common.annotation.Log;
import com.ximai.common.enums.BusinessStatus; import com.ximai.common.enums.BusinessStatus;
...@@ -165,26 +168,31 @@ public class ApiLogAspect { ...@@ -165,26 +168,31 @@ public class ApiLogAspect {
* @param operLog 操作日志 * @param operLog 操作日志
* @throws Exception 异常 * @throws Exception 异常
*/ */
private void setRequestValue(JoinPoint joinPoint, SysApiLog operLog) throws Exception { private void setRequestValue(JoinPoint joinPoint, SysApiLog operLog) {
String params = argsArrayToString(joinPoint.getArgs()); argsArrayToString(operLog, joinPoint.getArgs());
operLog.setOperParam(params);
} }
/** /**
* 参数拼装 * 参数拼装
*/ */
private String argsArrayToString(Object[] paramsArray) { private String argsArrayToString(SysApiLog operLog, Object[] paramsArray) {
String params = ""; String params = "";
if (paramsArray != null && paramsArray.length > 0) { if (paramsArray != null && paramsArray.length > 0) {
int i=1;
StrJoiner joiner = StrJoiner.of(",");
for (Object o : paramsArray) { for (Object o : paramsArray) {
joiner.append(o.getClass().getName());
if (StringUtils.isNotNull(o) && !isFilterObject(o)) { if (StringUtils.isNotNull(o) && !isFilterObject(o)) {
try { try {
Object jsonObj = JSON.toJSON(o); Object jsonObj = JSON.toJSON(o);
params += jsonObj.toString() + " "; BeanUtil.setFieldValue(operLog,"operParam"+i, jsonObj);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace();
} }
} }
i++;
} }
operLog.setParamType(joiner.toString());
} }
return params.trim(); return params.trim();
} }
......
...@@ -101,10 +101,7 @@ public class KanbanAbnormalService { ...@@ -101,10 +101,7 @@ public class KanbanAbnormalService {
int expireCt = abnormalList.stream().filter(s->{ int expireCt = abnormalList.stream().filter(s->{
if(s.getAbnormalStatus().equals(QcAbnormalReportStatusEnum.NOT.getStatus()) if(s.getAbnormalStatus().equals(QcAbnormalReportStatusEnum.NOT.getStatus())
||s.getAbnormalStatus().equals(QcAbnormalReportStatusEnum.SUBMIT.getStatus())){ ||s.getAbnormalStatus().equals(QcAbnormalReportStatusEnum.SUBMIT.getStatus())){
Calendar createTemp = Calendar.getInstance(); if(s.getCreateTime().compareTo(curr.getTime())<0){
createTemp.setTime(s.getCreateTime());
createTemp.add(Calendar.DATE, 1);
if(createTemp.getTime().compareTo(curr.getTime())<0){
return true; return true;
} }
} }
...@@ -116,4 +113,8 @@ public class KanbanAbnormalService { ...@@ -116,4 +113,8 @@ public class KanbanAbnormalService {
return abnormal1; return abnormal1;
} }
public static void main(String[] args) {
Calendar curr = Calendar.getInstance();
System.out.println(DateUtil.format(Calendar.getInstance().getTime(), "yyyy-MM-dd HH:mm"));
}
} }
...@@ -117,7 +117,7 @@ public class KanbanTaskService { ...@@ -117,7 +117,7 @@ public class KanbanTaskService {
.add(feedbackDto.getQuantityQualify().add(feedbackDto.getQuantityUnqualify()))); .add(feedbackDto.getQuantityQualify().add(feedbackDto.getQuantityUnqualify())));
} }
} }
if(s.getActualEndDate()!=null&&s.getActualEndDate().compareTo(s.getScheduleEndDate())>0){ if(s.getActualEndDate()!=null&&s.getActualEndDate().compareTo(s.getScheduleEndDate())<0){
endOnTimeRatioNumerator.set(endOnTimeRatioNumerator.get().add(BigDecimal.ONE)); endOnTimeRatioNumerator.set(endOnTimeRatioNumerator.get().add(BigDecimal.ONE));
} }
if(s.getScheduleEndDate().compareTo(curr.getTime())<0){ if(s.getScheduleEndDate().compareTo(curr.getTime())<0){
......
package com.ximai.system.domain; package com.ximai.system.domain;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.ximai.common.annotation.Excel; import com.ximai.common.annotation.Excel;
import com.ximai.common.annotation.Excel.ColumnType; import com.ximai.common.annotation.Excel.ColumnType;
import com.ximai.common.core.domain.BaseEntity; import com.ximai.common.core.domain.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import com.ximai.common.exception.ServiceException;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
/** /**
* 操作日志记录表 oper_log * 操作日志记录表 oper_log
*/ */
@Data
public class SysApiLog extends BaseEntity { public class SysApiLog extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
...@@ -84,11 +93,22 @@ public class SysApiLog extends BaseEntity { ...@@ -84,11 +93,22 @@ public class SysApiLog extends BaseEntity {
@Excel(name = "操作地点") @Excel(name = "操作地点")
private String operLocation; private String operLocation;
@ApiModelProperty(value = "方法参数1")
private String operParam1;
@ApiModelProperty(value = "方法参数2")
private String operParam2;
@ApiModelProperty(value = "方法参数3")
private String operParam3;
@ApiModelProperty(value = "方法参数4")
private String operParam4;
@ApiModelProperty(value = "方法参数5")
private String operParam5;
/** /**
* 请求参数 * 请求参数
*/ */
@Excel(name = "请求参数") @ApiModelProperty(value = "参数类型")
private String operParam; private String paramType;
/** /**
* 返回参数 * 返回参数
...@@ -115,139 +135,35 @@ public class SysApiLog extends BaseEntity { ...@@ -115,139 +135,35 @@ public class SysApiLog extends BaseEntity {
@Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") @Excel(name = "操作时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
private Date operTime; private Date operTime;
public Long getOperId() { public Object[] parseParamObject() throws ClassNotFoundException {
return operId; List<String> params = new ArrayList<String>();
} if(StringUtils.isNotEmpty(this.getOperParam1())){
params.add(this.getOperParam1());
public void setOperId(Long operId) { }
this.operId = operId; if(StringUtils.isNotEmpty(this.getOperParam2())){
} params.add(this.getOperParam2());
}
public String getTitle() { if(StringUtils.isNotEmpty(this.getOperParam3())){
return title; params.add(this.getOperParam3());
} }
if(StringUtils.isNotEmpty(this.getOperParam4())){
public void setTitle(String title) { params.add(this.getOperParam4());
this.title = title; }
} if(StringUtils.isNotEmpty(this.getOperParam5())){
params.add(this.getOperParam5());
public Integer getBusinessType() { }
return businessType; String[] paramTypeArr = this.getParamType().split(",");
} List<Object> paramsObj = new ArrayList<>();
int i=0;
public void setBusinessType(Integer businessType) { if(paramTypeArr.length!=params.size()){
this.businessType = businessType; throw new ServiceException("参数不致,检查方法是否发生变化");
} }
for (String param : params) {
public Integer[] getBusinessTypes() { Class clz = Class.forName(paramTypeArr[i]);
return businessTypes; Object obj1 = JSONUtil.toBean(param, clz);
} paramsObj.add(obj1);
i++;
public void setBusinessTypes(Integer[] businessTypes) { }
this.businessTypes = businessTypes; return paramsObj.toArray();
}
public String getMethod() {
return method;
}
public void setMethod(String method) {
this.method = method;
}
public String getRequestMethod() {
return requestMethod;
}
public void setRequestMethod(String requestMethod) {
this.requestMethod = requestMethod;
}
public Integer getOperatorType() {
return operatorType;
}
public void setOperatorType(Integer operatorType) {
this.operatorType = operatorType;
}
public String getOperName() {
return operName;
}
public void setOperName(String operName) {
this.operName = operName;
}
public String getDeptName() {
return deptName;
}
public void setDeptName(String deptName) {
this.deptName = deptName;
}
public String getOperUrl() {
return operUrl;
}
public void setOperUrl(String operUrl) {
this.operUrl = operUrl;
}
public String getOperIp() {
return operIp;
}
public void setOperIp(String operIp) {
this.operIp = operIp;
}
public String getOperLocation() {
return operLocation;
}
public void setOperLocation(String operLocation) {
this.operLocation = operLocation;
}
public String getOperParam() {
return operParam;
}
public void setOperParam(String operParam) {
this.operParam = operParam;
}
public String getJsonResult() {
return jsonResult;
}
public void setJsonResult(String jsonResult) {
this.jsonResult = jsonResult;
}
public Integer getStatus() {
return status;
}
public void setStatus(Integer status) {
this.status = status;
}
public String getErrorMsg() {
return errorMsg;
}
public void setErrorMsg(String errorMsg) {
this.errorMsg = errorMsg;
}
public Date getOperTime() {
return operTime;
}
public void setOperTime(Date operTime) {
this.operTime = operTime;
} }
} }
...@@ -43,4 +43,11 @@ public interface ISysApiLogService { ...@@ -43,4 +43,11 @@ public interface ISysApiLogService {
* 清空操作日志 * 清空操作日志
*/ */
void cleanApiLog(); void cleanApiLog();
/**
* 执行日志记录相关操作
* @param logIds
* @throws Exception
*/
void executeByIds(Long[] logIds) throws Exception;
} }
...@@ -3,18 +3,24 @@ package com.ximai.system.service.impl; ...@@ -3,18 +3,24 @@ package com.ximai.system.service.impl;
import com.ximai.system.domain.SysApiLog; import com.ximai.system.domain.SysApiLog;
import com.ximai.system.mapper.SysApiLogMapper; import com.ximai.system.mapper.SysApiLogMapper;
import com.ximai.system.service.ISysApiLogService; import com.ximai.system.service.ISysApiLogService;
import org.apache.commons.beanutils.MethodUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.lang.reflect.InvocationTargetException;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
* 操作日志 服务层处理 * 接口日志 服务层处理
*/ */
@Service @Service
public class SysApiLogServiceImpl implements ISysApiLogService { public class SysApiLogServiceImpl implements ISysApiLogService {
@Autowired @Autowired
private SysApiLogMapper operApiMapper; private SysApiLogMapper operApiMapper;
@Autowired
private ApplicationContext applicationContext;
/** /**
* 新增操作日志 * 新增操作日志
...@@ -23,6 +29,7 @@ public class SysApiLogServiceImpl implements ISysApiLogService { ...@@ -23,6 +29,7 @@ public class SysApiLogServiceImpl implements ISysApiLogService {
*/ */
@Override @Override
public void insertApiLog(SysApiLog operLog) { public void insertApiLog(SysApiLog operLog) {
operLog.setCreateTime(new Date());
operApiMapper.insertApiLog(operLog); operApiMapper.insertApiLog(operLog);
} }
...@@ -66,4 +73,19 @@ public class SysApiLogServiceImpl implements ISysApiLogService { ...@@ -66,4 +73,19 @@ public class SysApiLogServiceImpl implements ISysApiLogService {
public void cleanApiLog() { public void cleanApiLog() {
operApiMapper.cleanApiLog(); operApiMapper.cleanApiLog();
} }
@Override
public void executeByIds(Long[] logIds) throws Exception {
for(Long logid : logIds){
SysApiLog log = this.selectApiLogById(logid);
String clzStr = log.getMethod();
String clz = clzStr.substring(0,clzStr.lastIndexOf("."));
String methodStr = clzStr.substring(clzStr.lastIndexOf(".")+1);
Object obj = applicationContext.getBean(Class.forName(clz));
//参数转换
Object[] params = log.parseParamObject();
MethodUtils.invokeMethod(obj, methodStr.replace("()",""), params);
}
}
} }
...@@ -16,7 +16,12 @@ ...@@ -16,7 +16,12 @@
<result property="operUrl" column="oper_url"/> <result property="operUrl" column="oper_url"/>
<result property="operIp" column="oper_ip"/> <result property="operIp" column="oper_ip"/>
<result property="operLocation" column="oper_location"/> <result property="operLocation" column="oper_location"/>
<result property="operParam" column="oper_param"/> <result property="operParam1" column="oper_param1"/>
<result property="operParam2" column="oper_param2"/>
<result property="operParam3" column="oper_param3"/>
<result property="operParam4" column="oper_param4"/>
<result property="operParam5" column="oper_param5"/>
<result property="paramType" column="param_type"/>
<result property="jsonResult" column="json_result"/> <result property="jsonResult" column="json_result"/>
<result property="status" column="status"/> <result property="status" column="status"/>
<result property="errorMsg" column="error_msg"/> <result property="errorMsg" column="error_msg"/>
...@@ -35,7 +40,12 @@ ...@@ -35,7 +40,12 @@
oper_url, oper_url,
oper_ip, oper_ip,
oper_location, oper_location,
oper_param, oper_param1,
oper_param2,
oper_param3,
oper_param4,
oper_param5,
param_type,
json_result, json_result,
status, status,
error_msg, error_msg,
...@@ -45,9 +55,9 @@ ...@@ -45,9 +55,9 @@
<insert id="insertApiLog" parameterType="SysApiLog"> <insert id="insertApiLog" parameterType="SysApiLog">
insert into sys_api_log(title, business_type, method, request_method, operator_type, oper_name, dept_name, insert into sys_api_log(title, business_type, method, request_method, operator_type, oper_name, dept_name,
oper_url, oper_ip, oper_location, oper_param, json_result, status, error_msg, oper_time) oper_url, oper_ip, oper_location, oper_param1, oper_param2, oper_param3, oper_param4, oper_param5, param_type, json_result, status, error_msg, oper_time)
values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName}, values (#{title}, #{businessType}, #{method}, #{requestMethod}, #{operatorType}, #{operName}, #{deptName},
#{operUrl}, #{operIp}, #{operLocation}, #{operParam}, #{jsonResult}, #{status}, #{errorMsg}, sysdate()) #{operUrl}, #{operIp}, #{operLocation}, #{operParam1}, #{operParam2}, #{operParam3}, #{operParam4}, #{operParam5}, #{paramType}, #{jsonResult}, #{status}, #{errorMsg}, #{createTime})
</insert> </insert>
<select id="selectApiLogList" parameterType="SysApiLog" resultMap="SysApiLogResult"> <select id="selectApiLogList" parameterType="SysApiLog" resultMap="SysApiLogResult">
......
...@@ -236,6 +236,8 @@ ...@@ -236,6 +236,8 @@
<if test="menuId != null and menuId != 0">#{menuId},</if> <if test="menuId != null and menuId != 0">#{menuId},</if>
<if test="parentId != null and parentId != 0">#{parentId},</if> <if test="parentId != null and parentId != 0">#{parentId},</if>
<if test="menuName != null and menuName != ''">#{menuName},</if> <if test="menuName != null and menuName != ''">#{menuName},</if>
<if test="menuNameEn != null and menuNameEn != ''">#{menuNameEn},</if>
<if test="menuNameTh != null and menuNameTh != ''">#{menuNameTh},</if>
<if test="orderNum != null and orderNum != ''">#{orderNum},</if> <if test="orderNum != null and orderNum != ''">#{orderNum},</if>
<if test="path != null and path != ''">#{path},</if> <if test="path != null and path != ''">#{path},</if>
<if test="component != null and component != ''">#{component},</if> <if test="component != null and component != ''">#{component},</if>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment