add 进窑记录
This commit is contained in:
@@ -19,6 +19,9 @@ public class ItemProtocol {
|
||||
public static String item_standby_time = "standby_time";
|
||||
public static String item_production_time = "production_time";
|
||||
public static String item_error_time = "error_time";
|
||||
public static String item_kiln_number = "kiln_number";
|
||||
public static String item_barcode = "barcode";
|
||||
|
||||
public static String item_to_command = "to_command";
|
||||
public static String item_to_target = "to_target";
|
||||
public static String item_to_task = "to_task";
|
||||
@@ -42,6 +45,14 @@ public class ItemProtocol {
|
||||
return this.getOpcIntegerValue(item_status);
|
||||
}
|
||||
|
||||
public int getKiln_number() {
|
||||
return this.getOpcIntegerValue(item_kiln_number);
|
||||
}
|
||||
|
||||
public int getBarcode() {
|
||||
return this.getOpcIntegerValue(item_barcode);
|
||||
}
|
||||
|
||||
public String getOpen_time() {
|
||||
return this.getOpcStringValue(item_open_time);
|
||||
}
|
||||
@@ -99,22 +110,24 @@ public class ItemProtocol {
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB1.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB1.B1", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_status, "设备状态", "DB1.B2"));
|
||||
list.add(new ItemDto(item_open_time, "开机时间", "DB1.STRING4.50"));
|
||||
list.add(new ItemDto(item_standby_time, "待机时间", "DB1.D56"));
|
||||
list.add(new ItemDto(item_production_time, "生产时间", "DB1.D60"));
|
||||
list.add(new ItemDto(item_error_time, "故障时间", "DB1.D64"));
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_heartbeat, "心跳", "DB100.B0"));
|
||||
list.add(new ItemDto(item_mode, "工作模式", "DB100.B1", Boolean.TRUE));
|
||||
list.add(new ItemDto(item_status, "设备状态", "DB100.B2"));
|
||||
list.add(new ItemDto(item_kiln_number, "进窑窑号", "DB100.D4"));
|
||||
list.add(new ItemDto(item_barcode, "条码", "DB100.W8"));
|
||||
list.add(new ItemDto(item_open_time, "开机时间", "DB100.STRING10.50"));
|
||||
list.add(new ItemDto(item_standby_time, "待机时间", "DB100.D62"));
|
||||
list.add(new ItemDto(item_production_time, "生产时间", "DB100.D66"));
|
||||
list.add(new ItemDto(item_error_time, "故障时间", "DB100.D70"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_command, "下发指令", "DB2.W0", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(item_to_target, "下发目标站", "DB2.W2"));
|
||||
list.add(new ItemDto(item_to_task, "下发任务号", "DB2.D4"));
|
||||
ArrayList<ItemDto> list = new ArrayList<>();
|
||||
list.add(new ItemDto(item_to_command, "下发指令", "DB101.W0", Boolean.TRUE));
|
||||
list.add(new ItemDto(item_to_target, "下发目标站", "DB101.W2"));
|
||||
list.add(new ItemDto(item_to_task, "下发任务号", "DB101.D4"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@@ -54,15 +54,7 @@ public class LnshKilnTrussDefination implements OpcDeviceDriverDefination {
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos2() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(ItemProtocol.item_heartbeat, "心跳", "DB1.B0"));
|
||||
list.add(new ItemDto(ItemProtocol.item_mode, "工作模式", "DB1.B1", Boolean.valueOf(true)));
|
||||
list.add(new ItemDto(ItemProtocol.item_status, "设备状态", "DB1.B2"));
|
||||
list.add(new ItemDto(ItemProtocol.item_open_time, "开机时间", "DB1.STRING4.50"));
|
||||
list.add(new ItemDto(ItemProtocol.item_standby_time, "待机时间", "DB1.D56"));
|
||||
list.add(new ItemDto(ItemProtocol.item_production_time, "生产时间", "DB1.D60"));
|
||||
list.add(new ItemDto(ItemProtocol.item_error_time, "故障时间", "DB1.D64"));
|
||||
return list;
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,15 +1,19 @@
|
||||
package org.nl.acs.device_driver.lnsh.lnsh_kiln_truss;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.http.HttpResponse;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.instruction.service.InstructionService;
|
||||
import org.nl.acs.instruction.service.dto.Instruction;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
@@ -18,10 +22,14 @@ import org.nl.acs.opc.Device;
|
||||
import org.nl.acs.route.service.RouteLineService;
|
||||
import org.nl.acs.task.service.TaskService;
|
||||
import org.nl.modules.wql.util.SpringContextHolder;
|
||||
import org.openscada.opc.lib.da.Server;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.HttpStatus;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 晟华入出窑桁架
|
||||
@@ -43,6 +51,8 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
AcsToWmsService acsToWmsService = SpringContextHolder.getBean("acsToWmsServiceImpl");
|
||||
|
||||
String device_code;
|
||||
int mode = 0;
|
||||
int error = 0;
|
||||
@@ -54,6 +64,8 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
int hasGoods = 0;
|
||||
Boolean iserror = false;
|
||||
|
||||
private Date instruction_require_time = new Date();
|
||||
private int instruction_require_time_out = 3000;
|
||||
boolean requireSucess = false;
|
||||
|
||||
private Date checkHeartbeattime = new Date();
|
||||
@@ -68,6 +80,11 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
int status = 0;
|
||||
int last_status = 0;
|
||||
|
||||
int kiln_number = 0;
|
||||
int last_kiln_number = 0;
|
||||
int barcode = 0;
|
||||
int last_barcode = 0;
|
||||
|
||||
String open_time = "0";
|
||||
String last_open_time = "0";
|
||||
int standby_time = 0;
|
||||
@@ -85,11 +102,12 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
try {
|
||||
device_code = this.getDeviceCode();
|
||||
mode = this.itemProtocol.getMode();
|
||||
status = this.itemProtocol.getStatus();
|
||||
kiln_number = this.itemProtocol.getKiln_number();
|
||||
barcode = this.itemProtocol.getBarcode();
|
||||
open_time = this.itemProtocol.getOpen_time();
|
||||
standby_time = this.itemProtocol.getStandby_time();
|
||||
production_time = this.itemProtocol.getProduction_time();
|
||||
@@ -104,6 +122,14 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
logServer.deviceItemValue(this.device_code,"status" ,String.valueOf(status));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号status:" + last_status + " -> " + status);
|
||||
}
|
||||
if (kiln_number != last_kiln_number) {
|
||||
logServer.deviceItemValue(this.device_code,"kiln_number" ,String.valueOf(kiln_number));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号kiln_number:" + last_kiln_number + " -> " + kiln_number);
|
||||
}
|
||||
if (barcode != last_barcode) {
|
||||
logServer.deviceItemValue(this.device_code,"barcode" ,String.valueOf(barcode));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号barcode:" + last_barcode + " -> " + barcode);
|
||||
}
|
||||
if (!open_time.equals(last_open_time)) {
|
||||
logServer.deviceItemValue(this.device_code,"open_time" ,String.valueOf(open_time));
|
||||
logServer.deviceExecuteLog(this.device_code,"","","信号open_time:" + last_open_time + " -> " + open_time);
|
||||
@@ -148,25 +174,22 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
this.setIsonline(true);
|
||||
this.setIserror(false);
|
||||
message = "";
|
||||
Instruction instruction = null;
|
||||
List toInstructions;
|
||||
switch (mode) {
|
||||
case 1:
|
||||
log.debug("设备运转模式:等待工作");
|
||||
break;
|
||||
case 2:
|
||||
|
||||
break;
|
||||
case 3:
|
||||
|
||||
break;
|
||||
case 4:
|
||||
break;
|
||||
case 16:
|
||||
// 进窑确认
|
||||
if (!requireSucess && barcode != 0 && kiln_number != 0) {
|
||||
this.inKiln();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
last_mode = mode;
|
||||
last_status = status;
|
||||
last_kiln_number = kiln_number;
|
||||
last_barcode = barcode;
|
||||
last_open_time = open_time;
|
||||
last_standby_time = standby_time;
|
||||
last_production_time = production_time;
|
||||
@@ -182,6 +205,42 @@ public class LnshKilnTrussDeviceDriver extends AbstractOpcDeviceDriver implement
|
||||
}
|
||||
}
|
||||
|
||||
public void writing(int command) {
|
||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||
+ "." + org.nl.acs.device_driver.lnsh.lnsh_press.ItemProtocol.item_to_command;
|
||||
|
||||
String opcservcerid = this.getDevice().getOpc_server_id();
|
||||
Server server = ReadUtil.getServer(opcservcerid);
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_command, command);
|
||||
ReadUtil.write(itemMap, server);
|
||||
ReadUtil.write(itemMap, server);
|
||||
server.disconnect();
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "to_command 写入 " + command);
|
||||
}
|
||||
|
||||
public synchronized void inKiln() {
|
||||
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);
|
||||
} else {
|
||||
this.instruction_require_time = date;
|
||||
JSONObject param = new JSONObject();
|
||||
param.put("kiln_number", kiln_number);
|
||||
param.put("vehicle_code", barcode);
|
||||
HttpResponse response = acsToWmsService.inKiln(param);
|
||||
if (ObjectUtil.isNotEmpty(response)) {
|
||||
if (response.getStatus() == HttpStatus.OK.value()) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(response.body());
|
||||
if (ObjectUtil.isNotEmpty(jsonObject) && "200".equals(jsonObject.getString("status"))) {
|
||||
this.writing(this.mode);
|
||||
this.requireSucess = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() throws Exception {
|
||||
String mode;
|
||||
|
||||
@@ -76,7 +76,7 @@ public class LnshPressDeviceDriver extends AbstractOpcDeviceDriver implements De
|
||||
private Date instruction_require_time = new Date();
|
||||
private Date instruction_finished_time = new Date();
|
||||
|
||||
private int instruction_require_time_out;
|
||||
private int instruction_require_time_out = 3000;
|
||||
boolean requireSucess = false;
|
||||
|
||||
private int instruction_finished_time_out;
|
||||
|
||||
@@ -368,32 +368,30 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResponse inKiln(JSONObject json) {
|
||||
public HttpResponse inKiln(JSONObject param) {
|
||||
try {
|
||||
MDC.put(log_file_type, log_type);
|
||||
String wmsurl = acsConfigService.findByCode(AcsConfig.WMSURL).getValue();
|
||||
|
||||
HttpResponse result = null;
|
||||
log.info("inKiln - 请求参数 {}", param);
|
||||
AddressDto addressDto = addressService.findByCode("inKiln");
|
||||
String methods_url = addressDto.getMethods_url();
|
||||
String url = wmsurl + methods_url;
|
||||
|
||||
log.info("inKiln - 请求参数 {}", json.toString());
|
||||
HttpResponse result = null;
|
||||
try {
|
||||
result = HttpRequest.post(url)
|
||||
.header("Authorization", token)
|
||||
.body(String.valueOf(json))
|
||||
result = HttpRequest
|
||||
.post(wmsurl + methods_url)
|
||||
.body(param.toJSONString())
|
||||
.execute();
|
||||
System.out.println(result);
|
||||
log.info("inKiln - 返回参数 {}", result.body());
|
||||
} catch (Exception e) {
|
||||
System.out.println(e.getMessage());
|
||||
String msg = e.getMessage();
|
||||
//网络不通
|
||||
System.out.println(msg);
|
||||
}
|
||||
return result;
|
||||
|
||||
} finally {
|
||||
MDC.remove(log_file_type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -205,4 +205,12 @@ public class AcsToWmsController {
|
||||
public ResponseEntity<Object> mark(@RequestBody JSONObject whereJson) {
|
||||
return new ResponseEntity<>(acsToWmsService.mark(whereJson), HttpStatus.OK);
|
||||
}
|
||||
|
||||
@PostMapping("/inKiln")
|
||||
@Log("反馈进窑分配")
|
||||
@ApiOperation("反馈进窑分配")
|
||||
@SaIgnore
|
||||
public ResponseEntity<Object> inKiln(@RequestBody JSONObject param) {
|
||||
return ResponseEntity.ok(acsToWmsService.inKiln(param));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -118,4 +118,6 @@ public interface AcsToWmsService {
|
||||
|
||||
|
||||
JSONObject mark(JSONObject whereJson);
|
||||
|
||||
JSONObject inKiln(JSONObject param);
|
||||
}
|
||||
|
||||
@@ -749,4 +749,23 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
||||
throw new BadRequestException("[" + VehicleType.get(String.valueOf(vehicle_type)).label() + "] [" + vehicle_code + "] 无信息!");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject inKiln(JSONObject param) {
|
||||
String vehicle_code = TaskUtils.formatVehicleCode(param.getString("vehicle_code"));
|
||||
if (StrUtil.isNotBlank(vehicle_code)) {
|
||||
String kiln_number = param.getString("kiln_number");
|
||||
if (StrUtil.isNotBlank(kiln_number)) {
|
||||
JSONObject vd_update = new JSONObject();
|
||||
vd_update.put("kiln_number", "Y0" + kiln_number);
|
||||
vd_update.put("in_kiln_time", DateUtil.now());
|
||||
WQLObject.getWQLObject("st_ivt_vehicle_detail").update(vd_update, "is_delete = '0' AND vehicle_code = '" + vehicle_code + "'");
|
||||
}
|
||||
}
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("status", HttpStatus.OK.value());
|
||||
result.put("message", "反馈成功!");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user