称重指令
parent
8db40b5b69
commit
664a677020
|
|
@ -237,12 +237,22 @@ public class DeviceThread extends Thread {
|
|||
});
|
||||
}
|
||||
|
||||
public double scale(String scaleId) throws IOException {
|
||||
public Double scale(String scaleId) throws IOException {
|
||||
if (!this.scaleMap.containsKey(scaleId)) {
|
||||
throw new IllegalArgumentException(scaleId + " does not exist");
|
||||
}
|
||||
|
||||
return this.scaleMap.get(scaleId).weigh15();
|
||||
AbsScale scale = this.scaleMap.get(scaleId);
|
||||
|
||||
if(scale == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
if(!scale.isConnected()){
|
||||
scale.connect();
|
||||
}
|
||||
|
||||
return scale.weigh15();
|
||||
}
|
||||
|
||||
public void print(String printerId, File file) throws IOException {
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class XiShuiScale extends AbsScale {
|
|||
int errCount = 0;
|
||||
|
||||
while (run.get() && list.size() < 15) {
|
||||
long st = System.currentTimeMillis();
|
||||
// long st = System.currentTimeMillis();
|
||||
|
||||
byte[] buf = new byte[18];
|
||||
int read = inputStream.read(buf);
|
||||
|
|
|
|||
|
|
@ -562,12 +562,12 @@ public class LocalOrderService {
|
|||
|
||||
try {
|
||||
Config.deviceThread.print(printerId, getPrintFile(printdata));
|
||||
cmd.set("print", true);
|
||||
cmd.set("status", true);
|
||||
|
||||
ActionCmdLogSyncService.me.save(cmd.toJson(), sysuser);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
cmd.set("print", false);
|
||||
cmd.set("status", false);
|
||||
|
||||
ActionCmdLogSyncService.me.save(cmd.toJson(), sysuser);
|
||||
return Result.failed("打印指令失败");
|
||||
|
|
|
|||
|
|
@ -969,12 +969,12 @@ public class OrderTempSyncService {
|
|||
|
||||
try {
|
||||
Config.deviceThread.print(printerId, LocalOrderService.me.getPrintFile(printdata));
|
||||
cmd.set("print", true);
|
||||
cmd.set("status", true);
|
||||
|
||||
ActionCmdLogSyncService.me.save(cmd.toJson(), sysuser);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
cmd.set("print", false);
|
||||
cmd.set("status", false);
|
||||
|
||||
ActionCmdLogSyncService.me.save(cmd.toJson(), sysuser);
|
||||
return Result.failed("打印指令失败");
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ public class TransportController extends BaseController {
|
|||
renderJson(result ? Result.success(true) : Result.failed("抬闸失败"));
|
||||
}
|
||||
|
||||
@Before(TransportIdValidator.class)
|
||||
public void cmdScale() {
|
||||
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||
|
||||
|
|
@ -294,6 +295,7 @@ public class TransportController extends BaseController {
|
|||
return;
|
||||
}
|
||||
|
||||
String transport_id = get("transport_id");
|
||||
String which = getUpperCaseVal("which");// Enums.WhichEnum R01 入场流程 C01 出场流程
|
||||
|
||||
if (!Enums.CtrlFlowEnum.isValid(which)) {
|
||||
|
|
@ -301,8 +303,7 @@ public class TransportController extends BaseController {
|
|||
return;
|
||||
}
|
||||
|
||||
double result = TransportDeviceService.me.cmdScale(which, tokenuser);
|
||||
renderJson(Result.success(result));
|
||||
renderJson(TransportDeviceService.me.cmdScale(transport_id, which, tokenuser));
|
||||
}
|
||||
|
||||
@Before(TransportIdValidator.class)
|
||||
|
|
|
|||
|
|
@ -1,14 +1,19 @@
|
|||
package com.cowr.local.ssjygl.transport;
|
||||
|
||||
import com.cowr.common.enums.Enums;
|
||||
import com.cowr.common.enums.OrderStateEnum;
|
||||
import com.cowr.common.view.Result;
|
||||
import com.cowr.local.ssjygl.actioncmdlog.ActionCmdLogSyncService;
|
||||
import com.cowr.local.ssjygl.devicectrl.controllers.Controller;
|
||||
import com.cowr.local.ssjygl.main.CliCacheData;
|
||||
import com.cowr.local.ssjygl.main.Config;
|
||||
import com.cowr.model.SyncTask;
|
||||
import com.cowr.model.Sysuser;
|
||||
import com.cowr.model.Transport;
|
||||
import com.jfinal.kit.HttpKit;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.log.Log;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.Record;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
|
|
@ -258,18 +263,47 @@ public class TransportDeviceService {
|
|||
return ret;
|
||||
}
|
||||
|
||||
public double cmdScale(String which, Sysuser sysuser) {
|
||||
public Result cmdScale(String transport_id, String which, Sysuser sysuser) {
|
||||
try {
|
||||
Record cmdlog = new Record();
|
||||
cmdlog.set("cmd", "scale");
|
||||
cmdlog.set("which", which);
|
||||
cmdlog.set("transport_id", transport_id);
|
||||
cmdlog.set("status", false);
|
||||
|
||||
try {
|
||||
Transport transport = Transport.dao.findById(transport_id);
|
||||
|
||||
if (transport == null) {
|
||||
ActionCmdLogSyncService.me.save(cmdlog.toJson(), sysuser);
|
||||
return Result.failed("未找到出入场记录");
|
||||
}
|
||||
|
||||
if (transport.getState() >= OrderStateEnum.RECEIVED.getStateid()) {
|
||||
ActionCmdLogSyncService.me.save(cmdlog.toJson(), sysuser);
|
||||
return Result.failed("记录已完成或者已取消");
|
||||
}
|
||||
|
||||
Double weight = Config.deviceThread.scale(which);
|
||||
|
||||
// 称重失败,在称一次
|
||||
if (weight == null || weight == 0) {
|
||||
weight = Config.deviceThread.scale(which);
|
||||
}
|
||||
|
||||
if (weight == null || weight == 0) {
|
||||
ActionCmdLogSyncService.me.save(cmdlog.toJson(), sysuser);
|
||||
return Result.failed("称重失败");
|
||||
}
|
||||
|
||||
boolean ret = TransportSyncService.me.postWeigh(transport, weight, which);
|
||||
|
||||
cmdlog.set("status", ret);
|
||||
ActionCmdLogSyncService.me.save(cmdlog.toJson(), sysuser);
|
||||
|
||||
return Config.deviceThread.scale(which);
|
||||
return ret ? Result.success() : Result.failed("称重失败");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return 0.0;
|
||||
return Result.failed("称重失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -160,11 +160,6 @@ public class TransportSyncService {
|
|||
* @return
|
||||
*/
|
||||
public boolean postWeigh(int supermarket_id, String truck_license, Double weight, String which) {
|
||||
try {
|
||||
if (!Enums.CtrlFlowEnum.isValid(which)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Transport transport = TransportService.me.undoneTransport(supermarket_id, truck_license);
|
||||
|
||||
if (transport == null) {
|
||||
|
|
@ -177,6 +172,15 @@ public class TransportSyncService {
|
|||
return false;
|
||||
}
|
||||
|
||||
return postWeigh(transport, weight, which);
|
||||
}
|
||||
|
||||
public boolean postWeigh(Transport transport, Double weight, String which) {
|
||||
try {
|
||||
if (!Enums.CtrlFlowEnum.isValid(which)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean ret = false;
|
||||
|
||||
if (which.startsWith(Enums.CtrlFlowEnum.R.name())) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue