zhangjiangwei
2 years ago
9 changed files with 264 additions and 22 deletions
@ -0,0 +1,119 @@ |
|||
package org.nl.wms.sch.tasks; |
|||
|
|||
import cn.hutool.core.util.ObjectUtil; |
|||
import com.alibaba.fastjson.JSONObject; |
|||
import lombok.RequiredArgsConstructor; |
|||
import lombok.extern.slf4j.Slf4j; |
|||
import org.nl.exception.BadRequestException; |
|||
import org.nl.modules.system.util.CodeUtil; |
|||
import org.nl.utils.SpringContextHolder; |
|||
import org.nl.wms.sch.manage.AbstractAcsTask; |
|||
import org.nl.wql.core.bean.WQLObject; |
|||
import org.springframework.stereotype.Service; |
|||
|
|||
import java.util.List; |
|||
import java.util.stream.Collectors; |
|||
|
|||
/** |
|||
* @author zhangjiangwei |
|||
* @date 2023/03/22 08:59 |
|||
*/ |
|||
@Service |
|||
@RequiredArgsConstructor |
|||
@Slf4j |
|||
public class P2PTask extends AbstractAcsTask { |
|||
|
|||
@Override |
|||
public void updateTaskStatus(JSONObject taskJSON, String status) { |
|||
SpringContextHolder.getBean(SendTask.class).updateTaskStatus(taskJSON, status); |
|||
} |
|||
|
|||
@Override |
|||
public void findStartPoint() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void findNextPoint() { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public String createTask(JSONObject param) { |
|||
// 起点
|
|||
String startPointCode = param.getString("start_point_code"); |
|||
|
|||
// 判断起点是否存在
|
|||
JSONObject startPoint = WQLObject |
|||
.getWQLObject("sch_base_point") |
|||
.query("point_code = '" + startPointCode + "'") |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(startPoint)) { |
|||
throw new BadRequestException("未找到起点"); |
|||
} |
|||
|
|||
// 判断起点是否可用
|
|||
if (!"00".equals(startPoint.getString("lock_type"))) { |
|||
throw new BadRequestException(startPoint.getString("point_name") + "已被锁定"); |
|||
} |
|||
if ("00".equals(startPoint.getString("point_status"))) { |
|||
throw new BadRequestException("起点无货"); |
|||
} |
|||
|
|||
// 终点
|
|||
String nextPointCode = param.getString("next_point_code"); |
|||
|
|||
// 判断终点是否存在
|
|||
JSONObject nextPoint = WQLObject |
|||
.getWQLObject("sch_base_point") |
|||
.query("point_code = '" + nextPointCode + "'") |
|||
.uniqueResult(0); |
|||
if (ObjectUtil.isEmpty(nextPoint)) { |
|||
throw new BadRequestException("未找到终点"); |
|||
} |
|||
|
|||
// 判断终点是否可用
|
|||
if (!"00".equals(nextPoint.getString("lock_type"))) { |
|||
throw new BadRequestException(startPoint.getString("point_name") + "已被锁定"); |
|||
} |
|||
if (!"00".equals(nextPoint.getString("point_status"))) { |
|||
throw new BadRequestException("终点有货"); |
|||
} |
|||
|
|||
// 判断终点是否可以存放起点的物料
|
|||
List<String> nextPointMaterial = WQLObject |
|||
.getWQLObject("sch_base_point_material") |
|||
.query("point_id = " + nextPoint.getString("point_id")) |
|||
.getResultJSONArray(0) |
|||
.stream() |
|||
.map(o -> ((JSONObject) o).getString("material")) |
|||
.collect(Collectors.toList()); |
|||
if (!nextPointMaterial.contains(startPoint.getString("current_material_type"))) { |
|||
throw new BadRequestException("终点不能存放起点的物料"); |
|||
} |
|||
|
|||
return SpringContextHolder.getBean(SendTask.class).createTaskRelated( |
|||
startPoint, |
|||
nextPoint, |
|||
param, |
|||
P2PTask.class, |
|||
"03", |
|||
CodeUtil.getNewCode("P2P_BILL_CODE"), |
|||
"0"); |
|||
} |
|||
|
|||
@Override |
|||
public void forceFinish(String task_id) { |
|||
SpringContextHolder.getBean(SendTask.class).forceFinish(task_id); |
|||
} |
|||
|
|||
@Override |
|||
public void pullBack(String task_id) { |
|||
|
|||
} |
|||
|
|||
@Override |
|||
public void cancel(String task_id) { |
|||
|
|||
} |
|||
} |
Loading…
Reference in new issue