Browse Source

add 仙工控制门开关、仙工查询门状态 接口

master
张江玮 2 years ago
parent
commit
3bd4ba3da8
  1. 13
      hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java
  2. 34
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java
  3. 88
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java
  4. 31
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java
  5. 41
      hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java
  6. 2
      hd/nladmin-system/src/main/resources/config/application-prod.yml

13
hd/nladmin-system/src/main/java/org/nl/acs/agv/rest/AgvController.java

@ -4,6 +4,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.StringUtils;
import org.nl.acs.agv.server.AgvService;
import org.nl.acs.device.service.DeviceService;
@ -96,5 +97,17 @@ public class AgvController {
return new ResponseEntity<>(agvService.queryDeviceStation(), HttpStatus.OK);
}
@PostMapping("/xgAGVControlDoorSwitch")
@Log("仙工AGV控制门开关")
@ApiOperation("仙工AGV控制门开关")
public ResponseEntity<JSONObject> xgAGVControlDoorSwitch(@RequestBody JSONObject requestParam) {
return new ResponseEntity<>(agvService.xgAGVControlDoorSwitch(requestParam), HttpStatus.OK);
}
@PostMapping("/xgAGVQueryDoorStatus")
@Log("仙工AGV查询门状态")
@ApiOperation("仙工AGV查询门状态")
public ResponseEntity<JSONObject> xgAGVQueryDoorStatus(@RequestBody JSONObject requestParam) {
return new ResponseEntity<>(agvService.xgAGVQueryDoorStatus(requestParam), HttpStatus.OK);
}
}

34
hd/nladmin-system/src/main/java/org/nl/acs/agv/server/AgvService.java

@ -182,4 +182,38 @@ public interface AgvService {
String queryDeviceStation();
/**
* 控制门开关
*
* @param requestParam 请求参数
* 示例{
* "deviceID":"DOOR_001", //门禁ID
* "state":"1", //控制指令 0关门 1开门
* }
* @return 示例{
* "result":0, // -1操作失败 -2不存在当前设备
* "message":"操作成功"
* }
*/
JSONObject xgAGVControlDoorSwitch(JSONObject requestParam);
/**
* @param requestParam 请求参数
* 示例{
* "deviceIDs":"DOOR_001,DOOR_002", //门禁ID,英文逗号分割
* }
* @return 示例{
* "result": 0,
* "message": "操作成功",
* "data": [
* {
* "deviceID": "设备id",
* "doorState": "门磁状态", // 0门磁吸合,指门已经完全关闭;1门磁未吸合,指门未完全关闭,可能处于打开中、打开到位、关闭中;-1门禁不在线
* "timePoke": 0 //更新时间戳
* }
* ]
* }
*/
JSONObject xgAGVQueryDoorStatus(JSONObject requestParam);
}

88
hd/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/AgvServiceImpl.java

@ -44,11 +44,15 @@ import org.nl.logger.BusinessLogger;
import org.nl.start.auto.run.NDCSocketConnectionAutoRun;
import org.nl.utils.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Slf4j
@Service
@ -2060,12 +2064,84 @@ public class AgvServiceImpl implements AgvService {
return ret;
}
public static void main(String[] args) {
String address = "L1-01-01";
if (address.indexOf("-") > 0) {
String str = address.substring(address.indexOf("-"), address.length());
address = address.substring(0, address.indexOf("-"));
System.out.println(address);
@Override
public JSONObject xgAGVControlDoorSwitch(JSONObject requestParam) {
try {
JSONObject requestWMSParam = new JSONObject();
requestWMSParam.put("device_code", requestParam.optString("deviceID"));
requestWMSParam.put("device_status", "1".equals(requestParam.optString("state")) ? "open" : "close");
JSONObject wmsResult = acsToWmsService.gccControlDoorSwitch(requestWMSParam);
JSONObject result = new JSONObject();
if (HttpStatus.OK.value() == wmsResult.optInt("status")) {
result.put("result", 0);
result.put("message", "操作成功");
} else {
result.put("result", -1);
result.put("message", wmsResult.optString("message"));
}
return result;
} catch (Exception e) {
JSONObject result = new JSONObject();
result.put("result", -1);
result.put("message", e.getMessage());
return result;
}
}
@Override
public JSONObject xgAGVQueryDoorStatus(JSONObject requestParam) {
String[] deviceIDs = requestParam.optString("deviceIDs").split(",");
if (deviceIDs.length == 1 && StrUtil.isBlank(deviceIDs[0])) {
JSONObject result = new JSONObject();
result.put("result", 0);
result.put("message", "操作成功");
return result;
}
try {
com.alibaba.fastjson.JSONArray wmsResult = acsToWmsService.gccQueryDoorStatus();
if (ObjectUtil.isEmpty(wmsResult)) {
JSONObject result = new JSONObject();
result.put("result", 0);
result.put("message", "操作成功");
result.put("data", Arrays.stream(deviceIDs)
.map(id -> {
JSONObject door = new JSONObject();
door.put("deviceID", id);
door.put("doorState", -1);
door.put("timePoke", System.currentTimeMillis());
return door;
}).collect(Collectors.toList()));
return result;
}
List<JSONObject> data = Arrays.stream(deviceIDs).map(id -> {
JSONObject door = new JSONObject();
door.put("deviceID", id);
List<Object> list = wmsResult.stream().filter(o -> id.equals(((com.alibaba.fastjson.JSONObject) o).getString("device_code"))).collect(Collectors.toList());
if (list.isEmpty()) {
door.put("doorState", -1);
} else {
com.alibaba.fastjson.JSONObject row = (com.alibaba.fastjson.JSONObject) list.get(0);
door.put("doorState", "close".equals(row.getString("device_status")) ? 0 : 1);
}
door.put("timePoke", System.currentTimeMillis());
return door;
}).collect(Collectors.toList());
JSONObject result = new JSONObject();
result.put("result", 0);
result.put("message", "操作成功");
result.put("data", data);
return result;
} catch (Exception e) {
JSONObject result = new JSONObject();
result.put("result", 0);
result.put("message", e.getMessage());
return result;
}
}
}

31
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java

@ -108,4 +108,35 @@ public interface AcsToWmsService {
HttpResponse queryDoorsStatus();
/**
* 六维广钞厂请求开门或关门
*
* @param requestWMSParam 示例{
* "device_code":"AD1",
* "device_status":"open"
* }
* @return 示例{
* "status": 200,
* "message": "任务状态反馈成功!",
* "data": {},
* "errArr": []
* }
*/
JSONObject gccControlDoorSwitch(JSONObject requestWMSParam);
/**
* 六维广钞厂查询自动门状态
*
* @return 示例[
* {
* "device_code":"AD1",
* "device_status":"open"
* },
* {
* "device_code":"AD2",
* "device_status":"open"
* }
* ]
*/
com.alibaba.fastjson.JSONArray gccQueryDoorStatus();
}

41
hd/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

@ -518,4 +518,45 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
return result;
}
@Override
public JSONObject gccControlDoorSwitch(JSONObject requestWMSParam) {
try {
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
AddressDto addressDto = addressService.findByCode("gccControlDoorSwitch");
log.info("gccControlDoorSwitch - 请求参数{}", requestWMSParam);
String responseBody = HttpRequest
.post(wmsurl + addressDto.getMethods_url())
.body(requestWMSParam.toString())
.execute()
.body();
log.info("gccControlDoorSwitch - 响应参数{}", responseBody);
return JSONObject.fromObject(responseBody);
} catch (Exception e) {
JSONObject result = new JSONObject();
result.put("status", HttpStatus.BAD_REQUEST.value());
result.put("message", e.getMessage());
return result;
}
}
@Override
public com.alibaba.fastjson.JSONArray gccQueryDoorStatus() {
try {
String wmsurl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
AddressDto addressDto = addressService.findByCode("gccQueryDoorStatus");
log.info("gccQueryDoorStatus - 请求");
String responseBody = HttpRequest
.get(wmsurl + addressDto.getMethods_url())
.execute()
.body();
log.info("gccControlDoorSwitch - 响应参数{}", responseBody);
return com.alibaba.fastjson.JSONArray.parseArray(responseBody);
} catch (Exception e) {
return new com.alibaba.fastjson.JSONArray();
}
}
}

2
hd/nladmin-system/src/main/resources/config/application-prod.yml

@ -8,7 +8,7 @@ spring:
druid:
db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:tg_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:gcc_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true&allowPublicKeyRetrieval=true
username: ${DB_USER:root}
password: ${DB_PWD:123456}
# 初始连接数

Loading…
Cancel
Save