From 05277bb98c5cd271b9b0010126bf8f55ac519fff Mon Sep 17 00:00:00 2001 From: "lisai17@sina.com" Date: Sat, 12 Sep 2020 21:05:55 +0800 Subject: [PATCH] . --- .../com/cowr/model/base/BaseOrdercluster.java | 2 +- .../com/cowr/ssjygl/prepay/PrepayService.java | 100 +++++++++++------- .../local/ssjygl/prepay/PrepayController.java | 19 ++-- .../transport/TransportDeviceService.java | 2 +- .../transport/TransportQueryService.java | 1 + .../src/main/resources/dev/config.properties | 4 +- .../src/main/resources/dev/db.properties | 19 ++-- .../truck/OrderclusterTruckSyncService.java | 28 ++--- .../ssjygl/prepay/PrepayController.java | 31 +++--- 9 files changed, 116 insertions(+), 90 deletions(-) diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrdercluster.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrdercluster.java index 2a82b42..094ec56 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrdercluster.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrdercluster.java @@ -594,7 +594,7 @@ public abstract class BaseOrdercluster> extends Ba /** * name: customer_receiver_name - * type: VARCHAR(8) + * type: VARCHAR(128) * isNullable: YES * isPrimaryKey: NO * defaultValue: diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/PrepayService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/PrepayService.java index 14e7e80..7c53b89 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/PrepayService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/prepay/PrepayService.java @@ -148,6 +148,7 @@ public class PrepayService { out.set("prepay_surplus", prepayCustomer.getSurplus()); out.set("prepay_customer", customer); out.set("prepay_customer_info", prepayCustomer); + out.set("prepay_customer_invoice_type", customer.getInvoiceType()); // 客户发票类型 return out; } @@ -161,7 +162,58 @@ public class PrepayService { * @param etm * @return */ - public List consumption(Integer customer_id, Integer supermarket_id, String stm, String etm) { + public List consumption(Integer customer_id, Integer supermarket_id, String stm, String etm, String truck_license) { + String sale_sql = " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, t.customer_id, t.customer_name \n" + + " from order_sale t \n" + + " left join customer c on c.id = t.customer_id \n" + + " where t.state = ? \n" + + " and t.isprepaid = 1 \n" + + " and t.prepay_customer_id is not null \n" + + " and t.create_time >= ? \n" + + " and t.create_time <= ? \n"; + String temp_sql = " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, t.customer_id, t.customer_name \n" + + " from order_temp t \n" + + " where t.state = ? \n" + + " and t.isprepaid = 1 \n" + + " and t.prepay_customer_id is not null \n" + + " and t.create_time >= ? \n" + + " and t.create_time <= ? \n"; + + List saleList = new ArrayList<>(); + List tempList = new ArrayList<>(); + + saleList.add(OrderStateEnum.RECEIVED.getStateid()); + saleList.add(stm); + saleList.add(etm); + + tempList.add(OrderStateEnum.RECEIVED.getStateid()); + tempList.add(stm); + tempList.add(etm); + + if (supermarket_id != null && supermarket_id > 0) { + sale_sql += " and t.supermarket_id = ?"; + saleList.add(supermarket_id); + + temp_sql += " and t.supermarket_id = ?"; + tempList.add(supermarket_id); + } + + if (customer_id != null && customer_id > 0) { + sale_sql += " and t.customer_id = ?"; + saleList.add(customer_id); + + temp_sql += " and t.customer_id = ?"; + tempList.add(customer_id); + } + + if (StrKit.notBlank(truck_license)) { + sale_sql += " and t.truck_license like ?"; + saleList.add("%" + truck_license + "%"); + + temp_sql += " and t.truck_license like ?"; + tempList.add("%" + truck_license + "%"); + } + String sql = "select a.sn \n" + " ,p.order_sn \n" + " ,p.arrive_time \n" + @@ -174,55 +226,21 @@ public class PrepayService { " ,a.paid \n" + " ,a.customer_id \n" + " ,a.customer_name \n" + - " ,a.product_id \n" + - " ,a.product_name" + - " from ( \n" + - " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, c.id customer_id, c.name customer_name, t.product_id, t.product_name \n" + - " from order_sale t \n" + - " left join customer c on c.id = t.customer_id \n" + - " where t.state = ? \n" + - " and t.isprepaid = 1 \n" + - " and t.prepay_customer_id is not null \n" + - " and t.create_time >= ? \n" + - " and t.create_time <= ? \n" + - " union \n" + - " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, c.id customer_id, c.name customer_name, t.product_id, t.product_name \n" + - " from order_temp t \n" + - " left join customer c on c.id = t.customer_id \n" + - " where t.state = ? \n" + - " and t.isprepaid = 1 \n" + - " and t.prepay_customer_id is not null \n" + - " and t.create_time >= ? \n" + - " and t.create_time <= ? \n" + + " from ( \n" + sale_sql + + " union \n" + temp_sql + " ) a \n" + " left join supermarket s on s.id = a.supermarket_id \n" + " left join transport p on p.order_sn = a.sn " + " where 1 = 1 \n"; List paraList = new ArrayList<>(); - - paraList.add(OrderStateEnum.RECEIVED.getStateid()); - paraList.add(stm); - paraList.add(etm); - - paraList.add(OrderStateEnum.RECEIVED.getStateid()); - paraList.add(stm); - paraList.add(etm); - - if (supermarket_id != null && supermarket_id > 0) { - sql += " and a.supermarket_id = ?"; - paraList.add(supermarket_id); - } - - if (customer_id != null && customer_id > 0) { - sql += " and a.customer_id = ?"; - paraList.add(customer_id); - } + paraList.addAll(saleList); + paraList.addAll(tempList); return Db.find(sql, paraList.toArray()); } - public Workbook consumptionExport(Integer customer_id, Integer supermarket_id, String stm, String etm) { + public Workbook consumptionExport(Integer customer_id, Integer supermarket_id, String stm, String etm, String truck_license) { Customer customer = Customer.dao.findById(customer_id); String cname = ""; @@ -230,7 +248,7 @@ public class PrepayService { cname = customer.getName(); } - List list = consumption(customer_id, supermarket_id, stm, etm); + List list = consumption(customer_id, supermarket_id, stm, etm, truck_license); list.sort(new Comparator() { public int compare(Record o1, Record o2) { diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/prepay/PrepayController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/prepay/PrepayController.java index 5cc9934..f52ff0c 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/prepay/PrepayController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/prepay/PrepayController.java @@ -12,13 +12,13 @@ import org.apache.poi.ss.usermodel.Workbook; public class PrepayController extends BaseController { public void find() { - String name = get("name"); - Integer customer_id = getInt("customer_id"); - String stm = get("stm"); - String etm = get("etm"); - Double start = getParaToDouble("start"); - Double end = getParaToDouble("end"); - PageParam pp = getBean(PageParam.class, "", true); + String name = get("name"); + Integer customer_id = getInt("customer_id"); + String stm = get("stm"); + String etm = get("etm"); + Double start = getParaToDouble("start"); + Double end = getParaToDouble("end"); + PageParam pp = getBean(PageParam.class, "", true); renderJson(Result.object(PrepayService.me.find(pp, name, customer_id, stm, etm, start, end))); } @@ -29,11 +29,12 @@ public class PrepayController extends BaseController { Integer supermarket_id = getInt("supermarket_id"); String stm = get("stm"); String etm = get("etm"); + String truck_license = get("truck_license"); if (export == 0) { - renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm))); + renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm, truck_license))); } else { - Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm); + Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm, truck_license); render(new ExcelRender("消费记录_" + System.currentTimeMillis() + ".xlsx", wb)); } } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportDeviceService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportDeviceService.java index a96583a..65f2cc0 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportDeviceService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportDeviceService.java @@ -72,7 +72,7 @@ public class TransportDeviceService { */ public void addLicenseHistory(Record truck, String which, int state) { try { - if (truck == null) { + if (truck == null || StrKit.isBlank(truck.get("license"))) { return; } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportQueryService.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportQueryService.java index 38e0530..83d48e5 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportQueryService.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/transport/TransportQueryService.java @@ -109,6 +109,7 @@ public class TransportQueryService { Supermarket supermarket = Supermarket.dao.findById(transport.getSupermarketId()); if (supermarket != null) { transobj.set("supermarket_name", supermarket.getName()); + transobj.set("supermarket_invoice_type", supermarket.getInvoiceType()); } if(transport.getType() != null && transport.getType() == OrderTypeEnum.PURCHASE.getTypeid()){ diff --git a/ssjygl-xsx-local/src/main/resources/dev/config.properties b/ssjygl-xsx-local/src/main/resources/dev/config.properties index 3183363..5c6abec 100644 --- a/ssjygl-xsx-local/src/main/resources/dev/config.properties +++ b/ssjygl-xsx-local/src/main/resources/dev/config.properties @@ -2,8 +2,8 @@ devMode=true #本地服务 和 云端服务 socket 通信 socketserver.enable=true -socketserver.host=47.112.109.118 -#socketserver.host=localhost +#socketserver.host=47.112.109.118 +socketserver.host=localhost socketserver.port=21002 #和 web 端的 socket.io 通信端口 diff --git a/ssjygl-xsx-local/src/main/resources/dev/db.properties b/ssjygl-xsx-local/src/main/resources/dev/db.properties index 77f7fae..6c99a5c 100644 --- a/ssjygl-xsx-local/src/main/resources/dev/db.properties +++ b/ssjygl-xsx-local/src/main/resources/dev/db.properties @@ -1,16 +1,17 @@ # mysql # GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.119' IDENTIFIED BY 'Local_1' WITH GRANT OPTION; -#jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true -#user=ssjy_xsx -#password=Ssjy_xs_890 +jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true +user=ssjy_xsx +password=Ssjy_xs_890 -jdbcUrl=jdbc:mysql://localhost:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true -user=root -password=Ssjy_xsx_890 +#jdbcUrl=jdbc:mysql://localhost:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true +#user=root +#password=Ssjy_xsx_890 # redis redis.basekey=ssjcgl_xsx_dev -redis.ip=127.0.0.1 +#redis.ip=127.0.0.1 +redis.ip=r-wz9168ab2f2f7ec4pd.redis.rds.aliyuncs.com redis.port=6379 -redis.pwd= -redis.db= \ No newline at end of file +redis.pwd=CoWR1111 +redis.db=13 \ No newline at end of file diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckSyncService.java index 783e70d..0986211 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckSyncService.java @@ -2,6 +2,7 @@ package com.cowr.service.ssjygl.order.ordercluster.truck; import com.cowr.common.enums.Enums; import com.cowr.common.enums.UserTypeEnum; +import com.cowr.common.utils.DateTimeUtil; import com.cowr.common.view.Result; import com.cowr.model.*; import com.cowr.service.ssjygl.base.BaseSyncService; @@ -41,7 +42,7 @@ public class OrderclusterTruckSyncService extends BaseSyncService { List chk = new ArrayList<>(); String[] truckarr = trucks.split(","); - List ts = new ArrayList<>(); + List ts = new ArrayList<>(); List tsql = new ArrayList<>(); // 检查提交上来的车辆字符串是否用重复的 @@ -63,30 +64,33 @@ public class OrderclusterTruckSyncService extends BaseSyncService { " and truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray()); if (list != null && !list.isEmpty()) { - ts = new ArrayList<>(); + List retts = new ArrayList<>(); for (Blacklist bl : list) { - ts.add(bl.getTruckLicense()); + retts.add(bl.getTruckLicense()); } - return Result.failed(StrKit.join(ts, ",") + " 车牌号在黑名单中"); + return Result.failed(StrKit.join(retts, ",") + " 车牌号在黑名单中"); } - // 查询是否分配给其他集团订单 - ts.add(0, ordercluster_id + ""); // 加到查询参数里面 + // 查询是否在同一天分配给其他集团订单 + ts.add(0, ordercluster.getCutoffTime()); // 加到查询参数里面 + ts.add(0, ordercluster_id); // 加到查询参数里面 List chkduk = Db.find( - "select * from ordercluster_truck \n" + - " where ordercluster_id <> ? \n" + - " and truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray()); + "select * from ordercluster_truck t\n" + + " left join ordercluster o on o.id = t.ordercluster_id\n" + + " where t.ordercluster_id <> ? \n" + + " and o.cutoff_time = ? \n" + + " and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray()); if (chkduk != null && !chkduk.isEmpty()) { - ts = new ArrayList<>(); + List retts = new ArrayList<>(); for (Record bl : chkduk) { - ts.add(bl.get("truck_license")); + retts.add(bl.get("truck_license")); } - return Result.failed(StrKit.join(ts, ",") + " 车牌号已经分配给其他客户"); + return Result.failedstr( "%s 已在[%s]分配给其他客户", StrKit.join(retts, ","), DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime())); } // 查询已有的集团订单 diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/prepay/PrepayController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/prepay/PrepayController.java index 9d28bf0..15c8731 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/prepay/PrepayController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/prepay/PrepayController.java @@ -15,8 +15,8 @@ import org.apache.poi.ss.usermodel.Workbook; public class PrepayController extends BaseController { public void find() { - String name = get("name"); - Integer customer_id = getInt("customer_id"); + String name = get("name"); + Integer customer_id = getInt("customer_id"); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); @@ -28,18 +28,18 @@ public class PrepayController extends BaseController { customer_id = tokenuser.getEntityId(); } - String stm = get("stm"); - String etm = get("etm"); - Double start = getParaToDouble("start"); - Double end = getParaToDouble("end"); - PageParam pp = getBean(PageParam.class, "", true); + String stm = get("stm"); + String etm = get("etm"); + Double start = getParaToDouble("start"); + Double end = getParaToDouble("end"); + PageParam pp = getBean(PageParam.class, "", true); renderJson(Result.object(PrepayService.me.find(pp, name, customer_id, stm, etm, start, end))); } @Before(StartAndEndTimeValidator.class) public void consumption() { - int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 - Integer customer_id = getInt("customer_id"); + int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出 + Integer customer_id = getInt("customer_id"); Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token")); @@ -54,11 +54,12 @@ public class PrepayController extends BaseController { Integer supermarket_id = getInt("supermarket_id"); String stm = get("stm"); String etm = get("etm"); + String truck_license = get("truck_license"); if (export == 0) { - renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm))); + renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm, truck_license))); } else { - Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm); + Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm, truck_license); render(new ExcelRender("消费记录_" + System.currentTimeMillis() + ".xlsx", wb)); } } @@ -78,8 +79,8 @@ public class PrepayController extends BaseController { customer_id = tokenuser.getEntityId(); } - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm"); + String etm = get("etm"); if (export == 0) { renderJson(Result.success(PrepayService.me.flow(customer_id, stm, etm))); @@ -107,8 +108,8 @@ public class PrepayController extends BaseController { customer_id = tokenuser.getEntityId(); } - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm"); + String etm = get("etm"); if (export == 0) { renderJson(Result.object(PrepayDetailService.me.list(customer_id, stm, etm)));