This commit is contained in:
USER-20220102CG\noblelift
2022-08-16 19:48:08 +08:00
parent b7c0d7e387
commit ebb5bfe01a
5 changed files with 116 additions and 25 deletions

View File

@@ -1,6 +1,8 @@
package org.nl.acs.device_driver.lnsh.lnsh_Laminating_machine;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpResponse;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
@@ -176,8 +178,15 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i
case 2:
break;
case 4:
if (!requireSucess) {
getVehicle_code();
//申请入窑
if(move ==1 && !requireSucess && StrUtil.isNotEmpty(this.barcode)){
applyIn();
}
break;
case 5:
//申请出窑
if (!requireSucess && this.move != 0 && StrUtil.isNotEmpty(this.barcode)) {
outKiln();
}
break;
}
@@ -212,6 +221,64 @@ public class LnshLaminatingMachineDeviceDriver extends AbstractOpcDeviceDriver i
}
}
/**
* 申请入窑
*
* @param
*/
public synchronized boolean applyIn() {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_require_time = date;
JSONObject json = new JSONObject();
json.put("device_code",this.device_code);
json.put("type","5");
json.put("vehicle_code",barcode);
HttpResponse result = acsToWmsService.inKiln(json);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.get("status").toString(),"200")) {
this.writing(1);
this.setRequireSucess(true);
}
}
return true;
}
}
/**
* 申请出窑
*
* @param
*/
public synchronized boolean outKiln() {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
this.instruction_require_time = date;
JSONObject json = new JSONObject();
json.put("device_code",this.device_code);
json.put("vehicle_code",barcode);
HttpResponse result = acsToWmsService.outKiln(json);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.get("status").toString(),"200")) {
String code = jsonObject.getString("code");
this.writing(1);
this.writing(2,Integer.parseInt(code));
this.setRequireSucess(true);
}
}
return true;
}
}
public boolean exe_business() {
return true;
}

View File

@@ -1067,8 +1067,8 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
this.writing(this.mode);
}
this.setRequireSucess(true);
}
this.setRequireSucess(true);
return true;
}
}
@@ -1086,8 +1086,12 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
} else {
this.instruction_require_time = date;
JSONObject json = new JSONObject();
json.put("device_code",this.device_code);
json.put("qty",qty);
this.instruction_require_time = date;
String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code");
String demosub = linkobj.substring(1,linkobj.length()-1);
String demoArray[] = demosub.split(",");
List<String> demoList = Arrays.asList(demoArray);
json.put("device_code",demoList.get(put_station-1).replace("\"","")); json.put("qty",qty);
json.put("vehicle_code",barcode);
json.put("is_full","0");
json.put("product_code",product_code);
@@ -1155,8 +1159,8 @@ public class LnshPackagePalletManipulatorDeviceDriver extends AbstractOpcDeviceD
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
this.writing(this.mode);
}
this.setRequireSucess(true);
}
this.setRequireSucess(true);
return true;
}
}

View File

@@ -27,10 +27,7 @@ import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
import java.lang.reflect.Field;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
/**
* 荣力嘉耐-包装码拆垛机械手
@@ -706,6 +703,7 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
if (!requireSucess) {
applyEmpty();
}
break;
case 9:
//工单完成
if (!requireSucess && !order_No.equals("0")) {
@@ -837,18 +835,18 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
this.writing(this.mode);
ProduceshiftorderDto dto = produceshiftorderService.findByCode(order_No);
if (this.mode == 4) {
dto.setOrder_status("0");
dto.setOrder_status("1");
} else if (this.mode == 9){
dto.setOrder_status("2");
}
produceshiftorderService.update(dto);
this.writing(this.mode);
this.setRequireSucess(true);
}
}
this.setRequireSucess(true);
return true;
}
}
@@ -1015,8 +1013,12 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
} else {
this.instruction_require_time = date;
JSONObject json = new JSONObject();
json.put("device_code",this.device_code);
json.put("qty",qty);
this.instruction_require_time = date;
String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code");
String demosub = linkobj.substring(1,linkobj.length()-1);
String demoArray[] = demosub.split(",");
List<String> demoList = Arrays.asList(demoArray);
json.put("device_code",demoList.get(put_station-1).replace("\"","")); json.put("qty",qty);
json.put("vehicle_code",barcode);
json.put("is_full","1");
json.put("product_code",product_code);
@@ -1103,8 +1105,11 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
} else {
this.instruction_require_time = date;
JSONObject json = new JSONObject();
json.put("device_code",this.device_code);
json.put("qty",qty);
String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code");
String demosub = linkobj.substring(1,linkobj.length()-1);
String demoArray[] = demosub.split(",");
List<String> demoList = Arrays.asList(demoArray);
json.put("device_code",demoList.get(put_station-1).replace("\"","")); json.put("qty",qty);
json.put("vehicle_code",barcode);
json.put("is_full","0");
json.put("product_code",product_code);
@@ -1172,8 +1177,8 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
this.writing(this.mode);
}
this.setRequireSucess(true);
}
this.setRequireSucess(true);
return true;
}
}
@@ -1191,18 +1196,20 @@ public class RljnPackagePalletSplitManipulatorDeviceDriver extends AbstractOpcDe
} else {
this.instruction_require_time = date;
JSONObject json = new JSONObject();
json.put("device_code",this.device_code);
String linkobj = (String)this.getDevice().getExtraValue().get("link_device_code");
String demosub = linkobj.substring(1,linkobj.length()-1);
String demoArray[] = demosub.split(",");
List<String> demoList = Arrays.asList(demoArray);
json.put("device_code",demoList.get(put_station-1).replace("\"",""));
json.put("type","4");
json.put("qty",qty);
json.put("vehicle_code",barcode);
HttpResponse result = acsToWmsService.lnshApplyTaskToWms(json);
if (ObjectUtil.isNotEmpty(result)) {
JSONObject jsonObject = JSONObject.parseObject(result.body());
if (result.getStatus() == 200 && StrUtil.equals(jsonObject.getString("status"),"200")) {
this.writing(this.mode);
this.setRequireSucess(true);
}
}
this.setRequireSucess(true);
return true;
}
}

View File

@@ -286,6 +286,7 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
LnshPackagePalletManipulatorDeviceDriver lnshPackagePalletManipulatorDeviceDriver;
LnshPalletizingManipulatorDeviceDriver lnshPalletizingManipulatorDeviceDriver;
RljnPackagePalletSplitManipulatorDeviceDriver rljnPackagePalletSplitManipulatorDeviceDriver;
if (device.getDeviceDriver() instanceof LnshPalletizingManipulatorDeviceDriver) {
lnshPalletizingManipulatorDeviceDriver = (LnshPalletizingManipulatorDeviceDriver) device.getDeviceDriver();
if (StrUtil.isEmpty(qty)) {
@@ -312,8 +313,21 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
lnshPackagePalletManipulatorDeviceDriver.writing("to_material_code", material_code);
is_flag = true;
}
//下发成功后,写入工单信息表记录
if (is_flag) {
if (device.getDeviceDriver() instanceof RljnPackagePalletSplitManipulatorDeviceDriver) {
rljnPackagePalletSplitManipulatorDeviceDriver = (RljnPackagePalletSplitManipulatorDeviceDriver) device.getDeviceDriver();
if (StrUtil.isEmpty(qty)) {
throw new WDKException("数量不能为空");
}
if (StrUtil.isEmpty(material_code)) {
throw new WDKException("物料编号不能为空!");
}
rljnPackagePalletSplitManipulatorDeviceDriver.writing("to_order_No", producetask_code);
rljnPackagePalletSplitManipulatorDeviceDriver.writing("to_material_qty", qty);
rljnPackagePalletSplitManipulatorDeviceDriver.writing("to_material_code", material_code);
is_flag = true;
}
//下发成功后,写入工单信息表记录
ProduceshiftorderDto dto = new ProduceshiftorderDto();
dto.setOrder_code(producetask_code);
dto.setProduct_code(product_code);
@@ -328,7 +342,6 @@ public class WmsToAcsServiceImpl implements WmsToAcsService {
dto.setWeight(weight);
dto.setQty(qty);
produceshiftorderService.create(dto);
}
}
JSONObject resultJson = new JSONObject();