Merge branch 'master' into ls-dev

# Conflicts:
#	ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/main/Config.java
#	ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java
dev
lisai17@sina.com 2021-03-26 17:48:54 +08:00
commit 3a61b64cc1
15 changed files with 240 additions and 142 deletions

View File

@ -78,7 +78,17 @@ public class CustomerService extends BaseService {
" ) a on a.customer_id = t.id\n" +
" \n" +
" left join (\n" +
" select t.* from prepay_customer t\n" +
" select t.id,"+
" t.customer_id,\n"+
" t.supermarket_id,\n"+
"t.recharge_time,\n"+
" t.spend_time,\n"+
"t.first_recharge_time,\n"+
" t.threshold,\n"+
" t.notice,\n"+
" (t.surplus-ifnull(m.amount,0)) surplus from prepay_customer t\n"+
"left join (select customer_id,ifnull(sum(amount),0) amount from refund_detail where state<3 group by customer_id) m\n"+
" on t.customer_id=m.customer_id\n"+
" left join (\n" +
" select max(t.id) prepay_customer_id, t.customer_id from prepay_customer t\n" +
" group by t.customer_id\n" +

View File

@ -26,6 +26,14 @@ import java.util.List;
public class InvoiceLogService extends BaseService {
public static final InvoiceLogService me = new InvoiceLogService();
public InvoiceLog checkUseInvoiceLog(String invoice_number, String invoice_code) {
return InvoiceLog.dao.findFirst(
"select * from invoice_log t where t.invoice_number = ? and t.code = ? ",
invoice_number,
invoice_code
);
}
public InvoiceLog checkInvalidInvoiceLog(String invoice_number, String invoice_code) {
return InvoiceLog.dao.findFirst(
"select * from invoice_log t where t.state = ? and t.invoice_number = ? and t.code = ?",

View File

@ -11,6 +11,7 @@ import com.cowr.common.enums.OrderStateEnum;
import com.cowr.ssjygl.customer.receiver.CustomerReceiverService;
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService;
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
import com.cowr.ssjygl.prepay.refunddetail.RefundDetailService;
import com.jfinal.kit.StrKit;
import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db;
@ -20,6 +21,7 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@ -137,7 +139,8 @@ public class PrepayService {
}
Record out = new Record();
//获取账户可用余额
BigDecimal availableBalance = RefundDetailService.me.getAvailableBalance(prepayCustomer.getCustomerId(), prepayCustomer.getSurplus());
out.set("prepay_truck", true);
out.set("prepay_threshold", prepayCustomer.getThreshold());
out.set("prepay_truck_type", OrderTypeEnum.TEMP.getTypeid()); // 浠水固定只有外销
@ -145,7 +148,7 @@ public class PrepayService {
out.set("prepay_customer_name", customer.getName());
out.set("prepay_contact_name", pd.getContactName());
out.set("prepay_contact_phone", pd.getContactPhone());
out.set("prepay_surplus", prepayCustomer.getSurplus());
out.set("prepay_surplus", availableBalance);
out.set("prepay_customer", customer);
out.set("prepay_customer_info", prepayCustomer);
out.set("prepay_customer_invoice_type", customer.getInvoiceType()); // 客户发票类型

View File

@ -12,6 +12,7 @@ import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
@ -89,4 +90,21 @@ public class RefundDetailService extends BaseService {
public List<RefundDetail> list() {
return RefundDetail.dao.find("select * from refund_detail");
}
/**
*
* @param customer_id ID
* @param surplus
* @return
*/
public BigDecimal getAvailableBalance(Integer customer_id,BigDecimal surplus){
Record record = Db.findFirst("select ifnull(sum(amount),0) amount from refund_detail where state<3 and customer_id=? limit 1", customer_id);
BigDecimal amount = record.getBigDecimal("amount");
if(surplus==null){
surplus=new BigDecimal('0');
}
return surplus.subtract(amount);
}
}

View File

@ -195,7 +195,10 @@ public class DeviceThread extends Thread {
scale = new YaoHuaScale(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"));
// scale = new YaoHuaScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
// 2021-03-07 原来地方1号传感器故障让二期地磅厂家更换传感器
scale = new DingsongScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
} else {
scale = new XiShuiScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
}
@ -306,7 +309,25 @@ public class DeviceThread extends Thread {
scale.connect();
}
try {
return scale.weigh15();
}catch (Exception e){
log.error(e.getMessage(), e);
try {
scale.disconnect();
Thread.sleep(500);
scale.connect();
} catch (Exception e1) {
log.error(e1.getMessage(), e1);
}
if (!scale.isConnected()) {
return null;
}
return scale.weigh15();
}
}
public void print(String printerId, File file) throws IOException {

View File

@ -33,13 +33,13 @@ public class InController extends Controller implements Runnable {
setRod1Up("rodIn1Up");
}
if (StrKit.isBlank(rod2Up)) {
setRod1Up("rodIn2Up");
setRod2Up("rodIn2Up");
}
if (StrKit.isBlank(sensor1Reset)) {
setSensor1Reset("sensorIn1Reset");
}
if (StrKit.isBlank(sensor2Reset)) {
setSensor1Reset("sensorIn2Reset");
setSensor2Reset("sensorIn2Reset");
}
if (StrKit.isBlank(sensor1)) {
setSensor1("sensorIn1");

View File

@ -47,7 +47,7 @@ public class OutController extends Controller implements Runnable {
setSensor1("sensorOut1");
}
if (StrKit.isBlank(sensor2)) {
setSensor1("sensorOut2");
setSensor2("sensorOut2");
}
}

View File

@ -59,7 +59,7 @@ public class DingsongScale extends AbsScale {
ArrayList<String> list = new ArrayList<>();
AtomicBoolean run = new AtomicBoolean(true);
InputStream inputStream = socket.getInputStream();
try (InputStream inputStream = socket.getInputStream()) {
byte[] clearBuf = new byte[inputStream.available()];
inputStream.read(clearBuf);
int errCount = 0;
@ -88,7 +88,7 @@ public class DingsongScale extends AbsScale {
}
try {
if (Long.parseLong(weight) > 100000) {
if (Long.parseLong(weight) < 50 || Long.parseLong(weight) > 100000) {
errCount++;
continue;
}
@ -99,6 +99,9 @@ public class DingsongScale extends AbsScale {
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
list.add(weight);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
String max = "0";
if (list.size() > 0) {

View File

@ -59,7 +59,7 @@ public class KeLiScale extends AbsScale {
ArrayList<String> list = new ArrayList<>();
AtomicBoolean run = new AtomicBoolean(true);
InputStream inputStream = socket.getInputStream();
try (InputStream inputStream = socket.getInputStream()) {
byte[] clearBuf = new byte[inputStream.available()];
inputStream.read(clearBuf);
int errCount = 0;
@ -99,6 +99,10 @@ public class KeLiScale extends AbsScale {
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
list.add(weight);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
String max = "0";
if (list.size() > 0) {

View File

@ -52,7 +52,7 @@ public class XiShuiScale extends AbsScale {
ArrayList<String> list = new ArrayList<>();
AtomicBoolean run = new AtomicBoolean(true);
InputStream inputStream = socket.getInputStream();
try (InputStream inputStream = socket.getInputStream()) {
byte[] clearBuf = new byte[inputStream.available()];
inputStream.read(clearBuf);
int errCount = 0;
@ -92,6 +92,10 @@ public class XiShuiScale extends AbsScale {
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
list.add(weight);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
String max = "0";
if (list.size() > 0) {

View File

@ -55,7 +55,7 @@ public class YaoHuaScale extends AbsScale {
ArrayList<String> list = new ArrayList<>();
AtomicBoolean run = new AtomicBoolean(true);
InputStream inputStream = socket.getInputStream();
try (InputStream inputStream = socket.getInputStream()) {
byte[] clearBuf = new byte[inputStream.available()];
inputStream.read(clearBuf);
int errCount = 0;
@ -94,6 +94,9 @@ public class YaoHuaScale extends AbsScale {
// System.out.println("读一次耗时:" + (System.currentTimeMillis() - st) + ", " + Double.parseDouble(flip(weight)));
list.add(weight);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
}
String max = "0";
if (list.size() > 0) {

View File

@ -64,10 +64,14 @@ import com.cowr.model._MappingKit;
import com.cowr.ssjygl.CacheData;
import com.cowr.ssjygl.actioncmdlog.ActionCmdLogController;
import com.cowr.ssjygl.cctv.CctvController;
import com.cowr.local.ssjygl.prepay.PrepayController;
import com.cowr.local.ssjygl.overall.OverallController;
import com.cowr.ssjygl.modifylog.ModifyLogController;
import com.cowr.ssjygl.stat.invoice.InvoiceUseController;
import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
import com.cowr.local.ssjygl.stat.sale.OrderStatController;
import com.cowr.ssjygl.stat.transfer.OrderTransferStatController;
import com.cowr.local.ssjygl.system.sysuser.SysuserController;
import com.cowr.ssjygl.transportcompany.TransportCompanyService;
import com.cowr.ssjygl.transprice.TransPriceService;
import com.jfinal.config.*;
@ -84,6 +88,10 @@ import com.jfinal.plugin.druid.DruidPlugin;
import com.jfinal.plugin.druid.DruidStatViewHandler;
import com.jfinal.plugin.redis.RedisPlugin;
import com.jfinal.template.Engine;
import com.cowr.common.Interceptor.ReporterInterceptor;
import com.cowr.common.handler.GlobalHandler;
import com.cowr.common.view.JsonRenderFactory;
import com.cowr.model._MappingKit;
import java.io.File;
import java.sql.Connection;

View File

@ -17,6 +17,11 @@ import com.cowr.model.*;
import com.cowr.ssjygl.invoice.log.InvoiceLogService;
import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService;
import com.cowr.ssjygl.order.ordercluster.OrderclusterService;
import com.cowr.ssjygl.prepay.refunddetail.RefundDetailService;
import com.cowr.ssjygl.supermarket.product.SupermarketProductService;
import com.cowr.local.ssjygl.synctask.SyncTaskService;
import com.cowr.model.*;
import com.cowr.local.ssjygl.modifylog.ModifyLogSyncService;
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
import com.cowr.ssjygl.supermarket.product.SupermarketProductService;
import com.cowr.ssjygl.ticket.log.TicketLogService;
@ -377,9 +382,9 @@ public class OrderTempSyncService {
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
}
InvoiceLog invoiceLog = InvoiceLogService.me.checkInvalidInvoiceLog(invoice_number, invoice_code);
InvoiceLog invoiceLog = InvoiceLogService.me.checkUseInvoiceLog(invoice_number, invoice_code);
if (invoiceLog != null) {
return Result.failedstr("发票 %s|%s 已作废", invoice_number, invoice_code);
return Result.failedstr("发票 %s|%s 已使用!重新打开结算界面,获取新的发票信息。", invoice_number, invoice_code);
}
order.setInvoiceCode(invoice_code);
@ -719,13 +724,15 @@ public class OrderTempSyncService {
return Result.failed("不是预付费客户");
}
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(customer.getId());
if (prepayCustomer == null) {
return Result.failed("没有找到客户预付费信息");
}
if (prepayCustomer.getSurplus() == null || prepayCustomer.getSurplus().compareTo(min) == 0) {
//账户可用余额
BigDecimal availableBalance = RefundDetailService.me.getAvailableBalance(prepayCustomer.getCustomerId(), prepayCustomer.getSurplus());
if (availableBalance == null || availableBalance.compareTo(min) <= 0) {
return Result.failed("客户余额不足");
}
@ -740,9 +747,9 @@ public class OrderTempSyncService {
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
}
InvoiceLog invoiceLog = InvoiceLogService.me.checkInvalidInvoiceLog(invoice_number, invoice_code);
InvoiceLog invoiceLog = InvoiceLogService.me.checkUseInvoiceLog(invoice_number, invoice_code);
if (invoiceLog != null) {
return Result.failedstr("发票 %s|%s 已作废", invoice_number, invoice_code);
return Result.failedstr("发票 %s|%s 已使用!重新打开结算界面,获取新的发票信息。", invoice_number, invoice_code);
}
receive.setSurplus(receive.getSurplus() - 1);
@ -1045,9 +1052,9 @@ public class OrderTempSyncService {
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
}
InvoiceLog invoiceLog = InvoiceLogService.me.checkInvalidInvoiceLog(invoice_number, invoice_code);
InvoiceLog invoiceLog = InvoiceLogService.me.checkUseInvoiceLog(invoice_number, invoice_code);
if (invoiceLog != null) {
return Result.failedstr("发票 %s|%s 已作废", invoice_number, invoice_code);
return Result.failedstr("发票 %s|%s 已使用!重新打开结算界面,获取新的发票信息。", invoice_number, invoice_code);
}
order.setInvoiceCode(invoice_code);

View File

@ -291,7 +291,7 @@ public class SyncTaskService {
}
}
if (!saveauthlics.isEmpty() && !deleteauthlics.isEmpty()) {
if (!saveauthlics.isEmpty() || !deleteauthlics.isEmpty()) {
return recvAuthLicense(saveauthlics, deleteauthlics);
}

View File

@ -9,14 +9,13 @@ import com.cowr.common.view.Result;
import com.cowr.local.ssjygl.devicectrl.common.Const;
import com.cowr.local.ssjygl.main.CliCacheData;
import com.cowr.local.ssjygl.main.Config;
import com.cowr.local.ssjygl.order.LocalOrderService;
import com.cowr.local.ssjygl.modifylog.ModifyLogSyncService;
import com.cowr.local.ssjygl.ossfilelog.OssfileLogService;
import com.cowr.local.ssjygl.synctask.SyncTaskService;
import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.model.*;
import com.cowr.ssjygl.CacheData;
import com.cowr.ssjygl.blacklist.BlacklistService;
import com.cowr.local.ssjygl.modifylog.ModifyLogSyncService;
import com.cowr.ssjygl.order.OrderService;
import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService;
import com.cowr.ssjygl.transport.TransportService;
@ -30,7 +29,7 @@ import net.coobird.thumbnailator.Thumbnails;
import java.io.File;
import java.math.BigDecimal;
import java.util.*;
import java.util.Date;
/**
* MySQL
@ -361,6 +360,16 @@ public class TransportSyncService {
Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", result.getLicense() + " 未找到入场记录!"));
return result;
}
Date intime = transport.getInTime();
// 水利站是同进同出,进场时间不足 1 分钟,不识别抬杆
if (supermarket_id == 9 && (intime != null) && ((System.currentTimeMillis() - intime.getTime()) < (60 * 1000))) {
log.error("车辆【" + result.getLicense() + "】入场不到 1 分钟,可能是识别了车尾!");
Config.socketio.pubMessage(new Record().set("truck_license", result.getLicense()).set("msg", result.getLicense() + " 入场不到 1 分钟,可能是识别了车尾!"));
return result;
}
File uploadfile = null;
if (file != null) {
String fileuuid = StrKit.getRandomUUID();