add:修改缓存线区域关系
This commit is contained in:
@@ -2,6 +2,13 @@ package org.nl.common.enums;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @author ZZQ
|
* @author ZZQ
|
||||||
@@ -13,28 +20,28 @@ import lombok.Getter;
|
|||||||
public enum AcsTaskEnum {
|
public enum AcsTaskEnum {
|
||||||
UNDEFINED("0","未定义类型"),
|
UNDEFINED("0","未定义类型"),
|
||||||
//任务类型:3个点,任务编号,无需载具
|
//任务类型:3个点,任务编号,无需载具
|
||||||
PRODUCT_MAC("1","专机-专机任务"),
|
TASK_PRODUCT_MAC("1","专机-专机任务"),
|
||||||
//3个点,任务编号,缓存线空载具列表
|
//3个点,任务编号,缓存线空载具列表
|
||||||
PRODUCT_CACHE("2","专机-缓存线任务"),
|
TASK_PRODUCT_CACHE("2","专机-缓存线任务"),
|
||||||
//3个点,任务编号,缓存线满料载具列表
|
//3个点,任务编号,缓存线满料载具列表
|
||||||
CACHELINE_OUT("3","缓存线出库任务"),
|
TASK_CACHELINE_OUT("3","缓存线出库任务"),
|
||||||
|
|
||||||
//回调状态
|
//回调状态
|
||||||
ACS_RUNDING("1","运行中"),
|
STATUS_START("1","开始取货"),
|
||||||
ACS_FINISH("2","完成"),
|
STATUS_RUNDING("2","放货中"),
|
||||||
ACS_CANNEL("3","完成"),
|
STATUS_FINISH("3","完成"),
|
||||||
|
STATUS_CANNEL("4","取消"),
|
||||||
|
|
||||||
ACS_CALLTYPE_FULL("1","满料请求"),
|
REQUEST_CALLTYPE_FULL("1","满料请求"),
|
||||||
ACS_CALLTYPE_EMP("2","缺料请求"),
|
REQUEST_CALLTYPE_EMP("2","缺料请求"),
|
||||||
;
|
;
|
||||||
private String code;
|
private String code;
|
||||||
private String desc;
|
private String desc;
|
||||||
|
|
||||||
public static AcsTaskEnum getType(String type){
|
public static AcsTaskEnum getType(String type,String enumType){
|
||||||
for (AcsTaskEnum value : AcsTaskEnum.values()) {
|
Optional<AcsTaskEnum> first = Arrays.stream(AcsTaskEnum.values()).filter(a -> a.name().contains(enumType.toUpperCase(Locale.ROOT)) && a.getCode().equals(type)).findFirst();
|
||||||
if (value.getCode().equals(type)){
|
if (first.isPresent()){
|
||||||
return value;
|
return first.get();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return AcsTaskEnum.UNDEFINED;
|
return AcsTaskEnum.UNDEFINED;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,9 +44,9 @@ public class AcsToWmsController {
|
|||||||
return new ResponseEntity<>(acsToWmsService.receiveTaskStatusAcs(string), HttpStatus.OK);
|
return new ResponseEntity<>(acsToWmsService.receiveTaskStatusAcs(string), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
// @PostMapping("/orderFinish")
|
@PostMapping("/orderFinish")
|
||||||
// @Log("ACS给WMS下发工单完成状态")
|
@Log("ACS给WMS下发工单完成状态")
|
||||||
// @ApiOperation("ACS给WMS下发工单完成状态")
|
@ApiOperation("ACS给WMS下发工单完成状态")
|
||||||
public ResponseEntity<Object> orderFinish(@RequestBody String string) {
|
public ResponseEntity<Object> orderFinish(@RequestBody String string) {
|
||||||
return new ResponseEntity<>(acsToWmsService.orderFinish(string), HttpStatus.OK);
|
return new ResponseEntity<>(acsToWmsService.orderFinish(string), HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,14 +38,14 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
@Override
|
@Override
|
||||||
public Map<String, Object> apply(JSONObject jsonObject) {
|
public Map<String, Object> apply(JSONObject jsonObject) {
|
||||||
Map result = MapOf.of("status", HttpStatus.OK.value(), "message", "ACS向WMS申请任务成功!");
|
Map result = MapOf.of("status", HttpStatus.OK.value(), "message", "ACS向WMS申请任务成功!");
|
||||||
//1.满料请求
|
//1.专机设备满料请求
|
||||||
//2.缺料请求
|
//2.专机设备缺料请求:专机,深坑
|
||||||
String type = jsonObject.getString("type");
|
String type = jsonObject.getString("type");
|
||||||
try {
|
try {
|
||||||
if (type.equals(AcsTaskEnum.ACS_CALLTYPE_FULL.getCode())){
|
if (type.equals(AcsTaskEnum.REQUEST_CALLTYPE_FULL.getCode())){
|
||||||
agvInstService.fullMaster(jsonObject);
|
agvInstService.fullMaster(jsonObject);
|
||||||
}
|
}
|
||||||
if (type.equals(AcsTaskEnum.ACS_CALLTYPE_EMP.getCode())){
|
if (type.equals(AcsTaskEnum.REQUEST_CALLTYPE_EMP.getCode())){
|
||||||
agvInstService.callMatter(jsonObject);
|
agvInstService.callMatter(jsonObject);
|
||||||
}
|
}
|
||||||
}catch (Exception ex){
|
}catch (Exception ex){
|
||||||
@@ -78,10 +78,10 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
String message = "";
|
String message = "";
|
||||||
String status = "";
|
String status = "";
|
||||||
if ("1".equals(acs_task_status)) {
|
if ("1".equals(acs_task_status)) {
|
||||||
status = AcsTaskEnum.ACS_RUNDING.getCode();
|
status = AcsTaskEnum.STATUS_RUNDING.getCode();
|
||||||
}
|
}
|
||||||
if ("2".equals(acs_task_status)) {
|
if ("2".equals(acs_task_status)) {
|
||||||
status = AcsTaskEnum.ACS_FINISH.getCode();
|
status = AcsTaskEnum.STATUS_FINISH.getCode();
|
||||||
}
|
}
|
||||||
// 任务处理类
|
// 任务处理类
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -1,34 +1,21 @@
|
|||||||
package org.nl.wms.ext.acs.service.impl;
|
package org.nl.wms.ext.acs.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
|
||||||
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONArray;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.nl.common.ConstantParam;
|
import org.nl.common.ConstantParam;
|
||||||
import org.nl.common.enums.AcsTaskEnum;
|
import org.nl.common.enums.AcsTaskEnum;
|
||||||
import org.nl.common.enums.InterfaceLogType;
|
|
||||||
import org.nl.common.enums.StatusEnum;
|
import org.nl.common.enums.StatusEnum;
|
||||||
import org.nl.common.utils.IdUtil;
|
|
||||||
import org.nl.common.utils.MapOf;
|
import org.nl.common.utils.MapOf;
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
import org.nl.modules.system.service.RedisService;
|
|
||||||
import org.nl.modules.wql.WQL;
|
import org.nl.modules.wql.WQL;
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
import org.nl.modules.wql.exception.WDKException;
|
|
||||||
import org.nl.utils.PointLockUtils;
|
import org.nl.utils.PointLockUtils;
|
||||||
import org.nl.wms.sch.tasks.PointToPointTask;
|
import org.nl.wms.sch.tasks.SpeMachineryTask;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.data.redis.core.RedisTemplate;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.util.CollectionUtils;
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.function.Function;
|
|
||||||
import java.util.function.Predicate;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -68,7 +55,7 @@ public class AgvInstService {
|
|||||||
String needMove = order.getString("is_needmove");
|
String needMove = order.getString("is_needmove");
|
||||||
String materialprocessSeries = order.getString("materialprocess_series");
|
String materialprocessSeries = order.getString("materialprocess_series");
|
||||||
|
|
||||||
String taskType = AcsTaskEnum.PRODUCT_MAC.getCode();
|
String taskType = AcsTaskEnum.TASK_PRODUCT_MAC.getCode();
|
||||||
if (StatusEnum.STATUS_TRUE.equals(needMove)){
|
if (StatusEnum.STATUS_TRUE.equals(needMove)){
|
||||||
JSONObject devicePoint = basePoint.query("point_code = '" + point_code + "' and is_delete = 0 and is_used = 1").uniqueResult(0);
|
JSONObject devicePoint = basePoint.query("point_code = '" + point_code + "' and is_delete = 0 and is_used = 1").uniqueResult(0);
|
||||||
JSONObject empPoint = WQL.getWO("sch_point").addParamMap(MapOf.of("flag", "2", "point_code", point_code, "point_type", StatusEnum.POINT_LOCATION_EMP.getCode())).process().uniqueResult(0);
|
JSONObject empPoint = WQL.getWO("sch_point").addParamMap(MapOf.of("flag", "2", "point_code", point_code, "point_type", StatusEnum.POINT_LOCATION_EMP.getCode())).process().uniqueResult(0);
|
||||||
@@ -100,11 +87,11 @@ public class AgvInstService {
|
|||||||
if (StringUtils.isEmpty(cacheVehile)) {
|
if (StringUtils.isEmpty(cacheVehile)) {
|
||||||
throw new BadRequestException("缓存线:"+nextPoint+"没有可用空载具");
|
throw new BadRequestException("缓存线:"+nextPoint+"没有可用空载具");
|
||||||
}
|
}
|
||||||
taskType = AcsTaskEnum.CACHELINE_OUT.getCode();
|
taskType = AcsTaskEnum.TASK_CACHELINE_OUT.getCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
//生成任务nextPoint
|
//生成任务nextPoint
|
||||||
PointToPointTask pointTask = new PointToPointTask();
|
SpeMachineryTask pointTask = new SpeMachineryTask();
|
||||||
JSONObject taskForm = new JSONObject(MapOf.of("start_device_code",point_code,
|
JSONObject taskForm = new JSONObject(MapOf.of("start_device_code",point_code,
|
||||||
"next_device_code",nextPoint,"return_device_code", empPoint.getString("point_code"),"vehicle_code",
|
"next_device_code",nextPoint,"return_device_code", empPoint.getString("point_code"),"vehicle_code",
|
||||||
cacheVehile,"quantity", quantity,"product_area",devicePoint.getString("product_area"),"type",taskType));
|
cacheVehile,"quantity", quantity,"product_area",devicePoint.getString("product_area"),"type",taskType));
|
||||||
@@ -143,10 +130,10 @@ public class AgvInstService {
|
|||||||
if (StringUtils.isEmpty(cacheVehile)) {
|
if (StringUtils.isEmpty(cacheVehile)) {
|
||||||
throw new BadRequestException("缓存线:"+startPoint+"没有可用空载具");
|
throw new BadRequestException("缓存线:"+startPoint+"没有可用空载具");
|
||||||
}
|
}
|
||||||
PointToPointTask pointTask = new PointToPointTask();
|
SpeMachineryTask pointTask = new SpeMachineryTask();
|
||||||
JSONObject taskForm = new JSONObject(MapOf.of("start_device_code",startPoint,
|
JSONObject taskForm = new JSONObject(MapOf.of("start_device_code",startPoint,
|
||||||
"next_device_code",point_code,"return_device_code", startPoint,"vehicle_code",
|
"next_device_code",point_code,"return_device_code", startPoint,"vehicle_code",
|
||||||
cacheVehile,"product_area",devicePoint.getString("product_area"),"type",AcsTaskEnum.CACHELINE_OUT.getCode()));
|
cacheVehile,"product_area",devicePoint.getString("product_area"),"type",AcsTaskEnum.TASK_CACHELINE_OUT.getCode()));
|
||||||
String taskId = pointTask.createTask(taskForm);
|
String taskId = pointTask.createTask(taskForm);
|
||||||
log.info(OPT_NAME+"callMatter taskID:{}",taskId);
|
log.info(OPT_NAME+"callMatter taskID:{}",taskId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,165 +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 lombok.extern.slf4j.Slf4j;
|
|
||||||
import org.nl.common.enums.AcsTaskEnum;
|
|
||||||
import org.nl.common.enums.InterfaceLogType;
|
|
||||||
import org.nl.common.enums.StatusEnum;
|
|
||||||
import org.nl.common.utils.MapOf;
|
|
||||||
import org.nl.modules.common.exception.BadRequestException;
|
|
||||||
import org.nl.modules.system.util.CodeUtil;
|
|
||||||
import org.nl.common.utils.SecurityUtils;
|
|
||||||
import org.nl.modules.wql.core.bean.WQLObject;
|
|
||||||
import org.nl.wms.sch.manage.AbstractAcsTask;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
|
|
||||||
|
|
||||||
import java.util.HashMap;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 普通点对点任务
|
|
||||||
*/
|
|
||||||
@Slf4j
|
|
||||||
public class PointToPointTask extends AbstractAcsTask {
|
|
||||||
|
|
||||||
private static String OPT_NAME = "ACS回调# ";
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateTaskStatus(JSONObject param,String status) {
|
|
||||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
|
||||||
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
|
||||||
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
|
||||||
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
|
||||||
log.info(InterfaceLogType.ACS_TO_LMS.getDesc());
|
|
||||||
|
|
||||||
//参数:
|
|
||||||
String taskId = param.getString("taskId");
|
|
||||||
String workprocedureCode = param.getString("workorder_code");
|
|
||||||
//入箱条码,出箱条码
|
|
||||||
String inboxtxm = param.getString("inboxtxm");
|
|
||||||
String outboxtxm = param.getString("outboxtxm");
|
|
||||||
|
|
||||||
// 指令执行中
|
|
||||||
JSONObject task = taskTable.query("task_id = '" + taskId + "'").uniqueResult(0);
|
|
||||||
String taskStatus = task.getString("task_status");
|
|
||||||
AcsTaskEnum taskTypeEnum = AcsTaskEnum.getType(task.getString("task_type"));
|
|
||||||
try {
|
|
||||||
if (AcsTaskEnum.ACS_RUNDING.getCode().equals(status)) {
|
|
||||||
if (!taskStatus.equals(StatusEnum.TASK_PUBLISH.getCode())){
|
|
||||||
log.error(OPT_NAME+"任务:{} 状态异常不是处于下发状态:{}",taskId,taskStatus);
|
|
||||||
}
|
|
||||||
// 更新指令为执行中
|
|
||||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+taskId+"'");
|
|
||||||
//如果是缓存线任务:释放缓存线对应载具
|
|
||||||
// 如果终点是缓存线,出箱的时候代表已经入了满料箱子
|
|
||||||
//根据任务类型确认更新
|
|
||||||
switch (taskTypeEnum){
|
|
||||||
case PRODUCT_MAC:
|
|
||||||
break;
|
|
||||||
case PRODUCT_CACHE:
|
|
||||||
//到缓存线说明需要出一个空箱号
|
|
||||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
|
||||||
break;
|
|
||||||
case CACHELINE_OUT:
|
|
||||||
//到缓存线说明需要出满箱号
|
|
||||||
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
log.error(OPT_NAME+"未定义任务类型:{}",task.getString("task_type"));
|
|
||||||
throw new BadRequestException(OPT_NAME+"未定义任务类型:"+task.getString("task_type"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 指令完成
|
|
||||||
if (AcsTaskEnum.ACS_FINISH.getCode().equals(status)) {
|
|
||||||
if (!taskStatus.equals(StatusEnum.TASK_RUNNING.getCode())) {
|
|
||||||
log.error(OPT_NAME + "任务:{} 状态异常不是处于运行中状态:{}", taskId, taskStatus);
|
|
||||||
}
|
|
||||||
switch (taskTypeEnum) {
|
|
||||||
case PRODUCT_MAC:case CACHELINE_OUT:
|
|
||||||
//到专机:更新设备上料位物料数量
|
|
||||||
String point_code2 = task.getString("point_code2");
|
|
||||||
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
|
||||||
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
|
||||||
task.getDouble("material_qty");
|
|
||||||
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
|
||||||
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
|
||||||
break;
|
|
||||||
case PRODUCT_CACHE:
|
|
||||||
cacheVehTable.insert(MapOf.of("quantity", task.getString("material_qty"),
|
|
||||||
"material_id", task.getString("material_id"),
|
|
||||||
"vehicle_code", inboxtxm,
|
|
||||||
"vehicle_status", StatusEnum.CACHE_VEL_FULL.getCode(),
|
|
||||||
//工单,工序?
|
|
||||||
"workorder_code", workprocedureCode,
|
|
||||||
"create_time", DateUtil.now(),
|
|
||||||
"update_time", DateUtil.now()
|
|
||||||
//物料规格,物料名称 从物料信息表关联查询
|
|
||||||
));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
log.error(OPT_NAME + "未定义任务类型:{}", task.getString("task_type"));
|
|
||||||
throw new BadRequestException(OPT_NAME + "未定义任务类型:" + task.getString("task_type"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}catch (Exception ex){
|
|
||||||
log.error(OPT_NAME+"updateStatus error:{}",ex);
|
|
||||||
throw ex;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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 type = form.getString("type");
|
|
||||||
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", type);
|
|
||||||
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", "01");
|
|
||||||
task.put("is_delete", "0");
|
|
||||||
String 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", DateUtil.now());
|
|
||||||
task.put("update_time", DateUtil.now());
|
|
||||||
task.put("priority", "1");
|
|
||||||
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
|
|
||||||
return taskdtl_id;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void cancel(String taskId) {
|
|
||||||
log.info(OPT_NAME+"cancel taskID:{}",taskId);
|
|
||||||
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
|
||||||
//专机-专机
|
|
||||||
//专机-缓存线
|
|
||||||
//缓存线出库
|
|
||||||
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_CANNEL.getCode()),"task_id = '"+taskId+"'");
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,201 @@
|
|||||||
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.nl.common.enums.AcsTaskEnum;
|
||||||
|
import org.nl.common.enums.InterfaceLogType;
|
||||||
|
import org.nl.common.enums.StatusEnum;
|
||||||
|
import org.nl.common.utils.MapOf;
|
||||||
|
import org.nl.modules.common.exception.BadRequestException;
|
||||||
|
import org.nl.modules.system.util.CodeUtil;
|
||||||
|
import org.nl.common.utils.SecurityUtils;
|
||||||
|
import org.nl.modules.wql.core.bean.WQLObject;
|
||||||
|
import org.nl.wms.sch.manage.AbstractAcsTask;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专机任务
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
public class SpeMachineryTask extends AbstractAcsTask {
|
||||||
|
private final Map<String,SpeStatusHandler > SpeHandles= new HashMap<>();
|
||||||
|
private static String OPT_NAME = "ACS回调# ";
|
||||||
|
|
||||||
|
public SpeMachineryTask() {
|
||||||
|
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_MAC.name() ,new Spe2Spe());
|
||||||
|
SpeHandles.put(AcsTaskEnum.TASK_PRODUCT_CACHE.name() ,new Spe2Cache());
|
||||||
|
SpeHandles.put(AcsTaskEnum.TASK_CACHELINE_OUT.name() ,new Cache2Spe());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTaskStatus(JSONObject param,String status) {
|
||||||
|
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||||
|
log.info(InterfaceLogType.ACS_TO_LMS.getDesc());
|
||||||
|
// 指令执行中
|
||||||
|
JSONObject task = taskTable.query("task_id = '" + param.getString("taskId") + "'").uniqueResult(0);
|
||||||
|
AcsTaskEnum taskType = AcsTaskEnum.getType(task.getString("task_type"),"TASK_");
|
||||||
|
try {
|
||||||
|
SpeHandles.get(taskType.name()).handle(param,status,task);
|
||||||
|
}catch (Exception ex){
|
||||||
|
log.error(OPT_NAME+"updateStatus error:{}",ex);
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
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 type = form.getString("type");
|
||||||
|
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", type);
|
||||||
|
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", "01");
|
||||||
|
task.put("is_delete", "0");
|
||||||
|
String 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", DateUtil.now());
|
||||||
|
task.put("update_time", DateUtil.now());
|
||||||
|
task.put("priority", "1");
|
||||||
|
WQLObject.getWQLObject("SCH_BASE_Task").insert(task);
|
||||||
|
return taskdtl_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void cancel(String taskId) {
|
||||||
|
log.info(OPT_NAME+"cancel taskID:{}",taskId);
|
||||||
|
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||||
|
//专机-专机
|
||||||
|
//专机-缓存线
|
||||||
|
//缓存线出库
|
||||||
|
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_CANNEL.getCode()),"task_id = '"+taskId+"'");
|
||||||
|
|
||||||
|
}
|
||||||
|
interface SpeStatusHandler{
|
||||||
|
void handle(JSONObject param,String status,JSONObject task);
|
||||||
|
}
|
||||||
|
class Spe2Spe implements SpeStatusHandler{
|
||||||
|
@Override
|
||||||
|
public void handle(JSONObject param, String sta,JSONObject task) {
|
||||||
|
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_");
|
||||||
|
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||||
|
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||||
|
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||||
|
|
||||||
|
switch (status){
|
||||||
|
case STATUS_START:
|
||||||
|
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||||
|
break;
|
||||||
|
case STATUS_RUNDING:
|
||||||
|
break;
|
||||||
|
case STATUS_FINISH:
|
||||||
|
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_FINISH.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||||
|
//到专机:更新设备上料位物料数量
|
||||||
|
String point_code2 = task.getString("point_code2");
|
||||||
|
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||||
|
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
||||||
|
task.getDouble("material_qty");
|
||||||
|
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
||||||
|
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log.error(OPT_NAME+"未定义任务状态:{}",sta);
|
||||||
|
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Spe2Cache implements SpeStatusHandler{
|
||||||
|
@Override
|
||||||
|
public void handle(JSONObject param, String sta,JSONObject task) {
|
||||||
|
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_");
|
||||||
|
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||||
|
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||||
|
String workprocedureCode = param.getString("workorder_code");
|
||||||
|
String inboxtxm = param.getString("inboxtxm");
|
||||||
|
String outboxtxm = param.getString("outboxtxm");
|
||||||
|
switch (status){
|
||||||
|
case STATUS_START:
|
||||||
|
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||||
|
break;
|
||||||
|
case STATUS_RUNDING:
|
||||||
|
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||||
|
break;
|
||||||
|
case STATUS_FINISH:
|
||||||
|
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_FINISH.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||||
|
cacheVehTable.insert(MapOf.of("quantity", task.getString("material_qty"),
|
||||||
|
"material_id", task.getString("material_id"),
|
||||||
|
"vehicle_code", inboxtxm,
|
||||||
|
"vehicle_status", StatusEnum.CACHE_VEL_FULL.getCode(),
|
||||||
|
//工单,工序?
|
||||||
|
"workorder_code", workprocedureCode,
|
||||||
|
"create_time", DateUtil.now(),
|
||||||
|
"update_time", DateUtil.now()
|
||||||
|
//物料规格,物料名称 从物料信息表关联查询
|
||||||
|
));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
class Cache2Spe implements SpeStatusHandler{
|
||||||
|
@Override
|
||||||
|
public void handle(JSONObject param, String sta,JSONObject task) {
|
||||||
|
AcsTaskEnum status = AcsTaskEnum.getType(sta,"status_");
|
||||||
|
WQLObject taskTable = WQLObject.getWQLObject("sch_base_task");
|
||||||
|
WQLObject cacheVehTable = WQLObject.getWQLObject("sch_cacheline_vehilematerial");
|
||||||
|
WQLObject pointTable = WQLObject.getWQLObject("SCH_BASE_Point");
|
||||||
|
WQLObject deviceTable = WQLObject.getWQLObject("pdm_bi_device");
|
||||||
|
String outboxtxm = param.getString("outboxtxm");
|
||||||
|
|
||||||
|
switch (status){
|
||||||
|
case STATUS_START:
|
||||||
|
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_RUNNING.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||||
|
cacheVehTable.delete("vehicle_code = '" + outboxtxm + "'");
|
||||||
|
break;
|
||||||
|
case STATUS_FINISH:
|
||||||
|
taskTable.update(MapOf.of("task_status",StatusEnum.TASK_FINISH.getCode(),"update_name","acs","update_time", DateUtil.now()),"task_id = '"+task.getString("task_id")+"'");
|
||||||
|
|
||||||
|
String point_code2 = task.getString("point_code2");
|
||||||
|
JSONObject pointInfo = pointTable.query("point_code = '" + point_code2 + "'").uniqueResult(0);
|
||||||
|
JSONObject device = deviceTable.query("device_code = '" + pointInfo.getString("device_code") + "'").uniqueResult(0);
|
||||||
|
task.getDouble("material_qty");
|
||||||
|
double currentQty = device.getDouble("deviceinstor_qty") + task.getDouble("material_qty");
|
||||||
|
deviceTable.update(MapOf.of("deviceinstor_qty", String.valueOf(currentQty)), "device_code = '" + pointInfo.getString("device_code") + "'");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new BadRequestException(OPT_NAME+"未定义任务状态:"+sta);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Binary file not shown.
Reference in New Issue
Block a user