lisai17@sina.com 2020-09-12 21:05:55 +08:00
parent 5ab37782e8
commit 05277bb98c
9 changed files with 116 additions and 90 deletions

View File

@ -594,7 +594,7 @@ public abstract class BaseOrdercluster<M extends BaseOrdercluster<M>> extends Ba
/**
* name: customer_receiver_name
* type: VARCHAR(8)
* type: VARCHAR(128)
* isNullable: YES
* isPrimaryKey: NO
* defaultValue:

View File

@ -148,6 +148,7 @@ public class PrepayService {
out.set("prepay_surplus", prepayCustomer.getSurplus());
out.set("prepay_customer", customer);
out.set("prepay_customer_info", prepayCustomer);
out.set("prepay_customer_invoice_type", customer.getInvoiceType()); // 客户发票类型
return out;
}
@ -161,7 +162,58 @@ public class PrepayService {
* @param etm
* @return
*/
public List<Record> consumption(Integer customer_id, Integer supermarket_id, String stm, String etm) {
public List<Record> consumption(Integer customer_id, Integer supermarket_id, String stm, String etm, String truck_license) {
String sale_sql = " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, t.customer_id, t.customer_name \n" +
" from order_sale t \n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" +
" and t.isprepaid = 1 \n" +
" and t.prepay_customer_id is not null \n" +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n";
String temp_sql = " select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, t.customer_id, t.customer_name \n" +
" from order_temp t \n" +
" where t.state = ? \n" +
" and t.isprepaid = 1 \n" +
" and t.prepay_customer_id is not null \n" +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n";
List<Object> saleList = new ArrayList<>();
List<Object> tempList = new ArrayList<>();
saleList.add(OrderStateEnum.RECEIVED.getStateid());
saleList.add(stm);
saleList.add(etm);
tempList.add(OrderStateEnum.RECEIVED.getStateid());
tempList.add(stm);
tempList.add(etm);
if (supermarket_id != null && supermarket_id > 0) {
sale_sql += " and t.supermarket_id = ?";
saleList.add(supermarket_id);
temp_sql += " and t.supermarket_id = ?";
tempList.add(supermarket_id);
}
if (customer_id != null && customer_id > 0) {
sale_sql += " and t.customer_id = ?";
saleList.add(customer_id);
temp_sql += " and t.customer_id = ?";
tempList.add(customer_id);
}
if (StrKit.notBlank(truck_license)) {
sale_sql += " and t.truck_license like ?";
saleList.add("%" + truck_license + "%");
temp_sql += " and t.truck_license like ?";
tempList.add("%" + truck_license + "%");
}
String sql = "select a.sn \n" +
" ,p.order_sn \n" +
" ,p.arrive_time \n" +
@ -174,55 +226,21 @@ public class PrepayService {
" ,a.paid \n" +
" ,a.customer_id \n" +
" ,a.customer_name \n" +
" ,a.product_id \n" +
" ,a.product_name" +
" from ( \n" +
" select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, c.id customer_id, c.name customer_name, t.product_id, t.product_name \n" +
" from order_sale t \n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" +
" and t.isprepaid = 1 \n" +
" and t.prepay_customer_id is not null \n" +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n" +
" union \n" +
" select t.sn, t.supermarket_id, t.truck_license, t.weight, t.total_price, t.paid, c.id customer_id, c.name customer_name, t.product_id, t.product_name \n" +
" from order_temp t \n" +
" left join customer c on c.id = t.customer_id \n" +
" where t.state = ? \n" +
" and t.isprepaid = 1 \n" +
" and t.prepay_customer_id is not null \n" +
" and t.create_time >= ? \n" +
" and t.create_time <= ? \n" +
" from ( \n" + sale_sql +
" union \n" + temp_sql +
" ) a \n" +
" left join supermarket s on s.id = a.supermarket_id \n" +
" left join transport p on p.order_sn = a.sn " +
" where 1 = 1 \n";
List<Object> paraList = new ArrayList<>();
paraList.add(OrderStateEnum.RECEIVED.getStateid());
paraList.add(stm);
paraList.add(etm);
paraList.add(OrderStateEnum.RECEIVED.getStateid());
paraList.add(stm);
paraList.add(etm);
if (supermarket_id != null && supermarket_id > 0) {
sql += " and a.supermarket_id = ?";
paraList.add(supermarket_id);
}
if (customer_id != null && customer_id > 0) {
sql += " and a.customer_id = ?";
paraList.add(customer_id);
}
paraList.addAll(saleList);
paraList.addAll(tempList);
return Db.find(sql, paraList.toArray());
}
public Workbook consumptionExport(Integer customer_id, Integer supermarket_id, String stm, String etm) {
public Workbook consumptionExport(Integer customer_id, Integer supermarket_id, String stm, String etm, String truck_license) {
Customer customer = Customer.dao.findById(customer_id);
String cname = "";
@ -230,7 +248,7 @@ public class PrepayService {
cname = customer.getName();
}
List<Record> list = consumption(customer_id, supermarket_id, stm, etm);
List<Record> list = consumption(customer_id, supermarket_id, stm, etm, truck_license);
list.sort(new Comparator<Record>() {
public int compare(Record o1, Record o2) {

View File

@ -29,11 +29,12 @@ public class PrepayController extends BaseController {
Integer supermarket_id = getInt("supermarket_id");
String stm = get("stm");
String etm = get("etm");
String truck_license = get("truck_license");
if (export == 0) {
renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm)));
renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm, truck_license)));
} else {
Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm);
Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm, truck_license);
render(new ExcelRender("消费记录_" + System.currentTimeMillis() + ".xlsx", wb));
}
}

View File

@ -72,7 +72,7 @@ public class TransportDeviceService {
*/
public void addLicenseHistory(Record truck, String which, int state) {
try {
if (truck == null) {
if (truck == null || StrKit.isBlank(truck.get("license"))) {
return;
}

View File

@ -109,6 +109,7 @@ public class TransportQueryService {
Supermarket supermarket = Supermarket.dao.findById(transport.getSupermarketId());
if (supermarket != null) {
transobj.set("supermarket_name", supermarket.getName());
transobj.set("supermarket_invoice_type", supermarket.getInvoiceType());
}
if(transport.getType() != null && transport.getType() == OrderTypeEnum.PURCHASE.getTypeid()){

View File

@ -2,8 +2,8 @@
devMode=true
#本地服务 和 云端服务 socket 通信
socketserver.enable=true
socketserver.host=47.112.109.118
#socketserver.host=localhost
#socketserver.host=47.112.109.118
socketserver.host=localhost
socketserver.port=21002
#和 web 端的 socket.io 通信端口

View File

@ -1,16 +1,17 @@
# mysql
# GRANT ALL PRIVILEGES ON *.* TO 'root'@'192.168.1.119' IDENTIFIED BY 'Local_1' WITH GRANT OPTION;
#jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
#user=ssjy_xsx
#password=Ssjy_xs_890
jdbcUrl=jdbc:mysql://rm-wz9wa070076b2uge2ro.mysql.rds.aliyuncs.com:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=ssjy_xsx
password=Ssjy_xs_890
jdbcUrl=jdbc:mysql://localhost:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
user=root
password=Ssjy_xsx_890
#jdbcUrl=jdbc:mysql://localhost:3306/ssjy_xsx_dev?characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=convertToNull&useInformationSchema=true&serverTimezone=GMT%2B8&autoReconnect=true
#user=root
#password=Ssjy_xsx_890
# redis
redis.basekey=ssjcgl_xsx_dev
redis.ip=127.0.0.1
#redis.ip=127.0.0.1
redis.ip=r-wz9168ab2f2f7ec4pd.redis.rds.aliyuncs.com
redis.port=6379
redis.pwd=
redis.db=
redis.pwd=CoWR1111
redis.db=13

View File

@ -2,6 +2,7 @@ package com.cowr.service.ssjygl.order.ordercluster.truck;
import com.cowr.common.enums.Enums;
import com.cowr.common.enums.UserTypeEnum;
import com.cowr.common.utils.DateTimeUtil;
import com.cowr.common.view.Result;
import com.cowr.model.*;
import com.cowr.service.ssjygl.base.BaseSyncService;
@ -41,7 +42,7 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
List<String> chk = new ArrayList<>();
String[] truckarr = trucks.split(",");
List<String> ts = new ArrayList<>();
List<Object> ts = new ArrayList<>();
List<String> tsql = new ArrayList<>();
// 检查提交上来的车辆字符串是否用重复的
@ -63,30 +64,33 @@ public class OrderclusterTruckSyncService extends BaseSyncService {
" and truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
if (list != null && !list.isEmpty()) {
ts = new ArrayList<>();
List<String> retts = new ArrayList<>();
for (Blacklist bl : list) {
ts.add(bl.getTruckLicense());
retts.add(bl.getTruckLicense());
}
return Result.failed(StrKit.join(ts, ",") + " 车牌号在黑名单中");
return Result.failed(StrKit.join(retts, ",") + " 车牌号在黑名单中");
}
// 查询是否分配给其他集团订单
ts.add(0, ordercluster_id + ""); // 加到查询参数里面
// 查询是否在同一天分配给其他集团订单
ts.add(0, ordercluster.getCutoffTime()); // 加到查询参数里面
ts.add(0, ordercluster_id); // 加到查询参数里面
List<Record> chkduk = Db.find(
"select * from ordercluster_truck \n" +
" where ordercluster_id <> ? \n" +
" and truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
"select * from ordercluster_truck t\n" +
" left join ordercluster o on o.id = t.ordercluster_id\n" +
" where t.ordercluster_id <> ? \n" +
" and o.cutoff_time = ? \n" +
" and t.truck_license in (" + StrKit.join(tsql, ",") + ")", ts.toArray());
if (chkduk != null && !chkduk.isEmpty()) {
ts = new ArrayList<>();
List<String> retts = new ArrayList<>();
for (Record bl : chkduk) {
ts.add(bl.get("truck_license"));
retts.add(bl.get("truck_license"));
}
return Result.failed(StrKit.join(ts, ",") + " 车牌号已经分配给其他客户");
return Result.failedstr( "%s 已在[%s]分配给其他客户", StrKit.join(retts, ","), DateTimeUtil.sdfymd.get().format(ordercluster.getCutoffTime()));
}
// 查询已有的集团订单

View File

@ -54,11 +54,12 @@ public class PrepayController extends BaseController {
Integer supermarket_id = getInt("supermarket_id");
String stm = get("stm");
String etm = get("etm");
String truck_license = get("truck_license");
if (export == 0) {
renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm)));
renderJson(Result.success(PrepayService.me.consumption(customer_id, supermarket_id, stm, etm, truck_license)));
} else {
Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm);
Workbook wb = PrepayService.me.consumptionExport(customer_id, supermarket_id, stm, etm, truck_license);
render(new ExcelRender("消费记录_" + System.currentTimeMillis() + ".xlsx", wb));
}
}