add:新增agv充电功能

This commit is contained in:
2024-05-15 11:01:23 +08:00
parent dbb9403bf4
commit d82374f1f9
3 changed files with 53 additions and 0 deletions

View File

@@ -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);
}
}

View File

@@ -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);
}

View File

@@ -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;
}
}