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. Spring配置文件的加载,及装载多个beans.xml文件

    applicationContext.xml 是spring的全局配置文件,用来控制srping的特性 1  手动加载自定义的beans.xml文件 @Test public void testAut ...

  2. hdoj 2111 Saving HDU

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  3. Stage3D学习笔记(二):使用GPU绘制一个三角形

    我们需要使用到Adobe自家提供的AGALMiniAssembler代码类,可以在网下进行下载: 关于AGAL的入门知识可以参考下面的文章: AGAL介绍系列文章(第一部分)AGAL介绍系列文章(第二 ...

  4. Oracle- 存储过程和异常捕捉

    这段时间晚上有时候去打打球,回家看看电视剧,日子一天天过…….学了点ORACLE存储过程基础,作一下备注,以便日后需查阅. 创建无参存储过程 create procedure p_myPro1 is ...

  5. Oracle中的AS和IS

    Oracle中的AS和IS是ORACLE为了方便而设置的同义词基本上没有不同 . 使用规则: 1.在创建存储过程(PROCEDURE)/函数(FUNCTION),以及自定义类型(TPYE)和包(PAC ...

  6. Swif基本语法以及与OC比较三

         (未 经 博 主 同 意,不 得 转 载 !)   ------------------------华丽分割线----------------------- // // main.swift ...

  7. DRM你又赢了:其API纳入HTML5标准

    摘要:W3C今天发布了一份加密媒体扩展工作草案(EME),将支持DRM多媒体数字内容,而且浏览器将无需使用Flash或Silverlight.EME定义了一系列API,允许JavaScript和HTM ...

  8. Windows Server 2008找回密码

    1.通过Windows Server 2008 R2的安装光盘引导计算机启动,映像加载完毕后 ,按 Shift+F10 ,打开命令提示符界面,进入Windows目录所在分区(cd windows\sy ...

  9. 【44】将与参数无关的代码抽离templates

    1.template是产生代码的代码,这就意味着源码看起来很少,生成的目标码大量膨胀. 2.考虑,如果两个方法有重复代码,我们会新建一个方法,把重复的代码放进去,原先两个方法调用第三个方法.如果两个类 ...

  10. android129 zhihuibeijing 聊天机器人

    上屏幕界面activity_main.xml: 语音识别界面 <LinearLayout xmlns:android="http://schemas.android.com/apk/r ...