From 9e6af290b9520fafd2ecd4bc7b9b550b1f524a97 Mon Sep 17 00:00:00 2001 From: zengweihai Date: Wed, 20 Nov 2024 14:28:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E8=AF=84?= =?UTF-8?q?=E4=BC=B0=E6=8A=A5=E8=A1=A8=E5=B9=B3=E5=9D=87=E5=88=86=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=E5=8F=8A=E5=AF=B9=E5=BA=94=E5=AD=97=E6=AE=B5=E8=B0=83?= =?UTF-8?q?=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../data/SupEvalRecordReportListPlugin.java | 41 +++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 main/java/shkd/repc/resm/report/data/SupEvalRecordReportListPlugin.java diff --git a/main/java/shkd/repc/resm/report/data/SupEvalRecordReportListPlugin.java b/main/java/shkd/repc/resm/report/data/SupEvalRecordReportListPlugin.java new file mode 100644 index 0000000..5be6e1e --- /dev/null +++ b/main/java/shkd/repc/resm/report/data/SupEvalRecordReportListPlugin.java @@ -0,0 +1,41 @@ +package shkd.repc.resm.report.data; + +import com.grapecity.documents.excel.S; +import kd.bos.algo.DataSet; +import kd.bos.algo.JoinDataSet; +import kd.bos.algo.JoinType; +import kd.bos.entity.report.FastFilter; +import kd.bos.entity.report.FilterInfo; +import kd.bos.entity.report.ReportQueryParam; +import kd.bos.orm.query.QFilter; +import kd.bos.servicehelper.QueryServiceHelper; +import kd.repc.resm.formplugin.report.SupEvalRecordReportList; +import kd.repc.resm.formplugin.report.eval.SupEvalRecReportNewList; + +import java.util.List; + +public class SupEvalRecordReportListPlugin extends SupEvalRecReportNewList { + @Override + public DataSet query(ReportQueryParam reportQueryParam, Object arg1) throws Throwable { + FilterInfo filterInfo = reportQueryParam.getFilter(); + List evalTaskEntryFilter = this.getEvalTaskEntryFilter(filterInfo); + FastFilter fastFilter = filterInfo.getFastFilter(); + if (fastFilter != null) { + evalTaskEntryFilter.addAll(fastFilter.getQFilters()); + } + + QFilter[] evalTaskEntryFilterS = (QFilter[])evalTaskEntryFilter.toArray(new QFilter[evalTaskEntryFilter.size()]); + String selectFieldInResm = "evaldetail.suppliertype.name as listsuppliergroup,evaldetail.supplier as listsupplier,org as listevalorg,evaldetail.project_category as listproject_category,evaldetail.contract.project.name as listproject,name as listevaltask,evaldetail.evaltype as listevaltype,evaldetail.contract as listcontract ,evalmodel as listevalmodel ,eval_year_num as listyear ,duringeval as listduringeval ,ordertime as listevaldate,evaldetail.actualscore as listevalscore,evaldetail.evalgradle as listevalgrade,evaldetail.commonopinion as description,evaldetail.id as evaldetailid,id as evaltaskid"; + DataSet finish = QueryServiceHelper.queryDataSet("resm_evaltask_new", "resm_evaltask_new", selectFieldInResm, evalTaskEntryFilterS, (String)null); +// + DataSet finish_avg = finish.groupBy(new String[]{"listsupplier"}).avg("listevalscore").finish(); + + DataSet select = finish_avg.select("listsupplier as listsupplier1", "listevalscore as qeug_avgscore"); + + DataSet evalTaskSetEntry = QueryServiceHelper.queryDataSet("resm_evaltask_new", "resm_evaltask_new", selectFieldInResm, evalTaskEntryFilterS, (String)null); + JoinDataSet join = evalTaskSetEntry.join(select, JoinType.LEFT); + DataSet result = join.on("listsupplier", "listsupplier1").select("listsuppliergroup", "listsupplier", "listevalorg", "listproject_category", "listproject", "listevaltask", "listevaltype", "listcontract", "listevalmodel", "listyear", "listduringeval", "listevaldate", "listevalscore", "qeug_avgscore", "listevalgrade", "description", "evaldetailid","evaltaskid").finish(); + + return result.orderBy(new String[]{"listsupplier desc"}); + } +} From 3adaf6fd603448d1a95940823339277ebc78c7fa Mon Sep 17 00:00:00 2001 From: yuxueliang0813 <407010292@qq.com> Date: Wed, 20 Nov 2024 15:20:20 +0800 Subject: [PATCH 2/2] =?UTF-8?q?1=20=E6=AD=A3=E5=BC=8F=E4=BE=9B=E5=BA=94?= =?UTF-8?q?=E5=95=86=E5=92=8C=E4=BE=9B=E5=BA=94=E5=95=86=E5=8F=98=E6=9B=B4?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E9=80=9A=E8=BF=87=E5=90=8E=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=BC=80=E9=80=9A=E8=B4=A6=E5=8F=B7=E4=BA=BA=E5=91=98=202=20?= =?UTF-8?q?=E6=95=B0=E4=BB=93=E4=BC=9A=E8=AE=A1=E7=A7=91=E7=9B=AE=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E4=BB=BB=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bamp/base/task/DobeDWaccountViewTask.java | 245 ++++++++++++++++++ .../resm/opplugin/PushOASupplierOPPlugin.java | 24 ++ 2 files changed, 269 insertions(+) create mode 100644 main/java/shkd/bamp/base/task/DobeDWaccountViewTask.java diff --git a/main/java/shkd/bamp/base/task/DobeDWaccountViewTask.java b/main/java/shkd/bamp/base/task/DobeDWaccountViewTask.java new file mode 100644 index 0000000..3616487 --- /dev/null +++ b/main/java/shkd/bamp/base/task/DobeDWaccountViewTask.java @@ -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 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; + } +} diff --git a/main/java/shkd/repc/resm/opplugin/PushOASupplierOPPlugin.java b/main/java/shkd/repc/resm/opplugin/PushOASupplierOPPlugin.java index 2faec44..9d22fd4 100644 --- a/main/java/shkd/repc/resm/opplugin/PushOASupplierOPPlugin.java +++ b/main/java/shkd/repc/resm/opplugin/PushOASupplierOPPlugin.java @@ -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}); + } + } }