From 9cfdbf85cfa244f92dae8958835b7f98b0241cc9 Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Mon, 12 Oct 2020 14:51:50 +0800 Subject: [PATCH] . --- .../receive/InvoiceReceiveService.java | 6 ++++++ .../order/ordertemp/OrderTempSyncService.java | 10 +++++----- .../service/ssjygl/cache/CacheController.java | 11 ++++++++++- .../invoice/log/InvoiceLogSyncService.java | 19 ++++++++++++++++--- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveService.java index b2d7ef3..ae388e5 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/invoice/receive/InvoiceReceiveService.java @@ -48,6 +48,12 @@ public class InvoiceReceiveService extends BaseService { return receive; } + /** + * 最早的领用记录 + * @param supermarket_id + * @param invoice_number + * @return + */ public InvoiceReceive foremostReceive(int supermarket_id, String invoice_number) { String sql = "select * from invoice_receive t\n" + " where t.supermarket_id = ? \n" + diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java index ff00171..184a8f5 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempSyncService.java @@ -259,6 +259,11 @@ public class OrderTempSyncService { return Result.failedstr("毛重 %.2f 吨,不能超过 %s 吨", transport.getSecondWeight(), Config.configprop.getInt("weigh.max")); } + InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(transport.getSupermarketId(), invoice_number, invoice_code); + if (receive == null) { + return Result.failed("没有有效的发票领用记录,或者发票已经被使用"); + } + BigDecimal net_weight = transport.getSecondWeight().subtract(transport.getFirstWeight()); // 销售的用第二次减第一次 OrderclusterTruck ot = OrderclusterTruck.dao.findFirst("select * from ordercluster_truck t \n" + @@ -291,11 +296,6 @@ public class OrderTempSyncService { return Result.failedstr("净重 %.2f 吨,超过了剩余的 %.2f 余量", net_weight, ordercluster.getTotalWeight().subtract(overweight)); } - InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(transport.getSupermarketId(), invoice_number, invoice_code); - if (receive == null) { - return Result.failed("没有有效的发票领用记录,或者发票已经被使用"); - } - BigDecimal up = SupermarketProductService.me.getUnitPrice(transport.getSupermarketId(), ordercluster.getProductId()); if (up == null) { diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/cache/CacheController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/cache/CacheController.java index 95f7d3a..27c3fdb 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/cache/CacheController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/cache/CacheController.java @@ -1,5 +1,6 @@ package com.cowr.service.ssjygl.cache; +import com.cowr.common.utils.DateTimeUtil; import com.cowr.common.view.Result; import com.cowr.service.ssjygl.main.AuthInterceptor; import com.cowr.service.ssjygl.main.SvrCacheData; @@ -8,6 +9,10 @@ import com.cowr.ssjygl.transportcompany.TransportCompanyService; import com.cowr.ssjygl.transprice.TransPriceService; import com.jfinal.aop.Clear; import com.jfinal.core.Controller; +import com.jfinal.plugin.activerecord.Record; + +import java.util.Date; +import java.util.Map; @Clear(AuthInterceptor.class) public class CacheController extends Controller { @@ -26,6 +31,10 @@ public class CacheController extends Controller { } public void last(){ - renderJson(SvrCacheData.SUP_HEARTBEAT); + Record out = new Record(); + for(Map.Entry entry : SvrCacheData.SUP_HEARTBEAT.entrySet()){ + out.set(String.valueOf(entry.getKey()), DateTimeUtil.sdfhms.get().format(new Date(entry.getValue()))); + } + renderJson(out); } } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java index c2910cd..7297446 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/invoice/log/InvoiceLogSyncService.java @@ -172,6 +172,8 @@ public class InvoiceLogSyncService extends BaseSyncService { invoiceLog.setCode(code); invoiceLog.setInvoiceNumber(invoice_number); + SyncTask synctask = new SyncTask(); + InvoiceLog finalInvoiceLog = invoiceLog; boolean ret = Db.tx(new IAtom() { @Override @@ -183,7 +185,6 @@ public class InvoiceLogSyncService extends BaseSyncService { return false; } - SyncTask synctask = new SyncTask(); synctask.addSaveData(finalInvoiceLog); receive.setSurplus(receive.getSurplus() - 1); @@ -207,6 +208,11 @@ public class InvoiceLogSyncService extends BaseSyncService { } }); + // 普票作废理解同步到砂站 + if(ret){ + SyncTaskService.me.send(synctask); + } + return ret ? Result.success(invoiceLog) : Result.failed(false, "处理失败"); } @@ -263,6 +269,8 @@ public class InvoiceLogSyncService extends BaseSyncService { invoiceLog.setInvalidUserName(sysuser.getName()); invoiceLog.setState(OrderStateEnum.INVALID.getStateid()); + SyncTask synctask = new SyncTask(); + boolean ret = Db.tx(new IAtom() { @Override public boolean run() { @@ -276,7 +284,6 @@ public class InvoiceLogSyncService extends BaseSyncService { return false; } - SyncTask synctask = new SyncTask(); synctask.addUpdateData(order); ret = invoiceLog.update(); @@ -287,7 +294,8 @@ public class InvoiceLogSyncService extends BaseSyncService { synctask.addUpdateData(invoiceLog); - return SyncTaskService.me.save(synctask, order.getInt("supermarket_id")) && ModifyLogService.me.save(invoiceLog, old, Enums.DataOpType.UPDATE.getId(), sysuser); + return SyncTaskService.me.save(synctask, order.getInt("supermarket_id")) + && ModifyLogService.me.save(invoiceLog, old, Enums.DataOpType.UPDATE.getId(), sysuser); } catch (Exception e) { log.error(e.getMessage(), e); } @@ -295,6 +303,11 @@ public class InvoiceLogSyncService extends BaseSyncService { } }); + // 普票作废理解同步到砂站 + if(ret){ + SyncTaskService.me.send(synctask); + } + return ret ? Result.success() : Result.failed("作废失败"); }