lisai17@sina.com 2020-10-26 22:43:50 +08:00
parent 06ea0792b3
commit 6c069bf564
4 changed files with 94 additions and 7 deletions

View File

@ -4,11 +4,15 @@ import com.cowr.common.Const;
import com.cowr.common.base.BaseService; import com.cowr.common.base.BaseService;
import com.cowr.common.enums.OrderStateEnum; import com.cowr.common.enums.OrderStateEnum;
import com.cowr.common.enums.UserTypeEnum; import com.cowr.common.enums.UserTypeEnum;
import com.cowr.common.utils.DateTimeUtil;
import com.cowr.common.view.PageParam; import com.cowr.common.view.PageParam;
import com.cowr.common.view.Result; import com.cowr.common.view.Result;
import com.cowr.model.Ordercluster; import com.cowr.model.Ordercluster;
import com.cowr.model.OrderclusterTruck; import com.cowr.model.OrderclusterTruck;
import com.cowr.model.Sysuser; import com.cowr.model.Sysuser;
import com.cowr.model.Transport;
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService;
import com.cowr.ssjygl.transprice.TransPriceService;
import com.jfinal.kit.StrKit; import com.jfinal.kit.StrKit;
import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page; import com.jfinal.plugin.activerecord.Page;
@ -577,6 +581,60 @@ public class OrderclusterService extends BaseService {
return Db.paginate(pp.getPage(), pp.getSize(), "select * ", fromsql, salePara.toArray()); return Db.paginate(pp.getPage(), pp.getSize(), "select * ", fromsql, salePara.toArray());
} }
public BigDecimal getTotalPriceByLicense(int supermarket_id, String truck_license, double weight) {
Transport transport = Transport.dao.findFirst("select * from transport t \n" +
" 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) {
return null;
}
if (transport.getFirstWeight() == null || transport.getSecondWeight() == null) {
return null;
}
OrderclusterTruck ot = OrderclusterTruckService.me.checkValidLicense(transport.getSupermarketId(), transport.getTruckLicense());
if (ot == null) {
return null;
}
Ordercluster ordercluster = Ordercluster.dao.findById(ot.getOrderclusterId());
if (ordercluster == null) {
return null;
}
BigDecimal up = ordercluster.getUnitPrice(); // 集团订单是每天创建的,可以使用集团订单中确定的单价
if (up == null) {
return null;
}
BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()).abs();
BigDecimal total_price = TransPriceService.me.caleTotalPrice(up, net_weight);
if(total_price == null){
return null;
}
// 零散购砂总价四舍五入
if(ordercluster.getCustomerId() == null){
total_price = total_price.setScale(0, BigDecimal.ROUND_HALF_UP);
}
return total_price;
}
/** /**
* *
* *
@ -604,6 +662,7 @@ public class OrderclusterService extends BaseService {
/** /**
* *
*
* @param customer_id * @param customer_id
* @return * @return
*/ */

View File

@ -4,9 +4,11 @@ import com.cowr.local.ssjygl.devicectrl.device.*;
import com.cowr.local.ssjygl.devicectrl.utils.LicenseJPGPair; import com.cowr.local.ssjygl.devicectrl.utils.LicenseJPGPair;
import com.cowr.local.ssjygl.main.CliCacheData; import com.cowr.local.ssjygl.main.CliCacheData;
import com.cowr.model.PostLicenseResult; import com.cowr.model.PostLicenseResult;
import com.cowr.ssjygl.order.ordercluster.OrderclusterService;
import com.jfinal.log.Log; import com.jfinal.log.Log;
import java.io.IOException; import java.io.IOException;
import java.math.BigDecimal;
public class OutController extends Controller implements Runnable { public class OutController extends Controller implements Runnable {
private static Log log = Log.getLog(InController.class); private static Log log = Log.getLog(InController.class);
@ -209,6 +211,10 @@ public class OutController extends Controller implements Runnable {
log.debug("%s 【%s】上磅后控制LED显示称重结果【%s】", getWhich(), pair.license, weight); log.debug("%s 【%s】上磅后控制LED显示称重结果【%s】", getWhich(), pair.license, weight);
try { try {
BigDecimal total_price = OrderclusterService.me.getTotalPriceByLicense(CliCacheData.SUP.getId(), pair.license, weight);
log.debug("%s 【%s】总价 %s 元", getWhich(), pair.license, total_price);
String weightStr; String weightStr;
if (weight >= 100) { if (weight >= 100) {
weightStr = String.format("%.1f", weight); weightStr = String.format("%.1f", weight);
@ -216,7 +222,12 @@ public class OutController extends Controller implements Runnable {
weightStr = String.format("%.2f", weight); weightStr = String.format("%.2f", weight);
} }
getLed().setWeightInfo(pair.license, weightStr); if (total_price == null) {
getLed().setWeightInfo(pair.license, weightStr);
} else {
// 显示总价
getLed().setPriceInfo(pair.license, weightStr, String.format("%.2f", total_price));
}
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage(), e); log.error(e.getMessage(), e);
log.debug("%s 【%s】控制LED显示称重结果失败【%s】", getWhich(), pair.license, weight); log.debug("%s 【%s】控制LED显示称重结果失败【%s】", getWhich(), pair.license, weight);

View File

@ -15,12 +15,14 @@ import java.util.Date;
import java.util.concurrent.locks.ReentrantLock; import java.util.concurrent.locks.ReentrantLock;
public class LEDThread extends Device implements Runnable { public class LEDThread extends Device implements Runnable {
private static Log log = Log.getLog(LED.class); private static Log log = Log.getLog(LEDThread.class);
private static final String LEDPriceFormat = " %s \\n重: %s吨\\n %s元";
private static final String LEDWeightFormat = "%s\\n %s \\n重: %s吨"; private static final String LEDWeightFormat = "%s\\n %s \\n重: %s吨";
private static final String LEDInfoFormat = "%s\\n %s \\n%s"; private static final String LEDInfoFormat = "%s\\n %s \\n%s";
private String license = ""; private String license = "";
private String text = "系统启动"; private String text = "系统启动";
private String price = "";
private String format = LEDInfoFormat; private String format = LEDInfoFormat;
private Thread thread; private Thread thread;
private boolean running = true; private boolean running = true;
@ -37,14 +39,23 @@ public class LEDThread extends Device implements Runnable {
screen(); // 更新属性后,马上刷新显示内容 screen(); // 更新属性后,马上刷新显示内容
} }
public void setWeightInfo(String license, String text) { public void setWeightInfo(String license, String weight) {
this.license = license; this.license = license;
this.text = text; this.text = weight;
this.format = LEDWeightFormat; this.format = LEDWeightFormat;
screen(); // 更新属性后,马上刷新显示内容 screen(); // 更新属性后,马上刷新显示内容
} }
public void setPriceInfo(String license, String weight, String price) {
this.license = license;
this.text = weight;
this.price = price;
this.format = LEDPriceFormat;
screen(); // 更新属性后,马上刷新显示内容
}
private static final ThreadLocal<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat>() { private static final ThreadLocal<SimpleDateFormat> sdf = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() { protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("MM-dd HH:mm"); return new SimpleDateFormat("MM-dd HH:mm");
@ -109,8 +120,14 @@ public class LEDThread extends Device implements Runnable {
} }
} }
String date = sdf.get().format(new Date()); String dataStr = null;
String dataStr = String.format(this.format, date, this.license, this.text);
if (this.format.equals(LEDPriceFormat)) {
dataStr = String.format(this.format, this.license, this.text, this.price);
} else {
dataStr = String.format(this.format, sdf.get().format(new Date()), this.license, this.text);
}
byte[] data = dataStr.getBytes(Charset.forName("gb2312")); byte[] data = dataStr.getBytes(Charset.forName("gb2312"));
int dataLen = data.length; int dataLen = data.length;
byte[] msg = new byte[frameHead.length + packetHead.length + b.length + dataLen]; byte[] msg = new byte[frameHead.length + packetHead.length + b.length + dataLen];

View File

@ -40,7 +40,7 @@ public class TransportQueryService {
return Result.failed("未找到有效的出入场记录"); return Result.failed("未找到有效的出入场记录");
} }
if (transport.getFirstWeight() == null && transport.getSecondWeight() == null) { if (transport.getFirstWeight() == null || transport.getSecondWeight() == null) {
return Result.failed("重量数据不完整"); return Result.failed("重量数据不完整");
} }