dev
parent
5071993be2
commit
5c67cb6618
|
|
@ -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);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ public class OrderclusterTruckService extends BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 用超市id、车牌号查询当天关联的集团订单信息
|
* 用砂站id、车牌号查询当天关联的集团订单信息
|
||||||
*
|
*
|
||||||
* @param supermarket_id
|
* @param supermarket_id
|
||||||
* @param truck_license
|
* @param truck_license
|
||||||
|
|
|
||||||
|
|
@ -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,293 @@
|
||||||
|
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();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 票据使用情况统计
|
||||||
|
*/
|
||||||
|
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.invoice_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 {
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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;
|
||||||
|
|
@ -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);
|
||||||
|
|
@ -354,9 +356,9 @@ public class Config extends JFinalConfig {
|
||||||
System.exit(0);
|
System.exit(0);
|
||||||
} else {
|
} else {
|
||||||
log.info("====================================================");
|
log.info("====================================================");
|
||||||
log.info("============= 启动 %s %s 服务 ================", CliCacheData.SUP.getId(), CliCacheData.SUP.getName());
|
log.info("============= 启动 %s %s 服务 ================", CliCacheData.SUP.getId(), CliCacheData.SUP.getName());
|
||||||
log.info("====================================================");
|
log.info("====================================================");
|
||||||
log.info("============= 最大限重 %s 吨 =================", configprop.getInt("weigh.max"));
|
log.info("============= 最大限重 %s 吨 =================", configprop.getInt("weigh.max"));
|
||||||
log.info("====================================================");
|
log.info("====================================================");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -22,8 +22,8 @@ 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();
|
||||||
|
|
|
||||||
|
|
@ -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 字段
|
||||||
|
|
|
||||||
|
|
@ -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);
|
||||||
|
|
|
||||||
|
|
@ -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" +
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue