收付款未入账流水通知
This commit is contained in:
parent
690e630150
commit
26e3e65afa
|
|
@ -24,6 +24,7 @@ import java.util.HashMap;
|
|||
|
||||
/**
|
||||
* 动态表单插件-【SAP应收未清】 shjh_sapyswq
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class ASParbillFormPlugin extends AbstractFormPlugin implements Plugin {
|
||||
|
||||
|
|
|
|||
|
|
@ -13,21 +13,18 @@ import kd.bos.logging.Log;
|
|||
import kd.bos.logging.LogFactory;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.EventObject;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 修改反清账日期和反清账方式 表单插件
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class UnclearAndUpdateStatusFormPlugin extends AbstractFormPlugin implements Plugin {
|
||||
|
||||
private static final String OK_BUTTON_KEY = "btnok";//确认按钮
|
||||
private final static Log logger = LogFactory.getLog(UnclearAndUpdateStatusFormPlugin.class);
|
||||
|
||||
//更新反清账日期和反清后处理方式
|
||||
private static final String updateDateWay = "update tk_shjh_clear_account set fk_shjh_uncleardate=?,fk_shjh_unclearway=? where fid in (?);";
|
||||
//清账状态修改原因
|
||||
private static final String updateReason = "update tk_shjh_clear_account set fk_shjh_changereason=? where fid in (?);";
|
||||
|
||||
/**
|
||||
* 按钮监听注册
|
||||
*/
|
||||
|
|
@ -65,6 +62,7 @@ public class UnclearAndUpdateStatusFormPlugin extends AbstractFormPlugin impleme
|
|||
}
|
||||
sqlsb.setLength(sqlsb.length()-1);
|
||||
sqlsb.append(");");
|
||||
//更新反清账日期和反清后处理方式
|
||||
DB.update(DBRoute.of("fi"), sqlsb.toString(), new Object[]{uncleardate,unclearway});
|
||||
this.getView().returnDataToParent(key);
|
||||
}else if("updatestatus_check".equals(apiKey)){
|
||||
|
|
@ -78,6 +76,7 @@ public class UnclearAndUpdateStatusFormPlugin extends AbstractFormPlugin impleme
|
|||
}
|
||||
sqlsb.setLength(sqlsb.length()-1);
|
||||
sqlsb.append(");");
|
||||
//清账状态修改原因
|
||||
DB.update(DBRoute.of("fi"), sqlsb.toString(), new Object[]{changereason});
|
||||
this.getView().returnDataToParent(key);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import java.util.*;
|
|||
|
||||
/**
|
||||
* 清账单单据操作插件
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class ClearAccountBillOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ import java.util.Set;
|
|||
|
||||
/**
|
||||
* 清账明细单据操作插件
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class ClearDetailBillOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
|
|
@ -79,7 +80,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
|
|||
}else if("reject".equals(eok)){
|
||||
List<Long> receivers = new ArrayList<>();
|
||||
receivers.add(RequestContext.get().getCurrUserId());
|
||||
JhzjUtils.sendWEIXINQY(null,null,receivers);
|
||||
JhzjUtils.sendWEIXINQY(null,null, receivers);
|
||||
//驳回校验
|
||||
if(!"B".equals(prinfo.getString("billstatus"))){
|
||||
//清账明细单【单据状态】=已提交,才允许点击驳回按钮
|
||||
|
|
@ -97,7 +98,7 @@ public class ClearDetailBillOperation extends AbstractOperationServicePlugIn imp
|
|||
}
|
||||
|
||||
private boolean checkAmount(DynamicObject prinfo){
|
||||
//TODO【未清金额】+【账扣金额】+【尾差金额】≥【本次核销金额合计】
|
||||
//【未清金额】+【账扣金额】+【尾差金额】≥【本次核销金额合计】
|
||||
BigDecimal billtotal = BigDecimal.ZERO;
|
||||
BigDecimal a1 = prinfo.getBigDecimal("shjh_unclaimamount");
|
||||
BigDecimal a2 = prinfo.getBigDecimal("shjh_deductionamount");
|
||||
|
|
|
|||
|
|
@ -2,15 +2,25 @@ package shjh.jhzj7.fi.fi.plugin.operate;
|
|||
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.entity.plugin.AbstractOperationServicePlugIn;
|
||||
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
||||
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付信息变更单据操作插件
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class PayinfoChangeOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
private final static String paychgbill = "cas_paychgbill";//支付信息变更单
|
||||
|
||||
/**
|
||||
* 操作校验通过之后,开启事务之前,触发此事件;
|
||||
* 插件可以在此事件,对通过校验的数据,进行整理
|
||||
|
|
@ -24,7 +34,7 @@ public class PayinfoChangeOperation extends AbstractOperationServicePlugIn imple
|
|||
DynamicObject[] dos = e.getDataEntities();
|
||||
DynamicObject prinfo = null;
|
||||
for (int i = 0; i < dos.length; i++) {
|
||||
//TODO 反审核操作之前系统未把info对象所有属性加载出来,尤其是二开的字段,需要在此处重新load一下
|
||||
//反审核操作之前系统未把info对象所有属性加载出来,尤其是二开的字段,需要在此处重新load一下
|
||||
prinfo = BusinessDataServiceHelper.loadSingle(dos[i].getPkValue(),dos[i].getDataEntityType().getName(),
|
||||
"id,billno,shjh_sourcesystem");
|
||||
if("B".equals(prinfo.getString("shjh_sourcesystem"))){
|
||||
|
|
@ -34,4 +44,27 @@ public class PayinfoChangeOperation extends AbstractOperationServicePlugIn imple
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
||||
super.afterExecuteOperationTransaction(e);
|
||||
String eok = e.getOperationKey();
|
||||
if("recpushchg".equals(eok) || "paypushchg".equals(eok)){
|
||||
//根据当前所选付款单找到对应的变更单
|
||||
QFilter status = new QFilter("billstatus", QCP.equals, "A");
|
||||
QFilter sourcebill = new QFilter("sourcebillid", QCP.equals, e.getDataEntities()[0].getLong("id"));
|
||||
DynamicObject prinfo = BusinessDataServiceHelper.loadSingle(paychgbill,new QFilter[]{status.and(sourcebill)});
|
||||
if(prinfo != null){
|
||||
String sourcebillno = prinfo.getString("sourcebillno");//源单编号
|
||||
String changeCause = prinfo.getString("remark");//变更原因
|
||||
DynamicObject userField = prinfo.getDynamicObject("alterationuser");//变更人
|
||||
List<Long> receivers = new ArrayList<>(1);
|
||||
receivers.add(userField.getLong("id"));
|
||||
String title = "支付信息变更单号"+prinfo.getString("billno");
|
||||
String content = "请登录资金系统处理付款单"+sourcebillno+"的变更,原因如下:\n"+changeCause;
|
||||
JhzjUtils.sendEmail(title,content+"\n 变更详情页面:"+JhzjUtils.getBillPCURL(prinfo),receivers);
|
||||
JhzjUtils.sendWEIXINQY(title,content,receivers);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ import kd.sdk.plugin.Plugin;
|
|||
|
||||
/**
|
||||
* 付款申请单据操作插件
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class PayrequestBillOperation extends AbstractOperationServicePlugIn implements Plugin {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,246 +0,0 @@
|
|||
package shjh.jhzj7.fi.fi.plugin.task;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.util.TypeUtils;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.exception.KDException;
|
||||
import kd.bos.id.ID;
|
||||
import kd.bos.logging.Log;
|
||||
import kd.bos.logging.LogFactory;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.schedule.executor.AbstractTask;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shjh.jhzj7.fi.fi.utils.JhzjUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
public class AspAccountTask extends AbstractTask implements Plugin {
|
||||
private static final String entityName = "bd_accountview";//会计科目实体 财务库 表名 T_BD_Account
|
||||
// private static final String acctTableName = "bd_accounttable";//科目表
|
||||
private static final String acctTypeName = "bd_accounttype";//科目类型
|
||||
private static final String hswdName = "bd_asstacttype";//核算维度
|
||||
private static final String orgName = "bos_org";//业务单元
|
||||
private static final Log log = LogFactory.getLog(AspAccountTask.class);
|
||||
|
||||
private static final String dw_menthod = "mdm_arog";
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
JSONObject json_body = new JSONObject();
|
||||
json_body.put("totalNum","1");
|
||||
JSONObject json_detail = new JSONObject();
|
||||
json_detail.put("number","5404");
|
||||
json_detail.put("name","战略渠道支出2");
|
||||
json_detail.put("hsorgid","dobe");
|
||||
json_detail.put("acctType","05");
|
||||
json_detail.put("sytype","非损益类科目");
|
||||
json_detail.put("yefx","1");
|
||||
json_detail.put("acctsx","");
|
||||
json_detail.put("hswd","0005");
|
||||
json_detail.put("bbhs","nocurrency");
|
||||
json_detail.put("parentNumber","");
|
||||
json_detail.put("isleaf","true");
|
||||
json_detail.put("level","1");
|
||||
|
||||
JSONArray array = new JSONArray();
|
||||
array.add(json_detail);
|
||||
json_body.put("data",array);
|
||||
handleAccount(json_body);
|
||||
}
|
||||
|
||||
private void handleAccount(JSONObject json_body) {
|
||||
//解析接口返回值,与系统数据比较
|
||||
JSONArray detailsJson = json_body.getJSONArray("data");
|
||||
String number = null;//科目编号
|
||||
String name = null;//科目名称
|
||||
String hsorgid = null;//所属核算组织
|
||||
// String dwid = null;//数仓会计科目id
|
||||
String isleaf = null;//是否叶子节点
|
||||
String level = null;//层级
|
||||
String acctType = null;//科目类型 资产 负债 成本 损益 共同
|
||||
String sytype = null;//损益类型
|
||||
String yefx = null;//余额方向 借1 贷-1
|
||||
String acctsx = null;//科目金额类属性 现金、银行、现金等价物
|
||||
String hswd = null;//核算维度 基础资料
|
||||
String bbhs = null;//币别核算 不核算外币 核算所有外币 指定核算币别(需要指定币别ISO)
|
||||
String parentNumber = null;//父级科目编号
|
||||
DynamicObject hsorgInfo = null;
|
||||
DynamicObject acctInfo = null;
|
||||
DynamicObject acctTypeInfo = null;
|
||||
DynamicObject parentAcctInfo = null;
|
||||
DynamicObject hswdInfo = null;
|
||||
DynamicObject checkitementryInfo = null;
|
||||
for (int i = 0; i < detailsJson.size(); i++) {
|
||||
json_body = detailsJson.getJSONObject(i);
|
||||
number = json_body.getString("number");
|
||||
name = json_body.getString("name");
|
||||
hsorgid = json_body.getString("hsorgid");
|
||||
acctType = json_body.getString("acctType");
|
||||
sytype = json_body.getString("sytype");
|
||||
hswd = json_body.getString("hswd");
|
||||
bbhs = json_body.getString("bbhs");
|
||||
level = json_body.getString("level");
|
||||
isleaf = json_body.getString("isleaf");
|
||||
yefx = json_body.getString("yefx");
|
||||
if(JhzjUtils.isEmpty(number) || JhzjUtils.isEmpty(name) || JhzjUtils.isEmpty(hsorgid)){
|
||||
log.error(String.format("会计科目接口入参为空异常:%s", json_body.toJSONString()));
|
||||
continue;
|
||||
}
|
||||
//根据数仓id查找项目是否已存在
|
||||
acctInfo = BusinessDataServiceHelper.loadSingle(entityName,new QFilter[]{new QFilter("number","=",number)});
|
||||
if(acctInfo != null){
|
||||
//处理科目更新逻辑,此时能修改哪些字段?币别核算 核算维度(扩大范围是可以的,调整了维度不建议使用)
|
||||
// acctInfo.set("accounttable", 1318154893474663424l);//科目表fid
|
||||
// acctInfo.set("level", Integer.valueOf(level));//级次
|
||||
// acctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));
|
||||
// acctInfo.set("dc", yefx);//余额方向
|
||||
// acctInfo.set("masterid", acctInfo.getString("id"));//主数据内码
|
||||
// acctInfo.set("accrualdirection", "nocontrol");//科目录入方向控制 不控制nocontrol 借方debit 贷方credit
|
||||
// acctInfo.set("orgcontrollevel", Integer.valueOf(level));//控制级次
|
||||
// acctInfo.set("isleaf", Boolean.valueOf(isleaf));//明细科目
|
||||
// acctInfo.set("status", "C");
|
||||
// acctInfo.set("ismanual", true);
|
||||
// acctInfo.set("isassist", true);
|
||||
// acctInfo.set("creator", 2010985207800271872L);
|
||||
// SaveServiceHelper.update(acctInfo);
|
||||
// OperationServiceHelper.executeOperate("submit",entityName,new DynamicObject[]{acctInfo}, OperateOption.create());
|
||||
}else{
|
||||
//不存在,做新增 根据实体名称创建动态对象
|
||||
acctInfo = BusinessDataServiceHelper.newDynamicObject(entityName);
|
||||
acctInfo.set("accounttable", 1318154893474663424L);//科目表fid,上正式时,注意此ID
|
||||
acctInfo.set("number", number);
|
||||
acctInfo.set("name", name);
|
||||
if(!JhzjUtils.isEmpty(parentNumber)){
|
||||
//父级科目编号不为空,则还原父级科目对象
|
||||
parentAcctInfo = BusinessDataServiceHelper.loadSingleFromCache(entityName,new QFilter[]{new QFilter("number","=",parentNumber)});
|
||||
if(parentAcctInfo != null){
|
||||
acctInfo.set("longnumber", number);
|
||||
acctInfo.set("fullname", parentAcctInfo.getString("fullname")+"_"+name);
|
||||
acctInfo.set("parent", parentAcctInfo.getLong("id"));
|
||||
}else{
|
||||
log.error(String.format("数仓传入的父级科目编号在金蝶中找不到:%s", parentNumber));
|
||||
JhzjUtils.saveLog(number,"数仓会计科目同步",json_body.toString(),"数仓传入的父级科目编号在金蝶中找不到:"+parentNumber,false,"定时任务");
|
||||
continue;
|
||||
}
|
||||
}else{
|
||||
acctInfo.set("longnumber", number);
|
||||
acctInfo.set("fullname", name);
|
||||
}
|
||||
//创建组织
|
||||
hsorgInfo = BusinessDataServiceHelper.loadSingleFromCache(orgName,new QFilter[]{new QFilter("number","=",hsorgid)});
|
||||
if(hsorgInfo != null){
|
||||
acctInfo.set("createorg", hsorgInfo.getLong("id"));//创建组织
|
||||
acctInfo.set("org", hsorgInfo.getLong("id"));//管理组织
|
||||
acctInfo.set("useorg", hsorgInfo.getLong("id"));//核算组织
|
||||
}else{
|
||||
log.error(String.format("数仓传入的科目所属组织在金蝶中找不到:%s", hsorgid));
|
||||
JhzjUtils.saveLog(number,"数仓会计科目同步",json_body.toString(),"数仓传入的科目所属组织在金蝶中找不到:"+hsorgid,false,"定时任务");
|
||||
continue;
|
||||
}
|
||||
//科目类型
|
||||
acctTypeInfo = BusinessDataServiceHelper.loadSingleFromCache(acctTypeName,new QFilter[]{new QFilter("number","=",acctType)});
|
||||
if(acctTypeInfo != null){
|
||||
acctInfo.set("accounttype", acctTypeInfo.getLong("id"));
|
||||
}else{
|
||||
log.error(String.format("数仓传入的科目类型在金蝶中找不到:%s", acctType));
|
||||
JhzjUtils.saveLog(number,"数仓会计科目同步",json_body.toString(),"数仓传入的科目类型在金蝶中找不到:"+acctType,false,"定时任务");
|
||||
continue;
|
||||
}
|
||||
//核算维度
|
||||
if(!JhzjUtils.isEmpty(hswd)){
|
||||
hswdInfo = BusinessDataServiceHelper.loadSingleFromCache(hswdName,new QFilter[]{new QFilter("number","=",hswd)});
|
||||
if(hswdInfo != null){
|
||||
checkitementryInfo = acctInfo.getDynamicObjectCollection("checkitementry").addNew();
|
||||
checkitementryInfo.set("asstactitem",hswdInfo.getLong("id"));
|
||||
if(Boolean.valueOf(isleaf)){
|
||||
checkitementryInfo.set("isrequire", true);//必录
|
||||
checkitementryInfo.set("isdetail", true);//明细
|
||||
}else{
|
||||
checkitementryInfo.set("isrequire", false);//必录
|
||||
checkitementryInfo.set("isdetail", false);//明细
|
||||
}
|
||||
acctInfo.set("isassist", true);//主表的isassist是否包含核算项目为是
|
||||
}else{
|
||||
log.error(String.format("数仓传入的核算维度在金蝶中找不到:%s", hswd));
|
||||
JhzjUtils.saveLog(number,"数仓会计科目同步",json_body.toString(),"数仓传入的核算维度在金蝶中找不到:"+hswd,false,"定时任务");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
//币别核算--外币核算类型
|
||||
acctInfo.set("acctcurrency", bbhs);//不核算外币nocurrency 指定核算币别descurrency 核算所有币别allcurrency
|
||||
//如果是指定核算币别
|
||||
if("descurrency".equals(bbhs)){
|
||||
//处理具体币别分录数据
|
||||
}
|
||||
acctInfo.set("ctrlstrategy", "5");//控制策略 全局共享
|
||||
acctInfo.set("control", "nocontrol");//受控系统 nocontrol 无 应付 应收 资产
|
||||
//损益类型
|
||||
acctInfo.set("pltype", getSY(sytype));
|
||||
acctInfo.set("dc", yefx);//余额方向
|
||||
acctInfo.set("level", Integer.valueOf(level));//级次
|
||||
acctInfo.set("isleaf", Boolean.valueOf(isleaf));//明细科目
|
||||
acctInfo.set("startdate", new Date());//版本化日期
|
||||
acctInfo.set("enddate", TypeUtils.castToDate("2999-12-31"));//失效日期
|
||||
acctInfo.set("accrualdirection", "nocontrol");//科目录入方向控制 不控制nocontrol 借方debit 贷方credit
|
||||
acctInfo.set("orgcontrollevel", Integer.valueOf(level));//控制级次
|
||||
acctInfo.set("isallowca", false);//允许公司增加下级科目 由接口同步 为false时控制级次可以不设置
|
||||
acctInfo.set("ismanual", false);//手工录入 由接口同步
|
||||
acctInfo.set("iscash", getAcctSX("cash",acctsx));//现金科目
|
||||
acctInfo.set("isbank", getAcctSX("bank",acctsx));//银行科目
|
||||
acctInfo.set("iscashequivalent", getAcctSX("cashequivalent",acctsx));//现金等价物
|
||||
acctInfo.set("isjournal", false);//登日记账 现金等价物时需要勾选
|
||||
acctInfo.set("enable", 1);//是否启用
|
||||
acctInfo.set("status", "C");//单据状态 A保存 B已提交 C已审核
|
||||
acctInfo.set("creator", 43007523L);//创建人默认指定为金小蝶
|
||||
//手动指定科目的金蝶id
|
||||
long kmId = ID.genLongId();
|
||||
acctInfo.set("id", kmId);
|
||||
acctInfo.set("masterid", kmId);//主数据内码,系统不会根据id自动生成,需要手动设置
|
||||
//保存数据:直接保存入库,不走操作校验
|
||||
SaveServiceHelper.save(new DynamicObject[]{acctInfo});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getAcctSX(String mb,String acctsx){
|
||||
//科目属性
|
||||
if("cash".equals(mb) && "现金科目".equals(acctsx)){
|
||||
return true;
|
||||
}else if("bank".equals(mb) && "银行科目".equals(acctsx)){
|
||||
return true;
|
||||
}else if("cashequivalent".equals(mb) && "现金等价物".equals(acctsx)){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private String getSY(String sytype){
|
||||
//损益类型
|
||||
String typevalue = null;
|
||||
switch (sytype){
|
||||
case "收入要素":
|
||||
typevalue = "1";
|
||||
case "成本要素":
|
||||
typevalue = "2";
|
||||
case "管理费用":
|
||||
typevalue = "3";
|
||||
case "销售费用":
|
||||
typevalue = "4";
|
||||
case "财务费用":
|
||||
typevalue = "5";
|
||||
case "其它损益类型":
|
||||
typevalue = "6";
|
||||
case "非损益类科目":
|
||||
typevalue = "0";
|
||||
default:
|
||||
typevalue = "0";
|
||||
}
|
||||
return typevalue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -16,10 +16,10 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 定时任务更新资金计划收款实际数
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class FundPlanCollectionTask extends AbstractTask implements Plugin {
|
||||
private static final String entityName = "bd_accountview";
|
||||
|
||||
private static final String entityName = "bd_accountview";//资金计划
|
||||
|
||||
private static final Log logger = LogFactory.getLog(FundPlanCollectionTask.class);
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,118 @@
|
|||
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.*;
|
||||
|
||||
/**
|
||||
* 定时任务 未入账收付款流水通知
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class NotCreditedNoticeTask extends AbstractTask implements Plugin {
|
||||
|
||||
//付款流水查询
|
||||
private static final String paysql = "select fcompanyid,count(fid) from t_bei_transdetail where freceredtype='0' and fdebitAmount>0 and to_char(fcreatetime,'yyyy-MM-DD')=? group by fcompanyid";
|
||||
//付款流水查询
|
||||
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 Log logger = LogFactory.getLog(NotCreditedNoticeTask.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);
|
||||
//未入账的付款流水,T+1定时通知 企微和邮件(按公司汇总)
|
||||
Map<Long,String> companyids = DB.query(DBRoute.of("fi"),paysql,new Object[]{yesterdayStr},(rs) -> {
|
||||
Map<Long,String> companys = new HashMap<>();
|
||||
while(rs.next()) {
|
||||
companys.put(rs.getLong(1),rs.getString(2));
|
||||
}
|
||||
return companys;
|
||||
});
|
||||
logger.info("付款流水结果"+companyids.size());
|
||||
//遍历map处理消息发送
|
||||
QFilter qFilter;
|
||||
DynamicObject[] pzbcoll;
|
||||
DynamicObject pzbinfo;
|
||||
DynamicObjectCollection users;//配置表中的被通知人集合
|
||||
// Map<Long,DynamicObjectCollection> companyUsers = new HashMap<>();//公司与被通知人关联关系
|
||||
String title;
|
||||
String content;
|
||||
List<Long> receivers = new ArrayList<>();//消息接收人
|
||||
for (Map.Entry<Long, String> entry : companyids.entrySet()) {
|
||||
//根据公司ID和配置表查找人员
|
||||
qFilter = new QFilter("shjh_biztype", QCP.equals, "fk");//业务类型为付款
|
||||
qFilter.and("shjh_org", QCP.equals, entry.getKey());//公司ID
|
||||
qFilter.and("enable", QCP.equals, "1");//使用状态
|
||||
qFilter.and("shjh_customer", QCP.equals, 0l);//客户为空
|
||||
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");
|
||||
// companyUsers.put(entry.getKey(),users);
|
||||
receivers.clear();
|
||||
for (DynamicObject user : users) {
|
||||
receivers.add(user.getDynamicObject("fbasedataid").getLong("id"));
|
||||
}
|
||||
title = pzbinfo.getDynamicObject("shjh_org").getString("number")+"公司未入账的付款流水";
|
||||
content = "请登录资金系统处理 "+title+" 共"+entry.getValue()+"笔";
|
||||
JhzjUtils.sendEmail(title,content,receivers);
|
||||
JhzjUtils.sendWEIXINQY(title,content,receivers);
|
||||
}else{
|
||||
logger.info("付款未查找到对应人员"+qFilter.toArray());
|
||||
}
|
||||
}
|
||||
|
||||
//次日发送前一日未入账的收款单流水通知 企微和邮件(按公司汇总)
|
||||
companyids = DB.query(DBRoute.of("fi"),recesql,new Object[]{yesterdayStr},(rs) -> {
|
||||
Map<Long,String> companys = new HashMap<>();
|
||||
while(rs.next()) {
|
||||
companys.put(rs.getLong(1),rs.getString(2));
|
||||
}
|
||||
return companys;
|
||||
});
|
||||
logger.info("收款流水结果"+companyids.size());
|
||||
//遍历map处理消息发送
|
||||
for (Map.Entry<Long, String> entry : companyids.entrySet()) {
|
||||
//根据公司ID和配置表查找人员
|
||||
qFilter = new QFilter("shjh_biztype", QCP.equals, "sk");//业务类型为收款
|
||||
qFilter.and("shjh_org", QCP.equals, entry.getKey());//公司ID
|
||||
qFilter.and("enable", QCP.equals, "1");//使用状态
|
||||
qFilter.and("shjh_customer", QCP.equals, 0l);//客户为空
|
||||
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+" 共"+entry.getValue()+"笔";
|
||||
JhzjUtils.sendEmail(title,content,receivers);
|
||||
JhzjUtils.sendWEIXINQY(title,content,receivers);
|
||||
}else{
|
||||
logger.info("收款未查找到对应人员"+qFilter.toArray());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -18,12 +18,13 @@ import java.util.Map;
|
|||
|
||||
/**
|
||||
* 定时任务收款单自动下推生成清账单
|
||||
* @author yuxueliang
|
||||
*/
|
||||
public class ReceBillToClearBillTask extends AbstractTask implements Plugin {
|
||||
private static final String srcEntityName = "cas_recbill";//源单 收款单
|
||||
private static final String destEntityName = "shjh_clear_account";//目标单 清账单
|
||||
|
||||
private static final Log logger = LogFactory.getLog(FundPlanCollectionTask.class);
|
||||
private static final Log logger = LogFactory.getLog(ReceBillToClearBillTask.class);
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
|
|
|
|||
|
|
@ -77,7 +77,7 @@ public class JhzjUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* 组装入参,给指定人员发邮件
|
||||
* 组装入参,给指定单个人员发邮件
|
||||
* @param email 邮箱地址
|
||||
* @param title 邮件主题
|
||||
* @param content 邮件内容
|
||||
|
|
@ -87,7 +87,7 @@ public class JhzjUtils {
|
|||
EmailInfo emailInfo = new EmailInfo();
|
||||
emailInfo.setTitle(title);
|
||||
emailInfo.setContent(content);
|
||||
List receivers = new ArrayList<>();
|
||||
List receivers = new ArrayList<>(1);
|
||||
receivers.add(email);//增加接收人
|
||||
emailInfo.setReceiver(receivers);
|
||||
Map<String, Object> sendResult = EmailHandler.sendEmail(emailInfo);
|
||||
|
|
@ -96,7 +96,32 @@ public class JhzjUtils {
|
|||
}
|
||||
|
||||
/**
|
||||
* 组装入参,给指定人员发企微消息
|
||||
* 组装入参,给指定某些人员发邮件,走系统渠道
|
||||
* @param title 邮件主题
|
||||
* @param content 邮件内容
|
||||
* @param receivers 上游操作触发
|
||||
*/
|
||||
public static void sendEmail(String title, String content, List<Long> receivers){
|
||||
//构建消息体发送
|
||||
MessageInfo message = new MessageInfo();
|
||||
//信息 title
|
||||
message.setMessageTitle(new LocaleString(title));
|
||||
//信息主体 content
|
||||
message.setMessageContent(new LocaleString(content));
|
||||
//信息接收人
|
||||
message.setUserIds(receivers);
|
||||
//信息标签
|
||||
message.setTag(msgtag.getLocaleValue_zh_CN());
|
||||
message.setMessageTag(msgtag);
|
||||
//信息发送人-当前操作人
|
||||
message.setSenderId(RequestContext.get().getCurrUserId());
|
||||
message.setType("notice_email");//消息类型的编号
|
||||
message.setNotifyType(MessageChannels.EMAIL.getNumber());//消息渠道的编号
|
||||
MessageCenterServiceHelper.sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 组装入参,给指定某些人员发企微消息
|
||||
* @param title 消息主题
|
||||
* @param content 消息内容
|
||||
* @param receivers 信息接收人
|
||||
|
|
@ -105,9 +130,9 @@ public class JhzjUtils {
|
|||
//构建消息体发送
|
||||
MessageInfo message = new MessageInfo();
|
||||
//信息 title
|
||||
message.setMessageTitle(new LocaleString("测试消息主题"));
|
||||
message.setMessageTitle(new LocaleString(title));
|
||||
//信息主体 content
|
||||
message.setMessageContent(new LocaleString("消息主体内容,请登录资金系统处理业务"));
|
||||
message.setMessageContent(new LocaleString(content));
|
||||
//信息接收人
|
||||
message.setUserIds(receivers);
|
||||
//信息标签
|
||||
|
|
@ -116,12 +141,11 @@ public class JhzjUtils {
|
|||
//信息发送人-当前操作人
|
||||
message.setSenderId(RequestContext.get().getCurrUserId());
|
||||
message.setType("notice_wx");//消息类型的编号
|
||||
StringBuilder notifyType = new StringBuilder();
|
||||
// StringBuilder notifyType = new StringBuilder();
|
||||
// notifyType.append(MessageChannels.EMAIL.getNumber()).append(",");
|
||||
notifyType.append(MessageChannels.WEIXINQY.getNumber());
|
||||
message.setNotifyType(notifyType.toString());
|
||||
long result = MessageCenterServiceHelper.sendMessage(message);
|
||||
logger.info("微信消息返回"+result);
|
||||
// notifyType.append(MessageChannels.WEIXINQY.getNumber());
|
||||
message.setNotifyType(MessageChannels.WEIXINQY.getNumber());//消息渠道的编号
|
||||
MessageCenterServiceHelper.sendMessage(message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in New Issue