星空数据库后台——关于后台修改科目核算维度的猜想
这是关于后台修改科目核算维度的猜想,小伙伴么有兴趣看看就可以了。如果真的有调整需求,记得购买金选成功服务-基础数据调整服务,原厂支持给您最专业的保障。此内容仅用作交流学习,自行后台修改数据后果自负!!!
此猜想想要实现批量后台修改科目的核算维度信息,由于目前我的项目仅涉及到可选必录的修改,以及添加核算维度(好像标准产品就支持这样修改),所以以下内容基于上面两个场景考虑。
第一步:先将需要调整的科目内码收集到,支持多个科目同时修改,这里以修改科目内码4025的科目为例,编码1511
--drop table #accounttmp create table #accounttmp(faccountid int primary key,fnewitemdetailid int,fnewgroupnumber varchar(200),fnewgroupname varchar(200)) insert into #accounttmp(faccountid) values(4025)
第二步:收集科目当前的核算维度下挂情况到临时表#tmp_ACCOUNTFLEXENTRY
--DROP TABLE #tmp_ACCOUNTFLEXENTRY select * ,CONVERT(INT,0) FNEWID,identity(int,1,1) fidentity into #tmp_ACCOUNTFLEXENTRY from T_BD_ACCOUNTFLEXENTRY where FACCTID in (select faccountid from #accounttmp) create unique index u_tmp_accpuntflex on #tmp_ACCOUNTFLEXENTRY(FACCTID,FFLEXITEMPROPERTYID)
第三步:根据需求进行修改
这里演示的是内码为4025的科目,将下挂组织机构从必录修改为可选,同时追加一个核算维度编码为ZDY0002的可选核算维度。其他科目有其他维度调整需求也是类似的更新方式
--以上查询结果100003 对应FFLEXITEMPROPERTYID,'FF100003' 对应FDATAFIELDNAME,FFLEXITEMPROPERTYID=8 表示组织机构 update #tmp_ACCOUNTFLEXENTRY set FINPUTTYPE='2' where FINPUTTYPE='1' and FACCTID=4025 and FFLEXITEMPROPERTYID=8 insert into #tmp_ACCOUNTFLEXENTRY(FENTRYID,FACCTID,FFLEXITEMPROPERTYID,FACCTITEMISVALID,FINPUTTYPE,FDATAFIELDNAME,FSEQ,FMASTERID,FNEWID) SELECT 0,faccountid,100003 FFLEXITEMPROPERTYID,1 FACCTITEMISVALID,2 FINPUTTYPE,'FF100003' FDATAFIELDNAME,isnull(b.fseq,1) FSEQ,0 FMASTERID,ROW_NUMBER() over (order by faccountid)+(select isnull(max(FNEWID),0) from #tmp_ACCOUNTFLEXENTRY ) FNEWID from #accounttmp a left join (select FACCTID,max(FSEQ)+1 fseq from #tmp_ACCOUNTFLEXENTRY b group by FACCTID) b on a.faccountid=b.FACCTID where a.faccountid=4025
第四步:重构核算维度组合
不写游标了,通过循环脚本来实现 --拼接核算维度组合 declare @maxseq int; declare @curseq int; select @maxseq=max(fseq),@curseq=1 from #tmp_ACCOUNTFLEXENTRY update #accounttmp set fnewgroupnumber='',fnewitemdetailid=0,fnewgroupname='' while @curseq<=@maxseq begin update a set a.fnewgroupnumber=isnull(a.fnewgroupnumber,'')+ CONVERT(varchar(10),b.FFLEXITEMPROPERTYID)+'_'+CONVERT(varchar(10),b.FACCTITEMISVALID)+'_'+CONVERT(varchar(10),b.FINPUTTYPE)+'/', a.fnewgroupname=isnull(a.fnewgroupname,'')+ CONVERT(varchar(10),c.FNAME)+'/' from #accounttmp a join #tmp_ACCOUNTFLEXENTRY b on a.faccountid=b.FACCTID and b.FSEQ=@curseq join T_BD_FLEXITEMPROPERTY_L c on b.FFLEXITEMPROPERTYID=c.FID and c.FLOCALEID=2052 set @curseq=@curseq+1 end --修正末尾的'/' update #accounttmp set fnewgroupnumber=SUBSTRING(fnewgroupnumber,1,len(fnewgroupnumber)-1), fnewgroupname=SUBSTRING(fnewgroupname,1,len(fnewgroupname)-1)
第五步:匹配一下调整后的核算维度组合是否存在,不存在的才需要插入数据
--判断拼接后的组合是否存在,存在的情况下更新为新的id update a set a.fnewitemdetailid=b.FID from #accounttmp a join T_BD_FLEXITEMGROUP b on a.fnewgroupnumber=b.FNUMBER --不存在的情况下生成新的组合,往T_BD_FLEXITEMGROUP、T_BD_FLEXITEMGROUP_L、T_BD_FLEXITEMGRPENTRY select count(distinct fnewgroupnumber) from #accounttmp where fnewitemdetailid=0
第六步:插入核算维度组合数据
--生成内码 delete from Z_BAS_ITEM insert into Z_BAS_ITEM(Column1) select max(faccountid) faccountid from #accounttmp where fnewitemdetailid=0 --生成内码 delete from Z_BD_FLEXITEMGRPENTRY insert into Z_BD_FLEXITEMGRPENTRY(Column1) select fidentity from #tmp_ACCOUNTFLEXENTRY where FACCTID in (select max(faccountid) faccountid from #accounttmp where fnewitemdetailid=0 group by fnewgroupnumber ) --插入数据 insert into T_BD_FLEXITEMGRPENTRY(FID,FENTRYID,FFLEXITEMPROPERTYID,FACCTITEMISVALID,FINPUTTYPE,FFILTER,FDATAFIELDNAME,FSEQ,FMASTERID) select c.id,b.Id,FFLEXITEMPROPERTYID,FACCTITEMISVALID,FINPUTTYPE,'' FFILTER,FDATAFIELDNAME,FSEQ,FMASTERID from #tmp_ACCOUNTFLEXENTRY a join Z_BD_FLEXITEMGRPENTRY b on a.fidentity=b.Column1 join Z_BAS_ITEM c on a.FACCTID=c.Column1 ---插入数据 insert into T_BD_FLEXITEMGROUP(FID,FNUMBER,FCREATEORGID,FCREATORID,FCREATEDATE,FUSEORGID,FMODIFIERID,FMODIFYDATE,FDOCUMENTSTATUS,FAUDITORID,FAUDITDATE,FFORBIDSTATUS,FFORBIDDERID,FFORBIDDATE,FISSYSPRESET,FMASTERID) select b.Id FID,fnewgroupnumber FNUMBER, 1 FCREATEORGID,16394 FCREATORID,getdate() FCREATEDATE,1 FUSEORGID,16394 FMODIFIERID,getdate() FMODIFYDATE, 'C' FDOCUMENTSTATUS,16394 FAUDITORID,getdate() FAUDITDATE,'A' FFORBIDSTATUS,0 FFORBIDDERID,null FFORBIDDATE,0 FISSYSPRESET,b.Id FMASTERID from (select max(faccountid) faccountid, fnewgroupnumber from #accounttmp where fnewitemdetailid=0 group by fnewgroupnumber) a join Z_BAS_ITEM b on a.faccountid=b.Column1 --不考虑多语言,生成内码 delete from z_BD_FLEXITEMGROUP_L insert into z_BD_FLEXITEMGROUP_L(Column1) select max(faccountid) faccountid from #accounttmp where fnewitemdetailid=0 ---插入数据 insert into T_BD_FLEXITEMGROUP_L(FPKID,FID,FNAME,FDESCRIPTION,FLOCALEID) select c.id,b.Id,fnewgroupname FNAME, '' FDESCRIPTION,2052 FLOCALEID from (select max(faccountid) faccountid, fnewgroupnumber,fnewgroupname from #accounttmp where fnewitemdetailid=0 group by fnewgroupnumber,fnewgroupname) a join Z_BAS_ITEM b on a.faccountid=b.Column1 join z_BD_FLEXITEMGROUP_L c on a.faccountid=c.Column1 --情况z表数据 delete from z_BD_FLEXITEMGROUP_L delete from Z_BD_FLEXITEMGRPENTRY delete from Z_BAS_ITEM
第七步:更新科目的核算维度下挂情况
--更新科目新的核算维度组合 update a set a.fnewitemdetailid=b.FID from #accounttmp a join T_BD_FLEXITEMGROUP b on a.fnewgroupnumber=b.FNUMBER and a.fnewitemdetailid=0 --更新科目核算维度修改数据,由于我们只考虑必录的变更情况和新加维度,因此针对更新的数据 update b set b.FINPUTTYPE=a.FINPUTTYPE from #tmp_ACCOUNTFLEXENTRY a join T_BD_ACCOUNTFLEXENTRY b on a.FENTRYID=b.FENTRYID --生成内码 delete from Z_BD_ACCOUNTFLEXENTRY insert into Z_BD_ACCOUNTFLEXENTRY(Column1) select FNEWID from #tmp_ACCOUNTFLEXENTRY where FNEWID<>0 --插入科目下挂核算维度数据 insert into T_BD_ACCOUNTFLEXENTRY(FENTRYID,FACCTID,FFLEXITEMPROPERTYID,FACCTITEMISVALID,FINPUTTYPE,FDATAFIELDNAME,FSEQ,FMASTERID) select b.Id FENTRYID,FACCTID,FFLEXITEMPROPERTYID,FACCTITEMISVALID,FINPUTTYPE,FDATAFIELDNAME,FSEQ,FMASTERID from #tmp_ACCOUNTFLEXENTRY a join Z_BD_ACCOUNTFLEXENTRY b on a.FNEWID=b.Column1 delete from Z_BD_ACCOUNTFLEXENTRY --科目列表显示的核算维度组合修改 update b set b.FITEMDETAILID=a.fnewitemdetailid from #accounttmp a join T_BD_ACCOUNT b on a.faccountid=b.FACCTID and a.fnewitemdetailid<>b.FITEMDETAILID
好了,聪明的你如果认真看上面的实现过程,想必已经对星空核算维度的数据存储规则、数据引用情况了然于胸了。
好帖,参考这个贴解决了客户核算维度异常的问题
有更多后台表的图配合讲解里面的逻辑就更好
星空数据库后台——关于后台修改科目核算维度的猜想
这是关于后台修改科目核算维度的猜想,小伙伴么有兴趣看看就可以了。如果真的有调整需求,记得购买金选成功服务-基础数据调整服务,原厂支...
点击下载文档
上一篇:客户启用序列号使用过程中需要注意的事项下一篇:成本计算逻辑:工序协作
本文2024-09-16 18:19:08发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-21367.html
您需要登录后才可以发表评论, 登录登录 或者 注册
最新文档
热门文章