调整重量精度

dev
lisai17@sina.com 2021-11-11 01:11:18 +08:00
parent 91861aed62
commit 8cdbb365ba
4 changed files with 23 additions and 11 deletions

View File

@ -161,7 +161,8 @@ public abstract class Controller implements Runnable {
}
public Boolean postWeight(int supermarket_id, String license, Double weight, String which) {
return TransportSyncService.me.postWeigh(supermarket_id, license, weight, which);
// 控制硬件上传的重量是两位小数
return TransportSyncService.me.postWeigh(supermarket_id, license, Math.round(weight * 100) / 100.0, which);
}
void postLicenseQueue(String which, BlockingQueue<LicenseJPGPair> licenseQueue) {

View File

@ -103,7 +103,7 @@ public class Config extends JFinalConfig {
public static DeviceThread deviceThread = new DeviceThread();
public static SocketIOService socketio = null;
private static boolean client_run = true;
public static final String CLINET_VERSION = "20211108";
public static final String CLINET_VERSION = "20211111";
public static String getRootPath() {
return PathKit.getWebRootPath()

View File

@ -5,6 +5,7 @@ import com.cowr.common.enums.Enums;
import com.cowr.common.enums.OrderStateEnum;
import com.cowr.common.enums.OrderTypeEnum;
import com.cowr.common.utils.ChineseNumberUtil;
import com.cowr.common.utils.MathUtil;
import com.cowr.common.utils.StrUtil;
import com.cowr.common.view.Result;
import com.cowr.local.ssjygl.actioncmdlog.ActionCmdLogSyncService;
@ -201,8 +202,7 @@ public class LocalOrderService {
}
double goodsNetWeight = Math.abs(order.getDouble("weight"));
String goodsNetWeight = "";
String goodsTareWeight = "";
String goodsGrossWeight = "";
String clientName = "";
@ -225,6 +225,7 @@ public class LocalOrderService {
if (sntype == OrderTypeEnum.SALE.getTypeid()) {
goodsNetWeight = String.format("%.2f", Math.abs(order.getDouble("weight"))); // 净重
goodsTareWeight = String.format("%.2f", first_weight); // 皮重
goodsGrossWeight = String.format("%.2f", second_weight); // 毛重
@ -261,7 +262,7 @@ public class LocalOrderService {
}
// 运输单价,车辆载重对应的起步价
priceTrans = TransPriceService.me.getOrderStartTransPrice(order.getInt("trans_co_id"), goodsNetWeight) + "";
priceTrans = TransPriceService.me.getOrderStartTransPrice(order.getInt("trans_co_id"), Math.abs(order.getDouble("weight"))) + "";
priceGoods = StrUtil.getRecordStr(order, "unit_price"); // 商品单价
transDistance = StrUtil.getRecordStr(order, "trans_distance"); // 运输距离
@ -273,6 +274,7 @@ public class LocalOrderService {
priceTransTotalUpper = ""; // 运输总价大写
}
} else if (sntype == OrderTypeEnum.TRANSFER.getTypeid()) {
goodsNetWeight = String.format("%.2f", Math.abs(order.getDouble("weight"))); // 净重
goodsTareWeight = String.format("%.2f", second_weight); // 皮重
goodsGrossWeight = String.format("%.2f", first_weight); // 毛重
@ -300,7 +302,7 @@ public class LocalOrderService {
}
// 运输单价,车辆载重对应的起步价
priceTrans = TransPriceService.me.getOrderStartTransPrice(order.getInt("trans_co_id"), goodsNetWeight) + "";
priceTrans = TransPriceService.me.getOrderStartTransPrice(order.getInt("trans_co_id"), Math.abs(order.getDouble("weight"))) + "";
priceGoods = StrUtil.getRecordStr(order, "unit_price"); // 商品单价
transDistance = StrUtil.getRecordStr(order, "trans_distance"); // 运输距离
@ -312,8 +314,15 @@ public class LocalOrderService {
priceTransTotalUpper = ""; // 运输总价大写
}
} else if (sntype == OrderTypeEnum.TEMP.getTypeid()) {
goodsTareWeight = String.format("%.2f", first_weight); // 皮重
goodsGrossWeight = String.format("%.2f", second_weight); // 毛重
int decimal = 0;
double total_weight = order.getDouble("weight");
if (total_weight > 0 && String.valueOf(total_weight).indexOf(".") > 0) {
decimal = MathUtil.getNumberDecimalDigits(total_weight);
}
goodsNetWeight = String.format("%." + decimal + "f", Math.abs(order.getDouble("weight"))); // 净重
goodsTareWeight = String.format("%." + decimal + "f", first_weight); // 皮重
goodsGrossWeight = String.format("%." + decimal + "f", second_weight); // 毛重
clientName = StrUtil.getRecordStr(order, "customer_texpayer_name");
@ -362,6 +371,7 @@ public class LocalOrderService {
priceGoods = StrUtil.getRecordStr(order, "unit_price"); // 商品单价
} else if (sntype == OrderTypeEnum.TRASH.getTypeid()) {
goodsNetWeight = String.format("%.2f", Math.abs(order.getDouble("weight"))); // 净重
goodsTareWeight = String.format("%.2f", second_weight); // 皮重
goodsGrossWeight = String.format("%.2f", first_weight); // 毛重
@ -377,6 +387,7 @@ public class LocalOrderService {
remark = "废料订单:" + sn;
} else if (sntype == OrderTypeEnum.PURCHASE.getTypeid()) {
goodsNetWeight = String.format("%.2f", Math.abs(order.getDouble("weight"))); // 净重
goodsTareWeight = String.format("%.2f", second_weight); // 皮重
goodsGrossWeight = String.format("%.2f", first_weight); // 毛重
@ -430,7 +441,7 @@ public class LocalOrderService {
out.put("origin", origin);
out.put("dest", dest);
out.put("goodsName", StrUtil.getRecordStr(order, "product_name"));
out.put("goodsNetWeight", String.format("%.2f", goodsNetWeight));
out.put("goodsNetWeight", goodsNetWeight);
out.put("transDistance", transDistance);
out.put("priceGoods", priceGoods);
out.put("priceGoodsTotal", paid); // ? 重量总价?

View File

@ -859,7 +859,7 @@ public class OrderTempSyncService {
transport.setType(OrderTypeEnum.TEMP.getTypeid());
// 客户账户可用余额要可以支付本次订单
if (availableBalance.compareTo(order.getTotalPrice()) < 1) {
if (availableBalance.compareTo(order.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_UP)) < 0) {
return Result.failedstr("总价 %.2f,客户可用余额(%.2f)不足以支付", order.getTotalPrice(), availableBalance);
}
@ -877,7 +877,7 @@ public class OrderTempSyncService {
order.setPaid(new BigDecimal(0)); // 预付费的实际支付为 0
order.setPrepayCustomerId(prepayCustomer.getId());
if (prepayCustomer.getSurplus().compareTo(order.getTotalPrice()) < 1) {
if (prepayCustomer.getSurplus().compareTo(order.getTotalPrice().setScale(2, BigDecimal.ROUND_HALF_UP)) < 0) {
return false;
}