fix 工单操作 del loki
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
package org.nl.modules.loki.service.impl;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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 (ObjectUtil.isNotEmpty(json.get("logLabel"))) logLabel = json.getString("logLabel");
|
||||
if (ObjectUtil.isNotEmpty(json.get("logLabelValue"))) logLabelValue = json.getString("logLabelValue");
|
||||
if (ObjectUtil.isNotEmpty(json.get("text"))) text = json.getString("text");
|
||||
if (ObjectUtil.isNotEmpty(json.get("start"))) start = json.getLong("start");
|
||||
if (ObjectUtil.isNotEmpty(json.get("end"))) end = json.getLong("end");
|
||||
if (ObjectUtil.isNotEmpty(json.get("limits"))) limit = json.getString("limits");
|
||||
if (ObjectUtil.isNotEmpty(json.get("direction"))) 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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -39,7 +39,7 @@ public class MaterialDetailServiceImpl implements MaterialDetailService {
|
||||
@Override
|
||||
public Map<String, Object> queryAll(Map whereJson, Pageable page) {
|
||||
WQLObject wo = WQLObject.getWQLObject("md_me_material_detail");
|
||||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "1=1", "update_time desc");
|
||||
ResultBean rb = wo.pagequery(WqlUtil.getHttpContext(page), "is_delete = '0'", "update_time desc");
|
||||
final JSONObject json = rb.pageResult();
|
||||
return json;
|
||||
}
|
||||
|
||||
@@ -164,8 +164,13 @@ public class MaterialbaseServiceImpl implements MaterialbaseService {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
String ids_str = CommonUtils.idsArrayToInStr(ids);
|
||||
WQLObject.getWQLObject("md_me_materialbase").delete("material_id IN " + ids_str);
|
||||
WQLObject.getWQLObject("md_me_material_detail").delete("material_id IN " + ids_str);
|
||||
JSONObject material_update = new JSONObject();
|
||||
material_update.put("is_delete", "1");
|
||||
material_update.put("update_optid", SecurityUtils.getCurrentUserId());
|
||||
material_update.put("update_optname", SecurityUtils.getCurrentNickName());
|
||||
material_update.put("update_time", DateUtil.now());
|
||||
WQLObject.getWQLObject("md_me_materialbase").update(material_update, "material_id IN " + ids_str);
|
||||
WQLObject.getWQLObject("md_me_material_detail").update(material_update, "material_id IN " + ids_str);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -48,7 +48,7 @@
|
||||
FROM
|
||||
md_me_materialbase mb
|
||||
WHERE
|
||||
1 = 1
|
||||
is_delete = '0'
|
||||
OPTION 输入.search <> ""
|
||||
(
|
||||
mb.material_code like '%' 输入.search '%'
|
||||
|
||||
@@ -98,7 +98,7 @@ public class AcsToWmsController {
|
||||
@Log("排产单确认")
|
||||
@ApiOperation("排产单确认")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> sureProduceTask(@RequestBody Map whereJson) {
|
||||
public ResponseEntity<Object> sureProduceTask(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(acsToWmsService.sureWorkOrder(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public interface AcsToWmsService {
|
||||
* @param whereJson
|
||||
* @return
|
||||
*/
|
||||
Map<String, Object> sureWorkOrder(Map whereJson);
|
||||
Map<String, Object> sureWorkOrder(JSONObject whereJson);
|
||||
|
||||
/**
|
||||
* 根据木托盘类型获取对应所在的点位
|
||||
|
||||
@@ -544,12 +544,12 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String, Object> sureWorkOrder(Map jsonObject) {
|
||||
String type = (String) jsonObject.get("type");
|
||||
public Map<String, Object> sureWorkOrder(JSONObject jsonObject) {
|
||||
String type = jsonObject.getString("type");
|
||||
if (StrUtil.isEmpty(type)) {
|
||||
throw new BadRequestException("类型不能为空!");
|
||||
}
|
||||
String workorder_code = (String) jsonObject.get("workorder_code");
|
||||
String workorder_code = jsonObject.getString("workorder_code");
|
||||
if (StrUtil.isEmpty(type)) {
|
||||
throw new BadRequestException("工单编码不能为空!");
|
||||
}
|
||||
@@ -563,11 +563,12 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
if (workorder.getIntValue("order_status") < 3) {
|
||||
workorder.put("order_status", WorkOrderEnum.ORDER_STATUS_PRODUCING.value());
|
||||
workorder.put("realproducestart_date", DateUtil.now());
|
||||
TaskUtils.addACSUpdateColum(workorder);
|
||||
workorder_table.update(workorder);
|
||||
}
|
||||
} else if ("2".equals(type)) {
|
||||
// 工单完成
|
||||
String qty = (String) jsonObject.get("qty");
|
||||
String qty = jsonObject.getString("qty");
|
||||
if (StrUtil.isBlank(qty)) {
|
||||
throw new BadRequestException("数量不能为空!");
|
||||
}
|
||||
@@ -575,11 +576,11 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
if (workorder.getIntValue("order_status") < 5) {
|
||||
workorder.put("order_status", WorkOrderEnum.ORDER_STATUS_FINISH.value());
|
||||
workorder.put("real_qty", qty);
|
||||
String unqualified_qty = (String) jsonObject.get("unqualified_qty");
|
||||
String unqualified_qty = jsonObject.getString("unqualified_qty");
|
||||
if (StrUtil.isNotBlank(unqualified_qty) && !"0".equals(unqualified_qty)) {
|
||||
workorder.put("unqualified_qty", unqualified_qty);
|
||||
}
|
||||
String qualified_qty = (String) jsonObject.get("qualified_qty");
|
||||
String qualified_qty = jsonObject.getString("qualified_qty");
|
||||
if (StrUtil.isNotBlank(qualified_qty) && !"0".equals(qualified_qty)) {
|
||||
workorder.put("qualified_qty", qualified_qty);
|
||||
} else {
|
||||
@@ -587,6 +588,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
}
|
||||
|
||||
workorder.put("realproduceend_date", DateUtil.now());
|
||||
TaskUtils.addACSUpdateColum(workorder);
|
||||
workorder_table.update(workorder);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.modules.common.exception.BadRequestException;
|
||||
import org.nl.modules.common.utils.CommonUtils;
|
||||
import org.nl.modules.common.utils.SecurityUtils;
|
||||
import org.nl.modules.wql.WQL;
|
||||
import org.nl.modules.wql.core.bean.WQLObject;
|
||||
@@ -119,10 +120,8 @@ public class DeviceServiceImpl implements DeviceService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteAll(Long[] ids) {
|
||||
WQLObject wo = WQLObject.getWQLObject("pdm_bi_device");
|
||||
for (Long device_id : ids) {
|
||||
wo.delete("device_id = '" + device_id + "'");
|
||||
}
|
||||
String s = CommonUtils.idsArrayToInStr(ids);
|
||||
WQLObject.getWQLObject("pdm_bi_device").delete("device_id IN " + s);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,9 @@ import org.nl.wms.basedata.eum.VehicleType;
|
||||
import org.nl.wms.ext.acs.service.WmsToAcsService;
|
||||
import org.nl.wms.pdm.service.WorkordeService;
|
||||
import org.nl.wms.pdm.service.dto.WorkorderDto;
|
||||
import org.nl.wms.sch.manage.Region;
|
||||
import org.nl.wms.sch.manage.WorkOrderEnum;
|
||||
import org.nl.wms.sch.task.util.TaskUtils;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -31,6 +33,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static cn.hutool.db.sql.SqlExecutor.query;
|
||||
|
||||
/**
|
||||
* @author qinx
|
||||
* @description 服务实现
|
||||
@@ -111,12 +115,14 @@ public class WorkorderServiceImpl implements WorkordeService {
|
||||
work_order.put("planproducestart_date", dto.getPlanproducestart_date());
|
||||
work_order.put("planproduceend_date", dto.getPlanproduceend_date());
|
||||
work_order.put("material_id", dto.getMaterial_id());
|
||||
String device_code = dto.getDevice_code();
|
||||
Long device_id = dto.getDevice_id();
|
||||
JSONObject device = WQLObject.getWQLObject("pdm_bi_device").query("device = " + device_id).uniqueResult(0);
|
||||
String device_region_code = device.getString("region_code");
|
||||
String vehicle_type = dto.getVehicle_type();
|
||||
if (!device_code.startsWith("FJ")) {
|
||||
if (device_code.startsWith("YJ")) {
|
||||
if (!Region.FJ.value().equals(device_region_code)) {
|
||||
if (Region.YZ.value().equals(device_region_code)) {
|
||||
vehicle_type = VehicleType.STEEL_TRAY.value();
|
||||
} else if (device_code.startsWith("HL")) {
|
||||
} else if (Region.HL.value().equals(device_region_code)) {
|
||||
vehicle_type = VehicleType.CUP.value();
|
||||
}
|
||||
}
|
||||
@@ -404,29 +410,32 @@ public class WorkorderServiceImpl implements WorkordeService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finish(JSONObject param) {
|
||||
Long currentUserId = SecurityUtils.getCurrentUserId();
|
||||
String nickName = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
JSONObject row = param.getJSONObject("row");
|
||||
String workorder_id = row.getString("workorder_id");
|
||||
WQLObject wo = WQLObject.getWQLObject("PDM_BD_WORKORDER");
|
||||
JSONObject produceorderMap = new JSONObject();
|
||||
produceorderMap.put("workorder_id",workorder_id);
|
||||
produceorderMap.put("order_status","5");
|
||||
produceorderMap.put("update_optid", currentUserId);
|
||||
produceorderMap.put("device_id", null);
|
||||
produceorderMap.put("update_optname", nickName);
|
||||
produceorderMap.put("update_time", now);
|
||||
produceorderMap.put("realproduceend_date", now);
|
||||
wo.update(produceorderMap);
|
||||
//wms向acs发送请求 工单强制完成
|
||||
// TODO
|
||||
JSONArray array = new JSONArray();
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("ext_order_id",workorder_id);
|
||||
map.put("type","3");
|
||||
array.add(map);
|
||||
wmsToAcsService.orderStatusUpdate(array);
|
||||
String workorder_id = param.getString("workorder_id");
|
||||
WQLObject workorder_table = WQLObject.getWQLObject("pdm_bd_workorder");
|
||||
JSONObject workorder = workorder_table.query("workorder_id = " + workorder_id).uniqueResult(0);
|
||||
|
||||
if (workorder.getIntValue("order_status") < 5) {
|
||||
workorder.put("order_status", WorkOrderEnum.ORDER_STATUS_FINISH.value());
|
||||
String qty = param.getString("qty");
|
||||
if (StrUtil.isBlank(qty)) {
|
||||
throw new BadRequestException("数量不能为空!");
|
||||
}
|
||||
workorder.put("real_qty", qty);
|
||||
String unqualified_qty = param.getString("unqualified_qty");
|
||||
if (StrUtil.isNotBlank(unqualified_qty) && !"0".equals(unqualified_qty)) {
|
||||
workorder.put("unqualified_qty", unqualified_qty);
|
||||
}
|
||||
String qualified_qty = param.getString("qualified_qty");
|
||||
if (StrUtil.isNotBlank(qualified_qty) && !"0".equals(qualified_qty)) {
|
||||
workorder.put("qualified_qty", qualified_qty);
|
||||
} else {
|
||||
workorder.put("qualified_qty", Integer.parseInt(qty) - workorder.getIntValue("unqualified_qty"));
|
||||
}
|
||||
|
||||
workorder.put("realproduceend_date", DateUtil.now());
|
||||
TaskUtils.addCurrentUpdateColum(workorder);
|
||||
workorder_table.update(workorder);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Binary file not shown.
@@ -158,7 +158,3 @@ sa-token:
|
||||
jwt-secret-key: opsjajisdnnca0sdkksdfaaasdfwwq
|
||||
# token 前缀
|
||||
token-prefix: Bearer
|
||||
|
||||
loki:
|
||||
url: http://192.168.4.220:3100/loki/api/v1
|
||||
systemName: lms
|
||||
|
||||
@@ -2,7 +2,7 @@ spring:
|
||||
freemarker:
|
||||
check-template-location: false
|
||||
profiles:
|
||||
active: dev
|
||||
active: prod
|
||||
jackson:
|
||||
time-zone: GMT+8
|
||||
data:
|
||||
|
||||
Reference in New Issue
Block a user