|
|
@ -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) { |
|
|
|
// 校验任务
|
|
|
|