10 changed files with 901 additions and 41 deletions
@ -0,0 +1,167 @@ |
|||
package org.nl.system.service.quartz.task; |
|||
|
|||
import cn.hutool.core.date.DateUtil; |
|||
import cn.hutool.core.util.IdUtil; |
|||
import cn.hutool.core.util.StrUtil; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.apache.commons.lang3.ObjectUtils; |
|||
import org.nl.acs.common.base.CommonFinalParam; |
|||
import org.nl.acs.instruction.domain.Instruction; |
|||
import org.nl.acs.instruction.enums.InstructionStatusEnum; |
|||
import org.nl.acs.instruction.service.InstructionService; |
|||
import org.nl.acs.opc.DeviceAppService; |
|||
import org.nl.acs.opc.DeviceAppServiceImpl; |
|||
import org.nl.acs.route.service.RouteLineService; |
|||
import org.nl.acs.route.service.dto.RouteLineDto; |
|||
import org.nl.acs.task.enums.TaskStatusEnum; |
|||
import org.nl.acs.task.enums.TaskTypeEnum; |
|||
import org.nl.acs.task.service.TaskService; |
|||
import org.nl.acs.task.service.dto.TaskDto; |
|||
import org.nl.common.utils.SecurityUtils; |
|||
import org.nl.config.SpringContextHolder; |
|||
import org.nl.system.service.lucene.LuceneExecuteLogService; |
|||
import org.nl.system.service.lucene.dto.LuceneLogDto; |
|||
import org.nl.system.service.lucene.impl.LuceneExecuteLogServiceImpl; |
|||
import org.springframework.stereotype.Component; |
|||
|
|||
import java.util.Arrays; |
|||
import java.util.List; |
|||
|
|||
/** |
|||
* 自动创建指令 |
|||
*/ |
|||
@Slf4j |
|||
@Component |
|||
public class AutoCreateInst { |
|||
|
|||
/** |
|||
* 根据任务状态创建指令、生成下一条指令 |
|||
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货 |
|||
*/ |
|||
public void run() throws Exception { |
|||
log.info("自动生成指令" + DateUtil.now()); |
|||
TaskService taskserver = SpringContextHolder.getBean(TaskService.class); |
|||
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); |
|||
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); |
|||
DeviceAppService appService = SpringContextHolder.getBean(DeviceAppServiceImpl.class); |
|||
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogServiceImpl.class); |
|||
List<TaskDto> list = taskserver.queryAllByStatus("0"); |
|||
for (int i = 0; i < list.size(); i++) { |
|||
TaskDto acsTask = list.get(i); |
|||
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.AGV_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) { |
|||
continue; |
|||
} |
|||
if (StrUtil.equals(acsTask.getTask_type(), TaskTypeEnum.Truss_Task.getIndex()) && !StrUtil.startWith(acsTask.getTask_code(), "-")) { |
|||
continue; |
|||
} |
|||
String taskid = acsTask.getTask_id(); |
|||
String taskcode = acsTask.getTask_code(); |
|||
String task_type = acsTask.getTask_type(); |
|||
String vehiclecode = acsTask.getVehicle_code(); |
|||
String priority = acsTask.getPriority(); |
|||
String is_send = acsTask.getIs_send(); |
|||
|
|||
String start_device_code = acsTask.getStart_device_code(); |
|||
String start_point_code = acsTask.getStart_point_code(); |
|||
|
|||
String put_device_code = acsTask.getPut_device_code(); |
|||
String put_point_code = acsTask.getPut_point_code(); |
|||
|
|||
String next_device_code = acsTask.getNext_device_code(); |
|||
String next_point_code = acsTask.getNext_point_code(); |
|||
|
|||
String route_plan_code = acsTask.getRoute_plan_code(); |
|||
String vehicleType = acsTask.getVehicle_type(); |
|||
String agv_system_type = acsTask.getAgv_system_type(); |
|||
|
|||
String start_height = acsTask.getStart_height(); |
|||
String next_height = acsTask.getNext_height(); |
|||
|
|||
|
|||
if (StrUtil.equals(is_send, "0")) { |
|||
continue; |
|||
} |
|||
|
|||
//校验路由关系
|
|||
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code); |
|||
if (ObjectUtils.isEmpty(shortPathsList)) { |
|||
acsTask.setRemark("路由不通无法生成指令"); |
|||
taskserver.updateByCodeFromCache(acsTask); |
|||
continue; |
|||
} |
|||
|
|||
if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE)) { |
|||
continue; |
|||
} |
|||
|
|||
RouteLineDto routeLineDto = shortPathsList.get(0); |
|||
String path = routeLineDto.getPath(); |
|||
String type = routeLineDto.getType(); |
|||
String[] str = path.split("->"); |
|||
List<String> pathlist = Arrays.asList(str); |
|||
int index = 0; |
|||
for (int m = 0; m < pathlist.size(); m++) { |
|||
if (pathlist.get(m).equals(start_device_code)) { |
|||
index = m + 1; |
|||
break; |
|||
} |
|||
} |
|||
next_device_code = pathlist.get(index); |
|||
|
|||
if (StrUtil.equals(appService.findDeviceTypeByCode(next_device_code), "storage")) { |
|||
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z(); |
|||
} else { |
|||
next_point_code = next_device_code; |
|||
} |
|||
|
|||
Instruction instdto = new Instruction(); |
|||
instdto.setInstruction_type(task_type); |
|||
instdto.setInstruction_id(IdUtil.simpleUUID()); |
|||
instdto.setRoute_plan_code(route_plan_code); |
|||
instdto.setRemark(acsTask.getRemark()); |
|||
instdto.setMaterial(acsTask.getMaterial()); |
|||
instdto.setQuantity(acsTask.getQuantity()); |
|||
instdto.setTask_id(taskid); |
|||
instdto.setTask_code(taskcode); |
|||
instdto.setVehicle_code(vehiclecode); |
|||
String now = DateUtil.now(); |
|||
instdto.setCreate_time(now); |
|||
instdto.setCreate_by(SecurityUtils.getCurrentNickName()); |
|||
|
|||
instdto.setStart_device_code(start_device_code); |
|||
instdto.setStart_point_code(start_point_code); |
|||
instdto.setPut_device_code(put_device_code); |
|||
instdto.setPut_point_code(put_point_code); |
|||
instdto.setNext_device_code(next_device_code); |
|||
instdto.setNext_point_code(next_point_code); |
|||
|
|||
|
|||
instdto.setPriority(priority); |
|||
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex()); |
|||
instdto.setExecute_device_code(start_point_code); |
|||
instdto.setVehicle_type(vehicleType); |
|||
instdto.setAgv_system_type(agv_system_type); |
|||
instdto.setStart_height(start_height); |
|||
instdto.setNext_height(next_height); |
|||
|
|||
try { |
|||
instructionService.create(instdto); |
|||
} catch (Exception e) { |
|||
acsTask.setRemark(e.getMessage()); |
|||
taskserver.updateByCodeFromCache(acsTask); |
|||
LuceneLogDto logDto = LuceneLogDto.builder() |
|||
.device_code("定时创建指令失败") |
|||
.content(e.getMessage()) |
|||
.build(); |
|||
logDto.setLog_level(2); |
|||
luceneExecuteLogService.deviceExecuteLog(logDto); |
|||
continue; |
|||
} |
|||
//创建指令后修改任务状态
|
|||
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); |
|||
acsTask.setUpdate_time(DateUtil.now()); |
|||
taskserver.update(acsTask); |
|||
|
|||
} |
|||
} |
|||
} |
@ -0,0 +1,187 @@ |
|||
<?xml version="1.0" encoding="UTF-8"?> |
|||
<project version="4"> |
|||
<component name="BranchesTreeState"> |
|||
<expand> |
|||
<path> |
|||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" /> |
|||
<item name="LOCAL_ROOT" type="e8cecc67:BranchNodeDescriptor" /> |
|||
</path> |
|||
<path> |
|||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" /> |
|||
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" /> |
|||
</path> |
|||
<path> |
|||
<item name="ROOT" type="e8cecc67:BranchNodeDescriptor" /> |
|||
<item name="REMOTE_ROOT" type="e8cecc67:BranchNodeDescriptor" /> |
|||
<item name="GROUP_NODE:origin" type="e8cecc67:BranchNodeDescriptor" /> |
|||
</path> |
|||
</expand> |
|||
<select /> |
|||
</component> |
|||
<component name="ChangeListManager"> |
|||
<list default="true" id="a019a4eb-08e9-4982-8f64-7b4fa41c94ac" name="Default Changelist" comment=""> |
|||
<change afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateInst.java" afterDir="false" /> |
|||
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/one/CreateTaskRequest.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/one/CreateTaskRequest.java" afterDir="false" /> |
|||
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/AcsToWmsController.java" afterDir="false" /> |
|||
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/rest/WmsToAcsController.java" afterDir="false" /> |
|||
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/AcsToWmsService.java" afterDir="false" /> |
|||
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/WmsToAcsService.java" afterDir="false" /> |
|||
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java" afterDir="false" /> |
|||
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/service/impl/WmsToAcsServiceImpl.java" afterDir="false" /> |
|||
<change beforePath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java" beforeDir="false" afterPath="$PROJECT_DIR$/../../acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/service/impl/TaskServiceImpl.java" afterDir="false" /> |
|||
</list> |
|||
<option name="SHOW_DIALOG" value="false" /> |
|||
<option name="HIGHLIGHT_CONFLICTS" value="true" /> |
|||
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" /> |
|||
<option name="LAST_RESOLUTION" value="IGNORE" /> |
|||
</component> |
|||
<component name="Git.Settings"> |
|||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$/../.." /> |
|||
</component> |
|||
<component name="MavenImportPreferences"> |
|||
<option name="generalSettings"> |
|||
<MavenGeneralSettings> |
|||
<option name="localRepository" value="D:\JavaDevelop" /> |
|||
<option name="mavenHome" value="$PROJECT_DIR$/../../../../../maven/apache-maven-3.6.1" /> |
|||
<option name="userSettingsFile" value="D:\maven\apache-maven-3.6.1\conf\settings.xml" /> |
|||
</MavenGeneralSettings> |
|||
</option> |
|||
</component> |
|||
<component name="ProjectId" id="2yOBIGhJzTvRKwuadnnXUR9FtiT" /> |
|||
<component name="ProjectLevelVcsManager" settingsEditedManually="true" /> |
|||
<component name="ProjectViewState"> |
|||
<option name="hideEmptyMiddlePackages" value="true" /> |
|||
<option name="showLibraryContents" value="true" /> |
|||
</component> |
|||
<component name="PropertiesComponent"> |
|||
<property name="RequestMappingsPanelOrder0" value="0" /> |
|||
<property name="RequestMappingsPanelOrder1" value="1" /> |
|||
<property name="RequestMappingsPanelWidth0" value="75" /> |
|||
<property name="RequestMappingsPanelWidth1" value="75" /> |
|||
<property name="RunOnceActivity.OpenProjectViewOnStart" value="true" /> |
|||
<property name="RunOnceActivity.ShowReadmeOnStart" value="true" /> |
|||
<property name="WebServerToolWindowFactoryState" value="false" /> |
|||
<property name="aspect.path.notification.shown" value="true" /> |
|||
<property name="last_opened_file_path" value="$PROJECT_DIR$" /> |
|||
<property name="node.js.detected.package.eslint" value="true" /> |
|||
<property name="node.js.detected.package.tslint" value="true" /> |
|||
<property name="node.js.path.for.package.eslint" value="project" /> |
|||
<property name="node.js.path.for.package.tslint" value="project" /> |
|||
<property name="node.js.selected.package.eslint" value="(autodetect)" /> |
|||
<property name="node.js.selected.package.tslint" value="(autodetect)" /> |
|||
<property name="settings.editor.selected.configurable" value="MavenSettings" /> |
|||
</component> |
|||
<component name="ReactorSettings"> |
|||
<option name="notificationShown" value="true" /> |
|||
</component> |
|||
<component name="RebelAgentSelection"> |
|||
<selection>jr</selection> |
|||
</component> |
|||
<component name="RunManager"> |
|||
<configuration name="AppRun" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot"> |
|||
<module name="nlsso-server" /> |
|||
<option name="SPRING_BOOT_MAIN_CLASS" value="org.nl.AppRun" /> |
|||
<method v="2"> |
|||
<option name="Make" enabled="true" /> |
|||
</method> |
|||
</configuration> |
|||
</component> |
|||
<component name="SshConsoleOptionsProvider"> |
|||
<option name="myEncoding" value="UTF-8" /> |
|||
</component> |
|||
<component name="SvnConfiguration"> |
|||
<configuration /> |
|||
</component> |
|||
<component name="TaskManager"> |
|||
<task active="true" id="Default" summary="Default task"> |
|||
<changelist id="a019a4eb-08e9-4982-8f64-7b4fa41c94ac" name="Default Changelist" comment="" /> |
|||
<created>1749695657075</created> |
|||
<option name="number" value="Default" /> |
|||
<option name="presentableId" value="Default" /> |
|||
<updated>1749695657075</updated> |
|||
<workItem from="1749695660750" duration="16000" /> |
|||
<workItem from="1749696388346" duration="6162000" /> |
|||
</task> |
|||
<servers /> |
|||
</component> |
|||
<component name="TypeScriptGeneratedFilesManager"> |
|||
<option name="version" value="2" /> |
|||
</component> |
|||
<component name="Vcs.Log.Tabs.Properties"> |
|||
<option name="TAB_STATES"> |
|||
<map> |
|||
<entry key="MAIN"> |
|||
<value> |
|||
<State /> |
|||
</value> |
|||
</entry> |
|||
</map> |
|||
</option> |
|||
</component> |
|||
<component name="WindowStateProjectService"> |
|||
<state x="549" y="171" key="FileChooserDialogImpl" timestamp="1749696574867"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state x="549" y="171" key="FileChooserDialogImpl/0.0.1536.834@0.0.1536.834" timestamp="1749696574867" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.0.bottom" timestamp="1749710140243"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.0.bottom/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.0.center" timestamp="1749710140242"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.0.center/0.0.1536.834@0.0.1536.834" timestamp="1749710140242" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.0.left" timestamp="1749710140242"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.0.left/0.0.1536.834@0.0.1536.834" timestamp="1749710140242" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.0.right" timestamp="1749710140243"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.0.right/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.1.bottom" timestamp="1749710140243"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.1.bottom/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.1.center" timestamp="1749710140243"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.1.center/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.1.left" timestamp="1749710140243"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.1.left/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.1.right" timestamp="1749710140243"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.1.right/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.2.bottom" timestamp="1749710140243"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.2.bottom/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.2.center" timestamp="1749710140243"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.2.center/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.2.left" timestamp="1749710140243"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.2.left/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" /> |
|||
<state width="1493" height="497" key="GridCell.Tab.2.right" timestamp="1749710140243"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state width="1493" height="497" key="GridCell.Tab.2.right/0.0.1536.834@0.0.1536.834" timestamp="1749710140243" /> |
|||
<state x="270" y="61" key="SettingsEditor" timestamp="1749696623589"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state x="270" y="61" key="SettingsEditor/0.0.1536.834@0.0.1536.834" timestamp="1749696623589" /> |
|||
<state x="467" y="149" width="602" height="536" key="find.popup" timestamp="1749708680849"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state x="467" y="149" width="602" height="536" key="find.popup/0.0.1536.834@0.0.1536.834" timestamp="1749708680849" /> |
|||
<state x="431" y="155" width="672" height="678" key="search.everywhere.popup" timestamp="1749708494721"> |
|||
<screen x="0" y="0" width="1536" height="834" /> |
|||
</state> |
|||
<state x="431" y="155" width="672" height="678" key="search.everywhere.popup/0.0.1536.834@0.0.1536.834" timestamp="1749708494721" /> |
|||
</component> |
|||
</project> |
Loading…
Reference in new issue