zy-acs-manager/src/main/java/com/zy/acs/manager/core/scheduler/KernelScheduler.java
@@ -37,6 +37,8 @@ private final ReentrantLock lock = new ReentrantLock(Boolean.TRUE); @Autowired private AgvService agvService; @Autowired private BusService busService; @Autowired private TaskService taskService; @@ -154,13 +156,18 @@ @Scheduled(cron = "0/1 * * * * ? ") private void autoLocToLoc() { if (!configService.getVal("TaskAssignMode", Boolean.class)) { return; } int numOfAgv = 2; int maxCapacity = 1 * numOfAgv; AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, AgvModelType.CTU_BOX_TRANSPORT_AGV.toString())); if (null != agvModel) { maxCapacity = agvModel.getBackpack() * numOfAgv; if (0 < busService.count(new LambdaQueryWrapper<Bus>().in(Bus::getBusSts, BusStsType.RECEIVE.val(), BusStsType.PROGRESS.val()))) { return; } int numOfStockLocList; int agvCount = agvService.count(new LambdaQueryWrapper<Agv>().eq(Agv::getStatus, StatusType.ENABLE.val)); AgvModel agvModel = agvModelService.getOne(new LambdaQueryWrapper<AgvModel>().eq(AgvModel::getType, AgvModelType.CTU_BOX_TRANSPORT_AGV.toString())); if (null == agvModel || 0 == agvCount) { return; } int maxCapacity = agvModel.getBackpack() * Math.min(agvCount, 2); // STOCK List<Loc> stockList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.STOCK.val())); if (Cools.isEmpty(stockList)) { @@ -170,7 +177,7 @@ if (stockList.size() > maxCapacity) { stockList = stockList.subList(0, maxCapacity); } numOfStockLocList = stockList.size(); int numOfStockLocList = stockList.size(); // IDLE List<Loc> idleList = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getLocSts, LocStsType.IDLE.val())); zy-acs-manager/src/main/java/com/zy/acs/manager/core/service/FaultProcessor.java
@@ -54,7 +54,7 @@ vehFaultRec.setFaultName(null != errorType ? errorType.desc : "undefined"); vehFaultRec.setFaultLev(agv_04_up.getFaultLevel()); vehFaultRec.setFaultData(GsonUtils.toJson(Cools.add("data1", agv_04_up.getData1()).add("data2", agv_04_up.getData2()))); vehFaultRec.setHappenTime(errorTime); vehFaultRec.setHappenTime(new Date()); vehFaultRec.setProtocol(RadixTools.bytesToHexStr(agv_04_up.writeToBytes())); if (!vehFaultRecService.save(vehFaultRec)) { @@ -64,15 +64,6 @@ } catch (Exception e) { log.error("FaultProcessor", e); } } public static void main(String[] args) { short ss = 8193; // 2001 byte[] bytes = RadixTools.shortToByte(ss); // byte[] reverse = Utils.reverse(bytes); System.out.println(RadixTools.bytesToHexStr(bytes)); } } zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/BusService.java
@@ -19,4 +19,6 @@ List<Bus> selectBySts(BusStsType busStsType, String memo); void checkoutComplete(Long busId); } zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/BusServiceImpl.java
@@ -3,22 +3,22 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.zy.acs.framework.common.BaseRes; import com.zy.acs.framework.common.Cools; import com.zy.acs.framework.exception.CoolException; import com.zy.acs.manager.common.domain.TaskDto; import com.zy.acs.manager.manager.controller.param.OpenBusSubmitParam; import com.zy.acs.manager.manager.entity.Bus; import com.zy.acs.manager.manager.entity.Task; import com.zy.acs.manager.manager.enums.BusStsType; import com.zy.acs.manager.manager.enums.TaskStsType; import com.zy.acs.manager.manager.mapper.BusMapper; import com.zy.acs.manager.manager.service.BusService; import com.zy.acs.framework.common.Cools; import com.zy.acs.manager.manager.service.TaskService; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.*; @Slf4j @Service("busService") @@ -120,4 +120,32 @@ return this.list(wrapper); } @Override public void checkoutComplete(Long busId) { if (null == busId) { return; } int taskTotalCount = taskService.count(new LambdaQueryWrapper<Task>().eq(Task::getBusId, busId)); List<Task> actualDoneTasks = taskService.list(new LambdaQueryWrapper<Task>() .eq(Task::getBusId, busId) .in(Task::getTaskSts , TaskStsType.COMPLETE.val() , TaskStsType.CANCEL.val() ) ); if (taskTotalCount == actualDoneTasks.size()) { Bus bus = this.getById(busId); long cancelTasksCount = actualDoneTasks.stream().filter(task -> TaskStsType.CANCEL.val() == task.getTaskSts()).count(); if (cancelTasksCount == taskTotalCount) { bus.setBusSts(BusStsType.CANCEL.val()); } else { bus.setBusSts(BusStsType.FINISH.val()); } bus.setUpdateTime(new Date()); if (!this.updateById(bus)) { throw new CoolException("Bus[{" + busId + "}] failed to update"); } } } } zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/TaskServiceImpl.java
@@ -25,6 +25,8 @@ public class TaskServiceImpl extends ServiceImpl<TaskMapper, Task> implements TaskService { @Autowired private BusService busService; @Autowired private CodeService codeService; @Autowired private LocService locService; @@ -94,6 +96,7 @@ if (!this.updateById(task)) { throw new CoolException(BaseRes.ERROR); } busService.checkoutComplete(task.getBusId()); return Boolean.TRUE; } @@ -112,6 +115,7 @@ if (!this.updateById(task)) { throw new CoolException(BaseRes.ERROR); } busService.checkoutComplete(task.getBusId()); return Boolean.TRUE; }