Browse Source

fix:任务代码修改

add:手持接口部分增加
master
songxiaopeng 8 months ago
parent
commit
352f5a31af
  1. 63
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java
  2. 4
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/BaseRequest.java
  3. 3
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/IotToWmsServiceImpl.java
  4. 74
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pda/controller/PdaController.java
  5. 3
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java
  6. 23
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/enums/VehicleTypeEnum.java
  7. 226
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/POINTTask.java
  8. 236
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/SSXBKJTask.java
  9. 245
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java
  10. 249
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java
  11. 70
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cy/CYJKTask.java
  12. 87
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cy/CYXLTask.java
  13. 86
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJSLTask.java
  14. 104
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJXLTask.java
  15. 45
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/lk/LKZYTask.java
  16. 3
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/qg/QGJKTask.java
  17. 62
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/qg/QGXLTask.java
  18. 47
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/qt/QTSLTask.java
  19. 133
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/zw/ZWJKTask.java
  20. 3
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/zw/ZWSLTask.java
  21. 129
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/zw/ZWXLTask.java

63
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java

@ -125,7 +125,7 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
StandardStorageDeviceDriver standardStorageDeviceDriver;
//
SiemensConveyorDeviceDriver siemensConveyorDeviceDriver;
TaskDto task=new TaskDto();
TaskDto task = new TaskDto();
if (ObjectUtil.isNotEmpty(inst)) {
task = taskService.findById(inst.getTask_id());
}
@ -175,17 +175,27 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
return;
}
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
if(device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
if(standardInspectSiteDeviceDriver.getAction()==1){
if (standardInspectSiteDeviceDriver.getAction() == 1) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
}else{
} else {
log.info("当前涂板线未允许取货");
return;
}
}
BaseRequest request = new BaseRequest();
request.setRequestNo(IdUtil.simpleUUID());
request.setTaskId(task.getExt_task_id());
request.setPhase("3");
JSONObject resp = JSONObject.parseObject(acsToWmsService.feedbackState(request));
if ("200".equals(resp.getString("code"))) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
log.info("指令号:{},phase:{},acs请求wms到达取货点申请成功", inst.getInstruction_code(), phase);
} else {
log.info("指令号:{},phase:{},acs请求wms到达取货点申请失败", inst.getInstruction_code(), phase);
}
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
//到达取货等待点
//(需要WCS反馈)
} else if (phase == 0x04) {
@ -228,14 +238,23 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
if(device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
if(standardInspectSiteDeviceDriver.getAction()==1){
if (standardInspectSiteDeviceDriver.getAction() == 1) {
standardInspectSiteDeviceDriver.writing(2);
}
}
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
BaseRequest request = new BaseRequest();
request.setRequestNo(IdUtil.simpleUUID());
request.setTaskId(task.getExt_task_id());
request.setPhase("5");
JSONObject resp = JSONObject.parseObject(acsToWmsService.feedbackState(request));
if ("200".equals(resp.getString("code"))) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
log.info("指令号:{},phase:{},acs请求wms离开取货点申请成功", inst.getInstruction_code(), phase);
} else {
log.info("指令号:{},phase:{},acs请求wms离开取货点申请失败", inst.getInstruction_code(), phase);
}
//到达放货等待点
//(需要WCS反馈)
} else if (phase == 0x06) {
@ -273,8 +292,19 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
log.info("未找到关联编号{}对应的指令", ikey);
return;
}
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
BaseRequest request = new BaseRequest();
request.setRequestNo(IdUtil.simpleUUID());
request.setTaskId(task.getExt_task_id());
request.setPhase("7");
JSONObject resp = JSONObject.parseObject(acsToWmsService.feedbackState(request));
if ("200".equals(resp.getString("code"))) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
log.info("指令号:{},phase:{},acs请求wms到达放货点申请成功", inst.getInstruction_code(), phase);
} else {
log.info("指令号:{},phase:{},acs请求wms到达放货点申请失败", inst.getInstruction_code(), phase);
}
//放货完毕
//(需要WCS反馈)
} else if (phase == 0x09) {
@ -309,7 +339,18 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
log.info("未找到编号{}对应的指令", ikey);
return;
}
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
// data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
BaseRequest request = new BaseRequest();
request.setRequestNo(IdUtil.simpleUUID());
request.setTaskId(task.getExt_task_id());
request.setPhase("9");
JSONObject resp = JSONObject.parseObject(acsToWmsService.feedbackState(request));
if ("200".equals(resp.getString("code"))) {
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
log.info("指令号:{},phase:{},acs请求wms离开放货点申请成功", inst.getInstruction_code(), phase);
} else {
log.info("指令号:{},phase:{},acs请求wms离开放货点申请失败", inst.getInstruction_code(), phase);
}
}
//到达位置点
//(需要WCS反馈)

4
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/wms/data/BaseRequest.java

@ -68,5 +68,9 @@ public class BaseRequest {
*/
private String taskId;
/**
* 阶段
*/
private String phase;
}

3
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/IotToWmsServiceImpl.java

@ -11,6 +11,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
/**
* @author sxp
*/
@Slf4j
@Service
@Lazy

74
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pda/controller/PdaController.java

@ -35,43 +35,43 @@ public class PdaController {
@Resource
private PdaService pdaService;
@PostMapping("/yclrk")
@Log("原材料入库")
@ApiOperation("原材料入库")
public ResponseEntity<Object> yclrk(@RequestBody JSONObject param){
return new ResponseEntity<>(pdaService.yclrk(param), HttpStatus.OK);
}
@PostMapping("/dwzt")
@Log("点位状态")
@ApiOperation("点位状态")
public ResponseEntity<Object> dwzt(@RequestBody JSONObject param){
return new ResponseEntity<>(pdaService.dwzt(param), HttpStatus.OK);
}
@PostMapping("/yclck")
@Log("原材料出库")
@ApiOperation("原材料出库")
public ResponseEntity<Object> yclck(@RequestBody JSONObject param){
return new ResponseEntity<>(pdaService.yclck(param), HttpStatus.OK);
}
@PostMapping("/task")
@Log("点对点任务")
@ApiOperation("点对点任务")
public ResponseEntity<Object> task(@RequestBody JSONObject param){
return new ResponseEntity<>(pdaService.task(param), HttpStatus.OK);
}
@PostMapping("/zpjb")
@Log("组盘解绑")
@ApiOperation("组盘解绑")
public ResponseEntity<Object> zpjb(@RequestBody JSONObject param){
return new ResponseEntity<>(pdaService.zpjb(param), HttpStatus.OK);
}
@PostMapping("/yclrk")
// @PostMapping("/yclrk")
// @Log("原材料入库")
// @ApiOperation("原材料入库")
// public ResponseEntity<Object> yclrk(@RequestBody JSONObject param){
// return new ResponseEntity<>(pdaService.yclrk(param), HttpStatus.OK);
// }
//
// @PostMapping("/dwzt")
// @Log("点位状态")
// @ApiOperation("点位状态")
// public ResponseEntity<Object> dwzt(@RequestBody JSONObject param){
// return new ResponseEntity<>(pdaService.dwzt(param), HttpStatus.OK);
// }
//
//
// @PostMapping("/yclck")
// @Log("原材料出库")
// @ApiOperation("原材料出库")
// public ResponseEntity<Object> yclck(@RequestBody JSONObject param){
// return new ResponseEntity<>(pdaService.yclck(param), HttpStatus.OK);
// }
//
// @PostMapping("/task")
// @Log("点对点任务")
// @ApiOperation("点对点任务")
// public ResponseEntity<Object> task(@RequestBody JSONObject param){
// return new ResponseEntity<>(pdaService.task(param), HttpStatus.OK);
// }
//
// @PostMapping("/zpjb")
// @Log("组盘解绑")
// @ApiOperation("组盘解绑")
// public ResponseEntity<Object> zpjb(@RequestBody JSONObject param){
// return new ResponseEntity<>(pdaService.zpjb(param), HttpStatus.OK);
// }
@PostMapping("/dzwck")
@Log("待折弯件出库")
@ApiOperation("待折弯件出库")
public ResponseEntity<Object> dzwck(@RequestBody JSONObject param){

3
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java

@ -227,8 +227,9 @@ public abstract class AbstractTask {
task.setConfig_code(configCode);
task.setCreate_mode(param.getString("create_mode"));
task.setVehicle_code(param.getString("vehicle_code"));
task.setVehicle_type(param.getString("vehicle_type"));
task.setVehicle_qty(param.getInteger("vehicle_qty"));
task.setVehicle_type(param.getString("material_type"));
// task.setVehicle_type(param.getString("material_type"));
task.setTask_status(TaskStatus.APPLY.getCode());
task.setWorkshop_code(taskConfig.getWorkshop_code()); // 车间编码
// 设置起/终点

23
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/enums/VehicleTypeEnum.java

@ -0,0 +1,23 @@
package org.nl.wms.sch.task_manage.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* @author sp
* 载具类型
*/
@Getter
@AllArgsConstructor
public enum VehicleTypeEnum {
GTP("0", "钢托盘"),
LK_RO1("1", "笼框R01"),
LK_RO2("2", "笼框R02"),
LJ_S04("3", "S04料架"),
LJ_A06("4", "A06料架");
private final String code;
private final String label;
}

226
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/POINTTask.java

@ -1,226 +0,0 @@
package org.nl.wms.sch.task_manage.task.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext.service.WmsToAcsService;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
import org.nl.wms.sch.point.service.ISchBasePointService;
import org.nl.wms.sch.point.service.dao.SchBasePoint;
import org.nl.wms.sch.task.service.ISchBaseTaskService;
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task_manage.AbstractTask;
import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum;
import org.nl.wms.sch.task_manage.task.TaskType;
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: psh
* @Description: 点对点任务
* @Date: 2023/1/24
*/
@Slf4j
@Component
@TaskType("POINTTask")
@Lazy
public class POINTTask extends AbstractTask {
private static String TASK_CONFIG_CODE = "POINTTask";
/**
* 入口
*/
private static String ENTRANCE = "1";
@Autowired
private ISchBasePointService pointService;
@Autowired
private ISchBaseTaskService taskService;
@Autowired
private ISchBaseTaskconfigService taskConfigService;
@Autowired
private IPdmBdWorkorderService workorderService;
@Autowired
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
@Autowired
private PointMapper pointMapper;
@Autowired
private WmsToAcsService wmsToAcsService;
@Override
// @Transactional(rollbackFor = Exception.class)
protected void create() throws BadRequestException {
// 获取任务
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY);
// 配置信息
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
for (SchBaseTask task : tasks) {
task.setTask_status(TaskStatus.CREATED.getCode());
task.setRemark("");
SchBasePoint schBasePoint= pointService.getOne(new LambdaQueryWrapper<SchBasePoint>()
.eq(SchBasePoint::getPoint_code, task.getPoint_code1()));
task.setVehicle_code(schBasePoint.getVehicle_code());
task.setVehicle_code2(schBasePoint.getVehicle_code2());
taskService.update(task);
//发起任务时先把点位占用,防止发起重复任务
// point.setIng_task_code(task.getTask_code());
// pointService.update(point);
//下发
this.renotifyAcs(task);
}
}
/**
* 点对点任务暂定不需要等待点
*
* @param extGroupData
* @return
*/
private SchBasePoint findNextPoint(JSONObject extGroupData,SchBaseTask task) {
return null;
}
/**
* 1.取货完毕后起点减少最后一份组盘并且该组盘视为已结束
* 2.包片机LMS不记录点位信息由人工对组盘进行操作
*/
@Override
// @Transactional(rollbackFor = Exception.class)
protected void updateStatus(String task_code, TaskStatus status) {
// 校验任务
SchBaseTask taskObj = taskService.getById(task_code);
if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) {
throw new BadRequestException("该任务已完成!");
}
if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) {
throw new BadRequestException("该任务已取消!");
}
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = taskObj.getPoint_code2(); // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
if (status.equals(TaskStatus.EXECUTING)) { // 执行中
taskObj.setTask_status(TaskStatus.EXECUTING.getCode());
taskObj.setRemark("执行中");
}
if (status.equals(TaskStatus.FINISHED)) { // 完成
String vehicleCode=taskObj.getVehicle_code();
String vehicleCode2= taskObj.getVehicle_code2();
SchBaseVehiclematerialgroup one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper<SchBaseVehiclematerialgroup>()
.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicleCode)
.eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status,
GroupBindMaterialStatusEnum.BOUND.getValue()));
if (ObjectUtil.isNotEmpty(one)) {
// throw new BadRequestException(vehicleCode + " => " + startPointObj.getVehicle_type() + "的组盘信息未找到");
// }
one.setTask_code(taskObj.getTask_code());
one.setPoint_code(endPointObj.getPoint_code()); // 当前位置
one.setPoint_name(endPointObj.getPoint_name());
one.setMove_way(one.getMove_way() == null ? "" : (one.getMove_way() + " -> ") + endPointObj.getPoint_code());
one.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue());
one.setUpdate_id(GeneralDefinition.ACS_ID);
one.setUpdate_name(GeneralDefinition.ACS_NAME);
one.setUpdate_time(DateUtil.now());
vehiclematerialgroupService.updateById(one);
}
one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper<SchBaseVehiclematerialgroup>()
.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicleCode2)
.eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status,
GroupBindMaterialStatusEnum.BOUND.getValue()));
if (ObjectUtil.isNotEmpty(one)) {
// throw new BadRequestException(vehicleCode + " => " + startPointObj.getVehicle_type() + "的组盘信息未找到");
// }
one.setTask_code(taskObj.getTask_code());
one.setPoint_code(endPointObj.getPoint_code()); // 当前位置
one.setPoint_name(endPointObj.getPoint_name());
one.setMove_way(one.getMove_way() == null ? "" : (one.getMove_way() + " -> ") + endPointObj.getPoint_code());
one.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue());
one.setUpdate_id(GeneralDefinition.ACS_ID);
one.setUpdate_name(GeneralDefinition.ACS_NAME);
one.setUpdate_time(DateUtil.now());
vehiclematerialgroupService.updateById(one);
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(taskObj.getVehicle_code());
endPointObj.setVehicle_code2(taskObj.getVehicle_code2());
endPointObj.setVehicle_qty(1);
pointService.update(endPointObj);
// 起点清空
startPointObj.setVehicle_code("");
startPointObj.setVehicle_code2("");
startPointObj.setVehicle_qty(0);
startPointObj.setIng_task_code("");
startPointObj.setUpdate_time(DateUtil.now());
pointService.updateById(startPointObj);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(one.getGroup_id());
taskObj.setRemark("任务完成");
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁
if (ObjectUtil.isNotEmpty(endPointObj)) {
endPointObj.setIng_task_code("");
pointService.update(endPointObj);
}
// 起点解锁
if (ObjectUtil.isNotEmpty(startPointObj)) {
startPointObj.setIng_task_code("");
pointService.update(endPointObj);
}
taskObj.setRemark("任务取消");
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
}
taskService.update(taskObj);
}
@Override
public void forceFinish(String task_code) {
this.updateStatus(task_code, TaskStatus.FINISHED);
}
@Override
public void cancel(String task_code) {
this.updateStatus(task_code, TaskStatus.CANCELED);
}
@Override
protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) {
//重算最优点
JSONObject jsonObject = JSONObject.parseObject(schBaseTask.getExt_group_data());
SchBasePoint point = this.findNextPoint(jsonObject,schBaseTask);
//正极板现在不堆叠
if( "1".equals(jsonObject.getString("material_type"))) {
schBaseTask.setPoint_code1(point.getPoint_code()+"0"+(point.getVehicle_qty()));
}else{
schBaseTask.setPoint_code1(point.getPoint_code().replace("HCQ","QHQ"));
}
//重算点位时把点位占用
point.setIng_task_code(schBaseTask.getTask_code());
//如果是正极板对接位则直接减库存
if ((point.getPoint_code().startsWith("ZJBDJW"))) {
point.setVehicle_qty(point.getVehicle_qty() - 1);
}
pointService.update(point);
}
}

236
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/SSXBKJTask.java

@ -1,236 +0,0 @@
package org.nl.wms.sch.task_manage.task.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext.service.AcsToWmsService;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.pdm.service.dao.PdmBdWorkorder;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
import org.nl.wms.sch.point.service.ISchBasePointService;
import org.nl.wms.sch.point.service.dao.SchBasePoint;
import org.nl.wms.sch.task.service.ISchBaseTaskService;
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task_manage.AbstractTask;
import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum;
import org.nl.wms.sch.task_manage.enums.GroupStatusEnum;
import org.nl.wms.sch.task_manage.task.TaskType;
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper;
import org.nl.wms.util.PointUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.List;
/**
* @Author: psh
* @Description: 输送线补空架
* @Date: 2024/1/24
*/
@Slf4j
@Component
@TaskType("SSXBKJTask")
@Lazy
public class SSXBKJTask extends AbstractTask {
private static String TASK_CONFIG_CODE = "SSXBKJTask";
/**
* 入口
*/
private static String ENTRANCE = "1";
@Autowired
private ISchBasePointService pointService;
@Autowired
private ISchBaseTaskService taskService;
@Autowired
private ISchBaseTaskconfigService taskConfigService;
@Autowired
private IPdmBdWorkorderService workorderService;
@Autowired
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
@Autowired
private PointMapper pointMapper;
@Autowired
private AcsToWmsService acsToWmsService;
@Override
// @Transactional(rollbackFor = Exception.class)
protected void create() throws BadRequestException {
// 获取任务
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY);
// 配置信息
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
for (SchBaseTask task : tasks) {
// 找终点
SchBasePoint startPoint = pointService.getOne(new LambdaQueryWrapper<SchBasePoint>()
.eq(SchBasePoint::getPoint_code, task.getPoint_code1()));
String extGroupData = task.getExt_group_data();
JSONObject jsonObject = JSONObject.parseObject(extGroupData);
// String materialType = jsonObject.getString("material_type");
SchBasePoint point = findNextPoint();
if (ObjectUtil.isEmpty(point)) {
task.setRemark("未找到所需点位!");
taskService.update(task);
// 消息通知
log.info("原材料入库未找到当前符合条件的点位!");
continue;
}
// 设置终点并修改创建成功状态
task.setPoint_code2(point.getPoint_code());
task.setTask_status(TaskStatus.CREATED.getCode());
task.setRemark("");
taskService.update(task);
//发起任务时先把点位占用,防止发起重复任务
point.setIng_task_code(task.getTask_code());
// point.setVehicle_type(materialType);
pointService.update(point);
//下发
this.renotifyAcs(task);
}
}
/**
* 判断目标点位
*
* @return
*/
private SchBasePoint findNextPoint() {
String regionCode = "YL";
List<SchBasePoint> schBasePointList = pointMapper.findPointByRegion(regionCode, "2");
for (SchBasePoint schBasePoint : schBasePointList) {
if ("2".equals(schBasePoint.getPoint_status())
&& schBasePoint.getVehicle_qty() ==0) {
log.info("原材料入库找到当前符合条件的点位{}", schBasePoint.getPoint_code());
return schBasePoint;
}
}
return null;
}
@Override
// @Transactional(rollbackFor = Exception.class)
protected void updateStatus(String task_code, TaskStatus status) {
// 校验任务
SchBaseTask taskObj = taskService.getById(task_code);
if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) {
throw new BadRequestException("该任务已完成!");
}
if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) {
throw new BadRequestException("该任务已取消!");
}
// 获取参数
JSONObject extGroupData = ObjectUtil.isNotEmpty(taskObj.getExt_group_data())
? JSONObject.parseObject(taskObj.getExt_group_data())
: null;
// 载具编码:没有就创建一个
String vehicle_code = ObjectUtil.isNotEmpty(taskObj.getVehicle_code())
? taskObj.getVehicle_code()
: IdUtil.getSnowflake(1, 1).nextIdStr();
PdmBdWorkorder workorderCode = null;
if (extGroupData != null) {
workorderCode = ObjectUtil.isNotEmpty(extGroupData.getString("workorder_code"))
? workorderService.getOne(new LambdaQueryWrapper<PdmBdWorkorder>()
.eq(PdmBdWorkorder::getWorkorder_code, extGroupData.getString("workorder_code")))
: null;
}
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = ObjectUtil.isNotEmpty(taskObj.getPoint_code2())?taskObj.getPoint_code2().substring(0,taskObj.getPoint_code2().length()-2):"0"; // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
if (status.equals(TaskStatus.EXECUTING)) { // 执行中
taskObj.setTask_status(TaskStatus.EXECUTING.getCode());
taskObj.setRemark("执行中");
}
if (status.equals(TaskStatus.FINISHED)) { // 完成
// 起点清空
if (ObjectUtil.isNotEmpty(startPointObj)) {
PointUtils.clearPoint(startPointObj);
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
endPointObj.setVehicle_qty(1);
pointService.update(endPointObj);
// 要把数据存到组盘表 -> 改造公共方法,返回id
//todo 组盘表需要关联外部mes晶棒数据,一对多
SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
groupEntity.setCreate_id("2");
groupEntity.setCreate_name("ACS");
groupEntity.setCreate_time(DateUtil.now());
groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderCode)
? workorderCode.getMaterial_id()
: "");
groupEntity.setStanding_time(ObjectUtil.isNotEmpty(workorderCode)
? workorderCode.getStanding_time()
: 0);
groupEntity.setMaterial_weight(ObjectUtil.isNotEmpty(extGroupData)
? extGroupData.getBigDecimal("material_qty")
: BigDecimal.valueOf(0));
groupEntity.setWorkorder_code(ObjectUtil.isNotEmpty(workorderCode)
? workorderCode.getWorkorder_code()
: "");
groupEntity.setVehicle_code(vehicle_code);
groupEntity.setVehicle_type(taskObj.getVehicle_type());
groupEntity.setPoint_code(startPoint);
groupEntity.setPoint_name(startPointObj.getPoint_name());
groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
groupEntity.setInstorage_time(DateUtil.now());
groupEntity.setTask_code(taskObj.getTask_code());
groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
groupEntity.setIs_delete(false);
groupEntity.setMove_way(startPoint);
vehiclematerialgroupService.save(groupEntity);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(groupEntity.getGroup_id());
taskObj.setRemark("任务完成");
try {
//todo 入库成功后上报mes
}catch (Exception e){
log.error("原材料入库上报MES失败{}",e.getMessage(),e);
}
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁
if (ObjectUtil.isNotEmpty(endPointObj)) {
endPointObj.setIng_task_code("");
//任务取消把原先占用的位置释放
pointService.update(endPointObj);
}
taskObj.setRemark("任务取消");
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
}
taskService.update(taskObj);
}
@Override
public void forceFinish(String task_code) {
this.updateStatus(task_code, TaskStatus.FINISHED);
}
@Override
public void cancel(String task_code) {
this.updateStatus(task_code, TaskStatus.CANCELED);
}
@Override
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) {
//该场景无需重算等待点
}
}

245
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java

@ -1,245 +0,0 @@
package org.nl.wms.sch.task_manage.task.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.config.MapOf;
import org.nl.wms.ext.service.WmsToAcsService;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.pdm.service.dao.PdmBdWorkorder;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
import org.nl.wms.sch.point.service.ISchBasePointService;
import org.nl.wms.sch.point.service.dao.SchBasePoint;
import org.nl.wms.sch.task.service.ISchBaseTaskService;
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task_manage.AbstractTask;
import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum;
import org.nl.wms.sch.task_manage.enums.GroupStatusEnum;
import org.nl.wms.sch.task_manage.task.TaskType;
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper;
import org.nl.wms.util.PointUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* @Author: psh
* @Description: 原材料出库
* @Date: 2023/1/24
*/
@Slf4j
@Component
@TaskType("YCLCKTask")
@Lazy
public class YCLCKTask extends AbstractTask {
private static String TASK_CONFIG_CODE = "YCLCKTask";
/**
* 入口
*/
private static String ENTRANCE = "1";
@Autowired
private ISchBasePointService pointService;
@Autowired
private ISchBaseTaskService taskService;
@Autowired
private ISchBaseTaskconfigService taskConfigService;
@Autowired
private IPdmBdWorkorderService workorderService;
@Autowired
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
@Autowired
private PointMapper pointMapper;
@Autowired
private WmsToAcsService wmsToAcsService;
@Override
// @Transactional(rollbackFor = Exception.class)
protected void create() throws BadRequestException {
// 获取任务
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY);
// 配置信息
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
for (SchBaseTask task : tasks) {
SchBasePoint point = findNextPoint(task);
if (ObjectUtil.isEmpty(point)) {
task.setRemark("未找到所需点位!");
taskService.update(task);
// 消息通知
log.info("原材料出库未找到所需点位!");
continue;
}
// 设置起点并修改创建成功状态
task.setPoint_code2(point.getPoint_code());
task.setTask_status(TaskStatus.CREATED.getCode());
task.setRemark("");
SchBasePoint schBasePoint= pointService.getOne(new LambdaQueryWrapper<SchBasePoint>()
.eq(SchBasePoint::getPoint_code, task.getPoint_code1()));
task.setVehicle_code(schBasePoint.getVehicle_code());
task.setVehicle_code2(schBasePoint.getVehicle_code2());
taskService.update(task);
//发起任务时先把点位占用,防止发起重复任务
// point.setIng_task_code(task.getTask_code());
// point.setVehicle_qty(point.getVehicle_qty() - 1);
// point.setVehicle_type(materialType);
// pointService.update(point);
//下发
this.renotifyAcs(task);
}
}
/**
* todo 待确认怎么区分普通回温和快速回温
* todo 设置回温时间
*
* @return
*/
private SchBasePoint findNextPoint(SchBaseTask task) {
String regionCode = "HW";
List<SchBasePoint> schBasePointList = pointMapper.findPointByRegion(regionCode,"0");
for (SchBasePoint schBasePoint : schBasePointList) {
//已锁定直接返回
if(task.getTask_code().equals(schBasePoint.getIng_task_code())){
return schBasePoint;
}
if (schBasePoint.getIs_used()
&& schBasePoint.getVehicle_qty() ==0) {
log.info("原材料出库任务找到当前符合条件的缓存区位置{}",schBasePoint.getPoint_code());
return schBasePoint;
}
}
return null;
}
/**
* todo 任务完成设置完成时间为开始固化时间
*/
@Override
// @Transactional(rollbackFor = Exception.class)
protected void updateStatus(String task_code, TaskStatus status) {
// 校验任务
SchBaseTask taskObj = taskService.getById(task_code);
if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) {
throw new BadRequestException("该任务已完成!");
}
if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) {
throw new BadRequestException("该任务已取消!");
}
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = taskObj.getPoint_code2(); // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
if (status.equals(TaskStatus.EXECUTING)) { // 执行中
taskObj.setTask_status(TaskStatus.EXECUTING.getCode());
taskObj.setRemark("执行中");
}
if (status.equals(TaskStatus.FINISHED)) { // 完成
String vehicleCode=taskObj.getVehicle_code();
String vehicleCode2= taskObj.getVehicle_code2();
SchBaseVehiclematerialgroup one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper<SchBaseVehiclematerialgroup>()
.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicleCode)
.eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status,
GroupBindMaterialStatusEnum.BOUND.getValue()));
if (ObjectUtil.isNotEmpty(one)) {
// throw new BadRequestException(vehicleCode + " => " + startPointObj.getVehicle_type() + "的组盘信息未找到");
// }
one.setTask_code(taskObj.getTask_code());
one.setPoint_code(endPointObj.getPoint_code()); // 当前位置
one.setPoint_name(endPointObj.getPoint_name());
one.setMove_way(one.getMove_way() == null ? "" : (one.getMove_way() + " -> ") + endPointObj.getPoint_code());
one.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue());
one.setUpdate_id(GeneralDefinition.ACS_ID);
one.setUpdate_name(GeneralDefinition.ACS_NAME);
one.setUpdate_time(DateUtil.now());
vehiclematerialgroupService.updateById(one);
}
one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper<SchBaseVehiclematerialgroup>()
.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicleCode2)
.eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status,
GroupBindMaterialStatusEnum.BOUND.getValue()));
if (ObjectUtil.isNotEmpty(one)) {
// throw new BadRequestException(vehicleCode + " => " + startPointObj.getVehicle_type() + "的组盘信息未找到");
// }
one.setTask_code(taskObj.getTask_code());
one.setPoint_code(endPointObj.getPoint_code()); // 当前位置
one.setPoint_name(endPointObj.getPoint_name());
one.setMove_way(one.getMove_way() == null ? "" : (one.getMove_way() + " -> ") + endPointObj.getPoint_code());
one.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue());
one.setUpdate_id(GeneralDefinition.ACS_ID);
one.setUpdate_name(GeneralDefinition.ACS_NAME);
one.setUpdate_time(DateUtil.now());
vehiclematerialgroupService.updateById(one);
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(taskObj.getVehicle_code());
endPointObj.setVehicle_code2(taskObj.getVehicle_code2());
endPointObj.setVehicle_qty(1);
endPointObj.setUpdate_time(DateUtil.now());
pointService.update(endPointObj);
// 起点清空
startPointObj.setVehicle_code("");
startPointObj.setVehicle_code2("");
startPointObj.setIng_task_code("");
startPointObj.setUpdate_time(DateUtil.now());
pointService.updateById(startPointObj);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(one.getGroup_id());
taskObj.setRemark("任务完成");
try {
//todo 出库成功后上报mes
}catch (Exception e){
log.error("原材料出库上报MES失败{}",e.getMessage(),e);
}
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁
if (ObjectUtil.isNotEmpty(endPointObj)) {
endPointObj.setIng_task_code("");
pointService.update(endPointObj);
}
// 起点解锁
if (ObjectUtil.isNotEmpty(startPointObj)) {
startPointObj.setIng_task_code("");
pointService.update(startPointObj);
}
taskObj.setRemark("任务取消");
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
}
taskService.update(taskObj);
}
@Override
public void forceFinish(String task_code) {
this.updateStatus(task_code, TaskStatus.FINISHED);
}
@Override
public void cancel(String task_code) {
this.updateStatus(task_code, TaskStatus.CANCELED);
}
@Override
protected void feedbackTaskState(JSONObject param,SchBaseTask schBaseTask, BaseResponse result) {
//该场景无需重算等待点
}
}

249
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java

@ -1,249 +0,0 @@
package org.nl.wms.sch.task_manage.task.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext.service.AcsToWmsService;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.pdm.service.dao.PdmBdWorkorder;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
import org.nl.wms.sch.point.service.ISchBasePointService;
import org.nl.wms.sch.point.service.dao.SchBasePoint;
import org.nl.wms.sch.task.service.ISchBaseTaskService;
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task_manage.AbstractTask;
import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum;
import org.nl.wms.sch.task_manage.enums.GroupStatusEnum;
import org.nl.wms.sch.task_manage.enums.PointStatusEnum;
import org.nl.wms.sch.task_manage.task.TaskType;
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper;
import org.nl.wms.util.PointUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* @Author: psh
* @Description: 原材料入库
* @Date: 2024/1/24
*/
@Slf4j
@Component
@TaskType("YCLRKTask")
@Lazy
public class YCLRKTask extends AbstractTask {
private static String TASK_CONFIG_CODE = "YCLRKTask";
/**
* 入口
*/
private static String ENTRANCE = "1";
@Autowired
private ISchBasePointService pointService;
@Autowired
private ISchBaseTaskService taskService;
@Autowired
private ISchBaseTaskconfigService taskConfigService;
@Autowired
private IPdmBdWorkorderService workorderService;
@Autowired
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
@Autowired
private PointMapper pointMapper;
@Autowired
private AcsToWmsService acsToWmsService;
@Override
// @Transactional(rollbackFor = Exception.class)
protected void create() throws BadRequestException {
// 获取任务
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY);
// 配置信息
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
for (SchBaseTask task : tasks) {
// 找终点
SchBasePoint startPoint = pointService.getOne(new LambdaQueryWrapper<SchBasePoint>()
.eq(SchBasePoint::getPoint_code, task.getPoint_code1()));
String extGroupData = task.getExt_group_data();
JSONObject jsonObject = JSONObject.parseObject(extGroupData);
// String materialType = jsonObject.getString("material_type");
SchBasePoint point = findNextPoint();
if (ObjectUtil.isEmpty(point)) {
task.setRemark("未找到所需点位!");
taskService.update(task);
// 消息通知
log.info("原材料入库未找到当前符合条件的点位!");
continue;
}
// 设置终点并修改创建成功状态
task.setPoint_code2(point.getPoint_code());
task.setTask_status(TaskStatus.CREATED.getCode());
task.setVehicle_code(jsonObject.getString("mother_tray"));
task.setVehicle_code2(jsonObject.getString("sub_tray"));
task.setRemark("");
taskService.update(task);
//发起任务时先把点位占用,防止发起重复任务
point.setIng_task_code(task.getTask_code());
// point.setVehicle_type(materialType);
pointService.update(point);
//下发
this.renotifyAcs(task);
}
}
/**
* 判断目标点位
*
* @return
*/
private SchBasePoint findNextPoint() {
String regionCode = "YL";
List<SchBasePoint> schBasePointList = pointMapper.findPointByRegion(regionCode, "0");
for (SchBasePoint schBasePoint : schBasePointList) {
if (schBasePoint.getIs_used()
&& schBasePoint.getVehicle_qty() ==0) {
log.info("原材料入库找到当前符合条件的点位{}", schBasePoint.getPoint_code());
return schBasePoint;
}
}
return null;
}
@Override
// @Transactional(rollbackFor = Exception.class)
protected void updateStatus(String task_code, TaskStatus status) {
// 校验任务
SchBaseTask taskObj = taskService.getById(task_code);
if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) {
throw new BadRequestException("该任务已完成!");
}
if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) {
throw new BadRequestException("该任务已取消!");
}
// 获取参数
JSONObject extGroupData = ObjectUtil.isNotEmpty(taskObj.getExt_group_data())
? JSONObject.parseObject(taskObj.getExt_group_data())
: null;
PdmBdWorkorder workorderCode = null;
if (extGroupData != null) {
workorderCode = ObjectUtil.isNotEmpty(extGroupData.getString("workorder_code"))
? workorderService.getOne(new LambdaQueryWrapper<PdmBdWorkorder>()
.eq(PdmBdWorkorder::getWorkorder_code, extGroupData.getString("workorder_code")))
: null;
}
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = taskObj.getPoint_code2(); // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
if (status.equals(TaskStatus.EXECUTING)) { // 执行中
taskObj.setTask_status(TaskStatus.EXECUTING.getCode());
taskObj.setRemark("执行中");
}
if (status.equals(TaskStatus.FINISHED)) { // 完成
// 起点清空
if (ObjectUtil.isNotEmpty(startPointObj)) {
PointUtils.clearPoint(startPointObj);
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(taskObj.getVehicle_code());
endPointObj.setVehicle_code2(taskObj.getVehicle_code2());
endPointObj.setVehicle_qty(1);
pointService.update(endPointObj);
// 要把数据存到组盘表 -> 改造公共方法,返回id
//组盘表需要关联外部mes晶棒数据,一对多
SchBaseVehiclematerialgroup groupEntity = getSchBaseVehiclematerialgroup(taskObj, extGroupData, workorderCode, startPoint, startPointObj);
groupEntity.setVehicle_code(taskObj.getVehicle_code());
groupEntity.setVehicle_type("0");
vehiclematerialgroupService.save(groupEntity);
groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
groupEntity.setVehicle_code(taskObj.getVehicle_code2());
groupEntity.setVehicle_type("1");
vehiclematerialgroupService.save(groupEntity);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(groupEntity.getGroup_id());
taskObj.setRemark("任务完成");
try {
//todo 入库成功后上报mes
}catch (Exception e){
log.error("原材料入库上报MES失败{}",e.getMessage(),e);
}
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁
if (ObjectUtil.isNotEmpty(endPointObj)) {
endPointObj.setIng_task_code("");
//任务取消把原先占用的位置释放
pointService.update(endPointObj);
}
taskObj.setRemark("任务取消");
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
}
taskService.update(taskObj);
}
private static SchBaseVehiclematerialgroup getSchBaseVehiclematerialgroup(SchBaseTask taskObj, JSONObject extGroupData, PdmBdWorkorder workorderCode, String startPoint, SchBasePoint startPointObj) {
SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
groupEntity.setCreate_id("2");
groupEntity.setCreate_name("ACS");
groupEntity.setCreate_time(DateUtil.now());
groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderCode)
? workorderCode.getMaterial_id()
: "");
groupEntity.setStanding_time(ObjectUtil.isNotEmpty(workorderCode)
? workorderCode.getStanding_time()
: 0);
groupEntity.setMaterial_weight(ObjectUtil.isNotEmpty(extGroupData)
? extGroupData.getBigDecimal("material_qty")
: BigDecimal.valueOf(0));
groupEntity.setWorkorder_code(ObjectUtil.isNotEmpty(workorderCode)
? workorderCode.getWorkorder_code()
: "");
groupEntity.setPoint_code(startPoint);
groupEntity.setPoint_name(startPointObj.getPoint_name());
groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
groupEntity.setInstorage_time(DateUtil.now());
groupEntity.setTask_code(taskObj.getTask_code());
groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
groupEntity.setIs_delete(false);
groupEntity.setMove_way(startPoint);
return groupEntity;
}
@Override
public void forceFinish(String task_code) {
this.updateStatus(task_code, TaskStatus.FINISHED);
}
@Override
public void cancel(String task_code) {
this.updateStatus(task_code, TaskStatus.CANCELED);
}
@Override
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) {
//该场景无需重算等待点
}
}

70
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cy/CYJKTask.java

@ -1,13 +1,19 @@
package org.nl.wms.sch.task_manage.task.tasks.cy;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.service.WmsToAcsService;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.ext.service.dto.to.iot.AgvStateParam;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
@ -21,12 +27,14 @@ import org.nl.wms.sch.task_manage.AbstractTask;
import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.enums.GroupBindMaterialStatusEnum;
import org.nl.wms.sch.task_manage.enums.PointStatusEnum;
import org.nl.wms.sch.task_manage.enums.VehicleTypeEnum;
import org.nl.wms.sch.task_manage.task.TaskType;
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper;
import org.nl.wms.util.PointUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import java.util.Arrays;
@ -82,7 +90,9 @@ public class CYJKTask extends AbstractTask {
// 设置起点并修改创建成功状态
task.setPoint_code1(point.getPoint_code());
task.setTask_status(TaskStatus.CREATED.getCode());
task.setRemark("");
task.setRemark("创建完成");
task.setVehicle_code(point.getVehicle_code());
task.setVehicle_type(point.getVehicle_type());
taskService.update(task);
//发起任务时先把点位占用,防止发起重复任务
point.setIng_task_code(task.getTask_code());
@ -101,6 +111,7 @@ public class CYJKTask extends AbstractTask {
LambdaQueryWrapper<SchBasePoint> lam = new LambdaQueryWrapper<>();
lam.in(SchBasePoint::getRegion_code, Arrays.asList(reginList))
.eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_VEHICLE.getCode())
.eq(SchBasePoint::getPoint_type, "1")
.and(la -> la.isNull(SchBasePoint::getIng_task_code)
.or()
.eq(SchBasePoint::getIng_task_code, ""))
@ -176,6 +187,61 @@ public class CYJKTask extends AbstractTask {
@Override
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) {
//该场景无需重算等待点
// 反馈上位系统 反馈上位系统成功后,返回200给acs
AgvStateParam agvStateParam = new AgvStateParam();
agvStateParam.setTask_code(schBaseTask.getTask_code());
agvStateParam.setDevice_code(schBaseTask.getPoint_code2());
agvStateParam.setVehicle_code(schBaseTask.getVehicle_code());
String phase = param.getString("phase");
String iotUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("iot_url").getValue();
SchBasePoint endPoint = pointService.getById(schBaseTask.getPoint_code2());
if ("7".equals(phase)) {
//todo 请求放货状态需要修改
agvStateParam.setStatus("3");
//叉车到位 请求放货
String url = iotUrl + "iot/agvarrive";
applyIot(url, agvStateParam, result);
//锁住终点
endPoint.setIng_task_code(schBaseTask.getTask_code());
pointService.update(endPoint);
}
if ("9".equals(phase)) {
//todo 请求放货状态需要修改
agvStateParam.setStatus("4");
//取货完成,请求离开
String url = iotUrl + "iot/agvfinish";
applyIot(url, agvStateParam, result);
//终点解锁 设置载具类型和编码
endPoint.setIng_task_code("");
// endPoint.setVehicle_code(schBaseTask.getVehicle_code());
// endPoint.setVehicle_type(schBaseTask.getVehicle_type());
pointService.update(endPoint);
}
}
private void applyIot(String url, AgvStateParam agvStateParam, BaseResponse result) {
String jsonParam = JSON.toJSONString(agvStateParam);
log.info("请求iot参数为:{}", jsonParam);
try {
String resultMsg = HttpRequest.post(url)
.body(jsonParam)
.execute().body();
JSONObject res = JSONObject.parseObject(resultMsg);
if ("200".equals(res.getString("code"))) {
log.info("请求iot成功,返回结果为:{}", res);
result.setCode(HttpStatus.OK.value());
result.setMessage("请求iot成功!");
} else {
log.error("请求iot失败:{}", res);
result.setCode(HttpStatus.BAD_REQUEST.value());
result.setMessage("请求iot失败!");
}
} catch (Exception e) {
String msg = e.getMessage();
//请求iot失败
log.error("请求iot失败:{}", msg);
result.setCode(HttpStatus.BAD_REQUEST.value());
result.setMessage("请求iot失败!");
}
}
}

87
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/cy/CYXLTask.java

@ -8,11 +8,14 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.service.AcsToWmsService;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.ext.service.dto.to.iot.AgvStateParam;
import org.nl.wms.pda.service.dao.vo.PdaResponseVo;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
@ -48,10 +51,6 @@ import java.util.List;
@Lazy
public class CYXLTask extends AbstractTask {
private static String TASK_CONFIG_CODE = "CYXLTask";
/**
* 入口
*/
private static String ENTRANCE = "1";
@Autowired
private ISchBasePointService pointService;
@Autowired
@ -63,6 +62,9 @@ public class CYXLTask extends AbstractTask {
@Autowired
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
@Autowired
private AcsToWmsService acsToWmsService;
@Override
protected void create() throws BadRequestException {
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY);
@ -78,7 +80,7 @@ public class CYXLTask extends AbstractTask {
}
task.setPoint_code2(point.getPoint_code());
task.setTask_status(TaskStatus.CREATED.getCode());
task.setRemark("");
task.setRemark("创建完成");
taskService.update(task);
//发起任务时先把点位占用,防止发起重复任务
point.setIng_task_code(task.getTask_code());
@ -105,13 +107,7 @@ public class CYXLTask extends AbstractTask {
.orderByAsc(SchBasePoint::getIn_order_seq)
.orderByAsc(SchBasePoint::getPoint_code);
List<SchBasePoint> schBasePoints = pointService.list(lam);
for (SchBasePoint schBasePoint : schBasePoints) {
if (schBasePoint.getVehicle_qty() == 0) {
log.info("冲压下料入库找到当前符合条件的点位{}", schBasePoint.getPoint_code());
return schBasePoint;
}
}
return null;
return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null;
}
@Override
@ -133,15 +129,8 @@ public class CYXLTask extends AbstractTask {
String vehicle_code = ObjectUtil.isNotEmpty(taskObj.getVehicle_code())
? taskObj.getVehicle_code()
: IdUtil.getSnowflake(1, 1).nextIdStr();
// PdmBdWorkorder workorderCode = null;
// if (extGroupData != null) {
// workorderCode = ObjectUtil.isNotEmpty(extGroupData.getString("workorder_code"))
// ? workorderService.getOne(new LambdaQueryWrapper<PdmBdWorkorder>()
// .eq(PdmBdWorkorder::getWorkorder_code, extGroupData.getString("workorder_code")))
// : null;
// }
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = ObjectUtil.isNotEmpty(taskObj.getPoint_code2()) ? taskObj.getPoint_code2().substring(0, taskObj.getPoint_code2().length() - 2) : "0"; // 获取终点
String endPoint = taskObj.getPoint_code2(); // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
@ -156,16 +145,16 @@ public class CYXLTask extends AbstractTask {
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
// endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code : endPointObj.getVehicle_code());
endPointObj.setVehicle_qty(1);
pointService.update(endPointObj);
// 要把数据存到组盘表 -> 改造公共方法,返回id
//todo 涉及一对多、设置物料类型为待分拣冲压件、载具类型
SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
groupEntity.setCreate_id("2");
groupEntity.setCreate_name("ACS");
groupEntity.setCreate_time(DateUtil.now());
// SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
// groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
// groupEntity.setCreate_id("2");
// groupEntity.setCreate_name("ACS");
// groupEntity.setCreate_time(DateUtil.now());
// groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getMaterial_id()
// : "");
@ -178,28 +167,34 @@ public class CYXLTask extends AbstractTask {
// groupEntity.setWorkorder_code(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getWorkorder_code()
// : "");
groupEntity.setVehicle_code(vehicle_code);
groupEntity.setVehicle_type(taskObj.getVehicle_type());
groupEntity.setPoint_code(startPoint);
groupEntity.setPoint_name(startPointObj.getPoint_name());
groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
groupEntity.setInstorage_time(DateUtil.now());
groupEntity.setTask_code(taskObj.getTask_code());
groupEntity.setMove_way(startPoint);
groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
groupEntity.setIs_delete(false);
groupEntity.setMove_way(startPoint);
vehiclematerialgroupService.save(groupEntity);
// groupEntity.setVehicle_code(vehicle_code);
// groupEntity.setVehicle_type(taskObj.getVehicle_type());
// groupEntity.setPoint_code(startPoint);
// groupEntity.setPoint_name(startPointObj.getPoint_name());
// groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
// groupEntity.setInstorage_time(DateUtil.now());
// groupEntity.setTask_code(taskObj.getTask_code());
// groupEntity.setMove_way(startPoint);
// groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
// groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
// groupEntity.setIs_delete(false);
// groupEntity.setMove_way(startPoint);
// vehiclematerialgroupService.save(groupEntity);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(groupEntity.getGroup_id());
// taskObj.setGroup_id(groupEntity.getGroup_id());
taskObj.setRemark("任务完成");
JSONObject jsonObject = new JSONObject();
jsonObject.put("task_code", IdUtil.getSnowflake(1, 1).nextIdStr());
jsonObject.put("taskType", "CYJKTask");
jsonObject.put("next_device_code",taskObj.getPoint_code1());
acsToWmsService.acsApply(jsonObject);
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁
if (ObjectUtil.isNotEmpty(endPointObj)) {
endPointObj.setIng_task_code("");
endPointObj.setVehicle_qty(0);
//任务取消把原先占用的位置释放
pointService.update(endPointObj);
}
@ -228,17 +223,29 @@ public class CYXLTask extends AbstractTask {
agvStateParam.setVehicle_code(schBaseTask.getVehicle_code());
String phase = param.getString("phase");
String iotUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("iot_url").getValue();
SchBasePoint startPoint = pointService.getById(schBaseTask.getPoint_code1());
if ("3".equals(phase)) {
agvStateParam.setStatus("1");
//叉车到位 请求取货
String url = iotUrl + "iot/agvarrive";
applyIot(url, agvStateParam, result);
//锁住起点
startPoint.setIng_task_code(schBaseTask.getTask_code());
pointService.update(startPoint);
}
if ("5".equals(phase)) {
agvStateParam.setStatus("2");
//取货完成,请求离开
String url = iotUrl + "iot/agvfinish";
applyIot(url, agvStateParam, result);
//起点解锁 下发补空托盘任务
startPoint.setIng_task_code("");
pointService.update(startPoint);
JSONObject jsonObject = new JSONObject();
jsonObject.put("task_code", IdUtil.getSnowflake(1, 1).nextIdStr());
jsonObject.put("taskType", "CYJKTask");
jsonObject.put("next_device_code",schBaseTask.getPoint_code1());
acsToWmsService.acsApply(jsonObject);
}
}

86
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJSLTask.java

@ -2,12 +2,17 @@ package org.nl.wms.sch.task_manage.task.tasks.fj;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.service.WmsToAcsService;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.ext.service.dto.to.iot.AgvStateParam;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
@ -28,6 +33,7 @@ import org.nl.wms.util.PointUtils;
import org.nl.wms.util.TaskUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import java.util.Arrays;
@ -96,13 +102,14 @@ public class FJSLTask extends AbstractTask {
}
}
//查找待分拣物料
//查找待分拣物料 todo 需要关联组盘信息去查
private SchBasePoint findStartPoint(String startRegionStr) {
//从待分拣货架查找 物料类型是待分拣物料,物料类型字段尚未确定
String[] reginList = startRegionStr.split(",");
LambdaQueryWrapper<SchBasePoint> lam = new LambdaQueryWrapper<>();
lam.in(SchBasePoint::getRegion_code, Arrays.asList(reginList))
.eq(SchBasePoint::getPoint_status, PointStatusEnum.FULL_POINT.getCode())
.eq(SchBasePoint::getPoint_type,"1")
.and(la -> la.isNull(SchBasePoint::getIng_task_code)
.or()
.eq(SchBasePoint::getIng_task_code, ""))
@ -150,16 +157,16 @@ public class FJSLTask extends AbstractTask {
startPointObj.setUpdate_time(DateUtil.now());
pointService.updateById(startPointObj);
//todo 分拣上料完成后 组盘信息解绑
SchBaseVehiclematerialgroup vehicleMaterialGroupObj = vehiclematerialgroupService.getById(taskObj.getGroup_id());
vehicleMaterialGroupObj.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue());
vehicleMaterialGroupObj.setPoint_code(endPointObj.getPoint_code());
vehicleMaterialGroupObj.setPoint_name(endPointObj.getPoint_name());
vehicleMaterialGroupObj.setTask_code(taskObj.getTask_code());
vehicleMaterialGroupObj.setMove_way(vehicleMaterialGroupObj.getMove_way() + " -> " + endPointObj.getPoint_code());
vehicleMaterialGroupObj.setUpdate_id(GeneralDefinition.ACS_ID);
vehicleMaterialGroupObj.setUpdate_name(GeneralDefinition.ACS_NAME);
vehicleMaterialGroupObj.setUpdate_time(DateUtil.now());
vehiclematerialgroupService.updateById(vehicleMaterialGroupObj);
// SchBaseVehiclematerialgroup vehicleMaterialGroupObj = vehiclematerialgroupService.getById(taskObj.getGroup_id());
// vehicleMaterialGroupObj.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue());
// vehicleMaterialGroupObj.setPoint_code(endPointObj.getPoint_code());
// vehicleMaterialGroupObj.setPoint_name(endPointObj.getPoint_name());
// vehicleMaterialGroupObj.setTask_code(taskObj.getTask_code());
// vehicleMaterialGroupObj.setMove_way(vehicleMaterialGroupObj.getMove_way() + " -> " + endPointObj.getPoint_code());
// vehicleMaterialGroupObj.setUpdate_id(GeneralDefinition.ACS_ID);
// vehicleMaterialGroupObj.setUpdate_name(GeneralDefinition.ACS_NAME);
// vehicleMaterialGroupObj.setUpdate_time(DateUtil.now());
// vehiclematerialgroupService.updateById(vehicleMaterialGroupObj);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setRemark("任务完成");
@ -193,6 +200,61 @@ public class FJSLTask extends AbstractTask {
@Override
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) {
//该场景无需重算等待点
// 反馈上位系统 反馈上位系统成功后,返回200给acs
AgvStateParam agvStateParam = new AgvStateParam();
agvStateParam.setTask_code(schBaseTask.getTask_code());
agvStateParam.setDevice_code(schBaseTask.getPoint_code2());
agvStateParam.setVehicle_code(schBaseTask.getVehicle_code());
String phase = param.getString("phase");
String iotUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("iot_url").getValue();
SchBasePoint endPoint = pointService.getById(schBaseTask.getPoint_code2());
if ("7".equals(phase)) {
//todo 请求放货状态需要修改
agvStateParam.setStatus("3");
//叉车到位 请求放货
String url = iotUrl + "iot/agvarrive";
applyIot(url, agvStateParam, result);
//锁住终点
endPoint.setIng_task_code(schBaseTask.getTask_code());
pointService.update(endPoint);
}
if ("9".equals(phase)) {
//todo 请求放货状态需要修改
agvStateParam.setStatus("4");
//取货完成,请求离开
String url = iotUrl + "iot/agvfinish";
applyIot(url, agvStateParam, result);
//终点解锁 设置载具类型和编码
endPoint.setIng_task_code("");
// endPoint.setVehicle_code(schBaseTask.getVehicle_code());
// endPoint.setVehicle_type(schBaseTask.getVehicle_type());
pointService.update(endPoint);
}
}
private void applyIot(String url, AgvStateParam agvStateParam, BaseResponse result) {
String jsonParam = JSON.toJSONString(agvStateParam);
log.info("请求iot参数为:{}", jsonParam);
try {
String resultMsg = HttpRequest.post(url)
.body(jsonParam)
.execute().body();
JSONObject res = JSONObject.parseObject(resultMsg);
if ("200".equals(res.getString("code"))) {
log.info("请求iot成功,返回结果为:{}", res);
result.setCode(HttpStatus.OK.value());
result.setMessage("请求iot成功!");
} else {
log.error("请求iot失败:{}", res);
result.setCode(HttpStatus.BAD_REQUEST.value());
result.setMessage("请求iot失败!");
}
} catch (Exception e) {
String msg = e.getMessage();
//请求iot失败
log.error("请求iot失败:{}", msg);
result.setCode(HttpStatus.BAD_REQUEST.value());
result.setMessage("请求iot失败!");
}
}
}

104
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/fj/FJXLTask.java

@ -3,12 +3,17 @@ package org.nl.wms.sch.task_manage.task.tasks.fj;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.ext.service.dto.to.iot.AgvStateParam;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
@ -27,6 +32,7 @@ import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.nl.wms.util.PointUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import java.util.Arrays;
@ -129,7 +135,7 @@ public class FJXLTask extends AbstractTask {
// : null;
// }
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = ObjectUtil.isNotEmpty(taskObj.getPoint_code2()) ? taskObj.getPoint_code2().substring(0, taskObj.getPoint_code2().length() - 2) : "0"; // 获取终点
String endPoint = taskObj.getPoint_code2(); // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
@ -144,16 +150,16 @@ public class FJXLTask extends AbstractTask {
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
// endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
endPointObj.setVehicle_qty(1);
pointService.update(endPointObj);
// 要把数据存到组盘表
//todo 组盘一对一还是一对多、设置物料类型为待折弯冲压件、载具类型
SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
groupEntity.setCreate_id("2");
groupEntity.setCreate_name("ACS");
groupEntity.setCreate_time(DateUtil.now());
// SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
// groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
// groupEntity.setCreate_id("2");
// groupEntity.setCreate_name("ACS");
// groupEntity.setCreate_time(DateUtil.now());
// groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getMaterial_id()
// : "");
@ -166,27 +172,22 @@ public class FJXLTask extends AbstractTask {
// groupEntity.setWorkorder_code(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getWorkorder_code()
// : "");
groupEntity.setVehicle_code(vehicle_code);
groupEntity.setVehicle_type(taskObj.getVehicle_type());
groupEntity.setPoint_code(startPoint);
groupEntity.setPoint_name(startPointObj.getPoint_name());
groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
groupEntity.setInstorage_time(DateUtil.now());
groupEntity.setTask_code(taskObj.getTask_code());
groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
groupEntity.setIs_delete(false);
groupEntity.setMove_way(startPoint);
vehiclematerialgroupService.save(groupEntity);
// groupEntity.setVehicle_code(vehicle_code);
// groupEntity.setVehicle_type(taskObj.getVehicle_type());
// groupEntity.setPoint_code(startPoint);
// groupEntity.setPoint_name(startPointObj.getPoint_name());
// groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
// groupEntity.setInstorage_time(DateUtil.now());
// groupEntity.setTask_code(taskObj.getTask_code());
// groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
// groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
// groupEntity.setIs_delete(false);
// groupEntity.setMove_way(startPoint);
// vehiclematerialgroupService.save(groupEntity);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(groupEntity.getGroup_id());
// taskObj.setGroup_id(groupEntity.getGroup_id());
taskObj.setRemark("任务完成");
try {
//todo 入库成功后上报mes
} catch (Exception e) {
log.error("原材料入库上报MES失败{}", e.getMessage(), e);
}
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁
@ -213,6 +214,57 @@ public class FJXLTask extends AbstractTask {
@Override
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) {
//该场景无需重算等待点
// 反馈上位系统 反馈上位系统成功后,返回200给acs
AgvStateParam agvStateParam = new AgvStateParam();
agvStateParam.setTask_code(schBaseTask.getTask_code());
agvStateParam.setDevice_code(schBaseTask.getPoint_code1());
agvStateParam.setVehicle_code(schBaseTask.getVehicle_code());
String phase = param.getString("phase");
String iotUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("iot_url").getValue();
SchBasePoint startPoint = pointService.getById(schBaseTask.getPoint_code1());
if ("3".equals(phase)) {
agvStateParam.setStatus("1");
//叉车到位 请求取货
String url = iotUrl + "iot/agvarrive";
applyIot(url, agvStateParam, result);
//锁住起点
startPoint.setIng_task_code(schBaseTask.getTask_code());
pointService.update(startPoint);
}
if ("5".equals(phase)) {
agvStateParam.setStatus("2");
//取货完成,请求离开
String url = iotUrl + "iot/agvfinish";
applyIot(url, agvStateParam, result);
//起点解锁 下发补空托盘任务
startPoint.setIng_task_code("");
pointService.update(startPoint);
}
}
private void applyIot(String url, AgvStateParam agvStateParam, BaseResponse result) {
String jsonParam = JSON.toJSONString(agvStateParam);
log.info("请求iot参数为:{}", jsonParam);
try {
String resultMsg = HttpRequest.post(url)
.body(jsonParam)
.execute().body();
JSONObject res = JSONObject.parseObject(resultMsg);
if ("200".equals(res.getString("code"))) {
log.info("请求iot成功,返回结果为:{}", res);
result.setCode(HttpStatus.OK.value());
result.setMessage("请求iot成功!");
} else {
log.error("请求iot失败:{}", res);
result.setCode(HttpStatus.BAD_REQUEST.value());
result.setMessage("请求iot失败!");
}
} catch (Exception e) {
String msg = e.getMessage();
//请求iot失败
log.error("请求iot失败:{}", msg);
result.setCode(HttpStatus.BAD_REQUEST.value());
result.setMessage("请求iot失败!");
}
}
}

45
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/lk/LKZYTask.java

@ -130,7 +130,7 @@ public class LKZYTask extends AbstractTask {
// : null;
// }
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = ObjectUtil.isNotEmpty(taskObj.getPoint_code2()) ? taskObj.getPoint_code2().substring(0, taskObj.getPoint_code2().length() - 2) : "0"; // 获取终点
String endPoint = taskObj.getPoint_code2(); // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
@ -145,16 +145,16 @@ public class LKZYTask extends AbstractTask {
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
endPointObj.setVehicle_code(endPointObj.getVehicle_code());
endPointObj.setVehicle_qty(1);
pointService.update(endPointObj);
// 要把数据存到组盘表
//todo 组盘信息
SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
groupEntity.setCreate_id("2");
groupEntity.setCreate_name("ACS");
groupEntity.setCreate_time(DateUtil.now());
// SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
// groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
// groupEntity.setCreate_id("2");
// groupEntity.setCreate_name("ACS");
// groupEntity.setCreate_time(DateUtil.now());
// groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getMaterial_id()
// : "");
@ -167,27 +167,22 @@ public class LKZYTask extends AbstractTask {
// groupEntity.setWorkorder_code(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getWorkorder_code()
// : "");
groupEntity.setVehicle_code(vehicle_code);
groupEntity.setVehicle_type(taskObj.getVehicle_type());
groupEntity.setPoint_code(startPoint);
groupEntity.setPoint_name(startPointObj.getPoint_name());
groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
groupEntity.setInstorage_time(DateUtil.now());
groupEntity.setTask_code(taskObj.getTask_code());
groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
groupEntity.setIs_delete(false);
groupEntity.setMove_way(startPoint);
vehiclematerialgroupService.save(groupEntity);
// groupEntity.setVehicle_code(vehicle_code);
// groupEntity.setVehicle_type(taskObj.getVehicle_type());
// groupEntity.setPoint_code(startPoint);
// groupEntity.setPoint_name(startPointObj.getPoint_name());
// groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
// groupEntity.setInstorage_time(DateUtil.now());
// groupEntity.setTask_code(taskObj.getTask_code());
// groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
// groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
// groupEntity.setIs_delete(false);
// groupEntity.setMove_way(startPoint);
// vehiclematerialgroupService.save(groupEntity);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(groupEntity.getGroup_id());
// taskObj.setGroup_id(groupEntity.getGroup_id());
taskObj.setRemark("任务完成");
try {
//todo 入库成功后上报mes
} catch (Exception e) {
log.error("原材料入库上报MES失败{}", e.getMessage(), e);
}
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁

3
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/qg/QGJKTask.java

@ -18,6 +18,7 @@ import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task_manage.AbstractTask;
import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.enums.PointStatusEnum;
import org.nl.wms.sch.task_manage.task.TaskType;
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper;
@ -92,8 +93,10 @@ public class QGJKTask extends AbstractTask {
//查找空托盘
private SchBasePoint findStartPoint(String startRegionStr) {
//TODO 载具类型
LambdaQueryWrapper<SchBasePoint> lam = new LambdaQueryWrapper<>();
lam.in(SchBasePoint::getRegion_code, startRegionStr)
.eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_VEHICLE.getCode())
.and(la -> la.isNull(SchBasePoint::getIng_task_code)
.or()
.eq(SchBasePoint::getIng_task_code, ""))

62
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/qg/QGXLTask.java

@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.nl.common.exception.BadRequestException;
import org.nl.wms.ext.service.AcsToWmsService;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
@ -57,7 +58,8 @@ public class QGXLTask extends AbstractTask {
private IPdmBdWorkorderService workorderService;
@Autowired
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
@Autowired
private AcsToWmsService acsToWmsService;
@Override
protected void create() throws BadRequestException {
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY);
@ -100,13 +102,7 @@ public class QGXLTask extends AbstractTask {
.orderByAsc(SchBasePoint::getIn_order_seq)
.orderByAsc(SchBasePoint::getPoint_code);
List<SchBasePoint> schBasePoints = pointService.list(lam);
for (SchBasePoint schBasePoint : schBasePoints) {
if (StringUtils.isEmpty(schBasePoint.getIng_task_code()) && schBasePoint.getVehicle_qty() == 0) {
log.info("冲压下料入库找到当前符合条件的点位{}", schBasePoint.getPoint_code());
return schBasePoint;
}
}
return null;
return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null;
}
@Override
@ -136,7 +132,7 @@ public class QGXLTask extends AbstractTask {
// : null;
// }
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = ObjectUtil.isNotEmpty(taskObj.getPoint_code2()) ? taskObj.getPoint_code2().substring(0, taskObj.getPoint_code2().length() - 2) : "0"; // 获取终点
String endPoint = taskObj.getPoint_code2(); // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
@ -151,16 +147,16 @@ public class QGXLTask extends AbstractTask {
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
// endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
endPointObj.setVehicle_qty(1);
pointService.update(endPointObj);
// 要把数据存到组盘表 -> 改造公共方法,返回id
//todo 组盘表需要关联外部mes晶棒数据,一对多
SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
groupEntity.setCreate_id("2");
groupEntity.setCreate_name("ACS");
groupEntity.setCreate_time(DateUtil.now());
// SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
// groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
// groupEntity.setCreate_id("2");
// groupEntity.setCreate_name("ACS");
// groupEntity.setCreate_time(DateUtil.now());
// groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getMaterial_id()
// : "");
@ -173,27 +169,27 @@ public class QGXLTask extends AbstractTask {
// groupEntity.setWorkorder_code(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getWorkorder_code()
// : "");
groupEntity.setVehicle_code(vehicle_code);
groupEntity.setVehicle_type(taskObj.getVehicle_type());
groupEntity.setPoint_code(startPoint);
groupEntity.setPoint_name(startPointObj.getPoint_name());
groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
groupEntity.setInstorage_time(DateUtil.now());
groupEntity.setTask_code(taskObj.getTask_code());
groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
groupEntity.setIs_delete(false);
groupEntity.setMove_way(startPoint);
vehiclematerialgroupService.save(groupEntity);
// groupEntity.setVehicle_code(vehicle_code);
// groupEntity.setVehicle_type(taskObj.getVehicle_type());
// groupEntity.setPoint_code(startPoint);
// groupEntity.setPoint_name(startPointObj.getPoint_name());
// groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
// groupEntity.setInstorage_time(DateUtil.now());
// groupEntity.setTask_code(taskObj.getTask_code());
// groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
// groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
// groupEntity.setIs_delete(false);
// groupEntity.setMove_way(startPoint);
// vehiclematerialgroupService.save(groupEntity);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(groupEntity.getGroup_id());
// taskObj.setGroup_id(groupEntity.getGroup_id());
taskObj.setRemark("任务完成");
try {
//todo 入库成功后上报mes
} catch (Exception e) {
log.error("原材料入库上报MES失败{}", e.getMessage(), e);
}
JSONObject jsonObject = new JSONObject();
jsonObject.put("task_code", IdUtil.getSnowflake(1, 1).nextIdStr());
jsonObject.put("taskType", "QGJKTask");
jsonObject.put("next_device_code",taskObj.getPoint_code1());
acsToWmsService.acsApply(jsonObject);
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁

47
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/qt/QTSLTask.java

@ -88,7 +88,7 @@ public class QTSLTask extends AbstractTask {
* @return
*/
private SchBasePoint findNextPoint(String nextReginStr) {
//分配空库位
//todo 分配空库位 对应载具
String[] reginList = nextReginStr.split(",");
LambdaQueryWrapper<SchBasePoint> lam = new LambdaQueryWrapper<>();
lam.in(SchBasePoint::getRegion_code, Arrays.asList(reginList))
@ -130,7 +130,7 @@ public class QTSLTask extends AbstractTask {
// : null;
// }
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = ObjectUtil.isNotEmpty(taskObj.getPoint_code2()) ? taskObj.getPoint_code2().substring(0, taskObj.getPoint_code2().length() - 2) : "0"; // 获取终点
String endPoint = taskObj.getPoint_code2(); // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
@ -145,16 +145,16 @@ public class QTSLTask extends AbstractTask {
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
// endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
endPointObj.setVehicle_qty(1);
pointService.update(endPointObj);
// 要把数据存到组盘表
//todo 组盘信息
SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
groupEntity.setCreate_id("2");
groupEntity.setCreate_name("ACS");
groupEntity.setCreate_time(DateUtil.now());
// SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
// groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
// groupEntity.setCreate_id("2");
// groupEntity.setCreate_name("ACS");
// groupEntity.setCreate_time(DateUtil.now());
// groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getMaterial_id()
// : "");
@ -167,27 +167,22 @@ public class QTSLTask extends AbstractTask {
// groupEntity.setWorkorder_code(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getWorkorder_code()
// : "");
groupEntity.setVehicle_code(vehicle_code);
groupEntity.setVehicle_type(taskObj.getVehicle_type());
groupEntity.setPoint_code(startPoint);
groupEntity.setPoint_name(startPointObj.getPoint_name());
groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
groupEntity.setInstorage_time(DateUtil.now());
groupEntity.setTask_code(taskObj.getTask_code());
groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
groupEntity.setIs_delete(false);
groupEntity.setMove_way(startPoint);
vehiclematerialgroupService.save(groupEntity);
// groupEntity.setVehicle_code(vehicle_code);
// groupEntity.setVehicle_type(taskObj.getVehicle_type());
// groupEntity.setPoint_code(startPoint);
// groupEntity.setPoint_name(startPointObj.getPoint_name());
// groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
// groupEntity.setInstorage_time(DateUtil.now());
// groupEntity.setTask_code(taskObj.getTask_code());
// groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
// groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
// groupEntity.setIs_delete(false);
// groupEntity.setMove_way(startPoint);
// vehiclematerialgroupService.save(groupEntity);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(groupEntity.getGroup_id());
// taskObj.setGroup_id(groupEntity.getGroup_id());
taskObj.setRemark("任务完成");
try {
//todo 入库成功后上报mes
} catch (Exception e) {
log.error("原材料入库上报MES失败{}", e.getMessage(), e);
}
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁

133
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/zw/ZWJKTask.java

@ -3,14 +3,19 @@ package org.nl.wms.sch.task_manage.task.tasks.zw;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import freemarker.template.utility.StringUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.service.AcsToWmsService;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.ext.service.dto.to.iot.AgvStateParam;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.pdm.service.dao.PdmBdWorkorder;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
@ -31,6 +36,7 @@ import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper;
import org.nl.wms.util.PointUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
@ -70,16 +76,16 @@ public class ZWJKTask extends AbstractTask {
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>()
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE));
for (SchBaseTask task : tasks) {
SchBasePoint point = findNextPoint(taskConfig.getNext_region_str());
SchBasePoint point = findStartPoint(taskConfig.getStart_region_str());
if (ObjectUtil.isEmpty(point)) {
task.setRemark("未找到所需点位!");
taskService.update(task);
log.info("折弯叫空未找到当前符合条件的点位!");
continue;
}
task.setPoint_code2(point.getPoint_code());
task.setPoint_code1(point.getPoint_code());
task.setTask_status(TaskStatus.CREATED.getCode());
task.setRemark("");
task.setRemark("创建完成");
taskService.update(task);
//发起任务时先把点位占用,防止发起重复任务
point.setIng_task_code(task.getTask_code());
@ -93,12 +99,13 @@ public class ZWJKTask extends AbstractTask {
*
* @return
*/
private SchBasePoint findNextPoint(String nextReginStr) {
//todo 判断所需载具类型
private SchBasePoint findStartPoint(String nextReginStr) {
//todo 判断所需载具类型 暂定料框
String[] reginList = nextReginStr.split(",");
LambdaQueryWrapper<SchBasePoint> lam = new LambdaQueryWrapper<>();
lam.in(SchBasePoint::getRegion_code, Arrays.asList(reginList))
.eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_POINT.getCode())
.eq(SchBasePoint::getPoint_status, PointStatusEnum.EMPTY_VEHICLE.getCode())
.eq(SchBasePoint::getPoint_type,"2")
.and(la -> la.isNull(SchBasePoint::getIng_task_code) // 当前执行的任务为空或者NULL,有数据表示锁住
.or()
.eq(SchBasePoint::getIng_task_code, ""))
@ -106,13 +113,7 @@ public class ZWJKTask extends AbstractTask {
.orderByAsc(SchBasePoint::getIn_order_seq)
.orderByAsc(SchBasePoint::getPoint_code);
List<SchBasePoint> schBasePoints = pointService.list(lam);
for (SchBasePoint schBasePoint : schBasePoints) {
if (StringUtils.isEmpty(schBasePoint.getIng_task_code()) && schBasePoint.getVehicle_qty() == 0) {
log.info("折弯叫空找到当前符合条件的点位{}", schBasePoint.getPoint_code());
return schBasePoint;
}
}
return null;
return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null;
}
@Override
@ -142,7 +143,7 @@ public class ZWJKTask extends AbstractTask {
// : null;
// }
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = ObjectUtil.isNotEmpty(taskObj.getPoint_code2()) ? taskObj.getPoint_code2().substring(0, taskObj.getPoint_code2().length() - 2) : "0"; // 获取终点
String endPoint = taskObj.getPoint_code2(); // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
@ -157,16 +158,16 @@ public class ZWJKTask extends AbstractTask {
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
endPointObj.setVehicle_code(endPointObj.getVehicle_code());
endPointObj.setVehicle_qty(1);
pointService.update(endPointObj);
// 要把数据存到组盘表 -> 改造公共方法,返回id
//todo 组盘表需要关联外部mes晶棒数据,一对多
SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
groupEntity.setCreate_id("2");
groupEntity.setCreate_name("ACS");
groupEntity.setCreate_time(DateUtil.now());
// SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
// groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
// groupEntity.setCreate_id("2");
// groupEntity.setCreate_name("ACS");
// groupEntity.setCreate_time(DateUtil.now());
// groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getMaterial_id()
// : "");
@ -179,27 +180,22 @@ public class ZWJKTask extends AbstractTask {
// groupEntity.setWorkorder_code(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getWorkorder_code()
// : "");
groupEntity.setVehicle_code(vehicle_code);
groupEntity.setVehicle_type(taskObj.getVehicle_type());
groupEntity.setPoint_code(startPoint);
groupEntity.setPoint_name(startPointObj.getPoint_name());
groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
groupEntity.setInstorage_time(DateUtil.now());
groupEntity.setTask_code(taskObj.getTask_code());
groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
groupEntity.setIs_delete(false);
groupEntity.setMove_way(startPoint);
vehiclematerialgroupService.save(groupEntity);
// groupEntity.setVehicle_code(vehicle_code);
// groupEntity.setVehicle_type(taskObj.getVehicle_type());
// groupEntity.setPoint_code(startPoint);
// groupEntity.setPoint_name(startPointObj.getPoint_name());
// groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
// groupEntity.setInstorage_time(DateUtil.now());
// groupEntity.setTask_code(taskObj.getTask_code());
// groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
// groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
// groupEntity.setIs_delete(false);
// groupEntity.setMove_way(startPoint);
// vehiclematerialgroupService.save(groupEntity);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(groupEntity.getGroup_id());
// taskObj.setGroup_id(groupEntity.getGroup_id());
taskObj.setRemark("任务完成");
try {
//todo 入库成功后上报mes
} catch (Exception e) {
log.error("原材料入库上报MES失败{}", e.getMessage(), e);
}
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁
@ -226,6 +222,65 @@ public class ZWJKTask extends AbstractTask {
@Override
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) {
//该场景无需重算等待点
SchBasePoint endPoint = pointService.getById(schBaseTask.getPoint_code1());
//如果下料位不是自动折弯区,不需要反馈上位系统 暂定
if (!"ZDZWQ".equals(endPoint.getRegion_code())) {
return;
}
// 反馈上位系统 反馈上位系统成功后,返回200给acs
AgvStateParam agvStateParam = new AgvStateParam();
agvStateParam.setTask_code(schBaseTask.getTask_code());
agvStateParam.setDevice_code(schBaseTask.getPoint_code2());
agvStateParam.setVehicle_code(schBaseTask.getVehicle_code());
String phase = param.getString("phase");
String iotUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("iot_url").getValue();
if ("7".equals(phase)) {
//todo 请求放货状态需要修改
agvStateParam.setStatus("3");
//叉车到位 请求放货
String url = iotUrl + "iot/agvarrive";
applyIot(url, agvStateParam, result);
//锁住终点
endPoint.setIng_task_code(schBaseTask.getTask_code());
pointService.update(endPoint);
}
if ("9".equals(phase)) {
//todo 请求放货状态需要修改
agvStateParam.setStatus("4");
//取货完成,请求离开
String url = iotUrl + "iot/agvfinish";
applyIot(url, agvStateParam, result);
//终点解锁 设置载具类型和编码
endPoint.setIng_task_code("");
// endPoint.setVehicle_code(schBaseTask.getVehicle_code());
// endPoint.setVehicle_type(schBaseTask.getVehicle_type());
pointService.update(endPoint);
}
}
private void applyIot(String url, AgvStateParam agvStateParam, BaseResponse result) {
String jsonParam = JSON.toJSONString(agvStateParam);
log.info("请求iot参数为:{}", jsonParam);
try {
String resultMsg = HttpRequest.post(url)
.body(jsonParam)
.execute().body();
JSONObject res = JSONObject.parseObject(resultMsg);
if ("200".equals(res.getString("code"))) {
log.info("请求iot成功,返回结果为:{}", res);
result.setCode(HttpStatus.OK.value());
result.setMessage("请求iot成功!");
} else {
log.error("请求iot失败:{}", res);
result.setCode(HttpStatus.BAD_REQUEST.value());
result.setMessage("请求iot失败!");
}
} catch (Exception e) {
String msg = e.getMessage();
//请求iot失败
log.error("请求iot失败:{}", msg);
result.setCode(HttpStatus.BAD_REQUEST.value());
result.setMessage("请求iot失败!");
}
}
}

3
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/zw/ZWSLTask.java

@ -18,6 +18,7 @@ import org.nl.wms.sch.task.service.dao.SchBaseTask;
import org.nl.wms.sch.task.service.dao.SchBaseTaskconfig;
import org.nl.wms.sch.task_manage.AbstractTask;
import org.nl.wms.sch.task_manage.GeneralDefinition;
import org.nl.wms.sch.task_manage.enums.PointStatusEnum;
import org.nl.wms.sch.task_manage.task.TaskType;
import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.nl.wms.sch.task_manage.task.tasks.mapper.PointMapper;
@ -96,6 +97,8 @@ public class ZWSLTask extends AbstractTask {
List<String> regions = Arrays.asList(reginList);
LambdaQueryWrapper<SchBasePoint> lam = new LambdaQueryWrapper<>();
lam.in(SchBasePoint::getRegion_code, regions)
.eq(SchBasePoint::getPoint_status, PointStatusEnum.FULL_POINT.getCode())
.eq(SchBasePoint::getPoint_type,"1")
.and(la -> la.isNull(SchBasePoint::getIng_task_code)
.or()
.eq(SchBasePoint::getIng_task_code, ""))

129
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/zw/ZWXLTask.java

@ -3,17 +3,24 @@ package org.nl.wms.sch.task_manage.task.tasks.zw;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder;
import org.nl.system.service.param.impl.SysParamServiceImpl;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.ext.service.dto.to.iot.AgvStateParam;
import org.nl.wms.pdm.service.IPdmBdWorkorderService;
import org.nl.wms.sch.group.service.ISchBaseVehiclematerialgroupService;
import org.nl.wms.sch.group.service.dao.SchBaseVehiclematerialgroup;
import org.nl.wms.sch.point.service.ISchBasePointService;
import org.nl.wms.sch.point.service.dao.SchBasePoint;
import org.nl.wms.sch.region.service.ISchBaseRegionService;
import org.nl.wms.sch.task.service.ISchBaseTaskService;
import org.nl.wms.sch.task.service.ISchBaseTaskconfigService;
import org.nl.wms.sch.task.service.dao.SchBaseTask;
@ -27,6 +34,7 @@ import org.nl.wms.sch.task_manage.task.core.TaskStatus;
import org.nl.wms.util.PointUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;
import java.util.Arrays;
@ -57,6 +65,8 @@ public class ZWXLTask extends AbstractTask {
private IPdmBdWorkorderService workorderService;
@Autowired
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
@Autowired
private ISchBaseRegionService schBaseRegionService;
@Override
protected void create() throws BadRequestException {
@ -88,7 +98,7 @@ public class ZWXLTask extends AbstractTask {
* @return
*/
private SchBasePoint findNextPoint(String nextReginStr) {
//todo 外协加工需要加上pointtype
String[] reginList = nextReginStr.split(",");
LambdaQueryWrapper<SchBasePoint> lam = new LambdaQueryWrapper<>();
lam.in(SchBasePoint::getRegion_code, Arrays.asList(reginList))
@ -100,13 +110,7 @@ public class ZWXLTask extends AbstractTask {
.orderByAsc(SchBasePoint::getIn_order_seq)
.orderByAsc(SchBasePoint::getPoint_code);
List<SchBasePoint> schBasePoints = pointService.list(lam);
for (SchBasePoint schBasePoint : schBasePoints) {
if (StringUtils.isEmpty(schBasePoint.getIng_task_code()) && schBasePoint.getVehicle_qty() == 0) {
log.info("折弯下料入库找到当前符合条件的点位{}", schBasePoint.getPoint_code());
return schBasePoint;
}
}
return null;
return ObjectUtil.isNotEmpty(schBasePoints) ? schBasePoints.get(0) : null;
}
@Override
@ -136,7 +140,7 @@ public class ZWXLTask extends AbstractTask {
// : null;
// }
String startPoint = taskObj.getPoint_code1(); // 获取起点
String endPoint = ObjectUtil.isNotEmpty(taskObj.getPoint_code2()) ? taskObj.getPoint_code2().substring(0, taskObj.getPoint_code2().length() - 2) : "0"; // 获取终点
String endPoint = taskObj.getPoint_code2(); // 获取终点
SchBasePoint startPointObj = pointService.getById(startPoint);
SchBasePoint endPointObj = pointService.getById(endPoint);
// 根据传来的类型去对任务进行操作
@ -151,16 +155,16 @@ public class ZWXLTask extends AbstractTask {
}
// 终点解锁
endPointObj.setIng_task_code("");
endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
// endPointObj.setVehicle_code(ObjectUtil.isEmpty(endPointObj.getVehicle_code()) ? vehicle_code + "," : endPointObj.getVehicle_code() + vehicle_code + ",");
endPointObj.setVehicle_qty(1);
pointService.update(endPointObj);
// 要把数据存到组盘表 -> 改造公共方法,返回id
//todo 组盘信息修改
SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
groupEntity.setCreate_id("2");
groupEntity.setCreate_name("ACS");
groupEntity.setCreate_time(DateUtil.now());
// SchBaseVehiclematerialgroup groupEntity = new SchBaseVehiclematerialgroup();
// groupEntity.setGroup_id(IdUtil.getSnowflake(1, 1).nextIdStr());
// groupEntity.setCreate_id("2");
// groupEntity.setCreate_name("ACS");
// groupEntity.setCreate_time(DateUtil.now());
// groupEntity.setMaterial_id(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getMaterial_id()
// : "");
@ -173,27 +177,27 @@ public class ZWXLTask extends AbstractTask {
// groupEntity.setWorkorder_code(ObjectUtil.isNotEmpty(workorderCode)
// ? workorderCode.getWorkorder_code()
// : "");
groupEntity.setVehicle_code(vehicle_code);
groupEntity.setVehicle_type(taskObj.getVehicle_type());
groupEntity.setPoint_code(startPoint);
groupEntity.setPoint_name(startPointObj.getPoint_name());
groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
groupEntity.setInstorage_time(DateUtil.now());
groupEntity.setTask_code(taskObj.getTask_code());
groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
groupEntity.setIs_delete(false);
groupEntity.setMove_way(startPoint);
vehiclematerialgroupService.save(groupEntity);
// groupEntity.setVehicle_code(vehicle_code);
// groupEntity.setVehicle_type(taskObj.getVehicle_type());
// groupEntity.setPoint_code(startPoint);
// groupEntity.setPoint_name(startPointObj.getPoint_name());
// groupEntity.setPcsn(DateUtil.format(DateUtil.date(), "yyyyMMdd"));
// groupEntity.setInstorage_time(DateUtil.now());
// groupEntity.setTask_code(taskObj.getTask_code());
// groupEntity.setGroup_bind_material_status(GroupBindMaterialStatusEnum.BOUND.getValue()); // 绑定
// groupEntity.setGroup_status(GroupStatusEnum.IN_STORAGE.getType()); // 暂时不维护。
// groupEntity.setIs_delete(false);
// groupEntity.setMove_way(startPoint);
// vehiclematerialgroupService.save(groupEntity);
// 任务完成
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskObj.setGroup_id(groupEntity.getGroup_id());
// taskObj.setGroup_id(groupEntity.getGroup_id());
taskObj.setRemark("任务完成");
try {
//todo 入库成功后上报mes
} catch (Exception e) {
log.error("原材料入库上报MES失败{}", e.getMessage(), e);
}
// try {
// //todo 入库成功后上报mes
// } catch (Exception e) {
// log.error("原材料入库上报MES失败{}", e.getMessage(), e);
// }
}
if (status.equals(TaskStatus.CANCELED)) { // 取消
// 终点解锁
@ -220,6 +224,63 @@ public class ZWXLTask extends AbstractTask {
@Override
protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) {
//该场景无需重算等待点
SchBasePoint startPoint = pointService.getById(schBaseTask.getPoint_code1());
//如果下料位不是自动折弯区,不需要反馈上位系统 暂定
if (!"ZDZWQ".equals(startPoint.getRegion_code())) {
return;
}
// 反馈上位系统 反馈上位系统成功后,返回200给acs
AgvStateParam agvStateParam = new AgvStateParam();
agvStateParam.setTask_code(schBaseTask.getTask_code());
agvStateParam.setDevice_code(schBaseTask.getPoint_code1());
agvStateParam.setVehicle_code(schBaseTask.getVehicle_code());
String phase = param.getString("phase");
String iotUrl = SpringContextHolder.getBean(SysParamServiceImpl.class).findByCode("iot_url").getValue();
if ("3".equals(phase)) {
agvStateParam.setStatus("1");
//叉车到位 请求取货
String url = iotUrl + "iot/agvarrive";
applyIot(url, agvStateParam, result);
//锁住起点
startPoint.setIng_task_code(schBaseTask.getTask_code());
pointService.update(startPoint);
}
if ("5".equals(phase)) {
agvStateParam.setStatus("2");
//取货完成,请求离开
String url = iotUrl + "iot/agvfinish";
applyIot(url, agvStateParam, result);
//起点解锁 下发补空托盘任务
startPoint.setIng_task_code("");
pointService.update(startPoint);
}
}
private void applyIot(String url, AgvStateParam agvStateParam, BaseResponse result) {
String jsonParam = JSON.toJSONString(agvStateParam);
log.info("请求iot参数为:{}", jsonParam);
try {
String resultMsg = HttpRequest.post(url)
.body(jsonParam)
.execute().body();
JSONObject res = JSONObject.parseObject(resultMsg);
if ("200".equals(res.getString("code"))) {
log.info("请求iot成功,返回结果为:{}", res);
result.setCode(HttpStatus.OK.value());
result.setMessage("请求iot成功!");
} else {
log.error("请求iot失败:{}", res);
result.setCode(HttpStatus.BAD_REQUEST.value());
result.setMessage("请求iot失败!");
}
} catch (Exception e) {
String msg = e.getMessage();
//请求iot失败
log.error("请求iot失败:{}", msg);
result.setCode(HttpStatus.BAD_REQUEST.value());
result.setMessage("请求iot失败!");
}
}
}

Loading…
Cancel
Save