1 正式供应商和供应商变更审核通过后更新开通账号人员 2 数仓会计科目定时任务
This commit is contained in:
parent
9e6af290b9
commit
3adaf6fd60
|
@ -0,0 +1,245 @@
|
|||
package shkd.bamp.base.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.OperateOption;
|
||||
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.OperationServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.sdk.plugin.Plugin;
|
||||
import shkd.utils.DobeDWUtils;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
public class DobeDWaccountViewTask 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 Log log = LogFactory.getLog(DobeDWaccountViewTask.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(DobeDWUtils.isEmpty(number) || DobeDWUtils.isEmpty(name) || DobeDWUtils.isEmpty(hsorgid)){
|
||||
log.info(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(!DobeDWUtils.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.info(String.format("数仓传入的父级科目编号在金蝶中找不到:%s", parentNumber));
|
||||
DobeDWUtils.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.info(String.format("数仓传入的科目所属组织在金蝶中找不到:%s", hsorgid));
|
||||
DobeDWUtils.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.info(String.format("数仓传入的科目类型在金蝶中找不到:%s", acctType));
|
||||
DobeDWUtils.saveLog(number,"数仓会计科目同步",json_body.toString(),"数仓传入的科目类型在金蝶中找不到:"+acctType,false,"定时任务");
|
||||
continue;
|
||||
}
|
||||
//核算维度
|
||||
if(!DobeDWUtils.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.info(String.format("数仓传入的核算维度在金蝶中找不到:%s", hswd));
|
||||
DobeDWUtils.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;
|
||||
}
|
||||
}
|
|
@ -13,6 +13,7 @@ import kd.bos.logging.LogFactory;
|
|||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.SaveServiceHelper;
|
||||
import kd.bos.util.HttpClientUtils;
|
||||
import kd.bos.util.StringUtils;
|
||||
import shkd.repc.recon.opplugin.TestOPPlugin;
|
||||
|
@ -60,6 +61,9 @@ public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn {
|
|||
if (StringUtils.isNotEmpty(oaToken) && null != supplier) {
|
||||
pushOASupplier(oaToken,supplier);
|
||||
}
|
||||
|
||||
//处理联系人分录中的开通账号的人员名称更新到主表字段上面 yxl 20241120
|
||||
handleContactPerson(supplier);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -154,4 +158,24 @@ public class PushOASupplierOPPlugin extends AbstractOperationServicePlugIn {
|
|||
}
|
||||
return customerBody;
|
||||
}
|
||||
|
||||
private void handleContactPerson(DynamicObject supplier){
|
||||
// 获取正式供应商
|
||||
QFilter q = new QFilter("id", QCP.equals, supplier.getPkValue());
|
||||
DynamicObject officialSupplier = BusinessDataServiceHelper.loadSingle(RESM_OFFICIAL_SUPPLIER, new QFilter[]{q});
|
||||
DynamicObjectCollection lxrcoll = officialSupplier.getDynamicObjectCollection("entry_linkman");
|
||||
DynamicObject lxrinfo = null;
|
||||
String lxrmc = null;
|
||||
for (int i = 0; i < lxrcoll.size(); i++) {
|
||||
lxrinfo = lxrcoll.get(i);
|
||||
if(lxrinfo.getBoolean("isopenaccount")){
|
||||
lxrmc = lxrinfo.getString("contactperson");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(lxrmc != null){
|
||||
officialSupplier.set("qeug_supplierperson", lxrmc);//开通账号人员
|
||||
SaveServiceHelper.save(new DynamicObject[]{officialSupplier});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue