固定配额改成时段限制,不在做每日配额
parent
ec34b10022
commit
f50687ae2a
|
|
@ -144,4 +144,17 @@ public class DateTimeUtil {
|
||||||
|
|
||||||
return c.getTime().getTime() >= date.getTime();
|
return c.getTime().getTime() >= date.getTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 起始时间是否小于等于结束时间
|
||||||
|
*/
|
||||||
|
public static boolean isStmLtEtm(String stm, String etm) {
|
||||||
|
try {
|
||||||
|
Date t1 = sdf.get().parse(stm);
|
||||||
|
Date t2 = sdf.get().parse(etm);
|
||||||
|
return t1.getTime() <= t2.getTime();
|
||||||
|
} catch (Exception e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -340,13 +340,25 @@ public class OrderclusterService extends BaseService {
|
||||||
return Db.find(sql, paraList.toArray());
|
return Db.find(sql, paraList.toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Record> undonlist(int supermarket_id, String customer_name, String cutoff_time) {
|
public List<Record> undonlist(int supermarket_id, String customer_name, String start_time, String cutoff_time) {
|
||||||
|
List<Object> ts = new ArrayList<>();
|
||||||
|
ts.add(OrderStateEnum.RECEIVED.getStateid());
|
||||||
|
ts.add(start_time + " 00:00:00");
|
||||||
|
ts.add(cutoff_time + " 23:59:59");
|
||||||
|
ts.add(start_time + " 00:00:00");
|
||||||
|
ts.add(cutoff_time + " 23:59:59");
|
||||||
|
ts.add(start_time + " 00:00:00");
|
||||||
|
ts.add(cutoff_time + " 23:59:59");
|
||||||
|
ts.add(supermarket_id);
|
||||||
|
ts.add(customer_name);
|
||||||
String sql = "select * from ordercluster t \n" +
|
String sql = "select * from ordercluster t \n" +
|
||||||
" where t.state < ? \n" +
|
" where t.state < ? \n" +
|
||||||
" and t.cutoff_time like ? \n" +
|
" and (t.start_time >= ? and t.start_time <= ?) \n" +
|
||||||
|
" or (t.start_time <= ? and t.cutoff_time >= ?) \n" +
|
||||||
|
" or (t.cutoff_time >= ? and t.cutoff_time <= ?) \n" +
|
||||||
" and t.supermarket_id = ? \n" +
|
" and t.supermarket_id = ? \n" +
|
||||||
" and t.customer_name = ? ";
|
" and t.customer_name = ? ";
|
||||||
return Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), cutoff_time + "%", supermarket_id, customer_name);
|
return Db.find(sql, ts.toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -854,11 +854,12 @@ public class OrderStatService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销售月逐日统计
|
* 销售月逐日统计
|
||||||
*
|
* @param stm
|
||||||
* @param tm YYYY-MM
|
* @param etm
|
||||||
|
* @param supermarket_id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public List<Record> mdstat(String tm, Integer supermarket_id) {
|
public List<Record> mdstat(String stm, String etm, Integer supermarket_id) {
|
||||||
String paramsSql = "";
|
String paramsSql = "";
|
||||||
if (supermarket_id != null) {
|
if (supermarket_id != null) {
|
||||||
paramsSql = "and t.supermarket_id = ? \n";
|
paramsSql = "and t.supermarket_id = ? \n";
|
||||||
|
|
@ -870,39 +871,40 @@ public class OrderStatService {
|
||||||
" from order_sale t\n" +
|
" from order_sale t\n" +
|
||||||
" where t.state = ? \n" +
|
" where t.state = ? \n" +
|
||||||
paramsSql +
|
paramsSql +
|
||||||
" and t.create_time like ? \n" +
|
" and t.create_time >= ? \n" +
|
||||||
|
" and t.create_time <= ? \n" +
|
||||||
" union all\n" +
|
" union all\n" +
|
||||||
" select t.create_time, t.weight, t.paid, t.total_price\n" +
|
" select t.create_time, t.weight, t.paid, t.total_price\n" +
|
||||||
" from order_temp t\n" +
|
" from order_temp t\n" +
|
||||||
" where t.state = ? \n" +
|
" where t.state = ? \n" +
|
||||||
paramsSql +
|
paramsSql +
|
||||||
" and t.create_time like ? \n" +
|
" and t.create_time >= ? \n" +
|
||||||
|
" and t.create_time <= ? \n" +
|
||||||
") t\n" +
|
") t\n" +
|
||||||
"group by date_format(t.create_time, '%Y-%m-%d')\n" +
|
"group by date_format(t.create_time, '%Y-%m-%d')\n" +
|
||||||
"order by date_format(t.create_time, '%Y-%m-%d')";
|
"order by date_format(t.create_time, '%Y-%m-%d')";
|
||||||
|
|
||||||
List<Record> dblist;
|
List<Record> dblist;
|
||||||
if (supermarket_id != null) {
|
if (supermarket_id != null) {
|
||||||
dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), supermarket_id, tm + "%", OrderStateEnum.RECEIVED.getStateid(), supermarket_id, tm + "%");
|
dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), supermarket_id, stm, etm, OrderStateEnum.RECEIVED.getStateid(), supermarket_id, stm, etm);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), tm + "%", OrderStateEnum.RECEIVED.getStateid(), tm + "%");
|
dblist = Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), stm, etm, OrderStateEnum.RECEIVED.getStateid(), stm, etm);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Record total = new Record();
|
Record total = new Record();
|
||||||
|
total.set("id", dblist.size() + 1);
|
||||||
total.set("date", null);
|
total.set("date", null);
|
||||||
total.set("weight", 0.0d);
|
total.set("weight", 0.0d);
|
||||||
total.set("totalPrice", 0.0d);
|
total.set("totalPrice", 0.0d);
|
||||||
|
|
||||||
for (int i = 0; i < dblist.size(); i++) {
|
for (int i = 0; i < dblist.size(); i++) {
|
||||||
Record record = dblist.get(i);
|
Record record = dblist.get(i);
|
||||||
|
record.set("id", i + 1);
|
||||||
double weight = record.getDouble("weight");
|
double weight = record.getDouble("weight");
|
||||||
double totalPrice = record.getDouble("totalPrice");
|
double totalPrice = record.getDouble("totalPrice");
|
||||||
|
|
||||||
if (i > 0) {
|
if (i > 0) {
|
||||||
Record preobj = dblist.get(i - 1);
|
Record preobj = dblist.get(i - 1);
|
||||||
|
|
||||||
record.set("sweight", preobj.getDouble("sweight") + weight);
|
record.set("sweight", preobj.getDouble("sweight") + weight);
|
||||||
record.set("stotalPrice", preobj.getDouble("stotalPrice") + totalPrice);
|
record.set("stotalPrice", preobj.getDouble("stotalPrice") + totalPrice);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -921,19 +923,21 @@ public class OrderStatService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 销售月逐日统计
|
* 销售月逐日统计
|
||||||
*
|
* @param stm
|
||||||
* @param tm YYYY-MM
|
* @param etm
|
||||||
|
* @param supermarket_id
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Workbook mdstatExport(String tm, Integer supermarket_id) {
|
public Workbook mdstatExport(String stm, String etm, Integer supermarket_id) {
|
||||||
List<Record> list = mdstat(tm, supermarket_id);
|
List<Record> list = mdstat(stm, etm, supermarket_id);
|
||||||
Workbook wb = new XSSFWorkbook();
|
Workbook wb = new XSSFWorkbook();
|
||||||
Sheet sheet = wb.createSheet("销售月逐日统计");
|
Sheet sheet = wb.createSheet("销售月逐日统计");
|
||||||
|
|
||||||
// 副标题 start
|
// 副标题 start
|
||||||
String subtitle = "";
|
String subtitle = "";
|
||||||
try {
|
try {
|
||||||
subtitle += DateTimeUtil.sdfym.get().format(DateTimeUtil.sd.get().parse(tm));
|
subtitle += DateTimeUtil.sdfymd.get().format(DateTimeUtil.sdf.get().parse(stm)) + "至";
|
||||||
|
subtitle += DateTimeUtil.sdfymd.get().format(DateTimeUtil.sdf.get().parse(etm));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
@ -945,12 +949,12 @@ public class OrderStatService {
|
||||||
int a = 0;
|
int a = 0;
|
||||||
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("销售金额截止累计");
|
||||||
// 表头 end
|
// 表头 end
|
||||||
|
|
||||||
int end_col = 4;
|
int end_col = 2; // 4
|
||||||
int datalen = list.size();
|
int datalen = list.size();
|
||||||
|
|
||||||
for (int i = 0; i < datalen; i++) {
|
for (int i = 0; i < datalen; i++) {
|
||||||
|
|
@ -965,22 +969,22 @@ public class OrderStatService {
|
||||||
|
|
||||||
row.createCell(a++).setCellValue(date);
|
row.createCell(a++).setCellValue(date);
|
||||||
row.createCell(a++).setCellValue(record.getDouble("weight"));
|
row.createCell(a++).setCellValue(record.getDouble("weight"));
|
||||||
row.createCell(3).setCellValue(record.getDouble("totalPrice"));
|
row.createCell(a++).setCellValue(record.getDouble("totalPrice"));
|
||||||
} else {
|
} else {
|
||||||
date = date.substring(5, 10).replace("-", "月") + "日";
|
date = date.substring(0, 10);
|
||||||
row.createCell(a++).setCellValue(date);
|
row.createCell(a++).setCellValue(date);
|
||||||
row.createCell(a++).setCellValue(record.getDouble("weight"));
|
row.createCell(a++).setCellValue(record.getDouble("weight"));
|
||||||
row.createCell(a++).setCellValue(record.getDouble("sweight"));
|
// row.createCell(a++).setCellValue(record.getDouble("sweight"));
|
||||||
row.createCell(a++).setCellValue(record.getDouble("totalPrice"));
|
row.createCell(a++).setCellValue(record.getDouble("totalPrice"));
|
||||||
row.createCell(a++).setCellValue(record.getDouble("stotalPrice"));
|
// row.createCell(a++).setCellValue(record.getDouble("stotalPrice"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sheet.setColumnWidth(0, (int) ((10 + 0.71) * 256));
|
sheet.setColumnWidth(0, (int) ((10 + 0.71) * 256));
|
||||||
sheet.setColumnWidth(1, (int) ((16 + 0.71) * 256));
|
sheet.setColumnWidth(1, (int) ((16 + 0.71) * 256));
|
||||||
sheet.setColumnWidth(2, (int) ((16 + 0.71) * 256));
|
sheet.setColumnWidth(2, (int) ((16 + 0.71) * 256));
|
||||||
sheet.setColumnWidth(3, (int) ((16 + 0.71) * 256));
|
// sheet.setColumnWidth(3, (int) ((16 + 0.71) * 256));
|
||||||
sheet.setColumnWidth(4, (int) ((18 + 0.71) * 256));
|
// sheet.setColumnWidth(4, (int) ((18 + 0.71) * 256));
|
||||||
|
|
||||||
ReportExcelStyle.setCommonStyle(wb, sheet, CacheData.print_vendor, subtitle, datalen, end_col, 3);
|
ReportExcelStyle.setCommonStyle(wb, sheet, CacheData.print_vendor, subtitle, datalen, end_col, 3);
|
||||||
|
|
||||||
|
|
@ -1325,7 +1329,7 @@ public class OrderStatService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tm == null) {
|
if (StrKit.isBlank(tm)) {
|
||||||
if (!StrKit.notBlank(stm, etm)) {
|
if (!StrKit.notBlank(stm, etm)) {
|
||||||
log.error("参数错误");
|
log.error("参数错误");
|
||||||
return new ArrayList<>();
|
return new ArrayList<>();
|
||||||
|
|
@ -1365,7 +1369,7 @@ public class OrderStatService {
|
||||||
paraTemp.add(product_id);
|
paraTemp.add(product_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = "select ifnull(a.customer_name, '民用') customer_name, max(a.customer_id), sum(a.weight) weight, sum(a.total_price) total_price, count(a.sn) orderCount, a.product_id, max(a.product_name) product_name \n" +
|
sql = "select ifnull(a.customer_name, '民用') customer_name, max(a.customer_id) customer_id, sum(a.weight) weight, sum(a.total_price) total_price, count(a.sn) orderCount, a.product_id, max(a.product_name) product_name \n" +
|
||||||
" from( \n" +
|
" from( \n" +
|
||||||
sale_sql +
|
sale_sql +
|
||||||
" union \n " +
|
" union \n " +
|
||||||
|
|
@ -1374,7 +1378,7 @@ public class OrderStatService {
|
||||||
" left join customer c on c.id = a.customer_id \n" +
|
" left join customer c on c.id = a.customer_id \n" +
|
||||||
" group by a.customer_name, a.product_id ";
|
" group by a.customer_name, a.product_id ";
|
||||||
} else {
|
} else {
|
||||||
sql = "select ifnull(a.customer_name, '民用') customer_name, max(a.customer_id), sum(a.weight) weight, sum(a.total_price) total_price, count(a.sn) orderCount \n" +
|
sql = "select ifnull(a.customer_name, '民用') customer_name, max(a.customer_id) customer_id, sum(a.weight) weight, sum(a.total_price) total_price, count(a.sn) orderCount \n" +
|
||||||
" from( \n" +
|
" from( \n" +
|
||||||
sale_sql +
|
sale_sql +
|
||||||
" union \n " +
|
" union \n " +
|
||||||
|
|
@ -2217,4 +2221,89 @@ public class OrderStatService {
|
||||||
}
|
}
|
||||||
return recordList;
|
return recordList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Record yearStatisticsByCustomerId(String year, Integer customer_id, String customer_name, Integer type) {
|
||||||
|
String sql;
|
||||||
|
Record rec;
|
||||||
|
if (type == 1) { // 固定配额
|
||||||
|
if (StrKit.isBlank(year) || customer_id == null) {
|
||||||
|
log.error("参数错误");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
sql = "SELECT\n" +
|
||||||
|
" c.*\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
" (\n" +
|
||||||
|
" SELECT\n" +
|
||||||
|
" a.customer_id,\n" +
|
||||||
|
" u.name customer_name,\n" +
|
||||||
|
" a.total_price,\n" +
|
||||||
|
" a.total_weight, \n" +
|
||||||
|
" a.total_amount total_amount,\n" +
|
||||||
|
" r.surplus total_surplus\n" +
|
||||||
|
" FROM\n" +
|
||||||
|
" (\n" +
|
||||||
|
" SELECT\n" +
|
||||||
|
" ifnull(o.customer_id, - 1) customer_id,\n" +
|
||||||
|
" count(o.sn) cnt,\n" +
|
||||||
|
" o.state,\n" +
|
||||||
|
" o.create_time,\n" +
|
||||||
|
" p.total_amount total_amount,\n" +
|
||||||
|
" sum(o.total_price) total_price,\n" +
|
||||||
|
" sum(o.weight) total_weight\n" +
|
||||||
|
" FROM\n" +
|
||||||
|
" order_temp o\n" +
|
||||||
|
" LEFT JOIN (\n" +
|
||||||
|
" SELECT\n" +
|
||||||
|
" d.customer_id,\n" +
|
||||||
|
" sum(d.amount) total_amount\n" +
|
||||||
|
" FROM\n" +
|
||||||
|
" prepay_detail d\n" +
|
||||||
|
" WHERE\n" +
|
||||||
|
" d.state = 2\n" +
|
||||||
|
" AND d.verify_time LIKE ?\n" +
|
||||||
|
" GROUP BY\n" +
|
||||||
|
" d.customer_id\n" +
|
||||||
|
" ) p ON p.customer_id = o.customer_id\n" +
|
||||||
|
" WHERE\n" +
|
||||||
|
" o.state = 5\n" +
|
||||||
|
" AND o.create_time LIKE ?\n" +
|
||||||
|
" GROUP BY\n" +
|
||||||
|
" o.customer_id\n" +
|
||||||
|
" ) a\n" +
|
||||||
|
" LEFT JOIN customer u ON u.id = a.customer_id\n" +
|
||||||
|
" LEFT JOIN prepay_customer r ON r.customer_id = a.customer_id\n" +
|
||||||
|
" ) c\n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
" c.`customer_name` IS NOT NULL and c.customer_id = ?";
|
||||||
|
rec = Db.findFirst(sql, year + "%", year + "%", customer_id);
|
||||||
|
} else { // 零散配额
|
||||||
|
if (StrKit.isBlank(year) || customer_name == null) {
|
||||||
|
log.error("参数错误");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
sql = "SELECT\n" +
|
||||||
|
" a.*\n" +
|
||||||
|
"FROM\n" +
|
||||||
|
" (\n" +
|
||||||
|
" SELECT\n" +
|
||||||
|
" o.customer_name,\n" +
|
||||||
|
" count(o.sn) cnt,\n" +
|
||||||
|
" sum(o.total_price) total_price,\n" +
|
||||||
|
" sum(o.weight) total_weight\n" +
|
||||||
|
" FROM\n" +
|
||||||
|
" order_temp o\n" +
|
||||||
|
" WHERE\n" +
|
||||||
|
" o.state = 5\n" +
|
||||||
|
" AND o.create_time LIKE ?\n" +
|
||||||
|
" GROUP BY\n" +
|
||||||
|
" o.customer_id\n" +
|
||||||
|
" ) a\n" +
|
||||||
|
"WHERE\n" +
|
||||||
|
" a.`customer_name` = ?";
|
||||||
|
rec = Db.findFirst(sql, year + "%", customer_name);
|
||||||
|
}
|
||||||
|
return rec;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,6 @@ import com.cowr.common.base.BaseController;
|
||||||
import com.cowr.common.validator.DayValidator;
|
import com.cowr.common.validator.DayValidator;
|
||||||
import com.cowr.common.validator.MonthValidator;
|
import com.cowr.common.validator.MonthValidator;
|
||||||
import com.cowr.common.validator.StartAndEndIntervalValidator;
|
import com.cowr.common.validator.StartAndEndIntervalValidator;
|
||||||
import com.cowr.common.validator.YearValidator;
|
|
||||||
import com.cowr.common.view.ExcelRender;
|
import com.cowr.common.view.ExcelRender;
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.ssjygl.stat.sale.OrderStatService;
|
import com.cowr.ssjygl.stat.sale.OrderStatService;
|
||||||
|
|
@ -147,16 +146,19 @@ public class OrderStatController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 销售月逐日统计
|
* 销售月逐日统计
|
||||||
*/
|
*/
|
||||||
@Before(MonthValidator.class)
|
@Before(StartAndEndIntervalValidator.class)
|
||||||
public void mdstat() {
|
public void mdstat() {
|
||||||
String tm = get("tm");
|
String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00"
|
||||||
int export = getInt("export", 0);
|
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
|
int export = getInt("export", 0);
|
||||||
|
|
||||||
if (export == 0) {
|
if (export == 0) {
|
||||||
renderJson(Result.object(OrderStatService.me.mdstat(tm,supermarket_id)));
|
renderJson(Result.object(OrderStatService.me.mdstat(stm, etm, supermarket_id)));
|
||||||
} else {
|
} else {
|
||||||
Workbook wb = OrderStatService.me.mdstatExport(tm,supermarket_id);
|
Workbook wb = OrderStatService.me.mdstatExport(stm, etm, supermarket_id);
|
||||||
render(new ExcelRender(tm + "_销售月逐日统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
|
||||||
|
render(new ExcelRender(stm.substring(0, 10) + "至" + etm.substring(0, 10) + "_销售月逐日统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -330,4 +332,15 @@ public class OrderStatController extends BaseController {
|
||||||
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 固定、零散配额指定年的销售统计汇总数据
|
||||||
|
*/
|
||||||
|
public void yearStatisticsByCustomerId() {
|
||||||
|
String year = get("year");
|
||||||
|
Integer customer_id = getInt("customer_id");
|
||||||
|
String customer_name = get("customer_name");
|
||||||
|
Integer type = getInt("type");
|
||||||
|
renderJson(Result.object(OrderStatService.me.yearStatisticsByCustomerId(year, customer_id, customer_name, type)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ public class CheckUndonOrderclusterJob implements Job {
|
||||||
Result ret;
|
Result ret;
|
||||||
|
|
||||||
if (ordercluster.getCustomerId() != null) {
|
if (ordercluster.getCustomerId() != null) {
|
||||||
ret = OrderclusterSyncService.me.forwardCluster(ordercluster_id, surplus_weight, cutoff_time, user, true);
|
ret = OrderclusterSyncService.me.forwardCluster(ordercluster_id, surplus_weight, ordercluster.getCutoffTime(), cutoff_time, user, true);
|
||||||
} else {
|
} else {
|
||||||
String trucks = Db.queryStr("select group_concat(t.truck_license) trucks from ordercluster_truck t\n" +
|
String trucks = Db.queryStr("select group_concat(t.truck_license) trucks from ordercluster_truck t\n" +
|
||||||
" where t.ordercluster_id = ?\n" +
|
" where t.ordercluster_id = ?\n" +
|
||||||
|
|
@ -141,7 +141,7 @@ public class CheckUndonOrderclusterJob implements Job {
|
||||||
trucks = "";
|
trucks = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = OrderclusterSyncService.me.forwardTemp(ordercluster_id, surplus_weight, cutoff_time, trucks, user);
|
ret = OrderclusterSyncService.me.forwardTemp(ordercluster_id, surplus_weight, ordercluster.getCutoffTime(), cutoff_time, trucks, user);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ret.getCode() != Result.SUCCESS) {
|
if (ret.getCode() != Result.SUCCESS) {
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,7 @@ public class AuthInterceptor implements Interceptor {
|
||||||
add("/stat/sale/daydetail");
|
add("/stat/sale/daydetail");
|
||||||
add("/stat/sale/statMonthCustomer");
|
add("/stat/sale/statMonthCustomer");
|
||||||
add("/stat/sale/statRangeCustomer");
|
add("/stat/sale/statRangeCustomer");
|
||||||
|
add("/stat/sale/yearStatisticsByCustomerId");
|
||||||
|
|
||||||
add("/prepay/find");
|
add("/prepay/find");
|
||||||
add("/prepay/consumption");
|
add("/prepay/consumption");
|
||||||
|
|
|
||||||
|
|
@ -31,11 +31,12 @@ public class OrderclusterController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
int customer_id = getInt("customer_id");
|
int customer_id = getInt("customer_id");
|
||||||
|
Date start_time = getDate("start_time");
|
||||||
Date cutoff_time = getDate("cutoff_time");
|
Date cutoff_time = getDate("cutoff_time");
|
||||||
String suparrstr = get("suparr");
|
String suparrstr = get("suparr");
|
||||||
JSONArray suparr = JSONArray.parseArray(suparrstr);
|
JSONArray suparr = JSONArray.parseArray(suparrstr);
|
||||||
|
|
||||||
renderJson(OrderclusterSyncService.me.saveCluster(customer_id, cutoff_time, suparr, tokenuser));
|
renderJson(OrderclusterSyncService.me.saveCluster(customer_id, start_time, cutoff_time, suparr, tokenuser));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
renderJson(Result.failed("保存错误"));
|
renderJson(Result.failed("保存错误"));
|
||||||
|
|
@ -56,11 +57,12 @@ public class OrderclusterController extends BaseController {
|
||||||
String customer_texpayer_name = get("customer_texpayer_name");
|
String customer_texpayer_name = get("customer_texpayer_name");
|
||||||
Integer req_receipt = getInt("req_receipt");
|
Integer req_receipt = getInt("req_receipt");
|
||||||
double total_weight = getParaToDouble("total_weight");
|
double total_weight = getParaToDouble("total_weight");
|
||||||
|
Date start_time = getDate("start_time");
|
||||||
Date cutoff_time = getDate("cutoff_time");
|
Date cutoff_time = getDate("cutoff_time");
|
||||||
int supermarket_id = getInt("supermarket_id");
|
int supermarket_id = getInt("supermarket_id");
|
||||||
String trucks = get("trucks");
|
String trucks = get("trucks");
|
||||||
|
|
||||||
renderJson(OrderclusterSyncService.me.saveTemp(customer_name, customer_texpayer_name, customer_texpayer_num, req_receipt, total_weight, cutoff_time, supermarket_id, trucks, tokenuser));
|
renderJson(OrderclusterSyncService.me.saveTemp(customer_name, customer_texpayer_name, customer_texpayer_num, req_receipt, total_weight, start_time, cutoff_time, supermarket_id, trucks, tokenuser));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -258,9 +260,10 @@ public class OrderclusterController extends BaseController {
|
||||||
|
|
||||||
int ordercluster_id = getInt("id");
|
int ordercluster_id = getInt("id");
|
||||||
String total_weight = get("total_weight");
|
String total_weight = get("total_weight");
|
||||||
|
Date start_time = getDate("start_time");
|
||||||
Date cutoff_time = getDate("cutoff_time");
|
Date cutoff_time = getDate("cutoff_time");
|
||||||
|
|
||||||
renderJson(OrderclusterSyncService.me.forwardCluster(ordercluster_id, new BigDecimal(total_weight), cutoff_time, tokenuser));
|
renderJson(OrderclusterSyncService.me.forwardCluster(ordercluster_id, new BigDecimal(total_weight), start_time, cutoff_time, tokenuser));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Before(ForwardTempValidator.class)
|
@Before(ForwardTempValidator.class)
|
||||||
|
|
@ -274,10 +277,11 @@ public class OrderclusterController extends BaseController {
|
||||||
|
|
||||||
int ordercluster_id = getInt("id");
|
int ordercluster_id = getInt("id");
|
||||||
String total_weight = get("total_weight");
|
String total_weight = get("total_weight");
|
||||||
|
Date start_time = getDate("start_time");
|
||||||
Date cutoff_time = getDate("cutoff_time");
|
Date cutoff_time = getDate("cutoff_time");
|
||||||
String trucks = get("trucks");
|
String trucks = get("trucks");
|
||||||
|
|
||||||
renderJson(OrderclusterSyncService.me.forwardTemp(ordercluster_id, new BigDecimal(total_weight), cutoff_time, trucks, tokenuser));
|
renderJson(OrderclusterSyncService.me.forwardTemp(ordercluster_id, new BigDecimal(total_weight), start_time, cutoff_time, trucks, tokenuser));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void getMaximumConfiguration(){
|
public void getMaximumConfiguration(){
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
* @param suparr
|
* @param suparr
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Result saveCluster(int customer_id, Date cutoff_time, JSONArray suparr, Sysuser sysuser) {
|
public Result saveCluster(int customer_id, Date start_time, Date cutoff_time, JSONArray suparr, Sysuser sysuser) {
|
||||||
if (suparr == null || suparr.isEmpty()) {
|
if (suparr == null || suparr.isEmpty()) {
|
||||||
return Result.failed("砂站配额不能为空");
|
return Result.failed("砂站配额不能为空");
|
||||||
}
|
}
|
||||||
|
|
@ -156,6 +156,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
model.setTransDistance(SupermarketReceiverDistanceService.me.getDistance(supermarket_id, customer_id));
|
model.setTransDistance(SupermarketReceiverDistanceService.me.getDistance(supermarket_id, customer_id));
|
||||||
|
|
||||||
model.setTotalWeight(new BigDecimal(total_weight));
|
model.setTotalWeight(new BigDecimal(total_weight));
|
||||||
|
model.setStartTime(start_time);
|
||||||
model.setCutoffTime(cutoff_time);
|
model.setCutoffTime(cutoff_time);
|
||||||
|
|
||||||
model.setSupermarketId(supermarket_id);
|
model.setSupermarketId(supermarket_id);
|
||||||
|
|
@ -233,11 +234,13 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
String customer_texpayer_num,
|
String customer_texpayer_num,
|
||||||
Integer req_receipt,
|
Integer req_receipt,
|
||||||
double total_weight,
|
double total_weight,
|
||||||
|
Date start_time,
|
||||||
Date cutoff_time,
|
Date cutoff_time,
|
||||||
int supermarket_id,
|
int supermarket_id,
|
||||||
String trucks,
|
String trucks,
|
||||||
Sysuser sysuser
|
Sysuser sysuser
|
||||||
) {
|
) {
|
||||||
|
String query_start_time = DateTimeUtil.sdf.get().format(start_time);
|
||||||
String query_cutoff_time = DateTimeUtil.sdf.get().format(cutoff_time);
|
String query_cutoff_time = DateTimeUtil.sdf.get().format(cutoff_time);
|
||||||
Supermarket supermarket = SvrCacheData.SUP_CACHE.get(supermarket_id);
|
Supermarket supermarket = SvrCacheData.SUP_CACHE.get(supermarket_id);
|
||||||
if (supermarket == null) {
|
if (supermarket == null) {
|
||||||
|
|
@ -248,10 +251,10 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
return Result.failedstr("[%s]砂站还未部署", supermarket.getName());
|
return Result.failedstr("[%s]砂站还未部署", supermarket.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Record> undonlist = OrderclusterService.me.undonlist(supermarket_id, customer_name, query_cutoff_time);
|
List<Record> undonlist = OrderclusterService.me.undonlist(supermarket_id, customer_name, query_start_time, query_cutoff_time);
|
||||||
|
|
||||||
if (undonlist != null && !undonlist.isEmpty()) {
|
if (undonlist != null && !undonlist.isEmpty()) {
|
||||||
return Result.failedstr("客户[%s][%s]在砂站[%s]还有未完成的配额", customer_name, query_cutoff_time, SvrCacheData.SUP_CACHE.get(supermarket_id).getName());
|
return Result.failedstr("客户[%s][%s]至[%s]在砂站[%s]还有未完成的配额", customer_name, query_start_time, query_cutoff_time, SvrCacheData.SUP_CACHE.get(supermarket_id).getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
Product product = Product.dao.findById(Const.DEFAULT_PRODUCT_ID);
|
Product product = Product.dao.findById(Const.DEFAULT_PRODUCT_ID);
|
||||||
|
|
@ -299,12 +302,19 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
return Result.failed(StrKit.join(ts, ",") + " 车牌号在黑名单中");
|
return Result.failed(StrKit.join(ts, ",") + " 车牌号在黑名单中");
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.add(0, query_cutoff_time + "%");
|
ts.add(0, query_cutoff_time + " 23:59:59");
|
||||||
|
ts.add(0, query_start_time + " 00:00:00");
|
||||||
|
ts.add(0, query_cutoff_time + " 23:59:59");
|
||||||
|
ts.add(0, query_start_time + " 00:00:00");
|
||||||
|
ts.add(0, query_cutoff_time + " 23:59:59");
|
||||||
|
ts.add(0, query_start_time + " 00:00:00");
|
||||||
List<Record> chkduk = Db.find(
|
List<Record> chkduk = Db.find(
|
||||||
"select * from ordercluster_truck t \n" +
|
"select * 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 < 5 \n" + // OrderStateEnum.RECEIVED.getStateid()
|
" where c.state < 5 \n" + // OrderStateEnum.RECEIVED.getStateid()
|
||||||
" and c.cutoff_time like ? \n" +
|
" and (c.start_time >= ? and c.start_time <= ?) \n" +
|
||||||
|
" or (c.start_time <= ? and c.cutoff_time >= ?) \n" +
|
||||||
|
" or (c.cutoff_time >= ? and c.cutoff_time <= ?) \n" +
|
||||||
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
if (chkduk != null && !chkduk.isEmpty()) {
|
if (chkduk != null && !chkduk.isEmpty()) {
|
||||||
|
|
@ -312,8 +322,9 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
|
|
||||||
for (Record bl : chkduk) {
|
for (Record bl : chkduk) {
|
||||||
outerr.add(String.format(
|
outerr.add(String.format(
|
||||||
"[%s]已经在[%s]分配给了[%s]",
|
"[%s]已经在[%s]至[%s]分配给了[%s]",
|
||||||
bl.get("truck_license"),
|
bl.get("truck_license"),
|
||||||
|
DateTimeUtil.sdfymd.get().format(bl.get("start_time")),
|
||||||
DateTimeUtil.sdfymd.get().format(bl.get("cutoff_time")),
|
DateTimeUtil.sdfymd.get().format(bl.get("cutoff_time")),
|
||||||
bl.get("customer_name")
|
bl.get("customer_name")
|
||||||
));
|
));
|
||||||
|
|
@ -528,6 +539,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
oldobj.setTotalWeight(model.getTotalWeight());
|
oldobj.setTotalWeight(model.getTotalWeight());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String query_start_time = DateTimeUtil.sdf.get().format(oldobj.getStartTime());
|
||||||
String query_cutoff_time = DateTimeUtil.sdf.get().format(oldobj.getCutoffTime());
|
String query_cutoff_time = DateTimeUtil.sdf.get().format(oldobj.getCutoffTime());
|
||||||
List<String> chk = new ArrayList<>();
|
List<String> chk = new ArrayList<>();
|
||||||
String[] truckarr = trucks.split(",");
|
String[] truckarr = trucks.split(",");
|
||||||
|
|
@ -562,13 +574,20 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
return Result.failed(StrKit.join(retts, ",") + " 车牌号在黑名单中");
|
return Result.failed(StrKit.join(retts, ",") + " 车牌号在黑名单中");
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.add(0, query_cutoff_time + "%");
|
ts.add(0, query_cutoff_time + " 23:59:59");
|
||||||
|
ts.add(0, query_start_time + " 00:00:00");
|
||||||
|
ts.add(0, query_cutoff_time + " 23:59:59");
|
||||||
|
ts.add(0, query_start_time + " 00:00:00");
|
||||||
|
ts.add(0, query_cutoff_time + " 23:59:59");
|
||||||
|
ts.add(0, query_start_time + " 00:00:00");
|
||||||
List<Record> chkduk = Db.find(
|
List<Record> chkduk = Db.find(
|
||||||
"select * from ordercluster_truck t \n" +
|
"select * 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 < 5 \n" + // OrderStateEnum.RECEIVED.getStateid()
|
" where c.state < 5 \n" + // OrderStateEnum.RECEIVED.getStateid()
|
||||||
" and t.ordercluster_id <> " + oldobj.getId() +
|
" and t.ordercluster_id <> " + oldobj.getId() +
|
||||||
" and c.cutoff_time like ? \n" +
|
" and (c.start_time >= ? and c.start_time <= ?) \n" +
|
||||||
|
" or (c.start_time <= ? and c.cutoff_time >= ?) \n" +
|
||||||
|
" or (c.cutoff_time >= ? and c.cutoff_time <= ?) \n" +
|
||||||
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
if (chkduk != null && !chkduk.isEmpty()) {
|
if (chkduk != null && !chkduk.isEmpty()) {
|
||||||
|
|
@ -576,8 +595,9 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
|
|
||||||
for (Record bl : chkduk) {
|
for (Record bl : chkduk) {
|
||||||
outerr.add(String.format(
|
outerr.add(String.format(
|
||||||
"[%s]已经在[%s]分配给了[%s]",
|
"[%s]已经在[%s]至[%s]分配给了[%s]",
|
||||||
bl.get("truck_license"),
|
bl.get("truck_license"),
|
||||||
|
DateTimeUtil.sdfymd.get().format(bl.get("start_time")),
|
||||||
DateTimeUtil.sdfymd.get().format(bl.get("cutoff_time")),
|
DateTimeUtil.sdfymd.get().format(bl.get("cutoff_time")),
|
||||||
bl.get("customer_name")
|
bl.get("customer_name")
|
||||||
));
|
));
|
||||||
|
|
@ -611,13 +631,15 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
if (!dellist.isEmpty()) {
|
if (!dellist.isEmpty()) {
|
||||||
List<String> querydel = new ArrayList<>();
|
List<String> querydel = new ArrayList<>();
|
||||||
querydel.add(oldobj.getSupermarketId().toString());
|
querydel.add(oldobj.getSupermarketId().toString());
|
||||||
querydel.add(DateTimeUtil.sdf.get().format(oldobj.getCutoffTime()) + "%");
|
querydel.add(DateTimeUtil.sdfhms.get().format(oldobj.getStartTime()));
|
||||||
|
querydel.add(DateTimeUtil.sdfhms.get().format(oldobj.getCutoffTime()));
|
||||||
querydel.addAll(dellist);
|
querydel.addAll(dellist);
|
||||||
|
|
||||||
List<Transport> chktp = Transport.dao.find("select * from transport t \n" +
|
List<Transport> chktp = Transport.dao.find("select * from transport t \n" +
|
||||||
" where t.state < 5 \n" +
|
" where t.state < 5 \n" +
|
||||||
" and t.supermarket_id = ? \n" +
|
" and t.supermarket_id = ? \n" +
|
||||||
" and t.in_time like ? \n" +
|
" and t.in_time >= ? \n" +
|
||||||
|
" and t.in_time <= ? \n" +
|
||||||
" and t.truck_license in(" + StrKit.join(chktpsql, ",") + ")", querydel.toArray());
|
" and t.truck_license in(" + StrKit.join(chktpsql, ",") + ")", querydel.toArray());
|
||||||
|
|
||||||
if (!chktp.isEmpty()) {
|
if (!chktp.isEmpty()) {
|
||||||
|
|
@ -922,11 +944,11 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
* @param sysuser
|
* @param sysuser
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Result forwardCluster(int ordercluster_id, BigDecimal total_weight, Date cutoff_time, Sysuser sysuser) {
|
public Result forwardCluster(int ordercluster_id, BigDecimal total_weight, Date start_time, Date cutoff_time, Sysuser sysuser) {
|
||||||
return forwardCluster(ordercluster_id, total_weight, cutoff_time, sysuser, false);
|
return forwardCluster(ordercluster_id, total_weight, start_time, cutoff_time, sysuser, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result forwardCluster(int ordercluster_id, BigDecimal total_weight, Date cutoff_time, Sysuser sysuser, boolean isAuto) {
|
public Result forwardCluster(int ordercluster_id, BigDecimal total_weight, Date start_time, Date cutoff_time, Sysuser sysuser, boolean isAuto) {
|
||||||
Ordercluster oldobj = Ordercluster.dao.findById(ordercluster_id);
|
Ordercluster oldobj = Ordercluster.dao.findById(ordercluster_id);
|
||||||
|
|
||||||
if (oldobj == null) {
|
if (oldobj == null) {
|
||||||
|
|
@ -988,6 +1010,8 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
|
|
||||||
List<OrderclusterTruck> octs = OrderclusterTruck.dao.find("select * from ordercluster_truck t where t.ordercluster_id = ?", ordercluster_id);
|
List<OrderclusterTruck> octs = OrderclusterTruck.dao.find("select * from ordercluster_truck t where t.ordercluster_id = ?", ordercluster_id);
|
||||||
|
|
||||||
|
String query_start_time = DateTimeUtil.sdfhms.get().format(start_time);
|
||||||
|
String query_cutoff_time = DateTimeUtil.sdfhms.get().format(cutoff_time);
|
||||||
if (!octs.isEmpty()) {
|
if (!octs.isEmpty()) {
|
||||||
// 已有车辆的,在结转前,需要将已经分配其他集团订单的车辆去掉
|
// 已有车辆的,在结转前,需要将已经分配其他集团订单的车辆去掉
|
||||||
List<Object> ts = new ArrayList<>();
|
List<Object> ts = new ArrayList<>();
|
||||||
|
|
@ -1003,14 +1027,21 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
delmap.put(oct.getTruckLicense(), oct);
|
delmap.put(oct.getTruckLicense(), oct);
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.add(0, cutoff_time); // 加到查询参数里面
|
ts.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, query_start_time); // 加到查询参数里面
|
||||||
|
ts.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, query_start_time); // 加到查询参数里面
|
||||||
|
ts.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, query_start_time); // 加到查询参数里面
|
||||||
ts.add(0, ordercluster_id); // 加到查询参数里面
|
ts.add(0, ordercluster_id); // 加到查询参数里面
|
||||||
List<Record> chkduk = Db.find(
|
List<Record> chkduk = Db.find(
|
||||||
"select * from ordercluster_truck t\n" +
|
"select * from ordercluster_truck t\n" +
|
||||||
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
||||||
" where t.ordercluster_id <> ? \n" +
|
" where t.ordercluster_id <> ? \n" +
|
||||||
" and o.state < 5 \n" +
|
" and o.state < 5 \n" +
|
||||||
" and o.cutoff_time = ? \n" +
|
" and (o.start_time >= ? and o.start_time <= ?) \n" +
|
||||||
|
" or (o.start_time <= ? and o.cutoff_time >= ?) \n" +
|
||||||
|
" or (o.cutoff_time >= ? and o.cutoff_time <= ?) \n" +
|
||||||
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
if (chkduk != null && !chkduk.isEmpty()) {
|
if (chkduk != null && !chkduk.isEmpty()) {
|
||||||
|
|
@ -1024,12 +1055,23 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
|
|
||||||
SyncTask synctask = new SyncTask();
|
SyncTask synctask = new SyncTask();
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
List<Object> ts2 = new ArrayList<>();
|
||||||
|
ts2.add( oldobj.getSupermarketId()); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_start_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_start_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_start_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, oldobj.getCustomerId()); // 加到查询参数里面
|
||||||
final Ordercluster[] forwardoldobj = {Ordercluster.dao.findFirst(
|
final Ordercluster[] forwardoldobj = {Ordercluster.dao.findFirst(
|
||||||
"select * from ordercluster t \n" +
|
"select * from ordercluster t \n" +
|
||||||
" where t.customer_id = ? \n" +
|
" where t.customer_id = ? \n" +
|
||||||
" and t.cutoff_time = ? \n" +
|
" and (t.start_time >= ? and t.start_time <= ?) \n" +
|
||||||
|
" or (t.start_time <= ? and t.cutoff_time >= ?) \n" +
|
||||||
|
" or (t.cutoff_time >= ? and t.cutoff_time <= ?) \n" +
|
||||||
" and t.supermarket_id = ? \n" +
|
" and t.supermarket_id = ? \n" +
|
||||||
" and t.state < 5 limit 1", oldobj.getCustomerId(), cutoff_time, oldobj.getSupermarketId())};
|
" and t.state < 5 limit 1", ts2.toArray())};
|
||||||
|
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
@Override
|
@Override
|
||||||
|
|
@ -1058,6 +1100,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
forwardoldobj[0].setUuid(StrKit.getRandomUUID());
|
forwardoldobj[0].setUuid(StrKit.getRandomUUID());
|
||||||
forwardoldobj[0].setUnitPrice(unitprice); // 用最新的单价更新
|
forwardoldobj[0].setUnitPrice(unitprice); // 用最新的单价更新
|
||||||
forwardoldobj[0].setTotalWeight(total_weight);
|
forwardoldobj[0].setTotalWeight(total_weight);
|
||||||
|
forwardoldobj[0].setStartTime(start_time);
|
||||||
forwardoldobj[0].setCutoffTime(cutoff_time);
|
forwardoldobj[0].setCutoffTime(cutoff_time);
|
||||||
forwardoldobj[0].setCreateTime(now); // 当前系统时间
|
forwardoldobj[0].setCreateTime(now); // 当前系统时间
|
||||||
forwardoldobj[0].setCreateUserId(sysuser.getId()); // 当前用户id
|
forwardoldobj[0].setCreateUserId(sysuser.getId()); // 当前用户id
|
||||||
|
|
@ -1137,7 +1180,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
* @param sysuser
|
* @param sysuser
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Result forwardTemp(int ordercluster_id, BigDecimal total_weight, Date cutoff_time, String trucks, Sysuser sysuser) {
|
public Result forwardTemp(int ordercluster_id, BigDecimal total_weight, Date start_time, Date cutoff_time, String trucks, Sysuser sysuser) {
|
||||||
Ordercluster oldobj = Ordercluster.dao.findById(ordercluster_id);
|
Ordercluster oldobj = Ordercluster.dao.findById(ordercluster_id);
|
||||||
|
|
||||||
if (oldobj == null) {
|
if (oldobj == null) {
|
||||||
|
|
@ -1200,14 +1243,24 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
return Result.failed(StrKit.join(outts, ",") + " 车牌号在黑名单中");
|
return Result.failed(StrKit.join(outts, ",") + " 车牌号在黑名单中");
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.add(0, cutoff_time); // 加到查询参数里面
|
String query_start_time = DateTimeUtil.sdfhms.get().format(start_time);
|
||||||
|
String query_cutoff_time = DateTimeUtil.sdfhms.get().format(cutoff_time);
|
||||||
|
|
||||||
|
ts.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, query_start_time); // 加到查询参数里面
|
||||||
|
ts.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, query_start_time); // 加到查询参数里面
|
||||||
|
ts.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, query_start_time); // 加到查询参数里面
|
||||||
ts.add(0, ordercluster_id); // 加到查询参数里面
|
ts.add(0, ordercluster_id); // 加到查询参数里面
|
||||||
List<Record> chkduk = Db.find(
|
List<Record> chkduk = Db.find(
|
||||||
"select * from ordercluster_truck t\n" +
|
"select * from ordercluster_truck t\n" +
|
||||||
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
||||||
" where t.ordercluster_id <> ? \n" +
|
" where t.ordercluster_id <> ? \n" +
|
||||||
" and o.state < 5 \n" +
|
" and o.state < 5 \n" +
|
||||||
" and o.cutoff_time = ? \n" +
|
" and (o.start_time >= ? and o.start_time <= ?) \n" +
|
||||||
|
" or (o.start_time <= ? and o.cutoff_time >= ?) \n" +
|
||||||
|
" or (o.cutoff_time >= ? and o.cutoff_time <= ?) \n" +
|
||||||
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
if (chkduk != null && !chkduk.isEmpty()) {
|
if (chkduk != null && !chkduk.isEmpty()) {
|
||||||
|
|
@ -1225,7 +1278,15 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
SyncTask synctask = new SyncTask();
|
SyncTask synctask = new SyncTask();
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
String[] finalTruckarr = truckarr;
|
String[] finalTruckarr = truckarr;
|
||||||
|
List<Object> ts2 = new ArrayList<>();
|
||||||
|
ts2.add(oldobj.getSupermarketId()); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_start_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_start_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_cutoff_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, query_start_time); // 加到查询参数里面
|
||||||
|
ts2.add(0, oldobj.getCustomerName()); // 加到查询参数里面
|
||||||
boolean ret = Db.tx(new IAtom() {
|
boolean ret = Db.tx(new IAtom() {
|
||||||
@Override
|
@Override
|
||||||
public boolean run() throws SQLException {
|
public boolean run() throws SQLException {
|
||||||
|
|
@ -1249,9 +1310,11 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
Ordercluster forwardoldobj = Ordercluster.dao.findFirst(
|
Ordercluster forwardoldobj = Ordercluster.dao.findFirst(
|
||||||
"select * from ordercluster t \n" +
|
"select * from ordercluster t \n" +
|
||||||
" where t.customer_name = ? \n" +
|
" where t.customer_name = ? \n" +
|
||||||
" and t.cutoff_time = ? \n" +
|
" and (t.start_time >= ? and t.start_time <= ?) \n" +
|
||||||
|
" or (t.start_time <= ? and t.cutoff_time >= ?) \n" +
|
||||||
|
" or (t.cutoff_time >= ? and t.cutoff_time <= ?) \n" +
|
||||||
" and t.supermarket_id = ? \n" +
|
" and t.supermarket_id = ? \n" +
|
||||||
" and t.state < 5 limit 1", oldobj.getCustomerName(), cutoff_time, oldobj.getSupermarketId());
|
" and t.state < 5 limit 1", ts2.toArray());
|
||||||
|
|
||||||
if (forwardoldobj == null) {
|
if (forwardoldobj == null) {
|
||||||
// 新建一个
|
// 新建一个
|
||||||
|
|
@ -1260,6 +1323,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
forwardoldobj.setUuid(StrKit.getRandomUUID());
|
forwardoldobj.setUuid(StrKit.getRandomUUID());
|
||||||
forwardoldobj.setUnitPrice(unitprice);
|
forwardoldobj.setUnitPrice(unitprice);
|
||||||
forwardoldobj.setTotalWeight(total_weight);
|
forwardoldobj.setTotalWeight(total_weight);
|
||||||
|
forwardoldobj.setStartTime(start_time);
|
||||||
forwardoldobj.setCutoffTime(cutoff_time);
|
forwardoldobj.setCutoffTime(cutoff_time);
|
||||||
forwardoldobj.setCreateTime(now); // 当前系统时间
|
forwardoldobj.setCreateTime(now); // 当前系统时间
|
||||||
forwardoldobj.setCreateUserId(sysuser.getId()); // 当前用户id
|
forwardoldobj.setCreateUserId(sysuser.getId()); // 当前用户id
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,14 @@ public class SaveClusterValidator extends CrudParamValidator {
|
||||||
protected void validate(Controller c) {
|
protected void validate(Controller c) {
|
||||||
validateRequiredString("suparr", "suparr", "suparr 必填");
|
validateRequiredString("suparr", "suparr", "suparr 必填");
|
||||||
validateInteger("customer_id", 1, 2147483647, "customer_id", "customer_id 范围 1~2147483647");
|
validateInteger("customer_id", 1, 2147483647, "customer_id", "customer_id 范围 1~2147483647");
|
||||||
|
validateDate("start_time", "yyyy-MM-dd HH:mm:ss", false, "start_time", "cutoff_time 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整
|
||||||
validateDate("cutoff_time", "yyyy-MM-dd HH:mm:ss", false, "cutoff_time", "cutoff_time 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整
|
validateDate("cutoff_time", "yyyy-MM-dd HH:mm:ss", false, "cutoff_time", "cutoff_time 格式 yyyy-MM-dd HH:mm:ss"); // 默认时间时间字符串格式,生成后根据情况调整
|
||||||
|
|
||||||
if (StrKit.notBlank(c.get("cutoff_time")) && DateTimeUtil.isEarlyToday(c.get("cutoff_time"))) {
|
if (StrKit.notBlank(c.get("start_time")) && DateTimeUtil.isEarlyToday(c.get("start_time"))) {
|
||||||
addError("cutoff_time", "截止时间不能早于今天");
|
addError("start_time", "起始时间不能早于今天");
|
||||||
|
}
|
||||||
|
if (StrKit.notBlank(c.get("cutoff_time")) && !DateTimeUtil.isStmLtEtm(c.get("start_time"), c.get("cutoff_time"))) {
|
||||||
|
addError("start_time", "起始时间不能早于截止时间");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,15 +74,24 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
return Result.failed(StrKit.join(retts, ",") + " 车牌号在黑名单中");
|
return Result.failed(StrKit.join(retts, ",") + " 车牌号在黑名单中");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询是否在同一天分配给其他集团订单
|
// 查询是否在某一时间段分配给其他集团订单
|
||||||
ts.add(0, ordercluster.getCutoffTime()); // 加到查询参数里面
|
String start_time = DateTimeUtil.sdfhms.get().format(ordercluster.getStartTime());
|
||||||
|
String cutoff_time = DateTimeUtil.sdfhms.get().format(ordercluster.getCutoffTime());
|
||||||
|
ts.add(0, cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, start_time); // 加到查询参数里面
|
||||||
|
ts.add(0, cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, start_time); // 加到查询参数里面
|
||||||
|
ts.add(0, cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, start_time); // 加到查询参数里面
|
||||||
ts.add(0, ordercluster_id); // 加到查询参数里面
|
ts.add(0, ordercluster_id); // 加到查询参数里面
|
||||||
List<Record> chkduk = Db.find(
|
List<Record> chkduk = Db.find(
|
||||||
"select * from ordercluster_truck t\n" +
|
"select * from ordercluster_truck t\n" +
|
||||||
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
||||||
" where t.ordercluster_id <> ? \n" +
|
" where t.ordercluster_id <> ? \n" +
|
||||||
" and o.state < 5 \n" +
|
" and o.state < 5 \n" +
|
||||||
" and o.cutoff_time = ? \n" +
|
" and (o.start_time >= ? and o.start_time <= ?) \n" +
|
||||||
|
" or (o.start_time <= ? and o.cutoff_time >= ?) \n" +
|
||||||
|
" or (o.cutoff_time >= ? and o.cutoff_time <= ?) \n" +
|
||||||
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
if (chkduk != null && !chkduk.isEmpty()) {
|
if (chkduk != null && !chkduk.isEmpty()) {
|
||||||
|
|
@ -93,10 +102,10 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.failedstr(
|
return Result.failedstr(
|
||||||
"%s 已在[%s]分配",
|
"%s 已在[%s]至[%s]分配",
|
||||||
StrKit.join(retts, ","),
|
StrKit.join(retts, ","),
|
||||||
DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime())
|
DateTimeUtil.sdfymd.get().format(ordercluster.getStartTime()),
|
||||||
);
|
DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询已有的集团订单分配的车辆
|
// 查询已有的集团订单分配的车辆
|
||||||
|
|
@ -124,12 +133,14 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
if(!dellist.isEmpty()){
|
if(!dellist.isEmpty()){
|
||||||
List<String> querydel = new ArrayList<>();
|
List<String> querydel = new ArrayList<>();
|
||||||
querydel.add(ordercluster.getSupermarketId().toString());
|
querydel.add(ordercluster.getSupermarketId().toString());
|
||||||
querydel.add(DateTimeUtil.sdf.get().format(ordercluster.getCutoffTime()) + "%");
|
querydel.add(DateTimeUtil.sdfhms.get().format(ordercluster.getStartTime()));
|
||||||
|
querydel.add(DateTimeUtil.sdfhms.get().format(ordercluster.getCutoffTime()));
|
||||||
querydel.addAll(dellist);
|
querydel.addAll(dellist);
|
||||||
List<Transport> chktp = Transport.dao.find("select * from transport t \n" +
|
List<Transport> chktp = Transport.dao.find("select * from transport t \n" +
|
||||||
" where t.state < 5 \n" +
|
" where t.state < 5 \n" +
|
||||||
" and t.supermarket_id = ? \n" +
|
" and t.supermarket_id = ? \n" +
|
||||||
" and t.in_time like ? \n" +
|
" and t.in_time >= ? \n" +
|
||||||
|
" and t.in_time <= ? \n" +
|
||||||
" and t.truck_license in(" + StrKit.join(chktpsql, ",") + ")", querydel.toArray());
|
" and t.truck_license in(" + StrKit.join(chktpsql, ",") + ")", querydel.toArray());
|
||||||
|
|
||||||
if(!chktp.isEmpty()){
|
if(!chktp.isEmpty()){
|
||||||
|
|
|
||||||
|
|
@ -174,17 +174,19 @@ public class OrderStatController extends BaseController {
|
||||||
/**
|
/**
|
||||||
* 销售月逐日统计
|
* 销售月逐日统计
|
||||||
*/
|
*/
|
||||||
@Before(MonthValidator.class)
|
@Before(StartAndEndIntervalValidator.class)
|
||||||
public void mdstat() {
|
public void mdstat() {
|
||||||
String tm = get("tm");
|
String stm = get("stm"); // 前端将 YYYY-MM-DD 后面补 " 00:00:00"
|
||||||
|
String etm = get("etm"); // 前端将 YYYY-MM-DD 后面补 " 23:59:59"
|
||||||
Integer supermarket_id = getInt("supermarket_id");
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
int export = getInt("export", 0);
|
int export = getInt("export", 0);
|
||||||
|
|
||||||
if (export == 0) {
|
if (export == 0) {
|
||||||
renderJson(Result.object(OrderStatService.me.mdstat(tm, supermarket_id)));
|
renderJson(Result.object(OrderStatService.me.mdstat(stm, etm, supermarket_id)));
|
||||||
} else {
|
} else {
|
||||||
Workbook wb = OrderStatService.me.mdstatExport(tm, supermarket_id);
|
Workbook wb = OrderStatService.me.mdstatExport(stm, etm, supermarket_id);
|
||||||
render(new ExcelRender(tm + "_销售月逐日统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
|
||||||
|
render(new ExcelRender(stm.substring(0, 10) + "至" + etm.substring(0, 10) + "_销售月逐日统计_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -411,4 +413,16 @@ public class OrderStatController extends BaseController {
|
||||||
render(new ExcelRender("各砂站运输量统计表_" + System.currentTimeMillis() + ".xlsx", wb));
|
render(new ExcelRender("各砂站运输量统计表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 固定、零散配额指定年的销售统计汇总数据
|
||||||
|
*/
|
||||||
|
public void yearStatisticsByCustomerId() {
|
||||||
|
String year = get("year");
|
||||||
|
Integer customer_id = getInt("customer_id");
|
||||||
|
String customer_name = get("customer_name");
|
||||||
|
Integer type = getInt("type");
|
||||||
|
renderJson(Result.object(OrderStatService.me.yearStatisticsByCustomerId(year, customer_id, customer_name, type)));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,6 @@
|
||||||
package com.cowr.service.ssjygl.truck;
|
package com.cowr.service.ssjygl.truck;
|
||||||
|
|
||||||
import com.cowr.common.Const;
|
import com.cowr.common.Const;
|
||||||
import com.cowr.common.base.BaseModel;
|
|
||||||
import com.cowr.common.enums.Enums;
|
import com.cowr.common.enums.Enums;
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.model.*;
|
import com.cowr.model.*;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue