Browse Source

add: 添加Sorting交互接口,反馈物料完成信号,sorting下发交期时间/下道工序;添加呼叫无下道工序物料

master
yanps 2 weeks ago
parent
commit
0166ce4cbc
  1. 73
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java
  2. 21
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java
  3. 2
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/fab/service/dto/OrderMater.java
  4. 23
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/service/impl/HandheldServiceImpl.java
  5. 294
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/sorting/service/impl/SortingServiceImpl.java
  6. 15
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dao/mapper/SchBasePointMapper.xml
  7. 43
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java
  8. 12
      lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/ConnectorUtil.java

73
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/device_driver/basedriver/agv/ndcone/AgvNdcOneDeviceDriver.java

@ -188,24 +188,42 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
} else if (device_code.contains("_02")) {
Object plc_to_agv = extraValue.get("upper_lower_levels");
if (ObjectUtil.isNotNull(plc_to_agv) && "1".equals(plc_to_agv)) {
plcToAgvDeviceDriver.writing("AGVSetOutReqUpper", "1");
if (plcToAgvDeviceDriver.getAGVSetOutReqUpper() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVSetOutReqUpper", "1");
}
//plcToAgvDeviceDriver.writing("AGVSetOutReqUpper", "1");
if (plcToAgvDeviceDriver.getAGVSetOutUpperAllowed() == 1) {
plcToAgvDeviceDriver.writing("AGVInOP", "1");
if (plcToAgvDeviceDriver.getAGVInOP() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVInOP", "1");
}
//plcToAgvDeviceDriver.writing("AGVInOP", "1");
data = feedBackStatus(data, index, 1, inst, task, 2, false);
}
}
} else if (ObjectUtil.isNotEmpty(extraValue.get("upper_lower_levels"))) {
Object plc_to_agv = extraValue.get("upper_lower_levels");
if ("1".equals(plc_to_agv)) {
plcToAgvDeviceDriver.writing("AGVSetOutReqUpper", "1");
if (plcToAgvDeviceDriver.getAGVSetOutReqUpper() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVSetOutReqUpper", "1");
}
//plcToAgvDeviceDriver.writing("AGVSetOutReqUpper", "1");
if (plcToAgvDeviceDriver.getAGVSetOutUpperAllowed() == 1) {
plcToAgvDeviceDriver.writing("AGVInOP", "1");
if (plcToAgvDeviceDriver.getAGVInOP() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVInOP", "1");
}
//plcToAgvDeviceDriver.writing("AGVInOP", "1");
data = feedBackStatus(data, index, 1, inst, task, 2, false);
}
} else if ("2".equals(plc_to_agv)) {
plcToAgvDeviceDriver.writing("AGVSetOutReqLower", "1");
if (plcToAgvDeviceDriver.getAGVSetOutReqLower() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVSetOutReqLower", "1");
}
//plcToAgvDeviceDriver.writing("AGVSetOutReqLower", "1");
if (plcToAgvDeviceDriver.getAGVSetOutLowerAllowed() == 1) {
plcToAgvDeviceDriver.writing("AGVInOP", "1");
if (plcToAgvDeviceDriver.getAGVInOP() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVInOP", "1");
}
//plcToAgvDeviceDriver.writing("AGVInOP", "1");
data = feedBackStatus(data, index, 1, inst, task, 2, false);
}
}
@ -348,9 +366,15 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
if (device_code.contains("_01")) {
Object plc_to_agv = extraValue.get("upper_lower_levels");
if (ObjectUtil.isNotNull(plc_to_agv) && "1".equals(plc_to_agv)) {
plcToAgvDeviceDriver.writing("AGVSetInReqUpper", "1");
if (plcToAgvDeviceDriver.getAGVSetInReqUpper() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVSetInReqUpper", "1");
}
//plcToAgvDeviceDriver.writing("AGVSetInReqUpper", "1");
if (plcToAgvDeviceDriver.getAGVSetInUpperAllowed() == 1) {
plcToAgvDeviceDriver.writing("AGVInOP", "1");
if (plcToAgvDeviceDriver.getAGVInOP() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVInOP", "1");
}
//plcToAgvDeviceDriver.writing("AGVInOP", "1");
data = feedBackStatus(data, index, 3, inst, task, 2, false);
}
}
@ -361,15 +385,27 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
} else if (ObjectUtil.isNotEmpty(extraValue.get("upper_lower_levels"))) {
Object plc_to_agv = extraValue.get("upper_lower_levels");
if ("1".equals(plc_to_agv)) {
plcToAgvDeviceDriver.writing("AGVSetInReqUpper", "1");
if (plcToAgvDeviceDriver.getAGVSetInReqUpper() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVSetInReqUpper", "1");
}
//plcToAgvDeviceDriver.writing("AGVSetInReqUpper", "1");
if (plcToAgvDeviceDriver.getAGVSetInUpperAllowed() == 1) {
plcToAgvDeviceDriver.writing("AGVInOP", "1");
if (plcToAgvDeviceDriver.getAGVInOP() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVInOP", "1");
}
//plcToAgvDeviceDriver.writing("AGVInOP", "1");
data = feedBackStatus(data, index, 3, inst, task, 2, false);
}
} else if ("2".equals(plc_to_agv)) {
plcToAgvDeviceDriver.writing("AGVSetInReqLower", "1");
if (plcToAgvDeviceDriver.getAGVSetInReqLower() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVSetInReqLower", "1");
}
//plcToAgvDeviceDriver.writing("AGVSetInReqLower", "1");
if (plcToAgvDeviceDriver.getAGVSetInLowerAllowed() == 1) {
plcToAgvDeviceDriver.writing("AGVInOP", "1");
if (plcToAgvDeviceDriver.getAGVInOP() != 1) {
writeSignal(plcToAgvDeviceDriver, "AGVInOP", "1");
}
//plcToAgvDeviceDriver.writing("AGVInOP", "1");
data = feedBackStatus(data, index, 3, inst, task, 2, false);
}
}
@ -532,6 +568,19 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
}
}
/**
* 写信号
*/
public void writeSignal(PlcToAgvDeviceDriver plcToAgvDeviceDriver, String kepName, String kepValue) {
List list = new ArrayList<>();
Map map = new HashMap();
map.put("code", kepName);
map.put("value", kepValue);
list.add(map);
plcToAgvDeviceDriver.writing(list);
}
private byte[] getData(byte[] data, int index, Instruction inst, TaskDto task) {
String hasWms = paramService.findByCode("hasWms").getValue();
if ("3".equals(task.getTask_type()) && StrUtil.isNotEmpty(hasWms) && "1".equals(hasWms)) {

21
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/acs/service/impl/AcsToWmsServiceImpl.java

@ -423,7 +423,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
}
private void finishTask(String task_code, String point_code) {
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class).eq(SchBasePoint::getPoint_code, point_code)
pointService.update(Wrappers.lambdaUpdate(SchBasePoint.class)
.eq(SchBasePoint::getPoint_code, point_code)
.set(SchBasePoint::getIs_lock, false));
}
@ -492,6 +493,7 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
json.put("device_code", schBaseTask.getPoint_code1());
json.put("task_code", schBaseTask.getTask_code());
boolean flag = true;
String jobName = null;
AcsResponse acsResponse = connectorService.feedAgvTaskStatus(json);
if (acsResponse.getStatus() == 200 && StrUtil.isNotEmpty(acsResponse.getData())) {
JSONArray objects = JSONObject.parseArray(acsResponse.getData());
@ -517,13 +519,16 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
schBaseVehiclematerialgroup.setCreate_name("Connector");
iSchBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup);
if ("Y".equals(connectorDto.getFinished())) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("cJobName",connectorDto.getJobname());
try {
sortingService.applyFinishJobName(jsonObject);
}catch (Exception e){
log.info("wms反馈sorting->JobName完成,失败{}",e.getMessage());
}
jobName = connectorDto.getJobname();
}
}
if (StrUtil.isNotEmpty(jobName)) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("cJobName", jobName);
try {
sortingService.applyFinishJobName(jsonObject);
} catch (Exception e) {
log.info("wms反馈sorting->JobName完成,失败{}", e.getMessage());
}
}
} else {

2
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/fab/service/dto/OrderMater.java

@ -40,4 +40,6 @@ public class OrderMater {
* 客户编码
*/
public String custom;
public String create_time;
}

23
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/handheld/service/impl/HandheldServiceImpl.java

@ -110,8 +110,14 @@ public class HandheldServiceImpl implements HandheldService {
if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!");
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle);
if (ObjectUtil.isEmpty(mdBaseVehicle))
throw new BadRequestException("载具不存在或载具号与点位不匹配!");
throw new BadRequestException("载具不存在!");
AbstractTask connectorTask = taskFactory.getTask("RACKTask");
SchBasePoint one = iSchBasePointService.getOne(Wrappers.lambdaQuery(SchBasePoint.class)
.eq(SchBasePoint::getVehicle_code, vehicle)
.ne(SchBasePoint::getPoint_code, device_code));
if (ObjectUtil.isNotEmpty(one)) {
throw new BadRequestException("载具号已存在别的点位,请确认再下发");
}
// 准备参数:设备编码
JSONObject jo = new JSONObject();
jo.put("device_code", device_code);
@ -245,12 +251,14 @@ public class HandheldServiceImpl implements HandheldService {
@Transactional(rollbackFor = Exception.class)
public void cageBlankingTask(JSONObject param) {
Assert.noNullElements(new Object[]{param.getString("device_code"), param.getString("vehicle_code")},
"当前点位或目的地不能为空!");
"当前点位或载具号不能为空!");
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(param.getString("device_code"));
/*if (ObjectUtil.isEmpty(schBasePoint)) throw new BadRequestException("设备点位不存在!");
if (schBasePoint.getIs_lock()) {
throw new BadRequestException("该点位正在执行任务,请稍后再试!");
}*/
SchBasePoint one = iSchBasePointService.getOne(Wrappers.lambdaQuery(SchBasePoint.class)
.eq(SchBasePoint::getVehicle_code, param.getString("vehicle_code"))
.ne(SchBasePoint::getPoint_code, param.getString("device_code")));
if (ObjectUtil.isNotEmpty(one)) {
throw new BadRequestException("载具号已存在别的点位,请确认再下发");
}
String region_code = param.getString("region_code");
String device_code = param.getString("device_code");
String vehicle_code = param.getString("vehicle_code");
@ -405,7 +413,8 @@ public class HandheldServiceImpl implements HandheldService {
throw new BadRequestException("物料下料数量不能为空!");
}
MdBaseVehicle mdBaseVehicle = iMdBaseVehicleService.selectByVehicleCode(vehicle_code);
if(mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.TRAY.getVehicleCode())) throw new BadRequestException("钢托盘不能存放加工区!");
if (mdBaseVehicle.getVehicle_type().equals(VehicleTypeEnum.TRAY.getVehicleCode()))
throw new BadRequestException("钢托盘不能存放加工区!");
param.put("region_code", region_code);
jo.put("device_code", device_code);
jo.put("config_code", "ProcessingSMTTask");

294
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/ext/sorting/service/impl/SortingServiceImpl.java

@ -7,6 +7,7 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -35,6 +36,9 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@ -53,6 +57,8 @@ public class SortingServiceImpl implements SortingService {
@Autowired
private ISchBaseVehiclematerialgroupService iSchBaseVehiclematerialgroupService;
private static final DateTimeFormatter ISO_8601_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.SSSX");
@Override
@Transactional(rollbackFor = Exception.class)
@ -61,133 +67,136 @@ public class SortingServiceImpl implements SortingService {
try {
Assert.noNullElements(new Object[]{jsonObject, jsonObject.getString("pointCode"), jsonObject.getString("vehicle_code")
, jsonObject.getString("task_type"), jsonObject.getString("is_empty")}, "请求参数不能为空");
//任务号
String task_code = jsonObject.getString("task_code");
String pointCode = jsonObject.getString("pointCode");
//任务类型:1.运送托盘到sorting;2.从sorting运送托盘给线边库
String task_type = jsonObject.getString("task_type");
//是否空托盘; 1.是 0.否
String is_empty = jsonObject.getString("is_empty");
String task_time = jsonObject.getString("taskTime");
//冲床工作号
String jobname = jsonObject.getString("jobname");
//载具托盘号
String vehicle_code = jsonObject.getString("vehicle_code");
String vehicle_type = jsonObject.getString("vehicle_type");
//托盘上的堆垛信息
JSONArray jsonArray = JSONUtil.parseArray(jsonObject.get("pallet_detail"));
JSONArray jsonArray1 = JSONUtil.parseArray(jsonObject.get("pallet_detail2"));
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(pointCode);
if (ObjectUtil.isEmpty(schBasePoint)) {
log.info("点位编码不存在:{}", pointCode);
return MapOf.of("status", 400, "msg", "点位编码不存在!");
}
if (schBasePoint.getIs_lock()) {
log.info("该点位已创建任务:{}", pointCode);
return MapOf.of("status", 400, "msg", "该点位已创建任务!");
}
JSONObject taskParam = new JSONObject(MapOf.of("task_code", task_code, "job_name", jobname, "device_code", pointCode, "requestNo"
, "sorting_" + IdUtil.getStringId(), "ext_data", jsonObject, "vehicle_code", vehicle_code, "ext_data", jsonObject));
AbstractTask connectorTask = taskFactory.getTask("CNTTask");
if ("0".equals(vehicle_type)) {
// TODO:呼叫空托
if (SortingEnum.TASK_TYPE_ONE.getValue().equals(task_type) && SortingEnum.IS_EMPTY.getValue().equals(is_empty)) {
taskParam.put("vehicle_type", "G01");
taskParam.put("config_code", "SortingCNTTask");
connectorTask.apply(taskParam);
//TODO:叫料
} else if (SortingEnum.TASK_TYPE_ONE.getValue().equals(task_type) && SortingEnum.NOT_EMPTY.getValue().equals(is_empty)) {
if (StrUtil.isEmpty(vehicle_code)) {
log.info("载具号未传递");
return MapOf.of("status", 400, "msg", "载具号未传递!");
}
taskParam.put("config_code", "SortingCMTTask");
connectorTask.apply(taskParam);
//TODO:将空托盘放到线边库
} else if (SortingEnum.TASK_TYPE_TWO.getValue().equals(task_type) && SortingEnum.IS_EMPTY.getValue().equals(is_empty)) {
if (StrUtil.isEmpty(vehicle_code)) {
log.info("载具号未传递");
return MapOf.of("status", 400, "msg", "载具号未传递!");
}
taskParam.put("config_code", "SortingSNTTask");
connectorTask.apply(taskParam);
//TODO:将满料放到线边库
} else if (SortingEnum.TASK_TYPE_TWO.getValue().equals(task_type) && SortingEnum.NOT_EMPTY.getValue().equals(is_empty)) {
if (StrUtil.isEmpty(vehicle_code)) {
log.info("载具号未传递");
return MapOf.of("status", 400, "msg", "载具号未传递!");
}
if (CollUtil.isEmpty(jsonArray) || jsonArray.size() < 1) {
log.info("物料信息为空!");
return MapOf.of("status", 400, "msg", "物料信息为空!");
}
taskParam.put("config_code", "SortingSMTTask");
connectorTask.apply(taskParam);
if (StrUtil.isNotEmpty(jsonObject.getString("is_rawdata")) && "1".equals(jsonObject.getString("is_rawdata"))) {
createMaterial(jsonArray, jsonObject.getString("vehicle_code"));
} else {
//任务号
String task_code = jsonObject.getString("task_code");
String pointCode = jsonObject.getString("pointCode");
//任务类型:1.运送托盘到sorting;2.从sorting运送托盘给线边库
String task_type = jsonObject.getString("task_type");
//是否空托盘; 1.是 0.否
String is_empty = jsonObject.getString("is_empty");
String task_time = jsonObject.getString("taskTime");
//冲床工作号
String jobname = jsonObject.getString("jobname");
//载具托盘号
String vehicle_code = jsonObject.getString("vehicle_code");
String vehicle_type = jsonObject.getString("vehicle_type");
//托盘上的堆垛信息
JSONArray jsonArray1 = JSONUtil.parseArray(jsonObject.get("pallet_detail2"));
SchBasePoint schBasePoint = iSchBasePointService.selectByPointCode(pointCode);
if (ObjectUtil.isEmpty(schBasePoint)) {
log.info("点位编码不存在:{}", pointCode);
return MapOf.of("status", 400, "msg", "点位编码不存在!");
}
iSchBasePointService.update(new UpdateWrapper<SchBasePoint>()
.set("is_lock", true)
.set("remark", task_code)
.eq("point_code", pointCode));
} else if ("1".equals(vehicle_type)) {
//TODO:呼叫两个空笼框
if (SortingEnum.TASK_TYPE_ONE.getValue().equals(task_type) && SortingEnum.IS_EMPTY.getValue().equals(is_empty)) {
taskParam.put("device_code", pointCode + "_01");
taskParam.put("task_seq", "2");
taskParam.put("config_code", "SortingTwoCNTTask");
taskParam.put("task_code", task_code + "A");
connectorTask.apply(taskParam);
iSchBasePointService.update(new UpdateWrapper<SchBasePoint>()
.set("is_lock", true)
.set("remark", task_code)
.eq("point_code", pointCode + "_01"));
taskParam.put("device_code", pointCode + "_02");
taskParam.put("task_seq", "1");
taskParam.put("task_code", task_code + "B");
connectorTask.apply(taskParam);
iSchBasePointService.update(new UpdateWrapper<SchBasePoint>()
.set("is_lock", true)
.set("remark", task_code)
.eq("point_code", pointCode + "_02"));
//TODO:将两个笼框放到线边库
} else if (SortingEnum.TASK_TYPE_TWO.getValue().equals(task_type) && SortingEnum.NOT_EMPTY.getValue().equals(is_empty)) {
if (StrUtil.isEmpty(jsonObject.getString("vehicle_code2"))) {
log.info("第二个笼框载具号未传递");
return MapOf.of("status", 400, "msg", "第二个笼框载具号未传递!");
}
if (CollUtil.isEmpty(jsonArray) || jsonArray.size() < 1) {
log.info("物料信息为空!");
return MapOf.of("status", 400, "msg", "物料信息为空!");
}
if (CollUtil.isEmpty(jsonArray1) || jsonArray1.size() < 1) {
log.info("第二个物料信息为空!");
return MapOf.of("status", 400, "msg", "第二个物料信息为空!");
if (schBasePoint.getIs_lock()) {
log.info("该点位已创建任务:{}", pointCode);
return MapOf.of("status", 400, "msg", "该点位已创建任务!");
}
JSONObject taskParam = new JSONObject(MapOf.of("task_code", task_code, "job_name", jobname, "device_code", pointCode, "requestNo"
, "sorting_" + IdUtil.getStringId(), "ext_data", jsonObject, "vehicle_code", vehicle_code, "ext_data", jsonObject));
AbstractTask connectorTask = taskFactory.getTask("CNTTask");
if ("0".equals(vehicle_type)) {
// TODO:呼叫空托
if (SortingEnum.TASK_TYPE_ONE.getValue().equals(task_type) && SortingEnum.IS_EMPTY.getValue().equals(is_empty)) {
taskParam.put("vehicle_type", "G01");
taskParam.put("config_code", "SortingCNTTask");
connectorTask.apply(taskParam);
//TODO:叫料
} else if (SortingEnum.TASK_TYPE_ONE.getValue().equals(task_type) && SortingEnum.NOT_EMPTY.getValue().equals(is_empty)) {
if (StrUtil.isEmpty(vehicle_code)) {
log.info("载具号未传递");
return MapOf.of("status", 400, "msg", "载具号未传递!");
}
taskParam.put("config_code", "SortingCMTTask");
connectorTask.apply(taskParam);
//TODO:将空托盘放到线边库
} else if (SortingEnum.TASK_TYPE_TWO.getValue().equals(task_type) && SortingEnum.IS_EMPTY.getValue().equals(is_empty)) {
if (StrUtil.isEmpty(vehicle_code)) {
log.info("载具号未传递");
return MapOf.of("status", 400, "msg", "载具号未传递!");
}
taskParam.put("config_code", "SortingSNTTask");
connectorTask.apply(taskParam);
//TODO:将满料放到线边库
} else if (SortingEnum.TASK_TYPE_TWO.getValue().equals(task_type) && SortingEnum.NOT_EMPTY.getValue().equals(is_empty)) {
if (StrUtil.isEmpty(vehicle_code)) {
log.info("载具号未传递");
return MapOf.of("status", 400, "msg", "载具号未传递!");
}
if (CollUtil.isEmpty(jsonArray) || jsonArray.size() < 1) {
log.info("物料信息为空!");
return MapOf.of("status", 400, "msg", "物料信息为空!");
}
taskParam.put("config_code", "SortingSMTTask");
connectorTask.apply(taskParam);
}
taskParam.put("config_code", "SortingSMTTask");
taskParam.put("vehicle_code", vehicle_code);
taskParam.put("task_seq", "1");
taskParam.put("device_code", pointCode + "_01");
taskParam.put("task_code", task_code + "A");
connectorTask.apply(taskParam);
iSchBasePointService.update(new UpdateWrapper<SchBasePoint>()
.set("is_lock", true)
.set("remark", task_code)
.eq("point_code", pointCode + "_01"));
jsonObject.put("pallet_detail",jsonArray1);
taskParam = new JSONObject(MapOf.of("task_code", task_code, "job_name", jobname, "device_code", pointCode, "requestNo"
, "sorting_" + IdUtil.getStringId(), "ext_data", jsonObject, "vehicle_code", vehicle_code, "ext_data", jsonObject));
taskParam.put("config_code", "SortingSMTTask");
taskParam.put("task_seq", "2");
taskParam.put("vehicle_code", jsonObject.getString("vehicle_code2"));
taskParam.put("device_code", pointCode + "_02");
taskParam.put("task_code", task_code + "B");
connectorTask.apply(taskParam);
iSchBasePointService.update(new UpdateWrapper<SchBasePoint>()
.set("is_lock", true)
.set("remark", task_code)
.eq("point_code", pointCode + "_02"));
.eq("point_code", pointCode));
} else if ("1".equals(vehicle_type)) {
//TODO:呼叫两个空笼框
if (SortingEnum.TASK_TYPE_ONE.getValue().equals(task_type) && SortingEnum.IS_EMPTY.getValue().equals(is_empty)) {
taskParam.put("device_code", pointCode + "_01");
taskParam.put("task_seq", "2");
taskParam.put("config_code", "SortingTwoCNTTask");
taskParam.put("task_code", task_code + "A");
connectorTask.apply(taskParam);
iSchBasePointService.update(new UpdateWrapper<SchBasePoint>()
.set("is_lock", true)
.set("remark", task_code)
.eq("point_code", pointCode + "_01"));
taskParam.put("device_code", pointCode + "_02");
taskParam.put("task_seq", "1");
taskParam.put("task_code", task_code + "B");
connectorTask.apply(taskParam);
iSchBasePointService.update(new UpdateWrapper<SchBasePoint>()
.set("is_lock", true)
.set("remark", task_code)
.eq("point_code", pointCode + "_02"));
//TODO:将两个笼框放到线边库
} else if (SortingEnum.TASK_TYPE_TWO.getValue().equals(task_type) && SortingEnum.NOT_EMPTY.getValue().equals(is_empty)) {
if (StrUtil.isEmpty(jsonObject.getString("vehicle_code2"))) {
log.info("第二个笼框载具号未传递");
return MapOf.of("status", 400, "msg", "第二个笼框载具号未传递!");
}
if (CollUtil.isEmpty(jsonArray) || jsonArray.size() < 1) {
log.info("物料信息为空!");
return MapOf.of("status", 400, "msg", "物料信息为空!");
}
if (CollUtil.isEmpty(jsonArray1) || jsonArray1.size() < 1) {
log.info("第二个物料信息为空!");
return MapOf.of("status", 400, "msg", "第二个物料信息为空!");
}
taskParam.put("config_code", "SortingSMTTask");
taskParam.put("vehicle_code", vehicle_code);
taskParam.put("task_seq", "1");
taskParam.put("device_code", pointCode + "_01");
taskParam.put("task_code", task_code + "A");
connectorTask.apply(taskParam);
iSchBasePointService.update(new UpdateWrapper<SchBasePoint>()
.set("is_lock", true)
.set("remark", task_code)
.eq("point_code", pointCode + "_01"));
jsonObject.put("pallet_detail", jsonArray1);
taskParam = new JSONObject(MapOf.of("task_code", task_code, "job_name", jobname, "device_code", pointCode, "requestNo"
, "sorting_" + IdUtil.getStringId(), "ext_data", jsonObject, "vehicle_code", vehicle_code, "ext_data", jsonObject));
taskParam.put("config_code", "SortingSMTTask");
taskParam.put("task_seq", "2");
taskParam.put("vehicle_code", jsonObject.getString("vehicle_code2"));
taskParam.put("device_code", pointCode + "_02");
taskParam.put("task_code", task_code + "B");
connectorTask.apply(taskParam);
iSchBasePointService.update(new UpdateWrapper<SchBasePoint>()
.set("is_lock", true)
.set("remark", task_code)
.eq("point_code", pointCode + "_02"));
}
}
}
return MapOf.of("status", 200, "msg", "sucess");
} catch (Exception ex) {
log.info("sorting下发任务失败:{}", ex.getMessage());
@ -195,17 +204,60 @@ public class SortingServiceImpl implements SortingService {
}
}
private void createMaterial(JSONArray jsonArray, String vehicleCode) {
iSchBaseVehiclematerialgroupService.remove(Wrappers.lambdaQuery(SchBaseVehiclematerialgroup.class)
.eq(SchBaseVehiclematerialgroup::getVehicle_code, vehicleCode));
for (Object o : jsonArray) {
JSONObject jO = (JSONObject) JSONObject.toJSON(o);
String workorder = jO.getString("ProductionOrder");
String ProductID = jO.getString("ProductID");
Integer qty = jO.getInteger("Currentqty");
String Jobname = jO.getString("Jobname");
String dueDate = jO.getString("DueDate");
String region_code = jO.getString("NextOperation");
SchBaseVehiclematerialgroup schBaseVehiclematerialgroup = new SchBaseVehiclematerialgroup();
schBaseVehiclematerialgroup.setVehicle_code(vehicleCode);
schBaseVehiclematerialgroup.setMaterial_id(ProductID);
schBaseVehiclematerialgroup.setMaterial_qty(qty);
schBaseVehiclematerialgroup.setRegion_code(region_code);
schBaseVehiclematerialgroup.setOrder_code(workorder);
schBaseVehiclematerialgroup.setJob_name(Jobname);
if (StrUtil.isNotEmpty(dueDate) && isValidISO8601(dueDate)) {
dueDate = parseDate(dueDate);
}
schBaseVehiclematerialgroup.setDue_date(dueDate);
schBaseVehiclematerialgroup.setCreate_name("Sorting");
schBaseVehiclematerialgroup.setExtend(JSON.toJSONString(jO));
iSchBaseVehiclematerialgroupService.create(schBaseVehiclematerialgroup);
}
}
public static String parseDate(String isoString) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
ZonedDateTime zonedDateTime = ZonedDateTime.parse(isoString);
return formatter.format(zonedDateTime);
}
public static boolean isValidISO8601(String dateString) {
try {
ZonedDateTime.parse(dateString, ISO_8601_FORMATTER);
return true;
} catch (DateTimeParseException e) {
return false;
}
}
@Override
public List<ConnectorDto> getStructList(String jobName) {
log.info("sorting查询组盘请求参数数据:{}", jobName);
List<SchBaseVehiclematerialgroup> list = iSchBaseVehiclematerialgroupService.list(Wrappers.lambdaQuery(SchBaseVehiclematerialgroup.class)
.eq(SchBaseVehiclematerialgroup::getJob_name, jobName)
.eq(SchBaseVehiclematerialgroup::getCreate_name,"Connector"));
.eq(SchBaseVehiclematerialgroup::getCreate_name, "Connector"));
List<ConnectorDto> connectors = new ArrayList<>();
for (SchBaseVehiclematerialgroup schBaseVehiclematerialgroup : list) {
Gson gson = new Gson();
ConnectorDto connectorDto = gson.fromJson(schBaseVehiclematerialgroup.getExtend(), ConnectorDto.class);
connectorDto.setDueDate(StrUtil.isNotEmpty(connectorDto.getDueDate()) ? connectorDto.getDueDate() : DateUtil.now() );
connectorDto.setDueDate(StrUtil.isNotEmpty(connectorDto.getDueDate()) ? connectorDto.getDueDate() : DateUtil.now());
connectorDto.setNextOperation(StrUtil.isNotEmpty(connectorDto.getNextOperation()) ? connectorDto.getNextOperation() : RegionEnum.TRUBEND_SHELVES_3_1_1.getRegion_code());
connectors.add(connectorDto);
}

15
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/dao/mapper/SchBasePointMapper.xml

@ -28,7 +28,8 @@
sch_base_vehiclematerialgroup.region_code,
sch_base_vehiclematerialgroup.order_code,
sch_base_vehiclematerialgroup.due_date,
sch_base_vehiclematerialgroup.has_work
sch_base_vehiclematerialgroup.has_work,
sch_base_vehiclematerialgroup.create_time
FROM
sch_base_point
inner JOIN sch_base_vehiclematerialgroup ON sch_base_point.vehicle_code =
@ -44,8 +45,16 @@
<if test="due_date != null and due_date != ''">
and #{due_date} > sch_base_vehiclematerialgroup.due_date
</if>
AND sch_base_vehiclematerialgroup.region_code = #{region_code}
<if test="region_code != null and region_code != ''">
AND sch_base_vehiclematerialgroup.region_code = #{region_code}
</if>
<if test="due_date == null">
and sch_base_vehiclematerialgroup.due_date IS NULL
</if>
<if test="region_code == null">
AND sch_base_vehiclematerialgroup.region_code IS NULL
AND sch_base_vehiclematerialgroup.create_name = 'Sorting'
</if>
</select>
<select id="selectByRegionCode" resultType="java.lang.String">

43
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/point/service/impl/SchBasePointServiceImpl.java

@ -389,13 +389,13 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
}
@Override
public SchBasePoint selectByGroundPoint(String region_code, String pointStatus, String vehicle_type, int seq,int point_type) {
public SchBasePoint selectByGroundPoint(String region_code, String pointStatus, String vehicle_type, int seq, int point_type) {
List<SchBasePoint> schBasePoints = pointMapper.selectList(Wrappers.lambdaQuery(SchBasePoint.class)
.eq(SchBasePoint::getIs_lock, false)
.eq(SchBasePoint::getIs_used, true)
.eq(SchBasePoint::getPoint_status, pointStatus)
.eq(!vehicle_type.equals("G01"), SchBasePoint::getPoint_type, "1")
.eq(vehicle_type.equals("G01"), SchBasePoint::getPoint_type,point_type )
.eq(vehicle_type.equals("G01"), SchBasePoint::getPoint_type, point_type)
.eq(StrUtil.isNotBlank(vehicle_type), SchBasePoint::getCan_vehicle_type, vehicle_type)
.isNull(seq == 2, SchBasePoint::getVehicles)
.isNull(seq == 1, SchBasePoint::getVehicle_code)
@ -511,16 +511,37 @@ public class SchBasePointServiceImpl extends ServiceImpl<SchBasePointMapper, Sch
if (dueDate != null && StringUtils.isNotEmpty(dueDate.getValue())) {
s = DateUtil.offsetDay(new Date(), Integer.parseInt(dueDate.getValue())).toDateStr();
}
String last_regionCode = null;
if ("1".equals(regionCode)) {
last_regionCode = regionCode;
regionCode = null;
s = null;
}
List<OrderMater> collect = null;
List<OrderMater> structList = pointMapper.getStructList(regionCode, null, s);
List<OrderMater> collect = structList.stream().collect(Collectors.groupingBy(
OrderMater::getVehicle_code,
Collectors.collectingAndThen(
Collectors.maxBy(Comparator.comparing(OrderMater::getDue_date)),
Optional::get
)
)).values()
.stream()
.collect(Collectors.toList());
if ("1".equals(last_regionCode)) {
collect = structList.stream().collect(Collectors.groupingBy(
OrderMater::getVehicle_code,
Collectors.collectingAndThen(
Collectors.maxBy(Comparator.comparing(OrderMater::getCreate_time)),
Optional::get
)
)).values()
.stream()
.collect(Collectors.toList());
collect = collect.stream().sorted(Comparator.comparing(OrderMater::getVehicle_code)).collect(Collectors.toList());
} else {
collect = structList.stream().collect(Collectors.groupingBy(
OrderMater::getVehicle_code,
Collectors.collectingAndThen(
Collectors.maxBy(Comparator.comparing(OrderMater::getDue_date)),
Optional::get
)
)).values()
.stream()
.collect(Collectors.toList());
collect = collect.stream().sorted(Comparator.comparingLong(order -> getTime(order.getDue_date()))).collect(Collectors.toList());
}
return collect;
}

12
lms/nladmin-system/nlsso-server/src/main/java/org/nl/wms/sch/task_manage/task/ConnectorUtil.java

@ -66,10 +66,11 @@ public class ConnectorUtil {
/**
* 新的请求方式对象中包含数组
*
* @param api
* @param object
* @return
* @param <T>
* @return
*/
public static <T> AcsResponse notifyConnector2(String api, T object) {
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
@ -90,7 +91,7 @@ public class ConnectorUtil {
return AcsResponse.requestRefuse("未连接Connector!");
}
String url = connectorUrl + api;
log.info("反馈connector到达取货点的请求参数参数为:{},url:{}", JSON.toJSONString(object),url);
log.info("反馈connector到达取货点的请求参数参数为:{},url:{}", JSON.toJSONString(object), url);
AcsResponse resultForAcs;
try {
String resultMsg = HttpRequest.post(url)
@ -107,7 +108,8 @@ public class ConnectorUtil {
}
return resultForAcs;
}
public static <T> AcsResponse notifyEextSystem(String api, T object,String urlConfig) {
public static <T> AcsResponse notifyEextSystem(String api, T object, String urlConfig) {
SysParamServiceImpl sysParamService = SpringContextHolder.getBean(SysParamServiceImpl.class);
//判断是否连接ACS系统
Param isConnectConnector = sysParamService.findByCode(GeneralDefinition.IS_CONNECT_CONNECTOR);
@ -126,7 +128,7 @@ public class ConnectorUtil {
return AcsResponse.requestRefuse("未连接ACS!");
}
String url = connectorUrl + api;
log.info("反馈sortingAGV状态:{},url:{}", JSON.toJSONString(object),url);
log.info("反馈sortingAGV状态:{},url:{}", JSON.toJSONString(object), url);
AcsResponse resultForAcs;
try {
String resultMsg = HttpRequest.post(url)
@ -175,7 +177,7 @@ public class ConnectorUtil {
return new JSONObject(map);
}
String url = connectorUrl + api;
log.info("向connector申请物料下道工序和交期时间:{},接口路径:{}", JSON.toJSONString(object),url);
log.info("向connector申请物料下道工序和交期时间:{},接口路径:{}", JSON.toJSONString(object), url);
AcsResponse resultForAcs;
try {
String resultMsg = HttpRequest.post(url)

Loading…
Cancel
Save