巷道内移库给堆垛机下发任务

main
judy 1 year ago
parent f112deebbf
commit 180487501e
  1. 110
      shkj-wms/src/main/java/com/shkj/wms/scheduled/ScheduledTasks.java
  2. 20
      shkj-wms/src/main/java/com/shkj/wms/service/impl/BusinDataTaskServiceImpl.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<Boolean> outTask(BusinDataTask businDataTask) {
//查看输送线是否拥堵
Result<Boolean> booleanResult = this.PLCout(businDataTask);
@ -1704,6 +1714,104 @@ public class ScheduledTasks {
}
}
/**
* 巷道内移库任务给堆垛机下发指令
* @param businDataTask
* @return
*/
public Result<Boolean> moveTask(BusinDataTask businDataTask) {
List<WcsPlcProperty> 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<String, Object> pointDMap = plcReadAndWriteD.readPlcData(stkOperate, plcConnect.getPointTables());
if (pointDMap.containsKey(readNullPoint)&&Boolean.valueOf(pointDMap.get(readNullPoint).toString())&&pointDMap.get(overonaddress).equals("0")) {
//给堆垛机写命令
Map<String, Object> allMap = new HashMap<>(1);
Map<String, Object> plcTaskIdMap = new HashMap<>(1);
plcTaskIdMap.put("INTEGER", businDataTask.getId());
allMap.put(plcTaskId, plcTaskIdMap);
Map<String, Object> plcFromRowMap = new HashMap<>(1);
plcFromRowMap.put("SHORT", businDataTask.getFromRow());
allMap.put(plcFromRow, plcFromRowMap);
Map<String, Object> plcFromColumnMap = new HashMap<>(1);
plcFromColumnMap.put("SHORT", businDataTask.getFromColumn());
allMap.put(plcFromColumn, plcFromColumnMap);
Map<String, Object> plcFromLayerMap = new HashMap<>(1);
plcFromLayerMap.put("SHORT", businDataTask.getFromLayer());
allMap.put(plcFromLayer, plcFromLayerMap);
Map<String, Object> plcToRowMap = new HashMap<>(1);
plcToRowMap.put("SHORT", businDataTask.getToRow());
allMap.put(plcToRow, plcToRowMap);
Map<String, Object> plcToColumnMap = new HashMap<>(1);
plcToColumnMap.put("SHORT", businDataTask.getToColumn());
allMap.put(plcToColumn, plcToColumnMap);
Map<String, Object> plcToLayerMap = new HashMap<>(1);
plcToLayerMap.put("SHORT", businDataTask.getToLayer());
allMap.put(plcToLayer, plcToLayerMap);
Map<String, Object> 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) {

@ -1964,6 +1964,13 @@ public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper, B
return Result.err().msg("移入货位已被占用:" + inBaseLocation.getLocationCode());
}
//获取堆垛机
BasePointDeviceQueryBo pointDeviceQueryBo = new BasePointDeviceQueryBo();
pointDeviceQueryBo.setDevType("1");
pointDeviceQueryBo.setTunnel(outBaseLocation.getTunnel());
BaseDevicePlcVo baseDevicePlcVo = baseLocationPlcMapper.selectBaseDevicePlc(pointDeviceQueryBo);
Long stkPlcId = baseDevicePlcVo.getPlcId();
inBaseLocation.setLocationStatus("4");
iBaseLocationService.updateById(inBaseLocation);
//更改货位状态未移库中,此货位不可在出库
@ -1983,6 +1990,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper, B
BusinDataTask dataTaskIn = new BusinDataTask();
if (!inTunnel.equals(outTunnel)) {
//移出任务
dataTaskOut.setTaskStatus("0");
dataTaskOut.setBatch(DateUtils.getDate());
dataTaskOut.setIsUrgent("0");//非紧急任务
@ -1992,8 +2000,11 @@ public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper, B
dataTaskOut.setFromLayer(outBaseLocation.getLayer());
dataTaskOut.setFromRow(outBaseLocation.getLocationRow());
dataTaskOut.setTaskType(TaskTypeEnum.relocation_out.getValue());
dataTaskOut.setTunnel(outBaseLocation.getTunnel());
dataTaskOut.setPlcId(stkPlcId);
dataTaskIn.setTaskStatus("0");
//移入任务
dataTaskIn.setTaskStatus(TaskStatusEnum.wait_callback.getValue());
dataTaskIn.setBatch(DateUtils.getDate());
dataTaskIn.setIsUrgent("0");//非紧急任务
dataTaskIn.setIsTop("0");
@ -2002,6 +2013,7 @@ public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper, B
dataTaskIn.setToRow(inBaseLocation.getLocationRow());
dataTaskIn.setToColumn(inBaseLocation.getLocationColumn());
dataTaskIn.setTaskType(TaskTypeEnum.relocation_in.getValue());
dataTaskIn.setTunnel(inBaseLocation.getTunnel());
} else {
dataTaskAdd.setTaskStatus("0");
@ -2016,6 +2028,8 @@ public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper, B
dataTaskAdd.setFromRow(outBaseLocation.getLocationRow());
dataTaskAdd.setFromLayer(outBaseLocation.getLayer());
dataTaskAdd.setFromColumn(outBaseLocation.getLocationColumn());
dataTaskAdd.setTunnel(outTunnel);
dataTaskAdd.setPlcId(stkPlcId);
}
for (SysStockDetailVo sysStockDetailVo : sysStockDetailVos) {
@ -2036,12 +2050,14 @@ public class BusinDataTaskServiceImpl extends ServiceImpl<BusinDataTaskMapper, B
dataTaskOut.setPlcId(plcId);
dataTaskOut.setDpsNoOne(Long.valueOf(devCode));
dataTaskOut.setLocationId(inLocationId);
this.save(dataTaskIn);
this.save(dataTaskOut);
taskInId = dataTaskIn.getId();
dataTaskOut.setAssociatedTasksId(dataTaskIn.getId().toString());
this.save(dataTaskOut);
taskOutId = dataTaskOut.getId();
} else {
dataTaskAdd.setLocationId(inBaseLocation.getId());
this.save(dataTaskAdd);
}
index++;

Loading…
Cancel
Save