opt:acs标准版无效代码删减

This commit is contained in:
2026-03-30 14:35:19 +08:00
parent 0cbba7e8e3
commit 718c51331c
75 changed files with 3 additions and 7178 deletions

View File

@@ -12,7 +12,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.agv.xg_agv_car.XgAgvCarDeviceDriver;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.opc.DeviceAppService;
@@ -85,13 +84,6 @@ public class QueryAGVStatus {
taskService.update(task);
if (StrUtil.isNotEmpty(instructionCode)) {
Device carCode = deviceAppService.findDeviceByCode(instructionCode);
XgAgvCarDeviceDriver xgAgvCarDeviceDriver;
if (null != carCode) {
if (carCode.getDeviceDriver() instanceof XgAgvCarDeviceDriver) {
xgAgvCarDeviceDriver = (XgAgvCarDeviceDriver) carCode.getDeviceDriver();
xgAgvCarDeviceDriver.setTaskType(AgvActionTypeEnum.getStatus(instruction.getAgv_action_type()));
}
}
}
}

View File

@@ -1,33 +0,0 @@
package org.nl.acs.agv.rest;
import cn.dev33.satoken.annotation.SaIgnore;
import com.alibaba.fastjson.JSONObject;
import groovy.lang.Lazy;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.common.logging.annotation.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author 20220102CG\noblelift
*/
@Controller
public class XianGongAgvController {
@Lazy
@Autowired
private XianGongAgvService xianGongAgentService;
@PostMapping("/api/agv/xg/waitPointRequest")
@Log("仙工AGV请求取放货")
@SaIgnore
public ResponseEntity<JSONObject> xgAGVWaitPointRequest(@RequestBody JSONObject requestParam) {
return new ResponseEntity<>(xianGongAgentService.xgAGVWaitPointRequest(requestParam), HttpStatus.OK);
}
}

View File

@@ -1,7 +0,0 @@
package org.nl.acs.agv.rest;
/**
* @author 20220102CG\noblelift
*/
public class ZheDaAgvController {
}

View File

@@ -1,129 +0,0 @@
package org.nl.acs.agv.server;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.agv.server.dto.AgvDto;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.dto.InteractionJsonDTO;
import java.util.Map;
/**
* @Author: lyd
* @Description:
* @Date: 2022-08-15
*/
public interface XianGongAgvService {
/**
* 查询所有AGV
* @return
*/
Map<String, AgvDto> findAllAgvFromCache();
/**
* 查询自动门状态
*
* @param device
* @return
*/
public String queryDoorStatus(String device);
/**
* 先工agv 等待点请求
* AGV->ACS
* @param param
* @return
*/
public String waitPointRequest(String param);
/**
* acs->agv
* 关闭运单系列
*
* @param code
* @return
* @throws Exception
*/
public HttpResponse markComplete(String code) throws Exception;
/**
* 查询AGV状态
*
* @return
*/
public HttpResponse queryXZAgvDeviceStatus();
/**
* 查询AGV任务状态
* @param instCode
* @return
*/
public HttpResponse queryXZAgvInstStatus(String instCode);
/**
* 删除先知任务
*
* @param instCode
* @return
*/
public HttpResponse deleteXZAgvInst(String instCode);
/**
* 下发运单序列
*
* @param inst
* @return
* @throws Exception
*/
public HttpResponse sendOrderSequencesToXZ(Instruction inst) throws Exception;
/**
* 追加运单
* @param inst
* @return
* @throws Exception
*/
public HttpResponse addOrderSequences(Instruction inst) throws Exception;
/**
* 组织json数据
* @param inst
* @return
* @throws Exception
*/
public String sendOrderSequencesParam(Instruction inst) throws Exception;
/**
* 创建
* @param inst
* @param type
* @return
*/
public JSONObject createOrederData(Instruction inst, String type);
/**
* 请求取货放货
* @param requestParam
* @return
*/
JSONObject xgAGVWaitPointRequest(JSONObject requestParam);
/**
* 查询场景中指定机器人信息
*/
HttpResponse getRobotInfo(String robotCode);
/**
* 下发叉车运单
*
* @param dto
* @param interactionJsonDTO
* @return
*/
HttpResponse sendOrderSequencesToForklift(Instruction dto, InteractionJsonDTO interactionJsonDTO);
}

View File

@@ -1,50 +0,0 @@
package org.nl.acs.agv.server;
import cn.hutool.http.HttpResponse;
import org.nl.acs.instruction.domain.Instruction;
/**
* 浙大AGV服务
* @author 20220102CG\noblelift
*/
public interface ZheDaAgvService {
/**
* 下发指令
*
* @param inst 指令对象
* @return
* @throws Exception
*/
public HttpResponse sendAgvInstToAgv(Instruction inst) throws Exception;
/**
* 查询AGV状态
* 永裕家居项目:共两楼
*
* @param floor 1、二楼AGV系统2、一楼AGV系统
* @return
*/
public HttpResponse queryAgvInstStatus(String floor);
/**
* AGV任务处理
* @param jobno
* @param type
* @param address
* @param action
* @param processingVehicle
* @return
*/
String process(String jobno, String type, String address, String action, String processingVehicle);
/**
* 标记完成
*
* @param code
* @return
*/
public HttpResponse markComplete(String code);
}

View File

@@ -1,442 +0,0 @@
package org.nl.acs.agv.server.impl;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.AgvUtil;
import org.nl.acs.agv.server.ZheDaAgvService;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.system.service.param.ISysParamService;
import org.nl.config.SpringContextHolder;
import org.springframework.stereotype.Service;
/**
* @author 20220102CG\noblelift
*/
@Slf4j
@Service
@RequiredArgsConstructor
public class ZheDaAgvServiceImpl implements ZheDaAgvService {
private final ISysParamService paramService;
/**
* 判断是否追加任务
*/
private static final String THREE = "3";
private static final String FOUR = "4";
private static final String FIVE = "5";
/**
* 取货的进入前等待和离开等待
*/
private static final String LOAD = "load";
/**
* 取货的进入前等待和离开等待
*/
private static final String ENTRY_REQUIRED = "EntryRequired";
private static final String ENTRYREQUIRED = "entryRequired";
private static final String PAUSE_ON_STATION = "PauseOnStation";
/**
* 等待点等待
*/
private static final String WAIT = "Wait";
/**
* 放货的进入前等待和离开等待
*/
private static final String UNLOAD = "Unload";
@Override
public HttpResponse sendAgvInstToAgv(Instruction inst) throws Exception {
JSONObject jo = new JSONObject();
String start_point_code = inst.getStart_point_code();
String next_point_code = inst.getNext_point_code();
//1楼AGV普通任务
//2楼AGV普通任务
//2楼AGV起点追加任务
//2楼AGV终点追加任务
String task_type = inst.getInstruction_type();
jo.put("deadline", AgvUtil.getNextDay(1));
//判断是否追加任务
if (THREE.equals(task_type) || FOUR.equals(task_type)) {
jo.put("complete", "false");
} else {
jo.put("complete", "true");
}
jo.put("task_code", inst.getInstruction_code());
//根据任务,下发指令类型
JSONArray destinations = new JSONArray();
if (THREE.equals(task_type)) {
destinations.add(destination(start_point_code, "Wait", "5", CommonFinalParam.ONE));
} else if (FOUR.equals(task_type)) {
destinations.add(destination(start_point_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE));
destinations.add(destination(next_point_code, "Wait", "5", CommonFinalParam.ONE));
} else {
destinations.add(destination(start_point_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE));
destinations.add(destination(next_point_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE));
}
jo.put("destinations", destinations);
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvurl2 = paramService.findByCode(AcsConfig.AGVURL2).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
String agvport2 = paramService.findByCode(AcsConfig.AGVPORT2).getValue();
//不同楼层下发不同的agv系统
if (CommonFinalParam.ONE.equals(task_type)) {
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + inst.getInstruction_code();
} else {
agvurl = agvurl2 + ":" + agvport2 + "/v1/transportOrders/" + inst.getInstruction_code();
}
log.info("下发agv任务请求:{}", agvurl);
HttpResponse result = HttpRequest.post(agvurl)
//表单内容
.body(String.valueOf(jo))
//超时,毫秒
.timeout(20000)
.execute();
log.info("下发agv任务请求反馈:{}", result);
return result;
} else {
return null;
}
}
/**
* ZDAGV
* @param type
* @return
*/
@Override
public HttpResponse queryAgvInstStatus(String type) {
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
String agvurl = "";
String agvport = "";
if (CommonFinalParam.ONE.equals(type)) {
agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
}
if (CommonFinalParam.TWO.equals(type)) {
agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue();
agvport = paramService.findByCode(AcsConfig.AGVPORT2).getValue();
}
agvurl = agvurl + ":" + agvport + "/v1/transportOrders";
HttpResponse result = HttpRequest.get(agvurl)
//超时,毫秒
.timeout(20000)
.execute();
System.out.println("查询agv指令数据:" + result.body());
return result;
} else {
return null;
}
}
/**
* 处理AGV指令 ZDAGV
*
* @param jobno
* @param type
* @param address
* @param action
* @param processingVehicle
* @return
*/
@Override
public synchronized String process(String jobno, String type, String address, String action, String processingVehicle) {
log.info("查询到AGV请求参数,jobno:{},address:{}", jobno + ",address:" + address + ",type:" + type + ",action:" + action);
//释放AGV资源继续后续动作
boolean is_feedback = false;
String str = "";
String backaddress = address;
if (address.indexOf(CommonFinalParam.DOT) > 0) {
str = address.substring(address.indexOf(".") + 1, address.length());
address = address.substring(0, address.indexOf("."));
} else if (address.indexOf(CommonFinalParam.HYPHEN_) > 0) {
address = address.substring(0, address.indexOf("-"));
}
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
TaskService taskService = SpringContextHolder.getBean("taskServiceImpl");
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
Instruction inst = instructionService.findByCodeFromCache(jobno);
TaskDto task = taskService.findByCode(inst.getTask_code());
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class);
Device addressdevice = appService.findDeviceByCode(address);
//等待点等待
if (WAIT.equals(action)) {
if (WAIT.equals(type)) {
JSONObject jo = new JSONObject();
jo.put("task_code", inst.getInstruction_code());
JSONArray destinations = new JSONArray();
String inst_type = inst.getInstruction_type();
//如果任务类型为1在点位进行等待则查询当前叠盘位的数量取当前数量的层数进行追加任务
// if (CommonFinalParam.ONE.equals(inst_type)) {
// emptyVehicleStackingPositionDeviceDriver = (EmptyVehicleStackingPositionDeviceDriver) addressdevice.getDeviceDriver();
// int current_num = emptyVehicleStackingPositionDeviceDriver.getNumber();
// if (current_num > 12) {
// log.info("当前叠盘架:" + jobno + "已放满!");
// return null;
// }
// String start_point_code = inst.getStart_point_code();
// String next_point_code = inst.getNext_point_code();
// start_point_code = start_point_code + "." + (current_num + 1);
// destinations.add(destination(start_point_code, "Load", CommonFinalParam.ONE, CommonFinalParam.ONE));
// destinations.add(destination(next_point_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE));
//
// }
// String resp = acsToWmsService.requestTaskAgain(address, task.getExt_task_id(), inst.getVehicle_code());
JSONObject respjson = JSONObject.parseObject("");
if (StrUtil.equals(inst.getInstruction_type(), THREE)) {
//2楼AGV起点追加任务
String start_device_code = respjson.getString("device_code");
String next_device_code = inst.getNext_device_code();
destinations.add(destination(start_device_code, "load", CommonFinalParam.ONE, CommonFinalParam.ONE));
destinations.add(destination(next_device_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE));
} else if (StrUtil.equals(inst.getInstruction_type(), FOUR)) {
//2楼AGV终点追加任务
String next_device_code = respjson.getString("device_code");
destinations.add(destination(next_device_code, "Unload", CommonFinalParam.ONE, CommonFinalParam.ONE));
}
jo.put("destinations", destinations);
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
String url = agvurl + ":" + agvport + "/addDestinations";
log.info("下发agv任务请求:{}", url);
HttpResponse result = HttpRequest.post(url)
//表单内容
.body(String.valueOf(jo))
//超时,毫秒
.timeout(20000)
.execute();
log.info("下发agv任务请求反馈:{}", result);
//对任务进行封口
JSONObject complete = new JSONObject();
complete.put("task_code", inst.getInstruction_code());
String url2 = agvurl + ":" + agvport + "markComplete";
log.info("下发agv任务请求:{}", url2);
HttpResponse result2 = HttpRequest.post(url2)
//表单内容
.body(String.valueOf(complete))
//超时,毫秒
.timeout(20000)
.execute();
log.info("下发agv任务请求反馈:{}", result2);
}
}
JSONObject requestjo = new JSONObject();
if (is_feedback) {
requestjo.put("task_code", jobno);
requestjo.put("operation", action);
if (ENTRYREQUIRED.equals(type) || ENTRY_REQUIRED.equals(type)) {
requestjo.put("entryRequired", "true");
} else {
requestjo.put("pauseOnStation", "true");
}
log.info("反馈AGV请求数据:{}", requestjo);
System.out.println("back agv:" + requestjo);
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
if (FOUR.equals(inst.getInstruction_type())) {
agvurl = paramService.findByCode(AcsConfig.AGVURL2).getValue();
}
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + jobno + "/interact";
HttpResponse result = HttpRequest.post(agvurl)
.body(String.valueOf(requestjo))
//超时,毫秒
.timeout(20000)
.execute();
}
return requestjo.toString();
}
@Override
public HttpResponse markComplete(String code) {
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), CommonFinalParam.ONE)) {
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
agvurl = agvurl + ":" + agvport + "/v1/" + code + "/markComplete";
log.info("关闭agv运单序列请求:{}", agvurl);
HttpResponse result = HttpRequest.post(agvurl)
//.body(String.valueOf(orderjo))//表单内容
//超时,毫秒
.timeout(20000)
.execute();
log.info("关闭agv运单序列请求反馈:{}", result);
return result;
} else {
return null;
}
}
/**
* 返回一个点位操作子任务 ZDAGV
*
* @param locationName 点位
* @param operation 点位操作
* @param propertiesType 子任务类型
* @param pro 子任务参数
* 调用demo:destination("sh15p", "Spin", CommonFinalParam.TWO, "3.14")
* demo:destination("cz14", "JackUnload", "3", "")
* @return
*/
public static JSONObject destination(String locationName, String operation, String propertiesType, String pro) {
//新增业务订单
JSONObject destinationOrder = new JSONObject();
//目标工作站
destinationOrder.put("locationName", locationName);
//机器人在工作站要执行的操作
destinationOrder.put("operation", operation);
//取货前等待、取货后等待
if (CommonFinalParam.ONE.equals(propertiesType)) {
//pro 1 进入离开等待
if (CommonFinalParam.ONE.equals(pro)) {
JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject();
pro1.put("key", "EntryRequired");
pro1.put("value", "True");
properties.add(pro1);
JSONObject pro2 = new JSONObject();
pro2.put("key", "PauseOnStation");
pro2.put("value", "True");
properties.add(pro2);
destinationOrder.put("properties", properties);
//进入等待 离开不等待
} else if (CommonFinalParam.TWO.equals(pro)) {
JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject();
pro1.put("key", "EntryRequired");
pro1.put("value", "True");
properties.add(pro1);
JSONObject pro2 = new JSONObject();
pro2.put("key", "PauseOnStation");
pro2.put("value", "False");
properties.add(pro2);
destinationOrder.put("properties", properties);
//进入不等待 离开等待
} else if (THREE.equals(pro)) {
JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject();
pro1.put("key", "EntryRequired");
pro1.put("value", "False");
properties.add(pro1);
JSONObject pro2 = new JSONObject();
pro2.put("key", "PauseOnStation");
pro2.put("value", "True");
properties.add(pro2);
destinationOrder.put("properties", properties);
//不等待
} else {
JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject();
pro1.put("key", "EntryRequired");
pro1.put("value", "False");
properties.add(pro1);
JSONObject pro2 = new JSONObject();
pro2.put("key", "PauseOnStation");
pro2.put("value", "False");
properties.add(pro2);
destinationOrder.put("properties", properties);
}
//Spin转动
} else if (CommonFinalParam.TWO.equals(propertiesType)) {
JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject();
//坐标系类型global_spin_angle为全局坐标系
pro1.put("key", "global_spin_angle");
//弧度值如3.14
pro1.put("value", pro);
properties.add(pro1);
JSONObject pro2 = new JSONObject();
//固定值
pro2.put("key", "spin_direction");
//弧度值如0
pro2.put("value", "0");
properties.add(pro2);
destinationOrder.put("properties", properties);
//JackUnload,Jackload不操作
} else if (THREE.equals(propertiesType)) {
JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject();
//固定值
pro1.put("key", "recognize");
//固定值
pro1.put("value", "false");
properties.add(pro1);
destinationOrder.put("properties", properties);
} else if (FOUR.equals(propertiesType)) {
JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject();
//坐标系类型robot_spin_angle为机器人坐标系
pro1.put("key", "robot_spin_angle");
//弧度值如3.14
pro1.put("value", pro);
properties.add(pro1);
JSONObject pro2 = new JSONObject();
//固定值
pro2.put("key", "spin_direction");
//弧度值如0
pro2.put("value", "0");
properties.add(pro2);
destinationOrder.put("properties", properties);
//在该点进行等待
} else if (FIVE.equals(propertiesType)) {
JSONArray properties = new JSONArray();
JSONObject pro1 = new JSONObject();
pro1.put("key", "Wait");
pro1.put("value", "True");
properties.add(pro1);
destinationOrder.put("properties", properties);
}
return destinationOrder;
}
}

View File

@@ -1,11 +0,0 @@
package org.nl.acs.device_driver;
import com.alibaba.fastjson.JSONObject;
/**
* @author: geng by
* @createDate: 2023/4/21
*/
public interface FeedLmsRealFailed {
public JSONObject feedLmsRealFailedInfo();
}

View File

@@ -1,14 +0,0 @@
package org.nl.acs.device_driver;
public interface HeartbeatableDeviceDriver extends DeviceDriver {
default void checkHeartbeat() {
}
/**
* isOnline
* @return
*/
default boolean isOnline() {
return false;
}
}

View File

@@ -1,16 +0,0 @@
package org.nl.acs.device_driver;
import java.util.List;
public interface LinewayDeviceDriver extends DeviceDriver {
List<String> getRelatedDevices();
String getRelatedStacker();
int getMaxColumn();
int getMinColumn();
boolean getDirector();
}

View File

@@ -1,20 +0,0 @@
package org.nl.acs.device_driver;
public interface ScannerDeviceDriver extends DeviceDriver {
/**
* writeBarcode
* @param var1
*/
void writeBarcode(String var1);
/**
* cleanBarcode
*/
void cleanBarcode();
/**
* readBarcode
* @return
*/
String readBarcode();
}

View File

@@ -1,149 +0,0 @@
package org.nl.acs.device_driver;
public interface StandardRequestMethod {
/**
* 人工排产确认
*
* @return
*/
public default boolean order_verify() {
throw new RuntimeException("未实现");
}
;
/**
* 工单完成
*
* @return
*/
public default boolean order_finish() {
throw new RuntimeException("未实现");
}
;
/**
* 申请补满料盅托盘
*
* @return
*/
public default boolean apply_put_full_vehicle() {
throw new RuntimeException("未实现");
}
;
/**
* 申请补空料盅托盘
*
* @return
*/
public default boolean apply_put_empty_vehicle() {
throw new RuntimeException("未实现");
}
;
/**
* 申请取走空料盅托盘
*
* @return
*/
public default boolean apply_take_empty_vehicle() {
throw new RuntimeException("未实现");
}
;
/**
* 申请取走满料盅托盘(入库)
*
* @return
*/
public default boolean apply_take_full_vehicle() {
throw new RuntimeException("未实现");
}
;
/**
* 申请强制取走满料盅托盘
*
* @return
*/
public default boolean apply_force_take_full_vehicle() {
throw new RuntimeException("未实现");
}
;
/**
* 申请强制满托入缓存
*
* @return
*/
public default boolean apply_force_take_full_vehicle_in_storage() {
throw new RuntimeException("未实现");
}
;
/**
* 扫码成功申请
*
* @return
*/
public default boolean barcode_success_apply() {
throw new RuntimeException("未实现");
}
;
/**
* 获取组盘信息
*
* @return
*/
public default boolean get_vehicle_info() {
throw new RuntimeException("未实现");
}
;
/**
* 强制去包装位-不包装
*
* @return
*/
public default boolean force_no_package() {
throw new RuntimeException("未实现");
}
;
/**
* 申请贴标
*
* @return
*/
public default boolean apply_labelling() {
throw new RuntimeException("未实现");
}
;
/**
* 压机叫料
*
* @return
*/
public default boolean press_request_material() {
throw new RuntimeException("未实现");
}
;
}

View File

@@ -1,54 +0,0 @@
package org.nl.acs.device_driver;
import java.util.ArrayList;
import java.util.List;
public interface StorageDeviceDriver extends DeviceDriver {
/**
* getConfigForbidFront
* @return
*/
default List<Integer> getConfigForbidFront() {
return new ArrayList();
}
/**
* getConfigCantFront
* @return
*/
default List<Integer> getConfigCantFront() {
return new ArrayList();
}
/**
* getConfigCantBack
* @return
*/
default List<Integer> getConfigCantBack() {
return new ArrayList();
}
/**
* getConfigForbidFrontLocation
* @return
*/
default List<String> getConfigForbidFrontLocation() {
return new ArrayList();
}
/**
* getConfigCantFrontLocation
* @return
*/
default List<String> getConfigCantFrontLocation() {
return new ArrayList();
}
/**
* getConfigCantBackLocation
* @return
*/
default List<String> getConfigCantBackLocation() {
return new ArrayList();
}
}

View File

@@ -1,49 +0,0 @@
package org.nl.acs.device_driver.agv.xg_agv_car;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device.enums.DeviceType;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.DeviceDriverDefination;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* 仙工AGV
*/
@Service
public class XgAgvCarDefination implements DeviceDriverDefination {
@Override
public String getDriverCode() {
return "xg_agv_car";
}
@Override
public String getDriverName() {
return "仙工AGV车";
}
@Override
public String getDriverDescription() {
return "仙工AGV车";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new XgAgvCarDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return XgAgvCarDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.agv);
return types;
}
}

View File

@@ -1,310 +0,0 @@
package org.nl.acs.device_driver.agv.xg_agv_car;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.service.DeviceService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.opc.DeviceAppService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.config.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Map;
/**
* 仙工AGV
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class XgAgvCarDeviceDriver extends AbstractDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor {
@Autowired
DeviceAppService deviceAppservice = SpringContextHolder.getBean(DeviceAppService.class);
@Autowired
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl");
@Autowired
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl");
@Autowired
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl");
@Autowired
TaskService taskserver = SpringContextHolder.getBean("taskServiceImpl");
@Autowired
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@Autowired
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
@Autowired
XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class);
Integer hasGoods = 0;
int error = 0;
Boolean iserror = false;
Boolean islock = false;
int branchProtocol = 0;
int last_branchProtocol = 0;
/**
* 是否需要输入物料
*/
String input_material = "0";
/**
* 备注
*/
String remark = "";
/**
* 数量
*/
String qty = "";
/**
* 批次
*/
String batch = "";
/**
* 物料
*/
String material = "";
/**
* 目标点位
*/
String purpose = "";
/**
* 当前指令
*/
Instruction inst = null;
/**
* 上次指令
*/
Instruction last_inst = null;
boolean requireSucess = false;
/**
* 触摸屏手动触发任务
*/
private Boolean is_has_task = false;
/**
* 申请搬运任务
*/
private Boolean apply_handling = false;
/**
* 申请物料
*/
private Boolean apply_material = false;
/**
* 1取货完成 2放货完成 3进入区域 4离开区域
*/
private int flag;
/**
* 人工确认信号 默认0 agv到达后请求置1 等人工确认后变为2 反馈agv后继续为0
*/
private int manua_confirm = 0;
/**
* 是否推送场景的状态 0=可推送 1=正在更新场景 2=正在执行运单
*/
private String upload_scene_status = "";
/**
* 机器人当前运单
*/
private String current_order = "";
/**
* 机器人连接状态 0表示断连 1表示连接上
*/
private String connection_status = "";
/**
* 机器人可接单状态 true=可接单 false=不可接单
*/
private boolean dispatchable = false;
/**
* core出错标识
*/
private boolean is_error = false;
/**
* 是否正在执行用户下发的运单
*/
private boolean procBusiness = false;
/**
* 机器人当前地图不在场景中
*/
private boolean current_map_invalid = false;
/**
* 机器人是否断连
*/
private boolean disconnect = false;
/**
* 1 = api 设置可接单2 = api 设置不可接单(小车占用资源) 3 = api 设置不可接单(小车不占用资源)
*/
private int dispatchable_status = 0;
/**
* 低电量
*/
private boolean low_battery = false;
/**
* 暂停运单
*/
private boolean suspended = false;
/**
* 未确认定位
*/
private boolean unconfirmed_reloc = false;
/**
* 0: 控制权在core手上 1; 控制权被其他人抢走; 2: 控制权没有被抢占
*/
private int unlock = 0;
/**
* agv二次分配类型1、普通任务 2、取货二次分配 3、防货二次分配 4、取放货二次分配
*/
private String taskType = "";
String device_code = null;
String container;
String container_type_desc;
String last_container_type_desc;
String last_container;
private Date instruction_require_time = new Date();
private Date instruction_finished_time = new Date();
private int instruction_require_time_out;
String message;
// 1 上位系统允许进入 2 上位系统允许离开
int status = 0;
int agvphase = 0;
int index = 0;
int mode = 2;
int move;
@Override
public void execute() {
try {
// getAgvStatus();
} catch (Exception e) {
message = "获取机器人状态报错";
}
}
@Override
public JSONObject getDeviceStatusName() {
Map<String, Object> map = new LinkedHashMap<>();
// try {
// getAgvStatus();
// } catch (Exception e) {
// message = "获取机器人状态报错";
// }
String isError;
if (is_error) {
isError = "出错,不执行任何运单";
} else {
isError = "正常";
}
if (CommonFinalParam.ONE.equals(upload_scene_status)) {
upload_scene_status = "正在更新场景";
} else if (CommonFinalParam.TWO.equals(upload_scene_status)) {
upload_scene_status = "正在执行运单";
} else if (CommonFinalParam.DELETE.equals(upload_scene_status)) {
upload_scene_status = "可推送";
}
map.put("errors", isError);
map.put("upload_scene_status", upload_scene_status);
map.put("procBusiness", procBusiness ? "": "");
// map.put("current_order", current_order);
map.put("connection_status", "1".equals(connection_status) ? "连接上" : "断连");
map.put("dispatchable", dispatchable ? "可接单" : "不可接单");
map.put("dispatchable_status", dispatchable_status == 1?"设置可接单" : dispatchable_status == 2?"设置不可接单(小车占用资源)" : dispatchable_status == 3?"设置不可接单(小车不占用资源)" : "未知");
map.put("current_map_invalid", current_map_invalid ? "机器人不在地图场景中": "机器人在地图场景中");
map.put("disconnect", disconnect ? "机器人断连" : "机器人连接上");
map.put("low_battery", low_battery ? "低电量": "正常");
map.put("suspended", suspended ? "订单被暂停,需要人工手动恢复": "正常");
map.put("message", message);
map.put("agv_task_type", taskType);
map.put("unconfirmed_reloc", unconfirmed_reloc ? "未确认定位" : "正常");
map.put("unlock", unlock == 0 ? "控制权在core手上" : unlock == 1 ? "控制权被其他人抢走" : unlock == 2 ? "控制权没有被抢占" : "未知");
map.put("move_2","有货");
JSONObject jo = new JSONObject(map);
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
/**
* 获取机器人信息
*/
private void getAgvStatus() {
HttpResponse robotInfo = xianGongAgvService.getRobotInfo(this.getDevice().getDevice_name());
if (ObjectUtil.isNotEmpty(robotInfo) && robotInfo.getStatus() == 200) {
JSONObject jsonObject = JSONObject.parseObject(robotInfo.body());
String report = jsonObject.getString("report");
//core出错标识
is_error = jsonObject.getBooleanValue("is_error");
//是否推送场景的状态 0=可推送 1=正在更新场景 2=正在执行运单
upload_scene_status = jsonObject.getString("upload_scene_status");
JSONArray objects = JSONObject.parseArray(report);
for (Object object : objects) {
JSONObject json = (JSONObject) object;
//是否正在执行用户下发的运单
procBusiness = json.getBooleanValue("procBusiness");
//机器人当前运单
current_order = json.getString("current_order");
//机器人连接状态 0表示断连 1表示连接上
connection_status = json.getString("connection_status");
//机器人可接单状态 true=可接单 false=不可接单
dispatchable = json.getBooleanValue("dispatchable");
//机器人不可接单原因
JSONObject undispatchableReason = json.getJSONObject("undispatchable_reason");
//机器人当前地图不在场景中
current_map_invalid = undispatchableReason.getBooleanValue("current_map_invalid");
//网络断连
disconnect = undispatchableReason.getBooleanValue("disconnect");
//可接单状态: 0 = api 设置可接单, 1 = api 设置不可接单
dispatchable_status = undispatchableReason.getIntValue("dispatchable_status");
//低电量
low_battery = undispatchableReason.getBooleanValue("low_battery");
//当前车子的订单被暂停了,需要人为手动恢复
suspended = undispatchableReason.getBooleanValue("suspended");
//未确认定位
unconfirmed_reloc = undispatchableReason.getBooleanValue("unconfirmed_reloc");
//0: 控制权在core手上 , 1:控制权被其他人抢走
unlock = undispatchableReason.getIntValue("unlock");
}
} else {
message = "请求机器人状态失败";
log.info("请求{}机器人状态失败", this.getDevice().getDevice_name());
}
}
}

View File

@@ -1,82 +0,0 @@
package org.nl.acs.device_driver.autodoor.standard_autodoor;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.domain.ItemDto;
import java.util.ArrayList;
import java.util.List;
@Slf4j
public class ItemProtocol {
public static String item_open = "open";
public static String item_close = "close";
public static String item_to_open = "to_open";
public static String item_to_close = "to_close";
private StandardAutodoorDeviceDriver driver;
public ItemProtocol(StandardAutodoorDeviceDriver driver) {
this.driver = driver;
}
public int getOpen() {
return this.getOpcIntegerValue(item_open);
}
public int getClose() {
return this.getOpcIntegerValue(item_close);
}
public int getToOpen() {
return this.getOpcIntegerValue(item_to_open);
}
public int getToClose() {
return this.getOpcIntegerValue(item_to_close);
}
public int getOpcIntegerValue(String protocol) {
Integer value = this.driver.getIntegeregerValue(protocol);
if (value == null) {
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
} else {
return value;
}
return 0;
}
public String getOpcStringValue(String protocol) {
String value = this.driver.getStringValue(protocol);
if (StrUtil.isEmpty(value)) {
} else {
return value;
}
return "0";
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_open, "开到位", "10001"));
list.add(new ItemDto(item_close, "关到位", "10002"));
return list;
}
public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_to_open, "下发开门", "00001" ));
list.add(new ItemDto(item_to_close, "下发关门", "00002"));
return list;
}
@Override
public String toString() {
return "";
}
}

View File

@@ -1,63 +0,0 @@
package org.nl.acs.device_driver.autodoor.standard_autodoor;
import org.nl.acs.device.domain.ItemDto;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device.enums.DeviceType;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
import org.springframework.stereotype.Service;
import java.util.LinkedList;
import java.util.List;
/**
* 自动门驱动定义
*/
@Service
public class StandardAutodoorDefination implements OpcDeviceDriverDefination {
@Override
public String getDriverCode() {
return "standard_autodoor";
}
@Override
public String getDriverName() {
return "标准版-自动门";
}
@Override
public String getDriverDescription() {
return "标准版-自动门";
}
@Override
public DeviceDriver getDriverInstance(Device device) {
return (new StandardAutodoorDeviceDriver()).setDevice(device).setDriverDefination(this);
}
@Override
public Class<? extends DeviceDriver> getDeviceDriverType() {
return StandardAutodoorDeviceDriver.class;
}
@Override
public List<DeviceType> getFitDeviceTypes() {
List<DeviceType> types = new LinkedList();
types.add(DeviceType.autodoor);
return types;
}
@Override
public List<ItemDto> getReadableItemDtos() {
return ItemProtocol.getReadableItemDtos();
}
@Override
public List<ItemDto> getWriteableItemDtos() {
return ItemProtocol.getWriteableItemDtos();
}
}

View File

@@ -1,135 +0,0 @@
package org.nl.acs.device_driver.autodoor.standard_autodoor;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.monitor.DeviceStageMonitor;
import org.nl.acs.utils.ReadUtil;
import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.HashMap;
import java.util.Map;
/**
* 自动门驱动
*/
@Slf4j
@Data
@RequiredArgsConstructor
public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
protected ToDoorCommandControl toDoorCommandControl = new ToDoorCommandControl(this);
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
@Autowired
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
int open = 0;
int close = 0;
int last_open = 0;
int last_close = 0;
int toOpen = 0;
int last_toOpen = 0;
int toClose = 0;
int last_toClose = 0;
String device_code = null;
@Override
public Device getDevice() {
return this.device;
}
@Override
public void execute() {
String message = null;
device_code = this.getDevice().getDevice_code();
open = this.itemProtocol.getOpen();
close = this.itemProtocol.getClose();
toOpen = this.itemProtocol.getToOpen();
toClose = this.itemProtocol.getToClose();
if (open != last_open) {
logServer.deviceExecuteLog(this.device_code, "", "", "信号open" + last_open + "->" + open);
}
if (close != last_close) {
if(close ==1 ){
this.writing("to_close","0");
}
}
last_open = open;
last_close = close;
last_toClose = toClose;
last_toOpen = toOpen;
}
public void writing(String param, String value) {
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + param;
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_param, Integer.parseInt(value));
try {
this.toDoorCommandControl.control(param,value);
} catch (Exception e) {
e.printStackTrace();
}
}
public void writing(String param, int command) {
String to_command = String.format("%s.%s.%s.%s", this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.getDevice().getDevice_code(), param);
String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
ReadUtil.write(itemMap, server);
log.info("下发PLC信号{},{}", to_command, command);
System.out.println("设备:" + this.device_code + ",下发PLC信号" + to_command + ",value:" + command);
}
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String open = "";
String close = "";
if (this.getOpen() == 0) {
open = "未知";
} else if (this.getOpen() == 1) {
open = "开到位";
}
if (this.getClose() == 0) {
open = "未知";
} else if (this.getClose() == 1) {
open = "关到位";
}
jo.put("device_name", this.getDevice().getDevice_name());
jo.put("open", open);
jo.put("close", close);
jo.put("isOnline", true);
return jo;
}
@Override
public void setDeviceStatus(JSONObject data) {
}
}

View File

@@ -1,27 +0,0 @@
package org.nl.acs.device_driver.autodoor.standard_autodoor;
import java.util.HashMap;
import java.util.Map;
public class ToDoorCommandControl {
private StandardAutodoorDeviceDriver driver;
public ToDoorCommandControl(StandardAutodoorDeviceDriver driver){
this.driver = driver;
}
public void control(String param, String value) throws Exception {
// ItemValue[] itemValues = new ItemValue[]{new ItemValue(this.driver.getItem(ItemProtocol.item_to_command), command)};
Map<String, Object> itemMap = new HashMap<String, Object>();
String to_param = this.driver.getDevice().getOpc_server_code() + "." + this.driver.getDevice().getOpc_plc_code() + "." + this.driver.getDevice().getDevice_code()
+ "."+ param;
itemMap.put(to_param, Integer.parseInt(value));
try {
this.driver.checkcontrol(itemMap);
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -7,7 +7,6 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.common.exception.BadRequestException;
import org.nl.config.language.LangProcess;
import org.nl.system.service.param.ISysParamService;
@@ -23,8 +22,6 @@ public class AcsUtil {
public static <W> String notifyAcs(String api, W requestParam) {
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
;
ISysParamService paramService = SpringContextHolder.getBean(SysParamServiceImpl.class);
//判断是否连接立库WCS系统
String isConnect = paramService.findByCode("is_connect_liKu_Wcs").getValue();

View File

@@ -6,7 +6,6 @@ import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.ISysParamService;
import org.nl.system.service.param.impl.SysParamServiceImpl;
@@ -18,8 +17,6 @@ import org.nl.system.service.param.impl.SysParamServiceImpl;
public class LmsUtil {
public static <W> String notifyAcs(String api, W requestParam) {
DeviceExecuteLogService logServer = SpringContextHolder.getBean(DeviceExecuteLogService.class);
;
ISysParamService paramService = SpringContextHolder.getBean(SysParamServiceImpl.class);
//判断是否连接立库WCS系统
String isConnect = paramService.findByCode("hasWms").getValue();

View File

@@ -1,67 +0,0 @@
package org.nl.acs.ext.wms;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.ext.wms.service.AcsToWmsService;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.RedisUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.retry.annotation.Backoff;
import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Component;
@Component
@Slf4j
public class RetryableUtil {
private static ThreadLocal<Integer> retryTimes = new ThreadLocal<>();
@Autowired
private RedisUtils redisUtils;
@Autowired
private AcsToWmsService acsToWmsService;
/**
* 只针对对接系统连接拒绝、连接超时进行重试机制
* 如果系统连接成功 但是对方返回失败不进行重试
*
* @param url
* @param param
*/
@Retryable(maxAttempts = 5, backoff = @Backoff(delay = 15000L, multiplier = 2))
public void retryable(String url, String param, String token) {
HttpResponse httpResponse = null;
String respMessage = null;
try {
httpResponse =
HttpRequest
.post(url)
.header("Authorization", token).body(String.valueOf(param))
.body(param)
.timeout(5000)
.execute();
} catch (Exception e) {
respMessage = e.getMessage();
}
if (retryTimes.get() == null) {
retryTimes.set(1);
} else {
retryTimes.set(retryTimes.get() + 1);
}
if (httpResponse == null) {
log.error("接口进行第{}次重试,请求路径:{},请求参数:{},响应参数:{}", retryTimes.get(), url, JSONObject.parse(param), respMessage);
throw new BadRequestException(url + "_" + param + "_" + retryTimes.get());
}
retryTimes.remove();
log.info("接口重试成功,请求路径:{},请求参数:{},重试次数:{}", url, JSONObject.parse(param), retryTimes.get());
}
@Recover
public void recover(RuntimeException e) {
retryTimes.remove();
String[] excMessage = e.getMessage().split("_");
log.error("请求路径:{},请求参数:{},已达到最大重试次数:{},停止重试!", excMessage[0], excMessage[1], excMessage[2]);
}
}

View File

@@ -19,7 +19,6 @@ import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapp
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device;
@@ -39,7 +38,6 @@ import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.route.service.impl.RouteLineServiceImpl;
import org.nl.acs.task.TaskInstructionLock;
import org.nl.acs.task.domain.Task;
import org.nl.acs.task.enums.AgvSystemTypeEnum;
import org.nl.acs.task.enums.TaskStatusEnum;
@@ -61,12 +59,10 @@ import org.nl.acs.instruction.service.mapper.InstructionMapper;
import org.nl.common.utils.SecurityUtils;
import org.nl.config.language.LangProcess;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
import org.nl.system.service.param.ISysParamService;
import org.nl.common.utils.CodeUtil;
import org.nl.config.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -102,8 +98,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Autowired
private TaskService taskService;
@Autowired
private XianGongAgvService xiangGongAgvService;
@Autowired
private LimitRegionalService limitRegionalService;
@Autowired
private LuceneExecuteLogService luceneExecuteLogService;
@@ -445,32 +439,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
if (StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
throw new BadRequestException(dto.getStart_device_code() + "->" + dto.getNext_device_code() + "路由类型不是agv类型");
}
//判断是否是仙工AGV
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) {
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
String interactionJson = task.getInteraction_json();
if (StrUtil.isEmpty(interactionJson)) {
throw new BadRequestException("agv叉车调整长宽参数为空");
}
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
//仙工叉车
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto, interactionJsonDTO);
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
dto.setSend_status("2");
} else {
dto.setSend_status("1");
}
} else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
//一楼agv任务创建运单序列
HttpResponse response = xiangGongAgvService.sendOrderSequencesToXZ(dto);
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
dto.setSend_status("2");
} else {
dto.setSend_status("1");
}
}
}
} catch (Exception e) {
dto.setSend_status("2");
log.error(e.getMessage());
@@ -594,35 +562,6 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
if (ObjectUtil.isEmpty(route) && !(start_device_code.equals(next_device_code))) {
throw new BadRequestException(LangProcess.msg("error_isNull", "route"));
}
//判断是否是仙工AGV
if (shortPathsList.size() > 0 && StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) {
Device deviceByCode = deviceAppService.findDeviceByCode(dto.getStart_device_code());
if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type.getIndex())) {
String interactionJson = task.getInteraction_json();
if (StrUtil.isEmpty(interactionJson)) {
throw new BadRequestException("agv叉车调整长宽参数为空");
}
InteractionJsonDTO interactionJsonDTO = JSON.parseObject(interactionJson, InteractionJsonDTO.class);
//仙工叉车
HttpResponse response = xiangGongAgvService.sendOrderSequencesToForklift(dto, interactionJsonDTO);
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
dto.setSend_status("2");
} else {
dto.setSend_status("1");
}
} else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
//一楼agv任务创建运单序列
HttpResponse response = xiangGongAgvService.sendOrderSequencesToXZ(dto);
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) {
dto.setSend_status("2");
} else {
dto.setSend_status("1");
}
} else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.Two_NDC_System_Type.getIndex())) {
}
}
} catch (Exception e) {
dto.setSend_status("2");
log.error(e.getMessage());
@@ -1144,13 +1083,9 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
}
} else if (ObjectUtil.isNotEmpty(entity.getAgv_system_type()) && entity.getAgv_system_type().equals(CommonFinalParam.ONE)
&& !StrUtil.equals(entity.getSend_status(), "2")) {
XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class);
xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code());
flag = true;
} else if (ObjectUtil.isNotEmpty(entity.getAgv_system_type()) && entity.getAgv_system_type().equals(AgvSystemTypeEnum.XG_System_Type)
&& !StrUtil.equals(entity.getSend_status(), "2")) {
XianGongAgvService xianGongAgvService = SpringContextHolder.getBean(XianGongAgvService.class);
xianGongAgvService.deleteXZAgvInst(entity.getInstruction_code());
flag = true;
} else {
flag = true;

View File

@@ -3,7 +3,6 @@ package org.nl.acs.opc;
import org.nl.acs.device.domain.Device;
import org.nl.acs.device.enums.DeviceType;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.LinewayDeviceDriver;
import java.util.List;
import java.util.Map;
@@ -95,13 +94,6 @@ public interface DeviceAppService {
*/
void reload();
/**
* 找线网设备
*
* @return
*/
List<LinewayDeviceDriver> findLaneway();
/**
* 根据设备编号查询类型
*

View File

@@ -10,7 +10,6 @@ import org.nl.acs.device.enums.DeviceType;
import org.nl.acs.device.service.DeviceDriverDefinationAppService;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.DeviceDriverDefination;
import org.nl.acs.device_driver.LinewayDeviceDriver;
import org.nl.acs.device_driver.driver.OpcDeviceDriver;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -314,11 +313,6 @@ public class DeviceAppServiceImpl implements DeviceAppService, ApplicationAutoIn
return null;
}
@Override
public List<LinewayDeviceDriver> findLaneway() {
return this.findDeviceDriver(LinewayDeviceDriver.class);
}
@Override
public void autoInitial() throws Exception {
log.info("加载所有设备");

View File

@@ -3,12 +3,6 @@ package org.nl.acs.storage_cell.service.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Date;
import org.nl.common.annotation.Query;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @author jiaolm
* @date 2023-05-09

View File

@@ -4,12 +4,6 @@ package org.nl.acs.task.service.dto;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
import java.util.Date;
import org.nl.common.annotation.Query;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @author jiaolm
* @date 2023-05-09
@@ -17,6 +11,6 @@ import org.springframework.format.annotation.DateTimeFormat;
@Getter
@Setter
public class TaskQueryParam {
private String task_status;
}

View File

@@ -18,7 +18,6 @@ import groovy.lang.Lazy;
import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull;
import org.nl.acs.AcsConfig;
import org.nl.acs.agv.server.XianGongAgvService;
import org.nl.acs.auto.initial.ApplicationAutoInitial;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.domain.Device;
@@ -64,7 +63,6 @@ import org.nl.common.utils.CodeUtil;
import org.nl.config.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
@@ -72,9 +70,7 @@ import org.springframework.data.domain.Pageable;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -101,9 +97,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
private TaskFeedbackService taskFeedbackService;
@Autowired
private ISysParamService paramService;
@Lazy
@Autowired
private XianGongAgvService agvService;
@Autowired
private RouteLineService routeLineService;
@Autowired
@@ -911,10 +904,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
if (!TaskStatusEnum.FINISHED.getIndex().equals(updateTask.getTask_status())) {
//反馈上位系统任务状态
this.feedWmsTaskStatus(entity);
//关闭仙工运单序列
if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode()) || StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) {
this.markComplete(entity);
}
}
}
@@ -943,10 +932,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
this.removeByCodeFromCache(entity.getTask_code());
//反馈上位系统任务状态
this.feedWmsTaskStatus(entity);
//关闭仙工运单序列
if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode()) || StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) {
this.markComplete(entity);
}
}
@Override
@@ -975,10 +960,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
this.removeByCodeFromCache(entity.getTask_code());
//反馈上位系统任务状态
// this.feedWmsTaskStatus(entity);
//关闭仙工运单序列
if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode()) || StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) {
this.markComplete(entity);
}
}
@Override
@@ -1007,10 +988,6 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
this.removeByCodeFromCache(entity.getTask_code());
//反馈上位系统任务状态
this.feedWmsTaskStatus(entity);
//关闭仙工运单序列
if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode()) || StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) {
this.markComplete(entity);
}
}
@@ -1816,20 +1793,4 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
ja.add(feed_jo);
}
}
/**
* 关闭仙工运单序列
*
* @param taskDto
*/
private void markComplete(TaskDto taskDto) {
// 如果属于先知AGV关闭运单序列
try {
agvService.markComplete(taskDto.getTask_code());
} catch (Exception e) {
log.error("关闭运单异常,原因:{}", e.getMessage());
}
}
}

View File

@@ -4,11 +4,8 @@ import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.nl.acs.common.base.CommonMapper;
import org.nl.acs.task.domain.Task;
import org.nl.common.annotation.Query;
import org.springframework.stereotype.Repository;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import java.util.Map;

View File

@@ -1,50 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.common.annotation;
import org.nl.common.aspect.LimitType;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author jacky
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface Limit {
// 资源名称,用于描述接口功能
String name() default "";
// 资源 key
String key() default "";
// key prefix
String prefix() default "";
// 时间的,单位秒
int period();
// 限制访问次数
int count();
// 限制类型
LimitType limitType() default LimitType.CUSTOMER;
}

View File

@@ -1,39 +0,0 @@
package org.nl.common.annotation;
import org.springframework.core.annotation.AliasFor;
import org.springframework.core.annotation.AnnotationUtils;
import java.lang.annotation.*;
import java.util.concurrent.TimeUnit;
/**
* @Author: lyd
* @Description: 限流注解,添加了 {@link AliasFor} 必须通过 {@link AnnotationUtils} 获取,才会生效
* @Date: 2022-08-15
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface RateLimiter {
int NOT_LIMITED = 0;
/**
* qps
*/
@AliasFor("qps") double value() default NOT_LIMITED;
/**
* qps
*/
@AliasFor("value") double qps() default NOT_LIMITED;
/**
* 超时时长
*/
int timeout() default 0;
/**
* 超时时间单位
*/
TimeUnit timeUnit() default TimeUnit.MILLISECONDS;
}

View File

@@ -1,105 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.common.aspect;
import cn.hutool.core.util.StrUtil;
import com.google.common.collect.ImmutableList;
import lombok.extern.slf4j.Slf4j;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.aspectj.lang.reflect.MethodSignature;
import org.nl.common.annotation.Limit;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.RequestHolder;
import org.nl.common.utils.StringUtils;
import org.nl.config.language.LangProcess;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.script.DefaultRedisScript;
import org.springframework.data.redis.core.script.RedisScript;
import org.springframework.stereotype.Component;
import javax.servlet.http.HttpServletRequest;
import java.lang.reflect.Method;
/**
* @author /
*/
@Aspect
@Component
@Slf4j
public class LimitAspect {
private final RedisTemplate<Object,Object> redisTemplate;
private static final Logger logger = LoggerFactory.getLogger(LimitAspect.class);
public LimitAspect(RedisTemplate<Object,Object> redisTemplate) {
this.redisTemplate = redisTemplate;
}
@Pointcut("@annotation(org.nl.common.annotation.Limit)")
public void pointcut() {
}
@Around("pointcut()")
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
HttpServletRequest request = RequestHolder.getHttpServletRequest();
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
Method signatureMethod = signature.getMethod();
Limit limit = signatureMethod.getAnnotation(Limit.class);
LimitType limitType = limit.limitType();
String key = limit.key();
if (StrUtil.isEmpty(key)) {
if (limitType == LimitType.IP) {
key = StringUtils.getIp(request);
} else {
key = signatureMethod.getName();
}
}
ImmutableList<Object> keys = ImmutableList.of(StrUtil.join(limit.prefix(), "_", key, "_", request.getRequestURI().replaceAll("/","_")));
String luaScript = buildLuaScript();
RedisScript<Number> redisScript = new DefaultRedisScript<>(luaScript, Number.class);
Number count = redisTemplate.execute(redisScript, keys, limit.count(), limit.period());
if (null != count && count.intValue() <= limit.count()) {
log.info("第{}次访问key为 {},描述为 [{}] 的接口", count, keys, limit.name());
return joinPoint.proceed();
} else {
throw new BadRequestException(LangProcess.msg("error_sysLimit"));
}
}
/**
* 限流脚本
*/
private String buildLuaScript() {
return "local c" +
"\nc = redis.call('get',KEYS[1])" +
"\nif c and tonumber(c) > tonumber(ARGV[1]) then" +
"\nreturn c;" +
"\nend" +
"\nc = redis.call('incr',KEYS[1])" +
"\nif tonumber(c) == 1 then" +
"\nredis.call('expire',KEYS[1],ARGV[2])" +
"\nend" +
"\nreturn c;";
}
}

View File

@@ -1,27 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.common.aspect;
/**
* 限流枚举
* @author /
*/
public enum LimitType {
// 默认
CUSTOMER,
// by ip addr
IP
}

View File

@@ -1,140 +0,0 @@
/*
* <<
* Davinci
* ==
* Copyright (C) 2016 - 2019 EDP
* ==
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.common.mnt.util;
import lombok.extern.slf4j.Slf4j;
/**
* @author /
*/
@Slf4j
@SuppressWarnings({"unchecked","all"})
public enum DataTypeEnum {
/** mysql */
MYSQL("mysql", "mysql", "com.mysql.cj.jdbc.Driver", "`", "`", "'", "'"),
/** oracle */
ORACLE("oracle", "oracle", "oracle.jdbc.driver.OracleDriver", "\"", "\"", "\"", "\""),
/** sql server */
SQLSERVER("sqlserver", "sqlserver", "com.microsoft.sqlserver.jdbc.SQLServerDriver", "\"", "\"", "\"", "\""),
/** h2 */
H2("h2", "h2", "org.h2.Driver", "`", "`", "\"", "\""),
/** phoenix */
PHOENIX("phoenix", "hbase phoenix", "org.apache.phoenix.jdbc.PhoenixDriver", "", "", "\"", "\""),
/** mongo */
MONGODB("mongo", "mongodb", "mongodb.jdbc.MongoDriver", "`", "`", "\"", "\""),
/** sql4es */
ELASTICSEARCH("sql4es", "elasticsearch", "nl.anchormen.sql4es.jdbc.ESDriver", "", "", "'", "'"),
/** presto */
PRESTO("presto", "presto", "com.facebook.presto.jdbc.PrestoDriver", "", "", "\"", "\""),
/** moonbox */
MOONBOX("moonbox", "moonbox", "moonbox.jdbc.MbDriver", "`", "`", "`", "`"),
/** cassandra */
CASSANDRA("cassandra", "cassandra", "com.github.adejanovski.cassandra.jdbc.CassandraDriver", "", "", "'", "'"),
/** click house */
CLICKHOUSE("clickhouse", "clickhouse", "ru.yandex.clickhouse.ClickHouseDriver", "", "", "\"", "\""),
/** kylin */
KYLIN("kylin", "kylin", "org.apache.kylin.jdbc.Driver", "\"", "\"", "\"", "\""),
/** vertica */
VERTICA("vertica", "vertica", "com.vertica.jdbc.Driver", "", "", "'", "'"),
/** sap */
HANA("sap", "sap hana", "com.sap.db.jdbc.Driver", "", "", "'", "'"),
/** impala */
IMPALA("impala", "impala", "com.cloudera.impala.jdbc41.Driver", "", "", "'", "'");
private String feature;
private String desc;
private String driver;
private String keywordPrefix;
private String keywordSuffix;
private String aliasPrefix;
private String aliasSuffix;
private static final String JDBC_URL_PREFIX = "jdbc:";
DataTypeEnum(String feature, String desc, String driver, String keywordPrefix, String keywordSuffix, String aliasPrefix, String aliasSuffix) {
this.feature = feature;
this.desc = desc;
this.driver = driver;
this.keywordPrefix = keywordPrefix;
this.keywordSuffix = keywordSuffix;
this.aliasPrefix = aliasPrefix;
this.aliasSuffix = aliasSuffix;
}
public static DataTypeEnum urlOf(String jdbcUrl) {
String url = jdbcUrl.toLowerCase().trim();
for (DataTypeEnum dataTypeEnum : values()) {
if (url.startsWith(JDBC_URL_PREFIX + dataTypeEnum.feature)) {
try {
Class<?> aClass = Class.forName(dataTypeEnum.getDriver());
if (null == aClass) {
throw new RuntimeException("Unable to get driver instance for jdbcUrl: " + jdbcUrl);
}
} catch (ClassNotFoundException e) {
throw new RuntimeException("Unable to get driver instance: " + jdbcUrl);
}
return dataTypeEnum;
}
}
return null;
}
public String getFeature() {
return feature;
}
public String getDesc() {
return desc;
}
public String getDriver() {
return driver;
}
public String getKeywordPrefix() {
return keywordPrefix;
}
public String getKeywordSuffix() {
return keywordSuffix;
}
public String getAliasPrefix() {
return aliasPrefix;
}
public String getAliasSuffix() {
return aliasSuffix;
}
}

View File

@@ -1,103 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.common.mnt.util;
import cn.hutool.core.io.IoUtil;
import com.jcraft.jsch.ChannelShell;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.Session;
import lombok.extern.slf4j.Slf4j;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Vector;
/**
* 执行shell命令
*
* @author: ZhangHouYing
* @date: 2019/8/10
*/
@Slf4j
public class ExecuteShellUtil {
private Vector<String> stdout;
Session session;
public ExecuteShellUtil(final String ipAddress, final String username, final String password,int port) {
try {
JSch jsch = new JSch();
session = jsch.getSession(username, ipAddress, port);
session.setPassword(password);
session.setConfig("StrictHostKeyChecking", "no");
session.connect(3000);
} catch (Exception e) {
log.error(e.getMessage(),e);
}
}
public int execute(final String command) {
int returnCode = 0;
ChannelShell channel = null;
PrintWriter printWriter = null;
BufferedReader input = null;
stdout = new Vector<String>();
try {
channel = (ChannelShell) session.openChannel("shell");
channel.connect();
input = new BufferedReader(new InputStreamReader(channel.getInputStream()));
printWriter = new PrintWriter(channel.getOutputStream());
printWriter.println(command);
printWriter.println("exit");
printWriter.flush();
log.info("The remote command is: ");
String line;
while ((line = input.readLine()) != null) {
stdout.add(line);
System.out.println(line);
}
} catch (Exception e) {
log.error(e.getMessage(),e);
return -1;
}finally {
IoUtil.close(printWriter);
IoUtil.close(input);
if (channel != null) {
channel.disconnect();
}
}
return returnCode;
}
public void close(){
if (session != null) {
session.disconnect();
}
}
public String executeForResult(String command) {
execute(command);
StringBuilder sb = new StringBuilder();
for (String str : stdout) {
sb.append(str);
}
return sb.toString();
}
}

View File

@@ -1,105 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.common.mnt.util;
import ch.ethz.ssh2.Connection;
import ch.ethz.ssh2.SCPClient;
import com.google.common.collect.Maps;
import java.io.IOException;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
/**
* 远程执行linux命令
* @author: ZhangHouYing
* @date: 2019-08-10 10:06
*/
public class ScpClientUtil {
static private Map<String,ScpClientUtil> instance = Maps.newHashMap();
static synchronized public ScpClientUtil getInstance(String ip, int port, String username, String password) {
if (instance.get(ip) == null) {
instance.put(ip, new ScpClientUtil(ip, port, username, password));
}
return instance.get(ip);
}
public ScpClientUtil(String ip, int port, String username, String password) {
this.ip = ip;
this.port = port;
this.username = username;
this.password = password;
}
public void getFile(String remoteFile, String localTargetDirectory) {
Connection conn = new Connection(ip, port);
try {
conn.connect();
boolean isAuthenticated = conn.authenticateWithPassword(username, password);
if (!isAuthenticated) {
System.err.println("authentication failed");
}
SCPClient client = new SCPClient(conn);
client.get(remoteFile, localTargetDirectory);
} catch (IOException ex) {
Logger.getLogger(SCPClient.class.getName()).log(Level.SEVERE, null, ex);
}finally{
conn.close();
}
}
public void putFile(String localFile, String remoteTargetDirectory) {
putFile(localFile, null, remoteTargetDirectory);
}
public void putFile(String localFile, String remoteFileName, String remoteTargetDirectory) {
putFile(localFile, remoteFileName, remoteTargetDirectory,null);
}
public void putFile(String localFile, String remoteFileName, String remoteTargetDirectory, String mode) {
Connection conn = new Connection(ip, port);
try {
conn.connect();
boolean isAuthenticated = conn.authenticateWithPassword(username, password);
if (!isAuthenticated) {
System.err.println("authentication failed");
}
SCPClient client = new SCPClient(conn);
if ((mode == null) || (mode.length() == 0)) {
mode = "0600";
}
if (remoteFileName == null) {
client.put(localFile, remoteTargetDirectory);
} else {
client.put(localFile, remoteFileName, remoteTargetDirectory, mode);
}
} catch (IOException ex) {
Logger.getLogger(ScpClientUtil.class.getName()).log(Level.SEVERE, null, ex);
}finally{
conn.close();
}
}
private String ip;
private int port;
private String username;
private String password;
}

View File

@@ -1,206 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.common.mnt.util;
import com.alibaba.druid.pool.DruidDataSource;
import com.alibaba.druid.util.StringUtils;
import com.google.common.collect.Lists;
import lombok.extern.slf4j.Slf4j;
import javax.sql.DataSource;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.sql.*;
import java.util.List;
/**
* @author /
*/
@Slf4j
public class SqlUtils {
public static final String COLON = ":";
/**
* 获取数据源
*
* @param jdbcUrl /
* @param userName /
* @param password /
* @return DataSource
*/
private static DataSource getDataSource(String jdbcUrl, String userName, String password) {
DruidDataSource druidDataSource = new DruidDataSource();
String className;
try {
className = DriverManager.getDriver(jdbcUrl.trim()).getClass().getName();
} catch (SQLException e) {
throw new RuntimeException("Get class name error: =" + jdbcUrl);
}
if (StringUtils.isEmpty(className)) {
DataTypeEnum dataTypeEnum = DataTypeEnum.urlOf(jdbcUrl);
if (null == dataTypeEnum) {
throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
}
druidDataSource.setDriverClassName(dataTypeEnum.getDriver());
} else {
druidDataSource.setDriverClassName(className);
}
druidDataSource.setUrl(jdbcUrl);
druidDataSource.setUsername(userName);
druidDataSource.setPassword(password);
// 配置获取连接等待超时的时间
druidDataSource.setMaxWait(3000);
// 配置初始化大小、最小、最大
druidDataSource.setInitialSize(1);
druidDataSource.setMinIdle(1);
druidDataSource.setMaxActive(1);
// 如果链接出现异常则直接判定为失败而不是一直重试
druidDataSource.setBreakAfterAcquireFailure(true);
try {
druidDataSource.init();
} catch (SQLException e) {
log.error("Exception during pool initialization", e);
throw new RuntimeException(e.getMessage());
}
return druidDataSource;
}
private static Connection getConnection(String jdbcUrl, String userName, String password) {
DataSource dataSource = getDataSource(jdbcUrl, userName, password);
Connection connection = null;
try {
connection = dataSource.getConnection();
} catch (Exception ignored) {}
try {
int timeOut = 5;
if (null == connection || connection.isClosed() || !connection.isValid(timeOut)) {
log.info("connection is closed or invalid, retry get connection!");
connection = dataSource.getConnection();
}
} catch (Exception e) {
log.error("create connection error, jdbcUrl: {}", jdbcUrl);
throw new RuntimeException("create connection error, jdbcUrl: " + jdbcUrl);
}
return connection;
}
private static void releaseConnection(Connection connection) {
if (null != connection) {
try {
connection.close();
} catch (Exception e) {
log.error(e.getMessage(),e);
log.error("connection close error" + e.getMessage());
}
}
}
public static void closeResult(ResultSet rs) {
if (rs != null) {
try {
rs.close();
} catch (Exception e) {
log.error(e.getMessage(),e);
}
}
}
public static boolean testConnection(String jdbcUrl, String userName, String password) {
Connection connection = null;
try {
connection = getConnection(jdbcUrl, userName, password);
if (null != connection) {
return true;
}
} catch (Exception e) {
log.info("Get connection failed:" + e.getMessage());
} finally {
releaseConnection(connection);
}
return false;
}
public static String executeFile(String jdbcUrl, String userName, String password, File sqlFile) {
Connection connection = getConnection(jdbcUrl, userName, password);
try {
batchExecute(connection, readSqlList(sqlFile));
} catch (Exception e) {
log.error("sql脚本执行发生异常:{}",e.getMessage());
return e.getMessage();
}finally {
releaseConnection(connection);
}
return "success";
}
/**
* 批量执行sql
* @param connection /
* @param sqlList /
*/
public static void batchExecute(Connection connection, List<String> sqlList) throws SQLException {
Statement st = connection.createStatement();
for (String sql : sqlList) {
if (sql.endsWith(";")) {
sql = sql.substring(0, sql.length() - 1);
}
st.addBatch(sql);
}
st.executeBatch();
}
/**
* 将文件中的sql语句以为单位读取到列表中
* @param sqlFile /
* @return /
* @throws Exception e
*/
private static List<String> readSqlList(File sqlFile) throws Exception {
List<String> sqlList = Lists.newArrayList();
StringBuilder sb = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new InputStreamReader(
new FileInputStream(sqlFile), StandardCharsets.UTF_8))) {
String tmp;
while ((tmp = reader.readLine()) != null) {
log.info("line:{}", tmp);
if (tmp.endsWith(";")) {
sb.append(tmp);
sqlList.add(sb.toString());
sb.delete(0, sb.length());
} else {
sb.append(tmp);
}
}
if (!"".endsWith(sb.toString().trim())) {
sqlList.add(sb.toString());
}
}
return sqlList;
}
}

View File

@@ -1,159 +0,0 @@
/*
* Copyright 2019-2020 Zheng Jie
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* 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.common.mnt.util;
import java.io.*;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import java.util.zip.ZipInputStream;
/**
* @author: ZhangHouYing
* @date: 2019-08-10 13:34
*/
public class ZipUtils {
/**
* 解压文件
*
* @param zipFilePath 解压文件路径
* @param outputFolder 输出解压文件路径
*/
public static void unZipIt(String zipFilePath, String outputFolder) {
byte[] buffer = new byte[1024];
File folder = new File(outputFolder);
if (!folder.exists()) {
folder.mkdir();
}
try {
//get the zip file content
ZipInputStream zis = new ZipInputStream(new FileInputStream(zipFilePath));
ZipEntry ze = zis.getNextEntry();
while (ze != null) {
String fileName = ze.getName();
File newFile = new File(outputFolder + File.separator + fileName);
System.out.println("file unzip : " + newFile.getAbsoluteFile());
//大部分网络上的源码,这里没有判断子目录
if (ze.isDirectory()) {
if (!newFile.mkdirs()) {
System.out.println("was not successful.");
}
} else {
if (!new File(newFile.getParent()).mkdirs()) {
System.out.println("was not successful.");
}
FileOutputStream fos = new FileOutputStream(newFile);
int len;
while ((len = zis.read(buffer)) != -1) {
fos.write(buffer, 0, len);
}
fos.close();
}
ze = zis.getNextEntry();
}
zis.closeEntry();
zis.close();
System.out.println("Done");
} catch (IOException e) {
e.printStackTrace();
}
}
public static void unzip(File source, String out) throws IOException {
try (ZipInputStream zis = new ZipInputStream(new FileInputStream(source))) {
ZipEntry entry = zis.getNextEntry();
while (entry != null) {
File file = new File(out, entry.getName());
if (entry.isDirectory()) {
if (!file.mkdirs()) {
System.out.println("was not successful.");
}
} else {
File parent = file.getParentFile();
if (!parent.exists()) {
if (!parent.mkdirs()) {
System.out.println("was not successful.");
}
}
try (BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(file))) {
byte[] buffer = new byte[Math.toIntExact(entry.getSize())];
int location;
while ((location = zis.read(buffer)) != -1) {
bos.write(buffer, 0, location);
}
}
}
entry = zis.getNextEntry();
}
}
}
/**
* 把所有文件都直接解压到指定目录(忽略子文件夹)
*
* @param zipFile
* @param folderPath
* @throws ZipException
* @throws IOException
*/
public static void upZipFile(File zipFile, String folderPath) throws ZipException, IOException {
File desDir = new File(folderPath);
if (!desDir.exists()) {
if (!desDir.mkdirs()) {
System.out.println("was not successful.");
}
}
ZipFile zf = new ZipFile(zipFile);
for (Enumeration<?> entries = zf.entries(); entries.hasMoreElements(); ) {
ZipEntry entry = ((ZipEntry) entries.nextElement());
InputStream in = zf.getInputStream(entry);
String str = folderPath;
File desFile = new File(str, java.net.URLEncoder.encode(entry.getName(), "UTF-8"));
if (!desFile.exists()) {
File fileParentDir = desFile.getParentFile();
if (!fileParentDir.exists()) {
if (!fileParentDir.mkdirs()) {
System.out.println("was not successful.");
}
}
}
OutputStream out = new FileOutputStream(desFile);
byte[] buffer = new byte[1024 * 1024];
int realLength = in.read(buffer);
while (realLength != -1) {
out.write(buffer, 0, realLength);
realLength = in.read(buffer);
}
out.close();
in.close();
}
}
}

View File

@@ -77,7 +77,6 @@ public class SysDictController {
}
@Log("删除字典")
@DeleteMapping
// @SaCheckPermission("dict:del")
public ResponseEntity<Object> delete(@RequestBody Set<String> ids){
@@ -86,7 +85,6 @@ public class SysDictController {
}
@GetMapping("/dictDetail")
public ResponseEntity<Object> queryDetails(@RequestParam Map criteria, PageQuery pageable){
DictQuery dictQuery = JSONObject.parseObject(JSONObject.toJSONString(criteria), DictQuery.class);
return new ResponseEntity<>(TableDataInfo.build(dictService.queryAllDetail(dictQuery,pageable)),HttpStatus.OK);