lisai17@sina.com 2020-11-04 14:22:06 +08:00
parent d815d73ed3
commit e8a3b5e5d8
7 changed files with 104 additions and 15 deletions

View File

@ -16,6 +16,8 @@ public class Const {
public static final String REDIS_SEPARATE = ":"; // reids 分隔符 public static final String REDIS_SEPARATE = ":"; // reids 分隔符
public static final String REDIS_CACHENAME = "mian"; // redis 默认 cache 对象别名 public static final String REDIS_CACHENAME = "mian"; // redis 默认 cache 对象别名
public static final String REDIS_JSON = "json"; // redis 按 json 存储对象 public static final String REDIS_JSON = "json"; // redis 按 json 存储对象
public static final double DEFAULT_LGTD = 115.265535; // 默认经度 浠水县
public static final double DEFAULT_LTTD = 30.451867; // 默认维度 浠水县
public static final String TEMP_CODE_PEIE = "SMS_203673037"; // 配额分配通知 public static final String TEMP_CODE_PEIE = "SMS_203673037"; // 配额分配通知
public static Map<String, String> SMS_TEMP_MAP; public static Map<String, String> SMS_TEMP_MAP;

View File

@ -1,5 +1,6 @@
package com.cowr.ssjygl.overall; package com.cowr.ssjygl.overall;
import com.cowr.common.Const;
import com.cowr.common.enums.OrderStateEnum; import com.cowr.common.enums.OrderStateEnum;
import com.cowr.common.utils.DateTimeUtil; import com.cowr.common.utils.DateTimeUtil;
import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Db;
@ -395,18 +396,79 @@ group by date
public List<Record> lastOrder(Integer supermarket_id) { public List<Record> lastOrder(Integer supermarket_id) {
if (supermarket_id != null) { if (supermarket_id != null) {
return Db.find("select t.sn, t.customer_name, t.truck_license, t.weight, t.total_price, t.create_time, s.name supermarket_name from order_temp t\n" + return Db.find("select t.sn, t.customer_id, t.customer_name, t.truck_license, t.weight, t.total_price, t.create_time, t.supermarket_id, s.name supermarket_name \n" +
" from order_temp 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 t.state = 5 \n" + " where t.state = 5 \n" +
" and t.supermarket_id = ? \n" + " and t.supermarket_id = ? \n" +
" order by t.create_time desc \n" + " order by t.create_time desc \n" +
" limit 30", supermarket_id); " limit 30", supermarket_id);
} else { } else {
return Db.find("select t.sn, t.customer_name, t.truck_license, t.weight, t.total_price, t.create_time, s.name supermarket_name from order_temp t\n" + return Db.find("select t.sn, t.customer_id, t.customer_name, t.truck_license, t.weight, t.total_price, t.create_time, t.supermarket_id, s.name supermarket_name\n" +
" , s.lgtd origin_lgtd, s.lttd origin_lttd\n" +
" , ifnull(c.lgtd, " + Const.DEFAULT_LGTD + ") dest_lgtd, ifnull(c.lttd, " + Const.DEFAULT_LTTD + ") dest_lttd\n" +
" from order_temp 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 (\n" +
" select t.* from customer_receiver t\n" +
" left join (\n" +
" select t.customer_id, min(t.id) id from customer_receiver t group by t.customer_id\n" +
" ) a on a.id = t.id\n" +
" where a.id is not null\n" +
" ) c on c.customer_id = t.customer_id\n" +
" where t.state = 5 \n" + " where t.state = 5 \n" +
" order by t.create_time desc \n" + " order by t.create_time desc \n" +
" limit 30"); " limit 30");
} }
} }
public List<Record> customerQuota() {
Date now = new Date();
String nowdaytm = DateTimeUtil.sdf.get().format(now); // 当日
List<Record> outlist = new ArrayList<>();
Record c1 = new Record().set("id", 1).set("name", "固定客户").set("cnt", Db.queryInt("select count(*) cnt from customer"));
Record c2 = new Record().set("id", 2).set("name", "零散客户").set("cnt", Db.queryInt("select count(distinct customer_name) cnt from ordercluster where customer_id is null"));
outlist.add(c1);
outlist.add(c2);
List<Record> data1 = Db.find("select case when t.customer_id is null then 2 else 1 end cid, count(t.id) day_quota_cnt, sum(t.total_weight) day_quota_weight from ordercluster t\n" +
" where t.state < 5\n" +
" and t.cutoff_time like ?\n" +
" group by cid", nowdaytm + "%");
List<Record> data2 = Db.find("select case when t.customer_id is null then 2 else 1 end cid, count(t.sn) day_cnt, sum(t.weight) day_weight, sum(total_price) day_total_price from order_temp t\n" +
" where t.state = 5\n" +
" and t.create_time like ?\n" +
" group by cid", nowdaytm + "%");
for (Record record : data1) {
int cid = record.getInt("cid");
if (cid == 1) {
c1.set("day_quota_cnt", record.get("day_quota_cnt"));
c1.set("day_quota_weight", record.get("day_quota_weight"));
} else if (cid == 2) {
c2.set("day_quota_cnt", record.get("day_quota_cnt"));
c2.set("day_quota_weight", record.get("day_quota_weight"));
}
}
for (Record record : data2) {
int cid = record.getInt("cid");
if (cid == 1) {
c1.set("day_cnt", record.get("day_cnt"));
c1.set("day_weight", record.get("day_weight"));
c1.set("day_total_price", record.get("day_total_price"));
} else if (cid == 2) {
c2.set("day_cnt", record.get("day_cnt"));
c2.set("day_weight", record.get("day_weight"));
c2.set("day_total_price", record.get("day_total_price"));
}
}
return outlist;
}
} }

View File

@ -161,8 +161,8 @@ public class OrderPurchaseStatService {
row.createCell(a++).setCellValue("物流公司"); row.createCell(a++).setCellValue("物流公司");
row.createCell(a++).setCellValue("车牌号"); row.createCell(a++).setCellValue("车牌号");
row.createCell(a++).setCellValue("里程(公里)"); row.createCell(a++).setCellValue("里程(公里)");
row.createCell(a++).setCellValue("毛重(吨)");
row.createCell(a++).setCellValue("皮重(吨)"); row.createCell(a++).setCellValue("皮重(吨)");
row.createCell(a++).setCellValue("毛重(吨)");
row.createCell(a++).setCellValue("净重(吨)"); row.createCell(a++).setCellValue("净重(吨)");
row.createCell(a++).setCellValue("底单重(吨)"); row.createCell(a++).setCellValue("底单重(吨)");
row.createCell(a++).setCellValue("运费(元)"); row.createCell(a++).setCellValue("运费(元)");

View File

@ -272,8 +272,8 @@ public class OrderStatService {
row.createCell(a++).setCellValue("入场时间"); row.createCell(a++).setCellValue("入场时间");
row.createCell(a++).setCellValue("销售单编号"); row.createCell(a++).setCellValue("销售单编号");
row.createCell(a++).setCellValue("品类"); row.createCell(a++).setCellValue("品类");
row.createCell(a++).setCellValue("毛重(吨)");
row.createCell(a++).setCellValue("皮重(吨)"); row.createCell(a++).setCellValue("皮重(吨)");
row.createCell(a++).setCellValue("毛重(吨)");
row.createCell(a++).setCellValue("净重(吨)"); row.createCell(a++).setCellValue("净重(吨)");
row.createCell(a++).setCellValue("金额(元)"); row.createCell(a++).setCellValue("金额(元)");
row.createCell(a++).setCellValue("客户"); row.createCell(a++).setCellValue("客户");
@ -1448,7 +1448,7 @@ public class OrderStatService {
public List<Record> yearStatBySup(String year) { public List<Record> yearStatBySup(String year) {
List<Record> list; List<Record> list;
if (StrKit.notBlank(year)) { if (StrKit.notBlank(year)) {
list = Db.find("select s.name, a.* 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" +
@ -1456,7 +1456,7 @@ public class OrderStatService {
" 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 + "%");
} else { } else {
list = Db.find("select s.name, a.* 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" +
@ -1472,10 +1472,16 @@ public class OrderStatService {
hj.set("total_weight", new BigDecimal(0)); hj.set("total_weight", new BigDecimal(0));
for (Record record : list) { for (Record record : list) {
if (record.get("cnt") != null) {
hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt")); hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt"));
}
if (record.get("total_price") != null) {
hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price"))); hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price")));
}
if (record.get("total_weight") != null) {
hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight"))); hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight")));
} }
}
list.add(hj); list.add(hj);
@ -1510,7 +1516,11 @@ public class OrderStatService {
row = sheet.createRow(i + 1); row = sheet.createRow(i + 1);
a = 0; a = 0;
row.createCell(a++).setCellValue(order.getStr("name")); row.createCell(a++).setCellValue(order.getStr("name"));
if(order.get("cnt") != null){
row.createCell(a++).setCellValue(order.getInt("cnt")); row.createCell(a++).setCellValue(order.getInt("cnt"));
}else{
row.createCell(a++).setCellValue("");
}
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight")); row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight"));
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price")); row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price"));
} }
@ -1551,10 +1561,15 @@ public class OrderStatService {
hj.set("total_surplus", new BigDecimal(0)); hj.set("total_surplus", new BigDecimal(0));
for (Record record : list) { for (Record record : list) {
if (record.get("cnt") != null) {
hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt")); hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt"));
}
if (record.get("total_price") != null) {
hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price"))); hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price")));
}
if (record.get("total_weight") != null) {
hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight"))); hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight")));
}
if (record.get("total_surplus") != null) { if (record.get("total_surplus") != null) {
hj.set("total_surplus", hj.getBigDecimal("total_surplus").add(record.getBigDecimal("total_surplus"))); hj.set("total_surplus", hj.getBigDecimal("total_surplus").add(record.getBigDecimal("total_surplus")));
} }

View File

@ -95,7 +95,7 @@ public class Config extends JFinalConfig {
public static DeviceThread deviceThread = new DeviceThread(); public static DeviceThread deviceThread = new DeviceThread();
public static SocketIOService socketio = null; public static SocketIOService socketio = null;
private static boolean client_run = true; private static boolean client_run = true;
public static final String CLINET_VERSION = "20201103"; public static final String CLINET_VERSION = "20201104";
public static String getRootPath() { public static String getRootPath() {
return PathKit.getWebRootPath() return PathKit.getWebRootPath()

View File

@ -104,6 +104,12 @@ public class SyncTaskService {
// TODO:一次同步的数量不多,连续发送 // TODO:一次同步的数量不多,连续发送
for (SyncTask obj : list) { for (SyncTask obj : list) {
send(obj); send(obj);
try {
Thread.sleep(1000); // 历史数据间隔一秒发送
} catch (Exception e) {
}
} }
} }

View File

@ -35,4 +35,8 @@ public class OverallController extends Controller {
renderJson(Result.success(OverallService.me.lastOrder(supermarket_id))); renderJson(Result.success(OverallService.me.lastOrder(supermarket_id)));
} }
public void customerQuota() {
renderJson(Result.success(OverallService.me.customerQuota()));
}
} }