rev:优化充电接口
This commit is contained in:
@@ -183,6 +183,6 @@ public interface AgvService {
|
|||||||
|
|
||||||
String queryDeviceStation();
|
String queryDeviceStation();
|
||||||
|
|
||||||
HttpResponse chargingQuest(JSONObject json);
|
// HttpResponse chargingQuest(JSONObject json);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1757,55 +1757,55 @@ public class AgvServiceImpl implements AgvService {
|
|||||||
return jo.toString();
|
return jo.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
// @Override
|
||||||
public HttpResponse chargingQuest(JSONObject json) {
|
// public HttpResponse chargingQuest(JSONObject json) {
|
||||||
log.info("agvCode参数:{}", json);
|
// log.info("agvCode参数:{}", json);
|
||||||
String inst_no = CodeUtil.getNewCode("INSTRUCT_NO");
|
// String inst_no = CodeUtil.getNewCode("INSTRUCT_NO");
|
||||||
if (ObjectUtil.isEmpty(json)){
|
// if (ObjectUtil.isEmpty(json)){
|
||||||
throw new BadRequestException("agv编码为空!");
|
// throw new BadRequestException("agv编码为空!");
|
||||||
}
|
// }
|
||||||
String agv_code = json.getString("agv_code");
|
// String agv_code = json.getString("agv_code");
|
||||||
JSONArray ja = new JSONArray();
|
// JSONArray ja = new JSONArray();
|
||||||
JSONObject orderjo = new JSONObject();
|
// JSONObject orderjo = new JSONObject();
|
||||||
//指定agv车号
|
// //指定agv车号
|
||||||
if (StrUtil.equals(agv_code,"1")){
|
// if (StrUtil.equals(agv_code,"1")){
|
||||||
orderjo.put("intendedVehicle", "HS 1#AGV");
|
// orderjo.put("intendedVehicle", "HS 1#AGV");
|
||||||
}else if (StrUtil.equals(agv_code,"2")){
|
// }else if (StrUtil.equals(agv_code,"2")){
|
||||||
orderjo.put("intendedVehicle", "HS 2#AGV");
|
// orderjo.put("intendedVehicle", "HS 2#AGV");
|
||||||
}
|
// }
|
||||||
JSONObject jo = new JSONObject();
|
// JSONObject jo = new JSONObject();
|
||||||
//指定agv充电位置
|
// //指定agv充电位置
|
||||||
jo.put("locationName", "Charge-100");
|
// jo.put("locationName", "Charge-100");
|
||||||
//指定agv操作码
|
// //指定agv操作码
|
||||||
jo.put("operation", "CHARGE");
|
// jo.put("operation", "CHARGE");
|
||||||
ja.add(jo);
|
// ja.add(jo);
|
||||||
orderjo.put("destinations",ja);
|
// orderjo.put("destinations",ja);
|
||||||
System.out.println("orderjo的值:"+orderjo);
|
// System.out.println("orderjo的值:"+orderjo);
|
||||||
log.info("下发agv指令参数:{}", orderjo.toString());
|
// log.info("下发agv指令参数:{}", orderjo.toString());
|
||||||
HttpResponse result = null;
|
// HttpResponse result = null;
|
||||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
|
// if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
|
||||||
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
|
// String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
|
||||||
String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
|
// String agvport = acsConfigService.findConfigFromCache().get(AcsConfig.AGVPORT);
|
||||||
|
//
|
||||||
agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + inst_no;
|
// agvurl = agvurl + ":" + agvport + "/v1/transportOrders/" + inst_no;
|
||||||
|
//
|
||||||
log.info("下发agv指令参数:{}", orderjo.toString());
|
// log.info("下发agv指令参数:{}", orderjo.toString());
|
||||||
|
//
|
||||||
try {
|
// try {
|
||||||
result = HttpRequest.post(agvurl)
|
// result = HttpRequest.post(agvurl)
|
||||||
.body(String.valueOf(orderjo))//表单内容
|
// .body(String.valueOf(orderjo))//表单内容
|
||||||
.timeout(20000)//超时,毫秒
|
// .timeout(20000)//超时,毫秒
|
||||||
.execute();
|
// .execute();
|
||||||
System.out.println(result);
|
// System.out.println(result);
|
||||||
log.info("chargingQuest----返回参数{}", result);
|
// log.info("chargingQuest----返回参数{}", result);
|
||||||
} catch (Exception e) {
|
// } catch (Exception e) {
|
||||||
throw new RuntimeException("下发agv失败!");
|
// throw new RuntimeException("下发agv失败!");
|
||||||
}
|
// }
|
||||||
} else {
|
// } else {
|
||||||
throw new RuntimeException("系统参数未配置!");
|
// throw new RuntimeException("系统参数未配置!");
|
||||||
}
|
// }
|
||||||
return result;
|
// return result;
|
||||||
}
|
// }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject createOrederData(Instruction inst, String inst_type) {
|
public JSONObject createOrederData(Instruction inst, String inst_type) {
|
||||||
|
|||||||
@@ -174,6 +174,6 @@ public class TaskController {
|
|||||||
@PostMapping("/chargingTask")
|
@PostMapping("/chargingTask")
|
||||||
//@PreAuthorize("@el.check('task:add')")
|
//@PreAuthorize("@el.check('task:add')")
|
||||||
public ResponseEntity<Object> chargingQuest(@RequestBody JSONObject json) {
|
public ResponseEntity<Object> chargingQuest(@RequestBody JSONObject json) {
|
||||||
return new ResponseEntity<>(agvService.chargingQuest(json), HttpStatus.OK);
|
return new ResponseEntity<>(taskService.chargingQuest(json), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -270,5 +270,5 @@ public interface TaskService {
|
|||||||
*/
|
*/
|
||||||
Integer querySameOriginTask(String code);
|
Integer querySameOriginTask(String code);
|
||||||
|
|
||||||
HttpResponse chargingQuest(String agv_code);
|
HttpResponse chargingQuest(JSONObject json);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1629,20 +1629,19 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpResponse chargingQuest(String agvCode) {
|
public HttpResponse chargingQuest(JSONObject json) {
|
||||||
log.info("agvCode参数:{}", agvCode);
|
log.info("agvCode参数:{}", json);
|
||||||
String inst_no = CodeUtil.getNewCode("INSTRUCT_NO");
|
String inst_no = CodeUtil.getNewCode("INSTRUCT_NO");
|
||||||
if (StrUtil.isEmpty(agvCode)){
|
if (ObjectUtil.isEmpty(json)){
|
||||||
throw new BadRequestException("agv编码为空!");
|
throw new BadRequestException("agv编码为空!");
|
||||||
}
|
}
|
||||||
com.alibaba.fastjson.JSONObject jsonObject = JSON.parseObject(agvCode);
|
String agv_code = json.getString("agv_code");
|
||||||
String code = jsonObject.getString("agv_code");
|
|
||||||
JSONArray ja = new JSONArray();
|
JSONArray ja = new JSONArray();
|
||||||
JSONObject orderjo = new JSONObject();
|
JSONObject orderjo = new JSONObject();
|
||||||
//指定agv车号
|
//指定agv车号
|
||||||
if (StrUtil.equals(code,"1")){
|
if (StrUtil.equals(agv_code,"1")){
|
||||||
orderjo.put("intendedVehicle", "HS 1#AGV");
|
orderjo.put("intendedVehicle", "HS 1#AGV");
|
||||||
}else if (StrUtil.equals(code,"2")){
|
}else if (StrUtil.equals(agv_code,"2")){
|
||||||
orderjo.put("intendedVehicle", "HS 2#AGV");
|
orderjo.put("intendedVehicle", "HS 2#AGV");
|
||||||
}
|
}
|
||||||
JSONObject jo = new JSONObject();
|
JSONObject jo = new JSONObject();
|
||||||
@@ -1652,6 +1651,8 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
|
|||||||
jo.put("operation", "CHARGE");
|
jo.put("operation", "CHARGE");
|
||||||
ja.add(jo);
|
ja.add(jo);
|
||||||
orderjo.put("destinations",ja);
|
orderjo.put("destinations",ja);
|
||||||
|
System.out.println("orderjo的值:"+orderjo);
|
||||||
|
log.info("下发agv指令参数:{}", orderjo.toString());
|
||||||
HttpResponse result = null;
|
HttpResponse result = null;
|
||||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
|
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.FORKAGV).toString(), "1")) {
|
||||||
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
|
String agvurl = acsConfigService.findConfigFromCache().get(AcsConfig.AGVURL);
|
||||||
|
|||||||
Reference in New Issue
Block a user