21个文件已添加
10 文件已重命名
1个文件已删除
2个文件已修改
| | |
| | | import com.zy.asrs.wcs.asrs.entity.FlowGraph; |
| | | import com.zy.asrs.wcs.asrs.entity.param.FlowLogicCodeParam; |
| | | import com.zy.asrs.wcs.asrs.service.FlowGraphService; |
| | | import com.zy.asrs.wcs.core.thread.FlowExecute; |
| | | import com.zy.asrs.wcs.rcs.thread.FlowExecute; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/News.java |
| | |
| | | package com.zy.asrs.wcs.core; |
| | | package com.zy.asrs.wcs.rcs; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.wcs.core.MainProcess; |
| | | import com.zy.asrs.wcs.rcs.cache.MessageQueue; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.thread.ThreadHandler; |
| | | import com.zy.asrs.wcs.core.utils.RedisUtil; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DevicePlc; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.service.DevicePlcService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.scheduling.annotation.Async; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PostConstruct; |
| | | import javax.annotation.PreDestroy; |
| | | import java.lang.reflect.Constructor; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/8/4 |
| | | */ |
| | | @Slf4j |
| | | @Component |
| | | public class ServerBootstrap { |
| | | |
| | | @Autowired |
| | | private MainProcess mainProcess; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | @Autowired |
| | | private DevicePlcService devicePlcService; |
| | | |
| | | @PostConstruct |
| | | @Async |
| | | public void init() throws InterruptedException { |
| | | News.info("核心控制层开始初始化..............................................."); |
| | | Thread.sleep(2000); |
| | | // 初始化消息队列 |
| | | initMq(); |
| | | // 初始化下位机线程 |
| | | initThread(); |
| | | // 开始主流程进程 |
| | | mainProcess.start(); |
| | | News.info("核心控制层已启动..............................................."); |
| | | } |
| | | |
| | | private void initMq(){ |
| | | // 初始化设备mq |
| | | for (Device device : deviceService.list()) { |
| | | DeviceType type = deviceTypeService.getById(device.getDeviceType()); |
| | | SlaveType slaveType = SlaveType.findInstance(type.getFlag()); |
| | | if (slaveType != null) { |
| | | MessageQueue.init(slaveType, device.getId().intValue()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void initThread(){ |
| | | for (DeviceType type : deviceTypeService.list()) { |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getDeviceType, type.getId()) |
| | | .eq(Device::getStatus, 1) |
| | | ); |
| | | if (list.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | News.info("初始化{}线程...................................................", type.getName()); |
| | | for (Device device : list) { |
| | | DevicePlc devicePlc = devicePlcService.getById(device.getDevicePlc()); |
| | | if (devicePlc == null) { |
| | | continue; |
| | | } |
| | | |
| | | try { |
| | | Class<?> clazz = Class.forName("com.zy.asrs.wcs.rcs.thread.impl." + devicePlc.getFlag()); |
| | | Constructor<?> constructor = clazz.getConstructor(Device.class, RedisUtil.class); |
| | | Object instance = constructor.newInstance(device, redisUtil); |
| | | new Thread((Runnable) instance).start(); |
| | | SlaveConnection.put(SlaveType.findInstance(type.getFlag()), device.getId().intValue(), (ThreadHandler) instance); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | @PreDestroy |
| | | public void destroy() { |
| | | } |
| | | |
| | | |
| | | } |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/cache/MessageQueue.java |
| | |
| | | package com.zy.asrs.wcs.core.cache; |
| | | package com.zy.asrs.wcs.rcs.cache; |
| | | |
| | | import com.zy.asrs.wcs.core.model.Task; |
| | | import com.zy.asrs.wcs.core.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.Task; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.cache; |
| | | |
| | | import com.alibaba.fastjson.JSONObject; |
| | | |
| | | import java.util.concurrent.ArrayBlockingQueue; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/8/17 |
| | | */ |
| | | public class OutputQueue { |
| | | |
| | | // 堆垛机输出日志 |
| | | public static ArrayBlockingQueue<String> CRN = new ArrayBlockingQueue<>(32); |
| | | // 输送线输出日志 |
| | | public static ArrayBlockingQueue<String> DEVP = new ArrayBlockingQueue<>(32); |
| | | // 条码器输出日志 |
| | | public static ArrayBlockingQueue<JSONObject> BARCODE = new ArrayBlockingQueue<>(32); |
| | | // 穿梭车输出日志 |
| | | public static ArrayBlockingQueue<String> STE = new ArrayBlockingQueue<>(32); |
| | | //四向穿梭车输出日志 |
| | | public static ArrayBlockingQueue<String> SHUTTLE = new ArrayBlockingQueue<>(32); |
| | | //提升机输出日志 |
| | | public static ArrayBlockingQueue<String> LIFT = new ArrayBlockingQueue<>(32); |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.cache; |
| | | |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.thread.ThreadHandler; |
| | | |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
| | | /** |
| | | * 线程缓存容器 |
| | | * Created by vincent on 2020/8/4 |
| | | */ |
| | | public class SlaveConnection { |
| | | |
| | | private static final String _LINK = "_"; |
| | | |
| | | private static final Map<String, ThreadHandler> conContain = new ConcurrentHashMap<>(); |
| | | |
| | | public static void put(SlaveType type, Integer id, ThreadHandler threadHandler) { |
| | | String key = toKey(type, id); |
| | | remove(type, id); |
| | | conContain.put(key, threadHandler); |
| | | } |
| | | |
| | | public static ThreadHandler get(SlaveType type, Integer id) { |
| | | return conContain.get(toKey(type, id)); |
| | | } |
| | | |
| | | public static void remove(SlaveType type, Integer id) { |
| | | ThreadHandler threadHandler = get(type, id); |
| | | if (null == threadHandler) { |
| | | return; |
| | | } |
| | | conContain.remove(toKey(type, id)); |
| | | threadHandler.close(); |
| | | } |
| | | |
| | | public static Integer remove(ThreadHandler threadHandler) { |
| | | if (null == threadHandler) { |
| | | return null; |
| | | } |
| | | String key = null; |
| | | for (Map.Entry<String, ThreadHandler> entry : conContain.entrySet()){ |
| | | if (entry.getValue() == threadHandler) { |
| | | key = entry.getKey(); |
| | | break; |
| | | } |
| | | } |
| | | if (null != key) { |
| | | SlaveType type = SlaveType.findInstance(key); |
| | | Integer id = Integer.parseInt(key.split(_LINK)[1]); |
| | | remove(type, id); |
| | | return id; |
| | | } else { |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | private static String toKey(SlaveType type, Integer id){ |
| | | return type.toString()+_LINK+id; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.LiftThread; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.GetMapping; |
| | | import org.springframework.web.bind.annotation.PathVariable; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | public class LiftController extends BaseController { |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | |
| | | @GetMapping("/lift/status/list") |
| | | public R getLiftStatusList() { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getHostId, getHostId()) |
| | | .eq(DeviceType::getStatus, 1) |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Lift))); |
| | | if (deviceType == null) { |
| | | return R.error("设备类型不存在"); |
| | | } |
| | | |
| | | ArrayList<LiftProtocol> data = new ArrayList<>(); |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getHostId, getHostId()) |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceType, deviceType.getId())); |
| | | for (Device device : list) { |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); |
| | | LiftProtocol status = liftThread.getStatus(); |
| | | data.add(status); |
| | | } |
| | | return R.ok().add(data); |
| | | } |
| | | |
| | | @GetMapping("/lift/status/one/{deviceNo}") |
| | | public R getLiftStatus(@PathVariable String deviceNo) { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getHostId, getHostId()) |
| | | .eq(DeviceType::getStatus, 1) |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Lift))); |
| | | if (deviceType == null) { |
| | | return R.error("设备类型不存在"); |
| | | } |
| | | |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getHostId, getHostId()) |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceNo, deviceNo)); |
| | | |
| | | LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, device.getId().intValue()); |
| | | LiftProtocol status = liftThread.getStatus(); |
| | | return R.ok().add(status); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.R; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.DeviceType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceTypeService; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import com.zy.asrs.wcs.system.controller.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | public class ShuttleController extends BaseController { |
| | | |
| | | @Autowired |
| | | private DeviceService deviceService; |
| | | @Autowired |
| | | private DeviceTypeService deviceTypeService; |
| | | |
| | | @GetMapping("/shuttle/status/list") |
| | | public R getShuttleStatusList() { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getHostId, getHostId()) |
| | | .eq(DeviceType::getStatus, 1) |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle))); |
| | | if (deviceType == null) { |
| | | return R.error("设备类型不存在"); |
| | | } |
| | | |
| | | ArrayList<ShuttleProtocol> data = new ArrayList<>(); |
| | | List<Device> list = deviceService.list(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getHostId, getHostId()) |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceType, deviceType.getId())); |
| | | for (Device device : list) { |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | ShuttleProtocol status = shuttleThread.getStatus(); |
| | | data.add(status); |
| | | } |
| | | return R.ok().add(data); |
| | | } |
| | | |
| | | @GetMapping("/shuttle/status/one/{deviceNo}") |
| | | public R getShuttleStatus(@PathVariable String deviceNo) { |
| | | DeviceType deviceType = deviceTypeService.getOne(new LambdaQueryWrapper<DeviceType>() |
| | | .eq(DeviceType::getHostId, getHostId()) |
| | | .eq(DeviceType::getStatus, 1) |
| | | .eq(DeviceType::getFlag, String.valueOf(SlaveType.Shuttle))); |
| | | if (deviceType == null) { |
| | | return R.error("设备类型不存在"); |
| | | } |
| | | |
| | | Device device = deviceService.getOne(new LambdaQueryWrapper<Device>() |
| | | .eq(Device::getHostId, getHostId()) |
| | | .eq(Device::getStatus, 1) |
| | | .eq(Device::getDeviceType, deviceType.getId()) |
| | | .eq(Device::getDeviceNo, deviceNo)); |
| | | |
| | | ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue()); |
| | | ShuttleProtocol status = shuttleThread.getStatus(); |
| | | return R.ok().add(status); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.system.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | | 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.rcs.entity.ShuttleDeviceStatus; |
| | | import com.zy.asrs.wcs.rcs.service.ShuttleDeviceStatusService; |
| | | import com.zy.asrs.wcs.utils.ExcelUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | 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; |
| | | |
| | | @RestController |
| | | @RequestMapping("/api") |
| | | public class ShuttleDeviceStatusController extends BaseController { |
| | | |
| | | @Autowired |
| | | private ShuttleDeviceStatusService shuttleDeviceStatusService; |
| | | |
| | | @PreAuthorize("hasAuthority('rcs:shuttleDeviceStatus:list')") |
| | | @PostMapping("/shuttleDeviceStatus/page") |
| | | public R page(@RequestBody Map<String, Object> map) { |
| | | BaseParam baseParam = buildParam(map, BaseParam.class); |
| | | PageParam<ShuttleDeviceStatus, BaseParam> pageParam = new PageParam<>(baseParam, ShuttleDeviceStatus.class); |
| | | return R.ok().add(shuttleDeviceStatusService.page(pageParam, pageParam.buildWrapper(true))); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('rcs:shuttleDeviceStatus:list')") |
| | | @PostMapping("/shuttleDeviceStatus/list") |
| | | public R list(@RequestBody Map<String, Object> map) { |
| | | return R.ok().add(shuttleDeviceStatusService.list()); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('rcs:shuttleDeviceStatus:list')") |
| | | @GetMapping("/shuttleDeviceStatus/{id}") |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok().add(shuttleDeviceStatusService.getById(id)); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('rcs:shuttleDeviceStatus:save')") |
| | | @OperationLog("添加四向车设备状态列表") |
| | | @PostMapping("/shuttleDeviceStatus/save") |
| | | public R save(@RequestBody ShuttleDeviceStatus shuttleDeviceStatus) { |
| | | if (!shuttleDeviceStatusService.save(shuttleDeviceStatus)) { |
| | | return R.error("添加失败"); |
| | | } |
| | | return R.ok("添加成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('rcs:shuttleDeviceStatus:update')") |
| | | @OperationLog("修改四向车设备状态列表") |
| | | @PostMapping("/shuttleDeviceStatus/update") |
| | | public R update(@RequestBody ShuttleDeviceStatus shuttleDeviceStatus) { |
| | | if (!shuttleDeviceStatusService.updateById(shuttleDeviceStatus)) { |
| | | return R.error("修改失败"); |
| | | } |
| | | return R.ok("修改成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('rcs:shuttleDeviceStatus:remove')") |
| | | @OperationLog("删除四向车设备状态列表") |
| | | @PostMapping("/shuttleDeviceStatus/remove/{ids}") |
| | | public R remove(@PathVariable Long[] ids) { |
| | | if (!shuttleDeviceStatusService.removeByIds(Arrays.asList(ids))) { |
| | | return R.error("删除失败"); |
| | | } |
| | | return R.ok("删除成功"); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('rcs:shuttleDeviceStatus:list')") |
| | | @PostMapping("/shuttleDeviceStatus/query") |
| | | public R query(@RequestParam(required = false) String condition) { |
| | | List<KeyValVo> vos = new ArrayList<>(); |
| | | LambdaQueryWrapper<ShuttleDeviceStatus> wrapper = new LambdaQueryWrapper<>(); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(ShuttleDeviceStatus::getName, condition); |
| | | } |
| | | shuttleDeviceStatusService.page(new Page<>(1, 30), wrapper).getRecords().forEach( |
| | | item -> vos.add(new KeyValVo(item.getId(), item.getName())) |
| | | ); |
| | | return R.ok().add(vos); |
| | | } |
| | | |
| | | @PreAuthorize("hasAuthority('rcs:shuttleDeviceStatus:list')") |
| | | @PostMapping("/shuttleDeviceStatus/export") |
| | | public void export(@RequestBody Map<String, Object> map, HttpServletResponse response) throws Exception { |
| | | ExcelUtil.build(ExcelUtil.create(shuttleDeviceStatusService.list(), ShuttleDeviceStatus.class), response); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.entity; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import com.zy.asrs.wcs.rcs.service.DevicePlcService; |
| | | import com.zy.asrs.wcs.system.entity.Host; |
| | | import com.zy.asrs.wcs.system.entity.User; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import com.baomidou.mybatisplus.annotation.IdType; |
| | | import com.baomidou.mybatisplus.annotation.TableId; |
| | | import com.baomidou.mybatisplus.annotation.TableLogic; |
| | | import com.baomidou.mybatisplus.annotation.TableName; |
| | | import io.swagger.annotations.ApiModel; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.wcs.system.service.UserService; |
| | | import com.zy.asrs.wcs.system.service.HostService; |
| | | |
| | | import java.io.Serializable; |
| | | import java.util.Date; |
| | | |
| | | @Data |
| | | @TableName("wcs_shuttle_device_status") |
| | | public class ShuttleDeviceStatus implements Serializable { |
| | | |
| | | private static final long serialVersionUID = 1L; |
| | | |
| | | /** |
| | | * ID |
| | | */ |
| | | @ApiModelProperty(value= "ID") |
| | | @TableId(value = "id", type = IdType.AUTO) |
| | | private Long id; |
| | | |
| | | /** |
| | | * 编号 |
| | | */ |
| | | @ApiModelProperty(value= "编号") |
| | | private String uuid; |
| | | |
| | | /** |
| | | * 状态名称 |
| | | */ |
| | | @ApiModelProperty(value= "状态名称") |
| | | private String name; |
| | | |
| | | /** |
| | | * 标识 |
| | | */ |
| | | @ApiModelProperty(value= "标识") |
| | | private String flag; |
| | | |
| | | /** |
| | | * 所属机构 |
| | | */ |
| | | @ApiModelProperty(value= "所属机构") |
| | | private Long hostId; |
| | | |
| | | /** |
| | | * 状态 1: 正常 0: 禁用 |
| | | */ |
| | | @ApiModelProperty(value= "状态 1: 正常 0: 禁用 ") |
| | | private Integer status; |
| | | |
| | | /** |
| | | * 是否删除 1: 是 0: 否 |
| | | */ |
| | | @ApiModelProperty(value= "是否删除 1: 是 0: 否 ") |
| | | @TableLogic |
| | | private Integer deleted; |
| | | |
| | | /** |
| | | * 添加时间 |
| | | */ |
| | | @ApiModelProperty(value= "添加时间") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date createTime; |
| | | |
| | | /** |
| | | * 添加人员 |
| | | */ |
| | | @ApiModelProperty(value= "添加人员") |
| | | private Long createBy; |
| | | |
| | | /** |
| | | * 修改时间 |
| | | */ |
| | | @ApiModelProperty(value= "修改时间") |
| | | @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") |
| | | private Date updateTime; |
| | | |
| | | /** |
| | | * 修改人员 |
| | | */ |
| | | @ApiModelProperty(value= "修改人员") |
| | | private Long updateBy; |
| | | |
| | | /** |
| | | * 备注 |
| | | */ |
| | | @ApiModelProperty(value= "备注") |
| | | private String memo; |
| | | |
| | | /** |
| | | * 设备状态 |
| | | */ |
| | | @ApiModelProperty(value= "设备状态") |
| | | private String deviceStatus; |
| | | |
| | | /** |
| | | * PLC类型 |
| | | */ |
| | | @ApiModelProperty(value= "PLC类型") |
| | | private Long devicePlc; |
| | | |
| | | public ShuttleDeviceStatus() {} |
| | | |
| | | public ShuttleDeviceStatus(String uuid,String name,String flag,Long hostId,Integer status,Integer deleted,Date createTime,Long createBy,Date updateTime,Long updateBy,String memo,String deviceStatus,Long devicePlc) { |
| | | this.uuid = uuid; |
| | | this.name = name; |
| | | this.flag = flag; |
| | | this.hostId = hostId; |
| | | this.status = status; |
| | | this.deleted = deleted; |
| | | this.createTime = createTime; |
| | | this.createBy = createBy; |
| | | this.updateTime = updateTime; |
| | | this.updateBy = updateBy; |
| | | this.memo = memo; |
| | | this.deviceStatus = deviceStatus; |
| | | this.devicePlc = devicePlc; |
| | | } |
| | | |
| | | // ShuttleDeviceStatus shuttleDeviceStatus = new ShuttleDeviceStatus( |
| | | // null, // 编号 |
| | | // null, // 状态名称 |
| | | // null, // 标识 |
| | | // null, // 所属机构 |
| | | // null, // 状态 |
| | | // null, // 是否删除 |
| | | // null, // 添加时间 |
| | | // null, // 添加人员 |
| | | // null, // 修改时间 |
| | | // null, // 修改人员 |
| | | // null, // 备注 |
| | | // null, // 设备状态 |
| | | // null // PLC类型 |
| | | // ); |
| | | |
| | | public String getHostId$(){ |
| | | HostService service = SpringUtils.getBean(HostService.class); |
| | | Host host = service.getById(this.hostId); |
| | | if (!Cools.isEmpty(host)){ |
| | | return String.valueOf(host.getName()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getStatus$(){ |
| | | if (null == this.status){ return null; } |
| | | switch (this.status){ |
| | | case 1: |
| | | return "正常"; |
| | | case 0: |
| | | return "禁用"; |
| | | default: |
| | | return String.valueOf(this.status); |
| | | } |
| | | } |
| | | |
| | | public String getDeleted$(){ |
| | | if (null == this.deleted){ return null; } |
| | | switch (this.deleted){ |
| | | case 1: |
| | | return "是"; |
| | | case 0: |
| | | return "否"; |
| | | default: |
| | | return String.valueOf(this.deleted); |
| | | } |
| | | } |
| | | |
| | | public String getCreateTime$(){ |
| | | if (Cools.isEmpty(this.createTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.createTime); |
| | | } |
| | | |
| | | public String getCreateBy$(){ |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.getById(this.createBy); |
| | | if (!Cools.isEmpty(user)){ |
| | | return String.valueOf(user.getNickname()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getUpdateTime$(){ |
| | | if (Cools.isEmpty(this.updateTime)){ |
| | | return ""; |
| | | } |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime); |
| | | } |
| | | |
| | | public String getUpdateBy$(){ |
| | | UserService service = SpringUtils.getBean(UserService.class); |
| | | User user = service.getById(this.updateBy); |
| | | if (!Cools.isEmpty(user)){ |
| | | return String.valueOf(user.getNickname()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public String getDevicePlc$(){ |
| | | DevicePlcService service = SpringUtils.getBean(DevicePlcService.class); |
| | | DevicePlc devicePlc = service.getById(this.devicePlc); |
| | | if (!Cools.isEmpty(devicePlc)){ |
| | | return String.valueOf(devicePlc.getName()); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.mapper; |
| | | |
| | | import com.zy.asrs.wcs.rcs.entity.ShuttleDeviceStatus; |
| | | import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
| | | import org.apache.ibatis.annotations.Mapper; |
| | | import org.springframework.stereotype.Repository; |
| | | |
| | | @Mapper |
| | | @Repository |
| | | public interface ShuttleDeviceStatusMapper extends BaseMapper<ShuttleDeviceStatus> { |
| | | |
| | | } |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/Task.java |
| | |
| | | package com.zy.asrs.wcs.core.model; |
| | | package com.zy.asrs.wcs.rcs.model; |
| | | |
| | | import lombok.Data; |
| | | |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.model.enums; |
| | | |
| | | public enum LiftProtocolStatusType { |
| | | |
| | | NONE(-1, "未知"), |
| | | IDLE(1, "空闲"), |
| | | WORKING(2, "作业中"), |
| | | WAITING(3, "等待确认"), |
| | | OFFLINE(4, "离线"), |
| | | ; |
| | | |
| | | public Integer id; |
| | | public String desc; |
| | | |
| | | LiftProtocolStatusType(Integer id, String desc) { |
| | | this.id = id; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public static LiftProtocolStatusType get(Integer id) { |
| | | if (null == id) { |
| | | return null; |
| | | } |
| | | for (LiftProtocolStatusType type : LiftProtocolStatusType.values()) { |
| | | if (type.id.equals(id.intValue())) { |
| | | return type; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static LiftProtocolStatusType get(LiftProtocolStatusType type) { |
| | | if (null == type) { |
| | | return null; |
| | | } |
| | | for (LiftProtocolStatusType type2 : LiftProtocolStatusType.values()) { |
| | | if (type2 == type) { |
| | | return type2; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.model.enums; |
| | | |
| | | public enum ShuttleDeviceStatusType { |
| | | |
| | | NONE,//未知 |
| | | IDLE,//空闲 |
| | | OFFLINE,//离线 |
| | | WORKING,//工作中 |
| | | CHARGING,//充电中 |
| | | ; |
| | | |
| | | public static ShuttleDeviceStatusType findInstance(String s){ |
| | | for (ShuttleDeviceStatusType type : ShuttleDeviceStatusType.values()) { |
| | | if (type.toString().equals(s)) { |
| | | return type; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.model.enums; |
| | | |
| | | /** |
| | | * 四向穿梭车内部状态枚举 |
| | | */ |
| | | public enum ShuttleProtocolStatusType { |
| | | |
| | | NONE(0, "未知"), |
| | | IDLE(1, "空闲"), |
| | | WORKING(2, "作业中"), |
| | | WAITING(3, "等待确认"), |
| | | CHARGING(4, "充电中"), |
| | | CHARGING_WAITING(5, "充电任务等待确认"), |
| | | FIXING(6, "故障修复中"), |
| | | OFFLINE(7, "离线"), |
| | | ; |
| | | |
| | | public Integer id; |
| | | public String desc; |
| | | |
| | | ShuttleProtocolStatusType(Integer id, String desc) { |
| | | this.id = id; |
| | | this.desc = desc; |
| | | } |
| | | |
| | | public static ShuttleProtocolStatusType get(Integer id) { |
| | | if (null == id) { |
| | | return null; |
| | | } |
| | | for (ShuttleProtocolStatusType type : ShuttleProtocolStatusType.values()) { |
| | | if (type.id.equals(id.intValue())) { |
| | | return type; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public static ShuttleProtocolStatusType get(ShuttleProtocolStatusType type) { |
| | | if (null == type) { |
| | | return null; |
| | | } |
| | | for (ShuttleProtocolStatusType type2 : ShuttleProtocolStatusType.values()) { |
| | | if (type2 == type) { |
| | | return type2; |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | } |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/enums/SlaveType.java |
| | |
| | | package com.zy.asrs.wcs.core.model.enums; |
| | | package com.zy.asrs.wcs.rcs.model.enums; |
| | | |
| | | public enum SlaveType { |
| | | |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.model.protocol; |
| | | |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | @Slf4j |
| | | @Data |
| | | public class LiftProtocol { |
| | | |
| | | //**********************必须存在属性********************** |
| | | /** |
| | | * 提升机号 |
| | | */ |
| | | private String liftNo; |
| | | |
| | | /** |
| | | * 任务号 |
| | | */ |
| | | private String taskNo; |
| | | |
| | | /** |
| | | * 四向穿梭车号 |
| | | */ |
| | | private Integer shuttleNo = 0; |
| | | |
| | | /** |
| | | * 当前提升机状态(内部自我维护) |
| | | */ |
| | | private Integer protocolStatus = -1; |
| | | |
| | | /** |
| | | * 当前提升机状态枚举 |
| | | */ |
| | | private LiftProtocolStatusType protocolStatusType = LiftProtocolStatusType.NONE; |
| | | |
| | | /** |
| | | * 模式 => 自动/手动 |
| | | */ |
| | | private Boolean model; |
| | | |
| | | /** |
| | | * 运行状态 |
| | | */ |
| | | private Boolean run; |
| | | |
| | | /** |
| | | * 就绪状态 |
| | | */ |
| | | private Boolean ready; |
| | | |
| | | /** |
| | | * 前超限 |
| | | */ |
| | | private Boolean frontOverrun; |
| | | |
| | | /** |
| | | * 后超限 |
| | | */ |
| | | private Boolean backOverrun; |
| | | |
| | | /** |
| | | * 左超限 |
| | | */ |
| | | private Boolean leftOverrun; |
| | | |
| | | /** |
| | | * 右超限 |
| | | */ |
| | | private Boolean rightOverrun; |
| | | |
| | | /** |
| | | * 超高 |
| | | */ |
| | | private Boolean overHeight; |
| | | |
| | | /** |
| | | * 超重 |
| | | */ |
| | | private Boolean overWeight; |
| | | |
| | | /** |
| | | * 有托盘 |
| | | */ |
| | | private Boolean hasTray; |
| | | |
| | | /** |
| | | * 有小车 |
| | | */ |
| | | private Boolean hasCar; |
| | | |
| | | /** |
| | | * 故障码 |
| | | */ |
| | | private String errorCode; |
| | | |
| | | /** |
| | | * 任务地址 |
| | | */ |
| | | private Short taskAddress; |
| | | |
| | | /** |
| | | * 目的地址 |
| | | */ |
| | | private Short distAddress; |
| | | |
| | | /** |
| | | * 已完成的任务号 |
| | | */ |
| | | private String completeTaskNo; |
| | | |
| | | /** |
| | | * 层 |
| | | */ |
| | | private Integer lev; |
| | | |
| | | /** |
| | | * 作业标记 |
| | | */ |
| | | private Boolean pakMk = false; |
| | | |
| | | /** |
| | | * 日志采集时间 |
| | | */ |
| | | private Long deviceDataLog = System.currentTimeMillis(); |
| | | |
| | | /** |
| | | * 设备信息 |
| | | */ |
| | | private Device device; |
| | | |
| | | /** |
| | | * 设置提升机状态 |
| | | */ |
| | | public void setProtocolStatus(Integer status) { |
| | | this.protocolStatus = status; |
| | | this.protocolStatusType = LiftProtocolStatusType.get(status); |
| | | } |
| | | |
| | | /** |
| | | * 设置提升机状态 |
| | | */ |
| | | public void setProtocolStatus(LiftProtocolStatusType status) { |
| | | this.protocolStatus = status.id; |
| | | this.protocolStatusType = status; |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.model.protocol; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.zy.asrs.framework.common.SpringUtils; |
| | | import com.zy.asrs.wcs.rcs.model.enums.ShuttleDeviceStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.entity.ShuttleDeviceStatus; |
| | | import com.zy.asrs.wcs.rcs.service.ShuttleDeviceStatusService; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | /** |
| | | * 四向穿梭车 |
| | | */ |
| | | @Slf4j |
| | | @Data |
| | | public class ShuttleProtocol { |
| | | |
| | | //**********************必须存在属性********************** |
| | | /** |
| | | * 四向穿梭车号 |
| | | */ |
| | | private String shuttleNo; |
| | | |
| | | /** |
| | | * 任务号 |
| | | */ |
| | | private String taskNo; |
| | | |
| | | /** |
| | | * 当前小车状态(内部自我维护) |
| | | */ |
| | | private Integer protocolStatus; |
| | | |
| | | /** |
| | | * 当前小车作业状态枚举 |
| | | */ |
| | | private ShuttleProtocolStatusType protocolStatusType; |
| | | |
| | | /** |
| | | * 源库位 |
| | | */ |
| | | private String sourceLocNo; |
| | | |
| | | /** |
| | | * 目标库位 |
| | | */ |
| | | private String locNo; |
| | | |
| | | /** |
| | | * 小车设备状态 |
| | | */ |
| | | private Integer deviceStatus; |
| | | |
| | | /** |
| | | * 当前二维码 |
| | | * 0为空 |
| | | */ |
| | | private String currentCode; |
| | | |
| | | /** |
| | | * 电池电量 |
| | | */ |
| | | private String batteryPower; |
| | | |
| | | /** |
| | | * 错误编号 |
| | | */ |
| | | private String errorCode; |
| | | |
| | | |
| | | //**********************非必须属性,实际使用中可能存在空值********************** |
| | | |
| | | /** |
| | | * 电池温度 |
| | | */ |
| | | private String batteryTemp; |
| | | |
| | | /** |
| | | * 是否顶升 |
| | | */ |
| | | private Boolean hasLift; |
| | | |
| | | /** |
| | | * 行驶方向 |
| | | */ |
| | | private String runDirection; |
| | | |
| | | /** |
| | | * 是否为充电状态 |
| | | */ |
| | | private Boolean hasCharge; |
| | | |
| | | /** |
| | | * 电池电压 |
| | | */ |
| | | private Integer batteryVoltage; |
| | | |
| | | |
| | | //**********************系统自身所需属性********************** |
| | | /** |
| | | * 作业标记 false表示正在作业 |
| | | */ |
| | | private Boolean pakMk = true; |
| | | |
| | | /** |
| | | * 跑库状态 |
| | | */ |
| | | private Boolean moveLoc = false; |
| | | |
| | | /** |
| | | * 跑库类型,0:跑轨道,1:跑库位 |
| | | */ |
| | | private Integer moveType = 0; |
| | | |
| | | /** |
| | | * 跑库X起点 |
| | | */ |
| | | private Integer xStart = 0; |
| | | |
| | | /** |
| | | * 跑库X终点 |
| | | */ |
| | | private Integer xTarget = 0; |
| | | |
| | | /** |
| | | * 跑库X当前点位 |
| | | */ |
| | | private Integer xCurrent = 0; |
| | | |
| | | /** |
| | | * 跑库Y起点 |
| | | */ |
| | | private Integer yStart = 0; |
| | | |
| | | /** |
| | | * 跑库Y终点 |
| | | */ |
| | | private Integer yTarget = 0; |
| | | |
| | | /** |
| | | * 跑库Y当前点位 |
| | | */ |
| | | private Integer yCurrent = 0; |
| | | |
| | | /** |
| | | * 日志采集时间 |
| | | */ |
| | | private Long deviceDataLog = System.currentTimeMillis(); |
| | | |
| | | /** |
| | | * 设备信息 |
| | | */ |
| | | private Device device; |
| | | |
| | | /** |
| | | * 设置小车状态 |
| | | */ |
| | | public void setProtocolStatus(Integer status) { |
| | | this.protocolStatus = status; |
| | | this.protocolStatusType = ShuttleProtocolStatusType.get(status); |
| | | } |
| | | |
| | | /** |
| | | * 设置小车状态 |
| | | */ |
| | | public void setProtocolStatus(ShuttleProtocolStatusType status) { |
| | | this.protocolStatus = status.id; |
| | | this.protocolStatusType = status; |
| | | } |
| | | |
| | | /** |
| | | * 获取小车设备状态 |
| | | */ |
| | | public String getDeviceStatus$() { |
| | | if (this.deviceStatus == null) { |
| | | return ""; |
| | | } |
| | | ShuttleDeviceStatusService shuttleDeviceStatusService = SpringUtils.getBean(ShuttleDeviceStatusService.class); |
| | | ShuttleDeviceStatus status = shuttleDeviceStatusService.getOne(new LambdaQueryWrapper<ShuttleDeviceStatus>() |
| | | .eq(ShuttleDeviceStatus::getHostId, this.device.getHostId()) |
| | | .eq(ShuttleDeviceStatus::getDevicePlc, this.device.getDevicePlc()) |
| | | .eq(ShuttleDeviceStatus::getStatus, 1) |
| | | .eq(ShuttleDeviceStatus::getDeviceStatus, this.deviceStatus)); |
| | | if (status != null) { |
| | | return status.getName(); |
| | | } |
| | | return ""; |
| | | } |
| | | |
| | | /** |
| | | * 获取小车空闲状态 |
| | | */ |
| | | public Boolean getIdle() { |
| | | if (this.deviceStatus == null) { |
| | | return false; |
| | | } |
| | | |
| | | ShuttleDeviceStatusService shuttleDeviceStatusService = SpringUtils.getBean(ShuttleDeviceStatusService.class); |
| | | ShuttleDeviceStatus status = shuttleDeviceStatusService.getOne(new LambdaQueryWrapper<ShuttleDeviceStatus>() |
| | | .eq(ShuttleDeviceStatus::getHostId, this.device.getHostId()) |
| | | .eq(ShuttleDeviceStatus::getDevicePlc, this.device.getDevicePlc()) |
| | | .eq(ShuttleDeviceStatus::getStatus, 1) |
| | | .eq(ShuttleDeviceStatus::getDeviceStatus, this.deviceStatus)); |
| | | if (status != null) { |
| | | if (status.getFlag() != null && status.getFlag().equals(String.valueOf(ShuttleDeviceStatusType.IDLE))) { |
| | | return true;//空闲中 |
| | | } |
| | | } |
| | | return false;//默认不空闲 |
| | | } |
| | | |
| | | } |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/model/protocol/StaProtocol.java |
| | |
| | | package com.zy.asrs.wcs.core.model.protocol; |
| | | package com.zy.asrs.wcs.rcs.model.protocol; |
| | | |
| | | import lombok.Data; |
| | | |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.service; |
| | | |
| | | import com.baomidou.mybatisplus.extension.service.IService; |
| | | import com.zy.asrs.wcs.rcs.entity.ShuttleDeviceStatus; |
| | | |
| | | public interface ShuttleDeviceStatusService extends IService<ShuttleDeviceStatus> { |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.service.impl; |
| | | |
| | | import com.zy.asrs.wcs.rcs.mapper.ShuttleDeviceStatusMapper; |
| | | import com.zy.asrs.wcs.rcs.entity.ShuttleDeviceStatus; |
| | | import com.zy.asrs.wcs.rcs.service.ShuttleDeviceStatusService; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | @Service("shuttleDeviceStatusService") |
| | | public class ShuttleDeviceStatusServiceImpl extends ServiceImpl<ShuttleDeviceStatusMapper, ShuttleDeviceStatus> implements ShuttleDeviceStatusService { |
| | | |
| | | } |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/thread/CrnThread.java |
| | |
| | | package com.zy.asrs.wcs.core.thread; |
| | | package com.zy.asrs.wcs.rcs.thread; |
| | | |
| | | public interface CrnThread { |
| | | |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/thread/DevpThread.java |
| | |
| | | package com.zy.asrs.wcs.core.thread; |
| | | package com.zy.asrs.wcs.rcs.thread; |
| | | |
| | | public interface DevpThread { |
| | | |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/thread/FlowExecute.java |
| | |
| | | package com.zy.asrs.wcs.core.thread; |
| | | package com.zy.asrs.wcs.rcs.thread; |
| | | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.thread; |
| | | |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | |
| | | public interface LiftThread extends ThreadHandler{ |
| | | |
| | | LiftProtocol getStatus();//获取提升机状态 |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.thread; |
| | | |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | |
| | | public interface ShuttleThread extends ThreadHandler{ |
| | | |
| | | ShuttleProtocol getStatus();//获取四向穿梭车状态 |
| | | |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.thread; |
| | | |
| | | public interface ThreadHandler extends Runnable { |
| | | |
| | | boolean connect(); |
| | | |
| | | void close(); |
| | | |
| | | } |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/thread/impl/SiemensCrnThread.java |
| | |
| | | package com.zy.asrs.wcs.core.thread.impl; |
| | | package com.zy.asrs.wcs.rcs.thread.impl; |
| | | |
| | | import com.zy.asrs.wcs.core.thread.CrnThread; |
| | | import com.zy.asrs.wcs.rcs.thread.CrnThread; |
| | | |
| | | public class SiemensCrnThread implements CrnThread { |
| | | |
File was renamed from zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/thread/impl/SiemensDevpThread.java |
| | |
| | | package com.zy.asrs.wcs.core.thread.impl; |
| | | package com.zy.asrs.wcs.rcs.thread.impl; |
| | | |
| | | import com.zy.asrs.wcs.core.model.protocol.StaProtocol; |
| | | import com.zy.asrs.wcs.core.thread.DevpThread; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.StaProtocol; |
| | | import com.zy.asrs.wcs.rcs.thread.DevpThread; |
| | | import java.util.Map; |
| | | import java.util.concurrent.ConcurrentHashMap; |
| | | |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.thread.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.zy.asrs.common.utils.HttpHandler; |
| | | import com.zy.asrs.framework.common.DateUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.OutputQueue; |
| | | import com.zy.asrs.wcs.rcs.model.enums.LiftProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.LiftProtocol; |
| | | import com.zy.asrs.wcs.rcs.thread.LiftThread; |
| | | import com.zy.asrs.wcs.core.utils.RedisUtil; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | |
| | | @Slf4j |
| | | @SuppressWarnings("all") |
| | | public class SurayLiftThread implements LiftThread { |
| | | |
| | | private static final String API_URL = "http://127.0.0.1:8082"; |
| | | |
| | | private Device device; |
| | | private RedisUtil redisUtil; |
| | | private LiftProtocol liftProtocol; |
| | | |
| | | public SurayLiftThread(Device device,RedisUtil redisUtil) { |
| | | this.device = device; |
| | | this.redisUtil = redisUtil; |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | News.info("{}号提升机线程启动", device.getDeviceNo()); |
| | | this.connect(); |
| | | while (true) { |
| | | try { |
| | | read(); |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void read() { |
| | | try { |
| | | readStatus(); |
| | | |
| | | // //提升机处于运行状态,将标记置为false |
| | | // if (liftProtocol.getBusy()) { |
| | | // liftProtocol.setPakMk(false); |
| | | // } |
| | | // |
| | | // //提升机处于未运行、就绪、标记true、有任务号 |
| | | // if (!liftProtocol.getBusy() |
| | | // && !liftProtocol.getPakMk() |
| | | // && liftProtocol.getTaskNo() != 0) { |
| | | // //还有未完成的命令 |
| | | // executeWork(liftProtocol.getTaskNo()); |
| | | // } |
| | | } catch (Exception e) { |
| | | OutputQueue.LIFT.offer(MessageFormat.format("【{0}】读取提升机状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); |
| | | } |
| | | } |
| | | |
| | | private void readStatus() { |
| | | try { |
| | | //获取提升机数据 |
| | | JSONObject data = requestDeviceStatus(); |
| | | if (data != null) { |
| | | if (null == liftProtocol) { |
| | | liftProtocol = new LiftProtocol(); |
| | | liftProtocol.setLiftNo(device.getDeviceNo()); |
| | | liftProtocol.setProtocolStatus(LiftProtocolStatusType.IDLE); |
| | | liftProtocol.setDevice(device); |
| | | } |
| | | |
| | | //----------读取提升机状态----------- |
| | | //模式 |
| | | liftProtocol.setModel(true); |
| | | //运行状态 |
| | | liftProtocol.setRun(data.getInteger("runningstate") == 1); |
| | | //就绪状态 |
| | | liftProtocol.setReady(data.getInteger("readyState") == 1); |
| | | //有托盘 |
| | | liftProtocol.setHasTray(data.getString("haveCargo").equals("Y")); |
| | | //有小车 |
| | | liftProtocol.setHasCar(data.getString("haveCar").equals("Y")); |
| | | //故障码 |
| | | liftProtocol.setErrorCode(""); |
| | | //层 |
| | | liftProtocol.setLev(data.getInteger("curFloor")); |
| | | // //前超限 |
| | | // liftProtocol.setFrontOverrun(status1[4]); |
| | | // //后超限 |
| | | // liftProtocol.setBackOverrun(status1[5]); |
| | | // //左超限 |
| | | // liftProtocol.setLeftOverrun(status1[6]); |
| | | // //右超限 |
| | | // liftProtocol.setRightOverrun(status1[7]); |
| | | // //超高 |
| | | // liftProtocol.setOverHeight(status2[0]); |
| | | // //超重 |
| | | // liftProtocol.setOverWeight(status2[1]); |
| | | // //有托盘 |
| | | // liftProtocol.setHasTray(status2[5]); |
| | | // //有小车 |
| | | // liftProtocol.setHasCar(status2[6]); |
| | | // //设备故障 |
| | | // liftProtocol.setDeviceError(status2[7]); |
| | | // //任务号 |
| | | // liftProtocol.setTaskNo(siemensS7Net.getByteTransform().TransInt16(result1.Content, 2)); |
| | | // //目的地址 |
| | | // liftProtocol.setDistAddress(siemensS7Net.getByteTransform().TransInt16(result1.Content, 4)); |
| | | // //已完成任务号 |
| | | // liftProtocol.setCompleteTaskNo(siemensS7Net.getByteTransform().TransInt16(result1.Content, 6)); |
| | | // liftProtocol.setLev(lev); |
| | | }else { |
| | | OutputQueue.LIFT.offer(MessageFormat.format("【{0}】{1}读取提升机状态信息失败", DateUtils.convert(new Date()), device.getId())); |
| | | throw new CoolException(MessageFormat.format( "读取提升机状态信息失败 ===>> [id:{0}] [ip:{1}] [port:{2}]", device.getId(), device.getIp(), device.getPort())); |
| | | } |
| | | Thread.sleep(200); |
| | | } catch (Exception e) { |
| | | OutputQueue.LIFT.offer(MessageFormat.format("【{0}】读取提升机状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getId(), device.getIp(), device.getPort())); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean connect() { |
| | | return false; |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public LiftProtocol getStatus() { |
| | | return this.liftProtocol; |
| | | } |
| | | |
| | | //***************设备层通讯-不同厂商设备通讯方案不一致*************** |
| | | |
| | | //请求登录 |
| | | private String requestLoginToken() { |
| | | try { |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | | param.put("username", "admin"); |
| | | param.put("password", "admin123"); |
| | | param.put("msgTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/loginToken") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | return jsonObject.getString("token"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //获取设备状态 |
| | | private JSONObject requestDeviceStatus() { |
| | | //模拟数据 |
| | | String data = "[{\"taskNo\":1244,\"curFloor\":2,\"readyState\":1,\"haveCar\":'N',\"completeTaskNo\":0,\"haveCargo\":\"Y\",\"runningstate\":0,\"floors\":[{\"floor\":1,\"location\":1,\"run\":1,\"error\":1,\"cargoState\":\"Y\"},{\"floor\":1,\"location\":2,\"run\":0,\"error\":0,\"cargoState\":\"N\"}]}]"; |
| | | return JSON.parseArray(data).getJSONObject(0); |
| | | // try { |
| | | // String loginToken = requestLoginToken(); |
| | | // if (loginToken == null) { |
| | | // return null; |
| | | // } |
| | | // |
| | | // HashMap<String, Object> headers = new HashMap<>(); |
| | | // headers.put("Authorization", "Bearer " + loginToken); |
| | | // |
| | | // HashMap<String, Object> param = new HashMap<>(); |
| | | // param.put("messageName", "deviceRgvStatus"); |
| | | // param.put("msgTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | // param.put("deviceNo", device.getDeviceNo()); |
| | | // String response = new HttpHandler.Builder() |
| | | // .setUri(API_URL) |
| | | // .setPath("/RDS/deviceLifterStatus") |
| | | // .setHeaders(headers) |
| | | // .setJson(JSON.toJSONString(param)) |
| | | // .build() |
| | | // .doPost(); |
| | | // JSONObject jsonObject = JSON.parseObject(response); |
| | | // Integer code = jsonObject.getInteger("code"); |
| | | // if (code.equals(200)) { |
| | | // return jsonObject.getJSONArray("data").getJSONObject(0); |
| | | // } |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // return null; |
| | | } |
| | | } |
New file |
| | |
| | | package com.zy.asrs.wcs.rcs.thread.impl; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.zy.asrs.common.utils.HttpHandler; |
| | | import com.zy.asrs.framework.common.DateUtils; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.OutputQueue; |
| | | import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.thread.ShuttleThread; |
| | | import com.zy.asrs.wcs.core.utils.RedisUtil; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.HashMap; |
| | | |
| | | @Slf4j |
| | | @SuppressWarnings("all") |
| | | public class SurayShuttleThread implements ShuttleThread { |
| | | |
| | | private static final String API_URL = "http://127.0.0.1:8082"; |
| | | |
| | | private Device device; |
| | | private RedisUtil redisUtil; |
| | | private ShuttleProtocol shuttleProtocol; |
| | | |
| | | public SurayShuttleThread(Device device,RedisUtil redisUtil) { |
| | | this.device = device; |
| | | this.redisUtil = redisUtil; |
| | | } |
| | | |
| | | @Override |
| | | public void run() { |
| | | News.info("{}号四向车线程启动", device.getDeviceNo()); |
| | | this.connect(); |
| | | while (true) { |
| | | try { |
| | | read(); |
| | | Thread.sleep(500); |
| | | } catch (Exception e) { |
| | | log.error("ShuttleThread Fail", e); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void read() { |
| | | try { |
| | | readStatus(); |
| | | // //四向穿梭车空闲、有任务、标记为true、存在任务指令,需要执行任务的下一条指令 |
| | | // if (shuttleProtocol.getTaskNo() != 0) { |
| | | // Object obj = redisUtil.get(DeviceRedisConstant.SHUTTLE_WORK_FLAG + shuttleProtocol.getTaskNo()); |
| | | // if (null != obj) { |
| | | // ShuttleRedisCommand redisCommand = JSON.parseObject(obj.toString(), ShuttleRedisCommand.class); |
| | | // executeWork(redisCommand); |
| | | // } |
| | | // } |
| | | // |
| | | // //小车空闲且有跑库程序 |
| | | // if (shuttleProtocol.isIdle() && shuttleProtocol.getMoveLoc()) { |
| | | // moveLoc(); |
| | | // } |
| | | } catch (Exception e) { |
| | | log.error("ShuttleThread Fail!", e); |
| | | OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】读取四向穿梭车状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getDeviceNo(), device.getIp(), device.getPort())); |
| | | } |
| | | } |
| | | |
| | | private void readStatus() { |
| | | try { |
| | | JSONObject data = requestDeviceStatus(); |
| | | if (data != null) { |
| | | if (null == shuttleProtocol) { |
| | | shuttleProtocol = new ShuttleProtocol(); |
| | | shuttleProtocol.setShuttleNo(device.getDeviceNo()); |
| | | shuttleProtocol.setProtocolStatus(ShuttleProtocolStatusType.IDLE); |
| | | shuttleProtocol.setDevice(device); |
| | | } |
| | | |
| | | //----------读取四向穿梭车状态----------- |
| | | //小车忙状态位 |
| | | shuttleProtocol.setDeviceStatus(data.getInteger("deviceStatus")); |
| | | //当前二维码 |
| | | shuttleProtocol.setCurrentCode(data.getString("deviceLocation")); |
| | | //电池电量 |
| | | shuttleProtocol.setBatteryPower(data.getString("battery")); |
| | | |
| | | |
| | | //是否顶升 |
| | | shuttleProtocol.setHasLift(data.getInteger("palletStatus") == 1 ? true : false); |
| | | //行驶方向 |
| | | shuttleProtocol.setRunDirection(data.getString("direction")); |
| | | |
| | | ///读取四向穿梭车状态-end |
| | | |
| | | // //小车处于忙碌状态,将标记置为true |
| | | // if (shuttleProtocol.getDeviceStatusType() == ShuttleDeviceStatusType.BUSY) { |
| | | // shuttleProtocol.setPakMk(true); |
| | | // } |
| | | // |
| | | // if (shuttleProtocol.getProtocolStatusType() == null && shuttleProtocol.getDeviceStatus().intValue() == ShuttleDeviceStatusType.IDLE.id) { |
| | | // //小车空闲状态、小车任务状态为未知,认定曾离线过,需要复位成空闲 |
| | | // shuttleProtocol.setProtocolStatusType(ShuttleProtocolStatusType.IDLE); |
| | | // } |
| | | |
| | | // if (System.currentTimeMillis() - shuttleProtocol.getDeviceDataLog() > 1000 * 5) { |
| | | // //采集时间超过5s,保存一次数据记录 |
| | | // //保存数据记录 |
| | | // DeviceDataLogService deviceDataLogService = SpringUtils.getBean(DeviceDataLogService.class); |
| | | // DeviceDataLog deviceDataLog = new DeviceDataLog(); |
| | | // deviceDataLog.setOriginData(Base64.getEncoder().encodeToString(result.Content)); |
| | | // deviceDataLog.setWcsData(JSON.toJSONString(shuttleProtocol)); |
| | | // deviceDataLog.setType("shuttle"); |
| | | // deviceDataLog.setDeviceNo(shuttleProtocol.getShuttleNo().intValue()); |
| | | // deviceDataLog.setCreateTime(new Date()); |
| | | // deviceDataLogService.insert(deviceDataLog); |
| | | // |
| | | // //更新采集时间 |
| | | // shuttleProtocol.setDeviceDataLog(System.currentTimeMillis()); |
| | | // } |
| | | } else { |
| | | OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】{1}读取四向穿梭车状态信息失败", DateUtils.convert(new Date()), device.getDeviceNo())); |
| | | throw new CoolException(MessageFormat.format("读取四向穿梭车状态信息失败 ===>> [id:{0}] [ip:{1}] [port:{2}]", device.getDeviceNo(), device.getIp(), device.getPort())); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | OutputQueue.SHUTTLE.offer(MessageFormat.format("【{0}】读取四向穿梭车状态信息失败 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), device.getDeviceNo(), device.getIp(), device.getPort())); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public boolean connect() { |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public void close() { |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public ShuttleProtocol getStatus() { |
| | | return this.shuttleProtocol; |
| | | } |
| | | |
| | | |
| | | //***************设备层通讯-不同厂商设备通讯方案不一致*************** |
| | | |
| | | //请求登录 |
| | | private String requestLoginToken() { |
| | | try { |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | | param.put("username", "admin"); |
| | | param.put("password", "admin123"); |
| | | param.put("msgTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/loginToken") |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | return jsonObject.getString("token"); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | //获取设备状态 |
| | | private JSONObject requestDeviceStatus() { |
| | | try { |
| | | String loginToken = requestLoginToken(); |
| | | if (loginToken == null) { |
| | | return null; |
| | | } |
| | | |
| | | HashMap<String, Object> headers = new HashMap<>(); |
| | | headers.put("Authorization", "Bearer " + loginToken); |
| | | |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | | param.put("messageName", "deviceRgvStatus"); |
| | | param.put("msgTime", new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date())); |
| | | param.put("deviceNo", device.getDeviceNo()); |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(API_URL) |
| | | .setPath("/RDS/deviceRgvStatus") |
| | | .setHeaders(headers) |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | return jsonObject.getJSONArray("data").getJSONObject(0); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return null; |
| | | } |
| | | } |
| | |
| | | // generator.username="sa"; |
| | | // generator.password="Zoneyung@zy56$"; |
| | | |
| | | generator.table="sys_dict"; |
| | | generator.tableName="字典"; |
| | | generator.packagePath="com.zy.asrs.wcs.system"; |
| | | generator.table="wcs_shuttle_device_status"; |
| | | generator.tableName="四向车设备状态列表"; |
| | | generator.packagePath="com.zy.asrs.wcs.rcs"; |
| | | |
| | | generator.build(); |
| | | } |
New file |
| | |
| | | <?xml version="1.0" encoding="UTF-8"?> |
| | | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| | | <mapper namespace="com.zy.asrs.wcs.rcs.mapper.ShuttleDeviceStatusMapper"> |
| | | |
| | | </mapper> |