更新
This commit is contained in:
@@ -100,6 +100,7 @@ public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDrive
|
||||
int device_running_time = 0; //设备运转时间(S)
|
||||
int await_time = 0; //待机时间(S)
|
||||
int order = 0; //工单号
|
||||
int heartbeat = 0;
|
||||
|
||||
//出入库模式
|
||||
int operation_type = 0;
|
||||
@@ -125,6 +126,12 @@ public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDrive
|
||||
int last_device_running_time = 0; //设备运转时间(S)
|
||||
int last_await_time = 0; //待机时间(S)
|
||||
int last_order = 0; //工单号
|
||||
int last_heartbeat = 0;
|
||||
|
||||
private long last_feedDeviceStatusTime = 0;
|
||||
|
||||
int status_type = 0;
|
||||
int last_status_type = 0;
|
||||
|
||||
|
||||
Boolean isonline = true;
|
||||
@@ -277,6 +284,10 @@ public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDrive
|
||||
if (one_now != last_one_now) {
|
||||
logServer.deviceLog(this.device_code,"one_now" ,String.valueOf(one_now));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号one_now:" + last_one_now + "->" + one_now);
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("order",order);
|
||||
map.put("real_qty",order_now);
|
||||
acsToWmsService.feedOrderRealQty(map);
|
||||
}
|
||||
if (task != last_task) {
|
||||
logServer.deviceLog(this.device_code,"task" ,String.valueOf(task));
|
||||
@@ -304,9 +315,36 @@ public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDrive
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号order:" + last_order + "->" + order);
|
||||
}
|
||||
|
||||
/* if (mode == 2 && move != 0 && task > 0) {
|
||||
synchronized (this){
|
||||
long now_feedTime = System.currentTimeMillis();
|
||||
if (now_feedTime - last_feedDeviceStatusTime >= 10000){
|
||||
heartbeat = this.itemProtocol.getItem_heartbeat();
|
||||
if (heartbeat == last_heartbeat){
|
||||
status_type = 01;
|
||||
} else {
|
||||
status_type = 02;
|
||||
if (error > 0) {
|
||||
status_type = 05;
|
||||
}else if (mode == 1 && order > 0) {
|
||||
status_type = 03;
|
||||
} else if (mode == 0 && order > 0) {
|
||||
status_type = 04;
|
||||
}
|
||||
}
|
||||
if (status_type != last_status_type) {
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("device_code", device_code);
|
||||
map.put("status_type", "0" + status_type);
|
||||
map.put("start_time", DateUtil.now());
|
||||
map.put("error_code",error);
|
||||
acsToWmsService.feedDeviceStatusType(map);
|
||||
last_status_type = status_type;
|
||||
}
|
||||
last_heartbeat = heartbeat;
|
||||
last_feedDeviceStatusTime = now_feedTime;
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
@@ -475,6 +513,7 @@ public class HailiangEngravingMachineDeviceDriver extends AbstractOpcDeviceDrive
|
||||
last_device_running_time = device_running_time; //设备运转时间(S)
|
||||
last_await_time = await_time; //待机时间(S)
|
||||
last_order = order; //工单号
|
||||
last_heartbeat = heartbeat;
|
||||
}
|
||||
|
||||
public boolean exe_error() {
|
||||
|
||||
@@ -77,6 +77,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
String container;
|
||||
|
||||
int heartbeat = 0;
|
||||
int packer_ready = 0;//包装机就绪
|
||||
int mode = 0;//模式 所有设备就绪
|
||||
int move = 0;//有货
|
||||
@@ -92,6 +93,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
int await_time = 0; //待机时间(S)
|
||||
int order = 0; //工单号
|
||||
//出入库模式
|
||||
int last_heartbeat = 0;
|
||||
int operation_type = 0;
|
||||
int last_packer_ready = 0;//包装机就绪
|
||||
int last_mode = 0;//模式 所有设备就绪
|
||||
@@ -117,6 +119,11 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
private Date instruction_finished_time = new Date();
|
||||
private Date instruction_apply_time = new Date();
|
||||
private int instruction_require_time_out = 3000;
|
||||
|
||||
|
||||
private long last_feedDeviceStatusTime = 0;
|
||||
private long feedDeviceStatusTime = System.currentTimeMillis();
|
||||
|
||||
//请求成功标记
|
||||
Boolean requireSucess = false;
|
||||
Boolean fullrequireSucess = false;
|
||||
@@ -126,6 +133,9 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
int status_type = 0;
|
||||
int last_status_type = 0;
|
||||
|
||||
int branchProtocol = 0;
|
||||
//备注
|
||||
String remark;
|
||||
@@ -191,7 +201,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
logServer.deviceLog(this.device_code, "packer_ready", String.valueOf(packer_ready));
|
||||
logServer.deviceLogToacs(this.device_code, "", "", "信号packer_ready:" + last_packer_ready + "->" + packer_ready);
|
||||
}
|
||||
if (lack_req != last_lack_req) {
|
||||
if (lack_req != last_lack_req) {
|
||||
if (lack_req == 0) {
|
||||
this.setRequireSucess(false);
|
||||
}
|
||||
@@ -226,6 +236,11 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
if (order_now != last_order_now) {
|
||||
logServer.deviceLog(this.device_code, "order_now", String.valueOf(order_now));
|
||||
logServer.deviceLogToacs(this.device_code, "", "", "信号order_now:" + last_order_now + "->" + order_now);
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("order",order);
|
||||
map.put("real_qty",order_now);
|
||||
acsToWmsService.feedOrderRealQty(map);
|
||||
System.out.println(device_code + "当前数量:" + order_now);
|
||||
}
|
||||
|
||||
/* if (open_ready_time != last_open_ready_time) {
|
||||
@@ -245,9 +260,36 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
logServer.deviceLogToacs(this.device_code, "", "", "信号order:" + last_order + "->" + order);
|
||||
}
|
||||
|
||||
/* if (mode == 2 && move != 0 && task > 0) {
|
||||
synchronized (this){
|
||||
long now_feedTime = System.currentTimeMillis();
|
||||
if (now_feedTime - last_feedDeviceStatusTime >= 10000){
|
||||
heartbeat = this.itemProtocol.getItem_heartbeat();
|
||||
if (heartbeat == last_heartbeat){
|
||||
status_type = 01;
|
||||
} else {
|
||||
status_type = 02;
|
||||
if (error > 0) {
|
||||
status_type = 05;
|
||||
}else if (mode == 1 && order > 0) {
|
||||
status_type = 03;
|
||||
} else if (mode == 0 && order > 0) {
|
||||
status_type = 04;
|
||||
}
|
||||
}
|
||||
if (status_type != last_status_type) {
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("device_code", device_code);
|
||||
map.put("status_type", "0" + status_type);
|
||||
map.put("error_code",error);
|
||||
map.put("start_time", DateUtil.now());
|
||||
acsToWmsService.feedDeviceStatusType(map);
|
||||
last_status_type = status_type;
|
||||
}
|
||||
last_heartbeat = heartbeat;
|
||||
last_feedDeviceStatusTime = now_feedTime;
|
||||
}
|
||||
}
|
||||
|
||||
}*/
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
@@ -306,7 +348,7 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
apply_task();
|
||||
}
|
||||
}
|
||||
if (!fullrequireSucess){
|
||||
if (!fullrequireSucess) {
|
||||
if (mode == 1 && req_task_empty == 1 && move == 1) {
|
||||
logServer.deviceLogToacs(this.device_code, "", "", device_code + ":,move:" + move + ",mode:" + mode + ",fullrequireSucess:" + fullrequireSucess + "开始申请请求取走空料斗任务");
|
||||
apply_take_empty_task();
|
||||
@@ -712,4 +754,9 @@ public class HailiangPackerStationDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
public synchronized boolean apply_InEmpty() throws Exception {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -167,5 +167,9 @@ public class ItemProtocol {
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ItemProtocol{}";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +136,12 @@ public class HailiangSpecialDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
int last_line_ready = 0; //线体就绪
|
||||
int last_device_online = 0; //专机联机
|
||||
|
||||
int heartbeat = 0;
|
||||
int last_heartbeat = 0;
|
||||
private long last_feedDeviceStatusTime = 0;
|
||||
int status_type = 0;
|
||||
int last_status_type = 0;
|
||||
|
||||
Boolean isonline = true;
|
||||
int hasGoods = 0;
|
||||
String message = null;
|
||||
@@ -227,6 +233,7 @@ public class HailiangSpecialDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
device_ready = this.itemProtocol.getItem_device_ready();
|
||||
line_ready = this.itemProtocol.getItem_line_ready();
|
||||
|
||||
|
||||
if (mode != last_mode) {
|
||||
this.setRequireSucess(false);
|
||||
logServer.deviceLogToacs(this.device_code,"","","工作模式切换,刷新请求标记:"+this.requireSucess);
|
||||
@@ -305,6 +312,11 @@ public class HailiangSpecialDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
if (now_order_prod_num != last_now_order_prod_num) {
|
||||
logServer.deviceLog(this.device_code,"now_order_prod_num" ,String.valueOf(now_order_prod_num));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号now_order_prod_num:" + last_now_order_prod_num + "->" + now_order_prod_num);
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("order",order);
|
||||
map.put("real_qty",now_order_prod_num);
|
||||
acsToWmsService.feedOrderRealQty(map);
|
||||
System.out.println(device_code + "当前数量:" + now_order_prod_num);
|
||||
}
|
||||
if (full_number != last_full_number) {
|
||||
logServer.deviceLog(this.device_code,"full_number" ,String.valueOf(full_number));
|
||||
@@ -338,10 +350,36 @@ public class HailiangSpecialDeviceDriver extends AbstractOpcDeviceDriver impleme
|
||||
logServer.deviceLog(this.device_code,"order_prod_allnum" ,String.valueOf(order_prod_allnum));
|
||||
logServer.deviceLogToacs(this.device_code,"","","信号order_prod_allnum:" + last_order_prod_allnum + "->" + order_prod_allnum);
|
||||
}
|
||||
synchronized (this){
|
||||
long now_feedTime = System.currentTimeMillis();
|
||||
if (now_feedTime - last_feedDeviceStatusTime >= 10000){
|
||||
heartbeat = this.itemProtocol.getHeartbeat();
|
||||
if (heartbeat == last_heartbeat){
|
||||
status_type = 01;
|
||||
} else {
|
||||
status_type = 02;
|
||||
if (error > 0) {
|
||||
status_type = 05;
|
||||
}else if (mode == 1 && order > 0) {
|
||||
status_type = 03;
|
||||
} else if (mode == 0 && order > 0) {
|
||||
status_type = 04;
|
||||
}
|
||||
}
|
||||
if (status_type != last_status_type) {
|
||||
JSONObject map = new JSONObject();
|
||||
map.put("device_code", device_code);
|
||||
map.put("status_type", "0" + status_type);
|
||||
map.put("start_time", DateUtil.now());
|
||||
map.put("error_code",error);
|
||||
acsToWmsService.feedDeviceStatusType(map);
|
||||
last_status_type = status_type;
|
||||
}
|
||||
last_feedDeviceStatusTime = now_feedTime;
|
||||
last_heartbeat = heartbeat;
|
||||
}
|
||||
}
|
||||
|
||||
/* if (mode == 2 && move != 0 && task > 0) {
|
||||
|
||||
}*/
|
||||
} catch (Exception var17) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -95,4 +95,18 @@ public class AcsToWmsController {
|
||||
public ResponseEntity<Object> applyOutCacheLineTask(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(acstowmsService.applyOutCacheLineTask(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/feedDeviceStatusType")
|
||||
@Log("向wms反馈设备状态")
|
||||
@ApiOperation("向wms反馈设备状态")
|
||||
public ResponseEntity<Object> feedDeviceStatusType(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(acstowmsService.feedDeviceStatusType(param), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/feedOrderRealQty")
|
||||
@Log("向wms订单实时数量")
|
||||
@ApiOperation("向wms订单实时数量")
|
||||
public ResponseEntity<Object> feedOrderRealQty(@RequestBody JSONObject param) {
|
||||
return new ResponseEntity<>(acstowmsService.feedOrderRealQty(param), HttpStatus.OK);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -116,4 +116,20 @@ public interface AcsToWmsService {
|
||||
* @return
|
||||
*/
|
||||
HttpResponse applyOutCacheLineTask(JSONObject param);
|
||||
|
||||
/**
|
||||
* 向wms反馈设备状态
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
HttpResponse feedDeviceStatusType(JSONObject param);
|
||||
|
||||
/**
|
||||
* 向wms订单实时数量
|
||||
*
|
||||
* @param param
|
||||
* @return
|
||||
*/
|
||||
HttpResponse feedOrderRealQty(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -544,4 +544,68 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse feedDeviceStatusType(JSONObject param) {
|
||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS).toString(), "1")) {
|
||||
String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
|
||||
// TODO 还没向地址表中添加 feedDeviceStatusType
|
||||
AddressDto addressDto = addressService.findByCode("feedDeviceStatusType");
|
||||
String methods_url = addressDto.getMethods_url();
|
||||
String url = wmsUrl + methods_url;
|
||||
HttpResponse result = null;
|
||||
log.info("feedbackOrderStatus----请求参数{}", param);
|
||||
try {
|
||||
result = HttpRequest.post(url)
|
||||
.body(String.valueOf(param))
|
||||
.execute();
|
||||
String type = "";
|
||||
if (result.getStatus() == 200) {
|
||||
type = "info";
|
||||
} else {
|
||||
type = "error";
|
||||
}
|
||||
logServer.log("", "feedDeviceStatusType", type, param.toString(), result.body(), String.valueOf(result.getStatus()), url, "");
|
||||
log.info("feedDeviceStatusType----返回参数{}", result);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
//网络不通
|
||||
System.out.println(msg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse feedOrderRealQty(JSONObject param) {
|
||||
if (StrUtil.equals(acsConfigService.findConfigFromCache().get(AcsConfig.HASWMS).toString(), "1")) {
|
||||
String wmsUrl = acsConfigService.findConfigFromCache().get(AcsConfig.WMSURL);
|
||||
// TODO 还没向地址表中添加 feedDeviceStatusType
|
||||
AddressDto addressDto = addressService.findByCode("feedOrderRealQty");
|
||||
String methods_url = addressDto.getMethods_url();
|
||||
String url = wmsUrl + methods_url;
|
||||
HttpResponse result = null;
|
||||
log.info("feedOrderRealQty----请求参数{}", param);
|
||||
try {
|
||||
result = HttpRequest.post(url)
|
||||
.body(String.valueOf(param))
|
||||
.execute();
|
||||
String type = "";
|
||||
if (result.getStatus() == 200) {
|
||||
type = "info";
|
||||
} else {
|
||||
type = "error";
|
||||
}
|
||||
logServer.log("", "feedOrderRealQty", type, param.toString(), result.body(), String.valueOf(result.getStatus()), url, "");
|
||||
log.info("feedOrderRealQty----返回参数{}", result);
|
||||
} catch (Exception e) {
|
||||
String msg = e.getMessage();
|
||||
//网络不通
|
||||
System.out.println(msg);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,16 +5,13 @@ package org.nl.acs.order.service.impl;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.nl.acs.config.AcsConfig;
|
||||
import org.nl.acs.device.service.DeviceExtraService;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_engraving_machine.HailiangEngravingMachineDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_packer_station.HailiangPackerStationDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_smart_plc_test.HailiangSmartplcTestDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.hailiang_one.hailiang_special_device.HailiangSpecialDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.opc.DeviceAppService;
|
||||
import org.nl.acs.order.service.ProduceshiftorderService;
|
||||
import org.nl.acs.order.service.dto.ProduceshiftorderDto;
|
||||
import org.nl.exception.BadRequestException;
|
||||
@@ -33,7 +30,6 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.nl.utils.SecurityUtils;
|
||||
|
||||
Reference in New Issue
Block a user