任务管理

This commit is contained in:
2022-10-10 10:58:40 +08:00
parent bd9e684477
commit 2160e93d77
21 changed files with 491 additions and 1400 deletions

View File

@@ -5,7 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.sch.AcsUtil;
import org.nl.wms.sch.manage.AcsUtil;
import org.springframework.stereotype.Service;
import java.util.Map;

View File

@@ -8,7 +8,6 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.ext.acs.service.WmsToAcsService;
import org.nl.wms.sch.tasks.PointToPointTask;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;

View File

@@ -1,13 +1,23 @@
package org.nl.wms.pda.mps.service.impl;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.wms.ext.acs.service.AcsToWmsService;
import org.nl.wms.pda.mps.service.RawFoilService;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.dto.PointDto;
import org.nl.wms.sch.tasks.CallEmpReelTask;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -16,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
@Slf4j
public class RawFoilServiceImpl implements RawFoilService {
private final AcsToWmsService acsToWmsService;
private final PointService pointService;
@Override
public JSONObject queryProductArea() {
@@ -71,21 +82,114 @@ public class RawFoilServiceImpl implements RawFoilService {
}
@Override
@Transactional(rollbackFor = Exception.class)
public JSONObject needEmptyAxis(JSONObject whereJson) {
JSONObject result = new JSONObject();
JSONArray rows = new JSONArray();
result.put("rows", rows);
result.put("code", "1");
result.put("desc", "查询成功");
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
String end_pint_code = whereJson.getString("end_pint_code");
try {
if (ObjectUtil.isEmpty(end_pint_code)) throw new BadRequestException("终点点位不能为空");
String start_pint_code = "";
// 1.查询此点位是否存在
PointDto jsonPoint = pointService.findByCode(end_pint_code);
if (ObjectUtil.isEmpty(jsonPoint)) throw new BadRequestException("此点位不存在");
// 2.根据就近原则查对应空卷抽
JSONObject map = new JSONObject();
map.put("flag", "1");
map.put("product_area",jsonPoint.getProduct_area());
map.put("point_location",jsonPoint.getPoint_location());
JSONObject jsonIvt = WQL.getWO("PDA_01").addParamMap(map).process().uniqueResult(0);
// 3.如果没找到则继续找下一节点
if (ObjectUtil.isEmpty(jsonIvt)) {
String point_location = jsonPoint.getPoint_location();
if (StrUtil.equals(point_location, "0")) map.put("point_location","1");
if (StrUtil.equals(point_location, "1")) map.put("point_location","0");
JSONObject jsonIvt_tow = WQL.getWO("PDA_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonIvt_tow)) throw new BadRequestException("库存不足");
start_pint_code = jsonIvt_tow.getString("point_code");
} else {
start_pint_code = jsonIvt.getString("point_code");
}
// 起点和终点确定 生成任务
JSONObject param = new JSONObject();
param.put("start_pint_code",start_pint_code);
param.put("end_pint_code",end_pint_code);
CallEmpReelTask callEmpReelTask = new CallEmpReelTask();
String taskdtl_id = callEmpReelTask.createTask(param);
// 下发任务
JSONObject jsonObject = callEmpReelTask.renotifyAcs(taskdtl_id);
if (StrUtil.equals(jsonObject.getString("status"), "200")) {
// 成功返回 更新任务状态
JSONObject jsonTask = taskTab.query("taskdtl_id ='" + taskdtl_id + "'").uniqueResult(0);
jsonTask.put("task_status", "05");
taskTab.update(jsonTask);
}
result.put("rows", rows);
result.put("code", "1");
result.put("desc", "操作成功");
} catch (Exception e) {
result.put("rows", rows);
result.put("code", "0");
result.put("desc", "操作失败:"+e.getMessage());
}
return result;
}
@Override
public JSONObject confirmBlanking(JSONObject whereJson) {
JSONObject result = new JSONObject();
String start_pint_code = whereJson.getString("start_pint_code");
JSONObject result = new JSONObject();
JSONArray rows = new JSONArray();
try {
if (ObjectUtil.isEmpty(start_pint_code)) throw new BadRequestException("起点不能为空");
String end_pint_code ="";
// 1.查询此点位是否存在
PointDto jsonPoint = pointService.findByCode(start_pint_code);
if (ObjectUtil.isEmpty(jsonPoint)) throw new BadRequestException("起点点位不存在");
// 2.根据就近原则查对应空卷抽
JSONObject map = new JSONObject();
map.put("flag", "2");
map.put("product_area",jsonPoint.getProduct_area());
map.put("point_location",jsonPoint.getPoint_location());
JSONObject jsonIvt = WQL.getWO("PDA_01").addParamMap(map).process().uniqueResult(0);
// 3.如果没找到则继续找下一节点
if (ObjectUtil.isEmpty(jsonIvt)) {
String point_location = jsonPoint.getPoint_location();
if (StrUtil.equals(point_location, "0")) map.put("point_location","1");
if (StrUtil.equals(point_location, "1")) map.put("point_location","0");
JSONObject jsonIvt_tow = WQL.getWO("PDA_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonIvt_tow)) throw new BadRequestException("没有空位");
end_pint_code = jsonIvt_tow.getString("point_code");
} else {
end_pint_code = jsonIvt.getString("point_code");
}
// 4.起点和终点确定 生成任务
// 5.插入入库单
// 6.下发任务
} catch (Exception e) {
}
result.put("rows", rows);
result.put("code", "1");
result.put("desc", "查询成功");
@@ -114,5 +218,29 @@ public class RawFoilServiceImpl implements RawFoilService {
return result;
}
@Transactional(rollbackFor = Exception.class)
public String createTask(JSONObject param) {
WQLObject tab = WQLObject.getWQLObject("SCH_BASE_Task");
Long currentUserId = SecurityUtils.getCurrentUserId();
String currentUsername = SecurityUtils.getCurrentUsername();
JSONObject json = new JSONObject();
json.put("taskdtl_id", IdUtil.getSnowflake(1,1).nextId());
json.put("task_id",json.getString("taskdtl_id"));
json.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
json.put("task_type", "05");
json.put("task_status", "01");
json.put("start_point_code", param.getString("start_pint_code"));
json.put("next_point_code", param.getString("end_pint_code"));
json.put("handle_class", "0");
json.put("create_id", currentUserId);
json.put("create_name", currentUsername);
json.put("create_time", DateUtil.now());
json.put("priority","1" );
json.put("acs_task_type","1" );
tab.insert(json);
return json.getString("taskdtl_id");
}
}

View File

@@ -0,0 +1,87 @@
[交易说明]
交易名: 手持接口
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.product_area TYPEAS s_string
输入.point_location TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
QUERY
SELECT
ivt.*
FROM
ST_IVT_CoolPointIvt ivt
WHERE
ivt.empty_point_status = '02'
OPTION 输入.product_area <> ""
ivt.product_area = 输入.product_area
ENDOPTION
OPTION 输入.point_location <> ""
ivt.point_location = 输入.point_location
ENDOPTION
order by ivt.point_code ASC
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT
ivt.*
FROM
ST_IVT_CoolPointIvt ivt
WHERE
ivt.full_point_status = '01'
OPTION 输入.product_area <> ""
ivt.product_area = 输入.product_area
ENDOPTION
OPTION 输入.point_location <> ""
ivt.point_location = 输入.point_location
ENDOPTION
order by ivt.point_code ASC
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -3,8 +3,6 @@ package org.nl.wms.sch.manage;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.wms.sch.AcsUtil;
import org.nl.wms.sch.tasks.AcsTaskDto;
import org.nl.modules.wql.core.bean.WQLObject;
import java.util.ArrayList;

View File

@@ -1,4 +1,4 @@
package org.nl.wms.sch.tasks;
package org.nl.wms.sch.manage;
import lombok.Data;

View File

@@ -1,5 +1,5 @@
package org.nl.wms.sch;
package org.nl.wms.sch.manage;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;

View File

@@ -1,4 +1,4 @@
package org.nl.wms.sch.tasks;
package org.nl.wms.sch.manage;
/**
* 任务状态枚举

View File

@@ -13,7 +13,7 @@ import org.nl.wms.sch.manage.FinishTypeEnum;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.TaskService;
import org.nl.wms.sch.service.dto.TaskDto;
import org.nl.wms.sch.tasks.TaskTypeEnum;
import org.nl.wms.sch.manage.TaskTypeEnum;
import org.springframework.data.domain.Pageable;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;

View File

@@ -0,0 +1,128 @@
package org.nl.wms.sch.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.dto.PointDto;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@RequiredArgsConstructor
@Slf4j
public class BookTwoConfirmTask extends AbstractAcsTask {
private final String THIS_CLASS = BookTwoConfirmTask.class.getName();
@Override
@Transactional
public void updateTaskStatus(JSONObject taskObj, String status) {
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_CoolPointIvt");
String task_id = taskObj.getString("task_id");
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
if (StrUtil.equals(status,"0")) {
// 取消删除任务
taskTab.delete("task_id = '"+task_id+"'");
}
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) {
// 更新任务状态为执行中
jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode());
jsonTask.put("update_time", DateUtil.now());
taskTab.update(jsonTask);
}
if(StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) {
// 更改任务状态为完成
jsonTask.put("task_status",TaskStatusEnum.FINISHED.getCode());
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId());
jsonTask.put("update_optname", SecurityUtils.getCurrentUsername());
jsonTask.put("update_time", DateUtil.now());
taskTab.update(jsonTask);
String start_point_code = jsonTask.getString("start_point_code");
PointService point = SpringContextHolder.getBean(PointService.class);
// 校验起点是否存在
PointDto startDto = point.findByCode(start_point_code);
if (ObjectUtil.isEmpty(startDto)) throw new BadRequestException("未找到可用点位:" + startDto);
// 校验终点是否存在
PointDto nextDto = point.findByCode(jsonTask.getString("next_point_code"));
if (ObjectUtil.isEmpty(nextDto)) throw new BadRequestException("未找到可用点位:" + nextDto);
// 更新冷却库存状态
JSONObject jsonIvt = ivtTab.query("point_code ='" + start_point_code + "'").uniqueResult(0);
jsonIvt.put("empty_point_status", "01");
ivtTab.update(jsonIvt);
}
}
@Override
public void findStartPoint() {
}
@Override
public void findNextPoint() {
}
@Override
@Transactional
public String createTask(JSONObject form) {
WQLObject tab = WQLObject.getWQLObject("SCH_BASE_Task");
Long currentUserId = SecurityUtils.getCurrentUserId();
String currentUsername = SecurityUtils.getCurrentUsername();
JSONObject json = new JSONObject();
json.put("taskdtl_id", IdUtil.getSnowflake(1,1).nextId());
json.put("task_id",json.getString("taskdtl_id"));
json.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
json.put("task_type", "05");
json.put("task_status", "01");
json.put("start_point_code", form.getString("start_pint_code"));
json.put("next_point_code", form.getString("end_pint_code"));
json.put("handle_class", THIS_CLASS);
json.put("create_id", currentUserId);
json.put("create_name", currentUsername);
json.put("create_time", DateUtil.now());
json.put("priority","1" );
json.put("acs_task_type","1" );
tab.insert(json);
return json.getString("taskdtl_id");
}
@Override
@Transactional
public void forceFinish(String task_id) {
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
}
@Override
public void pullBack(String task_id) {
}
@Override
public void cancel(String task_id) {
}
}

View File

@@ -0,0 +1,138 @@
package org.nl.wms.sch.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.basedata.master.service.StoragevehicleinfoService;
import org.nl.wms.basedata.master.service.dto.StoragevehicleinfoDto;
import org.nl.wms.pdm.service.DeviceService;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.dto.PointDto;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.HashMap;
@Service
@RequiredArgsConstructor
@Slf4j
public class CallEmpReelTask extends AbstractAcsTask {
private final String THIS_CLASS = CallEmpReelTask.class.getName();
@Override
@Transactional
public void updateTaskStatus(JSONObject taskObj, String status) {
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
WQLObject ivtTab = WQLObject.getWQLObject("ST_IVT_CoolPointIvt");
String task_id = taskObj.getString("task_id");
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
if (StrUtil.equals(status,"0")) {
// 取消删除任务
taskTab.delete("task_id = '"+task_id+"'");
}
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) {
// 更新任务状态为执行中
jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode());
jsonTask.put("update_time", DateUtil.now());
taskTab.update(jsonTask);
}
if(StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) {
// 更改任务状态为完成
jsonTask.put("task_status",TaskStatusEnum.FINISHED.getCode());
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId());
jsonTask.put("update_optname", SecurityUtils.getCurrentUsername());
jsonTask.put("update_time", DateUtil.now());
taskTab.update(jsonTask);
String start_point_code = jsonTask.getString("start_point_code");
PointService point = SpringContextHolder.getBean(PointService.class);
// 校验起点是否存在
PointDto startDto = point.findByCode(start_point_code);
if (ObjectUtil.isEmpty(startDto)) throw new BadRequestException("未找到可用点位:" + startDto);
// 校验终点是否存在
PointDto nextDto = point.findByCode(jsonTask.getString("next_point_code"));
if (ObjectUtil.isEmpty(nextDto)) throw new BadRequestException("未找到可用点位:" + nextDto);
// 更新冷却库存状态
JSONObject jsonIvt = ivtTab.query("point_code ='" + start_point_code + "'").uniqueResult(0);
jsonIvt.put("empty_point_status", "01");
ivtTab.update(jsonIvt);
}
}
@Override
public void findStartPoint() {
}
@Override
public void findNextPoint() {
}
@Override
@Transactional
public String createTask(JSONObject form) {
WQLObject tab = WQLObject.getWQLObject("SCH_BASE_Task");
Long currentUserId = SecurityUtils.getCurrentUserId();
String currentUsername = SecurityUtils.getCurrentUsername();
JSONObject json = new JSONObject();
json.put("taskdtl_id", IdUtil.getSnowflake(1,1).nextId());
json.put("task_id",json.getString("taskdtl_id"));
json.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
json.put("task_type", "05");
json.put("task_status", "01");
json.put("start_point_code", form.getString("start_pint_code"));
json.put("next_point_code", form.getString("end_pint_code"));
json.put("handle_class", THIS_CLASS);
json.put("create_id", currentUserId);
json.put("create_name", currentUsername);
json.put("create_time", DateUtil.now());
json.put("priority","1" );
json.put("acs_task_type","1" );
tab.insert(json);
return json.getString("taskdtl_id");
}
@Override
@Transactional
public void forceFinish(String task_id) {
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
}
@Override
public void pullBack(String task_id) {
}
@Override
public void cancel(String task_id) {
}
}

View File

@@ -1,292 +0,0 @@
package org.nl.wms.sch.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.pdm.service.DeviceService;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.dto.PointDto;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
@Service
@RequiredArgsConstructor
@Slf4j
public class CallEmpVehicleTask extends AbstractAcsTask {
private final String THIS_CLASS = CallEmpVehicleTask.class.getName();
@Override
@Transactional
public void updateTaskStatus(JSONObject taskObj, String status) {
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject empTab = WQLObject.getWQLObject("st_ivt_EmptyVehicleRecord");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
String task_id = taskObj.getString("task_id");
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
if (StrUtil.equals(status,"0")) {
// 取消删除任务
taskTab.delete("task_id = '"+task_id+"'");
}
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) {
// 更新任务状态为执行中
jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode());
jsonTask.put("update_time", DateUtil.now());
jsonTask.put("car_no", taskObj.getString("car_no"));
taskTab.update(jsonTask);
}
if(StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) {
// 更改任务状态为完成
jsonTask.put("task_status",TaskStatusEnum.FINISHED.getCode());
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId());
jsonTask.put("update_optname", SecurityUtils.getCurrentUsername());
jsonTask.put("update_time", DateUtil.now());
taskTab.update(jsonTask);
PointService point = SpringContextHolder.getBean(PointService.class);
// 校验起点是否存在
PointDto start_point_code = point.findByCode(jsonTask.getString("start_point_code"));
if (ObjectUtil.isEmpty(start_point_code)) throw new BadRequestException("未找到可用点位:" + start_point_code);
// 校验终点是否存在
PointDto next_point_code = point.findByCode(jsonTask.getString("next_point_code"));
if (ObjectUtil.isEmpty(start_point_code)) throw new BadRequestException("未找到可用点位:" + next_point_code);
// 1.更新点位数量 2.解锁点位
JSONObject jsonEmp = empTab.query("task_uuid = '" + task_id + "'").uniqueResult(0);
int vehicle_qty = JSONObject.parseObject(JSON.toJSONString(start_point_code)).getIntValue("vehicle_qty");
BigDecimal vehicle_qty_point = NumberUtil.sub(String.valueOf(vehicle_qty), String.valueOf(jsonEmp.getIntValue("vehicle_qty")));
start_point_code.setVehicle_qty(Integer.valueOf(vehicle_qty_point.toString()));
if (StrUtil.equals(vehicle_qty_point.toString(), "0")) {
start_point_code.setPoint_status("00");
start_point_code.setVehicle_type("");
}
start_point_code.setLock_type("00");
pointTab.update(JSONObject.parseObject(JSON.toJSONString(start_point_code)));
// 完成单据状态
jsonEmp.put("bill_status", "50");
jsonEmp.put("update_optid", SecurityUtils.getCurrentUserId());
jsonEmp.put("update_optname", SecurityUtils.getCurrentUsername());
jsonEmp.put("update_time", DateUtil.now());
empTab.update(jsonEmp);
}
}
@Override
public void findStartPoint() {
}
@Override
public void findNextPoint() {
}
@Override
@Transactional
public String createTask(JSONObject form) {
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject empTab = WQLObject.getWQLObject("st_ivt_EmptyVehicleRecord");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
String start_point_code = form.getString("start_point_code");
String next_point_code = form.getString("next_point_code");
String qty = form.getString("qty");
String record_uuid = form.getString("record_uuid");
String vehicle_type = form.getString("vehicle_type");
// 出库终点不能为空
if (ObjectUtil.isEmpty(next_point_code)) {
throw new BadRequestException("终点不能为空");
} else {
// 判断终点是否有正在执行的任务
JSONObject beforTaskObj = taskTab.query("is_delete='0' and next_point_code='" + next_point_code + "' and task_status <>'" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(beforTaskObj)) throw new BadRequestException("存在指令号为'" + beforTaskObj.getString("task_code") + "' 未完成!");
}
// 载具数量不能为空
if (ObjectUtil.isEmpty(qty)) throw new BadRequestException("载具数量不能为空");
/*
* 1. 点对点: 起点和终点都确定,直接创建任务
* 2. 终点确定: 需要找到对应起点,在创建任务 具体找起点货位的规则在findBeginPoint()中
*/
// 终点确定:找起点
if (ObjectUtil.isEmpty(start_point_code)) {
JSONObject param = new JSONObject();
param.put("next_point_code",next_point_code);
param.put("vehicle_qty",qty);
JSONObject json = this.findBeginPoint(param);
start_point_code = json.getString("start_point_code");
vehicle_type = json.getString("vehicle_type");
} else {
// 判断终点是否是空位
JSONObject jsonPoint = pointTab.query("point_code = '" + start_point_code + "' and lock_type = '00' and point_status <> '02' and is_delete = '0' and is_used = '1'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonPoint)) throw new BadRequestException("起点点位不可用或不存在");
}
// 创建任务
JSONObject jsonTask = new JSONObject();
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
jsonTask.put("task_id", task_id);
jsonTask.put("taskdtl_id", task_id);
jsonTask.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
jsonTask.put("task_type", "04");
jsonTask.put("taskdtl_type", "04");
jsonTask.put("task_status", "01");
jsonTask.put("start_point_code", start_point_code);
jsonTask.put("next_point_code", next_point_code);
jsonTask.put("handle_class", THIS_CLASS);
jsonTask.put("vehicle_type", vehicle_type);
jsonTask.put("create_name", SecurityUtils.getCurrentUsername());
jsonTask.put("create_id", SecurityUtils.getCurrentUserId());
jsonTask.put("create_time", DateUtil.now());
jsonTask.put("acs_task_type", "1");
taskTab.insert(jsonTask);
// 锁定起点点位
JSONObject jsonPoint = pointTab.query("point_code = '" + start_point_code + "'").uniqueResult(0);
jsonPoint.put("lock_type", "02");
pointTab.update(jsonPoint);
// 更新空载具单据状态
if (ObjectUtil.isNotEmpty(record_uuid)) {
JSONObject jsonEmp = empTab.query("record_uuid ='" + record_uuid + "'").uniqueResult(0);
jsonEmp.put("bill_status","20");
empTab.update(jsonEmp);
}
return task_id;
}
@Override
@Transactional
public void forceFinish(String task_id) {
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
}
@Override
public void pullBack(String task_id) {
}
@Override
public void cancel(String task_id) {
}
@Transactional
public JSONObject findBeginPoint(JSONObject json) {
String next_point_code = json.getString("next_point_code");
String vehicle_qty = json.getString("vehicle_qty");
if (ObjectUtil.isEmpty(next_point_code)) throw new BadRequestException("终点不能为空");
if (ObjectUtil.isEmpty(vehicle_qty)) throw new BadRequestException("载具数量不能为空");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
WQLObject regionTab = WQLObject.getWQLObject("SCH_BASE_Region");
WQLObject orderTab = WQLObject.getWQLObject("mps_bd_produceshiftorder");
// 根据终点区域判断优先的起点区域
JSONObject jsonPointEnd = pointTab.query("point_code = '" + next_point_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonPointEnd)) throw new BadRequestException("终点点位不存在");
JSONObject jsonRegionEnd = regionTab.query("region_id ='" + jsonPointEnd.getString("region_id") + "'").uniqueResult(0);
// 根据起点找到对应设备,根据设备查询工单表中 - 正在运行的工单中的载具类型
String device_code = next_point_code.substring(0, next_point_code.indexOf("_"));
DeviceService deviceBean = SpringContextHolder.getBean(DeviceService.class);
DeviceDto deviceDto = deviceBean.findByCode(device_code);
if (ObjectUtil.isEmpty(deviceDto)) throw new BadRequestException("此设备不存在");
JSONObject jsonOrder = orderTab.query("device_id = '" + deviceDto.getDevice_id() + "' and order_status = '02' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonOrder)) throw new BadRequestException("此设备未在生产中或不存在");
/*
* 空托盘出库任务:
* 1.叠盘架B区、养生A区 --> 共挤线 优先级1叠盘架B区 2养生A区
* 2.叠盘架A区、养生A区 --> 油漆线 优先级1叠盘架A区 2养生A区
*/
String start_point_code = "";
JSONObject map = new JSONObject();
if (StrUtil.equals(jsonRegionEnd.getString("region_code"),RegionTypeEnum.GJQY.getCode())) {
// 共挤线呼叫空托盘业务查找叠盘架B区是否有满足条件的点位
map.put("flag", "1");
map.put("vehicle_qty", vehicle_qty);
map.put("vehicle_type", jsonOrder.getString("vehicle_type"));
map.put("region_code", RegionTypeEnum.DPJQB.getCode());
JSONObject jsonStartPointDPB = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonStartPointDPB)) {
start_point_code = jsonStartPointDPB.getString("point_code");
} else {
// 为空说明叠盘架B区没有则去养生A区找 : 只能找数量为1的空托盘
map.put("flag", "3");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
JSONObject jsonStartPointYSA = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonStartPointYSA)) {
start_point_code = jsonStartPointYSA.getString("point_code");
} else {
throw new BadRequestException("没有满足需求数量的点位");
/* // 如果没有则需要从养生区A区里找到 > 1的货位 出库到叠盘架B中
map.put("flag", "1");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
// 起点
JSONObject jsonStart = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonStart)) throw new BadRequestException("没有满足需求数量的点位");
// 终点
JSONObject jsonEnd = pointTab.query("region_id = '" + RegionTypeEnum.DPJQB.getId() + "' and point_status = '00' and lock_type = '00' and is_used = '1' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEnd)) throw new BadRequestException("叠盘架B货位不足");
JSONObject parem = new JSONObject();
parem.put("start_point_code",jsonStart.getString("point_code"));
parem.put("next_point_code",jsonEnd.getString("point_code"));
parem.put("qty",jsonStart.getString("vehicle_qty"));
parem.put("vehicle_type",jsonStart.getString("vehicle_qty"));
String task_id = this.createTask(parem);
// 生成 叠盘架 -> 共挤线的任务 返回叠盘架B的点位code
start_point_code = jsonEnd.getString("point_code");*/
}
}
} else if (StrUtil.equals(jsonRegionEnd.getString("region_code"),RegionTypeEnum.YQQY.getCode())) {
// 油漆线呼叫空托盘业务查找叠盘架A区是否有满足条件的点位
map.put("flag", "1");
map.put("vehicle_qty", vehicle_qty);
map.put("vehicle_type", jsonOrder.getString("vehicle_type"));
map.put("region_code", RegionTypeEnum.DPJQA.getCode());
JSONObject jsonStartPointDPA = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonStartPointDPA)) {
start_point_code = jsonStartPointDPA.getString("point_code");
} else {
// 为空说明叠盘架A区没有则去养生A区找
map.put("flag", "3");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
JSONObject jsonStartPointYSA = WQL.getWO("ST_VEHICLE_OUT_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonStartPointYSA)) throw new BadRequestException("没有满足需求数量的点位");
start_point_code = jsonStartPointYSA.getString("point_code");
}
}
JSONObject resuft = new JSONObject();
resuft.put("start_point_code",start_point_code);
resuft.put("vehicle_type",jsonOrder.getString("vehicle_type"));
return resuft;
}
}

View File

@@ -1,306 +0,0 @@
package org.nl.wms.sch.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.basedata.st.IvtChangeTypeEnum;
import org.nl.wms.basedata.st.StoreIvtServiceImpl;
import org.nl.wms.common.StructFindUtil;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.dto.PointDto;
import org.nl.wms.sch.service.impl.PointServiceImpl;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
@Service
public class CallMaterialTask extends AbstractAcsTask {
private final String THIS_CLASS = CallMaterialTask.class.getName();
@Override
@Transactional
public void updateTaskStatus(JSONObject taskObj, String status) {
/**
*改变任务状态
**/
String task_id = taskObj.getString("task_id");
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
JSONObject jsonTask = taskTab.query("task_id='" + task_id + "'").uniqueResult(0);
if (StrUtil.equals(status,"0")) {
// 取消删除任务
taskTab.delete("task_id = '"+task_id+"'");
}
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) {
//更新任务状态为执行中
jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode());
jsonTask.put("update_time", DateUtil.now());
jsonTask.put("car_no", taskObj.getString("car_no"));
taskTab.update(jsonTask);
HashMap map = new HashMap();
map.put("bill_status", "40");
map.put("update_optid", SecurityUtils.getCurrentUserId());
map.put("update_optname", SecurityUtils.getCurrentNickName());
map.put("update_time", DateUtil.now());
WQLObject.getWQLObject("ST_IVT_regionIO").update(map, "task_id='" + jsonTask.getString("task_id") + "'");
}
if (TaskStatusEnum.FINISHED.getCode().equals(status)) {
// 更新任务状态为完成
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode());
jsonTask.put("taskfinish_mode", taskObj.getString("taskfinish_mode"));
jsonTask.put("update_time", DateUtil.now());
jsonTask.put("remark", "任务执行完成");
///审核单据 增加库存 改变出入库表的状态
WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_regionIO");
JSONObject mstObj = mstTab.query("task_id='" + task_id + "' and is_delete='0'").uniqueResult(0);
//审核 加库存可和用数量
StoreIvtServiceImpl ivtService = new StoreIvtServiceImpl();
mstObj.put("bill_status", "50");
mstObj.put("confirm_optid", SecurityUtils.getCurrentUserId());
mstObj.put("confirm_optname", SecurityUtils.getCurrentNickName());
mstObj.put("confirm_time", DateUtil.now());
mstTab.update(mstObj);
String iostorinv_id = mstObj.getString("iostorinv_id");
String next_point_code = mstObj.getString("end_point_code");
String start_point_code = mstObj.getString("start_point_code");
JSONObject param = new JSONObject();
param.put("material_id", mstObj.getString("material_id"));
param.put("bill_id", iostorinv_id);
param.put("qty_unit_id", mstObj.getString("qty_unit_id"));
param.put("pcsn", mstObj.getString("pcsn"));
param.put("change_qty", mstObj.getString("qty"));
param.put("vehicle_code", mstObj.getString("vehicle_code"));
PointServiceImpl pointService = SpringContextHolder.getBean(PointServiceImpl.class);
PointDto nextPointDto = pointService.findByCode(next_point_code);
if (ObjectUtil.isNull(nextPointDto)) {
throw new BadRequestException("未找到可用点位:" + next_point_code);
}
PointDto startPointDto = pointService.findByCode(start_point_code);
if (ObjectUtil.isNull(startPointDto)) {
throw new BadRequestException("未找到可用点位:" + start_point_code);
}
param.put("struct_id", startPointDto.getPoint_id());
ivtService.addIvtFlow(param, IvtChangeTypeEnum.SUB_IVT);
//解锁仓位,托盘信息,回写到点位上去
String vehicle_code = jsonTask.getString("vehicle_code");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
JSONObject startPointObj = pointTab.query("point_code='" + jsonTask.getString("start_point_code") + "'").uniqueResult(0);
startPointObj.put("lock_type", "00");
startPointObj.put("point_status", "00");
startPointObj.put("vehicle_code", "");
startPointObj.put("vehicle_type", "");
pointTab.update(startPointObj);
taskTab.update(jsonTask);
}
}
@Override
public void findStartPoint() {
String task_status = TaskStatusEnum.SURE_START.getCode();
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
JSONArray taskArry = taskTab.query("task_status='" + task_status + "' AND handle_class='" + THIS_CLASS + "' AND is_delete='0' ").getResultJSONArray(0);
for (int i = 0; i < taskArry.size(); i++) {
JSONObject taskObj = taskArry.getJSONObject(i);
String task_id = taskObj.getString("task_id");
//1 将任务修改为分配 2将终点写入完成分配3 加锁点位
//找一个合适的仓位
WQLObject ProcedureIOStable = WQLObject.getWQLObject("ST_IVT_regionIO");
JSONObject IosObj = ProcedureIOStable.query("task_id='" + task_id + "' and is_delete ='0'").uniqueResult(0);
if (ObjectUtil.isEmpty(IosObj)) {
throw new BadRequestException("未找到任务号为'" + taskObj.getString("task_code") + "'的入库单据!");
}
JSONObject param = new JSONObject();
param.put("material_id", IosObj.getString("material_id"));
param.put("area_type", IosObj.getString("start_area"));
JSONObject inStructObj = StructFindUtil.getOutStruct(param);
if (ObjectUtil.isEmpty(inStructObj)) {
throw new BadRequestException("未找到合适的出库仓位!");
}
//修改单据状态,将终点填入
IosObj.put("bill_status", "20");
IosObj.put("start_point_code", inStructObj.getString("struct_code"));
ProcedureIOStable.update(IosObj);
//终点加锁
HashMap lock_map = new HashMap();
lock_map.put("lock_type", "01");
WQLObject.getWQLObject("sch_base_point").update(lock_map, "point_code = '" + inStructObj.getString("struct_code") + "'");
//修改任务状态
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
taskObj.put("update_optid", SecurityUtils.getCurrentUserId());
taskObj.put("update_optname", SecurityUtils.getCurrentNickName());
taskObj.put("update_time", DateUtil.now());
taskTab.update(taskObj);
}
}
@Override
public void findNextPoint() {
}
@Override
@Transactional
public String createTask(JSONObject form) {
//请求参数 载具、起点、终点
String vehicle_code = form.getString("vehicle_code");
String start_point_code = form.getString("start_point_code");
String next_point_code = form.getString("next_point_code");
String vehicle_type = form.getString("vehicle_type");
String task_status = TaskStatusEnum.START_AND_POINT.getCode();
String material_id = form.getString("material_id");
String create_mode = form.getString("create_mode");
String iostorinv_id = form.getString("iostorinv_id");
WQLObject taskTable = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject regionTable = WQLObject.getWQLObject("ST_IVT_regionIO");
if (StrUtil.isEmpty(next_point_code)) {
throw new BadRequestException("终点不能为空!");
}
if (StrUtil.isEmpty(material_id)) {
throw new BadRequestException("物料标识不能为空!");
}
if (StrUtil.isEmpty(create_mode)) {
throw new BadRequestException("创建方式不能为空!");
}
//判断终点有没有未完成的指令
JSONObject beforTaskObj = taskTable.
query("is_delete='0' and next_point_code='" + next_point_code + "' and task_status <>'" + TaskStatusEnum.FINISHED.getCode() + "'")
.uniqueResult(0);
if (ObjectUtil.isNotEmpty(beforTaskObj)) {
throw new BadRequestException("存在指令号为'" + beforTaskObj.getString("task_code") + "' 未完成!");
}
PointServiceImpl pointService = SpringContextHolder.getBean(PointServiceImpl.class);
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
String start_area = "";
String qty = "";
String qty_unit_id = "";
if (StrUtil.isEmpty(start_point_code)) {
// 起点为空找到对应的起点
JSONObject param = new JSONObject();
param.put("next_point_code",next_point_code);
param.put("vehicle_type",vehicle_type);
param.put("material_id",material_id);
JSONObject ivtObj = this.findBeginPoint(param);
qty = ivtObj.getString("canuse_qty");
qty_unit_id = ivtObj.getString("qty_unit_id");
start_point_code = ivtObj.getString("struct_code");
} else {
// 不能空则为点对点,查找对应出入库单据
if (ObjectUtil.isEmpty(iostorinv_id)) throw new BadRequestException("出库单id不能为空");
JSONObject jsonRegion = regionTable.query("iostorinv_id = '" + iostorinv_id + "'").uniqueResult(0);
qty = jsonRegion.getString("qty");
qty_unit_id = jsonRegion.getString("qty_unit_id");
}
PointDto startPoint = pointService.findByCode(start_point_code);
//起点点加锁
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point");
JSONObject startPointObj = pointTable.query("point_code='" + start_point_code + "'").uniqueResult(0);
startPointObj.put("lock_type", "01");
pointTable.update(startPointObj);
//减少库存可用数量
StoreIvtServiceImpl ivtService = new StoreIvtServiceImpl();
JSONObject param = new JSONObject();
param.put("material_id", material_id);
param.put("bill_id", iostorinv_id);
param.put("qty_unit_id", qty_unit_id);
param.put("change_qty", qty);
param.put("struct_id", startPoint.getPoint_id());
param.put("vehicle_code", startPoint.getVehicle_code());
ivtService.addIvtFlow(param, IvtChangeTypeEnum.SUB_CAN_USE);
JSONObject taskObj = new JSONObject();
taskObj.put("task_id", task_id);
taskObj.put("taskdtl_id", task_id);
taskObj.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
taskObj.put("task_type", "02");
taskObj.put("taskdtl_type", "02");
taskObj.put("task_status", task_status);
taskObj.put("start_point_code", start_point_code);
taskObj.put("start_area", start_area);
taskObj.put("request_param", form.toJSONString());
taskObj.put("next_point_code", next_point_code);
taskObj.put("vehicle_code", vehicle_code);
taskObj.put("handle_class", THIS_CLASS);
taskObj.put("is_auto_issue", "1");
taskObj.put("create_name", SecurityUtils.getCurrentUsername());
taskObj.put("create_id", SecurityUtils.getCurrentUserId());
taskObj.put("create_time", DateUtil.now());
taskObj.put("is_delete", "0");
taskTable.insert(taskObj);
return task_id;
}
@Override
public void forceFinish(String task_id) {
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
}
@Override
public void pullBack(String task_id) {
}
@Override
public void cancel(String task_id) {
}
@Transactional
public JSONObject findBeginPoint(JSONObject json) {
String next_point_code = json.getString("next_point_code");
String vehicle_type = json.getString("vehicle_type");
String material_id = json.getString("material_id");
WQLObject regionTab = WQLObject.getWQLObject("SCH_BASE_Region");
// 根据起点判断是什么区域 然后要入到什么区
PointDto endDto = SpringContextHolder.getBean(PointService.class).findByCode(next_point_code);
if (ObjectUtil.isEmpty(endDto)) throw new BadRequestException("终点点位不存在");
JSONObject jsonEndRegion = regionTab.query("region_id = '" + endDto.getRegion_id() + "'").uniqueResult(0);
/*
* 物料出库业务目前只有1个业务如果区域不正确则报错
* 1.养生A区 --> 油漆线
*/
JSONObject resuft = new JSONObject();
if (StrUtil.equals(jsonEndRegion.getString("region_code"),RegionTypeEnum.YQQY.getCode())) {
JSONObject map = new JSONObject();
map.put("flag", "3");
map.put("vehicle_type", vehicle_type);
map.put("material_id", material_id);
map.put("region_code", RegionTypeEnum.YSQA.getCode());
resuft = WQL.getWO("ST_REGION_OUT_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(resuft)) throw new BadRequestException("库存不足");
} else {
throw new BadRequestException("业务类型错误");
}
return resuft;
}
}

View File

@@ -1,120 +0,0 @@
package org.nl.wms.sch.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* 普通点对点任务
*/
@Service
public class PointToPointTask extends AbstractAcsTask {
@Override
@Transactional
public void updateTaskStatus(JSONObject taskObj, String status) {
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
String task_id = taskObj.getString("task_id");
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
if (StrUtil.equals(status,"0")) {
// 取消删除任务
taskTab.delete("task_id = '"+task_id+"'");
}
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) {
// 更新任务状态为执行中
jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode());
jsonTask.put("update_time", DateUtil.now());
jsonTask.put("car_no", taskObj.getString("car_no"));
taskTab.update(jsonTask);
}
if(StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) {
// 完成
jsonTask.put("task_status",TaskStatusEnum.FINISHED.getCode());
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId());
jsonTask.put("update_optname", SecurityUtils.getCurrentUsername());
jsonTask.put("update_time", DateUtil.now());
taskTab.update(jsonTask);
}
}
@Override
public void findStartPoint() {
}
@Override
public void findNextPoint() {
}
@Override
@Transactional
public String createTask(JSONObject form) {
String start_point_code = form.getString("start_point_code");
String next_point_code = form.getString("next_point_code");
String vehicle_code = form.getString("vehicle_code");
String now = DateUtil.now();
if (StrUtil.isEmpty(start_point_code)) {
throw new BadRequestException("起点不能为空!");
}
/* if (StrUtil.isEmpty(next_point_code)) {
throw new BadRequestException("终点不能为空!");
}
if (StrUtil.isEmpty(vehicle_code)) {
throw new BadRequestException("载具不能为空!");
}*/
String taskdtl_id = IdUtil.getSnowflake(1, 1).nextId() + "";
JSONObject task = new JSONObject();
task.put("taskdtl_id", taskdtl_id);
task.put("task_id", taskdtl_id);
task.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
task.put("task_type", "05");
task.put("taskdtl_type", "05");
task.put("task_status", "01");
task.put("start_point_code", start_point_code);
task.put("next_point_code", next_point_code);
task.put("vehicle_code", vehicle_code);
task.put("handle_class", this.getClass().getName());
task.put("finished_type", "00");
task.put("is_delete", "0");
Long currentUserId = SecurityUtils.getCurrentUserId();
task.put("create_id", currentUserId);
task.put("create_name", SecurityUtils.getCurrentNickName());
task.put("update_optid", currentUserId);
task.put("update_optname", SecurityUtils.getCurrentNickName());
task.put("create_time", now);
task.put("update_time", now);
task.put("priority", "1");
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
return taskdtl_id;
}
@Override
public void forceFinish(String task_id) {
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
}
@Override
public void pullBack(String taskdtl_id) {
}
@Override
public void cancel(String taskdtl_id) {
}
}

View File

@@ -1,44 +0,0 @@
package org.nl.wms.sch.tasks;
/**
* 任务状态枚举
*/
public enum RegionTypeEnum {
CPQYA(1, "CPQYA01", "成品区域A","1557538851726168064"),
YSQA(2, "YSQA01", "养生A区","1557539288307077120"),
YSQB(3, "YSQB01", "养生B区","1557539423292362752"),
GJQY(4, "GJQY01", "共挤区","1557539744848678912"),
YQQY(5, "YQQY01", "油漆区","1557913112412295168"),
DPJQA(6, "DPJQA01", "叠盘架A区","1558015562792177664"),
DPJQB(7, "DPJQB01", "叠盘架B区","1558015634472833024"),
KTPHCQA(8, "KTPHCQA01", "空托盘缓存A区","1558015810096730112"),
KTPHCQB(9, "KTPHCQB01", "空托盘缓存B区","1558015870570205184"),
HKQY(10, "HKQY01", "豪凯区域","1564862312702152704"),
CPQYB(11, "CPQYB01", "成品区域B","1564874102089584640"),
SSX(12, "SSX01", "输送线区域","1559374522581389312");
private int index;
private String code;
private String name;
private String id;
public String getCode() {
return code;
}
public String getName() {
return name;
}
public String getId() {
return id;
}
RegionTypeEnum(int index, String code, String name, String id) {
this.index = index;
this.id = id;
this.code = code;
this.name = name;
}
}

View File

@@ -1,310 +0,0 @@
package org.nl.wms.sch.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.basedata.master.service.StoragevehicleinfoService;
import org.nl.wms.basedata.master.service.dto.StoragevehicleinfoDto;
import org.nl.wms.pdm.service.DeviceService;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.dto.PointDto;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.HashMap;
@Service
@RequiredArgsConstructor
@Slf4j
public class SendEmpVehicleTask extends AbstractAcsTask {
private final String THIS_CLASS = SendEmpVehicleTask.class.getName();
@Override
@Transactional
public void updateTaskStatus(JSONObject taskObj, String status) {
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject empTab = WQLObject.getWQLObject("st_ivt_EmptyVehicleRecord");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
String task_id = taskObj.getString("task_id");
JSONObject jsonTask = taskTab.query("task_id = '" + task_id + "'").uniqueResult(0);
if (StrUtil.equals(status,"0")) {
// 取消删除任务
taskTab.delete("task_id = '"+task_id+"'");
}
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) {
// 更新任务状态为执行中
jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode());
jsonTask.put("update_time", DateUtil.now());
jsonTask.put("car_no", taskObj.getString("car_no"));
taskTab.update(jsonTask);
}
if(StrUtil.equals(status, TaskStatusEnum.FINISHED.getCode())) {
// 更改任务状态为完成
jsonTask.put("task_status",TaskStatusEnum.FINISHED.getCode());
jsonTask.put("update_optid", SecurityUtils.getCurrentUserId());
jsonTask.put("update_optname", SecurityUtils.getCurrentUsername());
jsonTask.put("update_time", DateUtil.now());
taskTab.update(jsonTask);
String start_point_code = jsonTask.getString("start_point_code");
PointService point = SpringContextHolder.getBean(PointService.class);
// 校验起点是否存在
PointDto startDto = point.findByCode(start_point_code);
if (ObjectUtil.isEmpty(startDto)) throw new BadRequestException("未找到可用点位:" + startDto);
// 校验终点是否存在
PointDto nextDto = point.findByCode(jsonTask.getString("next_point_code"));
if (ObjectUtil.isEmpty(nextDto)) throw new BadRequestException("未找到可用点位:" + nextDto);
// 1.更新点位数量 2.解锁点位
JSONObject jsonEmp = empTab.query("task_uuid = '" + task_id + "'").uniqueResult(0);
int vehicle_qty = JSONObject.parseObject(JSON.toJSONString(nextDto)).getIntValue("vehicle_qty");
BigDecimal vehicle_qty_point = NumberUtil.add(String.valueOf(vehicle_qty), String.valueOf(jsonEmp.getIntValue("vehicle_qty")));
nextDto.setVehicle_qty(Integer.valueOf(vehicle_qty_point.toString()));
nextDto.setPoint_status("01");
nextDto.setLock_type("00");
nextDto.setVehicle_type(jsonTask.getString("vehicle_type"));
nextDto.setVehicle_code(jsonTask.getString("vehicle_code"));
pointTab.update(JSONObject.parseObject(JSON.toJSONString(nextDto)));
// 完成单据状态
jsonEmp.put("bill_status", "50");
jsonEmp.put("update_optid", SecurityUtils.getCurrentUserId());
jsonEmp.put("update_optname", SecurityUtils.getCurrentUsername());
jsonEmp.put("update_time", DateUtil.now());
empTab.update(jsonEmp);
}
}
@Override
public void findStartPoint() {
}
@Override
public void findNextPoint() {
}
@Override
@Transactional
public String createTask(JSONObject form) {
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject empTab = WQLObject.getWQLObject("st_ivt_EmptyVehicleRecord");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
String start_point_code = form.getString("start_point_code");
String next_point_code = form.getString("next_point_code");
String vehicle_code = form.getString("vehicle_code");
String qty = form.getString("qty");
String record_uuid = form.getString("record_uuid");
String vehicle_type = "";
// 入库起点不能为空
if (ObjectUtil.isEmpty(start_point_code)) {
throw new BadRequestException("起点不能为空");
} else {
// 判断起点是否有正在执行的任务
JSONObject beforTaskObj = taskTab.query("is_delete='0' and start_point_code='" + start_point_code + "' and task_status <>'" + TaskStatusEnum.FINISHED.getCode() + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(beforTaskObj)) throw new BadRequestException("存在指令号为'" + beforTaskObj.getString("task_code") + "' 未完成!");
}
// 载具数量不能为空
if (ObjectUtil.isEmpty(qty)) throw new BadRequestException("载具数量不能为空");
/*
* 1. 点对点: 起点和终点都确定,直接创建任务
* 2. 起点确定: 需要找到对应终点,在创建任务 具体找终点货位的规则在findEndPoint()中
*/
// 起点确定:找终点
if (ObjectUtil.isEmpty(next_point_code)) {
JSONObject param = new JSONObject();
param.put("start_point_code",start_point_code);
param.put("vehicle_qty",qty);
param.put("vehicle_code",vehicle_code);
JSONObject json = this.findEndPoint(param);
next_point_code = json.getString("EndPoint_code");
vehicle_type = json.getString("vehicle_type");
} else {
// 判断终点是否是空位
JSONObject jsonPoint = pointTab.query("point_code = '" + next_point_code + "' and lock_type = '00' and point_status <> '02' and is_delete = '0' and is_used = '1'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonPoint)) throw new BadRequestException("终点点位不不可用或不存在");
}
// 创建任务
JSONObject jsonTask = new JSONObject();
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
jsonTask.put("task_id", task_id);
jsonTask.put("taskdtl_id", task_id);
jsonTask.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
jsonTask.put("task_type", "03");
jsonTask.put("taskdtl_type", "03");
jsonTask.put("task_status", "01");
jsonTask.put("start_point_code", start_point_code);
jsonTask.put("next_point_code", next_point_code);
jsonTask.put("vehicle_type", vehicle_type);
jsonTask.put("vehicle_code", vehicle_code);
jsonTask.put("handle_class", THIS_CLASS);
jsonTask.put("create_name", SecurityUtils.getCurrentUsername());
jsonTask.put("create_id", SecurityUtils.getCurrentUserId());
jsonTask.put("create_time", DateUtil.now());
jsonTask.put("acs_task_type", "1");
taskTab.insert(jsonTask);
// 锁定终点点位
JSONObject jsonPoint = pointTab.query("point_code = '" + next_point_code + "'").uniqueResult(0);
jsonPoint.put("lock_type", "02");
pointTab.update(jsonPoint);
// 更新空载具单据状态
if (ObjectUtil.isNotEmpty(record_uuid)) {
JSONObject jsonEmp = empTab.query("record_uuid ='" + record_uuid + "'").uniqueResult(0);
jsonEmp.put("bill_status","20");
empTab.update(jsonEmp);
}
return task_id;
}
@Override
@Transactional
public void forceFinish(String task_id) {
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
}
@Override
public void pullBack(String task_id) {
}
@Override
public void cancel(String task_id) {
}
@Transactional
public JSONObject findEndPoint(JSONObject json) {
String start_point_code = json.getString("start_point_code");
String vehicle_qty = json.getString("vehicle_qty");
String vehicle_code = json.getString("vehicle_code");
if (ObjectUtil.isEmpty(start_point_code)) throw new BadRequestException("起点不能为空");
if (ObjectUtil.isEmpty(vehicle_qty)) throw new BadRequestException("载具数量不能为空");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point"); // 点位表
WQLObject regionTab = WQLObject.getWQLObject("SCH_BASE_Region"); // 区域表
WQLObject orderTab = WQLObject.getWQLObject("mps_bd_produceshiftorder"); //空载具记录表
WQLObject velicleTab = WQLObject.getWQLObject("md_pb_storagevehicleinfo"); // 载具表
// 根据起点区域判断优先的终点区域
JSONObject jsonPointStart = pointTab.query("point_code = '" + start_point_code + "'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonPointStart)) throw new BadRequestException("起点点位不存在");
JSONObject jsonRegionStart = regionTab.query("region_id ='" + jsonPointStart.getString("region_id") + "'").uniqueResult(0);
// 根据起点找到对应设备,根据设备查询工单表中 - 正在运行的工单中的载具类型
String device_code = "";
if (ObjectUtil.isEmpty(vehicle_code)) {
device_code = start_point_code.substring(0, start_point_code.indexOf("_"));
}
String vehicle_type = "";
DeviceService deviceBean = SpringContextHolder.getBean(DeviceService.class);
DeviceDto deviceDto = deviceBean.findByCode(device_code);
if (ObjectUtil.isEmpty(deviceDto)) {
// 如果说明是货梯业务:则判断载具号是否为空
if (ObjectUtil.isEmpty(vehicle_code)) throw new BadRequestException("起点点位错误");
// 根据载具号找对应的载具类型
StoragevehicleinfoDto vehicleDto = SpringContextHolder.getBean(StoragevehicleinfoService.class).findByCode(vehicle_code);
if (ObjectUtil.isEmpty(vehicleDto)) throw new BadRequestException("载具不存在");
vehicle_type = vehicleDto.getStoragevehicle_type();
} else {
// 不为空说明不是货梯业务:则根据工单找到对应类型
JSONObject jsonOrder = orderTab.query("device_id = '" + deviceDto.getDevice_id() + "' and order_status = '02' and is_delete = '0'").uniqueResult(0);
if (ObjectUtil.isEmpty(jsonOrder)) throw new BadRequestException("此设备未在生产中或不存在");
vehicle_type = jsonOrder.getString("vehicle_type");
}
/*
* 空托盘入库业务:
* 1.油漆线 --> 叠盘架A区、养生区A区 优先级1叠盘架A区 2.养生A区
* 2.货梯 --> 叠盘架B区、养生区A区 优先级1叠盘架B区 2.养生A区
*/
String EndPoint_code = "";
HashMap<String, String> map = new HashMap<>();
if (StrUtil.equals(jsonRegionStart.getString("region_code"), RegionTypeEnum.YQQY.getCode())) {
// 油漆线入库查找叠盘架A区是否有满足的空位
map.put("flag", "1");
map.put("vehicle_qty",vehicle_qty);
map.put("vehicle_type",vehicle_type);
map.put("region_code",RegionTypeEnum.DPJQA.getCode());
JSONObject jsonEndPointDPA = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonEndPointDPA)) {
EndPoint_code = jsonEndPointDPA.getString("point_code");
} else {
// 为空说明没有相同的载具类型
map.put("flag", "2");
map.put("vehicle_type","");
JSONObject jsonEndPointDPA2 = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonEndPointDPA2)) {
EndPoint_code = jsonEndPointDPA2.getString("point_code");
} else {
// 为空说明叠盘架A区上货位不足则需要入库到养生A区
map.put("flag", "3");
map.put("region_code",RegionTypeEnum.YSQA.getCode() );
JSONObject jsonEndPointYSA = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEndPointYSA)) throw new BadRequestException("没有满足需求的空位");
EndPoint_code = jsonEndPointYSA.getString("point_code");
}
}
} else {
// 货梯入库查找叠盘架B区是否有满足的空位
map.put("flag", "1");
map.put("vehicle_qty",vehicle_qty);
map.put("vehicle_type",vehicle_type);
map.put("region_code",RegionTypeEnum.DPJQB.getCode());
JSONObject jsonEndPointDPB = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonEndPointDPB)) {
EndPoint_code = jsonEndPointDPB.getString("point_code");
} else {
// 为空说明没有相同的载具类型
map.put("flag", "2");
map.put("vehicle_type","");
JSONObject jsonEndPointDPB2 = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isNotEmpty(jsonEndPointDPB2)) {
EndPoint_code = jsonEndPointDPB2.getString("point_code");
} else {
// 为空说明叠盘架B区上货位不足则需要入库到养生A区
map.put("flag", "3");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
JSONObject jsonEndPointYSA = WQL.getWO("ST_VEHICLE_IN_02").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEndPointYSA)) throw new BadRequestException("没有满足需求的空位");
EndPoint_code = jsonEndPointYSA.getString("point_code");
}
}
}
JSONObject resuft = new JSONObject();
resuft.put("EndPoint_code",EndPoint_code);
resuft.put("vehicle_type",vehicle_type);
return resuft;
}
}

View File

@@ -1,311 +0,0 @@
package org.nl.wms.sch.tasks;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.basedata.st.IvtChangeTypeEnum;
import org.nl.wms.basedata.st.StoreIvtServiceImpl;
import org.nl.wms.common.StructFindUtil;
import org.nl.wms.sch.manage.AbstractAcsTask;
import org.nl.wms.sch.manage.TaskStatusEnum;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.service.dto.PointDto;
import org.nl.wms.sch.service.impl.PointServiceImpl;
import org.nl.modules.wql.WQL;
import org.nl.modules.wql.core.bean.WQLObject;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.HashMap;
@Service
@RequiredArgsConstructor
@Slf4j
public class SendMaterialTask extends AbstractAcsTask {
private final String THIS_CLASS = SendMaterialTask.class.getName();
@Override
@Transactional
public void updateTaskStatus(JSONObject taskObj, String status) {
/**
*改变任务状态
**/
String task_id = taskObj.getString("task_id");
WQLObject taskTab = WQLObject.getWQLObject("sch_base_task");
JSONObject jsonTask = taskTab.query("task_id='" + task_id + "'").uniqueResult(0);
if (StrUtil.equals(status,"0")) {
// 取消删除任务
taskTab.delete("task_id = '"+task_id+"'");
}
if (TaskStatusEnum.EXECUTING.getCode().equals(status)) {
//更新任务状态为执行中
jsonTask.put("task_status", TaskStatusEnum.EXECUTING.getCode());
jsonTask.put("update_time", DateUtil.now());
jsonTask.put("car_no", taskObj.getString("car_no"));
taskTab.update(jsonTask);
HashMap map = new HashMap();
map.put("update_optid", SecurityUtils.getCurrentUserId());
map.put("update_optname", SecurityUtils.getCurrentNickName());
map.put("update_time", DateUtil.now());
map.put("bill_status", "40");
WQLObject.getWQLObject("ST_IVT_regionIO").update(map, "task_id='" + jsonTask.getString("task_id") + "'");
}
if (TaskStatusEnum.FINISHED.getCode().equals(status)) {
// 更新任务状态为完成
jsonTask.put("task_status", TaskStatusEnum.FINISHED.getCode());
jsonTask.put("taskfinish_mode", taskObj.getString("taskfinish_mode"));
jsonTask.put("update_time", DateUtil.now());
jsonTask.put("remark", "任务执行完成");
///审核单据 增加库存 改变出入库表的状态
WQLObject mstTab = WQLObject.getWQLObject("ST_IVT_regionIO");
JSONObject mstObj = mstTab.query("task_id='" + task_id + "' and is_delete='0'").uniqueResult(0);
//审核 加库存可和用数量
StoreIvtServiceImpl ivtService = new StoreIvtServiceImpl();
mstObj.put("bill_status", "50");
mstObj.put("confirm_optid", SecurityUtils.getCurrentUserId());
mstObj.put("confirm_optname", SecurityUtils.getCurrentNickName());
mstObj.put("confirm_time", DateUtil.now());
mstTab.update(mstObj);
String iostorinv_id = mstObj.getString("iostorinv_id");
String bill_code = mstObj.getString("bill_code");
String bill_type_scode =mstObj.getString("bill_type");
String next_point_code = mstObj.getString("end_point_code");
String start_point_code = mstObj.getString("start_point_code");
JSONObject param = new JSONObject();
param.put("material_id", mstObj.getString("material_id"));
param.put("bill_code", bill_code);
param.put("bill_type_scode", bill_type_scode);
param.put("bill_id", iostorinv_id);
param.put("qty_unit_id", mstObj.getString("qty_unit_id"));
param.put("pcsn", mstObj.getString("pcsn"));
param.put("change_qty", mstObj.getString("qty"));
param.put("vehicle_code", mstObj.getString("vehicle_code"));
param.put("region_id", mstObj.getString("start_region_id"));
param.put("is_full", mstObj.getString("is_full"));
param.put("stewing_time", mstObj.getString("stewing_time"));
param.put("producetask_id", mstObj.getString("producetask_id"));
param.put("io_type", mstObj.getString("io_type"));
PointServiceImpl pointService = SpringContextHolder.getBean(PointServiceImpl.class);
PointDto nextPointDto = pointService.findByCode(next_point_code);
if (ObjectUtil.isNull(nextPointDto)) {
throw new BadRequestException("未找到可用点位:" + next_point_code);
}
PointDto startPointDto = pointService.findByCode(start_point_code);
if (ObjectUtil.isNull(startPointDto)) {
throw new BadRequestException("未找到可用点位:" + start_point_code);
}
param.put("struct_id", nextPointDto.getPoint_id());
ivtService.addIvtFlow(param, IvtChangeTypeEnum.ADD_IVT_AND_CAN_USE);
// 解锁点位
String vehicle_code = jsonTask.getString("vehicle_code");
WQLObject pointTab = WQLObject.getWQLObject("sch_base_point");
JSONObject endpointObj = pointTab.query("point_code='" + jsonTask.getString("next_point_code") + "'").uniqueResult(0);
endpointObj.put("lock_type", "00");
endpointObj.put("point_status", "02");
endpointObj.put("vehicle_code", vehicle_code);
endpointObj.put("vehicle_type", jsonTask.getString("vehicle_type"));
pointTab.update(endpointObj);
taskTab.update(jsonTask);
/* JSONObject startPointObj = pointTab.query("point_code='" + jsonTask.getString("start_point_code") + "'").uniqueResult(0);
startPointObj.put("lock_type", "00");
startPointObj.put("point_status", "00");
startPointObj.put("vehicle_code", "");
pointTab.update(startPointObj);
taskTab.update(jsonTask);*/
}
}
@Override
public void findStartPoint() {
}
@Override
public void findNextPoint() {
String task_status = TaskStatusEnum.SURE_START.getCode();
WQLObject taskTab = WQLObject.getWQLObject("SCH_BASE_Task");
JSONArray taskArry = taskTab.query("task_status='" + task_status + "' AND handle_class='" + THIS_CLASS + "' AND is_delete='0' ").getResultJSONArray(0);
for (int i = 0; i < taskArry.size(); i++) {
JSONObject taskObj = taskArry.getJSONObject(i);
String task_id = taskObj.getString("task_id");
//1 将任务修改为分配 2将终点写入完成分配3 加锁点位
//找一个合适的仓位
WQLObject ProcedureIOStable = WQLObject.getWQLObject("ST_IVT_regionIO");
JSONObject IosObj = ProcedureIOStable.query("task_id='" + task_id + "' and is_delete ='0'").uniqueResult(0);
if (ObjectUtil.isEmpty(IosObj)) {
throw new BadRequestException("未找到任务号为'" + taskObj.getString("task_code") + "'的入库单据!");
}
JSONObject param = new JSONObject();
param.put("material_id", IosObj.getString("material_id"));
param.put("area_type", IosObj.getString("end_area"));
param.put("vehicle_code", IosObj.getString("vehicle_code"));
JSONObject inStructObj = StructFindUtil.getInStruct(param);
if (ObjectUtil.isEmpty(inStructObj)) {
throw new BadRequestException("未找到合适的入库仓位!");
}
//修改单据状态,将终点填入
IosObj.put("bill_status", "20");
IosObj.put("end_point_code", inStructObj.getString("struct_code"));
ProcedureIOStable.update(IosObj);
//终点加锁
HashMap lock_map = new HashMap();
lock_map.put("lock_type", "01");
WQLObject.getWQLObject("sch_base_point").update(lock_map, "point_code = '" + inStructObj.getString("struct_code") + "'");
//修改任务状态
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
taskObj.put("update_optid", SecurityUtils.getCurrentUserId());
taskObj.put("update_optname", SecurityUtils.getCurrentNickName());
taskObj.put("update_time", DateUtil.now());
taskTab.update(taskObj);
}
}
@Override
@Transactional
public String createTask(JSONObject form) {
//请求参数 载具、起点、终点
String vehicle_code = form.getString("vehicle_code");
String vehicle_type = form.getString("vehicle_type");
String start_point_code = form.getString("start_point_code");
String next_point_code = form.getString("next_point_code");
WQLObject taskTable = WQLObject.getWQLObject("SCH_BASE_Task");
WQLObject iosTable = WQLObject.getWQLObject("ST_IVT_regionIO");
if (StrUtil.isEmpty(start_point_code)) {
throw new BadRequestException("起点不能为空!");
}
//判断起点有没有未完成的指令
JSONObject beforTaskObj = taskTable.
query("is_delete='0' and start_point_code='" + start_point_code + "' and task_status <>'" + TaskStatusEnum.FINISHED.getCode() + "'")
.uniqueResult(0);
if (ObjectUtil.isNotEmpty(beforTaskObj)) {
throw new BadRequestException("存在指令号为'" + beforTaskObj.getString("task_code") + "' 未完成!");
}
if (StrUtil.isEmpty(next_point_code)) {
// 终点为空需要找终点
JSONObject param = new JSONObject();
param.put("start_point_code",start_point_code);
JSONObject endPoint = this.findEndPoint(param);
next_point_code = endPoint.getString("next_point_code");
}
//终点点加锁
WQLObject pointTable = WQLObject.getWQLObject("sch_base_point");
JSONObject endPointObj = pointTable.query("point_code='" + next_point_code + "'").uniqueResult(0);
endPointObj.put("lock_type", "01");
pointTable.update(endPointObj);
// 创建任务
PointService pointService = SpringContextHolder.getBean(PointService.class);
JSONObject taskObj = new JSONObject();
CodeUtil.getNewCode("TASK_CODE");
String task_id = IdUtil.getSnowflake(1, 1).nextId() + "";
taskObj.put("task_id", task_id);
taskObj.put("taskdtl_id", task_id);
taskObj.put("task_code", CodeUtil.getNewCode("TASK_CODE"));
taskObj.put("task_type", "01");
taskObj.put("vehicle_type", vehicle_type);
taskObj.put("taskdtl_type", "01");
taskObj.put("acs_task_type", "1");
taskObj.put("task_status", TaskStatusEnum.START_AND_POINT.getCode());
taskObj.put("start_point_code", start_point_code);
PointDto startPoint = pointService.findByCode(start_point_code);
taskObj.put("start_area", startPoint.getRegion_id());
taskObj.put("request_param", form.toJSONString());
taskObj.put("next_point_code", next_point_code);
PointDto nextPoint = pointService.findByCode(next_point_code);
taskObj.put("next_area", nextPoint.getRegion_id());
taskObj.put("vehicle_code", vehicle_code);
taskObj.put("handle_class", THIS_CLASS);
taskObj.put("is_auto_issue", "1");
taskObj.put("create_name", SecurityUtils.getCurrentUsername());
taskObj.put("create_id", SecurityUtils.getCurrentUserId());
taskObj.put("create_time", DateUtil.now());
taskObj.put("is_delete", "0");
taskTable.insert(taskObj);
return task_id;
}
@Override
public void forceFinish(String task_id) {
JSONObject taskObj = WQLObject.getWQLObject("SCH_BASE_Task").query("task_id = '" + task_id + "'").uniqueResult(0);
this.updateTaskStatus(taskObj, TaskStatusEnum.FINISHED.getCode());
}
@Override
public void pullBack(String task_id) {
}
@Override
public void cancel(String task_id) {
}
@Transactional
public JSONObject findEndPoint(JSONObject json) {
String start_point_code = json.getString("start_point_code");
WQLObject regionTab = WQLObject.getWQLObject("SCH_BASE_Region");
// 根据起点判断是什么区域 然后要入到什么区
PointDto startDto = SpringContextHolder.getBean(PointService.class).findByCode(start_point_code);
if (ObjectUtil.isEmpty(startDto)) throw new BadRequestException("起点点位不存在");
JSONObject jsonStartRegion = regionTab.query("region_id = '" + startDto.getRegion_id() + "'").uniqueResult(0);
/*
* 物料入库业务目前只有2个业务如果区域不正确则报错
* 1.共挤线 --> 养生区A
* 2.豪凯线 --> 成品区
*/
String next_point_code = "";
if (StrUtil.equals(jsonStartRegion.getString("region_code"),RegionTypeEnum.GJQY.getCode())) {
JSONObject map = new JSONObject();
map.put("flag", "2");
map.put("region_code", RegionTypeEnum.YSQA.getCode());
JSONObject jsonEndPoint = WQL.getWO("ST_REGION_IN_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEndPoint)) throw new BadRequestException("仓位不足");
next_point_code = jsonEndPoint.getString("point_code");
} else if (StrUtil.equals(jsonStartRegion.getString("region_code"),RegionTypeEnum.HKQY.getCode())) {
JSONObject map = new JSONObject();
map.put("flag", "2");
map.put("region_code", RegionTypeEnum.CPQYA.getCode());
JSONObject jsonEndPoint = WQL.getWO("ST_REGION_IN_01").addParamMap(map).process().uniqueResult(0);
if (ObjectUtil.isEmpty(jsonEndPoint)) throw new BadRequestException("仓位不足");
next_point_code = jsonEndPoint.getString("point_code");
}
JSONObject resuft = new JSONObject();
resuft.put("next_point_code",next_point_code);
return resuft;
}
}

View File

@@ -17,7 +17,6 @@ import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.pdm.service.DeviceService;
import org.nl.wms.pdm.service.dto.DeviceDto;
import org.nl.wms.sch.tasks.SendMaterialTask;
import org.nl.wms.st.inbill.service.RegionioInService;
import org.nl.wms.st.inbill.service.dto.RegionioDto;
import org.nl.modules.wql.WQL;

View File

@@ -14,7 +14,6 @@ import lombok.extern.slf4j.Slf4j;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.wms.sch.tasks.CallMaterialTask;
import org.nl.wms.st.inbill.service.dto.RegionioDto;
import org.nl.wms.st.outbill.service.RegionioOutService;
import org.nl.modules.wql.WQL;

View File

@@ -16,7 +16,6 @@ import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.tasks.SendEmpVehicleTask;
import org.nl.wms.st.vehiclebill.service.InEmptyvehiclerecordService;
import org.nl.wms.st.vehiclebill.service.dto.EmptyvehiclerecordDto;
import org.nl.modules.wql.WQL;

View File

@@ -16,7 +16,6 @@ import org.nl.modules.system.util.CodeUtil;
import org.nl.modules.common.utils.SecurityUtils;
import org.nl.modules.wql.util.SpringContextHolder;
import org.nl.wms.sch.service.PointService;
import org.nl.wms.sch.tasks.CallEmpVehicleTask;
import org.nl.wms.st.vehiclebill.service.OutEmptyvehiclerecordService;
import org.nl.wms.st.vehiclebill.service.dto.EmptyvehiclerecordDto;
import org.nl.modules.wql.WQL;