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("\r\n");
sqlstr.append(" where ap_payableitem.top_billid = '"+billPk+"'").append("\r\n");
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("\r\n");
sqlstr.append("select distinct ap_payablebill.def2 guid,").append("\r\n");
sqlstr.append(" ap_payablebill.money dkAmount,").append("\r\n");
sqlstr.append(" billuser.user_name createby,").append("\r\n");
sqlstr.append(" ap_payablebill.billdate createdate,").append("\r\n");
sqlstr.append(" ap_payablebill.approvedate approvedate,").append("\r\n");
sqlstr.append(" appuser.user_name approvedby,").append("\r\n");
sqlstr.append(" bd_supplier.code sfProviderCode,").append("\r\n");
sqlstr.append(" bd_supplier.name sfProviderName,").append("\r\n");
sqlstr.append(" ").append("\r\n");
sqlstr.append(" 0 billstate,").append("\r\n");
sqlstr.append(" ap_payablebill.pk_payablebill billPk,").append("\r\n");
sqlstr.append(" ap_payablebill.billno").append("\r\n");
sqlstr.append(" from ap_payablebill").append("\r\n");
sqlstr.append(" left join ap_payableitem").append("\r\n");
sqlstr.append(" on ap_payableitem.pk_payablebill = ap_payablebill.pk_payablebill").append("\r\n");
sqlstr.append(" left join bd_supplier").append("\r\n");
sqlstr.append(" on bd_supplier.pk_supplier = ap_payableitem.supplier").append("\r\n");
sqlstr.append(" left join sm_user appuser").append("\r\n");
sqlstr.append(" on appuser.cuserid = ap_payablebill.approver").append("\r\n");
sqlstr.append(" left join sm_user billuser").append("\r\n");
sqlstr.append(" on billuser.cuserid = ap_payablebill.billmaker").append("\r\n");
sqlstr.append(" where ap_payablebill.pk_payablebill = '"+pk_payablebill+"'").append("\r\n");
sqlstr.append(" and nvl(ap_payablebill.dr, 0) = 0 and nvl(appuser.dr,0) = 0").append("\r\n");
sqlstr.append(" and nvl(bd_supplier.dr,0) = 0 and nvl(billuser.dr,0) = 0").append("\r\n");
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;
} }

  

PayablebillImpl的更多相关文章

随机推荐

  1. Unity3D为FirstPersonController添加跑步与下蹲动作

    using UnityEngine; using System.Collections; public class MyController : MonoBehaviour { ; ; ; priva ...

  2. Delphi外挂开发网站

    http://cheatengine.org/http://wenku.baidu.com/view/2d5de818964bcf84b9d57b15.html   [delphi外G]http:// ...

  3. 转载 SharePoint Foundation和SharePoint Server的区别

    SharePoint Server 2010用来取代MOSS 2007,它有标准版和企业版两个版本,使用SQL Server数据库: 早期版本中的STS或WSS在2010中更名为SharePoint ...

  4. Info.plist和pch文件的作用

  5. MYSQL- 分页存储过程

    工作需要,用到MYSQL的分页功能,在网上找到一个不错的分页存储过程,代码整理了一下! 存储过程代码 CREATE PROCEDURE `sp_hj_splitpage`( in _pagecurre ...

  6. HTTP 与 HTTPS 的区别

    本文转自:http://www.cnblogs.com/ok-lanyan/archive/2012/07/14/2591204.html HTTP是一个属于应用层的面向对象的协议,由于其简捷.快速的 ...

  7. SQLite DBHelp

    c#连接SQLite SQLite这个精巧的小数据库,无需安装软件,只需要一个System.Data.SQLite.DLL文件即可操作SQLite数据库.SQLite是一个开源数据库,现在已变得越来越 ...

  8. Filter过滤器

    filter功能.它使用户可以改变一个 request和修改一个response. Filter 不是一个servlet,它不能产生一个response,它能够在一个request到达servlet之 ...

  9. jboss7的服务器开启和关闭命令

    国内私募机构九鼎控股打造APP,来就送 20元现金领取地址:http://jdb.jiudingcapital.com/phone.html内部邀请码:C8E245J (不写邀请码,没有现金送)国内私 ...

  10. Thread学习

    1.定义 2.作用 3.和进程的比较 4.多线程(multithreading)的优点和缺陷 5.调度(scheduling) 6.线程相关概念 定义 线程就是最小的可编程指令序列,是进程的子集.一个 ...