Browse Source

add:新增agv充电功能

master
涂强 8 months ago
parent
commit
d82374f1f9
  1. 8
      hd/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java
  2. 2
      hd/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java
  3. 43
      hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

8
hd/nladmin-system/src/main/java/org/nl/acs/task/rest/TaskController.java

@ -166,4 +166,12 @@ public class TaskController {
String s = acsToWmsService.applyTaskToWms(device_code, container_code, height, weight);
return new ResponseEntity<>(s, HttpStatus.CREATED);
}
@Log("请求充电任务")
@ApiOperation("请求充电任务")
@PostMapping("/chargingTask")
//@PreAuthorize("@el.check('task:add')")
public ResponseEntity<Object> chargingQuest(@RequestBody String agv_code) {
return new ResponseEntity<>(taskService.chargingQuest(agv_code), HttpStatus.OK);
}
}

2
hd/nladmin-system/src/main/java/org/nl/acs/task/service/TaskService.java

@ -1,6 +1,7 @@
package org.nl.acs.task.service;
import cn.hutool.http.HttpResponse;
import net.sf.json.JSONObject;
import org.nl.acs.task.service.dto.TaskDto;
import org.springframework.data.domain.Pageable;
@ -269,4 +270,5 @@ public interface TaskService {
*/
Integer querySameOriginTask(String code);
HttpResponse chargingQuest(String agv_code);
}

43
hd/nladmin-system/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java

@ -7,6 +7,7 @@ import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSON;
import lombok.RequiredArgsConstructor;
@ -1627,4 +1628,46 @@ public class TaskServiceImpl implements TaskService, ApplicationAutoInitial {
return num;
}
@Override
public HttpResponse chargingQuest(String agvCode) {
String inst_no = CodeUtil.getNewCode("INSTRUCT_NO");
if (StrUtil.isEmpty(agvCode)){
throw new BadRequestException("agv编码为空!");
}
JSONArray ja = new JSONArray();
JSONObject orderjo = new JSONObject();
//指定agv车号
orderjo.put("intendedVehicle", agvCode);
JSONObject jo = new JSONObject();
//指定agv充电位置
jo.put("locationName", "100");
//指定agv操作码
jo.put("operation", "Charge");
ja.add(jo);
orderjo.put("destinations",ja);
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;
}
}

Loading…
Cancel
Save