• 从中间表取数更新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{
    
    	@Override
    	public 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+fklx
    		List<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 将已存在的AggVO放入Map
    		Map<String, AggPaymentOrderVO> vomap = new HashMap<String, AggPaymentOrderVO>();
    		if(pklist != null && pklist.size() > 0){
    			//根据已存在的主表主键获取已存在的AggVO
    			BillQuery<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);
    			}
    		}
    
    		//翻译OaPaymentOrderVO
    		updateHeadVO(volist.toArray(new OaPaymentOrderVO[0])); 
    		//insertlist存放执行插入的aggvo
    		List<AggPaymentOrderVO> insertlist = new ArrayList<AggPaymentOrderVO>();
    		//updatelist存放执行更新后的aggvo
    		List<AggPaymentOrderVO> updatelist = new ArrayList<AggPaymentOrderVO>();
    		//orgupdatelist存放执行更新前的aggvo
    		List<AggPaymentOrderVO> orgupdatelist = new ArrayList<AggPaymentOrderVO>();
    		for (OaPaymentOrderVO vo : volist) {//封装insertlist、updatelist、orgupdatelist
    			String 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;
    	}
    }
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
  • 相关阅读:
    MySQL日志管理、备份与恢复
    this.$message提示内容添加换行
    Linux运维_Bash脚本_编译安装GTK+-3.24.41
    原生HTML,CSS,JS实现tab栏切换效果
    网络安全(黑客)自学
    第一章:计算机网络和因特网
    C语言 ——宽字符
    Android Studio的初次认识
    Super Apps 超级应用们背后的道家哲学
    git-使用命令笔记
  • 原文地址:https://blog.csdn.net/weixin_45714641/article/details/133820222