dev
parent
d26243b2b6
commit
8a6ad81935
|
|
@ -78,4 +78,14 @@ public class SyncTask extends BaseSyncTask<SyncTask> {
|
||||||
this.setIncrementData(JSONObject.toJSONString(_increment_data));
|
this.setIncrementData(JSONObject.toJSONString(_increment_data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SyncTask clone(){
|
||||||
|
SyncTask out = super.clone();
|
||||||
|
out._save_data = (JSONObject) this._save_data.clone();
|
||||||
|
out._update_data = (JSONObject) this._update_data.clone();
|
||||||
|
out._delete_data = (JSONObject) this._delete_data.clone();
|
||||||
|
out._increment_data = (JSONObject) this._increment_data.clone();
|
||||||
|
|
||||||
|
return out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -694,4 +694,40 @@ public class OrderclusterService extends BaseService {
|
||||||
|
|
||||||
return out == null ? new BigDecimal(0) : out;
|
return out == null ? new BigDecimal(0) : out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按客户查询未完成的配额量
|
||||||
|
*
|
||||||
|
* @param customer_id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public BigDecimal getOverTotalPriceByCustomer(int customer_id) {
|
||||||
|
String sql = "select sum(a.total_price) total_price from ( \n" +
|
||||||
|
" select t.ordercluster_id, sum(t.weight) weight, sum(t.total_price) total_price from order_sale t \n" +
|
||||||
|
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
||||||
|
" where t.state = ? \n" +
|
||||||
|
" and o.state < ? \n" +
|
||||||
|
" and o.customer_id = ? \n" +
|
||||||
|
" group by t.ordercluster_id \n" +
|
||||||
|
" \n" +
|
||||||
|
" union \n" +
|
||||||
|
" select t.ordercluster_id, sum(t.weight) weight, sum(t.total_price) total_price from order_temp t \n" +
|
||||||
|
" left join ordercluster o on o.id = t.ordercluster_id\n" +
|
||||||
|
" where t.state = ? \n" +
|
||||||
|
" and o.state < ? \n" +
|
||||||
|
" and o.customer_id = ? \n" +
|
||||||
|
" group by t.ordercluster_id \n" +
|
||||||
|
") a \n" +
|
||||||
|
"group by a.ordercluster_id ";
|
||||||
|
|
||||||
|
BigDecimal out = Db.queryBigDecimal(
|
||||||
|
sql,
|
||||||
|
OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid(), customer_id,
|
||||||
|
OrderStateEnum.RECEIVED.getStateid(), OrderStateEnum.RECEIVED.getStateid(), customer_id
|
||||||
|
);
|
||||||
|
|
||||||
|
return out == null ? new BigDecimal(0) : out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 当前配额指定的客户、超市、品类对应的单价
|
||||||
BigDecimal unitprice = CustomerSupermarketProductService.me.getUnitPrice(customer_id, supermarket_id, product.getId());
|
BigDecimal unitprice = CustomerSupermarketProductService.me.getUnitPrice(customer_id, supermarket_id, product.getId());
|
||||||
if (unitprice == null) {
|
if (unitprice == null) {
|
||||||
return Result.failed("未配置商品单价");
|
return Result.failed("未配置商品单价");
|
||||||
|
|
@ -123,7 +124,7 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
List<Record> undonlist = OrderclusterService.me.undonlist(supermarket_id, customer_id);
|
List<Record> undonlist = OrderclusterService.me.undonlist(supermarket_id, customer_id);
|
||||||
|
|
||||||
if (undonlist != null && !undonlist.isEmpty()) {
|
if (undonlist != null && !undonlist.isEmpty()) {
|
||||||
BigDecimal plan_total_weight = new BigDecimal(total_weight); // 本次配额重量
|
BigDecimal plan_total_price = new BigDecimal(total_weight).multiply(unitprice); // 本次配额总价格
|
||||||
|
|
||||||
for (Record record : undonlist) {
|
for (Record record : undonlist) {
|
||||||
Date record_cutoff_time = record.getDate("cutoff_time");
|
Date record_cutoff_time = record.getDate("cutoff_time");
|
||||||
|
|
@ -132,16 +133,16 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
if (record_cutoff_time.getTime() == cutoff_time.getTime()) {
|
if (record_cutoff_time.getTime() == cutoff_time.getTime()) {
|
||||||
return Result.failedstr("客户[%s][%s]在砂站[%s]还有未完成的配额", customerObj.getName(), DateTimeUtil.sdfymd.get().format(cutoff_time), SvrCacheData.SUP_CACHE.get(supermarket_id).getName());
|
return Result.failedstr("客户[%s][%s]在砂站[%s]还有未完成的配额", customerObj.getName(), DateTimeUtil.sdfymd.get().format(cutoff_time), SvrCacheData.SUP_CACHE.get(supermarket_id).getName());
|
||||||
} else {
|
} else {
|
||||||
// 累加总量
|
// 累加总价
|
||||||
plan_total_weight = plan_total_weight.add(record.getBigDecimal("total_weight"));
|
plan_total_price = plan_total_price.add(record.getBigDecimal("total_weight").multiply(record.getBigDecimal("unit_price")));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按客户统计已完成量
|
// 按客户统计已完成量
|
||||||
BigDecimal overweight = OrderclusterService.me.getOverWeightByCustomer(customer_id); // 按客户找集团订单已完成量
|
BigDecimal overTotalPrice = OrderclusterService.me.getOverTotalPriceByCustomer(customer_id); // 按客户找集团订单已完成量
|
||||||
|
|
||||||
if (plan_total_weight.subtract(overweight).multiply(unitprice).compareTo(prepayCustomer.getSurplus()) > 0) {
|
if (plan_total_price.subtract(overTotalPrice).compareTo(prepayCustomer.getSurplus()) > 0) {
|
||||||
return Result.failedstr("剩余总配额 %.2f,客户余额(%.2f)不足", plan_total_weight.subtract(overweight), prepayCustomer.getSurplus());
|
return Result.failedstr("剩余总配额 %.2f元,客户余额(%.2f元)不足", plan_total_price.subtract(overTotalPrice), prepayCustomer.getSurplus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -730,22 +731,22 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
List<Record> undonlist = OrderclusterService.me.undonlist(oldobj.getCustomerId());
|
List<Record> undonlist = OrderclusterService.me.undonlist(oldobj.getCustomerId());
|
||||||
|
|
||||||
if (undonlist != null && !undonlist.isEmpty()) {
|
if (undonlist != null && !undonlist.isEmpty()) {
|
||||||
BigDecimal plan_total_weight = model.getTotalWeight();
|
BigDecimal plan_total_price = model.getTotalWeight().multiply(oldobj.getUnitPrice());
|
||||||
|
|
||||||
for (Record record : undonlist) {
|
for (Record record : undonlist) {
|
||||||
if (model.getId().equals(record.getInt("id"))) {
|
if (model.getId().equals(record.getInt("id"))) {
|
||||||
continue; // 当前修改的记录已经做为初始值了,不再累计
|
continue; // 当前修改的记录已经做为初始值了,不再累计
|
||||||
}
|
}
|
||||||
|
|
||||||
// 累加总量
|
// 累加总价
|
||||||
plan_total_weight = plan_total_weight.add(record.getBigDecimal("total_weight"));
|
plan_total_price = plan_total_price.add(record.getBigDecimal("total_weight").multiply(record.getBigDecimal("unit_price")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按客户统计已完成量
|
// 按客户统计已完成量
|
||||||
BigDecimal overweight = OrderclusterService.me.getOverWeightByCustomer(oldobj.getCustomerId()); // 按客户找集团订单已完成量
|
BigDecimal overTotalPrice = OrderclusterService.me.getOverTotalPriceByCustomer(oldobj.getCustomerId()); // 按客户找集团订单已完成量
|
||||||
|
|
||||||
if (plan_total_weight.subtract(overweight).multiply(oldobj.getUnitPrice()).compareTo(prepayCustomer.getSurplus()) > 0) {
|
if (plan_total_price.subtract(overTotalPrice).compareTo(prepayCustomer.getSurplus()) > 0) {
|
||||||
return Result.failedstr("计划总配额 %.2f,超过了客户余额(%.2f)", plan_total_weight.subtract(overweight), prepayCustomer.getSurplus());
|
return Result.failedstr("剩余总配额 %.2f元,客户余额(%.2f元)不足", plan_total_price.subtract(overTotalPrice), prepayCustomer.getSurplus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -957,22 +958,22 @@ public class OrderclusterSyncService extends BaseSyncService {
|
||||||
List<Record> undonlist = OrderclusterService.me.undonlist(oldobj.getCustomerId());
|
List<Record> undonlist = OrderclusterService.me.undonlist(oldobj.getCustomerId());
|
||||||
|
|
||||||
if (undonlist != null && !undonlist.isEmpty()) {
|
if (undonlist != null && !undonlist.isEmpty()) {
|
||||||
BigDecimal plan_total_weight = total_weight;
|
BigDecimal plan_total_price = total_weight.multiply(oldobj.getUnitPrice());
|
||||||
|
|
||||||
for (Record record : undonlist) {
|
for (Record record : undonlist) {
|
||||||
if (oldobj.getId().equals(record.getInt("id"))) {
|
if (oldobj.getId().equals(record.getInt("id"))) {
|
||||||
continue; // 当前修改的记录已经做为初始值了,不再累计
|
continue; // 当前修改的记录已经做为初始值了,不再累计
|
||||||
}
|
}
|
||||||
|
|
||||||
// 累加总量
|
// 累加总价
|
||||||
plan_total_weight = plan_total_weight.add(record.getBigDecimal("total_weight"));
|
plan_total_price = plan_total_price.add(record.getBigDecimal("total_weight").multiply(record.getBigDecimal("unit_price")));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 按客户统计已完成量
|
// 按客户统计已完成量
|
||||||
BigDecimal overweight = OrderclusterService.me.getOverWeightByCustomer(oldobj.getCustomerId()); // 按客户找集团订单已完成量
|
BigDecimal overTotalPrice = OrderclusterService.me.getOverTotalPriceByCustomer(oldobj.getCustomerId()); // 按客户找集团订单已完成量
|
||||||
|
|
||||||
if (plan_total_weight.subtract(overweight).multiply(oldobj.getUnitPrice()).compareTo(prepayCustomer.getSurplus()) > 0) {
|
if (plan_total_price.subtract(overTotalPrice).compareTo(prepayCustomer.getSurplus()) > 0) {
|
||||||
return Result.failedstr("计划总配额 %.2f,超过了客户余额(%.2f)", plan_total_weight.subtract(overweight), prepayCustomer.getSurplus());
|
return Result.failedstr("剩余总配额 %.2f元,客户余额(%.2f元)不足", plan_total_price.subtract(overTotalPrice), prepayCustomer.getSurplus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -270,6 +270,8 @@ public class SyncTaskService {
|
||||||
try {
|
try {
|
||||||
JSONArray saveauthlics = new JSONArray(); // 授权车牌号需要推送更新到其他砂站
|
JSONArray saveauthlics = new JSONArray(); // 授权车牌号需要推送更新到其他砂站
|
||||||
JSONArray deleteauthlics = new JSONArray();
|
JSONArray deleteauthlics = new JSONArray();
|
||||||
|
List<SyncTask> sts = new ArrayList<>();
|
||||||
|
Date now = new Date();
|
||||||
|
|
||||||
if (save_data != null && !save_data.isEmpty()) {
|
if (save_data != null && !save_data.isEmpty()) {
|
||||||
for (String tablename : save_data.keySet()) {
|
for (String tablename : save_data.keySet()) {
|
||||||
|
|
@ -283,10 +285,39 @@ public class SyncTaskService {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
synctask.setCreateTime(now);
|
||||||
|
|
||||||
for (int i = 0; i < arr.size(); i++) {
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
JSONObject obj = arr.getJSONObject(i);
|
JSONObject obj = arr.getJSONObject(i);
|
||||||
|
|
||||||
list.add(new Record().setColumns(obj.getInnerMap()));
|
list.add(new Record().setColumns(obj.getInnerMap()));
|
||||||
|
|
||||||
|
// 分发黑名单
|
||||||
|
if(Blacklist.dao.getTablename().equals(tablename)) {
|
||||||
|
Blacklist blacklist = new Blacklist();
|
||||||
|
blacklist._setAttrs(obj.getInnerMap());
|
||||||
|
synctask.addSaveData(blacklist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分发黑名单
|
||||||
|
if(Blacklist.dao.getTablename().equals(tablename)){
|
||||||
|
for (Map.Entry<Integer, Supermarket> entry : SvrCacheData.SUP_CACHE.entrySet()) {
|
||||||
|
Supermarket supermarket = entry.getValue();
|
||||||
|
|
||||||
|
// 只对已经部署了客户端的砂站同步数据
|
||||||
|
// 从下面上报的数据,再广播出去
|
||||||
|
if (supermarket.getIsdeploy() == 0 || supermarket.getId() == current_supermarket_id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncTask newsynctask = synctask.clone();
|
||||||
|
newsynctask.setId(StrKit.getRandomUUID());
|
||||||
|
newsynctask.setSupermarketId(supermarket.getId());
|
||||||
|
|
||||||
|
sts.add(newsynctask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] ret = Db.batchSave(tablename, list, list.size());
|
int[] ret = Db.batchSave(tablename, list, list.size());
|
||||||
|
|
@ -320,10 +351,39 @@ public class SyncTaskService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SyncTask synctask = new SyncTask();
|
||||||
|
synctask.setCreateTime(now);
|
||||||
|
|
||||||
for (int i = 0; i < arr.size(); i++) {
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
JSONObject obj = arr.getJSONObject(i);
|
JSONObject obj = arr.getJSONObject(i);
|
||||||
|
|
||||||
list.add(new Record().setColumns(obj.getInnerMap()));
|
list.add(new Record().setColumns(obj.getInnerMap()));
|
||||||
|
|
||||||
|
// 分发黑名单
|
||||||
|
if(Blacklist.dao.getTablename().equals(tablename)) {
|
||||||
|
Blacklist blacklist = new Blacklist();
|
||||||
|
blacklist._setAttrs(obj.getInnerMap());
|
||||||
|
synctask.addUpdateData(blacklist);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分发黑名单
|
||||||
|
if(Blacklist.dao.getTablename().equals(tablename)){
|
||||||
|
for (Map.Entry<Integer, Supermarket> entry : SvrCacheData.SUP_CACHE.entrySet()) {
|
||||||
|
Supermarket supermarket = entry.getValue();
|
||||||
|
|
||||||
|
// 只对已经部署了客户端的砂站同步数据
|
||||||
|
// 从下面上报的数据,再广播出去
|
||||||
|
if (supermarket.getIsdeploy() == 0 || supermarket.getId() == current_supermarket_id) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SyncTask newsynctask = synctask.clone();
|
||||||
|
newsynctask.setId(StrKit.getRandomUUID());
|
||||||
|
newsynctask.setSupermarketId(supermarket.getId());
|
||||||
|
|
||||||
|
sts.add(newsynctask);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int[] ret = Db.batchUpdate(tablename, pks, list, list.size());
|
int[] ret = Db.batchUpdate(tablename, pks, list, list.size());
|
||||||
|
|
@ -368,8 +428,6 @@ public class SyncTaskService {
|
||||||
// 对指定表的固定字段进行 增加或者减少
|
// 对指定表的固定字段进行 增加或者减少
|
||||||
// 2020-10-10 只在修改 PrepayCustomer 中的余额时需要用到
|
// 2020-10-10 只在修改 PrepayCustomer 中的余额时需要用到
|
||||||
if (increment_data != null && !increment_data.isEmpty()) {
|
if (increment_data != null && !increment_data.isEmpty()) {
|
||||||
List<SyncTask> sts = new ArrayList<>();
|
|
||||||
Date now = new Date();
|
|
||||||
|
|
||||||
for (String tablename : increment_data.keySet()) {
|
for (String tablename : increment_data.keySet()) {
|
||||||
JSONObject data = increment_data.getJSONObject(tablename);
|
JSONObject data = increment_data.getJSONObject(tablename);
|
||||||
|
|
@ -432,6 +490,7 @@ public class SyncTaskService {
|
||||||
|
|
||||||
sts.add(synctask);
|
sts.add(synctask);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!sts.isEmpty()) {
|
if (!sts.isEmpty()) {
|
||||||
int[] ret = Db.batchSave(sts, sts.size());
|
int[] ret = Db.batchSave(sts, sts.size());
|
||||||
|
|
@ -447,7 +506,6 @@ public class SyncTaskService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!saveauthlics.isEmpty() && !deleteauthlics.isEmpty()) {
|
if (!saveauthlics.isEmpty() && !deleteauthlics.isEmpty()) {
|
||||||
return recvAuthLicense(saveauthlics, deleteauthlics, current_supermarket_id);
|
return recvAuthLicense(saveauthlics, deleteauthlics, current_supermarket_id);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
# 日志级别
|
# 日志级别
|
||||||
log4j.rootLogger=DEBUG, console, fileDebug, fileInfo
|
log4j.rootLogger=DEBUG, console, fileDebug, fileError
|
||||||
log4j.rootLogger.encoding=UTF-8
|
log4j.rootLogger.encoding=UTF-8
|
||||||
log4j.logger.com.cowr=DEBUG
|
log4j.logger.com.cowr=DEBUG
|
||||||
log4j.logger.com.jfinal=DEBUG
|
log4j.logger.com.jfinal=DEBUG
|
||||||
|
|
@ -33,16 +33,16 @@ log4j.appender.fileDebug.MaxBackupIndex=1000
|
||||||
log4j.appender.fileDebug.layout=org.apache.log4j.PatternLayout
|
log4j.appender.fileDebug.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.fileDebug.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss.SSS} %p %t %F %L - %M %m %X{traceId}%n
|
log4j.appender.fileDebug.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss.SSS} %p %t %F %L - %M %m %X{traceId}%n
|
||||||
|
|
||||||
# 输出到文件 info
|
# 输出到文件 error
|
||||||
log4j.appender.fileInfo=org.apache.log4j.RollingFileAppender
|
log4j.appender.fileError=org.apache.log4j.RollingFileAppender
|
||||||
log4j.appender.fileInfo.encoding=UTF-8
|
log4j.appender.fileError.encoding=UTF-8
|
||||||
log4j.appender.fileInfo.Append=true
|
log4j.appender.fileError.Append=true
|
||||||
log4j.appender.fileInfo.Threshold=INFO
|
log4j.appender.fileError.Threshold=ERROR
|
||||||
log4j.appender.fileInfo.File=../logs/ssjygl.xsx.service.info.log
|
log4j.appender.fileError.File=../logs/ssjygl.xsx.service.error.log
|
||||||
log4j.appender.fileInfo.MaxFileSize=10MB
|
log4j.appender.fileError.MaxFileSize=10MB
|
||||||
log4j.appender.fileInfo.MaxBackupIndex=500
|
log4j.appender.fileError.MaxBackupIndex=500
|
||||||
log4j.appender.fileInfo.layout=org.apache.log4j.PatternLayout
|
log4j.appender.fileError.layout=org.apache.log4j.PatternLayout
|
||||||
log4j.appender.fileInfo.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss.SSS} %p %t %F %L - %M %m %n
|
log4j.appender.fileError.layout.ConversionPattern=%-d{yyyy-MM-dd HH:mm:ss.SSS} %p %t %F %L - %M %m %n
|
||||||
|
|
||||||
# ConversionPattern参数的格式含义
|
# ConversionPattern参数的格式含义
|
||||||
# 格式名 含义
|
# 格式名 含义
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue