1. 兰溪巴河砂站有部分客户只拖砂记录吨位,不需要扣钱

2. 巴河暂时只做进料,且进料结算固定扣除两吨
3. 巴河车辆一天只录入一次车皮
4. 巴河站点销售结算可以自选商品
dev
徐杰盟 2025-05-29 10:41:32 +08:00
parent efa3310f05
commit e28986fe79
12 changed files with 206 additions and 21 deletions

View File

@ -1,8 +1,10 @@
package com.cowr.ssjygl;
import com.cowr.ssjygl.transprice.TransPriceModel;
import com.jfinal.plugin.activerecord.Record;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -15,6 +17,8 @@ public class CacheData {
// 需要通过数据库加载的参数
public static Map<Integer, BigDecimal> TRANS_CO_PRICE_MODULUS; // 物流公司运输起步价格系数
public static Map<String, Record> OUT_TRUCK_LICENSE_DATA = new HashMap<>(); // 出场车辆数据
public static List<TransPriceModel> TRANS_PRICE_CONFIG_TRASH;
public static List<TransPriceModel> TRANS_PRICE_CONFIG_SALE;
public static List<TransPriceModel> TRANS_PRICE_CONFIG_TRANSFER;

View File

@ -130,7 +130,7 @@ public class OrderTempService extends BaseService {
" left join order_temp ot on t.old_sn = ot.sn \n" +
" where 1=1 ";
// supermarket_type = 1;
supermarket_type = null;
}

View File

@ -28,7 +28,8 @@ public class SupermarketSandfarmDistanceService extends BaseService {
public BigDecimal getDistance(int supermarket_id, int sandfarm_id) {
try {
return Db.queryBigDecimal("select distance from supermarket_sandfarm_distance where supermarket_id = ? and sandfarm_id = ?", supermarket_id, sandfarm_id);
BigDecimal bigDecimal = Db.queryBigDecimal("select distance from supermarket_sandfarm_distance where supermarket_id = ? and sandfarm_id = ?", supermarket_id, sandfarm_id);
return bigDecimal;
} catch (Exception e) {
log.error(e.getMessage(), e);

View File

@ -194,6 +194,11 @@ public class DeviceThread extends Thread {
if (supermarket_id == 1) { // 城隍用了耀华的表头
scale = new YaoHuaScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
}
// 根据砂站id兼容不同的表头
if (supermarket_id == 4) { // 巴河用了科力的表头
scale = new KeLiScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
}
// else if (supermarket_id == 4) { // 石畈用了两个不一样的表头
// if (scaleconf.getIntValue("port") == 10001) { // 根据现场实际接线配置
//// scale = new YaoHuaScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
@ -396,7 +401,7 @@ public class DeviceThread extends Thread {
}
// 永安砂站只有一个磅,同进同出,出入口共用道闸
if (CliCacheData.SUP.getId() == 9 && Enums.WhichEnum.C01.name().equals(which)) {
if (CliCacheData.SUP.getId() == 4 && Enums.WhichEnum.C01.name().equals(which)) {
which = Enums.WhichEnum.R01.name();
if (num == 1) {

View File

@ -250,6 +250,11 @@ public class InController extends Controller implements Runnable {
log.debug("%s 【%s】称重失败【%s】", getWhich(), pair.license, weight);
}
// 巴河进料需要减两吨
if (CliCacheData.SUP.getId() == 4 && weight > 35){
weight -= 2;
}
log.debug("%s 【%s】上磅后控制LED显示称重结果【%s】", getWhich(), pair.license, weight);
try {
String weightStr;

View File

@ -0,0 +1,31 @@
package com.cowr.local.ssjygl.jobs;
import com.cowr.ssjygl.CacheData;
import com.jfinal.log.Log;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
/**
* Description:
* Created by XuSan on 2023/12/20.
*
*
* @author XuSan
* @version 1.0
*/
public class TruckLicenseDatJob implements Job {
private static Log log = Log.getLog(TruckLicenseDatJob.class);
@Override
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
try {
CacheData.OUT_TRUCK_LICENSE_DATA.clear();
log.info("清空车辆数据: %s",CacheData.OUT_TRUCK_LICENSE_DATA.size());
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}

View File

@ -17,9 +17,12 @@ import com.cowr.ssjygl.order.ordertemp.OrderTempPKValidator;
import com.cowr.ssjygl.order.ordertemp.OrderTempService;
import com.jfinal.aop.Before;
import com.jfinal.aop.Clear;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import org.apache.poi.ss.usermodel.Workbook;
import java.math.BigDecimal;
import static com.cowr.common.utils.DateTimeUtil.TM_TIME;
import static com.cowr.common.utils.DateTimeUtil.now;
@ -112,6 +115,13 @@ public class OrderTempController extends BaseController {
String uuid = get("uuid");
String transport_id = get("transport_id");
Integer product_id = getInt("product_id");
String unitPrice = get("unit_price");
BigDecimal unit_price = null;
if (StrKit.notBlank(unitPrice)){
unit_price = new BigDecimal(unitPrice);
}
String invoice_number = get("invoice_number");
String invoice_code = get("invoice_code");
String ticket_code = get("ticket_code");
@ -120,7 +130,7 @@ public class OrderTempController extends BaseController {
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
int req_receipt = getInt("req_receipt", 0); // 是否需要发票0 默认不需要1需要
renderJson(OrderTempSyncService.me.pay(uuid, transport_id, product_id, invoice_number, invoice_code, ticket_code, pay_type, memo, printer, tokenuser, req_receipt));
renderJson(OrderTempSyncService.me.pay(uuid, transport_id, product_id, unit_price, invoice_number, invoice_code, ticket_code, pay_type, memo, printer, tokenuser, req_receipt));
}
@ -140,10 +150,18 @@ public class OrderTempController extends BaseController {
String invoice_code = get("invoice_code");
String ticket_code = get("ticket_code");
String memo = get("memo");
Integer product_id = getInt("product_id");
String unitPrice = get("unit_price");
BigDecimal unit_price = null;
if (StrKit.notBlank(unitPrice)){
unit_price = new BigDecimal(unitPrice);
}
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
// int req_receipt = getInt("req_receipt", 0); // 是否需要发票0 默认不需要1需要
renderJson(OrderTempSyncService.me.payordercluster(uuid, transport_id, ordercluster_id, invoice_number, invoice_code, ticket_code, memo, printer, tokenuser));
renderJson(OrderTempSyncService.me.payordercluster(uuid, product_id, unit_price, transport_id, ordercluster_id, invoice_number, invoice_code, ticket_code, memo, printer, tokenuser));
}
@Before(OrderTempPrepayValidator.class)
@ -162,11 +180,18 @@ public class OrderTempController extends BaseController {
String invoice_code = get("invoice_code");
String ticket_code = get("ticket_code");
Integer product_id = getInt("product_id");
String unitPrice = get("unit_price");
BigDecimal unit_price = null;
if (StrKit.notBlank(unitPrice)){
unit_price = new BigDecimal(unitPrice);
}
String memo = get("memo");
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
int req_receipt = getInt("req_receipt", 0); // 是否需要发票0 默认不需要1需要
renderJson(OrderTempSyncService.me.prepay(uuid, transport_id, ordercluster_id, invoice_number, invoice_code, ticket_code, product_id, memo, printer, tokenuser, req_receipt));
renderJson(OrderTempSyncService.me.prepay(uuid, transport_id, ordercluster_id, invoice_number, invoice_code, ticket_code, product_id,unit_price, memo, printer, tokenuser, req_receipt));
}
@Before(OrderTempPrepayValidator.class)
@ -185,11 +210,16 @@ public class OrderTempController extends BaseController {
String invoice_code = get("invoice_code");
String ticket_code = get("ticket_code");
Integer product_id = getInt("product_id");
String unitPrice = get("unit_price");
BigDecimal unit_price = null;
if (StrKit.notBlank(unitPrice)){
unit_price = new BigDecimal(unitPrice);
}
String memo = get("memo");
String printer = get("printer", Enums.PrinterIdEnum.printer1.name());
int req_receipt = getInt("req_receipt", 0); // 是否需要发票0 默认不需要1需要
renderJson(OrderTempSyncService.me.presellpay(uuid, transport_id, ordercluster_id, invoice_number, invoice_code, ticket_code, product_id, memo, printer, tokenuser, req_receipt));
renderJson(OrderTempSyncService.me.presellpay(uuid, transport_id, ordercluster_id, invoice_number, invoice_code, ticket_code, product_id, unit_price, memo, printer, tokenuser, req_receipt));
}
@Before(SnValidator.class)

View File

@ -45,6 +45,7 @@ public class OrderTempSyncService {
String uuid,
String transport_id,
Integer product_id,
BigDecimal unit_price,
String invoice_number,
String invoice_code,
String ticket_code,
@ -72,6 +73,11 @@ public class OrderTempSyncService {
BigDecimal up = SupermarketProductService.me.getUnitPrice(transport.getSupermarketId(), product.getId());
// 如果接口有传入单价就用传入的单价信息
if (Objects.nonNull(unit_price)){
up = unit_price;
}
if (up == null) {
return Result.failedstr("未查到有效的单价信息");
}
@ -148,11 +154,16 @@ public class OrderTempSyncService {
order.setTruckLicense(transport.getTruckLicense());
order.setProductId(product.getId());
order.setProductName(product.getName());
BigDecimal total_price = TransPriceService.me.caleTotalPrice(up, net_weight);
// 如果是管理费设置总价为0
if ("管理费".equals(order.getProductName())){
total_price = BigDecimal.ZERO;
}
// 支付信息
order.setUnitPrice(up);
order.setWeight(net_weight); // 使用净重更新重量
order.setTotalPrice(TransPriceService.me.caleTotalPrice(up, net_weight)); // 获取根据净重和单价计算的总价,作为实付金额
order.setTotalPrice(total_price); // 获取根据净重和单价计算的总价,作为实付金额
order.setPaid(order.getTotalPrice()); // 实际应付金额,预付费走另外的接口
order.setPayType(pay_type); // 1.线下支付2.线上支付,走银行流程
@ -303,6 +314,8 @@ public class OrderTempSyncService {
public Result payordercluster(
String uuid,
Integer product_id,
BigDecimal unit_price,
String transport_id,
Integer ordercluster_id,
String invoice_number,
@ -426,12 +439,30 @@ public class OrderTempSyncService {
order.setSupermarketId(transport.getSupermarketId());
order.setTruckLicense(transport.getTruckLicense());
if (Objects.isNull(product_id)){
product_id = ordercluster.getProductId();
}
Product product = Product.dao.findById(product_id);
// Product product = Product.dao.findById(ordercluster.getProductId());
if (product == null) {
return Result.failedstr("未找到有效的品类信息");
}
order.setProductId(product.getId());
order.setProductName(product.getName());
// 运输信息
order.setProductId(ordercluster.getProductId());
order.setProductName(ordercluster.getProductName());
// order.setProductId(ordercluster.getProductId());
// order.setProductName(ordercluster.getProductName());
BigDecimal up = ordercluster.getUnitPrice(); // 集团订单是每天创建的,可以使用集团订单中确定的单价
// 如果接口有传入单价就用传入的单价信息
if (Objects.nonNull(unit_price)){
up = unit_price;
}
if (up == null) {
return Result.failedstr("未查到有效的单价信息");
}
@ -470,6 +501,11 @@ public class OrderTempSyncService {
// 2024年9月2日 散户(处置砂,黄砂)结算付款不再四舍五入,保留小数点后两位数
total_price = total_price.setScale(2, BigDecimal.ROUND_HALF_UP);
// 如果是管理费设置总价为0
if ("管理费".equals(order.getProductName())){
total_price = BigDecimal.ZERO;
}
// 支付信息
order.setUnitPrice(up);
order.setWeight(net_weight); // 使用净重更新重量
@ -654,6 +690,7 @@ public class OrderTempSyncService {
String invoice_code,
String ticket_code,
Integer product_id,
BigDecimal unit_price,
String memo,
String printerId,
Sysuser sysuser,
@ -802,7 +839,12 @@ public class OrderTempSyncService {
// order.setInvoiceType(2); // 不需要开发票的,都是要专票的
}
Product product = Product.dao.findById(ordercluster.getProductId());
if (Objects.isNull(product_id)){
product_id = ordercluster.getProductId();
}
Product product = Product.dao.findById(product_id);
// Product product = Product.dao.findById(ordercluster.getProductId());
if (product == null) {
return Result.failedstr("未找到有效的品类信息");
@ -830,6 +872,11 @@ public class OrderTempSyncService {
// BigDecimal up = CustomerSupermarketProductService.me.getUnitPrice(customer.getId(), transport.getSupermarketId(), product.getId());
BigDecimal up = ordercluster.getUnitPrice(); // 集团订单是每天创建的,可以使用集团订单中确定的单价
// 如果接口有传入单价就用传入的单价信息
if (Objects.nonNull(unit_price)){
up = unit_price;
}
if (up == null) {
return Result.failedstr("未查到有效的单价信息");
}
@ -848,7 +895,11 @@ public class OrderTempSyncService {
// 支付信息
order.setUnitPrice(up);
order.setWeight(net_weight); // 使用净重更新重量
order.setTotalPrice(TransPriceService.me.caleTotalPrice(up, net_weight)); // 获取根据净重和单价计算的总价,作为应付金额
BigDecimal totalPrice = TransPriceService.me.caleTotalPrice(up, net_weight);
if ("管理费".equals(order.getProductName())){
totalPrice = BigDecimal.ZERO;
}
order.setTotalPrice(totalPrice); // 获取根据净重和单价计算的总价,作为应付金额
order.setPaid(order.getTotalPrice()); // 如果有预付费,该字段根据预付费情况设置。实付金额
order.setPayType(1);
order.setOrderclusterId(ordercluster_id);
@ -1056,6 +1107,7 @@ public class OrderTempSyncService {
String invoice_code,
String ticket_code,
Integer product_id,
BigDecimal unit_price,
String memo,
String printerId,
Sysuser sysuser,
@ -1205,7 +1257,13 @@ public class OrderTempSyncService {
// order.setInvoiceType(2); // 不需要开发票的,都是要专票的
}
Product product = Product.dao.findById(ordercluster.getProductId());
if (Objects.isNull(product_id)){
product_id = ordercluster.getProductId();
}
Product product = Product.dao.findById(product_id);
// Product product = Product.dao.findById(ordercluster.getProductId());
if (product == null) {
return Result.failedstr("未找到有效的品类信息");
@ -1233,6 +1291,11 @@ public class OrderTempSyncService {
// BigDecimal up = CustomerSupermarketProductService.me.getUnitPrice(customer.getId(), transport.getSupermarketId(), product.getId());
BigDecimal up = ordercluster.getUnitPrice(); // 集团订单是每天创建的,可以使用集团订单中确定的单价
// 如果接口有传入单价就用传入的单价信息
if (Objects.nonNull(unit_price)){
up = unit_price;
}
if (up == null) {
return Result.failedstr("未查到有效的单价信息");
}
@ -1247,11 +1310,15 @@ public class OrderTempSyncService {
// 运输信息
order.setProductId(product.getId());
order.setProductName(product.getName());
BigDecimal totalPrice = TransPriceService.me.caleTotalPrice(up, net_weight);
if ("管理费".equals(order.getProductName())){
totalPrice = BigDecimal.ZERO;
}
// 支付信息
order.setUnitPrice(up);
order.setWeight(net_weight); // 使用净重更新重量
order.setTotalPrice(TransPriceService.me.caleTotalPrice(up, net_weight)); // 获取根据净重和单价计算的总价,作为应付金额
order.setTotalPrice(totalPrice); // 获取根据净重和单价计算的总价,作为应付金额
order.setPaid(order.getTotalPrice()); // 如果有预付费,该字段根据预付费情况设置。实付金额
order.setPayType(1);
order.setOrderclusterId(ordercluster_id);

View File

@ -116,7 +116,16 @@ public class OrderTransferSyncService {
return Result.failedstr("重量数据有误,第一次称重:%.4f,第二次称重:%.4f", transport.getFirstWeight(), transport.getSecondWeight());
}
BigDecimal net_weight = transport.getFirstWeight().subtract(transport.getSecondWeight()); // 转运的用第一次减第二次
// 巴河的转运需要皮重减2吨
BigDecimal firstWeight = transport.getFirstWeight();
// if (transport.getSupermarketId() == 4){
// firstWeight = firstWeight.subtract(BigDecimal.valueOf(2));
// transport.setFirstWeight(firstWeight);
// }
BigDecimal net_weight = firstWeight.subtract(transport.getSecondWeight()); // 转运的用第一次减第二次
if (source_weight != null) {
order.setSourceWeight(new BigDecimal(source_weight));
@ -186,11 +195,14 @@ public class OrderTransferSyncService {
BigDecimal distance = SupermarketSandfarmDistanceService.me.getDistance(transport.getSupermarketId(), ordercluster.getSupermarketId());
order.setTransDistance(distance); // 转运运距
BigDecimal transUnitPrice = new BigDecimal(TransPriceService.me.getTransferStartTransPrice(order.getTransDistance().doubleValue()));
order.setTransUnitPrice(transUnitPrice); // 转运单价
// 支付时,用净重计算运费
order.setTransPrice(new BigDecimal(TransPriceService.me.caleTransferTransPrice( net_weight.doubleValue(), order.getTransDistance().doubleValue()))); // 转运运费
if (Objects.nonNull(distance)){
order.setTransDistance(distance); // 转运运距
log.info("转运运距 :%s", distance);
BigDecimal transUnitPrice = new BigDecimal(TransPriceService.me.getTransferStartTransPrice(order.getTransDistance().doubleValue()));
order.setTransUnitPrice(transUnitPrice); // 转运单价
// 支付时,用净重计算运费
order.setTransPrice(new BigDecimal(TransPriceService.me.caleTransferTransPrice( net_weight.doubleValue(), order.getTransDistance().doubleValue()))); // 转运运费
}
transport.setState(OrderStateEnum.RECEIVED.getStateid()); // 标记 transport state 为 5 ,表示出入场记录完成

View File

@ -9,7 +9,6 @@ import com.cowr.common.view.Result;
import com.cowr.local.ssjygl.main.Config;
import com.cowr.model.*;
import com.cowr.ssjygl.customer.supermarketproduct.CustomerSupermarketProductService;
import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService;
import com.cowr.ssjygl.order.OrderService;
import com.cowr.ssjygl.order.ordercluster.OrderclusterService;
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService;
@ -94,6 +93,7 @@ public class TransportQueryService {
return Result.success(transobj);
}
public Result transportInfo(String transport_id) {
Transport transport = Transport.dao.findById(transport_id);

View File

@ -649,6 +649,32 @@ public class TransportSyncService {
}
}
// 判断是否是巴河站点的进料车辆
if (transport.getSupermarketId() == 4 && transport.getFirstWeight().compareTo(new BigDecimal(35)) > 0) {
log.info("开始二次进料");
String truckLicense = transport.getTruckLicense();
Record o;
if (CacheData.OUT_TRUCK_LICENSE_DATA.containsKey(truckLicense)) {
log.info("读取缓存");
o = CacheData.OUT_TRUCK_LICENSE_DATA.get(truckLicense);
}else{
log.info("读取数据库");
o = Db.findFirst("SELECT out_which,second_weight,second_weight_which,second_pic FROM `transport` " +
" WHERE truck_license = ? AND state = 5 AND DATE(arrive_time) = CURDATE() " +
" ORDER BY arrive_time" +
" LIMIT 0,1", truckLicense);
CacheData.OUT_TRUCK_LICENSE_DATA.put(truckLicense, o);
}
if (o != null){
log.info("数据 o:"+o.toJson());
transport.setSecondWeight(o.getBigDecimal("second_weight"));
transport.setSecondWeightWhich(o.getStr("second_weight_which"));
transport.setSecondPic(o.getStr("second_pic"));
transport.setOutWhich(o.getStr("out_which"));
transport.setOutTime(new Date());
}
}
SyncTask synctask = new SyncTask();
boolean ret = Db.tx(new IAtom() {

View File

@ -17,6 +17,10 @@ CustomerDiscount.job=com.cowr.local.ssjygl.jobs.CustomerDiscountJob
CustomerDiscount.cron= 0 0 0/1 * * ?
CustomerDiscount.enable=true
TruckLicenseData.job=com.cowr.local.ssjygl.jobs.TruckLicenseDatJob
TruckLicenseData.cron= 0 0 0 * * ?
TruckLicenseData.enable=true
Hbrsms.job=com.cowr.local.ssjygl.hbrsms.HbrsmsJob
Hbrsms.cron= 0 * * * * ?
Hbrsms.enable=true