add: 添加管芯抓取反馈
This commit is contained in:
@@ -27,7 +27,10 @@ public class ItemProtocol {
|
|||||||
public static String item_material = "material";
|
public static String item_material = "material";
|
||||||
//明细数量
|
//明细数量
|
||||||
public static String item_Itemized_qty = "Itemized_qty";
|
public static String item_Itemized_qty = "Itemized_qty";
|
||||||
|
//管芯编码
|
||||||
|
public static String item_paper_code = "paper_code";
|
||||||
|
//管芯取货位
|
||||||
|
public static String item_paper_location = "paper_location";
|
||||||
//下发命令
|
//下发命令
|
||||||
public static String item_to_command = "to_command";
|
public static String item_to_command = "to_command";
|
||||||
//下发物料类型
|
//下发物料类型
|
||||||
@@ -69,6 +72,13 @@ public class ItemProtocol {
|
|||||||
return this.getOpcStringValue(item_material);
|
return this.getOpcStringValue(item_material);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getPaperCode() {
|
||||||
|
return this.getOpcStringValue(item_paper_code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPaperLocation() {
|
||||||
|
return this.getOpcIntegerValue(item_paper_location);
|
||||||
|
}
|
||||||
|
|
||||||
public int getItemized_qty() {
|
public int getItemized_qty() {
|
||||||
return this.getOpcIntegerValue(item_Itemized_qty);
|
return this.getOpcIntegerValue(item_Itemized_qty);
|
||||||
@@ -118,6 +128,8 @@ public class ItemProtocol {
|
|||||||
list.add(new ItemDto(item_qty, "总数量", "DB1001.B5"));
|
list.add(new ItemDto(item_qty, "总数量", "DB1001.B5"));
|
||||||
list.add(new ItemDto(item_material, "物料类型", "DB1.B6"));
|
list.add(new ItemDto(item_material, "物料类型", "DB1.B6"));
|
||||||
list.add(new ItemDto(item_Itemized_qty, "物料明细数量", "DB1.B9"));
|
list.add(new ItemDto(item_Itemized_qty, "物料明细数量", "DB1.B9"));
|
||||||
|
list.add(new ItemDto(item_paper_code, "管芯编码", "DB1.B7"));
|
||||||
|
list.add(new ItemDto(item_paper_location, "管芯取货位", "DB1.B8"));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
package org.nl.acs.device_driver.paper_tube_pick_site;
|
package org.nl.acs.device_driver.paper_tube_pick_site;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ObjectUtil;
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import cn.hutool.http.HttpResponse;
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
@@ -11,6 +14,8 @@ import org.nl.acs.device_driver.DeviceDriver;
|
|||||||
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
import org.nl.acs.device_driver.RouteableDeviceDriver;
|
||||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||||
|
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||||
|
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||||
import org.nl.acs.history.ErrorUtil;
|
import org.nl.acs.history.ErrorUtil;
|
||||||
import org.nl.acs.history.service.DeviceErrorLogService;
|
import org.nl.acs.history.service.DeviceErrorLogService;
|
||||||
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
import org.nl.acs.history.service.impl.DeviceErrorLogServiceImpl;
|
||||||
@@ -25,12 +30,12 @@ import org.nl.acs.route.service.impl.RouteLineServiceImpl;
|
|||||||
import org.nl.acs.task.service.TaskService;
|
import org.nl.acs.task.service.TaskService;
|
||||||
import org.nl.config.SpringContextHolder;
|
import org.nl.config.SpringContextHolder;
|
||||||
import org.nl.config.language.LangProcess;
|
import org.nl.config.language.LangProcess;
|
||||||
|
import org.nl.config.lucene.service.LuceneExecuteLogService;
|
||||||
|
import org.nl.config.lucene.service.dto.LuceneLogDto;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.sql.Struct;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 纸管抓取位
|
* 纸管抓取位
|
||||||
@@ -54,6 +59,10 @@ public class PaperTubePickSiteDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
|
DeviceExtraService deviceExtraService = SpringContextHolder.getBean(DeviceExtraServiceImpl.class);
|
||||||
@Autowired
|
@Autowired
|
||||||
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
DeviceErrorLogService errorLogServer = SpringContextHolder.getBean(DeviceErrorLogServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
|
||||||
|
@Autowired
|
||||||
|
LuceneExecuteLogService luceneExecuteLogService = SpringContextHolder.getBean(LuceneExecuteLogService.class);
|
||||||
|
|
||||||
private Date instruction_require_time = new Date();
|
private Date instruction_require_time = new Date();
|
||||||
private Date instruction_finished_time = new Date();
|
private Date instruction_finished_time = new Date();
|
||||||
@@ -96,12 +105,17 @@ public class PaperTubePickSiteDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
//下发物料数量
|
//下发物料数量
|
||||||
int to_qty=0;
|
int to_qty=0;
|
||||||
int last_to_qty=0;
|
int last_to_qty=0;
|
||||||
|
//管芯编码
|
||||||
|
String paper_code = null;
|
||||||
|
int paper_location = 0 ;
|
||||||
|
|
||||||
|
|
||||||
Boolean isonline = true;
|
Boolean isonline = true;
|
||||||
|
|
||||||
Boolean iserror = false;
|
Boolean iserror = false;
|
||||||
|
|
||||||
|
String message = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 1-执行任务;2-取货完成;3-放货完成;
|
* 1-执行任务;2-取货完成;3-放货完成;
|
||||||
*/
|
*/
|
||||||
@@ -128,6 +142,9 @@ public class PaperTubePickSiteDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
error = this.itemProtocol.getError();
|
error = this.itemProtocol.getError();
|
||||||
move = this.itemProtocol.getMove();
|
move = this.itemProtocol.getMove();
|
||||||
action = this.itemProtocol.getAction();
|
action = this.itemProtocol.getAction();
|
||||||
|
paper_code = this.itemProtocol.getPaperCode();
|
||||||
|
paper_location = this.itemProtocol.getPaperLocation();
|
||||||
|
|
||||||
if (mode != last_mode) {
|
if (mode != last_mode) {
|
||||||
this.setRequireSucess(false);
|
this.setRequireSucess(false);
|
||||||
if (mode == 2) {
|
if (mode == 2) {
|
||||||
@@ -165,7 +182,13 @@ public class PaperTubePickSiteDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
return;
|
return;
|
||||||
case 2:
|
case 2:
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 6:
|
||||||
|
if(!this.getRequireSucess() && StrUtil.isNotEmpty(this.getPaper_code()) && this.getPaper_location() > 0 && this.getPaper_location() < 6){
|
||||||
|
boolean b = feedbackDie();
|
||||||
|
if(b){
|
||||||
|
requireSucess = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@@ -198,10 +221,78 @@ public class PaperTubePickSiteDeviceDriver extends AbstractOpcDeviceDriver imple
|
|||||||
last_to_qty = to_qty;
|
last_to_qty = to_qty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean feedbackDie() {
|
||||||
|
Date date = new Date();
|
||||||
|
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
|
||||||
|
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time);
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
JSONObject jo = new JSONObject();
|
||||||
|
jo.put("device_code",this.getDevice_code());
|
||||||
|
jo.put("row_num",this.getPaper_location());
|
||||||
|
jo.put("material_code",this.getPaper_code());
|
||||||
|
HttpResponse httpResponse = acsToWmsService.feedbackDies(jo);
|
||||||
|
JSONObject jsonObject = null;
|
||||||
|
if(ObjectUtil.isNotEmpty(httpResponse)){
|
||||||
|
String body = httpResponse.body();
|
||||||
|
jsonObject = JSONObject.parseObject(body);
|
||||||
|
}
|
||||||
|
if(ObjectUtil.isNotNull(jsonObject) && jsonObject.getInteger("status") == 200){
|
||||||
|
Map map = new HashMap();
|
||||||
|
map.put("to_command", 6);
|
||||||
|
try {
|
||||||
|
this.writing(map);
|
||||||
|
} catch (Exception e) {
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code(device_code)
|
||||||
|
.content("下发信号报错" + map)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(3);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code(device_code)
|
||||||
|
.content("反馈LMS管芯失败" + httpResponse.body())
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(3);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void thingToNothing() {
|
protected void thingToNothing() {
|
||||||
this.setRequireSucess(false);
|
this.setRequireSucess(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public String getToParam() {
|
||||||
|
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writing(Map<String, Object> map) throws Exception {
|
||||||
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||||
|
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||||
|
map.forEach((key, value) -> {
|
||||||
|
if (ObjectUtil.isNotEmpty(value)) {
|
||||||
|
itemMap.put(getToParam() + key, value);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||||
|
this.checkcontrol(itemMap);
|
||||||
|
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||||
|
LuceneLogDto logDto = LuceneLogDto.builder()
|
||||||
|
.device_code(device_code)
|
||||||
|
.content("下发多个电气信号" + itemMap)
|
||||||
|
.build();
|
||||||
|
logDto.setLog_level(3);
|
||||||
|
luceneExecuteLogService.deviceExecuteLog(logDto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void writing(int command) {
|
public void writing(int command) {
|
||||||
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
|
||||||
+ "." + org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor.ItemProtocol.item_to_command;
|
+ "." + org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor.ItemProtocol.item_to_command;
|
||||||
|
|||||||
@@ -192,4 +192,11 @@ public interface AcsToWmsService {
|
|||||||
GetWasteFoilWeightResponse feedbackWeight(GetWasteFoilWeightRequest param);
|
GetWasteFoilWeightResponse feedbackWeight(GetWasteFoilWeightRequest param);
|
||||||
|
|
||||||
String getBoxInfo(JSONObject param);
|
String getBoxInfo(JSONObject param);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 反馈管芯抓取位
|
||||||
|
* @param param
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
HttpResponse feedbackDies(JSONObject param);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -638,6 +638,39 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HttpResponse feedbackDies(JSONObject param) {
|
||||||
|
HttpResponse result2 = null;
|
||||||
|
try {
|
||||||
|
String wmsurl = paramService.findByCode(AcsConfig.WMSURL).getValue();
|
||||||
|
AddressDto addressDto = addressService.findByCode("feedbackDie");
|
||||||
|
String url = wmsurl + addressDto.getMethods_url();
|
||||||
|
log.info("feedbackDie - 反馈管芯请求路径{}", param);
|
||||||
|
try {
|
||||||
|
result2 = HttpRequest.post(url)
|
||||||
|
.header("Authorization", token)
|
||||||
|
.body(String.valueOf(param))
|
||||||
|
.execute();
|
||||||
|
} catch (Exception e) {
|
||||||
|
String msg = e.getMessage();
|
||||||
|
log.info("feedbackDie-----输出参数{}", msg);
|
||||||
|
//网络不通
|
||||||
|
}
|
||||||
|
log.info("feedbackDie - 反馈管芯{}", result2.body());
|
||||||
|
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"feedbackDie", String.valueOf(result2.getStatus()),
|
||||||
|
JSON.toJSONString(result2.body()),
|
||||||
|
String.valueOf(result2.body()), "反馈管芯抓取");
|
||||||
|
luceneLogService.interfaceExecuteLog(luceneLogDto);
|
||||||
|
return result2;
|
||||||
|
} catch (Exception e) {
|
||||||
|
LuceneLogDto luceneLogDto = new LuceneLogDto(4,"feedbackDie", String.valueOf(result2.getStatus()),
|
||||||
|
JSON.toJSONString(result2.body()),
|
||||||
|
String.valueOf(result2.body()), "反馈管芯抓取报错");
|
||||||
|
luceneLogService.interfaceExecuteLog(luceneLogDto);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JSONObject queryStationState(Instruction inst) {
|
public JSONObject queryStationState(Instruction inst) {
|
||||||
|
|||||||
Reference in New Issue
Block a user