本地年统计修改
parent
f43cc279a6
commit
efc87ba4b2
|
|
@ -9,6 +9,7 @@ import com.cowr.common.utils.poimerge.PoiDynamicMarge;
|
|||
import com.cowr.common.view.ReportExcelStyle;
|
||||
import com.cowr.model.Supermarket;
|
||||
import com.cowr.ssjygl.CacheData;
|
||||
import com.cowr.ssjygl.supermarket.SupermarketService;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.log.Log;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
|
|
@ -3882,7 +3883,7 @@ public class OrderStatService {
|
|||
|
||||
return PoiDynamicMarge.createExcel(headers, title, listMap, regions, titleMap);
|
||||
}
|
||||
public Workbook yearsalestatExportBySupLocal(String tm) {
|
||||
public Workbook yearsalestatExportBySupLocal(String tm,Integer supermarket_id) {
|
||||
String title = "销售统计";
|
||||
if (!StrKit.isBlank(tm)) {
|
||||
title = tm + "年销售统计";
|
||||
|
|
@ -3897,7 +3898,7 @@ public class OrderStatService {
|
|||
titleMap.put("weight", "销量(吨)");
|
||||
titleMap.put("total_price", "金额(元)");
|
||||
List<Map<String, Object>> listMap = new ArrayList<>();
|
||||
List<Record> list = statYearBySupLocal(tm, 2);
|
||||
List<Record> list = statYearBySupLocal(tm, supermarket_id);
|
||||
for (Record r : list) {
|
||||
Map<String, Object> map = r.getColumns();
|
||||
listMap.add(map);
|
||||
|
|
@ -4613,501 +4614,78 @@ public class OrderStatService {
|
|||
" left join product p on p.id = a.product_id order BY p.id ASC";
|
||||
}
|
||||
|
||||
public List<Record> statYearBySupLocal(String tm, int type) {
|
||||
// 砂站
|
||||
List<Record> sups = Db.find("SELECT\n" +
|
||||
" t.id,\n" +
|
||||
" t.`name`\n" +
|
||||
"FROM\n" +
|
||||
" supermarket t\n" +
|
||||
"WHERE\n" +
|
||||
// " id <= 6\n" +
|
||||
// "OR id = 11 or id = 12 "
|
||||
"t.type = 0 "
|
||||
);
|
||||
public List<Record> statYearBySupLocal(String tm, Integer supermarket_id) {
|
||||
Supermarket sup = Supermarket.dao.findById(supermarket_id);
|
||||
|
||||
List<Object> shParamsList = new ArrayList<>();
|
||||
List<Object> yhParamsList = new ArrayList<>();
|
||||
String shParams = "";
|
||||
String yhParams = "";
|
||||
if (!StrKit.isBlank(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";
|
||||
// shParams += " and t.date between ? and ? \n";
|
||||
// yhParams += " and t.date between ? and ? \n";
|
||||
// shParamsList.add(tm + "%");
|
||||
// yhParamsList.add(tm + "%");
|
||||
addTm(tm, shParamsList);
|
||||
addTm(tm, yhParamsList);
|
||||
}
|
||||
// 实售
|
||||
List<Record> shList = Db.find(
|
||||
"select s.id, s.name, p.id product_id, p.`name` product_name, ifnull(a.orderCount, 0) as order_num, ifnull(a.totalPrice, 0) as total_price, ifnull(a.weight, 0) as weight\n" +
|
||||
" from supermarket_product t\n" +
|
||||
" left join (\n" +
|
||||
" select t.id, t.product_id, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
|
||||
" from (\n" +
|
||||
" select t.supermarket_id as id, t.total_price, t.weight, t.product_id\n" +
|
||||
" from order_temp t \n" +
|
||||
// " from order_end t \n" +
|
||||
" where t.sale_type = 0 \n" +
|
||||
" and t.state = 5 \n" +
|
||||
shParams +
|
||||
" ) t\n" +
|
||||
" group by t.id, t.product_id\n" +
|
||||
" ) a on a.id = t.supermarket_id and a.product_id = t.product_id\n" +
|
||||
" left join supermarket s on s.id = t.supermarket_id\n" +
|
||||
" left join product p on p.id = t.product_id " +
|
||||
" WHERE s.id is not null " +
|
||||
" order BY s.id, p.id ASC", shParamsList.toArray());
|
||||
// 预售
|
||||
List<Record> yhList = Db.find(
|
||||
"SELECT\n" +
|
||||
" s.id,\n" +
|
||||
" ifnull( t.order_num, 0 ) order_num,\n" +
|
||||
" ifnull( t.weight, 0 ) weight,\n" +
|
||||
" ifnull( t.total_price, 0 ) total_price \n" +
|
||||
"FROM\n" +
|
||||
" supermarket s\n" +
|
||||
" LEFT JOIN (\n" +
|
||||
" SELECT\n" +
|
||||
" t.supermarket_id,\n" +
|
||||
" ifnull( count(*), 0 ) AS order_num,\n" +
|
||||
// " ifnull( sum( t.count), 0 ) AS order_num,\n" +
|
||||
" ifnull( sum( t.weight ), 0 ) AS weight,\n" +
|
||||
" ifnull( sum( t.total_price ), 0 ) AS total_price \n" +
|
||||
" FROM\n" +
|
||||
" order_temp t\n" +
|
||||
" LEFT JOIN ordercluster c ON c.id = t.ordercluster_id\n" +
|
||||
" LEFT JOIN presell_order p ON p.id = c.presell_order_id \n" +
|
||||
// " order_end t\n" +
|
||||
" WHERE\n" +
|
||||
" t.sale_type = 1 \n" +
|
||||
" AND t.state = 5 \n" +
|
||||
yhParams +
|
||||
" GROUP BY\n" +
|
||||
" t.supermarket_id \n" +
|
||||
" ) t ON s.id = t.supermarket_id",
|
||||
|
||||
// "SELECT\n" +
|
||||
// " t.supermarket_id id,\n" +
|
||||
// " ifnull(count(*), 0) as order_num,\n" +
|
||||
// " ifnull(sum(t.weight), 0) as weight,\n" +
|
||||
// " ifnull(sum(t.total_price), 0) as total_price\n" +
|
||||
// "FROM\n" +
|
||||
// " order_temp t\n" +
|
||||
// "LEFT JOIN ordercluster c ON c.id = t.ordercluster_id\n" +
|
||||
// "LEFT JOIN presell_order p ON p.id = c.presell_order_id\n" +
|
||||
// "WHERE\n" +
|
||||
// " t.sale_type = 1\n" +
|
||||
// " AND t.state = 5\n" +
|
||||
// " AND p.del = 0\n" +
|
||||
// yhParams +
|
||||
// "GROUP BY\n" +
|
||||
// " t.supermarket_id",
|
||||
yhParamsList.toArray());
|
||||
|
||||
List<Record> retChildren = new ArrayList<>();
|
||||
List<Record> retList = new ArrayList<>();
|
||||
List<Record> shList1 = new ArrayList<>();
|
||||
List<Record> yhList1 = new ArrayList<>();
|
||||
|
||||
int hj_hs_sh_order_num = 0;
|
||||
double hj_hs_sh_weight = 0.0;
|
||||
double hj_hs_sh_total_price = 0.0;
|
||||
// 实售
|
||||
List<Record> shList = Db.find(getLocalSaleSql(shParams), shParamsList.toArray());
|
||||
|
||||
int hj_els_sh_order_num = 0;
|
||||
double hj_els_sh_weight = 0.0;
|
||||
double hj_els_sh_total_price = 0.0;
|
||||
// 实售总
|
||||
List<Record> stList = Db.find(getLocalSaleSql(shParams), shParamsList.toArray());
|
||||
|
||||
int hj_jzs_sh_order_num = 0;
|
||||
double hj_jzs_sh_weight = 0.0;
|
||||
double hj_jzs_sh_total_price = 0.0;
|
||||
//所有总
|
||||
List<Record> totalList = Db.find("select count(t.sn) as order_num, sum(t.total_price) as total_price, sum(t.weight) as weight\n" +
|
||||
" from order_temp t where t.sale_type = 0" + shParams, shParamsList.toArray());
|
||||
|
||||
int hj_czs_sh_order_num = 0;
|
||||
double hj_czs_sh_weight = 0.0;
|
||||
double hj_czs_sh_total_price = 0.0;
|
||||
|
||||
int hj_yh_order_num = 0;
|
||||
double hj_yh_weight = 0.0;
|
||||
double hj_yh_total_price = 0.0;
|
||||
|
||||
// 实售合并
|
||||
// 实售处理
|
||||
if (shList != null && !shList.isEmpty()) {
|
||||
Map<Integer, Record> shMap = new HashMap<>();
|
||||
for (Record s : shList) {
|
||||
int id = s.getInt("id");
|
||||
int product_id = s.getInt("product_id");
|
||||
if ((id == 1 || id == 5 || id == 6 || id == 7 || id == 8 || id == 9 || id == 10) && product_id == 1) {
|
||||
shMap.put(id, s);
|
||||
} else {
|
||||
shList1.add(s);
|
||||
s.set("key", supermarket_id + "_sh_"+s.getInt("product_id"));
|
||||
s.set("item_name", "实售");
|
||||
s.set("name",sup.getName());
|
||||
}
|
||||
}
|
||||
if (shMap.size() > 1) {
|
||||
Record s_1 = shMap.get(1);
|
||||
Record s_5 = shMap.get(5);
|
||||
Record s_6 = shMap.get(6);
|
||||
Record s_7 = shMap.get(7);
|
||||
Record s_8 = shMap.get(8);
|
||||
Record s_9 = shMap.get(9);
|
||||
Record s_10 = shMap.get(10);
|
||||
if (s_1 != null && s_7 != null) {
|
||||
Record s_1_7 = margeRecord(s_1, s_7, 1);
|
||||
shList1.add(s_1_7);
|
||||
shMap.remove(1);
|
||||
shMap.remove(7);
|
||||
}
|
||||
if (s_5 != null && s_9 != null) {
|
||||
Record s_5_9 = margeRecord(s_5, s_9, 1);
|
||||
shList1.add(s_5_9);
|
||||
shMap.remove(5);
|
||||
shMap.remove(9);
|
||||
}
|
||||
if (s_6 != null && s_8 != null && s_10 == null) {
|
||||
Record s_6_8 = margeRecord(s_6, s_8, 1);
|
||||
shList1.add(s_6_8);
|
||||
shMap.remove(6);
|
||||
shMap.remove(8);
|
||||
}
|
||||
if (s_6 != null && s_8 == null && s_10 != null) {
|
||||
Record s_6_10 = margeRecord(s_6, s_10, 1);
|
||||
shList1.add(s_6_10);
|
||||
shMap.remove(6);
|
||||
shMap.remove(10);
|
||||
}
|
||||
if (s_6 != null && s_8 != null && s_10 != null) {
|
||||
Record s_8_10 = margeRecord(s_8, s_10, 1);
|
||||
Record s_6_8_10 = margeRecord(s_6, s_8_10, 1);
|
||||
shList1.add(s_6_8_10);
|
||||
shMap.remove(6);
|
||||
shMap.remove(8);
|
||||
shMap.remove(10);
|
||||
}
|
||||
if (shMap.size() > 0) {
|
||||
shList1.addAll(shMap.values());
|
||||
}
|
||||
} else if (shMap.size() == 1) {
|
||||
shList1.addAll(shMap.values());
|
||||
}
|
||||
} else {
|
||||
for (Record s : sups) {
|
||||
Record p = new Record();
|
||||
p.set("id", s.getInt("id"));
|
||||
p.set("name", s.getStr("name"));
|
||||
p.set("product_id", 1);
|
||||
p.set("product_name", "黄砂");
|
||||
p.set("order_num", 0);
|
||||
p.set("weight", new BigDecimal(0));
|
||||
p.set("total_price", new BigDecimal(0));
|
||||
shList1.add(p);
|
||||
}
|
||||
}
|
||||
// 预售合并
|
||||
if (yhList != null && !yhList.isEmpty()) {
|
||||
Map<Integer, Record> yhMap = new HashMap<>();
|
||||
for (Record s : yhList) {
|
||||
int id = s.getInt("id");
|
||||
if (id == 1 || id == 5 || id == 6 || id == 7 || id == 8 || id == 9 || id == 10) {
|
||||
yhMap.put(id, s);
|
||||
} else {
|
||||
yhList1.add(s);
|
||||
}
|
||||
}
|
||||
if (yhMap.size() > 1) {
|
||||
Record s_1 = yhMap.get(1);
|
||||
Record s_5 = yhMap.get(5);
|
||||
Record s_6 = yhMap.get(6);
|
||||
Record s_7 = yhMap.get(7);
|
||||
Record s_8 = yhMap.get(8);
|
||||
Record s_9 = yhMap.get(9);
|
||||
Record s_10 = yhMap.get(10);
|
||||
if (s_1 != null && s_7 != null) {
|
||||
Record s_1_7 = margeRecord(s_1, s_7, null);
|
||||
yhList1.add(s_1_7);
|
||||
yhMap.remove(1);
|
||||
yhMap.remove(7);
|
||||
}
|
||||
if (s_5 != null && s_9 != null) {
|
||||
Record s_5_9 = margeRecord(s_5, s_9, null);
|
||||
yhList1.add(s_5_9);
|
||||
yhMap.remove(5);
|
||||
yhMap.remove(9);
|
||||
}
|
||||
if (s_6 != null && s_8 != null && s_10 == null) {
|
||||
Record s_6_8 = margeRecord(s_6, s_8, null);
|
||||
yhList1.add(s_6_8);
|
||||
yhMap.remove(6);
|
||||
yhMap.remove(8);
|
||||
}
|
||||
if (s_6 != null && s_8 == null && s_10 != null) {
|
||||
Record s_6_10 = margeRecord(s_6, s_10, null);
|
||||
yhList1.add(s_6_10);
|
||||
yhMap.remove(6);
|
||||
yhMap.remove(10);
|
||||
}
|
||||
if (s_6 != null && s_8 != null && s_10 != null) {
|
||||
Record s_8_10 = margeRecord(s_8, s_10, null);
|
||||
Record s_6_8_10 = margeRecord(s_6, s_8_10, null);
|
||||
yhList1.add(s_6_8_10);
|
||||
yhMap.remove(6);
|
||||
yhMap.remove(8);
|
||||
yhMap.remove(10);
|
||||
}
|
||||
if (yhMap.size() > 0) {
|
||||
yhList1.addAll(yhMap.values());
|
||||
}
|
||||
} else if (yhMap.size() == 1) {
|
||||
yhList1.addAll(yhMap.values());
|
||||
}
|
||||
} else {
|
||||
for (Record s : sups) {
|
||||
Record p = new Record();
|
||||
p.set("id", s.getInt("id"));
|
||||
p.set("order_num", 0);
|
||||
p.set("weight", new BigDecimal(0));
|
||||
p.set("total_price", new BigDecimal(0));
|
||||
yhList1.add(p);
|
||||
}
|
||||
}
|
||||
if (sups.size() > 0) {
|
||||
for (Record s : sups) {
|
||||
Record p = new Record();
|
||||
int s_id = s.getInt("id");
|
||||
String name = s.getStr("name");
|
||||
p.set("key", s_id);
|
||||
p.set("name", name);
|
||||
Record sh = new Record();
|
||||
sh.set("key", s_id + "_sh");
|
||||
sh.set("item_name", "实售");
|
||||
List<Record> shChildren = new ArrayList<>();
|
||||
if (shList1.size() > 0) {
|
||||
boolean flag = true;
|
||||
for (Record sl : shList1) {
|
||||
int sl_id = sl.getInt("id");
|
||||
int product_id = sl.getInt("product_id");
|
||||
if (s_id == sl_id) {
|
||||
flag = false;
|
||||
Record r = new Record();
|
||||
int order_num = sl.getInt("order_num") == null ? 0 : sl.getInt("order_num");
|
||||
BigDecimal weight = sl.getBigDecimal("weight") == null ? new BigDecimal(0) : sl.getBigDecimal("weight");
|
||||
BigDecimal total_price = sl.getBigDecimal("total_price") == null ? new BigDecimal(0) : sl.getBigDecimal("total_price");
|
||||
|
||||
if (product_id == 1) {
|
||||
hj_hs_sh_order_num += order_num;
|
||||
hj_hs_sh_weight += weight.doubleValue();
|
||||
hj_hs_sh_total_price += total_price.doubleValue();
|
||||
} else if (product_id == 2) {
|
||||
hj_els_sh_order_num += order_num;
|
||||
hj_els_sh_weight += weight.doubleValue();
|
||||
hj_els_sh_total_price += total_price.doubleValue();
|
||||
} else if (product_id == 3) {
|
||||
hj_jzs_sh_order_num += order_num;
|
||||
hj_jzs_sh_weight += weight.doubleValue();
|
||||
hj_jzs_sh_total_price += total_price.doubleValue();
|
||||
}else if (product_id == 4) {
|
||||
hj_czs_sh_order_num += order_num;
|
||||
hj_czs_sh_weight += weight.doubleValue();
|
||||
hj_czs_sh_total_price += total_price.doubleValue();
|
||||
retList.addAll(shList);
|
||||
}
|
||||
|
||||
r.set("key", s_id + "_sh_" + product_id);
|
||||
r.set("id", s_id);
|
||||
r.set("name", name);
|
||||
r.set("item_name", "实售");
|
||||
r.set("product_id", product_id);
|
||||
r.set("product_name", sl.getStr("product_name"));
|
||||
r.set("order_num", order_num);
|
||||
r.set("weight", weight);
|
||||
r.set("total_price", total_price);
|
||||
retList.add(r);
|
||||
shChildren.add(new Record().setColumns(r).remove("name").remove("item_name"));
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
Record r = new Record();
|
||||
r.set("key", s_id + "_sh_1");
|
||||
r.set("id", s_id);
|
||||
r.set("name", name);
|
||||
r.set("item_name", "实售");
|
||||
r.set("product_id", 1);
|
||||
r.set("product_name", "-");
|
||||
r.set("order_num", "-");
|
||||
r.set("weight", "-");
|
||||
r.set("total_price", "-");
|
||||
retList.add(r);
|
||||
shChildren.add(new Record().setColumns(r).remove("name").remove("item_name"));
|
||||
|
||||
// 实售总处理
|
||||
if (stList != null && !stList.isEmpty()) {
|
||||
for (Record s : stList) {
|
||||
s.set("key", "hj_sh_" + s.getInt("product_id"));
|
||||
s.set("item_name", "实售");
|
||||
s.set("name","合计");
|
||||
}
|
||||
retList.addAll(stList);
|
||||
}
|
||||
|
||||
shChildren.sort(new Comparator<Record>() {
|
||||
@Override
|
||||
public int compare(Record o1, Record o2) {
|
||||
return o1.getInt("product_id") - o2.getInt("product_id");
|
||||
// 所有总处理
|
||||
if (totalList != null && !totalList.isEmpty()) {
|
||||
for (Record s : totalList) {
|
||||
s.set("key", "total");
|
||||
s.set("product_name","-");
|
||||
s.set("item_name", "-");
|
||||
s.set("name","总合计");
|
||||
}
|
||||
});
|
||||
sh.set("children", shChildren);
|
||||
|
||||
Record yh = new Record();
|
||||
yh.set("key", s.getInt("id") + "_yh");
|
||||
yh.set("item_name", "预售");
|
||||
List<Record> yhChildren = new ArrayList<>();
|
||||
if (yhList1.size() > 0) {
|
||||
boolean flag = true;
|
||||
for (Record yl : yhList1) {
|
||||
int yl_id = yl.getInt("id");
|
||||
if (s_id == yl_id) {
|
||||
flag = false;
|
||||
Record r = new Record();
|
||||
|
||||
int order_num = yl.getInt("order_num") == null ? 0 : yl.getInt("order_num");
|
||||
BigDecimal weight = yl.getBigDecimal("weight") == null ? new BigDecimal(0) : yl.getBigDecimal("weight");
|
||||
BigDecimal total_price = yl.getBigDecimal("total_price") == null ? new BigDecimal(0) : yl.getBigDecimal("total_price");
|
||||
hj_yh_order_num += order_num;
|
||||
hj_yh_weight += weight.doubleValue();
|
||||
hj_yh_total_price += total_price.doubleValue();
|
||||
|
||||
r.set("key", yl_id + "_yh_1");
|
||||
r.set("id", s_id);
|
||||
r.set("name", name);
|
||||
r.set("item_name", "预售");
|
||||
r.set("product_name", "-");
|
||||
r.set("order_num", order_num);
|
||||
r.set("weight", weight);
|
||||
r.set("total_price", total_price);
|
||||
retList.add(r);
|
||||
yhChildren.add(new Record().setColumns(r).remove("name").remove("item_name"));
|
||||
}
|
||||
}
|
||||
if (flag) {
|
||||
Record r2 = new Record();
|
||||
r2.set("key", s_id + "_yh_1");
|
||||
r2.set("id", s_id);
|
||||
r2.set("name", name);
|
||||
r2.set("item_name", "预售");
|
||||
r2.set("product_name", "-");
|
||||
r2.set("order_num", "-");
|
||||
r2.set("weight", "-");
|
||||
r2.set("total_price", "-");
|
||||
retList.add(r2);
|
||||
yhChildren.add(new Record().setColumns(r2).remove("name").remove("item_name"));
|
||||
}
|
||||
}
|
||||
yh.set("children", yhChildren);
|
||||
List<Record> children = new ArrayList<>();
|
||||
|
||||
children.add(sh);
|
||||
children.add(yh);
|
||||
p.set("children", children);
|
||||
|
||||
retChildren.add(p);
|
||||
retList.addAll(totalList);
|
||||
}
|
||||
|
||||
retList.sort(new Comparator<Record>() {
|
||||
@Override
|
||||
public int compare(Record o1, Record o2) {
|
||||
if (o1.getInt("product_id") != null && o2.getInt("product_id") != null
|
||||
&& o1.getInt("id") == o2.getInt("id")) {
|
||||
return o1.getInt("product_id") - o2.getInt("product_id");
|
||||
} else if (o1.getInt("id") != null && o2.getInt("id") != null) {
|
||||
return o1.getInt("id") - o2.getInt("id");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
});
|
||||
|
||||
// 合计
|
||||
Record hj = new Record();
|
||||
List<Record> hj_sh_children = new ArrayList<>();
|
||||
List<Record> hj_yh_children = new ArrayList<>();
|
||||
return retList;
|
||||
|
||||
Record hj_sh_hs = new Record();
|
||||
hj_sh_hs.set("key", "hj_sh_1");
|
||||
hj_sh_hs.set("name", "合计");
|
||||
hj_sh_hs.set("item_name", "实售");
|
||||
hj_sh_hs.set("product_name", "黄砂");
|
||||
hj_sh_hs.set("order_num", hj_hs_sh_order_num);
|
||||
hj_sh_hs.set("weight", hj_hs_sh_weight);
|
||||
hj_sh_hs.set("total_price", hj_hs_sh_total_price);
|
||||
retList.add(hj_sh_hs);
|
||||
hj_sh_children.add(new Record().setColumns(hj_sh_hs).remove("name").remove("item_name"));
|
||||
|
||||
Record hj_sh_els = new Record();
|
||||
hj_sh_els.set("key", "hj_sh_2");
|
||||
hj_sh_els.set("name", "合计");
|
||||
hj_sh_els.set("item_name", "实售");
|
||||
hj_sh_els.set("product_name", "鹅卵石");
|
||||
hj_sh_els.set("order_num", hj_els_sh_order_num);
|
||||
hj_sh_els.set("weight", hj_els_sh_weight);
|
||||
hj_sh_els.set("total_price", hj_els_sh_total_price);
|
||||
retList.add(hj_sh_els);
|
||||
hj_sh_children.add(new Record().setColumns(hj_sh_els).remove("name").remove("item_name"));
|
||||
|
||||
Record hj_sh_jzs = new Record();
|
||||
hj_sh_jzs.set("key", "hj_sh_3");
|
||||
hj_sh_jzs.set("name", "合计");
|
||||
hj_sh_jzs.set("item_name", "实售");
|
||||
hj_sh_jzs.set("product_name", "机制砂");
|
||||
hj_sh_jzs.set("order_num", hj_jzs_sh_order_num);
|
||||
hj_sh_jzs.set("weight", hj_jzs_sh_weight);
|
||||
hj_sh_jzs.set("total_price", hj_jzs_sh_total_price);
|
||||
retList.add(hj_sh_jzs);
|
||||
hj_sh_children.add(hj_sh_jzs);
|
||||
|
||||
Record hj_sh_czs = new Record();
|
||||
hj_sh_czs.set("key", "hj_sh_4");
|
||||
hj_sh_czs.set("name", "合计");
|
||||
hj_sh_czs.set("item_name", "实售");
|
||||
hj_sh_czs.set("product_name", "处置砂");
|
||||
hj_sh_czs.set("order_num", hj_czs_sh_order_num);
|
||||
hj_sh_czs.set("weight", hj_czs_sh_weight);
|
||||
hj_sh_czs.set("total_price", hj_czs_sh_total_price);
|
||||
retList.add(hj_sh_czs);
|
||||
hj_sh_children.add(hj_sh_czs);
|
||||
|
||||
Record hj_yh_1 = new Record();
|
||||
hj_yh_1.set("key", "hj_yh_1");
|
||||
hj_yh_1.set("name", "合计");
|
||||
hj_yh_1.set("item_name", "预售");
|
||||
hj_yh_1.set("product_name", "-");
|
||||
hj_yh_1.set("order_num", hj_yh_order_num);
|
||||
hj_yh_1.set("weight", hj_yh_weight);
|
||||
hj_yh_1.set("total_price", hj_yh_total_price);
|
||||
retList.add(hj_yh_1);
|
||||
hj_yh_children.add(hj_yh_1);
|
||||
|
||||
Record hj_sh = new Record();
|
||||
hj_sh.set("key", "hj_sh");
|
||||
hj_sh.set("item_name", "实售");
|
||||
hj_sh.set("children", hj_sh_children);
|
||||
|
||||
Record hj_yh = new Record();
|
||||
hj_yh.set("key", "hj_yh");
|
||||
hj_yh.set("item_name", "预售");
|
||||
hj_yh.set("children", hj_yh_children);
|
||||
|
||||
List<Record> hj_children = new ArrayList<>();
|
||||
hj_children.add(hj_sh);
|
||||
hj_children.add(hj_yh);
|
||||
|
||||
hj.set("key", "hj").set("name", "合计").set("children", hj_children);
|
||||
retChildren.add(hj);
|
||||
|
||||
// 总合计
|
||||
Record total = new Record();
|
||||
total.set("key", "total").set("name", "总合计").set("item_name", "-").set("product_name", "-")
|
||||
.set("order_num", hj_hs_sh_order_num + hj_els_sh_order_num + hj_jzs_sh_order_num + hj_czs_sh_order_num + hj_yh_order_num)
|
||||
.set("weight", hj_hs_sh_weight + hj_els_sh_weight + hj_jzs_sh_weight + hj_czs_sh_weight + hj_yh_weight)
|
||||
.set("total_price", hj_hs_sh_total_price + hj_els_sh_total_price + hj_jzs_sh_total_price+ hj_czs_sh_total_price + hj_yh_total_price);
|
||||
|
||||
retList.add(total);
|
||||
|
||||
retChildren.add(total);
|
||||
}
|
||||
|
||||
return type == 1 ? retChildren : retList;
|
||||
private String getLocalSaleSql(String params) {
|
||||
return "select p.id product_id, p.`name` product_name, ifnull(a.orderCount, 0) as order_num, ifnull(a.totalPrice, 0) as total_price, ifnull(a.weight, 0) as weight\n" +
|
||||
" from (\n" +
|
||||
" select t.product_id" +
|
||||
", count(t.sn) as orderCount" +
|
||||
", sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
|
||||
" from order_temp t \n" +
|
||||
" where t.sale_type = 0" +
|
||||
params +
|
||||
" group by t.product_id\n" +
|
||||
" ) a \n" +
|
||||
" left join product p on p.id = a.product_id order BY p.id ASC";
|
||||
|
||||
}
|
||||
|
||||
private void addTm(String tm, List<Object> list) {
|
||||
|
|
|
|||
|
|
@ -369,11 +369,11 @@ public class OrderStatController extends BaseController {
|
|||
public void statYearBySup() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statYearBySupLocal(tm, 2)));
|
||||
renderJson(Result.object(OrderStatService.me.statYearBySupLocal(tm, supermarket_id)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.yearsalestatExportBySupLocal(tm);
|
||||
Workbook wb = OrderStatService.me.yearsalestatExportBySupLocal(tm,supermarket_id);
|
||||
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
|
@ -385,11 +385,11 @@ public class OrderStatController extends BaseController {
|
|||
public void statYearBySup1() {
|
||||
String tm = get("tm");
|
||||
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||
Boolean stat_product = getBoolean("stat_product", false);
|
||||
Integer supermarket_id = getInt("supermarket_id");
|
||||
if (export == 0) {
|
||||
renderJson(Result.object(OrderStatService.me.statYearBySup1(tm)));
|
||||
renderJson(Result.object(OrderStatService.me.statYearBySupLocal(tm, supermarket_id)));
|
||||
} else {
|
||||
Workbook wb = OrderStatService.me.yearsalestatExportBySup(tm);
|
||||
Workbook wb = OrderStatService.me.yearsalestatExportBySupLocal(tm,supermarket_id);
|
||||
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue