Merge branch 'Four-Way-Rack' of http://47.97.1.152:5880/r/zy-asrs-master into Four-Way-Rack
| | |
| | | import React, { useEffect, useRef, useState } from "react"; |
| | | import { getToken } from '@/utils/token-util' |
| | | import { Badge, Descriptions } from 'antd'; |
| | | import Http from '@/utils/http'; |
| | | import { Badge, Button, Descriptions, Drawer, Input, Card, Select, message } from 'antd'; |
| | | import { |
| | | PageContainer, |
| | | } from '@ant-design/pro-components'; |
| | | |
| | | let items = [ |
| | | { |
| | | key: '1', |
| | | label: '任务号', |
| | | children: '1', |
| | | }, |
| | | { |
| | | key: '2', |
| | | label: '工作状态', |
| | | children: <Badge status="processing" text="Running" />, |
| | | }, |
| | | { |
| | | key: '3', |
| | | label: '设备状态', |
| | | children: <Badge status="processing" text="Running" />, |
| | | }, |
| | | { |
| | | key: '4', |
| | | label: '坐标码', |
| | | children: '1,2,3', |
| | | }, |
| | | { |
| | | key: '5', |
| | | label: '电量', |
| | | children: '50%', |
| | | }, |
| | | { |
| | | key: '6', |
| | | label: '错误码', |
| | | children: '0', |
| | | }, |
| | | { |
| | | key: '7', |
| | | label: '顶升状态', |
| | | children: 'Y', |
| | | }, |
| | | { |
| | | key: '8', |
| | | label: '充电状态', |
| | | children: 'Y', |
| | | }, |
| | | { |
| | | key: '9', |
| | | label: '作业标记', |
| | | children: 'Y', |
| | | }, |
| | | { |
| | | key: '10', |
| | | label: '跑库开关', |
| | | children: 'Y', |
| | | }, |
| | | ]; |
| | | import './index.less' |
| | | |
| | | const Main = () => { |
| | | const [deviceInfos, setDeviceInfos] = useState([]); |
| | | const [ws, setWs] = useState(null); |
| | | const [openOpera, setOpenOpera] = useState(false); |
| | | const [currentData, setCurrentData] = useState(null); |
| | | const [targetLoc, setTargetLoc] = useState(""); |
| | | |
| | | useEffect(() => { |
| | | var newWs = new WebSocket("ws://127.0.0.1:9090/wcs/ws/shuttle/websocket"); |
| | |
| | | }, []) |
| | | |
| | | useEffect(() => { |
| | | |
| | | if (ws) { |
| | | ws.onopen = function () { |
| | | console.log("open"); |
| | |
| | | })) |
| | | } |
| | | |
| | | return ( |
| | | <PageContainer |
| | | header={{ |
| | | breadcrumb: {}, |
| | | }} |
| | | > |
| | | <div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'space-around' }}> |
| | | {deviceInfos.map(item => { |
| | | if(item == null) { |
| | | return; |
| | | } |
| | | let tmpTitle = item.shuttleNo + "号四向车" |
| | | let tmpData = [ |
| | | { |
| | | key: '1', |
| | | label: '任务号', |
| | | children: item.taskNo, |
| | | }, |
| | | { |
| | | key: '2', |
| | | label: '工作状态', |
| | | children: <Badge status="processing" text={item.protocolStatusType} />, |
| | | }, |
| | | { |
| | | key: '3', |
| | | label: '设备状态', |
| | | children: <Badge status="processing" text={item.deviceStatus$} />, |
| | | }, |
| | | { |
| | | key: '4', |
| | | label: '坐标码', |
| | | children: item.currentCode, |
| | | }, |
| | | { |
| | | key: '5', |
| | | label: '电量', |
| | | children: item.batteryPower, |
| | | }, |
| | | { |
| | | key: '6', |
| | | label: '错误码', |
| | | children: '0', |
| | | }, |
| | | { |
| | | key: '7', |
| | | label: '顶升状态', |
| | | children: item.hasLift ? 'Y' : 'N', |
| | | }, |
| | | { |
| | | key: '8', |
| | | label: '充电状态', |
| | | children: item.hasCharge ? 'Y' : 'N', |
| | | }, |
| | | { |
| | | key: '9', |
| | | label: '作业标记', |
| | | children: item.pakMk ? 'Y' : 'N', |
| | | }, |
| | | { |
| | | key: '10', |
| | | label: '跑库开关', |
| | | children: item.moveLoc ? 'Y' : 'N', |
| | | }, |
| | | { |
| | | key: '11', |
| | | label: '运行方向', |
| | | children: item.runDirection, |
| | | }, |
| | | { |
| | | key: '12', |
| | | label: '是否有托盘', |
| | | children: item.hasPallet ? 'Y' : 'N', |
| | | }, |
| | | ]; |
| | | return <div key={item.id} style={{ width: '45%' }}> |
| | | <Descriptions size="small" title={tmpTitle} bordered items={tmpData} /> |
| | | const showOpera = (data) => { |
| | | setOpenOpera(true); |
| | | console.log(data); |
| | | setCurrentData(data); |
| | | }; |
| | | |
| | | const closeOpera = () => { |
| | | setOpenOpera(false); |
| | | }; |
| | | |
| | | const targetLocChange = (e) => { |
| | | setTargetLoc(e.target.value) |
| | | } |
| | | |
| | | const shuttleOperator = async (type) => { |
| | | if (type == 'moveLoc') { |
| | | if (targetLoc == '') { |
| | | message.warning('请输入目标位置'); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | try { |
| | | const resp = await Http.doPost('api/basShuttle/operator/shuttle', { |
| | | shuttleNo: currentData.shuttleNo, |
| | | shuttleTaskMode: type, |
| | | targetLocNo: targetLoc |
| | | }); |
| | | if (resp.code === 200) { |
| | | message.success("请求成功"); |
| | | return true; |
| | | } else { |
| | | message.warning(resp.msg); |
| | | return false; |
| | | } |
| | | } catch (error) { |
| | | message.warning("请求失败"); |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | let codeContent = (<PageContainer |
| | | header={{ |
| | | breadcrumb: {}, |
| | | }} |
| | | > |
| | | <div style={{ display: 'flex', flexWrap: 'wrap', justifyContent: 'space-around' }}> |
| | | {deviceInfos.map(item => { |
| | | if (item == null) { |
| | | return; |
| | | } |
| | | let tmpTitle = item.shuttleNo + "号四向车" |
| | | let tmpData = [ |
| | | { |
| | | key: '1', |
| | | label: '任务号', |
| | | children: item.taskNo, |
| | | }, |
| | | { |
| | | key: '2', |
| | | label: '工作状态', |
| | | children: <Badge status="processing" text={item.protocolStatusType} />, |
| | | }, |
| | | { |
| | | key: '3', |
| | | label: '设备状态', |
| | | children: <Badge status="processing" text={item.deviceStatus$} />, |
| | | }, |
| | | { |
| | | key: '4', |
| | | label: '坐标码', |
| | | children: item.currentCode, |
| | | }, |
| | | { |
| | | key: '5', |
| | | label: '电量', |
| | | children: item.batteryPower, |
| | | }, |
| | | { |
| | | key: '6', |
| | | label: '错误码', |
| | | children: '0', |
| | | }, |
| | | { |
| | | key: '7', |
| | | label: '顶升状态', |
| | | children: item.hasLift ? 'Y' : 'N', |
| | | }, |
| | | { |
| | | key: '8', |
| | | label: '充电状态', |
| | | children: item.hasCharge ? 'Y' : 'N', |
| | | }, |
| | | { |
| | | key: '9', |
| | | label: '作业标记', |
| | | children: item.pakMk ? 'Y' : 'N', |
| | | }, |
| | | { |
| | | key: '10', |
| | | label: '跑库开关', |
| | | children: item.moveLoc ? 'Y' : 'N', |
| | | }, |
| | | { |
| | | key: '11', |
| | | label: '运行方向', |
| | | children: item.runDirection, |
| | | }, |
| | | { |
| | | key: '12', |
| | | label: '是否有托盘', |
| | | children: item.hasPallet ? 'Y' : 'N', |
| | | }, |
| | | ]; |
| | | return <div key={item.id} style={{ width: '45%' }}> |
| | | <div style={{ marginBottom: '10px' }}> |
| | | <span style={{ marginRight: '10px' }}>{tmpTitle}</span> |
| | | <Button type="primary" onClick={() => showOpera(item)}>操作</Button> |
| | | </div> |
| | | })} |
| | | </div> |
| | | </PageContainer> |
| | | ) |
| | | <Descriptions size="small" bordered items={tmpData} /> |
| | | </div> |
| | | })} |
| | | </div> |
| | | </PageContainer>); |
| | | |
| | | if (currentData) { |
| | | codeContent = ( |
| | | <> |
| | | {codeContent} |
| | | <Drawer title="操作面板" onClose={closeOpera} open={openOpera}> |
| | | <h2 style={{ marginBottom: '15px' }}>{currentData.shuttleNo}号四向车</h2> |
| | | <div style={{ marginBottom: '15px' }}> |
| | | <Card title="移动指令" style={{ width: 300 }}> |
| | | <p> |
| | | <Input addonBefore="目标位置" defaultValue="1-1-1" onChange={targetLocChange} /> |
| | | </p> |
| | | <p> |
| | | <Button onClick={() => shuttleOperator('moveLoc')}>移动到目标位置</Button> |
| | | </p> |
| | | </Card> |
| | | </div> |
| | | |
| | | <div style={{ marginBottom: '15px' }}> |
| | | <Card title="相关指令" style={{ width: 300 }}> |
| | | <div className="commandItem"> |
| | | <Button onClick={() => shuttleOperator('palletLift')}>托盘顶升</Button> |
| | | <Button onClick={() => shuttleOperator('palletDown')}>托盘下降</Button> |
| | | <Button onClick={() => shuttleOperator('chargeOpen')}>充电开</Button> |
| | | <Button onClick={() => shuttleOperator('chargeClose')}>充电关</Button> |
| | | <Button onClick={() => shuttleOperator('reset')}>复位</Button> |
| | | </div> |
| | | </Card> |
| | | </div> |
| | | |
| | | <div style={{ marginBottom: '15px' }}> |
| | | <Card title="跑库系统" style={{ width: 300 }}> |
| | | <div className="commandItem"> |
| | | <div><Input addonBefore="X起点" defaultValue="1" /></div> |
| | | <div><Input addonBefore="X终点" defaultValue="1" /></div> |
| | | <div><Input addonBefore="Y起点" defaultValue="1" /></div> |
| | | <div><Input addonBefore="Y终点" defaultValue="1" /></div> |
| | | <div> |
| | | <Select |
| | | defaultValue="0" |
| | | style={{ width: 120 }} |
| | | options={[{ value: '0', label: '跑轨道' }, { value: '1', label: '跑库位' }, { value: '2', label: '母轨道循环跑' }, { value: '3', label: '子轨道循环跑' }]} |
| | | /> |
| | | </div> |
| | | <Button>跑库</Button> |
| | | </div> |
| | | </Card> |
| | | </div> |
| | | </Drawer> |
| | | </> |
| | | ) |
| | | } |
| | | |
| | | return (codeContent); |
| | | } |
| | | |
| | | export default Main; |
New file |
| | |
| | | .commandItem { |
| | | display: flex; |
| | | justify-content: space-between; |
| | | flex-wrap: wrap; |
| | | } |
| | | |
| | | .commandItem > Button { |
| | | width: 120px; |
| | | margin-bottom: 10px; |
| | | } |
| | | |
| | | .commandItem > div { |
| | | width: 120px; |
| | | margin-bottom: 10px; |
| | | } |
| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.BaseRes; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.asrs.wcs.common.annotation.OperationLog; |
| | | import com.zy.asrs.wcs.common.domain.BaseParam; |
| | | import com.zy.asrs.wcs.common.domain.KeyValVo; |
| | | import com.zy.asrs.wcs.common.domain.PageParam; |
| | | import com.zy.asrs.wcs.core.domain.param.ShuttleOperatorParam; |
| | | import com.zy.asrs.wcs.core.entity.BasShuttle; |
| | | import com.zy.asrs.wcs.core.entity.Motion; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.entity.TaskCtg; |
| | | import com.zy.asrs.wcs.core.kernel.AnalyzeService; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskStsType; |
| | | import com.zy.asrs.wcs.core.service.BasShuttleService; |
| | | import com.zy.asrs.wcs.core.service.MotionService; |
| | | import com.zy.asrs.wcs.core.service.TaskCtgService; |
| | | import com.zy.asrs.wcs.core.service.TaskService; |
| | | import com.zy.asrs.wcs.core.utils.Utils; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | |
| | | |
| | | @Autowired |
| | | private BasShuttleService basShuttleService; |
| | | @Autowired |
| | | private TaskCtgService taskCtgService; |
| | | @Autowired |
| | | private SnowflakeIdWorker snowflakeIdWorker; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private AnalyzeService analyzeService; |
| | | @Autowired |
| | | private MotionService motionService; |
| | | |
| | | @PreAuthorize("hasAuthority('core:basShuttle:list')") |
| | | @PostMapping("/basShuttle/page") |
| | |
| | | ExcelUtil.build(ExcelUtil.create(basShuttleService.list(), BasShuttle.class), response); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('core:basShuttle:operator')") |
| | | @PostMapping("/basShuttle/operator/shuttle") |
| | | @Transactional |
| | | public R shuttleOperator(@RequestBody ShuttleOperatorParam param) { |
| | | if (Cools.isEmpty(param.getShuttleNo(), param.getShuttleTaskMode())) { |
| | | return R.error("参数为空"); |
| | | } |
| | | |
| | | Integer shuttleNo = param.getShuttleNo(); |
| | | |
| | | //获取迁移任务类型 |
| | | TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>() |
| | | .eq(TaskCtg::getFlag, "MANUAL") |
| | | .eq(TaskCtg::getStatus, 1)); |
| | | if (taskCtg == null) { |
| | | return R.error(); |
| | | } |
| | | |
| | | String targetLoc = null;//任务目标(借用字段) |
| | | String targetSite = param.getShuttleTaskMode();//任务类型(借用字段) |
| | | if (param.getShuttleTaskMode().equals("moveLoc")) { |
| | | //迁移任务 |
| | | targetLoc = param.getTargetLocNo(); |
| | | } |
| | | |
| | | Task task = new Task(); |
| | | task.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | | task.setTaskNo(String.valueOf(Utils.getTaskNo("MANUAL"))); |
| | | task.setTaskSts(TaskStsType.NEW_MANUAL.getId()); |
| | | task.setTaskCtg(taskCtg.getId()); |
| | | task.setPriority(10); |
| | | task.setOriginSite(null); |
| | | task.setOriginLoc(null); |
| | | task.setDestSite(targetSite); |
| | | task.setDestLoc(targetLoc); |
| | | task.setIoTime(new Date()); |
| | | task.setStartTime(new Date()); |
| | | task.setStatus(1); |
| | | task.setMemo("manual"); |
| | | task.setShuttleNo(param.getShuttleNo()); |
| | | boolean result = taskService.save(task); |
| | | if (!result) { |
| | | return R.error(); |
| | | } |
| | | |
| | | // generate motion list |
| | | List<Motion> motionList = analyzeService.generateShuttleManualMotion(task); |
| | | if (Cools.isEmpty(motionList)) { |
| | | News.error("保存{}号四向穿梭车手动任务失败!!!", shuttleNo); |
| | | return R.error(); |
| | | } |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); |
| | | |
| | | task.setTaskSts(TaskStsType.ANALYZE_MANUAL.getId()); |
| | | if (!taskService.updateById(task)) { |
| | | News.error("保存{}号四向穿梭车手动任务失败!!!", shuttleNo); |
| | | return R.error(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.core.domain.param; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class ShuttleOperatorParam { |
| | | |
| | | // 四向穿梭车号 |
| | | private Integer shuttleNo; |
| | | |
| | | // 命令类型 |
| | | private String shuttleTaskMode; |
| | | |
| | | // 目标库位 |
| | | private String targetLocNo; |
| | | |
| | | } |
| | |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.wcs.core.domain.dto.MotionDto; |
| | | import com.zy.asrs.wcs.core.entity.Task; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.MotionCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskStsType; |
| | | import com.zy.asrs.wcs.core.model.enums.WorkZoneType; |
| | |
| | | return motionList; |
| | | } |
| | | |
| | | /** |
| | | * 生成小车手动动作 |
| | | */ |
| | | public List<Motion> generateShuttleManualMotion(Task task) { |
| | | List<Motion> motionList = new ArrayList<>(); |
| | | if (task.getTaskSts() != TaskStsType.NEW_MOVE.getId()) { |
| | | return motionList; |
| | | } |
| | | |
| | | String targetLoc = task.getDestLoc();//任务目标(借用字段) |
| | | String targetSite = task.getDestSite();//任务类型(借用字段) |
| | | |
| | | //获取穿梭车类型 |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle)) |
| | | .eq(DeviceType::getStatus, 1)); |
| | | if (deviceType == null) { |
| | | return motionList; |
| | | } |
| | | |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceNo, task.getShuttleNo()) |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getHostId, task.getHostId()) |
| | | .eq(Device::getStatus, 1)); |
| | | if (device == null) { |
| | | return motionList; |
| | | } |
| | | |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | if (shuttleThread == null) { |
| | | return motionList; |
| | | } |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) { |
| | | return motionList; |
| | | } |
| | | |
| | | if (targetSite.equals("moveLoc")) {//移动 |
| | | String shuttleLocNo = shuttleProtocol.getCurrentLocNo(); |
| | | |
| | | // 判断穿梭车是否在目标层 |
| | | if (Utils.getLev(shuttleLocNo) == Utils.getLev(targetLoc)) { |
| | | |
| | | // 穿梭车走行至目标库位 |
| | | motionList.addAll(kernelService.shuttleMove( |
| | | MotionDto.build((dto -> { |
| | | dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); |
| | | dto.setLocNo(shuttleLocNo); |
| | | })), |
| | | MotionDto.build((dto -> { |
| | | dto.setShuttleNo(shuttleProtocol.getShuttleNo().intValue()); |
| | | dto.setLocNo(targetLoc); |
| | | })), |
| | | MotionCtgType.SHUTTLE_MOVE |
| | | )); |
| | | |
| | | } |
| | | } else if (targetSite.equals("palletLift")) { |
| | | //托盘顶升 |
| | | motionList.add(Motion.build(motion -> { |
| | | motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); |
| | | motion.setDevice(String.valueOf(task.getShuttleNo())); |
| | | motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_LIFT.val()); |
| | | })); |
| | | } else if (targetSite.equals("palletDown")) { |
| | | //托盘下降 |
| | | motionList.add(Motion.build(motion -> { |
| | | motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); |
| | | motion.setDevice(String.valueOf(task.getShuttleNo())); |
| | | motion.setMotionCtg(MotionCtgType.SHUTTLE_PALLET_DOWN.val()); |
| | | })); |
| | | } else if (targetSite.equals("chargeOpen")) { |
| | | //充电开 |
| | | motionList.add(Motion.build(motion -> { |
| | | motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); |
| | | motion.setDevice(String.valueOf(task.getShuttleNo())); |
| | | motion.setMotionCtg(MotionCtgType.SHUTTLE_CHARGE_ON.val()); |
| | | })); |
| | | } else if (targetSite.equals("chargeClose")) { |
| | | //充电关 |
| | | motionList.add(Motion.build(motion -> { |
| | | motion.setDeviceCtg(DeviceCtgType.SHUTTLE.val()); |
| | | motion.setDevice(String.valueOf(task.getShuttleNo())); |
| | | motion.setMotionCtg(MotionCtgType.SHUTTLE_CHARGE_OFF.val()); |
| | | })); |
| | | } else if (targetSite.equals("reset")) { |
| | | //复位 |
| | | } |
| | | |
| | | return motionList; |
| | | } |
| | | |
| | | } |
| | |
| | | shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | | shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; |
| | | break; |
| | | // case SHUTTLE_MOVE_FROM_CONVEYOR: |
| | | // shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | | // shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; |
| | | // break; |
| | | // case SHUTTLE_MOVE_TO_CONVEYOR: |
| | | // shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | | // shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; |
| | | // break; |
| | | // case SHUTTLE_MOVE_FROM_LIFT_TO_CONVEYOR://穿梭车出提升机去输送线 |
| | | // // 判断提升机状态 |
| | | // liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); |
| | | // if (liftThread == null) { |
| | | // return false; |
| | | // } |
| | | // liftProtocol = liftThread.getLiftProtocol(); |
| | | // // 判断提升机是否自动、空闲、准备就绪、链条没有转动、没有未就绪报错 |
| | | // if (!liftProtocol.getMode() |
| | | // || liftProtocol.getRunning() |
| | | // || !liftProtocol.getReady() |
| | | // || liftProtocol.getForwardRotationFeedback() |
| | | // || liftProtocol.getReverseFeedback() |
| | | // || liftProtocol.getNotReady().intValue() != 0 |
| | | // ) { |
| | | // return false; |
| | | // } |
| | | // |
| | | // if (liftProtocol.getLev().intValue() != Utils.getLev(motion.getTarget())) {//判断提升机是否达到目标层 |
| | | // return false; |
| | | // } |
| | | // |
| | | // //判断提升机是否被锁定 |
| | | // if (!liftProtocol.getLiftLock()) { |
| | | // //锁定提升机 |
| | | // LiftCommand lockCommand = liftThread.getLockCommand(true);//获取提升机锁定命令 |
| | | // lockCommand.setLiftNo(liftProtocol.getLiftNo()); |
| | | // lockCommand.setTaskNo(motion.getWrkNo().shortValue());//获取任务号 |
| | | // liftThread.assignWork(lockCommand); |
| | | // return false;//等待下一次轮询 |
| | | // } |
| | | // |
| | | // //判断提升机工作号是否和当前任务相同 |
| | | // if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { |
| | | // return false; |
| | | // } |
| | | // |
| | | // shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.NORMAL.id, assignCommand, shuttleThread); |
| | | // shuttleTaskModeType = ShuttleTaskModeType.SHUTTLE_MOVE_LOC_NO; |
| | | // break; |
| | | // case SHUTTLE_TRANSPORT: |
| | | // shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | // shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; |
| | | // |
| | | // shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); |
| | | // shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); |
| | | // break; |
| | | // case SHUTTLE_TRANSPORT_FROM_LIFT://穿梭车载货出提升机 |
| | | // // 判断提升机状态 |
| | | // liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); |
| | | // if (liftThread == null) { |
| | | // return false; |
| | | // } |
| | | // liftProtocol = liftThread.getLiftProtocol(); |
| | | // // 判断提升机是否自动、空闲、准备就绪、链条没有转动、没有未就绪报错 |
| | | // if (!liftProtocol.getMode() |
| | | // || liftProtocol.getRunning() |
| | | // || !liftProtocol.getReady() |
| | | // || liftProtocol.getForwardRotationFeedback() |
| | | // || liftProtocol.getReverseFeedback() |
| | | // || liftProtocol.getNotReady().intValue() != 0 |
| | | // ) { |
| | | // return false; |
| | | // } |
| | | // |
| | | // if (liftProtocol.getLev().intValue() != Utils.getLev(motion.getTarget())) {//判断提升机是否达到目标层 |
| | | // return false; |
| | | // } |
| | | // |
| | | // //判断提升机是否被锁定 |
| | | // if (!liftProtocol.getLiftLock()) { |
| | | // //锁定提升机 |
| | | // LiftCommand lockCommand = liftThread.getLockCommand(true);//获取提升机锁定命令 |
| | | // lockCommand.setLiftNo(liftProtocol.getLiftNo()); |
| | | // lockCommand.setTaskNo(motion.getWrkNo().shortValue());//获取任务号 |
| | | // liftThread.assignWork(lockCommand); |
| | | // return false;//等待下一次轮询 |
| | | // } |
| | | // |
| | | // //判断提升机工作号是否和当前任务相同 |
| | | // if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { |
| | | // return false; |
| | | // } |
| | | // |
| | | // shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | // shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; |
| | | // shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); |
| | | //// shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); |
| | | // break; |
| | | // case SHUTTLE_TRANSPORT_TO_LIFT://穿梭车载货进提升机 |
| | | // // 判断提升机状态 |
| | | // liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); |
| | | // if (liftThread == null) { |
| | | // return false; |
| | | // } |
| | | // liftProtocol = liftThread.getLiftProtocol(); |
| | | // // 判断提升机是否自动、空闲、准备就绪、链条没有转动、没有未就绪报错 |
| | | // if (!liftProtocol.getMode() |
| | | // || liftProtocol.getRunning() |
| | | // || !liftProtocol.getReady() |
| | | // || liftProtocol.getForwardRotationFeedback() |
| | | // || liftProtocol.getReverseFeedback() |
| | | // || liftProtocol.getNotReady().intValue() != 0 |
| | | // ) { |
| | | // return false; |
| | | // } |
| | | // |
| | | // if (liftProtocol.getLev().intValue() != Utils.getLev(motion.getTarget())) {//判断提升机是否达到目标层 |
| | | // return false; |
| | | // } |
| | | // |
| | | // //判断提升机是否被锁定 |
| | | // if (!liftProtocol.getLiftLock()) { |
| | | // //锁定提升机 |
| | | // LiftCommand lockCommand = liftThread.getLockCommand(true);//获取提升机锁定命令 |
| | | // lockCommand.setLiftNo(liftProtocol.getLiftNo()); |
| | | // lockCommand.setTaskNo(motion.getWrkNo().shortValue());//获取任务号 |
| | | // liftThread.assignWork(lockCommand); |
| | | // return false;//等待下一次轮询 |
| | | // } |
| | | // |
| | | // //判断提升机工作号是否和当前任务相同 |
| | | // if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { |
| | | // return false; |
| | | // } |
| | | // |
| | | // shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | // shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; |
| | | //// shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); |
| | | // shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); |
| | | // break; |
| | | // case SHUTTLE_TRANSPORT_FROM_CONVEYOR: |
| | | // shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | // shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; |
| | | // |
| | | // shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); |
| | | // shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); |
| | | // break; |
| | | // case SHUTTLE_TRANSPORT_TO_CONVEYOR: |
| | | // shuttleCommands = this.shuttleAssignCommand(motion.getOrigin(), motion.getTarget(), NavigationMapType.DFX.id, assignCommand, shuttleThread); |
| | | // shuttleTaskModeType = ShuttleTaskModeType.PAK_IN; |
| | | // |
| | | // shuttleCommands.add(0, shuttleThread.getPalletCommand((short) 1)); |
| | | // shuttleCommands.add(shuttleCommands.size(), shuttleThread.getPalletCommand((short) 2)); |
| | | // break; |
| | | // case SHUTTLE_CHARGE_ON: |
| | | // shuttleTaskModeType = ShuttleTaskModeType.CHARGE; |
| | | // shuttleCommands.add(shuttleThread.getChargeSwitchCommand((short) 1)); |
| | | // assignCommand.setCharge(Boolean.TRUE); |
| | | // break; |
| | | case SHUTTLE_CHARGE_ON://充电开 |
| | | shuttleTaskModeType = ShuttleTaskModeType.CHARGE; |
| | | shuttleCommands.add(shuttleThread.getChargeCommand(motion.getWrkNo(), true)); |
| | | assignCommand.setCharge(Boolean.TRUE); |
| | | break; |
| | | case SHUTTLE_CHARGE_OFF://充电关 |
| | | shuttleTaskModeType = ShuttleTaskModeType.CHARGE; |
| | | shuttleCommands.add(shuttleThread.getChargeCommand(motion.getWrkNo(), false)); |
| | | assignCommand.setCharge(Boolean.TRUE); |
| | | break; |
| | | case SHUTTLE_PALLET_LIFT://托盘顶升 |
| | | shuttleTaskModeType = ShuttleTaskModeType.PALLET_LIFT; |
| | | shuttleCommands.add(shuttleThread.getLiftCommand(motion.getWrkNo(), true)); |
| | | break; |
| | | case SHUTTLE_PALLET_DOWN://托盘下降 |
| | | shuttleTaskModeType = ShuttleTaskModeType.PALLET_DOWN; |
| | | shuttleCommands.add(shuttleThread.getLiftCommand(motion.getWrkNo(), false)); |
| | | break; |
| | | default: |
| | | throw new CoolException(motion.getMotionCtgEl() + "没有指定任务作业流程!!!"); |
| | | } |
| | |
| | | return false; |
| | | } |
| | | |
| | | // SiemensLiftThread liftThread = null; |
| | | // LiftProtocol liftProtocol = null; |
| | | LiftThread liftThread = null; |
| | | LiftProtocol liftProtocol = null; |
| | | |
| | | switch (Objects.requireNonNull(MotionCtgType.get(motion.getMotionCtgEl()))){ |
| | | case SHUTTLE_MOVE: |
| | |
| | | return false; |
| | | } |
| | | break; |
| | | // case SHUTTLE_MOVE_TO_LIFT: |
| | | // case SHUTTLE_MOVE_FROM_LIFT: |
| | | // case SHUTTLE_TRANSPORT_FROM_LIFT: |
| | | // case SHUTTLE_TRANSPORT_TO_LIFT: |
| | | // case SHUTTLE_MOVE_FROM_LIFT_TO_CONVEYOR: |
| | | // liftThread = (SiemensLiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); |
| | | // if (liftThread == null) { |
| | | // return false; |
| | | // } |
| | | // liftProtocol = liftThread.getLiftProtocol(); |
| | | // |
| | | // if (!shuttleProtocol.getCurrentLocNo().equals(motion.getTarget())) { |
| | | // return false; |
| | | // } |
| | | // |
| | | case SHUTTLE_MOVE_TO_LIFT: |
| | | case SHUTTLE_MOVE_FROM_LIFT: |
| | | case SHUTTLE_TRANSPORT_FROM_LIFT: |
| | | case SHUTTLE_TRANSPORT_TO_LIFT: |
| | | case SHUTTLE_MOVE_FROM_LIFT_TO_CONVEYOR: |
| | | liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, Integer.parseInt(motion.getTemp())); |
| | | if (liftThread == null) { |
| | | return false; |
| | | } |
| | | liftProtocol = liftThread.getStatus(); |
| | | |
| | | if (!shuttleProtocol.getCurrentLocNo().equals(motion.getTarget())) { |
| | | return false; |
| | | } |
| | | |
| | | // //判断提升机是否被锁定 |
| | | // if (liftProtocol.getLiftLock()) { |
| | | // //解锁提升机 |
| | |
| | | // liftThread.assignWork(lockCommand); |
| | | // return false; |
| | | // } |
| | | // |
| | | // //判断提升机工作号是否和当前任务相同 |
| | | // if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { |
| | | // return false; |
| | | // } |
| | | // |
| | | // if (liftProtocol.getTaskNo().intValue() != 0) { |
| | | |
| | | //判断提升机工作号是否和当前任务相同 |
| | | if (liftProtocol.getTaskNo().intValue() != motion.getWrkNo()) { |
| | | return false; |
| | | } |
| | | |
| | | // if (liftProtocol.getTaskNo() != 0) { |
| | | // //清空提升机号 |
| | | // liftThread.setTaskNo(0); |
| | | // } |
| | | // |
| | | // break; |
| | | |
| | | break; |
| | | default: |
| | | break; |
| | | } |
| | |
| | | |
| | | List<Task> selectByExecuteSts(); |
| | | |
| | | List<Task> selectManualByAnalyzeSts(); |
| | | |
| | | List<Task> selectManualByExecuteSts(); |
| | | |
| | | List<Task> selectWaitAnalyzeInBoundTask(); |
| | | |
| | | List<Task> selectPakOut(); |
| | |
| | | SHUTTLE_CHARGE_ON(SHUTTLE), |
| | | SHUTTLE_CHARGE_OFF(SHUTTLE), |
| | | |
| | | SHUTTLE_PALLET_LIFT(SHUTTLE),//托盘顶升 |
| | | SHUTTLE_PALLET_DOWN(SHUTTLE),//托盘下降 |
| | | |
| | | // AGV ---------------------------------------------- |
| | | AGV_TRANSPORT(AGV), |
| | | |
| | |
| | | package com.zy.asrs.wcs.core.model.enums; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.core.entity.TaskSts; |
| | | import com.zy.asrs.wcs.core.service.TaskStsService; |
| | | |
| | | public enum TaskStsType { |
| | | |
| | |
| | | throw new CoolException("TaskStsType Error!!!"); |
| | | } |
| | | |
| | | public static TaskStsType queryById(Long id) { |
| | | TaskStsService taskStsService = SpringUtils.getBean(TaskStsService.class); |
| | | TaskSts taskSts = taskStsService.getById(id); |
| | | if (taskSts == null) { |
| | | throw new CoolException("TaskStsType Error!!!"); |
| | | } |
| | | return query(Long.valueOf(taskSts.getUuid())); |
| | | } |
| | | |
| | | public Long getId() { |
| | | TaskStsService taskStsService = SpringUtils.getBean(TaskStsService.class); |
| | | TaskSts taskSts = taskStsService.getOne(new LambdaQueryWrapper<TaskSts>() |
| | | .eq(TaskSts::getUuid, sts) |
| | | .eq(TaskSts::getStatus, 1)); |
| | | if (taskSts == null) { |
| | | throw new CoolException("TaskStsType Error!!!"); |
| | | } |
| | | return taskSts.getId(); |
| | | } |
| | | |
| | | } |
| | |
| | | |
| | | List<Task> selectByExecuteSts(); |
| | | |
| | | List<Task> selectManualByAnalyzeSts(); |
| | | |
| | | List<Task> selectManualByExecuteSts(); |
| | | |
| | | List<Task> selectWaitAnalyzeInBoundTask(); |
| | | |
| | | List<Task> selectPakOut(); |
| | |
| | | Task task = new Task(); |
| | | task.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | | task.setTaskNo(String.valueOf(Utils.getTaskNo("CHARGE"))); |
| | | task.setTaskSts(TaskStsType.NEW_CHARGE.sts); |
| | | task.setTaskSts(TaskStsType.NEW_CHARGE.getId()); |
| | | task.setTaskCtg(taskCtg.getId()); |
| | | task.setPriority(10); |
| | | task.setOriginSite(null); |
| | |
| | | Task task = new Task(); |
| | | task.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | | task.setTaskNo(String.valueOf(Utils.getTaskNo("MOVE"))); |
| | | task.setTaskSts(TaskStsType.NEW_MOVE.sts); |
| | | task.setTaskSts(TaskStsType.NEW_MOVE.getId()); |
| | | task.setTaskCtg(taskCtg.getId()); |
| | | task.setPriority(10); |
| | | task.setOriginSite(null); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<Task> selectManualByAnalyzeSts() { |
| | | return this.baseMapper.selectManualByAnalyzeSts(); |
| | | } |
| | | |
| | | @Override |
| | | public List<Task> selectManualByExecuteSts() { |
| | | return this.baseMapper.selectManualByExecuteSts(); |
| | | } |
| | | |
| | | @Override |
| | | public List<Task> selectWaitAnalyzeInBoundTask() { |
| | | return this.baseMapper.selectWaitAnalyzeInBoundTask(); |
| | | } |
| | |
| | | private ShuttleCommandService shuttleCommandService; |
| | | |
| | | // @Scheduled(cron = "0/1 * * * * ? ") |
| | | public synchronized void executeWrkMast() { |
| | | public synchronized void executeTask() { |
| | | Date now = new Date(); |
| | | // ANALYZE_INBOUND |
| | | for (Task task : taskService.selectByAnalyzeSts()) { |
| | |
| | | continue; |
| | | } |
| | | |
| | | // 更新wrkMast |
| | | switch (TaskStsType.query(task.getTaskSts())) { |
| | | // 更新Task |
| | | switch (TaskStsType.queryById(task.getTaskSts())) { |
| | | case ANALYZE_INBOUND: |
| | | task.setTaskSts(TaskStsType.EXECUTE_INBOUND.sts); |
| | | task.setTaskSts(TaskStsType.EXECUTE_INBOUND.getId()); |
| | | break; |
| | | case ANALYZE_OUTBOUND: |
| | | task.setTaskSts(TaskStsType.EXECUTE_OUTBOUND.sts); |
| | | task.setTaskSts(TaskStsType.EXECUTE_OUTBOUND.getId()); |
| | | break; |
| | | } |
| | | task.setUpdateTime(now); |
| | |
| | | continue; |
| | | } |
| | | |
| | | // 更新wrkMast |
| | | switch (TaskStsType.query(task.getTaskSts())) { |
| | | // 更新Task |
| | | switch (TaskStsType.queryById(task.getTaskSts())) { |
| | | case EXECUTE_INBOUND: |
| | | task.setTaskSts(TaskStsType.COMPLETE_INBOUND.sts); |
| | | task.setTaskSts(TaskStsType.COMPLETE_INBOUND.getId()); |
| | | break; |
| | | case EXECUTE_OUTBOUND: |
| | | task.setTaskSts(TaskStsType.COMPLETE_OUTBOUND.sts); |
| | | task.setTaskSts(TaskStsType.COMPLETE_OUTBOUND.getId()); |
| | | break; |
| | | } |
| | | task.setUpdateTime(now); |
| | |
| | | // } |
| | | // } |
| | | |
| | | // @Scheduled(cron = "0/1 * * * * ? ") |
| | | public synchronized void executeManualTask() { |
| | | Date now = new Date(); |
| | | // ANALYZE_MANUAL |
| | | for (Task task : taskService.selectByAnalyzeSts()) { |
| | | Motion executingMotion = motionService.selectOfTop1(task.getUuid(), MotionStsType.EXECUTING.val(), task.getHostId()); |
| | | if (executingMotion != null) {//存在正在执行的motion |
| | | continue; |
| | | } |
| | | |
| | | Motion motion = motionService.selectOfTop1(task.getUuid(), MotionStsType.INIT.val(), task.getHostId()); |
| | | if (null != motion) { |
| | | boolean result = this.executeMotion(motion); |
| | | if (!result) { |
| | | continue; |
| | | } |
| | | // 更新Task |
| | | switch (TaskStsType.queryById(task.getTaskSts())) { |
| | | case ANALYZE_MANUAL: |
| | | task.setTaskSts(TaskStsType.EXECUTE_MANUAL.getId()); |
| | | break; |
| | | } |
| | | task.setUpdateTime(now); |
| | | if (!taskService.updateById(task)) { |
| | | log.error("{}其他工作档更新状态失败!", task.getTaskNo()); |
| | | } |
| | | } |
| | | } |
| | | // EXECUTE_MANUAL |
| | | for (Task task : taskService.selectManualByExecuteSts()) { |
| | | if (!motionService.hasRunningMotion(task.getUuid(), task.getHostId())) { |
| | | Motion motion = motionService.selectOfTop1(task.getUuid(), MotionStsType.WAITING.val(), task.getHostId()); |
| | | if (null != motion) { |
| | | boolean result = this.executeMotion(motion); |
| | | if (!result) { |
| | | continue; |
| | | } |
| | | } else { |
| | | if (motionService.selectOfTop1(task.getUuid(), MotionStsType.EXECUTING.val(), task.getHostId()) != null) { |
| | | continue; |
| | | } |
| | | |
| | | // 更新Task |
| | | switch (TaskStsType.queryById(task.getTaskSts())) { |
| | | case EXECUTE_MANUAL: |
| | | task.setTaskSts(TaskStsType.COMPLETE_MANUAL.getId()); |
| | | break; |
| | | } |
| | | task.setUpdateTime(now); |
| | | if (!taskService.updateById(task)) { |
| | | log.error("{}他工作档更新状态失败!", task.getTaskNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Scheduled(cron = "0/1 * * * * ? ") |
| | | public void scanMotionByExecuting() { |
| | | List<Motion> motionList = motionService.selectBySts(MotionStsType.EXECUTING.val()); |
| | |
| | | Task task = new Task(); |
| | | task.setUuid(String.valueOf(snowflakeIdWorker.nextId())); |
| | | task.setTaskNo(String.valueOf(Utils.getTaskNo("MOVE"))); |
| | | task.setTaskSts(TaskStsType.NEW_MOVE.sts); |
| | | task.setTaskSts(TaskStsType.NEW_MOVE.getId()); |
| | | task.setTaskCtg(taskCtg.getId()); |
| | | task.setPriority(10); |
| | | task.setOriginSite(null); |
| | |
| | | <select id="selectByAnalyzeSts" resultType="com.zy.asrs.wcs.core.entity.Task"> |
| | | select * from wcs_task |
| | | where 1=1 |
| | | and task_sts in (2, 102, 202, 302) |
| | | and task_sts in (2, 102) |
| | | order by priority desc,start_time,task_no asc |
| | | </select> |
| | | |
| | | <select id="selectByExecuteSts" resultType="com.zy.asrs.wcs.core.entity.Task"> |
| | | select * from wcs_task |
| | | where 1=1 |
| | | and task_sts in (3, 103, 203, 303) |
| | | and task_sts in (3, 103) |
| | | order by priority desc,start_time,task_no asc |
| | | </select> |
| | | |
| | | <select id="selectManualByAnalyzeSts" resultType="com.zy.asrs.wcs.core.entity.Task"> |
| | | select * from wcs_task |
| | | where 1=1 |
| | | and task_sts in (402) |
| | | order by priority desc,start_time,task_no asc |
| | | </select> |
| | | |
| | | <select id="selectManualByExecuteSts" resultType="com.zy.asrs.wcs.core.entity.Task"> |
| | | select * from wcs_task |
| | | where 1=1 |
| | | and task_sts in (403) |
| | | order by priority desc,start_time,task_no asc |
| | | </select> |
| | | |