dev
parent
efc7c2b866
commit
a8a54ac2b8
|
|
@ -19,6 +19,7 @@ public class Const {
|
|||
public static final double DEFAULT_LGTD = 115.265535; // 默认经度 浠水县
|
||||
public static final double DEFAULT_LTTD = 30.451867; // 默认维度 浠水县
|
||||
|
||||
public static final String TEMP_CODE_AGGR_STAT = "SMS_205434464"; // 累计销售汇总
|
||||
public static final String TEMP_CODE_DAY_STAT = "SMS_205430436"; // 日销售汇总
|
||||
public static final String TEMP_CODE_CUSTOMER_DAY_STAT = "SMS_205430478"; // 客户日销售汇总
|
||||
public static final String TEMP_CODE_PEIE = "SMS_203673037"; // 配额分配通知
|
||||
|
|
@ -33,5 +34,8 @@ public class Const {
|
|||
SMS_TEMP_MAP.put(TEMP_CODE_PEIE, "已经在${supermarket_name}分配了${weight}吨配额,请在${date}安排车辆前去运输。");
|
||||
SMS_TEMP_MAP.put(TEMP_CODE_DEPOSIT_SUCCESS, "${time}${customer_name}在浠水县长投环保有限公司的预存${amount}元,合计余额${surplus}元。");
|
||||
SMS_TEMP_MAP.put(TEMP_CODE_DEPOSIT_FAIL, "${time}${customer_name}在浠水县长投环保有限公司预存的${amount}元审核未通过,若有疑问请及时联系浠水县长投环保结算中心。");
|
||||
SMS_TEMP_MAP.put(TEMP_CODE_AGGR_STAT, "截至${time1}累计销售黄砂${aggr_weight}吨,共计${aggr_price}元,运输${aggr_cnt}辆次。" +
|
||||
"账户累计${aggr_total_price}元,其中预付费客户总余额${customer_total_surplus}元。" +
|
||||
"${time2}当日销售黄砂${total_weight}吨,共计${total_price}元,运输${total_cnt}辆次。");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ import java.util.List;
|
|||
public class SmsLogService extends BaseService {
|
||||
public static final SmsLogService me = new SmsLogService();
|
||||
|
||||
public Page<Record> find(PageParam pp, String stm, String etm, String phone, String name, Integer sendstatus, String sendcontent) {
|
||||
public Record find(PageParam pp, String stm, String etm, String phone, String name, Integer sendstatus, String sendcontent) {
|
||||
String selectsql = "select * ";
|
||||
String fromsql = "from sms_log t where 1=1 \n";
|
||||
List<Object> paraList = new ArrayList<>();
|
||||
|
|
@ -56,6 +56,7 @@ public class SmsLogService extends BaseService {
|
|||
paraList.add("%" + sendcontent + "%");
|
||||
}
|
||||
|
||||
String totalBillNumSql = "select sum(t.bill_num) total_bill_num " + fromsql;
|
||||
String totalRowSql = "select count(*) " + fromsql;
|
||||
String findSql = selectsql + fromsql;
|
||||
|
||||
|
|
@ -72,6 +73,16 @@ public class SmsLogService extends BaseService {
|
|||
findSql += " order by t.create_time desc ";
|
||||
}
|
||||
|
||||
return Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
|
||||
Page<Record> page = Db.paginateByFullSql(pp.getPage(), pp.getSize(), totalRowSql, findSql, paraList.toArray());
|
||||
|
||||
Record out = new Record();
|
||||
out.set("list", page.getList());
|
||||
out.set("pageNumber", page.getPageNumber());
|
||||
out.set("pageSize", page.getPageSize());
|
||||
out.set("totalPage", page.getTotalPage());
|
||||
out.set("totalRow", page.getTotalRow());
|
||||
out.set("totalBillNum", Db.queryInt(totalBillNumSql, paraList.toArray()));
|
||||
|
||||
return out;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class Config extends JFinalConfig {
|
|||
public static DeviceThread deviceThread = new DeviceThread();
|
||||
public static SocketIOService socketio = null;
|
||||
private static boolean client_run = true;
|
||||
public static final String CLINET_VERSION = "20201106";
|
||||
public static final String CLINET_VERSION = "20201111";
|
||||
|
||||
public static String getRootPath() {
|
||||
return PathKit.getWebRootPath()
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public class StatSmsJob implements Job {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* 每日销售汇总,含明细
|
||||
*/
|
||||
public void stat() {
|
||||
Date now = new Date();
|
||||
|
|
@ -176,6 +176,66 @@ public class StatSmsJob implements Job {
|
|||
SmsService.me.sendDayStat(sendobj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 累计销售汇总,含前日汇总
|
||||
*/
|
||||
public void statAggr() {
|
||||
Date now = new Date();
|
||||
Calendar c = Calendar.getInstance();
|
||||
c.setTime(now);
|
||||
c.add(Calendar.DAY_OF_MONTH, -1);
|
||||
|
||||
String predaytm = DateTimeUtil.sdf.get().format(c.getTime()); // 前一日
|
||||
String sendtmtext = DateTimeUtil.sdfymd.get().format(c.getTime());
|
||||
|
||||
String ordersql = "select count(t.sn) aggr_cnt, sum(t.weight) aggr_weight, sum(t.total_price) aggr_price from order_temp t where t.state = 5";
|
||||
String cusmersql = "select ifnull(sum(t.surplus), 0) customer_total_surplus from prepay_customer t";
|
||||
String daysql = "select count(t.sn) total_cnt, ifnull(sum(t.weight), 0) total_weight, ifnull(sum(t.total_price), 0) total_price from order_temp t\n" +
|
||||
" where t.state = 5\n" +
|
||||
" and t.create_time like '" + predaytm + "%'";
|
||||
|
||||
JSONObject obj = new JSONObject();
|
||||
Record orderobj = Db.findFirst(ordersql);
|
||||
Record customerobj = Db.findFirst(cusmersql);
|
||||
Record dayobj = Db.findFirst(daysql);
|
||||
|
||||
obj.put("time1", sendtmtext);
|
||||
obj.put("time2", sendtmtext);
|
||||
|
||||
if (
|
||||
orderobj == null
|
||||
|| customerobj == null
|
||||
|| dayobj == null
|
||||
|| orderobj.get("aggr_cnt") == null
|
||||
|| orderobj.get("aggr_weight") == null
|
||||
|| orderobj.get("aggr_price") == null
|
||||
|| customerobj.get("customer_total_surplus") == null
|
||||
|| dayobj.get("total_cnt") == null
|
||||
|| dayobj.get("total_weight") == null
|
||||
|| dayobj.get("total_price") == null
|
||||
) {
|
||||
log.error("sql 执行错误");
|
||||
log.error("1 执行错误 %s", orderobj == null ? null : orderobj.toJson());
|
||||
log.error("2 执行错误 %s", customerobj == null ? null : customerobj.toJson());
|
||||
log.error("3 执行错误 %s", dayobj == null ? null : dayobj.toJson());
|
||||
return;
|
||||
}
|
||||
|
||||
obj.put("aggr_cnt", orderobj.get("aggr_cnt"));
|
||||
obj.put("aggr_weight", String.format("%.2f万", orderobj.getBigDecimal("aggr_weight").divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP)));
|
||||
obj.put("aggr_price", String.format("%.2f万", orderobj.getBigDecimal("aggr_price").divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP)));
|
||||
|
||||
obj.put("customer_total_surplus", String.format("%.2f万", customerobj.getBigDecimal("customer_total_surplus").divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP)));
|
||||
obj.put("aggr_total_price", String.format("%.2f万", orderobj.getBigDecimal("aggr_price").add(customerobj.getBigDecimal("customer_total_surplus")).divide(new BigDecimal("10000"), 2, BigDecimal.ROUND_HALF_UP)));
|
||||
|
||||
obj.put("total_cnt", dayobj.get("total_cnt"));
|
||||
|
||||
obj.put("total_weight", String.format("%.2f", dayobj.getBigDecimal("total_weight")));
|
||||
obj.put("total_price", String.format("%.2f", dayobj.getBigDecimal("total_price")));
|
||||
|
||||
SmsService.me.sendStatAggr(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(JobExecutionContext jobExecutionContext) {
|
||||
if (Config.isDev()) {
|
||||
|
|
|
|||
|
|
@ -423,11 +423,11 @@ public class SmsService {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean sendDayStat(JSONObject obj) {
|
||||
public boolean sendStat(JSONObject obj, String temp_code, int type){
|
||||
try {
|
||||
Date now = new Date();
|
||||
|
||||
List<SmsNoticeContact> list = SmsNoticeContact.dao.find("select * from sms_notice_contact t where json_contains(t.type, \"1\")");
|
||||
List<SmsNoticeContact> list = SmsNoticeContact.dao.find("select * from sms_notice_contact t where json_contains(t.type, \"" + type + "\")");
|
||||
|
||||
if (list.isEmpty()) {
|
||||
log.debug("没有找到短信通知联系人");
|
||||
|
|
@ -439,7 +439,7 @@ public class SmsService {
|
|||
for (SmsNoticeContact contact : list) {
|
||||
String content = null;
|
||||
try {
|
||||
content = this.aliyunsms.generator(Const.SMS_TEMP_MAP.get(Const.TEMP_CODE_DAY_STAT), obj);
|
||||
content = this.aliyunsms.generator(Const.SMS_TEMP_MAP.get(temp_code), obj);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage(), e);
|
||||
return false;
|
||||
|
|
@ -451,7 +451,7 @@ public class SmsService {
|
|||
phone = "13627293906";
|
||||
}
|
||||
|
||||
String response = this.aliyunsms.send(phone, Const.TEMP_CODE_DAY_STAT, obj);
|
||||
String response = this.aliyunsms.send(phone, temp_code, obj);
|
||||
log.debug(response);
|
||||
|
||||
JSONObject ret = JSONObject.parseObject(response);
|
||||
|
|
@ -500,4 +500,12 @@ public class SmsService {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean sendDayStat(JSONObject obj) {
|
||||
return sendStat(obj, Const.TEMP_CODE_DAY_STAT, 1);
|
||||
}
|
||||
|
||||
public boolean sendStatAggr(JSONObject obj){
|
||||
return sendStat(obj, Const.TEMP_CODE_AGGR_STAT, 2);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue