| | |
| | | import com.core.common.Cools; |
| | | import com.core.common.R; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.core.model.StationObjModel; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | |
| | | return R.error("请输入初始化长度"); |
| | | } |
| | | |
| | | List<HashMap<String, Object>> list = new ArrayList<>(); |
| | | List<StationObjModel> list = new ArrayList<>(); |
| | | for (int i = param.getStationNo(); i < param.getStationNo() + param.getInitLength(); i++) { |
| | | HashMap<String, Object> map = new HashMap<>(); |
| | | map.put("devpNo", param.getDevpNo()); |
| | | map.put("stationId", i); |
| | | list.add(map); |
| | | StationObjModel stationObjModel = new StationObjModel(); |
| | | stationObjModel.setDeviceNo(param.getDevpNo()); |
| | | stationObjModel.setStationId(i); |
| | | list.add(stationObjModel); |
| | | } |
| | | |
| | | basDevp.setStationList(JSON.toJSONString(list)); |
| | |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.common.web.BaseController; |
| | | import com.zy.core.enums.LocStsType; |
| | | import com.zy.core.enums.MapNodeType; |
| | | |
| | | import com.zy.core.enums.RedisKeyType; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private BasMapService basMapService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | |
| | | @RequestMapping(value = "/locMast/{id}/auth") |
| | | @ManagerAuth |
| | |
| | | int mapX = (int) map.get("mapX"); |
| | | int mapY = (int) map.get("mapY"); |
| | | locMast.setLocNo(Utils.getLocNo(row, bay, finalLev)); |
| | | locMast.setLocSts(String.valueOf(LocStsType.O)); |
| | | locMast.setRow1(row); |
| | | locMast.setBay1(bay); |
| | | locMast.setLev1(finalLev); |
| | |
| | | }); |
| | | } |
| | | |
| | | redisUtil.del(RedisKeyType.LOC_MAP_BASE.key); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.core.model.StationObjModel; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | |
| | | Integer taskNo = param.getTaskNo(); |
| | | Integer targetStationId = param.getTargetStationId(); |
| | | |
| | | JSONObject finalStation = null; |
| | | StationObjModel finalStation = null; |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<BasDevp>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | List<JSONObject> list = JSON.parseArray(basDevp.getStationList(), JSONObject.class); |
| | | for (JSONObject entity : list) { |
| | | if(entity.getInteger("stationId").equals(stationId)){ |
| | | List<StationObjModel> list = basDevp.getStationList$(); |
| | | for (StationObjModel entity : list) { |
| | | if(entity.getStationId().equals(stationId)){ |
| | | finalStation = entity; |
| | | break; |
| | | } |
| | |
| | | return R.error("站点不存在"); |
| | | } |
| | | |
| | | Integer devpNo = finalStation.getInteger("devpNo"); |
| | | Integer devpNo = finalStation.getDeviceNo(); |
| | | |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, devpNo); |
| | | if (stationThread == null) { |
| | |
| | | //目标库位 |
| | | private String locNo; |
| | | |
| | | //条码 |
| | | private String barcode; |
| | | |
| | | //任务优先级 |
| | | private Integer taskPri; |
| | | |
| | |
| | | //wms任务号 |
| | | private String taskNo; |
| | | |
| | | //源站 |
| | | private Integer sourceStaNo; |
| | | |
| | | //目标站 |
| | | private Integer staNo; |
| | | |
| | | //源库位 |
| | | private String sourceLocNo; |
| | | |
| | | //条码 |
| | | private String barcode; |
| | | |
| | | //任务优先级 |
| | | private Integer taskPri; |
| | | |
| | |
| | | package com.zy.asrs.entity; |
| | | |
| | | import com.core.common.Cools;import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.core.common.Cools; |
| | | import com.zy.core.model.StationObjModel; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | |
| | | @ApiModelProperty(value= "") |
| | | private String memo; |
| | | |
| | | @ApiModelProperty(value= "") |
| | | @TableField("control_rows") |
| | | private String controlRows; |
| | | |
| | | /** |
| | | * 入站列表 |
| | | */ |
| | | @ApiModelProperty(value= "入站列表") |
| | | @TableField("in_station_list") |
| | | private String inStationList; |
| | | |
| | | /** |
| | | * 出站列表 |
| | | */ |
| | | @ApiModelProperty(value= "出站列表") |
| | | @TableField("out_station_list") |
| | | private String outStationList; |
| | | |
| | | public BasCrnp() {} |
| | | |
| | | public BasCrnp(Integer status,Integer wrkNo,String inEnable,String outEnable,Long createBy,Date createTime,Long updateBy,Date updateTime,String memo) { |
| | |
| | | return this.status == 1 ? "正常" : "禁用"; |
| | | } |
| | | |
| | | public List<StationObjModel> getInStationList$(){ |
| | | List<StationObjModel> list = new ArrayList<>(); |
| | | if (Cools.isEmpty(this.inStationList)){ |
| | | return list; |
| | | } |
| | | |
| | | List<StationObjModel> jsonList = JSON.parseArray(this.inStationList,StationObjModel.class); |
| | | for (StationObjModel json : jsonList){ |
| | | list.add(json); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public List<StationObjModel> getOutStationList$(){ |
| | | List<StationObjModel> list = new ArrayList<>(); |
| | | if (Cools.isEmpty(this.outStationList)){ |
| | | return list; |
| | | } |
| | | |
| | | List<StationObjModel> jsonList = JSON.parseArray(this.outStationList,StationObjModel.class); |
| | | for (StationObjModel json : jsonList){ |
| | | list.add(json); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.entity; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.core.common.Cools;import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | |
| | | import com.zy.core.model.StationObjModel; |
| | | import org.springframework.format.annotation.DateTimeFormat; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import lombok.Data; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | @Data |
| | | @TableName("asr_bas_devp") |
| | |
| | | return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(this.updateTime); |
| | | } |
| | | |
| | | public List<StationObjModel> getStationList$(){ |
| | | List<StationObjModel> list = new ArrayList<>(); |
| | | if (Cools.isEmpty(this.stationList)){ |
| | | return list; |
| | | } |
| | | |
| | | List<StationObjModel> jsonList = JSON.parseArray(this.stationList, StationObjModel.class); |
| | | for (StationObjModel json : jsonList){ |
| | | list.add(json); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public List<StationObjModel> getBarcodeStationList$(){ |
| | | List<StationObjModel> list = new ArrayList<>(); |
| | | if (Cools.isEmpty(this.barcodeStationList)){ |
| | | return list; |
| | | } |
| | | |
| | | List<StationObjModel> jsonList = JSON.parseArray(this.barcodeStationList, StationObjModel.class); |
| | | for (StationObjModel json : jsonList){ |
| | | list.add(json); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public List<StationObjModel> getInStationList$(){ |
| | | List<StationObjModel> list = new ArrayList<>(); |
| | | if (Cools.isEmpty(this.inStationList)){ |
| | | return list; |
| | | } |
| | | |
| | | List<StationObjModel> jsonList = JSON.parseArray(this.inStationList, StationObjModel.class); |
| | | for (StationObjModel json : jsonList){ |
| | | list.add(json); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | public List<StationObjModel> getOutStationList$(){ |
| | | List<StationObjModel> list = new ArrayList<>(); |
| | | if (Cools.isEmpty(this.outStationList)){ |
| | | return list; |
| | | } |
| | | |
| | | List<StationObjModel> jsonList = JSON.parseArray(this.outStationList, StationObjModel.class); |
| | | for (StationObjModel json : jsonList){ |
| | | list.add(json); |
| | | } |
| | | return list; |
| | | } |
| | | |
| | | } |
| | |
| | | @TableField("status") |
| | | private Integer status; |
| | | |
| | | @ApiModelProperty(value= "") |
| | | @TableField("barcode") |
| | | private String barcode; |
| | | |
| | | public String getLocSts$(){ |
| | | BasLocStsService service = SpringUtils.getBean(BasLocStsService.class); |
| | | BasLocSts basLocSts = service.selectById(this.locSts); |
| | |
| | | private String barcode; |
| | | |
| | | /** |
| | | * 四向穿梭车号 |
| | | * 堆垛机号 |
| | | */ |
| | | @ApiModelProperty(value= "四向穿梭车号") |
| | | @TableField(value = "shuttle_no",strategy = FieldStrategy.IGNORED) |
| | | private Integer shuttleNo; |
| | | @ApiModelProperty(value= "堆垛机号") |
| | | @TableField(value = "crn_no",strategy = FieldStrategy.IGNORED) |
| | | private Integer crnNo; |
| | | |
| | | /** |
| | | * 提升机号 |
| | | * RGV号 |
| | | */ |
| | | @ApiModelProperty(value= "提升机号") |
| | | @TableField(value = "lift_no",strategy = FieldStrategy.IGNORED) |
| | | private Integer liftNo; |
| | | @ApiModelProperty(value= "RGV号") |
| | | @TableField(value = "rgv_no",strategy = FieldStrategy.IGNORED) |
| | | private Integer rgvNo; |
| | | |
| | | /** |
| | | * WMS任务号 |
| | |
| | | import com.baomidou.mybatisplus.annotations.TableField; |
| | | import com.baomidou.mybatisplus.annotations.TableId; |
| | | import com.baomidou.mybatisplus.annotations.TableName; |
| | | import com.baomidou.mybatisplus.enums.FieldStrategy; |
| | | import com.baomidou.mybatisplus.enums.IdType; |
| | | import com.core.common.Cools; |
| | | import com.core.common.SpringUtils; |
| | |
| | | private String barcode; |
| | | |
| | | /** |
| | | * 四向穿梭车号 |
| | | * 堆垛机号 |
| | | */ |
| | | @ApiModelProperty(value= "四向穿梭车号") |
| | | @TableField(value = "shuttle_no") |
| | | private Integer shuttleNo; |
| | | @ApiModelProperty(value= "堆垛机号") |
| | | @TableField(value = "crn_no") |
| | | private Integer crnNo; |
| | | |
| | | /** |
| | | * 提升机号 |
| | | * RGV号 |
| | | */ |
| | | @ApiModelProperty(value= "提升机号") |
| | | @TableField(value = "lift_no") |
| | | private Integer liftNo; |
| | | @ApiModelProperty(value= "RGV号") |
| | | @TableField(value = "rgv_no") |
| | | private Integer rgvNo; |
| | | |
| | | /** |
| | | * WMS任务号 |
| | |
| | | @Repository |
| | | public interface WrkMastMapper extends BaseMapper<WrkMast> { |
| | | |
| | | // wcs --------------------------------------------- |
| | | // 入库第一步,扫码仪获取条码信息时查询 |
| | | // @Select("select top 1 * from asr_wrk_mast where source_sta_no=#{sourceStaNo} and wrk_sts=2 and barcode=#{barcode} and (io_type=1 or io_type=10) order by io_pri desc,io_time,wrk_no ASC") |
| | | WrkMast selectPakInStep1(@Param("sourceStaNo")Integer sourceStaNo, @Param("barcode")String barcode); |
| | | |
| | | WrkMast selectPakInStep11(@Param("sourceStaNo")Integer sourceStaNo); |
| | | |
| | | List<WrkMast> selectInStep4(); |
| | | |
| | | WrkMast selectByWorkNo(Integer workNo); |
| | | |
| | | List<WrkMast> selectLiftStep223103(); |
| | | |
| | | WrkMast selectByWorkNo324104(Integer workNo); |
| | | |
| | | List<WrkMast> selectBy2125(); |
| | | |
| | | List<WrkMast> selectShuttleWrkByLev(String lev); |
| | | |
| | | List<WrkMast> selectShuttleOutWrkByLev(String lev); |
| | | |
| | | List<WrkMast> selectLiftWrkMast(Integer liftNo); |
| | | |
| | | List<WrkMast> selectLocToLocWrkMast();//查询库位移转工作档 |
| | | |
| | | WrkMast selectPickStepByBarcode(String barcode); |
| | | |
| | | WrkMast selectShuttleHasMoveWorking(@Param("shuttleNo") Integer shuttleNo); |
| | | |
| | | List<WrkMast> selectShuttleMoveWrk(); |
| | | |
| | | WrkMast selectShuttleWorking(@Param("shuttleNo") Integer shuttleNo);//是否有穿梭车任务(移库任务除外) |
| | | |
| | | WrkMast selectByBarcode(String barcode); |
| | | |
| | | List<WrkMast> selectInWrkMastByLiftNo(Integer liftNo);//搜索指定提升机的入库任务 |
| | | |
| | | WrkMast selectChargeWorking(Integer shuttleNo); |
| | | |
| | | WrkMast selectChargeWorkingByChargeSta(Integer chargeSta); |
| | | |
| | | } |
| | |
| | | |
| | | WrkMast selectByWorkNo(Integer workNo); |
| | | |
| | | Boolean judgeInbound(WrkMast wrkMast); |
| | | |
| | | //查询指定楼层任务 |
| | | List<WrkMast> selectWrkByLev(Integer lev); |
| | | |
| | | //查询指定楼层已分配车辆的任务 |
| | | List<WrkMast> selectShuttleWrkByLev(Integer lev); |
| | | |
| | | //查询指定楼层已分配车辆的出库任务 |
| | | List<WrkMast> selectShuttleOutWrkByLev(Integer lev); |
| | | |
| | | WrkMast selectChargeWorking(Integer shuttleNo); |
| | | |
| | | WrkMast selectChargeWorkingByChargeSta(Integer chargeSta); |
| | | |
| | | Boolean hasBusyByShuttle(Integer shuttleNo); |
| | | |
| | | WrkMast selectShuttleHasMoveWorking(Integer shuttleNo); |
| | | |
| | | WrkMast selectShuttleWorking(Integer shuttleNo);//是否有穿梭车任务(移库任务除外) |
| | | |
| | | List<WrkMast> selectShuttleMoveWrk(); |
| | | |
| | | List<WrkMast> selectLiftWrkMast(Integer liftNo); |
| | | |
| | | } |
| | |
| | | package com.zy.asrs.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.service.impl.ServiceImpl; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.mapper.WrkMastMapper; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.core.enums.WrkIoType; |
| | | import com.zy.core.enums.WrkStsType; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | @Service("wrkMastService") |
| | | public class WrkMastServiceImpl extends ServiceImpl<WrkMastMapper, WrkMast> implements WrkMastService { |
| | |
| | | return this.baseMapper.selectByWorkNo(workNo); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean judgeInbound(WrkMast wrkMast) { |
| | | switch (WrkStsType.query(wrkMast.getWrkSts())) { |
| | | case NEW_INBOUND: |
| | | case INBOUND_DEVICE_RUN: |
| | | case INBOUND_LIFT_RUN: |
| | | case INBOUND_LIFT_RUN_COMPLETE: |
| | | case INBOUND_SHUTTLE_RUN: |
| | | case INBOUND_SHUTTLE_RUN_COMPLETE: |
| | | case COMPLETE_INBOUND: |
| | | case SETTLE_INBOUND: |
| | | return Boolean.TRUE; |
| | | case NEW_OUTBOUND: |
| | | case OUTBOUND_SHUTTLE_RUN: |
| | | case OUTBOUND_SHUTTLE_RUN_COMPLETE: |
| | | case OUTBOUND_LIFT_RUN: |
| | | case OUTBOUND_LIFT_RUN_COMPLETE: |
| | | case COMPLETE_OUTBOUND: |
| | | case SETTLE_OUTBOUND: |
| | | return Boolean.FALSE; |
| | | } |
| | | return Boolean.TRUE; |
| | | } |
| | | |
| | | @Override |
| | | public List<WrkMast> selectWrkByLev(Integer lev) { |
| | | ArrayList<WrkMast> currentLevList = new ArrayList<>(); |
| | | List<WrkMast> wrkMasts = this.baseMapper.selectList(new EntityWrapper<WrkMast>()); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | int wrkLev; |
| | | if (wrkMast.getIoType() == WrkIoType.IN.id) { |
| | | wrkLev = Utils.getLev(wrkMast.getLocNo()); |
| | | } else if (wrkMast.getIoType() == WrkIoType.OUT.id) { |
| | | wrkLev = Utils.getLev(wrkMast.getSourceLocNo()); |
| | | } else if (wrkMast.getIoType() == WrkIoType.SHUTTLE_MOVE.id) { |
| | | wrkLev = Utils.getLev(wrkMast.getLocNo()); |
| | | } else if (wrkMast.getIoType() == WrkIoType.LOC_MOVE.id) { |
| | | wrkLev = Utils.getLev(wrkMast.getLocNo()); |
| | | } else if (wrkMast.getIoType() == WrkIoType.SHUTTLE_CHARGE.id) { |
| | | continue; |
| | | } else { |
| | | throw new CoolException("未知任务类型"); |
| | | } |
| | | |
| | | if (wrkLev == lev) { |
| | | currentLevList.add(wrkMast); |
| | | } |
| | | } |
| | | return currentLevList; |
| | | } |
| | | |
| | | @Override |
| | | public List<WrkMast> selectShuttleWrkByLev(Integer lev) { |
| | | return this.baseMapper.selectShuttleWrkByLev("%" + lev); |
| | | } |
| | | |
| | | @Override |
| | | public List<WrkMast> selectShuttleOutWrkByLev(Integer lev) { |
| | | return this.baseMapper.selectShuttleOutWrkByLev("%" + lev); |
| | | } |
| | | |
| | | @Override |
| | | public WrkMast selectChargeWorking(Integer shuttleNo) { |
| | | return this.baseMapper.selectChargeWorking(shuttleNo); |
| | | } |
| | | |
| | | @Override |
| | | public WrkMast selectChargeWorkingByChargeSta(Integer chargeSta) { |
| | | return this.baseMapper.selectChargeWorkingByChargeSta(chargeSta); |
| | | } |
| | | |
| | | @Override |
| | | public Boolean hasBusyByShuttle(Integer shuttleNo) { |
| | | List<WrkMast> wrkMasts = this.selectList(new EntityWrapper<WrkMast>().in("wrk_sts" |
| | | , WrkStsType.NEW_INBOUND.sts |
| | | , WrkStsType.INBOUND_DEVICE_RUN.sts |
| | | , WrkStsType.INBOUND_LIFT_RUN.sts |
| | | , WrkStsType.INBOUND_LIFT_RUN_COMPLETE.sts |
| | | , WrkStsType.INBOUND_SHUTTLE_RUN.sts |
| | | , WrkStsType.INBOUND_SHUTTLE_RUN_COMPLETE.sts |
| | | |
| | | , WrkStsType.NEW_OUTBOUND.sts |
| | | , WrkStsType.OUTBOUND_SHUTTLE_RUN.sts |
| | | , WrkStsType.OUTBOUND_SHUTTLE_RUN_COMPLETE.sts |
| | | , WrkStsType.OUTBOUND_LIFT_RUN.sts |
| | | , WrkStsType.OUTBOUND_LIFT_RUN_COMPLETE.sts |
| | | |
| | | , WrkStsType.NEW_MOVE.sts |
| | | , WrkStsType.MOVE_NEARBY.sts |
| | | , WrkStsType.MOVE_NEARBY_COMPLETE.sts |
| | | , WrkStsType.MOVE_IN_LIFT.sts |
| | | , WrkStsType.MOVE_IN_LIFT_COMPLETE.sts |
| | | , WrkStsType.MOVE_LIFT_RUN.sts |
| | | , WrkStsType.MOVE_LIFT_RUN_COMPLETE.sts |
| | | , WrkStsType.MOVE_OUT_LIFT.sts |
| | | , WrkStsType.MOVE_OUT_LIFT_COMPLETE.sts |
| | | , WrkStsType.MOVE_SHUTTLE.sts |
| | | |
| | | , WrkStsType.NEW_CHARGE.sts |
| | | , WrkStsType.CHARGE_SHUTTLE_RUN.sts |
| | | , WrkStsType.CHARGE_SHUTTLE_RUN_COMPLETE.sts |
| | | , WrkStsType.CHARGE_SHUTTLE_CHARGING.sts |
| | | , WrkStsType.CHARGE_SHUTTLE_CHARGING_COMPLETE.sts |
| | | ).eq("shuttle_no", shuttleNo)); |
| | | if (Cools.isEmpty(wrkMasts)) { |
| | | return false; |
| | | } |
| | | return true; |
| | | } |
| | | |
| | | @Override |
| | | public WrkMast selectShuttleHasMoveWorking(Integer shuttleNo) { |
| | | return this.baseMapper.selectShuttleHasMoveWorking(shuttleNo); |
| | | } |
| | | |
| | | @Override |
| | | public WrkMast selectShuttleWorking(Integer shuttleNo) { |
| | | return this.baseMapper.selectShuttleWorking(shuttleNo); |
| | | } |
| | | |
| | | @Override |
| | | public List<WrkMast> selectShuttleMoveWrk() { |
| | | return this.baseMapper.selectShuttleMoveWrk(); |
| | | } |
| | | |
| | | @Override |
| | | public List<WrkMast> selectLiftWrkMast(Integer liftNo) { |
| | | return this.baseMapper.selectLiftWrkMast(liftNo); |
| | | } |
| | | } |
| | |
| | | } |
| | | |
| | | locMast.setLocSts("F"); |
| | | locMast.setBarcode(wrkMast.getBarcode()); |
| | | locMast.setModiTime(new Date()); |
| | | boolean result = locMastService.updateById(locMast); |
| | | if (!result) { |
| | |
| | | } |
| | | |
| | | locMast.setLocSts("O"); |
| | | locMast.setBarcode(""); |
| | | locMast.setModiTime(new Date()); |
| | | boolean result = locMastService.updateById(locMast); |
| | | if (!result) { |
| | |
| | | |
| | | import lombok.Data; |
| | | |
| | | /** |
| | | * Created by vincent on 2020/6/11 |
| | | */ |
| | | @Data |
| | | public class StartupDto { |
| | | |
| | | private Integer sourceStaNo; |
| | | |
| | | private Integer staNo; |
| | | |
| | | private Integer crnNo; |
| | | |
| | | private String locNo; |
| | | |
| | | private Integer workNo; |
| | | |
| | | private Integer taskPri; |
| | | |
| | | } |
| | |
| | | package com.zy.common.service; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.core.exception.CoolException; |
| | | import com.zy.asrs.domain.param.*; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.utils.NavigateUtils; |
| | | import com.zy.core.News; |
| | | import com.zy.core.enums.WrkIoType; |
| | | import com.zy.core.enums.WrkStsType; |
| | | import com.zy.core.model.StationObjModel; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Service |
| | |
| | | private WrkLastnoService wrkLastnoService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | @Autowired |
| | | private NavigateUtils navigateUtils; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | |
| | | /** |
| | | * 生成工作号 |
| | |
| | | } |
| | | } |
| | | return workNo; |
| | | } |
| | | |
| | | //检测工作号是否在指定类型工作范围内 |
| | | public synchronized boolean checkWorkNoContainMk(Integer workNo, Integer wrkMk) { |
| | | WrkLastno wrkLastno = wrkLastnoService.selectById(wrkMk); |
| | | if (Cools.isEmpty(wrkLastno)) { |
| | | throw new CoolException("数据异常,请联系管理员"); |
| | | } |
| | | |
| | | int sNo = wrkLastno.getSNo(); |
| | | int eNo = wrkLastno.getENo(); |
| | | if (workNo >= sNo && workNo <= eNo) { |
| | | return true; |
| | | } |
| | | return false; |
| | | } |
| | | |
| | | public static String zerofill(String msg, Integer count) { |
| | | if (msg.length() == count) { |
| | | return msg; |
| | | } else if (msg.length() > count) { |
| | | return msg.substring(0, 16); |
| | | } else { |
| | | StringBuilder msgBuilder = new StringBuilder(msg); |
| | | for(int i = 0; i < count - msg.length(); ++i) { |
| | | msgBuilder.insert(0, "0"); |
| | | } |
| | | return msgBuilder.toString(); |
| | | } |
| | | } |
| | | |
| | | public boolean completeTask(CompleteTaskParam param) { |
| | |
| | | ioPri = param.getTaskPri().doubleValue(); |
| | | } |
| | | |
| | | Integer crnNo = commonService.findCrnNoByLocNo(locMast.getLocNo()); |
| | | if (crnNo == null) { |
| | | throw new CoolException("未找到对应堆垛机"); |
| | | } |
| | | |
| | | // 获取工作号 |
| | | int workNo = getWorkNo(WrkIoType.IN.id); |
| | | // 保存工作档 |
| | |
| | | wrkMast.setSourceStaNo(param.getSourceStaNo());//源站 |
| | | wrkMast.setStaNo(param.getStaNo());//目标站 |
| | | wrkMast.setWmsWrkNo(param.getTaskNo()); |
| | | wrkMast.setBarcode(param.getBarcode()); |
| | | wrkMast.setCrnNo(crnNo); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiTime(now); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | |
| | | ioPri = param.getTaskPri().doubleValue(); |
| | | } |
| | | |
| | | Integer crnNo = commonService.findCrnNoByLocNo(locMast.getLocNo()); |
| | | if (crnNo == null) { |
| | | throw new CoolException("未找到对应堆垛机"); |
| | | } |
| | | |
| | | // 获取工作号 |
| | | int workNo = getWorkNo(WrkIoType.OUT.id); |
| | | // 保存工作档 |
| | |
| | | wrkMast.setIoType(WrkIoType.OUT.id); // 入出库状态: 101.出库 |
| | | wrkMast.setIoPri(ioPri); |
| | | wrkMast.setSourceLocNo(param.getSourceLocNo()); // 源库位 |
| | | wrkMast.setSourceStaNo(param.getSourceStaNo());//源站 |
| | | wrkMast.setStaNo(param.getStaNo());//目标站 |
| | | wrkMast.setWmsWrkNo(param.getTaskNo()); |
| | | wrkMast.setBarcode(param.getBarcode()); |
| | | wrkMast.setCrnNo(crnNo); |
| | | wrkMast.setAppeTime(now); |
| | | wrkMast.setModiTime(now); |
| | | boolean res = wrkMastService.insert(wrkMast); |
| | |
| | | return true; |
| | | } |
| | | |
| | | public Integer findCrnNoByLocNo(String locNo) { |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | String controlRows = basCrnp.getControlRows(); |
| | | if (Cools.isEmpty(controlRows)) { |
| | | continue; |
| | | } |
| | | |
| | | List<Integer> rowList = JSON.parseArray(controlRows, Integer.class); |
| | | if(rowList.contains(Utils.getRow(locNo))) { |
| | | return basCrnp.getCrnNo(); |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | public Integer findInStationId(Integer crnNo, Integer sourceStationId) { |
| | | BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", crnNo)); |
| | | if(basCrnp == null) { |
| | | return null; |
| | | } |
| | | |
| | | Integer targetStationId = null; |
| | | List<StationObjModel> stationList = basCrnp.getInStationList$(); |
| | | for (StationObjModel stationObjModel : stationList) { |
| | | try { |
| | | String startLev = String.valueOf(sourceStationId).substring(0, 1); |
| | | List<NavigateNode> navigateNodes = navigateUtils.calcByStationId(Integer.parseInt(startLev), sourceStationId, stationObjModel.getStationId()); |
| | | if(navigateNodes != null) { |
| | | targetStationId = stationObjModel.getStationId(); |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return targetStationId; |
| | | } |
| | | |
| | | public Integer findOutStationId(Integer crnNo, Integer targetStationId) { |
| | | BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", crnNo)); |
| | | if(basCrnp == null) { |
| | | return null; |
| | | } |
| | | |
| | | Integer finalSourceStationId = null; |
| | | List<StationObjModel> stationList = basCrnp.getOutStationList$(); |
| | | for (StationObjModel stationObjModel : stationList) { |
| | | try { |
| | | String startLev = String.valueOf(targetStationId).substring(0, 1); |
| | | List<NavigateNode> navigateNodes = navigateUtils.calcByStationId(Integer.parseInt(startLev), stationObjModel.getStationId(), targetStationId); |
| | | if(navigateNodes != null) { |
| | | finalSourceStationId = stationObjModel.getStationId(); |
| | | break; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | return finalSourceStationId; |
| | | } |
| | | |
| | | } |
| | |
| | | package com.zy.core; |
| | | |
| | | import com.zy.asrs.service.impl.MainServiceImpl; |
| | | import com.core.common.SpringUtils; |
| | | import com.zy.core.plugin.MainProcessPluginApi; |
| | | import com.zy.core.properties.SystemProperties; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import javax.annotation.PreDestroy; |
| | | |
| | | /** |
| | | * WCS主流程 |
| | | * Created by vincent on 2020/8/6 |
| | | */ |
| | | @Data |
| | | @Slf4j |
| | | @Component |
| | | public class MainProcess { |
| | | |
| | | @Autowired |
| | | private MainServiceImpl mainService; |
| | | @Value("${mainProcessPlugin}") |
| | | private String mainProcessPlugin; |
| | | private MainProcessPluginApi mainProcessPluginApi; |
| | | // 所属线程 |
| | | private Thread thread; |
| | | // 频率 |
| | | private int i = 0; |
| | | |
| | | /** |
| | | * =====>> 开始工作 |
| | |
| | | thread = new Thread(() -> { |
| | | while (!Thread.currentThread().isInterrupted()) { |
| | | try { |
| | | |
| | | // 间隔 |
| | | Thread.sleep(300); |
| | | if (mainProcessPluginApi == null) { |
| | | String className = mainProcessPlugin.contains(".") ? mainProcessPlugin : "com.zy.core.plugin." + mainProcessPlugin; |
| | | Class<? extends MainProcessPluginApi> clazz = Class.forName(className).asSubclass(MainProcessPluginApi.class); |
| | | mainProcessPluginApi = SpringUtils.getBean(clazz); |
| | | } |
| | | |
| | | // 系统运行状态判断 |
| | | if (!SystemProperties.WCS_RUNNING_STATUS.get()) { |
| | | continue; |
| | | } |
| | | |
| | | mainProcessPluginApi.run(); |
| | | // 间隔 |
| | | Thread.sleep(200); |
| | | } catch (Exception e) { |
| | |
| | | LOC_MAP_BASE("loc_map_base"), |
| | | |
| | | DEVICE_LOG_KEY("device_log_key_"), |
| | | |
| | | GENERATE_FAKE_IN_TASK_LIMIT("generate_fake_in_task_limit_"), |
| | | GENERATE_FAKE_OUT_TASK_LIMIT("generate_fake_out_task_limit_"), |
| | | GENERATE_FAKE_IN_STATION_DATA_LIMIT("generate_fake_in_station_data_limit_"), |
| | | CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT("check_out_station_stay_time_out_limit_"), |
| | | CHECK_IN_STATION_STAY_TIME_OUT_LIMIT("check_in_station_stay_time_out_limit_"), |
| | | ; |
| | | |
| | | public String key; |
| | |
| | | |
| | | NEW_INBOUND(1, "生成入库任务"), |
| | | INBOUND_DEVICE_RUN(2, "设备上走"), |
| | | INBOUND_LIFT_RUN(3, "提升机搬运中"), |
| | | INBOUND_LIFT_RUN_COMPLETE(4, "提升机搬运完成"), |
| | | INBOUND_SHUTTLE_RUN(5, "小车搬运中"), |
| | | INBOUND_SHUTTLE_RUN_COMPLETE(6, "小车搬运完成"), |
| | | INBOUND_RUN(3, "设备搬运中"), |
| | | INBOUND_RUN_COMPLETE(4, "设备搬运完成"), |
| | | COMPLETE_INBOUND(9, "入库完成"), |
| | | SETTLE_INBOUND(10, "入库库存更新"), |
| | | |
| | | NEW_OUTBOUND(101, "生成出库任务"), |
| | | OUTBOUND_SHUTTLE_RUN(102, "小车搬运中"), |
| | | OUTBOUND_SHUTTLE_RUN_COMPLETE(103, "小车搬运完成"), |
| | | OUTBOUND_LIFT_RUN(104, "提升机搬运中"), |
| | | OUTBOUND_LIFT_RUN_COMPLETE(105, "提升机搬运完成"), |
| | | OUTBOUND_RUN(102, "设备搬运中"), |
| | | OUTBOUND_RUN_COMPLETE(103, "设备搬运完成"), |
| | | STATION_RUN(104, "站点运行中"), |
| | | COMPLETE_OUTBOUND(109, "出库完成"), |
| | | SETTLE_OUTBOUND(110, "出库库存更新"), |
| | | |
| New file |
| | |
| | | package com.zy.core.model; |
| | | |
| | | import lombok.Data; |
| | | |
| | | @Data |
| | | public class StationObjModel { |
| | | |
| | | private Integer deviceNo; |
| | | |
| | | private Integer stationId; |
| | | |
| | | private Integer deviceRow; |
| | | |
| | | private Integer deviceBay; |
| | | |
| | | private Integer deviceLev; |
| | | |
| | | } |
| | |
| | | // 源位置层号 |
| | | private Short sourcePosZ = 0; |
| | | |
| | | // 源站 |
| | | private Short sourceStaNo = 0; |
| | | |
| | | // 源巷道 |
| | | private Short sourceLane = 0; |
| | | |
| | | // 目标位置排号 |
| | | private Short destinationPosX = 0; |
| | | |
| | |
| | | |
| | | // 目标位置层号 |
| | | private Short destinationPosZ = 0; |
| | | |
| | | // 目标站 |
| | | private Short destinationStaNo = 0; |
| | | |
| | | // 目标巷道 |
| | | private Short destinationLane = 0; |
| | | |
| | | // 任务确认 0:未确认 1:已确认 |
| | | private Short command = 0; |
| | |
| | | import com.zy.asrs.entity.DeviceConfig; |
| | | import com.zy.common.model.NavigateNode; |
| | | import com.zy.common.utils.NavigateUtils; |
| | | import com.zy.core.News; |
| | | import com.zy.core.model.CommandResponse; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.network.api.ZyStationConnectApi; |
| | |
| | | private final DeviceConfig deviceConfig; |
| | | // 允许并行执行多个命令任务(固定线程池)。如需更高并发可调整大小。 |
| | | private final ExecutorService executor = Executors |
| | | .newFixedThreadPool(Math.max(2, Runtime.getRuntime().availableProcessors())); |
| | | .newFixedThreadPool(9999); |
| | | |
| | | public ZyStationFakeConnect(DeviceConfig deviceConfig) { |
| | | this.deviceConfig = deviceConfig; |
| | |
| | | } |
| | | |
| | | private void handleCommand(StationCommand command) { |
| | | News.info("[WCS Debug] 站点仿真模拟已启动,命令数据={}", JSON.toJSONString(command)); |
| | | Integer taskNo = command.getTaskNo(); |
| | | Integer stationId = command.getStationId(); |
| | | Integer targetStationId = command.getTargetStaNo(); |
| | | |
| | | if(taskNo == 0 && targetStationId == 0){ |
| | | //清空站点 |
| | | resetStation(stationId); |
| | | return; |
| | | } |
| | | |
| | | if (taskNo == 9999 && targetStationId == 0) { |
| | | //生成仿真数据 |
| | | generateFakeData(stationId, taskNo); |
| | | return; |
| | | } |
| | | |
| | | if (taskNo == 9998 && targetStationId == 0) { |
| | | //生成出库站点仿真数据 |
| | | generateFakeOutStationData(stationId); |
| | | return; |
| | | } |
| | | |
| | | String startLev = String.valueOf(stationId).substring(0, 1); |
| | | String endLev = String.valueOf(targetStationId).substring(0, 1); |
| | |
| | | }else { |
| | | diffLevCommand(command); |
| | | } |
| | | } |
| | | |
| | | private void generateFakeData(Integer stationId, Integer taskNo) { |
| | | ZyStationStatusEntity status = statusList.stream() |
| | | .filter(item -> item.getStationId().equals(stationId)).findFirst().orElse(null); |
| | | if (status == null) { |
| | | return; |
| | | } |
| | | |
| | | status.setTaskNo(taskNo); |
| | | status.setLoading(true); |
| | | status.setBarcode(String.valueOf(System.currentTimeMillis())); |
| | | } |
| | | |
| | | private void generateFakeOutStationData(Integer stationId) { |
| | | ZyStationStatusEntity status = statusList.stream() |
| | | .filter(item -> item.getStationId().equals(stationId)).findFirst().orElse(null); |
| | | if (status == null) { |
| | | return; |
| | | } |
| | | |
| | | status.setLoading(true); |
| | | } |
| | | |
| | | private void resetStation(Integer stationId) { |
| | | ZyStationStatusEntity status = statusList.stream() |
| | | .filter(item -> item.getStationId().equals(stationId)).findFirst().orElse(null); |
| | | if (status == null) { |
| | | return; |
| | | } |
| | | |
| | | status.setTaskNo(0); |
| | | status.setLoading(false); |
| | | status.setBarcode(""); |
| | | } |
| | | |
| | | private void currentLevCommand(StationCommand command) { |
| | |
| | | return; |
| | | } |
| | | |
| | | stationMove(navigateNodes, taskNo, targetStationId); |
| | | stationMove(navigateNodes, taskNo, targetStationId, false); |
| | | } |
| | | |
| | | private void diffLevCommand(StationCommand command) { |
| | |
| | | return; |
| | | } |
| | | |
| | | stationMove(navigateNodes, taskNo, stationId); |
| | | stationMove(targetNavigateNodes, taskNo, targetStationId); |
| | | stationMove(navigateNodes, taskNo, stationId, true); |
| | | stationMove(targetNavigateNodes, taskNo, targetStationId, false); |
| | | } |
| | | |
| | | private void stationMove(List<NavigateNode> navigateNodes, Integer taskNo, Integer targetStationId) { |
| | | private void stationMove(List<NavigateNode> navigateNodes, Integer taskNo, Integer targetStationId, boolean clearData) { |
| | | Integer lastStationId = null; |
| | | for (int i = 0; i < navigateNodes.size(); i++) { |
| | | NavigateNode navigateNode = navigateNodes.get(i); |
| | |
| | | continue; |
| | | } |
| | | |
| | | if (nextStatus.getTaskNo() == 0) { |
| | | if (nextStatus.getTaskNo() == 0 || nextStatus.getTaskNo() == 9999) { |
| | | break; |
| | | } |
| | | |
| | |
| | | } |
| | | } catch (Exception e) { |
| | | continue; |
| | | } |
| | | |
| | | synchronized (status) { |
| | | status.setTaskNo(taskNo); |
| | | status.setTargetStaNo(targetStationId); |
| | | status.setLoading(true); |
| | | } |
| | | |
| | | if (lastStationId != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | synchronized (status) { |
| | | status.setTaskNo(taskNo); |
| | | status.setTargetStaNo(targetStationId); |
| | | status.setLoading(true); |
| | | } |
| | | |
| | | lastStationId = currentStationId; |
| | | sleep(1000); |
| | | } |
| | | |
| | | sleep(10000); |
| | | if (lastStationId != null) { |
| | | Integer finalLastStationId = lastStationId; |
| | | ZyStationStatusEntity lastStatus = statusList.stream() |
| | | .filter(item -> item.getStationId().equals(finalLastStationId)).findFirst().orElse(null); |
| | | if (lastStatus != null) { |
| | | synchronized (lastStatus) { |
| | | lastStatus.setTaskNo(0); |
| | | lastStatus.setTargetStaNo(0); |
| | | lastStatus.setLoading(false); |
| | | if (clearData) { |
| | | sleep(10000); |
| | | if (lastStationId != null) { |
| | | Integer finalLastStationId = lastStationId; |
| | | ZyStationStatusEntity lastStatus = statusList.stream() |
| | | .filter(item -> item.getStationId().equals(finalLastStationId)).findFirst().orElse(null); |
| | | if (lastStatus != null) { |
| | | synchronized (lastStatus) { |
| | | lastStatus.setTaskNo(0); |
| | | lastStatus.setTargetStaNo(0); |
| | | lastStatus.setLoading(false); |
| | | } |
| | | } |
| | | } |
| | | } |
| New file |
| | |
| | | package com.zy.core.plugin; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.domain.param.CreateInTaskParam; |
| | | import com.zy.asrs.domain.param.CreateOutTaskParam; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.common.utils.HttpHandler; |
| | | import com.zy.common.utils.RedisUtil; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.*; |
| | | import com.zy.core.model.StationObjModel; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import com.zy.core.thread.CrnThread; |
| | | import com.zy.core.thread.StationThread; |
| | | import com.zy.core.utils.CrnOperateProcessUtils; |
| | | import com.zy.core.utils.StationOperateProcessUtils; |
| | | import com.zy.system.entity.Config; |
| | | import com.zy.system.service.ConfigService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.*; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class FakeProcess implements MainProcessPluginApi { |
| | | |
| | | private static Map<Integer,Long> stationStayTimeMap = new HashMap<>(); |
| | | private static String enableFake = "N"; |
| | | |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | @Autowired |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | @Autowired |
| | | private RedisUtil redisUtil; |
| | | @Autowired |
| | | private CrnOperateProcessUtils crnOperateUtils; |
| | | @Autowired |
| | | private StationOperateProcessUtils stationOperateProcessUtils; |
| | | |
| | | @Override |
| | | public void run() { |
| | | Config enableFakeConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake")); |
| | | if (enableFakeConfig != null) { |
| | | enableFake = enableFakeConfig.getValue(); |
| | | } |
| | | |
| | | //检测入库站是否有任务生成,并仿真生成模拟入库站点数据 |
| | | checkInStationHasTask(); |
| | | //生成仿真模拟入库任务 |
| | | generateFakeInTask(); |
| | | //生成仿真模拟出库任务 |
| | | generateFakeOutTask(); |
| | | //计算所有站点停留时间 |
| | | calcAllStationStayTime(); |
| | | //检测出库站点停留是否超时 |
| | | checkOutStationStayTimeOut(); |
| | | //检测入库站点堆垛机是否取走货物 |
| | | checkInStationCrnTake(); |
| | | |
| | | //请求生成入库任务 |
| | | generateStoreWrkFile(); |
| | | //执行堆垛机任务 |
| | | crnOperateUtils.crnIoExecute(); |
| | | //堆垛机任务执行完成-具备仿真能力 |
| | | crnIoExecuteFinish(); |
| | | //执行输送站点入库任务 |
| | | stationOperateProcessUtils.stationInExecute(); |
| | | //执行输送站点出库任务 |
| | | stationOperateProcessUtils.stationOutExecute(); |
| | | //检测输送站点出库任务执行完成 |
| | | stationOperateProcessUtils.stationOutExecuteFinish(); |
| | | } |
| | | |
| | | //检测入库站是否有任务生成,并仿真生成模拟入库站点数据 |
| | | private synchronized void checkInStationHasTask() { |
| | | if (!enableFake.equals("Y")) { |
| | | return; |
| | | } |
| | | |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if(stationThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap(); |
| | | |
| | | List<StationObjModel> list = basDevp.getInStationList$(); |
| | | for (StationObjModel entity : list) { |
| | | Integer stationId = entity.getStationId(); |
| | | if(!stationMap.containsKey(stationId)){ |
| | | continue; |
| | | } |
| | | |
| | | StationProtocol stationProtocol = stationMap.get(stationId); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | Object object = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId); |
| | | if (object != null) { |
| | | continue; |
| | | } |
| | | |
| | | //满足自动、无物、工作号0,生成入库数据 |
| | | if (stationProtocol.isAutoing() |
| | | && !stationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() == 0 |
| | | ) { |
| | | StationCommand command = stationThread.getMoveCommand(9999, stationId, 0, 0); |
| | | MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command)); |
| | | redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 10); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //生成仿真模拟入库任务 |
| | | private synchronized void generateFakeInTask() { |
| | | if (!enableFake.equals("Y")) { |
| | | return; |
| | | } |
| | | |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if(stationThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap(); |
| | | |
| | | List<StationObjModel> list = basDevp.getInStationList$(); |
| | | for (StationObjModel model : list) { |
| | | Integer stationId = model.getStationId(); |
| | | if(!stationMap.containsKey(stationId)){ |
| | | continue; |
| | | } |
| | | |
| | | StationProtocol stationProtocol = stationMap.get(stationId); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | Object object = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_TASK_LIMIT.key + stationId); |
| | | if (object != null) { |
| | | return; |
| | | } |
| | | |
| | | //满足自动、有物、工作号9999,生成入库数据 |
| | | if (stationProtocol.isAutoing() |
| | | && stationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() == 9999 |
| | | ) { |
| | | //检测任务是否生成 |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode())); |
| | | if (!wrkMasts.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", String.valueOf(LocStsType.O))); |
| | | if (locMastList.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | int nextInt = new Random().nextInt(locMastList.size()); |
| | | LocMast locMast = locMastList.get(nextInt); |
| | | |
| | | Integer crnNo = commonService.findCrnNoByLocNo(locMast.getLocNo()); |
| | | if (crnNo == null) { |
| | | continue; |
| | | } |
| | | |
| | | Integer targetStationId = commonService.findInStationId(crnNo, stationId); |
| | | if (targetStationId == null) { |
| | | continue; |
| | | } |
| | | |
| | | CreateInTaskParam taskParam = new CreateInTaskParam(); |
| | | taskParam.setTaskNo(String.valueOf(commonService.getWorkNo(WrkIoType.IN.id))); |
| | | taskParam.setSourceStaNo(stationId); |
| | | taskParam.setStaNo(targetStationId); |
| | | taskParam.setLocNo(locMast.getLocNo()); |
| | | taskParam.setBarcode(stationProtocol.getBarcode()); |
| | | boolean result = commonService.createInTask(taskParam); |
| | | |
| | | redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_TASK_LIMIT.key + stationId, "lock", 5); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //生成仿真模拟出库任务 |
| | | private synchronized void generateFakeOutTask() { |
| | | if (!enableFake.equals("Y")) { |
| | | return; |
| | | } |
| | | |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if(stationThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap(); |
| | | |
| | | List<StationObjModel> list = basDevp.getOutStationList$(); |
| | | for (StationObjModel entity : list) { |
| | | Integer stationId = entity.getStationId(); |
| | | if(!stationMap.containsKey(stationId)){ |
| | | continue; |
| | | } |
| | | |
| | | StationProtocol stationProtocol = stationMap.get(stationId); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | Object object = redisUtil.get(RedisKeyType.GENERATE_FAKE_OUT_TASK_LIMIT.key + stationId); |
| | | if(object != null){ |
| | | return; |
| | | } |
| | | |
| | | //满足自动、无物、工作号0,生成出库数据 |
| | | if (stationProtocol.isAutoing() |
| | | && !stationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() == 0 |
| | | ) { |
| | | List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", String.valueOf(LocStsType.F))); |
| | | if (locMastList.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | LocMast locMast = locMastList.get(0); |
| | | |
| | | Integer crnNo = commonService.findCrnNoByLocNo(locMast.getLocNo()); |
| | | if (crnNo == null) { |
| | | continue; |
| | | } |
| | | |
| | | Integer sourceStationId = commonService.findOutStationId(crnNo, stationId); |
| | | if (sourceStationId == null) { |
| | | continue; |
| | | } |
| | | |
| | | CreateOutTaskParam taskParam = new CreateOutTaskParam(); |
| | | taskParam.setTaskNo(String.valueOf(commonService.getWorkNo(WrkIoType.OUT.id))); |
| | | taskParam.setSourceStaNo(sourceStationId); |
| | | taskParam.setStaNo(stationId); |
| | | taskParam.setSourceLocNo(locMast.getLocNo()); |
| | | taskParam.setBarcode(locMast.getBarcode()); |
| | | boolean result = commonService.createOutTask(taskParam); |
| | | redisUtil.set(RedisKeyType.GENERATE_FAKE_OUT_TASK_LIMIT.key + stationId, "lock", 15); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 请求生成入库任务 |
| | | * 入库站,根据条码扫描生成入库工作档 |
| | | */ |
| | | public synchronized void generateStoreWrkFile() { |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if(stationThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap(); |
| | | |
| | | List<StationObjModel> list = basDevp.getInStationList$(); |
| | | for (StationObjModel entity : list) { |
| | | Integer stationId = entity.getStationId(); |
| | | if(!stationMap.containsKey(stationId)){ |
| | | continue; |
| | | } |
| | | |
| | | StationProtocol stationProtocol = stationMap.get(stationId); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | //满足自动、有物、工作号9999,生成入库数据 |
| | | if (stationProtocol.isAutoing() |
| | | && stationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() == 9999 |
| | | ) { |
| | | //检测任务是否生成 |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode())); |
| | | if (!wrkMasts.isEmpty()) { |
| | | continue; |
| | | } |
| | | |
| | | String wmsUrl = null; |
| | | Config wmsSystemUriConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemUri")); |
| | | if (wmsSystemUriConfig != null) { |
| | | wmsUrl = wmsSystemUriConfig.getValue(); |
| | | } |
| | | |
| | | if(wmsUrl == null){ |
| | | News.error("未配置WMS系统URI,配置文件Code编码:wmsSystemUri"); |
| | | return; |
| | | } |
| | | |
| | | String wmsSystemInUrl = null; |
| | | Config wmsSystemInUrlConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "wmsSystemInUrl")); |
| | | if (wmsSystemInUrlConfig != null) { |
| | | wmsSystemInUrl = wmsSystemInUrlConfig.getValue(); |
| | | } |
| | | |
| | | if(wmsSystemInUrlConfig == null){ |
| | | News.error("未配置WMS入库接口地址,配置文件Code编码:wmsSystemInUrl"); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | HashMap<String, Object> param = new HashMap<>(); |
| | | param.put("barcode", stationProtocol.getBarcode()); |
| | | param.put("ioType", 1); |
| | | param.put("sourceStaNo", stationProtocol.getStationId()); |
| | | param.put("locType1", stationProtocol.getPalletHeight()); |
| | | |
| | | String response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath(wmsSystemInUrl) |
| | | .setJson(JSON.toJSONString(param)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | CreateInTaskParam taskParam = new CreateInTaskParam(); |
| | | taskParam.setTaskNo(String.valueOf(dto.getWorkNo())); |
| | | taskParam.setLocNo(dto.getLocNo()); |
| | | taskParam.setTaskPri(dto.getTaskPri()); |
| | | boolean result = commonService.createInTask(taskParam); |
| | | } else { |
| | | News.error("请求WMS接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response); |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //计算所有站点停留时间 |
| | | public synchronized void calcAllStationStayTime() { |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | List<StationProtocol> list = stationThread.getStatus(); |
| | | for (StationProtocol stationProtocol : list) { |
| | | if (stationProtocol.getTaskNo() > 0 && !stationStayTimeMap.containsKey(stationProtocol.getStationId())) { |
| | | stationStayTimeMap.put(stationProtocol.getStationId(), System.currentTimeMillis()); |
| | | } |
| | | |
| | | if(stationProtocol.getTaskNo() <= 0 && stationStayTimeMap.containsKey(stationProtocol.getStationId())) { |
| | | stationStayTimeMap.remove(stationProtocol.getStationId()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //检测出库站点停留是否超时 |
| | | public synchronized void checkOutStationStayTimeOut() { |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | List<StationObjModel> outStationList = basDevp.getOutStationList$(); |
| | | if(outStationList.isEmpty()){ |
| | | News.info("输送线:{} 出库站点未设置", basDevp.getDevpNo()); |
| | | continue; |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | Object lock = redisUtil.get(RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId()); |
| | | if(lock != null){ |
| | | continue; |
| | | } |
| | | |
| | | Long stayTime = stationStayTimeMap.get(stationObjModel.getStationId()); |
| | | if (stayTime == null) { |
| | | continue; |
| | | } |
| | | |
| | | if(System.currentTimeMillis() - stayTime > 1000 * 15) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if(stationThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | StationCommand command = stationThread.getMoveCommand(0, stationObjModel.getStationId(), 0, 0); |
| | | if(command == null){ |
| | | continue; |
| | | } |
| | | |
| | | MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command)); |
| | | redisUtil.set(RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10); |
| | | News.info("输送站点重置命令下发成功,站点号={},命令数据={}", stationObjModel.getStationId(), JSON.toJSONString(command)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //检测入库站点堆垛机是否取走货物 |
| | | public synchronized void checkInStationCrnTake() { |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | List<StationObjModel> inStationList = basCrnp.getInStationList$(); |
| | | if(inStationList.isEmpty()){ |
| | | News.info("堆垛机:{} 入库站点未设置", basCrnp.getCrnNo()); |
| | | continue; |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : inStationList) { |
| | | Object lock = redisUtil.get(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId()); |
| | | if(lock != null){ |
| | | continue; |
| | | } |
| | | |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if(stationThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | StationCommand command = stationThread.getMoveCommand(0, stationObjModel.getStationId(), 0, 0); |
| | | if(command == null){ |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = statusMap.get(stationObjModel.getStationId()); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if(stationProtocol.getTaskNo() > 0) { |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command)); |
| | | redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10); |
| | | News.info("输送站点重置命令下发成功,站点号={},命令数据={}", stationObjModel.getStationId(), JSON.toJSONString(command)); |
| | | }else { |
| | | if (wrkMast.getWrkSts() != WrkStsType.NEW_INBOUND.sts && wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) { |
| | | Integer crnNo = wrkMast.getCrnNo(); |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crnNo); |
| | | if (crnThread == null) { |
| | | continue; |
| | | } |
| | | CrnProtocol crnProtocol = crnThread.getStatus(); |
| | | if (crnProtocol.getStatusType().equals(CrnStatusType.FETCH_MOVING) || crnProtocol.getStatusType().equals(CrnStatusType.FETCHING)) { |
| | | continue; |
| | | } |
| | | |
| | | MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command)); |
| | | redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10); |
| | | News.info("输送站点重置命令下发成功,站点号={},命令数据={}", stationObjModel.getStationId(), JSON.toJSONString(command)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //堆垛机任务执行完成 |
| | | public synchronized void crnIoExecuteFinish() { |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo()); |
| | | if(crnThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | CrnProtocol crnProtocol = crnThread.getStatus(); |
| | | if(crnProtocol == null){ |
| | | continue; |
| | | } |
| | | |
| | | if (crnProtocol.getMode() == CrnModeType.AUTO.id |
| | | && crnProtocol.getTaskNo() > 0 |
| | | && crnProtocol.getStatus() == CrnStatusType.WAITING.id |
| | | ) { |
| | | |
| | | // 获取待确认工作档 |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(crnProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | News.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | |
| | | Long updateWrkSts = null; |
| | | if(wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts){ |
| | | updateWrkSts = WrkStsType.COMPLETE_INBOUND.sts; |
| | | }else if(wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts){ |
| | | updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts; |
| | | |
| | | //生成仿真站点数据 |
| | | List<StationObjModel> outStationList = basCrnp.getOutStationList$(); |
| | | if(outStationList.isEmpty()){ |
| | | News.info("堆垛机:{} 出库站点未设置", basCrnp.getCrnNo()); |
| | | continue; |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) { |
| | | continue; |
| | | } |
| | | |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | //生成仿真站点数据 |
| | | StationCommand command = stationThread.getMoveCommand(9998, wrkMast.getSourceStaNo(), 0, 0); |
| | | MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command)); |
| | | } |
| | | }else{ |
| | | News.error("堆垛机处于等待确认且任务完成状态,但工作状态异常。堆垛机号={},工作号={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | |
| | | wrkMast.setWrkSts(updateWrkSts); |
| | | wrkMast.setSystemMsg(""); |
| | | wrkMast.setIoTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | CrnCommand resetCommand = crnThread.getResetCommand(crnProtocol.getCrnNo()); |
| | | MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, resetCommand)); |
| | | News.info("堆垛机任务状态更新成功,堆垛机号={},工作号={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.core.plugin; |
| | | |
| | | public interface MainProcessPluginApi { |
| | | |
| | | void run(); |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.core.plugin; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.zy.asrs.service.BasMapService; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.List; |
| | | |
| | | @Slf4j |
| | | @Component |
| | | public class NormalProcess implements MainProcessPluginApi{ |
| | | |
| | | @Autowired |
| | | private BasMapService basMapService; |
| | | |
| | | @Override |
| | | public void run() { |
| | | getLevList(); |
| | | } |
| | | |
| | | private void getLevList() { |
| | | List<Integer> list = basMapService.getLevList(); |
| | | System.out.println(JSON.toJSONString(list)); |
| | | } |
| | | |
| | | } |
| | |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | public interface StationThread extends ThreadHandler { |
| | | |
| | | List<StationProtocol> getStatus(); |
| | | |
| | | Map<Integer, StationProtocol> getStatusMap(); |
| | | |
| | | StationCommand getMoveCommand(Integer taskNo, Integer stationId, Integer targetStationId, Integer palletSize); |
| | | |
| | | CommandResponse sendCommand(StationCommand command); |
| | |
| | | basCrnp = new BasCrnp(); |
| | | basCrnp.setCrnNo(deviceConfig.getDeviceNo()); |
| | | basCrnp.setStatus(1); |
| | | basCrnp.setInEnable("N"); |
| | | basCrnp.setOutEnable("N"); |
| | | basCrnp.setCreateTime(new Date()); |
| | | basCrnpService.insert(basCrnp); |
| | | } |
| | |
| | | import com.zy.core.network.entity.ZyStationStatusEntity; |
| | | |
| | | import java.text.MessageFormat; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | |
| | | return commandResponse; |
| | | } |
| | | |
| | | @Override |
| | | public Map<Integer, StationProtocol> getStatusMap() { |
| | | Map<Integer, StationProtocol> map = new HashMap<>(); |
| | | for (StationProtocol stationProtocol : statusList) { |
| | | map.put(stationProtocol.getStationId(), stationProtocol); |
| | | } |
| | | return map; |
| | | } |
| | | } |
| New file |
| | |
| | | package com.zy.core.utils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.LocMast; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.LocMastService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.CrnModeType; |
| | | import com.zy.core.enums.CrnStatusType; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.WrkStsType; |
| | | import com.zy.core.model.StationObjModel; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.CrnCommand; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.model.protocol.CrnProtocol; |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import com.zy.core.thread.CrnThread; |
| | | import com.zy.core.thread.StationThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | public class CrnOperateProcessUtils { |
| | | |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | |
| | | //入出库 ===>> 堆垛机入出库作业下发 |
| | | public synchronized void crnIoExecute() { |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo()); |
| | | if(crnThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | CrnProtocol crnProtocol = crnThread.getStatus(); |
| | | if(crnProtocol == null){ |
| | | continue; |
| | | } |
| | | |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .eq("crn_no", basCrnp.getCrnNo()) |
| | | .in("wrk_sts", WrkStsType.INBOUND_RUN.sts, WrkStsType.OUTBOUND_RUN.sts) |
| | | ); |
| | | if(!wrkMasts.isEmpty()){ |
| | | continue; |
| | | } |
| | | |
| | | // 只有当堆垛机空闲 并且 无任务时才继续执行 |
| | | if (crnProtocol.getMode() == CrnModeType.AUTO.id |
| | | && crnProtocol.getTaskNo() == 0 |
| | | && crnProtocol.getStatus() == CrnStatusType.IDLE.id |
| | | && crnProtocol.getLoaded() == 0 |
| | | && crnProtocol.getForkPos() == 0 |
| | | && crnProtocol.getAlarm() == 0 |
| | | ) { |
| | | // 如果最近一次是入库模式 |
| | | if (crnProtocol.getLastIo().equals("I")) { |
| | | if (basCrnp.getInEnable().equals("Y")) { |
| | | this.crnExecuteIn(basCrnp, crnThread); // 入库 |
| | | crnProtocol.setLastIo("O"); |
| | | } else if (basCrnp.getOutEnable().equals("Y")) { |
| | | this.crnExecuteOut(basCrnp, crnThread); // 出库 |
| | | crnProtocol.setLastIo("I"); |
| | | } |
| | | } |
| | | // 如果最近一次是出库模式 |
| | | else if (crnProtocol.getLastIo().equals("O")) { |
| | | if (basCrnp.getOutEnable().equals("Y")) { |
| | | this.crnExecuteOut(basCrnp, crnThread); // 出库 |
| | | crnProtocol.setLastIo("I"); |
| | | } else if (basCrnp.getInEnable().equals("Y")) { |
| | | this.crnExecuteIn(basCrnp, crnThread); // 入库 |
| | | crnProtocol.setLastIo("O"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private synchronized void crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) { |
| | | CrnProtocol crnProtocol = crnThread.getStatus(); |
| | | if(crnProtocol == null){ |
| | | return; |
| | | } |
| | | |
| | | if(!basCrnp.getInEnable().equals("Y")){ |
| | | News.info("堆垛机:{} 可入信号不满足", basCrnp.getCrnNo()); |
| | | return; |
| | | } |
| | | |
| | | List<StationObjModel> inStationList = basCrnp.getInStationList$(); |
| | | if(inStationList.isEmpty()){ |
| | | News.info("堆垛机:{} 入库站点未设置", basCrnp.getCrnNo()); |
| | | return; |
| | | } |
| | | |
| | | Integer crnNo = basCrnp.getCrnNo(); |
| | | |
| | | for (StationObjModel stationObjModel : inStationList) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationProtocolMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = stationProtocolMap.get(stationObjModel.getStationId()); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isAutoing()) { |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isLoading()) { |
| | | continue; |
| | | } |
| | | |
| | | if (stationProtocol.getTaskNo() <= 0) { |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isInEnable()) { |
| | | News.taskInfo(stationProtocol.getTaskNo(), "取货站点:{} 没有可入信号", stationObjModel.getStationId()); |
| | | continue; |
| | | } |
| | | |
| | | // 获取任务 |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo()); |
| | | if (null == wrkMast) { |
| | | News.taskInfo(stationProtocol.getTaskNo(), "工作号:{} 任务信息不存在", stationProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | |
| | | if(wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts){ |
| | | News.taskInfo(stationProtocol.getTaskNo(), "工作号:{} 任务状态异常", stationProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | |
| | | // 获取库位信息 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getLocNo()); |
| | | if (locMast == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "目标库位:{} 信息不存在", wrkMast.getLocNo()); |
| | | continue; |
| | | } |
| | | |
| | | if (!locMast.getLocSts().equals("S")) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "目标库位:{} 状态异常", wrkMast.getLocNo()); |
| | | continue; |
| | | } |
| | | |
| | | String sourceLocNo = Utils.getLocNo(stationObjModel.getDeviceRow(), stationObjModel.getDeviceBay(), stationObjModel.getDeviceLev()); |
| | | |
| | | CrnCommand command = crnThread.getPickAndPutCommand(sourceLocNo, wrkMast.getLocNo(), wrkMast.getWrkNo(), crnNo); |
| | | |
| | | wrkMast.setWrkSts(WrkStsType.INBOUND_RUN.sts); |
| | | wrkMast.setCrnNo(crnNo); |
| | | wrkMast.setSystemMsg(""); |
| | | wrkMast.setIoTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command)); |
| | | News.info("堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(command)); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private synchronized void crnExecuteOut(BasCrnp basCrnp, CrnThread crnThread) { |
| | | CrnProtocol crnProtocol = crnThread.getStatus(); |
| | | if(crnProtocol == null){ |
| | | return; |
| | | } |
| | | |
| | | if(!basCrnp.getOutEnable().equals("Y")){ |
| | | News.info("堆垛机:{} 可出信号不满足", basCrnp.getCrnNo()); |
| | | return; |
| | | } |
| | | |
| | | List<StationObjModel> outStationList = basCrnp.getOutStationList$(); |
| | | if(outStationList.isEmpty()){ |
| | | News.info("堆垛机:{} 出库站点未设置", basCrnp.getCrnNo()); |
| | | return; |
| | | } |
| | | |
| | | Integer crnNo = basCrnp.getCrnNo(); |
| | | |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>() |
| | | .eq("crn_no", crnNo) |
| | | .eq("wrk_sts", WrkStsType.NEW_OUTBOUND.sts) |
| | | ); |
| | | |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationProtocolMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = stationProtocolMap.get(stationObjModel.getStationId()); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isAutoing()) { |
| | | continue; |
| | | } |
| | | |
| | | if (stationProtocol.isLoading()) { |
| | | continue; |
| | | } |
| | | |
| | | if (stationProtocol.getTaskNo() != 0) { |
| | | continue; |
| | | } |
| | | |
| | | if (!stationProtocol.isOutEnable()) { |
| | | News.info("放货站点:{} 没有可出信号", stationObjModel.getStationId()); |
| | | continue; |
| | | } |
| | | |
| | | // 获取库位信息 |
| | | LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo()); |
| | | if (locMast == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "源库位:{} 信息不存在", wrkMast.getSourceLocNo()); |
| | | continue; |
| | | } |
| | | |
| | | if (!locMast.getLocSts().equals("R")) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "源库位:{} 状态异常", wrkMast.getSourceLocNo()); |
| | | continue; |
| | | } |
| | | |
| | | String targetLocNo = Utils.getLocNo(stationObjModel.getDeviceRow(), stationObjModel.getDeviceBay(), stationObjModel.getDeviceLev()); |
| | | |
| | | CrnCommand command = crnThread.getPickAndPutCommand(wrkMast.getSourceLocNo(), targetLocNo, wrkMast.getWrkNo(), crnNo); |
| | | |
| | | wrkMast.setWrkSts(WrkStsType.OUTBOUND_RUN.sts); |
| | | wrkMast.setCrnNo(crnNo); |
| | | wrkMast.setSystemMsg(""); |
| | | wrkMast.setIoTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command)); |
| | | News.info("堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(command)); |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //堆垛机任务执行完成 |
| | | public synchronized void crnIoExecuteFinish() { |
| | | List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>()); |
| | | for (BasCrnp basCrnp : basCrnps) { |
| | | CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo()); |
| | | if(crnThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | CrnProtocol crnProtocol = crnThread.getStatus(); |
| | | if(crnProtocol == null){ |
| | | continue; |
| | | } |
| | | |
| | | if (crnProtocol.getMode() == CrnModeType.AUTO.id |
| | | && crnProtocol.getTaskNo() > 0 |
| | | && crnProtocol.getStatus() == CrnStatusType.WAITING.id |
| | | ) { |
| | | |
| | | // 获取待确认工作档 |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(crnProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | News.error("堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | |
| | | Long updateWrkSts = null; |
| | | if(wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts){ |
| | | updateWrkSts = WrkStsType.COMPLETE_INBOUND.sts; |
| | | }else if(wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts){ |
| | | updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts; |
| | | }else{ |
| | | News.error("堆垛机处于等待确认且任务完成状态,但工作状态异常。堆垛机号={},工作号={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo()); |
| | | continue; |
| | | } |
| | | |
| | | wrkMast.setWrkSts(updateWrkSts); |
| | | wrkMast.setSystemMsg(""); |
| | | wrkMast.setIoTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | CrnCommand resetCommand = crnThread.getResetCommand(crnProtocol.getCrnNo()); |
| | | MessageQueue.offer(SlaveType.Crn, crnProtocol.getCrnNo(), new Task(2, resetCommand)); |
| | | News.info("堆垛机任务状态更新成功,堆垛机号={},工作号={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | package com.zy.core.utils; |
| | | |
| | | import com.alibaba.fastjson.JSON; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.common.service.CommonService; |
| | | import com.zy.core.News; |
| | | import com.zy.core.cache.MessageQueue; |
| | | import com.zy.core.cache.SlaveConnection; |
| | | import com.zy.core.enums.SlaveType; |
| | | import com.zy.core.enums.WrkStsType; |
| | | import com.zy.core.model.StationObjModel; |
| | | import com.zy.core.model.Task; |
| | | import com.zy.core.model.command.StationCommand; |
| | | import com.zy.core.model.protocol.StationProtocol; |
| | | import com.zy.core.thread.StationThread; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | @Component |
| | | public class StationOperateProcessUtils { |
| | | |
| | | @Autowired |
| | | private BasDevpService basDevpService; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private CommonService commonService; |
| | | @Autowired |
| | | private BasCrnpService basCrnpService; |
| | | |
| | | //执行输送站点入库任务 |
| | | public synchronized void stationInExecute() { |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if(stationThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap(); |
| | | |
| | | List<StationObjModel> list = basDevp.getInStationList$(); |
| | | for (StationObjModel entity : list) { |
| | | Integer stationId = entity.getStationId(); |
| | | if(!stationMap.containsKey(stationId)){ |
| | | continue; |
| | | } |
| | | |
| | | StationProtocol stationProtocol = stationMap.get(stationId); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | //满足自动、有物、工作号9999 |
| | | if (stationProtocol.isAutoing() |
| | | && stationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() == 9999 |
| | | ) { |
| | | //检测任务是否生成 |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode())); |
| | | if (wrkMast == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (wrkMast.getWrkSts() == WrkStsType.INBOUND_DEVICE_RUN.sts) { |
| | | continue; |
| | | } |
| | | |
| | | String locNo = wrkMast.getLocNo(); |
| | | Integer crnNo = commonService.findCrnNoByLocNo(locNo); |
| | | if (crnNo == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "未匹配到堆垛机"); |
| | | continue; |
| | | } |
| | | |
| | | Integer targetStationId = commonService.findInStationId(crnNo, stationId); |
| | | if (targetStationId == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "搜索入库站点失败"); |
| | | continue; |
| | | } |
| | | |
| | | StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationId, targetStationId, 0); |
| | | if(command == null){ |
| | | News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败"); |
| | | continue; |
| | | } |
| | | |
| | | wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts); |
| | | wrkMast.setSourceStaNo(stationProtocol.getStationId()); |
| | | wrkMast.setStaNo(targetStationId); |
| | | wrkMast.setSystemMsg(""); |
| | | wrkMast.setIoTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command)); |
| | | News.info("输送站点入库命令下发成功,站点号={},工作号={},命令数据={}", stationId, wrkMast.getWrkNo(), JSON.toJSONString(command)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //执行输送站点出库任务 |
| | | public synchronized void stationOutExecute() { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | BasCrnp basCrnp = basCrnpService.selectOne(new EntityWrapper<BasCrnp>().eq("crn_no", wrkMast.getCrnNo())); |
| | | if (basCrnp == null) { |
| | | continue; |
| | | } |
| | | |
| | | List<StationObjModel> outStationList = basCrnp.getOutStationList$(); |
| | | if(outStationList.isEmpty()){ |
| | | News.info("堆垛机:{} 出库站点未设置", basCrnp.getCrnNo()); |
| | | continue; |
| | | } |
| | | |
| | | for (StationObjModel stationObjModel : outStationList) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo()); |
| | | if(stationThread == null){ |
| | | continue; |
| | | } |
| | | |
| | | Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap(); |
| | | StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId()); |
| | | if (stationProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | //满足自动、有物、工作号0 |
| | | if (stationProtocol.isAutoing() |
| | | && stationProtocol.isLoading() |
| | | && stationProtocol.getTaskNo() == 0 |
| | | ) { |
| | | StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0); |
| | | if(command == null){ |
| | | News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败"); |
| | | continue; |
| | | } |
| | | |
| | | wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts); |
| | | wrkMast.setSystemMsg(""); |
| | | wrkMast.setIoTime(new Date()); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command)); |
| | | News.info("输送站点出库命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command)); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | //检测输送站点出库任务执行完成 |
| | | public synchronized void stationOutExecuteFinish() { |
| | | List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts)); |
| | | for (WrkMast wrkMast : wrkMasts) { |
| | | Integer wrkNo = wrkMast.getWrkNo(); |
| | | |
| | | boolean complete = true; |
| | | List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>()); |
| | | for (BasDevp basDevp : basDevps) { |
| | | StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo()); |
| | | if (stationThread == null) { |
| | | continue; |
| | | } |
| | | |
| | | List<StationProtocol> list = stationThread.getStatus(); |
| | | for (StationProtocol stationProtocol : list) { |
| | | if (stationProtocol.getTaskNo().equals(wrkNo)) { |
| | | complete = false; |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (complete) { |
| | | wrkMast.setWrkSts(WrkStsType.COMPLETE_OUTBOUND.sts); |
| | | wrkMast.setIoTime(new Date()); |
| | | wrkMastService.updateById(wrkMast); |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | |
| | | deviceExecuteConfig: |
| | | # 每个线程管控设备执行数量 |
| | | threadControlCount: 10 |
| | | liftType: lift |
| | | liftType: lift |
| | | |
| | | mainProcessPlugin: FakeProcess |
| | |
| | | <result column="update_by" property="updateBy" /> |
| | | <result column="update_time" property="updateTime" /> |
| | | <result column="memo" property="memo" /> |
| | | <result column="control_rows" property="controlRows" /> |
| | | <result column="in_station_list" property="inStationList" /> |
| | | <result column="out_station_list" property="outStationList" /> |
| | | |
| | | </resultMap> |
| | | |
| | |
| | | <result column="error_memo" property="errorMemo" /> |
| | | <result column="qr_code_value" property="qrCodeValue" /> |
| | | <result column="status" property="status" /> |
| | | <result column="barcode" property="barcode" /> |
| | | |
| | | </resultMap> |
| | | |
| | |
| | | <result column="error_memo" property="errorMemo" /> |
| | | <result column="memo" property="memo" /> |
| | | <result column="barcode" property="barcode" /> |
| | | <result column="shuttle_no" property="shuttleNo" /> |
| | | <result column="lift_no" property="liftNo" /> |
| | | <result column="crn_no" property="crnNo" /> |
| | | <result column="rgv_no" property="rgvNo" /> |
| | | <result column="wms_wrk_no" property="wmsWrkNo" /> |
| | | <result column="system_msg" property="systemMsg" /> |
| | | |
| | | </resultMap> |
| | | |
| | | <select id="selectPakInStep1" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast where source_sta_no=#{sourceStaNo} and wrk_sts=2 and barcode=#{barcode} and (io_type=1 or io_type=10) order by io_pri desc,io_time,wrk_no ASC limit 0,1 |
| | | </select> |
| | | |
| | | <select id="selectPakInStep11" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast where source_sta_no=#{sourceStaNo} and wrk_sts=1 and (io_type=1 or io_type=10) order by io_pri desc,io_time,wrk_no ASC limit 0,1 |
| | | </select> |
| | | |
| | | <select id="selectInStep4" resultMap="BaseResultMap"> |
| | | select * |
| | | from asr_wrk_mast |
| | | where 1=1 |
| | | and wrk_sts = 4 |
| | | and io_type in (1,10,53,57) |
| | | order by io_pri desc,wrk_sts desc |
| | | </select> |
| | | |
| | | <select id="selectByWorkNo" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where wrk_no=#{workNo} |
| | | limit 0,1 |
| | | </select> |
| | | |
| | | <select id="selectLiftStep223103" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where 1=1 |
| | | and wrk_sts in (2,103,303) |
| | | order by io_pri desc,wrk_sts desc |
| | | </select> |
| | | |
| | | <select id="selectByWorkNo324104" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where wrk_no=#{workNo} |
| | | and wrk_sts in (3,104,303,306) |
| | | limit 0,1 |
| | | </select> |
| | | |
| | | <select id="selectBy2125" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where wrk_sts in (101,105) |
| | | and io_type in (101,103,107,110) |
| | | order by io_pri desc,wrk_sts desc |
| | | </select> |
| | | |
| | | <select id="selectShuttleWrkByLev" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where shuttle_no is not null |
| | | and ((wrk_sts not in (9,10) and loc_no like #{lev}) or (wrk_sts not in (29,30) and source_loc_no like #{lev})) |
| | | order by io_pri desc,wrk_sts desc |
| | | </select> |
| | | |
| | | <select id="selectShuttleOutWrkByLev" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where shuttle_no is not null |
| | | and (wrk_sts not in (109,110) and source_loc_no like #{lev}) |
| | | order by io_pri desc,wrk_sts desc |
| | | </select> |
| | | |
| | | <select id="selectLiftWrkMast" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where lift_no = #{liftNo} |
| | | </select> |
| | | |
| | | <select id="selectLocToLocWrkMast" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where io_type in (11) |
| | | and wrk_sts not in (9,10,109,110) |
| | | order by io_pri desc,wrk_sts desc |
| | | </select> |
| | | |
| | | <select id="selectPickStepByBarcode" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where io_type in (53,103,107) |
| | | and wrk_sts in (2,3,104,109) |
| | | and barcode = #{barcode} |
| | | order by io_pri desc,wrk_sts desc |
| | | limit 0,1 |
| | | </select> |
| | | |
| | | <select id="selectShuttleHasMoveWorking" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where 1=1 |
| | | and shuttle_no = #{shuttleNo} |
| | | and wrk_sts not in (311) |
| | | and io_type = 200 |
| | | order by io_pri desc,io_time,wrk_no asc |
| | | limit 0,1 |
| | | </select> |
| | | |
| | | <select id="selectShuttleMoveWrk" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where 1=1 |
| | | and wrk_sts in (301,302,303,304,305,306,307,308,309,310,311) |
| | | and io_type = 200 |
| | | order by io_pri desc,io_time,wrk_no asc |
| | | </select> |
| | | |
| | | <select id="selectShuttleWorking" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where 1=1 |
| | | and shuttle_no = #{shuttleNo} |
| | | and wrk_sts not in (9,10,109,110,210) |
| | | and io_type not in (200,300) |
| | | order by io_pri desc,io_time,wrk_no asc |
| | | limit 0,1 |
| | | </select> |
| | | |
| | | <select id="selectByBarcode" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where 1=1 |
| | | and barcode = #{barcode} |
| | | order by io_pri desc,io_time,wrk_no asc |
| | | limit 0,1 |
| | | </select> |
| | | |
| | | <select id="selectInWrkMastByLiftNo" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where 1=1 |
| | | and lift_no = #{liftNo} |
| | | and io_type <= 100 |
| | | and wrk_sts in (1,2,3,4,5) |
| | | order by io_pri desc,io_time,wrk_no asc |
| | | </select> |
| | | |
| | | <select id="selectChargeWorking" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where io_type in (300) |
| | | and shuttle_no = #{shuttleNo} |
| | | order by io_pri desc,io_time,wrk_no asc |
| | | </select> |
| | | |
| | | <select id="selectChargeWorkingByChargeSta" resultMap="BaseResultMap"> |
| | | select * from asr_wrk_mast |
| | | where wrk_sts in (201,202,203,204,205,210) |
| | | and mk = #{chargeSta} |
| | | order by io_pri desc,io_time,wrk_no asc |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | rgvList: [], |
| | | activeNames: "", |
| | | searchRgvNo: "", |
| | | showControl: true, |
| | | showControl: false, |
| | | controlParam: { |
| | | rgvNo: "", |
| | | sourcePos: "", |
| | |
| | | {type: 'checkbox'} |
| | | ,{field: 'crnNo', align: 'center',title: '编号'} |
| | | ,{field: 'status$', align: 'center',title: '状态'} |
| | | ,{field: 'wrkNo', align: 'center',title: '工作号'} |
| | | // ,{field: 'wrkNo', align: 'center',title: '工作号'} |
| | | ,{field: 'inEnable', align: 'center',title: '可入(checkBox)'} |
| | | ,{field: 'outEnable', align: 'center',title: '可出(checkBox)'} |
| | | ,{field: 'createBy', align: 'center',title: '创建人员'} |
| | | ,{field: 'createTime$', align: 'center',title: '创建时间'} |
| | | ,{field: 'updateBy', align: 'center',title: '修改人员'} |
| | | ,{field: 'updateTime$', align: 'center',title: '修改时间'} |
| | | ,{field: 'controlRows', align: 'center',title: '控制库位排号'} |
| | | ,{field: 'inStationList', align: 'center',title: '入库站列表'} |
| | | ,{field: 'outStationList', align: 'center',title: '出库站列表'} |
| | | // ,{field: 'createBy', align: 'center',title: '创建人员'} |
| | | // ,{field: 'createTime$', align: 'center',title: '创建时间'} |
| | | // ,{field: 'updateBy', align: 'center',title: '修改人员'} |
| | | // ,{field: 'updateTime$', align: 'center',title: '修改时间'} |
| | | ,{field: 'memo', align: 'center',title: '备注'} |
| | | |
| | | ,{fixed: 'right', title:'操作', align: 'center', toolbar: '#operate', width:120} |
| | |
| | | {type: 'checkbox', fixed: 'left'} |
| | | ,{field: 'locNo', align: 'center',title: '库位号',sort:true} |
| | | ,{field: 'locSts$', align: 'center',title: '库位状态',width:200} |
| | | ,{field: 'qrCodeValue', align: 'center',title: '二维码值', sort:true} |
| | | ,{field: 'barcode', align: 'center',title: '托盘码'} |
| | | ,{field: 'row1', align: 'center',title: '排', sort:true} |
| | | ,{field: 'bay1', align: 'center',title: '列', sort:true} |
| | | ,{field: 'lev1', align: 'center',title: '层', sort:true} |
| | |
| | | </select> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">工作号: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="wrkNo" placeholder="请输入工作号"> |
| | | </div> |
| | | </div> |
| | | <!-- <div class="layui-form-item">--> |
| | | <!-- <label class="layui-form-label">工作号: </label>--> |
| | | <!-- <div class="layui-input-block">--> |
| | | <!-- <input class="layui-input" name="wrkNo" placeholder="请输入工作号">--> |
| | | <!-- </div>--> |
| | | <!-- </div>--> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">可入(checkBox): </label> |
| | | <div class="layui-input-block"> |
| | |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">控制库位排号: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="controlRows" placeholder="请输入控制库位排号"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">入库站列表: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="inStationList" placeholder="请输入入库站列表"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">出库站列表: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="outStationList" placeholder="请输入出库站列表"> |
| | | </div> |
| | | </div> |
| | | <div class="layui-form-item"> |
| | | <label class="layui-form-label">备注: </label> |
| | | <div class="layui-input-block"> |
| | | <input class="layui-input" name="memo" placeholder="请输入备注"> |
| | |
| | | </el-table-column> |
| | | <el-table-column property="barcode" label="托盘码"> |
| | | </el-table-column> |
| | | <el-table-column property="liftNo" label="提升机"> |
| | | </el-table-column> |
| | | <el-table-column property="shuttleNo" label="穿梭车"> |
| | | <el-table-column property="crnNo" label="堆垛机"> |
| | | </el-table-column> |
| | | <el-table-column property="systemMsg" label="系统消息"> |
| | | </el-table-column> |
| | |
| | | <!-- <el-dropdown-item command="change">修改</el-dropdown-item>--> |
| | | <el-dropdown-item command="complete">完成</el-dropdown-item> |
| | | <el-dropdown-item command="cancel">取消</el-dropdown-item> |
| | | <el-dropdown-item command="shuttleCommand">穿梭车指令</el-dropdown-item> |
| | | <!-- <el-dropdown-item command="shuttleCommand">穿梭车指令</el-dropdown-item>--> |
| | | </el-dropdown-menu> |
| | | </el-dropdown> |
| | | </template> |