收款单未推送sap的定时发送消息
This commit is contained in:
parent
8e95710c66
commit
c87261361a
|
|
@ -42,7 +42,7 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
//TODO 查询当月已审核收款类资金计划(收款不区分公司,当月应只有一个)
|
||||
//查询当月已审核收款类资金计划(收款不区分公司,当月应只有一个)
|
||||
QFilter qFilter = new QFilter("billstatus", QCP.equals, "C");//单据状态
|
||||
qFilter.and("name", QCP.equals, " 编制表");//报表名称
|
||||
qFilter.and("enable", QCP.equals, "1");//是否可用
|
||||
|
|
@ -51,7 +51,7 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
if(collection.length > 0){
|
||||
//调用SAP应收已清接口,按照公司、月份、计划科目汇总金额
|
||||
Map<String, BigDecimal> acctamountMap = getSapARClearedData();
|
||||
if(acctamountMap == null){
|
||||
if(acctamountMap == null || acctamountMap.isEmpty()){
|
||||
return;
|
||||
}
|
||||
ReportDataSDKService reportService = new ReportDataSDKService();//报表服务,用于写入或者查询报表数据
|
||||
|
|
@ -132,9 +132,10 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
//日期格式
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||
JSONArray IT_LIST = new JSONArray();
|
||||
String duedate_starts = sdf.format(lastMonthFirstDay);//上月1号
|
||||
String duedate_ends = sdf.format(new Date());//当前日期
|
||||
addFilterCondition(IT_LIST, "BUDAT", duedate_starts, duedate_ends);//过账日期-上月和当前月
|
||||
String duedate_starts = sdf.format(lastMonthFirstDay);//TODO 上月1号-取出纳模块的当前期间的1号
|
||||
String duedate_ends = sdf.format(new Date());//系统当前日期
|
||||
// addFilterCondition(IT_LIST, "BUDAT", duedate_starts, duedate_ends);//过账日期-上月和当前月
|
||||
addFilterCondition(IT_LIST, "BUDAT", "2024-01-01", "2024-12-31");//TODO 测试指定日期
|
||||
JSONObject sapresult = SapUtils.sapARClearedDataAPI(IT_LIST, "FundPlanCollectionTask");
|
||||
if(sapresult != null){
|
||||
JSONObject data = sapresult.getJSONObject("data");
|
||||
|
|
@ -156,12 +157,16 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
if(JhzjUtils.isEmpty(months)){
|
||||
continue;
|
||||
}
|
||||
accountnum = xdMembersubjectNumber(sapresult);
|
||||
if(JhzjUtils.isEmpty(accountnum)){
|
||||
continue;
|
||||
}
|
||||
months = JhzjUtils.getFundPeriodBySAPDate(months);
|
||||
//根据品牌和事业部关系,将该笔金额归属到事业部上
|
||||
ppsybinfo = BusinessDataServiceHelper.loadSingleFromCache(ppsybName,new QFilter[]{new QFilter("shjh_pp", QCP.equals, productnum)});
|
||||
if(ppsybinfo != null){
|
||||
sybnum = ppsybinfo.getDynamicObject("shjh_division").getString("number");
|
||||
mapkey = sybnum+months;
|
||||
mapkey = sybnum+months+accountnum;
|
||||
if(acctamountMap.containsKey(mapkey)){
|
||||
acctamountMap.put(mapkey, JhzjUtils.addTwoAmount(amount,acctamountMap.get(mapkey)));
|
||||
}else{
|
||||
|
|
@ -170,10 +175,6 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
}else{
|
||||
//TODO 如果品牌没有对应的事业部时,数据放哪里?
|
||||
}
|
||||
// sapresult.getString("BUKRS");//公司编号
|
||||
// sapresult.getString("WAERS");//币别编号
|
||||
// sapresult.getString("HKONT");//科目编号
|
||||
// sapresult.getString("RSTGR");//付款原因代码
|
||||
}
|
||||
return acctamountMap;
|
||||
}
|
||||
|
|
@ -182,73 +183,148 @@ public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
|||
}
|
||||
|
||||
//根据sap的应收已清数据获取对应的资金计划科目编号
|
||||
private String xdMembersubjectNumber(DynamicObject bill){
|
||||
private String xdMembersubjectNumber(JSONObject sapresult){
|
||||
//公司范围_多选基础资料
|
||||
// DynamicObject openorg = bill.getDynamicObject("openorg");
|
||||
// if (null != openorg) {
|
||||
// Long orgid = openorg.getLong("id");
|
||||
// QFilter q1 = new QFilter("shjh_companys.fbasedataid", QCP.equals, orgid);
|
||||
// qFilter = qFilter.and(q1);
|
||||
// }
|
||||
//业务大类
|
||||
// DynamicObject shjhBizbig = bill.getDynamicObject("shjh_bizebig");
|
||||
// if (null != shjhBizbig) {
|
||||
// Long shjhBizbigid = shjhBizbig.getLong("id");
|
||||
// QFilter q2 = new QFilter("shjh_bizbig.fbasedataid", QCP.equals, shjhBizbigid);
|
||||
// qFilter = qFilter.and(q2);
|
||||
// }
|
||||
//业务小类
|
||||
// DynamicObject shjhbizsmall = bill.getDynamicObject("shjh_bizsmall");
|
||||
// if (null != shjhbizsmall) {
|
||||
// Long shjhbizsmallid = shjhbizsmall.getLong("id");
|
||||
// QFilter q3 = new QFilter("shjh_bizsmall.fbasedataid", QCP.equals, shjhbizsmallid);
|
||||
// qFilter = qFilter.and(q3);
|
||||
// }
|
||||
//成本中心 shjh_costcenter
|
||||
// DynamicObject shjhCostcenter = bill.getDynamicObject("shjh_costcenter");
|
||||
// if (null != shjhCostcenter) {
|
||||
// Long costcenterid = shjhCostcenter.getLong("id");
|
||||
// QFilter q4 = new QFilter("shjh_cc.fbasedataid", QCP.equals, costcenterid);
|
||||
// qFilter = qFilter.and(q4);
|
||||
// }
|
||||
// DynamicObjectCollection entrys = bill.getDynamicObjectCollection("entry");//付款明细
|
||||
// if (!entrys.isEmpty()) {
|
||||
// DynamicObject entry = entrys.get(0);
|
||||
// //原因码 shjh_reasoncode
|
||||
// DynamicObject shjhYym = entry.getDynamicObject("shjh_yym");
|
||||
// if (null != shjhYym) {
|
||||
// Long yymid = shjhYym.getLong("id");
|
||||
// QFilter q5 = new QFilter("shjh_yym.fbasedataid", QCP.equals, yymid);
|
||||
// qFilter = qFilter.and(q5);
|
||||
// }
|
||||
// //会计科目 shjh_coaitemcode
|
||||
// DynamicObject shjhSapkjkm = entry.getDynamicObject("shjh_accountsap");
|
||||
// if (null != shjhSapkjkm) {
|
||||
// Long kjkmid = shjhSapkjkm.getLong("id");
|
||||
// QFilter q6 = new QFilter("shjh_kjkm.fbasedataid", QCP.equals, kjkmid);
|
||||
// qFilter = qFilter.and(q6);
|
||||
// }
|
||||
// }
|
||||
//收款单,系统自动根据配置表(shjh_pay_account)带出资金计划科目
|
||||
QFilter qFilter = new QFilter("shjh_biztype", QCP.equals,"B");//业务类型:收款
|
||||
//公司范围_多选基础资料
|
||||
DynamicObject openorg = bill.getDynamicObject("openorg");
|
||||
if (null != openorg) {
|
||||
Long orgid = openorg.getLong("id");
|
||||
QFilter q1 = new QFilter("shjh_companys.fbasedataid", QCP.equals, orgid);
|
||||
qFilter = qFilter.and(q1);
|
||||
}
|
||||
//业务大类
|
||||
DynamicObject shjhBizbig = bill.getDynamicObject("shjh_bizebig");
|
||||
if (null != shjhBizbig) {
|
||||
Long shjhBizbigid = shjhBizbig.getLong("id");
|
||||
QFilter q2 = new QFilter("shjh_bizbig.fbasedataid", QCP.equals, shjhBizbigid);
|
||||
qFilter = qFilter.and(q2);
|
||||
}
|
||||
//业务小类
|
||||
DynamicObject shjhbizsmall = bill.getDynamicObject("shjh_bizsmall");
|
||||
if (null != shjhbizsmall) {
|
||||
Long shjhbizsmallid = shjhbizsmall.getLong("id");
|
||||
QFilter q3 = new QFilter("shjh_bizsmall.fbasedataid", QCP.equals, shjhbizsmallid);
|
||||
qFilter = qFilter.and(q3);
|
||||
}
|
||||
//成本中心 shjh_costcenter
|
||||
DynamicObject shjhCostcenter = bill.getDynamicObject("shjh_costcenter");
|
||||
if (null != shjhCostcenter) {
|
||||
Long costcenterid = shjhCostcenter.getLong("id");
|
||||
QFilter q4 = new QFilter("shjh_cc.fbasedataid", QCP.equals, costcenterid);
|
||||
qFilter = qFilter.and(q4);
|
||||
}
|
||||
DynamicObjectCollection entrys = bill.getDynamicObjectCollection("entry");//付款明细
|
||||
if (!entrys.isEmpty()) {
|
||||
DynamicObject entry = entrys.get(0);
|
||||
//原因码 shjh_reasoncode
|
||||
DynamicObject shjhYym = entry.getDynamicObject("shjh_yym");
|
||||
if (null != shjhYym) {
|
||||
Long yymid = shjhYym.getLong("id");
|
||||
QFilter q5 = new QFilter("shjh_yym.fbasedataid", QCP.equals, yymid);
|
||||
qFilter = qFilter.and(q5);
|
||||
}
|
||||
//会计科目 shjh_coaitemcode
|
||||
DynamicObject shjhSapkjkm = entry.getDynamicObject("shjh_accountsap");
|
||||
if (null != shjhSapkjkm) {
|
||||
Long kjkmid = shjhSapkjkm.getLong("id");
|
||||
QFilter q6 = new QFilter("shjh_kjkm.fbasedataid", QCP.equals, kjkmid);
|
||||
qFilter = qFilter.and(q6);
|
||||
}
|
||||
}
|
||||
//原因码
|
||||
String yym = sapresult.getString("RSTGR");
|
||||
QFilter q5 = new QFilter("shjh_yym.fbasedataid.number", QCP.equals, yym);
|
||||
qFilter = qFilter.and(q5).and(new QFilter("enable", QCP.equals, "1"));//可用状态
|
||||
|
||||
DynamicObject[] accounts = BusinessDataServiceHelper.load(payReceName, "id", qFilter.toArray());
|
||||
//再根据生效日期,失效日期区间,判断当前时间满足的数据
|
||||
Date currentDate = new Date();
|
||||
QFilter startDateFilter = new QFilter("shjh_begindate", QCP.less_equals, currentDate);
|
||||
QFilter endDateFilter = new QFilter("shjh_enddate", QCP.large_equals, currentDate);
|
||||
QFilter newFilter = qFilter.and(startDateFilter).and(endDateFilter);
|
||||
|
||||
DynamicObject[] accounts = BusinessDataServiceHelper.load(payReceName, "id,shjh_priority", newFilter.toArray(),"shjh_priority");
|
||||
if (accounts.length > 1) {
|
||||
//上述查询条件返回结果大于1时,再根据生效日期,失效日期区间,判断当前时间满足的数据
|
||||
Date currentDate = new Date();
|
||||
QFilter startDateFilter = new QFilter("shjh_begindate", QCP.less_equals, currentDate);
|
||||
QFilter endDateFilter = new QFilter("shjh_enddate", QCP.large_equals, currentDate);
|
||||
QFilter newFilter = qFilter.and(startDateFilter).and(endDateFilter);
|
||||
//多个条件时根据优先级排序,拿到优先级最高的
|
||||
accounts = BusinessDataServiceHelper.load(payReceName, "id", newFilter.toArray(),"shjh_priority");
|
||||
}
|
||||
if (accounts.length > 0) {
|
||||
String kmbh = sapresult.getString("HKONT");//科目编号
|
||||
String custfive = sapresult.getString("SPART");//客户组5
|
||||
String cust = sapresult.getString("KUNNR");//客户编号
|
||||
DynamicObjectCollection kmcolls;//科目集合
|
||||
DynamicObjectCollection custfivecolls;//客户组5集合
|
||||
DynamicObjectCollection custcolls;//包含客户的集合
|
||||
DynamicObjectCollection nocustcolls;//不包含客户的集合
|
||||
boolean kmbhFlag;
|
||||
boolean custfiveFlag;
|
||||
boolean custFlag;
|
||||
boolean nocustFlag;
|
||||
DynamicObject account;
|
||||
for (int i = 0; i < accounts.length; i++) {
|
||||
account = BusinessDataServiceHelper.loadSingle(accounts[i].getPkValue(), payReceName);
|
||||
kmbhFlag = false;
|
||||
kmcolls = account.getDynamicObjectCollection("shjh_kjkm");//科目
|
||||
if(kmcolls.isEmpty()){
|
||||
//当前配置表没有配置科目,即任何科目都可以匹配
|
||||
kmbhFlag = true;
|
||||
}else{
|
||||
//科目上配置有参数,需要判断与当前科目是否匹配
|
||||
for (DynamicObject kminfo : kmcolls) {
|
||||
if(kminfo.getDynamicObject("fbasedataid").getString("number").equals(kmbh)){
|
||||
kmbhFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
custfiveFlag = false;
|
||||
custfivecolls = account.getDynamicObjectCollection("shjh_khzw");//客户组5
|
||||
if(custfivecolls.isEmpty()){
|
||||
//当前配置表没有配置客户组5,即任何客户组5都可以匹配
|
||||
custfiveFlag = true;
|
||||
}else{
|
||||
for (DynamicObject custfiveinfo : custfivecolls) {
|
||||
if(custfiveinfo.getDynamicObject("fbasedataid").getString("number").equals(custfive)){
|
||||
custfiveFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
custFlag = false;
|
||||
custcolls = account.getDynamicObjectCollection("shjh_bhkh");//包含客户
|
||||
if(custcolls.isEmpty()){
|
||||
//当前配置表没有配置客户,即任何客户都可以匹配
|
||||
custFlag = true;
|
||||
}else{
|
||||
for (DynamicObject custinfo : custcolls) {
|
||||
if(custinfo.getDynamicObject("fbasedataid").getString("number").equals(cust)){
|
||||
custFlag = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
nocustFlag = false;
|
||||
nocustcolls = account.getDynamicObjectCollection("shjh_bbhkh");//不包含客户
|
||||
if(nocustcolls.isEmpty()){
|
||||
//当前配置表没有配置客户,即任何客户都可以匹配
|
||||
nocustFlag = true;
|
||||
}else{
|
||||
nocustFlag = true;
|
||||
for (DynamicObject nocustinfo : custcolls) {
|
||||
if(nocustinfo.getDynamicObject("fbasedataid").getString("number").equals(cust)){
|
||||
nocustFlag = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(kmbhFlag && custfiveFlag && custFlag && nocustFlag){
|
||||
//所有标记都满足,则返回
|
||||
return account.getDynamicObject("shjh_membersubject").getString("number");
|
||||
}
|
||||
}
|
||||
}else if(accounts.length == 1) {
|
||||
// 处理找到符合条件的资金科目
|
||||
DynamicObject account = accounts[0];
|
||||
account = BusinessDataServiceHelper.loadSingle(account.getPkValue(), payReceName);
|
||||
DynamicObject account = BusinessDataServiceHelper.loadSingle(accounts[0].getPkValue(), payReceName);
|
||||
return account.getDynamicObject("shjh_membersubject").getString("number");
|
||||
} else {
|
||||
logger.info("没有找到符合条件的资金计划科目");
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ public class NotCreditedNoticeTask extends AbstractTask implements Plugin {
|
|||
//付款流水查询
|
||||
private static final String recesql = "select fcompanyid,count(fid) from t_bei_transdetail where freceredtype='0' and fcreditAmount>0 and to_char(fcreatetime,'yyyy-MM-DD')=? group by fcompanyid";
|
||||
|
||||
private static final String pzbName = "shjh_sfkwyltzb";//配置表
|
||||
private static final String pzbName = "shjh_sfkwyltzb";//收付款未认领人员通知映射表
|
||||
private static final Log logger = LogFactory.getLog(NotCreditedNoticeTask.class);
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -0,0 +1,101 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.task;
|
||||
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.db.DB;
|
||||
import kd.bos.db.DBRoute;
|
||||
import kd.bos.exception.KDException;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.schedule.executor.AbstractTask;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 定时任务 未认领收款单邮件企微通知
|
||||
* 每日查询前一日(收款日期)未推送sap生成凭证的收款单,并按照《收付款单(未认领)人员通知映射表》定时发送邮件、企微消息通知
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class NotSAPNumNoticeTask extends AbstractTask implements Plugin {
|
||||
|
||||
//fk_shjh_ispushsap 已推送sap标记
|
||||
private static final String recesql = "select fopenorgid,fpayerid,fpayername,count(fid) from T_CAS_ReceivingBill where fk_shjh_ispushsap='0' and to_char(Fpayeedate,'yyyy-MM-DD')=? group by fopenorgid,fpayerid,fpayername";
|
||||
private static final String recbillName = "cas_recbill";//收款单 T_CAS_ReceivingBill
|
||||
private static final String pzbName = "shjh_sfkwyltzb";//收付款未认领人员通知映射表
|
||||
private static final Log logger = LogFactory.getLog(NotSAPNumNoticeTask.class);
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
//获取昨天的日期字符串
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
||||
String yesterdayStr = yesterday.format(formatter);
|
||||
logger.info("昨天"+yesterdayStr);
|
||||
//查询前一日未生成凭证的收款单 企微和邮件(按公司汇总)
|
||||
Map<String,String> companyids = DB.query(DBRoute.of("fi"),recesql,new Object[]{yesterdayStr},(rs) -> {
|
||||
Map<String,String> companys = new HashMap<>();
|
||||
while(rs.next()) {
|
||||
//存放 公司-未处理的收款单个数
|
||||
companys.put(rs.getString(1)+"@"+rs.getString(2)+"@"+rs.getString(3),rs.getString(4));
|
||||
}
|
||||
return companys;
|
||||
});
|
||||
logger.info("收款单查询结果"+companyids.size());
|
||||
|
||||
//遍历map处理消息发送
|
||||
QFilter qFilter;
|
||||
QFilter custFilter;
|
||||
DynamicObject[] pzbcoll;
|
||||
DynamicObject pzbinfo;
|
||||
DynamicObjectCollection users;//配置表中的被通知人集合
|
||||
String entrykey;
|
||||
String title;
|
||||
String content;
|
||||
String orgid;//公司ID
|
||||
String customerid;//客户ID
|
||||
String customername;//客户名称
|
||||
List<Long> receivers = new ArrayList<>();//消息接收人
|
||||
for (Map.Entry<String, String> entry : companyids.entrySet()) {
|
||||
entrykey = entry.getKey();
|
||||
orgid = entrykey.substring(0,entrykey.indexOf("@"));
|
||||
customerid = entrykey.substring(entrykey.indexOf("@")+1,entrykey.lastIndexOf("@"));
|
||||
customername = entrykey.substring(entrykey.lastIndexOf("@")+1);
|
||||
//根据公司ID和配置表查找人员
|
||||
qFilter = new QFilter("shjh_biztype", QCP.equals, "sk");//业务类型为收款
|
||||
qFilter.and("shjh_org", QCP.equals, Long.parseLong(orgid));//公司ID
|
||||
qFilter.and("enable", QCP.equals, "1");//使用状态
|
||||
custFilter = new QFilter("shjh_customer", QCP.equals, Long.parseLong(customerid));//客户
|
||||
pzbcoll = BusinessDataServiceHelper.load(pzbName,"id",new QFilter[]{qFilter,custFilter});
|
||||
if(pzbcoll == null || pzbcoll.length == 0){
|
||||
//根据客户没有找到对应配置表,去掉客户再查找一次
|
||||
pzbcoll = BusinessDataServiceHelper.load(pzbName,"id",qFilter.toArray());
|
||||
}
|
||||
if(pzbcoll != null && pzbcoll.length >= 1){
|
||||
pzbinfo = BusinessDataServiceHelper.loadSingle(pzbcoll[0].getLong("id"),pzbName);
|
||||
users = pzbinfo.getDynamicObjectCollection("shjh_users");
|
||||
receivers.clear();
|
||||
for (DynamicObject user : users) {
|
||||
receivers.add(user.getDynamicObject("fbasedataid").getLong("id"));
|
||||
}
|
||||
title = pzbinfo.getDynamicObject("shjh_org").getString("number")+"公司未处理的收款单";
|
||||
content = "请登录资金系统处理 "+title+",客户名称 "+customername+" 共"+entry.getValue()+"笔";
|
||||
JhzjUtils.sendEmail(title,content,receivers,pzbinfo);
|
||||
JhzjUtils.sendWEIXINQY(title,content,receivers,pzbinfo);
|
||||
}else{
|
||||
logger.info("收款未查找到对应人员"+qFilter.toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue