|
@@ -72,14 +72,14 @@ public class DailyReimNightMsgWarnTask extends AbstractTask implements StopTask
|
|
|
Date beginDate = DateUtils.getDateByDayAndHour(-1, 21);
|
|
|
Date endDate = DateUtils.getDateByDayAndHour(0, 9);
|
|
|
|
|
|
- DynamicObjectCollection transDetailData = getTransDetailData(company, beginDate, endDate,null,0);
|
|
|
+ DynamicObjectCollection transDetailData = getTransDetailData(company, beginDate, endDate);
|
|
|
if(transDetailData == null || transDetailData.isEmpty()){
|
|
|
BizLog.log("没有符合条件的数据,不进行消息发送。");
|
|
|
return;
|
|
|
}
|
|
|
String timeFlag = DateUtils.formatDateDay(new Date());
|
|
|
for(DynamicObject transDetail : transDetailData){
|
|
|
- String uniqueKey = String.join("-", WARTYPE.getValue(),timeFlag,transDetail.getString("foppunit"));
|
|
|
+ String uniqueKey = String.join("-", WARTYPE.getValue(),timeFlag,transDetail.getString("billno"));
|
|
|
if(ORM.create().exists("nckd_msgwarnlog",new QFilter("nckd_unique_key", QCP.equals,uniqueKey).toArray())){
|
|
|
// 消息如果已发送,就不在执行
|
|
|
continue;
|
|
@@ -107,44 +107,42 @@ public class DailyReimNightMsgWarnTask extends AbstractTask implements StopTask
|
|
|
}
|
|
|
|
|
|
protected String getMcCenterMessage(String payerAccount , DynamicObject transDetail) {
|
|
|
- Long accountBankId = transDetail.getLong("faccountbankid");
|
|
|
- DynamicObject accountBank = QueryServiceHelper.queryOne("bd_accountbanks", "bankaccountnumber,bank.name",
|
|
|
- new QFilter("id", QCP.equals,accountBankId).toArray());
|
|
|
- return MsgWarnTemplateConstant.formatDailyMessage(
|
|
|
- payerAccount,
|
|
|
- accountBank.getString("bankaccountnumber"),
|
|
|
- accountBank.getString("bank.name"),
|
|
|
- transDetail.getString("foppunit"),
|
|
|
- transDetail.getString("totaltimes"),
|
|
|
- transDetail.getBigDecimal("totalamount").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString());
|
|
|
+ return MsgWarnTemplateConstant.formatDailyNightMessage(
|
|
|
+ transDetail.getString("oppunit"),
|
|
|
+ transDetail.getBigDecimal("debitamount").setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString(),
|
|
|
+ transDetail.getString("company.name"),
|
|
|
+ transDetail.getString("accountbank.bankaccountnumber"),
|
|
|
+ transDetail.getString("bank.name"),
|
|
|
+ transDetail.getString("description"),
|
|
|
+ DateUtils.formatDate(transDetail.getDate("biztime")));
|
|
|
}
|
|
|
|
|
|
- protected DynamicObjectCollection getTransDetailData(DynamicObject company , Date beginDate , Date endDate,BigDecimal maxAmount,int maxTimes){
|
|
|
- DataSet transDetailDataSet = getTransDetailDataSet(company, beginDate, endDate,maxAmount,maxTimes);
|
|
|
+ protected DynamicObjectCollection getTransDetailData(DynamicObject company , Date beginDate , Date endDate){
|
|
|
+ DataSet transDetailDataSet = getTransDetailDataSet(company, beginDate, endDate);
|
|
|
// 看报表与消息的兼容程度,再看怎么处理,暂时转成动态对象集合
|
|
|
return ORM.create().toPlainDynamicObjectCollection(transDetailDataSet.copy());
|
|
|
}
|
|
|
|
|
|
- protected DataSet getTransDetailDataSet(DynamicObject company , Date beginDate , Date endDate,BigDecimal maxAmount,int maxTimes){
|
|
|
- MainEntityType dt = EntityMetadataCache.getDataEntityType(BeiBeTransDetailConstant.ENTITYID);
|
|
|
- Long defualtAccountBankId = getDefualtAccountBankId(company);
|
|
|
+ protected DataSet getTransDetailDataSet(DynamicObject company , Date beginDate , Date endDate){
|
|
|
|
|
|
-
|
|
|
- String dbRouteKey = dt.getDBRouteKey();
|
|
|
- String nightSql = "SELECT faccountbankid, foppunit, COUNT(1) totaltimes, SUM(fdebitAmount) totalamount , 'times' source FROM t_bei_transdetail "
|
|
|
- + "WHERE fcompanyid = ? and faccountbankid = ? AND fbiztime >= ? AND fbiztime < ? "
|
|
|
- + "AND TRIM(foppunit) <> '' AND LENGTH(foppunit) <= 4 AND fdebitAmount != 0 "
|
|
|
- + "GROUP BY faccountbankid, foppunit";
|
|
|
-
|
|
|
- return DB.queryDataSet(this.getClass().getName(), DBRoute.of(dbRouteKey), nightSql,
|
|
|
- new Object[]{company.getPkValue(),defualtAccountBankId, beginDate, endDate});
|
|
|
- }
|
|
|
-
|
|
|
- protected Long getDefualtAccountBankId(DynamicObject company){
|
|
|
- DynamicObject accountBankBill = QueryServiceHelper.queryOne("bd_accountbanks", "id", new QFilter[]{
|
|
|
- new QFilter("company", QCP.equals, company.getPkValue()),
|
|
|
- new QFilter("isdefaultpay", QCP.equals, true)
|
|
|
- });
|
|
|
- return accountBankBill == null ? null : accountBankBill.getLong("id");
|
|
|
+ List<QFilter> filterList = new ArrayList<>();
|
|
|
+ filterList.add(new QFilter(BeiBeTransDetailConstant.KEY_COMPANY, QFilter.equals, company.getPkValue()));
|
|
|
+ if(beginDate != null){
|
|
|
+ filterList.add(new QFilter(BeiBeTransDetailConstant.KEY_BIZTIME, QFilter.large_equals, beginDate));
|
|
|
+ }
|
|
|
+ if(endDate != null){
|
|
|
+ filterList.add(new QFilter(BeiBeTransDetailConstant.KEY_BIZTIME, QFilter.less_than, endDate));
|
|
|
+ }
|
|
|
+ // 除默认付款付之外的付款
|
|
|
+ filterList.add(new QFilter("accountbank.isdefaultpay", QFilter.equals, true));
|
|
|
+ filterList.add(QFilter.isNotNull("oppunit"));
|
|
|
+ filterList.add(new QFilter("length(trim(oppunit))", QCP.large_than,0));
|
|
|
+ filterList.add(new QFilter("length(oppunit)", QCP.less_equals,4));
|
|
|
+
|
|
|
+ // 付款金额大于0
|
|
|
+ filterList.add(new QFilter(BeiBeTransDetailConstant.KEY_DEBITAMOUNT, QFilter.large_than, BigDecimal.ZERO));
|
|
|
+ return QueryServiceHelper.queryDataSet(this.getClass().getName() ,BeiBeTransDetailConstant.ENTITYID,
|
|
|
+ "id,billno,company.name,accountbank.name,accountbank.bankaccountnumber,bank.name,debitamount,oppunit,description,bizdate,biztime",
|
|
|
+ filterList.toArray(new QFilter[0]),"bizdate desc");
|
|
|
}
|
|
|
}
|