Merge branch 'ls-dev'
# Conflicts: # ssjygl-xsx-local/src/main/java/com/cowr/local/ssjygl/netty/NettyClient.javadev
commit
8b0150d7a0
|
|
@ -129,4 +129,39 @@ public class ReportExcelStyle {
|
||||||
sheet.getLastRowNum() //end row
|
sheet.getLastRowNum() //end row
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void setCommonCellStyle(
|
||||||
|
Workbook wb,
|
||||||
|
Sheet sheet,
|
||||||
|
int datalen,
|
||||||
|
int end_col
|
||||||
|
){
|
||||||
|
// 通用单元格格式
|
||||||
|
Font font = wb.createFont();
|
||||||
|
CellStyle cellStyle = wb.createCellStyle();
|
||||||
|
font.setFontHeight((short) (10 * 20));
|
||||||
|
font.setFontName("宋体");
|
||||||
|
cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中
|
||||||
|
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
|
||||||
|
cellStyle.setFont(font);
|
||||||
|
|
||||||
|
Row row;
|
||||||
|
|
||||||
|
// 设置通用单元格格式
|
||||||
|
for (int r = 0; r < datalen + 1; r++) {
|
||||||
|
row = sheet.getRow(r);
|
||||||
|
if (row == null) {
|
||||||
|
row = sheet.createRow(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int c = 0; c < end_col + 1; c++) {
|
||||||
|
Cell cell = row.getCell(c);
|
||||||
|
|
||||||
|
if (cell == null) {
|
||||||
|
cell = row.createCell(c);
|
||||||
|
}
|
||||||
|
cell.setCellStyle(cellStyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import com.cowr.model.base.BaseSupermarketCustomerDistance;
|
||||||
/**
|
/**
|
||||||
* Generated by COWR Tue Aug 25 17:27:08 CST 2020
|
* Generated by COWR Tue Aug 25 17:27:08 CST 2020
|
||||||
* TableName: supermarket_customer_distance
|
* TableName: supermarket_customer_distance
|
||||||
* Remarks: 基础配置 - 超市到客户的距离
|
* Remarks: 基础配置 - 砂站到客户的距离
|
||||||
* PrimaryKey: supermarket_id,customer_id
|
* PrimaryKey: supermarket_id,customer_id
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ public abstract class BaseCustomerSupermarketProduct<M extends BaseCustomerSuper
|
||||||
* isNullable: NO
|
* isNullable: NO
|
||||||
* isPrimaryKey: YES
|
* isPrimaryKey: YES
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
* @param supermarketId 超市id
|
* @param supermarketId 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="supermarket_id")
|
@JSONField(name="supermarket_id")
|
||||||
public void setSupermarketId(Integer supermarketId) {
|
public void setSupermarketId(Integer supermarketId) {
|
||||||
|
|
@ -57,7 +57,7 @@ public abstract class BaseCustomerSupermarketProduct<M extends BaseCustomerSuper
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return supermarket_id 超市id
|
* @return supermarket_id 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="supermarket_id")
|
@JSONField(name="supermarket_id")
|
||||||
public Integer getSupermarketId() {
|
public Integer getSupermarketId() {
|
||||||
|
|
@ -92,7 +92,7 @@ public abstract class BaseCustomerSupermarketProduct<M extends BaseCustomerSuper
|
||||||
* isNullable: NO
|
* isNullable: NO
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
* @param unitPrice 商品在超市的销售单价
|
* @param unitPrice 商品在砂站的销售单价
|
||||||
*/
|
*/
|
||||||
@JSONField(name="unit_price")
|
@JSONField(name="unit_price")
|
||||||
public void setUnitPrice(java.math.BigDecimal unitPrice) {
|
public void setUnitPrice(java.math.BigDecimal unitPrice) {
|
||||||
|
|
@ -101,7 +101,7 @@ public abstract class BaseCustomerSupermarketProduct<M extends BaseCustomerSuper
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return unit_price 商品在超市的销售单价
|
* @return unit_price 商品在砂站的销售单价
|
||||||
*/
|
*/
|
||||||
@JSONField(name="unit_price")
|
@JSONField(name="unit_price")
|
||||||
public java.math.BigDecimal getUnitPrice() {
|
public java.math.BigDecimal getUnitPrice() {
|
||||||
|
|
|
||||||
|
|
@ -340,7 +340,7 @@ public abstract class BaseInvoiceInvalidVerify<M extends BaseInvoiceInvalidVerif
|
||||||
* isNullable: YES
|
* isNullable: YES
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
* @param supermarketId 超市id
|
* @param supermarketId 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="supermarket_id")
|
@JSONField(name="supermarket_id")
|
||||||
public void setSupermarketId(Integer supermarketId) {
|
public void setSupermarketId(Integer supermarketId) {
|
||||||
|
|
@ -349,7 +349,7 @@ public abstract class BaseInvoiceInvalidVerify<M extends BaseInvoiceInvalidVerif
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return supermarket_id 超市id
|
* @return supermarket_id 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="supermarket_id")
|
@JSONField(name="supermarket_id")
|
||||||
public Integer getSupermarketId() {
|
public Integer getSupermarketId() {
|
||||||
|
|
|
||||||
|
|
@ -234,7 +234,7 @@ public abstract class BaseInvoiceReceive<M extends BaseInvoiceReceive<M>> extend
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
*
|
*
|
||||||
* @param supermarketId 领取超市id
|
* @param supermarketId 领取砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "supermarket_id")
|
@JSONField(name = "supermarket_id")
|
||||||
public void setSupermarketId(Integer supermarketId) {
|
public void setSupermarketId(Integer supermarketId) {
|
||||||
|
|
@ -243,7 +243,7 @@ public abstract class BaseInvoiceReceive<M extends BaseInvoiceReceive<M>> extend
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return supermarket_id 领取超市id
|
* @return supermarket_id 领取砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "supermarket_id")
|
@JSONField(name = "supermarket_id")
|
||||||
public Integer getSupermarketId() {
|
public Integer getSupermarketId() {
|
||||||
|
|
|
||||||
|
|
@ -252,7 +252,7 @@ public abstract class BaseOrderInvalidVerify<M extends BaseOrderInvalidVerify<M>
|
||||||
* isNullable: YES
|
* isNullable: YES
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
* @param supermarketId 超市id
|
* @param supermarketId 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="supermarket_id")
|
@JSONField(name="supermarket_id")
|
||||||
public void setSupermarketId(Integer supermarketId) {
|
public void setSupermarketId(Integer supermarketId) {
|
||||||
|
|
@ -261,7 +261,7 @@ public abstract class BaseOrderInvalidVerify<M extends BaseOrderInvalidVerify<M>
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return supermarket_id 超市id
|
* @return supermarket_id 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name="supermarket_id")
|
@JSONField(name="supermarket_id")
|
||||||
public Integer getSupermarketId() {
|
public Integer getSupermarketId() {
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ public abstract class BaseOrderTemp<M extends BaseOrderTemp<M>> extends BaseMode
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
*
|
*
|
||||||
* @param supermarketId 超市id
|
* @param supermarketId 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "supermarket_id")
|
@JSONField(name = "supermarket_id")
|
||||||
public void setSupermarketId(Integer supermarketId) {
|
public void setSupermarketId(Integer supermarketId) {
|
||||||
|
|
@ -105,7 +105,7 @@ public abstract class BaseOrderTemp<M extends BaseOrderTemp<M>> extends BaseMode
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return supermarket_id 超市id
|
* @return supermarket_id 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "supermarket_id")
|
@JSONField(name = "supermarket_id")
|
||||||
public Integer getSupermarketId() {
|
public Integer getSupermarketId() {
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import com.alibaba.fastjson.annotation.JSONField;
|
||||||
/**
|
/**
|
||||||
* Generated by COWR Tue Aug 25 17:27:08 CST 2020
|
* Generated by COWR Tue Aug 25 17:27:08 CST 2020
|
||||||
* TableName: supermarket_customer_distance
|
* TableName: supermarket_customer_distance
|
||||||
* Remarks: 基础配置 - 超市到客户的距离
|
* Remarks: 基础配置 - 砂站到客户的距离
|
||||||
* PrimaryKey: supermarket_id,customer_id
|
* PrimaryKey: supermarket_id,customer_id
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
|
|
@ -27,7 +27,7 @@ public abstract class BaseSupermarketCustomerDistance<M extends BaseSupermarketC
|
||||||
* isPrimaryKey: YES
|
* isPrimaryKey: YES
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
*
|
*
|
||||||
* @param supermarketId 超市id
|
* @param supermarketId 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "supermarket_id")
|
@JSONField(name = "supermarket_id")
|
||||||
public void setSupermarketId(Integer supermarketId) {
|
public void setSupermarketId(Integer supermarketId) {
|
||||||
|
|
@ -36,7 +36,7 @@ public abstract class BaseSupermarketCustomerDistance<M extends BaseSupermarketC
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return supermarket_id 超市id
|
* @return supermarket_id 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "supermarket_id")
|
@JSONField(name = "supermarket_id")
|
||||||
public Integer getSupermarketId() {
|
public Integer getSupermarketId() {
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ public abstract class BaseSyncTask<M extends BaseSyncTask<M>> extends BaseModel<
|
||||||
* isPrimaryKey: NO
|
* isPrimaryKey: NO
|
||||||
* defaultValue:
|
* defaultValue:
|
||||||
*
|
*
|
||||||
* @param supermarketId 超市id
|
* @param supermarketId 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "supermarket_id")
|
@JSONField(name = "supermarket_id")
|
||||||
public void setSupermarketId(Integer supermarketId) {
|
public void setSupermarketId(Integer supermarketId) {
|
||||||
|
|
@ -105,7 +105,7 @@ public abstract class BaseSyncTask<M extends BaseSyncTask<M>> extends BaseModel<
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return supermarket_id 超市id
|
* @return supermarket_id 砂站id
|
||||||
*/
|
*/
|
||||||
@JSONField(name = "supermarket_id")
|
@JSONField(name = "supermarket_id")
|
||||||
public Integer getSupermarketId() {
|
public Integer getSupermarketId() {
|
||||||
|
|
|
||||||
|
|
@ -132,7 +132,7 @@ public class InvoiceReceiveService extends BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取指定超市下一个可用的发票号码
|
* 获取指定砂站下一个可用的发票号码
|
||||||
* TODO:要区分专票和普票
|
* TODO:要区分专票和普票
|
||||||
*
|
*
|
||||||
* @param supermarket_id
|
* @param supermarket_id
|
||||||
|
|
|
||||||
|
|
@ -338,12 +338,13 @@ 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) {
|
public List<Record> undonlist(int supermarket_id, String customer_name, String cutoff_time) {
|
||||||
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.supermarket_id = ? \n" +
|
" and t.supermarket_id = ? \n" +
|
||||||
" and t.customer_name = ? ";
|
" and t.customer_name = ? ";
|
||||||
return Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), supermarket_id, customer_name);
|
return Db.find(sql, OrderStateEnum.RECEIVED.getStateid(), cutoff_time + "%", supermarket_id, customer_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -26,11 +26,49 @@ import java.util.List;
|
||||||
public class OrderclusterTruckService extends BaseService {
|
public class OrderclusterTruckService extends BaseService {
|
||||||
public static final OrderclusterTruckService me = new OrderclusterTruckService();
|
public static final OrderclusterTruckService me = new OrderclusterTruckService();
|
||||||
|
|
||||||
public Page<Record> find(PageParam pp) {
|
public Page<Record> find(PageParam pp, String stm, String etm, String customer_name, String truck_license, Integer state) {
|
||||||
String selectsql = "select * ";
|
String selectsql = "select t.id, t.truck_license" +
|
||||||
String fromsql = "from ordercluster_truck t where 1=1 ";
|
", c.uuid, c.total_weight, c.avg_weight, c.create_time, c.cutoff_time, c.complete_time" +
|
||||||
|
", c.unit_price, c.state, c.supermarket_id, c.trans_distance, c.pay_type, c.create_user_id" +
|
||||||
|
", c.create_user_name, c.req_receipt, c.change_time, c.product_id, c.product_name, c.customer_id" +
|
||||||
|
", c.customer_name, c.customer_texpayer_name, c.customer_texpayer_num, c.customer_address" +
|
||||||
|
", c.customer_phone, c.customer_bank_name, c.customer_bank_account, c.customer_receiver_name" +
|
||||||
|
", c.customer_receiver_phone, c.customer_receiver_address, c.customer_receiver_lgtd" +
|
||||||
|
", c.customer_receiver_lttd, c.trans_co_id, c.trans_co_name, c.trans_co_texpayer_name" +
|
||||||
|
", c.trans_co_texpayer_num, c.trans_co_address, c.trans_co_phone, c.trans_co_bank_name" +
|
||||||
|
", c.trans_co_bank_account, c.time_interval, c.mini_truck" +
|
||||||
|
", s.name supermarket_name ";
|
||||||
|
String fromsql = "from ordercluster_truck t \n" +
|
||||||
|
" left join ordercluster c on c.id = t.ordercluster_id \n" +
|
||||||
|
" left join supermarket s on s.id = c.supermarket_id \n" +
|
||||||
|
" where 1=1 ";
|
||||||
List<Object> paraList = new ArrayList<>();
|
List<Object> paraList = new ArrayList<>();
|
||||||
|
|
||||||
|
if (StrKit.notBlank(stm)) {
|
||||||
|
fromsql += " and c.cutoff_time >= ? \n";
|
||||||
|
paraList.add(stm);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(etm)) {
|
||||||
|
fromsql += " and c.cutoff_time <= ? \n";
|
||||||
|
paraList.add(etm);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(customer_name)) {
|
||||||
|
fromsql += " and c.customer_name like ? \n";
|
||||||
|
paraList.add("%" + customer_name.trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(truck_license)) {
|
||||||
|
fromsql += " and t.truck_license like ? \n";
|
||||||
|
paraList.add("%" + truck_license.trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state != null) {
|
||||||
|
fromsql += " and c.state = ? \n";
|
||||||
|
paraList.add(state);
|
||||||
|
}
|
||||||
|
|
||||||
String totalRowSql = "select count(*) " + fromsql;
|
String totalRowSql = "select count(*) " + fromsql;
|
||||||
String findSql = selectsql + fromsql;
|
String findSql = selectsql + fromsql;
|
||||||
|
|
||||||
|
|
@ -43,6 +81,8 @@ public class OrderclusterTruckService extends BaseService {
|
||||||
} else {
|
} else {
|
||||||
findSql += " " + Const.ORDER_BY_DESC;
|
findSql += " " + Const.ORDER_BY_DESC;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
findSql += " order by c.cutoff_time desc, t.id";
|
||||||
}
|
}
|
||||||
|
|
||||||
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
|
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
|
||||||
|
|
@ -54,6 +94,7 @@ public class OrderclusterTruckService extends BaseService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 验证车牌号是不是再当天有运输任务
|
* 验证车牌号是不是再当天有运输任务
|
||||||
|
*
|
||||||
* @param supermarket_id
|
* @param supermarket_id
|
||||||
* @param truck_license
|
* @param truck_license
|
||||||
* @return
|
* @return
|
||||||
|
|
@ -88,7 +129,7 @@ public class OrderclusterTruckService extends BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用超市id、车牌号查询当天关联的集团订单信息
|
* 用砂站id、车牌号查询当天关联的集团订单信息
|
||||||
*
|
*
|
||||||
* @param supermarket_id
|
* @param supermarket_id
|
||||||
* @param truck_license
|
* @param truck_license
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ 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.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.cowr.ssjygl.stat.invoice;
|
||||||
|
|
||||||
|
import com.cowr.common.validator.DayValidator;
|
||||||
|
import com.cowr.common.view.ExcelRender;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.cowr.ssjygl.stat.sale.OrderStatService;
|
||||||
|
import com.jfinal.aop.Before;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
import org.apache.poi.ss.usermodel.Workbook;
|
||||||
|
|
||||||
|
public class InvoiceUseController extends Controller {
|
||||||
|
@Before(DayValidator.class)
|
||||||
|
public void statuse() {
|
||||||
|
String tm = get("tm");
|
||||||
|
Integer supermarket_id = getInt("supermarket_id");
|
||||||
|
Integer invoice_type = getInt("invoice_type");
|
||||||
|
String invoice_number = get("invoice_number");
|
||||||
|
String invoice_code = get("invoice_code");
|
||||||
|
Integer invoice_state = getInt("invoice_state");
|
||||||
|
String order_sn = get("order_sn");
|
||||||
|
String truck_license = get("truck_license");
|
||||||
|
Integer order_state = getInt("order_state");
|
||||||
|
|
||||||
|
int export = getInt("export", 0);
|
||||||
|
if (export == 0) {
|
||||||
|
renderJson(Result.success(InvoiceUseService.me.statuse(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, order_sn, truck_license, order_state)));
|
||||||
|
}else{
|
||||||
|
Workbook wb = InvoiceUseService.me.statuseExport(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, order_sn, truck_license, order_state);
|
||||||
|
render(new ExcelRender(tm + "_票据使用记录_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,312 @@
|
||||||
|
package com.cowr.ssjygl.stat.invoice;
|
||||||
|
|
||||||
|
import com.cowr.common.utils.DataUtil;
|
||||||
|
import com.cowr.common.utils.DateTimeUtil;
|
||||||
|
import com.jfinal.kit.StrKit;
|
||||||
|
import com.jfinal.log.Log;
|
||||||
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
|
import com.jfinal.plugin.activerecord.Record;
|
||||||
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class InvoiceUseService {
|
||||||
|
private static Log log = Log.getLog(InvoiceUseService.class);
|
||||||
|
public static InvoiceUseService me = new InvoiceUseService();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 票据使用情况统计
|
||||||
|
*
|
||||||
|
* @param tm 日期 yyyy-DD-dd
|
||||||
|
* @param supermarket_id 砂站id
|
||||||
|
* @param invoice_type 发票类型 1 普票、2 专票
|
||||||
|
* @param invoice_number 发票代码
|
||||||
|
* @param invoice_code 发票号码
|
||||||
|
* @param invoice_state 发票状态 5 已使用 9 已取消
|
||||||
|
* @param order_sn 订单号
|
||||||
|
* @param truck_license 车牌号
|
||||||
|
* @param order_state 订单状态 5 已出货 9 已取消
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Record statuse(
|
||||||
|
String tm,
|
||||||
|
Integer supermarket_id,
|
||||||
|
Integer invoice_type,
|
||||||
|
String invoice_number,
|
||||||
|
String invoice_code,
|
||||||
|
Integer invoice_state,
|
||||||
|
String order_sn,
|
||||||
|
String truck_license,
|
||||||
|
Integer order_state
|
||||||
|
) {
|
||||||
|
String logsql = "select \n" +
|
||||||
|
" t.id rowkey, t.invoice_number, t.`code` invoice_code, t.state invoice_state, t.settlement_user_name, t.settlement_time, t.create_time, t.invalid_time, t.invalid_memo, t.invoice_type, t.invalid_user_name\n" +
|
||||||
|
" , r.receive_user_name, r.create_time receive_time, r.supermarket_id\n" +
|
||||||
|
" , o.sn order_sn, o.weight, o.total_price, o.unit_price, o.truck_license, o.customer_id, o.customer_texpayer_name, o.customer_texpayer_num, o.isprepaid, o.state order_state\n" +
|
||||||
|
" , s.name supermarket_name " +
|
||||||
|
" from invoice_log t\n" +
|
||||||
|
" left join invoice_receive r on t.invoice_receive_id = r.id\n" +
|
||||||
|
" left join order_temp o on o.sn = t.order_sn \n" +
|
||||||
|
" left join supermarket s on s.id = r.supermarket_id \n" +
|
||||||
|
" where 1 = 1 \n";
|
||||||
|
|
||||||
|
String ordsql = "select\n" +
|
||||||
|
" t.uuid rowkey, t.invoice_number, t.invoice_code, null invoice_state, t.settlement_user_name, null settlement_time, t.create_time, null invalid_time, null invalid_memo, t.invoice_type, null invalid_user_name\n" +
|
||||||
|
" , null receive_user_name, null receive_time, t.supermarket_id \n" +
|
||||||
|
" , t.sn order_sn, t.weight, t.total_price, t.unit_price, t.truck_license, t.customer_id, t.customer_texpayer_name, t.customer_texpayer_num, t.isprepaid, t.state order_state \n" +
|
||||||
|
" , s.name supermarket_name " +
|
||||||
|
" from order_temp t \n" +
|
||||||
|
" left join invoice_log l on l.order_sn = t.sn \n" +
|
||||||
|
" left join supermarket s on s.id = t.supermarket_id \n" +
|
||||||
|
" where t.invoice_type = 2 \n" +
|
||||||
|
" and l.id is null\n";
|
||||||
|
|
||||||
|
List<Object> paramlog = new ArrayList<>();
|
||||||
|
List<Object> paramord = new ArrayList<>();
|
||||||
|
|
||||||
|
logsql += " and t.create_time like ? \n";
|
||||||
|
ordsql += " and t.create_time like ? \n";
|
||||||
|
|
||||||
|
paramlog.add(tm + "%");
|
||||||
|
paramord.add(tm + "%");
|
||||||
|
|
||||||
|
if (supermarket_id != null) {
|
||||||
|
logsql += " and r.supermarket_id = ? \n"; // 这里用领用记录的 supermarket_id
|
||||||
|
ordsql += " and t.supermarket_id = ? \n";
|
||||||
|
|
||||||
|
paramlog.add(supermarket_id);
|
||||||
|
paramord.add(supermarket_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(invoice_number)) {
|
||||||
|
logsql += " and t.invoice_number like ? \n";
|
||||||
|
ordsql += " and t.invoice_number like ? \n";
|
||||||
|
|
||||||
|
paramlog.add("%" + invoice_number.trim() + "%");
|
||||||
|
paramord.add("%" + invoice_number.trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(invoice_code)) {
|
||||||
|
logsql += " and t.code like ? \n";
|
||||||
|
ordsql += " and t.invoice_code like ? \n";
|
||||||
|
|
||||||
|
paramlog.add("%" + invoice_code.trim() + "%");
|
||||||
|
paramord.add("%" + invoice_code.trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(order_sn)) {
|
||||||
|
logsql += " and t.order_sn like ? \n";
|
||||||
|
ordsql += " and t.sn like ? \n";
|
||||||
|
|
||||||
|
paramlog.add("%" + order_sn.trim() + "%");
|
||||||
|
paramord.add("%" + order_sn.trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StrKit.notBlank(truck_license)) {
|
||||||
|
logsql += " and o.truck_license like ? \n"; // 订单表里面才有车牌号
|
||||||
|
ordsql += " and t.truck_license like ? \n";
|
||||||
|
|
||||||
|
paramlog.add("%" + truck_license.trim() + "%");
|
||||||
|
paramord.add("%" + truck_license.trim() + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (invoice_state != null) {
|
||||||
|
logsql += " and t.state = ? \n";
|
||||||
|
paramlog.add(invoice_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (order_state != null) {
|
||||||
|
logsql += " and o.state = ? \n";
|
||||||
|
ordsql += " and t.state = ? \n";
|
||||||
|
|
||||||
|
paramlog.add(order_state);
|
||||||
|
paramord.add(order_state);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Record> list = new ArrayList<>();
|
||||||
|
|
||||||
|
if (invoice_type != null && invoice_type == 1) {
|
||||||
|
list = Db.find(logsql + " order by t.create_time", paramlog.toArray());
|
||||||
|
} else {
|
||||||
|
if (invoice_type != null && invoice_type == 2) {
|
||||||
|
logsql += " and t.invoice_type = ? \n";
|
||||||
|
ordsql += " and t.invoice_type = ? \n";
|
||||||
|
|
||||||
|
paramlog.add(invoice_type);
|
||||||
|
paramord.add(invoice_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
paramlog.addAll(paramord);
|
||||||
|
|
||||||
|
list = Db.find("select * from (" + logsql + "\n union \n " + ordsql + ") a order by a.create_time ", paramlog.toArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
Record out = new Record();
|
||||||
|
out.set("list", list);
|
||||||
|
out.set("cnt", list.size());
|
||||||
|
out.set("total_weight", 0.0);
|
||||||
|
out.set("total_price", 0.0);
|
||||||
|
out.set("invoice_type_1_cnt", 0);
|
||||||
|
out.set("invoice_type_2_cnt", 0);
|
||||||
|
|
||||||
|
for (Record record : list) {
|
||||||
|
if (record.get("weight") != null) {
|
||||||
|
out.set("total_weight", out.getBigDecimal("total_weight").add(record.getBigDecimal("weight")));
|
||||||
|
}
|
||||||
|
if (record.get("total_price") != null) {
|
||||||
|
out.set("total_price", out.getBigDecimal("total_price").add(record.getBigDecimal("total_price")));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (record.getInt("invoice_type") == 1) {
|
||||||
|
out.set("invoice_type_1_cnt", out.getInt("invoice_type_1_cnt") + 1);
|
||||||
|
} else if (record.getInt("invoice_type") == 2) {
|
||||||
|
out.set("invoice_type_2_cnt", out.getInt("invoice_type_2_cnt") + 1);
|
||||||
|
} else {
|
||||||
|
log.debug("错误数据: %s", record.toJson());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Workbook statuseExport(
|
||||||
|
String tm,
|
||||||
|
Integer supermarket_id,
|
||||||
|
Integer invoice_type,
|
||||||
|
String invoice_number,
|
||||||
|
String invoice_code,
|
||||||
|
Integer invoice_state,
|
||||||
|
String order_sn,
|
||||||
|
String truck_license,
|
||||||
|
Integer order_state
|
||||||
|
) {
|
||||||
|
Record ret = statuse(tm, supermarket_id, invoice_type, invoice_number, invoice_code, invoice_state, order_sn, truck_license, order_state);
|
||||||
|
|
||||||
|
List<Record> list = ret.get("list");
|
||||||
|
|
||||||
|
Workbook wb = new XSSFWorkbook();
|
||||||
|
Sheet sheet = wb.createSheet("票据使用记录");
|
||||||
|
|
||||||
|
// 表头 start
|
||||||
|
Row row = sheet.createRow(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("订单状态");
|
||||||
|
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
|
||||||
|
|
||||||
|
int end_col = 19;
|
||||||
|
int datalen = list.size();
|
||||||
|
for (int i = 0; i < datalen; i++) {
|
||||||
|
Record order = list.get(i);
|
||||||
|
|
||||||
|
row = sheet.createRow(i + 1);
|
||||||
|
a = 0;
|
||||||
|
row.createCell(a++).setCellValue(i + 1);
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("order_sn"));
|
||||||
|
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("create_time")));
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("supermarket_name"));
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("customer_texpayer_name"));
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("customer_texpayer_num"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "weight"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price"));
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("truck_license"));
|
||||||
|
if (order.get("order_state") != null) {
|
||||||
|
switch (order.getInt("order_state")) {
|
||||||
|
case 1:
|
||||||
|
row.createCell(a++).setCellValue("新建");
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
row.createCell(a++).setCellValue("待付款");
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
row.createCell(a++).setCellValue("已完成");
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
row.createCell(a++).setCellValue("已取消");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
}
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("invoice_number"));
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("invoice_code"));
|
||||||
|
row.createCell(a++).setCellValue(order.getInt("invoice_type") == 2 ? "专票" : "普票");
|
||||||
|
if (order.get("invoice_state") != null) {
|
||||||
|
switch (order.getInt("invoice_state")) {
|
||||||
|
case 5:
|
||||||
|
row.createCell(a++).setCellValue("已使用");
|
||||||
|
break;
|
||||||
|
case 9:
|
||||||
|
row.createCell(a++).setCellValue("已作废");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
}
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("settlement_user_name"));
|
||||||
|
if (order.get("settlement_time") != null) {
|
||||||
|
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("settlement_time")));
|
||||||
|
} else {
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
}
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("invalid_user_name"));
|
||||||
|
if (order.get("invalid_time") != null) {
|
||||||
|
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("invalid_time")));
|
||||||
|
} else {
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
}
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("invalid_memo"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 通用单元格格式
|
||||||
|
Font font = wb.createFont();
|
||||||
|
CellStyle cellStyle = wb.createCellStyle();
|
||||||
|
font.setFontHeight((short) (10 * 20));
|
||||||
|
font.setFontName("宋体");
|
||||||
|
cellStyle.setAlignment(HorizontalAlignment.CENTER);//水平居中
|
||||||
|
cellStyle.setVerticalAlignment(VerticalAlignment.CENTER);//垂直居中
|
||||||
|
cellStyle.setFont(font);
|
||||||
|
|
||||||
|
// 设置通用单元格格式
|
||||||
|
for (int r = 0; r < datalen + 1; r++) {
|
||||||
|
row = sheet.getRow(r);
|
||||||
|
if (row == null) {
|
||||||
|
row = sheet.createRow(r);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int c = 0; c < end_col + 1; c++) {
|
||||||
|
Cell cell = row.getCell(c);
|
||||||
|
|
||||||
|
if (cell == null) {
|
||||||
|
cell = row.createCell(c);
|
||||||
|
}
|
||||||
|
cell.setCellStyle(cellStyle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return wb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -12,8 +12,10 @@ import com.jfinal.log.Log;
|
||||||
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 org.apache.poi.ss.usermodel.*;
|
import org.apache.poi.ss.usermodel.*;
|
||||||
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class OrderStatService {
|
public class OrderStatService {
|
||||||
|
|
@ -285,8 +287,6 @@ public class OrderStatService {
|
||||||
|
|
||||||
double sum_weight = 0.0;
|
double sum_weight = 0.0;
|
||||||
double sum_price = 0.0;
|
double sum_price = 0.0;
|
||||||
double sum_distance = 0.0;
|
|
||||||
double sum_trans_price = 0.0;
|
|
||||||
double isprepaid_sum_price = 0.0;
|
double isprepaid_sum_price = 0.0;
|
||||||
int datalen = list.size();
|
int datalen = list.size();
|
||||||
int end_col = sup_name == null ? 11 : 10;
|
int end_col = sup_name == null ? 11 : 10;
|
||||||
|
|
@ -296,8 +296,6 @@ public class OrderStatService {
|
||||||
|
|
||||||
sum_weight += DataUtil.getDefaultByRecord(order, "weight");
|
sum_weight += DataUtil.getDefaultByRecord(order, "weight");
|
||||||
sum_price += DataUtil.getDefaultByRecord(order, "total_price");
|
sum_price += DataUtil.getDefaultByRecord(order, "total_price");
|
||||||
sum_distance += DataUtil.getDefaultByRecord(order, "trans_distance");
|
|
||||||
sum_trans_price += DataUtil.getDefaultByRecord(order, "trans_price");
|
|
||||||
|
|
||||||
if (order.getInt("isprepaid") == 1) {
|
if (order.getInt("isprepaid") == 1) {
|
||||||
isprepaid_sum_price += DataUtil.getDefaultByRecord(order, "total_price");
|
isprepaid_sum_price += DataUtil.getDefaultByRecord(order, "total_price");
|
||||||
|
|
@ -306,6 +304,11 @@ public class OrderStatService {
|
||||||
row = sheet.createRow(i + 3);
|
row = sheet.createRow(i + 3);
|
||||||
a = 0;
|
a = 0;
|
||||||
row.createCell(a++).setCellValue(i + 1);
|
row.createCell(a++).setCellValue(i + 1);
|
||||||
|
|
||||||
|
if (order.get("in_time") == null) {
|
||||||
|
log.error("有 transport 未同步成功 %s", order.toJson());
|
||||||
|
}
|
||||||
|
|
||||||
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("in_time")));
|
row.createCell(a++).setCellValue(DateTimeUtil.sdfhms.get().format(order.getDate("in_time")));
|
||||||
row.createCell(a++).setCellValue(order.getStr("sn"));
|
row.createCell(a++).setCellValue(order.getStr("sn"));
|
||||||
row.createCell(a++).setCellValue(order.getStr("product_name"));
|
row.createCell(a++).setCellValue(order.getStr("product_name"));
|
||||||
|
|
@ -1441,4 +1444,186 @@ public class OrderStatService {
|
||||||
|
|
||||||
return wb;
|
return wb;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<Record> yearStatBySup(String year) {
|
||||||
|
List<Record> list;
|
||||||
|
if (StrKit.notBlank(year)) {
|
||||||
|
list = Db.find("select s.name, a.* from supermarket s\n" +
|
||||||
|
"left join (\n" +
|
||||||
|
" select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" +
|
||||||
|
" where t.state = 5\n" +
|
||||||
|
" and t.create_time like ? \n" +
|
||||||
|
" group by t.supermarket_id\n" +
|
||||||
|
") a on s.id = a.id", year + "%");
|
||||||
|
} else {
|
||||||
|
list = Db.find("select s.name, a.* from supermarket s\n" +
|
||||||
|
"left join (\n" +
|
||||||
|
" select t.supermarket_id id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" +
|
||||||
|
" where t.state = 5\n" +
|
||||||
|
" group by t.supermarket_id\n" +
|
||||||
|
") a on s.id = a.id");
|
||||||
|
}
|
||||||
|
|
||||||
|
Record hj = new Record();
|
||||||
|
hj.set("id", 0);
|
||||||
|
hj.set("name", "合计");
|
||||||
|
hj.set("cnt", 0);
|
||||||
|
hj.set("total_price", new BigDecimal(0));
|
||||||
|
hj.set("total_weight", new BigDecimal(0));
|
||||||
|
|
||||||
|
for (Record record : list) {
|
||||||
|
hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt"));
|
||||||
|
hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price")));
|
||||||
|
hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight")));
|
||||||
|
}
|
||||||
|
|
||||||
|
list.add(hj);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Workbook yearStatBySupExport(String year) {
|
||||||
|
List<Record> list = yearStatBySup(year);
|
||||||
|
Workbook wb = new XSSFWorkbook();
|
||||||
|
Sheet sheet;
|
||||||
|
|
||||||
|
if (StrKit.notBlank(year)) {
|
||||||
|
sheet = wb.createSheet(year + "年销售汇总");
|
||||||
|
} else {
|
||||||
|
sheet = wb.createSheet("销售汇总");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 表头 start
|
||||||
|
Row row = sheet.createRow(0);
|
||||||
|
int a = 0;
|
||||||
|
row.createCell(a++).setCellValue("名称");
|
||||||
|
row.createCell(a++).setCellValue("订单量");
|
||||||
|
row.createCell(a++).setCellValue("总销售吨数");
|
||||||
|
row.createCell(a++).setCellValue("总销售额");
|
||||||
|
|
||||||
|
int end_col = 4;
|
||||||
|
int datalen = list.size();
|
||||||
|
for (int i = 0; i < datalen; i++) {
|
||||||
|
Record order = list.get(i);
|
||||||
|
|
||||||
|
row = sheet.createRow(i + 1);
|
||||||
|
a = 0;
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("name"));
|
||||||
|
row.createCell(a++).setCellValue(order.getInt("cnt"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price"));
|
||||||
|
}
|
||||||
|
|
||||||
|
ReportExcelStyle.setCommonCellStyle(wb, sheet, datalen, end_col);
|
||||||
|
|
||||||
|
return wb;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Record> yearStatByCustomer(String year) {
|
||||||
|
List<Record> list;
|
||||||
|
if (StrKit.notBlank(year)) {
|
||||||
|
list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" +
|
||||||
|
" select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" +
|
||||||
|
" where t.state = 5\n" +
|
||||||
|
" and t.create_time like ? \n" +
|
||||||
|
" group by t.customer_id\n" +
|
||||||
|
" ) a\n" +
|
||||||
|
" left join customer c on c.id = a.id\n" +
|
||||||
|
" left join prepay_customer p on p.customer_id = a.id", year + "%");
|
||||||
|
} else {
|
||||||
|
list = Db.find("select ifnull(c.name, '零散') name, a.*, p.surplus total_surplus from (\n" +
|
||||||
|
" select ifnull(t.customer_id, -1) id, count(t.sn) cnt, sum(t.total_price) total_price, sum(weight) total_weight from order_temp t\n" +
|
||||||
|
" where t.state = 5\n" +
|
||||||
|
" group by t.customer_id\n" +
|
||||||
|
" ) a\n" +
|
||||||
|
" left join customer c on c.id = a.id\n" +
|
||||||
|
" left join prepay_customer p on p.customer_id = a.id");
|
||||||
|
}
|
||||||
|
|
||||||
|
Record hj = new Record();
|
||||||
|
hj.set("id", 0);
|
||||||
|
hj.set("name", "合计");
|
||||||
|
hj.set("cnt", 0);
|
||||||
|
hj.set("total_price", new BigDecimal(0));
|
||||||
|
hj.set("total_weight", new BigDecimal(0));
|
||||||
|
hj.set("total_weight", new BigDecimal(0));
|
||||||
|
hj.set("total_surplus", new BigDecimal(0));
|
||||||
|
|
||||||
|
for (Record record : list) {
|
||||||
|
hj.set("cnt", hj.getInt("cnt") + record.getInt("cnt"));
|
||||||
|
hj.set("total_price", hj.getBigDecimal("total_price").add(record.getBigDecimal("total_price")));
|
||||||
|
hj.set("total_weight", hj.getBigDecimal("total_weight").add(record.getBigDecimal("total_weight")));
|
||||||
|
|
||||||
|
if (record.get("total_surplus") != null) {
|
||||||
|
hj.set("total_surplus", hj.getBigDecimal("total_surplus").add(record.getBigDecimal("total_surplus")));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
hj.set("total_account_surplus", hj.getBigDecimal("total_surplus").add(hj.getBigDecimal("total_price")));
|
||||||
|
|
||||||
|
list.add(hj);
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Workbook yearStatByCustomerExport(String year) {
|
||||||
|
List<Record> list = yearStatByCustomer(year);
|
||||||
|
Workbook wb = new XSSFWorkbook();
|
||||||
|
Sheet sheet;
|
||||||
|
|
||||||
|
if (StrKit.notBlank(year)) {
|
||||||
|
sheet = wb.createSheet(year + "年销售汇总");
|
||||||
|
} else {
|
||||||
|
sheet = wb.createSheet("销售汇总");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 表头 start
|
||||||
|
Row row = sheet.createRow(0);
|
||||||
|
int a = 0;
|
||||||
|
row.createCell(a++).setCellValue("名称");
|
||||||
|
row.createCell(a++).setCellValue("订单量");
|
||||||
|
row.createCell(a++).setCellValue("总销售吨数");
|
||||||
|
row.createCell(a++).setCellValue("总销售额");
|
||||||
|
row.createCell(a++).setCellValue("客户总余额");
|
||||||
|
|
||||||
|
int end_col = 5;
|
||||||
|
int datalen = list.size();
|
||||||
|
Record hj = null;
|
||||||
|
|
||||||
|
for (int i = 0; i < datalen; i++) {
|
||||||
|
Record order = list.get(i);
|
||||||
|
|
||||||
|
row = sheet.createRow(i + 1);
|
||||||
|
a = 0;
|
||||||
|
|
||||||
|
if (order.getInt("id") == 0) {
|
||||||
|
hj = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
row.createCell(a++).setCellValue(order.getStr("name"));
|
||||||
|
row.createCell(a++).setCellValue(order.getInt("cnt"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_weight"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_price"));
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(order, "total_surplus"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hj != null) {
|
||||||
|
row = sheet.createRow(datalen + 1);
|
||||||
|
a = 0;
|
||||||
|
|
||||||
|
row.createCell(a++).setCellValue("账户总余额");
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
row.createCell(a++).setCellValue(DataUtil.getDefaultByRecord(hj, "total_account_surplus"));
|
||||||
|
row.createCell(a++).setCellValue("");
|
||||||
|
}
|
||||||
|
|
||||||
|
sheet.addMergedRegion(new CellRangeAddress(datalen + 1, datalen + 1, 3, 4));// 下标从0开始 起始行号,终止行号, 起始列号,终止列号
|
||||||
|
ReportExcelStyle.setCommonCellStyle(wb, sheet, datalen + 1, end_col);
|
||||||
|
|
||||||
|
return wb;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import com.jfinal.core.Controller;
|
||||||
/**
|
/**
|
||||||
* Generated by COWR Tue Aug 25 17:27:14 CST 2020
|
* Generated by COWR Tue Aug 25 17:27:14 CST 2020
|
||||||
* TableName: supermarket_customer_distance
|
* TableName: supermarket_customer_distance
|
||||||
* Remarks: 基础配置 - 超市到客户的距离
|
* Remarks: 基础配置 - 砂站到客户的距离
|
||||||
* PrimaryKey: supermarket_id,customer_id
|
* PrimaryKey: supermarket_id,customer_id
|
||||||
*/
|
*/
|
||||||
public class SupermarketCustomerDistancePKValidator extends CrudParamValidator {
|
public class SupermarketCustomerDistancePKValidator extends CrudParamValidator {
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* Generated by COWR Tue Aug 25 17:27:14 CST 2020
|
* Generated by COWR Tue Aug 25 17:27:14 CST 2020
|
||||||
* TableName: supermarket_customer_distance
|
* TableName: supermarket_customer_distance
|
||||||
* Remarks: 基础配置 - 超市到客户的距离
|
* Remarks: 基础配置 - 砂站到客户的距离
|
||||||
* PrimaryKey: supermarket_id,customer_id
|
* PrimaryKey: supermarket_id,customer_id
|
||||||
*/
|
*/
|
||||||
public class SupermarketCustomerDistanceService extends BaseService {
|
public class SupermarketCustomerDistanceService extends BaseService {
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ import com.cowr.model.SupermarketCustomerDistance;
|
||||||
/**
|
/**
|
||||||
* Generated by COWR Tue Aug 25 17:27:14 CST 2020
|
* Generated by COWR Tue Aug 25 17:27:14 CST 2020
|
||||||
* TableName: supermarket_customer_distance
|
* TableName: supermarket_customer_distance
|
||||||
* Remarks: 基础配置 - 超市到客户的距离
|
* Remarks: 基础配置 - 砂站到客户的距离
|
||||||
* PrimaryKey: supermarket_id,customer_id
|
* PrimaryKey: supermarket_id,customer_id
|
||||||
*/
|
*/
|
||||||
public class SupermarketCustomerDistanceValidator extends CrudParamValidator {
|
public class SupermarketCustomerDistanceValidator extends CrudParamValidator {
|
||||||
|
|
|
||||||
|
|
@ -169,7 +169,7 @@ public class DeviceThread extends Thread {
|
||||||
LEDThread led = new LEDThread(which + "_led", ledconf.getString("ip"), ledconf.getIntValue("port"));
|
LEDThread led = new LEDThread(which + "_led", ledconf.getString("ip"), ledconf.getIntValue("port"));
|
||||||
AbsScale scale;
|
AbsScale scale;
|
||||||
|
|
||||||
// 根据超市id,兼容不同的表头
|
// 根据砂站id,兼容不同的表头
|
||||||
if (supermarket_id == 3) { // 城隍用了耀华的表头
|
if (supermarket_id == 3) { // 城隍用了耀华的表头
|
||||||
scale = new YaoHuaScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
|
scale = new YaoHuaScale(which + "_scale", scaleconf.getString("ip"), scaleconf.getIntValue("port"));
|
||||||
} else if (supermarket_id == 4) { // 石畈用了两个不一样的表头
|
} else if (supermarket_id == 4) { // 石畈用了两个不一样的表头
|
||||||
|
|
|
||||||
|
|
@ -82,4 +82,20 @@ public class InvoiceLogController extends Controller {
|
||||||
InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段
|
InvoiceLog model = getModel(InvoiceLog.class, "", true); // 忽略不在model中的字段
|
||||||
renderJson(InvoiceLogService.me.findByPk(model));
|
renderJson(InvoiceLogService.me.findByPk(model));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void invalid() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Integer supermarket_id = getInt("supermarket_id", 0);
|
||||||
|
String invoice_number = get("invoice_number");
|
||||||
|
String code = get("code");
|
||||||
|
String invalid_memo = get("invalid_memo");
|
||||||
|
|
||||||
|
renderJson(InvoiceLogSyncService.me.invalid(supermarket_id, invoice_number, code, invalid_memo, tokenuser));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,120 @@
|
||||||
package com.cowr.local.ssjygl.invoice.log;
|
package com.cowr.local.ssjygl.invoice.log;
|
||||||
|
|
||||||
|
import com.cowr.common.enums.Enums;
|
||||||
|
import com.cowr.common.enums.OrderStateEnum;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.local.ssjygl.base.BaseSyncService;
|
import com.cowr.local.ssjygl.base.BaseSyncService;
|
||||||
|
import com.cowr.local.ssjygl.main.CliCacheData;
|
||||||
|
import com.cowr.local.ssjygl.synctask.SyncTaskService;
|
||||||
|
import com.cowr.model.*;
|
||||||
|
import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService;
|
||||||
|
import com.cowr.ssjygl.modifylog.ModifyLogService;
|
||||||
|
import com.jfinal.kit.StrKit;
|
||||||
import com.jfinal.log.Log;
|
import com.jfinal.log.Log;
|
||||||
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
|
import com.jfinal.plugin.activerecord.IAtom;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
public class InvoiceLogSyncService extends BaseSyncService {
|
public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
private static Log log = Log.getLog(InvoiceLogSyncService.class);
|
private static Log log = Log.getLog(InvoiceLogSyncService.class);
|
||||||
public static InvoiceLogSyncService me = new InvoiceLogSyncService();
|
public static InvoiceLogSyncService me = new InvoiceLogSyncService();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 作废发票,未关联订单的(损毁等,不是正常开票使用的发票)
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Result invalid(int supermarket_id, String invoice_number, String code, String invalid_memo, Sysuser sysuser) {
|
||||||
|
if (supermarket_id != CliCacheData.SUP.getId()) {
|
||||||
|
return Result.failed("砂站信息错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 先判断这张发票有没有被领用
|
||||||
|
InvoiceReceive receive = InvoiceReceiveService.me.checkSurplusReceive(supermarket_id, invoice_number, code);
|
||||||
|
if (receive == null) {
|
||||||
|
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
||||||
|
}
|
||||||
|
|
||||||
|
InvoiceLog invoiceLog = InvoiceLog.dao.findFirst("select * from invoice_log t \n" +
|
||||||
|
" where t.invoice_number = ? and t.code = ? limit 1 ", invoice_number, code);
|
||||||
|
|
||||||
|
if (invoiceLog != null) {
|
||||||
|
// 再判断这张发票是不是已经被取消了
|
||||||
|
if (invoiceLog.getState() == OrderStateEnum.INVALID.getStateid()) {
|
||||||
|
return Result.failed("发票已作废");
|
||||||
|
} else {
|
||||||
|
// 还要判断这张发票已经在订单上使用了
|
||||||
|
return Result.failed("发票已使用,请使用“取消发票”功能");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 然后就可以开始取消了
|
||||||
|
|
||||||
|
invoiceLog = new InvoiceLog();
|
||||||
|
invoiceLog.setId(StrKit.getRandomUUID());
|
||||||
|
invoiceLog.setInvalidUserId(sysuser.getId());
|
||||||
|
invoiceLog.setInvalidUserName(sysuser.getName());
|
||||||
|
invoiceLog.setInvalidTime(new Date());
|
||||||
|
invoiceLog.setInvalidMemo(invalid_memo);
|
||||||
|
invoiceLog.setState(OrderStateEnum.INVALID.getStateid());
|
||||||
|
invoiceLog.setInvoiceReceiveId(receive.getId());
|
||||||
|
invoiceLog.setCode(code);
|
||||||
|
invoiceLog.setInvoiceNumber(invoice_number);
|
||||||
|
|
||||||
|
receive.setSurplus(receive.getSurplus() - 1);
|
||||||
|
receive.setInvalidCount(receive.getInvalidCount() + 1);
|
||||||
|
|
||||||
|
if (receive.getSurplus() == 0) {
|
||||||
|
// 作废最后一张发票,当前发票停再最后一个发票号码上
|
||||||
|
receive.setCurrentCode(receive.getEndCode());
|
||||||
|
} else {
|
||||||
|
if (code.equals(receive.getStartCode())) { // 作废第一张发票
|
||||||
|
receive.setCurrentCode(String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode()) + 1));
|
||||||
|
} else if (code.equals(receive.getCurrentCode())) { // 作废顺延的下一张发票
|
||||||
|
receive.setCurrentCode(String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getCurrentCode()) + 1));
|
||||||
|
} else {
|
||||||
|
// 其他情况下不更新 current_code
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
|
||||||
|
InvoiceLog finalInvoiceLog = invoiceLog;
|
||||||
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() {
|
||||||
|
try {
|
||||||
|
boolean ret = finalInvoiceLog.save();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
synctask.addSaveData(finalInvoiceLog);
|
||||||
|
|
||||||
|
ret = receive.update();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
synctask.addUpdateData(receive);
|
||||||
|
|
||||||
|
return SyncTaskService.me.save(synctask)
|
||||||
|
&& ModifyLogService.me.save(finalInvoiceLog, null, Enums.DataOpType.SAVE.getId(), sysuser);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 普票作废理解同步到砂站
|
||||||
|
if (ret) {
|
||||||
|
SyncTaskService.me.send(synctask);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret ? Result.success(invoiceLog) : Result.failed(false, "处理失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -56,6 +56,7 @@ import com.cowr.ssjygl.cctv.CctvController;
|
||||||
import com.cowr.local.ssjygl.prepay.PrepayController;
|
import com.cowr.local.ssjygl.prepay.PrepayController;
|
||||||
import com.cowr.local.ssjygl.overall.OverallController;
|
import com.cowr.local.ssjygl.overall.OverallController;
|
||||||
import com.cowr.ssjygl.modifylog.ModifyLogController;
|
import com.cowr.ssjygl.modifylog.ModifyLogController;
|
||||||
|
import com.cowr.ssjygl.stat.invoice.InvoiceUseController;
|
||||||
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;
|
||||||
|
|
@ -94,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 = "20201030";
|
public static final String CLINET_VERSION = "20201103";
|
||||||
|
|
||||||
public static String getRootPath() {
|
public static String getRootPath() {
|
||||||
return PathKit.getWebRootPath()
|
return PathKit.getWebRootPath()
|
||||||
|
|
@ -225,6 +226,7 @@ public class Config extends JFinalConfig {
|
||||||
me.add("/stat/sale", OrderStatController.class);
|
me.add("/stat/sale", OrderStatController.class);
|
||||||
me.add("/stat/transfer", OrderTransferStatController.class);
|
me.add("/stat/transfer", OrderTransferStatController.class);
|
||||||
me.add("/stat/purchase", OrderPurchaseStatController.class);
|
me.add("/stat/purchase", OrderPurchaseStatController.class);
|
||||||
|
me.add("/stat/invoiceuse", InvoiceUseController.class);
|
||||||
|
|
||||||
// -- 发票管理
|
// -- 发票管理
|
||||||
me.add("/invoice/log", InvoiceLogController.class);
|
me.add("/invoice/log", InvoiceLogController.class);
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,7 @@ public class Main {
|
||||||
|
|
||||||
log.info("====================================================");
|
log.info("====================================================");
|
||||||
log.info("========= 启动本地服务 ==============");
|
log.info("========= 启动本地服务 ==============");
|
||||||
log.info("========= PID: %s ===============", pid);
|
log.info("========= PID: %s ==============", pid);
|
||||||
|
|
||||||
boolean isprod = Config.isProd();
|
boolean isprod = Config.isProd();
|
||||||
String path = PathKit.getWebRootPath();
|
String path = PathKit.getWebRootPath();
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ public class NettyClient {
|
||||||
new ReadTimeoutHandler(15),
|
new ReadTimeoutHandler(15),
|
||||||
new IdleStateHandler(5, 5, 5), // 处理心跳包
|
new IdleStateHandler(5, 5, 5), // 处理心跳包
|
||||||
new StringEncoder(CharsetUtil.UTF_8),
|
new StringEncoder(CharsetUtil.UTF_8),
|
||||||
new LineBasedFrameDecoder(1020 * 4096), // 处理粘包问题 // 数据内容超过这里设置的值,会导致数据发送失败
|
new LineBasedFrameDecoder(1024 * 4096), // 处理粘包问题 // 数据内容超过这里设置的值,会导致数据发送失败
|
||||||
new StringDecoder(CharsetUtil.UTF_8),
|
new StringDecoder(CharsetUtil.UTF_8),
|
||||||
new MsgHandler(supermarket_id)
|
new MsgHandler(supermarket_id)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,12 @@ public class OrderclusterTruckController extends Controller {
|
||||||
*/
|
*/
|
||||||
public void find() {
|
public void find() {
|
||||||
PageParam pp = getBean(PageParam.class, "", true);
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
renderJson(Result.object(OrderclusterTruckService.me.find(pp)));
|
String stm = get("stm");
|
||||||
|
String etm = get("etm");
|
||||||
|
String customer_name = get("customer_name");
|
||||||
|
String truck_license = get("truck_license");
|
||||||
|
Integer state = getInt("state");
|
||||||
|
renderJson(Result.object(OrderclusterTruckService.me.find(pp, stm, etm, customer_name, truck_license, state)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -632,7 +632,7 @@ public class OrderTempSyncService {
|
||||||
InvoiceReceive receive = null;
|
InvoiceReceive receive = null;
|
||||||
|
|
||||||
// 2020-09-29 需要开具专票的,先开具结算单,不打发票
|
// 2020-09-29 需要开具专票的,先开具结算单,不打发票
|
||||||
// 2020-10-12 所有超市都可以开结算单
|
// 2020-10-12 所有砂站都可以开结算单
|
||||||
if (customer.getInvoiceType() == 2) {
|
if (customer.getInvoiceType() == 2) {
|
||||||
order.setInvoiceType(2);
|
order.setInvoiceType(2);
|
||||||
// 需要专票的,在结算开了专票之后,再修改 invoice_site 字段
|
// 需要专票的,在结算开了专票之后,再修改 invoice_site 字段
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ 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;
|
||||||
|
|
@ -279,4 +280,26 @@ public class OrderStatController extends BaseController {
|
||||||
render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void statYearCustomer() {
|
||||||
|
String tm = get("tm");
|
||||||
|
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||||
|
if (export == 0) {
|
||||||
|
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm)));
|
||||||
|
} else {
|
||||||
|
Workbook wb = OrderStatService.me.yearStatByCustomerExport(tm);
|
||||||
|
render(new ExcelRender("按客户统计总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void statYearBySup() {
|
||||||
|
String tm = get("tm");
|
||||||
|
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||||
|
if (export == 0) {
|
||||||
|
renderJson(Result.object(OrderStatService.me.yearStatBySup(tm)));
|
||||||
|
} else {
|
||||||
|
Workbook wb = OrderStatService.me.yearStatBySupExport(tm);
|
||||||
|
render(new ExcelRender("按砂站总销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -174,6 +174,13 @@ public class SyncTaskService {
|
||||||
if (ret.length != list.size()) {
|
if (ret.length != list.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i : ret) {
|
||||||
|
// 必须是每条 sql 修改一条记录
|
||||||
|
if (i != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -196,6 +203,13 @@ public class SyncTaskService {
|
||||||
if (ret.length != list.size()) {
|
if (ret.length != list.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i : ret) {
|
||||||
|
// 必须是每条 sql 修改一条记录
|
||||||
|
if (i != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 将订单同步到不同的超市
|
// 将订单同步到不同的砂站
|
||||||
for (Map.Entry<Integer, SyncTask> entry : map.entrySet()) {
|
for (Map.Entry<Integer, SyncTask> entry : map.entrySet()) {
|
||||||
if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) {
|
if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -137,11 +137,11 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
Supermarket supermarket = Supermarket.dao.findById(supermarket_id);
|
Supermarket supermarket = Supermarket.dao.findById(supermarket_id);
|
||||||
|
|
||||||
if (supermarket == null) {
|
if (supermarket == null) {
|
||||||
return Result.failed("未找到超市信息");
|
return Result.failed("未找到砂站信息");
|
||||||
}
|
}
|
||||||
|
|
||||||
// 先判断这张发票有没有被领用
|
// 先判断这张发票有没有被领用
|
||||||
InvoiceReceive receive = InvoiceReceiveService.me.checkReceive(supermarket_id, invoice_number, code);
|
InvoiceReceive receive = InvoiceReceiveService.me.checkSurplusReceive(supermarket_id, invoice_number, code);
|
||||||
if (receive == null) {
|
if (receive == null) {
|
||||||
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
return Result.failed("没有有效的发票领用记录,或者发票已经被使用");
|
||||||
}
|
}
|
||||||
|
|
@ -175,10 +175,12 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
receive.setSurplus(receive.getSurplus() - 1);
|
receive.setSurplus(receive.getSurplus() - 1);
|
||||||
receive.setInvalidCount(receive.getInvalidCount() + 1);
|
receive.setInvalidCount(receive.getInvalidCount() + 1);
|
||||||
|
|
||||||
if (receive.getSurplus() == 0) {
|
if (receive.getSurplus() < 0) {
|
||||||
|
return Result.failed("作废失败,减少剩余量时发生错误");
|
||||||
|
} else if (receive.getSurplus() == 0) {
|
||||||
// 作废最后一张发票,当前发票停再最后一个发票号码上
|
// 作废最后一张发票,当前发票停再最后一个发票号码上
|
||||||
receive.setCurrentCode(receive.getEndCode());
|
receive.setCurrentCode(receive.getEndCode());
|
||||||
} else {
|
} else{
|
||||||
if (code.equals(receive.getStartCode())) { // 作废第一张发票
|
if (code.equals(receive.getStartCode())) { // 作废第一张发票
|
||||||
receive.setCurrentCode(String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode()) + 1));
|
receive.setCurrentCode(String.format("%0" + receive.getStartCode().length() + "d", Integer.parseInt(receive.getStartCode()) + 1));
|
||||||
} else if (code.equals(receive.getCurrentCode())) { // 作废顺延的下一张发票
|
} else if (code.equals(receive.getCurrentCode())) { // 作废顺延的下一张发票
|
||||||
|
|
@ -435,7 +437,7 @@ public class InvoiceLogSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将订单同步到不同的超市
|
// 将订单同步到不同的砂站
|
||||||
for (Map.Entry<Integer, SyncTask> entry : map.entrySet()) {
|
for (Map.Entry<Integer, SyncTask> entry : map.entrySet()) {
|
||||||
if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) {
|
if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -65,7 +65,7 @@ public class CheckUndonOrderclusterJob implements Job {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 各个超市分开同步
|
// 各个砂站分开同步
|
||||||
for (Map.Entry<Integer, SyncTask> entry : syncmap.entrySet()) {
|
for (Map.Entry<Integer, SyncTask> entry : syncmap.entrySet()) {
|
||||||
if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) {
|
if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ import com.cowr.ssjygl.cctv.CctvController;
|
||||||
import com.cowr.service.ssjygl.prepay.PrepayController;
|
import com.cowr.service.ssjygl.prepay.PrepayController;
|
||||||
import com.cowr.service.ssjygl.overall.OverallController;
|
import com.cowr.service.ssjygl.overall.OverallController;
|
||||||
import com.cowr.ssjygl.modifylog.ModifyLogController;
|
import com.cowr.ssjygl.modifylog.ModifyLogController;
|
||||||
|
import com.cowr.ssjygl.stat.invoice.InvoiceUseController;
|
||||||
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;
|
||||||
|
|
@ -192,6 +193,7 @@ public class Config extends JFinalConfig {
|
||||||
me.add("/stat/sale", OrderStatController.class);
|
me.add("/stat/sale", OrderStatController.class);
|
||||||
me.add("/stat/transfer", OrderTransferStatController.class);
|
me.add("/stat/transfer", OrderTransferStatController.class);
|
||||||
me.add("/stat/purchase", OrderPurchaseStatController.class);
|
me.add("/stat/purchase", OrderPurchaseStatController.class);
|
||||||
|
me.add("/stat/invoiceuse", InvoiceUseController.class);
|
||||||
|
|
||||||
// -- 发票管理
|
// -- 发票管理
|
||||||
me.add("/invoice/log", InvoiceLogController.class);
|
me.add("/invoice/log", InvoiceLogController.class);
|
||||||
|
|
|
||||||
|
|
@ -221,6 +221,8 @@ public class NettyServer {
|
||||||
.fluentPut("target", Enums.MsgTarget.SYNCRECV)
|
.fluentPut("target", Enums.MsgTarget.SYNCRECV)
|
||||||
.fluentPut("id", data.get("id"))
|
.fluentPut("id", data.get("id"))
|
||||||
.toJSONString());
|
.toJSONString());
|
||||||
|
} else {
|
||||||
|
log.debug("数据接收后,入库失败:", msg);
|
||||||
}
|
}
|
||||||
} else if (Enums.MsgTarget.SYNCRECV.name().equals(target)) {
|
} else if (Enums.MsgTarget.SYNCRECV.name().equals(target)) {
|
||||||
SyncTaskService.me.syncComplete(json.getString("id"));
|
SyncTaskService.me.syncComplete(json.getString("id"));
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
package com.cowr.service.ssjygl.order.ordercluster;
|
||||||
|
|
||||||
|
import com.cowr.common.validator.CrudParamValidator;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
import com.jfinal.kit.StrKit;
|
||||||
|
|
||||||
|
public class EditTempClusterValidator extends CrudParamValidator {
|
||||||
|
@Override
|
||||||
|
protected void validate(Controller c) {
|
||||||
|
validateRequired("id", "id", "id 必填");
|
||||||
|
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
|
||||||
|
validateBigDecimal("total_weight", new java.math.BigDecimal("0.01"), new java.math.BigDecimal(9.9999999999E10), "total_weight", "total_weight 范围 0.01~9.9999999999E10");
|
||||||
|
validateString("trucks", 1, 2000, "trucks", "trucks 长度 1~2000");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleError(Controller c) {
|
||||||
|
c.renderJson(Result.failed(getErrmsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
package com.cowr.service.ssjygl.order.ordercluster;
|
||||||
|
|
||||||
|
import com.cowr.common.utils.DateTimeUtil;
|
||||||
|
import com.cowr.common.validator.CrudParamValidator;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
import com.jfinal.kit.StrKit;
|
||||||
|
|
||||||
|
public class ForwardClusterValidator extends CrudParamValidator {
|
||||||
|
@Override
|
||||||
|
protected void validate(Controller c) {
|
||||||
|
validateRequired("id", "id", "id 必填");
|
||||||
|
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
|
||||||
|
validateBigDecimal("total_weight", new java.math.BigDecimal("0.01"), new java.math.BigDecimal(9.9999999999E10), "total_weight", "total_weight 范围 0.01~9.9999999999E10");
|
||||||
|
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"))) {
|
||||||
|
addError("cutoff_time", "截止时间不能早于今天");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleError(Controller c) {
|
||||||
|
c.renderJson(Result.failed(getErrmsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.cowr.service.ssjygl.order.ordercluster;
|
||||||
|
|
||||||
|
import com.cowr.common.utils.DateTimeUtil;
|
||||||
|
import com.cowr.common.validator.CrudParamValidator;
|
||||||
|
import com.cowr.common.view.Result;
|
||||||
|
import com.jfinal.core.Controller;
|
||||||
|
import com.jfinal.kit.StrKit;
|
||||||
|
|
||||||
|
public class ForwardTempValidator extends CrudParamValidator {
|
||||||
|
@Override
|
||||||
|
protected void validate(Controller c) {
|
||||||
|
validateRequired("id", "id", "id 必填");
|
||||||
|
validateInteger("id", 1, 2147483647, "id", "id 范围 1~2147483647");
|
||||||
|
validateBigDecimal("total_weight", new java.math.BigDecimal("0.01"), new java.math.BigDecimal(9.9999999999E10), "total_weight", "total_weight 范围 0.01~9.9999999999E10");
|
||||||
|
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"))) {
|
||||||
|
addError("cutoff_time", "截止时间不能早于今天");
|
||||||
|
}
|
||||||
|
|
||||||
|
validateString("trucks", 1, 2000, "trucks", "trucks 长度 1~2000");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void handleError(Controller c) {
|
||||||
|
c.renderJson(Result.failed(getErrmsg()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -14,6 +14,7 @@ import com.cowr.ssjygl.order.ordercluster.OrderclusterValidator;
|
||||||
import com.jfinal.aop.Before;
|
import com.jfinal.aop.Before;
|
||||||
import com.jfinal.log.Log;
|
import com.jfinal.log.Log;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
public class OrderclusterController extends BaseController {
|
public class OrderclusterController extends BaseController {
|
||||||
|
|
@ -91,7 +92,22 @@ public class OrderclusterController extends BaseController {
|
||||||
}
|
}
|
||||||
|
|
||||||
Ordercluster model = getModel(Ordercluster.class, "", true); // 忽略不在model中的字段
|
Ordercluster model = getModel(Ordercluster.class, "", true); // 忽略不在model中的字段
|
||||||
renderJson(OrderclusterSyncService.me.update(model, tokenuser));
|
renderJson(OrderclusterSyncService.me.updateCluster(model, tokenuser));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before(EditTempClusterValidator.class)
|
||||||
|
public void editTemp() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ordercluster model = getModel(Ordercluster.class, "", true); // 忽略不在model中的字段
|
||||||
|
String trucks = get("trucks");
|
||||||
|
|
||||||
|
renderJson(OrderclusterSyncService.me.updateTemp(model, trucks, tokenuser));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -226,4 +242,41 @@ public class OrderclusterController extends BaseController {
|
||||||
|
|
||||||
renderJson(Result.object(OrderclusterSyncService.me.complete(ordercluster_id, tokenuser)));
|
renderJson(Result.object(OrderclusterSyncService.me.complete(ordercluster_id, tokenuser)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 修改 ordercluster 订单簇 - 集团客户订单
|
||||||
|
*/
|
||||||
|
@Before(ForwardClusterValidator.class)
|
||||||
|
public void forwardCluster() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ordercluster_id = getInt("id");
|
||||||
|
double total_weight = getParaToDouble("total_weight");
|
||||||
|
Date cutoff_time = getDate("cutoff_time");
|
||||||
|
|
||||||
|
renderJson(OrderclusterSyncService.me.forwardCluster(ordercluster_id, new BigDecimal(total_weight), cutoff_time, tokenuser));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before(ForwardTempValidator.class)
|
||||||
|
public void forwardTemp() {
|
||||||
|
Sysuser tokenuser = SysuserSyncService.me.getSysuserByToken(get("token"));
|
||||||
|
|
||||||
|
if (tokenuser == null) {
|
||||||
|
renderJson(Result.noauth());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ordercluster_id = getInt("id");
|
||||||
|
double total_weight = getParaToDouble("total_weight");
|
||||||
|
Date cutoff_time = getDate("cutoff_time");
|
||||||
|
String trucks = get("trucks");
|
||||||
|
|
||||||
|
renderJson(OrderclusterSyncService.me.forwardTemp(ordercluster_id, new BigDecimal(total_weight), cutoff_time, trucks, tokenuser));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -96,7 +96,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chksup.contains(supermarket_id)) {
|
if (chksup.contains(supermarket_id)) {
|
||||||
return Result.failed("同一个客户不能重复给超市分配配额");
|
return Result.failed("同一个客户不能重复给砂站分配配额");
|
||||||
} else {
|
} else {
|
||||||
chksup.add(supermarket_id);
|
chksup.add(supermarket_id);
|
||||||
|
|
||||||
|
|
@ -112,7 +112,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (total_weight == 0) {
|
if (total_weight == 0) {
|
||||||
log.debug("重量为 0 的超市(id:%s)跳过", supermarket_id);
|
log.debug("重量为 0 的砂站(id:%s)跳过", supermarket_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -209,7 +209,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
syncmap.get(model.getSupermarketId()).addSaveData(model);
|
syncmap.get(model.getSupermarketId()).addSaveData(model);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 将订单同步到不同的超市
|
// 将订单同步到不同的砂站
|
||||||
for (Map.Entry<Integer, SyncTask> entry : syncmap.entrySet()) {
|
for (Map.Entry<Integer, SyncTask> entry : syncmap.entrySet()) {
|
||||||
if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) {
|
if (!SyncTaskService.me.save(entry.getValue(), entry.getKey())) {
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -245,6 +245,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
String trucks,
|
String trucks,
|
||||||
Sysuser sysuser
|
Sysuser sysuser
|
||||||
) {
|
) {
|
||||||
|
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) {
|
||||||
return Result.failed("砂站信息无效");
|
return Result.failed("砂站信息无效");
|
||||||
|
|
@ -254,10 +255,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);
|
List<Record> undonlist = OrderclusterService.me.undonlist(supermarket_id, customer_name, query_cutoff_time);
|
||||||
|
|
||||||
if (undonlist != null && !undonlist.isEmpty()) {
|
if (undonlist != null && !undonlist.isEmpty()) {
|
||||||
return Result.failedstr("客户[%s]在砂站[%s]还有未完成的配额", customer_name, SvrCacheData.SUP_CACHE.get(supermarket_id).getName());
|
return Result.failedstr("客户[%s][%s]在砂站[%s]还有未完成的配额", customer_name, 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);
|
||||||
|
|
@ -305,7 +306,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
return Result.failed(StrKit.join(ts, ",") + " 车牌号在黑名单中");
|
return Result.failed(StrKit.join(ts, ",") + " 车牌号在黑名单中");
|
||||||
}
|
}
|
||||||
|
|
||||||
ts.add(0, DateTimeUtil.sdf.get().format(cutoff_time) + "%");
|
ts.add(0, query_cutoff_time + "%");
|
||||||
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" +
|
||||||
|
|
@ -314,16 +315,20 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
" 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()) {
|
||||||
ts = new ArrayList<>();
|
List<String> outerr = new ArrayList<>();
|
||||||
|
|
||||||
for (Record bl : chkduk) {
|
for (Record bl : chkduk) {
|
||||||
ts.add(bl.get("truck_license"));
|
outerr.add(String.format(
|
||||||
|
"[%s]已经在[%s]分配给了[%s]",
|
||||||
|
bl.get("truck_license"),
|
||||||
|
DateTimeUtil.sdfymd.get().format(bl.get("cutoff_time")),
|
||||||
|
bl.get("customer_name")
|
||||||
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.failed(StrKit.join(ts, ",") + " 车牌号已经分配给其他客户");
|
return Result.failed(StrKit.join(outerr, "。"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SyncTask synctask = new SyncTask();
|
SyncTask synctask = new SyncTask();
|
||||||
Ordercluster model = new Ordercluster();
|
Ordercluster model = new Ordercluster();
|
||||||
model.setCustomerName(customer_name);
|
model.setCustomerName(customer_name);
|
||||||
|
|
@ -510,7 +515,203 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Result update(Ordercluster model, Sysuser sysuser) {
|
|
||||||
|
public Result updateTemp(Ordercluster model, String trucks, Sysuser sysuser) {
|
||||||
|
Ordercluster oldobj = model.findByPk();
|
||||||
|
|
||||||
|
if (oldobj == null) {
|
||||||
|
return Result.failed(false, "按主键未找到对应记录");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldobj.getState() >= OrderStateEnum.RECEIVED.getStateid()) {
|
||||||
|
return Result.failed(false, "订单已完成,不能修改");
|
||||||
|
}
|
||||||
|
|
||||||
|
BigDecimal overweight = OrderclusterService.me.getOverWeight(model.getId()); // 集团订单已完成量
|
||||||
|
|
||||||
|
if (model.getTotalWeight().compareTo(overweight) < 0) {
|
||||||
|
return Result.failedstr("总量不能低于已运输量(%.2f)", overweight);
|
||||||
|
} else {
|
||||||
|
oldobj.setTotalWeight(model.getTotalWeight());
|
||||||
|
}
|
||||||
|
|
||||||
|
String query_cutoff_time = DateTimeUtil.sdf.get().format(oldobj.getCutoffTime());
|
||||||
|
List<String> chk = new ArrayList<>();
|
||||||
|
String[] truckarr = trucks.split(",");
|
||||||
|
List<Object> ts = new ArrayList<>();
|
||||||
|
List<String> tsql = new ArrayList<>();
|
||||||
|
|
||||||
|
// 检查提交上来的车辆字符串是否用重复的
|
||||||
|
for (String truck_license : truckarr) {
|
||||||
|
if (chk.contains(truck_license)) {
|
||||||
|
return Result.failedstr("车牌号 %s 重复", truck_license);
|
||||||
|
}
|
||||||
|
|
||||||
|
chk.add(truck_license);
|
||||||
|
|
||||||
|
ts.add(truck_license);
|
||||||
|
tsql.add("?");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否还在黑名单中,未被移除
|
||||||
|
List<Blacklist> list = Blacklist.dao.find(
|
||||||
|
"select * from blacklist \n" +
|
||||||
|
" where remove_user_id is null \n" +
|
||||||
|
" and truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
|
if (list != null && !list.isEmpty()) {
|
||||||
|
List<String> retts = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Blacklist bl : list) {
|
||||||
|
retts.add(bl.getTruckLicense());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.failed(StrKit.join(retts, ",") + " 车牌号在黑名单中");
|
||||||
|
}
|
||||||
|
|
||||||
|
ts.add(0, query_cutoff_time + "%");
|
||||||
|
List<Record> chkduk = Db.find(
|
||||||
|
"select * from ordercluster_truck t \n" +
|
||||||
|
" left join ordercluster c on c.id = t.ordercluster_id\n" +
|
||||||
|
" where c.state < 5 \n" + // OrderStateEnum.RECEIVED.getStateid()
|
||||||
|
" and t.ordercluster_id <> " + oldobj.getId() +
|
||||||
|
" and c.cutoff_time like ? \n" +
|
||||||
|
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
|
if (chkduk != null && !chkduk.isEmpty()) {
|
||||||
|
List<String> outerr = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Record bl : chkduk) {
|
||||||
|
outerr.add(String.format(
|
||||||
|
"[%s]已经在[%s]分配给了[%s]",
|
||||||
|
bl.get("truck_license"),
|
||||||
|
DateTimeUtil.sdfymd.get().format(bl.get("cutoff_time")),
|
||||||
|
bl.get("customer_name")
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.failed(StrKit.join(outerr, "。"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询已有的集团订单分配的车辆
|
||||||
|
List<OrderclusterTruck> otlist = OrderclusterTruck.dao.find(
|
||||||
|
"select * from ordercluster_truck \n" +
|
||||||
|
" where ordercluster_id = ? \n", oldobj.getId());
|
||||||
|
|
||||||
|
List<String> dellist = new ArrayList<>();
|
||||||
|
List<String> chktpsql = new ArrayList<>();
|
||||||
|
List<String> chkold = new ArrayList<>();
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
|
||||||
|
// 数据库中,提交上的数据中没有的,要删掉
|
||||||
|
for (OrderclusterTruck ot : otlist) {
|
||||||
|
if (!chk.contains(ot.getTruckLicense())) {
|
||||||
|
dellist.add(ot.getTruckLicense());
|
||||||
|
chktpsql.add("?");
|
||||||
|
synctask.addDeleteData(ot);
|
||||||
|
} else {
|
||||||
|
chkold.add(ot.getTruckLicense());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 要删除的车辆没有结算,不能删除
|
||||||
|
if (!dellist.isEmpty()) {
|
||||||
|
List<String> querydel = new ArrayList<>();
|
||||||
|
querydel.add(oldobj.getSupermarketId().toString());
|
||||||
|
querydel.add(DateTimeUtil.sdf.get().format(oldobj.getCutoffTime()) + "%");
|
||||||
|
querydel.addAll(dellist);
|
||||||
|
|
||||||
|
List<Transport> chktp = Transport.dao.find("select * from transport t \n" +
|
||||||
|
" where t.state < 5 \n" +
|
||||||
|
" and t.supermarket_id = ? \n" +
|
||||||
|
" and t.in_time like ? \n" +
|
||||||
|
" and t.truck_license in(" + StrKit.join(chktpsql, ",") + ")", querydel.toArray());
|
||||||
|
|
||||||
|
if (!chktp.isEmpty()) {
|
||||||
|
List<String> outerr = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Transport tp : chktp) {
|
||||||
|
outerr.add(String.format("[%s]已进入[%s]砂站,删除后不能结算", tp.getTruckLicense(), SvrCacheData.SUP_CACHE.get(tp.getSupermarketId()).getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.failed(StrKit.join(outerr, "\r\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<OrderclusterTruck> savelist = new ArrayList<>();
|
||||||
|
|
||||||
|
for (String truck_license : truckarr) {
|
||||||
|
// 已经在数据库中的,不再重复添加
|
||||||
|
if (chkold.contains(truck_license)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
OrderclusterTruck oct = new OrderclusterTruck();
|
||||||
|
oct.setId(StrKit.getRandomUUID());
|
||||||
|
oct.setOrderclusterId(oldobj.getId());
|
||||||
|
oct.setTruckLicense(truck_license);
|
||||||
|
|
||||||
|
synctask.addSaveData(oct);
|
||||||
|
savelist.add(oct);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() throws SQLException {
|
||||||
|
try {
|
||||||
|
if (!dellist.isEmpty()) {
|
||||||
|
int delret = Db.delete("delete from ordercluster_truck where ordercluster_id = " + oldobj.getId() +
|
||||||
|
" and truck_license in ('" + StrKit.join(dellist, "','") + "')");
|
||||||
|
|
||||||
|
log.debug("删除 ordercluster_truck %d", delret);
|
||||||
|
|
||||||
|
if (delret != dellist.size()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!savelist.isEmpty()) {
|
||||||
|
int[] ret = Db.batchSave(savelist, savelist.size());
|
||||||
|
|
||||||
|
for (int i : ret) {
|
||||||
|
// 必须是每条 sql 修改一条记录
|
||||||
|
if (i != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean ret = oldobj.update();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
synctask.addUpdateData(oldobj);
|
||||||
|
|
||||||
|
return SyncTaskService.me.save(synctask, oldobj.getSupermarketId())
|
||||||
|
&& ModifyLogService.me.save(model, null, Enums.DataOpType.UPDATE.getId(), sysuser);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
SyncTaskService.me.send(synctask);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret ? Result.success(oldobj) : Result.failed("修改失败");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return Result.failed("修改失败");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Result updateCluster(Ordercluster model, Sysuser sysuser) {
|
||||||
Ordercluster oldobj = model.findByPk();
|
Ordercluster oldobj = model.findByPk();
|
||||||
|
|
||||||
if (oldobj == null) {
|
if (oldobj == null) {
|
||||||
|
|
@ -546,7 +747,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
BigDecimal overweight = OrderclusterService.me.getOverWeightByCustomer(oldobj.getCustomerId()); // 按客户找集团订单已完成量
|
BigDecimal overweight = OrderclusterService.me.getOverWeightByCustomer(oldobj.getCustomerId()); // 按客户找集团订单已完成量
|
||||||
|
|
||||||
if (plan_total_weight.subtract(overweight).multiply(oldobj.getUnitPrice()).compareTo(prepayCustomer.getSurplus()) > 0) {
|
if (plan_total_weight.subtract(overweight).multiply(oldobj.getUnitPrice()).compareTo(prepayCustomer.getSurplus()) > 0) {
|
||||||
return Result.failedstr("剩余总配额 %.2f,客户余额(%.2f)不足", plan_total_weight.subtract(overweight), prepayCustomer.getSurplus());
|
return Result.failedstr("计划总配额 %.2f,超过了客户余额(%.2f)", plan_total_weight.subtract(overweight), prepayCustomer.getSurplus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -592,6 +793,10 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
SyncTaskService.me.send(synctask);
|
||||||
|
}
|
||||||
|
|
||||||
return ret ? Result.success(oldobj) : Result.failed("修改失败");
|
return ret ? Result.success(oldobj) : Result.failed("修改失败");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
|
|
@ -646,6 +851,41 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
if (oldobj.getState() >= OrderStateEnum.RECEIVED.getStateid()) {
|
if (oldobj.getState() >= OrderStateEnum.RECEIVED.getStateid()) {
|
||||||
return Result.failed("已经完结或者取消的,不能再修改");
|
return Result.failed("已经完结或者取消的,不能再修改");
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
List<OrderclusterTruck> otlist = OrderclusterTruck.dao.find(
|
||||||
|
"select * from ordercluster_truck \n" +
|
||||||
|
" where ordercluster_id = ? \n", oldobj.getId());
|
||||||
|
|
||||||
|
if (!otlist.isEmpty()) {
|
||||||
|
List<String> trlist = new ArrayList<>();
|
||||||
|
List<String> chktpsql = new ArrayList<>();
|
||||||
|
|
||||||
|
// 数据库中,提交上的数据中没有的,要删掉
|
||||||
|
for (OrderclusterTruck ot : otlist) {
|
||||||
|
trlist.add(ot.getTruckLicense());
|
||||||
|
chktpsql.add("?");
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> querydel = new ArrayList<>();
|
||||||
|
querydel.add(oldobj.getSupermarketId().toString());
|
||||||
|
querydel.add(DateTimeUtil.sdf.get().format(oldobj.getCutoffTime()) + "%");
|
||||||
|
querydel.addAll(trlist);
|
||||||
|
|
||||||
|
List<Transport> chktp = Transport.dao.find("select * from transport t \n" +
|
||||||
|
" where t.state < 5 \n" +
|
||||||
|
" and t.supermarket_id = ? \n" +
|
||||||
|
" and t.in_time like ? \n" +
|
||||||
|
" and t.truck_license in(" + StrKit.join(chktpsql, ",") + ")", querydel.toArray());
|
||||||
|
|
||||||
|
if (!chktp.isEmpty()) {
|
||||||
|
List<String> errarr = new ArrayList<>();
|
||||||
|
for (Transport t : chktp) {
|
||||||
|
errarr.add(t.getTruckLicense());
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.failedstr("配额中的车辆[%s]还未结算出场,或者砂站数据还未同步至结算中心,不能结束", StrKit.join(errarr, ","));
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
|
||||||
oldobj.setState(OrderStateEnum.RECEIVED.getStateid()); // 将订单状态置为 5
|
oldobj.setState(OrderStateEnum.RECEIVED.getStateid()); // 将订单状态置为 5
|
||||||
oldobj.setCompleteTime(new Date());
|
oldobj.setCompleteTime(new Date());
|
||||||
|
|
@ -673,4 +913,379 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
return Result.failed("修改失败");
|
return Result.failed("修改失败");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 固定购砂结转
|
||||||
|
* /order/ordercluster/forwardCluster
|
||||||
|
*
|
||||||
|
* @param ordercluster_id ordercluster 的 id
|
||||||
|
* @param total_weight 结转的重量,默认哦那个剩余重量填充
|
||||||
|
* @param cutoff_time 结转目的日期
|
||||||
|
* @param sysuser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Result forwardCluster(int ordercluster_id, BigDecimal total_weight, Date cutoff_time, Sysuser sysuser) {
|
||||||
|
Ordercluster oldobj = Ordercluster.dao.findById(ordercluster_id);
|
||||||
|
|
||||||
|
if (oldobj == null) {
|
||||||
|
return Result.failed(false, "按主键未找到对应记录");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldobj.getState() >= OrderStateEnum.RECEIVED.getStateid()) {
|
||||||
|
return Result.failed("已经完结或者取消的,不能再修改");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldobj.getCustomerId() == null) {
|
||||||
|
return Result.failed("固定供砂配额信息错误");
|
||||||
|
}
|
||||||
|
|
||||||
|
PrepayCustomer prepayCustomer = PrepayCustomerService.me.getPrepayCustomer(oldobj.getCustomerId());
|
||||||
|
if (prepayCustomer == null) {
|
||||||
|
return Result.failed("不是预付费用户");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按客户查询未完成的订单量
|
||||||
|
List<Record> undonlist = OrderclusterService.me.undonlist(oldobj.getCustomerId());
|
||||||
|
|
||||||
|
if (undonlist != null && !undonlist.isEmpty()) {
|
||||||
|
BigDecimal plan_total_weight = total_weight;
|
||||||
|
|
||||||
|
for (Record record : undonlist) {
|
||||||
|
if (oldobj.getId().equals(record.getInt("id"))) {
|
||||||
|
continue; // 当前修改的记录已经做为初始值了,不再累计
|
||||||
|
}
|
||||||
|
|
||||||
|
// 累加总量
|
||||||
|
plan_total_weight = plan_total_weight.add(record.getBigDecimal("total_weight"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按客户统计已完成量
|
||||||
|
BigDecimal overweight = OrderclusterService.me.getOverWeightByCustomer(oldobj.getCustomerId()); // 按客户找集团订单已完成量
|
||||||
|
|
||||||
|
if (plan_total_weight.subtract(overweight).multiply(oldobj.getUnitPrice()).compareTo(prepayCustomer.getSurplus()) > 0) {
|
||||||
|
return Result.failedstr("计划总配额 %.2f,超过了客户余额(%.2f)", plan_total_weight.subtract(overweight), prepayCustomer.getSurplus());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按客户统计已完成量
|
||||||
|
BigDecimal over_weight = OrderclusterService.me.getOverWeight(oldobj.getId()); // 按客户找集团订单已完成量
|
||||||
|
BigDecimal surplus_weight = oldobj.getTotalWeight().subtract(over_weight); // 剩余未完成量
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. total_weight >= surplus_weight 将旧的剩余量清 0
|
||||||
|
2. total_weight < surplus_weight 将旧的剩余量调整到 surplus_weight - total_weight
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (total_weight.compareTo(surplus_weight) >= 0) {
|
||||||
|
oldobj.setTotalWeight(over_weight); // 将总量设置成和已完成量一样,就是将余量设置为 0 了
|
||||||
|
} else {
|
||||||
|
oldobj.setTotalWeight(surplus_weight.subtract(total_weight)); // 结转不完的,要留下
|
||||||
|
}
|
||||||
|
|
||||||
|
List<OrderclusterTruck> octs = OrderclusterTruck.dao.find("select * from ordercluster_truck t where t.ordercluster_id = ?", ordercluster_id);
|
||||||
|
|
||||||
|
if (!octs.isEmpty()) {
|
||||||
|
// 已有车辆的,在结转前,需要将已经分配其他集团订单的车辆去掉
|
||||||
|
List<Object> ts = new ArrayList<>();
|
||||||
|
List<String> tsql = new ArrayList<>();
|
||||||
|
Map<String, Integer> delmap = new HashMap<>();
|
||||||
|
|
||||||
|
// 检查提交上来的车辆字符串是否用重复的
|
||||||
|
for (int i = 0; i < octs.size(); i++) {
|
||||||
|
OrderclusterTruck oct = octs.get(i);
|
||||||
|
ts.add(oct.getTruckLicense());
|
||||||
|
tsql.add("?");
|
||||||
|
|
||||||
|
delmap.put(oct.getTruckLicense(), i);
|
||||||
|
}
|
||||||
|
|
||||||
|
ts.add(0, cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, ordercluster_id); // 加到查询参数里面
|
||||||
|
List<Record> chkduk = Db.find(
|
||||||
|
"select * from ordercluster_truck t\n" +
|
||||||
|
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
||||||
|
" where t.ordercluster_id <> ? \n" +
|
||||||
|
" and o.state < 5 \n" +
|
||||||
|
" and o.cutoff_time = ? \n" +
|
||||||
|
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
|
if (chkduk != null && !chkduk.isEmpty()) {
|
||||||
|
for (Record record : chkduk) {
|
||||||
|
if (delmap.containsKey(record.getStr("truck_license"))) {
|
||||||
|
octs.remove(delmap.get(record.getStr("truck_license")).intValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
Date now = new Date();
|
||||||
|
|
||||||
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() throws SQLException {
|
||||||
|
try {
|
||||||
|
boolean ret = false;
|
||||||
|
|
||||||
|
if (oldobj.getState() < OrderStateEnum.RECEIVED.getStateid()) { // 没有完结的进行完结,已经完结的就不动了
|
||||||
|
oldobj.setState(OrderStateEnum.RECEIVED.getStateid()); // 将订单状态置为 5
|
||||||
|
oldobj.setCompleteTime(now);
|
||||||
|
|
||||||
|
ret = oldobj.update();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
synctask.addUpdateData(oldobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
Ordercluster forwardoldobj = Ordercluster.dao.findFirst(
|
||||||
|
"select * from ordercluster t \n" +
|
||||||
|
" where t.customer_id = ? \n" +
|
||||||
|
" and t.cutoff_time = ? \n" +
|
||||||
|
" and t.state < 5 limit 1", oldobj.getCustomerId(), cutoff_time);
|
||||||
|
|
||||||
|
if (forwardoldobj == null) {
|
||||||
|
// 新建一个
|
||||||
|
forwardoldobj = oldobj.clone();
|
||||||
|
forwardoldobj.setId(null); // 等待数据库自增长
|
||||||
|
forwardoldobj.setUuid(StrKit.getRandomUUID());
|
||||||
|
forwardoldobj.setTotalWeight(total_weight);
|
||||||
|
forwardoldobj.setCutoffTime(cutoff_time);
|
||||||
|
forwardoldobj.setCreateTime(now); // 当前系统时间
|
||||||
|
forwardoldobj.setCreateUserId(sysuser.getId()); // 当前用户id
|
||||||
|
forwardoldobj.setCreateUserName(sysuser.getName());
|
||||||
|
forwardoldobj.setState(OrderStateEnum.INITIAL.getStateid()); // 新增固定为 1
|
||||||
|
|
||||||
|
ret = forwardoldobj.save();
|
||||||
|
synctask.addSaveData(forwardoldobj);
|
||||||
|
} else {
|
||||||
|
// 已有的,直接更新重量
|
||||||
|
forwardoldobj.setTotalWeight(forwardoldobj.getTotalWeight().add(total_weight));
|
||||||
|
|
||||||
|
ret = forwardoldobj.update();
|
||||||
|
synctask.addUpdateData(forwardoldobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!octs.isEmpty()) {
|
||||||
|
List<OrderclusterTruck> savelist = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < octs.size(); i++) {
|
||||||
|
OrderclusterTruck oldoct = octs.get(i);
|
||||||
|
|
||||||
|
OrderclusterTruck oct = new OrderclusterTruck();
|
||||||
|
oct.setId(StrKit.getRandomUUID());
|
||||||
|
oct.setOrderclusterId(forwardoldobj.getId());
|
||||||
|
oct.setTruckLicense(oldoct.getTruckLicense());
|
||||||
|
|
||||||
|
synctask.addSaveData(oct);
|
||||||
|
savelist.add(oct);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!savelist.isEmpty()) {
|
||||||
|
int[] retarr = Db.batchSave(savelist, savelist.size());
|
||||||
|
|
||||||
|
for (int i : retarr) {
|
||||||
|
// 必须是每条 sql 修改一条记录
|
||||||
|
if (i != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SyncTaskService.me.save(synctask, forwardoldobj.getSupermarketId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
SyncTaskService.me.send(synctask);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret ? Result.success() : Result.failed("操作失败");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 零散购砂结转
|
||||||
|
* /order/ordercluster/forwardTemp
|
||||||
|
*
|
||||||
|
* @param ordercluster_id ordercluster 的 id
|
||||||
|
* @param total_weight 结转的重量,默认哦那个剩余重量填充
|
||||||
|
* @param cutoff_time 结转目的日期
|
||||||
|
* @param trucks 默认用当前配额的车辆填充
|
||||||
|
* @param sysuser
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Result forwardTemp(int ordercluster_id, BigDecimal total_weight, Date cutoff_time, String trucks, Sysuser sysuser) {
|
||||||
|
Ordercluster oldobj = Ordercluster.dao.findById(ordercluster_id);
|
||||||
|
|
||||||
|
if (oldobj == null) {
|
||||||
|
return Result.failed(false, "按主键未找到对应记录");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldobj.getState() >= OrderStateEnum.RECEIVED.getStateid()) {
|
||||||
|
return Result.failed("已经完结或者取消的,不能再修改");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 按客户统计已完成量
|
||||||
|
BigDecimal over_weight = OrderclusterService.me.getOverWeight(oldobj.getId()); // 按客户找集团订单已完成量
|
||||||
|
BigDecimal surplus_weight = oldobj.getTotalWeight().subtract(over_weight); // 剩余未完成量
|
||||||
|
|
||||||
|
/*
|
||||||
|
1. total_weight >= surplus_weight 将旧的剩余量清 0
|
||||||
|
2. total_weight < surplus_weight 将旧的剩余量调整到 surplus_weight - total_weight
|
||||||
|
*/
|
||||||
|
|
||||||
|
if (total_weight.compareTo(surplus_weight) >= 0) {
|
||||||
|
oldobj.setTotalWeight(over_weight); // 将总量设置成和已完成量一样,就是将余量设置为 0 了
|
||||||
|
} else {
|
||||||
|
oldobj.setTotalWeight(surplus_weight.subtract(total_weight)); // 结转不完的,要留下
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] truckarr = trucks.split(",");
|
||||||
|
|
||||||
|
// 已有车辆的,在结转前,需要将已经分配其他集团订单的车辆去掉
|
||||||
|
List<Object> ts = new ArrayList<>();
|
||||||
|
List<String> tsql = new ArrayList<>();
|
||||||
|
Map<String, Integer> delmap = new HashMap<>();
|
||||||
|
|
||||||
|
// 检查提交上来的车辆字符串是否用重复的
|
||||||
|
for (int i = 0; i < truckarr.length; i++) {
|
||||||
|
String truck_license = truckarr[i];
|
||||||
|
ts.add(truck_license);
|
||||||
|
tsql.add("?");
|
||||||
|
|
||||||
|
delmap.put(truck_license, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
ts.add(0, cutoff_time); // 加到查询参数里面
|
||||||
|
ts.add(0, ordercluster_id); // 加到查询参数里面
|
||||||
|
List<Record> chkduk = Db.find(
|
||||||
|
"select * from ordercluster_truck t\n" +
|
||||||
|
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
||||||
|
" where t.ordercluster_id <> ? \n" +
|
||||||
|
" and o.state < 5 \n" +
|
||||||
|
" and o.cutoff_time = ? \n" +
|
||||||
|
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
|
||||||
|
|
||||||
|
if (chkduk != null && !chkduk.isEmpty()) {
|
||||||
|
for (Record record : chkduk) {
|
||||||
|
if (delmap.containsKey(record.getStr("truck_license"))) {
|
||||||
|
delmap.remove(record.getStr("truck_license"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] newarr = new String[delmap.keySet().size()];
|
||||||
|
delmap.keySet().toArray(newarr);
|
||||||
|
truckarr = newarr;
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
Date now = new Date();
|
||||||
|
String[] finalTruckarr = truckarr;
|
||||||
|
|
||||||
|
boolean ret = Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() throws SQLException {
|
||||||
|
try {
|
||||||
|
boolean ret = false;
|
||||||
|
|
||||||
|
if (oldobj.getState() < OrderStateEnum.RECEIVED.getStateid()) { // 没有完结的进行完结,已经完结的就不动了
|
||||||
|
oldobj.setState(OrderStateEnum.RECEIVED.getStateid()); // 将订单状态置为 5
|
||||||
|
oldobj.setCompleteTime(now);
|
||||||
|
|
||||||
|
ret = oldobj.update();
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
synctask.addUpdateData(oldobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Ordercluster forwardoldobj = Ordercluster.dao.findFirst(
|
||||||
|
"select * from ordercluster t \n" +
|
||||||
|
" where t.customer_name = ? \n" +
|
||||||
|
" and t.cutoff_time = ? \n" +
|
||||||
|
" and t.state < 5 limit 1", oldobj.getCustomerName(), cutoff_time);
|
||||||
|
|
||||||
|
if (forwardoldobj == null) {
|
||||||
|
// 新建一个
|
||||||
|
forwardoldobj = oldobj.clone();
|
||||||
|
forwardoldobj.setId(null); // 等待数据库自增长
|
||||||
|
forwardoldobj.setUuid(StrKit.getRandomUUID());
|
||||||
|
forwardoldobj.setTotalWeight(total_weight);
|
||||||
|
forwardoldobj.setCutoffTime(cutoff_time);
|
||||||
|
forwardoldobj.setCreateTime(now); // 当前系统时间
|
||||||
|
forwardoldobj.setCreateUserId(sysuser.getId()); // 当前用户id
|
||||||
|
forwardoldobj.setCreateUserName(sysuser.getName());
|
||||||
|
forwardoldobj.setState(OrderStateEnum.INITIAL.getStateid()); // 新增固定为 1
|
||||||
|
|
||||||
|
ret = forwardoldobj.save();
|
||||||
|
synctask.addSaveData(forwardoldobj);
|
||||||
|
} else {
|
||||||
|
// 已有的,直接更新重量
|
||||||
|
forwardoldobj.setTotalWeight(forwardoldobj.getTotalWeight().add(total_weight));
|
||||||
|
|
||||||
|
ret = forwardoldobj.update();
|
||||||
|
synctask.addUpdateData(forwardoldobj);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ret) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (finalTruckarr.length > 0) {
|
||||||
|
List<OrderclusterTruck> savelist = new ArrayList<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < finalTruckarr.length; i++) {
|
||||||
|
String truck_license = finalTruckarr[i];
|
||||||
|
|
||||||
|
OrderclusterTruck oct = new OrderclusterTruck();
|
||||||
|
oct.setId(StrKit.getRandomUUID());
|
||||||
|
oct.setOrderclusterId(forwardoldobj.getId());
|
||||||
|
oct.setTruckLicense(truck_license);
|
||||||
|
|
||||||
|
synctask.addSaveData(oct);
|
||||||
|
savelist.add(oct);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!savelist.isEmpty()) {
|
||||||
|
int[] retarr = Db.batchSave(savelist, savelist.size());
|
||||||
|
|
||||||
|
for (int i : retarr) {
|
||||||
|
// 必须是每条 sql 修改一条记录
|
||||||
|
if (i != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return SyncTaskService.me.save(synctask, forwardoldobj.getSupermarketId());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ret) {
|
||||||
|
SyncTaskService.me.send(synctask);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret ? Result.success() : Result.failed("操作失败");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -71,7 +71,12 @@ public class OrderclusterTruckController extends Controller {
|
||||||
*/
|
*/
|
||||||
public void find() {
|
public void find() {
|
||||||
PageParam pp = getBean(PageParam.class, "", true);
|
PageParam pp = getBean(PageParam.class, "", true);
|
||||||
renderJson(Result.object(OrderclusterTruckService.me.find(pp)));
|
String stm = get("stm");
|
||||||
|
String etm = get("etm");
|
||||||
|
String customer_name = get("customer_name");
|
||||||
|
String truck_license = get("truck_license");
|
||||||
|
Integer state = getInt("state");
|
||||||
|
renderJson(Result.object(OrderclusterTruckService.me.find(pp, stm, etm, customer_name, truck_license, state)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import com.cowr.common.utils.DateTimeUtil;
|
||||||
import com.cowr.common.view.Result;
|
import com.cowr.common.view.Result;
|
||||||
import com.cowr.model.*;
|
import com.cowr.model.*;
|
||||||
import com.cowr.service.ssjygl.base.BaseSyncService;
|
import com.cowr.service.ssjygl.base.BaseSyncService;
|
||||||
|
import com.cowr.service.ssjygl.main.SvrCacheData;
|
||||||
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
||||||
import com.cowr.ssjygl.modifylog.ModifyLogService;
|
import com.cowr.ssjygl.modifylog.ModifyLogService;
|
||||||
import com.jfinal.kit.StrKit;
|
import com.jfinal.kit.StrKit;
|
||||||
|
|
@ -91,15 +92,20 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
retts.add(bl.get("truck_license"));
|
retts.add(bl.get("truck_license"));
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result.failedstr("%s 已在[%s]分配", StrKit.join(retts, ","), DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
|
return Result.failedstr(
|
||||||
|
"%s 已在[%s]分配",
|
||||||
|
StrKit.join(retts, ","),
|
||||||
|
DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime())
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 查询已有的集团订单
|
// 查询已有的集团订单分配的车辆
|
||||||
List<OrderclusterTruck> otlist = OrderclusterTruck.dao.find(
|
List<OrderclusterTruck> otlist = OrderclusterTruck.dao.find(
|
||||||
"select * from ordercluster_truck \n" +
|
"select * from ordercluster_truck \n" +
|
||||||
" where ordercluster_id = ? \n", ordercluster_id);
|
" where ordercluster_id = ? \n", ordercluster_id);
|
||||||
|
|
||||||
List<String> dellist = new ArrayList<>();
|
List<String> dellist = new ArrayList<>();
|
||||||
|
List<String> chktpsql = new ArrayList<>();
|
||||||
List<String> chkold = new ArrayList<>();
|
List<String> chkold = new ArrayList<>();
|
||||||
SyncTask synctask = new SyncTask();
|
SyncTask synctask = new SyncTask();
|
||||||
|
|
||||||
|
|
@ -107,12 +113,36 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
for (OrderclusterTruck ot : otlist) {
|
for (OrderclusterTruck ot : otlist) {
|
||||||
if (!chk.contains(ot.getTruckLicense())) {
|
if (!chk.contains(ot.getTruckLicense())) {
|
||||||
dellist.add(ot.getTruckLicense());
|
dellist.add(ot.getTruckLicense());
|
||||||
|
chktpsql.add("?");
|
||||||
synctask.addDeleteData(ot);
|
synctask.addDeleteData(ot);
|
||||||
} else {
|
} else {
|
||||||
chkold.add(ot.getTruckLicense());
|
chkold.add(ot.getTruckLicense());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 要删除的车辆没有结算,不能删除
|
||||||
|
if(!dellist.isEmpty()){
|
||||||
|
List<String> querydel = new ArrayList<>();
|
||||||
|
querydel.add(ordercluster.getSupermarketId().toString());
|
||||||
|
querydel.add(DateTimeUtil.sdf.get().format(ordercluster.getCutoffTime()) + "%");
|
||||||
|
querydel.addAll(dellist);
|
||||||
|
List<Transport> chktp = Transport.dao.find("select * from transport t \n" +
|
||||||
|
" where t.state < 5 \n" +
|
||||||
|
" and t.supermarket_id = ? \n" +
|
||||||
|
" and t.in_time like ? \n" +
|
||||||
|
" and t.truck_license in(" + StrKit.join(chktpsql, ",") + ")", querydel.toArray());
|
||||||
|
|
||||||
|
if(!chktp.isEmpty()){
|
||||||
|
List<String> outerr = new ArrayList<>();
|
||||||
|
|
||||||
|
for(Transport tp : chktp){
|
||||||
|
outerr.add(String.format("[%s]已进入[%s]砂站,删除后不能结算", tp.getTruckLicense(), SvrCacheData.SUP_CACHE.get(tp.getSupermarketId()).getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.failed(StrKit.join(outerr, "\r\n"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<OrderclusterTruck> savelist = new ArrayList<>();
|
List<OrderclusterTruck> savelist = new ArrayList<>();
|
||||||
|
|
||||||
for (String truck_license : truckarr) {
|
for (String truck_license : truckarr) {
|
||||||
|
|
@ -151,6 +181,10 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
|
||||||
" and truck_license in ('" + StrKit.join(dellist, "','") + "')");
|
" and truck_license in ('" + StrKit.join(dellist, "','") + "')");
|
||||||
|
|
||||||
log.debug("删除 ordercluster_truck %d", delret);
|
log.debug("删除 ordercluster_truck %d", delret);
|
||||||
|
|
||||||
|
if(delret != dellist.size()){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!savelist.isEmpty()) {
|
if (!savelist.isEmpty()) {
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.cowr.common.enums.UserTypeEnum;
|
||||||
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.model.Sysuser;
|
import com.cowr.model.Sysuser;
|
||||||
|
|
@ -340,4 +341,20 @@ public class OrderStatController extends BaseController {
|
||||||
render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
render(new ExcelRender(stm + "_" + etm + "_砂站" + (isprepaid != null && isprepaid == 1 ? "预付费" : "") + "销售汇总表_" + System.currentTimeMillis() + ".xlsx", wb));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void statYearCustomer() {
|
||||||
|
String tm = get("tm");
|
||||||
|
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||||
|
if (export == 0) {
|
||||||
|
renderJson(Result.object(OrderStatService.me.yearStatByCustomer(tm)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void statYearBySup() {
|
||||||
|
String tm = get("tm");
|
||||||
|
int export = getInt("export", 0); // 是否导出为exce 0 不导出,1 导出
|
||||||
|
if (export == 0) {
|
||||||
|
renderJson(Result.object(OrderStatService.me.yearStatBySup(tm)));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ public class SyncTaskService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 按砂站ID去找未完成的,避免一个砂站有过多的未完成堆积,导致其他的不能下发
|
* 按砂站ID去找未完成的,避免一个砂站有过多的未完成堆积,导致其他的不能下发
|
||||||
|
*
|
||||||
* @param supermarket_id
|
* @param supermarket_id
|
||||||
*/
|
*/
|
||||||
public void task(int supermarket_id) {
|
public void task(int supermarket_id) {
|
||||||
|
|
@ -246,6 +247,13 @@ public class SyncTaskService {
|
||||||
if (ret.length != list.size()) {
|
if (ret.length != list.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i : ret) {
|
||||||
|
// 必须是每条 sql 修改一条记录
|
||||||
|
if (i != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -267,6 +275,13 @@ public class SyncTaskService {
|
||||||
if (ret.length != list.size()) {
|
if (ret.length != list.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i : ret) {
|
||||||
|
// 必须是每条 sql 修改一条记录
|
||||||
|
if (i != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -368,6 +383,13 @@ public class SyncTaskService {
|
||||||
if (ret.length != sts.size()) {
|
if (ret.length != sts.size()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (int i : ret) {
|
||||||
|
// 必须是每条 sql 修改一条记录
|
||||||
|
if (i != 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue