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. Morris Traversal

    昨天临近要睡觉的时候做了一个leetcode题目,"Recover BST",算法很容易就想到了,直接找出两个异常点就好了,但是我写的算法是用栈实现的非递归遍历,空间复杂度是O(N ...

  2. Android实例-退出程序(XE8+小米2)

    unit Unit1; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Var ...

  3. [C语言 - 13] 运算符

    算术运算符 运算符的优先级 括号 > 正负 > 数学运算 > 位运算 > 数学对比 > 逻辑对比 > 条件运算 > 赋值运算   A.赋值运算符 复合赋值运算 ...

  4. SQLServer2005数据导入Mysql到详细教程

    如果转载请注明转载地址,谢谢. SQL SERVER数据导入MYSQL目录 1.Navicat for MySQL 版本10.0.9 2.创建目标数据库 3.创建正确的SQL SERVER数据库ODB ...

  5. Mysql 存储过程、函数、触发器和视图的权限检查

    当存储过程.函数.触发器和视图创建后,不单单创建者要执行,其它用户也可能需要执行,换句话说,执行者有可能不是创建者本身,那么在执行存储过程时,MySQL是如何做权限检查的? 在默认情况下,MySQL将 ...

  6. jQuery遍历json

    使用 each var anObject = {one:1,two:2,three:3}; $.each(anObject,function(name,value) { alert(name); al ...

  7. Codeforces Round #325 (Div. 2) F. Lizard Era: Beginning meet in the mid

    F. Lizard Era: Beginning Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/5 ...

  8. dojo(四):ajax请求

    储备知识 1.在介绍新版本的ajax请求之前,需要先了解一些dojo/Deferreds. 初次听到“Deferred”这个概念,可能会觉得这是一个神秘的东西.实际上它在执行异步操作的时候非常强大,例 ...

  9. 支持向量机(SVM)算法的matlab的实现

    支持向量机(SVM)的matlab的实现 支持向量机是一种分类算法之中的一个,matlab中也有对应的函数来对其进行求解:以下贴一个小例子.这个例子来源于我们实际的项目. clc; clear; N= ...

  10. 操作BLOB、CLOB、BFILE

    BFILE        二进制文件,存储在数据库外的操作系统文件,只读的.把此文件当二进制处理. BLOB        二进制大对象.存储在数据库里的大对象,一般是图像声音等文件. CLOB    ...