diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/cw_site/CwSiteDeviceDriver.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/cw_site/CwSiteDeviceDriver.java index 3cd8b20..e9b7682 100644 --- a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/cw_site/CwSiteDeviceDriver.java +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/cw_site/CwSiteDeviceDriver.java @@ -176,6 +176,14 @@ public class CwSiteDeviceDriver extends AbstractOpcDeviceDriver implements Devic request.setType("2"); acsToWmsService.notify(request); resultSucess=true; + }else if(move ==0 && this.getDeviceCode().startsWith("HCQ06") &&!resultSucess){ + //点位数量变更后通知lms + FeedBackTaskStatusRequest request = new FeedBackTaskStatusRequest(); + request.setState("0"); + request.setDevice_code(this.getDeviceCode()); + request.setType("3"); + acsToWmsService.notify(request); + resultSucess=true; } if (error != last_error) { } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java index 4c52dde..ac5bc4a 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/service/impl/AcsToWmsServiceImpl.java @@ -179,6 +179,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService { device_code=device_code.substring(0,device_code.length()-2); pointMapper.updatePointVehicleQty(device_code,state); break; + case 3: + //正极板空架缓存区人工搬走后显示更新无货 + pointMapper.updatePointVehicleQty(device_code,state); + break; default: break; } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ZJBKGHJRKTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ZJBKGHJRKTask.java new file mode 100644 index 0000000..0f20b4c --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ZJBKGHJRKTask.java @@ -0,0 +1,216 @@ +package org.nl.wms.sch.task_manage.task.tasks; + +import cn.hutool.core.date.DateUtil; +import cn.hutool.core.lang.Assert; +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.nl.wms.util.PointUtils; +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: 2024/1/31 + */ +@Slf4j +@Component +@TaskType("ZJBKGHJRKTask") +@Lazy +public class ZJBKGHJRKTask extends AbstractTask { + private static String TASK_CONFIG_CODE = "ZJBKGHJRKTask"; + /** + * 入口 + */ + 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; + + /** + * 正极板空固化架入库任务,检测到正极板空固化架对接位堆满三层, + * 则自动生成到HCQ06正极板空固化架缓存区的任务 + */ + @Override +// @Transactional(rollbackFor = Exception.class) + protected void create() throws BadRequestException { + List schBasePointList = pointMapper.findPointByRegion2("ZJBKGHJDJW"); + for (SchBasePoint schBasePoint : schBasePointList) { + if (schBasePoint.getVehicle_qty() == 3 && ObjectUtil.isEmpty(schBasePoint.getIng_task_code())) { + log.info("正极板空固化架对接位{}已经放满,开始进行后续判断", schBasePoint.getPoint_code()); + List nextPointList = pointMapper.findPointByRegion2("HCQ6"); + for(SchBasePoint nextPoint : nextPointList){ + if(ObjectUtil.isEmpty(nextPoint.getIng_task_code())&&nextPoint.getVehicle_qty()==0){ + //生成任务并下发 + log.info("找到目标点{}",nextPoint.getPoint_code()); + this.createTask(schBasePoint, nextPoint.getPoint_code()); + } + } + } + } + } + + /** + * 创建任务并下发 + * + * @param schBasePoint + * @param endPoint + * @return + */ + private void createTask(SchBasePoint schBasePoint, String endPoint) { + // 申请任务 + SchBaseTask task = new SchBaseTask(); // 任务实体 + String apply_point_code = schBasePoint.getPoint_code(); // 请求点 + String config_code = "ZJBKGHJRKTask"; + // 1、校验数据 + SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper() + .eq(SchBaseTaskconfig::getConfig_code, config_code)); + Assert.notNull(taskConfig, "找不到配置文件,请确认[" + config_code + "]配置是否存在!"); + // 最大任务数 + Integer tcmn = taskConfig.getTask_create_max_num(); + // 获取执行中的任务 + List unFinishTasksByTaskConfig = taskService.findUnFinishTasksByTaskConfig( + taskConfig.getConfig_code(), apply_point_code , taskConfig.getTask_direction()); + + Assert.isFalse(unFinishTasksByTaskConfig.size() >= tcmn, + "该点位申请的任务未完成数已超过上限,无法申请任务"); + // 获取对接位点位对象 + SchBasePoint pointObj = pointService.getOne(new LambdaQueryWrapper() + .eq(SchBasePoint::getPoint_code, apply_point_code)); + // 校验是否需要自动agv + if (!pointObj.getIs_auto()) { + // 如果不需要自动,则不创建任务 + return; + } + // 2、创建申请任务 + task.setConfig_code(config_code); + task.setCreate_mode(GeneralDefinition.ACS_CREATION); + task.setVehicle_code(schBasePoint.getVehicle_code()); + task.setVehicle_qty(schBasePoint.getVehicle_qty()); + task.setTask_status(TaskStatus.APPLY.getCode()); + task.setWorkshop_code(taskConfig.getWorkshop_code()); // 车间编码 + task.setPoint_code1(apply_point_code); + task.setTask_type("2"); + task.setPoint_code2(endPoint); + task.setTask_status(TaskStatus.CREATED.getCode()); + task.setRemark(""); + // 设置起/终点 +// this.setTaskPoint(taskConfig, task, apply_point_code); + taskService.create(task); + + //下发 + this.renotifyAcs(task); + } + + /** + * 修改任务状态 + * 1.任务完成时,无需再次组盘,将点位表起点货位三个组盘信息移动到终点 + * 2.组盘表中三个点位增加移动动作,并且修改当前点位到目标地点 + * 3. + * + * @param task_code + * @param status + * @return + */ + @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().substring(0, taskObj.getPoint_code1().length() - 2); // 获取起点 + 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)) { // 完成 + StringBuilder group_id = new StringBuilder(); + // 终点解锁 + endPointObj.setIng_task_code(""); + endPointObj.setVehicle_type(startPointObj.getVehicle_type()); + endPointObj.setVehicle_code(startPointObj.getVehicle_code()); + endPointObj.setVehicle_qty(startPointObj.getVehicle_qty()); + endPointObj.setUpdate_time(DateUtil.now()); + pointService.update(endPointObj); + // 起点清空 + if (ObjectUtil.isNotEmpty(startPointObj)) { + PointUtils.clearPoint(startPointObj); + } + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setGroup_id(group_id.toString()); + taskObj.setRemark("任务完成"); + } + 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) { + //无需重算最优点 + } +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSFMTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSFMTask.java index 8cb1287..aeacd52 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSFMTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/ghs/GHSFMTask.java @@ -289,6 +289,6 @@ public class GHSFMTask extends AbstractTask { @Override protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) { - //todo 重算最优点 + //无需重算最优点 } } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.java index fe5b8e1..2d81432 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.java @@ -13,6 +13,8 @@ import java.util.List; public interface PointMapper { List findPointByRegion(String regionCode,String point_status); + List findPointByRegion2(String regionCode); + List findPointByParentPoint(String pointCode); void updatePointStatus(String device_code,String state); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.xml b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.xml index 979d1c9..445e3ec 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.xml +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.xml @@ -11,6 +11,16 @@ ORDER BY region_code + +