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. cocos2d-x的helloLua例子函数名定义误导初学者

    初次研究cocos2d-x, cocos2d-x支持lua是一个很不错的功能,使用lua来开发有个最大的好处就是不用每次改了游戏代码都编译,大多数情况下改了脚本直接运行程序就可以了,发布更新时也不用更 ...

  2. dataStructure@ Binary Search Tree

    #include<iostream> #include<cstdio> #include<cstring> #include<limits> #incl ...

  3. openstack iptables

  4. TextView & EditText

    TextView 1.下划线 textView.getPaint().setFlags(Paint. UNDERLINE_TEXT_FLAG ); //下划线 2.单独做第一步,文字会出现锯齿,要加下 ...

  5. Android实例-使用自定义字体文件(XE8+小米2)

    结果: 1.需要修改DELPHI自身的FMX.FontGlyphs.Android.pas,复制到程序的根目录下(红色部分为修改过的). 2.字体文件从 C:\Windows\Fonts 直接拷贝到A ...

  6. 转载 ASP.NET中如何取得Request URL的各个部分

    转载原地址 http://blog.miniasp.com/post/2008/02/10/How-Do-I-Get-Paths-and-URL-fragments-from-the-HttpRequ ...

  7. jquery-ui 之Sortable详解

    <div class="aaa"> <ul id="sortable"> <li id="test">I ...

  8. (原创)vagrant up 异常报错,出现 There was an error while executing `VBoxManage` 的解决方法

    最近在使用 vagrant homestead 时,不小心在虚拟机上使用了 exit 命令退出虚拟机,导致再使用 vagrant up 时出现以下错误: Bringing machine 'larav ...

  9. RStudio:R语言编辑器

    RStudio:R语言编辑器 四窗口 左上:写代码,运行的方式是ctrl+Enter,或者用Run按钮 10 + 15 ## [1] 25 左下:终端,上面窗口的代码运行后会在这里显示,也可以直接在这 ...

  10. java基础理论知识的一些总结

    在学习Java初期,由于我们是刚开始接触Java,我们不仅需要牢牢掌握Java的基础理论知识,来为我们后面对Java更深层次的学习打好基础,而且我们需要养成编程人的思想习惯.来我们一起来探索Java基 ...