| | |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.domain.vo.PlcErrorTableVo; |
| | | import com.zy.asrs.domain.vo.SiteTableVo; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.BasSte; |
| | | import com.zy.asrs.entity.WrkCharge; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.BasSteService; |
| | | import com.zy.asrs.service.WrkChargeService; |
| | | import com.zy.common.model.enums.WrkChargeType; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.core.DevpThread; |
| | | import com.zy.asrs.service.impl.MainServiceImpl; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.OutputQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.SteChargeType; |
| | | import com.zy.core.enums.SteStatusType; |
| | | import com.zy.core.model.DevpSlave; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.protocol.StaProtocol; |
| | | import com.zy.core.model.protocol.SteProtocol; |
| | | import com.zy.core.properties.SlaveProperties; |
| | | import com.zy.core.thread.SiemensDevpThread; |
| | | import com.zy.core.thread.SteThread; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import com.zy.core.thread.impl.FyDevpThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 输送设备接口 |
| | | * Created by vincent on 2020-06-01 |
| | | */ |
| | | @Slf4j |
| | | @RestController |
| | | @RequestMapping("/site") |
| | | public class SiteController { |
| | |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | @Autowired |
| | | private WrkChargeService wrkChargeService; |
| | | @Autowired |
| | | private BasSteService basSteService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | private MainServiceImpl mainService; |
| | | |
| | | @GetMapping("/io/mode/info/site") |
| | | @ManagerAuth(memo = "充电模式") |
| | | public R ioMode(){ |
| | | @ManagerAuth(memo = "入出库模式") |
| | | public R ioMode() { |
| | | List<Map<String, Object>> res = new ArrayList<>(); |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | Map<String, Object> map1 = new HashMap<>(); |
| | | map1.put("floor", 1); |
| | | map1.put("modeVal", devpThread.charge0); |
| | | map1.put("modeDesc", devpThread.charge0?"充电中":"关闭"); |
| | | res.add(map1); |
| | | FyDevpThread devpThread = (FyDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | Map<String, Object> map2 = new HashMap<>(); |
| | | map2.put("floor", 2); |
| | | map2.put("modeVal", devpThread.charge1); |
| | | map2.put("modeDesc", devpThread.charge1?"充电中":"关闭"); |
| | | //map2.put("modeVal", devpThread.ioModeOf2F.id); |
| | | //map2.put("modeDesc", devpThread.ioModeOf2F.desc); |
| | | res.add(map2); |
| | | Map<String, Object> map3 = new HashMap<>(); |
| | | map3.put("floor", 3); |
| | | map3.put("modeVal", devpThread.charge2); |
| | | map3.put("modeDesc", devpThread.charge2?"充电中":"关闭"); |
| | | res.add(map3); |
| | | } |
| | | return R.ok().add(res); |
| | | } |
| | | |
| | | @PostMapping("/io/mode/action/site") |
| | | @ManagerAuth(memo = "充电控制") |
| | | public R ioModeAction(@RequestParam("floor") Integer floor, @RequestParam("charge") Boolean charge){ |
| | | if (null != wrkChargeService.selectWorking(null, WrkChargeType.charge)) { |
| | | return R.error("目前存在小车充电任务,请稍后再试"); |
| | | } |
| | | if (null != wrkChargeService.selectWorking(null, WrkChargeType.reset)) { |
| | | return R.error("目前存在小车复位任务,请稍后再试"); |
| | | } |
| | | if (charge) { |
| | | return R.ok(); |
| | | } |
| | | |
| | | SteChargeType steCharge = SteChargeType.get(floor); |
| | | assert steCharge != null; |
| | | Integer steNo = basSteService.hasCarOfLocNo(steCharge.locNo); |
| | | if (Cools.isEmpty(steNo)) { |
| | | return R.error(steNo + "号小车不在" + floor + "号充电桩,请检查小车定位"); |
| | | } |
| | | SteThread steThread = (SteThread) SlaveConnection.get(SlaveType.Ste, steNo); |
| | | SteProtocol steProtocol = steThread.getSteProtocol(); |
| | | BasSte basSte = basSteService.selectById(steNo); |
| | | if (steProtocol.getMode() == 0) { |
| | | return R.error(steNo + "号小车离线,无法操作"); |
| | | } |
| | | if (!steProtocol.getStatusType().equals(SteStatusType.IDLE)) { |
| | | return R.error(steNo + "号小车不是空闲,无法操作"); |
| | | } |
| | | WrkCharge wrkCharge = wrkChargeService.selectWorking(steNo, WrkChargeType.reset); |
| | | if (wrkCharge == null) { |
| | | // 开始穿梭车复位任务 |
| | | wrkCharge = new WrkCharge(); |
| | | wrkCharge.setSteNo(steNo); |
| | | wrkCharge.setWrkNo(commonService.getChargeWorkNo(6)); |
| | | wrkCharge.setWrkSts(41L); // 41.小车准备复位 |
| | | wrkCharge.setCrnNo(2); // 固定2号堆垛机 |
| | | wrkCharge.setIoPri((double) 10); |
| | | wrkCharge.setSourceLocNo(steCharge.locNo); |
| | | wrkCharge.setLocNo(basSte.getIdleLoc()); |
| | | wrkCharge.setMemo("reset"); |
| | | wrkCharge.setAppeTime(new Date()); |
| | | if (!wrkChargeService.insert(wrkCharge)) { |
| | | log.error("保存{}号穿梭车复位任务失败!!!", steNo); |
| | | } |
| | | } |
| | | return R.ok(steNo + "号小车准备离开" + floor + "号充电桩"); |
| | | } |
| | | |
| | | @PostMapping("/table/site") |
| | | @ManagerAuth(memo = "站点信息表") |
| | | public R siteTable(){ |
| | | public R siteTable() { |
| | | List<SiteTableVo> list = new ArrayList<>(); |
| | | // 内存数据 |
| | | Map<Integer, StaProtocol> station = new HashMap<>(); |
| | | FyDevpThread xx = (FyDevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | FyDevpThread devpThread = (FyDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | station.putAll(devpThread.getStation()); |
| | | } |
| | | // 持久数据 |
| | |
| | | vo.setDevNo(devp.getDevNo()); // 站点编号 |
| | | list.add(vo); |
| | | StaProtocol staProtocol = station.get(devp.getDevNo()); |
| | | if (null == staProtocol) { continue; } |
| | | if (null == staProtocol) { |
| | | continue; |
| | | } |
| | | vo.setWorkNo(staProtocol.getWorkNo()); // 工作号 |
| | | vo.setAutoing(staProtocol.isAutoing()?"Y":"N"); // 自动 |
| | | vo.setLoading(staProtocol.isLoading()?"Y":"N"); // 有物 |
| | | vo.setInEnable(staProtocol.isInEnable()?"Y":"N"); // 可入 |
| | | vo.setOutEnable(staProtocol.isOutEnable()?"Y":"N"); // 可出 |
| | | vo.setPakMk(staProtocol.isPakMk()?"Y":"N"); // 入库标记 |
| | | vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N"); // 空板信号 |
| | | vo.setAutoing(staProtocol.isAutoing() ? "Y" : "N"); // 自动 |
| | | vo.setLoading(staProtocol.isLoading() ? "Y" : "N"); // 有物 |
| | | vo.setInEnable(mainService.isInEnable(xx, devp.getDevNo()) ? "Y" : "N"); // 可入 |
| | | vo.setOutEnable(mainService.isOutEnable(xx, devp.getDevNo()) ? "Y" : "N"); // 可出 |
| | | vo.setPakMk(staProtocol.isPakMk() ? "Y" : "N"); // 入库标记 |
| | | vo.setEmptyMk(staProtocol.isEmptyMk() ? "Y" : "N"); // 空板信号 |
| | | vo.setStaNo(staProtocol.getStaNo()); // 目标站 |
| | | vo.setFinishWorkNo(staProtocol.getFinishWorkNo()); |
| | | // vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "低" : "高"); //高低库位 |
| | | //vo.setLocType1(staProtocol.getWeight() == 1 ? "重" : "轻"); |
| | | vo.setFinishWorkNo(staProtocol.getFinishWorkNo()); |
| | | // if (staProtocol.getSiteId() == 1031 || staProtocol.getSiteId() == 1032) { |
| | | // vo.setOutInModel((staProtocol.getOutInModel() != null && staProtocol.getOutInModel() == 1) ? "出" : "入"); |
| | | // |
| | | // } |
| | | } |
| | | return R.ok().add(list); |
| | | } |
| | | |
| | | @PostMapping("/table/plc/errors") |
| | | @ManagerAuth(memo = "输送设备plc异常信息表") |
| | | public R plcErrorTable(){ |
| | | public R plcErrorTable() { |
| | | List<PlcErrorTableVo> list = new ArrayList<>(); |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | FyDevpThread devpThread = (FyDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | Map<Integer, StaProtocol> station = devpThread.getStation(); |
| | | |
| | | for(Map.Entry<Integer, StaProtocol> entry : station.entrySet()) { |
| | | for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) { |
| | | StaProtocol staProtocol = entry.getValue(); |
| | | // if (staProtocol) { |
| | | // PlcErrorTableVo vo = new PlcErrorTableVo(); |
| | |
| | | } |
| | | |
| | | list.sort((o1, o2) -> { |
| | | if (o1.getNo().compareTo(o2.getNo()) > 0){ |
| | | if (o1.getNo().compareTo(o2.getNo()) > 0) { |
| | | return 1; |
| | | }else if (o1.getNo().compareTo(o2.getNo()) < 0){ |
| | | } else if (o1.getNo().compareTo(o2.getNo()) < 0) { |
| | | return 0; |
| | | }else{ |
| | | } else { |
| | | return -1; |
| | | } |
| | | |
| | |
| | | |
| | | @PostMapping("/output/site") |
| | | @ManagerAuth(memo = "站点设备报文日志输出") |
| | | public R siteOutput(){ |
| | | public R siteOutput() { |
| | | StringBuilder str = new StringBuilder(); |
| | | String s; |
| | | int i = 0; |
| | | while((s = OutputQueue.DEVP.poll()) != null && i <=10) { |
| | | while ((s = OutputQueue.DEVP.poll()) != null && i <= 10) { |
| | | str.append("\n").append(s); |
| | | i++; |
| | | } |
| | |
| | | /****************************************************************/ |
| | | |
| | | @GetMapping("/detl/{siteId}") |
| | | public R siteDetl(@PathVariable("siteId") Integer siteId){ |
| | | public R siteDetl(@PathVariable("siteId") Integer siteId) { |
| | | SiteTableVo vo = new SiteTableVo(); |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | FyDevpThread devpThread = (FyDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | Map<Integer, StaProtocol> station = devpThread.getStation(); |
| | | for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) { |
| | | if (siteId.equals(entry.getKey())) { |
| | | StaProtocol staProtocol = entry.getValue(); |
| | | vo.setDevNo(entry.getKey()); // 站点编号 |
| | | vo.setWorkNo(staProtocol.getWorkNo()); // 工作号 |
| | | vo.setAutoing(staProtocol.isAutoing()?"Y":"N"); // 自动 |
| | | vo.setLoading(staProtocol.isLoading()?"Y":"N"); // 有物 |
| | | vo.setInEnable(staProtocol.isInEnable()?"Y":"N"); // 可入 |
| | | vo.setOutEnable(staProtocol.isOutEnable()?"Y":"N"); // 可出 |
| | | vo.setPakMk(staProtocol.isPakMk()?"Y":"N"); // 需求1 |
| | | vo.setEmptyMk(staProtocol.isEmptyMk()?"Y":"N"); // 空板信号 |
| | | vo.setAutoing(staProtocol.isAutoing() ? "Y" : "N"); // 自动 |
| | | vo.setLoading(staProtocol.isLoading() ? "Y" : "N"); // 有物 |
| | | vo.setInEnable(staProtocol.isInEnable() ? "Y" : "N"); // 可入 |
| | | vo.setOutEnable(staProtocol.isOutEnable() ? "Y" : "N"); // 可出 |
| | | vo.setPakMk(staProtocol.isPakMk() ? "Y" : "N"); // 需求1 |
| | | vo.setEmptyMk(staProtocol.isEmptyMk() ? "Y" : "N"); // 空板信号 |
| | | vo.setStaNo(staProtocol.getStaNo()); // 目标站 |
| | | vo.setLocType1(staProtocol.isHigh() != staProtocol.isLow() && staProtocol.isLow() ? "低" : "高"); //高低库位 |
| | | return R.ok().add(vo); |
| | | } |
| | | } |
| | |
| | | public R siteDetlUpdate(@RequestParam Integer siteId, |
| | | @RequestParam Short workNo, |
| | | @RequestParam Short staNo, |
| | | @RequestParam String pakMk){ |
| | | @RequestParam String pakMk) { |
| | | for (DevpSlave devp : slaveProperties.getDevp()) { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | FyDevpThread devpThread = (FyDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId()); |
| | | Map<Integer, StaProtocol> station = devpThread.getStation(); |
| | | for (Map.Entry<Integer, StaProtocol> entry : station.entrySet()) { |
| | | if (siteId.equals(entry.getKey())) { |
| | | StaProtocol staProtocol = entry.getValue(); |
| | | staProtocol = staProtocol.clone(); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | } |
| | | if (workNo != null) { |
| | | staProtocol.setWorkNo(workNo); |
| | | } |