修改逻辑

路径写死
不记录2d
图修改
bug修改
连接断开彻底断开
just-order
LAPTOP-S9HJSOEB\昊天 2 years ago
parent 3e7d5b601c
commit f3809ba02b

@ -102,6 +102,14 @@
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>9</source>
<target>9</target>
</configuration>
</plugin>
</plugins>
</build>
</project>

File diff suppressed because one or more lines are too long

@ -329,6 +329,7 @@ public class StockService {
}
Order order = orderMapper.selectOne(new QueryWrapper<Order>()
.eq("street_Id",street.getId())
.eq("left_right1",stockCheck.getDirection())
.eq("column1",stock.getColumn())
.eq("row1",stock.getRow())
@ -345,7 +346,7 @@ public class StockService {
// Assert.notNull(shelveId,"无该货架信息");
Street street = streetService.getStreetByPlcId(stockCheckSearch.getSRMNumber());
Stock stock = stockMapper.getByStreetAndDirectionAndSideAndRowColumn(street.getId(),stockCheckSearch.getDirection(),stockCheckSearch.getSeparation(),stockCheckSearch.getRow(),stockCheckSearch.getColumn());
if(stock.getCheckPic()!=null){
if(stock != null && stock.getCheckPic()!=null){
stock.setCheckPics(stock.getCheckPic().split(";"));
}

@ -99,7 +99,9 @@ public class Decoder extends DelimiterBasedFrameDecoder {
}
//获取照片后发送进行计算逻辑,并在拍照队列中取出拍照发送
else if(GET_PHOTO_END.equals(transmissionPojo.getHeader())){
ClientChanel.get(transmissionPojo.getStreetNumber()).writeAndFlush(transmissionPojo.toString(TransmissionType.RTS));
if(transmissionPojo.getTaskId() != null && !"0".equals(transmissionPojo.getTaskId())) {
ClientChanel.get(transmissionPojo.getStreetNumber()).writeAndFlush(transmissionPojo.toString(TransmissionType.RTS));
}
try {
Thread.sleep(50L);
} catch (InterruptedException e) {
@ -113,6 +115,7 @@ public class Decoder extends DelimiterBasedFrameDecoder {
TransmissionPojo pojo = new TransmissionPojo(cameraDelayTask.getCommand());
ClientChanel.get(pojo.getStreetNumber()).writeAndFlush(pojo.toString(TransmissionType.GPS));
}
}
//照片和结果保存,并发送给上位机
else if(RETURN_CHECK.equals(transmissionPojo.getHeader())){

@ -8,7 +8,7 @@ import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.UUID;
import java.util.*;
@Data
public class TransmissionPojo {
@ -22,16 +22,16 @@ public class TransmissionPojo {
private String pcd;//点位文件路径
private String taskId;
private Integer checkId;
private String checkId;
private Integer direction;//左右
private Integer count; //数量
private String category; //品规
private String[] picsPath; //照片
private Integer count = 0; //数量
private String category = ""; //品规
private Set<String> picsPath; //照片
private Integer result;
public TransmissionPojo(CheckLog checkLog , Street street){
this.checkId = checkLog.getId();
this.checkId = checkLog.getId().toString();
this.streetNumber = street.getPlcId();
this.taskId = checkLog.getLotnum();
this.row = checkLog.getRow();
@ -46,14 +46,32 @@ public class TransmissionPojo {
}
/**
* 30
*
* @param number
* @param length 3
* @return
*/
public static String convertNumberToFixedLengthChars(int number, int length) {
if (length < 1) {
throw new IllegalArgumentException("Length must be a positive integer.");
}
String numStr = Integer.toString(number);
while (numStr.length() < length) {
numStr = "0" + numStr;
}
return numStr;
}
public TransmissionPojo( Street street,Integer row , Integer column,Integer direction,String orderId){
this.streetNumber = street.getPlcId();
this.row = row;
this.taskId = orderId;
this.taskId = "0";
this.direction = direction;
this.column = column;
this.checkId = 0;
this.checkId = convertNumberToFixedLengthChars(row, 3) + convertNumberToFixedLengthChars(column, 3);
}
public String toString(TransmissionType type) {
@ -64,8 +82,6 @@ public class TransmissionPojo {
return "GPS&" + streetNumber +"/"+row +"/"+column+ "&" + checkId + "&" + taskId + "&" + direction+ "&" + category + "&" + count;
}else if (type == TransmissionType.RTS) {
return "RTS&" + streetNumber +"/"+row +"/"+column+ "&" + checkId + "&" + taskId + "&" + direction + "&" + category + "&" + count;
}else if (type == TransmissionType.SGPS) {
return "SGPS&" + streetNumber +"/"+row +"/"+column+ "&" + checkId + "&" + taskId + "&" + direction ;
}
return "";
}
@ -79,35 +95,64 @@ public class TransmissionPojo {
String[] dataArr = dataArray[1].split("/");
this.streetNumber = dataArr[0];
this.row = Integer.valueOf(dataArr[1]);
this.column = Integer.valueOf(dataArr[2]);
if(dataArr.length > 2) {
this.column = Integer.valueOf(dataArr[2]);
}
}else {
this.streetNumber = dataArray[1];
}
if (dataArray.length > 2) {
this.checkId = Integer.valueOf(dataArray[2]);
this.checkId = dataArray[2];
this.taskId = (dataArray[3]);
this.direction = Integer.valueOf(dataArray[4]);
if(dataArray[4] != null && !"".equals(dataArray[4]) && !"null".equals(dataArray[4])) {
this.direction = Integer.valueOf(dataArray[4]);
}
}
if (dataArray.length > 5) {
this.category = dataArray[5];
if(!"".equals(dataArray[6]) && dataArray[6] != null) {
if(dataArray[5] != null &&!"".equals(dataArray[5]) && !"null".equals(dataArray[5]) ) {
this.category = dataArray[5];
}
if( dataArray.length > 6 && dataArray[6] != null && !"".equals(dataArray[6]) && ! "null".equals(dataArray[5])) {
this.count = Integer.valueOf(dataArray[6]);
}
}
if (dataArray.length > 7) {
this.result = Integer.parseInt(dataArray[7])==0 ?0:1;
this.picsPath = dataArray[8].split(";");
//不记录2d图像
//String path2D = "/fileData/"+this.taskId+"/"+this.checkId+"/"+this.direction+".jpg";
String path3D = "/fileData/"+this.taskId+"/"+this.checkId+"/"+(this.direction+2)+".PNG";
Set<String> strings = new HashSet<>();
//strings.add(path2D);
strings.add(path3D);
// 将数组中的元素添加到 Set 集合中
if(dataArray.length > 8 && dataArray[8].split(";").length>0) {
String[] s = dataArray[8].split(";");
for (int i = 0; i < s.length; i++) {
s[i] = s[i].replace("\\\\","/");
s[i] = s[i].replace("\\","/");
if(s[i].startsWith(".")) {
s[i] = s[i].replaceFirst(".", ""); // 移除单个字符
}
// 或者
// stringArray[i] = stringArray[i].replaceAll(regexToRemove, ""); // 使用正则表达式移除字符类别
}
Collections.addAll(strings,s);
strings.remove("");
}
this.picsPath = strings;
}
if (dataArray.length > 9) {
this.pcd = dataArray[9];
if(this.taskId != null && !"".equals(this.taskId) && this.checkId != null && !"".equals(this.checkId))
this.pcd = "/fileData/"+this.taskId+"/"+this.checkId+"/"+(this.direction+2)+".pcd";
}
}
public static void main(String[] args) {
TransmissionPojo transmissionPojo = new TransmissionPojo("RTE&6/3&562493&2121&1&S001&25&1&1.jpg;2.jpg&1.pcd>");
TransmissionPojo transmissionPojo = new TransmissionPojo("GPE&002/1/18&7&2&123&41111&30&0&fff;.\\\\f.png;/f.png>");
System.out.println(transmissionPojo);
}
}

@ -60,6 +60,10 @@ public class KsecNettyClient {
* @param upId
*/
public void reconnect(Integer upId) {
if (channel != null) {
channel.disconnect();
channel.close();
}
Boolean isConnected = false;
int num = 0;
ConfigProperties.KSEC ksec = configProperties.getKsec();
@ -73,9 +77,7 @@ public class KsecNettyClient {
e.printStackTrace();
}
while ((ksec.getReconnectNum() == -1 || num < ksec.getReconnectNum()) && !isConnected) {
if (channel != null) {
channel.close();
}
try {
Thread.sleep(ksec.getReconnectInterval());

Loading…
Cancel
Save