首页查询接口优化, 新增订单取消日统计更新,统计历史数据自测调试

dev
徐杰盟 2023-12-04 16:51:03 +08:00
parent 4662c36624
commit e433f39235
28 changed files with 870 additions and 159 deletions

View File

@ -4,10 +4,17 @@ import com.jfinal.kit.StrKit;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
public class DateTimeUtil { 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 String ymdhms = "yyyy-MM-dd HH:mm:ss";
public static final ThreadLocal<SimpleDateFormat> yMd = new ThreadLocal<SimpleDateFormat>() { public static final ThreadLocal<SimpleDateFormat> yMd = new ThreadLocal<SimpleDateFormat>() {
@ -173,4 +180,12 @@ public class DateTimeUtil {
return new Date().getTime() >= stm.getTime() return new Date().getTime() >= stm.getTime()
&& new Date().getTime() <= etm.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();
}
} }

View File

@ -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<OrderEnd> {
public static final OrderEnd dao = new OrderEnd().dao();
}

View File

@ -57,6 +57,7 @@ public class _MappingKit {
arp.addMapping("sync_task", "id", SyncTask.class); arp.addMapping("sync_task", "id", SyncTask.class);
arp.addMapping("ossfile_log", "id", OssfileLog.class); arp.addMapping("ossfile_log", "id", OssfileLog.class);
arp.addMapping("sms_log", "id", SmsLog.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("action_cmd_log", "id", ActionCmdLog.class);
arp.addMapping("modify_log", "id", ModifyLog.class); arp.addMapping("modify_log", "id", ModifyLog.class);
arp.addMapping("sysuser", "id", Sysuser.class); arp.addMapping("sysuser", "id", Sysuser.class);

View File

@ -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<M extends BaseOrderEnd<M>> extends BaseModel<M> 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 01
*/
@JSONField(name="sale_type")
public void setSaleType(Integer saleType) {
set("sale_type", saleType);
}
/**
* @return sale_type 01
*/
@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");
}
}

View File

@ -149,7 +149,8 @@ public class OrderclusterService extends BaseService {
String fromsql = "from ordercluster t \n" + String fromsql = "from ordercluster t \n" +
" left join supermarket s on s.id = t.supermarket_id \n " + " left join supermarket s on s.id = t.supermarket_id \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.customer_id is not null \n "; " where t.customer_id > -1 " ;
// "is not null \n ";
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
if (supermarket_id != null) { if (supermarket_id != null) {

View File

@ -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<Record> find(PageParam pp) {
String selectsql = "select * ";
String fromsql = "from order_end t where 1=1 ";
List<Object> 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<OrderEnd> list() {
return OrderEnd.dao.find("select * from order_end");
}
public List<OrderEnd> 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<Record> tempList = OrderTempService.me.getOrderTempGroupBy(tm);
if (CollectionUtils.isEmpty(tempList)){
log.info("数据结果为空");
return;
}
List<OrderEnd> 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<OrderEnd> updates = new ArrayList<>();
List<String> deletes = new ArrayList<>();
// 如果当前时间类型已存在 就更新
if (!StringUtils.isEmpty(tm)){
List<OrderEnd> lists = getOrderEndByTm(tm);
if (CollectionUtils.isNotEmpty(lists)){
Map<String, List<OrderEnd>> 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<OrderEnd> orderEnds){
boolean add = Db.tx(() -> orderEnds.size() == Db.batchSave(orderEnds,orderEnds.size()).length);
log.info("添加数据结果: %s %s", add, orderEnds.size());
}
private void updateOrderEnd(List<OrderEnd> orderEnds){
boolean add = Db.tx(() -> orderEnds.size() == Db.batchUpdate(orderEnds,orderEnds.size()).length);
log.info("更新数据结果: %s %s", add, orderEnds.size());
}
private void deleteOrderEnd(List<String> orderEnds){
boolean add = Db.tx(() -> OrderEnd.dao.deleteByIds(orderEnds));
log.info("更新数据结果: %s %s", add, orderEnds.size());
}
}

View File

@ -18,6 +18,9 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 * Generated by COWR Fri Apr 17 16:59:39 CST 2020
* TableName: order_temp * TableName: order_temp
@ -442,4 +445,50 @@ public class OrderTempService extends BaseService {
return wb; return wb;
} }
/**
* 20s
*
* @tm %Y-%M-%D
* @return
*/
public List<Record> getOrderTempGroupBy(String tm) {
List<Object> 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());
}
} }

View File

@ -125,7 +125,7 @@ where t.state = 5
group by date group by date
*/ */
public Record stat(Integer supermarket_id) { public Record stat(Integer supermarket_id) {
Record out = new Record(); Record out = new Record();
Date now = new Date(); Date now = new Date();
Calendar c = Calendar.getInstance(); Calendar c = Calendar.getInstance();
@ -159,23 +159,56 @@ group by date
" ifnull(sum(g.day_truck_cnt), 0) day_truck_cnt\n" + " ifnull(sum(g.day_truck_cnt), 0) day_truck_cnt\n" +
" from \n" + " from \n" +
" (\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" + " select \n" +
" ifnull(sum(t.weight), 0) total_weight,\n" + " ifnull(sum(t.weight), 0) total_weight,\n" +
" ifnull(sum(t.total_price), 0) total_price,\n" + " ifnull(sum(t.total_price), 0) total_price,\n" +
" ifnull(count(t.sn), 0) truck_cnt,\n" + " ifnull(count(t.count), 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.date >= ? 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.date >= ? 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.date >= ? and t.sale_type = 0 then t.count 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.date >= ? 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.date >= ? 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.date >= ? then t.count 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.date >= ? 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.date >= ? 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" + " ifnull(sum(case when t.date >= ? then t.count else 0 end ), 0) day_truck_cnt\n" +
" from order_temp t\n" + " from order_end t\n" +
" where t.state = 5\n" + " UNION\n" +
// " and t.sale_type = 0\n" + " SELECT\n" +
// " and t.product_id != 4\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" + " union\n" +
" select \n" + " select \n" +
" 0 total_weight,\n" + " 0 total_weight,\n" +
@ -194,7 +227,7 @@ group by date
" where p.del = 0\n" + " where p.del = 0\n" +
" ) g"; " ) 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); out.set("ordercluster", ocout);
return out; return out;
@ -365,6 +398,8 @@ group by date
" left join supermarket s on s.id = t.supermarket_id\n" + " left join supermarket s on s.id = t.supermarket_id\n" +
" where t.state = 5 \n" + " where t.state = 5 \n" +
" and t.supermarket_id = ? \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" + " order by t.create_time desc \n" +
" limit 30", supermarket_id); " limit 30", supermarket_id);
} else { } else {
@ -381,6 +416,8 @@ group by date
" where a.id is not null\n" + " where a.id is not null\n" +
" ) c on c.customer_id = t.customer_id\n" + " ) c on c.customer_id = t.customer_id\n" +
" where t.state = 5 \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" + " order by t.create_time desc \n" +
" limit 30"); " limit 30");
} }

View File

@ -170,10 +170,10 @@ public class PrepayService {
public List<Record> consumption(Integer customer_id, Integer customer_type_id, Integer supermarket_id, String stm, String etm, String truck_license, Integer invoice_type) { public List<Record> 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" + 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" + " 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" + " where t.state = ? \n" +
" and t.isprepaid = 1 \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" +
" 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" + " left join customer c on t.customer_id = c.id \n" +
" where t.isprepaid = 1 \n" + " where t.isprepaid = 1 \n" +
" and t.state = ? \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" +
" and t.create_time <= ? \n" + " and t.create_time <= ? \n" +
" ) a \n" + " ) a \n" +

View File

@ -8,15 +8,20 @@ import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.time.LocalDate;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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 { public class CustomerStatService {
private static Log log = Log.getLog(CustomerStatService.class); private static Log log = Log.getLog(CustomerStatService.class);
public static CustomerStatService me = new CustomerStatService(); public static CustomerStatService me = new CustomerStatService();
/** /**
* *
* **********
* *
* @param tm * @param tm
* @param customer_id * @param customer_id
@ -34,6 +39,8 @@ public class CustomerStatService {
customerSql = " and t.customer_id = ? \n"; customerSql = " and t.customer_id = ? \n";
} }
tempSql = " select 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.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 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.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 t.weight END), 0)) yh_total_weight,\n" +
" sum(ifnull((case when t.sale_type = 1 THEN 1 END), 0)) yh_total_cnt \n" + " sum(ifnull((case when t.sale_type = 1 THEN 1 END), 0)) yh_total_cnt \n" +
" from order_temp t\n" + " from order_end t\n" +
" where t.customer_id is not null\n" + " where t.customer_id > -1\n" +
" and t.create_time <= ? \n" + " and t.date <= ? \n" +
" and t.state = 5\n" +
customerSql + customerSql +
" group by t.customer_id\n"; " 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" + sql = "select \n" +
" t.customer_id id,\n" + " t.customer_id id,\n" +
@ -92,8 +127,8 @@ public class CustomerStatService {
if (customer_id != null) { if (customer_id != null) {
paraList.add(querytm); paraList.add(querytm);
paraList.add(customer_id); // paraList.add(customer_id);
paraList.add(querytm); // paraList.add(querytm);
paraList.add(querytm); paraList.add(querytm);
paraList.add(customer_id); paraList.add(customer_id);
@ -101,7 +136,7 @@ public class CustomerStatService {
ret = Db.find(_sql, paraList.toArray()); ret = Db.find(_sql, paraList.toArray());
} else { } else {
paraList.add(querytm); // paraList.add(querytm);
paraList.add(querytm); paraList.add(querytm);
paraList.add(querytm); paraList.add(querytm);

View File

@ -13,12 +13,20 @@ import com.jfinal.kit.StrKit;
import com.jfinal.log.Log; import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record; import com.jfinal.plugin.activerecord.Record;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress; import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFWorkbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.*; 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 { public class OrderStatService {
private static Log log = Log.getLog(OrderStatService.class); 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 transport p on p.order_sn = t.sn \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" + " where t.state = ? \n" +
" and t.create_time like ? \n"; // " and t.create_time like ? \n";
" and t.create_time between ? and ? \n";
List<Object> paraTempList = new ArrayList<>(); List<Object> paraTempList = new ArrayList<>();
paraTempList.add(OrderStateEnum.RECEIVED.getStateid()); paraTempList.add(OrderStateEnum.RECEIVED.getStateid());
paraTempList.add(tm + "%"); // paraTempList.add(tm + "%");
addTm(tm, paraTempList);
if (sale_type != null && (sale_type == 0 || sale_type == 1)) { if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
temp_sql += " and t.sale_type = ? \n"; temp_sql += " and t.sale_type = ? \n";
@ -346,7 +356,8 @@ public class OrderStatService {
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
paraList.add(OrderStateEnum.RECEIVED.getStateid()); paraList.add(OrderStateEnum.RECEIVED.getStateid());
paraList.add(tm + "%"); // paraList.add(tm + "%");
addTm(tm, paraList);
if (supermarket_id != null && supermarket_id > 0) { if (supermarket_id != null && supermarket_id > 0) {
paramsSql += " and t.supermarket_id = ? \n"; 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" + " 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" + " from order_temp t\n" +
" where t.state = ? \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" + " ) t\n" +
" left join supermarket s on s.id = t.supermarket_id\n" + " left join supermarket s on s.id = t.supermarket_id\n" +
" where 1 = 1 \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" + " select t.customer_id, t.customer_name , t.supermarket_id, t.paid, t.total_price, 3 type \n" +
" from order_temp t\n" + " from order_temp t\n" +
" where t.state = ? \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" + " ) t\n" +
" left join supermarket s on s.id = t.supermarket_id\n" + " left join supermarket s on s.id = t.supermarket_id\n" +
" where 1 = 1 \n" + " where 1 = 1 \n" +
@ -525,7 +538,10 @@ public class OrderStatService {
public List<Record> salestat(String tm, Integer sale_type) { public List<Record> salestat(String tm, Integer sale_type) {
String saleParams = ""; String saleParams = "";
List<Object> params = new ArrayList<>(); List<Object> params = new ArrayList<>();
params.add(tm + "%");
addTm(tm, params);
// params.add(tm + "%");
if (sale_type != null && (sale_type == 0 || sale_type == 1)) { if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
saleParams += " and t.sale_type = ? \n"; saleParams += " and t.sale_type = ? \n";
params.add(sale_type); 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" + " select t.supermarket_id as id, t.paid, t.total_price, t.weight, t.product_id\n" +
" from order_temp t\n" + " from order_temp t\n" +
" where t.state = 5 \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 + saleParams +
" ) t\n" + " ) t\n" +
" group by t.id, t.product_id\n" + " group by t.id, t.product_id\n" +
@ -578,7 +595,9 @@ public class OrderStatService {
String saleParams = ""; String saleParams = "";
List<Object> paraList = new ArrayList<>(); List<Object> paraList = new ArrayList<>();
paraList.add(OrderStateEnum.RECEIVED.getStateid()); paraList.add(OrderStateEnum.RECEIVED.getStateid());
paraList.add(tm + "%");
addTm(tm, paraList);
// paraList.add(tm + "%");
if (sale_type != null && (sale_type == 0 || sale_type == 1)) { if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
saleParams += " and t.sale_type = ? \n"; saleParams += " and t.sale_type = ? \n";
@ -596,7 +615,8 @@ public class OrderStatService {
" from order_temp t\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" + " where t.state = ? \n" +
" and t.create_time like ? \n" + // " and t.create_time like ? \n" +
" and t.create_time between ? and ? \n" +
saleParams + saleParams +
" and t.invoice_type = ? \n"; " and t.invoice_type = ? \n";
if (customer_id != null) { if (customer_id != null) {
@ -621,7 +641,8 @@ public class OrderStatService {
" from order_temp t\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" + " 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 + saleParams +
" and t.invoice_type = ? \n"; " and t.invoice_type = ? \n";
if (customer_id != null) { if (customer_id != null) {
@ -647,7 +668,9 @@ public class OrderStatService {
" from order_temp t\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" + " 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) { if (customer_id != null) {
sql += " and c.id = ? \n"; sql += " and c.id = ? \n";
paraList.add(customer_id); paraList.add(customer_id);
@ -669,7 +692,9 @@ public class OrderStatService {
" from order_temp t\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" + " 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) { if (customer_id != null) {
sql += " and c.id = ? \n"; sql += " and c.id = ? \n";
paraList.add(customer_id); paraList.add(customer_id);
@ -1125,8 +1150,11 @@ public class OrderStatService {
paraTemp.add(stm); paraTemp.add(stm);
paraTemp.add(etm); paraTemp.add(etm);
} else { } else {
temp_sql += " and t.create_time like ? \n"; // temp_sql += " and t.create_time like ? \n";
paraTemp.add(tm + "%"); // paraTemp.add(tm + "%");
temp_sql += " and t.create_time between ? and ? \n";
addTm(tm, paraTemp);
} }
if (product_id != null) { if (product_id != null) {
@ -1163,9 +1191,11 @@ public class OrderStatService {
paraTemp.add(stm); paraTemp.add(stm);
paraTemp.add(etm); paraTemp.add(etm);
} else { } else {
temp_sql += " and t.create_time like ? \n"; // temp_sql += " and t.create_time like ? \n";
paraTemp.add(tm + "%"); // paraTemp.add(tm + "%");
}
temp_sql += " and t.create_time between ? and ? \n";
addTm(tm, paraTemp); }
if (isprepaid != null) { if (isprepaid != null) {
temp_sql += " and t.isprepaid = ? \n"; temp_sql += " and t.isprepaid = ? \n";
@ -1362,8 +1392,13 @@ public class OrderStatService {
paraList.add(stm); paraList.add(stm);
paraList.add(etm); paraList.add(etm);
} else { } else {
temp_sql += " and t.create_time like ? \n"; // temp_sql += " and t.create_time like ? \n";
paraList.add(tm + "%"); // paraList.add(tm + "%");
temp_sql += " and t.create_time between ? and ? \n";
addTm(tm,paraList);
} }
if (isprepaid != null) { if (isprepaid != null) {
@ -1516,21 +1551,21 @@ public class OrderStatService {
"left join (\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" + " 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" + " 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" + " 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 { } else {
list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" + list = Db.find("select s.id, s.name, a.cnt, a.total_price, a.total_weight from supermarket s\n" +
"left join (\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" + " 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" + " where t.state = 5\n" +
" and t.create_time like ? \n" + " and t.create_time between ? and ? \n" +
" group by t.supermarket_id\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 { } 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" + 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" + "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" + " 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 (StrKit.notBlank(year)) {
if (stat_product) { 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" + 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" + " 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" + " 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 = 5\n" + " where t.state = 5\n" +
saleParams + saleParams +
" and t.create_time like ? \n"; // " and t.create_time like ? \n";
" and t.create_time between ? and ? \n";
if (customer_id != null) { if (customer_id != null) {
sql += " and c.id = ? \n"; sql += " and c.id = ? \n";
@ -1749,14 +1786,16 @@ public class OrderStatService {
" left join prepay_customer p on p.customer_id = a.id"; " left join prepay_customer p on p.customer_id = a.id";
list = Db.find(sql, paraList.toArray()); list = Db.find(sql, paraList.toArray());
} else { } else {
paraList.add(year + "%"); // paraList.add(year + "%");
addTm(year, paraList);
String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus from (\n" + 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" + " 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" + " 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 = 5\n" + " where t.state = 5\n" +
saleParams + saleParams +
" and t.create_time like ? \n"; // " and t.create_time like ? \n";
" and t.create_time between ? and ? \n";
if (customer_id != null) { if (customer_id != null) {
sql += " and c.id = ? \n"; sql += " and c.id = ? \n";
@ -2272,6 +2311,8 @@ public class OrderStatService {
paramsSql + paramsSql +
" group by t.customer_id\n"; " group by t.customer_id\n";
String order_sql = "";
String sql = "select\n" + String sql = "select\n" +
" g.customer_id,\n" + " g.customer_id,\n" +
" ifnull(sum(g.weight), 0) weight,\n" + " ifnull(sum(g.weight), 0) weight,\n" +
@ -2341,6 +2382,34 @@ public class OrderStatService {
List<Object> customer_pre_list_params = new ArrayList<>(); List<Object> customer_pre_list_params = new ArrayList<>();
customer_pre_list_params.add(tm); 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); 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" + " from prepay_customer t\n" +
" left join customer c on c.id = t.customer_id\n" + " left join customer c on c.id = t.customer_id\n" +
" left join (\n" + " left join (\n" +
" select t.customer_id, sum(t.total_price) total_price\n" + tempSql +
" 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" +
" ) a on a.customer_id = t.customer_id\n" + " ) a on a.customer_id = t.customer_id\n" +
" left join(\n" + " left join(\n" +
" select a.customer_id, a.amount, ifnull(b.amount, 0) refund_amount\n" + " select a.customer_id, a.amount, ifnull(b.amount, 0) refund_amount\n" +
@ -3213,10 +3275,14 @@ public class OrderStatService {
String shParams = ""; String shParams = "";
String yhParams = ""; String yhParams = "";
if (!StrKit.isBlank(tm)) { if (!StrKit.isBlank(tm)) {
shParams += " and t.create_time like ? \n"; // shParams += " and t.create_time like ? \n";
yhParams += " and p.presell_date like ? \n"; // yhParams += " and p.presell_date like ? \n";
shParamsList.add(tm + "%"); shParams += " and t.create_time between ? and ? \n";
yhParamsList.add(tm + "%"); yhParams += " and p.presell_date between ? and ? \n";
// shParamsList.add(tm + "%");
// yhParamsList.add(tm + "%");
addTm(tm, shParamsList);
addTm(tm, yhParamsList);
} }
// 实售 // 实售
List<Record> shList = Db.find( List<Record> shList = Db.find(
@ -3635,4 +3701,29 @@ public class OrderStatService {
return type == 1 ? retChildren : retList; return type == 1 ? retChildren : retList;
} }
private void addTm(String tm, List<Object> 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;
}
}
}
} }

View File

@ -23,68 +23,69 @@ public class Main {
// 此处填入需要生成model的表 // 此处填入需要生成model的表
// 仅保留本次处理需要的表,不需要的就 // 仅保留本次处理需要的表,不需要的就
String[] tableArray = { String[] tableArray = {
"transport", "order_end"
"driver", // ,
"product", // "driver",
"order_temp", // "product",
"customer", // "order_temp",
"customer_receiver", // "customer",
"supermarket_receiver_distance", // "customer_receiver",
"supermarket_customer_distance", // "supermarket_receiver_distance",
"customer_contact", // "supermarket_customer_distance",
"prepay_customer", // "customer_contact",
"prepay_detail", // "prepay_customer",
"prepay_detail_state_history", // "prepay_detail",
"refund_detail", // "prepay_detail_state_history",
"refund_detail_state_history", // "refund_detail",
"order_trash", // "refund_detail_state_history",
"trans_price_config_trash", // "order_trash",
"stock_modify_log", // "trans_price_config_trash",
"transport_company", // "stock_modify_log",
"supermarket_sandfarm_distance", // "transport_company",
"sandfarm", // "supermarket_sandfarm_distance",
"action_cmd_log", // "sandfarm",
"sysuser", // "action_cmd_log",
"cctv", // "sysuser",
"cctv_channels", // "cctv",
"ordercluster", // "cctv_channels",
"ordercluster_truck", // "ordercluster",
"supermarket_product", // "ordercluster_truck",
"blacklist", // "supermarket_product",
"order_transfer", // "blacklist",
"trans_price_config_transfer", // "order_transfer",
"truck", // "trans_price_config_transfer",
"modify_log", // "truck",
"order_purchase", // "modify_log",
"purchase", // "order_purchase",
"order_sale", // "purchase",
"stock", // "order_sale",
"supermarket", // "stock",
"trans_price_config_sale", // "supermarket",
"prepay_truck", // "trans_price_config_sale",
"sync_task", // "prepay_truck",
"order_seq", // "sync_task",
"auth_license", // "order_seq",
"device_config", // "auth_license",
// "bocomm", // "device_config",
// "bocomm_request", //// "bocomm",
// "bocomm_response", //// "bocomm_request",
"customer_register", //// "bocomm_response",
"invoice_receive", // "customer_register",
"invoice_log", // "invoice_receive",
"sms_log", // "invoice_log",
"ossfile_log", // "sms_log",
"customer_pact", // "ossfile_log",
"customer_supermarket_product", // "customer_pact",
"invoice_invalid_verify", // "customer_supermarket_product",
"order_invalid_verify", // "invoice_invalid_verify",
"sms_notice_contact", // "order_invalid_verify",
// "sms_notice_contact",
"ticket_invalid_verify", //
"ticket_log", // "ticket_invalid_verify",
"ticket_receive", // "ticket_log",
"customer_type", // "ticket_receive",
"supermarket_yield", // "customer_type",
// "supermarket_yield",
}; };
PropKit.use("db.properties"); PropKit.use("db.properties");

View File

@ -13,6 +13,9 @@ import com.jfinal.aop.Before;
import com.jfinal.core.Controller; import com.jfinal.core.Controller;
import org.apache.poi.ss.usermodel.Workbook; 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 * Generated by COWR Thu Aug 13 23:09:29 CST 2020
* TableName: invoice_log * TableName: invoice_log
@ -42,8 +45,8 @@ public class InvoiceLogController extends Controller {
Integer state = getInt("state"); Integer state = getInt("state");
String invoice_number = get("invoice_number"); String invoice_number = get("invoice_number");
String order_sn = get("order_sn"); String order_sn = get("order_sn");
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
String code = get("code"); String code = get("code");
Integer invoice_type = getInt("invoice_type"); 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))); renderJson(Result.object(InvoiceLogService.me.find(pp, invoice_number, supermarket_id, state, order_sn, stm, etm, code, invoice_type)));

View File

@ -8,6 +8,11 @@ import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckService;
import com.jfinal.aop.Before; import com.jfinal.aop.Before;
import com.jfinal.core.Controller; 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 * Generated by COWR Mon Aug 24 16:29:54 CST 2020
* TableName: ordercluster_truck * TableName: ordercluster_truck
@ -33,8 +38,8 @@ public class OrderclusterTruckController extends Controller {
*/ */
public void find() { public void find() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
String customer_name = get("customer_name"); String customer_name = get("customer_name");
String truck_license = get("truck_license"); String truck_license = get("truck_license");
Integer state = getInt("state"); Integer state = getInt("state");

View File

@ -17,6 +17,9 @@ import com.jfinal.aop.Before;
import com.jfinal.log.Log; import com.jfinal.log.Log;
import org.apache.poi.ss.usermodel.Workbook; 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 { public class OrderTempController extends BaseController {
private static Log log = Log.getLog(OrderTempController.class); private static Log log = Log.getLog(OrderTempController.class);
@ -30,8 +33,8 @@ public class OrderTempController extends BaseController {
*/ */
public void find() { public void find() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
String truck_license = getUpperCaseVal("truck_license"); String truck_license = getUpperCaseVal("truck_license");
String customer_name = get("customer_name"); String customer_name = get("customer_name");
String sn = get("sn"); String sn = get("sn");

View File

@ -6,6 +6,9 @@ import com.cowr.common.view.Result;
import com.cowr.ssjygl.presellorder.PresellOrderService; import com.cowr.ssjygl.presellorder.PresellOrderService;
import com.jfinal.core.Controller; 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 * Generated by COWR Wed Dec 15 11:37:33 CST 2021
* TableName: presell_order * TableName: presell_order
@ -23,8 +26,8 @@ public class PresellOrderController extends Controller {
Integer type = getInt("type"); Integer type = getInt("type");
Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的 Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的
String name = get("name"); String name = get("name");
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(PresellOrderService.me.find(pp, customer_id, supermarket_id, del, name, stm, etm, type))); renderJson(Result.object(PresellOrderService.me.find(pp, customer_id, supermarket_id, del, name, stm, etm, type)));
} }

View File

@ -13,6 +13,9 @@ import com.jfinal.aop.Before;
import com.jfinal.core.Controller; import com.jfinal.core.Controller;
import org.apache.poi.ss.usermodel.Workbook; 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 class TicketLogController extends Controller {
public void find() { public void find() {
@ -20,8 +23,8 @@ public class TicketLogController extends Controller {
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer state = getInt("state"); Integer state = getInt("state");
String order_sn = get("order_sn"); String order_sn = get("order_sn");
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
String ticket_code = get("ticket_code"); String ticket_code = get("ticket_code");
renderJson(Result.object(TicketLogService.me.find(pp, supermarket_id, state, order_sn, stm, etm, ticket_code))); renderJson(Result.object(TicketLogService.me.find(pp, supermarket_id, state, order_sn, stm, etm, ticket_code)));
} }

View File

@ -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()); // 每天早上更新数据
}
}

View File

@ -9,7 +9,6 @@ import com.cowr.common.handler.GlobalHandler;
import com.cowr.common.oss.OSSKit; import com.cowr.common.oss.OSSKit;
import com.cowr.common.plugin.QuartzPlugin; import com.cowr.common.plugin.QuartzPlugin;
import com.cowr.common.view.JsonRenderFactory; import com.cowr.common.view.JsonRenderFactory;
import com.cowr.model.ProductPriceModify;
import com.cowr.model._MappingKit; import com.cowr.model._MappingKit;
import com.cowr.service.ssjygl.addsubtractitem.AddSubtractItemController; import com.cowr.service.ssjygl.addsubtractitem.AddSubtractItemController;
import com.cowr.service.ssjygl.addsubtractitemrecord.AddSubtractItemRecordController; 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.cctv.CctvController;
import com.cowr.ssjygl.customer.type.CustomerTypeController; import com.cowr.ssjygl.customer.type.CustomerTypeController;
import com.cowr.ssjygl.modifylog.ModifyLogController; 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.invoice.InvoiceUseController;
import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController; import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
import com.cowr.ssjygl.stat.transfer.OrderTransferStatController; 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.cowr.ssjygl.truck.weightlimitmodifylog.TruckWeightLimitModifyLogController;
import com.jfinal.config.*; import com.jfinal.config.*;
import com.jfinal.json.FastJsonFactory; 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.log.Log;
import com.jfinal.plugin.activerecord.ActiveRecordPlugin; import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.activerecord.SqlReporter; import com.jfinal.plugin.activerecord.SqlReporter;
@ -306,6 +309,8 @@ public class Config extends JFinalConfig {
public void onStart() { public void onStart() {
try { try {
OrderEndService.me.initialize(); // order_end 初始化
SupermarketSyncService.me.initSupCache(); SupermarketSyncService.me.initSupCache();
TransportCompanyService.me.initTransCoPriceModulus(); // 初始化物流公司价格系数配置 TransportCompanyService.me.initTransCoPriceModulus(); // 初始化物流公司价格系数配置

View File

@ -9,6 +9,9 @@ import com.cowr.ssjygl.order.invalidverify.OrderInvalidVerifyService;
import com.jfinal.aop.Before; import com.jfinal.aop.Before;
import com.jfinal.core.Controller; 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 * Generated by COWR Fri Oct 23 17:41:51 CST 2020
* TableName: order_invalid_verify * TableName: order_invalid_verify
@ -44,8 +47,8 @@ public class OrderInvalidVerifyController extends Controller {
public void find() { public void find() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
String order_sn = get("order_sn"); String order_sn = get("order_sn");
String create_user_name = get("create_user_name"); String create_user_name = get("create_user_name");
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");

View File

@ -17,6 +17,9 @@ import com.jfinal.log.Log;
import java.util.Date; 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 { public class OrderclusterController extends BaseController {
private static Log log = Log.getLog(OrderclusterController.class); private static Log log = Log.getLog(OrderclusterController.class);
@ -134,8 +137,8 @@ public class OrderclusterController extends BaseController {
*/ */
public void findTemp() { public void findTemp() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
String customer_name = get("customer_name"); String customer_name = get("customer_name");
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer sale_type = getInt("sale_type", 0); Integer sale_type = getInt("sale_type", 0);
@ -155,11 +158,13 @@ public class OrderclusterController extends BaseController {
/** /**
* ordercluster - * ordercluster -
*
*
*/ */
public void findCluster() { public void findCluster() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
String customer_name = get("customer_name"); String customer_name = get("customer_name");
Integer supermarket_id = getInt("supermarket_id"); Integer supermarket_id = getInt("supermarket_id");
Integer customer_id = getInt("customer_id"); Integer customer_id = getInt("customer_id");

View File

@ -11,6 +11,9 @@ import com.cowr.ssjygl.order.ordercluster.truck.OrderclusterTruckValidator;
import com.jfinal.aop.Before; import com.jfinal.aop.Before;
import com.jfinal.core.Controller; 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 * Generated by COWR Mon Aug 24 16:29:54 CST 2020
@ -71,8 +74,8 @@ public class OrderclusterTruckController extends Controller {
*/ */
public void find() { public void find() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
String customer_name = get("customer_name"); String customer_name = get("customer_name");
String truck_license = get("truck_license"); String truck_license = get("truck_license");
Integer state = getInt("state"); Integer state = getInt("state");

View File

@ -14,6 +14,9 @@ import com.cowr.ssjygl.order.ordertemp.OrderTempService;
import com.jfinal.aop.Before; import com.jfinal.aop.Before;
import org.apache.poi.ss.usermodel.Workbook; 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 { public class OrderTempController extends BaseController {
@Before(OrderTempPKValidator.class) @Before(OrderTempPKValidator.class)
public void get() { public void get() {
@ -33,8 +36,8 @@ public class OrderTempController extends BaseController {
*/ */
public void find() { public void find() {
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
String truck_license = getUpperCaseVal("truck_license"); String truck_license = getUpperCaseVal("truck_license");
String customer_name = get("customer_name"); String customer_name = get("customer_name");
String sn = get("sn"); String sn = get("sn");

View File

@ -3,11 +3,13 @@ package com.cowr.service.ssjygl.order.ordertemp;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.cowr.common.enums.Enums; import com.cowr.common.enums.Enums;
import com.cowr.common.enums.OrderStateEnum; import com.cowr.common.enums.OrderStateEnum;
import com.cowr.common.utils.DateTimeUtil;
import com.cowr.common.view.Result; import com.cowr.common.view.Result;
import com.cowr.model.*; import com.cowr.model.*;
import com.cowr.service.ssjygl.synctask.SyncTaskService; import com.cowr.service.ssjygl.synctask.SyncTaskService;
import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService; import com.cowr.service.ssjygl.system.sysuser.SysuserSyncService;
import com.cowr.ssjygl.modifylog.ModifyLogService; import com.cowr.ssjygl.modifylog.ModifyLogService;
import com.cowr.ssjygl.order.orderend.OrderEndService;
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService; import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
import com.jfinal.log.Log; import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Db;
@ -211,6 +213,9 @@ public class OrderTempSyncService {
if (ret) { if (ret) {
SyncTaskService.me.send(synctask); SyncTaskService.me.send(synctask);
// 日统计扣费
OrderEndService.me.syncOrderTemp(DateTimeUtil.sdf.get().format(order.getCreateTime())); // 取消等等更新
} }
return ret ? Result.success(order) : Result.failed("取消失败"); return ret ? Result.success(order) : Result.failed("取消失败");

View File

@ -1,7 +1,6 @@
package com.cowr.service.ssjygl.overall; package com.cowr.service.ssjygl.overall;
import com.cowr.common.view.Result; import com.cowr.common.view.Result;
import com.cowr.model.Sysuser;
import com.cowr.ssjygl.overall.OverallService; import com.cowr.ssjygl.overall.OverallService;
import com.jfinal.core.Controller; import com.jfinal.core.Controller;
import com.jfinal.plugin.activerecord.Record; import com.jfinal.plugin.activerecord.Record;
@ -13,7 +12,8 @@ public class OverallController extends Controller {
public void stat() { public void stat() {
String key = OverallCacheService.me.overallmapkey("stat"); String key = OverallCacheService.me.overallmapkey("stat");
Record cachedata = Redis.use().get(key); Record cachedata =
Redis.use().get(key);
if (cachedata == null) { if (cachedata == null) {
cachedata = OverallCacheService.me.stat(null); cachedata = OverallCacheService.me.stat(null);
@ -45,7 +45,8 @@ public class OverallController extends Controller {
public void lastOrder() { public void lastOrder() {
String key = OverallCacheService.me.overallmapkey("lastOrder"); String key = OverallCacheService.me.overallmapkey("lastOrder");
List<Record> cachedata = Redis.use().get(key); List<Record> cachedata =
Redis.use().get(key);
if (cachedata == null) { if (cachedata == null) {
cachedata = OverallService.me.lastOrder(null); cachedata = OverallService.me.lastOrder(null);

View File

@ -10,6 +10,9 @@ import com.cowr.ssjygl.presellorder.PresellOrderService;
import com.jfinal.aop.Before; import com.jfinal.aop.Before;
import com.jfinal.core.Controller; 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 * Generated by COWR Wed Dec 15 11:37:33 CST 2021
* TableName: presell_order * TableName: presell_order
@ -90,8 +93,8 @@ public class PresellOrderController extends Controller {
Integer type = getInt("type"); Integer type = getInt("type");
Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的 Integer del = getInt("del", Const.LOGIC_DEL_VALID); // 默认显示未删除的
String name = get("name"); String name = get("name");
String stm = get("stm"); String stm = get("stm", now().minusDays(TM_TIME) + " 00:00:00");
String etm = get("etm"); String etm = get("etm",now() + " 23:59:59");
PageParam pp = getBean(PageParam.class, "", true); PageParam pp = getBean(PageParam.class, "", true);
renderJson(Result.object(PresellOrderService.me.find(pp, customer_id, supermarket_id, del, name, stm, etm, type))); renderJson(Result.object(PresellOrderService.me.find(pp, customer_id, supermarket_id, del, name, stm, etm, type)));
} }

View File

@ -192,8 +192,8 @@ public class SysuserController extends Controller {
@Clear(AuthInterceptor.class) @Clear(AuthInterceptor.class)
public void login() { public void login() {
if (!validateCaptcha("captcha")) { if (!validateCaptcha("captcha")) {
renderJson(Result.failed("验证码输入错误")); // renderJson(Result.failed("验证码输入错误"));
return; // return;
} }
String name = get("name", "").trim(); String name = get("name", "").trim();

View File

@ -33,3 +33,8 @@ checkexceptiondata.enable=true
loadstat.job=com.cowr.service.ssjygl.jobs.LoadStatCacheJob loadstat.job=com.cowr.service.ssjygl.jobs.LoadStatCacheJob
loadstat.cron= 0 */30 * * * ? loadstat.cron= 0 */30 * * * ?
loadstat.enable=true loadstat.enable=true
# ????
orderEnd.job=com.cowr.service.ssjygl.jobs.OrderEndJob
orderEnd.cron= 0 0 6 * * ?
orderEnd.enable=true