| | |
| | | |
| | | private Integer serial = -1; |
| | | |
| | | private long time = 0; |
| | | |
| | | public DynamicNode() {} |
| | | |
| | | public DynamicNode(String vehicle) { |
| | |
| | | this.serial = serial; |
| | | } |
| | | |
| | | public DynamicNode(String vehicle, Integer serial, long time) { |
| | | this.vehicle = vehicle; |
| | | this.serial = serial; |
| | | this.time = time; |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | DynamicNode dynamicNode = dynamicMatrix[codeMatrixIdx[0]][codeMatrixIdx[1]]; |
| | | |
| | | |
| | | Integer serial = dynamicNode.getSerial(); |
| | | long time = dynamicNode.getTime(); |
| | | |
| | | List<String> resetCodeList = new ArrayList<>(); |
| | | |
| | | for (int i = 0; i < dynamicMatrix.length; i++) { |
| | | for (int j = 0; j < dynamicMatrix[i].length; j++) { |
| | | |
| | | if (i == codeMatrixIdx[0] && j == codeMatrixIdx[1]) { continue; } |
| | | |
| | | DynamicNode node = dynamicMatrix[i][j]; |
| | | if (node.getVehicle().equals(agvNo) && node.getSerial() < serial) { |
| | | if (node.getVehicle().equals(agvNo)) { |
| | | if (node.getSerial() < serial || node.getTime() != time) { |
| | | resetCodeList.add(codeMatrix[i][j]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!Cools.isEmpty(resetCodeList)) { |
| | | |
| | |
| | | import com.zy.acs.manager.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.jdbc.core.JdbcTemplate; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.Collections; |
| | | import java.util.List; |
| | | |
| | | /** |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | // http://localhost:8088/demo/auto/go/patrol?count=10 |
| | | @GetMapping("/auto/go/patrol") |
| | | public R autoGoPatrol(@RequestParam(required = false, defaultValue = "5") Integer count) { |
| | | List<Agv> list = agvService.list(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val)); |
| | | Collections.shuffle(list); |
| | | List<Agv> agvs = list.subList(0, count); |
| | | int result = 0; |
| | | for (Agv agv : agvs) { |
| | | patrolService.startupPatrol(agv.getUuid()); |
| | | result++; |
| | | } |
| | | return R.ok().add(result); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | Integer serial = dynamicNode.getSerial(); |
| | | long time = dynamicNode.getTime(); |
| | | |
| | | List<String> resetCodeList = new ArrayList<>(); |
| | | |
| | | for (int i = 0; i < dynamicMatrix.length; i++) { |
| | | for (int j = 0; j < dynamicMatrix[i].length; j++) { |
| | | |
| | | if (i == codeMatrixIdx[0] && j == codeMatrixIdx[1]) { continue; } |
| | | |
| | | DynamicNode node = dynamicMatrix[i][j]; |
| | | if (node.getVehicle().equals(agvNo) && node.getSerial() < serial) { |
| | | if (node.getVehicle().equals(agvNo)) { |
| | | if (node.getSerial() < serial || node.getTime() != time) { |
| | | resetCodeList.add(codeMatrix[i][j]); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (!Cools.isEmpty(resetCodeList)) { |
| | | |
| | |
| | | if (Cools.isEmpty(codeList, vehicle)) { |
| | | return; |
| | | } |
| | | long time = System.currentTimeMillis() / 1000; |
| | | int serial = 1; |
| | | for (String code : codeList) { |
| | | int[] node = getCodeMatrixIdx(lev, code); |
| | | dynamicMatrix[node[0]][node[1]] = new DynamicNode(vehicle, serial); |
| | | dynamicMatrix[node[0]][node[1]] = new DynamicNode(vehicle, serial, time); |
| | | serial++; |
| | | } |
| | | } else { |
| | |
| | | |
| | | private Integer serial = -1; |
| | | |
| | | private long time = 0; |
| | | |
| | | public DynamicNode() {} |
| | | |
| | | public DynamicNode(String vehicle) { |
| | |
| | | this.serial = serial; |
| | | } |
| | | |
| | | public DynamicNode(String vehicle, Integer serial, long time) { |
| | | this.vehicle = vehicle; |
| | | this.serial = serial; |
| | | this.time = time; |
| | | } |
| | | } |
| | |
| | | # 将 dynamicMatrix 转换为 numpy 结构化数组 |
| | | def convert_to_structured_array(dynamicMatrix): |
| | | # 定义结构化数组的 dtype |
| | | dtype = [('serial', int), ('vehicle', 'U2')] |
| | | dtype = [('serial', int), ('vehicle', 'U2'), ('time', int)] |
| | | |
| | | # 确保每个字典包含所有字段 |
| | | structured_list = [] |
| | | for row in dynamicMatrix: |
| | | for d in row: |
| | | # 提取字段,确保 'time' 存在,否则设置为默认值(例如 0.0) |
| | | serial = d.get('serial', 0) |
| | | vehicle = d.get('vehicle', '0') |
| | | time_val = d.get('time', 0) |
| | | structured_list.append((serial, vehicle, time_val)) |
| | | |
| | | # 将嵌套的列表转换为结构化数组 |
| | | structured_array = np.array([tuple(d.values()) for row in dynamicMatrix for d in row], dtype=dtype) |
| | | structured_array = np.array(structured_list, dtype=dtype) |
| | | # 重塑为原始的二维形状 |
| | | return structured_array.reshape(len(dynamicMatrix), -1) |
| | | |