|
|
@ -20,6 +20,7 @@ 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; |
|
|
@ -66,17 +67,143 @@ public class XSCKTask extends AbstractTask { |
|
|
|
@Override |
|
|
|
// @Transactional(rollbackFor = Exception.class)
|
|
|
|
protected void create() throws BadRequestException { |
|
|
|
// 获取任务
|
|
|
|
List<SchBaseTask> tasks = taskService.findTasksByTaskStatus(TASK_CONFIG_CODE, TaskStatus.APPLY); |
|
|
|
// 配置信息
|
|
|
|
SchBaseTaskconfig taskConfig = taskConfigService.getOne(new LambdaQueryWrapper<SchBaseTaskconfig>() |
|
|
|
.eq(SchBaseTaskconfig::getConfig_code, TASK_CONFIG_CODE)); |
|
|
|
for (SchBaseTask task : tasks) { |
|
|
|
String extGroupData = task.getExt_group_data(); |
|
|
|
JSONObject jsonObject = JSONObject.parseObject(extGroupData); |
|
|
|
String materialType = jsonObject.getString("material_type"); |
|
|
|
SchBasePoint point = findNextPoint(jsonObject); |
|
|
|
if (ObjectUtil.isEmpty(point)) { |
|
|
|
task.setRemark("未找到所需点位!"); |
|
|
|
taskService.update(task); |
|
|
|
// 消息通知
|
|
|
|
log.info("销售出库未找到当前符合条件的点位materialType:{},", materialType); |
|
|
|
continue; |
|
|
|
} |
|
|
|
// 设置起点并修改创建成功状态
|
|
|
|
task.setPoint_code1(point.getPoint_code()); |
|
|
|
task.setTask_status(TaskStatus.CREATED.getCode()); |
|
|
|
task.setRemark(""); |
|
|
|
taskService.update(task); |
|
|
|
|
|
|
|
//发起任务时先把点位占用,防止发起重复任务
|
|
|
|
point.setIng_task_code(task.getTask_code()); |
|
|
|
point.setVehicle_qty(point.getVehicle_qty() - 1); |
|
|
|
point.setVehicle_type(materialType); |
|
|
|
pointService.update(point); |
|
|
|
|
|
|
|
//下发
|
|
|
|
this.renotifyAcs(task); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private SchBasePoint findNextPoint(SchBasePoint startPoint) { |
|
|
|
/** |
|
|
|
* 判断目标点位 |
|
|
|
* 从10-1查找可以物料一致且有货的点位 |
|
|
|
* |
|
|
|
* @param extGroupData |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
private SchBasePoint findNextPoint(JSONObject extGroupData) { |
|
|
|
String regionCode = "HCQ1"; |
|
|
|
String materialType = extGroupData.getString("material_type"); |
|
|
|
List<SchBasePoint> schBasePointList = pointMapper.findPointByRegion(regionCode,"2"); |
|
|
|
for(int i=schBasePointList.size()-1;i>=0;i--){ |
|
|
|
SchBasePoint schBasePoint=schBasePointList.get(i); |
|
|
|
if (!"1".equals(schBasePoint.getPoint_type())&&schBasePoint.getVehicle_qty()!=0 |
|
|
|
&&ObjectUtil.isEmpty(schBasePoint.getIng_task_code()) |
|
|
|
&&(ObjectUtil.isEmpty(schBasePoint.getVehicle_type())||materialType.equals(schBasePoint.getVehicle_type()))){ |
|
|
|
log.info("销售出库任务找到当前符合条件的缓存区位置{}",schBasePoint.getPoint_code()); |
|
|
|
return schBasePoint; |
|
|
|
} |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 1.取货完毕后起点减少最后一份组盘,并且该组盘视为已结束 |
|
|
|
* 2.销售出库LMS不记录点位信息,由人工对组盘进行操作 |
|
|
|
*/ |
|
|
|
@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(); // 获取起点
|
|
|
|
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)) { // 完成
|
|
|
|
List<String> vehicleCodeList = Arrays.stream(startPointObj.getVehicle_code().split(",")).collect(Collectors.toList()); |
|
|
|
String vehicleCode=vehicleCodeList.get(vehicleCodeList.size()-1); |
|
|
|
SchBaseVehiclematerialgroup one = vehiclematerialgroupService.getOne(new LambdaQueryWrapper<SchBaseVehiclematerialgroup>() |
|
|
|
.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicleCode) |
|
|
|
.eq(SchBaseVehiclematerialgroup::getGroup_bind_material_status, |
|
|
|
GroupBindMaterialStatusEnum.BOUND.getValue())); |
|
|
|
if (ObjectUtil.isEmpty(one)) { |
|
|
|
throw new BadRequestException(vehicleCode + " => " + startPointObj.getVehicle_type() + "的组盘信息未找到"); |
|
|
|
} |
|
|
|
one.setTask_code(taskObj.getTask_code()); |
|
|
|
one.setPoint_code(endPointObj.getPoint_code()); // 当前位置
|
|
|
|
one.setPoint_name(endPointObj.getPoint_name()); |
|
|
|
one.setMove_way(one.getMove_way()==null?"":(one.getMove_way() + " -> ") + endPointObj.getPoint_code()); |
|
|
|
one.setGroup_bind_material_status(GroupBindMaterialStatusEnum.UNBOUND.getValue()); |
|
|
|
one.setUpdate_id(GeneralDefinition.ACS_ID); |
|
|
|
one.setUpdate_name(GeneralDefinition.ACS_NAME); |
|
|
|
one.setUpdate_time(DateUtil.now()); |
|
|
|
vehiclematerialgroupService.updateById(one); |
|
|
|
// 起点清空
|
|
|
|
if (vehicleCodeList.size()==1) { |
|
|
|
startPointObj.setVehicle_code(""); |
|
|
|
}else{ |
|
|
|
StringBuilder vehicle_code=new StringBuilder(); |
|
|
|
for(int i=0;i<=vehicleCodeList.size()-2;i++){ |
|
|
|
vehicle_code.append(vehicleCodeList.get(i)).append(','); |
|
|
|
} |
|
|
|
startPointObj.setVehicle_code(vehicle_code.toString()); |
|
|
|
} |
|
|
|
startPointObj.setIng_task_code(""); |
|
|
|
startPointObj.setUpdate_time(DateUtil.now()); |
|
|
|
pointService.updateById(startPointObj); |
|
|
|
//销售出库完毕后,整排打上记号只允许销售出库
|
|
|
|
pointMapper.updatePointType(endPointObj.getPoint_code().substring(0,endPointObj.getPoint_code().length()-2),"2"); |
|
|
|
// 任务完成
|
|
|
|
taskObj.setTask_status(TaskStatus.FINISHED.getCode()); |
|
|
|
taskObj.setGroup_id(one.getGroup_id()); |
|
|
|
taskObj.setRemark("任务完成"); |
|
|
|
} |
|
|
|
if (status.equals(TaskStatus.CANCELED)) { // 取消
|
|
|
|
// 终点解锁
|
|
|
|
if (ObjectUtil.isNotEmpty(endPointObj)) { |
|
|
|
endPointObj.setIng_task_code(""); |
|
|
|
pointService.update(endPointObj); |
|
|
|
} |
|
|
|
// 起点解锁
|
|
|
|
if (ObjectUtil.isNotEmpty(startPointObj)) { |
|
|
|
startPointObj.setIng_task_code(""); |
|
|
|
startPointObj.setVehicle_qty(startPointObj.getVehicle_qty()+1); |
|
|
|
pointService.update(endPointObj); |
|
|
|
} |
|
|
|
taskObj.setRemark("任务取消"); |
|
|
|
taskObj.setTask_status(TaskStatus.CANCELED.getCode()); |
|
|
|
} |
|
|
|
taskService.update(taskObj); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|