Browse Source

add:新增手持 缓存码变更功能

rev:修改原料区、原料缓存区货位分配逻辑:按启用的排号轮询,确定排号后 按 层号 升序、列号 升序这样的逻辑来分配的
master
zds 4 months ago
parent
commit
62b162847e
  1. 109
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pda/service/impl/PdaServiceImpl.java
  2. 14
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dto/PointLeftDto.java
  3. 20
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java
  4. 4
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/ISchBaseTaskService.java
  5. 12
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/impl/SchBaseTaskServiceImpl.java
  6. 8
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/AbstractTask.java
  7. 7
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/GeneralDefinition.java
  8. 4
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/KJRKTask.java
  9. 11
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/POINTTask.java
  10. 4
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/SSXBKJTask.java
  11. 4
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLCKTask.java
  12. 104
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/YCLRKTask.java
  13. 5
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.java
  14. 33
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.xml

109
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/pda/service/impl/PdaServiceImpl.java

@ -1,6 +1,7 @@
package org.nl.wms.pda.service.impl;
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;
@ -20,6 +21,8 @@ import org.nl.wms.sch.material.service.dao.Material;
import org.nl.wms.sch.material.service.dao.mapper.MaterialMapper;
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.dao.SchBaseTask;
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.tasks.mapper.PointMapper;
@ -39,7 +42,7 @@ import java.util.List;
@Lazy
public class PdaServiceImpl implements PdaService {
@Autowired
private PdaMapper pdaMapper;
private ISchBaseTaskService taskService;
@Autowired
private ISchBasePointService pointService;
@Autowired
@ -116,16 +119,8 @@ public class PdaServiceImpl implements PdaService {
PdaResponseVo result = new PdaResponseVo();
String subTray = param.getString("sub_tray");
subTray = subTray.trim();
if(ObjectUtil.isEmpty(subTray)){
result = PdaResponseVo.pdaResultError("子托盘号不能为空!");
return result;
}
String motherTray = param.getString("mother_tray");
motherTray = motherTray.trim();
if(ObjectUtil.isEmpty(motherTray)){
result = PdaResponseVo.pdaResultError("母托盘号不能为空!");
return result;
}
//子拖盘解绑
if(ObjectUtil.isNotEmpty(subTray)){
//查询母托盘
@ -188,45 +183,69 @@ public class PdaServiceImpl implements PdaService {
new_sub_tray = new_sub_tray.trim();
if(ObjectUtil.isEmpty(new_sub_tray)){
result = PdaResponseVo.pdaResultError("新子托盘号不能为空!");
}else{
List<Material> materialList = materialMapper.selectList(new LambdaQueryWrapper<Material>()
.eq(Material::getPalletSN,new_sub_tray)
.le(Material::getReturn_status, "1")
.eq(Material::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue()));
if (ObjectUtil.isEmpty(materialList)) {
result = PdaResponseVo.pdaResultError("新子托盘号无组盘入库单据信息!");
}else{
if(ObjectUtil.isEmpty(sub_tray)){
result = PdaResponseVo.pdaResultError("原子托盘号不能为空!");
}else if (!sub_tray.startsWith("YBHC")){
result = PdaResponseVo.pdaResultError("原子托盘号非缓存临时码!");
}else{
//更新点位载具
LambdaUpdateWrapper<SchBasePoint> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(SchBasePoint::getVehicle_code2,sub_tray);
return result;
}
List<Material> materialList = materialMapper.selectList(new LambdaQueryWrapper<Material>()
.eq(Material::getPalletSN,new_sub_tray)
.le(Material::getReturn_status, "1")
.eq(Material::getGroup_bind_material_status, GroupBindMaterialStatusEnum.BOUND.getValue()));
if (ObjectUtil.isEmpty(materialList)) {
result = PdaResponseVo.pdaResultError("新子托盘号无组盘入库单据信息!");
return result;
}
if(ObjectUtil.isEmpty(sub_tray)){
result = PdaResponseVo.pdaResultError("原子托盘号不能为空!");
return result;
}
if(!sub_tray.startsWith("YBHC")){
result = PdaResponseVo.pdaResultError("原子托盘号非缓存临时码YBHC开头!");
return result;
}
//查询点位记录
LambdaQueryWrapper<SchBasePoint> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(SchBasePoint::getVehicle_code2,sub_tray);
int countPoint = pointMapper.selectCount(queryWrapper);
if(countPoint<=0){
result = PdaResponseVo.pdaResultError("原子托盘号未在系统点位仓位上!");
return result;
}
//判断该子托盘是否存在未完成任务
Integer sub_tray_lists = taskService.findUnFinishTasksBySub_tray("",sub_tray);
if(sub_tray_lists>0){
result = PdaResponseVo.pdaResultError("该任务申请子托盘[\"+sub_tray+\"]存在未完成的任务!");
return result;
}
//查询组盘记录
LambdaQueryWrapper<SchBaseVehiclematerialgroup> queryWrapper_group = new LambdaQueryWrapper<>();
queryWrapper_group.eq(SchBaseVehiclematerialgroup::getVehicle_code,sub_tray);
queryWrapper_group.le(SchBaseVehiclematerialgroup::getGroup_bind_material_status,"2");
int countGroup = vehiclematerialgroupMapper.selectCount(queryWrapper_group);
if(countGroup<=0){
result = PdaResponseVo.pdaResultError("原子托盘号无已绑定的组盘记录!");
return result;
}
//更新点位载具
LambdaUpdateWrapper<SchBasePoint> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(SchBasePoint::getVehicle_code2,sub_tray);
updateWrapper.set(SchBasePoint::getVehicle_code2,new_sub_tray);
updateWrapper.set(SchBasePoint::getUpdate_id,currentUserId);
updateWrapper.set(SchBasePoint::getUpdate_name,nickName);
updateWrapper.set(SchBasePoint::getUpdate_time,now);
pointMapper.update(null,updateWrapper);
updateWrapper.set(SchBasePoint::getVehicle_code2,new_sub_tray);
updateWrapper.set(SchBasePoint::getUpdate_id,currentUserId);
updateWrapper.set(SchBasePoint::getUpdate_name,nickName);
updateWrapper.set(SchBasePoint::getUpdate_time,now);
pointMapper.update(null,updateWrapper);
//更新组盘载具
LambdaUpdateWrapper<SchBaseVehiclematerialgroup> updateWrapper_group = new LambdaUpdateWrapper<>();
updateWrapper_group.eq(SchBaseVehiclematerialgroup::getVehicle_code,sub_tray);
updateWrapper_group.le(SchBaseVehiclematerialgroup::getGroup_bind_material_status,"2");
//更新组盘载具
LambdaUpdateWrapper<SchBaseVehiclematerialgroup> updateWrapper_group = new LambdaUpdateWrapper<>();
updateWrapper_group.eq(SchBaseVehiclematerialgroup::getVehicle_code,sub_tray);
updateWrapper_group.le(SchBaseVehiclematerialgroup::getGroup_bind_material_status,"2");
updateWrapper_group.set(SchBaseVehiclematerialgroup::getVehicle_code,new_sub_tray);
updateWrapper_group.set(SchBaseVehiclematerialgroup::getSource_vehicle_code,sub_tray);
updateWrapper_group.set(SchBaseVehiclematerialgroup::getUpdate_id,currentUserId);
updateWrapper_group.set(SchBaseVehiclematerialgroup::getUpdate_name,nickName);
updateWrapper_group.set(SchBaseVehiclematerialgroup::getUpdate_time,now);
vehiclematerialgroupMapper.update(null,updateWrapper_group);
result = PdaResponseVo.pdaResultOk("缓存码变更成功!");
}
}
}
updateWrapper_group.set(SchBaseVehiclematerialgroup::getVehicle_code,new_sub_tray);
updateWrapper_group.set(SchBaseVehiclematerialgroup::getSource_vehicle_code,sub_tray);
updateWrapper_group.set(SchBaseVehiclematerialgroup::getUpdate_id,currentUserId);
updateWrapper_group.set(SchBaseVehiclematerialgroup::getUpdate_name,nickName);
updateWrapper_group.set(SchBaseVehiclematerialgroup::getUpdate_time,now);
vehiclematerialgroupMapper.update(null,updateWrapper_group);
result = PdaResponseVo.pdaResultOk("缓存码变更成功!");
return result;
}

14
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dto/PointLeftDto.java

@ -0,0 +1,14 @@
package org.nl.wms.sch.point.service.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class PointLeftDto implements Serializable {
/** 点位编码 */
private Integer row_num;
/** 点位名称 */
private Integer left_num;
}

20
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java

@ -63,7 +63,6 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
Boolean parent_point = ObjectUtil.isNotEmpty(whereJson.get("parent_point")) ? Boolean.valueOf(whereJson.get("parent_point").toString()) : false;
LambdaQueryWrapper<SchBasePoint> lam = new LambdaQueryWrapper<>();
lam.like(ObjectUtil.isNotEmpty(blurry), SchBasePoint::getPoint_code, blurry)
// .or(ObjectUtil.isNotEmpty(blurry), lam1 -> lam1.like(SchBasePoint::getPoint_name, blurry))
.eq(ObjectUtil.isNotEmpty(workshop_code), SchBasePoint::getWorkshop_code, workshop_code)
.in(ObjectUtil.isNotEmpty(roles),SchBasePoint::getWorkshop_code,roles)
.eq(ObjectUtil.isNotEmpty(region_code), SchBasePoint::getRegion_code, region_code)
@ -83,25 +82,6 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
.apply(parent_point, "point_code = parent_point_code");
IPage<SchBasePoint> pages = new Page<>(page.getPage() + 1, page.getSize());
pointMapper.selectPage(pages, lam);
// 可以存放的载具类型
pages.getRecords().forEach(point -> {
if (ObjectUtil.isNotEmpty(point.getCan_vehicle_type())) {
point.setCan_vehicle_types(Arrays.asList(point.getCan_vehicle_type().split(",")));
}
String pointStatus = point.getPoint_status(); // 点位状态
String pointType = point.getPoint_type(); // 点位类型
SchBaseRegion regionObj = regionMapper.selectById(point.getRegion_code());
if (ObjectUtil.isNotEmpty(regionObj)) {
if (ObjectUtil.isNotEmpty(pointStatus) && ObjectUtil.isNotEmpty(regionObj.getPoint_status_explain())) {
// 设置
point.setPoint_status_name(PointUtils.getStatusOrTypeName(regionObj.getPoint_status_explain(), pointStatus));
}
if (ObjectUtil.isNotEmpty(pointType) && ObjectUtil.isNotEmpty(regionObj.getPoint_type_explain())) {
// 设置
point.setPoint_type_name(PointUtils.getStatusOrTypeName(regionObj.getPoint_type_explain(), pointType));
}
}
});
return pages;
}

4
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/ISchBaseTaskService.java

@ -65,7 +65,7 @@ public interface ISchBaseTaskService extends IService<SchBaseTask> {
* @param point_code2
* @return
*/
List<SchBaseTask> findUnFinishTasksByPoint_code2(String task_code, String point_code2);
Integer findUnFinishTasksByPoint_code2(String task_code, String point_code2);
/**
* 根据任务号和子托盘查询未完成的任务
@ -73,7 +73,7 @@ public interface ISchBaseTaskService extends IService<SchBaseTask> {
* @param sub_tray
* @return
*/
List<SchBaseTask> findUnFinishTasksBySub_tray(String task_code, String sub_tray);
Integer findUnFinishTasksBySub_tray(String task_code, String sub_tray);
/**
* 根据任务类型和任务状态查询任务

12
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task/service/impl/SchBaseTaskServiceImpl.java

@ -126,8 +126,7 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
return schBaseTasks;
}
@Override
public List<SchBaseTask> findUnFinishTasksByPoint_code2(String task_code, String point_code2) {
Assert.notNull(task_code, "任务编码不能为空!");
public Integer findUnFinishTasksByPoint_code2(String task_code, String point_code2) {
Assert.notNull(point_code2, "点位不能为空!");
LambdaQueryWrapper<SchBaseTask> lam = new LambdaQueryWrapper<>();
lam.lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode())
@ -136,21 +135,20 @@ public class SchBaseTaskServiceImpl extends ServiceImpl<SchBaseTaskMapper, SchBa
.or()
.eq(SchBaseTask::getPoint_code2, point_code2))
.eq(SchBaseTask::getIs_delete, false);
List<SchBaseTask> schBaseTasks = schBaseTaskMapper.selectList(lam);
Integer schBaseTasks = schBaseTaskMapper.selectCount(lam);
return schBaseTasks;
}
@Override
public List<SchBaseTask> findUnFinishTasksBySub_tray(String task_code, String sub_tray) {
Assert.notNull(task_code, "任务编码不能为空!");
public Integer findUnFinishTasksBySub_tray(String task_code, String sub_tray) {
Assert.notNull(sub_tray, "子托盘不能为空!");
LambdaQueryWrapper<SchBaseTask> lam = new LambdaQueryWrapper<>();
lam.lt(SchBaseTask::getTask_status, TaskStatus.FINISHED.getCode())
.ne(ObjectUtil.isNotEmpty(task_code),SchBaseTask::getTask_code, task_code)// 不是当前任务
.eq(SchBaseTask::getVehicle_code2, sub_tray)
.eq(SchBaseTask::getIs_delete, false);
List<SchBaseTask> schBaseTasks = schBaseTaskMapper.selectList(lam);
return schBaseTasks;
Integer taskCount = schBaseTaskMapper.selectCount(lam);
return taskCount;
}
@Override

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

@ -218,15 +218,15 @@ public abstract class AbstractTask {
}
}else{
//判断该申请点位是否存在起点或终点的未完成任务
List<SchBaseTask> apply_point_lists = taskService.findUnFinishTasksByPoint_code2("",apply_point_code);
Assert.isFalse(apply_point_lists.size()>0,
Integer apply_point_lists = taskService.findUnFinishTasksByPoint_code2("",apply_point_code);
Assert.isFalse(apply_point_lists>0,
"该任务申请点位["+apply_point_code+"]已存在未完成的任务,无法申请任务!");
}
//子托盘非空
if(ObjectUtil.isNotEmpty(sub_tray)) {
//判断该子托盘是否存在未完成任务
List<SchBaseTask> apply_sub_tray_lists = taskService.findUnFinishTasksBySub_tray("",sub_tray);
Assert.isFalse(apply_sub_tray_lists.size()>0,
Integer sub_tray_lists = taskService.findUnFinishTasksBySub_tray("",sub_tray);
Assert.isFalse(sub_tray_lists>0,
"该任务申请子托盘["+sub_tray+"]已存在未完成的任务,无法申请任务!");
}
// 最大可创建任务数

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

@ -77,9 +77,10 @@ public class GeneralDefinition {
public static final String IS_CONNECT_MES = "is_connect_mes";
/** MES路径 */
public static final String MES_URL = "mes_url";
// 完成/取消
/** 任务完成 */
public static final String TASK_FINISH = "任务完成";
/** 当前货架排 */
public static final String NOW_YL_ROW = "now_yl_row";
/** 当前货架排 */
public static final String NOW_YLHC_ROW = "now_ylhc_row";
/** 任务取消 */
public static final String TASK_CANCEL = "任务取消";
}

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

@ -76,8 +76,8 @@ public class KJRKTask extends AbstractTask {
continue;
}else{
// 获取任务
List<SchBaseTask> taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),point.getPoint_code());
if(taskList.size()>0){
Integer taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),point.getPoint_code());
if(taskList>0){
task.setRemark("分配终点点位"+point.getPoint_code()+"已存在未完成任务!");
taskService.update(task);
// 消息通知

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

@ -56,8 +56,6 @@ public class POINTTask extends AbstractTask {
private IWorkorderService workorderService;
@Autowired
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
@Autowired
private ISysParamService paramService;
@Override
// @Transactional(rollbackFor = Exception.class)
@ -82,10 +80,7 @@ public class POINTTask extends AbstractTask {
SchBasePoint nextSchBasePoint= pointService.getOne(new LambdaQueryWrapper<SchBasePoint>()
.eq(SchBasePoint::getPoint_code, task.getPoint_code2()));
if(task.getPoint_code2().startsWith("DKT")){
//判断叠盘机最大叠盘数量
Param max_dkt_qty = paramService.findByCode(GeneralDefinition.MAX_DKT_QTY);
Assert.notNull(max_dkt_qty, "找不到配置文件,请确认系统参数[max_dkt_qty]配置是否存在!");
Integer max_qty = Integer.valueOf(max_dkt_qty.getValue());
Integer max_qty = nextSchBasePoint.getVehicle_max_qty();
//如果是叠盘位,根据当前数量+1为目标地址
int qty=nextSchBasePoint.getVehicle_qty()+1;
if(qty <= max_qty){
@ -105,8 +100,8 @@ public class POINTTask extends AbstractTask {
continue;
}
// 获取任务
List<SchBaseTask> taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),task.getPoint_code2());
if(taskList.size()>0){
Integer taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),task.getPoint_code2());
if(taskList>0){
task.setRemark("分配终点点位"+task.getPoint_code2()+"已存在未完成任务!");
taskService.update(task);
// 消息通知

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

@ -76,8 +76,8 @@ public class SSXBKJTask extends AbstractTask {
continue;
}else{
// 获取任务
List<SchBaseTask> taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),point.getPoint_code());
if(taskList.size()>0){
Integer taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),point.getPoint_code());
if(taskList>0){
task.setRemark("分配起点点位"+point.getPoint_code()+"已存在未完成任务!");
taskService.update(task);
// 消息通知

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

@ -121,8 +121,8 @@ public class YCLCKTask extends AbstractTask {
continue;
}else{
// 获取任务
List<SchBaseTask> taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),point.getPoint_code());
if(taskList.size()>0){
Integer taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),point.getPoint_code());
if(taskList>0){
task.setRemark("分配终点点位"+point.getPoint_code()+"已存在未完成任务!");
taskService.update(task);
// 消息通知

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

@ -3,6 +3,7 @@ package org.nl.wms.sch.task_manage.task.tasks;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.http.HttpRequest;
@ -12,6 +13,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import lombok.extern.slf4j.Slf4j;
import org.nl.common.exception.BadRequestException;
import org.nl.system.service.param.ISysParamService;
import org.nl.system.service.param.dao.Param;
import org.nl.wms.ext.service.dto.to.BaseResponse;
import org.nl.wms.mes.domain.Head;
import org.nl.wms.mes.domain.QPMES062Request;
@ -25,11 +28,13 @@ import org.nl.wms.sch.material.service.dao.Material;
import org.nl.wms.sch.material.service.dao.mapper.MaterialMapper;
import org.nl.wms.sch.point.service.ISchBasePointService;
import org.nl.wms.sch.point.service.dao.SchBasePoint;
import org.nl.wms.sch.point.service.dto.PointLeftDto;
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;
@ -41,10 +46,7 @@ import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
/**
@ -69,7 +71,7 @@ public class YCLRKTask extends AbstractTask {
@Autowired
private ISchBaseTaskconfigService taskConfigService;
@Autowired
private IPdmBdWorkorderService workorderService;
private ISysParamService paramService;
@Autowired
private ISchBaseVehiclematerialgroupService vehiclematerialgroupService;
@Autowired
@ -107,8 +109,8 @@ public class YCLRKTask extends AbstractTask {
continue;
}else{
// 获取任务
List<SchBaseTask> taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),point.getPoint_code());
if(taskList.size()>0){
Integer taskList = taskService.findUnFinishTasksByPoint_code2(task.getTask_code(),point.getPoint_code());
if(taskList>0){
task.setRemark("分配终点点位"+point.getPoint_code()+"已存在未完成任务!");
taskService.update(task);
// 消息通知
@ -156,11 +158,11 @@ public class YCLRKTask extends AbstractTask {
//人工录入的子托盘号以YBHC开头
if(sub_tray.startsWith("YBHC")) {
String regionCode = "YLHC";
return getSchBasePoint(regionCode);
return getSchBasePointByYLHC(regionCode);
}else {//非人工录入子托盘
//1、优先从原料库存区查找
String regionCode = "YL";
SchBasePoint point = getSchBasePoint(regionCode);
SchBasePoint point = getSchBasePointByYL(regionCode);
if (ObjectUtil.isNotEmpty(point)){
return point;
}else {//2、原料库存区未找到,则去空架缓存区查找
@ -190,6 +192,90 @@ public class YCLRKTask extends AbstractTask {
return null;
}
/**
* 根据区域编码查找合适的点位
* 规则根据启用的原料区的排号顺序分配234567一共6排
* 每次记录当前分配的排号到参数表下次分配前读取参数表上次分配排号
* @param regionCode
* @return
*/
private SchBasePoint getSchBasePointByYL(String regionCode) {
List<PointLeftDto> rowist = pointMapper.findPointRowByCondition(regionCode,0);
if(ObjectUtil.isNotEmpty(rowist)){
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (PointLeftDto pointLeft : rowist) {
map.put(pointLeft.getRow_num(), pointLeft.getLeft_num());
}
Param now_yl_row = paramService.findByCode(GeneralDefinition.NOW_YL_ROW);
Assert.notNull(now_yl_row, "找不到配置文件,请确认系统参数[now_yl_row]配置是否存在!");
//获取上次已分配的排数
Integer row = Integer.valueOf(now_yl_row.getValue());
//最多轮询7次map
int tryTime = 7;
while(tryTime>0){
row = row +1;
if(row>7){
row = row%7;
}
if(map.containsKey(row)){
//分配原料入库点位
SchBasePoint point = pointMapper.findPointByCondition2(regionCode,row);
if(ObjectUtil.isNotEmpty(point)){
//更新参数排号
now_yl_row.setValue(row.toString());
paramService.update(now_yl_row);
return point;
}
}else{
tryTime = tryTime -1;
}
}
}
return null;
}
/**
* 根据区域编码查找合适的点位
* 规则根据启用的原料缓存区的排号顺序分配234一共3排
* 每次记录当前分配的排号到参数表下次分配前读取参数表上次分配排号
* @param regionCode
* @return
*/
private SchBasePoint getSchBasePointByYLHC(String regionCode) {
List<PointLeftDto> rowist = pointMapper.findPointRowByCondition(regionCode,0);
if(ObjectUtil.isNotEmpty(rowist)){
Map<Integer, Integer> map = new HashMap<Integer, Integer>();
for (PointLeftDto pointLeft : rowist) {
map.put(pointLeft.getRow_num(), pointLeft.getLeft_num());
}
Param now_ylhc_row = paramService.findByCode(GeneralDefinition.NOW_YLHC_ROW);
Assert.notNull(now_ylhc_row, "找不到配置文件,请确认系统参数[now_ylhc_row]配置是否存在!");
//获取上次已分配的排数
Integer row = Integer.valueOf(now_ylhc_row.getValue());
//最多轮询7次map
int tryTime = 7;
while(tryTime>0){
row = row +1;
if(row>7){
row = row%7;
}
if(map.containsKey(row)){
//分配原料入库点位
SchBasePoint point = pointMapper.findPointByCondition2(regionCode,row);
if(ObjectUtil.isNotEmpty(point)){
//更新参数排号
now_ylhc_row.setValue(row.toString());
paramService.update(now_ylhc_row);
return point;
}
}else{
tryTime = tryTime -1;
}
}
}
return null;
}
@Override
protected void updateStatus(String task_code, TaskStatus status) {
// 校验任务

5
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.java

@ -3,6 +3,7 @@ package org.nl.wms.sch.task_manage.task.tasks.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.nl.wms.mes.domain.QPMES118ResponseBody;
import org.nl.wms.sch.point.service.dao.SchBasePoint;
import org.nl.wms.sch.point.service.dto.PointLeftDto;
import java.util.List;
@ -16,6 +17,10 @@ public interface PointMapper extends BaseMapper<SchBasePoint> {
List<SchBasePoint> findPointByCondition(String regionCode,String point_status,Integer vehicle_qty);
List<PointLeftDto> findPointRowByCondition(String regionCode, Integer vehicle_qty);
SchBasePoint findPointByCondition2(String regionCode,Integer row_num);
List<SchBasePoint> findPointByParentPoint(String pointCode);
void updatePointStatus(String device_code,String state);

33
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/tasks/mapper/PointMapper.xml

@ -22,7 +22,38 @@
and p.is_used = 1
AND (p.ing_task_code IS NULL or p.ing_task_code = '')
AND (p.vehicle_code2 IS NULL or p.vehicle_code2 = '')
ORDER BY region_code
ORDER BY region_code,p.layer_num,p.row_num,p.col_num
</select>
<select id="findPointRowByCondition" resultType="org.nl.wms.sch.point.service.dto.PointLeftDto">
SELECT
p.row_num,
count(*) as left_num
FROM
`sch_base_point` p
WHERE
p.region_code = #{regionCode}
and p.vehicle_qty = #{vehicle_qty}
and p.is_used = 1
AND (p.ing_task_code IS NULL or p.ing_task_code = '')
AND (p.vehicle_code2 IS NULL or p.vehicle_code2 = '')
group by p.row_num
order by p.row_num
</select>
<select id="findPointByCondition2" resultType="org.nl.wms.sch.point.service.dao.SchBasePoint">
SELECT
p.*
FROM
`sch_base_point` p
WHERE p.region_code = #{regionCode}
and p.row_num = #{row_num}
and p.vehicle_qty = 0
and p.is_used = 1
AND (p.ing_task_code IS NULL or p.ing_task_code = '')
AND (p.vehicle_code2 IS NULL or p.vehicle_code2 = '')
ORDER BY p.layer_num,p.row_num,p.col_num
LIMIT 1
</select>
<select id="findPointByParentPoint" resultType="org.nl.wms.sch.point.service.dao.SchBasePoint">

Loading…
Cancel
Save