fix: 日志记录修改
This commit is contained in:
@@ -6,6 +6,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.common.logging.domain.InterfaceLogType;
|
||||
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
||||
import org.nl.wms.ext.record.core.Record;
|
||||
import org.nl.wms.ext.record.core.RecordDefinition;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
@@ -42,7 +44,8 @@ public class AcsToWmsController {
|
||||
}
|
||||
|
||||
@PostMapping("/outHotTaskApply")
|
||||
@Log(value = "申请出烘箱任务", isInterfaceLog = true, interfaceLogType = InterfaceLogType.ACS_TO_LMS)
|
||||
@Record(interactName = "申请出烘箱任务", direction = RecordDefinition.ACS_LMS)
|
||||
// @Log(value = "申请出烘箱任务", isInterfaceLog = true, interfaceLogType = InterfaceLogType.ACS_TO_LMS)
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> outHotTaskApply(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(acsToWmsService.outHotTaskApply(whereJson), HttpStatus.OK);
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.wms.sch.task_manage.AcsTaskDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author: lyd
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.lang.annotation.Target;
|
||||
* @Author: lyd
|
||||
* @Date: 2024/9/23
|
||||
*/
|
||||
@Target(ElementType.METHOD)
|
||||
@Target({ElementType.TYPE, ElementType.METHOD})
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
public @interface Record {
|
||||
/** 对接名称 */
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.wms.ext.record.core;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
@@ -51,13 +52,17 @@ public class RecordAspect {
|
||||
|
||||
@Around("logPointcut()")
|
||||
public Object logAround(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
// 获取 API URL
|
||||
String apiUrl = request.getRequestURL().toString();
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
Record annotation = method.getAnnotation(Record.class);
|
||||
// 方法路径
|
||||
String params = getParameter(method, joinPoint.getArgs());
|
||||
Object result = joinPoint.proceed();
|
||||
sysInteractRecordService.saveRecord(params, result, annotation.direction(), annotation.interactName());
|
||||
sysInteractRecordService.saveRecord(apiUrl, joinPoint, params, result, annotation.direction(), annotation.interactName());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -94,6 +99,18 @@ public class RecordAspect {
|
||||
|
||||
@AfterThrowing(pointcut = "logPointcut()", throwing = "e")
|
||||
public void logAfterThrowing(JoinPoint joinPoint, Throwable e) {
|
||||
log.error("{}", e);
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
HttpServletRequest request = attributes.getRequest();
|
||||
// 获取 API URL
|
||||
String apiUrl = request.getRequestURL().toString();
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
Record annotation = method.getAnnotation(Record.class);
|
||||
// 方法路径
|
||||
String params = getParameter(method, joinPoint.getArgs());
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", 400);
|
||||
result.put("message", e.getMessage());
|
||||
sysInteractRecordService.saveRecord(apiUrl, (ProceedingJoinPoint)joinPoint, params, result, annotation.direction(), annotation.interactName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.nl.wms.ext.record.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.system.service.param.dao.Param;
|
||||
import org.nl.wms.ext.acs.service.dto.to.BaseResponse;
|
||||
@@ -54,13 +55,15 @@ public interface ISysInteractRecordService extends IService<SysInteractRecord> {
|
||||
|
||||
/**
|
||||
* 创建记录
|
||||
* @param apiUrl
|
||||
* @param joinPoint \
|
||||
* @param request 、
|
||||
* @param response 、
|
||||
* @param direction 、
|
||||
* @param interactName \
|
||||
*/
|
||||
@Async
|
||||
void saveRecord(String request, Object response, String direction, String interactName);
|
||||
void saveRecord(String apiUrl, ProceedingJoinPoint joinPoint, String request, Object response, String direction, String interactName);
|
||||
|
||||
/**
|
||||
* 保存记录
|
||||
|
||||
@@ -22,31 +22,34 @@ public class SysInteractRecord implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(value = "interact_id", type = IdType.NONE)
|
||||
|
||||
|
||||
private String interact_id;
|
||||
|
||||
|
||||
|
||||
private String interact_name;
|
||||
|
||||
|
||||
|
||||
private int code;
|
||||
|
||||
|
||||
|
||||
private String message;
|
||||
|
||||
|
||||
|
||||
private String request_param;
|
||||
|
||||
|
||||
|
||||
private String response_param;
|
||||
|
||||
|
||||
|
||||
private String record_time;
|
||||
|
||||
|
||||
|
||||
private String direction;
|
||||
|
||||
|
||||
|
||||
private Boolean is_success;
|
||||
|
||||
private String api_url;
|
||||
private String target_class;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.nl.common.domain.query.PageQuery;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.config.language.LangProcess;
|
||||
@@ -24,6 +26,7 @@ import org.nl.wms.ext.record.service.dao.mapper.SysInteractRecordMapper;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@@ -95,9 +98,15 @@ public class SysInteractRecordServiceImpl extends ServiceImpl<SysInteractRecordM
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveRecord(String request, Object response, String direction, String interactName) {
|
||||
public void saveRecord(String apiUrl, ProceedingJoinPoint joinPoint, String request, Object response, String direction, String interactName) {
|
||||
String responseJsonString = JSONObject.toJSONString(response);
|
||||
JSONObject responseJson = JSONObject.parseObject(responseJsonString);
|
||||
JSONObject responseOb = JSONObject.parseObject(responseJsonString);
|
||||
JSONObject responseJson = responseOb.getJSONObject("body");
|
||||
if (ObjectUtil.isEmpty(responseJson)) {
|
||||
responseJson = responseOb;
|
||||
}
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
String methodName = joinPoint.getTarget().getClass().getName() + "." + signature.getName() + "()";
|
||||
SysInteractRecord entity = new SysInteractRecord();
|
||||
entity.setInteract_id(IdUtil.getSnowflake(1, 1).nextIdStr());
|
||||
entity.setInteract_name(interactName);
|
||||
@@ -106,6 +115,8 @@ public class SysInteractRecordServiceImpl extends ServiceImpl<SysInteractRecordM
|
||||
entity.setRecord_time(DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss.SSS"));
|
||||
entity.setDirection(direction);
|
||||
entity.setRequest_param(request);
|
||||
entity.setTarget_class(methodName);
|
||||
entity.setApi_url(apiUrl);
|
||||
entity.setResponse_param(JSONObject.toJSONString(response));
|
||||
entity.setIs_success(responseJson.getInteger("status") == HttpStatus.HTTP_OK);
|
||||
sysInteractRecordMapper.insert(entity);
|
||||
|
||||
@@ -28,10 +28,7 @@ import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.core.constant.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.tasks.nbj.SendShaftAGVTask;
|
||||
import org.nl.wms.sch.task_manage.tasks.slitter.SlitterDownAGVTask;
|
||||
import org.nl.wms.sch.task_manage.tasks.slitter.SlitterInHotAGVTask;
|
||||
import org.nl.wms.sch.task_manage.tasks.slitter.SlitterSendRollAGVTask;
|
||||
import org.nl.wms.sch.task_manage.tasks.slitter.SlitterUpTrussTask;
|
||||
import org.nl.wms.sch.task_manage.tasks.slitter.*;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.slf4j.MDC;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@@ -77,6 +74,8 @@ public class SlitterPdaServiceImpl implements SlitterPdaService {
|
||||
private SlitterDownAGVTask slitterDownAGVTask;
|
||||
@Autowired
|
||||
private SlitterInHotAGVTask slitterInHotAGVTask;
|
||||
@Autowired
|
||||
private SlitterRebakeAGVTask slitterRebakeAGVTask;
|
||||
@Override
|
||||
public JSONObject queryOrderInfo(JSONObject param) {
|
||||
JSONObject result = new JSONObject();
|
||||
@@ -239,10 +238,10 @@ public class SlitterPdaServiceImpl implements SlitterPdaService {
|
||||
// 组织请求任务参数
|
||||
JSONObject taskParam = new JSONObject();
|
||||
taskParam.put("device_code", pointCode);
|
||||
taskParam.put("config_code", "SlitterInHotAGVTask");
|
||||
taskParam.put("config_code", "SlitterRebakeAGVTask");
|
||||
taskParam.put("order_code", rawOrder.getContainer_name());
|
||||
taskParam.put("create_mode", GeneralDefinition.PDA_CREATION);
|
||||
slitterInHotAGVTask.apply(taskParam);
|
||||
slitterRebakeAGVTask.apply(taskParam);
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("message", "母卷回库任务创建成功!");
|
||||
return result;
|
||||
|
||||
@@ -4,6 +4,8 @@ import cn.dev33.satoken.annotation.SaIgnore;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.logging.annotation.Log;
|
||||
import org.nl.wms.ext.record.core.Record;
|
||||
import org.nl.wms.ext.record.core.RecordDefinition;
|
||||
import org.nl.wms.pda.st.service.GxPdaService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
@@ -31,7 +33,8 @@ public class GxPdaController {
|
||||
return new ResponseEntity<>(gxPdaService.getGxSpecification(), HttpStatus.OK);
|
||||
}
|
||||
@PostMapping("/confirmedInStorage")
|
||||
@Log("管芯确认入库")
|
||||
// @Log("管芯确认入库")
|
||||
@Record(interactName = "管芯确认入库", direction = RecordDefinition.LMS_ACS)
|
||||
public ResponseEntity<Object> confirmedInStorage(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(gxPdaService.confirmedInStorageV2(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class AcsUtil {
|
||||
String msg = e.getMessage();
|
||||
//ConnectException: Connection refused: connect
|
||||
//网络不通
|
||||
result.put("status", HttpStatus.BAD_REQUEST);
|
||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
result.put("message", "网络不通,操作失败!");
|
||||
result.put("data", new JSONObject());
|
||||
log.error("ACS出现异常: {}", e);
|
||||
@@ -236,8 +236,8 @@ public class AcsUtil {
|
||||
String msg = e.getMessage();
|
||||
//ConnectException: Connection refused: connect
|
||||
//网络不通
|
||||
result.put("status", HttpStatus.BAD_REQUEST);
|
||||
result.put("message", "网络不通,操作失败!");
|
||||
result.put("status", HttpStatus.BAD_REQUEST.value());
|
||||
result.put("message", msg);
|
||||
result.put("data", new JSONObject());
|
||||
}
|
||||
//acs抛异常这里
|
||||
|
||||
@@ -8,6 +8,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.pdm.bi.dao.PdmBiRawfoilworkorder;
|
||||
import org.nl.wms.pdm.bi.service.IpdmBiRawfoilworkorderService;
|
||||
import org.nl.wms.pdm.ivt.hot.service.IstIvtHotpointivtService;
|
||||
import org.nl.wms.pdm.ivt.hot.service.dao.StIvtHotpointivt;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.TaskStatus;
|
||||
@@ -44,6 +46,8 @@ public class BakingOperationServiceImpl implements BakingOperationService {
|
||||
private InHotTrussTask inHotTrussTask;
|
||||
@Autowired
|
||||
private InHotDockingTrussTask inHotDockingTrussTask;
|
||||
@Autowired
|
||||
private IstIvtHotpointivtService hotpointivtService;
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public JSONObject acsRequestOutHotTask(JSONObject param) {
|
||||
@@ -55,6 +59,10 @@ public class BakingOperationServiceImpl implements BakingOperationService {
|
||||
if (schBaseTasks.size() > 0) {
|
||||
throw new BadRequestException("点位[" + deviceCode + "]已经存在任务!");
|
||||
}
|
||||
StIvtHotpointivt hotPoint = hotpointivtService.getPointByCode(deviceCode, false);
|
||||
if ("01".equals(hotPoint.getPoint_status())) {
|
||||
throw new BadRequestException("烘箱「" + deviceCode + "」系统库存为空!");
|
||||
}
|
||||
param.put("config_code", "OutHotToDockingTrussTask");
|
||||
outHotToDockingTrussTask.apply(param);
|
||||
JSONObject result = new JSONObject();
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package org.nl.wms.sch.task_manage.tasks.slitter;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.common.exception.BadRequestException;
|
||||
import org.nl.wms.sch.point.service.ISchBasePointService;
|
||||
import org.nl.wms.sch.point.service.dao.SchBasePoint;
|
||||
import org.nl.wms.sch.task.service.ISchBaseTaskService;
|
||||
import org.nl.wms.sch.task.service.dao.SchBaseTask;
|
||||
import org.nl.wms.sch.task_manage.AbstractTask;
|
||||
import org.nl.wms.sch.task_manage.TaskStatus;
|
||||
import org.nl.wms.sch.task_manage.core.constant.GeneralDefinition;
|
||||
import org.nl.wms.sch.task_manage.core.constant.RegionConstant;
|
||||
import org.nl.wms.sch.task_manage.core.enums.TaskFinishedTypeEnum;
|
||||
import org.nl.wms.util.PointUtils;
|
||||
import org.nl.wms.util.TaskUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.nl.wms.util.TaskUtils.checkTaskOptionStatus;
|
||||
import static org.nl.wms.util.TaskUtils.setUpdateByPC;
|
||||
|
||||
/**
|
||||
* 分切复烤AGV任务
|
||||
* @Author: lyd
|
||||
* @Date: 2024/9/27
|
||||
*/
|
||||
@Slf4j
|
||||
@Component("SlitterRebakeAGVTask")
|
||||
public class SlitterRebakeAGVTask extends AbstractTask {
|
||||
private final String THIS_CLASS = SlitterRebakeAGVTask.class.getName();
|
||||
@Autowired
|
||||
private ISchBaseTaskService taskService;
|
||||
@Autowired
|
||||
private ISchBasePointService pointService;
|
||||
@Override
|
||||
public void create() throws BadRequestException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createCompletion(SchBaseTask task) {
|
||||
TaskUtils.taskLock(RegionConstant.REGION_A1_HXZC + "5", () -> {
|
||||
// 找个对接位(状态是空的,没有任务的)
|
||||
List<SchBasePoint> endPoints = pointService.getHotNotTaskPoint("A1", RegionConstant.REGION_A1_HXZC,
|
||||
"5", "1");
|
||||
if (endPoints.size() == 0) {
|
||||
throw new BadRequestException("没有可用的烘箱对接位!");
|
||||
}
|
||||
SchBasePoint endPoint = endPoints.get(0);
|
||||
task.setPoint_code2(endPoint.getPoint_code());
|
||||
// 保存任务参数
|
||||
task.setHandle_class(THIS_CLASS);
|
||||
task.setTask_status(TaskStatus.START_AND_POINT.getCode());
|
||||
setUpdateByPC(task);
|
||||
taskService.save(task);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
checkTaskOptionStatus(taskObj);
|
||||
JSONObject requestObj = JSONObject.parseObject(taskObj.getRequest_param());
|
||||
String orderCode = requestObj.getString("order_code");
|
||||
// 点位赋值。
|
||||
String endPointCode = taskObj.getPoint_code2();
|
||||
SchBasePoint endPoint = pointService.getById(endPointCode);
|
||||
endPoint.setPoint_status("5");
|
||||
endPoint.setMaterial_code(orderCode);
|
||||
PointUtils.setUpdateByType(endPoint, taskFinishedType);
|
||||
pointService.updateById(endPoint);
|
||||
// 完成
|
||||
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) {
|
||||
checkTaskOptionStatus(taskObj);
|
||||
// 取消
|
||||
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
|
||||
taskObj.setRemark(GeneralDefinition.TASK_CANCEL);
|
||||
taskObj.setFinished_type(taskFinishedType.getCode());
|
||||
TaskUtils.setUpdateByType(taskObj, taskFinishedType);
|
||||
taskService.updateById(taskObj);
|
||||
}
|
||||
}
|
||||
@@ -121,18 +121,18 @@
|
||||
/>
|
||||
<el-table-column prop="code" :label="$t('Record.table.code')" :min-width="flexWidth('code',crud.data,$t('Record.table.code'))" />
|
||||
<el-table-column prop="message" :label="$t('Record.table.message')" :min-width="flexWidth('message',crud.data,$t('Record.table.message'))" />
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="request_param"-->
|
||||
<!-- :label="$t('Record.table.request_param')"-->
|
||||
<!-- show-overflow-tooltip-->
|
||||
<!-- :min-width="200"-->
|
||||
<!-- />-->
|
||||
<!-- <el-table-column-->
|
||||
<!-- prop="response_param"-->
|
||||
<!-- :label="$t('Record.table.response_param')"-->
|
||||
<!-- show-overflow-tooltip-->
|
||||
<!-- :min-width="200"-->
|
||||
<!-- />-->
|
||||
<el-table-column
|
||||
prop="api_url"
|
||||
label="URL"
|
||||
show-overflow-tooltip
|
||||
:min-width="200"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="target_class"
|
||||
label="Class"
|
||||
show-overflow-tooltip
|
||||
:min-width="200"
|
||||
/>
|
||||
<el-table-column
|
||||
prop="record_time"
|
||||
:label="$t('Record.table.record_time')"
|
||||
@@ -145,7 +145,8 @@
|
||||
</el-table-column>
|
||||
<el-table-column prop="is_success" :label="$t('Record.table.is_success')" :min-width="flexWidth('is_success',crud.data,$t('Record.table.is_success'))">
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.is_success ? $t('common.Success') : $t('common.Fail') }}
|
||||
<el-tag v-if="scope.row.is_success" type="success">{{ $t('common.Success') }}</el-tag>
|
||||
<el-tag v-else type="danger">{{ $t('common.Fail') }}</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column v-permission="[]" :label="$t('common.Operate')" width="120px" align="center" fixed="right">-->
|
||||
|
||||
Reference in New Issue
Block a user