This commit is contained in:
2023-01-27 18:25:32 +08:00
30 changed files with 1790 additions and 345 deletions

View File

@@ -12,17 +12,20 @@
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
*//*
package org.nl.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
*/
/**
* @author ZhangHouYing
* @date 2019-08-24 15:44
*/
*//*
@Configuration
public class WebSocketConfig {
@@ -31,3 +34,4 @@ public class WebSocketConfig {
return new ServerEndpointExporter();
}
}
*/

View File

@@ -1,40 +0,0 @@
package org.nl.modules.loki.rest;
import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.annotation.RateLimiter;
import org.nl.modules.loki.service.LokiService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
/**
* @Author: lyd
* @Description: 日志监控
* @Date: 2022-08-15
*/
@RestController
@RequiredArgsConstructor
@Api(tags = "日志监控")
@RequestMapping("/api/loki")
@Slf4j
public class LokiController {
private final LokiService lokiService;
@GetMapping("/labels/values")
@ApiOperation("获取标签")
public ResponseEntity<Object> labelsValues() {
return new ResponseEntity<>(lokiService.getLabelsValues(), HttpStatus.OK);
}
@PostMapping("/logs")
@ApiOperation("获取日志")
@RateLimiter(value = 1, timeout = 300) // 限流
public ResponseEntity<Object> getLogData(@RequestBody JSONObject json) {
return new ResponseEntity<>(lokiService.getLogData(json), HttpStatus.OK);
}
}

View File

@@ -1,25 +0,0 @@
package org.nl.modules.loki.service;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
/**
* @Author: lyd
* @Description: 服务类
* @Date: 2022-08-15
*/
public interface LokiService {
/**
* 获取日志信息
* @param json
* @return
*/
JSONObject getLogData(JSONObject json);
/**
* 获取labels和values树
* @return
*/
JSONArray getLabelsValues();
}

View File

@@ -1,113 +0,0 @@
package org.nl.modules.loki.service.impl;
import cn.hutool.core.util.CharsetUtil;
import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import org.nl.modules.loki.service.LokiService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
/**
* @Author: lyd
* @Description: 实现类
* @Date: 2022-08-15
*/
@Service
@RequiredArgsConstructor
public class LokiServiceImpl implements LokiService {
@Value("${loki.url}")
private String lokiUrl;
@Value("${loki.systemName}")
private String systemName;
@Override
public JSONObject getLogData(JSONObject json) {
String logLabel = "";
String logLabelValue = "";
Long start = 0L;
Long end = 0L;
String text = "";
String limit = "100";
String direction = "backward";
if (json.get("logLabel") != null) logLabel = json.getString("logLabel");
if (json.get("logLabelValue") != null) logLabelValue = json.getString("logLabelValue");
if (json.get("text") != null) text = json.getString("text");
if (json.get("start") != null) start = json.getLong("start");
if (json.get("end") != null) end = json.getLong("end");
if (json.get("limits") != null) limit = json.getString("limits");
if (json.get("direction") != null) direction = json.getString("direction");
/**
* 组织参数
* 纳秒数
* 1660037391880000000
* 1641453208415000000
* http://localhost:3100/loki/api/v1/query_range?query={host="localhost"} |= ``&limit=1500&start=1641453208415000000&end=1660027623419419002
*/
JSONObject parse = null;
String query = lokiUrl + "/query_range?query={system=\"" + systemName + "\", " + logLabel + "=\"" + logLabelValue + "\"} |= `" + text + "`";
String result = "";
if (start==0L) {
result = HttpUtil.get(query + "&limit=" + limit + "&direction=" + direction, CharsetUtil.CHARSET_UTF_8);
} else {
result = HttpUtil.get(query + "&limit=" + limit + "&start=" + start + "&end=" + end + "&direction=" + direction, CharsetUtil.CHARSET_UTF_8);
}
try {
parse = (JSONObject) JSONObject.parse(result);
} catch (Exception e) {
// reslut的值可能为:too many outstanding requests,无法转化成Json
System.out.println("reslut:" + result);
// e.printStackTrace();
}
return parse;
}
/**
* 获取labels和values树
*
* @return
*/
@Override
public JSONArray getLabelsValues() {
/**
* [{
* label:
* value:
* children:[{
* label
* value
* }]
* }]
*/
JSONArray result = new JSONArray();
// 获取所有标签
String labelString = HttpUtil.get(lokiUrl + "/labels", CharsetUtil.CHARSET_UTF_8);
JSONObject parse = (JSONObject) JSONObject.parse(labelString);
JSONArray labels = parse.getJSONArray("data");
for (int i=0; i<labels.size(); i++) {
// 获取标签下的所有值
String valueString = HttpUtil.get(lokiUrl + "/label/" + labels.getString(i) + "/values", CharsetUtil.CHARSET_UTF_8);
JSONObject parse2 = (JSONObject) JSONObject.parse(valueString);
JSONArray values = parse2.getJSONArray("data");
JSONArray children = new JSONArray();
// 组成树形状态 两级
for (int j=0; j<values.size(); j++) {
JSONObject leaf = new JSONObject();
leaf.put("label", values.getString(j));
leaf.put("value", values.getString(j));
children.add(leaf);
}
JSONObject node = new JSONObject();
node.put("label", labels.getString(i));
node.put("value", labels.getString(i));
node.put("children", children);
result.add(node);
}
return result;
}
}

View File

@@ -10,6 +10,7 @@ import org.nl.common.domain.query.PageQuery;
import org.nl.modules.logging.annotation.Log;
import org.nl.system.service.param.ISysParamService;
import org.nl.system.service.param.dao.Param;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.validation.annotation.Validated;
@@ -33,7 +34,6 @@ import java.util.Map;
@RequestMapping("/api/param")
@RequiredArgsConstructor
class SysParamController {
private final ISysParamService paramService;
@GetMapping
@Log("查询系统参数")

View File

@@ -39,19 +39,4 @@ public class QuartzConfig {
}
}
/**
* 注入scheduler到spring
* @param quartzJobFactory /
* @return Scheduler
* @throws Exception /
*/
@Bean(name = "scheduler")
public Scheduler scheduler(QuartzJobFactory quartzJobFactory) throws Exception {
SchedulerFactoryBean factoryBean=new SchedulerFactoryBean();
factoryBean.setJobFactory(quartzJobFactory);
factoryBean.afterPropertiesSet();
Scheduler scheduler=factoryBean.getScheduler();
scheduler.start();
return scheduler;
}
}

View File

@@ -21,8 +21,7 @@ import static org.quartz.TriggerBuilder.newTrigger;
@Component
public class QuartzManage {
private static final String JOB_NAME = "TASK_";
@Resource(name = "scheduler")
@Resource(name = "quartzScheduler")
private Scheduler scheduler;
public void addJob(SysQuartzJob quartzJob) {

View File

@@ -71,7 +71,7 @@ public class ProductionOutServiceImpl implements ProductionOutService {
* 生产区确认
* a.解锁出库点位、清除木箱号
*/
jsonPoint.put("point_status", "00");
jsonPoint.put("point_status", "1");
jsonPoint.put("lock_type", "1");
jsonPoint.put("vehicle_code", "");
jsonPoint.put("vehicle_type", "");

View File

@@ -263,6 +263,7 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
}
}
map.remove("tableData");
String currentUserId = SecurityUtils.getCurrentUserId();
String nickName = SecurityUtils.getCurrentNickName();
@@ -2536,9 +2537,12 @@ public class CheckOutBillServiceImpl implements CheckOutBillService {
JSONArray allRowArr = WQL.getWO("ST_OUTIVT04")
.addParam("flag", "1")
.addParam("iostorinvdtl_id", iostorinvdtl_id)
.addParam("iostorinv_id", iostorinv_id)
.process()
.getResultJSONArray(0);
if (ObjectUtil.isEmpty(allRowArr)) throw new BadRequestException("当前没有可设置的分配明细");
for (int i = 0; i < allRowArr.size(); i++) {
// 调用当前排处理方法
JSONObject jsonRow = allRowArr.getJSONObject(i);

View File

@@ -14,6 +14,7 @@
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.iostorinv_id TYPEAS s_string
输入.iostorinvdtl_id TYPEAS s_string
输入.block_num TYPEAS s_string
输入.row_num TYPEAS s_string
@@ -58,6 +59,10 @@
dis.iostorinvdtl_id = 输入.iostorinvdtl_id
ENDOPTION
OPTION 输入.iostorinv_id <> ""
dis.iostorinv_id = 输入.iostorinv_id
ENDOPTION
group by attr.block_num,attr.row_num
order by attr.row_num ASC