lisai17@sina.com 2020-10-29 14:28:44 +08:00
parent 57c96db052
commit fad8dbe4a8
3 changed files with 34 additions and 19 deletions

View File

@ -12,8 +12,10 @@ import com.cowr.model.OrderclusterTruck;
import com.cowr.model.Sysuser; import com.cowr.model.Sysuser;
import com.cowr.model.Transport; import com.cowr.model.Transport;
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.transprice.TransPriceService; import com.cowr.ssjygl.transprice.TransPriceService;
import com.jfinal.kit.StrKit; import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record; import com.jfinal.plugin.activerecord.Record;
@ -29,6 +31,7 @@ import java.util.*;
* <p> * <p>
*/ */
public class OrderclusterService extends BaseService { public class OrderclusterService extends BaseService {
private static Log log = Log.getLog(OrderclusterService.class);
public static final OrderclusterService me = new OrderclusterService(); public static final OrderclusterService me = new OrderclusterService();
public Result get(Integer id, Sysuser sysuser) { public Result get(Integer id, Sysuser sysuser) {
@ -582,53 +585,50 @@ public class OrderclusterService extends BaseService {
} }
public BigDecimal getTotalPriceByLicense(int supermarket_id, String truck_license, double weight) { public BigDecimal getTotalPriceByLicense(int supermarket_id, String truck_license, double weight) {
Transport transport = Transport.dao.findFirst("select * from transport t \n" + Transport transport = TransportService.me.undoneTransport(supermarket_id, truck_license);
" where t.state < ? \n" +
" and t.supermarket_id = ? \n" +
" and t.truck_license = ? \n" +
" and t.out_time like ? ",
OrderStateEnum.RECEIVED.getStateid(),
supermarket_id,
truck_license,
DateTimeUtil.sdf.get().format(new Date()) + "%"
);
if (transport == null) { if (transport == null) {
log.debug("没有找到运输记录");
return null; return null;
} }
if (transport.getFirstWeight() == null || transport.getSecondWeight() == null) { if (transport.getFirstWeight() == null) {
log.debug("没有入场重量");
return null; return null;
} }
OrderclusterTruck ot = OrderclusterTruckService.me.checkValidLicense(transport.getSupermarketId(), transport.getTruckLicense()); OrderclusterTruck ot = OrderclusterTruckService.me.checkValidLicense(transport.getSupermarketId(), transport.getTruckLicense());
if (ot == null) { if (ot == null) {
log.debug("没有配车记录");
return null; return null;
} }
Ordercluster ordercluster = Ordercluster.dao.findById(ot.getOrderclusterId()); Ordercluster ordercluster = Ordercluster.dao.findById(ot.getOrderclusterId());
if (ordercluster == null) { if (ordercluster == null) {
log.debug("没有找到关联的集团订单信息");
return null; return null;
} }
BigDecimal up = ordercluster.getUnitPrice(); // 集团订单是每天创建的,可以使用集团订单中确定的单价 BigDecimal up = ordercluster.getUnitPrice(); // 集团订单是每天创建的,可以使用集团订单中确定的单价
if (up == null) { if (up == null) {
log.debug("集团订单单价信息错误");
return null; return null;
} }
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()).abs(); BigDecimal net_weight = new BigDecimal(weight).subtract(transport.getFirstWeight()).abs();
BigDecimal total_price = TransPriceService.me.caleTotalPrice(up, net_weight); BigDecimal total_price = TransPriceService.me.caleTotalPrice(up, net_weight);
if(total_price == null){ if (total_price == null) {
log.debug("总价计算错误");
return null; return null;
} }
// 零散购砂总价四舍五入 // 零散购砂总价四舍五入
if(ordercluster.getCustomerId() == null){ if (ordercluster.getCustomerId() == null) {
total_price = total_price.setScale(0, BigDecimal.ROUND_HALF_UP); total_price = total_price.setScale(0, BigDecimal.ROUND_HALF_UP);
} }

View File

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

View File

@ -286,11 +286,26 @@ public class TransportDeviceService {
return Result.failed("记录已完成或者已取消"); return Result.failed("记录已完成或者已取消");
} }
Double weight = Config.deviceThread.scale(which); Double weight = null;
int tryCount = 0;
// 称重失败,在称一次 // 称重失败,在称一次
if (weight == null || weight == 0) { while (tryCount < 4) {
try {
weight = Config.deviceThread.scale(which); weight = Config.deviceThread.scale(which);
if (weight != null && weight > 0) {
break;
}
Thread.sleep(500);
}catch (Exception e){
log.error(e.getMessage(), e);
}finally {
tryCount++;
log.debug("%s 第 %s 次,重 %s", transport.getTruckLicense(), tryCount, weight);
}
} }
if (weight == null || weight == 0) { if (weight == null || weight == 0) {