dev
parent
c7c18bd88e
commit
d7b7127f55
|
|
@ -593,8 +593,34 @@ public class OrderStatService {
|
||||||
* @param tm
|
* @param tm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Record> salestatCustomer(String tm) {
|
public List<Record> salestatCustomer(String tm, Integer invoice_type) {
|
||||||
String sql = "select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
|
|
||||||
|
List<Record> dblist = null;
|
||||||
|
if (invoice_type != null) {
|
||||||
|
dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
|
||||||
|
" from (\n" +
|
||||||
|
" select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight\n" +
|
||||||
|
" from order_sale t\n" +
|
||||||
|
" where t.state = ? \n" +
|
||||||
|
" and t.invoice_type = ? \n" +
|
||||||
|
" and t.create_time like ? \n" +
|
||||||
|
" union all\n" +
|
||||||
|
" select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight\n" +
|
||||||
|
" from order_temp t\n" +
|
||||||
|
" where t.state = ? \n" +
|
||||||
|
" and t.invoice_type = ? \n" +
|
||||||
|
" and t.create_time like ? \n" +
|
||||||
|
" ) t\n" +
|
||||||
|
" group by t.customer_name",
|
||||||
|
OrderStateEnum.RECEIVED.getStateid(),
|
||||||
|
invoice_type,
|
||||||
|
tm + "%",
|
||||||
|
OrderStateEnum.RECEIVED.getStateid(),
|
||||||
|
invoice_type,
|
||||||
|
tm + "%"
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
dblist = Db.find("select max(t.customer_id) id, t.customer_name name, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
|
||||||
" from (\n" +
|
" from (\n" +
|
||||||
" select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight\n" +
|
" select ifnull(t.customer_id, t.customer_name) customer_id, t.customer_name, t.paid, t.total_price, t.weight\n" +
|
||||||
" from order_sale t\n" +
|
" from order_sale t\n" +
|
||||||
|
|
@ -606,9 +632,13 @@ public class OrderStatService {
|
||||||
" where t.state = ? \n" +
|
" where t.state = ? \n" +
|
||||||
" and t.create_time like ? \n" +
|
" and t.create_time like ? \n" +
|
||||||
" ) t\n" +
|
" ) t\n" +
|
||||||
" group by t.customer_name";
|
" group by t.customer_name",
|
||||||
|
OrderStateEnum.RECEIVED.getStateid(),
|
||||||
List<Record> dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), tm + "%", OrderStateEnum.RECEIVED.getStateid(), tm + "%");
|
tm + "%",
|
||||||
|
OrderStateEnum.RECEIVED.getStateid(),
|
||||||
|
tm + "%"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Record total = new Record();
|
Record total = new Record();
|
||||||
total.set("id", 0);
|
total.set("id", 0);
|
||||||
|
|
@ -732,8 +762,8 @@ public class OrderStatService {
|
||||||
* @param tm
|
* @param tm
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Workbook salestatCustomerExport(String tm, String title, String subtitle) {
|
public Workbook salestatCustomerExport(String tm, String title, String subtitle, Integer invoice_type) {
|
||||||
List<Record> list = salestatCustomer(tm);
|
List<Record> list = salestatCustomer(tm, invoice_type);
|
||||||
Workbook wb = new XSSFWorkbook();
|
Workbook wb = new XSSFWorkbook();
|
||||||
Sheet sheet = wb.createSheet(title);
|
Sheet sheet = wb.createSheet(title);
|
||||||
|
|
||||||
|
|
@ -789,7 +819,7 @@ public class OrderStatService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Workbook daysalestatCustomerExport(String tm) {
|
public Workbook daysalestatCustomerExport(String tm, Integer invoice_type) {
|
||||||
String title = "销售日统计";
|
String title = "销售日统计";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -803,10 +833,10 @@ public class OrderStatService {
|
||||||
|
|
||||||
subtitle += title;
|
subtitle += title;
|
||||||
|
|
||||||
return salestatCustomerExport(tm, title, subtitle);
|
return salestatCustomerExport(tm, title, subtitle, invoice_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Workbook monthsalestatCustomerExport(String tm) {
|
public Workbook monthsalestatCustomerExport(String tm, Integer invoice_type) {
|
||||||
String title = "销售月统计";
|
String title = "销售月统计";
|
||||||
|
|
||||||
// 副标题 start
|
// 副标题 start
|
||||||
|
|
@ -819,7 +849,7 @@ public class OrderStatService {
|
||||||
|
|
||||||
subtitle += title;
|
subtitle += title;
|
||||||
|
|
||||||
return salestatCustomerExport(tm, title, subtitle);
|
return salestatCustomerExport(tm, title, subtitle, invoice_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -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 = "20201111";
|
public static final String CLINET_VERSION = "20201130";
|
||||||
|
|
||||||
public static String getRootPath() {
|
public static String getRootPath() {
|
||||||
return PathKit.getWebRootPath()
|
return PathKit.getWebRootPath()
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,29 @@
|
||||||
package com.cowr.service.ssjygl.jobs;
|
package com.cowr.service.ssjygl.jobs;
|
||||||
|
|
||||||
import com.cowr.common.enums.OrderStateEnum;
|
import com.cowr.common.enums.OrderStateEnum;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.model.Ordercluster;
|
import com.cowr.model.Ordercluster;
|
||||||
import com.cowr.model.SyncTask;
|
import com.cowr.model.SyncTask;
|
||||||
|
import com.cowr.model.Sysuser;
|
||||||
|
import com.cowr.service.ssjygl.order.ordercluster.OrderclusterSyncService;
|
||||||
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
||||||
|
import com.cowr.ssjygl.order.ordercluster.OrderclusterService;
|
||||||
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.IAtom;
|
import com.jfinal.plugin.activerecord.IAtom;
|
||||||
import org.quartz.Job;
|
import org.quartz.Job;
|
||||||
import org.quartz.JobExecutionContext;
|
import org.quartz.JobExecutionContext;
|
||||||
|
|
||||||
import java.util.Calendar;
|
import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class CheckUndonOrderclusterJob implements Job {
|
public class CheckUndonOrderclusterJob implements Job {
|
||||||
private static Log log = Log.getLog(CheckUndonOrderclusterJob.class);
|
private static Log log = Log.getLog(CheckUndonOrderclusterJob.class);
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void execute(JobExecutionContext jobExecutionContext) {
|
* 关闭到时间未完成的 ordercluster
|
||||||
|
*/
|
||||||
|
public void closeOrder() {
|
||||||
try {
|
try {
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
c.set(Calendar.HOUR_OF_DAY, 0);
|
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
|
@ -88,4 +92,77 @@ public class CheckUndonOrderclusterJob implements Job {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转结未完成的 ordercluster
|
||||||
|
*/
|
||||||
|
public void forwardOrder() {
|
||||||
|
try {
|
||||||
|
Calendar c = Calendar.getInstance();
|
||||||
|
c.set(Calendar.HOUR_OF_DAY, 0);
|
||||||
|
c.set(Calendar.MINUTE, 0);
|
||||||
|
c.set(Calendar.SECOND, 0);
|
||||||
|
c.set(Calendar.MILLISECOND, 0);
|
||||||
|
|
||||||
|
List<Ordercluster> undonlist = Ordercluster.dao.find(
|
||||||
|
"select * from ordercluster t \n" +
|
||||||
|
" where t.state < ? \n" +
|
||||||
|
" and t.cutoff_time < ? ",
|
||||||
|
OrderStateEnum.RECEIVED.getStateid(), c.getTime());
|
||||||
|
|
||||||
|
if (undonlist != null && !undonlist.isEmpty()) {
|
||||||
|
log.debug("完成未执行完的订单 %d", undonlist.size());
|
||||||
|
|
||||||
|
for (Ordercluster ordercluster : undonlist) {
|
||||||
|
int ordercluster_id = ordercluster.getId();
|
||||||
|
BigDecimal over_weight = OrderclusterService.me.getOverWeight(ordercluster_id); // 按客户找集团订单已完成量
|
||||||
|
BigDecimal surplus_weight = ordercluster.getTotalWeight().subtract(over_weight); // 剩余未完成量
|
||||||
|
Sysuser user = new Sysuser();
|
||||||
|
user.setId(0);
|
||||||
|
user.setName("system");
|
||||||
|
|
||||||
|
Calendar cold = Calendar.getInstance();
|
||||||
|
cold.setTime(ordercluster.getCutoffTime());
|
||||||
|
cold.set(Calendar.DATE, 1);
|
||||||
|
Date cutoff_time = cold.getTime();
|
||||||
|
|
||||||
|
Result ret;
|
||||||
|
|
||||||
|
if (ordercluster.getCustomerId() != null) {
|
||||||
|
ret = OrderclusterSyncService.me.forwardCluster(ordercluster_id, surplus_weight, cutoff_time, user);
|
||||||
|
} else {
|
||||||
|
String trucks = Db.queryStr("select group_concat(t.truck_license) trucks from ordercluster_truck t\n" +
|
||||||
|
" where t.ordercluster_id = ?\n" +
|
||||||
|
" group by t.ordercluster_id", ordercluster_id);
|
||||||
|
ret = OrderclusterSyncService.me.forwardTemp(ordercluster_id, surplus_weight, cutoff_time, trucks, user);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.getCode() != Result.SUCCESS) {
|
||||||
|
log.error("自动转结失败。ordercluster_id:%s, err msg: %s", ordercluster_id, ret.getMsg());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Thread.sleep(1000);
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.debug("自动转结完成, %s");
|
||||||
|
} else {
|
||||||
|
log.debug("无未完成的订单");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void execute(JobExecutionContext jobExecutionContext) {
|
||||||
|
try {
|
||||||
|
forwardOrder();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -142,11 +142,12 @@ public class OrderStatController extends BaseController {
|
||||||
@Before(DayValidator.class)
|
@Before(DayValidator.class)
|
||||||
public void daystatCustomer() {
|
public void daystatCustomer() {
|
||||||
String tm = get("tm");
|
String tm = get("tm");
|
||||||
|
Integer invoice_type = getInt("invoice_type");
|
||||||
int export = getInt("export", 0);
|
int export = getInt("export", 0);
|
||||||
if (export == 0) {
|
if (export == 0) {
|
||||||
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm)));
|
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type)));
|
||||||
} else {
|
} else {
|
||||||
Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm);
|
Workbook wb = OrderStatService.me.daysalestatCustomerExport(tm, invoice_type);
|
||||||
render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
render(new ExcelRender(tm + "_销售日统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -157,12 +158,13 @@ public class OrderStatController extends BaseController {
|
||||||
@Before(MonthValidator.class)
|
@Before(MonthValidator.class)
|
||||||
public void monthstatCustomer() {
|
public void monthstatCustomer() {
|
||||||
String tm = get("tm");
|
String tm = get("tm");
|
||||||
|
Integer invoice_type = getInt("invoice_type");
|
||||||
int export = getInt("export", 0);
|
int export = getInt("export", 0);
|
||||||
|
|
||||||
if (export == 0) {
|
if (export == 0) {
|
||||||
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm)));
|
renderJson(Result.object(OrderStatService.me.salestatCustomer(tm, invoice_type)));
|
||||||
} else {
|
} else {
|
||||||
Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm);
|
Workbook wb = OrderStatService.me.monthsalestatCustomerExport(tm, invoice_type);
|
||||||
render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
render(new ExcelRender(tm + "_销售月统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue