| | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | |
| | | import com.zy.asrs.domain.param.SystemSwitchParam; |
| | | import com.zy.asrs.domain.vo.CrnDetailVo; |
| | | import com.zy.asrs.domain.vo.CrnLatestDataVo; |
| | | import com.zy.asrs.domain.vo.FakeTaskTraceVo; |
| | | import com.zy.asrs.domain.vo.StationLatestDataVo; |
| | | import com.zy.asrs.domain.vo.RgvLatestDataVo; |
| | | import com.zy.asrs.domain.vo.StationTaskTraceVo; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.common.CodeRes; |
| | |
| | | import com.zy.core.thread.StationThread; |
| | | import com.zy.core.thread.RgvThread; |
| | | import com.zy.core.model.protocol.RgvProtocol; |
| | | import com.zy.core.network.fake.FakeTaskTraceRegistry; |
| | | import com.zy.core.trace.StationTaskTraceRegistry; |
| | | |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | private BasMapService basMapService; |
| | | @Autowired |
| | | private StationCycleCapacityService stationCycleCapacityService; |
| | | @Autowired |
| | | private FakeTaskTraceRegistry fakeTaskTraceRegistry; |
| | | @Autowired |
| | | private StationTaskTraceRegistry stationTaskTraceRegistry; |
| | | |
| | | @PostMapping("/system/running/status") |
| | | @ManagerAuth(memo = "系统运行状态") |
| | |
| | | public R stationLatestData() { |
| | | List<StationLatestDataVo> vos = new ArrayList<>(); |
| | | |
| | | WrkLastno inTaskRange = wrkLastnoService.selectById(WrkIoType.IN.id); |
| | | WrkLastno outTaskRange = wrkLastnoService.selectById(WrkIoType.OUT.id); |
| | | WrkLastno inTaskRange = wrkLastnoService.getById(WrkIoType.IN.id); |
| | | WrkLastno outTaskRange = wrkLastnoService.getById(WrkIoType.OUT.id); |
| | | |
| | | List<DeviceConfig> devpList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | List<DeviceConfig> devpList = deviceConfigService.list(new QueryWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Devp))); |
| | | for (DeviceConfig deviceConfig : devpList) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, |
| | |
| | | } |
| | | |
| | | private boolean isInRange(Integer taskNo, WrkLastno taskRange) { |
| | | if (taskRange == null || taskRange.getSNo() == null || taskRange.getENo() == null) { |
| | | if (taskRange == null || taskRange.getsNo() == null || taskRange.geteNo() == null) { |
| | | return false; |
| | | } |
| | | return taskNo >= taskRange.getSNo() && taskNo <= taskRange.getENo(); |
| | | return taskNo >= taskRange.getsNo() && taskNo <= taskRange.geteNo(); |
| | | } |
| | | |
| | | @PostMapping("/latest/data/crn") |
| | |
| | | public R crnLatestData() { |
| | | List<CrnLatestDataVo> vos = new ArrayList<>(); |
| | | |
| | | List<DeviceConfig> crnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | List<DeviceConfig> crnList = deviceConfigService.list(new QueryWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Crn))); |
| | | for (DeviceConfig deviceConfig : crnList) { |
| | | // 获取堆垛机信息 |
| | |
| | | vo.setCrnStatus(CrnStatusType.MACHINE_ERROR); |
| | | } else { |
| | | if (crnProtocol.getTaskNo() > 0) { |
| | | WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); |
| | | WrkMast wrkMast = wrkMastService.getById(crnProtocol.getTaskNo()); |
| | | if (wrkMast != null) { |
| | | vo.setCrnStatus(CrnStatusType.process(wrkMast.getIoType())); |
| | | } else { |
| | |
| | | @ManagerAuth(memo = "双工位堆垛机实时数据") |
| | | public R dualCrnLatestData() { |
| | | List<CrnLatestDataVo> vos = new ArrayList<>(); |
| | | List<DeviceConfig> dualCrnList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | List<DeviceConfig> dualCrnList = deviceConfigService.list(new QueryWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.DualCrn))); |
| | | for (DeviceConfig deviceConfig : dualCrnList) { |
| | | DualCrnThread crnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn, deviceConfig.getDeviceNo()); |
| | |
| | | @ManagerAuth(memo = "RGV实时数据") |
| | | public R rgvLatestData(){ |
| | | List<RgvLatestDataVo> vos = new ArrayList<>(); |
| | | List<DeviceConfig> rgvList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>() |
| | | List<DeviceConfig> rgvList = deviceConfigService.list(new QueryWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Rgv))); |
| | | for (DeviceConfig deviceConfig : rgvList) { |
| | | RgvThread rgvThread = (RgvThread) SlaveConnection.get(SlaveType.Rgv, deviceConfig.getDeviceNo()); |
| | |
| | | @GetMapping("/latest/data/station/cycle/capacity") |
| | | public R stationCycleCapacity() { |
| | | return R.ok().add(stationCycleCapacityService.getLatestSnapshot()); |
| | | } |
| | | |
| | | @PostMapping("/latest/data/fake/trace") |
| | | @ManagerAuth(memo = "仿真任务轨迹实时数据") |
| | | public R fakeTaskTraceLatestData() { |
| | | List<FakeTaskTraceVo> traceList = fakeTaskTraceRegistry.listActiveTraces(); |
| | | return R.ok().add(traceList); |
| | | } |
| | | |
| | | @PostMapping("/latest/data/station/trace") |
| | | @ManagerAuth(memo = "输送任务轨迹实时数据") |
| | | public R stationTaskTraceLatestData() { |
| | | List<StationTaskTraceVo> traceList = stationTaskTraceRegistry.listLatestTraces(); |
| | | return R.ok().add(traceList); |
| | | } |
| | | |
| | | // @PostMapping("/latest/data/barcode") |
| | |
| | | } |
| | | CrnDetailVo vo = new CrnDetailVo(); |
| | | |
| | | DeviceConfig deviceConfig = deviceConfigService.selectOne(new EntityWrapper<DeviceConfig>() |
| | | DeviceConfig deviceConfig = deviceConfigService.getOne(new QueryWrapper<DeviceConfig>() |
| | | .eq("device_type", String.valueOf(SlaveType.Crn)) |
| | | .eq("device_no", crnNo)); |
| | | |
| | |
| | | vo.setCrnStatus(crnProtocol.getStatusType().desc); |
| | | |
| | | if (crnProtocol.getAlarm() > 0) { |
| | | BasCrnpErr crnError = basCrnpErrService.selectById(crnProtocol.getAlarm()); |
| | | BasCrnpErr crnError = basCrnpErrService.getById(crnProtocol.getAlarm()); |
| | | vo.setError(crnError == null ? "未知异常" : crnError.getErrName()); |
| | | } |
| | | |
| | | if (crnProtocol.getTaskNo() > 0) { |
| | | WrkMast wrkMast = wrkMastService.selectById(crnProtocol.getTaskNo()); |
| | | WrkMast wrkMast = wrkMastService.getById(crnProtocol.getTaskNo()); |
| | | if (wrkMast != null) { |
| | | vo.setSourceStaNo(String.valueOf(wrkMast.getSourceStaNo())); |
| | | vo.setStaNo(String.valueOf(wrkMast.getStaNo())); |
| | |
| | | } |
| | | |
| | | private List<List<HashMap<String, Object>>> buildLocMapBase() { |
| | | BasMap basMap = basMapService.selectOne(new EntityWrapper<BasMap>().eq("lev", 1)); |
| | | BasMap basMap = basMapService.getOne(new QueryWrapper<BasMap>().eq("lev", 1)); |
| | | if (Cools.isEmpty(basMap) || Cools.isEmpty(basMap.getData())) { |
| | | return null; |
| | | } |
| | |
| | | JSONArray data = JSON.parseArray(object.toString()); |
| | | return R.ok().add(data); |
| | | } |
| | | EntityWrapper<LocMast> wrapper = new EntityWrapper<>(); |
| | | QueryWrapper<LocMast> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("lev1", 1); |
| | | List<LocMast> locMasts = locMastService.selectList(wrapper); |
| | | List<LocMast> locMasts = locMastService.list(wrapper); |
| | | redisUtil.set(RedisKeyType.LOC_MAST_MAP_LIST.key, JSON.toJSONString(locMasts), 60 * 60 * 24); |
| | | return R.ok().add(locMasts); |
| | | } |