代码提交
parent
e550301940
commit
306abf3ab5
|
|
@ -109,7 +109,7 @@
|
|||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>druid</artifactId>
|
||||
<version>1.1.22</version>
|
||||
<version>1.1.20</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
|
||||
|
|
|
|||
|
|
@ -139,4 +139,11 @@ public class DataUtil {
|
|||
|
||||
return obj == null ? 0.0 : obj;
|
||||
}
|
||||
|
||||
public static String formatWithVarargs(String format, Object... objs) {
|
||||
if (null == objs || objs.length == 0){
|
||||
return format;
|
||||
}
|
||||
return String.format(format, objs);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -199,5 +199,48 @@ public abstract class BaseOrderEnd<M extends BaseOrderEnd<M>> extends BaseModel<
|
|||
return getInt("count");
|
||||
}
|
||||
|
||||
/**
|
||||
* name: product_id
|
||||
* type: INT(10)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue:
|
||||
* @param productId 订单总数
|
||||
*/
|
||||
@JSONField(name="product_id")
|
||||
public void setProductId(Integer productId) {
|
||||
set("product_id", productId);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return count 订单总数
|
||||
*/
|
||||
@JSONField(name="product_id")
|
||||
public Integer getProductId() {
|
||||
return getInt("product_id");
|
||||
}
|
||||
/**
|
||||
* name: invoice_type
|
||||
* type: INT(10)
|
||||
* isNullable: NO
|
||||
* isPrimaryKey: NO
|
||||
* defaultValue:
|
||||
* @param invoiceType 发票类型
|
||||
*/
|
||||
@JSONField(name="invoice_type")
|
||||
public void setInvoiceType(Integer invoiceType) {
|
||||
set("invoice_type", invoiceType);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return invoice_type 发票类型
|
||||
*/
|
||||
@JSONField(name="invoice_type")
|
||||
public Integer getInvoiceType() {
|
||||
return getInt("invoice_type");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -67,7 +67,7 @@ public class AliyunSmsService {
|
|||
|
||||
CommonResponse response = client.getCommonResponse(request);
|
||||
|
||||
// {"TotalCount":1,"Message":"OK","RequestId":"710D29B5-3F13-463D-9935-62D2EB763A79","Code":"OK","SmsSendDetailDTOs":{"SmsSendDetailDTO":[{"TemplateCode":"SMS_66850327","ReceiveDate":"2020-09-13 00:28:16","PhoneNum":"13627293906","Content":"【智慧砂石】2020-09-13平台异常,异常信息:Windows 10Windows 10Windows 10Windows 10Windows 10Windows 10Windows 10Windows 10Windows 10","SendStatus":3,"SendDate":"2020-09-13 00:28:10","ErrCode":"DELIVERED"}]}}
|
||||
// {"TotalCount":1,"Message":"OK","RequestId":"710D29B5-3F13-463D-9935-62D2EB763A79","Code":"OK","SmsSendDetailDTOs":{"SmsSendDetailDTO":[{"TemplateCode":"SMS_66850327","ReceiveDate":"2020-09-13 00:28:16","PhoneNum":"18891233883","Content":"【智慧砂石】2020-09-13平台异常,异常信息:Windows 10Windows 10Windows 10Windows 10Windows 10Windows 10Windows 10Windows 10Windows 10","SendStatus":3,"SendDate":"2020-09-13 00:28:10","ErrCode":"DELIVERED"}]}}
|
||||
|
||||
return response.getData();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -640,7 +640,9 @@ public class OrderclusterService extends BaseService {
|
|||
|
||||
// 零散购砂总价四舍五入
|
||||
if (ordercluster.getCustomerId() == null) {
|
||||
total_price = total_price.setScale(0, BigDecimal.ROUND_HALF_UP);
|
||||
// total_price = total_price.setScale(0, BigDecimal.ROUND_HALF_UP);
|
||||
// 2024年9月2日 散户(处置砂,黄砂)结算付款不再四舍五入,保留小数点后两位数
|
||||
total_price = total_price.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
return total_price;
|
||||
|
|
@ -725,11 +727,11 @@ public class OrderclusterService extends BaseService {
|
|||
*/
|
||||
public BigDecimal undoPrice(int customer_id, int sale_type) {
|
||||
String sql = "select(\n" +
|
||||
" select sum(t.`total_weight` * t.`unit_price`) `total_price`\n" +
|
||||
" select IFNULL(sum(t.`total_weight` * t.`unit_price`),0) `total_price`\n" +
|
||||
" from `ordercluster` t\n" +
|
||||
" where t.`customer_id`= ?\n" +
|
||||
" and t.state < ? and t.sale_type = ?) - (\n" +
|
||||
" select sum(t.`weight` * t.`unit_price`) total_price\n" +
|
||||
" select IFNULL(sum(t.`weight` * t.`unit_price`),0) total_price\n" +
|
||||
" from order_temp t\n" +
|
||||
" where exists(\n" +
|
||||
" select 1 from `ordercluster` o\n" +
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@ import org.apache.commons.collections4.CollectionUtils;
|
|||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
|
@ -65,6 +64,11 @@ public class OrderEndService extends BaseService {
|
|||
|
||||
public List<OrderEnd> getOrderEndByTm(String tm,String customerId) {
|
||||
|
||||
Long count = Db.queryLong("select count(id) from order_end");
|
||||
if (count == 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Object> paraList = new ArrayList<>();
|
||||
String sql = "SELECT * FROM ORDER_END \n" +
|
||||
"WHERE 1 = 1 \n";
|
||||
|
|
@ -81,21 +85,25 @@ public class OrderEndService extends BaseService {
|
|||
|
||||
return OrderEnd.dao.find(sql,paraList.toArray());
|
||||
}
|
||||
public List<OrderEnd> getOrderEndByTm(List<Date> dates) {
|
||||
public List<OrderEnd> getOrderEndByIds(List<String> ids) {
|
||||
|
||||
Long count = Db.queryLong("select count(id) from order_end");
|
||||
if (count == 0) {
|
||||
return null;
|
||||
}
|
||||
List<Object> paraList = new ArrayList<>();
|
||||
String sql = "SELECT * FROM ORDER_END \n" +
|
||||
"WHERE 1 = 1 \n";
|
||||
|
||||
if (CollectionUtils.isNotEmpty(dates)){
|
||||
sql += (" and DATE in (");
|
||||
if (CollectionUtils.isNotEmpty(ids)){
|
||||
sql += (" and ID in (");
|
||||
|
||||
for (int i = 0; i < dates.size(); i++) {
|
||||
for (int i = 0; i < ids.size(); i++) {
|
||||
if (i > 0) {
|
||||
sql += (",");
|
||||
}
|
||||
sql += ("?");
|
||||
paraList.add(DateTimeUtil.sdf.get().format(dates.get(i)));
|
||||
paraList.add(ids.get(i));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -188,7 +196,12 @@ public class OrderEndService extends BaseService {
|
|||
List<OrderEnd> orderEnds = tempList.stream()
|
||||
.map(data -> {
|
||||
OrderEnd o = JSON.toJavaObject(JSON.parseObject(data.toJson()), OrderEnd.class);
|
||||
o.setId(o.getCustomerId() + "_" + DateTimeUtil.sdf.get().format(o.getDate("date")) + "_" + o.getSupermarketId() + "_" + o.getSaleType());
|
||||
o.setId(o.getCustomerId() +
|
||||
"_" + DateTimeUtil.sdf.get().format(o.getDate("date")) +
|
||||
"_" + o.getSupermarketId() +
|
||||
"_" + o.getSaleType() +
|
||||
"_" + o.getInvoiceType() +
|
||||
"_" + o.getProductId());
|
||||
return o;
|
||||
})
|
||||
.collect(toList());
|
||||
|
|
@ -204,9 +217,9 @@ public class OrderEndService extends BaseService {
|
|||
}
|
||||
|
||||
if (CollectionUtils.isEmpty(lists) && CollectionUtils.isNotEmpty(orderEnds)){
|
||||
List<Date> dates = orderEnds.stream().map(OrderEnd::getDate)
|
||||
List<String> ids = orderEnds.stream().map(OrderEnd::getId)
|
||||
.collect(toList());
|
||||
lists = getOrderEndByTm(dates);
|
||||
lists = getOrderEndByIds(ids);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -483,7 +483,7 @@ public class OrderTempService extends BaseService {
|
|||
paraList.add(tm + ETM_SUFFIX);
|
||||
} else{
|
||||
findSql += " AND CREATE_TIME < ? \n";
|
||||
paraList.add(LocalDate.now() + STM_SUFFIX);
|
||||
paraList.add(LocalDate.now().plusDays(1) + STM_SUFFIX);
|
||||
}
|
||||
|
||||
String sql = "SELECT\n" +
|
||||
|
|
@ -493,6 +493,8 @@ public class OrderTempService extends BaseService {
|
|||
"SUM( WEIGHT ) WEIGHT,\n" +
|
||||
"SUM( TOTAL_PRICE ) TOTAL_PRICE,\n" +
|
||||
"SALE_TYPE,\n" +
|
||||
"PRODUCT_ID,\n" +
|
||||
"INVOICE_TYPE,\n" +
|
||||
"ifnull(COUNT( SN ), 0 ) COUNT \n" +
|
||||
"FROM\n" +
|
||||
"ORDER_TEMP \n" +
|
||||
|
|
@ -507,6 +509,8 @@ public class OrderTempService extends BaseService {
|
|||
"GROUP BY\n" +
|
||||
"CUSTOMER_ID,\n" +
|
||||
"SUPERMARKET_ID,\n" +
|
||||
"PRODUCT_ID,\n" +
|
||||
"INVOICE_TYPE,\n" +
|
||||
"SALE_TYPE,\n" +
|
||||
"DATE_FORMAT( CREATE_TIME, '%Y-%m-%d' )";
|
||||
|
||||
|
|
|
|||
|
|
@ -170,7 +170,7 @@ public class PrepayService {
|
|||
public List<Record> consumption(Integer customer_id, Integer customer_type_id, Integer supermarket_id, String stm, String etm, String truck_license, Integer invoice_type) {
|
||||
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, t.create_time \n" +
|
||||
" from order_temp t \n" +
|
||||
// " left join customer c on c.id = t.customer_id \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 > -1 \n" +
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ import com.cowr.common.base.BaseService;
|
|||
import com.cowr.common.view.PageParam;
|
||||
import com.cowr.model.Customer;
|
||||
import com.cowr.model.PrepayCustomer;
|
||||
import com.cowr.model.PrepayDetail;
|
||||
import com.cowr.model.RefundDetail;
|
||||
import com.cowr.ssjygl.prepay.prepaycustomer.PrepayCustomerService;
|
||||
import com.jfinal.kit.StrKit;
|
||||
|
|
@ -42,7 +41,7 @@ public class RefundDetailService extends BaseService {
|
|||
return out;
|
||||
}
|
||||
|
||||
public Page<Record> find(PageParam pp, String name, String stm, String etm, Integer state) {
|
||||
public Page<Record> find(PageParam pp, String name, String stm, String etm, Integer state, Integer cId) {
|
||||
String selectsql = "select t.*, c.name customer_name, c.address, c.texpayer_name, c.texpayer_num, c.memo, p.surplus";
|
||||
String fromsql = " from refund_detail t \n" +
|
||||
" left join customer c on t.customer_id = c.id" +
|
||||
|
|
@ -60,6 +59,12 @@ public class RefundDetailService extends BaseService {
|
|||
paraList.add(stm);
|
||||
}
|
||||
|
||||
|
||||
if (StrKit.notNull(cId)) {
|
||||
fromsql += " and t.c.id >= ?";
|
||||
paraList.add(cId);
|
||||
}
|
||||
|
||||
if (StrKit.notBlank(etm)) {
|
||||
fromsql += " and t.create_time <= ?";
|
||||
paraList.add(etm);
|
||||
|
|
|
|||
|
|
@ -8,12 +8,9 @@ import org.apache.poi.ss.usermodel.*;
|
|||
import org.apache.poi.ss.util.CellRangeAddress;
|
||||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static com.cowr.common.utils.DateTimeUtil.STM_SUFFIX;
|
||||
|
||||
public class CustomerStatService {
|
||||
private static Log log = Log.getLog(CustomerStatService.class);
|
||||
public static CustomerStatService me = new CustomerStatService();
|
||||
|
|
@ -48,7 +45,7 @@ public class CustomerStatService {
|
|||
" sum(ifnull((case when t.sale_type = 1 THEN t.weight END), 0)) yh_total_weight,\n" +
|
||||
" sum(ifnull((case when t.sale_type = 1 THEN t.count END), 0)) yh_total_cnt \n" +
|
||||
" from order_end t\n" +
|
||||
" where t.customer_id > -1\n" +
|
||||
" where t.customer_id > 0\n" +
|
||||
" and t.date <= ? \n" +
|
||||
customerSql +
|
||||
" group by t.customer_id\n";
|
||||
|
|
@ -57,41 +54,41 @@ public class CustomerStatService {
|
|||
paraList.add(customer_id);
|
||||
}
|
||||
|
||||
// 如果是当天的就加上销售订单数据
|
||||
if (LocalDate.now().toString().equals(tm)){
|
||||
|
||||
tempSql += "UNION select t.customer_id,\n" +
|
||||
" sum(ifnull((case when t.sale_type = 0 THEN t.total_price END), 0)) sh_total_price,\n" +
|
||||
" sum(ifnull((case when t.sale_type = 0 THEN t.weight END), 0)) sh_total_weight,\n" +
|
||||
" sum(ifnull((case when t.sale_type = 0 THEN 1 END), 0)) sh_total_cnt,\n" +
|
||||
" sum(ifnull((case when t.sale_type = 1 THEN t.total_price END), 0)) yh_total_price,\n" +
|
||||
" sum(ifnull((case when t.sale_type = 1 THEN t.weight END), 0)) yh_total_weight,\n" +
|
||||
" sum(ifnull((case when t.sale_type = 1 THEN 1 END), 0)) yh_total_cnt \n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.customer_id is not null\n" +
|
||||
" and t.create_time >= ? \n" +
|
||||
" and t.state = 5\n" +
|
||||
customerSql +
|
||||
" group by t.customer_id\n";
|
||||
|
||||
|
||||
tempSql = "select t.customer_id,\n" +
|
||||
" sum(ifnull(t.sh_total_price, 0)) sh_total_price,\n" +
|
||||
" sum(ifnull(t.sh_total_weight, 0)) sh_total_weight,\n" +
|
||||
" sum(ifnull(t.sh_total_cnt, 0)) sh_total_cnt,\n" +
|
||||
" sum(ifnull(t.yh_total_price, 0)) yh_total_price,\n" +
|
||||
" sum(ifnull(t.yh_total_weight, 0)) yh_total_weight,\n" +
|
||||
" sum(ifnull(t.yh_total_cnt, 0)) yh_total_cnt \n" +
|
||||
" from (\n" +
|
||||
tempSql +
|
||||
") t" +
|
||||
" group by t.customer_id";
|
||||
|
||||
paraList.add(tm + STM_SUFFIX);
|
||||
if (customer_id != null) {
|
||||
paraList.add(customer_id);
|
||||
}
|
||||
}
|
||||
// // 如果是当天的就加上销售订单数据
|
||||
// if (LocalDate.now().toString().equals(tm)){
|
||||
//
|
||||
// tempSql += "UNION select t.customer_id,\n" +
|
||||
// " sum(ifnull((case when t.sale_type = 0 THEN t.total_price END), 0)) sh_total_price,\n" +
|
||||
// " sum(ifnull((case when t.sale_type = 0 THEN t.weight END), 0)) sh_total_weight,\n" +
|
||||
// " sum(ifnull((case when t.sale_type = 0 THEN 1 END), 0)) sh_total_cnt,\n" +
|
||||
// " sum(ifnull((case when t.sale_type = 1 THEN t.total_price END), 0)) yh_total_price,\n" +
|
||||
// " sum(ifnull((case when t.sale_type = 1 THEN t.weight END), 0)) yh_total_weight,\n" +
|
||||
// " sum(ifnull((case when t.sale_type = 1 THEN 1 END), 0)) yh_total_cnt \n" +
|
||||
// " from order_temp t\n" +
|
||||
// " where t.customer_id is not null\n" +
|
||||
// " and t.create_time >= ? \n" +
|
||||
// " and t.state = 5\n" +
|
||||
// customerSql +
|
||||
// " group by t.customer_id\n";
|
||||
//
|
||||
//
|
||||
// tempSql = "select t.customer_id,\n" +
|
||||
// " sum(ifnull(t.sh_total_price, 0)) sh_total_price,\n" +
|
||||
// " sum(ifnull(t.sh_total_weight, 0)) sh_total_weight,\n" +
|
||||
// " sum(ifnull(t.sh_total_cnt, 0)) sh_total_cnt,\n" +
|
||||
// " sum(ifnull(t.yh_total_price, 0)) yh_total_price,\n" +
|
||||
// " sum(ifnull(t.yh_total_weight, 0)) yh_total_weight,\n" +
|
||||
// " sum(ifnull(t.yh_total_cnt, 0)) yh_total_cnt \n" +
|
||||
// " from (\n" +
|
||||
// tempSql +
|
||||
// ") t" +
|
||||
// " group by t.customer_id";
|
||||
//
|
||||
// paraList.add(tm + STM_SUFFIX);
|
||||
// if (customer_id != null) {
|
||||
// paraList.add(customer_id);
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
sql = "select \n" +
|
||||
|
|
|
|||
|
|
@ -18,12 +18,8 @@ import org.apache.poi.ss.util.CellRangeAddress;
|
|||
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
|
||||
import static com.cowr.common.utils.DateTimeUtil.ETM_SUFFIX;
|
||||
import static com.cowr.common.utils.DateTimeUtil.STM_SUFFIX;
|
||||
|
||||
public class OrderStatService {
|
||||
private static Log log = Log.getLog(OrderStatService.class);
|
||||
public static OrderStatService me = new OrderStatService();
|
||||
|
|
@ -640,7 +636,7 @@ public class OrderStatService {
|
|||
" left join customer c on c.id = t.customer_id \n" +
|
||||
" where t.state = ? \n" +
|
||||
// " and t.create_time like ? \n" +
|
||||
" and and t.create_time between ? and ? \n" +
|
||||
" and t.create_time between ? and ? \n" +
|
||||
saleParams +
|
||||
" and t.invoice_type = ? \n";
|
||||
if (customer_id != null) {
|
||||
|
|
@ -1768,27 +1764,41 @@ public class OrderStatService {
|
|||
// paraList.add(year + "%");
|
||||
addTm(year, paraList);
|
||||
String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus ,a.product_id,a.product_name from (\n" +
|
||||
" select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight,t.product_id,t.product_name, c.name customer_name \n" +
|
||||
" from order_temp t\n" +
|
||||
// " select ifnull(t.customer_id, -1) id," +
|
||||
" select ifnull(c.id, -1) id," +
|
||||
// " count(t.sn) orderCount, " +
|
||||
" sum(t.count) orderCount, " +
|
||||
"sum(t.total_price) totalPrice, sum(weight) weight,t.product_id," +
|
||||
// "t.product_name," +
|
||||
"p.name product_name," +
|
||||
"c.name customer_name \n" +
|
||||
// " from order_temp t\n" +
|
||||
" from order_end t\n" +
|
||||
" LEFT JOIN product p ON p.id = t.product_id " +
|
||||
" left join customer c on c.id = t.customer_id\n" +
|
||||
" where t.state = 5\n" +
|
||||
// " where t.state = 5\n" +
|
||||
" where 1 = 1\n" +
|
||||
saleParams +
|
||||
// " and t.create_time like ? \n";
|
||||
" and t.create_time between ? and ? \n";
|
||||
// " and t.create_time between ? and ? \n";
|
||||
" and t.date between ? and ? \n";
|
||||
|
||||
if (customer_id != null) {
|
||||
sql += " and c.id = ? \n";
|
||||
paraList.add(customer_id);
|
||||
} else if (customer_type_id != null) {
|
||||
if (customer_type_id == 99) {
|
||||
sql += " and t.customer_id is null \n";
|
||||
// sql += " and t.customer_id is null \n";
|
||||
sql += " AND c.id IS NULL \n";
|
||||
} else {
|
||||
sql += " and c.customer_type_id = ? \n";
|
||||
paraList.add(customer_type_id);
|
||||
}
|
||||
}
|
||||
|
||||
sql += " group by t.customer_id,t.product_id,t.product_name\n" +
|
||||
sql += " group by t.customer_id,t.product_id," +
|
||||
// "t.product_name\n" +
|
||||
"p.name \n" +
|
||||
" ) a\n" +
|
||||
" left join prepay_customer p on p.customer_id = a.id";
|
||||
list = Db.find(sql, paraList.toArray());
|
||||
|
|
@ -1796,20 +1806,27 @@ public class OrderStatService {
|
|||
// paraList.add(year + "%");
|
||||
addTm(year, paraList);
|
||||
String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus from (\n" +
|
||||
" select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight, c.name customer_name \n" +
|
||||
" from order_temp t\n" +
|
||||
// " select ifnull(t.customer_id, -1) id," +
|
||||
" select ifnull(c.id, -1) id," +// "count(t.sn) orderCount, " +
|
||||
" sum(t.count) orderCount, " +
|
||||
"sum(t.total_price) totalPrice, sum(weight) weight, c.name customer_name \n" +
|
||||
// " from order_temp t\n" +
|
||||
" from order_end t\n" +
|
||||
" left join customer c on c.id = t.customer_id\n" +
|
||||
" where t.state = 5\n" +
|
||||
// " where t.state = 5\n" +
|
||||
" where 1 = 1\n" +
|
||||
saleParams +
|
||||
// " and t.create_time like ? \n";
|
||||
" and t.create_time between ? and ? \n";
|
||||
// " and t.create_time between ? and ? \n";
|
||||
" and t.date between ? and ? \n";
|
||||
|
||||
if (customer_id != null) {
|
||||
sql += " and c.id = ? \n";
|
||||
paraList.add(customer_id);
|
||||
} else if (customer_type_id != null) {
|
||||
if (customer_type_id == 99) {
|
||||
sql += " and t.customer_id is null \n";
|
||||
// sql += " and t.customer_id is null \n";
|
||||
sql += " AND c.id IS NULL \n";
|
||||
} else {
|
||||
sql += " and c.customer_type_id = ? \n";
|
||||
paraList.add(customer_type_id);
|
||||
|
|
@ -1826,34 +1843,50 @@ public class OrderStatService {
|
|||
} else {
|
||||
if (stat_product) {
|
||||
String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus,a.product_id,a.product_name from (\n" +
|
||||
" select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight,t.product_id,t.product_name, c.name customer_name \n" +
|
||||
" from order_temp t\n" +
|
||||
// " select ifnull(t.customer_id, -1) id," +
|
||||
" select ifnull(c.id, -1) id," +// "count(t.sn) orderCount, " +
|
||||
" sum(t.count) orderCount, " +
|
||||
"sum(t.total_price) totalPrice, sum(weight) weight,t.product_id," +
|
||||
// "t.product_name," +
|
||||
"p.name product_name," +
|
||||
" c.name customer_name \n" +
|
||||
// " from order_temp t\n" +
|
||||
" from order_end t\n" +
|
||||
" LEFT JOIN product p ON p.id = t.product_id " +
|
||||
" left join customer c on c.id = t.customer_id\n" +
|
||||
" where t.state = 5\n" + saleParams;
|
||||
// " where t.state = 5\n" +
|
||||
" where 1 = 1\n" + saleParams;
|
||||
|
||||
if (customer_id != null) {
|
||||
sql += " and c.id = ? \n";
|
||||
paraList.add(customer_id);
|
||||
} else if (customer_type_id != null) {
|
||||
if (customer_type_id == 99) {
|
||||
sql += " and t.customer_id is null \n";
|
||||
} else {
|
||||
// sql += " and t.customer_id is null \n";
|
||||
sql += " AND c.id IS NULL \n"; } else {
|
||||
sql += " and c.customer_type_id = ? \n";
|
||||
paraList.add(customer_type_id);
|
||||
}
|
||||
}
|
||||
|
||||
sql += " group by t.customer_id,t.product_id,t.product_name\n" +
|
||||
sql += " group by t.customer_id,t.product_id," +
|
||||
// "t.product_name\n" +
|
||||
"p.name \n" +
|
||||
" ) a\n" +
|
||||
" left join prepay_customer p on p.customer_id = a.id";
|
||||
|
||||
list = Db.find(sql, paraList.toArray());
|
||||
} else {
|
||||
String sql = "select ifnull(a.customer_name, '零散') name, a.*, p.surplus totalSurplus from (\n" +
|
||||
" select ifnull(t.customer_id, -1) id, count(t.sn) orderCount, sum(t.total_price) totalPrice, sum(weight) weight, c.name customer_name \n" +
|
||||
" from order_temp t\n" +
|
||||
// " select ifnull(t.customer_id, -1) id," +
|
||||
" select ifnull(c.id, -1) id," +// "count(t.sn) orderCount, " +
|
||||
" sum(t.count) orderCount, " +
|
||||
"sum(t.total_price) totalPrice, sum(weight) weight, c.name customer_name \n" +
|
||||
// " from order_temp t\n" +
|
||||
" from order_end t\n" +
|
||||
" left join customer c on c.id = t.customer_id\n" +
|
||||
" where t.state = 5\n" + saleParams;
|
||||
// " where t.state = 5\n" +
|
||||
" where 1 = 1\n" + saleParams;
|
||||
|
||||
if (customer_id != null) {
|
||||
sql += " and c.id = ? \n";
|
||||
|
|
@ -2278,6 +2311,9 @@ public class OrderStatService {
|
|||
sups.add(new Record()
|
||||
.set("id", 97).set("name", "河东湾处置砂").set("isdeploy", 1).set("del", 0)
|
||||
);
|
||||
sups.add(new Record()
|
||||
.set("id", 96).set("name", "团陂处置砂").set("isdeploy", 1).set("del", 0)
|
||||
);
|
||||
}
|
||||
|
||||
String paramsSql = "";
|
||||
|
|
@ -2370,32 +2406,32 @@ public class OrderStatService {
|
|||
" group by t.customer_id\n";
|
||||
|
||||
|
||||
String endDay = etm.split(" ")[0];
|
||||
if (LocalDate.now().toString().equals(endDay)) {
|
||||
|
||||
union_4 = "union select\n" +
|
||||
" ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
" t.supermarket_id,\n" +
|
||||
" ifnull(sum(t.weight), 0) weight,\n" +
|
||||
" ifnull(sum(t.total_price), 0) total_price\n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.state = 5\n";
|
||||
// " and t.product_id != 4\n" +
|
||||
|
||||
if (invoice_type != null) {
|
||||
union_4 += "and t.invoice_type = " + invoice_type + " \n";
|
||||
}
|
||||
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
union_4 += " and t.sale_type = " + sale_type + " \n";
|
||||
}else{
|
||||
// union_4 += " and t.sale_type = 0 \n";
|
||||
}
|
||||
|
||||
union_4 += " AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' )" +
|
||||
" group by t.customer_id\n";
|
||||
|
||||
}
|
||||
// String endDay = etm.split(" ")[0];
|
||||
// if (LocalDate.now().toString().equals(endDay)) {
|
||||
//
|
||||
// union_4 = "union select\n" +
|
||||
// " ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
// " t.supermarket_id,\n" +
|
||||
// " ifnull(sum(t.weight), 0) weight,\n" +
|
||||
// " ifnull(sum(t.total_price), 0) total_price\n" +
|
||||
// " from order_temp t\n" +
|
||||
// " where t.state = 5\n";
|
||||
//// " and t.product_id != 4\n" +
|
||||
//
|
||||
// if (invoice_type != null) {
|
||||
// union_4 += "and t.invoice_type = " + invoice_type + " \n";
|
||||
// }
|
||||
//
|
||||
// if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
// union_4 += " and t.sale_type = " + sale_type + " \n";
|
||||
// }else{
|
||||
//// union_4 += " and t.sale_type = 0 \n";
|
||||
// }
|
||||
//
|
||||
// union_4 += " AND t.create_time >= CONCAT( CURDATE(), ' 00:00:00' )" +
|
||||
// " group by t.customer_id\n";
|
||||
//
|
||||
// }
|
||||
|
||||
|
||||
|
||||
|
|
@ -2526,73 +2562,128 @@ public class OrderStatService {
|
|||
// " GROUP BY\n" +
|
||||
// " t.customer_id ";
|
||||
|
||||
String order_sql = "";
|
||||
// String order_sql = "";
|
||||
|
||||
String sql = "select\n" +
|
||||
// String sql = "select\n" +
|
||||
// " g.customer_id,\n" +
|
||||
// " ifnull(sum(g.weight), 0) weight,\n" +
|
||||
// " ifnull(sum(g.total_price), 0) total_price,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 1 or g.supermarket_id = 7 then g.weight end), 0) xsl_1,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 2 then g.weight end), 0) xsl_2,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 3 then g.weight end), 0) xsl_3,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 4 then g.weight end), 0) xsl_4,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 5 or g.supermarket_id = 9 then g.weight end), 0) xsl_5,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 6 or g.supermarket_id = 8 or g.supermarket_id = 10 then g.weight end), 0) xsl_6,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 11 then g.weight end), 0) xsl_11,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 12 then g.weight end), 0) xsl_12,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 97 then g.weight end), 0) xsl_97,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 98 then g.weight end), 0) xsl_98,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 99 then g.weight end), 0) xsl_99,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 1 or g.supermarket_id = 7 then g.total_price end), 0) xse_1,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 2 then g.total_price end), 0) xse_2,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 3 then g.total_price end), 0) xse_3,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 4 then g.total_price end), 0) xse_4,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 5 or g.supermarket_id = 9 then g.total_price end), 0) xse_5,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 6 or g.supermarket_id = 8 or g.supermarket_id = 10 then g.total_price end), 0) xse_6,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 11 then g.total_price end), 0) xse_11,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 12 then g.total_price end), 0) xse_12,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 97 then g.total_price end), 0) xse_97,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 98 then g.total_price end), 0) xse_98,\n" +
|
||||
// " ifnull(sum(case when g.supermarket_id = 99 then g.total_price end), 0) xse_99\n" +
|
||||
// " from (\n" +
|
||||
// today +
|
||||
// " select\n" +
|
||||
// " ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
// " t.supermarket_id,\n" +
|
||||
// " ifnull(sum(t.weight), 0) weight,\n" +
|
||||
// " ifnull(sum(t.total_price), 0) total_price\n" +
|
||||
// " from order_end t\n" +
|
||||
// " where " +
|
||||
//// "t.supermarket_id != 4\n" +
|
||||
//// " and t.product_id != 4\n" +
|
||||
//// " and " +
|
||||
// " t.date >= ? \n" +
|
||||
// " and t.date <= ?\n" +
|
||||
// saleParam +
|
||||
// " group by t.customer_id, t.supermarket_id\n" +
|
||||
// union_4 +
|
||||
// union_97 +
|
||||
// union_98 +
|
||||
// union_99 +
|
||||
// " ) g\n" +
|
||||
// " group by g.customer_id\n";
|
||||
String sql = "SELECT\n" +
|
||||
" g.customer_id,\n" +
|
||||
" ifnull(sum(g.weight), 0) weight,\n" +
|
||||
" ifnull(sum(g.total_price), 0) total_price,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 1 or g.supermarket_id = 7 then g.weight end), 0) xsl_1,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 2 then g.weight end), 0) xsl_2,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 3 then g.weight end), 0) xsl_3,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 4 then g.weight end), 0) xsl_4,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 5 or g.supermarket_id = 9 then g.weight end), 0) xsl_5,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 6 or g.supermarket_id = 8 or g.supermarket_id = 10 then g.weight end), 0) xsl_6,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 11 then g.weight end), 0) xsl_11,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 12 then g.weight end), 0) xsl_12,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 97 then g.weight end), 0) xsl_97,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 98 then g.weight end), 0) xsl_98,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 99 then g.weight end), 0) xsl_99,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 1 or g.supermarket_id = 7 then g.total_price end), 0) xse_1,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 2 then g.total_price end), 0) xse_2,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 3 then g.total_price end), 0) xse_3,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 4 then g.total_price end), 0) xse_4,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 5 or g.supermarket_id = 9 then g.total_price end), 0) xse_5,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 6 or g.supermarket_id = 8 or g.supermarket_id = 10 then g.total_price end), 0) xse_6,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 11 then g.total_price end), 0) xse_11,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 12 then g.total_price end), 0) xse_12,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 97 then g.total_price end), 0) xse_97,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 98 then g.total_price end), 0) xse_98,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 99 then g.total_price end), 0) xse_99\n" +
|
||||
" from (\n" +
|
||||
today +
|
||||
" select\n" +
|
||||
" ifnull(t.customer_id, 0) customer_id,\n" +
|
||||
" ifnull( sum( g.weight ), 0 ) weight,\n" +
|
||||
" ifnull( sum( g.total_price ), 0 ) total_price,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 1 OR g.supermarket_id = 7 THEN g.weight END ), 0 ) xsl_1,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 2 THEN g.weight END ), 0 ) xsl_2,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 3 THEN g.weight END ), 0 ) xsl_3,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 4 THEN g.weight END ), 0 ) xsl_4,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 5 OR g.supermarket_id = 9 THEN g.weight END ), 0 ) xsl_5,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 6 OR g.supermarket_id = 8 OR g.supermarket_id = 10 THEN g.weight END ),0) xsl_6,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 11 THEN g.weight END ), 0 ) xsl_11,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 12 THEN g.weight END ), 0 ) xsl_12,\n" +
|
||||
" ifnull( sum( CASE WHEN g.product_id = 4 AND g.sale_type = 0 AND g.supermarket_id = 5 THEN g.weight END ),0) xsl_96,\n" +
|
||||
" ifnull( sum( CASE WHEN g.product_id = 4 AND g.sale_type = 0 AND g.supermarket_id = 10 THEN g.weight END ),0) xsl_97,\n" +
|
||||
" ifnull( sum( CASE WHEN g.product_id = 4 AND g.sale_type = 0 AND g.supermarket_id = 1 THEN g.weight END ),0) xsl_98,\n" +
|
||||
" ifnull( sum( CASE WHEN g.product_id = 4 AND g.sale_type = 0 AND g.supermarket_id = 4 THEN g.weight END ),0 ) xsl_99,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 1 OR g.supermarket_id = 7 THEN g.total_price END ), 0 ) xse_1,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 2 THEN g.total_price END ), 0 ) xse_2,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 3 THEN g.total_price END ), 0 ) xse_3,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 4 THEN g.total_price END ), 0 ) xse_4,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 5 OR g.supermarket_id = 9 THEN g.total_price END ), 0 ) xse_5,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 6 OR g.supermarket_id = 8 OR g.supermarket_id = 10 THEN g.total_price END ),0) xse_6,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 11 THEN g.total_price END ), 0 ) xse_11,\n" +
|
||||
" ifnull( sum( CASE WHEN g.supermarket_id = 12 THEN g.total_price END ), 0 ) xse_12,\n" +
|
||||
" ifnull( sum( CASE WHEN g.product_id = 4 AND g.sale_type = 0 AND g.supermarket_id = 5 THEN g.total_price END ),0) xse_96,\n" +
|
||||
" ifnull( sum( CASE WHEN g.product_id = 4 AND g.sale_type = 0 AND g.supermarket_id = 10 THEN g.total_price END ),0) xse_97,\n" +
|
||||
" ifnull( sum( CASE WHEN g.product_id = 4 AND g.sale_type = 0 AND g.supermarket_id = 1 THEN g.total_price END ),0) xse_98,\n" +
|
||||
" ifnull( sum( CASE WHEN g.product_id = 4 AND g.sale_type = 0 AND g.supermarket_id = 4 THEN g.total_price END ),0) xse_99 \n" +
|
||||
"FROM\n" +
|
||||
" (\n" +
|
||||
" SELECT\n" +
|
||||
" ifnull( t.customer_id, 0 ) customer_id,\n" +
|
||||
" t.supermarket_id,\n" +
|
||||
" ifnull(sum(t.weight), 0) weight,\n" +
|
||||
" ifnull(sum(t.total_price), 0) total_price\n" +
|
||||
" from order_end t\n" +
|
||||
" where " +
|
||||
// "t.supermarket_id != 4\n" +
|
||||
// " and t.product_id != 4\n" +
|
||||
// " and " +
|
||||
" t.product_id,\n" +
|
||||
" t.sale_type,\n" +
|
||||
" ifnull( sum( t.weight ), 0 ) weight,\n" +
|
||||
" ifnull( sum( t.total_price ), 0 ) total_price \n" +
|
||||
" FROM\n" +
|
||||
" order_end t \n" +
|
||||
" WHERE\n" +
|
||||
" t.date >= ? \n" +
|
||||
" and t.date <= ?\n" +
|
||||
" AND t.date <= ? \n" +
|
||||
paramsSql +
|
||||
saleParam +
|
||||
" group by t.customer_id, t.supermarket_id\n" +
|
||||
union_4 +
|
||||
union_97 +
|
||||
union_98 +
|
||||
union_99 +
|
||||
" ) g\n" +
|
||||
" group by g.customer_id\n";
|
||||
|
||||
" GROUP BY\n" +
|
||||
" t.customer_id,\n" +
|
||||
" t.supermarket_id,\n" +
|
||||
" t.product_id,\n" +
|
||||
" t.sale_type \n" +
|
||||
" ) g \n" +
|
||||
"GROUP BY\n" +
|
||||
" g.customer_id";
|
||||
List<Record> customer_sale_list;
|
||||
|
||||
if (invoice_type != null) {
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
// customer_sale_list = Db.find(sql, stm, etm, sale_type, stm, etm, sale_type, stm, etm, sale_type);
|
||||
customer_sale_list = Db.find(sql, stm, etm, sale_type, stm, etm, stm, etm, stm, etm);
|
||||
// customer_sale_list = Db.find(sql, stm, etm, sale_type, stm, etm, stm, etm, stm, etm);
|
||||
customer_sale_list = Db.find(sql, stm, etm, invoice_type, sale_type);
|
||||
} else {
|
||||
// customer_sale_list = Db.find(sql, stm, etm, invoice_type, stm, etm, invoice_type, stm, etm, invoice_type);
|
||||
customer_sale_list = Db.find(sql, stm, etm, stm, etm, stm, etm, stm, etm);
|
||||
// customer_sale_list = Db.find(sql, stm, etm, stm, etm, stm, etm, stm, etm);
|
||||
customer_sale_list = Db.find(sql, stm, etm, invoice_type);
|
||||
}
|
||||
} else {
|
||||
if (sale_type != null && (sale_type == 0 || sale_type == 1)) {
|
||||
// customer_sale_list = Db.find(sql,stm, etm, sale_type, stm, etm, sale_type, stm, etm, sale_type);
|
||||
customer_sale_list = Db.find(sql,stm, etm, sale_type, stm, etm, stm, etm, stm, etm);
|
||||
// customer_sale_list = Db.find(sql,stm, etm, sale_type, stm, etm, stm, etm, stm, etm);
|
||||
customer_sale_list = Db.find(sql, stm, etm, sale_type);
|
||||
} else {
|
||||
customer_sale_list = Db.find(sql, stm, etm, stm, etm, stm, etm, stm, etm);
|
||||
// customer_sale_list = Db.find(sql, stm, etm, stm, etm, stm, etm, stm, etm);
|
||||
customer_sale_list = Db.find(sql, stm, etm);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2613,27 +2704,27 @@ public class OrderStatService {
|
|||
String tempSql =
|
||||
" select t.customer_id, sum(t.total_price) total_price\n" +
|
||||
" from order_end t\n" +
|
||||
" where t.customer_id > -1\n" +
|
||||
// "and t.product_id != 4\n" +
|
||||
" and t.date <= ?\n" +
|
||||
" where t.customer_id > 0\n" +
|
||||
" and t.product_id != 4\n" +
|
||||
" and t.date >= ?\n" +
|
||||
" and t.sale_type = 0\n" +
|
||||
" group by t.customer_id\n";
|
||||
|
||||
// 如果是当天的就加上销售订单数据
|
||||
if (LocalDate.now().toString().equals(tm)) {
|
||||
tempSql += " select t.customer_id, sum(t.total_price) total_price\n" +
|
||||
" from order_temp t\n" +
|
||||
" where t.customer_id is not null\n" +
|
||||
// "and t.product_id != 4\n" +
|
||||
" and t.create_time >= ?\n" +
|
||||
" and t.create_time <= ?\n" +
|
||||
" and t.state = 5\n" +
|
||||
// " and t.sale_type = 0\n" +
|
||||
" group by t.customer_id\n";
|
||||
customer_pre_list_params.add(tm + STM_SUFFIX);
|
||||
customer_pre_list_params.add(tm + ETM_SUFFIX);
|
||||
|
||||
}
|
||||
// if (LocalDate.now().toString().equals(tm)) {
|
||||
// tempSql += " select t.customer_id, sum(t.total_price) total_price\n" +
|
||||
// " from order_temp t\n" +
|
||||
// " where t.customer_id is not null\n" +
|
||||
//// "and t.product_id != 4\n" +
|
||||
// " and t.create_time >= ?\n" +
|
||||
// " and t.create_time <= ?\n" +
|
||||
// " and t.state = 5\n" +
|
||||
//// " and t.sale_type = 0\n" +
|
||||
// " group by t.customer_id\n";
|
||||
// customer_pre_list_params.add(tm + STM_SUFFIX);
|
||||
// customer_pre_list_params.add(tm + ETM_SUFFIX);
|
||||
//
|
||||
// }
|
||||
|
||||
// customer_pre_list_params.add(tm);
|
||||
customer_pre_list_params.add(tm);
|
||||
|
|
@ -3221,9 +3312,9 @@ public class OrderStatService {
|
|||
}
|
||||
if (!StrKit.isBlank(etm)) {
|
||||
paramsSql += " and t.create_time <= ?\n";
|
||||
paramsSql2 += " and p.create_time >= ?\n";
|
||||
paramsSql2 += " and p.create_time <= ?\n";
|
||||
paraList1.add(etm);
|
||||
paraList2.add(stm);
|
||||
paraList2.add(etm);
|
||||
}
|
||||
paraList1.addAll(paraList2);
|
||||
String sql = " SELECT c.name, t.* from (\n" +
|
||||
|
|
@ -3254,7 +3345,7 @@ public class OrderStatService {
|
|||
" ifnull(sum(case when g.supermarket_id = 4 then g.weight end), 0) xsw_4,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 5 or g.supermarket_id = 9 then g.weight end), 0) xsw_5,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 6 or g.supermarket_id = 8 or g.supermarket_id = 10 then g.weight end), 0) xsw_6,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 11 then g.weight end), 0) xsw_11\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 11 then g.weight end), 0) xsw_11,\n" +
|
||||
" ifnull(sum(case when g.supermarket_id = 12 then g.weight end), 0) xsw_12\n" +
|
||||
" from (\n" +
|
||||
" select a.customer_id, a.supermarket_id, sum(a.presell_amount) presell_amount, sum(a.pug_amount) pug_amount, sum(a.weight) weight from (\n" +
|
||||
|
|
@ -3529,8 +3620,10 @@ public class OrderStatService {
|
|||
if (!StrKit.isBlank(tm)) {
|
||||
// shParams += " and t.create_time like ? \n";
|
||||
// yhParams += " and p.presell_date like ? \n";
|
||||
shParams += " and t.create_time between ? and ? \n";
|
||||
yhParams += " and p.presell_date between ? and ? \n";
|
||||
// shParams += " and t.create_time between ? and ? \n";
|
||||
// yhParams += " and p.presell_date between ? and ? \n";
|
||||
shParams += " and t.date between ? and ? \n";
|
||||
yhParams += " and t.date between ? and ? \n";
|
||||
// shParamsList.add(tm + "%");
|
||||
// yhParamsList.add(tm + "%");
|
||||
addTm(tm, shParamsList);
|
||||
|
|
@ -3544,9 +3637,10 @@ public class OrderStatService {
|
|||
" select t.id, t.product_id, count(*) as orderCount, sum(t.total_price) as totalPrice, sum(t.weight) as weight\n" +
|
||||
" from (\n" +
|
||||
" select t.supermarket_id as id, t.total_price, t.weight, t.product_id\n" +
|
||||
" from order_temp t \n" +
|
||||
// " from order_temp t \n" +
|
||||
" from order_end t \n" +
|
||||
" where t.sale_type = 0 \n" +
|
||||
" and t.state = 5 \n" +
|
||||
// " and t.state = 5 \n" +
|
||||
shParams +
|
||||
" ) t\n" +
|
||||
" group by t.id, t.product_id\n" +
|
||||
|
|
@ -3565,16 +3659,18 @@ public class OrderStatService {
|
|||
" LEFT JOIN (\n" +
|
||||
" SELECT\n" +
|
||||
" t.supermarket_id,\n" +
|
||||
" ifnull( count(*), 0 ) AS order_num,\n" +
|
||||
// " ifnull( count(*), 0 ) AS order_num,\n" +
|
||||
" ifnull( sum( t.count), 0 ) AS order_num,\n" +
|
||||
" ifnull( sum( t.weight ), 0 ) AS weight,\n" +
|
||||
" ifnull( sum( t.total_price ), 0 ) AS total_price \n" +
|
||||
" FROM\n" +
|
||||
" order_temp t\n" +
|
||||
" LEFT JOIN ordercluster c ON c.id = t.ordercluster_id\n" +
|
||||
" LEFT JOIN presell_order p ON p.id = c.presell_order_id \n" +
|
||||
// " order_temp t\n" +
|
||||
// " LEFT JOIN ordercluster c ON c.id = t.ordercluster_id\n" +
|
||||
// " LEFT JOIN presell_order p ON p.id = c.presell_order_id \n" +
|
||||
" order_end t\n" +
|
||||
" WHERE\n" +
|
||||
" t.sale_type = 1 \n" +
|
||||
" AND t.state = 5 \n" +
|
||||
// " AND t.state = 5 \n" +
|
||||
yhParams +
|
||||
" GROUP BY\n" +
|
||||
" t.supermarket_id \n" +
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package com.cowr.ssjygl.transprice;
|
||||
|
||||
import com.cowr.common.Const;
|
||||
import com.cowr.common.utils.MathUtil;
|
||||
import com.cowr.model.Sandfarm;
|
||||
import com.cowr.model.TransPriceConfigSale;
|
||||
|
|
@ -75,14 +74,15 @@ public class TransPriceService {
|
|||
* @param net_weight 净重
|
||||
* @return Double
|
||||
*/
|
||||
public Double caleTotalPriceDouble(BigDecimal up, BigDecimal net_weight) {
|
||||
public BigDecimal caleTotalPriceDouble(BigDecimal up, BigDecimal net_weight) {
|
||||
if (up == null || net_weight == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// return MathUtil.round4(up.multiply(net_weight).doubleValue()); // 三舍四入 保留 0 位小数
|
||||
// 2020-07-01 保留两位小数
|
||||
return up.multiply(net_weight).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
// return up.multiply(net_weight).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
return up.multiply(net_weight).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -97,7 +97,8 @@ public class TransPriceService {
|
|||
return null;
|
||||
}
|
||||
|
||||
return new BigDecimal(caleTotalPriceDouble(up, net_weight));
|
||||
// return new BigDecimal(caleTotalPriceDouble(up, net_weight));
|
||||
return caleTotalPriceDouble(up, net_weight);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ public class OutController extends Controller implements Runnable {
|
|||
log.debug("%s 【%s】上磅,等待地感线圈状态", getWhich(), pair.license);
|
||||
try {
|
||||
while (!getResetFlow()) { // 流程没有被重置,就一直等待地感线圈状态
|
||||
if (getPlc().read(getSensor1())) { // 读取前地感状态
|
||||
if (getPlc().read(getSensor1()) || getPlc().read(getSensor2())) { // 读取前地感状态
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -180,6 +180,9 @@ public class OutController extends Controller implements Runnable {
|
|||
log.error(e.getMessage(), e);
|
||||
}
|
||||
|
||||
// 获取到地感线圈状态后,等待 5 秒后开始称重
|
||||
Thread.sleep(6000);
|
||||
|
||||
// 重置流程,这个位置要重置地感线圈状态
|
||||
if (getResetFlow()) {
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -142,7 +142,7 @@ public class NettyClient {
|
|||
if (!validateMsg(msg)) {
|
||||
sendMsg(ctx, deny().toJSONString());
|
||||
}
|
||||
|
||||
// log.info("收到消息:" + msg);
|
||||
JSONObject json = JSONObject.parseObject(msg);
|
||||
String target = json.getString("target");
|
||||
|
||||
|
|
|
|||
|
|
@ -462,7 +462,9 @@ public class OrderTempSyncService {
|
|||
return Result.failed("总价计算错误");
|
||||
}
|
||||
|
||||
total_price = total_price.setScale(0, BigDecimal.ROUND_HALF_UP);
|
||||
// total_price = total_price.setScale(0, BigDecimal.ROUND_HALF_UP);
|
||||
// 2024年9月2日 散户(处置砂,黄砂)结算付款不再四舍五入,保留小数点后两位数
|
||||
total_price = total_price.setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
// 支付信息
|
||||
order.setUnitPrice(up);
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ public class RefundDetailController extends BaseController {
|
|||
String etm = get("etm");
|
||||
Integer state = getInt("state");
|
||||
PageParam pp = getBean(PageParam.class, "", true);
|
||||
renderJson(Result.object(RefundDetailService.me.find(pp, name, stm, etm, state)));
|
||||
renderJson(Result.object(RefundDetailService.me.find(pp, name, stm, etm, state,null)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -0,0 +1,131 @@
|
|||
package com.cowr.service.ssjygl.Interceptor;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Created by wanyan on 2024/8/23
|
||||
*
|
||||
* @author wanyan
|
||||
* @version 1.0
|
||||
*/
|
||||
|
||||
import com.alibaba.druid.filter.FilterChain;
|
||||
import com.alibaba.druid.filter.FilterEventAdapter;
|
||||
import com.alibaba.druid.proxy.jdbc.ConnectionProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.JdbcParameter;
|
||||
import com.alibaba.druid.proxy.jdbc.PreparedStatementProxy;
|
||||
import com.alibaba.druid.proxy.jdbc.StatementProxy;
|
||||
import com.cowr.common.utils.DataUtil;
|
||||
import com.cowr.common.utils.DateTimeUtil;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.log.Log;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
public class UpdateOnlyListener extends FilterEventAdapter {
|
||||
|
||||
private static Log log = Log.getLog(UpdateOnlyListener.class);
|
||||
|
||||
private static ArrayList<String> tableName = Lists.newArrayList();
|
||||
|
||||
static {
|
||||
tableName.add("order_temp");
|
||||
tableName.add("prepay_customer");
|
||||
// tableName.add("sync_task");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int preparedStatement_executeUpdate(FilterChain chain, PreparedStatementProxy statement) throws SQLException {
|
||||
String sql = statement.getSql();
|
||||
if(checkSql(sql)){
|
||||
List<String> param = Lists.newArrayList();
|
||||
if(statement.getParametersSize() > 0){
|
||||
for(int i = 0; i < statement.getParametersSize();i++){
|
||||
JdbcParameter jdbcParameter = statement.getParameters().get(i);
|
||||
|
||||
Object value = jdbcParameter.getValue();
|
||||
if (value instanceof Date){
|
||||
value = DateTimeUtil.sdfhms.get().format(value);
|
||||
}
|
||||
param.add(value + "");
|
||||
}
|
||||
// sql = sql + param;
|
||||
}
|
||||
saveSqlLog(statement.getConnectionProxy(),sql,param);
|
||||
}
|
||||
return chain.preparedStatement_executeUpdate(statement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] statement_executeBatch(FilterChain chain, StatementProxy statement) throws SQLException {
|
||||
String sql = statement.getBatchSql();
|
||||
if(checkSql(sql)){
|
||||
List<String> param = Lists.newArrayList();
|
||||
if(statement.getParametersSize() > 0){
|
||||
for(int i = 0; i < statement.getParametersSize();i++){
|
||||
JdbcParameter jdbcParameter = statement.getParameters().get(i);
|
||||
Object value = jdbcParameter.getValue();
|
||||
if (value instanceof Date){
|
||||
value = DateTimeUtil.sdfhms.get().format(value);
|
||||
}
|
||||
param.add(value+ "");
|
||||
}
|
||||
// sql = sql + param;
|
||||
}
|
||||
saveSqlLog(statement.getConnectionProxy(),sql,param);
|
||||
}
|
||||
return chain.statement_executeBatch(statement);
|
||||
}
|
||||
|
||||
|
||||
private Boolean checkSql(String sql){
|
||||
for (String tablename : tableName) {
|
||||
if (sql.contains(tablename)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
private void saveSqlLog(ConnectionProxy connection, String sql, List<String> param ) {
|
||||
// 这里可以实现你的监控逻辑,例如打印或记录日志
|
||||
// log.info("druid监听到sql:" + sql + " ,参数: " + param);
|
||||
String sqlData = sql.replaceAll("\\?", "%s");
|
||||
String format = DataUtil.formatWithVarargs(sqlData, param.toArray());
|
||||
log.info("druid监听到sql:" + format);
|
||||
String insertSql = "INSERT INTO sql_log (id, sql_content) VALUES (?, ?)";
|
||||
PreparedStatement pstmt = null;
|
||||
try {
|
||||
|
||||
pstmt = connection.prepareStatement(insertSql);
|
||||
pstmt.setString(1, StrKit.getRandomUUID());
|
||||
pstmt.setString(2, format);
|
||||
// pstmt.addBatch();
|
||||
int i = pstmt.executeUpdate();
|
||||
if (i != 1){
|
||||
log.error("sql_log 插入失败");
|
||||
log.error("sql_log: " + format);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 异常处理
|
||||
// log.error(convException(e));
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
public static String convException(Exception e) {
|
||||
StringWriter sw = new StringWriter();
|
||||
PrintWriter pw = new PrintWriter(sw);
|
||||
e.printStackTrace(pw);
|
||||
StringBuffer buffer = sw.getBuffer();
|
||||
return buffer.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -28,6 +28,8 @@ public class AuthInterceptor implements Interceptor {
|
|||
add("/order/temp/find");
|
||||
add("/order/temp/get");
|
||||
|
||||
add("/refunddetail/find");
|
||||
|
||||
add("/stat/sale/statDayCustomer");
|
||||
add("/stat/sale/daydetail");
|
||||
add("/stat/sale/statMonthCustomer");
|
||||
|
|
@ -102,6 +104,11 @@ public class AuthInterceptor implements Interceptor {
|
|||
) {
|
||||
c.renderJson(Result.permissionDenied());
|
||||
return;
|
||||
}else{
|
||||
Integer entityId = sysuser.getEntityId();
|
||||
if (null != entityId){
|
||||
c.set("cId",sysuser.getId());
|
||||
}
|
||||
}
|
||||
|
||||
int update = SysuserSyncService.me.updateOnlineTime(sysuser.getId());
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import com.cowr.common.oss.OSSKit;
|
|||
import com.cowr.common.plugin.QuartzPlugin;
|
||||
import com.cowr.common.view.JsonRenderFactory;
|
||||
import com.cowr.model._MappingKit;
|
||||
import com.cowr.service.ssjygl.Interceptor.UpdateOnlyListener;
|
||||
import com.cowr.service.ssjygl.addsubtractitem.AddSubtractItemController;
|
||||
import com.cowr.service.ssjygl.addsubtractitemrecord.AddSubtractItemRecordController;
|
||||
import com.cowr.service.ssjygl.blacklist.BlacklistController;
|
||||
|
|
@ -270,6 +271,7 @@ public class Config extends JFinalConfig {
|
|||
wallFilter.setDbType("mysql");
|
||||
druidPlugin.addFilter(wallFilter);
|
||||
druidPlugin.addFilter(new StatFilter()); // 添加 StatFilter 才会有统计数据
|
||||
druidPlugin.addFilter(new UpdateOnlyListener());
|
||||
me.add(druidPlugin);
|
||||
|
||||
ActiveRecordPlugin arp = new ActiveRecordPlugin(druidPlugin);
|
||||
|
|
|
|||
|
|
@ -880,7 +880,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
|||
}
|
||||
|
||||
// 客户在所有砂站的未完成的配额中,未执行完成的总金额
|
||||
BigDecimal undo_price = OrderclusterService.me.undoPrice(oldobj.getCustomerId(), 0);
|
||||
BigDecimal undo_price = OrderclusterService.me.undoPrice(oldobj.getCustomerId(), 0); // 预售配额修改
|
||||
BigDecimal plan_total_price;
|
||||
if (model.getTotalWeight().compareTo(oldobj.getTotalWeight()) > 0) { // 修改后,比原来的大
|
||||
BigDecimal ofsset_weight = model.getTotalWeight().subtract(oldobj.getTotalWeight()); // 本次修改增加的重量
|
||||
|
|
|
|||
|
|
@ -99,12 +99,14 @@ public class RefundDetailController extends BaseController {
|
|||
* 分页查找 refund_detail 预付费客户退费详情
|
||||
*/
|
||||
public void find() {
|
||||
|
||||
String name = get("name");
|
||||
String stm = get("stm");
|
||||
String etm = get("etm");
|
||||
Integer cId = getAttr("cId");
|
||||
Integer state = getInt("state");
|
||||
PageParam pp = getBean(PageParam.class, "", true);
|
||||
renderJson(Result.object(RefundDetailService.me.find(pp, name, stm, etm, state)));
|
||||
renderJson(Result.object(RefundDetailService.me.find(pp, name, stm, etm, state,cId)));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -89,9 +89,9 @@ public class SmsService {
|
|||
try {
|
||||
String phone = sysuser.getPhone();
|
||||
|
||||
if (Config.isDev()) {
|
||||
phone = "13627293906";
|
||||
}
|
||||
// if (Config.isDev()) {
|
||||
phone = "18891233883";
|
||||
// }
|
||||
|
||||
log.debug("给 %s 发送短信", phone);
|
||||
|
||||
|
|
@ -366,7 +366,7 @@ public class SmsService {
|
|||
String phone = sysuser.getPhone();
|
||||
|
||||
if (Config.isDev()) {
|
||||
phone = "13627293906";
|
||||
phone = "18891233883";
|
||||
}
|
||||
|
||||
log.debug("给 %s 发送短信", phone);
|
||||
|
|
@ -459,7 +459,7 @@ public class SmsService {
|
|||
String phone = contact.getPhone();
|
||||
|
||||
if (Config.isDev()) {
|
||||
// phone = "13627293906";
|
||||
// phone = "18891233883";
|
||||
phone = "18891233883";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ public class OrderStatController extends BaseController {
|
|||
/**
|
||||
* 各砂站运输量统计表
|
||||
*/
|
||||
@Clear()
|
||||
@Clear(AuthInterceptor.class)
|
||||
public void trafficStatisticsOfEachSandStation() {
|
||||
String stm = get("stm");
|
||||
String etm = get("etm");
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class SyncTaskService {
|
|||
.fluentPut("id", data.get("id"))
|
||||
.toJSONString());
|
||||
} else {
|
||||
log.debug("数据接收后,入库失败:", data);
|
||||
log.debug("数据接收后,入库失败:", JSONObject.toJSONString(data));
|
||||
}
|
||||
|
||||
Thread.sleep(100);
|
||||
|
|
@ -249,9 +249,9 @@ public class SyncTaskService {
|
|||
* @return
|
||||
*/
|
||||
public boolean recv(JSONObject recvdata, int current_supermarket_id) {
|
||||
// if (!isEnable()) {
|
||||
// return true;
|
||||
// }
|
||||
if (!isEnable()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
long st = System.currentTimeMillis();
|
||||
|
||||
|
|
@ -291,6 +291,30 @@ public class SyncTaskService {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (isCachePrimary(current_supermarket_id + recvdata.getString("id"))) {
|
||||
// 存在就不在执行
|
||||
|
||||
try{
|
||||
|
||||
SyncTask o = recvdata.toJavaObject(SyncTask.class);
|
||||
o.setState(2); // 上报任务保存
|
||||
SyncTask sync = SyncTask.dao.findById(o.getId());
|
||||
if (null == sync) {
|
||||
if (!o.save()) {
|
||||
log.info("save sync_task fail " + o.toJson());
|
||||
}
|
||||
}else{
|
||||
if (sync.getState() == 2){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("save sync_task error " + e.getMessage(), e);
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean ret = Db.tx(new IAtom() {
|
||||
@Override
|
||||
public boolean run() {
|
||||
|
|
@ -319,6 +343,11 @@ public class SyncTaskService {
|
|||
for (int i = 0; i < arr.size(); i++) {
|
||||
JSONObject obj = arr.getJSONObject(i);
|
||||
|
||||
// // 判断是否新增过
|
||||
// if (saveData(tablename, obj)){
|
||||
// continue;
|
||||
// }
|
||||
|
||||
list.add(new Record().setColumns(obj.getInnerMap()));
|
||||
|
||||
// 分发黑名单
|
||||
|
|
@ -494,6 +523,8 @@ public class SyncTaskService {
|
|||
// 2020-10-10 只在修改 PrepayCustomer 中的余额时需要用到
|
||||
if (increment_data != null && !increment_data.isEmpty()) {
|
||||
|
||||
boolean isUpdate = false;
|
||||
|
||||
for (String tablename : increment_data.keySet()) {
|
||||
JSONObject data = increment_data.getJSONObject(tablename);
|
||||
String pks = data.getString("pks");
|
||||
|
|
@ -518,7 +549,7 @@ public class SyncTaskService {
|
|||
try {
|
||||
BigDecimal old = record.getBigDecimal(key);
|
||||
|
||||
BigDecimal add = old.add(new BigDecimal(increment_data.getString(key)));
|
||||
BigDecimal add = old.add(new BigDecimal(increment_data.getString(key))).setScale(2, BigDecimal.ROUND_HALF_UP);
|
||||
|
||||
if (add.compareTo(BigDecimal.ZERO) < 0){
|
||||
log.error("余额小于0 ");
|
||||
|
|
@ -557,7 +588,7 @@ public class SyncTaskService {
|
|||
if (!ret) {
|
||||
return false;
|
||||
}
|
||||
|
||||
isUpdate = ret;
|
||||
try {
|
||||
|
||||
// 新增成功进行修改
|
||||
|
|
@ -601,6 +632,10 @@ public class SyncTaskService {
|
|||
for (Map.Entry<Integer, Supermarket> entry : SvrCacheData.SUP_CACHE.entrySet()) {
|
||||
Supermarket supermarket = entry.getValue();
|
||||
|
||||
if (!isUpdate){ // 是否更新余额
|
||||
// 没更新就不广播
|
||||
break;
|
||||
}
|
||||
// 只对已经部署了客户端的砂站同步数据
|
||||
// 从下面上报的数据,再广播出去
|
||||
if (supermarket.getIsdeploy() == 0 || supermarket.getId() == current_supermarket_id) {
|
||||
|
|
@ -643,26 +678,32 @@ public class SyncTaskService {
|
|||
// return recvAuthLicense(saveauthlics, deleteauthlics, current_supermarket_id);
|
||||
// }
|
||||
|
||||
try{
|
||||
|
||||
SyncTask o = recvdata.toJavaObject(SyncTask.class);
|
||||
if (!o.save()) {
|
||||
return false;
|
||||
}
|
||||
}catch (Exception e){
|
||||
log.error("save sync_task error " + e.getMessage(), e);
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
}
|
||||
// try{
|
||||
//
|
||||
// SyncTask o = recvdata.toJavaObject(SyncTask.class);
|
||||
// o.setState(2); // 上报任务保存
|
||||
// if (null == SyncTask.dao.findById(o.getId()) || !o.save()) {
|
||||
// return false;
|
||||
// }
|
||||
// }catch (Exception e){
|
||||
// log.error("save sync_task error " + e.getMessage(), e);
|
||||
// log.error(e.getMessage(), e);
|
||||
// return false;
|
||||
// }
|
||||
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
if (e.getMessage().contains("PRIMARY")) {
|
||||
String message = e.getMessage();
|
||||
if (message.contains("PRIMARY")) {
|
||||
log.error("主键冲突 %s", recvdata.toJSONString());
|
||||
} else if (e.getMessage().contains("Duplicate entry")) {
|
||||
// 筛出主键
|
||||
String[] split = message.split("'");
|
||||
String id = split[1];
|
||||
savePrimary(id); // 记录冲突id
|
||||
} else if (message.contains("Duplicate entry")) {
|
||||
log.error("重复数据 %s", recvdata.toJSONString());
|
||||
} else {
|
||||
log.error(e.getMessage(), e);
|
||||
log.error(message, e);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
@ -673,6 +714,8 @@ public class SyncTaskService {
|
|||
|
||||
// 执行完成添加状态
|
||||
// Redis.use().set(redisKey,"1");
|
||||
// 保存任务id 避免重复执行
|
||||
savePrimary(current_supermarket_id + recvdata.getString("id")); // 任务编号
|
||||
|
||||
log.debug("recv 2 time: %s", System.currentTimeMillis() - st);
|
||||
return ret;
|
||||
|
|
@ -688,6 +731,25 @@ public class SyncTaskService {
|
|||
|
||||
}
|
||||
|
||||
public void savePrimary(String id){
|
||||
String redisKey = Config.dbprop.get("redis.basekey") + Const.REDIS_SEPARATE + SyncTask.tablename + Const.REDIS_SEPARATE + "Primary" + Const.REDIS_SEPARATE + id;
|
||||
|
||||
Redis.use().set(redisKey,id);
|
||||
|
||||
Redis.use().expire(redisKey, 3* 86400);
|
||||
|
||||
}
|
||||
|
||||
public boolean isCachePrimary(String id){
|
||||
String redisKey = Config.dbprop.get("redis.basekey") + Const.REDIS_SEPARATE + SyncTask.tablename + Const.REDIS_SEPARATE + "Primary" + Const.REDIS_SEPARATE + id;
|
||||
return Redis.use().exists(redisKey) ;
|
||||
}
|
||||
|
||||
public boolean saveData(String tablename,JSONObject o){
|
||||
// String redisKey = Config.dbprop.get("redis.basekey") + Const.REDIS_SEPARATE + SyncTask.tablename + Const.REDIS_SEPARATE + "Primary" + Const.REDIS_SEPARATE + id;
|
||||
// Redis.use().set(redisKey,id);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 过滤新增数据
|
||||
private void updataOrderTemp(String tablename, List<Record> list) {
|
||||
|
|
|
|||
|
|
@ -389,7 +389,8 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
Sysuser tokenuser
|
||||
) {
|
||||
try {
|
||||
if (model.checkDuplicate("phone")) {
|
||||
model.setDel(Const.LOGIC_DEL_VALID);
|
||||
if (model.checkDuplicate("phone","del")) {
|
||||
return Result.failed(false, "手机号已存在");
|
||||
}
|
||||
|
||||
|
|
@ -403,12 +404,13 @@ public class SysuserSyncService extends BaseSyncService {
|
|||
customer.setTexpayerName(texpayer_name);
|
||||
customer.setInvoiceType(invoice_type);
|
||||
customer.setCustomerTypeId(customer_type_id);
|
||||
customer.setDel(Const.LOGIC_DEL_VALID);
|
||||
|
||||
if (customer.checkDuplicate("name")) {
|
||||
if (customer.checkDuplicate("name","del")) {
|
||||
return Result.failed(false, "名称已存在");
|
||||
}
|
||||
|
||||
if (customer.checkDuplicate("texpayer_name")) {
|
||||
if (customer.checkDuplicate("texpayer_name","del")) {
|
||||
return Result.failed(false, "名称已存在");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import com.cowr.common.enums.OrderStateEnum;
|
|||
import com.cowr.common.enums.OrderTypeEnum;
|
||||
import com.cowr.common.utils.DateTimeUtil;
|
||||
import com.cowr.model.*;
|
||||
import com.cowr.service.ssjygl.Interceptor.UpdateOnlyListener;
|
||||
import com.cowr.service.ssjygl.supermarket.SupermarketSyncService;
|
||||
import com.cowr.service.ssjygl.synctask.SyncTaskService;
|
||||
import com.cowr.ssjygl.CacheData;
|
||||
|
|
@ -11,8 +12,6 @@ import com.cowr.ssjygl.invoice.receive.InvoiceReceiveService;
|
|||
import com.jfinal.kit.PropKit;
|
||||
import com.jfinal.kit.StrKit;
|
||||
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
||||
import com.jfinal.plugin.activerecord.Db;
|
||||
import com.jfinal.plugin.activerecord.IAtom;
|
||||
import com.jfinal.plugin.druid.DruidPlugin;
|
||||
import org.apache.poi.ss.usermodel.Row;
|
||||
import org.apache.poi.ss.usermodel.Sheet;
|
||||
|
|
|
|||
|
|
@ -8,8 +8,8 @@ print.vendorTaxId=91421125MA49GYYK2B
|
|||
start.trans.distance=5
|
||||
|
||||
#本地服务 和 云端服务 socket 通信
|
||||
#socketserver.enable=true
|
||||
#socketserver.port=21002
|
||||
socketserver.enable=true
|
||||
socketserver.port=21002
|
||||
|
||||
|
||||
endpoint=oss-cn-shenzhen.aliyuncs.com
|
||||
|
|
|
|||
Loading…
Reference in New Issue