diff --git a/shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java b/shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java index 7b5130f..8b5b60e 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java +++ b/shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java @@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.injector.methods.UpdateById; import com.baomidou.mybatisplus.extension.api.R; import com.shkj.common.constant.RedisConstant; import com.shkj.common.core.domain.Result; @@ -44,6 +45,7 @@ import org.springframework.data.redis.core.RedisTemplate; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; +import org.unbescape.css.CssIdentifierEscapeLevel; import javax.annotation.Resource; import java.math.BigDecimal; @@ -1579,6 +1581,10 @@ public class ScheduledTasks { } } + else if (taskType.equals(TaskTypeEnum.seat_adjustment.getValue())){ + BusinDataTask businDataTask = iBusinDataTaskService.getById(businDataTaskVo.getId()); + moveTask(businDataTask); + } log.info("任务号" + businDataTaskVo.getId() + "任务状态" + businDataTaskVo.getTaskStatus() + "点位信息" + businDataTaskVo.getPoints()); //统一提交任务数据 iBusinDataTaskService.saveOrUpdate(BeanUtil.toBean(businDataTaskVo, BusinDataTask.class)); @@ -1606,7 +1612,11 @@ public class ScheduledTasks { return Result.err(); } - // 出库任务 + /** + * 给堆垛机下发出库任务 + * @param businDataTask + * @return + */ public Result outTask(BusinDataTask businDataTask) { //查看输送线是否拥堵 Result booleanResult = this.PLCout(businDataTask); @@ -1704,6 +1714,104 @@ public class ScheduledTasks { } } + /** + * 巷道内移库任务,给堆垛机下发指令 + * @param businDataTask + * @return + */ + public Result moveTask(BusinDataTask businDataTask) { + + List propertyList = iWcsPlcPropertyService.getWcsPlcPropertyByPlcId(businDataTask.getPlcId()); + + WcsPlcConnect plcConnect = iWcsPlcConnectService.getById(businDataTask.getPlcId()); + PlcOperate stkOperate = plcInit.getPlcOperateByIp(plcConnect.getPlcIp()); + //堆垛机是否空闲 + String readNullPoint=""; + String plcTaskId =""; + String plcToRow =""; + String plcToColumn =""; + String plcToLayer =""; + String plcFromRow =""; + String plcFromColumn =""; + String plcFromLayer =""; + //堆垛机工作状态 + String overonaddress=""; + String plcml=""; + for (WcsPlcProperty stkProperty : propertyList) { + //获取要堆垛机要写入的点位 + if (stkProperty.getPointType().equals("101")) { + plcTaskId = stkProperty.getAddress(); + }else if (stkProperty.getPointType().equals("108")){ + plcToRow = stkProperty.getAddress(); + }else if (stkProperty.getPointType().equals("109")){ + plcToColumn =stkProperty.getAddress(); + }else if (stkProperty.getPointType().equals("110")){ + plcToLayer=stkProperty.getAddress(); + }else if (stkProperty.getPointType().equals("104")){ + plcFromRow=stkProperty.getAddress(); + }else if(stkProperty.getPointType().equals("105")){ + plcFromColumn=stkProperty.getAddress(); + }else if(stkProperty.getPointType().equals("106")){ + plcFromLayer=stkProperty.getAddress(); + }else if(stkProperty.getPointType().equals("102")){ + plcml=stkProperty.getAddress(); + }else if (stkProperty.getPointType().equals("12")){ + readNullPoint=stkProperty.getAddress(); + }else if(stkProperty.getPointType().equals("4")){ + overonaddress= stkProperty.getAddress(); + } + } + + //根据连接的plcId获取属性 + PLCReadAndWrite plcReadAndWriteD = new PLCReadAndWrite(); + Map pointDMap = plcReadAndWriteD.readPlcData(stkOperate, plcConnect.getPointTables()); + if (pointDMap.containsKey(readNullPoint)&&Boolean.valueOf(pointDMap.get(readNullPoint).toString())&&pointDMap.get(overonaddress).equals("0")) { + //给堆垛机写命令 + Map allMap = new HashMap<>(1); + Map plcTaskIdMap = new HashMap<>(1); + plcTaskIdMap.put("INTEGER", businDataTask.getId()); + allMap.put(plcTaskId, plcTaskIdMap); + Map plcFromRowMap = new HashMap<>(1); + plcFromRowMap.put("SHORT", businDataTask.getFromRow()); + allMap.put(plcFromRow, plcFromRowMap); + Map plcFromColumnMap = new HashMap<>(1); + plcFromColumnMap.put("SHORT", businDataTask.getFromColumn()); + allMap.put(plcFromColumn, plcFromColumnMap); + Map plcFromLayerMap = new HashMap<>(1); + plcFromLayerMap.put("SHORT", businDataTask.getFromLayer()); + allMap.put(plcFromLayer, plcFromLayerMap); + Map plcToRowMap = new HashMap<>(1); + plcToRowMap.put("SHORT", businDataTask.getToRow()); + allMap.put(plcToRow, plcToRowMap); + Map plcToColumnMap = new HashMap<>(1); + plcToColumnMap.put("SHORT", businDataTask.getToColumn()); + allMap.put(plcToColumn, plcToColumnMap); + Map plcToLayerMap = new HashMap<>(1); + plcToLayerMap.put("SHORT", businDataTask.getToLayer()); + allMap.put(plcToLayer, plcToLayerMap); + Map plcMLMap = new HashMap<>(1); + plcMLMap.put("Short", 4); + allMap.put(plcml, plcMLMap); + + PLCReadAndWrite plcReadAndWrite = new PLCReadAndWrite(); + if (plcReadAndWrite.execWrite(stkOperate, JsonUtil.toJSONString(allMap))) { + log.info("巷道内移库任务给堆垛机下发成功!"+businDataTask.getId()); + businDataTask.setTaskStatus(TaskStatusEnum.wait_callback.getValue()); + iBusinDataTaskService.updateById(businDataTask); + return Result.ok(); + }else { + businDataTask.setTaskStatus(TaskStatusEnum.err.getValue()); + businDataTask.setExceptionMsg("下发堆垛机命令失败"); + businDataTask.setUpdateTime(DateUtils.getNowDate()); + iBusinDataTaskService.updateById(businDataTask); + log.info("巷道内移库任务给堆垛机下发失败!"+businDataTask.getId()); + return Result.err().msg("巷道内移库任务给堆垛机下发失败"); + } + } + return Result.ok(); + } + + //检查当前物料号是否有出库任务(正常出库,紧急出库) public BusinDataTaskOutVo checkOutTaskData(String goods) { diff --git a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java index 106d49c..174c111 100644 --- a/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java +++ b/shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.java @@ -1964,6 +1964,13 @@ public class BusinDataTaskServiceImpl extends ServiceImpl