本文主要是介绍从中间表取数更新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.IPaymentorderMaintain;
import nc.jdbc.framework.processor.BeanListProcessor;
import nc.jdbc.framework.processor.ColumnListProcessor;
import nc.vo.jych.oavo.OaPaymentOrderVO;
import nc.vo.jych.paymentorder.AggPaymentOrderVO;
import nc.vo.jych.paymentorder.PaymentOrderVO;
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;
import nc.vo.zkch.utils.SqlBuilder;/*** @desc : 从中间表取数更新TW付款单数据* @author hanh* @date : 2023-10-10*/
public class OAPaymentOrderPlugin implements IBackgroundWorkPlugin{@Overridepublic PreAlertObject executeTask(BgWorkingContext arg0) throws BusinessException {//抽取中间表数据generatePaymentOrder();return null;}//抽取中间表数据@SuppressWarnings("unchecked")private void generatePaymentOrder() throws BusinessException {//通过是否执行标识查询中间表中未执行的主表数据SqlBuilder sqlname = new SqlBuilder();sqlname.append(" select * from jych_zj_fkd where nvl(dr,0) = 0 and nvl(iszx,'N') != 'Y' ");//volist存放中间表中未执行的主表数据List<OaPaymentOrderVO> volist = (List<OaPaymentOrderVO>) getDao().executeQuery(sqlname.toString(), new BeanListProcessor(OaPaymentOrderVO.class));if(volist == null || volist.size() < 1){return;}/*通过id+数据来源+付款类型来判断新增或修改*///idlist存放id+sjly+fklxList<String> idlist = new ArrayList<String>();//zjpklist存放中间表主表主键List<String> zjpklist = new ArrayList<String>();for (OaPaymentOrderVO vo : volist) {//给idlist和zjpklist赋值String id = vo.getId() + vo.getSjly() + NullValueUtils.getNullStringValue(vo.getFklx());idlist.add(id);zjpklist.add(vo.getPk_fkd());}//根据中间表id+sjly+fklx,查询nc系统中已存在的主表主键SqlBuilder pksql = new SqlBuilder();pksql.append(" select pk_paymentorder from jych_paymentorder where nvl(dr,0) = 0 and ");pksql.append(" wxtbs||sjly||fklx ", idlist.toArray(new String[0]));List<String> pklist = (List<String>) getDao().executeQuery(pksql.toString(), new ColumnListProcessor());//Map<key : id+sjly=fklx , value : AggVO> 将已存在的AggVO放入MapMap<String, AggPaymentOrderVO> vomap = new HashMap<String, AggPaymentOrderVO>();if(pklist != null && pklist.size() > 0){//根据已存在的主表主键获取已存在的AggVOBillQuery<AggPaymentOrderVO> billQuery = new BillQuery<AggPaymentOrderVO>(AggPaymentOrderVO.class);AggPaymentOrderVO[] vos = billQuery.query(pklist.toArray(new String[0]));for (AggPaymentOrderVO aggvo : vos) {//将aggvo对应的id和aggvo捆绑String wxtbs = aggvo.getParentVO().getWxtbs();String sjly = aggvo.getParentVO().getSjly();String fklx = aggvo.getParentVO().getFklx();String id = wxtbs + sjly + fklx;vomap.put(id, aggvo);}}//翻译OaPaymentOrderVOupdateHeadVO(volist.toArray(new OaPaymentOrderVO[0])); //insertlist存放执行插入的aggvoList<AggPaymentOrderVO> insertlist = new ArrayList<AggPaymentOrderVO>();//updatelist存放执行更新后的aggvoList<AggPaymentOrderVO> updatelist = new ArrayList<AggPaymentOrderVO>();//orgupdatelist存放执行更新前的aggvoList<AggPaymentOrderVO> orgupdatelist = new ArrayList<AggPaymentOrderVO>();for (OaPaymentOrderVO vo : volist) {//封装insertlist、updatelist、orgupdatelistString id = vo.getId() + vo.getSjly() + NullValueUtils.getNullStringValue(vo.getFklx());if(vomap != null && vomap.size() > 0 && vomap.containsKey(id)){ //修改AggPaymentOrderVO aggvo = vomap.get(id);AggPaymentOrderVO clone = (AggPaymentOrderVO) aggvo.clone();PaymentOrderVO headvo = clone.getParentVO();headvo.setStatus(VOStatus.UPDATED);setHeadvo(headvo, vo);updatelist.add(clone);orgupdatelist.add(aggvo);} else { //新增AggPaymentOrderVO aggvo = new AggPaymentOrderVO();PaymentOrderVO headvo = new PaymentOrderVO();headvo.setStatus(VOStatus.NEW);headvo.setPk_billtype("XS01");headvo.setTranstypecode("XS01-Cxx-01");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);aggvo.setParentVO(headvo);insertlist.add(aggvo);}}if(insertlist != null && insertlist.size() > 0){//调新增接口AggPaymentOrderVO[] insertvos = getService().insert(insertlist.toArray(new AggPaymentOrderVO[0]), insertlist.toArray(new AggPaymentOrderVO[0]));List<AggPaymentOrderVO> insertvolist = new ArrayList<AggPaymentOrderVO>();for (AggPaymentOrderVO insertvo : insertvos) {AggPaymentOrderVO clone = (AggPaymentOrderVO) insertvo.clone();PaymentOrderVO vo = clone.getParentVO();vo.setVbillstatus(1);vo.setApprovedate(new UFDateTime());vo.setApprover(vo.getCreator());insertvolist.add(clone);}getService().approve(insertvolist.toArray(new AggPaymentOrderVO[0]), insertvos);}if(updatelist != null && updatelist.size() > 0){//调更新接口getService().update(updatelist.toArray(new AggPaymentOrderVO[0]), orgupdatelist.toArray(new AggPaymentOrderVO[0]));}SqlBuilder updatesql = new SqlBuilder(); //更新中间表中已执行数据的是否执行标识updatesql.append(" update jych_zj_fkd set iszx = 'Y' where ");updatesql.append(" pk_fkd ", zjpklist.toArray(new String[0]));getDao().executeUpdate(updatesql.toString());}private void updateHeadVO(OaPaymentOrderVO[] 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\")",// 付款形式-原值"def1->fkxs",// 申请人"def2->lastname",// 申请人"lastname->getColValue2(bd_psndoc,pk_psndoc,name,lastname,dr,0)",// 合同号-原值"def3->htbh",// 合同编号"htbh->getColValue(view_jych_contract,pk,htbh,htbh)",// 申请部门"def4->departmentname",// 申请部门"departmentname->getColValue2(org_dept,pk_dept,name,departmentname,dr,0)",// 项目编号"def5->xmbh",// 项目编号"xmbh->getColValue2(zkch_marketpro,pk_marketpro,marketprocode,xmbh,dr,0)"});}public void setHeadvo(PaymentOrderVO headvo, OaPaymentOrderVO vo){headvo.setWxtbs(vo.getId());//申请日期headvo.setSqrq(vo.getSqrq());//所属机构headvo.setSsjg(vo.getSzjg());//申请人headvo.setSqr(vo.getLastname());//申请部门headvo.setSqbm(vo.getDepartmentname());//支付单单号headvo.setZfddh(vo.getZfddh());//项目编号headvo.setXmbh(vo.getXmbh());//合同编号headvo.setHtbh(vo.getHtbh());//付款事由headvo.setFksy(vo.getFksy());//本次付款金额headvo.setBcfkmny(vo.getBcfkjey());//本次实际支付headvo.setBcsjzf(vo.getBcsjzf());//应付金额headvo.setYingfmny(vo.getYfkje());//付款形式headvo.setFkxs(vo.getFkxs());//是否冲销预付款headvo.setIscxyfk(vo.getSfcxyfk());//摘要
// headvo.setMarketprocode(vo.getZy());//归档时间headvo.setGddate(vo.getLastoperatedate());//出纳审批时间headvo.setCnspdate(vo.getOperatedate());//付款类型headvo.setFklx(vo.getFklx());//数据来源headvo.setSjly(vo.getSjly());headvo.setSfhjk(vo.getSfhjk());headvo.setCxje(vo.getCxje());headvo.setDef1(vo.getDef1());headvo.setDef2(vo.getDef2());headvo.setDef3(vo.getDef3());headvo.setDef4(vo.getDef4());headvo.setDef5(vo.getDef5());}private IPaymentorderMaintain service;private IPaymentorderMaintain getService() {if (service == null) {service = NCLocator.getInstance().lookup(IPaymentorderMaintain.class);}return service;}private BaseDAO dao;private BaseDAO getDao(){if(dao == null){dao = new BaseDAO();}return dao;}
}
这篇关于从中间表取数更新TW付款单数据(不含表体)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!