• PayablebillImpl


    package nc.impl.arap.payablebill;
    
    import java.util.List;
    import java.util.Map;
    
    import nc.bs.dao.BaseDAO;
    import nc.itf.arap.payablebill.IPayablebillItf;
    import nc.jdbc.framework.processor.BeanListProcessor;
    import nc.jdbc.framework.processor.MapProcessor;
    import nc.vo.arap.payable.PayableBillVO;
    import nc.vo.arap.payablebill.MidPayinfoVO;
    import nc.vo.pub.AggregatedValueObject;
    import nc.vo.pub.BusinessException;
    
    /**
     * 应付单管理审批弃审中间表数据操作接口实现
     * @author 陈志锋
     * 2015-12-25
     */
    public class PayablebillImpl implements IPayablebillItf {
    	
    	private BaseDAO baseDAO;
    	public BaseDAO getBaseDAO(){
    		if(baseDAO == null){
    			baseDAO = new BaseDAO();
    		}
    		return baseDAO;
    	}
    	
    	@Override
    	public Boolean insertInfoMiddle(AggregatedValueObject aggvo) throws BusinessException {
    		String pk_payablebill = aggvo.getParentVO().getPrimaryKey();
    		MidPayinfoVO[] billVOs = getMidPayinfoVO(pk_payablebill);
    		if(billVOs != null){
    			for (int i = 0; i < billVOs.length; i++) {
    				MidPayinfoVO midPayinfoVO = billVOs[i];
    				midPayinfoVO.setDr(0);
    				getBaseDAO().insertVO(midPayinfoVO);
    			}
    		}
    		return true;
    	}
    
    	
    	@Override
    	public Boolean deteleInfoMiddle(String billPk) throws BusinessException {
    		
    		StringBuffer sqlstr=new StringBuffer("");
    		sqlstr.append("select * from (select ap_payableitem.pk_payablebill from ap_payableitem").append("
    ");
    		sqlstr.append("     where ap_payableitem.top_billid = '"+billPk+"'").append("
    ");
    		sqlstr.append("     order by ap_payableitem.ts desc ) temp where rownum = 1"); 
    		List<PayableBillVO> list = (List<PayableBillVO>) getBaseDAO().executeQuery(sqlstr.toString(), new BeanListProcessor(PayableBillVO.class));
    		if(list != null && list.size() > 0){
    			for (int i = 0; i < list.size(); i++) {
    				PayableBillVO billVO = list.get(i);
    				String pk_bill = billVO.getPrimaryKey();
    				if(billVO.getApprovestatus() == 1){
    					continue;
    				}else{
    					String delsql = " update MID_PAYINFO set billstate = 1,dr=1 where billPK='"+pk_bill+"' and nvl(dr,0)=0 ";
    					getBaseDAO().executeUpdate(delsql);
    				}
    			}
    		}
    		return true;
    	}
    
    	private MidPayinfoVO[] getMidPayinfoVO(String pk_payablebill) throws BusinessException{
    		StringBuffer sqlstr=new StringBuffer("");
    		sqlstr.append("").append("
    ");
    		sqlstr.append("select distinct ap_payablebill.def2        guid,").append("
    ");
    		sqlstr.append("       ap_payablebill.money       dkAmount,").append("
    ");
    		sqlstr.append("       billuser.user_name         createby,").append("
    ");
    		sqlstr.append("       ap_payablebill.billdate    createdate,").append("
    ");
    		sqlstr.append("       ap_payablebill.approvedate approvedate,").append("
    ");
    		sqlstr.append("       appuser.user_name   approvedby,").append("
    ");
    		sqlstr.append("       bd_supplier.code sfProviderCode,").append("
    ");
    		sqlstr.append("       bd_supplier.name sfProviderName,").append("
    ");
    		sqlstr.append("        ").append("
    ");
    		sqlstr.append("       0 billstate,").append("
    ");
    		sqlstr.append("       ap_payablebill.pk_payablebill billPk,").append("
    ");
    		sqlstr.append("       ap_payablebill.billno").append("
    ");
    		sqlstr.append("  from ap_payablebill").append("
    ");
    		sqlstr.append("    left join ap_payableitem").append("
    ");
    		sqlstr.append("         on ap_payableitem.pk_payablebill = ap_payablebill.pk_payablebill").append("
    ");
    		sqlstr.append("    left join bd_supplier").append("
    ");
    		sqlstr.append("         on bd_supplier.pk_supplier = ap_payableitem.supplier").append("
    ");
    		sqlstr.append("    left join sm_user appuser").append("
    ");
    		sqlstr.append("        on appuser.cuserid = ap_payablebill.approver").append("
    ");
    		sqlstr.append("    left join sm_user billuser").append("
    ");
    		sqlstr.append("       on billuser.cuserid = ap_payablebill.billmaker").append("
    ");
    		sqlstr.append(" where ap_payablebill.pk_payablebill = '"+pk_payablebill+"'").append("
    ");
    		sqlstr.append("   and nvl(ap_payablebill.dr, 0) = 0 and nvl(appuser.dr,0) = 0").append("
    ");
    		sqlstr.append("   and nvl(bd_supplier.dr,0) = 0 and nvl(billuser.dr,0) = 0").append("
    ");
    		sqlstr.append("   and ap_payablebill.billstatus = 1 and nvl(ap_payablebill.def2,'~') <> '~' "); 
    		List<MidPayinfoVO> listMidVO = (List<MidPayinfoVO>) getBaseDAO().executeQuery(sqlstr.toString(), new BeanListProcessor(MidPayinfoVO.class));
    		if(listMidVO != null && listMidVO.size() > 0){
    			return listMidVO.toArray(new MidPayinfoVO[0]);
    		}else{
    			return null;
    		}
    		
    	}
    
    	@Override
    	public String getPayableStatue(String pk_payablebill)throws BusinessException {
    		String sql = "select ap_payablebill.approvestatus from ap_payablebill where ap_payablebill.pk_payablebill = '"+pk_payablebill+"'";
    		Map map = (Map) getBaseDAO().executeQuery(sql, new MapProcessor());
    		String billstatus = "";
    		if(map != null || map.size() > 0){
    			billstatus = (map.get("approvestatus")==null?"":map.get("approvestatus")) + "";
    		}
    		return billstatus;
    	}
    	
    	
    	
    	
    }
    

      

    ---- 动动手指关注我!或许下次你又能在我这里找到你需要的答案!ZZZZW与你一起学习,一起进步!
  • 相关阅读:
    《Genesis-3D开源游戏引擎完整实例教程-跑酷游戏篇:简介及目录》(附上完整工程文件)
    Genesis-3D开源游戏引擎简介!
    《Genesis-3D开源游戏引擎--横版格斗游戏制作教程:简介及目录》(附上完整工程文件)
    《Genesis-3D开源游戏引擎-官方录制系列视频教程:进阶实例篇》
    《Genesis-3D开源游戏引擎-官方录制系列视频教程:基础操作篇》
    《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇08:弹幕系统》本系列完结
    《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇07:全屏炸弹》
    《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇06:计分》
    《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇05:角色中弹》
    《Genesis-3D开源游戏引擎完整实例教程-2D射击游戏篇04:碰撞检测》
  • 原文地址:https://www.cnblogs.com/zzzzw/p/5078670.html
Copyright © 2020-2023  润新知