从中间表取数更新TW销售合同登记数据(含表体)

2023-10-15 05:15

本文主要是介绍从中间表取数更新TW销售合同登记数据(含表体),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

package nc.bs.backgroundtasks;import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.NCLocator;
import nc.bs.pub.pa.PreAlertObject;
import nc.bs.pub.taskcenter.BgWorkingContext;
import nc.bs.pub.taskcenter.IBackgroundWorkPlugin;
import nc.impl.pubapp.pattern.data.bill.BillQuery;
import nc.itf.jych.IXshtdjMaintain;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.ColumnListProcessor;
import nc.vo.jych.oavo.OaXshtBVO;
import nc.vo.jych.oavo.OaXshtVO;
import nc.vo.jych.util.SqlBuilder;
import nc.vo.jych.xshtdj.AggXshtdjVO;
import nc.vo.jych.xshtdj.XshtdjBVO;
import nc.vo.jych.xshtdj.XshtdjVO;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVOUtil;
import nc.vo.pub.VOStatus;
import nc.vo.pub.lang.UFDate;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.wgbfb.tool.NullValueUtils;
/*** @desc : 从中间表取数更新TW销售合同登记数据* @author hanh* @date : 2023-10-09*/public class OAXshtdjPlugin implements IBackgroundWorkPlugin{@Overridepublic PreAlertObject executeTask(BgWorkingContext arg0) throws BusinessException {//抽取中间表数据generateZjXsht();return null;}//抽取中间表数据@SuppressWarnings("unchecked")private void generateZjXsht() throws BusinessException {//查询中间表中未执行的主表数据String sql = " select * from jych_zj_xsht where nvl(dr,0) = 0 and nvl(iszx,'N') != 'Y'  ";//volist存放中间表中未执行的主表数据List<OaXshtVO> volist = (List<OaXshtVO>) getDao().executeQuery(sql.toString(), new BeanListProcessor(OaXshtVO.class));if(volist == null || volist.size() < 1){return;}//idlist存放id+sjlyList<String> idlist = new ArrayList<String>(); //zjpklist存放中间表主表主键List<String> zjpklist = new ArrayList<String>();for (OaXshtVO vo : volist) {//给idlist和zjpklist赋值String id = vo.getId()+vo.getSjly();idlist.add(id);zjpklist.add(vo.getPk_xsht());}//根据中间表id+sjly,查询nc系统中已存在的主表主键SqlBuilder pksql = new SqlBuilder(); pksql.append(" select pk_xshtdj from jych_xshtdj where nvl(dr,0) = 0 and ");pksql.appendNotIn(" def1||sjly ", idlist.toArray(new String[0]));List<String> pklist = (List<String>) getDao().executeQuery(pksql.toString(), new ColumnListProcessor());//Map<key : id+sjly , value : AggVO> 将已存在的AggVO放入vomapMap<String, AggXshtdjVO> vomap = new HashMap<String, AggXshtdjVO>();if(pklist != null && pklist.size() > 0){//根据已存在的主表主键获取已存在的AggVOBillQuery<AggXshtdjVO> billQuery = new BillQuery<AggXshtdjVO>(AggXshtdjVO.class);AggXshtdjVO[] aggvos = billQuery.query(pklist.toArray(new String[0]));for (AggXshtdjVO aggvo : aggvos) {//将aggvo对应的id和aggvo捆绑String wxtbs = aggvo.getParentVO().getDef1();String sjly = aggvo.getParentVO().getSjly();String id = wxtbs + sjly;vomap.put(id, aggvo);}}SqlBuilder sqlnameb = new SqlBuilder(); //查询中间表中主表所对应的子表数据sqlnameb.append(" select * from jych_zj_xsht_b where nvl(dr,0) = 0 and ");sqlnameb.append(" mainid||sjly ", idlist.toArray(new String[0]));//bvolist存放已存在主表对应的子表数据List<OaXshtBVO> bvolist = (List<OaXshtBVO>) getDao().executeQuery(sqlnameb.toString(), new BeanListProcessor(OaXshtBVO.class));//Map<key : mainid+sjly , value : AggVO> 已存在主表对应的子表数据放入bvomapMap<String, List<OaXshtBVO>> bvomap = new HashMap<String, List<OaXshtBVO>>();if(bvolist != null && bvolist.size() > 0){for (OaXshtBVO bvo : bvolist) {//将bvo对应的mainid和bvo捆绑String mainid = bvo.getMainid()+bvo.getSjly();if(bvomap.containsKey(mainid)){//如果bvomap存在该mainid,直接将该bvo和该mainid捆绑List<OaXshtBVO> list = bvomap.get(mainid);list.add(bvo);bvomap.put(mainid, list);} else {//如果bvomap不存在该mainid,则新建一个list,然后再将该bvo和该mainid捆绑List<OaXshtBVO> list = new ArrayList<OaXshtBVO>();list.add(bvo);bvomap.put(mainid, list);}}}//翻译OaXshtVOupdateHeadVO(volist.toArray(new OaXshtVO[0])); //insertlist存放执行插入的aggvoList<AggXshtdjVO> insertlist = new ArrayList<AggXshtdjVO>();//updatelist存放执行更新后的aggvoList<AggXshtdjVO> updatelist = new ArrayList<AggXshtdjVO>();//orgupdatelist存放执行更新前的aggvo	List<AggXshtdjVO> orgupdatelist = new ArrayList<AggXshtdjVO>();		for (OaXshtVO vo : volist) {//封装insertlist、updatelist、orgupdatelistif(vomap != null && vomap.size() > 0 && vomap.containsKey(vo.getId()+vo.getSjly())){ //修改AggXshtdjVO aggvo = vomap.get(vo.getId()+vo.getSjly());AggXshtdjVO clone = (AggXshtdjVO) aggvo.clone();XshtdjVO headvo = clone.getParentVO();headvo.setStatus(VOStatus.UPDATED);setHeadvo(headvo, vo);updatelist.add(clone);orgupdatelist.add(aggvo);} else { //新增AggXshtdjVO aggvo = new AggXshtdjVO();XshtdjVO headvo = new XshtdjVO();headvo.setStatus(VOStatus.NEW);headvo.setPk_billtype("XSHT");headvo.setTranstypecode("XSHT");headvo.setPk_org(vo.getPk_org());headvo.setPk_org_v(vo.getPk_org_v());headvo.setPk_group(vo.getPk_group());headvo.setPk_transtype(vo.getPk_transtype());headvo.setDbilldate(new UFDate());headvo.setVbillstatus(-1);setHeadvo(headvo, vo);if(bvomap != null && bvomap.size() > 0 && bvomap.containsKey(vo.getId()+vo.getSjly())){XshtdjBVO[] bvos = setbodyvo(bvomap.get(vo.getId()+vo.getSjly()));aggvo.setChildrenVO(bvos);}aggvo.setParentVO(headvo);insertlist.add(aggvo);}}if(insertlist != null && insertlist.size() > 0){//调新增接口AggXshtdjVO[] insertvos = getService().insert(insertlist.toArray(new AggXshtdjVO[0]), insertlist.toArray(new AggXshtdjVO[0]));List<AggXshtdjVO> insertvolist = new ArrayList<AggXshtdjVO>();for (AggXshtdjVO insertvo : insertvos) {AggXshtdjVO clone = (AggXshtdjVO) insertvo.clone();XshtdjVO vo = clone.getParentVO();vo.setVbillstatus(1);vo.setApprovedate(new UFDateTime());vo.setApprover(vo.getCreator());insertvolist.add(clone);}getService().approve(insertvolist.toArray(new AggXshtdjVO[0]), insertvos);}if(updatelist != null && updatelist.size() > 0){//调更新接口getService().update(updatelist.toArray(new AggXshtdjVO[0]), orgupdatelist.toArray(new AggXshtdjVO[0]));}SqlBuilder updatesql = new SqlBuilder(); //更新中间表中已执行数据的是否执行标识updatesql.append(" update jych_zj_xsht set iszx = 'Y' where ");updatesql.append(" pk_xsht ", zjpklist.toArray(new String[0]));getDao().executeUpdate(updatesql.toString());}private void updateHeadVO(OaXshtVO[] headvos) {SuperVOUtil.execFormulaWithVOs(headvos, new String[] {// 组织"pk_org->getcolvalue2(org_orgs,pk_org,code,\"05\",islastversion,\"Y\")",// 组织版本"pk_org_v->getcolvalue(org_orgs,pk_vid,pk_org,pk_org)",// 集团"pk_group->getcolvalue(org_group,pk_group,code,\"01\")",//申请人"lastname->getColValue2(bd_psndoc,pk_psndoc,name,lastname,dr,0)",//申请部门"departmentname->getColValue2(org_dept,pk_dept,name,departmentname,dr,0)",//甲方"jfdwbm->getcolvalue2(bd_customer,pk_customer,name,jfdwbm,dr,0)",//乙方"partyb->getcolvalue2(bd_supplier,pk_supplier,name,\"北京城建智控科技股份有限公司\",dr,0)",//币种"bz->getcolvalue2(bd_currtype,pk_currtype,name,bz,dr,0)",//营销项目"xmbh->getColValue2(zkch_marketpro,pk_marketpro,marketprocode,xmbh,dr,0)",});}public void setHeadvo(XshtdjVO headvo, OaXshtVO vo){headvo.setDef1(vo.getId());//项目编号headvo.setPk_marketpro(vo.getXmbh());//合同编码headvo.setHtcode(vo.getHtbh());//合同名称headvo.setHtname(vo.getHtmc());//合同类型headvo.setHttype(vo.getHtlx());//投标类型headvo.setTbtype(vo.getTblx());//甲方headvo.setPartya(vo.getJfdwbm());headvo.setPartyb(vo.getPartyb());//合同金额(含税)headvo.setNmny(vo.getHtjkhs());//合同金额(不含税)headvo.setNtmny(vo.getHtjkbhs());//税率(%)headvo.setTaxrate(NullValueUtils.getNullStringValue(vo.getSl()));//税额headvo.setPaid(vo.getSe());//累计开票金额//				headvo.setLjkpmny(rs.getString(1));//累计回款金额//				headvo.setLjhkmny(rs.getString(1));//累计结算金额//				headvo.setLjnjsmny(rs.getString(1));//申请日期headvo.setSqdate(vo.getSqrq());//签约日期headvo.setQydate(vo.getQyrq());//归档日期headvo.setGddate(vo.getSjyyrq());//所属机构headvo.setSsjg(vo.getSzjg());//申请人headvo.setSqr(vo.getLastname());//申请部门headvo.setSqdept(vo.getDepartmentname());//是否关联交易方headvo.setIsgljyf(vo.getSfgljyf());//是否包含自研产品headvo.setIszycp(vo.getSfbhzycp());//合同开工日期headvo.setHtkgdate(vo.getHtkgrq());//合同竣工日期headvo.setHtjgdate(vo.getHtjgrq());//合同工期headvo.setHtgq(vo.getHtgq());//履约地点headvo.setLyadress(vo.getLydd());//币种headvo.setBz(vo.getBz());//汇率headvo.setHl(vo.getHl());//合同份数headvo.setHtfs(vo.getHtfs());//是否为公司标椎合同模板headvo.setIsgsbzmb(vo.getSfwgsbzhtmb());//合同章headvo.setHtz(vo.getHtz());//公章headvo.setGz(vo.getGz());//法人章headvo.setFrz(vo.getFrz());//总经理手签章headvo.setZjlsqz(vo.getZjlsqz());//福州分公司公章headvo.setFzfgsgz(vo.getFzfgsgz());//总经理印章headvo.setZjlyz(vo.getZjlyz());//备注说明headvo.setMemo(vo.getBzsm());headvo.setSjly(vo.getSjly());}public XshtdjBVO[] setbodyvo(List<OaXshtBVO> bvolist){XshtdjBVO[] bvos = new XshtdjBVO[bvolist.size()];for (int i = 0; i < bvos.length; i++) {OaXshtBVO bvo = bvolist.get(i);bvos[i] = new XshtdjBVO();bvos[i].setRowno(i+1+"0");//税率bvos[i].setTaxrate(bvo.getSl());//含税金额bvos[i].setNmny(bvo.getHsje());//不含税金额bvos[i].setNtmny(bvo.getBhsje());//合计税额bvos[i].setPaid(bvo.getSey());//合同事项bvos[i].setHtsx(bvo.getHtsx());bvos[i].setStatus(VOStatus.NEW);}return bvos;}private IXshtdjMaintain service;private IXshtdjMaintain getService() {if (service == null) {service = NCLocator.getInstance().lookup(IXshtdjMaintain.class);}return service;}private BaseDAO dao;private BaseDAO getDao(){if(dao == null){dao = new BaseDAO();}return dao;}}

这篇关于从中间表取数更新TW销售合同登记数据(含表体)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/215558

相关文章

大模型研发全揭秘:客服工单数据标注的完整攻略

在人工智能(AI)领域,数据标注是模型训练过程中至关重要的一步。无论你是新手还是有经验的从业者,掌握数据标注的技术细节和常见问题的解决方案都能为你的AI项目增添不少价值。在电信运营商的客服系统中,工单数据是客户问题和解决方案的重要记录。通过对这些工单数据进行有效标注,不仅能够帮助提升客服自动化系统的智能化水平,还能优化客户服务流程,提高客户满意度。本文将详细介绍如何在电信运营商客服工单的背景下进行

基于MySQL Binlog的Elasticsearch数据同步实践

一、为什么要做 随着马蜂窝的逐渐发展,我们的业务数据越来越多,单纯使用 MySQL 已经不能满足我们的数据查询需求,例如对于商品、订单等数据的多维度检索。 使用 Elasticsearch 存储业务数据可以很好的解决我们业务中的搜索需求。而数据进行异构存储后,随之而来的就是数据同步的问题。 二、现有方法及问题 对于数据同步,我们目前的解决方案是建立数据中间表。把需要检索的业务数据,统一放到一张M

关于数据埋点,你需要了解这些基本知识

产品汪每天都在和数据打交道,你知道数据来自哪里吗? 移动app端内的用户行为数据大多来自埋点,了解一些埋点知识,能和数据分析师、技术侃大山,参与到前期的数据采集,更重要是让最终的埋点数据能为我所用,否则可怜巴巴等上几个月是常有的事。   埋点类型 根据埋点方式,可以区分为: 手动埋点半自动埋点全自动埋点 秉承“任何事物都有两面性”的道理:自动程度高的,能解决通用统计,便于统一化管理,但个性化定

使用SecondaryNameNode恢复NameNode的数据

1)需求: NameNode进程挂了并且存储的数据也丢失了,如何恢复NameNode 此种方式恢复的数据可能存在小部分数据的丢失。 2)故障模拟 (1)kill -9 NameNode进程 [lytfly@hadoop102 current]$ kill -9 19886 (2)删除NameNode存储的数据(/opt/module/hadoop-3.1.4/data/tmp/dfs/na

异构存储(冷热数据分离)

异构存储主要解决不同的数据,存储在不同类型的硬盘中,达到最佳性能的问题。 异构存储Shell操作 (1)查看当前有哪些存储策略可以用 [lytfly@hadoop102 hadoop-3.1.4]$ hdfs storagepolicies -listPolicies (2)为指定路径(数据存储目录)设置指定的存储策略 hdfs storagepolicies -setStoragePo

Hadoop集群数据均衡之磁盘间数据均衡

生产环境,由于硬盘空间不足,往往需要增加一块硬盘。刚加载的硬盘没有数据时,可以执行磁盘数据均衡命令。(Hadoop3.x新特性) plan后面带的节点的名字必须是已经存在的,并且是需要均衡的节点。 如果节点不存在,会报如下错误: 如果节点只有一个硬盘的话,不会创建均衡计划: (1)生成均衡计划 hdfs diskbalancer -plan hadoop102 (2)执行均衡计划 hd

poj3468(线段树成段更新模板题)

题意:包括两个操作:1、将[a.b]上的数字加上v;2、查询区间[a,b]上的和 下面的介绍是下解题思路: 首先介绍  lazy-tag思想:用一个变量记录每一个线段树节点的变化值,当这部分线段的一致性被破坏我们就将这个变化值传递给子区间,大大增加了线段树的效率。 比如现在需要对[a,b]区间值进行加c操作,那么就从根节点[1,n]开始调用update函数进行操作,如果刚好执行到一个子节点,

hdu1394(线段树点更新的应用)

题意:求一个序列经过一定的操作得到的序列的最小逆序数 这题会用到逆序数的一个性质,在0到n-1这些数字组成的乱序排列,将第一个数字A移到最后一位,得到的逆序数为res-a+(n-a-1) 知道上面的知识点后,可以用暴力来解 代码如下: #include<iostream>#include<algorithm>#include<cstring>#include<stack>#in

hdu1689(线段树成段更新)

两种操作:1、set区间[a,b]上数字为v;2、查询[ 1 , n ]上的sum 代码如下: #include<iostream>#include<algorithm>#include<cstring>#include<stack>#include<queue>#include<set>#include<map>#include<stdio.h>#include<stdl

【Prometheus】PromQL向量匹配实现不同标签的向量数据进行运算

✨✨ 欢迎大家来到景天科技苑✨✨ 🎈🎈 养成好习惯,先赞后看哦~🎈🎈 🏆 作者简介:景天科技苑 🏆《头衔》:大厂架构师,华为云开发者社区专家博主,阿里云开发者社区专家博主,CSDN全栈领域优质创作者,掘金优秀博主,51CTO博客专家等。 🏆《博客》:Python全栈,前后端开发,小程序开发,人工智能,js逆向,App逆向,网络系统安全,数据分析,Django,fastapi