|
@@ -1,33 +1,35 @@
|
|
|
package com.uas.pda.dao.impl;
|
|
|
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.StringWriter;
|
|
|
-import java.util.*;
|
|
|
-
|
|
|
import com.uas.erp.core.BaseUtil;
|
|
|
import com.uas.erp.core.HttpUtil;
|
|
|
-import com.uas.erp.core.TCPUtil;
|
|
|
-import jsx3.app.DOM;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.http.HttpStatus;
|
|
|
-import org.springframework.stereotype.Repository;
|
|
|
-
|
|
|
import com.uas.erp.core.StringUtil;
|
|
|
+import com.uas.erp.core.TCPUtil;
|
|
|
import com.uas.erp.core.exception.APIErrorException;
|
|
|
import com.uas.erp.core.exception.APIErrorException.APIErrorCode;
|
|
|
import com.uas.erp.dao.BaseDao;
|
|
|
import com.uas.erp.dao.SqlRowList;
|
|
|
import com.uas.erp.model.Page;
|
|
|
import com.uas.pda.dao.PdaCommonDao;
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONObject;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.stereotype.Repository;
|
|
|
import org.w3c.dom.Document;
|
|
|
import org.w3c.dom.Element;
|
|
|
|
|
|
import javax.xml.parsers.DocumentBuilder;
|
|
|
import javax.xml.parsers.DocumentBuilderFactory;
|
|
|
import javax.xml.parsers.ParserConfigurationException;
|
|
|
-import javax.xml.transform.*;
|
|
|
+import javax.xml.transform.OutputKeys;
|
|
|
+import javax.xml.transform.Transformer;
|
|
|
+import javax.xml.transform.TransformerException;
|
|
|
+import javax.xml.transform.TransformerFactory;
|
|
|
import javax.xml.transform.dom.DOMSource;
|
|
|
import javax.xml.transform.stream.StreamResult;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.StringWriter;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Repository("pdaCommonDaoImpl")
|
|
|
public class PdaCommonDaoImpl implements PdaCommonDao {
|
|
@@ -362,7 +364,7 @@ public class PdaCommonDaoImpl implements PdaCommonDao {
|
|
|
/**
|
|
|
* 扫码式出库条码采集灭灯
|
|
|
* @param id
|
|
|
- * @param detno
|
|
|
+ * @param
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
@@ -470,41 +472,56 @@ public class PdaCommonDaoImpl implements PdaCommonDao {
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 扫码式上架亮灯,建议仓位
|
|
|
+ * AGV入库生成任务
|
|
|
* @param code 条码号
|
|
|
- * @param emCode 操作人
|
|
|
+ * @param location 起始位
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public String turnScanLocationON(String code, String emCode) {
|
|
|
+ public String turnScanLocationON(String code, String location) {
|
|
|
SqlRowList rs = baseDao.queryForRowSet("select * from prodoutprebar left join shelf on sh_code=pb_shelfcode" +
|
|
|
- " where pb_barcode=? and pb_inmancode=? and pb_inoutno='扫码式上架' and pb_type='扫码式'", code, emCode);
|
|
|
- String type = null, shcode = null, ip = null, shnoaddress = null,color = null;
|
|
|
- int level = 0, port = 0;
|
|
|
- String da = createStringOfZeros(100);
|
|
|
+ " where pb_barcode =? and nvl(pb_ifget,0)=0 and pb_type='AGV入库' order by pb_detno ", code);
|
|
|
+ String type = null, shcode = null, ip = null, color = null;
|
|
|
+ int number = 0;
|
|
|
if (rs.hasNext()) {
|
|
|
while (rs.next()) {
|
|
|
- if (rs.getCurrentIndex() == 0) {
|
|
|
- shcode = rs.getString("pb_shelfcode");
|
|
|
- shnoaddress = rs.getString("sh_noaddress");
|
|
|
- level = rs.getInt("pb_level");
|
|
|
- port = rs.getInt("sh_port");
|
|
|
- ip = rs.getString("sh_ip");
|
|
|
- color = colorcode(rs.getInt("pb_color"));
|
|
|
- }
|
|
|
- //拼接位置100个字符,将第几个位置的0替换掉,pb_levelnumber;
|
|
|
- da = replaceCharacter(da, rs.getGeneralInt("pb_levelnumber"), '1');
|
|
|
- }
|
|
|
- //String reste = DengCommand(shnoaddress,ip,port,da);
|
|
|
- String reste = "";
|
|
|
- try {
|
|
|
- reste = sendCodingCommand(shnoaddress, level, ip, port, da,color);
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+
|
|
|
+ // 添加基本字段
|
|
|
+ jsonObject.put("reqCode", baseDao.getSeqId("agv_seq"));
|
|
|
+ jsonObject.put("taskCode", rs.getString("pb_id"));
|
|
|
+ jsonObject.put("taskTyp", "RK");
|
|
|
+ jsonObject.put("ctnrTyp", "1");
|
|
|
+ jsonObject.put("ctnrCode", rs.getString("pb_barcode"));
|
|
|
+
|
|
|
+ // 创建positionCodePath数组
|
|
|
+ JSONArray positionCodePathArray = new JSONArray();
|
|
|
+
|
|
|
+ // 创建第一个positionCodePath对象并添加到数组
|
|
|
+ JSONObject positionCodePath1 = new JSONObject();
|
|
|
+ positionCodePath1.put("positionCode",location);
|
|
|
+ positionCodePath1.put("type", "00");
|
|
|
+ positionCodePathArray.put(positionCodePath1);
|
|
|
+
|
|
|
+ // 创建第二个positionCodePath对象并添加到数组
|
|
|
+ JSONObject positionCodePath2 = new JSONObject();
|
|
|
+ positionCodePath2.put("positionCode", rs.getString("pb_location"));
|
|
|
+ positionCodePath2.put("type", "00");
|
|
|
+ positionCodePathArray.put(positionCodePath2);
|
|
|
+
|
|
|
+ // 将positionCodePath数组添加到外层JSONObject
|
|
|
+ jsonObject.put("positionCodePath", positionCodePathArray);
|
|
|
+ ip = rs.getString("sh_ip");
|
|
|
+ // 打印JSON字符串
|
|
|
+ System.out.println(jsonObject.toString()); // 使用4个空格进行缩进
|
|
|
+ sendTurnOnOutCommand(ip,"rcms/services/rest/hikRpcService/genAgvSchedulingTask",jsonObject.toString());
|
|
|
}
|
|
|
- reste = "点亮"+reste;
|
|
|
+
|
|
|
+ String reste = rs.getString("pb_location");
|
|
|
return reste;
|
|
|
}
|
|
|
+
|
|
|
+ //sendGYOUTCommand
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -546,30 +563,35 @@ public class PdaCommonDaoImpl implements PdaCommonDao {
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ AGV根据人员取消入库任务
|
|
|
+ */
|
|
|
@Override
|
|
|
public String scanEndTransOff(String emCode) throws IOException {
|
|
|
SqlRowList rs = baseDao.queryForRowSet("select * from prodoutprebar left join shelf on sh_code=pb_shelfcode" +
|
|
|
- " where pb_inmancode=? and pb_inoutno='扫码式上架' and pb_type='扫码式'", emCode);
|
|
|
- String type = null, shcode = null, ip = null, shnoaddress = null,color = null;
|
|
|
- int level = 0, port = 0;
|
|
|
- String da = createStringOfZeros(100);
|
|
|
- String reste="";
|
|
|
- if(rs.hasNext()) {
|
|
|
+ " where pb_inoutno='AGV入库' and nvl(pb_ifget,0)=0 and pb_inmancode=? order by pb_detno ", emCode);
|
|
|
+ String type = null, shcode = null, ip = null, color = null;
|
|
|
+ int number = 0;
|
|
|
+ if (rs.hasNext()) {
|
|
|
while (rs.next()) {
|
|
|
- shcode = rs.getString("pb_shelfcode");
|
|
|
- shnoaddress = rs.getString("sh_noaddress");
|
|
|
- level = rs.getInt("pb_level");
|
|
|
- port = rs.getInt("sh_port");
|
|
|
- ip = rs.getString("sh_ip");
|
|
|
- color = colorcode(rs.getInt("pb_color"));
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+
|
|
|
+ // 添加基本字段
|
|
|
+ jsonObject.put("reqCode", baseDao.getSeqId("agv_seq"));
|
|
|
+ jsonObject.put("taskCode", rs.getString("pb_id"));
|
|
|
+ jsonObject.put("forceCancel", "1");
|
|
|
+ jsonObject.put("matterArea", rs.getString("pb_location"));
|
|
|
+
|
|
|
+ // 打印JSON字符串
|
|
|
+ System.out.println(jsonObject.toString()); // 使用4个空格进行缩进
|
|
|
+ sendTurnOnOutCommand(ip,"rcms/services/rest/hikRpcService/cancelTask",jsonObject.toString());
|
|
|
}
|
|
|
- //String reste = DengCommand(shnoaddress,ip,port,da);
|
|
|
- String reste1 = sendCodingCommand(shnoaddress, level, ip, port, da, color);
|
|
|
- //灭一个删一个数据
|
|
|
- reste = StringUtil.hasText(reste)?reste+"," + reste1:reste+reste1;
|
|
|
- reste = "结束上架,灭灯"+reste;
|
|
|
+
|
|
|
+ String reste = "料架号:"+shcode+",位置:"+",点亮";
|
|
|
return reste;
|
|
|
}
|
|
|
+
|
|
|
+ //sendGYOUTCommand
|
|
|
return null;
|
|
|
}
|
|
|
|
|
@@ -604,30 +626,51 @@ public class PdaCommonDaoImpl implements PdaCommonDao {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 感应式出库点亮发送指令
|
|
|
+ * AGV出库发送指令
|
|
|
* @param id 出库单Id 一次性全部点亮
|
|
|
- * @param shelfcode 料架编号
|
|
|
+ * @param agvcode AGV编号
|
|
|
*/
|
|
|
@Override
|
|
|
- public String turnStartGYOutCommand(int id,String shelfcode) throws IOException {
|
|
|
+ public String turnStartGYOutCommand(int id,String agvcode) throws IOException {
|
|
|
SqlRowList rs = baseDao.queryForRowSet("select * from prodoutprebar left join shelf on sh_code=pb_shelfcode" +
|
|
|
- " where pb_piid =? and nvl(pb_ifget,0)=0 and pb_type='感应式' and pb_shelfcode=?", id, shelfcode);
|
|
|
+ " where pb_piid =? and nvl(pb_ifget,0)=0 and pb_type='AGV' order by pb_detno ", id);
|
|
|
String type = null, shcode = null, ip = null, color = null;
|
|
|
int number = 0;
|
|
|
- ArrayList<Integer> positions = new ArrayList<>();
|
|
|
if (rs.hasNext()) {
|
|
|
while (rs.next()) {
|
|
|
- if (rs.getCurrentIndex() == 0) {
|
|
|
- shcode = rs.getString("pb_shelfcode");
|
|
|
- number = rs.getInt("pb_number");//在整个料架的第几个位置
|
|
|
- ip = rs.getString("sh_ip");
|
|
|
- color = colorcode(rs.getInt("pb_color"));
|
|
|
- }
|
|
|
- //拼接位置100个字符,将第几个位置的0替换掉,pb_levelnumber;
|
|
|
- positions.add(number-1);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+
|
|
|
+ // 添加基本字段
|
|
|
+ jsonObject.put("reqCode", baseDao.getSeqId("agv_seq"));
|
|
|
+ jsonObject.put("taskCode", rs.getString("pb_id"));
|
|
|
+ jsonObject.put("taskTyp", "CK");
|
|
|
+ jsonObject.put("ctnrTyp", "1");
|
|
|
+ jsonObject.put("ctnrCode", rs.getString("pb_barcode"));
|
|
|
+
|
|
|
+ // 创建positionCodePath数组
|
|
|
+ JSONArray positionCodePathArray = new JSONArray();
|
|
|
+
|
|
|
+ // 创建第一个positionCodePath对象并添加到数组
|
|
|
+ JSONObject positionCodePath1 = new JSONObject();
|
|
|
+ positionCodePath1.put("positionCode", rs.getString("pb_location"));
|
|
|
+ positionCodePath1.put("type", "00");
|
|
|
+ positionCodePathArray.put(positionCodePath1);
|
|
|
+
|
|
|
+ // 创建第二个positionCodePath对象并添加到数组
|
|
|
+ JSONObject positionCodePath2 = new JSONObject();
|
|
|
+ positionCodePath2.put("positionCode", agvcode);
|
|
|
+ positionCodePath2.put("type", "00");
|
|
|
+ positionCodePathArray.put(positionCodePath2);
|
|
|
+
|
|
|
+ // 将positionCodePath数组添加到外层JSONObject
|
|
|
+ jsonObject.put("positionCodePath", positionCodePathArray);
|
|
|
+
|
|
|
+ // 打印JSON字符串
|
|
|
+ System.out.println(jsonObject.toString()); // 使用4个空格进行缩进
|
|
|
+ sendTurnOnOutCommand(ip,"rcms/services/rest/hikRpcService/genAgvSchedulingTask",jsonObject.toString());
|
|
|
}
|
|
|
- String reste = sendTurnOnOutCommand(ip,positions,color);
|
|
|
- reste = "料架号:"+shcode+",位置:"+",点亮"+reste;
|
|
|
+
|
|
|
+ String reste = "料架号:"+shcode+",位置:"+",点亮";
|
|
|
return reste;
|
|
|
}
|
|
|
|
|
@@ -636,23 +679,22 @@ public class PdaCommonDaoImpl implements PdaCommonDao {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 感应式出库亮灯
|
|
|
+ * AGV指令发送
|
|
|
* @param ip
|
|
|
- * @param positions
|
|
|
- * @param color
|
|
|
+ * @param message
|
|
|
* @return
|
|
|
*/
|
|
|
- private String sendTurnOnOutCommand(String ip,ArrayList <Integer> positions,String color ) {
|
|
|
+ private String sendTurnOnOutCommand(String ip,String method,String message ) {
|
|
|
/**{
|
|
|
"Action": 2,
|
|
|
"Positions": [4,5,6],
|
|
|
"Color":6
|
|
|
}*/
|
|
|
- Map<String,String> map = new HashMap<>();
|
|
|
- map.put("Action","2");
|
|
|
- map.put("Positions",positions.toString());
|
|
|
+// Map<String,String> map = new HashMap<>();
|
|
|
+// map.put("Action","2");
|
|
|
+// map.put("Positions",positions.toString());
|
|
|
try {
|
|
|
- HttpUtil.Response response = HttpUtil.sendPostRequest("http://" +ip+"/TurnOn",map);
|
|
|
+ HttpUtil.Response response = HttpUtil.doPost("http://" +ip+"/"+method,message,false,null);
|
|
|
/*{ Succeed : true, Code : 0, Message : “已切换为出库模式。” }
|
|
|
{ Succeed : false, Code : 10, Message : "失败:Token 错误。"}
|
|
|
{ Succeed : false, Code : 50, Message : “失败:设备仍在执行作业。” }
|
|
@@ -667,11 +709,12 @@ public class PdaCommonDaoImpl implements PdaCommonDao {
|
|
|
}else{
|
|
|
String res = response.getResponseText();
|
|
|
Map<Object, Object> resMap = BaseUtil.parseFormStoreToMap(res);
|
|
|
- if(Boolean.valueOf(resMap.get("Succeed").toString())){
|
|
|
- return "成功";
|
|
|
- }else{
|
|
|
- return resMap.get("Message").toString();
|
|
|
- }
|
|
|
+// if(Boolean.valueOf(resMap.get("message").toString())){
|
|
|
+// return "成功";
|
|
|
+// }else{
|
|
|
+// return resMap.get("message").toString();
|
|
|
+// }
|
|
|
+ return resMap.get("message").toString();
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
@@ -679,22 +722,36 @@ public class PdaCommonDaoImpl implements PdaCommonDao {
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
- * 恢复待机模式
|
|
|
- * @param shelfcode
|
|
|
+ * 取消AGV出库任务
|
|
|
+ * @param id
|
|
|
* @return
|
|
|
*/
|
|
|
@Override
|
|
|
- public String turnStandByCommand(String shelfcode) {
|
|
|
- SqlRowList rs = baseDao.queryForRowSet("select sh_ip from shelf where sh_code=?",shelfcode);
|
|
|
- if (rs.next()) {
|
|
|
+ public String turnStandByCommand(int id) {
|
|
|
+ SqlRowList rs = baseDao.queryForRowSet("select * from prodoutprebar left join shelf on sh_code=pb_shelfcode" +
|
|
|
+ " where pb_piid =? and nvl(pb_ifget,0)=0 and pb_type='AGV' order by pb_detno ", id);
|
|
|
+ String type = null, shcode = null, ip = null, color = null;
|
|
|
+ int number = 0;
|
|
|
+ if (rs.hasNext()) {
|
|
|
+ while (rs.next()) {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
|
|
|
- /*恢复调用/Standby
|
|
|
- { Succeed : true, Code : 0, Message : “已切换为待机模式。” }
|
|
|
- { Succeed : false, Code : 10, Message : "失败:Token 错误。"}
|
|
|
- { Succeed : false, Code : 20, Message : “失败:当前有未修正的错误。” }
|
|
|
- { Succeed : false, Code : 21, Message : “失败:当前有未完成的作业。” }*/
|
|
|
- return null;
|
|
|
+ // 添加基本字段
|
|
|
+ jsonObject.put("reqCode", baseDao.getSeqId("agv_seq"));
|
|
|
+ jsonObject.put("taskCode", rs.getString("pb_id"));
|
|
|
+ jsonObject.put("forceCancel", "1");
|
|
|
+ jsonObject.put("matterArea", rs.getString("pb_location"));
|
|
|
+
|
|
|
+ // 打印JSON字符串
|
|
|
+ System.out.println(jsonObject.toString()); // 使用4个空格进行缩进
|
|
|
+ sendTurnOnOutCommand(ip,"rcms/services/rest/hikRpcService/cancelTask",jsonObject.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ String reste = "料架号:"+shcode+",位置:"+",点亮";
|
|
|
+ return reste;
|
|
|
}
|
|
|
+
|
|
|
+ //sendGYOUTCommand
|
|
|
return null;
|
|
|
}
|
|
|
|