acs测试提交
This commit is contained in:
@@ -0,0 +1,54 @@
|
|||||||
|
package org.nl.wms.common;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import org.nl.exception.BadRequestException;
|
||||||
|
import org.nl.wql.core.bean.WQLObject;
|
||||||
|
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
|
||||||
|
public class KilnUtil {
|
||||||
|
static Queue<String> KilnQueue = new ArrayBlockingQueue<>(10);
|
||||||
|
//入窑扫码
|
||||||
|
public static void inKiln(String vehicle_code) {
|
||||||
|
KilnQueue.offer(vehicle_code);
|
||||||
|
//插入窑设备记录表
|
||||||
|
WQLObject recordTable = WQLObject.getWQLObject("pdm_bi_kilnrecord");
|
||||||
|
WQLObject groupTable = WQLObject.getWQLObject("st_buss_vehiclegroup");
|
||||||
|
JSONObject groupObj = groupTable.query("vehicle_code ='" + vehicle_code + "'").uniqueResult(0);
|
||||||
|
if (ObjectUtil.isEmpty(groupObj)) {
|
||||||
|
throw new BadRequestException("未找到组盘信息,不能入窑!");
|
||||||
|
}
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
jo.put("record_id", IdUtil.getSnowflake(1, 1).nextId());
|
||||||
|
jo.put("vehicle_code", vehicle_code);
|
||||||
|
jo.put("material_id", groupObj.getString("material_id"));
|
||||||
|
jo.put("material_code", groupObj.getString("material_code"));
|
||||||
|
jo.put("material_name", groupObj.getString("material_name"));
|
||||||
|
jo.put("material_spec", groupObj.getString("material_spec"));
|
||||||
|
jo.put("qty", groupObj.getString("qty"));
|
||||||
|
jo.put("in_time", DateUtil.now());
|
||||||
|
jo.put("out_time", "");
|
||||||
|
jo.put("is_success", "0");
|
||||||
|
jo.put("is_delete", "0");
|
||||||
|
recordTable.insert(jo);
|
||||||
|
}
|
||||||
|
|
||||||
|
//出窑扫码
|
||||||
|
public static void outKiln(String vehicle_code) {
|
||||||
|
KilnQueue.offer(vehicle_code);
|
||||||
|
//更新窑设备记录表
|
||||||
|
WQLObject recordTable = WQLObject.getWQLObject("pdm_bi_kilnrecord");
|
||||||
|
JSONObject vehicleObj = recordTable.query("vehicle_code='" + vehicle_code + " and out_time ='''").uniqueResult(0);
|
||||||
|
if (ObjectUtil.isEmpty(vehicleObj)) {
|
||||||
|
throw new BadRequestException("未找到信息");
|
||||||
|
}
|
||||||
|
vehicleObj.put("out_time", DateUtil.now());
|
||||||
|
recordTable.update(vehicleObj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -51,6 +51,13 @@ public class AcsToWmsController {
|
|||||||
acsToWmsService.group(whereJson);
|
acsToWmsService.group(whereJson);
|
||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
@PostMapping("/inKiln")
|
||||||
|
@Log("入窑扫码器")
|
||||||
|
@ApiOperation("入窑扫码器")
|
||||||
|
public ResponseEntity<Object> inKiln(@RequestBody Map whereJson) {
|
||||||
|
acsToWmsService.inKiln(whereJson);
|
||||||
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/ispackage")
|
@PostMapping("/ispackage")
|
||||||
@Log("ACS给WMS请求是否自动码垛")
|
@Log("ACS给WMS请求是否自动码垛")
|
||||||
@@ -96,4 +103,10 @@ public class AcsToWmsController {
|
|||||||
return new ResponseEntity<>(HttpStatus.OK);
|
return new ResponseEntity<>(HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/status")
|
||||||
|
@Log("ACS给WMS反馈任务状态")
|
||||||
|
@ApiOperation("ACS给WMS反馈任务状态")
|
||||||
|
public ResponseEntity<Object> receiveTaskStatusAcs(@RequestBody String string) {
|
||||||
|
return new ResponseEntity<>(acsToWmsService.receiveTaskStatusAcs(string), HttpStatus.OK);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,14 @@ public interface AcsToWmsService {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
void group(Map jsonObject);
|
void group(Map jsonObject);
|
||||||
|
/**
|
||||||
|
* 入窑扫码器
|
||||||
|
*
|
||||||
|
* @param jsonObject 条件
|
||||||
|
* @return Map<String, Object>
|
||||||
|
*/
|
||||||
|
|
||||||
|
Map<String, Object> inKiln(Map jsonObject);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ACS给WMS请求是否优先包装
|
* ACS给WMS请求是否优先包装
|
||||||
@@ -75,5 +82,14 @@ public interface AcsToWmsService {
|
|||||||
void sureProduceTask(Map jsonObject);
|
void sureProduceTask(Map jsonObject);
|
||||||
|
|
||||||
void updateVehicleType(Map jsonObject);
|
void updateVehicleType(Map jsonObject);
|
||||||
|
/**
|
||||||
|
* ACS客户端--->WMS服务端
|
||||||
|
* ACS向WMS反馈任务状态
|
||||||
|
*
|
||||||
|
* @param jsonObject 条件
|
||||||
|
* @return Map<String, Object>
|
||||||
|
*/
|
||||||
|
|
||||||
|
Map<String, Object> receiveTaskStatusAcs(String string);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,21 +9,29 @@ import com.alibaba.fastjson.JSONArray;
|
|||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.checkerframework.checker.units.qual.K;
|
||||||
import org.nl.exception.BadRequestException;
|
import org.nl.exception.BadRequestException;
|
||||||
import org.nl.modules.system.util.CodeUtil;
|
import org.nl.modules.system.util.CodeUtil;
|
||||||
import org.nl.utils.SecurityUtils;
|
import org.nl.utils.SecurityUtils;
|
||||||
import org.nl.wms.WorkProcedureEnum;
|
import org.nl.wms.WorkProcedureEnum;
|
||||||
|
import org.nl.wms.common.KilnUtil;
|
||||||
import org.nl.wms.common.PointUpdateUtil;
|
import org.nl.wms.common.PointUpdateUtil;
|
||||||
import org.nl.wms.common.StructFindUtil;
|
import org.nl.wms.common.StructFindUtil;
|
||||||
import org.nl.wms.database.service.dto.VehicleDto;
|
import org.nl.wms.database.service.dto.VehicleDto;
|
||||||
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
import org.nl.wms.ext.acs.service.AcsToWmsService;
|
||||||
import org.nl.wms.sch.manage.AreaEnum;
|
import org.nl.wms.sch.manage.AreaEnum;
|
||||||
|
import org.nl.wms.sch.manage.TaskStatusEnum;
|
||||||
import org.nl.wms.sch.manage.buss.*;
|
import org.nl.wms.sch.manage.buss.*;
|
||||||
|
import org.nl.wms.sch.service.TaskService;
|
||||||
|
import org.nl.wms.sch.service.dto.TaskDto;
|
||||||
import org.nl.wql.WQL;
|
import org.nl.wql.WQL;
|
||||||
import org.nl.wql.core.bean.WQLObject;
|
import org.nl.wql.core.bean.WQLObject;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
@@ -37,6 +45,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
private final RgvTask rgvTask;
|
private final RgvTask rgvTask;
|
||||||
private final WmsToAcsServiceImpl wmsToAcsServiceImpl;
|
private final WmsToAcsServiceImpl wmsToAcsServiceImpl;
|
||||||
private final ToConveyorTask toConveyorTask;
|
private final ToConveyorTask toConveyorTask;
|
||||||
|
private final TaskService taskService;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -160,7 +170,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
if (ObjectUtil.isEmpty(produceInfoByCode)) {
|
if (ObjectUtil.isEmpty(produceInfoByCode)) {
|
||||||
throw new BadRequestException("未找到点位为'" + device_code + "'对应机械手的生产工单!");
|
throw new BadRequestException("未找到点位为'" + device_code + "'对应机械手的生产工单!");
|
||||||
}
|
}
|
||||||
jsonObject.put("vehicle_type",produceInfoByCode.getString("vehicle_type"));
|
jsonObject.put("vehicle_type", produceInfoByCode.getString("vehicle_type"));
|
||||||
|
|
||||||
callEmptyVehicleTask.createTask((JSONObject) JSON.toJSON(jsonObject));
|
callEmptyVehicleTask.createTask((JSONObject) JSON.toJSON(jsonObject));
|
||||||
break;
|
break;
|
||||||
@@ -340,6 +350,13 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> inKiln(Map jsonObject) {
|
||||||
|
String vehicle_code = String.valueOf(jsonObject.get("vehicle_code"));
|
||||||
|
KilnUtil.inKiln(vehicle_code);
|
||||||
|
return new JSONObject();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public Map<String, Object> ispackage(Map jsonObject) {
|
public Map<String, Object> ispackage(Map jsonObject) {
|
||||||
@@ -355,7 +372,9 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
JSONObject groupObj = groupTable.query("vehicle_code ='" + vehicle_code + "'").uniqueResult(0);
|
JSONObject groupObj = groupTable.query("vehicle_code ='" + vehicle_code + "'").uniqueResult(0);
|
||||||
groupTable.query("vehicle_code ='" + vehicle_code + "'").uniqueResult(0);
|
groupTable.query("vehicle_code ='" + vehicle_code + "'").uniqueResult(0);
|
||||||
JSONObject returnjo = new JSONObject();
|
JSONObject returnjo = new JSONObject();
|
||||||
returnjo.put("is_autopackage", groupObj.getString("is_autopackage"));
|
returnjo.put("code", groupObj.getString("is_autopackage"));
|
||||||
|
//更新窑的信息
|
||||||
|
KilnUtil.outKiln(vehicle_code);
|
||||||
return returnjo;
|
return returnjo;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -424,8 +443,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
String producetask_code = (String) jsonObject.get("producetask_code");
|
String producetask_code = (String) jsonObject.get("producetask_code");
|
||||||
String device_code = (String) jsonObject.get("device_code");
|
String device_code = (String) jsonObject.get("device_code");
|
||||||
String material_code = (String) jsonObject.get("material_code");
|
String material_code = (String) jsonObject.get("material_code");
|
||||||
String qty = (String) jsonObject.get("qty");
|
String qty = String.valueOf(jsonObject.get("qty"));
|
||||||
String weight = (String) jsonObject.get("weight");
|
|
||||||
String type = (String) jsonObject.get("type");
|
String type = (String) jsonObject.get("type");
|
||||||
if (StrUtil.isEmpty(type)) {
|
if (StrUtil.isEmpty(type)) {
|
||||||
throw new BadRequestException("类型不能为空!");
|
throw new BadRequestException("类型不能为空!");
|
||||||
@@ -459,14 +477,12 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
if (!StrUtil.equals(materiObj.getString("material_id"), taskObj.getString("material_id"))) {
|
if (!StrUtil.equals(materiObj.getString("material_id"), taskObj.getString("material_id"))) {
|
||||||
throw new BadRequestException("物料标识不一样!");
|
throw new BadRequestException("物料标识不一样!");
|
||||||
}
|
}
|
||||||
taskObj.put("producetask_status", "03");
|
taskObj.put("producetask_status", "04");
|
||||||
|
|
||||||
}
|
}
|
||||||
if (StrUtil.equals("2", type)) {
|
if (StrUtil.equals("2", type)) {
|
||||||
taskObj.put("producetask_status", "04");
|
|
||||||
}
|
|
||||||
if (StrUtil.equals("3", type)) {
|
|
||||||
taskObj.put("producetask_status", "05");
|
taskObj.put("producetask_status", "05");
|
||||||
|
taskObj.put("real_qty",qty);
|
||||||
}
|
}
|
||||||
taskTable.update(taskObj);
|
taskTable.update(taskObj);
|
||||||
}
|
}
|
||||||
@@ -494,6 +510,72 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> receiveTaskStatusAcs(String string) {
|
||||||
|
{
|
||||||
|
JSONArray array = JSONArray.parseArray(string);
|
||||||
|
//返回处理失败的任务
|
||||||
|
JSONArray errArr = new JSONArray();
|
||||||
|
for (int i = 0; i < array.size(); i++) {
|
||||||
|
JSONObject row = array.getJSONObject(i);
|
||||||
|
String task_id = row.getString("ext_task_uuid");
|
||||||
|
row.put("task_id",task_id);
|
||||||
|
TaskDto taskDto = taskService.findById(task_id);
|
||||||
|
String processing_class = taskDto.getHandle_class();
|
||||||
|
//1:执行中,2:完成 ,3:acs取消
|
||||||
|
String acs_task_status = row.getString("task_status");
|
||||||
|
String message = "";
|
||||||
|
String status = "";
|
||||||
|
if ("1".equals(acs_task_status)) {
|
||||||
|
status = TaskStatusEnum.EXECUTING.getCode();
|
||||||
|
}
|
||||||
|
if ("2".equals(acs_task_status)) {
|
||||||
|
status = TaskStatusEnum.FINISHED.getCode();
|
||||||
|
}
|
||||||
|
// 任务处理类
|
||||||
|
try {
|
||||||
|
Class<?> clz = Class.forName(processing_class);
|
||||||
|
Object obj = clz.newInstance();
|
||||||
|
// 调用每个任务类的forceFinishInst()强制结束方法
|
||||||
|
Method m = obj.getClass().getDeclaredMethod("updateTaskStatus", JSONObject.class, String.class);
|
||||||
|
m.invoke(obj, row, status);
|
||||||
|
} catch (InvocationTargetException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
//空指针
|
||||||
|
if (ObjectUtil.isNull(e.getTargetException().getMessage())) {
|
||||||
|
message = e.getTargetException().toString();
|
||||||
|
} else {
|
||||||
|
message = e.getTargetException().getMessage();
|
||||||
|
}
|
||||||
|
log.info("任务状态更新失败:{}", message);
|
||||||
|
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("task_id", task_id);
|
||||||
|
json.put("message", message);
|
||||||
|
errArr.add(json);
|
||||||
|
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
message = e.getMessage();
|
||||||
|
log.info("任务状态更新失败:{}", message);
|
||||||
|
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("task_id", task_id);
|
||||||
|
json.put("message", message);
|
||||||
|
errArr.add(json);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject result = new JSONObject();
|
||||||
|
result.put("status", HttpStatus.OK.value());
|
||||||
|
result.put("message", "任务状态反馈成功!");
|
||||||
|
result.put("data", new JSONObject());
|
||||||
|
result.put("errArr", errArr);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private JSONObject getProduceInfoByCode(String code) {
|
private JSONObject getProduceInfoByCode(String code) {
|
||||||
//根据 设备点位去找生产任务信息
|
//根据 设备点位去找生产任务信息
|
||||||
//1 根据点位去找设备,去找对应的设备信息
|
//1 根据点位去找设备,去找对应的设备信息
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public abstract class AbstractAcsTask {
|
|||||||
for (int i = 0, j = tasks.size(); i < j; i++) {
|
for (int i = 0, j = tasks.size(); i < j; i++) {
|
||||||
JSONObject json = tasks.getJSONObject(i);
|
JSONObject json = tasks.getJSONObject(i);
|
||||||
AcsTaskDto taskDto = new AcsTaskDto();
|
AcsTaskDto taskDto = new AcsTaskDto();
|
||||||
taskDto.setTask_id(json.getString("task_id"));
|
taskDto.setExt_task_uuid(json.getString("task_id"));
|
||||||
taskDto.setTask_code(json.getString("task_code"));
|
taskDto.setTask_code(json.getString("task_code"));
|
||||||
taskDto.setTask_type("1");
|
taskDto.setTask_type("1");
|
||||||
taskDto.setRoute_plan_code("normal");
|
taskDto.setRoute_plan_code("normal");
|
||||||
@@ -114,7 +114,7 @@ public abstract class AbstractAcsTask {
|
|||||||
for (int i = 0, j = arr.size(); i < j; i++) {
|
for (int i = 0, j = arr.size(); i < j; i++) {
|
||||||
JSONObject json = arr.getJSONObject(i);
|
JSONObject json = arr.getJSONObject(i);
|
||||||
AcsTaskDto taskDto = new AcsTaskDto();
|
AcsTaskDto taskDto = new AcsTaskDto();
|
||||||
taskDto.setTask_id(json.getString("task_id"));
|
taskDto.setExt_task_uuid(json.getString("task_id"));
|
||||||
taskDto.setTask_code(json.getString("task_code"));
|
taskDto.setTask_code(json.getString("task_code"));
|
||||||
taskDto.setTask_type("1");
|
taskDto.setTask_type("1");
|
||||||
taskDto.setRoute_plan_code("normal");
|
taskDto.setRoute_plan_code("normal");
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import lombok.Data;
|
|||||||
@Data
|
@Data
|
||||||
public class AcsTaskDto {
|
public class AcsTaskDto {
|
||||||
//任务标识
|
//任务标识
|
||||||
private String task_id;
|
private String ext_task_uuid;
|
||||||
//任务编码
|
//任务编码
|
||||||
private String task_code;
|
private String task_code;
|
||||||
//任务类型
|
//任务类型
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ public class AutoCreateTask {
|
|||||||
if ("200".equals(status)) {
|
if ("200".equals(status)) {
|
||||||
taskList.forEach(item -> {
|
taskList.forEach(item -> {
|
||||||
JSONObject taskObj = new JSONObject();
|
JSONObject taskObj = new JSONObject();
|
||||||
taskObj.put("task_id", item.getTask_id());
|
taskObj.put("task_id", item.getExt_task_uuid());
|
||||||
taskObj.put("task_status", TaskStatusEnum.ISSUE.getCode());
|
taskObj.put("task_status", TaskStatusEnum.ISSUE.getCode());
|
||||||
taskObj.put("remark", "下发成功");
|
taskObj.put("remark", "下发成功");
|
||||||
taskObj.put("update_time", DateUtil.now());
|
taskObj.put("update_time", DateUtil.now());
|
||||||
@@ -99,7 +99,7 @@ public class AutoCreateTask {
|
|||||||
} else {//下发失败
|
} else {//下发失败
|
||||||
taskList.forEach(item -> {
|
taskList.forEach(item -> {
|
||||||
JSONObject taskObj = new JSONObject();
|
JSONObject taskObj = new JSONObject();
|
||||||
taskObj.put("task_id", item.getTask_id());
|
taskObj.put("task_id", item.getExt_task_uuid());
|
||||||
taskObj.put("task_status", TaskStatusEnum.ISSUE.getCode());
|
taskObj.put("task_status", TaskStatusEnum.ISSUE.getCode());
|
||||||
taskObj.put("remark", "下发失败:" + message);
|
taskObj.put("remark", "下发失败:" + message);
|
||||||
taskObj.put("update_time", DateUtil.now());
|
taskObj.put("update_time", DateUtil.now());
|
||||||
|
|||||||
Binary file not shown.
@@ -13,6 +13,8 @@ import java.text.ParseException;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
|
|
||||||
public class Test3 extends BaseTest {
|
public class Test3 extends BaseTest {
|
||||||
@org.junit.Test
|
@org.junit.Test
|
||||||
@@ -424,6 +426,15 @@ public class Test3 extends BaseTest {
|
|||||||
ruleTable.insert(joObj);
|
ruleTable.insert(joObj);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
Queue<String> ma = new ArrayBlockingQueue<>(10);
|
||||||
|
for (int i = 0; i <9 ; i++) {
|
||||||
|
ma.offer("pla00"+i);
|
||||||
|
}
|
||||||
|
ma.poll();
|
||||||
|
for (String str:ma){
|
||||||
|
System.out.println(str);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user