Merge remote-tracking branch 'origin/main'

This commit is contained in:
zhaoyf
2026-06-29 19:34:38 +08:00
10 changed files with 380 additions and 36 deletions

View File

@@ -0,0 +1,43 @@
package org.nl.common.domain.constant;
/**
*区域常量
*/
public class RegionConstant {
/**
* 一次配盘区编码
*/
public static final String FIRST_MEAL = "firstMeal";
/**
* 机加工二次配盘区,原料线边库
*/
public static final String MACHINE_RAW_MATERIAL_SIDE = "6.010";
/**
* 焊接二次配盘区,原料线边库
*/
public static final String WELDING_RAW_MATERIAL_SIDE = "6.009";
/**
* 喷涂二次配盘区,原料线边库
*/
public static final String SPRAYING_RAW_MATERIAL_SIDE = "6.008";
/**
* 机加工半成品
*/
public static final String MACHINE_SEMI_MATERIAL_SIDE = "6.010";
/**
* 焊接半成品
*/
public static final String WELDING_SEMI_MATERIAL_SIDE = "6.009";
/**
* 喷涂半成品
*/
public static final String SPRAYING_SEMI_MATERIAL_SIDE = "6.008";
}

View File

@@ -77,7 +77,7 @@ public class SchBasePointController {
@PostMapping("/getPointList")
@Log("获取区域下拉框")
public ResponseEntity<Object> getPointList(@RequestBody(required = false) SchBasePoint region) {
return new ResponseEntity<>(schBasePointService.getPointList(region), HttpStatus.OK);
return new ResponseEntity<>(schBasePointService.getPointList(region.getRegion_code()), HttpStatus.OK);
}

View File

@@ -60,7 +60,7 @@ public interface ISchBasePointService extends IService<SchBasePoint> {
* @param region 参数
* @return List<SchBasePoint>
*/
List<SchBasePoint> getPointList(SchBasePoint region);
List<SchBasePoint> getPointList(String region);
/**
* 解锁/上锁
@@ -106,4 +106,13 @@ public interface ISchBasePointService extends IService<SchBasePoint> {
*/
List<SchBasePoint> checkEndPointTask(String regionCode, String getLockType, String sortType, String
pointType, String pointCode, String vehicleIsNull, boolean isFourPoint);
/**
* 查询区域中闲置点
* @param regions
* @return
*/
List<SchBasePoint> selectIdlePoint(List<String> regions);
}

View File

@@ -1,29 +0,0 @@
package org.nl.wms.sch_manage.service.core;
import com.alibaba.fastjson.JSONObject;
/**
* @Author: Liuxy
* @Description: 点位工具类
* @Date: 2025/5/20
*/
public class PointUtils {
/**
* 获取状态名或者类型名
*
* @param explain 参数
* @param label 参数
* @return String
*/
public static String getStatusOrTypeName(String explain, String label) {
JSONObject statusArr = new JSONObject();
String[] split = explain.split("");
for (int j = 0; j < split.length; j++) {
String[] status = split[j].split("-");
statusArr.put(status[0], status[1]);
}
// 设置
return statusArr.getString(label);
}
}

View File

@@ -0,0 +1,89 @@
package org.nl.wms.sch_manage.service.core;
import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.nl.common.domain.constant.RegionConstant;
import org.nl.wms.sch_manage.service.ISchBasePointService;
import org.nl.wms.sch_manage.service.core.tasks.Point2PointTask;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
import org.nl.wms.warehouse_manage.service.*;
import org.nl.wms.warehouse_manage.service.dao.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.*;
import java.util.stream.Collectors;
/**
* 结构车间定时配送
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class StructAreaDeliveryAutoTask {
@Autowired
private ISchBasePointService iSchBasePointService;
@Autowired
private Point2PointTask point2PointTask;
@Autowired
private IMdPbGroupplateService iMdPbGroupplateService;
//定时任务:查询一次配盘区配盘,配送至对应二次配盘缓存区
@SneakyThrows
public void run() {
// 1. 一次性查询所有需要处理的配盘点
List<SchBasePoint> firstMealPoints = iSchBasePointService.getPointList(RegionConstant.FIRST_MEAL);
List<SchBasePoint> validPoints = firstMealPoints.stream()
.filter(point -> StringUtils.isNotEmpty(point.getVehicle_code()))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(validPoints)) {
log.info("没有需要处理的配盘点");
return;
}
//查看所有可用点位 按区域区分
Map<String, List<String>> empRegionPointMap = iSchBasePointService.selectIdlePoint(Arrays.asList(RegionConstant.SPRAYING_RAW_MATERIAL_SIDE
, RegionConstant.WELDING_RAW_MATERIAL_SIDE
, RegionConstant.MACHINE_RAW_MATERIAL_SIDE
, RegionConstant.MACHINE_RAW_MATERIAL_SIDE)).stream()
.collect(Collectors.groupingBy(
SchBasePoint::getRegion_code,
Collectors.mapping(SchBasePoint::getPoint_code, Collectors.toList())
));
if (CollectionUtil.isEmpty(empRegionPointMap)){
return;
}
//点位映射
Map<String, String> vehicleLoadPortMap = iMdPbGroupplateService.list(
new LambdaQueryWrapper<GroupPlate>()
.in(GroupPlate::getStoragevehicle_code, validPoints.stream()
.map(SchBasePoint::getVehicle_code)
.collect(Collectors.toSet()))
.select(GroupPlate::getStoragevehicle_code, GroupPlate::getLoad_port)).stream()
.collect(Collectors.toMap(
GroupPlate::getStoragevehicle_code,
GroupPlate::getLoad_port
));
for (SchBasePoint validPoint : validPoints) {
final String loadPoint = vehicleLoadPortMap.get(validPoint.getVehicle_code());
final SchBasePoint loadInfo = iSchBasePointService.selectByCode(loadPoint);
final List<String> empPointCodes = empRegionPointMap.get(loadInfo.getRegion_code());
if (CollectionUtil.isNotEmpty(empPointCodes)){
//创建搬运任务
final JSONObject param = new JSONObject();
param.put("point_code1",validPoint.getPoint_code());
param.put("point_code2",empPointCodes.get(0));
param.put("vehicle_code",validPoint.getVehicle_code());
param.put("config_code","Point2PointTask");
param.put("Priority","1");
point2PointTask.create(param);
}
}
}
}

View File

@@ -0,0 +1,200 @@
package org.nl.wms.sch_manage.service.core.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import org.nl.common.exception.BadRequestException;
import org.nl.common.utils.CodeUtil;
import org.nl.common.utils.IdUtil;
import org.nl.common.utils.SecurityUtils;
import org.nl.wms.basedata_manage.service.IStructattrService;
import org.nl.wms.basedata_manage.service.dao.Structattr;
import org.nl.wms.sch_manage.enums.TaskStatus;
import org.nl.wms.sch_manage.service.ISchBasePointService;
import org.nl.wms.sch_manage.service.ISchBaseTaskService;
import org.nl.wms.sch_manage.service.core.AbstractTask;
import org.nl.wms.sch_manage.service.core.AcsTaskDto;
import org.nl.wms.sch_manage.service.core.TaskType;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
import org.nl.wms.sch_manage.service.dao.SchBaseTask;
import org.nl.wms.warehouse_manage.enums.IOSEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
/**
* 点对点搬运任务
*/
@Component(value = "Point2PointTask")
@TaskType("Point2PointTask")
public class Point2PointTask extends AbstractTask {
/**
* 任务服务类
*/
@Autowired
private ISchBaseTaskService taskService;
/**
* 点位服务
*/
@Autowired
private ISchBasePointService iSchBasePointService;
/**
* 仓位服务
*/
@Autowired
private IStructattrService iStructattrService;
@Override
public String create(JSONObject json) {
SchBaseTask task = new SchBaseTask();
task.setTask_id(IdUtil.getStringId());
task.setTask_code(CodeUtil.getNewCode("TASK_CODE"));
task.setTask_status(TaskStatus.CREATE.getCode());
task.setConfig_code(json.getString("config_code"));
task.setPoint_code1(json.getString("point_code1"));
task.setPoint_code2(json.getString("point_code2"));
task.setVehicle_code(json.getString("vehicle_code"));
task.setRequest_param(json.toString());
task.setPriority(json.getString("Priority"));
task.setCreate_id(SecurityUtils.getCurrentUserId());
task.setCreate_name(SecurityUtils.getCurrentNickName());
task.setCreate_time(DateUtil.now());
taskService.save(task);
return task.getTask_id();
}
@Override
public AcsTaskDto sendAcsParam(String taskId) {
SchBaseTask taskDao = taskService.getById(taskId);
// 组织下发给acs的数据
AcsTaskDto acsTaskDto = new AcsTaskDto();
acsTaskDto.setExt_task_uuid(taskDao.getTask_id());
acsTaskDto.setTask_code(taskDao.getTask_code());
acsTaskDto.setStart_device_code(taskDao.getPoint_code1());
acsTaskDto.setNext_device_code(taskDao.getPoint_code2());
acsTaskDto.setPriority(taskDao.getPriority());
acsTaskDto.setTask_type("1");
return acsTaskDto;
}
@Override
protected void updateStatus(String task_code, TaskStatus status) {
// 校验任务
SchBaseTask taskObj = taskService.getByCode(task_code);
if (taskObj.getTask_status().equals(TaskStatus.FINISHED.getCode())) {
throw new BadRequestException("该任务已完成!");
}
if (taskObj.getTask_status().equals(TaskStatus.CANCELED.getCode())) {
throw new BadRequestException("该任务已取消!");
}
// 根据传来的类型去对任务进行操作
if (status.equals(TaskStatus.EXECUTING)) {
// 更新明细状态
taskObj.setTask_status(TaskStatus.EXECUTING.getCode());
taskObj.setRemark("执行中");
taskService.updateById(taskObj);
}
if (status.equals(TaskStatus.FINISHED)) {
this.finishTask(taskObj);
}
if (status.equals(TaskStatus.CANCELED)) {
this.cancelTask(taskObj);
}
}
@Override
public void forceFinish(String task_code) {
SchBaseTask taskObj = taskService.getByCode(task_code);
if (ObjectUtil.isEmpty(taskObj)) {
throw new BadRequestException("该任务不存在");
}
this.finishTask(taskObj);
}
@Override
public void cancel(String task_code) {
SchBaseTask taskObj = taskService.getByCode(task_code);
if (ObjectUtil.isEmpty(taskObj)) {
throw new BadRequestException("该任务不存在");
}
if (Integer.parseInt(taskObj.getTask_status()) > Integer.parseInt(TaskStatus.CREATE.getCode())) {
throw new BadRequestException("只能取消生成中的任务!");
}
this.cancelTask(taskObj);
}
@Transactional
public void finishTask(SchBaseTask taskObj) {
// 更新起点
iSchBasePointService.update(
new UpdateWrapper<SchBasePoint>().lambda()
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1())
.set(SchBasePoint::getVehicle_code, null)
.set(SchBasePoint::getIos_id, null)
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("无货"))
);
iStructattrService.update(
new UpdateWrapper<Structattr>().lambda()
.eq(Structattr::getStruct_code, taskObj.getPoint_code1())
.set(Structattr::getStoragevehicle_code, null)
.set(Structattr::getTask_code, null)
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定"))
);
// 更新终点
iSchBasePointService.update(
new UpdateWrapper<SchBasePoint>().lambda()
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code2())
.set(SchBasePoint::getVehicle_code, taskObj.getVehicle_code())
.set(SchBasePoint::getIos_id, null)
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("有货"))
);
iStructattrService.update(
new UpdateWrapper<Structattr>().lambda()
.eq(Structattr::getStruct_code, taskObj.getPoint_code2())
.set(Structattr::getStoragevehicle_code, taskObj.getVehicle_code())
.set(Structattr::getTask_code, null)
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定"))
);
// 更新任务
taskObj.setRemark("已完成");
taskObj.setTask_status(TaskStatus.FINISHED.getCode());
taskService.updateById(taskObj);
}
@Transactional
public void cancelTask(SchBaseTask taskObj) {
// 更新起点
iSchBasePointService.update(
new UpdateWrapper<SchBasePoint>().lambda()
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code1())
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("无货"))
);
iStructattrService.update(
new UpdateWrapper<Structattr>().lambda()
.eq(Structattr::getStruct_code, taskObj.getPoint_code1())
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定"))
);
// 更新终点
iSchBasePointService.update(
new UpdateWrapper<SchBasePoint>().lambda()
.eq(SchBasePoint::getPoint_code, taskObj.getPoint_code2())
.set(SchBasePoint::getPoint_status, IOSEnum.POINT_STATUS.code("无货"))
);
iStructattrService.update(
new UpdateWrapper<Structattr>().lambda()
.eq(Structattr::getStruct_code, taskObj.getPoint_code2())
.set(Structattr::getLock_type, IOSEnum.LOCK_TYPE.code("未锁定"))
);
// 更新任务
taskObj.setRemark("已取消");
taskObj.setTask_status(TaskStatus.CANCELED.getCode());
taskService.updateById(taskObj);
}
}

View File

@@ -2,6 +2,8 @@ package org.nl.wms.sch_manage.service.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.nl.wms.sch_manage.service.dao.SchBasePoint;
import org.nl.wms.sch_manage.service.dto.SchBasePointQuery;
@@ -28,6 +30,28 @@ public interface SchBasePointMapper extends BaseMapper<SchBasePoint> {
*/
List<SchBasePoint> getAllUnlockAbnormalPoints();
@Select("SELECT p.*\n" +
"FROM sch_base_point p\n" +
"WHERE p.is_used = 1\n" +
" AND p.region_code IN \n" +
" <foreach collection='regions' item='region' open='(' separator=',' close=')'>\n" +
" #{region}\n" +
" </foreach>\n" +
" AND NOT EXISTS (\n" +
" SELECT 1\n" +
" FROM sch_base_task t\n" +
" WHERE t.is_delete = 0\n" +
" AND t.task_status <= '20'\n" +
" AND (\n" +
" t.point_code1 = p.point_code\n" +
" OR t.point_code2 = p.point_code\n" +
" OR t.point_code3 = p.point_code\n" +
" OR t.point_code4 = p.point_code\n" +
" )\n" +
" )\n" +
"ORDER BY p.point_code")
List<SchBasePoint> selectIdlePoint(@Param("regions") List<String> regions);
/**
* 行锁获取id的点位
*

View File

@@ -26,7 +26,6 @@ import org.nl.wms.sch_manage.service.dao.mapper.SchBasePointMapper;
import org.nl.wms.sch_manage.service.dao.mapper.SchBaseRegionMapper;
import org.nl.wms.sch_manage.service.dao.mapper.SchBaseTaskMapper;
import org.nl.wms.sch_manage.service.dto.SchBasePointQuery;
import org.nl.wms.sch_manage.service.core.PointUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -137,12 +136,12 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
}
@Override
public List<SchBasePoint> getPointList(SchBasePoint region) {
public List<SchBasePoint> getPointList(String region) {
if (ObjectUtil.isEmpty(region)) {
return this.list();
}
return pointMapper.selectList(new LambdaQueryWrapper<SchBasePoint>()
.eq(SchBasePoint::getRegion_code, region.getRegion_code()));
.eq(SchBasePoint::getRegion_code, region));
}
@Override
@@ -264,4 +263,8 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
.collect(Collectors.toList());
}
@Override
public List<SchBasePoint> selectIdlePoint(List<String> regions) {
return this.baseMapper.selectIdlePoint(regions);
}
}

View File

@@ -113,7 +113,9 @@ public class WorkOrderDto implements Serializable {
@JsonProperty("ProductionStatus")
private String productionStatus;
/**
* 工单对应产线
*/
@JsonProperty("WorkArea")
private String workArea;
@@ -320,4 +322,4 @@ public class WorkOrderDto implements Serializable {
private BigDecimal status;
}
}
}
}

View File

@@ -55,3 +55,6 @@ ALTER TABLE `st_ivt_iostorinvdis`
ALTER TABLE `st_ivt_iostorinvdtl`
DROP COLUMN `source_load_port`,
ADD COLUMN `source_load_port` varchar(255) NULL COMMENT '来源单指定上料口' AFTER `material_code`;
ALTER TABLE `st_ivt_iostorinvdtl`
ADD COLUMN `callback_strategy` varchar(64) NULL COMMENT '单据回传策略配置类名' AFTER `source_load_port`;