两个List集合判断取出大集合中不包含小集合的数据, sql加入 in() 条件查询

	//记录结算单中没在付款单中出现的合同号(完全没有承担的亏损)--------------------mz---------------------
		String x2="SELECT a.CFCONTRACTNUMBER 合同号,sum(a.FACTUALAMT) 已承担亏损 FROM T_CAS_ReceivingBillEntry a left join T_CAS_ReceivingBill b ON A.FReceivingBillID = B.FID left join T_BD_Customer c on b.FPAYERID=c.fid where c.fname_l2 ='"+this.prmtcust.getValue().toString()+"' and a.FCONTRACTENTRYSEQ=1 group by a.CFCONTRACTNUMBER";
		IRowSet rsx2 = SQLExecutorFactory.getRemoteInstance(x2).executeSQL();   
		ArrayList<String> yfcontractList = new  ArrayList<String>();
		while(rsx2.next()){
			yfcontractList.add(rsx2.getString("合同号"))	; //应付单里面承担的亏损的合同号
		}
		//循环遍历取出不在付款单集合中的该养户的结算单中的合同号
		jscontractList.removeAll(yfcontractList); //差异集合, 
	 
		StringBuffer  contacts=new StringBuffer();
        for (int j = 0; j < jscontractList.size(); j++) {
        	contacts.append("'" + jscontractList.get(j) + "',");
		}
          String result = contacts.toString();
          if(!result.equals("")){
        	  String tp = result.substring(result.length() - 1, result.length());
    		  result=result.substring(0, result.length() - 1);
            String mz="select d.fnumber 合同号,a.CFCURRENTBALANCE 亏损金额,a.CFCUSTINFO 信息 from CT_DUC_CalculateStatement a left join T_DUC_BreedingContract d on a.CFCONTRACTNOID=d.fid   left join T_BD_Customer c on a.CFCUSTID=c.fid where c.fname_l2 ='"+this.prmtcust.getValue().toString()+"' and a.CFCURRENTBALANCE<0 and d.fnumber  in (  "+result+"  )  ";
    		IRowSet rsmz = SQLExecutorFactory.getRemoteInstance(mz).executeSQL();
            while(rsmz.next()){
            	IRow irow = this.kdtE2.addRow();
    			irow.getCell("conNo").setValue(rsmz.getString("合同号"));
    			irow.getCell("materiel").setValue("亏损");
    			irow.getCell("qty").setValue("1");
    			irow.getCell("measurementUnit").setValue("笔");
    			irow.getCell("amount").setValue(rsmz.getDouble("亏损金额")*(-1));
            } 
          }
		

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值