|
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
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.baomidou.mybatisplus.extension.api.R; |
|
|
|
import com.shkj.common.constant.RedisConstant; |
|
|
|
import com.shkj.common.constant.RedisConstant; |
|
|
|
import com.shkj.common.core.domain.Result; |
|
|
|
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.scheduling.annotation.Scheduled; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
|
|
|
|
|
import org.unbescape.css.CssIdentifierEscapeLevel; |
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.annotation.Resource; |
|
|
|
import java.math.BigDecimal; |
|
|
|
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()); |
|
|
|
log.info("任务号" + businDataTaskVo.getId() + "任务状态" + businDataTaskVo.getTaskStatus() + "点位信息" + businDataTaskVo.getPoints()); |
|
|
|
//统一提交任务数据
|
|
|
|
//统一提交任务数据
|
|
|
|
iBusinDataTaskService.saveOrUpdate(BeanUtil.toBean(businDataTaskVo, BusinDataTask.class)); |
|
|
|
iBusinDataTaskService.saveOrUpdate(BeanUtil.toBean(businDataTaskVo, BusinDataTask.class)); |
|
|
|
@ -1606,7 +1612,11 @@ public class ScheduledTasks { |
|
|
|
return Result.err(); |
|
|
|
return Result.err(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 出库任务
|
|
|
|
/** |
|
|
|
|
|
|
|
* 给堆垛机下发出库任务 |
|
|
|
|
|
|
|
* @param businDataTask |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
public Result<Boolean> outTask(BusinDataTask businDataTask) { |
|
|
|
public Result<Boolean> outTask(BusinDataTask businDataTask) { |
|
|
|
//查看输送线是否拥堵
|
|
|
|
//查看输送线是否拥堵
|
|
|
|
Result<Boolean> booleanResult = this.PLCout(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) { |
|
|
|
public BusinDataTaskOutVo checkOutTaskData(String goods) { |
|
|
|
|