dev
parent
9f92675ba1
commit
b1fe10d98a
|
|
@ -3,6 +3,7 @@ package com.cowr.service.ssjygl.jobs;
|
||||||
import com.aliyun.oss.model.OSSObjectSummary;
|
import com.aliyun.oss.model.OSSObjectSummary;
|
||||||
import com.aliyun.oss.model.ObjectListing;
|
import com.aliyun.oss.model.ObjectListing;
|
||||||
import com.cowr.common.oss.OSSKit;
|
import com.cowr.common.oss.OSSKit;
|
||||||
|
import com.cowr.service.ssjygl.main.Config;
|
||||||
import com.jfinal.kit.Prop;
|
import com.jfinal.kit.Prop;
|
||||||
import com.jfinal.kit.PropKit;
|
import com.jfinal.kit.PropKit;
|
||||||
import com.jfinal.log.Log;
|
import com.jfinal.log.Log;
|
||||||
|
|
@ -17,6 +18,8 @@ public class CleanOSSBakFileJob implements Job {
|
||||||
|
|
||||||
public void execute() {
|
public void execute() {
|
||||||
try {
|
try {
|
||||||
|
// 黄州和浠水的本地备份库
|
||||||
|
// 保留近两天的
|
||||||
String[] prefixkeys = new String[]{"ssjy/xsx/dbbak/ssjy_xsx_", "ssjy/dbbak/ssjy"};
|
String[] prefixkeys = new String[]{"ssjy/xsx/dbbak/ssjy_xsx_", "ssjy/dbbak/ssjy"};
|
||||||
List<String> delkeys = new ArrayList<>();
|
List<String> delkeys = new ArrayList<>();
|
||||||
long st = System.currentTimeMillis();
|
long st = System.currentTimeMillis();
|
||||||
|
|
@ -49,7 +52,15 @@ public class CleanOSSBakFileJob implements Job {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext jobExecutionContext) {
|
public void execute(JobExecutionContext jobExecutionContext) {
|
||||||
|
try {
|
||||||
|
if (Config.isDev()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
execute();
|
execute();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package com.cowr.service.ssjygl.jobs;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSONObject;
|
import com.alibaba.fastjson.JSONObject;
|
||||||
import com.cowr.common.utils.DateTimeUtil;
|
import com.cowr.common.utils.DateTimeUtil;
|
||||||
|
import com.cowr.service.ssjygl.main.Config;
|
||||||
import com.cowr.service.ssjygl.main.SvrCacheData;
|
import com.cowr.service.ssjygl.main.SvrCacheData;
|
||||||
import com.cowr.service.ssjygl.sms.log.SmsService;
|
import com.cowr.service.ssjygl.sms.log.SmsService;
|
||||||
import com.jfinal.kit.StrKit;
|
import com.jfinal.kit.StrKit;
|
||||||
|
|
@ -98,13 +99,16 @@ public class StatSmsJob implements Job {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (smsmap.isEmpty()) {
|
if (smsmap.isEmpty()) {
|
||||||
log.debug("%s 可以发送的短信内容", predaytm);
|
log.debug("%s 没有可以发送的短信内容", predaytm);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SmsService.me.sendCustomerDayStat(smsmap);
|
SmsService.me.sendCustomerDayStat(smsmap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
public void stat() {
|
public void stat() {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
Calendar c = Calendar.getInstance();
|
Calendar c = Calendar.getInstance();
|
||||||
|
|
@ -121,11 +125,11 @@ public class StatSmsJob implements Job {
|
||||||
" from order_temp t\n" +
|
" from order_temp t\n" +
|
||||||
" where t.state = 5\n" +
|
" where t.state = 5\n" +
|
||||||
" and t.customer_id is not null\n" +
|
" and t.customer_id is not null\n" +
|
||||||
// " and t.create_time like ?\n" +
|
" and t.create_time like ?\n" +
|
||||||
" group by t.supermarket_id\n" +
|
" group by t.supermarket_id\n" +
|
||||||
" ) a on a.supermarket_id = t.id\n" +
|
" ) a on a.supermarket_id = t.id\n" +
|
||||||
" order by t.id";
|
" order by t.id";
|
||||||
List<Record> list = Db.find(sql);//, predaytm + "%");
|
List<Record> list = Db.find(sql, predaytm + "%");
|
||||||
|
|
||||||
if (list.isEmpty()) {
|
if (list.isEmpty()) {
|
||||||
log.debug("%s 没有销售数据", predaytm);
|
log.debug("%s 没有销售数据", predaytm);
|
||||||
|
|
@ -156,23 +160,38 @@ public class StatSmsJob implements Job {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (truck_num <= 0) {
|
||||||
|
log.debug("%s 无销售数据", sendtmtext);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String supermarket_detail = StrKit.join(supdetail, ",");
|
String supermarket_detail = StrKit.join(supdetail, ",");
|
||||||
|
|
||||||
sendobj.put("time", sendtmtext);
|
sendobj.put("time", sendtmtext);
|
||||||
|
sendobj.put("supermarket_count", list.size());
|
||||||
sendobj.put("weight", String.format("%.2f", weight));
|
sendobj.put("weight", String.format("%.2f", weight));
|
||||||
sendobj.put("total_price", String.format("%.2f", total_price));
|
sendobj.put("total_price", String.format("%.2f", total_price));
|
||||||
sendobj.put("truck_num", truck_num);
|
sendobj.put("truck_num", truck_num);
|
||||||
sendobj.put("supermarket_detail", supermarket_detail.substring(0, supermarket_detail.length() - 1));
|
sendobj.put("supermarket_detail", supermarket_detail.substring(0, supermarket_detail.length() - 1));
|
||||||
|
|
||||||
System.out.println(sendobj);
|
SmsService.me.sendDayStat(sendobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(JobExecutionContext jobExecutionContext) {
|
public void execute(JobExecutionContext jobExecutionContext) {
|
||||||
|
if (Config.isDev()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
statCustomer();
|
statCustomer();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
stat();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -294,8 +294,6 @@ public class Config extends JFinalConfig {
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
new StatSmsJob().stat();
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,8 +10,11 @@ import com.cowr.service.ssjygl.main.SvrCacheData;
|
||||||
import com.cowr.sms.AliyunSmsService;
|
import com.cowr.sms.AliyunSmsService;
|
||||||
import com.jfinal.kit.StrKit;
|
import com.jfinal.kit.StrKit;
|
||||||
import com.jfinal.log.Log;
|
import com.jfinal.log.Log;
|
||||||
|
import com.jfinal.plugin.activerecord.Db;
|
||||||
|
import com.jfinal.plugin.activerecord.IAtom;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.sql.SQLException;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public class SmsService {
|
public class SmsService {
|
||||||
|
|
@ -78,8 +81,9 @@ public class SmsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean sendBySysusers(List<Sysuser> users, String temp_code, JSONObject obj, String content, String relate_table, String relate_id){
|
private boolean sendBySysusers(List<Sysuser> users, String temp_code, JSONObject obj, String content, String relate_table, String relate_id) {
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
List<SmsLog> logs = new ArrayList<>();
|
||||||
|
|
||||||
for (Sysuser sysuser : users) {
|
for (Sysuser sysuser : users) {
|
||||||
try {
|
try {
|
||||||
|
|
@ -123,13 +127,26 @@ public class SmsService {
|
||||||
smslog.setRelateTable(relate_table);
|
smslog.setRelateTable(relate_table);
|
||||||
smslog.setRelateId(relate_id);
|
smslog.setRelateId(relate_id);
|
||||||
|
|
||||||
smslog.save();
|
logs.add(smslog);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
try {
|
||||||
|
return Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() {
|
||||||
|
int[] ret = Db.batchSave(logs, logs.size());
|
||||||
|
|
||||||
|
return ret.length == logs.size();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -295,20 +312,21 @@ public class SmsService {
|
||||||
/**
|
/**
|
||||||
* 客户每日汇总
|
* 客户每日汇总
|
||||||
* ${time}共计运输黄砂${weight}吨、运输车次${truck_num}辆次,合计${total_price}元。其中${supermarket_detail}元。。
|
* ${time}共计运输黄砂${weight}吨、运输车次${truck_num}辆次,合计${total_price}元。其中${supermarket_detail}元。。
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean sendCustomerDayStat(Map<Integer, JSONObject> smsmap){
|
public boolean sendCustomerDayStat(Map<Integer, JSONObject> smsmap) {
|
||||||
if(smsmap.isEmpty()){
|
if (smsmap.isEmpty()) {
|
||||||
log.debug("发送对象没有内容");
|
log.debug("发送对象没有内容");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<String> ids = new ArrayList<>();
|
List<String> ids = new ArrayList<>();
|
||||||
for(Integer k : smsmap.keySet()){
|
for (Integer k : smsmap.keySet()) {
|
||||||
ids.add("?");
|
ids.add("?");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ids.isEmpty()){
|
if (ids.isEmpty()) {
|
||||||
log.debug("没有有效的id");
|
log.debug("没有有效的id");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -323,21 +341,23 @@ public class SmsService {
|
||||||
}
|
}
|
||||||
|
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
|
List<SmsLog> logs = new ArrayList<>();
|
||||||
|
|
||||||
for (Sysuser sysuser : users) {
|
for (Sysuser sysuser : users) {
|
||||||
try {
|
try {
|
||||||
Integer customer_id = sysuser.getEntityId();
|
Integer customer_id = sysuser.getEntityId();
|
||||||
|
|
||||||
if(!smsmap.containsKey(customer_id)){
|
if (!smsmap.containsKey(customer_id)) {
|
||||||
log.debug("没有找到 %s 关联的发送内容", customer_id);
|
log.debug("没有找到 %s 关联的发送内容", customer_id);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
String phone = sysuser.getPhone();
|
String phone = sysuser.getPhone();
|
||||||
|
|
||||||
if (Config.isDev()) {
|
// 客户的这个,先全部往 13627293906 这里发,看看运行情况
|
||||||
|
// if (Config.isDev()) {
|
||||||
phone = "13627293906";
|
phone = "13627293906";
|
||||||
}
|
// }
|
||||||
|
|
||||||
log.debug("给 %s 发送短信", phone);
|
log.debug("给 %s 发送短信", phone);
|
||||||
|
|
||||||
|
|
@ -382,12 +402,103 @@ public class SmsService {
|
||||||
smslog.setRelateTable(Customer.tablename);
|
smslog.setRelateTable(Customer.tablename);
|
||||||
smslog.setRelateId(customer_id.toString());
|
smslog.setRelateId(customer_id.toString());
|
||||||
|
|
||||||
smslog.save();
|
logs.add(smslog);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error(e.getMessage(), e);
|
log.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
try {
|
||||||
|
return Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() {
|
||||||
|
int[] ret = Db.batchSave(logs, logs.size());
|
||||||
|
|
||||||
|
return ret.length == logs.size();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean sendDayStat(JSONObject obj) {
|
||||||
|
try {
|
||||||
|
Date now = new Date();
|
||||||
|
|
||||||
|
List<SmsNoticeContact> list = SmsNoticeContact.dao.find("select * from sms_notice_contact t where json_contains(t.type, \"1\")");
|
||||||
|
|
||||||
|
if (list.isEmpty()) {
|
||||||
|
log.debug("没有找到短信通知联系人");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<SmsLog> logs = new ArrayList<>();
|
||||||
|
|
||||||
|
for (SmsNoticeContact contact : list) {
|
||||||
|
String content = null;
|
||||||
|
try {
|
||||||
|
content = this.aliyunsms.generator(Const.SMS_TEMP_MAP.get(Const.TEMP_CODE_DAY_STAT), obj);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String phone = contact.getPhone();
|
||||||
|
|
||||||
|
if (Config.isDev()) {
|
||||||
|
phone = "13627293906";
|
||||||
|
}
|
||||||
|
|
||||||
|
String response = this.aliyunsms.send(phone, Const.TEMP_CODE_DAY_STAT, obj);
|
||||||
|
log.debug(response);
|
||||||
|
|
||||||
|
JSONObject ret = JSONObject.parseObject(response);
|
||||||
|
|
||||||
|
SmsLog smslog = new SmsLog();
|
||||||
|
smslog.setId(StrKit.getRandomUUID());
|
||||||
|
smslog.setPhone(phone);
|
||||||
|
smslog.setName(contact.getName());
|
||||||
|
smslog.setContent(obj.toJSONString());
|
||||||
|
smslog.setCreateTime(now);
|
||||||
|
smslog.setSendcontent(content);
|
||||||
|
|
||||||
|
if (ret.containsKey("BizId")) {
|
||||||
|
smslog.setBizid(ret.getString("BizId"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.containsKey("Code")) {
|
||||||
|
smslog.setCode(ret.getString("Code"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.containsKey("RequestId")) {
|
||||||
|
smslog.setRequestid(ret.getString("RequestId"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ret.containsKey("RequestId")) {
|
||||||
|
smslog.setRequestid(ret.getString("RequestId"));
|
||||||
|
}
|
||||||
|
|
||||||
|
smslog.setRelateTable("stat");
|
||||||
|
smslog.setRelateId(null);
|
||||||
|
|
||||||
|
logs.add(smslog);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Db.tx(new IAtom() {
|
||||||
|
@Override
|
||||||
|
public boolean run() throws SQLException {
|
||||||
|
int[] ret = Db.batchSave(logs, logs.size());
|
||||||
|
|
||||||
|
return ret.length == logs.size();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error(e.getMessage(), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,8 @@ public class SmsNoticeContactService extends BaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model.setType(JSONArray.toJSONString(list)); // 将 ["1"] 转为 [1]
|
||||||
|
|
||||||
Result ret = super.save(model, sysuser);
|
Result ret = super.save(model, sysuser);
|
||||||
|
|
||||||
if(ret.getCode() == Result.SUCCESS){
|
if(ret.getCode() == Result.SUCCESS){
|
||||||
|
|
@ -70,6 +72,8 @@ public class SmsNoticeContactService extends BaseService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
model.setType(JSONArray.toJSONString(list)); // 将 ["1"] 转为 [1]
|
||||||
|
|
||||||
Result ret = super.update(model, sysuser);
|
Result ret = super.update(model, sysuser);
|
||||||
|
|
||||||
if(ret.getCode() == Result.SUCCESS){
|
if(ret.getCode() == Result.SUCCESS){
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ cleanossbakfile.job=com.cowr.service.ssjygl.jobs.CleanOSSBakFileJob
|
||||||
cleanossbakfile.cron= 1 0 1 * * ?
|
cleanossbakfile.cron= 1 0 1 * * ?
|
||||||
cleanossbakfile.enable=true
|
cleanossbakfile.enable=true
|
||||||
|
|
||||||
# 每天 8 点统计发送前一天各客户销售情况
|
# 每天 8 点统计发送前一天各销售情况,包含了客户信息汇总(发给客户)和总的汇总(发给公司)
|
||||||
statsms.job=com.cowr.service.ssjygl.jobs.StatSmsJob
|
statsms.job=com.cowr.service.ssjygl.jobs.StatSmsJob
|
||||||
statsms.cron= 0 0 8 * * ?
|
statsms.cron= 0 0 8 * * ?
|
||||||
statsms.enable=false
|
statsms.enable=false
|
||||||
Loading…
Reference in New Issue