lisai17@sina.com 2021-03-07 19:32:22 +08:00
parent f3839eb798
commit f54734c197
2 changed files with 46 additions and 34 deletions

View File

@ -59,45 +59,48 @@ public class DingsongScale extends AbsScale {
ArrayList<String> list = new ArrayList<>(); ArrayList<String> list = new ArrayList<>();
AtomicBoolean run = new AtomicBoolean(true); AtomicBoolean run = new AtomicBoolean(true);
InputStream inputStream = socket.getInputStream(); try (InputStream inputStream = socket.getInputStream()) {
byte[] clearBuf = new byte[inputStream.available()]; byte[] clearBuf = new byte[inputStream.available()];
inputStream.read(clearBuf); inputStream.read(clearBuf);
int errCount = 0; int errCount = 0;
while (run.get() && list.size() < 15) { while (run.get() && list.size() < 15) {
long st = System.currentTimeMillis(); long st = System.currentTimeMillis();
byte[] buf = new byte[DATA_LENGTH]; byte[] buf = new byte[DATA_LENGTH];
int read = inputStream.read(buf); int read = inputStream.read(buf);
if (read != DATA_LENGTH && errCount < 10) { if (read != DATA_LENGTH && errCount < 10) {
errCount++;
continue;
}
String weight = new String(Arrays.copyOfRange(buf, DATA_FROM, DATA_TO));
if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
// System.out.println("error:" + weight);
if (errCount == 100) {
break;
}
errCount++;
continue;
}
try {
if (Long.parseLong(weight) > 100000) {
errCount++; errCount++;
continue; continue;
} }
} catch (Exception e) {
log.error(e.getMessage(), e); String weight = new String(Arrays.copyOfRange(buf, DATA_FROM, DATA_TO));
}
if (!pattern.matcher(weight).matches() || weight.equals("000000")) {
// System.out.println("error:" + weight);
if (errCount == 100) {
break;
}
errCount++;
continue;
}
try {
if (Long.parseLong(weight) < 50 || Long.parseLong(weight) > 100000) {
errCount++;
continue;
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight))); // System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
list.add(weight); list.add(weight);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
} }
String max = "0"; String max = "0";

View File

@ -9,14 +9,13 @@ import com.cowr.common.view.Result;
import com.cowr.local.ssjygl.devicectrl.common.Const; import com.cowr.local.ssjygl.devicectrl.common.Const;
import com.cowr.local.ssjygl.main.CliCacheData; import com.cowr.local.ssjygl.main.CliCacheData;
import com.cowr.local.ssjygl.main.Config; import com.cowr.local.ssjygl.main.Config;
import com.cowr.local.ssjygl.order.LocalOrderService; import com.cowr.local.ssjygl.modifylog.ModifyLogSyncService;
import com.cowr.local.ssjygl.ossfilelog.OssfileLogService; import com.cowr.local.ssjygl.ossfilelog.OssfileLogService;
import com.cowr.local.ssjygl.synctask.SyncTaskService; import com.cowr.local.ssjygl.synctask.SyncTaskService;
import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService; import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.model.*; import com.cowr.model.*;
import com.cowr.ssjygl.CacheData; import com.cowr.ssjygl.CacheData;
import com.cowr.ssjygl.blacklist.BlacklistService; import com.cowr.ssjygl.blacklist.BlacklistService;
import com.cowr.local.ssjygl.modifylog.ModifyLogSyncService;
import com.cowr.ssjygl.order.OrderService; import com.cowr.ssjygl.order.OrderService;
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService; import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService;
import com.cowr.ssjygl.transport.TransportService; import com.cowr.ssjygl.transport.TransportService;
@ -30,7 +29,7 @@ import net.coobird.thumbnailator.Thumbnails;
import java.io.File; import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.*; import java.util.Date;
/** /**
* MySQL * MySQL
@ -361,6 +360,16 @@ public class TransportSyncService {
Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", result.getLicense() + " 未找到入场记录!")); Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", result.getLicense() + " 未找到入场记录!"));
return result; return result;
} }
Date intime = transport.getInTime();
// 水利站是同进同出,进场时间不足 1 分钟,不识别抬杆
if (supermarket_id == 9 && (intime != null) && ((System.currentTimeMillis() - intime.getTime()) < (60 * 1000))) {
log.error("车辆【" + result.getLicense() + "】入场不到 1 分钟,可能是识别了车尾!");
Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", result.getLicense() + " 入场不到 1 分钟,可能是识别了车尾!"));
return result;
}
File uploadfile = null; File uploadfile = null;
if (file != null) { if (file != null) {
String fileuuid = StrKit.getRandomUUID(); String fileuuid = StrKit.getRandomUUID();