dev
parent
3a2651834d
commit
92f3a501ed
|
|
@ -5,8 +5,10 @@ import com.cowr.common.utils.DateTimeUtil;
|
||||||
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 java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class OverallService {
|
public class OverallService {
|
||||||
public static OverallService me = new OverallService();
|
public static OverallService me = new OverallService();
|
||||||
|
|
@ -118,11 +120,17 @@ public class OverallService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
public Record stat(){
|
public Record stat(Integer supermarket_id){
|
||||||
long st = System.currentTimeMillis();
|
long st = System.currentTimeMillis();
|
||||||
Record out = new Record();
|
Record out = new Record();
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
List<Object> params1 = new ArrayList<>();
|
||||||
|
List<Object> params2 = new ArrayList<>();
|
||||||
|
|
||||||
|
params1.add(OrderStateEnum.INVALID.getStateid());
|
||||||
|
params2.add(OrderStateEnum.RECEIVED.getStateid());
|
||||||
|
|
||||||
|
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
c.setTime(now);
|
c.setTime(now);
|
||||||
|
|
@ -137,16 +145,16 @@ public class OverallService {
|
||||||
|
|
||||||
String premonthtm = DateTimeUtil.sd.get().format(c.getTime()); // 前一月
|
String premonthtm = DateTimeUtil.sd.get().format(c.getTime()); // 前一月
|
||||||
|
|
||||||
out.set("ordercluster", Db.findFirst("select \n" +
|
String sql_ordercluster = "select \n" +
|
||||||
" sum(t.total_weight) total_weight, \n" +
|
" sum(t.total_weight) total_weight, \n" +
|
||||||
" sum(case when t.cutoff_time like '" + nowmonttm +"%' then t.total_weight end ) month_total_weight, \n" +
|
" sum(case when t.cutoff_time like '" + nowmonttm +"%' then t.total_weight end ) month_total_weight, \n" +
|
||||||
" sum(case when t.cutoff_time like '" + nowdaytm + "%' then t.total_weight end ) day_total_weight, \n" +
|
" sum(case when t.cutoff_time like '" + nowdaytm + "%' then t.total_weight end ) day_total_weight, \n" +
|
||||||
" sum(case when t.cutoff_time like '" + premonthtm + "%' then t.total_weight end ) before_month_total_weight, \n" +
|
" sum(case when t.cutoff_time like '" + premonthtm + "%' then t.total_weight end ) before_month_total_weight, \n" +
|
||||||
" sum(case when t.cutoff_time like '" + predaytm + "%' then t.total_weight end ) before_day_total_weight \n" +
|
" sum(case when t.cutoff_time like '" + predaytm + "%' then t.total_weight end ) before_day_total_weight \n" +
|
||||||
" from ordercluster t\n" +
|
" from ordercluster t\n" +
|
||||||
" where t.state < ?", OrderStateEnum.INVALID.getStateid()));
|
" where t.state < ?";
|
||||||
|
|
||||||
out.set("ordercluster_truck", Db.find("select\n" +
|
String sql_ordercluster_truck = "select\n" +
|
||||||
" count(t.id) cnt,\n" +
|
" count(t.id) cnt,\n" +
|
||||||
" sum(case when t.change_time like '" + nowmonttm +"%' then 1 else 0 end) month_cnt,\n" +
|
" sum(case when t.change_time like '" + nowmonttm +"%' then 1 else 0 end) month_cnt,\n" +
|
||||||
" sum(case when t.change_time like '" + nowdaytm + "%' then 1 else 0 end) day_cnt,\n" +
|
" sum(case when t.change_time like '" + nowdaytm + "%' then 1 else 0 end) day_cnt,\n" +
|
||||||
|
|
@ -154,9 +162,38 @@ public class OverallService {
|
||||||
" sum(case when t.change_time like '" + predaytm + "%' then 1 else 0 end) before_day_cnt\n" +
|
" sum(case when t.change_time like '" + predaytm + "%' then 1 else 0 end) before_day_cnt\n" +
|
||||||
" from ordercluster_truck t\n" +
|
" from ordercluster_truck t\n" +
|
||||||
" left join ordercluster c on c.id = t.ordercluster_id\n" +
|
" left join ordercluster c on c.id = t.ordercluster_id\n" +
|
||||||
" where c.state < ?", OrderStateEnum.INVALID.getStateid()));
|
" where c.state < ?";
|
||||||
|
|
||||||
out.set("by_supermarket", Db.find(" select \n" +
|
String sql_by_customer = "\n" +
|
||||||
|
" select\n" +
|
||||||
|
" t.customer_id,\n" +
|
||||||
|
" ifnull(max(case when t.customer_id is null then null else t.customer_name end), '零散客户') customer_name,\n" +
|
||||||
|
" sum(t.weight) weight,\n" +
|
||||||
|
" sum(t.total_price) total_price,\n" +
|
||||||
|
" count(*) truck_cnt,\n" +
|
||||||
|
" \n" +
|
||||||
|
" ifnull(sum(case when t.create_time like '" + nowmonttm +"%' then t.weight end), 0) month_weight,\n" +
|
||||||
|
" ifnull(sum(case when t.create_time like '" + nowdaytm + "%' then t.weight end), 0) day_weight,\n" +
|
||||||
|
" \n" +
|
||||||
|
" ifnull(sum(case when t.create_time like '" + nowmonttm +"%' then t.total_price end), 0) month_total_price,\n" +
|
||||||
|
" ifnull(sum(case when t.create_time like '" + nowdaytm + "%' then t.total_price end), 0) day_total_price,\n" +
|
||||||
|
" \n" +
|
||||||
|
" count(case when t.create_time like '" + nowmonttm +"%' then t.sn end) month_truck_cnt,\n" +
|
||||||
|
" count(case when t.create_time like '" + nowdaytm + "%' then t.sn end) day_truck_cnt,\n" +
|
||||||
|
" \n" +
|
||||||
|
" ifnull(sum(case when t.create_time like '" + premonthtm + "%' then t.weight end), 0) before_month_weight,\n" +
|
||||||
|
" ifnull(sum(case when t.create_time like '" + predaytm + "%' then t.weight end), 0) before_day_weight,\n" +
|
||||||
|
" \n" +
|
||||||
|
" ifnull(sum(case when t.create_time like '" + premonthtm + "%' then t.total_price end), 0) before_month_total_price,\n" +
|
||||||
|
" ifnull(sum(case when t.create_time like '" + predaytm + "%' then t.total_price end), 0) before_day_total_price,\n" +
|
||||||
|
" \n" +
|
||||||
|
" count(case when t.create_time like '" + premonthtm + "%' then t.sn end) before_month_truck_cnt,\n" +
|
||||||
|
" count(case when t.create_time like '" + predaytm + "%' then t.sn end) before_day_truck_cnt\n" +
|
||||||
|
" from order_temp t\n" +
|
||||||
|
" where t.state = ?\n";
|
||||||
|
|
||||||
|
|
||||||
|
String sql_by_supermarket = " select \n" +
|
||||||
" s.id supermarket_id,\n" +
|
" s.id supermarket_id,\n" +
|
||||||
" s.name supermarket_name,\n" +
|
" s.name supermarket_name,\n" +
|
||||||
" s.name2 supermarket_name2,\n" +
|
" s.name2 supermarket_name2,\n" +
|
||||||
|
|
@ -201,38 +238,30 @@ public class OverallService {
|
||||||
" count(case when t.create_time like '" + premonthtm + "%' then t.sn end) before_month_truck_cnt,\n" +
|
" count(case when t.create_time like '" + premonthtm + "%' then t.sn end) before_month_truck_cnt,\n" +
|
||||||
" count(case when t.create_time like '" + predaytm + "%' then t.sn end) before_day_truck_cnt\n" +
|
" count(case when t.create_time like '" + predaytm + "%' then t.sn end) before_day_truck_cnt\n" +
|
||||||
" from order_temp t\n" +
|
" from order_temp t\n" +
|
||||||
" where t.state = ?\n" +
|
" where t.state = ?\n";
|
||||||
" group by t.supermarket_id\n" +
|
|
||||||
" ) a on a.supermarket_id = s.id;", OrderStateEnum.RECEIVED.getStateid()));
|
|
||||||
|
|
||||||
out.set("by_customer", Db.find("\n" +
|
if(supermarket_id != null){
|
||||||
"select\n" +
|
sql_ordercluster += " and t.supermarket_id = ? ";
|
||||||
" t.customer_id,\n" +
|
sql_ordercluster_truck += " and c.supermarket_id = ? ";
|
||||||
" ifnull(max(case when t.customer_id is null then null else t.customer_name end), '零散客户') customer_name,\n" +
|
sql_by_customer += " and t.supermarket_id = ? ";
|
||||||
" sum(t.weight) weight,\n" +
|
|
||||||
" sum(t.total_price) total_price,\n" +
|
params1.add(supermarket_id);
|
||||||
" count(*) truck_cnt,\n" +
|
params2.add(supermarket_id);
|
||||||
" \n" +
|
|
||||||
" ifnull(sum(case when t.create_time like '" + nowmonttm +"%' then t.weight end), 0) month_weight,\n" +
|
out.set("by_supermarket", Db.find(sql_by_supermarket +
|
||||||
" ifnull(sum(case when t.create_time like '" + nowdaytm + "%' then t.weight end), 0) day_weight,\n" +
|
" and t.supermarket_id = ? " +
|
||||||
" \n" +
|
" group by t.supermarket_id\n" +
|
||||||
" ifnull(sum(case when t.create_time like '" + nowmonttm +"%' then t.total_price end), 0) month_total_price,\n" +
|
" ) a on a.supermarket_id = s.id \n" +
|
||||||
" ifnull(sum(case when t.create_time like '" + nowdaytm + "%' then t.total_price end), 0) day_total_price,\n" +
|
" where s.id = ? ", OrderStateEnum.RECEIVED.getStateid(), supermarket_id, supermarket_id));
|
||||||
" \n" +
|
}else{
|
||||||
" count(case when t.create_time like '" + nowmonttm +"%' then t.sn end) month_truck_cnt,\n" +
|
out.set("by_supermarket", Db.find( sql_by_supermarket +
|
||||||
" count(case when t.create_time like '" + nowdaytm + "%' then t.sn end) day_truck_cnt,\n" +
|
" group by t.supermarket_id\n" +
|
||||||
" \n" +
|
" ) a on a.supermarket_id = s.id", OrderStateEnum.RECEIVED.getStateid()));
|
||||||
" ifnull(sum(case when t.create_time like '" + premonthtm + "%' then t.weight end), 0) before_month_weight,\n" +
|
}
|
||||||
" ifnull(sum(case when t.create_time like '" + predaytm + "%' then t.weight end), 0) before_day_weight,\n" +
|
|
||||||
" \n" +
|
out.set("ordercluster", Db.findFirst(sql_ordercluster, params1.toArray()));
|
||||||
" ifnull(sum(case when t.create_time like '" + premonthtm + "%' then t.total_price end), 0) before_month_total_price,\n" +
|
out.set("ordercluster_truck", Db.find(sql_ordercluster_truck, params1.toArray()));
|
||||||
" ifnull(sum(case when t.create_time like '" + predaytm + "%' then t.total_price end), 0) before_day_total_price,\n" +
|
out.set("by_customer", Db.find(sql_by_customer + " group by t.customer_id", params2.toArray()));
|
||||||
" \n" +
|
|
||||||
" count(case when t.create_time like '" + premonthtm + "%' then t.sn end) before_month_truck_cnt,\n" +
|
|
||||||
" count(case when t.create_time like '" + predaytm + "%' then t.sn end) before_day_truck_cnt\n" +
|
|
||||||
"from order_temp t\n" +
|
|
||||||
"where t.state = ?\n" +
|
|
||||||
"group by t.customer_id", OrderStateEnum.RECEIVED.getStateid()));
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ import com.cowr.model.Supermarket;
|
||||||
import com.cowr.ssjygl.CacheData;
|
import com.cowr.ssjygl.CacheData;
|
||||||
import com.cowr.ssjygl.cctv.CctvController;
|
import com.cowr.ssjygl.cctv.CctvController;
|
||||||
import com.cowr.local.ssjygl.prepay.PrepayController;
|
import com.cowr.local.ssjygl.prepay.PrepayController;
|
||||||
import com.cowr.ssjygl.overall.OverallController;
|
import com.cowr.local.ssjygl.overall.OverallController;
|
||||||
import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
|
import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
|
||||||
import com.cowr.local.ssjygl.stat.sale.OrderStatController;
|
import com.cowr.local.ssjygl.stat.sale.OrderStatController;
|
||||||
import com.cowr.ssjygl.stat.transfer.OrderTransferStatController;
|
import com.cowr.ssjygl.stat.transfer.OrderTransferStatController;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.cowr.local.ssjygl.overall;
|
||||||
|
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.local.ssjygl.system.sysuser.SysuserSyncService;
|
||||||
|
import com.cowr.model.Sysuser;
|
||||||
|
import com.cowr.ssjygl.overall.OverallService;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
|
||||||
|
public class OverallController extends Controller {
|
||||||
|
public void stat(){
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
// 是客户账户
|
||||||
|
if (tokenuser == null || tokenuser.getEntityId() == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
renderJson(Result.success(OverallService.me.stat(tokenuser.getEntityId())));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -42,7 +42,7 @@ import com.cowr.common.Const;
|
||||||
import com.cowr.common.plugin.QuartzPlugin;
|
import com.cowr.common.plugin.QuartzPlugin;
|
||||||
import com.cowr.ssjygl.cctv.CctvController;
|
import com.cowr.ssjygl.cctv.CctvController;
|
||||||
import com.cowr.service.ssjygl.prepay.PrepayController;
|
import com.cowr.service.ssjygl.prepay.PrepayController;
|
||||||
import com.cowr.ssjygl.overall.OverallController;
|
import com.cowr.service.ssjygl.overall.OverallController;
|
||||||
import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
|
import com.cowr.ssjygl.stat.purchase.OrderPurchaseStatController;
|
||||||
import com.cowr.service.ssjygl.stat.sale.OrderStatController;
|
import com.cowr.service.ssjygl.stat.sale.OrderStatController;
|
||||||
import com.cowr.ssjygl.stat.transfer.OrderTransferStatController;
|
import com.cowr.ssjygl.stat.transfer.OrderTransferStatController;
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
package com.cowr.ssjygl.overall;
|
package com.cowr.service.ssjygl.overall;
|
||||||
|
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.ssjygl.overall.OverallService;
|
||||||
import com.jfinal.core.Controller;
|
import com.jfinal.core.Controller;
|
||||||
|
|
||||||
public class OverallController extends Controller {
|
public class OverallController extends Controller {
|
||||||
public void stat(){
|
public void stat(){
|
||||||
renderJson(Result.success(OverallService.me.stat()));
|
renderJson(Result.success(OverallService.me.stat(null)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue