| | |
| | | |
| | | import com.zy.acs.conveyor.common.web.BaseController; |
| | | import com.zy.acs.conveyor.controller.requestParam.StaParam; |
| | | import com.zy.acs.conveyor.controller.responseParam.StationResponseParam; |
| | | import com.zy.acs.conveyor.controller.vo.PlcErrorTableVo; |
| | | import com.zy.acs.conveyor.core.DevpThread; |
| | | import com.zy.acs.conveyor.core.cache.SlaveConnection; |
| | | import com.zy.acs.conveyor.core.enums.SlaveType; |
| | | import com.zy.acs.conveyor.core.model.protocol.StaProtocol; |
| | | import com.zy.acs.conveyor.core.model.StaProtocol; |
| | | import com.zy.acs.conveyor.core.service.StationService; |
| | | import com.zy.acs.conveyor.entity.Job; |
| | | import com.zy.acs.conveyor.service.JobService; |
| | | import com.zy.acs.framework.common.R; |
| | |
| | | @Autowired |
| | | private JobService jobService; |
| | | |
| | | @Autowired |
| | | private StationService stationService; |
| | | |
| | | /** |
| | | * 站点查询 |
| | | */ |
| | | @ResponseBody |
| | | @PostMapping("/station/getTaskNo") |
| | | public R query(@RequestBody StaParam param) { |
| | | log.info("根据站点查询staNo:{}", param); |
| | | String staNo = param.getStaNo(); |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, param.getDevpId()); |
| | | List<StationResponseParam> list = new ArrayList<>(); |
| | | Map<Integer, StaProtocol> station = devpThread.getStation(); |
| | | StaProtocol staProtocol = station.get(Integer.parseInt(staNo)); |
| | | Map<Integer, StaProtocol> station = stationService.getStationMap(param.getDevpId()); |
| | | StaProtocol staProtocol = station.get(param.getStationId()); |
| | | if (staProtocol == null) { |
| | | return R.error("站点不存在"); |
| | | } |
| | | Integer workNo = staProtocol.getWorkNo(); |
| | | if (workNo != null) { |
| | | Job jobByJobNo = jobService.getJobByJobNo(workNo); |
| | |
| | | @ResponseBody |
| | | @PostMapping("/station/getError") |
| | | public R getError(@RequestBody StaParam param) { |
| | | log.info("根据站点查询staNo:{}", param); |
| | | String staNo = param.getStaNo(); |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, param.getDevpId()); |
| | | Map<Integer, StaProtocol> station = devpThread.getStation(); |
| | | StaProtocol staProtocol = station.get(Integer.parseInt(staNo)); |
| | | return R.ok(staPlcErr(staProtocol)); |
| | | List<PlcErrorTableVo> list = new ArrayList<>(); |
| | | if (param.getStationId() != null) { |
| | | Map<Integer, StaProtocol> station = stationService.getStationMap(param.getDevpId()); |
| | | StaProtocol staProtocol = station.get(param.getStationId()); |
| | | return R.ok(staPlcErr(list, staProtocol)); |
| | | } |
| | | if (param.getStationIds() != null && !param.getStationIds().isEmpty()) { |
| | | Map<Integer, StaProtocol> station = stationService.getStationMap(param.getDevpId()); |
| | | for (Integer stationId : param.getStationIds()) { |
| | | StaProtocol staProtocol = station.get(stationId); |
| | | list = staPlcErr(list, staProtocol); |
| | | return R.ok(list); |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | private List<PlcErrorTableVo> staPlcErr(StaProtocol staProtocol) { |
| | | private List<PlcErrorTableVo> staPlcErr(List<PlcErrorTableVo> list, StaProtocol staProtocol) { |
| | | if (staProtocol == null) { |
| | | return null; |
| | | } |
| | | List<PlcErrorTableVo> list = new ArrayList<>(); |
| | | if (staProtocol.getBreakerErr()) { |
| | | PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | | vo.setStaNo(staProtocol.getSiteId()); |