This commit is contained in:
2023-02-11 13:36:14 +08:00
23 changed files with 419 additions and 97 deletions

View File

@@ -74,6 +74,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
public int error = 0;
public int door = 0;
public int temperature = 0;
public int to_temperature = 0;
public int countdown_house = 0;
public int countdown_min = 0;
public int countdown_sec = 0;
@@ -120,6 +121,9 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
String device_code;
String message = null;
@Override
public Device getDevice() {
return this.device;
@@ -130,7 +134,6 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
@Override
public void execute() {
String message = null;
device_code = this.getDeviceCode();
heartbeat = this.itemProtocol.getItem_heartbeat();
@@ -154,7 +157,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
currentA = this.itemProtocol.getItem_currentA();
currentB = this.itemProtocol.getItem_currentB();
currentC = this.itemProtocol.getItem_currentC();
to_temperature = this.itemProtocol.getItem_to_temperature();
if (mode != last_mode) {
//this.setRequireSucess(false);
}
@@ -187,6 +190,7 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
}
if (finish == 1 && !requireSucess) {
message = "烘箱完成反馈LMS...";
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "开始烘箱完成反馈lms~");
//烘箱完成反馈LMS
apply_finish();
@@ -358,8 +362,10 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
ApplyLabelingAndBindingResponse applyLabelingAndBindingResponse = acsToWmsService.applyLabelingAndBindingRequest(applyLabelingAndBindingRequest);
if (applyLabelingAndBindingResponse.getstatus() == 200) {
requireSucess = true;
message = "烘箱完成反馈LMS成功...";
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "烘箱完成反馈lms响应消息:" + String.valueOf(applyLabelingAndBindingResponse));
} else {
message = "烘箱完成反馈LMS失败"+String.valueOf(applyLabelingAndBindingResponse);
logServer.deviceExecuteLog(this.getDevice_code(), "", "", "烘箱完成反馈lms响应消息:" + String.valueOf(applyLabelingAndBindingResponse));
}
return true;

View File

@@ -118,6 +118,10 @@ public class ItemProtocol {
return this.getOpcFloatValue(item_currentC);
} ;
public int getItem_to_temperature(){
return this.getOpcIntegerValue(item_to_temperature);
} ;
Boolean isonline;
public int getOpcIntegerValue(String protocol) {

View File

@@ -232,7 +232,9 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
jo.put("countdown_min", hongXiangConveyorDeviceDriver.getCountdown_min());
jo.put("countdown_sec", hongXiangConveyorDeviceDriver.getCountdown_sec());
//温度需要除以10
jo.put("temperature", hongXiangConveyorDeviceDriver.getTemperature()/10);
jo.put("temperature", hongXiangConveyorDeviceDriver.getTo_temperature()/10);
jo.put("now_temperature", hongXiangConveyorDeviceDriver.getTemperature()/10);
jo.put("door", hongXiangConveyorDeviceDriver.getDoor());
jo.put("finish", hongXiangConveyorDeviceDriver.getFinish());
jo.put("task", hongXiangConveyorDeviceDriver.getTask());

View File

@@ -83,7 +83,7 @@ public class DeviceExecuteAutoRun extends AbstractAutoRunnable {
}
}
Thread.sleep(10000L);
// Thread.sleep(10000L);
log.info("设备执行线程开始...");
while (true) {

View File

@@ -4,6 +4,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.modules.wql.core.bean.ResultBean;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
@@ -34,7 +35,12 @@ public class DeviceManageServiceImpl implements DeviceManageService {
String opc_plc_id = json.getString("opc_plc_id");
if (StrUtil.isNotEmpty(opc_plc_id) && StrUtil.isNotEmpty(opc_server_id)) {
//OPC表【acs_opc】
String opc_code = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0).getString("opc_code");
JSONObject rb = opcTab.query("is_delete= '0' AND is_active= '1' AND opc_id = '" + opc_server_id + "'").uniqueResult(0);
if(ObjectUtil.isEmpty(rb)){
System.out.println(device.getDevice_code());
continue;
}
String opc_code= rb.getString("opc_code");
device.setOpc_server_code(opc_code);
if(ObjectUtil.isEmpty(plcTab.query("is_delete= '0' AND is_active= '1' AND plc_id = '" + opc_plc_id + "'").uniqueResult(0)))
{

View File

@@ -19,10 +19,12 @@ public class DeviceOpcProtocolRunable implements Runnable {
OpcServerManageDto OpcServer;
int error_num;
String message;
private Server server;
public DeviceOpcProtocolRunable() {
this.error_num = 0;
this.message = null;
this.server = null;
}
public List<OpcItemDto> getProtocols() {
@@ -60,8 +62,12 @@ public class DeviceOpcProtocolRunable implements Runnable {
public void run() {
while (true) {
try {
Server server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
Group group = server.addGroup();
this.server = OpcServerUtl.getServerWithOutException(this.OpcServer.getOpc_host(), this.OpcServer.getCls_id(), this.OpcServer.getUser(), this.OpcServer.getPassword(), this.OpcServer.getDomain());
// Group group = server.addGroup(this.OpcServer.getOpc_host());
Group group = server.addGroup(this.OpcServer.getOpc_code());
if(ObjectUtil.isEmpty(group)){
log.info("group is null ");
}
List<String> itemsString = new ArrayList();
Iterator it = this.protocols.iterator();
@@ -110,11 +116,18 @@ public class DeviceOpcProtocolRunable implements Runnable {
label97:
while (true) {
long begin = System.currentTimeMillis();
Map<Item, ItemState> itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
Map<Item, ItemState> itemStatus = null;
try {
itemStatus = group.read(true, (Item[]) itemsMap.values().toArray(new Item[0]));
} catch (Exception e){
// System.out.println("数据同步异常:"+itemsMap);
e.printStackTrace();
}
long end = System.currentTimeMillis();
log.trace("{} 开始记时{}", tag, DateUtil.now());
long duration = end - begin;
log.trace("{} 读取耗时:{}", tag, duration);
System.out.println("线程:"+tag + " 读取耗时:"+ duration);
if (duration > 1000L) {
if (!time_out) {
log.warn("{} 读取超时 : {}", tag, duration);
@@ -125,6 +138,8 @@ public class DeviceOpcProtocolRunable implements Runnable {
time_out = false;
}
if(ObjectUtil.isEmpty(itemStatus)) continue label97;
Set<Item> items = itemStatus.keySet();
Iterator var18 = items.iterator();
@@ -151,7 +166,7 @@ public class DeviceOpcProtocolRunable implements Runnable {
ItemState itemState = (ItemState) itemStatus.get(item);
value = OpcUtl.getValue(item, itemState);
his = accessor_value.getValue(item.getId());
if (!ObjectUtil.equal(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
log.warn("opc 值不健康 item: {}, 状态: {}", item.getId(), itemState.getQuality());
}
} while (ObjectUtil.equal(value, his));//如果两次的值相等,不走下面的代码
@@ -178,7 +193,16 @@ public class DeviceOpcProtocolRunable implements Runnable {
}
}
} catch (Exception var30) {
String error_message = "设备信息同步异常";
if (this.server != null) {
try {
this.server.disconnect();
} catch (Exception var25) {
}
}
this.server = null;
String error_message = "设备信息同步异常,"+var30;
if (!StrUtil.equals(this.message, error_message)) {
log.warn("", var30);
}

View File

@@ -0,0 +1,78 @@
package org.nl.acs.opc;
import org.nl.modules.wql.exception.WDKException;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Objects;
public class ObjectUtl {
private ObjectUtl() {
}
public static boolean isEquals(Object a, Object b) {
if (a == null && b == null) {
return true;
} else if (a != null && b != null) {
if (a.getClass().isArray()) {
if (a instanceof boolean[]) {
return Arrays.equals((boolean[]) ((boolean[]) a), (boolean[]) ((boolean[]) b));
} else if (a instanceof byte[]) {
return Arrays.equals((byte[]) ((byte[]) a), (byte[]) ((byte[]) b));
} else if (a instanceof int[]) {
return Arrays.equals((int[]) ((int[]) a), (int[]) ((int[]) b));
} else if (a instanceof long[]) {
return Arrays.equals((long[]) ((long[]) a), (long[]) ((long[]) b));
} else if (a instanceof double[]) {
return Arrays.equals((double[]) ((double[]) a), (double[]) ((double[]) b));
} else if (a instanceof short[]) {
return Arrays.equals((short[]) ((short[]) a), (short[]) ((short[]) b));
} else if (a instanceof char[]) {
return Arrays.equals((char[]) ((char[]) a), (char[]) ((char[]) b));
} else if (a instanceof float[]) {
return Arrays.equals((float[]) ((float[]) a), (float[]) ((float[]) b));
} else if (a instanceof Object[]) {
return Arrays.equals((Object[]) ((Object[]) a), (Object[]) ((Object[]) b));
} else {
throw new WDKException("未实现");
}
} else {
return Objects.equals(a, b);
}
} else {
return false;
}
}
public static boolean isTrue(Boolean boolean_) {
return boolean_ != null && isEquals(boolean_, true);
}
public static boolean isTrue(Boolean targetBoolean, boolean defaultBoolean) {
return targetBoolean == null ? defaultBoolean : targetBoolean;
}
public static boolean isFalse(Boolean boolean_) {
return boolean_ != null && isEquals(boolean_, false);
}
public static boolean isObject(Class<?> clazz) {
if (clazz == null) {
return false;
} else if (clazz.getClass().isArray()) {
return false;
} else {
return Object.class.isAssignableFrom(clazz);
}
}
}

View File

@@ -29,7 +29,7 @@ public class opcServerManageServiceImpl implements OpcServerManageService {
public List<OpcServerManageDto> queryAll() {
//return this.opcServerRepository.queryAll(OpcServerManageDto.class);
//OPC表【acs_opc】
JSONArray arr = WQLObject.getWQLObject("acs_opc").query().getResultJSONArray(0);
JSONArray arr = WQLObject.getWQLObject("acs_opc").query("is_active='1' and is_delete='0'").getResultJSONArray(0);
return arr.toJavaList(OpcServerManageDto.class);
}

View File

@@ -45,9 +45,6 @@
<el-form-item label="">
<el-input v-model="form.value" style="width: 370px;" />
</el-form-item>
<!-- <el-form-item label="操作" prop="description">-->
<!-- <el-input v-model="form.remark" style="width: 380px;" rows="5" type="textarea" />-->
<!-- </el-form-item>-->
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="text" @click="crud.cancelCU">取消</el-button>
@@ -74,22 +71,27 @@
align="center"
>
<template slot-scope="scope">
<el-dropdown trigger="click" @command="handleCommand">
<span class="el-dropdown-link">
<i class="el-icon-menu" />
</span>
<el-dropdown-menu slot="dropdown">
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'a')">完成</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'b')">取消</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'c')">强制取消</el-dropdown-item>
<el-dropdown-item :command="beforeHandleCommand(scope.$index, scope.row,'d')">初始化</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
<el-button slot="right" size="mini" style="margin-left: -1px;margin-right: 2px" type="text" @click="dialogFormVisible = true">
查询历史
</el-button>
</template>
</el-table-column>
</el-table>
<!--分页组件-->
<pagination />
<!--弹窗设置设备与图标绑定与角度-->
<el-dialog title="历史" :visible.sync="dialogFormVisible" width="35%">
<el-form :model="form" size="small">
<el-form-item label="unified_key" prop="unified_key" label-width="100px">
<el-input v-model="form.unified_key" :disabled="true" />
</el-form-item>
<el-form-item label="code" prop="key" label-width="100px">
<el-input v-model="form.key" :disabled="true" />
</el-form-item>
</el-form>
</el-dialog>
</div>
</div>
</template>
@@ -102,7 +104,7 @@ import crudOperation from '@crud/CRUD.operation'
import { getDicts } from '@/api/system/dict'
const defaultForm = {
unified_key: 'opc_value',
unified_key: '',
key: null,
value: null,
last_modify_date: null
@@ -142,7 +144,14 @@ export default {
],
permission: {
},
dialogFormVisible: false,
rules: {
},
form: {
unified_key: 'opc_value',
key: null,
value: null,
last_modify_date: null
}
}
},
@@ -155,26 +164,7 @@ export default {
// 钩子在获取表格数据之前执行false 则代表不获取数据
[CRUD.HOOK.beforeRefresh]() {
return true
},
// https://www.cnblogs.com/jdWu-d/p/11898666.html
beforeHandleCommand(index, row, command) {
return {
'index': index,
'row': row,
'command': command
}
},
handleCommand(command) {
switch (command.command) {
case 'a':// 完成
this.finish(command.index, command.row)
break
case 'b':// 取消
this.cancel(command.index, command.row)
break
}
}
}
}
</script>

View File

@@ -452,6 +452,11 @@
<artifactId>easyexcel</artifactId>
<version>2.2.6</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.20</version>
</dependency>
</dependencies>
<distributionManagement>

View File

@@ -0,0 +1,98 @@
package org.nl.config;
import com.alibaba.druid.filter.FilterChain;
import com.alibaba.druid.filter.FilterEventAdapter;
import com.alibaba.druid.proxy.jdbc.JdbcParameter;
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxy;
import com.alibaba.druid.proxy.jdbc.ResultSetProxy;
import com.alibaba.druid.proxy.jdbc.StatementProxy;
import com.alibaba.druid.sql.SQLUtils;
import com.alibaba.druid.util.JdbcUtils;
import com.alibaba.fastjson.JSON;
import com.mysql.cj.jdbc.result.ResultSetImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.MDC;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
/*
* @author ZZQ
* @Date 2023/2/10 11:27 上午
*/
@Slf4j
public class DruidFilter extends FilterEventAdapter {
@Override
public int preparedStatement_executeUpdate(FilterChain chain, PreparedStatementProxy statement) throws SQLException {
return super.preparedStatement_executeUpdate(chain, statement);
}
@Override
public int statement_executeUpdate(FilterChain chain, StatementProxy statement, String sql) throws SQLException {
return super.statement_executeUpdate(chain, statement, sql);
}
@Override
protected void statementExecuteAfter(StatementProxy statement, String sql, boolean result) {
String traceId = MDC.get("traceId");
int size = statement.getParametersSize();
String executeSql = sql;
int count = 0;
try {
count=statement.getUpdateCount();
}catch (Exception ex){ }
if (StringUtils.isNotEmpty(traceId) && count>0) {
if (size > 0) {
Collection<JdbcParameter> values = statement.getParameters().values();
List<Object> params = new ArrayList<>();
for (JdbcParameter value : values) {
params.add(value.getValue());
}
executeSql = SQLUtils.format(executeSql, JdbcUtils.MYSQL, params);
}
log.info("[----SQL----][update][ SQL: {} ]", executeSql);
}
super.statementExecuteAfter(statement, sql, result);
}
@Override
public ResultSetProxy statement_getResultSet(FilterChain chain, StatementProxy statement) throws SQLException {
ResultSetProxy rs = super.statement_getResultSet(chain, statement);
String executeSql = statement.getLastExecuteSql();
String traceId = MDC.get("traceId");
if (StringUtils.isNotEmpty(traceId)){
int result = 0;
if (rs != null) {
ResultSetImpl rss = rs.getResultSetRaw().unwrap(ResultSetImpl.class);
result = rss.getRows().size();
}
try {
int size = statement.getParametersSize();
if (size>0){
Collection<JdbcParameter> values = statement.getParameters().values();
List<Object> params = new ArrayList<>();
for (JdbcParameter value : values) {
params.add(value.getValue());
}
executeSql = SQLUtils.format(executeSql, JdbcUtils.MYSQL, params);
}
}catch (Exception ex){
log.warn("[-SQL解析异常-][{}]",ex.getMessage());
}
log.info("[----SQL----][select][执行结果:{}][ SQL: {} ]",result, executeSql);
}
return rs;
}
}

View File

@@ -116,21 +116,20 @@ public class LogAspect {
}
}
}catch (Exception ex){
StringBuffer errorInfo = new StringBuffer();
errorInfo.append(ex.getMessage()).append("\n");
StringBuffer errorStack = new StringBuffer();
String errorMsg = ex.getMessage();
int x = 0;
StackTraceElement[] stackTrace = ex.getStackTrace();
if (stackTrace!=null && stackTrace.length>0){
errorInfo.append("---堆栈信息:");
for (StackTraceElement stack : stackTrace) {
x++;
errorInfo.append(stack.toString()).append("\n");
errorStack.append(stack.toString()).append(" | ");
if (x>10){
break;
}
}
}
log.error("[--requestError--][请求接口:{}][请求参数:{}]异常信息 :{}", url,params, errorInfo.toString());
log.error("[-requestError-][请求接口:{}]【异常信息:{}】[请求参数:{}][异常堆栈:{}]", url,errorMsg,params, errorStack.toString());
Log log = new Log("ERROR", System.currentTimeMillis() - comming);
log.setExceptionDetail(ThrowableUtil.getStackTrace(ex).getBytes());
logService.save(getUsername(), StringUtils.getBrowser(request), StringUtils.getIp(request), (ProceedingJoinPoint) joinPoint, log);

View File

@@ -23,10 +23,10 @@ public class EsLogController {
private final EsLogService esLogService;
@GetMapping("/labels")
@GetMapping("/labels/{type}")
@ApiOperation("获取标签")
public ResponseEntity<Object> labelsValues() {
return new ResponseEntity<>(esLogService.getLabelsValues(), HttpStatus.OK);
public ResponseEntity<Object> labelsValues(@PathVariable String type) {
return new ResponseEntity<>(esLogService.getLabelsValues(type), HttpStatus.OK);
}
@PostMapping("/query")

View File

@@ -16,7 +16,7 @@ public interface EsLogService {
* 获取labels和values树
* @return
*/
JSONArray getLabelsValues();
JSONArray getLabelsValues(String type);
/**
* 日志查询

View File

@@ -27,6 +27,10 @@ public class LogQuery {
* 日志级别
*/
private String logLevel;
/**
* 系统标签
*/
private String system;
/**
* 是否只查询Http相关请求
*/

View File

@@ -8,9 +8,13 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.script.Script;
import org.elasticsearch.search.aggregations.AggregationBuilders;
import org.elasticsearch.search.aggregations.Aggregations;
import org.elasticsearch.search.aggregations.bucket.terms.Terms;
import org.nl.common.domain.query.PageQuery;
import org.nl.common.enums.LevelEnum;
import org.nl.modules.logging.repository.EsLogRepository;
@@ -21,12 +25,19 @@ import org.nl.wms.ext.acs.service.impl.AcsToWmsServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate;
import org.springframework.data.elasticsearch.core.aggregation.impl.AggregatedPageImpl;
import org.springframework.data.elasticsearch.core.query.FetchSourceFilter;
import org.springframework.data.elasticsearch.core.query.NativeSearchQueryBuilder;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
/**
* @author ldjun
@@ -40,6 +51,8 @@ public class EsLogServiceImpl implements EsLogService {
private final EsLogRepository esLogRepository;
private final ElasticsearchRestTemplate elasticsearchRestTemplate;
@Override
public Page query(LogQuery logQuery){
Page<T> page = new Page<>();
@@ -60,6 +73,9 @@ public class EsLogServiceImpl implements EsLogService {
if (StringUtils.isNotEmpty(logQuery.getLogLevel())){
query.must().add(QueryBuilders.matchQuery("logLevel", LevelEnum.checkLevel(logQuery.getLogLevel())));
}
if (StringUtils.isNotEmpty(logQuery.getSystem())){
query.must().add(QueryBuilders.matchQuery("system", logQuery.getSystem()));
}
if (logQuery.getIsRequest()){
query.must().add(QueryBuilders.existsQuery("requestMethod"));
}
@@ -86,13 +102,23 @@ public class EsLogServiceImpl implements EsLogService {
@Override
public JSONArray getLabelsValues() {
public JSONArray getLabelsValues(String type) {
JSONArray result = new JSONArray();
for (LevelEnum value : LevelEnum.values()) {
JSONObject level = new JSONObject();
level.put("label", value.name());
level.put("value", value.name());
result.add(level);
FetchSourceFilter fetchSourceFilter = new FetchSourceFilter(new String[]{type}, null);
NativeSearchQueryBuilder queryBuilder = new NativeSearchQueryBuilder();
queryBuilder.withCollapseField(type+".keyword");
queryBuilder.withSourceFilter(fetchSourceFilter);
queryBuilder.addAggregation(AggregationBuilders.terms(type).field(type+".keyword").size(100));
Aggregations agg = elasticsearchRestTemplate.query(queryBuilder.build(), SearchResponse::getAggregations);
Terms terms = agg.get(type);
List<? extends Terms.Bucket> buckets = terms.getBuckets();
if (!CollectionUtils.isEmpty(buckets)){
buckets.stream().map(Terms.Bucket::getKeyAsString).forEach(v-> {
JSONObject item = new JSONObject();
item.put("label", v);
item.put("value", v);
result.add(item);
});
}
return result;
}

View File

@@ -98,7 +98,7 @@
IF 输入.flag = "2"
QUERY
SELECT
SELECT DISTINCT
dtl.check_code,
(
CASE

View File

@@ -17,6 +17,8 @@
输入.pcsn TYPEAS s_string
输入.struct_id TYPEAS s_string
输入.iostorinv_id TYPEAS s_string
输入.width TYPEAS s_string
输入.thickness TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
@@ -122,3 +124,54 @@
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "5"
QUERY
SELECT
sub.width,
sub.thickness
FROM
ST_IVT_IOStorInvDis dis
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.package_box_sn = dis.box_no
WHERE
1 = 1
OPTION 输入.iostorinv_id <> ""
dis.iostorinv_id = 输入.iostorinv_id
ENDOPTION
group by sub.width,sub.thickness
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "6"
QUERY
SELECT
sub.package_box_sn AS box_no,
MAX( sub.product_description ) AS material_name,
SUM( sub.net_weight ) AS qty
FROM
ST_IVT_IOStorInvDis dis
LEFT JOIN pdm_bi_subpackagerelation sub ON sub.container_name = dis.pcsn
WHERE
1 = 1
OPTION 输入.iostorinv_id <> ""
dis.iostorinv_id = 输入.iostorinv_id
ENDOPTION
OPTION 输入.width <> ""
sub.width = 输入.width
ENDOPTION
OPTION 输入.thickness <> ""
sub.width = 输入.thickness
ENDOPTION
group by sub.package_box_sn
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -0,0 +1 @@
druid.filters.DruidFilter=org.nl.config.DruidFilter

View File

@@ -23,10 +23,10 @@ spring:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
# url: jdbc:log4jdbc:mysql://${DB_HOST:10.1.3.91}:${DB_PORT:3306}/${DB_NAME:lms_test2}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:hl_tb_lms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:lms}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
# username: ${DB_USER:root}
username: ${DB_USER:root}
password: ${DB_PWD:Root.123456}
password: ${DB_PWD:942464Yy}
# 初始连接数
initial-size: 5
# 最小连接数
@@ -58,16 +58,17 @@ spring:
enabled: true
url-pattern: /druid/*
reset-enable: false
filter:
stat:
enabled: true
# 记录慢SQL
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
filters:
DruidFilter,stat
# stat:
# enabled: true
# # 记录慢SQL
# log-slow-sql: true
# slow-sql-millis: 1000
# merge-sql: true
# wall:
# config:
# multi-statement-allow: true
redis:
#数据库索引
database: ${REDIS_DB:15}

View File

@@ -59,16 +59,17 @@ spring:
enabled: true
url-pattern: /druid/*
reset-enable: false
filter:
stat:
enabled: true
# 记录慢SQL
log-slow-sql: true
slow-sql-millis: 1000
merge-sql: true
wall:
config:
multi-statement-allow: true
filters:
DruidFilter,stat
# stat:
# enabled: true
# # 记录慢SQL
# log-slow-sql: true
# slow-sql-millis: 1000
# merge-sql: true
# wall:
# config:
# multi-statement-allow: true
redis:
#数据库索引
database: ${REDIS_DB:14}

View File

@@ -8,9 +8,9 @@ export function getLogData(param) {
})
}
export function labelsValues() {
export function labelsValues(type) {
return request({
url: '/api/esLog/labels',
url: '/api/esLog/labels/' + type,
method: 'get'
})
}

View File

@@ -3,12 +3,27 @@
<div class="head-container">
<!--工具栏-->
<el-form :inline="true" class="demo-form-inline" label-suffix=":" label-width="90px">
<el-form-item label="日志级别">
<el-form-item label="标签">
<el-select
v-model="system"
clearable
style="width: 100px; height: 35px;top: -5px;"
placeholder="所属标签"
>
<el-option
v-for="item in systemOptions"
:key="item.value"
:label="item.label"
:value="item.value"
/>
</el-select>
</el-form-item>
<el-form-item label="级别">
<el-select
v-model="logLevelValue"
clearable
style="width: 100px; height: 35px;top: -5px;"
placeholder="选择级别"
placeholder="日志级别"
>
<el-option
v-for="item in labelsOptions"
@@ -38,8 +53,8 @@
<el-form-item label="SQL日志" prop="filterSql">
<el-switch
v-model="filterSql"
active-color="#409EFF"
inactive-color="#F56C6C"
active-color="#F56C6C"
inactive-color="#409EFF"
active-value="1"
inactive-valu="0"
/>
@@ -135,16 +150,15 @@
<div style="width: 100%">
<div v-for="(log, index) in logs" :key="index">
<div>
<span>{{ log.system }}</span>
<span style="color: #6c0a99;font-weight: 700">{{ log.system }}</span>
<span style="color: #13ce66">{{ log.thread }}</span>
<span :style="fontType(log.logLevel)">{{ log.logLevel }}</span>
<span>{{ log.requestIp }}</span>
<span style="color: #b4bccc">{{ log.requestTime }}</span>
<span style="color: #7c8db0">{{ log.requestTime }}</span>
<span style="color: chocolate">{{ log.traceId }}</span>
<span style="color: #7a6df0">{{ log.requestMethod }}</span>
<span style="margin: 5px;font-size: 15px">-----{{ log.message }}</span>
</div>
</div>
</div>
</el-card>
@@ -158,6 +172,7 @@ import logOperation from '@/views/loki/api/loki'
let queryParam = {
logLevel: null,
system: null,
startTime: null,
endTime: null,
traceId: null,
@@ -172,7 +187,9 @@ export default {
data() {
return {
labelsOptions: [], // 所有标签和对应所有值数据
systemOptions: [], // 所有标签和对应所有值数据
logLevelValue: '',
system: '',
timeRange: [],
message: '',
traceId: '',
@@ -243,7 +260,8 @@ export default {
}
},
created() {
this.initLabelsValues()
this.initLabelsValues('logLevel')
this.initLabelsValues('system')
},
methods: {
fontType(level) {
@@ -258,9 +276,14 @@ export default {
}
return { 'color': '#a74dc6' }
},
initLabelsValues() {
logOperation.labelsValues().then(res => {
initLabelsValues(type) {
logOperation.labelsValues(type).then(res => {
if (type === 'logLevel') {
this.labelsOptions = res
}
if (type === 'system') {
this.systemOptions = res
}
})
},
queryData() {
@@ -281,6 +304,7 @@ export default {
queryParam.traceId = this.traceId
queryParam.size = this.size
queryParam.page = this.page
queryParam.system = this.system
logOperation.getLogData(queryParam).then(res => {
this.showEmpty = false