diff --git a/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/AutoCleanFile.java b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/AutoCleanFile.java new file mode 100644 index 0000000..a76b77a --- /dev/null +++ b/acs/nladmin-system/nlsso-server/src/main/java/org/nl/quartz/task/AutoCleanFile.java @@ -0,0 +1,71 @@ +package org.nl.quartz.task; + +import cn.hutool.core.util.ObjectUtil; +import lombok.SneakyThrows; +import lombok.extern.slf4j.Slf4j; +import org.nl.config.SpringContextHolder; +import org.nl.system.service.param.dao.Param; +import org.nl.system.service.param.impl.SysParamServiceImpl; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.context.annotation.Profile; +import org.springframework.stereotype.Component; + +import java.io.File; +import java.util.concurrent.TimeUnit; + +/** + * @author LENOVO + * 定时清理日志文件 + */ +@Slf4j +@Component +@Profile("prod") +public class AutoCleanFile { + + private static long DAYS_TO_MILLIS = TimeUnit.DAYS.toMillis(14); + + @Value("${logging.file.path}") + private String logPath; + + @SneakyThrows + public void run() { + log.info("定时清理日志文件AutoCleanFile开始:"); + File directory = new File(logPath); + if (directory.exists() && directory.isDirectory()) { + cleanDirectory(directory); + } else { + System.out.println("指定的路径不存在或不是一个目录。"); + } + } + + // 递归清理文件夹内的过期文件 + private static void cleanDirectory(File directory) { + File[] files = directory.listFiles(); + if (files != null) { + long currentTime = System.currentTimeMillis(); + for (File file : files) { + if (file.isDirectory()) { + // 如果是目录,递归调用 + cleanDirectory(file); + } else if (file.isFile()) { + SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class); + Param byCode = sysParamService.findByCode("log_time"); + if (ObjectUtil.isNotNull(byCode)) { + DAYS_TO_MILLIS = TimeUnit.DAYS.toMillis(Long.parseLong(byCode.getValue())); + } + if (currentTime - file.lastModified() > DAYS_TO_MILLIS) { + boolean deleted = file.delete(); + if (deleted) { + log.info("已删除文件: " + file.getAbsolutePath()); + } else { + log.info("无法删除文件: " + file.getAbsolutePath()); + } + } else { + log.info("文件未超过七天, 不做任何修改: " + file.getAbsolutePath()); + } + } + } + } + } + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/service/impl/HandheldServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/service/impl/HandheldServiceImpl.java index ca38106..7b8e9a5 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/service/impl/HandheldServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/service/impl/HandheldServiceImpl.java @@ -87,6 +87,7 @@ public class HandheldServiceImpl implements HandheldService { semiAutomaticBending(vehicle, device_code, param); break; case "3": + interiorAisle(vehicle, device_code, param); break; default: break; @@ -94,6 +95,31 @@ public class HandheldServiceImpl implements HandheldService { } + /** + * 内部过道送托盘 + * @param vehicle + * @param device_code + * @param param + */ + private void interiorAisle(String vehicle, String device_code, JSONObject param) { + MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle); + if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具不存在!"); + SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(device_code); + if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!"); + AbstractTask connectorTask = taskFactory.getTask("ATTask"); + // 准备参数:设备编码 + JSONObject jo = new JSONObject(); + jo.put("device_code", device_code); + jo.put("config_code", "ATTask"); + jo.put("create_mode", GeneralDefinition.AUTO_CREATION); + jo.put("vehicle_code", vehicle); + jo.put("vehicle_type", mdBaseVehicle.getVehicle_type()); + jo.put("region_code", RegionEnum.NBGD.getRegion_code()); + param.put("region_code", RegionEnum.NBGD.getRegion_code()); + jo.put("ext_data", param); + connectorTask.apply(jo); + } + /** * 空料架送回 * @@ -137,8 +163,8 @@ public class HandheldServiceImpl implements HandheldService { if (CollUtil.isEmpty(Arrays.asList(vehicle_list))) { MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle); if (ObjectUtil.isEmpty(mdBaseVehicle)) throw new BadRequestException("载具不存在!"); - if (!mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.RACKS_S04.getVehicleCode()) - && !mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.RACKS_S06.getVehicleCode())) { + if (!mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.FRAME_R01.getVehicleCode()) + && !mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.FRAME_R02.getVehicleCode())) { throw new BadRequestException("托盘类型不匹配,,生成搬运任务失败!"); } } else { @@ -616,13 +642,6 @@ public class HandheldServiceImpl implements HandheldService { jsonObject.put("pointCode", isConnectConnector.getValue()); jsonObject.put("status", json.getString("status")); wmsToAcsService.notifyAcs1(jsonObject); - Param isConnectConnector1 = sysParamService.findByCode(GeneralDefinition.ADD_ROUTE_DOOR); - if ("1".equals(json.getString("status"))) { - isConnectConnector1.setValue(json.getString("type")); - } else { - isConnectConnector1.setValue("0"); - } - sysParamService.update(isConnectConnector1); } @Override diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/ISchBasePointService.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/ISchBasePointService.java index c4dd523..4b6f5a5 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/ISchBasePointService.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/ISchBasePointService.java @@ -100,7 +100,7 @@ public interface ISchBasePointService extends IService { * * @param region_code,vehicleType托盘类型允许多种类型 */ - SchBasePoint selectEmpVehicleByRegionCode(String region_code, String... vehicleType); + SchBasePoint selectEmpVehicleByRegionCode(String region_code, String vehicleType); /** @@ -212,4 +212,13 @@ public interface ISchBasePointService extends IService { * @return */ List selectPointByRegion(String regionCode); + + /** + * 根据载具类型和区域获取点位 + * @param region_code + * @param vehicle_code + * @param s + * @return + */ + SchBasePoint selectPointByEmpAndRegion(String region_code, String vehicle_code, String s); } diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java index 1985db6..9fc1516 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java @@ -77,6 +77,8 @@ public class SchBasePointServiceImpl extends ServiceImpl queryAll(Map whereJson, PageQuery page) { @@ -85,6 +87,7 @@ public class SchBasePointServiceImpl extends ServiceImpl schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class) + .eq(SchBasePoint::getIs_lock, false) + .isNull(SchBasePoint::getVehicle_code) + .eq(SchBasePoint::getPoint_type, s) + .eq(SchBasePoint::getRegion_code, region_code) + .eq(SchBasePoint::getPoint_status, GoodsEnum.OUT_OF_STOCK.getValue()) + .eq(SchBasePoint::getIs_used, true)); + if (CollUtil.isNotEmpty(schBasePoints) && schBasePoints.size() > 0) { + SchBasePoint schBasePoint = schBasePoints.get(0); + schBasePoint.setIs_lock(true); + update(Wrappers.lambdaUpdate(SchBasePoint.class) + .eq(SchBasePoint::getPoint_code, schBasePoint.getPoint_code()) + .set(SchBasePoint::getIs_lock, true)); + return schBasePoint; + } + return null; + } + } + @Override public List getStructList(String region_code, String vehicle_type) { //1.查询的结果一个托盘有多个800,PC需要怎么展示? @@ -552,16 +582,23 @@ public class SchBasePointServiceImpl extends ServiceImpl schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getIs_lock, false). isNotNull(SchBasePoint::getVehicle_code) .eq(StrUtil.isNotEmpty(region_code), SchBasePoint::getRegion_code, region_code) .eq(SchBasePoint::getPoint_status, GoodsEnum.EMPTY_PALLETS.getValue()) - .in(SchBasePoint::getCan_vehicle_type, vehicleType) + .eq(SchBasePoint::getCan_vehicle_type, vehicleType) .eq(SchBasePoint::getIs_used, true)); if (CollectionUtils.isEmpty(schBasePoints)) { + schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class).eq(SchBasePoint::getIs_lock, false) + .isNotNull(SchBasePoint::getVehicle_code) + .eq(SchBasePoint::getPoint_status, GoodsEnum.EMPTY_PALLETS.getValue()) + .eq(SchBasePoint::getCan_vehicle_type, vehicleType) + .eq(SchBasePoint::getIs_used, true)); + } + if (schBasePoints.size() == 0) { return null; } SchBasePoint schBasePoint = schBasePoints.get(0); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/connector/CNTTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/connector/CNTTask.java index f695b6e..cfe5596 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/connector/CNTTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/connector/CNTTask.java @@ -85,7 +85,7 @@ public class CNTTask extends AbstractTask { task.setVehicle_type(schBasePoint.getCan_vehicle_type()); task.setRemark(""); task.setTask_status(TaskStatus.CREATED.getCode()); - if (task.getPoint_code1().endsWith("2")) { + if (task.getPoint_code1().endsWith("1")) { task.setAcs_trace_id("4"); } taskService.updateById(task); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/connector/FTGTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/connector/FTGTask.java index d9ad499..9ef45e0 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/connector/FTGTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/connector/FTGTask.java @@ -30,6 +30,10 @@ import java.util.Comparator; import java.util.List; import java.util.stream.Collectors; +/** + * @author LENOVO + * connector补空托任务 + */ @Slf4j @Component(value = "FTGTask") public class FTGTask extends AbstractTask { @@ -54,12 +58,6 @@ public class FTGTask extends AbstractTask { protected void create() throws BadRequestException { // 获取任务 List tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); - /*Comparator numericSuffixComparator = (s1, s2) -> { - Integer suffix1 = getNumericSuffix(s1.getPoint_code1()); - Integer suffix2 = getNumericSuffix(s2.getPoint_code1()); - return suffix1.compareTo(suffix2); - }; - List collect = tasks.stream().sorted(numericSuffixComparator).collect(Collectors.toList());*/ for (SchBaseTask task : tasks) { // 查找空载具点位 SchBasePoint schBasePoint = schBasePointService.selectEmpVehicleByRegionCode(RegionEnum.LAG_ROBOT_BEANDING_CELL.getRegion_code(),task.getVehicle_type()); diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/handheld/AtTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/handheld/AtTask.java new file mode 100644 index 0000000..4dcb0f2 --- /dev/null +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/handheld/AtTask.java @@ -0,0 +1,173 @@ +package org.nl.wms.sch.task_manage.task.tasks.handheld; + +import cn.hutool.core.util.ObjectUtil; +import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import lombok.extern.slf4j.Slf4j; +import org.nl.common.enums.GoodsEnum; +import org.nl.common.exception.BadRequestException; +import org.nl.system.service.notice.ISysNoticeService; +import org.nl.wms.ext.acs.service.dto.to.BaseResponse; +import org.nl.wms.ext.fab.service.dto.SendVehicleVo; +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_manage.AbstractTask; +import org.nl.wms.sch.task_manage.GeneralDefinition; +import org.nl.wms.sch.task_manage.enums.NoticeTypeEnum; +import org.nl.wms.sch.task_manage.enums.TaskFinishedTypeEnum; +import org.nl.wms.sch.task_manage.task.core.TaskStatus; +import org.nl.wms.util.PointUtils; +import org.nl.wms.util.TaskUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Component; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; + +/** + * @author LENOVO + * 空托盘送回 + */ +@Slf4j +@Component(value = "ATTask") +public class AtTask extends AbstractTask { + + private static final String TASK_CONFIG_CODE = "ATTask"; + @Autowired + private ISchBasePointService pointService; + @Autowired + private ISchBaseTaskService taskService; + @Autowired + private ISchBaseTaskconfigService taskConfigService; + @Autowired + private ISysNoticeService noticeService; + @Autowired + private ISchBasePointService schBasePointService; + @Autowired + private ISchBaseVehiclematerialgroupService schBaseVehiclematerialgroupService; + + @Override + @Transactional(rollbackFor = Exception.class) + protected void create() throws BadRequestException { + // 获取任务 + List tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); + + for (SchBaseTask task : tasks) { + TaskUtils.setUpdateByAcs(task); + SendVehicleVo sendVehicleVo = JSONObject.parseObject(task.getRequest_param(), SendVehicleVo.class); + //查询地面点位的载具编码 + // 根据对接位查找对应的载具类型 + SchBasePoint schBasePoint = schBasePointService.selectPointByEmpAndRegion(sendVehicleVo.getRegion_code(), task.getVehicle_code(), "0"); + if (ObjectUtil.isEmpty(schBasePoint)) { + task.setRemark("未找到所需点位!"); + taskService.updateById(task); + // 消息通知 + noticeService.createNotice("未找到所需点位!", TASK_CONFIG_CODE + task.getTask_code(), + NoticeTypeEnum.WARN.getCode()); + continue; + } + //删除组盘信息 + schBaseVehiclematerialgroupService.remove(new QueryWrapper() + .eq("vehicle_code", schBasePoint.getVehicle_code())); + taskService.update(new UpdateWrapper() + .set("task_status", TaskStatus.CREATED.getCode()) + .set("point_code2", schBasePoint.getPoint_code()) + .eq("task_id", task.getTask_id())); + + //更新点位信息 + schBasePoint.setIng_task_code(task.getTask_code()); + schBasePoint.setIs_lock(true); + schBasePoint.setPoint_status(GoodsEnum.EMPTY_PALLETS.getValue()); + PointUtils.setUpdateByAcs(schBasePoint); + pointService.updateById(schBasePoint); + } + } + + @Override + protected void updateStatus(String task_code, TaskStatus status) { + //TODO:完成任务的时候将int_task_code的清除 + + } + + @Override + public void forceFinish(String task_code) { + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.finishTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR); + } + + @Override + public void cancel(String task_code) { + //TODO:取消任务的时候将int_task_code的清除 + SchBaseTask taskObj = taskService.getByCode(task_code); + if (ObjectUtil.isEmpty(taskObj)) { + throw new BadRequestException("该任务不存在"); + } + this.cancelTask(taskObj, TaskFinishedTypeEnum.MANUAL_CONNECTOR); + } + + @Override + protected void feedbackTaskState(JSONObject param, SchBaseTask schBaseTask, BaseResponse result) { + + } + + public void finishTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 获取参数 + String startPoint = taskObj.getPoint_code1(); + SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint); + // 起点清空 + if (ObjectUtil.isNotEmpty(schBasePoint)) { + PointUtils.updateByIngTaskCode(schBasePoint); + pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, startPoint) + .set(SchBasePoint::getIs_lock, false) + .set(SchBasePoint::getVehicle_code, null)); + } + String point_code2 = taskObj.getPoint_code2(); + SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); + if (ObjectUtil.isNotEmpty(schBasePoint2)) { + PointUtils.updateByIngTaskCode(schBasePoint2); + pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code2) + .set(SchBasePoint::getIs_lock, false) + .set(SchBasePoint::getVehicle_code, taskObj.getVehicle_code())); + } + // 任务完成 + taskObj.setTask_status(TaskStatus.FINISHED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_FINISH); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } + + public void cancelTask(SchBaseTask taskObj, TaskFinishedTypeEnum taskFinishedType) { + // 获取参数 + String startPoint = taskObj.getPoint_code1(); + SchBasePoint schBasePoint = pointService.selectByPointCode(startPoint); + // 起点清空 + if (ObjectUtil.isNotEmpty(schBasePoint)) { + PointUtils.updateByIngTaskCode(schBasePoint); + pointService.updateById(schBasePoint); + } + String point_code2 = taskObj.getPoint_code2(); + SchBasePoint schBasePoint2 = pointService.selectByPointCode(point_code2); + if (ObjectUtil.isNotEmpty(schBasePoint2)) { + PointUtils.updateByIngTaskCode(schBasePoint2); + pointService.updateById(schBasePoint2); + } + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setRemark(GeneralDefinition.TASK_CANCEL); + taskObj.setTask_status(TaskStatus.CANCELED.getCode()); + taskObj.setFinished_type(taskFinishedType.getCode()); + TaskUtils.setUpdateByType(taskObj, taskFinishedType); + taskService.updateById(taskObj); + } + +} diff --git a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/sorting/SortingCNTTask.java b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/sorting/SortingCNTTask.java index 8392a47..8ac7ddd 100644 --- a/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/sorting/SortingCNTTask.java +++ b/lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/sorting/SortingCNTTask.java @@ -59,7 +59,7 @@ public class SortingCNTTask extends AbstractTask { for (SchBaseTask task : tasks) { TaskUtils.setUpdateByAcs(task); // 找起点 - SchBasePoint basePoint = schBasePointService.selectEmpVehicleByRegionCode(RegionEnum.ZDFJ.getRegion_code(), task.getVehicle_type()); + SchBasePoint basePoint = schBasePointService.selectEmpVehicleByRegionCode(RegionEnum.LAG_ROBOT_BEANDING_CELL.getRegion_code(), task.getVehicle_type()); if (basePoint==null){ task.setRemark("未找到所需点位!"); taskService.updateById(task); diff --git a/lms/nladmin-ui/src/views/wms/sch/point/index.vue b/lms/nladmin-ui/src/views/wms/sch/point/index.vue index 25fc891..67bd0e4 100644 --- a/lms/nladmin-ui/src/views/wms/sch/point/index.vue +++ b/lms/nladmin-ui/src/views/wms/sch/point/index.vue @@ -90,6 +90,17 @@ /> + + +