From e433f39235fba1297f0f7d0d22b1f5b2efd1032b Mon Sep 17 00:00:00 2001 From: xjm Date: Mon, 4 Dec 2023 16:51:03 +0800 Subject: [PATCH] =?UTF-8?q?=E9=A6=96=E9=A1=B5=E6=9F=A5=E8=AF=A2=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E4=BC=98=E5=8C=96,=20=E6=96=B0=E5=A2=9E=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E5=8F=96=E6=B6=88=E6=97=A5=E7=BB=9F=E8=AE=A1=E6=9B=B4?= =?UTF-8?q?=E6=96=B0,=E7=BB=9F=E8=AE=A1=E5=8E=86=E5=8F=B2=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E8=87=AA=E6=B5=8B=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/cowr/common/utils/DateTimeUtil.java | 15 ++ .../main/java/com/cowr/model/OrderEnd.java | 15 ++ .../main/java/com/cowr/model/_MappingKit.java | 1 + .../com/cowr/model/base/BaseOrderEnd.java | 203 ++++++++++++++++++ .../ordercluster/OrderclusterService.java | 3 +- .../order/orderend/OrderEndService.java | 190 ++++++++++++++++ .../order/ordertemp/OrderTempService.java | 49 +++++ .../cowr/ssjygl/overall/OverallService.java | 69 ++++-- .../com/cowr/ssjygl/prepay/PrepayService.java | 6 +- .../stat/customer/CustomerStatService.java | 49 ++++- .../ssjygl/stat/sale/OrderStatService.java | 171 +++++++++++---- .../src/main/java/generator/Main.java | 125 +++++------ .../invoice/log/InvoiceLogController.java | 7 +- .../truck/OrderclusterTruckController.java | 9 +- .../order/ordertemp/OrderTempController.java | 7 +- .../presellorder/PresellOrderController.java | 7 +- .../ticket/log/TicketLogController.java | 7 +- .../cowr/service/ssjygl/jobs/OrderEndJob.java | 23 ++ .../com/cowr/service/ssjygl/main/Config.java | 9 +- .../OrderInvalidVerifyController.java | 7 +- .../ordercluster/OrderclusterController.java | 13 +- .../truck/OrderclusterTruckController.java | 7 +- .../order/ordertemp/OrderTempController.java | 7 +- .../order/ordertemp/OrderTempSyncService.java | 5 + .../ssjygl/overall/OverallController.java | 7 +- .../presellorder/PresellOrderController.java | 7 +- .../system/sysuser/SysuserController.java | 4 +- .../src/main/resources/job.properties | 7 +- 28 files changed, 870 insertions(+), 159 deletions(-) create mode 100644 ssjygl-xsx-common/src/main/java/com/cowr/model/OrderEnd.java create mode 100644 ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderEnd.java create mode 100644 ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/orderend/OrderEndService.java create mode 100644 ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/OrderEndJob.java diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/common/utils/DateTimeUtil.java b/ssjygl-xsx-common/src/main/java/com/cowr/common/utils/DateTimeUtil.java index 432abde..15f82fd 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/common/utils/DateTimeUtil.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/common/utils/DateTimeUtil.java @@ -4,10 +4,17 @@ import com.jfinal.kit.StrKit; import java.text.ParseException; import java.text.SimpleDateFormat; +import java.time.LocalDate; import java.util.Calendar; import java.util.Date; public class DateTimeUtil { + public static final int TM_TIME = 31; + public static final int MONTH_INDEX = 12; + public static final String + STM_SUFFIX = " 00:00:00", + ETM_SUFFIX = " 23:59:59" + ; public static final String ymdhms = "yyyy-MM-dd HH:mm:ss"; public static final ThreadLocal yMd = new ThreadLocal() { @@ -173,4 +180,12 @@ public class DateTimeUtil { return new Date().getTime() >= stm.getTime() && new Date().getTime() <= etm.getTime(); } + + public static String dateSubDay(LocalDate now,int subDay) { + return now.minusDays(subDay).toString(); + } + + public static LocalDate now(){ + return LocalDate.now(); + } } diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/OrderEnd.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/OrderEnd.java new file mode 100644 index 0000000..5cb0f82 --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/OrderEnd.java @@ -0,0 +1,15 @@ +package com.cowr.model; + +import com.cowr.model.base.BaseOrderEnd; + +/** + * Generated by COWR Wed Nov 29 10:33:21 CST 2023 + * TableName: order_end + * Remarks: 订单相关 - 外销单日统计 + + * PrimaryKey: id + */ +@SuppressWarnings("serial") +public class OrderEnd extends BaseOrderEnd { + public static final OrderEnd dao = new OrderEnd().dao(); +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/_MappingKit.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/_MappingKit.java index d4ecf50..d5a21cb 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/model/_MappingKit.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/_MappingKit.java @@ -57,6 +57,7 @@ public class _MappingKit { arp.addMapping("sync_task", "id", SyncTask.class); arp.addMapping("ossfile_log", "id", OssfileLog.class); arp.addMapping("sms_log", "id", SmsLog.class); + arp.addMapping("order_end", "id", OrderEnd.class); arp.addMapping("action_cmd_log", "id", ActionCmdLog.class); arp.addMapping("modify_log", "id", ModifyLog.class); arp.addMapping("sysuser", "id", Sysuser.class); diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderEnd.java b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderEnd.java new file mode 100644 index 0000000..244d5ff --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/model/base/BaseOrderEnd.java @@ -0,0 +1,203 @@ +package com.cowr.model.base; + +import com.cowr.common.base.BaseModel; +import com.jfinal.plugin.activerecord.IBean; +import com.alibaba.fastjson.annotation.JSONField; + +/** + * Generated by COWR Wed Nov 29 10:33:21 CST 2023 + * TableName: order_end + * Remarks: 订单相关 - 外销单日统计 + + * PrimaryKey: id + */ +@SuppressWarnings("serial") +public abstract class BaseOrderEnd> extends BaseModel implements IBean { + + public static final String tablename = "order_end"; + + @JSONField(serialize=false) + public String getTablename(){ + return tablename; + } + + /** + * name: id + * type: varchar(20) + * isNullable: NO + * isPrimaryKey: YES + * defaultValue: + * @param id 主键id + + */ + @JSONField(name="id") + public void setId(String id) { + set("id", id); + } + + + /** + * @return id 主键id + + */ + @JSONField(name="id") + public String getId() { + return get("id"); + } + + /** + * name: CUSTOMER_ID + * type: INT(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: + * @param customerId 客户编号 + */ + @JSONField(name="customer_id") + public void setCustomerId(Integer customerId) { + set("customer_id", customerId); + } + + + /** + * @return customer_id 客户编号 + */ + @JSONField(name="customer_id") + public Integer getCustomerId() { + return getInt("customer_id"); + } + + /** + * name: date + * type: DATE(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: + * @param date 日期 + */ + @JSONField(name="date") + public void setDate(java.util.Date date) { + set("date", date); + } + + + /** + * @return date 日期 + */ + @JSONField(name="date") + public java.util.Date getDate() { + return get("date"); + } + + /** + * name: SUPERMARKET_ID + * type: INT(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: + * @param supermarketId 超市id + */ + @JSONField(name="supermarket_id") + public void setSupermarketId(Integer supermarketId) { + set("supermarket_id", supermarketId); + } + + + /** + * @return supermarket_id 超市id + */ + @JSONField(name="supermarket_id") + public Integer getSupermarketId() { + return getInt("supermarket_id"); + } + + /** + * name: WEIGHT + * type: DECIMAL(12,4) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: + * @param weight 购买重量 + */ + @JSONField(name="weight") + public void setWeight(java.math.BigDecimal weight) { + set("weight", weight); + } + + + /** + * @return weight 购买重量 + */ + @JSONField(name="weight") + public java.math.BigDecimal getWeight() { + return get("weight"); + } + + /** + * name: TOTAL_PRICE + * type: DECIMAL(12,2) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: + * @param totalPrice 总价 + */ + @JSONField(name="total_price") + public void setTotalPrice(java.math.BigDecimal totalPrice) { + set("total_price", totalPrice); + } + + + /** + * @return total_price 总价 + */ + @JSONField(name="total_price") + public java.math.BigDecimal getTotalPrice() { + return get("total_price"); + } + + /** + * name: SALE_TYPE + * type: INT(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: + * @param saleType 0:正常配额订单,1:预售配额订单 + */ + @JSONField(name="sale_type") + public void setSaleType(Integer saleType) { + set("sale_type", saleType); + } + + + /** + * @return sale_type 0:正常配额订单,1:预售配额订单 + */ + @JSONField(name="sale_type") + public Integer getSaleType() { + return getInt("sale_type"); + } + + /** + * name: COUNT + * type: INT(10) + * isNullable: NO + * isPrimaryKey: NO + * defaultValue: + * @param count 订单总数 + */ + @JSONField(name="count") + public void setCount(Integer count) { + set("count", count); + } + + + /** + * @return count 订单总数 + */ + @JSONField(name="count") + public Integer getCount() { + return getInt("count"); + } + + +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java index d664d30..8e5c19b 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordercluster/OrderclusterService.java @@ -149,7 +149,8 @@ public class OrderclusterService extends BaseService { String fromsql = "from ordercluster t \n" + " left join supermarket s on s.id = t.supermarket_id \n " + " left join customer c on c.id = t.customer_id \n " + - " where t.customer_id is not null \n "; + " where t.customer_id > -1 " ; +// "is not null \n "; List paraList = new ArrayList<>(); if (supermarket_id != null) { diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/orderend/OrderEndService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/orderend/OrderEndService.java new file mode 100644 index 0000000..6ac48f0 --- /dev/null +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/orderend/OrderEndService.java @@ -0,0 +1,190 @@ +package com.cowr.ssjygl.order.orderend; + +import com.alibaba.fastjson.JSON; +import com.aliyuncs.utils.StringUtils; +import com.cowr.common.Const; +import com.cowr.common.base.BaseService; +import com.cowr.common.utils.DateTimeUtil; +import com.cowr.common.view.PageParam; +import com.cowr.model.OrderEnd; +import com.cowr.ssjygl.order.ordertemp.OrderTempService; +import com.jfinal.kit.StrKit; +import com.jfinal.log.Log; +import com.jfinal.plugin.activerecord.Db; +import com.jfinal.plugin.activerecord.Page; +import com.jfinal.plugin.activerecord.Record; +import org.apache.commons.collections4.CollectionUtils; + +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static java.util.stream.Collectors.toList; + +/** + * Generated by COWR Wed Nov 29 10:33:22 CST 2023 + * TableName: order_end + * Remarks: 订单相关 - 外销单日统计 + + * PrimaryKey: id + */ +public class OrderEndService extends BaseService { + private static final Log log = Log.getLog(OrderEndService.class); + + public static final OrderEndService me = new OrderEndService(); + + public Page find(PageParam pp) { + String selectsql = "select * "; + String fromsql = "from order_end t where 1=1 "; + List paraList = new ArrayList<>(); + + String totalRowSql = "select count(*) " + fromsql; + String findSql = selectsql + fromsql; + + // 前端传了排序字段,并且排序字段存在相关表中 + if (StrKit.notBlank(pp.getSort_field()) && OrderEnd.dao.hasColunm(pp.getSort_field())) { + findSql += " order by t." + pp.getSort_field() + " is null, t." + pp.getSort_field(); + + if (Const.ORDER_BY_ASC.equals(pp.getSort_order())) { + findSql += " " + Const.ORDER_BY_ASC; + } else { + findSql += " " + Const.ORDER_BY_DESC; + } + } + + return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray()); + } + + public List list() { + return OrderEnd.dao.find("select * from order_end"); + } + + + public List getOrderEndByTm(String tm) { + + String sql = "SELECT * FROM ORDER_END \n" + + "WHERE DATE = ? \n"; + + return OrderEnd.dao.find(sql,tm); + } + public void initialize(){ + + // 有数据无需全量同步 + Long count = Db.queryLong("select count(id) from order_end"); + if (count > 0) { + return; + } + + // 开始同步历史数据 + syncOrderTemp(null); + } + + public void syncOrderTemp(String tm){ + try { + processing(tm); + }catch (Exception e){ + log.error("同步数据异常 %s %s", e.getMessage(),e); + } + } + + public void processing(String tm){ + + + // 获取历史数据 + List tempList = OrderTempService.me.getOrderTempGroupBy(tm); + + if (CollectionUtils.isEmpty(tempList)){ + log.info("数据结果为空"); + return; + } + + List orderEnds = tempList.stream() + .map(data -> { + OrderEnd o = JSON.toJavaObject(JSON.parseObject(data.toJson()), OrderEnd.class); + o.setId(o.getCustomerId() + "_" + DateTimeUtil.sdf.get().format(o.getDate("date")) + "_" + o.getSupermarketId() + "_" + o.getSaleType()); + return o; + }) + .collect(toList()); + + List updates = new ArrayList<>(); + List deletes = new ArrayList<>(); + + // 如果当前时间类型已存在 就更新 + if (!StringUtils.isEmpty(tm)){ + List lists = getOrderEndByTm(tm); + + if (CollectionUtils.isNotEmpty(lists)){ + Map> map = lists.stream() + .collect(Collectors.groupingBy(OrderEnd::getId, toList())); +// .collect(Collectors.groupingBy(o -> o.getCustomerId() + "_" + o.get("date") + "_" + o.getSupermarketId() + "_" + o.getSaleType(), toList())); + + // 获取key + deletes.addAll(map.keySet()); + + // 删除key + deletes.removeAll(orderEnds.stream().map(OrderEnd::getId).collect(toList())); + + + orderEnds.removeIf(o -> { +// String key = o.getCustomerId() + "_" + DateTimeUtil.sdf.get().format(o.getDate("date")) + "_" + o.getSupermarketId() + "_" + o.getSaleType(); + String key = o.getId(); + + if (map.containsKey(key)) { + OrderEnd orderEnd = map.get(key).get(0); +// o.setId(orderEnd.getId()); + if (!o.equals(orderEnd)) { + updates.add(o); + } + return true; + } + return false; + }); + } + + + } + + if (CollectionUtils.isNotEmpty(orderEnds)){ + // 存库 + addOrderEnd(orderEnds); + } + + if (CollectionUtils.isNotEmpty(updates)){ + // 更新 + updateOrderEnd(updates); + } + + if (CollectionUtils.isNotEmpty(deletes)){ + // 更新 + deleteOrderEnd(deletes); + } + + } + + + private void addOrderEnd(List orderEnds){ + + boolean add = Db.tx(() -> orderEnds.size() == Db.batchSave(orderEnds,orderEnds.size()).length); + + log.info("添加数据结果: %s %s", add, orderEnds.size()); + } + + + private void updateOrderEnd(List orderEnds){ + + boolean add = Db.tx(() -> orderEnds.size() == Db.batchUpdate(orderEnds,orderEnds.size()).length); + + log.info("更新数据结果: %s %s", add, orderEnds.size()); + } + + private void deleteOrderEnd(List orderEnds){ + + + boolean add = Db.tx(() -> OrderEnd.dao.deleteByIds(orderEnds)); + + log.info("更新数据结果: %s %s", add, orderEnds.size()); + } + + +} diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java index e2c8470..be1f0a5 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/order/ordertemp/OrderTempService.java @@ -18,6 +18,9 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.util.ArrayList; import java.util.List; +import static com.cowr.common.utils.DateTimeUtil.ETM_SUFFIX; +import static com.cowr.common.utils.DateTimeUtil.STM_SUFFIX; + /** * Generated by COWR Fri Apr 17 16:59:39 CST 2020 * TableName: order_temp @@ -442,4 +445,50 @@ public class OrderTempService extends BaseService { return wb; } + + + /** + * 20s + * 查询销售订单分组数据 + * @tm %Y-%M-%D + * @return 销售订单数据 + */ + public List getOrderTempGroupBy(String tm) { + List paraList = new ArrayList<>(); + + String findSql = ""; + + if (tm != null) { + findSql = " AND CREATE_TIME BETWEEN ? AND ? \n"; + paraList.add(tm + STM_SUFFIX); + paraList.add(tm + ETM_SUFFIX); + } + + String sql = "SELECT\n" + + "CUSTOMER_ID,\n" + + "DATE_FORMAT( CREATE_TIME, '%Y-%m-%d' ) DATE,\n" + + "SUPERMARKET_ID,\n" + + "SUM( WEIGHT ) WEIGHT,\n" + + "SUM( TOTAL_PRICE ) TOTAL_PRICE,\n" + + "SALE_TYPE,\n" + + "COUNT( SN ) COUNT \n" + + "FROM\n" + + "ORDER_TEMP \n" + + "WHERE CUSTOMER_ID > -1\n" + + "AND SUPERMARKET_ID > -1\n" + + "AND WEIGHT > -1\n" + + "AND TOTAL_PRICE > -1 \n" + + "AND SALE_TYPE > -1\n" + + "AND STATE = 5 \n" + + findSql + + "GROUP BY\n" + + "CUSTOMER_ID,\n" + + "SUPERMARKET_ID,\n" + + "SALE_TYPE,\n" + + "DATE_FORMAT( CREATE_TIME, '%Y-%m-%d' )"; + + + + return Db.find(sql,paraList.toArray()); + } } diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java index 8b9e308..55d8885 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/overall/OverallService.java @@ -125,7 +125,7 @@ where t.state = 5 group by date */ - public Record stat(Integer supermarket_id) { + public Record stat(Integer supermarket_id) { Record out = new Record(); Date now = new Date(); Calendar c = Calendar.getInstance(); @@ -159,23 +159,56 @@ group by date " ifnull(sum(g.day_truck_cnt), 0) day_truck_cnt\n" + " from \n" + " (\n" + +// " select \n" + +// " ifnull(sum(t.weight), 0) total_weight,\n" + +// " ifnull(sum(t.total_price), 0) total_price,\n" + +// " ifnull(count(t.sn), 0) truck_cnt,\n" + +// " ifnull(sum(case when t.create_time >= ? and t.sale_type = 0 then t.weight end ), 0) year_total_weight,\n" + +// " ifnull(sum(case when t.create_time >= ? and t.sale_type = 0 then t.total_price end ), 0) year_total_price,\n" + +// " ifnull(sum(case when t.create_time >= ? and t.sale_type = 0 then 1 else 0 end ), 0) year_truck_cnt,\n" + +// " ifnull(sum(case when t.create_time >= ? then t.weight end ), 0) month_total_weight,\n" + +// " ifnull(sum(case when t.create_time >= ? then t.total_price end ), 0) month_total_price,\n" + +// " ifnull(sum(case when t.create_time >= ? then 1 else 0 end ), 0) month_truck_cnt,\n" + +// " ifnull(sum(case when t.create_time >= ? then t.weight end ), 0) day_total_weight,\n" + +// " ifnull(sum(case when t.create_time >= ? then t.total_price end ), 0) day_total_price,\n" + +// " ifnull(sum(case when t.create_time >= ? then 1 else 0 end ), 0) day_truck_cnt\n" + +// " from order_temp t\n" + +// " where t.state = 5\n" + +// " and t.sale_type = 0\n" + +// " and t.product_id != 4\n" + " select \n" + " ifnull(sum(t.weight), 0) total_weight,\n" + " ifnull(sum(t.total_price), 0) total_price,\n" + - " ifnull(count(t.sn), 0) truck_cnt,\n" + - " ifnull(sum(case when t.create_time >= ? and t.sale_type = 0 then t.weight end ), 0) year_total_weight,\n" + - " ifnull(sum(case when t.create_time >= ? and t.sale_type = 0 then t.total_price end ), 0) year_total_price,\n" + - " ifnull(sum(case when t.create_time >= ? and t.sale_type = 0 then 1 else 0 end ), 0) year_truck_cnt,\n" + - " ifnull(sum(case when t.create_time >= ? then t.weight end ), 0) month_total_weight,\n" + - " ifnull(sum(case when t.create_time >= ? then t.total_price end ), 0) month_total_price,\n" + - " ifnull(sum(case when t.create_time >= ? then 1 else 0 end ), 0) month_truck_cnt,\n" + - " ifnull(sum(case when t.create_time >= ? then t.weight end ), 0) day_total_weight,\n" + - " ifnull(sum(case when t.create_time >= ? then t.total_price end ), 0) day_total_price,\n" + - " ifnull(sum(case when t.create_time >= ? then 1 else 0 end ), 0) day_truck_cnt\n" + - " from order_temp t\n" + - " where t.state = 5\n" + -// " and t.sale_type = 0\n" + -// " and t.product_id != 4\n" + + " ifnull(count(t.count), 0) truck_cnt,\n" + + " ifnull(sum(case when t.date >= ? and t.sale_type = 0 then t.weight end ), 0) year_total_weight,\n" + + " ifnull(sum(case when t.date >= ? and t.sale_type = 0 then t.total_price end ), 0) year_total_price,\n" + + " ifnull(sum(case when t.date >= ? and t.sale_type = 0 then t.count else 0 end ), 0) year_truck_cnt,\n" + + " ifnull(sum(case when t.date >= ? then t.weight end ), 0) month_total_weight,\n" + + " ifnull(sum(case when t.date >= ? then t.total_price end ), 0) month_total_price,\n" + + " ifnull(sum(case when t.date >= ? then t.count else 0 end ), 0) month_truck_cnt,\n" + + " ifnull(sum(case when t.date >= ? then t.weight end ), 0) day_total_weight,\n" + + " ifnull(sum(case when t.date >= ? then t.total_price end ), 0) day_total_price,\n" + + " ifnull(sum(case when t.date >= ? then t.count else 0 end ), 0) day_truck_cnt\n" + + " from order_end t\n" + + " UNION\n" + + " SELECT\n" + + " ifnull( sum( t.weight ), 0 ) total_weight,\n" + + " ifnull( sum( t.total_price ), 0 ) total_price,\n" + + " ifnull( count( t.sn ), 0 ) truck_cnt,\n" + + " ifnull( sum( t.weight ), 0 ) year_total_weight,\n" + + " ifnull( sum( t.total_price ), 0 ) year_total_price,\n" + + " ifnull( count( t.sn ), 0 ) year_truck_cnt,\n" + + " ifnull( sum( t.weight ), 0 ) month_total_weight,\n" + + " ifnull( sum( t.total_price ), 0 ) month_total_price,\n" + + " ifnull( count( t.sn ), 0 ) month_truck_cnt,\n" + + " ifnull( sum( t.weight ), 0 ) day_total_weight,\n" + + " ifnull( sum( t.total_price ), 0 ) day_total_price,\n" + + " ifnull( count( t.sn ), 0 ) month_truck_cnt \n" + + " FROM\n" + + " order_temp t \n" + + " WHERE\n" + + " t.state = 5 \n" + + " AND t.create_time = ? " + " union\n" + " select \n" + " 0 total_weight,\n" + @@ -194,7 +227,7 @@ group by date " where p.del = 0\n" + " ) g"; - Record ocout = Db.findFirst(sql_ordercluster, year, year, year, month, month, month, day, day, day, year, month, day); + Record ocout = Db.findFirst(sql_ordercluster, year, year, year, month, month, month, day, day, day, day, year, month, day); out.set("ordercluster", ocout); return out; @@ -365,6 +398,8 @@ group by date " left join supermarket s on s.id = t.supermarket_id\n" + " where t.state = 5 \n" + " and t.supermarket_id = ? \n" + + " AND t.CREATE_TIME >= CURDATE() - INTERVAL 30 DAY\n" + + " AND t.CREATE_TIME < CURDATE()" + " order by t.create_time desc \n" + " limit 30", supermarket_id); } else { @@ -381,6 +416,8 @@ group by date " where a.id is not null\n" + " ) c on c.customer_id = t.customer_id\n" + " where t.state = 5 \n" + + " AND t.CREATE_TIME >= CURDATE() - INTERVAL 30 DAY\n" + + " AND t.CREATE_TIME < CURDATE()" + " order by t.create_time desc \n" + " limit 30"); } 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 a99b7d7..1416648 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 @@ -170,10 +170,10 @@ public class PrepayService { public List consumption(Integer customer_id, Integer customer_type_id, Integer supermarket_id, String stm, String etm, String truck_license, Integer invoice_type) { 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, t.create_time \n" + " from order_temp t \n" + - " left join customer c on c.id = t.customer_id \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.prepay_customer_id > -1 \n" + " and t.create_time >= ? \n" + " and t.create_time <= ? \n"; @@ -431,7 +431,7 @@ public class PrepayService { " left join customer c on t.customer_id = c.id \n" + " where t.isprepaid = 1 \n" + " and t.state = ? \n" + - " and t.prepay_customer_id is not null\n" + + " and t.prepay_customer_id > -1\n" + " and t.create_time >= ? \n" + " and t.create_time <= ? \n" + " ) a \n" + diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/customer/CustomerStatService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/customer/CustomerStatService.java index 4b9d72f..6769498 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/customer/CustomerStatService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/customer/CustomerStatService.java @@ -8,15 +8,20 @@ import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import java.time.LocalDate; import java.util.ArrayList; import java.util.List; +import static com.cowr.common.utils.DateTimeUtil.ETM_SUFFIX; +import static com.cowr.common.utils.DateTimeUtil.STM_SUFFIX; + public class CustomerStatService { private static Log log = Log.getLog(CustomerStatService.class); public static CustomerStatService me = new CustomerStatService(); /** * 检查每日账户余额 + * *****改成勾选客户查询***** * * @param tm * @param customer_id @@ -34,6 +39,8 @@ public class CustomerStatService { customerSql = " and t.customer_id = ? \n"; } + + tempSql = " select t.customer_id,\n" + " sum(ifnull((case when t.sale_type = 0 THEN t.total_price END), 0)) sh_total_price,\n" + " sum(ifnull((case when t.sale_type = 0 THEN t.weight END), 0)) sh_total_weight,\n" + @@ -41,12 +48,40 @@ public class CustomerStatService { " sum(ifnull((case when t.sale_type = 1 THEN t.total_price END), 0)) yh_total_price,\n" + " sum(ifnull((case when t.sale_type = 1 THEN t.weight END), 0)) yh_total_weight,\n" + " sum(ifnull((case when t.sale_type = 1 THEN 1 END), 0)) yh_total_cnt \n" + - " from order_temp t\n" + - " where t.customer_id is not null\n" + - " and t.create_time <= ? \n" + - " and t.state = 5\n" + + " from order_end t\n" + + " where t.customer_id > -1\n" + + " and t.date <= ? \n" + + customerSql + " group by t.customer_id\n"; + paraList.add(tm); + if (customer_id != null) { + paraList.add(customer_id); + } + + // 如果是当天的就加上销售订单数据 + if (LocalDate.now().toString().equals(tm)){ + tempSql += "UNION select t.customer_id,\n" + + " sum(ifnull((case when t.sale_type = 0 THEN t.total_price END), 0)) sh_total_price,\n" + + " sum(ifnull((case when t.sale_type = 0 THEN t.weight END), 0)) sh_total_weight,\n" + + " sum(ifnull((case when t.sale_type = 0 THEN 1 END), 0)) sh_total_cnt,\n" + + " sum(ifnull((case when t.sale_type = 1 THEN t.total_price END), 0)) yh_total_price,\n" + + " sum(ifnull((case when t.sale_type = 1 THEN t.weight END), 0)) yh_total_weight,\n" + + " sum(ifnull((case when t.sale_type = 1 THEN 1 END), 0)) yh_total_cnt \n" + + " from order_temp t\n" + + " where t.customer_id is not null\n" + + " and t.create_time >= ? \n" + + " and t.create_time <= ? \n" + + " and t.state = 5\n" + + customerSql + + " group by t.customer_id\n"; + paraList.add(tm + STM_SUFFIX); + paraList.add(tm + ETM_SUFFIX); + if (customer_id != null) { + paraList.add(customer_id); + } + + } sql = "select \n" + " t.customer_id id,\n" + @@ -92,8 +127,8 @@ public class CustomerStatService { if (customer_id != null) { paraList.add(querytm); - paraList.add(customer_id); - paraList.add(querytm); +// paraList.add(customer_id); +// paraList.add(querytm); paraList.add(querytm); paraList.add(customer_id); @@ -101,7 +136,7 @@ public class CustomerStatService { ret = Db.find(_sql, paraList.toArray()); } else { - paraList.add(querytm); +// paraList.add(querytm); paraList.add(querytm); paraList.add(querytm); diff --git a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java index 290831d..a283b9e 100644 --- a/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java +++ b/ssjygl-xsx-common/src/main/java/com/cowr/ssjygl/stat/sale/OrderStatService.java @@ -13,12 +13,20 @@ import com.jfinal.kit.StrKit; import com.jfinal.log.Log; import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Record; +import org.apache.commons.collections4.CollectionUtils; 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.time.LocalDate; import java.util.*; +import java.util.concurrent.CompletableFuture; +import java.util.concurrent.CopyOnWriteArrayList; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.Executors; + +import static com.cowr.common.utils.DateTimeUtil.*; public class OrderStatService { private static Log log = Log.getLog(OrderStatService.class); @@ -73,11 +81,13 @@ public class OrderStatService { " left join transport p on p.order_sn = t.sn \n" + " left join customer c on c.id = t.customer_id \n" + " where t.state = ? \n" + - " and t.create_time like ? \n"; +// " and t.create_time like ? \n"; + " and t.create_time between ? and ? \n"; List paraTempList = new ArrayList<>(); paraTempList.add(OrderStateEnum.RECEIVED.getStateid()); - paraTempList.add(tm + "%"); +// paraTempList.add(tm + "%"); + addTm(tm, paraTempList); if (sale_type != null && (sale_type == 0 || sale_type == 1)) { temp_sql += " and t.sale_type = ? \n"; @@ -346,7 +356,8 @@ public class OrderStatService { List paraList = new ArrayList<>(); paraList.add(OrderStateEnum.RECEIVED.getStateid()); - paraList.add(tm + "%"); +// paraList.add(tm + "%"); + addTm(tm, paraList); if (supermarket_id != null && supermarket_id > 0) { paramsSql += " and t.supermarket_id = ? \n"; @@ -369,7 +380,8 @@ public class OrderStatService { " select t.customer_id, t.customer_name , t.supermarket_id, t.paid, t.total_price,t.product_id, t.product_name, 3 type \n" + " from order_temp t\n" + " where t.state = ? \n" + - " and t.create_time like ?\n" + +// " and t.create_time like ?\n" + + " and t.create_time between ? and ? \n" + " ) t\n" + " left join supermarket s on s.id = t.supermarket_id\n" + " where 1 = 1 \n" + @@ -381,7 +393,8 @@ public class OrderStatService { " select t.customer_id, t.customer_name , t.supermarket_id, t.paid, t.total_price, 3 type \n" + " from order_temp t\n" + " where t.state = ? \n" + - " and t.create_time like ?\n" + +// " and t.create_time like ?\n" + + " and t.create_time between ? and ? \n" + " ) t\n" + " left join supermarket s on s.id = t.supermarket_id\n" + " where 1 = 1 \n" + @@ -525,7 +538,10 @@ public class OrderStatService { public List salestat(String tm, Integer sale_type) { String saleParams = ""; List params = new ArrayList<>(); - params.add(tm + "%"); + + addTm(tm, params); + +// params.add(tm + "%"); if (sale_type != null && (sale_type == 0 || sale_type == 1)) { saleParams += " and t.sale_type = ? \n"; params.add(sale_type); @@ -538,7 +554,8 @@ public class OrderStatService { " select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" + " from order_temp t\n" + " where t.state = 5 \n" + - " and t.create_time like ? \n" + +// " and t.create_time like ? \n" + + " and t.create_time between ? and ? \n" + saleParams + " ) t\n" + " group by t.id, t.product_id\n" + @@ -578,7 +595,9 @@ public class OrderStatService { String saleParams = ""; List paraList = new ArrayList<>(); paraList.add(OrderStateEnum.RECEIVED.getStateid()); - paraList.add(tm + "%"); + + addTm(tm, paraList); +// paraList.add(tm + "%"); if (sale_type != null && (sale_type == 0 || sale_type == 1)) { saleParams += " and t.sale_type = ? \n"; @@ -596,7 +615,8 @@ public class OrderStatService { " from order_temp t\n" + " left join customer c on c.id = t.customer_id \n" + " where t.state = ? \n" + - " and t.create_time like ? \n" + +// " and t.create_time like ? \n" + + " and t.create_time between ? and ? \n" + saleParams + " and t.invoice_type = ? \n"; if (customer_id != null) { @@ -621,7 +641,8 @@ public class OrderStatService { " from order_temp t\n" + " left join customer c on c.id = t.customer_id \n" + " where t.state = ? \n" + - " and t.create_time like ? \n" + +// " and t.create_time like ? \n" + + " and and t.create_time between ? and ? \n" + saleParams + " and t.invoice_type = ? \n"; if (customer_id != null) { @@ -647,7 +668,9 @@ public class OrderStatService { " from order_temp t\n" + " left join customer c on c.id = t.customer_id \n" + " where t.state = ? \n" + - " and t.create_time like ? \n" + saleParams + ""; +// " and t.create_time like ? \n" + + " and t.create_time between ? and ? \n" + + saleParams; if (customer_id != null) { sql += " and c.id = ? \n"; paraList.add(customer_id); @@ -669,7 +692,9 @@ public class OrderStatService { " from order_temp t\n" + " left join customer c on c.id = t.customer_id \n" + " where t.state = ? \n" + - " and t.create_time like ? \n" + saleParams + ""; +// " and t.create_time like ? \n" + + " and t.create_time between ? and ? \n" + + saleParams; if (customer_id != null) { sql += " and c.id = ? \n"; paraList.add(customer_id); @@ -1125,8 +1150,11 @@ public class OrderStatService { paraTemp.add(stm); paraTemp.add(etm); } else { - temp_sql += " and t.create_time like ? \n"; - paraTemp.add(tm + "%"); +// temp_sql += " and t.create_time like ? \n"; +// paraTemp.add(tm + "%"); + + temp_sql += " and t.create_time between ? and ? \n"; + addTm(tm, paraTemp); } if (product_id != null) { @@ -1163,9 +1191,11 @@ public class OrderStatService { paraTemp.add(stm); paraTemp.add(etm); } else { - temp_sql += " and t.create_time like ? \n"; - paraTemp.add(tm + "%"); - } +// temp_sql += " and t.create_time like ? \n"; +// paraTemp.add(tm + "%"); + + temp_sql += " and t.create_time between ? and ? \n"; + addTm(tm, paraTemp); } if (isprepaid != null) { temp_sql += " and t.isprepaid = ? \n"; @@ -1362,8 +1392,13 @@ public class OrderStatService { paraList.add(stm); paraList.add(etm); } else { - temp_sql += " and t.create_time like ? \n"; - paraList.add(tm + "%"); +// temp_sql += " and t.create_time like ? \n"; +// paraList.add(tm + "%"); + temp_sql += " and t.create_time between ? and ? \n"; + + addTm(tm,paraList); + + } if (isprepaid != null) { @@ -1516,21 +1551,21 @@ public class OrderStatService { "left join (\n" + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + " where t.state = 5\n" + - " and t.create_time like ? \n" + + " and t.create_time between ? and ? \n" + " group by t.supermarket_id,t.product_id,t.product_name\n" + - ") a on s.id = a.id order by s.id", year + "%"); + ") a on s.id = a.id order by s.id", year + "-01-01 00:00:00",year + "-12-31 23:59:59"); } else { list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" + "left join (\n" + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" + " where t.state = 5\n" + - " and t.create_time like ? \n" + + " and t.create_time between ? and ? \n" + " group by t.supermarket_id\n" + - ") a on s.id = a.id order by s.id", year + "%"); + ") a on s.id = a.id order by s.id", year + "-01-01 00:00:00",year + "-12-31 23:59:59"); } } else { - if (stat_product) { + if (stat_product) { // ***** 待优化 使用多线程,分砂场查询 ***** list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight,a.product_id,a.product_name from supermarket s\n" + "left join (\n" + " select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight,t.product_id,t.product_name from order_temp t\n" + @@ -1723,14 +1758,16 @@ public class OrderStatService { } if (StrKit.notBlank(year)) { if (stat_product) { - paraList.add(year + "%"); +// paraList.add(year + "%"); + addTm(year, paraList); String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus ,a.product_id,a.product_name from (\n" + " select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight,t.product_id,t.product_name, c.name customer_name \n" + " from order_temp t\n" + " left join customer c on c.id = t.customer_id\n" + " where t.state = 5\n" + saleParams + - " and t.create_time like ? \n"; +// " and t.create_time like ? \n"; + " and t.create_time between ? and ? \n"; if (customer_id != null) { sql += " and c.id = ? \n"; @@ -1749,14 +1786,16 @@ public class OrderStatService { " left join prepay_customer p on p.customer_id = a.id"; list = Db.find(sql, paraList.toArray()); } else { - paraList.add(year + "%"); +// paraList.add(year + "%"); + addTm(year, paraList); String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus from (\n" + " select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight, c.name customer_name \n" + " from order_temp t\n" + " left join customer c on c.id = t.customer_id\n" + " where t.state = 5\n" + saleParams + - " and t.create_time like ? \n"; +// " and t.create_time like ? \n"; + " and t.create_time between ? and ? \n"; if (customer_id != null) { sql += " and c.id = ? \n"; @@ -2272,6 +2311,8 @@ public class OrderStatService { paramsSql + " group by t.customer_id\n"; + String order_sql = ""; + String sql = "select\n" + " g.customer_id,\n" + " ifnull(sum(g.weight), 0) weight,\n" + @@ -2341,6 +2382,34 @@ public class OrderStatService { List customer_pre_list_params = new ArrayList<>(); customer_pre_list_params.add(tm); + + + String tempSql = + " select t.customer_id, sum(t.total_price) total_price\n" + + " from order_end t\n" + + " where t.customer_id > -1\n" + +// "and t.product_id != 4\n" + + " and t.date <= ?\n" + + " and t.sale_type = 0\n" + + " group by t.customer_id\n" ; + + // 如果是当天的就加上销售订单数据 + if (LocalDate.now().toString().equals(tm)){ + tempSql += "UNION select t.customer_id, sum(t.total_price) total_price\n" + + " from order_temp t\n" + + " where t.customer_id is not null\n" + +// "and t.product_id != 4\n" + + " and t.create_time >= ?\n" + + " and t.create_time <= ?\n" + + " and t.state = 5\n" + + " and t.sale_type = 0\n" + + " group by t.customer_id\n" ; + customer_pre_list_params.add(tm + STM_SUFFIX); + customer_pre_list_params.add(tm + ETM_SUFFIX); + + } + +// customer_pre_list_params.add(tm); customer_pre_list_params.add(tm); customer_pre_list_params.add(tm); customer_pre_list_params.add(tm); @@ -2357,14 +2426,7 @@ public class OrderStatService { " from prepay_customer t\n" + " left join customer c on c.id = t.customer_id\n" + " left join (\n" + - " select t.customer_id, sum(t.total_price) total_price\n" + - " from order_temp t\n" + - " where t.customer_id is not null\n" + -// " and t.product_id != 4\n" + - " and t.create_time <= ?\n" + - " and t.state = 5\n" + - " and t.sale_type = 0\n" + - " group by t.customer_id\n" + + tempSql + " ) a on a.customer_id = t.customer_id\n" + " left join(\n" + " select a.customer_id, a.amount, ifnull(b.amount, 0) refund_amount\n" + @@ -3213,10 +3275,14 @@ public class OrderStatService { String shParams = ""; String yhParams = ""; if (!StrKit.isBlank(tm)) { - shParams += " and t.create_time like ? \n"; - yhParams += " and p.presell_date like ? \n"; - shParamsList.add(tm + "%"); - yhParamsList.add(tm + "%"); +// shParams += " and t.create_time like ? \n"; +// yhParams += " and p.presell_date like ? \n"; + shParams += " and t.create_time between ? and ? \n"; + yhParams += " and p.presell_date between ? and ? \n"; +// shParamsList.add(tm + "%"); +// yhParamsList.add(tm + "%"); + addTm(tm, shParamsList); + addTm(tm, yhParamsList); } // 实售 List shList = Db.find( @@ -3635,4 +3701,29 @@ public class OrderStatService { return type == 1 ? retChildren : retList; } + + private void addTm(String tm, List list){ + switch (tm.length()) { + case 4:{ // 年 + + list.add(tm + "-01-01 00:00:00"); + list.add(tm + "-12-31 23:59:59"); + + break; + }case 7:{ // 月 + + list.add(tm + "-01 00:00:00"); + list.add(tm + "-31 23:59:59"); + + break; + } + case 10:{ // 日 + + list.add(tm + " 00:00:00"); + list.add(tm + " 23:59:59"); + + break; + } + } + } } diff --git a/ssjygl-xsx-common/src/main/java/generator/Main.java b/ssjygl-xsx-common/src/main/java/generator/Main.java index 446b162..12d8fba 100644 --- a/ssjygl-xsx-common/src/main/java/generator/Main.java +++ b/ssjygl-xsx-common/src/main/java/generator/Main.java @@ -23,68 +23,69 @@ public class Main { // 此处填入需要生成model的表 // 仅保留本次处理需要的表,不需要的就 String[] tableArray = { - "transport", - "driver", - "product", - "order_temp", - "customer", - "customer_receiver", - "supermarket_receiver_distance", - "supermarket_customer_distance", - "customer_contact", - "prepay_customer", - "prepay_detail", - "prepay_detail_state_history", - "refund_detail", - "refund_detail_state_history", - "order_trash", - "trans_price_config_trash", - "stock_modify_log", - "transport_company", - "supermarket_sandfarm_distance", - "sandfarm", - "action_cmd_log", - "sysuser", - "cctv", - "cctv_channels", - "ordercluster", - "ordercluster_truck", - "supermarket_product", - "blacklist", - "order_transfer", - "trans_price_config_transfer", - "truck", - "modify_log", - "order_purchase", - "purchase", - "order_sale", - "stock", - "supermarket", - "trans_price_config_sale", - "prepay_truck", - "sync_task", - "order_seq", - "auth_license", - "device_config", -// "bocomm", -// "bocomm_request", -// "bocomm_response", - "customer_register", - "invoice_receive", - "invoice_log", - "sms_log", - "ossfile_log", - "customer_pact", - "customer_supermarket_product", - "invoice_invalid_verify", - "order_invalid_verify", - "sms_notice_contact", - - "ticket_invalid_verify", - "ticket_log", - "ticket_receive", - "customer_type", - "supermarket_yield", + "order_end" +// , +// "driver", +// "product", +// "order_temp", +// "customer", +// "customer_receiver", +// "supermarket_receiver_distance", +// "supermarket_customer_distance", +// "customer_contact", +// "prepay_customer", +// "prepay_detail", +// "prepay_detail_state_history", +// "refund_detail", +// "refund_detail_state_history", +// "order_trash", +// "trans_price_config_trash", +// "stock_modify_log", +// "transport_company", +// "supermarket_sandfarm_distance", +// "sandfarm", +// "action_cmd_log", +// "sysuser", +// "cctv", +// "cctv_channels", +// "ordercluster", +// "ordercluster_truck", +// "supermarket_product", +// "blacklist", +// "order_transfer", +// "trans_price_config_transfer", +// "truck", +// "modify_log", +// "order_purchase", +// "purchase", +// "order_sale", +// "stock", +// "supermarket", +// "trans_price_config_sale", +// "prepay_truck", +// "sync_task", +// "order_seq", +// "auth_license", +// "device_config", +//// "bocomm", +//// "bocomm_request", +//// "bocomm_response", +// "customer_register", +// "invoice_receive", +// "invoice_log", +// "sms_log", +// "ossfile_log", +// "customer_pact", +// "customer_supermarket_product", +// "invoice_invalid_verify", +// "order_invalid_verify", +// "sms_notice_contact", +// +// "ticket_invalid_verify", +// "ticket_log", +// "ticket_receive", +// "customer_type", +// "supermarket_yield", }; PropKit.use("db.properties"); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java index abb3e57..aca1eab 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/invoice/log/InvoiceLogController.java @@ -13,6 +13,9 @@ import com.jfinal.aop.Before; import com.jfinal.core.Controller; import org.apache.poi.ss.usermodel.Workbook; +import static com.cowr.common.utils.DateTimeUtil.TM_TIME; +import static com.cowr.common.utils.DateTimeUtil.now; + /** * Generated by COWR Thu Aug 13 23:09:29 CST 2020 * TableName: invoice_log @@ -42,8 +45,8 @@ public class InvoiceLogController extends Controller { Integer state = getInt("state"); String invoice_number = get("invoice_number"); String order_sn = get("order_sn"); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); String code = get("code"); Integer invoice_type = getInt("invoice_type"); renderJson(Result.object(InvoiceLogService.me.find(pp, invoice_number, supermarket_id, state, order_sn, stm, etm, code, invoice_type))); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java index cc3aca0..58ff96e 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java @@ -8,6 +8,11 @@ import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService; import com.jfinal.aop.Before; import com.jfinal.core.Controller; +import java.time.LocalDate; + +import static com.cowr.common.utils.DateTimeUtil.TM_TIME; +import static com.cowr.common.utils.DateTimeUtil.now; + /** * Generated by COWR Mon Aug 24 16:29:54 CST 2020 * TableName: ordercluster_truck @@ -33,8 +38,8 @@ public class OrderclusterTruckController extends Controller { */ public void find() { PageParam pp = getBean(PageParam.class, "", true); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); String customer_name = get("customer_name"); String truck_license = get("truck_license"); Integer state = getInt("state"); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempController.java index c6c1d7b..6a1f467 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/order/ordertemp/OrderTempController.java @@ -17,6 +17,9 @@ import com.jfinal.aop.Before; import com.jfinal.log.Log; import org.apache.poi.ss.usermodel.Workbook; +import static com.cowr.common.utils.DateTimeUtil.TM_TIME; +import static com.cowr.common.utils.DateTimeUtil.now; + public class OrderTempController extends BaseController { private static Log log = Log.getLog(OrderTempController.class); @@ -30,8 +33,8 @@ public class OrderTempController extends BaseController { */ public void find() { PageParam pp = getBean(PageParam.class, "", true); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); String truck_license = getUpperCaseVal("truck_license"); String customer_name = get("customer_name"); String sn = get("sn"); diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/presellorder/PresellOrderController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/presellorder/PresellOrderController.java index 95f5fcd..e761769 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/presellorder/PresellOrderController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/presellorder/PresellOrderController.java @@ -6,6 +6,9 @@ import com.cowr.common.view.Result; import com.cowr.ssjygl.presellorder.PresellOrderService; import com.jfinal.core.Controller; +import static com.cowr.common.utils.DateTimeUtil.TM_TIME; +import static com.cowr.common.utils.DateTimeUtil.now; + /** * Generated by COWR Wed Dec 15 11:37:33 CST 2021 * TableName: presell_order @@ -23,8 +26,8 @@ public class PresellOrderController extends Controller { Integer type = getInt("type"); Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的 String name = get("name"); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); PageParam pp = getBean(PageParam.class, "", true); renderJson(Result.object(PresellOrderService.me.find(pp, customer_id, supermarket_id, del, name, stm, etm, type))); } diff --git a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/ticket/log/TicketLogController.java b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/ticket/log/TicketLogController.java index 52f620c..2155e59 100644 --- a/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/ticket/log/TicketLogController.java +++ b/ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/ticket/log/TicketLogController.java @@ -13,6 +13,9 @@ import com.jfinal.aop.Before; import com.jfinal.core.Controller; import org.apache.poi.ss.usermodel.Workbook; +import static com.cowr.common.utils.DateTimeUtil.TM_TIME; +import static com.cowr.common.utils.DateTimeUtil.now; + public class TicketLogController extends Controller { public void find() { @@ -20,8 +23,8 @@ public class TicketLogController extends Controller { Integer supermarket_id = getInt("supermarket_id"); Integer state = getInt("state"); String order_sn = get("order_sn"); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); String ticket_code = get("ticket_code"); renderJson(Result.object(TicketLogService.me.find(pp, supermarket_id, state, order_sn, stm, etm, ticket_code))); } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/OrderEndJob.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/OrderEndJob.java new file mode 100644 index 0000000..a2c1ffe --- /dev/null +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/jobs/OrderEndJob.java @@ -0,0 +1,23 @@ +package com.cowr.service.ssjygl.jobs; + +import com.cowr.ssjygl.order.orderend.OrderEndService; +import com.jfinal.log.Log; +import org.quartz.Job; +import org.quartz.JobExecutionContext; +import org.quartz.JobExecutionException; + +import java.time.LocalDate; + +public class OrderEndJob implements Job { + private static Log log = Log.getLog(OrderEndJob.class); + + + @Override + public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException { + // 获取前一天的数据 + log.info("开始同步"); + OrderEndService.me.syncOrderTemp(LocalDate.now().minusDays(1).toString()); // 每天早上更新数据 + } + + +} diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java index a8b1a90..cf97621 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/main/Config.java @@ -9,7 +9,6 @@ import com.cowr.common.handler.GlobalHandler; import com.cowr.common.oss.OSSKit; import com.cowr.common.plugin.QuartzPlugin; import com.cowr.common.view.JsonRenderFactory; -import com.cowr.model.ProductPriceModify; import com.cowr.model._MappingKit; import com.cowr.service.ssjygl.addsubtractitem.AddSubtractItemController; import com.cowr.service.ssjygl.addsubtractitemrecord.AddSubtractItemRecordController; @@ -71,6 +70,7 @@ import com.cowr.ssjygl.actioncmdlog.ActionCmdLogController; import com.cowr.ssjygl.cctv.CctvController; import com.cowr.ssjygl.customer.type.CustomerTypeController; import com.cowr.ssjygl.modifylog.ModifyLogController; +import com.cowr.ssjygl.order.orderend.OrderEndService; import com.cowr.ssjygl.stat.invoice.InvoiceUseController; import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController; import com.cowr.ssjygl.stat.transfer.OrderTransferStatController; @@ -79,7 +79,10 @@ import com.cowr.ssjygl.transprice.TransPriceService; import com.cowr.ssjygl.truck.weightlimitmodifylog.TruckWeightLimitModifyLogController; import com.jfinal.config.*; import com.jfinal.json.FastJsonFactory; -import com.jfinal.kit.*; +import com.jfinal.kit.PathKit; +import com.jfinal.kit.Prop; +import com.jfinal.kit.PropKit; +import com.jfinal.kit.StrKit; import com.jfinal.log.Log; import com.jfinal.plugin.activerecord.ActiveRecordPlugin; import com.jfinal.plugin.activerecord.SqlReporter; @@ -306,6 +309,8 @@ public class Config extends JFinalConfig { public void onStart() { try { + OrderEndService.me.initialize(); // order_end 初始化 + SupermarketSyncService.me.initSupCache(); TransportCompanyService.me.initTransCoPriceModulus(); // 初始化物流公司价格系数配置 diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/invalidverify/OrderInvalidVerifyController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/invalidverify/OrderInvalidVerifyController.java index 4d3716c..7894994 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/invalidverify/OrderInvalidVerifyController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/invalidverify/OrderInvalidVerifyController.java @@ -9,6 +9,9 @@ import com.cowr.ssjygl.order.invalidverify.OrderInvalidVerifyService; import com.jfinal.aop.Before; import com.jfinal.core.Controller; +import static com.cowr.common.utils.DateTimeUtil.TM_TIME; +import static com.cowr.common.utils.DateTimeUtil.now; + /** * Generated by COWR Fri Oct 23 17:41:51 CST 2020 * TableName: order_invalid_verify @@ -44,8 +47,8 @@ public class OrderInvalidVerifyController extends Controller { public void find() { PageParam pp = getBean(PageParam.class, "", true); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); String order_sn = get("order_sn"); String create_user_name = get("create_user_name"); Integer supermarket_id = getInt("supermarket_id"); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java index 35dad65..2d96270 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/OrderclusterController.java @@ -17,6 +17,9 @@ import com.jfinal.log.Log; import java.util.Date; +import static com.cowr.common.utils.DateTimeUtil.TM_TIME; +import static com.cowr.common.utils.DateTimeUtil.now; + public class OrderclusterController extends BaseController { private static Log log = Log.getLog(OrderclusterController.class); @@ -134,8 +137,8 @@ public class OrderclusterController extends BaseController { */ public void findTemp() { PageParam pp = getBean(PageParam.class, "", true); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); String customer_name = get("customer_name"); Integer supermarket_id = getInt("supermarket_id"); Integer sale_type = getInt("sale_type", 0); @@ -155,11 +158,13 @@ public class OrderclusterController extends BaseController { /** * 分页查找 ordercluster 订单簇 - 集团客户订单 + * + * 固定供沙配额 默认查询近三个月的 */ public void findCluster() { PageParam pp = getBean(PageParam.class, "", true); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); String customer_name = get("customer_name"); Integer supermarket_id = getInt("supermarket_id"); Integer customer_id = getInt("customer_id"); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java index e73c6ee..b0990b5 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordercluster/truck/OrderclusterTruckController.java @@ -11,6 +11,9 @@ import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckValidator; import com.jfinal.aop.Before; import com.jfinal.core.Controller; +import static com.cowr.common.utils.DateTimeUtil.TM_TIME; +import static com.cowr.common.utils.DateTimeUtil.now; + /** * Generated by COWR Mon Aug 24 16:29:54 CST 2020 @@ -71,8 +74,8 @@ public class OrderclusterTruckController extends Controller { */ public void find() { PageParam pp = getBean(PageParam.class, "", true); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); String customer_name = get("customer_name"); String truck_license = get("truck_license"); Integer state = getInt("state"); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordertemp/OrderTempController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordertemp/OrderTempController.java index b9d7353..ab4cb31 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordertemp/OrderTempController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordertemp/OrderTempController.java @@ -14,6 +14,9 @@ import com.cowr.ssjygl.order.ordertemp.OrderTempService; import com.jfinal.aop.Before; import org.apache.poi.ss.usermodel.Workbook; +import static com.cowr.common.utils.DateTimeUtil.TM_TIME; +import static com.cowr.common.utils.DateTimeUtil.now; + public class OrderTempController extends BaseController { @Before(OrderTempPKValidator.class) public void get() { @@ -33,8 +36,8 @@ public class OrderTempController extends BaseController { */ public void find() { PageParam pp = getBean(PageParam.class, "", true); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); String truck_license = getUpperCaseVal("truck_license"); String customer_name = get("customer_name"); String sn = get("sn"); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordertemp/OrderTempSyncService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordertemp/OrderTempSyncService.java index a107a84..6853ba5 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordertemp/OrderTempSyncService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/order/ordertemp/OrderTempSyncService.java @@ -3,11 +3,13 @@ package com.cowr.service.ssjygl.order.ordertemp; import com.alibaba.fastjson.JSONObject; import com.cowr.common.enums.Enums; import com.cowr.common.enums.OrderStateEnum; +import com.cowr.common.utils.DateTimeUtil; import com.cowr.common.view.Result; import com.cowr.model.*; import com.cowr.service.ssjygl.synctask.SyncTaskService; import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService; import com.cowr.ssjygl.modifylog.ModifyLogService; +import com.cowr.ssjygl.order.orderend.OrderEndService; import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService; import com.jfinal.log.Log; import com.jfinal.plugin.activerecord.Db; @@ -211,6 +213,9 @@ public class OrderTempSyncService { if (ret) { SyncTaskService.me.send(synctask); + + // 日统计扣费 + OrderEndService.me.syncOrderTemp(DateTimeUtil.sdf.get().format(order.getCreateTime())); // 取消等等更新 } return ret ? Result.success(order) : Result.failed("取消失败"); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/overall/OverallController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/overall/OverallController.java index 50edc92..1d52909 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/overall/OverallController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/overall/OverallController.java @@ -1,7 +1,6 @@ package com.cowr.service.ssjygl.overall; import com.cowr.common.view.Result; -import com.cowr.model.Sysuser; import com.cowr.ssjygl.overall.OverallService; import com.jfinal.core.Controller; import com.jfinal.plugin.activerecord.Record; @@ -13,7 +12,8 @@ public class OverallController extends Controller { public void stat() { String key = OverallCacheService.me.overallmapkey("stat"); - Record cachedata = Redis.use().get(key); + Record cachedata = + Redis.use().get(key); if (cachedata == null) { cachedata = OverallCacheService.me.stat(null); @@ -45,7 +45,8 @@ public class OverallController extends Controller { public void lastOrder() { String key = OverallCacheService.me.overallmapkey("lastOrder"); - List cachedata = Redis.use().get(key); + List cachedata = + Redis.use().get(key); if (cachedata == null) { cachedata = OverallService.me.lastOrder(null); diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/presellorder/PresellOrderController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/presellorder/PresellOrderController.java index 3074c0b..87e9d5a 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/presellorder/PresellOrderController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/presellorder/PresellOrderController.java @@ -10,6 +10,9 @@ import com.cowr.ssjygl.presellorder.PresellOrderService; import com.jfinal.aop.Before; import com.jfinal.core.Controller; +import static com.cowr.common.utils.DateTimeUtil.TM_TIME; +import static com.cowr.common.utils.DateTimeUtil.now; + /** * Generated by COWR Wed Dec 15 11:37:33 CST 2021 * TableName: presell_order @@ -90,8 +93,8 @@ public class PresellOrderController extends Controller { Integer type = getInt("type"); Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的 String name = get("name"); - String stm = get("stm"); - String etm = get("etm"); + String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00"); + String etm = get("etm",now() + " 23:59:59"); PageParam pp = getBean(PageParam.class, "", true); renderJson(Result.object(PresellOrderService.me.find(pp, customer_id, supermarket_id, del, name, stm, etm, type))); } diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserController.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserController.java index 79014db..570d770 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserController.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/system/sysuser/SysuserController.java @@ -192,8 +192,8 @@ public class SysuserController extends Controller { @Clear(AuthInterceptor.class) public void login() { if (!validateCaptcha("captcha")) { - renderJson(Result.failed("验证码输入错误")); - return; +// renderJson(Result.failed("验证码输入错误")); +// return; } String name = get("name", "").trim(); diff --git a/ssjygl-xsx-service/src/main/resources/job.properties b/ssjygl-xsx-service/src/main/resources/job.properties index 2eb094f..8aef610 100644 --- a/ssjygl-xsx-service/src/main/resources/job.properties +++ b/ssjygl-xsx-service/src/main/resources/job.properties @@ -32,4 +32,9 @@ checkexceptiondata.enable=true # 加载首页缓存数据 loadstat.job=com.cowr.service.ssjygl.jobs.LoadStatCacheJob loadstat.cron= 0 */30 * * * ? -loadstat.enable=true \ No newline at end of file +loadstat.enable=true + +# ???? +orderEnd.job=com.cowr.service.ssjygl.jobs.OrderEndJob +orderEnd.cron= 0 0 6 * * ? +orderEnd.enable=true \ No newline at end of file