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