1.预算科的财力管理(tb_bgt_fund)有总财力,总财力拆分成科室财力。科室财力就是给各个科室的专管员(科长)用的钱,专管员拿到财力管理分配的钱之后,
把这些钱分给他下面的预算单位,预算单位通过项目(tb_bgt_item_info)跟专管员要钱,这个就是个审核的流程。
2.项目分为公共项目和基本项目。在新增公共项目的时候是先在tb_bgt_item里添加一条,然后在tb_bgt_item_info表里添加一条。
在添加基本项目的时候,不用在tb_bgt_item表里添加了,因为tb_bgt_item(项目主表)里有基本项目的数据了,所以只在tb_bgt_item_info(项目明细表)表中添加一条即可。
3.预算调整模块跟预算编制模块是同级的。预算编制是年初做的,预算调整是对年初的项目进行调整(调增或者调减)
4.审核过程中,要审核到申请数=建议数=控制数。此年初(或者年中)审核完成之后的流程就有指标了,指标就是额度(此单位能用的钱,例如100元)。有指标的同时也得有指标文,
指标文是个doc文件,里面描述的是科室信息,预算单位信息,项目信息,资金用途信息等
4.预算执行是对预算编制或者预算调整的执行,单位向上级申请花一些指标中的钱(我这里公有100元,现在申请花20元)
5.申请之后,就该真正的给钱了,就到了支付模块的计划额度下达了,汇总,送银行等,做完这一系列操作这笔钱就从国库拨款到单位了。
第二:
1.授权额度汇总的jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file ="../../../page/common/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript" src="<%=basePath%>/js/mofit/workflow.js"></script>
<script type="text/javascript" src="<%=path%>/js/tools.js"></script>
<!-- 基础数据弹出选择框的几个通用函数 -->
<script type="text/javascript" src="<%=path%>/js/baseDictDataTool.js"></script>
<script type="text/javascript" src="<%=path%>/js/const.js"></script>
<script type="text/javascript" src="<%=path%>/js/onlyinputnumber.js"></script>
<script type="text/javascript" src="<%=path%>/js/tools.js"></script>
<script type="text/javascript">
var rows=-1;
var flag = 0;
var agencyItemId = userLogonObj.agencyItemId;//userLogonObj是comm.jsp的东西,由于此页面include包含了comm.jsp,所以可以直接用
var agencyId=userLogonObj.agencyId;//获取单位id:l例如某单位的id是223
var agencyCode="";//登陆人。例如:133001
//var userType=userLogonObj.userType;//用户类型
/* AF.func("SetObjectProp", "condition \r\n visible \r\n true");
AF.func("SetObjectProp", "condition1 \r\n visible \r\n false");
/* 加载数据 */
var is_Tree=0;//左侧是否有树,0表示没树,1表示有树。(因为有树的时候跟没树的时候topbar的宽度是不一样的)
function OnReady(id){
if (id == 'AF') {
AF.func("Build", "<%=path%>/sz/xml/plan/authSum/authSumQuery_Tree.xml"); //左侧有树
AF.func("SetObjProp", "layout1 \r\n TR.row2 \r\n height \r\n 60"); //控制行高,因为有树,38就不够了
var depttreeurl = pubAct+"&busId=sys_7&elementcode=AGENCY_CODE&power=0&isTree=true";
AF.func("itemlist.expend", ""); //展开所有的节点
AF.func("dept_tree.InsertItem","0\r\n\r\n预算单位");
AF.func("dept_tree.Build",depttreeurl+"\r\n0");
var childId = AF.func("dept_tree.getChild", AF.func("dept_tree.getChild", 0));
AF.func("dept_tree.SetCurSel",childId);
agencyCode=AF.func("dept_tree.GetXMLProp",childId+"\r\n text").split("-")[0]
AF.func("itemlist.SetProp", "curselmode \r\n rows");//当前行或区域的显示模式rows - 允许多行选择(Ctrl、shift+鼠标);
AF.func("itemlist01.SetProp", "curselmode \r\n rows");
AF.func("itemlist02.SetProp", "curselmode \r\n rows");
AF.func("condition.zjxz.Filter","code=0||code=1||code=2||code=9");//
AF.func("condition2.zjxz.Filter","code=0||code=1||code=2||code=9");//
refreshData();
}
}
//var allotId="";
function OnEvent(id, Event, p1, p2, p3, p4){
// alert(Event);
<%-- if(Event=="condition2.DropdownSelChanged"){//选择task.xml中的下拉菜单(例如月份、资金性质)
if(p1=="dy_type"){
if(dy_type==1){
AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/SumOrder_dan.xml");
}
if(dy_type==2){
AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/payDetail_dan.xml"); /* 加载主xml*/
}
if(dy_type==3){
AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/payOrder_dan.xml");
}
}
} --%>
if(Event=="dept_tree.SelChanged"){//单位树选择变化 ,选择左侧树的
agencyItemId = p1;
//agencyId=p2.split("@")[0];
agencyCode=p2.split("@")[3];
if(p2.length==0){
agencyCode="";
}
refreshData();
}
if (id=='AF') {
if(Event=="topbar.EditChanged"){
if(p1=='whz'){//点击未汇总时候按钮的隐藏与显示。未汇总
flag = 0;//这里可以不写flag = 0;因为flag默认就是0
if(is_Tree==0){//左侧没树
AF.func("SetObjProp", "layout1 \r\n TR.row2 \r\n height \r\n 60"); //控制行高
}else if(is_Tree==1){//左侧有树
AF.func("SetObjProp", "layout1 \r\n TR.row2 \r\n height \r\n 60"); //控制行高
}
var btns = [ ["whz",'true'],["yhz",'true'],["hz",'true'],["fh",'true'],["wfimgbtn",'true'],["print",'false'],["printview",'false'],["dc",'false']];
buttonIsHide(btns);
is_visible(true,false,true,false);
refreshData();
}else if(p1=='yhz'){//已汇总
flag = 1;
if(is_Tree==0){//左侧没树
AF.func("SetObjProp", "layout1 \r\n TR.row2 \r\n height \r\n 60"); //控制行高:
}else if(is_Tree==1){//左侧有树
AF.func("SetObjProp", "layout1 \r\n TR.row2 \r\n height \r\n 60"); //控制行高:
}
var btns = [["whz",'true'],["yhz",'true'],["hz",'false'],["fh",'false'],["wfimgbtn",'false'],["print",'true'],["printview",'true'],["dc",'true']];
buttonIsHide(btns);
is_visible(false,true,false,true);
refreshData();
}
}else if(Event=="itemlist01.SelChanged"){//列表选择变化
//var row = AF.func("itemlist01.GetCurrentRow", "");//获取选中行,用逗号分隔
//var reqId= AF.func("itemlist01.GetCellData", row[i] + "\r\nCOLLECT_ID");
var row = AF.func("itemlist01.findAll", "chk==1");
var rows = row.split(",");//必须分开写.获取的行,不是该行的id
for(var i=0;i<rows.length;i++){
if(i==rows.length-1){//只要最后一个
var reqId= AF.func("itemlist01.GetCellData", rows[i] + "\r\nCOLLECT_ID");
}
}
//查详情(查看汇总的明细)
if(rows.length>=1&&p1!=-1){//当选中一个的时候,长度就是1,因此只要有选中的,集合rows的长度一定大于1。p1=0或者1表示选择,p1=-1表示取消选择
AF.func("itemlist02.Load", pubAct+"&busId=authSum&method=hasSumQuery_mx&reqId="+reqId+"&isList=true&tempparam="+ Math.random());
}else{
reqId=-1;
AF.func("itemlist02.Load", pubAct+"&busId=authSum&method=hasSumQuery_mx&reqId="+reqId+"&isList=true&tempparam="+ Math.random());
}
}else if(Event == 'condition.ButtonClicked'){
if(p1=='query'){ //根据条件查询事件,未汇总
refreshData();
}
}else if(Event == 'condition2.ButtonClicked'){
if(p1=='querySum'){ //根据条件查询事件,已汇总
refreshData();
}
}else if(Event == 'topbar.ButtonClicked'){
if(p1=='hz'){ //汇总
authSum();
}
if(p1=='print'){//打印(批量打印)
printreport();
//setTimeout(callFuncTimeOutDY,1000);//不延时就无法打印
//updateStatus();
}
if(p1=='printview'){//打印预览
var dy_type = AF.func("condition2.GetValue", "dy_type");
//alert("leixing:"+dy_type);
var row = AF.func("itemlist01.findAll", "chk==1");
var rows = row.split(",");
if(row == ''||rows.length!=1){
showMsgDialog(basepath,AF,"请选择一条数据!",'info');
return;
}
var allotId = AF.func("itemlist01.GetCellData", row+" \r\n COLLECT_ID");
if(dy_type==1){
print('sumOrder.jsp');//打印预览是去每个小jsp中去预览,因此写了三个小jsp
}
if(dy_type==2){
print('payDetail.jsp');
}
if(dy_type==3){
print('payOrder.jsp');
}
}
if(p1=='dc'){//导出
printreport();
setTimeout(callFuncTimeOutDC,1000);//不延时就无法导出
}
}else if(Event=="rptdefine.Printed"){//打印结束的事件,打印结束了就可以去修改状态了
var dy_type = AF.func("condition2.GetValue", "dy_type");
var row = AF.func("itemlist01.findAll", "chk==1");
var rows = row.split(",");//必须分开写.获取的行,不是该行的id
if(rows == "" || rows == null){
//AF.func("MsgFloat", "请您首先选中一条记录!");
showMsgDialog(basepath,AF,"请选择至少一条数据!",'info');
return;
}
//var allotId = AF.func("itemlist01.GetCellData", row+" \r\n COLLECT_ID");
var ids = '';
for(var i=0;i<rows.length;i++){
var allotId= AF.func("itemlist01.GetCellData", rows[i] + "\r\nCOLLECT_ID");
ids += allotId +",";
}
var url = pubAct;
pdata = {/*pdata是参数集合,对应dao层方法的参数param */
busId:"authSum",
method:"updateStatus", //修改打印状态对应的后台方法
dy_type:dy_type,//打印类型
ids:ids,
allotId:allotId//主键
}
$.post(url,pdata,function(data){/*data对应着updateStatus方法的返回值 */
if(data&&data.msg){
showMsgDialog(basepath,AF,data.msg,'info'); //弹出打印提示信息.msg是dao层的返回值
}else{
showMsgDialog(basepath,AF,"修改失败!",'info');//错误的时候没有返回值,因此自己手写了修改失败四个字
return;
}
},"json");
}
}
}
//判断是否隐藏的函数
function is_visible(f1,f2,f3,f4){
AF.func("SetObjectProp", "condition \r\n visible \r\n"+f1);
AF.func("SetObjectProp", "condition2 \r\n visible \r\n"+f2);
AF.func("SetObjectProp", "itemlist \r\n visible \r\n "+f3);
AF.func("SetObjectProp", "aa \r\n visible \r\n "+f4);
}
//打印和导出公用的的部分,不是批量打印
<%-- function printreport(){
var dy_type = AF.func("condition2.GetValue", "dy_type");
var row = AF.func("itemlist01.findAll", "chk==1");
var rows = row.split(",");
if(row == "" || rows == null){
//AF.func("MsgFloat", "请您首先选中一条记录!");
showMsgDialog(basepath,AF,"请选择一条数据!",'info');
return;
}
var allotId = AF.func("itemlist01.GetCellData", row+" \r\n COLLECT_ID");
var dy_date = AF.func("condition2.GetValue", "dy_date");
if(dy_type==1){
AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/SumOrder_dan.xml");
AF.func("rptdefine.SetSource", "ds1\r\n"+pubAct+"&busId=authSum&method=querySumOrder&allotId="+allotId+"&dy_date="+dy_date+"&isList=true&tempparam="+ Math.random());
AF.func("rptdefine.calc", "mode=asynch;range=current");//计算
}
if(dy_type==2){
AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/payDetail_dan.xml"); /* 加载主xml*/
AF.func("rptdefine.SetSource", "ds1\r\n"+pubAct+"&busId=authSum&method=queryPayDetail&allotId="+allotId+"&dy_date="+dy_date+"&isList=true&tempparam="+ Math.random());
AF.func("rptdefine.calc", "mode=asynch;range=current");//计算
}
if(dy_type==3){
AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/payOrder_dan.xml");
AF.func("rptdefine.SetSource", "ds1\r\n"+pubAct+"&busId=authSum&method=queryPayOrder&allotId="+allotId+"&dy_date="+dy_date+"&isList=true&tempparam="+ Math.random());
AF.func("rptdefine.calc", "mode=asynch;range=current");//计算
}
} --%>
//打印(批量打印)
function printreport(){
var dy_type = AF.func("condition2.GetValue", "dy_type");
var row = AF.func("itemlist01.findAll", "chk==1");
var rows = row.split(",");
if(row == "" || rows == null){
//AF.func("MsgFloat", "请您首先选中一条记录!");
showMsgDialog(basepath,AF,"请选择一条数据!",'info');
return;
}
//var allotId = AF.func("itemlist01.GetCellData", row+" \r\n COLLECT_ID");
var allotId="";
var dy_date = AF.func("condition2.GetValue", "dy_date");
if(dy_type==1){
<%-- AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/SumOrder_dan.xml");
AF.func("rptdefine.SetSource", "ds1\r\n"+pubAct+"&busId=authSum&method=querySumOrder&allotId="+allotId+"&dy_date="+dy_date+"&isList=true&tempparam="+ Math.random());
AF.func("rptdefine.calc", "mode=asynch;range=current");//计算 --%>
/*上面的是打印,下面的批量打印 */
AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/SumOrder_dan.xml"); //打开xml
AF.func("rptdefine.BeginBatchPrint", "isShareBlankPart=true"); //开始批打印,begin
for(var i=0;i<rows.length;i++ ) { //通常是循环
allotId = AF.func("itemlist01.GetCellData", rows[i]+" \r\n COLLECT_ID");
AF.func("rptdefine.SetSource", "ds1\r\n"+pubAct+"&busId=authSum&method=querySumOrder&allotId="+allotId+"&dy_date="+dy_date+"&isList=true&tempparam="+ Math.random()); //设置查询取数条件
AF.func("rptdefine.Calc", ""); //填充数据,也就是计算
AF.func("rptdefine.Print", ""); //在批中,该函数并没有实际的打印动作,并且也不需要参数,但该步骤必不可少 alert("f="+f);
}
AF.func("rptdefine.EndBatchPrint", "");//打印结束
}
if(dy_type==2){
<%-- AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/payDetail_dan.xml"); /* 加载主xml*/
AF.func("rptdefine.SetSource", "ds1\r\n"+pubAct+"&busId=authSum&method=queryPayDetail&allotId="+allotId+"&dy_date="+dy_date+"&isList=true&tempparam="+ Math.random());
AF.func("rptdefine.calc", "mode=asynch;range=current");//计算 --%>
AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/payDetail_dan.xml"); //打开xml
AF.func("rptdefine.BeginBatchPrint", "isShareBlankPart=true"); //开始批打印,begin
for(var i=0;i<rows.length;i++ ) { //通常是循环
allotId = AF.func("itemlist01.GetCellData", rows[i]+" \r\n COLLECT_ID");
AF.func("rptdefine.SetSource", "ds1\r\n"+pubAct+"&busId=authSum&method=queryPayDetail&allotId="+allotId+"&dy_date="+dy_date+"&isList=true&tempparam="+ Math.random()); //设置查询取数条件
AF.func("rptdefine.Calc", ""); //填充数据,也就是计算
AF.func("rptdefine.Print", ""); //在批中,该函数并没有实际的打印动作,并且也不需要参数,但该步骤必不可少 alert("f="+f);
}
AF.func("rptdefine.EndBatchPrint", "");//打印结束
}
if(dy_type==3){
<%-- AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/payOrder_dan.xml");
AF.func("rptdefine.SetSource", "ds1\r\n"+pubAct+"&busId=authSum&method=queryPayOrder&allotId="+allotId+"&dy_date="+dy_date+"&isList=true&tempparam="+ Math.random());
AF.func("rptdefine.calc", "mode=asynch;range=current");//计算 --%>
AF.func("rptdefine.Build", "<%=path%>/sz/xml/plan/authSum/authSum.xml"); //打开xml
AF.func("rptdefine.BeginBatchPrint", "isShareBlankPart=true"); //开始批打印,begin
for(var i=0;i<rows.length;i++ ) { //通常是循环
allotId = AF.func("itemlist01.GetCellData", rows[i]+" \r\n COLLECT_ID");
AF.func("rptdefine.SetSource", "ds1\r\n"+pubAct+"&busId=authSum&method=queryPayOrder&allotId="+allotId+"&dy_date="+dy_date+"&isList=true&tempparam="+ Math.random()); //设置查询取数条件
AF.func("rptdefine.Calc", ""); //填充数据,也就是计算
AF.func("rptdefine.Print", ""); //在批中,该函数并没有实际的打印动作,并且也不需要参数,但该步骤必不可少 alert("f="+f);
}
AF.func("rptdefine.EndBatchPrint", "");//打印结束
}
}
//导出的一部分,此部分需要 延时加载
function callFuncTimeOutDC(){
AF.func("rptdefine.callfunc","105");//105表示弹出的是导出框
}
//修改打印状态
/* function updateStatus(){
var dy_type = AF.func("condition2.GetValue", "dy_type");
var row = AF.func("itemlist01.findAll", "chk==1");
var rows = row.split(",");//必须分开写.获取的行,不是该行的id
if(row == "" || rows == null){
//AF.func("MsgFloat", "请您首先选中一条记录!");
showMsgDialog(basepath,AF,"请选择一条数据!",'info');
return;
}
var allotId = AF.func("itemlist01.GetCellData", row+" \r\n COLLECT_ID");
var url = pubAct;
pdata = {//pdata是参数集合,对应dao层方法的参数param
busId:"authSum",
method:"updateStatus", //修改打印状态对应的后台方法
dy_type:dy_type,//打印类型
allotId:allotId//主键
}
$.post(url,pdata,function(data){//data对应着updateStatus方法的返回值
if(data&&data.msg){
showMsgDialog(basepath,AF,data.msg,'info'); //弹出打印提示信息
}else{
showMsgDialog(basepath,AF,"修改失败!",'info');
return;
}
},"json");
} */
//打印预览的功能
function print(url){
var dy_date = AF.func("condition2.GetValue", "dy_date");//打印日期
var dy_type = AF.func("condition2.GetValue", "dy_type");//打印类型
var row = AF.func("itemlist01.findAll", "chk==1");
var allotId = AF.func("itemlist01.GetCellData", row+" \r\n COLLECT_ID");
//alert(dy_date+" ----- "+dy_type);
url=url+"?allotId="+allotId+"&dy_date="+dy_date;
//两种弹框的方式
/* window.open(url,"window",
"height=630,width=950,status=yes,toolbar=no,menubar=no,location=no,resizable=yes,minimize=yes,maximize=yes"); */
showModule(url,1400,700,"");
}
//按钮的显示与隐藏
function buttonIsHide(btns){
var handle = AF.func("GetHandle", "");
for(var i=0;i<btns.length;i++)
{
AF.func(handle + "topbar.SetObjectProp",btns[i][0]+"\r\nvisible\r\n"+btns[i][1]);
}
}
//汇总
function authSum(){
rows = AF.func("itemlist.findAll", "chk==1");
rows = rows.split(",");//必须分开写.获取的行,不是该行的id
if(rows == "" || rows == null){
//AF.func("MsgFloat", "请您首先选中一条记录!");
showMsgDialog(basepath,AF,"请选择一条数据!",'info');
return;
}
var ids = '';//存放主键
var aduit_sum_s='';//存放审批金额
for(var i=0;i<rows.length;i++){
var appId= AF.func("itemlist.GetCellData", rows[i] + "\r\nPLAN_ID");//获得当前选中行的主键
var aduit_sum= AF.func("itemlist.GetCellData", rows[i] + "\r\nADUIT_SUM");//获取审批金额,用于判断正负
ids += appId +",";
aduit_sum_s+= aduit_sum +",";
}
var hzjc = AF.func("condition.GetValue", "hzjc");//汇总级次
var pdata = {};
pdata.busId = 'authSum';
pdata.method='sum';
pdata.ids=ids;
pdata.hzjc=hzjc;
pdata.aduit_sum_s=aduit_sum_s;
var url = pubAct;
$.post(url,pdata,function(data){
if(data&&data.msg){
refreshData();
AF.func("MessageBoxFloat", data.msg+"\r\n title=Prompt; icon=Information; hold=3");
}else{
showMsgDialog(basepath,AF,data.msg,'info');
}
},"json");
}
//汇总的回调方法
function onFinishedAuthSum(data){
flag=0;
refreshData();
//AF.func("SelectRow",rows);
if(data.msg){
AF.func("MsgFloat", data.msg+"\r\n title=Success; icon=Info; hold=3.5;center=true");//汇总成功
} else{
showMsgDialog(basepath,AF,data.msg,'info');//汇总失败
}
}
//刷新数据
function refreshData(){
if(flag==0){//刚加载的时候或者点击未汇总的时候
var startdate = AF.func("condition.GetValue", "startdate");//起始时间
var enddate = AF.func("condition.GetValue", "enddate");//结束时间
var yf = AF.func("condition.GetValue", "yf");//月份
var zjxz = AF.func("condition.GetValue", "zjxz");//资金性质
var dlyh = AF.func("condition.GetValue", "dlyh");//代理银行
if(enddate<startdate){
showMsgDialog(basepath,AF,'开始日期不能大于结束日期','info');
return false;
}
//AF.func("itemlist.Load", pubAct+"&busId=authSum&method=queryListData&startdate="+startdate+"&enddate="+enddate+"&yf="+yf+"&zjxz="+zjxz+"&dlyh="+dlyh+"&hzjc="+hzjc+"&isList=true&tempparam="+ Math.random());
AF.func("itemlist.Load", pubAct+"&busId=authSum&method=queryListData&startdate="+startdate+"&enddate="+enddate+"&yf="+yf+"&zjxz="+zjxz+"&dlyh="+dlyh+"&agencyId="+agencyId+"&agencyCode="+agencyCode+"&isList=true&tempparam="+ Math.random());
}else if(flag==1){//已汇总
var startdate = AF.func("condition2.GetValue", "startdate");//起始时间
var enddate = AF.func("condition2.GetValue", "enddate");//结束时间
var dlyh = AF.func("condition2.GetValue", "dlyh");//代理银行
var zjxz = AF.func("condition2.GetValue", "zjxz");//资金性质
var zt = AF.func("condition2.GetValue", "zt");//状态
if(enddate<startdate){
showMsgDialog(basepath,AF,'开始日期不能大于结束日期','info');
return false;
}
//alert(startdate+" "+enddate+" "+dlyh+" "+zjxz+" "+zt);
//AF.func("aa.itemlist01.Load",'{"Record": [{"MONTH":"5"}]}');//用josn写假数据进行测试,如果前台没有错误的话,浏览器就能显示出这个5来
//AF.func("itemlist01.Load", pubAct+"&busId=authSum&method=hasSumQuery&isList=true&tempparam="+ Math.random());//这是没有查询条件时候的请求
AF.func("itemlist01.Load", pubAct+"&busId=authSum&method=hasSumQuery&startdate="+startdate+"&enddate="+enddate+"&zt="+zt+"&zjxz="+zjxz+"&dlyh="+dlyh+"&agencyId="+agencyId+"&agencyCode="+agencyCode+"&isList=true&tempparam="+ Math.random());
AF.func("itemlist01.SelectRow",0);
}
}
</script>
<title>授权额度汇总信息</title>
</head>
<body class="easyui-layout" style="overflow:hidden;">
<!-- <div data-options="region:'west',border:false,split:true" style="height:100%;width:200px;" >
<script>insertFreeForm('DTree', '')</script>script在第一次加载的时候被执行,insertFreeForm是硕正的公有方法,里面参数分别表示id和param
</div> -->
<div data-options="region:'center',border:false" fit=true style="overflow:hidden;">
<script>insertFreeForm('AF')</script>
</div>
<div id="printflag" style="display:none" ></div>
</body>
</html>
2.授权额度汇总的dao
package com.mofit.plan.authSum.dao;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.common.constants.CommonConst;
import com.common.util.DBHelper;
import com.common.util.PubTool;
import com.common.util.StringUtil;
import com.frameworkset.common.poolman.PreparedDBUtil;
import com.mofit.common.datarule.service.DataRuleService;
import com.mofit.common.util.CommonConstant;
@SuppressWarnings("all")
public class AuthSumDao {
/**
* 功能码:busId='authSum'
* 未汇总
* @param cp
* @param param
* @return ret
* @throws Exception
*/
public Map<String, Object> queryListData (Map<String, Object> cp,Map<String, Object> param) throws Exception{
Map<String, Object> ret = new HashMap<String, Object>( );
Map userlogonEntity=(Map)cp.get("user");
String annual = PubTool.getMapValue(userlogonEntity, "bgtAnnual", "");
String userType=PubTool.getMapValue(userlogonEntity, "userType", "");
//String agencyId =PubTool.getMapValue(userlogonEntity,"agencyId",""); //预算单位ID //233
//String agencyCode =PubTool.getMapValue(userlogonEntity,"agencyCode","");//133001
String agencyId =PubTool.getMapValue(param, "agencyId", "");
String agencyCode=PubTool.getMapValue(param, "agencyCode", "");
StringBuilder sql = new StringBuilder();
List params = new ArrayList();//目的是动态添加where条件
String yf = PubTool.getMapValue(param, "yf", "");//获取map集合中 的值
String zjxz = PubTool.getMapValue(param, "zjxz", "");
String dlyh = PubTool.getMapValue(param, "dlyh", "");
String enddate = PubTool.getMapValue(param, "enddate", "");
String startdate = PubTool.getMapValue(param, "startdate", "");
sql.append("select v.PLAN_ID PLAN_ID,");//计划编号
sql.append("v.BANK_NAME,");//代理银行
sql.append("v.PAY_MONTH PAY_MONTH,");//支出时限
sql.append("v.PLAN_MONTH PLAN_MONTH,");//月份
sql.append("v.Bgt_FileName Bgt_FileName,");//指标文号
sql.append("v.BDGSOURCE_CODE ||'--'|| v. BDGSOURCE_NAME AS AGENCY_CODE_NAME,");//预算单位
sql.append("v.ADUIT_SUM ADUIT_SUM,");//审批金额
sql.append("v.EXPFUNC_CODE || '--' || v.EXPFUNC_NAME AS EXPFUNC_CODE_NAME,");//功能分类
sql.append("v.ITEM_NAME ITEM_CODE_NAME,");//预算项目
sql.append("v.PAYTYPE_NAME PAYTYPE_NAME,");//支付方式
sql.append("v.PAYKIND_NAME PAYKIND_NAME,");//支出类型
sql.append("v.FUNDTYPE_CODE || '--' || v.FUNDTYPE_NAME AS FUNDTYPE_CODE_NAME,");//资金性质
sql.append("v.MOFDEPT_NAME MOFDEPT_NAME,");//业务科室
sql.append("v.BDGSOURCE_CODE || '--' || v.BDGSOURCE_NAME AS BDGSOURCE_CODE_NAME,");//预算来源
sql.append("v.FUNDCLASS_CODE || '--' || v.FUNDCLASS_NAME AS FUNDCLASS_CODE_NAME,");//经费类型
sql.append("v.CONTRACT_ID CONTRACT_ID,");//合同编号
sql.append("v.ORDER_DATE ORDER_DATE,");//下达日期
sql.append("decode(v.IS_JIJIAN,0,'是',1,'否') AS IS_JIJIAN ");//基建
sql.append(" from VW_TB_PLAN_INFO v ");//计划表试图
sql.append(" where v.IS_SUM=0 and v.PAYTYPE_ID=3");//未汇总,支付方式=授权支付
// sql.append(" and v.FLOW_STATUS=2 and v.ANNUAL=extract(year from sysdate)");//不用判断流程状态为2,我这里只要是下达了的数据,流程状态肯定为2,因此我要判断是否下达
sql.append(" and v.IS_ORDER=1 and v.ANNUAL=?");//是否下达、当前年度
params.add(annual);
if(!startdate.equals("")){ //开始时间,在视图里已经把该字段转化成字符串类型了,因此不能to_date了
//sql.append(" and v.ORDER_DATE >= to_date(?,'YYYY-MM-DD')");
sql.append(" and v.ORDER_DATE >=?");
params.add(startdate.replace('.', '-'));//startdate是个字符串2015.05.12,而视图中的ORDER_DATE是字符串类型的,值为2015-05-12,因此要把.替换成-
}
if(!enddate.equals("")){
sql.append(" and v.ORDER_DATE <= ?");
params.add(enddate.replace('.', '-'));
}
if(!yf.equals("")&&!yf.equals("0")){ //月份
System.out.println(param.get("yf").toString());
sql.append(" and v.plan_month=?" );
params.add(yf);
}
if(!zjxz.equals("")&&!zjxz.equals("0")){ //资金性质,测试的时候找‘11公共财政预算资金’,数据库对应着18
System.out.println(param.get("zjxz").toString());
sql.append(" and v.FUNDTYPE_ID=?" );
params.add(zjxz);
}
/* if(!param.get("hzjc").toString().equals("")){ //汇总级次(判断是按部门汇总还是按单位汇总),在vw_plan_info中没有汇总级次字段,汇总级次是通过预算单位来体现的(部门汇总的code是0,单位汇总的code字段是1,因此可以通过code字段)
System.out.println(param.get("hzjc").toString());
sql.append(" and v.PUBAGENCY_ISLEAF=?" );//测试的时候输入1单位汇总
params.add(param.get("hzjc").toString());
}*/
if(!dlyh.equals("")&&!dlyh.equals("0")){ //代理银行,code为001的对应着id为58,页面显示的是001,传到后台的是58
sql.append(" and v.BANK_CODE=?" );//测试的时候输入001
params.add(dlyh);
}
//数据权限
CommonConstant.executeDataRule(cp,params,sql,agencyCode, "");
sql.append(" order by AGENCY_CODE ASC,PLAN_ID DESC ");
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
}else{
//throw new BizException("未找到信息!");
ret.put("items", new ArrayList());
}
return ret;
}
/**汇总第一步:拼接待汇总sql(包括正负sql)(不管用到几个sql,这里把这两个sql(正的和负的)都先找(写)出来。然后在insert的时候在判断是不是用到了。)
* @param cp
* @param param
* @return sqlMap
* @throws Exception
*/
private Map<String,String> UnionAuthSql(Map<String, Object> cp,Map<String, Object> param)
{
Map<String,String> sqlMap=new HashMap<String,String>();
StringBuffer addsql=new StringBuffer();
StringBuffer subsql=new StringBuffer();
Map<String, Object> userlogonEntity = (Map<String, Object>) cp.get("user");//获取用户信息
String annual = PubTool.getMapValue(userlogonEntity, "bgtAnnual", ""); //年度
//第一步:获取前台的变量
String hzjc = PubTool.getMapValue(param, "hzjc", "").trim();//从前台下拉菜单中获取汇总级次(0或者1),也就是预算单位
String str=(hzjc.equals("0")?"substr(AGENCY_CODE,1,3)":"substr(AGENCY_CODE,1,6)");//判断汇总级次是0的话说明是部门汇总,截取前三位字节;1表示是单位汇总(例如133001),截取前六位。看表t_pubagency中的code字段
String ids[] = ((String)param.get("ids")).split(",");//前台页面的主键,多个值
StringBuffer mainsql=new StringBuffer("select sum(Aduit_Sum) as sum_money, AGENCY_ID,ANNUAL,plan_month,FUNDTYPE_CODE,BANK_CODE,IS_JIJIAN,"+str+" AGENCY_CODE from VW_TB_PLAN_INFO where annual="+annual+" and plan_id in( ");
for(int x=0;x<ids.length;x++){
mainsql.append(Integer.parseInt(ids[x])+",");
}
mainsql=mainsql.deleteCharAt(mainsql.length()-1);
mainsql=mainsql.append(")");
String sumconditionsql=" and Aduit_Sum>0 ";
String subconditionsql=" and Aduit_Sum<0 ";
String groupsql="group by(plan_month,FUNDTYPE_CODE, AGENCY_ID,ANNUAL,BANK_CODE,IS_JIJIAN,"+str+")";//月份,资金性质,预算单位,年度,代理银行,是否基建,汇总级次
sqlMap.put("addsql", addsql.append(mainsql).append(sumconditionsql).append(groupsql).toString());
sqlMap.put("subsql", subsql.append(mainsql).append(subconditionsql).append(groupsql).toString());
return sqlMap;
}
/**汇总第二步:汇总后的结果插入到汇总表中
* @param sql 待插入sql
* @param cp
* @param param
* @return
* @throws Exception
*/
private String InsertQuotaCollect(String sql,Map<String, Object> cp,Map<String, Object> param)throws Exception{
PreparedDBUtil pdb = DBHelper.query(sql.toString());
Map userlogonEntity=(Map)cp.get("user");
String seq="";
String userName=PubTool.getMapValue(userlogonEntity,"userName",""); //机构id;//获取cp中的用户名作为汇总人姓名,在insert汇总表的时候要用到
String ids[] = ((String)param.get("ids")).split(",");//前台页面的主键,多个值
String hzjc = PubTool.getMapValue(param, "hzjc", "").trim();//从前台下拉菜单中获取汇总级次(0或者1),也就是预算单位
String str=(hzjc.equals("0")?"substr(AGENCY_CODE,1,3)":"AGENCY_CODE");//判断汇总级次是0的话说明是部门汇总,截取前三位字节;1表示是单位汇总(例如133001),截取前六位。看表t_pubagency中的code字段
if(pdb!=null&&pdb.size()>0){
for(int x=0;x<pdb.size();x++){
//1.汇总表的insert语句
seq = DBHelper.getSeqNextVal("SEQ_TB_QUOTA_COLLECT");//汇总表序列
StringBuffer collectsql=new StringBuffer();
collectsql.append("insert into TB_QUOTA_COLLECT(collect_id,agency_id,fundtype_id,annual,quota_month,collect_sum,collect_name,is_jijian,BANK_CODE,agency_code,collect_date) values(");
collectsql.append(seq+",");
collectsql.append(pdb.getObject(x, 1)+",");
collectsql.append(pdb.getObject(x, 4)+",");
collectsql.append(pdb.getObject(x, 2)+",");
collectsql.append("'"+pdb.getObject(x, 3)+"'"+",");
collectsql.append(pdb.getFloat(x, 0)+",");
collectsql.append("'"+userName+"',");
collectsql.append(pdb.getObject(x,6)+",");
collectsql.append("'"+pdb.getObject(x, 5)+"'"+",");
collectsql.append("'"+pdb.getObject(x, 7)+"'"+",");
collectsql.append("sysdate)");//后来追加银行id
DBHelper.insert(collectsql.toString());
//2.计划表的update语句
//String hzjc2 = PubTool.getMapValue(param, "hzjc", "").trim();
StringBuffer plansql=new StringBuffer();
plansql.append("update tb_plan_info set COLLECT_ID=?,IS_SUM=1 ");
plansql.append(" where plan_id in(");
plansql.append(" select plan_id from vw_tb_plan_info where ");
plansql.append(" PLAN_MONTH="+pdb.getObject(x, 3) );//月份
plansql.append(" and FUNDTYPE_CODE="+pdb.getObject(x, 4) );//资金性质
plansql.append(" and AGENCY_id="+pdb.getObject(x, 1));//所属单位流水号id-----pdb.getObject(x, 1),pdb.getObject(x, 7)
plansql.append(" and ANNUAL="+pdb.getObject(x, 2));//年度
plansql.append(" and BANK_CODE="+pdb.getObject(x, 5));//代理银行
plansql.append(" and IS_JIJIAN="+pdb.getObject(x, 6));//是否基建
plansql.append(" and "+str+"="+pdb.getObject(x, 7));//汇总级次
if(sql.contains(" and Aduit_Sum>0")){//这个是在UnionAuthSql方法中的select语句中的
plansql.append(" and aduit_sum>0");//判断汇总金额大于0
}else{
plansql.append(" and aduit_sum<0");//判断汇总金额大于0
}
//sql3.append(")");
plansql.append(" and plan_id in(");
for(int y=0;y<ids.length;y++){
plansql.append(Integer.parseInt(ids[y])+",");//此时在最后的时候多了一个逗号
}
plansql=plansql.deleteCharAt(plansql.length()-1);
plansql.append("))");
DBHelper.update(plansql.toString(),seq);//给主键传值
}
}
return seq;
}
/**功能码:busId='authSum'
* 汇总(汇总条件按照代理银行,资金性质,预算单位,月份进行汇总),审批金额的正的与负的分别汇总,是否基建
* @param cp
* @param param
* @return ret
* @throws Exception
*/
public Map<String, Object> sum(Map<String, Object> cp,Map<String, Object> param)throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
Map<String,String> sqlMap=UnionAuthSql(cp,param);
//循环取出正负sql
for(Map.Entry<String, String> entry:sqlMap.entrySet()){
String seq=InsertQuotaCollect(entry.getValue(),cp,param);
//updatePlanInfo(seq,entry.getValue(),cp,param);
}
ret.put("msg","汇总成功!");
return ret;
}
/**
* 功能码:busId='authSum'
* 已汇总的查询
* @param cp
* @param param
* @return ret
* @throws Exception
*/
public Map<String, Object> hasSumQuery(Map<String, Object> cp,Map<String, Object> param)
throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
Map userlogonEntity=(Map)cp.get("user");
String annual = PubTool.getMapValue(userlogonEntity, "bgtAnnual", "");
String userType = PubTool.getMapValue(userlogonEntity, "userType", "");
String agencyId =PubTool.getMapValue(userlogonEntity, "agencyId", "");
String agencyCode =PubTool.getMapValue(param, "agencyCode", "");
//String agencyId =PubTool.getMapValue(userlogonEntity,"agencyId",""); //预算单位ID //233
/* String dlyh = PubTool.getMapValue(param, "dlyh", "");//代理银行
String zt = PubTool.getMapValue(param, "zt", "");//状态
String zjxz = PubTool.getMapValue(param, "zjxz", "");//资金性质
String enddate = PubTool.getMapValue(param, "enddate", "");//开始时间
String startdate = PubTool.getMapValue(param, "startdate", "");//结束时间
*/ sql.append("select t.COLLECT_ID COLLECT_ID, ");//汇总id
sql.append("t.QUOTA_MONTH QUOTA_MONTH,");//月份
sql.append("(select T_PUBBANK.NAME FROM T_PUBBANK WHERE t.BANK_CODE = T_PUBBANK.CODE) BANK_NAME,");//银行
sql.append("(select T_PUBAGENCY.Code ||'-'|| T_PUBAGENCY.Name from T_PUBAGENCY where T_PUBAGENCY.id =t.AGENCY_ID) AGENCY_CODE_NAME,");//预算单位
sql.append(" t.COLLECT_SUM COLLECT_SUM,");//金额
sql.append("(select T_PUBFUNDTYPE.Code ||'-'|| T_PUBFUNDTYPE.Name from T_PUBFUNDTYPE where T_PUBFUNDTYPE.Id = t.FUNDTYPE_ID) FUNDTYPE_CODE_NAME,");//资金性质
sql.append("t.COLLECT_NAME COLLECT_NAME,");//汇总人
sql.append("to_char(t.COLLECT_DATE,'YYYY-MM-dd') as COLLECT_DATE ");//汇总日期。即使不使用to_char,在oracle中也能查出来,但是现在必须加上to_cahr,目的是把取到的日期转化成字符串,因为硕正里只认识字符串
sql.append("from tb_quota_collect t ");
sql.append(" where 1=1 ");
sql.append(" and ANNUAL=? ");
params.add(annual);
if(!param.get("startdate").toString().equals("")){
sql.append(" and to_char(t.COLLECT_DATE,'YYYY-MM-dd')>=? ");
params.add(param.get("startdate").toString().replace('.', '-'));
}
if(!param.get("enddate").toString().equals("")){
sql.append(" and to_char(t.COLLECT_DATE,'YYYY-MM-dd')<=? ");
params.add(param.get("enddate").toString().replace('.', '-'));
}
if(!param.get("dlyh").toString().equals("")&&!param.get("dlyh").toString().equals("0")){
//System.out.println("--------代理银行:"+param.get("dlyh").toString());
sql.append(" and t.BANK_CODE=?");//判断银行
params.add(param.get("dlyh").toString());
}
if(!param.get("zjxz").toString().equals("")&&!param.get("zjxz").toString().equals("0")){
sql.append(" and t.FUNDTYPE_ID=?");//判断资金性质
params.add(param.get("zjxz").toString());
}
if(!param.get("zt").toString().equals("")&&!param.get("zt").toString().equals("0")){
String zt=param.get("zt").toString();
if(zt.equals("1"))
sql.append(" and (SQHZ_PRINTFLAG=0 or SQZF_PRINTFLAG=0 or DWSQ_PRINTFLAG=0)");//1.待处理汇总计划
if(zt.equals("2"))
sql.append(" and SQHZ_PRINTFLAG=0");//2.未打印授权汇总清算通知单
if(zt.equals("3"))
sql.append(" and DWSQ_PRINTFLAG=0");//3.未打印单位授权明细单
if(zt.equals("4"))
sql.append(" and SQZF_PRINTFLAG=0");//4.未打印授权支付通知单
}
//数据权限
CommonConstant.executeDataRule(cp,params,sql,agencyCode, "");
sql.append(" order BY t.COLLECT_ID DESC ");
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
}else{
ret.put("items", new ArrayList());
}
return ret;
}
/**功能码:busId='authSum'
* 功能:已汇总的明细查询
* @param cp
* @param param
* @return ret
* @throws Exception
*/
public Map<String, Object> hasSumQuery_mx(Map<String, Object> cp,Map<String, Object> param)
throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
StringBuilder sql = new StringBuilder();
String reqId = PubTool.getMapValue(param, "reqId", "");//
List params = new ArrayList();
sql.append("select v.PLAN_ID PLAN_ID,");//计划编号
sql.append("(select name from T_PUBBANK where v.BANK_CODE=T_PUBBANK.code) bank_Name,");//开户银行名称
sql.append("v.PAY_MONTH PAY_MONTH,");//支出时限
//sql.append(" (select distinct t.name from t_dicenumitem t where t.code=v.plan_month and t.elementcode='MONTH') PLAN_MONTH, ");
sql.append("v.PLAN_MONTH PLAN_MONTH,");//月份
sql.append("v.BGT_FILENAME,");//指标文号
sql.append("v.BDGSOURCE_CODE ||'--'|| v. BDGSOURCE_NAME AS AGENCY_CODE_NAME,");//预算单位
sql.append("v.ADUIT_SUM ADUIT_SUM,");//审批金额
sql.append("v.EXPFUNC_CODE ||'--'|| v.EXPFUNC_NAME AS EXPFUNC_CODE_NAME,");//功能分类
sql.append("v.ITEM_NAME ITEM_CODE_NAME,");//预算项目
sql.append("v.PAYTYPE_NAME PAYTYPE_NAME,");//支付方式
sql.append("v.PAYKIND_NAME PAYKIND_NAME,");//支出类型
sql.append("v.FUNDTYPE_CODE ||'--'|| v.FUNDTYPE_NAME AS FUNDTYPE_CODE_NAME,");//资金性质
sql.append("v.MOFDEPT_NAME MOFDEPT_NAME,");//业务科室
sql.append("v.BDGSOURCE_CODE ||'--'|| v.BDGSOURCE_NAME AS BDGSOURCE_CODE_NAME,");//预算来源
sql.append("v.FUNDCLASS_CODE ||'--'|| v.FUNDCLASS_NAME AS FUNDCLASS_CODE_NAME,");//经费类型
sql.append("v.CONTRACT_ID CONTRACT_ID,");//合同编号
sql.append("v.ORDER_DATE ORDER_DATE,");//下达日期
sql.append("decode(v.IS_JIJIAN,0,'是',1,'否') AS IS_JIJIAN ");//基建
sql.append(" from tb_quota_collect t ");//汇总表
sql.append("left join VW_TB_PLAN_INFO v ");//计划表试图
sql.append("on v.COLLECT_ID=t.collect_id ");
sql.append("where 1=1 and t.COLLECT_ID=? ");
params.add(reqId);
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
}else{
ret.put("items", new ArrayList());
}
return ret;
}
/**
* 1.查询汇总通知单 用于打印预览
* @param cp
* @param param
* @return ret
* @throws Exception
*/
public Map<String, Object> querySumOrder(Map<String, Object> cp,Map<String, Object> param)
throws Exception{
Map<String, Object> ret = new HashMap<String, Object>( );
StringBuilder sql = new StringBuilder();
String allotId = PubTool.getMapValue(param, "allotId", "");//下拉菜单
String dy_date = PubTool.getMapValue(param, "dy_date", "");//下拉菜单
//String agency_item_id = PubTool.getMapValue(param, "agency_item_id", "");//部门id,当选择左侧树的时候产生
// System.out.println("kkkkkk:"+agency_item_id);
sql.append("select ");//支出功能分类编码
sql.append(" v.EXPFUNC_NAME,");//支出功能分类名称
sql.append(" v.EXPFUNC_CODE ,");//支出功能分类编码
// sql.append("v.PUBAGENCY_NAME PUBAGENCY_NAME,");//预算单位
sql.append(" v.AGENCY_NAME,");//预算单位
sql.append("v.Item_Code Item_Code,");//项目编码
sql.append("v.Item_Name Item_Name,");//项目名称
sql.append("v.Bgt_FileNAME Bgt_FileNAME,");//预算文号,用的指标文号
sql.append("replace(v.MONTH,'月','') planmonth,");//月份
sql.append("substr(v.AGENCY_CODE,0,3) AGENCY_CODE,");//部门编码
sql.append("(select name from T_PUBBANK where v.BANK_CODE=T_PUBBANK.code) bank_Name,");//开户银行名称
sql.append("(select code from t_pubagency where itemid=(select superitemid from t_pubagency where itemid=v.AGENCY_ITEM_ID) ) SUPERAGENCYCODE,");//部门
sql.append("v.ADUIT_SUM ADUIT_SUM, ");//审批额度就是授权额度
sql.append(" v.FUNDTYPE_NAME, ");//资金性质
sql.append("decode(v.IS_JIJIAN, 0, '(基建)','') as IS_JIJIAN ");//基建
sql.append(" from vw_tb_plan_info v ");
sql.append("left join tb_quota_collect t ");
sql.append(" on v.COLLECT_ID=t.collect_id");
sql.append(" where t.collect_id=?");
//sql.append(" and AGENCY_ITEM_ID=?");//后来加的,针对左侧树的
PreparedDBUtil pdb = DBHelper.query(sql.toString(),allotId);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
if(StringUtil.isNotEmpty(dy_date)){
ret.put("year",dy_date.split("\\.")[0]);//特殊字符用split方法的时候需要转义。年月日用于在硕正的数据源中进行拖拽的
ret.put("month", dy_date.split("\\.")[1]);
ret.put("day", dy_date.split("\\.")[2]);
}
if(StringUtil.isNotEmpty(allotId)){
ret.put("Id", allotId);
System.out.println(ret.size());
}
}else{
ret.put("items", new ArrayList());
//throw new BizException("未找到信息!");
}
return ret;
}
/**
* 2.查询支付明细单
* @param cp
* @param param
* @return ret
* @throws Exception
*/
public Map<String, Object> queryPayDetail(Map<String, Object> cp,Map<String, Object> param)
throws Exception{
Map<String, Object> ret = new HashMap<String, Object>( );
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
String allotId = PubTool.getMapValue(param, "allotId", "");
String dy_date = PubTool.getMapValue(param, "dy_date", "");//没用到日期
//String agency_item_id = PubTool.getMapValue(param, "agency_item_id", "");
//System.out.println("============"+allotId);
sql.append("select ");
sql.append("v.AGENCY_CODE,");//预算单位编码
sql.append("v.AGENCY_NAME,");//预算单位名称
sql.append("v.FUNDTYPE_NAME,");//资金性质
sql.append("v.EXPFUNC_CODE,");//功能分类编码
sql.append("v.EXPFUNC_NAME,");//功能分类名称
sql.append("v.MONTH,");//计划月份
sql.append("v.Item_Name,");//项目名称
sql.append("v.Bgt_FileNAME,");//预算文号,用的指标文号
sql.append("(select name from T_PUBBANK where v.agencybank_code=T_PUBBANK.CODE) bank_Name,");//开户银行
sql.append("(select distinct bank_account from T_PUBBANKACCOUNT where v.agency_id=T_PUBBANKACCOUNT.agency_id) bank_account,");//账号
sql.append("v.ADUIT_SUM ADUIT_SUM,");//额度
sql.append("(select code from t_pubagency where itemid=(select superitemid from t_pubagency where itemid=v.AGENCY_ITEM_ID) ) superagencyname, ");//部门
sql.append("decode(v.IS_JIJIAN, 0, '(基建)','') as IS_JIJIAN ");//基建
sql.append("from vw_tb_plan_info v ");
sql.append("left join tb_quota_collect t ");
sql.append(" on v.COLLECT_ID=t.collect_id");
sql.append(" where t.collect_id=? ");
//sql.append(" and AGENCY_ITEM_ID=?");//后来加的,针对左侧树的
params.add(allotId);
//params.add(agency_item_id);
//System.out.println(sql);
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
if(StringUtil.isNotEmpty(dy_date)){
ret.put("year",dy_date.split("\\.")[0]);//特殊字符用split方法的时候需要转义。年月日用于在硕正的数据源中进行拖拽的
ret.put("month", dy_date.split("\\.")[1]);
ret.put("day", dy_date.split("\\.")[2]);
}
}else{
ret.put("items", new ArrayList());
}
return ret;
}
/**
* 3.查询授权支付通知单
* @param cp
* @param param
* @return ret
* @throws Exception
*/
public Map<String, Object> queryPayOrder(Map<String, Object> cp,Map<String, Object> param)
throws Exception{
Map<String, Object> ret = new HashMap<String, Object>( );
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
String allotId = PubTool.getMapValue(param, "allotId", "");
String dy_date = PubTool.getMapValue(param, "dy_date", "");//下拉菜单
//String agency_item_id = PubTool.getMapValue(param, "agency_item_id", "");
sql.append("select ");
sql.append("t.COLLECT_ID,");//单据号
sql.append("v.Item_Code,");//预算项目编码
sql.append("v.Item_Name,");//预算项目名称
sql.append("v.EXPFUNC_CODE,");//功能分类编码
sql.append("v.EXPFUNC_NAME,");//功能分类名称
sql.append("v.Bgt_FileNAME,");//预算文号,用的指标文号
sql.append("v.ADUIT_SUM ADUIT_SUM ,");//额度
sql.append("(select name from T_PUBBANK where v.BANK_CODE=T_PUBBANK.CODE) bank_Name,");//银行名称
sql.append("v.FUNDTYPE_NAME,");//资金性质
sql.append("replace(v.MONTH,'月','') planmonth,");//月份
sql.append("(select name from t_pubagency where itemid=(select superitemid from t_pubagency where itemid=v.AGENCY_ITEM_ID) ) superagencyname,");//部门
sql.append("decode(v.IS_JIJIAN, 0, '(基建)','') as IS_JIJIAN ");//基建
sql.append("from vw_tb_plan_info v left join tb_quota_collect t on v.COLLECT_ID=t.collect_id");
sql.append(" where t.collect_id=? ");
// sql.append(" and AGENCY_ITEM_ID=?");//后来加的,针对左侧树的
params.add(allotId);
//params.add(agency_item_id);
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
if(StringUtil.isNotEmpty(dy_date)){
ret.put("year",dy_date.split("\\.")[0]);//特殊字符用split方法的时候需要转义。年月日用于在硕正的数据源中进行拖拽的
ret.put("month", dy_date.split("\\.")[1]);
ret.put("day", dy_date.split("\\.")[2]);
}
if(StringUtil.isNotEmpty(allotId)){
ret.put("Id", allotId);
System.out.println(ret.size());
}
}else{
ret.put("items", new ArrayList());
}
return ret;
}
/**
* 改变三个报表的打印状态
* @param cp
* @param param
* @return ret
* @throws Exception
*/
public Map<String, Object> updateStatus(Map<String, Object> cp,Map<String, Object> param)
throws Exception{
Map<String, Object> ret = new HashMap<String, Object>( );
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
//String allotId = PubTool.getMapValue(param, "allotId", "");
String arr = (String)param.get("ids");
String[] list = arr.split(",");
String dy_type = PubTool.getMapValue(param, "dy_type", "");
sql.append("update tb_quota_collect ");
if("1".equals(dy_type)){//汇总单
sql.append(" set SQHZ_PRINTFLAG=1 ");
}else if("2".equals(dy_type)){//明细单
sql.append(" set DWSQ_PRINTFLAG=1");
}else if("3".equals(dy_type)){//支付单
sql.append(" set SQZF_PRINTFLAG=1");
}
sql.append(" where collect_id in(");
for(int x=0;x<list.length;x++){
sql.append(Integer.parseInt(list[x])+",");//此时在最后的时候多了一个逗号
}
sql=sql.deleteCharAt(sql.length()-1);//这里减去一个逗号
sql.append(")");
//params.add(allotId);
DBHelper.update(sql.toString(),params);
ret.put("msg","打印成功!");//此时jsp页面的函数的返回值不为空了data
return ret;
}
}
3.支付令汇总的jsp
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file ="../../../page/common/common.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>申请书</title>
<script type="text/javascript" src="<%=basePath%>/js/mofit/workflow.js"></script>
<script type="text/javascript" src="<%=path%>/js/tools.js"></script>
<!-- 基础数据弹出选择框的几个通用函数 -->
<script type="text/javascript" src="<%=path%>/js/baseDictDataTool.js"></script>
<script type="text/javascript" src="<%=path%>/js/const.js"></script>
<script type="text/javascript" src="<%=path%>/js/onlyinputnumber.js"></script>
<script type="text/javascript" src="<%=path%>/js/tools.js"></script>
<script type="text/javascript">
var flag = 0;//在refreshData方法中用到
var new_file_ids = "";//附件的全局变量
var agencyCode="";//登陆人。例如:133001
function OnReady(id){
if (id == 'AF') {
AF.func("Build", "<%=path%>/sz/xml/direct/directSumPrint/common/main.xml");//加载
var depttreeurl = pubAct+"&busId=sys_7&elementcode=AGENCY_CODE&power=0&isTree=true"; /* 树的url*/
AF.func("Tab1.sqs.dept_tree.InsertItem","0\r\n\r\n预算单位"); /* 添加预算单位这几个字 ,之后在写dept_tree.Build的时候,dept_tree.Build才会起作用*/
AF.func("Tab1.dhz.dept_tree.InsertItem","0\r\n\r\n预算单位");
AF.func("Tab1.sqs.dept_tree.Build",depttreeurl+"\r\n0");
var childId = AF.func("Tab1.sqs.dept_tree.getChild", AF.func("Tab1.sqs.dept_tree.getChild", 0));
AF.func("Tab1.sqs.dept_tree.SetCurSel",childId);
agencyCode=AF.func("Tab1.sqs.dept_tree.GetXMLProp",childId+"\r\n text").split("-")[0];
AF.func("Tab1.dhz.dept_tree.Build",depttreeurl+"\r\n0");
var childId1 = AF.func("Tab1.dhz.dept_tree.getChild", AF.func("Tab1.dhz.dept_tree.getChild", 0));
AF.func("Tab1.dhz.dept_tree.SetCurSel",childId1);
agencyCode=AF.func("Tab1.dhz.dept_tree.GetXMLProp",childId+"\r\n text").split("-")[0];
AF.func("Tab1.view.dept_tree.InsertItem","0\r\n\r\n预算单位");
AF.func("Tab1.view.dept_tree.Build",depttreeurl+"\r\n0");
var childId2 = AF.func("Tab1.view.dept_tree.getChild", AF.func("Tab1.view.dept_tree.getChild", 0));
AF.func("Tab1.view.dept_tree.SetCurSel",childId2);
agencyCode=AF.func("Tab1.view.dept_tree.GetXMLProp",childId+"\r\n text").split("-")[0];
AF.func("Tab1.sqs.itemlist.SetProp", "curselmode \r\n rows");//申请书页签中的选中行
AF.func("Tab1.zfl.itemlist.SetProp", "curselmode \r\n rows");//支付令页签中的选中行
AF.func("Tab1.dhz.itemlist.SetProp", "curselmode \r\n rows");//待汇总页签中的选中行
AF.func("Tab1.hz.itemlist01.SetProp", "curselmode \r\n rows");//汇总清算通知单页签中的选中行
AF.func("Tab1.view.itemlist.SetProp", "curselmode \r\n rows");//支付令预览页签中的选中行
refreshData();
}
}
function OnEvent(id, Event, p1, p2, p3, p4){
//申请书
if(Event=="Tab1.sqs.dept_tree.SelChanged"){//单位树选择变化 ,选择左侧树的
agencyItemId = p1;
agencyCode=p2.split("@")[3];
if(p2.length==0){ //undefined 转换为为空
agencyCode="";
}
refreshData();
}
//待汇总支付令
if(Event=="Tab1.dhz.dept_tree.SelChanged"){//单位树选择变化 ,选择左侧树的
agencyItemId = p1;
agencyCode=p2.split("@")[3];
if(p2.length==0){ //undefined 转换为为空
agencyCode="";
}
refreshData();
}
//支付令浏览
if(Event=="Tab1.view.dept_tree.SelChanged"){//单位树选择变化 ,选择左侧树的
agencyItemId = p1;
agencyCode=p2.split("@")[3];
if(p2.length==0){ //undefined 转换为为空
agencyCode="";
}
refreshData();
}
//alert("p1="+p1);
//alert("Event="+Event+" p1="+p1+" p2="+p2+" p3="+p3+" p4="+p4);
var url=pubAct;//放在这里给五个页签公用,五个页签具体的参数是各自后来追加进去的
if(Event=="Tab1.sqs.condition.ButtonClicked"){//页签1:申请书页签
if(p1=='create_zfl'){////点击生成支付令
var dlyh = AF.func("Tab1.sqs.condition.GetValue", "dlyh");//代理银行
if(dlyh==""){
// AF.func("MsgFloat","请选择!");//两种提示
showMsgDialog(basepath,AF,"请选择代理银行!",'info');
return;
}
var paydate = AF.func("Tab1.sqs.condition.GetValue", "paydate");//支付日期
dlyh=cjkEncode(dlyh);//加密,不加密就乱码cjkEncode
url=url+"&dlyh="+dlyh+"&paydate="+paydate;//追加url的参数
commButtonClicked("sqs.itemlist","createPayment",url);//页签1:切换申请书(sqs)页签后点击生成支付令按钮,调用了后台的sql是createPayment
}
if(p1=="upfile"){//上传附件
showUpFile("sqs");
}
if(p1=="contract"){ //合同信息
showContract("sqs");
}
}
if(Event=="Tab1.zfl.condition.ButtonClicked"){//页签2:支付令页签
if(p1=='sx'){//点击生效
commButtonClicked("zfl.itemlist","takeEffect",url);//切换支付令(zfl)页签后点击生效按钮,调用了后台的sql是takeEffect
}
if(p1=="upfile"){//上传附件
showUpFile("zfl");
}
if(p1=="contract"){ //合同信息
showContract("zfl");
}
}
if(Event=="Tab1.dhz.condition.ButtonClicked"){//页签3:待汇总页签
if(p1=='hz'){//点击汇总
var yh = AF.func("Tab1.dhz.condition.GetValue", "yh");//代理银行
var selecthz = AF.func("Tab1.dhz.condition.GetValue", "selecthz");//选择汇总
var dlyh=cjkEncode(yh);
if(dlyh==""){
showMsgDialog(basepath,AF,"请选择代理银行数据!",'info');
return;
}
url=url+"&dlyh="+dlyh+"&selecthz="+selecthz;//追加url的参数
commButtonClicked("dhz.itemlist","sum",url);//切换到待汇总(dhz)页签后点击汇总按钮,调用了后台的sql是sum
}
if(p1=="upfile"){//上传附件
showUpFile("dhz");
}
if(p1=="contract"){ //合同信息
showContract("dhz");
}
}
if(Event=="Tab1.hz.condition.ButtonClicked"){//页签4:汇总通知单页签
if(p1=='querySum'){//点击查询
flag=3;
refreshData();//在汇总通知单页签中点击查询
}
}
if(Event=="Tab1.hz.topbar.ButtonClicked"){//页签4:汇总通知单页签
if(p1=='print'){//点击打印
var row = AF.func("Tab1.hz.itemlist01.findAll", "chk==1");
var rows = row.split(",");
if(row == "" || rows == null){
showMsgDialog(basepath,AF,"请选择一条数据!",'info');
return;
}
var allotId = AF.func("Tab1.hz.itemlist01.GetCellData", row+" \r\n COLLECT_ID");
var url="sumOrder.jsp"+"?allotId="+allotId;
showModule("sumOrder.jsp",1300,800,"allotId="+allotId);
}
}
if(Event=="Tab1.view.condition.ButtonClicked"){//页签5:支付令预览页签
if(p1=='querySum'){//点击查询
flag=4;
refreshData();//在汇总通知单页签中点击查询
}
}
if(Event=="Tab1.view.topbar.ButtonClicked"){//页签5:支付令预览页签
if(p1=='print'){//打印按钮
var row = AF.func("Tab1.view.itemlist.findAll", "chk==1");
var rows = row.split(",");
if(row == "" || rows == null){
showMsgDialog(basepath,AF,"请选择一条数据!",'info');
return;
}
var allotId = AF.func("Tab1.view.itemlist.GetCellData", row+" \r\n PAY_ID");
var url="payOrder.jsp"+"?allotId="+allotId;
showModule("payOrder.jsp",1500,1000,"allotId="+allotId);
}
if(p1=="upfile"){//上传附件
showUpFile("view");
}
if(p1=="contract"){ //合同信息
showContract("view");
}
if(p1=="writeOff"){ //冲销操作
writeOff("view");
}
}
if(Event=="SelChanged"){//切换页签(freeform里面的事件)
if(p3=='sqs'){//切换到申请书
AF.func("Tab1.sqs.itemlist.SetColProp", "PAY_ID \r\n isHide \r\n false");
AF.func("Tab1.sqs.itemlist.SetColProp", "BH \r\n isHide \r\n true");
flag=0;
AF.func("Tab1.sqs.itemlist.SetValue", "USED_AMOUNT\r\n" + 0);
refreshData();
}
if(p3=='zfl'){//切换到支付令
AF.func("Tab1.zfl.itemlist.SetColProp", "PAY_ID \r\n isHide \r\n true");//动态更改XML文档中某 Col 的属性
AF.func("Tab1.zfl.itemlist.SetColProp", "BH \r\n isHide \r\n false");
AF.func("Tab1.zfl.itemlist.SetValue", "USED_AMOUNT\r\n" + 0);
flag=1;
refreshData();
}else if(p3=='dhz'){//切换到待汇总支付令
AF.func("Tab1.dhz.itemlist.SetColProp", "PAY_ID \r\n isHide \r\n true");
AF.func("Tab1.dhz.itemlist.SetColProp", "BH \r\n isHide \r\n false");
AF.func("Tab1.dhz.itemlist.SetValue", "USED_AMOUNT\r\n" + 0);
flag=2;
refreshData();
}else if(p3=='hz'){//汇总清算通知单
AF.func("Tab1.hz.itemlist.SetValue", "USED_AMOUNT\r\n" + 0);
flag=3;
refreshData();
}else if(p3=='view'){//支付令预览
AF.func("Tab1.view.itemlist.SetColProp", "PAY_ID \r\n isHide \r\n true");
AF.func("Tab1.view.itemlist.SetColProp", "BH \r\n isHide \r\n false");
AF.func("Tab1.view.itemlist.SetValue", "USED_AMOUNT\r\n" + 0);
flag=4;
refreshData();
}
}
if(Event == "Tab1.sqs.itemlist.SelChanged"){ //页签1:列表变化,即勾选选择框触发事件
sum("Tab1.sqs.itemlist","PAY_MONEY","Tab1.sqs.condition");//(计算总金额)
}
if(Event == "Tab1.sqs.itemlist.Clicked" && p1=="-1" && p2=="chk"){ //全选。p3==1是全选,p3=0是反选
sum("Tab1.sqs.itemlist","PAY_MONEY","Tab1.sqs.condition","USED_AMOUNT");
}
if(Event == "Tab1.zfl.itemlist.SelChanged"){ //页签2:列表变化,即勾选选择框触发事件(计算总金额)
sum("Tab1.zfl.itemlist","PAY_MONEY","Tab1.zfl.condition");
}
if(Event == "Tab1.zfl.itemlist.Clicked" && p1=="-1" && p2=="chk"){ //全选。p3==1是全选,p3=0是反选
sum("Tab1.zfl.itemlist","PAY_MONEY","Tab1.zfl.condition","USED_AMOUNT");
}
if(Event == "Tab1.dhz.itemlist.SelChanged"){ //页签3:列表变化,即勾选选择框触发事件(计算总金额)
sum("Tab1.dhz.itemlist","PAY_MONEY","Tab1.dhz.condition");
}
if(Event == "Tab1.dhz.itemlist.Clicked" && p1=="-1" && p2=="chk"){ //全选。p3==1是全选,p3=0是反选
sum("Tab1.dhz.itemlist","PAY_MONEY","Tab1.dhz.condition","USED_AMOUNT");
}
if(Event == "Tab1.view.itemlist.SelChanged"){ //页签5:列表变化,即勾选选择框触发事件(计算总金额)
sum("Tab1.view.itemlist","PAY_MONEY","Tab1.view.condition");
}
if(Event == "Tab1.view.itemlist.Clicked" && p1=="-1" && p2=="chk"){ //全选。p3==1是全选,p3=0是反选
sum("Tab1.view.itemlist","PAY_MONEY","Tab1.view.condition","USED_AMOUNT");
}
if(Event == "Tab1.hz.itemlist01.SelChanged"){ //页签4:列表变化,即勾选选择框触发事件
var reqId= "";
sum("Tab1.hz.itemlist01","COLLECT_MONEY","Tab1.hz.condition");//(计算总金额)
var row = AF.func("Tab1.hz.itemlist01.findAll", "chk==1");//
var rows = row.split(",");
for(var i=0;i<rows.length;i++){
if(i==rows.length-1){//只要最后一个
reqId= AF.func("Tab1.hz.itemlist01.GetCellData", rows[i] + "\r\nCOLLECT_ID");
}
}
//查详情(查看汇总的明细)
if(rows.length>=1&&p1!=-1){//当选中一个的时候,长度就是1,因此只要有选中的,集合rows的长度一定大于1。p1=0或者1表示选择,p1=-1表示取消选择
AF.func("Tab1.hz.itemlist02.Load", pubAct+"&busId=paySum&method=sumOrderDetail&reqId="+reqId+"&isList=true&tempparam="+ Math.random());
}else{//把仅剩下的一条数据也取消的时候(表示没有数据的时候)
reqId=-1;//此时给汇总表的主键置成-1,就差不出来汇总详情了
AF.func("Tab1.hz.itemlist02.Load", pubAct+"&busId=paySum&method=sumOrderDetail&reqId="+reqId+"&isList=true&tempparam="+ Math.random());
}
}
if(Event == "Tab1.hz.itemlist01.Clicked" && p1=="-1" && p2=="chk"){ //全选。p3==1是全选,p3=0是反选
allsum("Tab1.hz.itemlist01","COLLECT_MONEY","Tab1.hz.condition","USED_AMOUNT");
}
if(Event=="Tab1.dhz.condition.DropdownSelChanged"){//自动刷新(在待汇总页签,任意下拉菜单被选中,自动刷新数据)
if(p1=='yh'){
flag=2;
refreshData();
}
}
}
//公用方法(在点击每个页签中的按钮的时候),生成支付令&&支付令生效的函数&&汇总的函数
function commButtonClicked(Tabid,str,url){//Tabid在切换页签的时候用到(页签的id),str是用来区分到底是哪个方法,col_id是xml中的列
var ids=multi_select("Tab1."+Tabid,"PAY_ID");
if(ids==null){
return;
}
var BH=multi_select("Tab1."+Tabid,"BH");//这是专门给生效按钮用的
pdata = {//调用方法,集合中的最后一个元素不要加逗号,否则jsp页面无法显示了
busId:"paySum", //功能码
method:str,
//method:"commButtonClicked",//方法(生成支付令或者支付令生效的方法)
//role:str,//role是用来区分的,在dao中的commButtonClicked方法中用。如果是点击生成支付令就是createPayment,如果是点击生效str就是takeEffect.
BH:BH,//此参数只是在生效时候用
ids:ids
}
$.post(url,pdata,function(data){//data对应着方法的返回值
if(data&&data.check_message){//这个if语句只给击生效按钮使用
showMsgDialog(basepath,AF,data.check_message,'info');//不能生效
return;
}
if(data&&data.msg){//这个if语句是公共的
//showMsgDialog(basepath,AF,data.msg,'info'); //弹出打印提示信息.msg是dao层的返回值(弹出框)
AF.func("MessageBoxFloat", data.msg+"\r\n title=Prompt; icon=Information; hold=3");//一闪而逝
if(str=="createPayment"){//点击生成支付令按钮之后刷新申请书页签
flag=0;
refreshData();
}else if(str=="takeEffect"){//点击生效按钮之后刷新支付令页签
flag=1;
refreshData();
}else if(str="sum"){//点击汇总按钮之后刷新支付令页签
flag=2;
refreshData();
}
}else{
showMsgDialog(basepath,AF,"操作失败!",'info');//错误的时候没有返回值,因此自己手写了修改失败四个字(弹出框)
return;
}
},"json");
}
//多选(公用方法,第一个参数是该TreeList的id,第二个参数是主键字段)
function multi_select (myid,primary){
var row = AF.func(myid+".findAll", "chk==1");
var rows = row.split(",");//必须分开写.获取的行,不是该行的id
if(rows == "" || rows == null){
showMsgDialog(basepath,AF,"请选择至少一条数据!",'info');
return;
}
var ids = '';
for(var i=0;i<rows.length;i++){
allotId= AF.func(myid+".GetCellData", rows[i] + "\r\n"+primary);
ids += allotId +",";
}
return ids;
}
//公共方法,计算总金额(勾选),myid是选中行的路径,parimary是xml中的COL,text是文本框所对应的路径
function sum(myid,primary,text){
var rows = AF.func(myid+".FindAll", "chk==1").split(",");
var money_sum=0;//这里不能写"",而是写成0,因为0表示int类型,""表示字符串
var arr = new Array();
if(rows!=""){
for(var i=0;i<rows.length;i++){
//arr[i]= Number(AF.func(myid+".GetCellData", rows[i] + "\r\n"+primary));//类型转换 ,这两个都行
arr[i]= Number(AF.func(myid+".GetCellData", rows[i] + "\r\n"+primary));
money_sum += arr[i] ;
}
}
AF.func(text+".SetValue", "USED_AMOUNT\r\n" + money_sum.toFixed(2));//COLLECT_SUM是xml中的总金额,SetValue是在设置值
}
//上传附件
function showUpFile(treelist_id){
var row = AF.func("Tab1."+treelist_id+".itemlist.FindAll", "chk=1");
if(row == "" || row == null){
showMsgDialog(basepath,AF,"请选择一条数据!",'info');
return;
}else{
if (row.split(",").length > 1) {
showMsgDialog(basepath,AF,"只能选择一条数据!",'info');
return;
}
}
var payId= AF.func("Tab1."+treelist_id+".itemlist.GetCellData", row + "\r\n PAY_ID");//获得当前选中行的主键
var params ="payId="+payId+"&isuse=true&filetype=26"
var winrtn = showModule("../../../page/common/fileUpload.jsp?bsessionid="+bsessionid+"&"+params,700,400,null);
if(winrtn){
new_file_ids = winrtn;
}
}
//冲销操作
function writeOff(treelist_id){
var row = AF.func("Tab1."+treelist_id+".itemlist.FindAll", "chk=1");
if(row == "" || row == null){
showMsgDialog(basepath,AF,"请选择一条数据!",'info');
return;
}else{
if (row.split(",").length > 1) {
showMsgDialog(basepath,AF,"只能选择一条数据!",'info');
return;
}
}
var payId= AF.func("Tab1."+treelist_id+".itemlist.GetCellData", row + "\r\n PAY_ID");//获得当前选中行的主键
var PAY_MONEY= AF.func("Tab1."+treelist_id+".itemlist.GetCellData", row + "\r\n PAY_MONEY");//PAY_MONEY
if (PAY_MONEY <= 0) {
AF.func("MsgFloat","请选择金额大于0的数据进行冲销! \r\nicon=Info; hold=3.5;center=true");
return false;
}
var p = {};
p.busId = "paySum";
p.method = "writeOffPayInfo";
p.payId =payId; //payId
$.post(pubAct, p, function(data) {
showMsgDialog(basepath, AF, data.msg, 'info');
}, "json");
}
//合同信息(调用小宁的方法)
function showContract(treelist_id){
var rows = AF.func("Tab1."+treelist_id+".itemlist.findAll", "chk==1");
if(rows == "" || rows == null){
showMsgDialog(basepath,AF,"请您首先选中一条记录!",'info');
return;
}else{
if (rows.split(",").length > 1) {
showMsgDialog(basepath,AF,"只能对一条记录进行操作!",'info');
return;
}
}
var contarct_id = AF.func("Tab1."+treelist_id+".itemlist.GetCellData", rows + "\r\n CONTRACT_ID");//获得当前选中行的主键
if(contarct_id=="" ||contarct_id==null){
showMsgDialog(basepath, AF, "合同号为空,无法查看!", 'info');
return;
}
var params = 'contarct_id=' + contarct_id;
var returnValue = showModule("../../../page/common/publicConConfirm.jsp", 850,
300, params);
}
//查询的方法
function refreshData(){
if(flag==0){//1.查询申请书
AF.func("Tab1.sqs.itemlist.Load", pubAct+"&busId=paySum&method=applyListData&agencyCode="+agencyCode+"&isList=true&tempparam="+ Math.random());
}if(flag==1){//2.查询支付令
AF.func("Tab1.zfl.itemlist.Load", pubAct+"&busId=paySum&method=paymentData&agencyCode="+agencyCode+"&isList=true&tempparam="+ Math.random());
}
if(flag==2){//查询待汇总支付令
// AF.func("Tab1.dhz.itemlist.Load", pubAct+"&busId=paySum&method=noSum&isList=true&tempparam="+ Math.random());
var dlyh = AF.func("Tab1.dhz.condition.GetValue", "yh");//代理银行
dlyh=cjkEncode(dlyh);
AF.func("Tab1.dhz.itemlist.Load", pubAct+"&busId=paySum&method=noSum&dlyh="+dlyh+"&agencyCode="+agencyCode+"&isList=true&tempparam="+ Math.random());
}
if(flag==3){//查询汇总清算通知单
var startdate = AF.func("Tab1.hz.condition.GetValue", "startdate");//开始日期
var enddate = AF.func("Tab1.hz.condition.GetValue", "enddate");//结束日期
var dlyh = AF.func("Tab1.hz.condition.GetValue", "dlyh");//代理银行
dlyh=cjkEncode(dlyh);
var zclx = AF.func("Tab1.hz.condition.GetValue", "zclx");//支出类型
if(enddate<startdate){
showMsgDialog(basepath,AF,'开始日期不能大于结束日期','info');
return false;
}
AF.func("Tab1.hz.itemlist01.Load", pubAct+"&busId=paySum&method=sumOrder&startdate="+startdate+"&enddate="+enddate+"&dlyh="+dlyh+"&zclx="+zclx+"&agencyCode="+agencyCode+"&isList=true&tempparam="+ Math.random());
AF.func("Tab1.hz.itemlist01.SelectRow",0);//默认选中第一行
}if(flag==4){
var startdate = AF.func("Tab1.view.condition.GetValue", "startdate");//开始日期
var enddate = AF.func("Tab1.view.condition.GetValue", "enddate");//结束日期
var dlyh = AF.func("Tab1.view.condition.GetValue", "dlyh");//代理银行
dlyh=cjkEncode(dlyh);
var zclx = AF.func("Tab1.view.condition.GetValue", "zclx");//支出类型
var zjxz = AF.func("Tab1.view.condition.GetValue", "zjxz");//资金性质
var status = AF.func("Tab1.view.condition.GetValue", "status");//状态
var printstatus = AF.func("Tab1.view.condition.GetValue", "printstatus");//打印状态
if(enddate<startdate){
showMsgDialog(basepath,AF,'开始日期不能大于结束日期','info');
return false;
}
AF.func("Tab1.view.itemlist.Load", pubAct+"&busId=paySum&method=view&startdate="+startdate+"&enddate="+enddate+"&dlyh="+dlyh+"&zclx="+zclx+"&zjxz="+zjxz+"&printstatus="+printstatus+"&status="+status+"&agencyCode="+agencyCode+"&isList=true&tempparam="+ Math.random());
}
}
</script>
</head>
<body class="easyui-layout" style="overflow:hidden;">
<div id="af3" data-options="region:'center',border:false" fit=true style="overflow:hidden;">
<!--<script>insertFreeForm('AF',"EventLog=a.txt;FuncLog=x.txt")</script> -->
<script>insertFreeForm('AF',"EventLog=a.txt;FuncLog=x.txt")</script>
</div>
</body>
</html>
4.支付令汇总的dao层
package com.mofit.direct.directSumPrint.dao;
import groovy.sql.Sql;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.common.constants.CommonConst;
import com.common.exception.BizException;
import com.common.util.DBHelper;
import com.common.util.PubTool;
import com.common.util.StringUtil;
import com.frameworkset.common.poolman.PreparedDBUtil;
import com.mofit.common.dao.PayInfoCommonDao;
import com.mofit.common.datarule.service.DataRuleService;
import com.mofit.common.util.CommonConstant;
@SuppressWarnings("all")
public class SumPrintDao {
PayInfoCommonDao payInfoCommonDao;
public PayInfoCommonDao getPayInfoCommonDao() {
return payInfoCommonDao;
}
public void setPayInfoCommonDao(PayInfoCommonDao payInfoCommonDao) {
this.payInfoCommonDao = payInfoCommonDao;
}
String fundtype_id="";
/**
* 功能码:paySum
* 进入申请书页签,查询申请书列表,(每个查询的方法中,v.IS_CANCEL=0和 v.ANNUAL=extract(year from sysdate)是必备的where条件)
* 前置条件:是否作废,是否冻结,流程状态为2,支付类型为2(直接支付),年度为当前年度。后置条件:是否生成支付令:否
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> applyListData (Map<String, Object> cp,Map<String, Object> param) throws Exception{
Map<String, Object> ret = new HashMap<String, Object>( );
Map userlogonEntity=(Map)cp.get("user");
String annual = PubTool.getMapValue(userlogonEntity, "bgtAnnual", "");
String agencyId =PubTool.getMapValue(userlogonEntity,"agencyId",""); //预算单位ID //233
String userType = userlogonEntity.get("userType").toString(); //用户类型
String agencyCode=PubTool.getMapValue(param, "agencyCode", "");
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
//String allotId = PubTool.getMapValue(param, "allotId", "");
sql.append("select ");
sql.append(" pay_id,");//申请号
//sql.append("to_char(PAY_DATE,'YYYY-MM-dd') as PAY_DATE,");
sql.append("PAY_DATE,");//申请日期
sql.append("AGENCY_CODE ||'--'|| AGENCY_NAME AS AGENCY_CODE_NAME,");//预算单位
sql.append("PAYEE_NAME,");//收款人全称
sql.append("PAYEE_BANK,");//收款人开户行
sql.append("PAYEE_ACCOUNT,");//收款人账号
sql.append("MOFDEPT_CODE||'--'||MOFDEPT_NAME as MOFDEPT_CODE_NAME,");//业务科室(资金科室)
sql.append("FUNDTYPE_CODE||'--'||FUNDTYPE_NAME as FUNDTYPE_CODE_NAME,");//资金性质
sql.append("BDGSOURCE_CODE||'--'||BDGSOURCE_NAME as BDGSOURCE_CODE_NAME,");//预算来源
sql.append("EXPECONORMIC_NAME,");//经费类型
sql.append("EXPFUNC_CODE||'--'||EXPFUNC_NAME as EXPFUNC_CODE_NAME,");//功能分类
sql.append("ITEM_NAME,");//预算项目
sql.append("EXPECONORMIC_CODE||'--'||EXPECONORMIC_NAME as EXPECONORMIC_CODE_NAME,");//经济分类
sql.append("PAY_MONEY,");//金额
sql.append("REMARK, ");//用途
sql.append("CONTRACT_ID ");//合同号
sql.append(" from vw_tb_pay_info v ");
////sql.append(" where v.IS_CANCEL=0 and v.ANNUAL=extract(year from sysdate) and v.PAYTYPE_ID ='2' and v.IS_ZFL=0");//是否生成支付令,支付类型为2。缺少流程状态为2,测试用
sql.append(" where v.IS_CANCEL=0 and v.FLOW_STATUS=2 and v.ANNUAL=? and v.IS_ZFL=0 and v.PAYTYPE_ID ='2' ");//判断条件是否冻结,是否作废,状态为2,年度为当前年度,支付类型为直接支付。t.FREEZE=0表示不是冻结的,在试图中已经有了这个where,因此这里不用加了
params.add(annual);
//数据权限
CommonConstant.executeDataRule(cp,params,sql,agencyCode, "");
sql.append(" order by AGENCY_CODE ASC,PAY_ID DESC,PAY_DATE DESC");//按预算单位PUBAGENCY_NAME升序,按日期和编号降序(由大到小)
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
}else{
ret.put("items", new ArrayList());//如果没有数据,就不显示那个小方块
//throw new BizException("未找到申请书信息!");
}
return ret;
}
/**
* 汇总的select语句
* @param cp
* @param param
* @return
* @throws Exception
*/
private String sum_selectSql(Map<String,Object> cp,Map<String,Object> param) throws Exception{
Map<String,Object> ret = new HashMap<String,Object>();
fundtype_id=StringUtil.cjkDecode(param.get("selecthz").toString().trim());//资金性质
String ids = (String)param.get("ids");
String[] list = ids.split(",");
StringBuilder sql_select = new StringBuilder();
if(fundtype_id.equals("0")){//不按资金性质汇总
sql_select.append("select ");
sql_select.append("ANNUAL,PAY_BANK,PAY_ACCOUNT,PAY_NAME,CENTER_BANK_ID,sum(PAY_MONEY) ");
sql_select.append(" from vw_tb_pay_info ");
sql_select.append(" where pay_id in(");
for(int x=0;x<list.length;x++){
sql_select.append(Integer.parseInt(list[x])+",");//此时在最后的时候多了一个逗号
}
sql_select=sql_select.deleteCharAt(sql_select.length()-1);
sql_select.append(")");
sql_select.append(" group by ANNUAL, PAY_ACCOUNT,PAY_BANK,PAY_NAME,CENTER_BANK_ID");//年度、付款人账号、付款银行、付款人名称、中心银行账号
}else if(fundtype_id.equals("1")){//安资金性质汇总
sql_select.append("select ");
sql_select.append("ANNUAL,PAY_BANK,PAY_ACCOUNT,PAY_NAME,CENTER_BANK_ID,FUNDTYPE_ID,sum(PAY_MONEY) ");//年度,收款人银行,收款人账号,收款人名称,资金性质id
sql_select.append(" from vw_tb_pay_info ");
sql_select.append(" where pay_id in(");
for(int x=0;x<list.length;x++){
sql_select.append(Integer.parseInt(list[x])+",");//此时在最后的时候多了一个逗号
}
sql_select=sql_select.deleteCharAt(sql_select.length()-1);
sql_select.append(")");
sql_select.append(" group by ANNUAL,PAY_ACCOUNT,PAY_BANK,PAY_NAME,CENTER_BANK_ID,fundtype_id");//年度,收款人银行,收款人账号,收款人名称,资金性质id、资金性质
}
return sql_select.toString();
}
/***
* 汇总的insert和update语句
* @param sql
* @param cp
* @param param
* @throws Exception
*/
private void sum_insertAndUpdateSql(String sql,Map<String, Object> cp,Map<String, Object> param)throws Exception{
PreparedDBUtil pdb = DBHelper.query(sql.toString());
fundtype_id=StringUtil.cjkDecode(param.get("selecthz").toString().trim());//资金性质
Map userlogonEntity=(Map)cp.get("user");
String userName=PubTool.getMapValue(userlogonEntity,"userName",""); //机构id;//获取cp中的用户名作为汇总人姓名,在insert汇总表的时候要用到
String userId=PubTool.getMapValue(userlogonEntity,"userId","");
String ids = (String)param.get("ids");//获取前台传过来的参数id
String[] list = ids.split(",");
String seq_collect="";
if(pdb!=null&&pdb.size()>0&&fundtype_id.equals("0")){//不按资金性质汇总&&pdb有数据
for(int x=0;x<pdb.size();x++){
//新增汇总表
seq_collect = DBHelper.getSeqNextVal("SEQ_TB_PAY_COLLECT");//支付令汇总的序列,在TB_PAY_COLLECT表中
StringBuffer sql_insert=new StringBuffer();
sql_insert.append("insert into TB_PAY_COLLECT(COLLECT_ID,ANNUAL,CENTER_BANK_ID,pay_bank,pay_account,pay_name,payee_bank_id,PAYEE_BANK,PAYEE_ACCOUNT,PAYEE_NAME,COLLECT_USERID,COLLECT_USERNAME,COLLECT_MONEY,COLLECT_DATE)");//主键、年度、付款银行编码、收款人银行、收款人账号、收款人名称、汇总人id,汇总人姓名,部门编码,汇总日期,//资金性质
sql_insert.append(" values(");
sql_insert.append(seq_collect+",");//主键
sql_insert.append(pdb.getObject(x,0)+",");//年度
//查询国库单一账户做为付款人
Map<String,Object> map=getCenterBankIdInfo();
sql_insert.append(""+map.get("center_id")+",");//付款银行编码(国库单一账户)
sql_insert.append("'"+map.get("bank_name")+"',");
sql_insert.append("'"+map.get("bank_account")+"',");
sql_insert.append("'"+map.get("center_name")+"',");
sql_insert.append("'"+pdb.getObject(x,4)+"',");//收款人银行ID
sql_insert.append("'"+pdb.getObject(x,1)+"',");//收款人银行
sql_insert.append(pdb.getObject(x,2)+",");//收款人账号、
sql_insert.append("'"+pdb.getObject(x,3)+"',");//收款人名称、
sql_insert.append("'"+userId+"',");//汇总人id,
sql_insert.append("'"+userName+"',");//汇总人姓名,
sql_insert.append("'"+pdb.getObject(x,5)+"',");//总金额,,,,,,,,,,,,
sql_insert.append("sysdate)");//汇总日期,
DBHelper.insert(sql_insert.toString());
//update
StringBuilder sql_update = new StringBuilder();
sql_update.append("update tb_pay_info t set COLLECT_ID="+seq_collect+",is_COLLECT=1");
sql_update.append(" where pay_id in(select pay_id from vw_tb_pay_info where ");
sql_update.append(" ANNUAL="+pdb.getObject(x, 0));//年度
sql_update.append(" and PAY_BANK='"+pdb.getObject(x, 1)+"'");//收款人银行,
sql_update.append(" and PAY_ACCOUNT='"+pdb.getObject(x, 2)+"'");//收款人账号
sql_update.append(" and PAY_NAME='"+pdb.getObject(x, 3)+"'");//收款人名称
if(pdb.getObject(x, 4)==null){
sql_update.append(" and CENTER_BANK_ID is null ");//代理银行
}else{
sql_update.append(" and CENTER_BANK_ID="+pdb.getObject(x, 4));//代理银行
}
sql_update.append(" and pay_id in(");
for(int y=0;y<list.length;y++){
sql_update.append(Integer.parseInt(list[y])+",");//此时在最后的时候多了一个逗号
}
sql_update=sql_update.deleteCharAt(sql_update.length()-1);
sql_update.append("))");
DBHelper.update(sql_update.toString());
}
}
if(pdb!=null&&pdb.size()>0&&fundtype_id.equals("1")){//按资金性质汇总&&pdb有数据
for(int x=0;x<pdb.size();x++){
//新增汇总表
seq_collect = DBHelper.getSeqNextVal("SEQ_TB_PAY_COLLECT");//支付令汇总的序列,在TB_PAY_COLLECT表中
StringBuffer sql_insert=new StringBuffer();
sql_insert.append("insert into TB_PAY_COLLECT(COLLECT_ID,ANNUAL,CENTER_BANK_ID,pay_bank,pay_account,pay_name,payee_bank_id,PAYEE_BANK,PAYEE_ACCOUNT,PAYEE_NAME,COLLECT_USERID,COLLECT_USERNAME,COLLECT_MONEY,COLLECT_DATE,FUNDTYPE_ID)");//主键、年度、付款银行编码、收款人银行、收款人账号、收款人名称、汇总人id,汇总人姓名,汇总日期,资金性质
sql_insert.append(" values(");
sql_insert.append(seq_collect+",");//主键
sql_insert.append(pdb.getObject(x,0)+",");//年度
//查询国库单一账户做为付款人
Map<String,Object> map=getCenterBankIdInfo();
sql_insert.append(""+map.get("center_id")+",");//付款银行编码(国库单一账户)
sql_insert.append("'"+map.get("bank_name")+"',");
sql_insert.append("'"+map.get("bank_account")+"',");
sql_insert.append("'"+map.get("center_name")+"',");
sql_insert.append(pdb.getObject(x,4)+",");//收款人银行ID
sql_insert.append("'"+pdb.getObject(x,1)+"',");//收款人银行
sql_insert.append(pdb.getObject(x,2)+",");//收款人账号、
sql_insert.append("'"+pdb.getObject(x,3)+"',");//收款人名称、
sql_insert.append("'"+userId+"',");//汇总人id,
sql_insert.append("'"+userName+"',");//汇总人姓名,
sql_insert.append("'"+pdb.getObject(x,6)+"',");//总金额,,,,,,,,,,,,
sql_insert.append("sysdate,");//汇总日期,
sql_insert.append(pdb.getObject(x,5)+")");//资金性质
DBHelper.insert(sql_insert.toString());
//update
StringBuilder sql_update = new StringBuilder();
sql_update.append("update tb_pay_info t set COLLECT_ID="+seq_collect+",is_COLLECT=1 ");
sql_update.append("where pay_id in(select pay_id from vw_tb_pay_info where ");
sql_update.append(" ANNUAL="+pdb.getObject(x, 0));//年度
sql_update.append(" and PAY_BANK='"+pdb.getObject(x, 1)+"'");//收款人银行,
sql_update.append(" and PAY_ACCOUNT="+pdb.getObject(x, 2));//收款人账号
sql_update.append(" and PAY_NAME='"+pdb.getObject(x, 3)+"'");//收款人名称
if(pdb.getObject(x, 4)==null){
sql_update.append(" and CENTER_BANK_ID is null ");//代理银行
}else{
sql_update.append(" and CENTER_BANK_ID="+pdb.getObject(x, 4));//代理银行
}
sql_update.append(" and fundtype_id="+pdb.getObject(x, 5));//资金性质
sql_update.append(" and pay_id in(");
for(int y=0;y<list.length;y++){
sql_update.append(Integer.parseInt(list[y])+",");//此时在最后的时候多了一个逗号
}
sql_update=sql_update.deleteCharAt(sql_update.length()-1);
sql_update.append("))");
DBHelper.update(sql_update.toString());
}
}
}
private Map<String,Object> getCenterBankIdInfo() throws Exception{
String sql="select center_id,bank_account,bank_name,center_name from T_PUBCENTERACCOUNT where account_type=0";
PreparedDBUtil pdb = DBHelper.query(sql);
Map<String,Object> map=new HashMap<String,Object> ();
if(pdb!=null&&pdb.size()>0){
for(int x=0;x<pdb.size();x++){
map.put("center_id", pdb.getObject(x,0));
map.put("bank_account", pdb.getObject(x,1));
map.put("bank_name", pdb.getObject(x,2));
map.put("center_name", pdb.getObject(x,3));
}
}
return map;
}
/**
* 汇总的方法
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> sum(Map<String, Object> cp,Map<String, Object> param)throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
String sql=sum_selectSql(cp,param);
sum_insertAndUpdateSql(sql,cp,param);
//sum_updateSql(seq,sql,cp,param);
ret.put("msg","汇总成功!");
return ret;
}
/**
* 页签1:生成支付令
* 生成支付令按钮:update:是否生成支付令,支付日期,付款人银行,付款人账号,付款人名称,中心银行账号编码,BH(支付令编号)。代理银行在默认情况下显示:全部@123456@中心账户简称@0
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> createPayment (Map<String, Object> cp,Map<String, Object> param) throws Exception{
Map<String, Object> ret = new HashMap<String, Object>( );
StringBuilder sql = new StringBuilder();//针对tb_pay_info
List params = new ArrayList();
//String seq_payment = DBHelper.getSeqNextVal("SEQ_CREATEPAYMENT");//生成支付令的序列,在tb_pay_info表中,给BH用
//String seq_collect = DBHelper.getSeqNextVal("SEQ_TB_PAY_COLLECT");//支付令汇总的序列,在TB_PAY_COLLECT表中
String ids = (String)param.get("ids");
//String role=(String) param.get("role");//用来区分是生成支付令还是支付令生效
sql.append("update tb_pay_info t ");
int length=sql.length();
String[] list_ids=ids.split(",");
//第一步:获取下拉菜单的值
String pay_bank="",pay_account="",center_name="",center_bank_id="",paydate="";//这四个变量都是代理银行下拉菜单的一部分和支付日期下拉菜单
String dlyh =StringUtil.cjkDecode(param.get("dlyh").toString().trim());//cjkDecode是在获得jsp页面传过来的数据时候进行解密
if(!dlyh.equals("")){//代理银行下拉菜单
String[] str=dlyh.split("@");
pay_bank=str[0];
pay_account=str[1];
center_name=str[2];
center_bank_id=str[3];
}
if(!param.get("paydate").toString().equals("")){ //支付日期下拉菜单
paydate=param.get("paydate").toString();//支付令日期
}
//第二步:拼接sql语句
for(int x=0;x<list_ids.length;x++){
String seq_payment =payInfoCommonDao.getSeqBhNumber("2");//生成支付令的序列,在tb_pay_info表中的bh字段
sql.append("set t.IS_ZFL=1 ");//是否生成支付令
if(!dlyh.equals("")&&!center_bank_id.equals(0)){//如果为0表示选中的是全部(代理银行在默认情况下显示:全部@123456@中心账户简称@0)
sql.append(", t.PAY_BANK='"+pay_bank+"'");//付款人银行
sql.append(", t.PAY_ACCOUNT='"+pay_account+"'");//付款人银行账号
sql.append(",t.PAY_NAME='"+center_name+"'");//付款人名称
sql.append(",t.CENTER_BANK_ID='"+center_bank_id+"'");//中心银行账号编码
}
if(!paydate.equals("")){
sql.append(", t.ZFL_DATE=to_date('"+paydate+"','YYYY-MM-dd') ");//支付令日期
}
sql.append(",t.BH="+seq_payment);//支付令编码
sql.append(" where pay_id="+list_ids[x]);
DBHelper.update(sql.toString());
sql.delete(length, sql.length());
}
ret.put("msg","支付令生成成功!");
return ret;
}
/**功能码:paySum
* 进入支付令页签,查询支付令
* 前置条件:是否生成支付令=1,后置条件:是否送代理银行=0(未送)
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> paymentData (Map<String, Object> cp,Map<String, Object> param) throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
Map userlogonEntity=(Map)cp.get("user");
String annual = PubTool.getMapValue(userlogonEntity, "bgtAnnual", "");
String agencyId =PubTool.getMapValue(userlogonEntity,"agencyId",""); //预算单位ID //233
String userType = userlogonEntity.get("userType").toString();
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
sql.append("select ");
sql.append("pay_id,");
sql.append(" BH,");
//sql.append("to_char(PAY_DATE,'YYYY-MM-dd') as PAY_DATE,");
sql.append("PAY_DATE,");//申请日期
sql.append("AGENCY_CODE ||'--'|| AGENCY_NAME AS AGENCY_CODE_NAME,");//预算单位
sql.append("PAYEE_NAME,");//收款人全称
sql.append("PAYEE_BANK,");//收款人开户行
sql.append("PAYEE_ACCOUNT,");//收款人账号
sql.append("MOFDEPT_CODE||'--'||MOFDEPT_NAME as MOFDEPT_CODE_NAME,");//业务科室(资金科室)
sql.append("FUNDTYPE_CODE||'--'||FUNDTYPE_NAME as FUNDTYPE_CODE_NAME,");//资金性质
sql.append("BDGSOURCE_CODE||'--'||BDGSOURCE_NAME as BDGSOURCE_CODE_NAME,");//预算来源
sql.append("EXPECONORMIC_NAME,");//经费类型
sql.append("EXPFUNC_CODE||'--'||EXPFUNC_NAME as EXPFUNC_CODE_NAME,");//功能分类
sql.append("ITEM_NAME,");//预算项目
sql.append("EXPECONORMIC_CODE||'--'||EXPECONORMIC_NAME as EXPECONORMIC_CODE_NAME,");//经济分类
sql.append("PAY_MONEY,");//金额
sql.append("REMARK,");//用途
sql.append("CONTRACT_ID ");//合同号
sql.append(" from vw_tb_pay_info v ");
sql.append(" where v.IS_ZFL=1 and v.IS_SENDBANK=0 ");
sql.append(" and v.ANNUAL=? ");
params.add(annual);
//数据权限
CommonConstant.executeDataRule(cp,params,sql,"", "");
sql.append(" order by AGENCY_CODE ASC,BH DESC,PAY_DATE DESC");
//sql.append(" where v.IS_ZFL=1 and v.ZFL_ID is null");//前置条件是IS_ZFL=1(是否生成支付令),后置条件是还不存在支付令id
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
}else{
ret.put("items", new ArrayList());
//throw new BizException("未找到申请书信息!");
}
return ret;
}
/**
* 页签2:生效
* 支付令生效按钮:修改送银行字段。当数据库中有比该选中的bh小的数据,就不允许该选中的bh生效。
* 第一步,找出最大的BH:select max(BH) from tb_pay_info where BH in (199, 201, 198)
* 第二步,找是否有不能进行生效的数据:select count(*) from tb_pay_info where bH<max and BH not in (199, 201, 198) and IS_SENDBANK = 0
* 第三步:判断:if第二步的sql语句查询为空,说明没有不符合的,此时可以生效
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> takeEffect (Map<String, Object> cp,Map<String, Object> param) throws Exception{
/*Map<String, Object> ret = new HashMap<String, Object>( );
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
String ids = (String)param.get("ids");
String bh =payInfoCommonDao.getSeqBhNumber("2");//生成支付令的序列,在tb_pay_info表中的bh字段
String[] list_id=ids.split(",");
sql.append("update tb_pay_info t set is_sendbank=1,bh=? where t.pay_id in(");
for(int x=0;x<list_id.length;x++){
sql.append(Integer.parseInt(list_id[x])+",");//此时在最后的时候多了一个逗号
}
sql=sql.deleteCharAt(sql.length()-1);
sql.append(")");
DBHelper.update(sql.toString(),bh);
ret.put("msg","生效成功!");
return ret; */
Map<String, Object> ret = new HashMap<String, Object>( );
StringBuilder sql = new StringBuilder();//针对tb_pay_info
List params = new ArrayList();
String ids = (String)param.get("ids");
sql.append("update tb_pay_info t ");
String BH = (String)param.get("BH");
String[] list_BH=BH.split(",");
String[] list_id=ids.split(",");
StringBuilder check_sql = new StringBuilder();
check_sql.append("select * from tb_pay_info ");
check_sql.append("where bH<(select max(BH) from tb_pay_info where BH in( ");
for(int y=0;y<list_BH.length;y++){
check_sql.append(Integer.parseInt(list_BH[y])+",");
}
check_sql=check_sql.deleteCharAt(check_sql.length()-1);
check_sql.append(")) ");
check_sql.append(" and BH not in(");
for(int y=0;y<list_BH.length;y++){
check_sql.append(Integer.parseInt(list_BH[y])+",");
}
check_sql=check_sql.deleteCharAt(check_sql.length()-1);
check_sql.append(") ");
check_sql.append(" and IS_SENDBANK=0 ");//没送银行
PreparedDBUtil pdb = DBHelper.query(check_sql.toString());
if(pdb!=null&&pdb.size()>0){//不能生效
ret.put("check_message", "生效失败,请按正确的编号顺序进行生效!");
}else{//如果没查到数据,说明在这个bH之前的数据都已经送银行了,此时可以生效成功
sql.append("set t.IS_SENDBANK=1 ");
//boolean flag=InsertOrUpdateSumSql(sql,params,ids,"update");\
sql.append(" where t.pay_id in(");
for(int x=0;x<list_id.length;x++){
sql.append(Integer.parseInt(list_id[x])+",");//此时在最后的时候多了一个逗号
}
sql=sql.deleteCharAt(sql.length()-1);
sql.append(")");
DBHelper.update(sql.toString());
}
ret.put("msg","生效成功!");
return ret;
}
/**
* 功能码:paySum
* 页签3:进入待汇总页签,查询待汇总支付令(此查询包括两种url,第一种url是刚点击待汇总页签查询待汇总数据,第二种情况是选择下拉菜单触发硕正事件)
* 前置条件:支付令编号不为空,后置条件:是否汇总=0,
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> noSum (Map<String, Object> cp,Map<String, Object> param) throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
Map userlogonEntity=(Map)cp.get("user");
String annual = PubTool.getMapValue(userlogonEntity, "bgtAnnual", "");
String agencyId =PubTool.getMapValue(userlogonEntity,"agencyId",""); //预算单位ID //233
String agencyCode= PubTool.getMapValue(param, "agencyCode", "");//部门编码
String userType = userlogonEntity.get("userType").toString();
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
sql.append("select ");
sql.append("pay_id,");
sql.append(" BH,");
//sql.append("to_char(PAY_DATE,'YYYY-MM-dd') as PAY_DATE,");
sql.append("PAY_DATE,");//申请日期
sql.append("AGENCY_CODE ||'--'|| AGENCY_NAME AS AGENCY_CODE_NAME,");//预算单位
sql.append("PAYEE_NAME,");//收款人全称
sql.append("PAYEE_BANK,");//收款人开户行
sql.append("PAYEE_ACCOUNT,");//收款人账号
sql.append("MOFDEPT_CODE||'--'||MOFDEPT_NAME as MOFDEPT_CODE_NAME,");//业务科室(资金科室)
sql.append("FUNDTYPE_CODE||'--'||FUNDTYPE_NAME as FUNDTYPE_CODE_NAME,");//资金性质
sql.append("BDGSOURCE_CODE||'--'||BDGSOURCE_NAME as BDGSOURCE_CODE_NAME,");//预算来源
sql.append("EXPECONORMIC_NAME,");//经费类型
sql.append("EXPFUNC_CODE||'--'||EXPFUNC_NAME as EXPFUNC_CODE_NAME,");//功能分类
sql.append("ITEM_NAME,");//预算项目
sql.append("EXPECONORMIC_CODE||'--'||EXPECONORMIC_NAME as EXPECONORMIC_CODE_NAME,");//经济分类
sql.append("PAY_MONEY,");//金额
sql.append("REMARK,");//用途
sql.append("CONTRACT_ID ");//合同号
sql.append("from vw_tb_pay_info v ");
sql.append(" where v.IS_SENDBANK=1 and v.IS_COLLECT=0 ");
sql.append(" and v.ANNUAL=? ");
params.add(annual);
//数据权限
CommonConstant.executeDataRule(cp,params,sql,agencyCode, "");
//String selecthz =param.get("selecthz").toString().trim();//下拉菜单,选择汇总条件
if(param.containsKey("dlyh")){//如果不写这个,会报错
String dlyh=StringUtil.cjkDecode(param.get("dlyh").toString().trim());
String center_bank_id=dlyh.substring(dlyh.lastIndexOf("@")+1, dlyh.length());
if(!center_bank_id.toString().equals("")&&!center_bank_id.equals("0")){ //代理银行编码
sql.append(" and v.CENTER_BANK_ID=?");
params.add(center_bank_id);
}
}
sql.append(" order by AGENCY_CODE ASC,BH DESC,PAY_DATE DESC");
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
}else{
ret.put("items", new ArrayList());
//throw new BizException("未找到申请书信息!");
}
return ret;
}
/**
* 查询汇总清算通知单
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> sumOrder (Map<String, Object> cp,Map<String, Object> param) throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
Map userlogonEntity=(Map)cp.get("user");
String annual = PubTool.getMapValue(userlogonEntity, "bgtAnnual", ""); //当前年度
String agencyId =PubTool.getMapValue(userlogonEntity,"agencyId",""); //预算单位ID //233
String userType =userlogonEntity.get("userType").toString();
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
String startdate = PubTool.getMapValue(param, "startdate", "");//开始时间
String enddate = PubTool.getMapValue(param, "enddate", "");//结束时间
String dlyh = PubTool.getMapValue(param, "dlyh", "");//代理银行
String zclx = PubTool.getMapValue(param, "zclx", "");//支出类型
/*sql.append("select ");
sql.append("COLLECT_ID,"); //汇总编号
sql.append("PAYEE_BANK, ");//收款人开户行(收款人银行账户)
sql.append("PAYEE_NAME,");//收款人名称
sql.append("PAYEE_ACCOUNT,");//收款人账号
sql.append("(select distinct PAY_BANK from tb_pay_info where tb_pay_info.COLLECT_ID=TB_PAY_COLLECT.COLLECT_ID) PAY_BANK,");//付款人银行账户
sql.append("to_char(COLLECT_DATE,'YYYY-MM-DD') as COLLECT_DATE,");//汇总日期,xml只能保存字符串,因此这里要转换一下
sql.append("COLLECT_USERNAME, ");//汇总人
sql.append("COLLECT_MONEY,");//汇总金额
sql.append("AGENCY_CODE ");
sql.append(" from TB_PAY_COLLECT ");//汇总表
sql.append(" where ANNUAL=? ");//and AGENCY_ID=?
*/
sql.append("select distinct ");
sql.append("t.COLLECT_ID,"); //汇总编号
sql.append("t.PAYEE_BANK, ");//收款人开户行(收款人银行账户)
sql.append("t.PAYEE_NAME,");//收款人名称
sql.append("t.PAYEE_ACCOUNT,");//收款人账号
sql.append("v.PAY_BANK,");//付款人银行账户
sql.append("to_char(COLLECT_DATE,'YYYY-MM-DD') as COLLECT_DATE,");//汇总日期,xml只能保存字符串,因此这里要转换一下
sql.append("COLLECT_USERNAME, ");//汇总人
sql.append("COLLECT_MONEY");//汇总金额
sql.append(" from TB_PAY_COLLECT t,vw_tb_pay_info v where t.collect_id=v.COLLECT_ID(+)");//汇总表
sql.append(" and t.ANNUAL=? ");//and AGENCY_ID=?
params.add(annual);
//数据权限
CommonConstant.executeDataRule(cp,params,sql,"", "");
//params.add(agencyId);
if(!startdate.equals("")){
sql.append(" and substr(t.COLLECT_DATE,0,9) >=to_date(?,'YYYY-MM-DD')");//注释:针对开始日期不能与结束日期相等的。
params.add(startdate.replace('.', '-'));
}
if(!enddate.equals("")){
sql.append(" and substr(t.COLLECT_DATE,0,9) <=to_date(?,'YYYY-MM-DD')");
params.add(enddate.replace('.', '-'));
}
String center_bank_id=dlyh.substring(dlyh.lastIndexOf("@")+1, dlyh.length());
if(!center_bank_id.toString().equals("")&&!center_bank_id.equals("0")){ //代理银行编码
sql.append(" and t.payee_bank_id=? ");
params.add(center_bank_id );
}
/* if(!zclx.equals("")){ //支出类型
sql.append(" and PAYKIND_ID=?");
params.add(zclx);
}*/
sql.append(" order by COLLECT_ID DESC ,COLLECT_DATE DESC");//由大到小
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
}else{
ret.put("items", new ArrayList());
//throw new BizException("未找到汇总信息!");
}
return ret;
}
/**
* 查询汇总的详情
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> sumOrderDetail (Map<String, Object> cp,Map<String, Object> param) throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
String reqId = PubTool.getMapValue(param, "reqId", "");//
sql.append("select ");
sql.append(" vw_tb_pay_info.collect_id collect_id,");
sql.append("pay_id,");
sql.append("EXPFUNC_CODE,");//功能分类编码
sql.append("EXPFUNC_NAME,");//功能分类名称
sql.append("FUNDTYPE_NAME,");//资金性质
sql.append(" (SELECT CODE FROM T_PUBAGENCY WHERE ITEMID=(SELECT SUPERITEMID FROM T_PUBAGENCY WHERE ITEMID=vw_tb_pay_info.AGENCY_ITEM_ID)) SUPERAGENCYCODE,");//部门编码
sql.append("(SELECT NAME FROM T_PUBAGENCY WHERE ITEMID=(SELECT SUPERITEMID FROM T_PUBAGENCY WHERE ITEMID=vw_tb_pay_info.AGENCY_ITEM_ID)) SUPERAGENCYNAME,");//部门名称
sql.append("PAY_MONEY");//支付金额
sql.append(" from vw_tb_pay_info ");
sql.append(" left join tb_pay_collect on tb_pay_collect.collect_id=vw_tb_pay_info.collect_id");
sql.append(" where tb_pay_collect.COLLECT_ID=?");
sql.append(" order by AGENCY_CODE ASC,BH DESC,PAY_DATE DESC");
params.add(reqId);
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
}else{
ret.put("items", new ArrayList());
//throw new BizException("未找到详细信息!");
}
return ret;
}
/**
* 打印汇总通知单
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> printSumOrder (Map<String, Object> cp,Map<String, Object> param) throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
Map userlogonEntity=(Map)cp.get("user");
String annual = PubTool.getMapValue(userlogonEntity, "bgtAnnual", ""); //当前年度
String agencyId =PubTool.getMapValue(userlogonEntity,"agencyId",""); //预算单位ID //233
StringBuilder sql = new StringBuilder();
StringBuilder sql2 = new StringBuilder();
StringBuilder sql3 = new StringBuilder();
List params = new ArrayList();
String allotId = PubTool.getMapValue(param, "allotId", "");
sql.append("select ");
sql.append("t1.COLLECT_ID COLLECT_ID,"); //汇总编号
sql.append("t1.ANNUAL ANNUAL,");//年度
//sql.append("t1.CENTER_BANK_ID,");//中心账号编码,付款人信息通过关联银行中心账户表获得
sql.append("t2.CENTER_NAME PAY_NAME,");//付款人全称
sql.append("t2.BANK_NAME PAY_BANK,");//付款人银行
sql.append("t2.BANK_ACCOUNT PAY_ACCOUNT,");//付款人账户
sql.append("t1.PAYEE_BANK PAYEE_BANK,");//收款人银行
sql.append("t1.PAYEE_ACCOUNT PAYEE_ACCOUNT,");//收款人开户行(收款人银行账户)
sql.append("t1.PAYEE_NAME PAYEE_NAME,");//收款人名称
sql.append("to_char(t1.COLLECT_DATE,'YYYY-MM-DD') as COLLECT_DATE,");//汇总日期,xml只能保存字符串,因此这里要转换一下
sql.append("t1.COLLECT_MONEY COLLECT_MONEY ");//汇总金额
sql.append(" from TB_PAY_COLLECT t1 ");//汇总表
sql.append(" left join T_PUBCENTERACCOUNT t2 ");//银行中心账户表
sql.append(" on t2.CENTER_ID=t1.CENTER_BANK_ID ");
sql.append(" where 1=1 and ");
sql.append(" t1.COLLECT_ID=? ");
sql.append(" and t1.ANNUAL=? ");//
params.add(allotId);
params.add(annual);
sql.append(" order by t1.Collect_id ASC");
sql2.append(" select ");
sql2.append(" PAY_ID,");//主键
sql2.append(" EXPFUNC_CODE,");//功能分类编码
sql2.append(" EXPFUNC_NAME,");//功能分类名称
sql2.append(" (SELECT CODE FROM T_PUBAGENCY WHERE ITEMID=(SELECT SUPERITEMID FROM T_PUBAGENCY WHERE ITEMID=vw_tb_pay_info.AGENCY_ITEM_ID)) SUPERAGENCYCODE,");//部门编码
sql2.append("(SELECT NAME FROM T_PUBAGENCY WHERE ITEMID=(SELECT SUPERITEMID FROM T_PUBAGENCY WHERE ITEMID=vw_tb_pay_info.AGENCY_ITEM_ID)) SUPERAGENCYNAME,");//部门名称
sql2.append("PAY_MONEY ");//支付金额
sql2.append(" from vw_tb_pay_info ");//支付表试图
sql2.append("left join TB_PAY_COLLECT ");
sql2.append(" on vw_tb_pay_info.COLLECT_ID=TB_PAY_COLLECT.COLLECT_ID ");
sql2.append(" where vw_tb_pay_info.COLLECT_ID=? ");
sql2.append(" and vw_tb_pay_info.ANNUAL=? ");//
sql3.append(" select MIN(BH)||' 至 '||MAX(BH) AS BH ");//去最大BH和最小BH
sql3.append(" from vw_tb_pay_info ");
sql3.append(" where vw_tb_pay_info.COLLECT_ID=? ");
sql3.append(" and vw_tb_pay_info.ANNUAL=? ");
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
PreparedDBUtil pdb2 = DBHelper.query(sql2.toString(),allotId,annual);
PreparedDBUtil pdb3 = DBHelper.query(sql3.toString(), allotId,annual);
/*String pay_ids=pdb2.getValue(0, "PAY_ID");
StringBuffer sql1=new StringBuffer();
sql1.append(" select b.* from( ");
sql1.append(" select applay_man,pay_id,max(t1.end_date) max_endate,max(to_char(end_date, 'yyyy\""+"年"+"\"mm\""+"月"+"\"dd\""+"日"+"')) end_date,");
sql1.append(" min(t1.src_user_name) src_user_name");
sql1.append(" from tb_wf_proc_log t1, tb_pay_ref_proc t where t.proc_inst_id = t1.processinst_id");
sql1.append(" and t1.remark = 'completeWf' and t.PAY_ID in ("+pay_ids+") ");
sql1.append(" group by applay_man,pay_id");
sql1.append(" ) b,tb_pay_info c ");
sql1.append(" where b.applay_man<>c.staff_name(+) ");
sql1.append(" and c.pay_id=b.pay_id and c.PAY_ID in ("+pay_ids+")");
sql1.append(" order by b.max_endate ");
PreparedDBUtil pdb3 = DBHelper.query(sql1.toString());*/
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults()); //显示汇总的结果
ret.put("year",pdb.getString(0, 8).split("-")[0]);//年
ret.put("month", pdb.getString(0,8).split("-")[1]);//月
ret.put("day", pdb.getString(0, 8).split("-")[2]);//日
ret.put("items2", pdb2.getAllResults());// 显示详情的结果
ret.put("item3", pdb3.getAllResults());
/*ret.put("wangx", pdb3.getValue(2, "src_user_name"));
ret.put("wangxdate", pdb3.getValue(2, "end_date"));
ret.put("wangy", pdb3.getValue(3, "applay_man"));
ret.put("wangydate", pdb3.getValue(3, "end_date"));
ret.put("yanw", pdb3.getValue(4, "applay_man"));
ret.put("yanwdate", pdb3.getValue(4, "end_date"));
ret.put("xuejr", pdb3.getValue(5, "applay_man"));
ret.put("xuejrdate", pdb3.getValue(5, "end_date"));*/
}else{
ret.put("items", new ArrayList());
//throw new BizException("未找到汇总信息!");
}
return ret;
}
/**
* 打印之后修改状态
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> updateStatus(Map<String, Object> cp,Map<String, Object> param)
throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
Map userlogonEntity=(Map)cp.get("user");
String userName=PubTool.getMapValue(userlogonEntity,"userName","");
String userId=PubTool.getMapValue(userlogonEntity,"userId","");
String allotId = PubTool.getMapValue(param, "allotId", "");
sql.append("update tb_pay_collect ");
sql.append(" set PRINT_ID=?,");//打印人id
sql.append(" PRINT_USERNAME=? , ");//打印人姓名
sql.append(" PRINT_DATE=sysdate ");//打印日期
sql.append(" where COLLECT_ID=?");
params.add(userId);
params.add(userName);
params.add(allotId);
DBHelper.update(sql.toString(),params);
ret.put("msg","打印成功!");//此时jsp页面的函数的返回值不为空了data
return ret;
}
/**
* 支付令预览
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> view (Map<String, Object> cp,Map<String, Object> param) throws Exception{
Map<String, Object> ret = new HashMap<String, Object>();
Map userlogonEntity=(Map)cp.get("user");
String annual = PubTool.getMapValue(userlogonEntity, "bgtAnnual", ""); //当前年度
String agencyId =PubTool.getMapValue(userlogonEntity,"agencyId",""); //预算单位ID //233
String agencyCode= PubTool.getMapValue(param, "agencyCode", "");//部门编码
String userType = userlogonEntity.get("userType").toString();
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
String startdate = PubTool.getMapValue(param, "startdate", "");//开始时间,支付令日期
String enddate = PubTool.getMapValue(param, "enddate", "");//结束时间
//String dlyh = PubTool.getMapValue(param, "dlyh", "");//代理银行
String zclx = PubTool.getMapValue(param, "zclx", "");//支出类型
String zjxz = PubTool.getMapValue(param, "zjxz", "");//支出类型
String status = PubTool.getMapValue(param, "status", "");//状态
String printstatus = PubTool.getMapValue(param, "printstatus", "");//打印状态
String dlyh=StringUtil.cjkDecode(param.get("dlyh").toString().trim());
sql.append("select ");
sql.append("pay_id,");
sql.append(" BH,");
//sql.append("to_char(PAY_DATE,'YYYY-MM-dd') as PAY_DATE,");
sql.append("PAY_DATE,");//申请日期,视图中已经转成tochar了,因此这里不用在转了
sql.append("AGENCY_CODE ||'--'|| AGENCY_NAME AS AGENCY_CODE_NAME,");//预算单位
sql.append("PAYEE_NAME,");//收款人全称
sql.append("PAYEE_BANK,");//收款人开户行
sql.append("PAYEE_ACCOUNT,");//收款人账号
sql.append("MOFDEPT_CODE||'--'||MOFDEPT_NAME as MOFDEPT_CODE_NAME,");//业务科室(资金科室)
sql.append("FUNDTYPE_CODE||'--'||FUNDTYPE_NAME as FUNDTYPE_CODE_NAME,");//资金性质
sql.append("BDGSOURCE_CODE||'--'||BDGSOURCE_NAME as BDGSOURCE_CODE_NAME,");//预算来源
sql.append("EXPECONORMIC_NAME,");//经费类型
sql.append("EXPFUNC_CODE||'--'||EXPFUNC_NAME as EXPFUNC_CODE_NAME,");//功能分类
sql.append("ITEM_NAME,");//预算项目
sql.append("EXPECONORMIC_CODE||'--'||EXPECONORMIC_NAME as EXPECONORMIC_CODE_NAME,");//经济分类
sql.append("PAY_MONEY,");//金额
sql.append("REMARK,");//用途
sql.append("CONTRACT_ID ");//合同号
sql.append("from vw_tb_pay_info ");
sql.append(" where is_collect=1 and bh is not null ");
sql.append(" and ANNUAL=? ");
params.add(annual);
//数据权限
CommonConstant.executeDataRule(cp,params,sql,agencyCode, "");
//如果用占位符(?)的形式,就会报sql语句错误,无效的列索引。因此只能在这里写死
if (!startdate.equals("")) {//开始时间
//sql.append(" and ZFL_DATE >=to_date('"+startdate+"','YYYY-MM-DD')");//视图中现在就是字符串类型的了
sql.append(" and ZFL_DATE >='"+startdate.replace('.', '-').trim()+"'");//这里必须要trim,因为日期插件里得到的日期是'2015 - 06 - 09',有空格
}
if (!enddate.equals("")) {//结束时间
sql.append(" and ZFL_DATE <='"+enddate.replace('.', '-').trim()+"'");
}
if (!dlyh.equals("")&&!dlyh.equals("0")) {//代理银行编码,刚进入页签的时候默认显示全部,此时的值不是空就是0
String center_bank_id = dlyh.substring(dlyh.lastIndexOf("@") + 1,dlyh.length());
String bankname= dlyh.substring(0,dlyh.indexOf("@"));
if(!center_bank_id.equals("0")&&!bankname.equals("全部")){//手动下拉的时候,当我们下拉时候选择全部的时候,此时后台接受的值是:'全部' || '@' ||'123456' || '@' ||'中心账户简称' || '@' ||0
sql.append(" and CENTER_BANK_ID= "+center_bank_id);
}
}
if (!zjxz.equals("")&&!zjxz.equals("0")) {//资金性质id
sql.append(" and FUNDTYPE_ID="+zjxz);
}
if (!printstatus.equals("")) {//打印状态
if(printstatus.equals("0")){//未打印
sql.append(" and IS_PRINT=0 ");
}
if(printstatus.equals("1")){//已打印
sql.append(" and IS_PRINT=1 ");
}
}
if (!status.equals("")) {//状态
if(status.equals("1")){//未退出,正常
sql.append(" and IS_BACK=0 ");
}
if(status.equals("2")){//被退回
sql.append(" and IS_BACK=1 ");
}
}
if(!"-1".equals(zclx)){
sql.append(" and PAYKINDID="+zclx);
}
//if(!zclx.equals("")){ //支出类型
// sql.append(" and PAYKINDID="+zclx);
//}
sql.append(" order by AGENCY_CODE ASC,BH DESC,PAY_DATE DESC");
PreparedDBUtil pdb = DBHelper.query(sql.toString(),params);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults());
}else{
ret.put("items", new ArrayList());//new HashMap()
}
return ret;
}
/**
* 支付令预览页签中的打印按钮,打印支付凭证
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> printpayOrder (Map<String, Object> cp,Map<String, Object> param) throws Exception{
Map<String, Object> ret = new HashMap<String, Object>( );
StringBuilder sql = new StringBuilder();
String allotId = PubTool.getMapValue(param, "allotId", "");
sql.append(" select ");
sql.append(" v.PAY_ID,");//主键
//sql.append("to_char(v.ZFL_DATE,'YYYY-MM-DD') as ZFL_DATE,");//支付令日期,xml只能保存字符串,因此这里要转换一下。现在视图里面已经转好了
sql.append("v.ZFL_DATE,");
sql.append("v.PAY_NAME,");//付款人全称
sql.append("v.PAY_BANK,");//付款人银行
sql.append("v.PAY_ACCOUNT,");//付款人账号
sql.append("v.PAYEE_NAME,");//收款人全称
sql.append("v.PAYEE_BANK,");//收款人银行
sql.append("v.PAYEE_ACCOUNT,");//收款人账号
sql.append(" v.AGENCY_NAME,");//基层单位
sql.append("(SELECT NAME FROM T_PUBAGENCY WHERE ITEMID=(SELECT SUPERITEMID FROM T_PUBAGENCY WHERE ITEMID=v.AGENCY_ITEM_ID)) SUPERPUBAGENCY_NAME,");//一级单位
sql.append(" v.EXPFUNC_CODE ||''||v.EXPFUNC_NAME AS EXPFUNC_CODE_NAME,");//功能分类编码加名称
sql.append(" v.EXPFUNC_CODE,");//功能分类编码
sql.append(" v.EXPFUNC_NAME,");//功能分类名称
sql.append("v.ITEM_CODE ||''|| v.ITEM_NAME AS ITEM_CODE_NAME,");//项目编码||名称
sql.append("v.BGT_FILENAME, ");//指标文号
sql.append("v.FUNDTYPE_NAME, ");//资金性质
sql.append("v.REMARK ,");//用途
sql.append("v.bh ,");//支付令编号
sql.append("v.PAY_MONEY ");
sql.append(" from vw_tb_pay_info v");//支付表试图
sql.append(" where 1=1 and ");
sql.append(" pay_id=? ");
sql.append(" order by AGENCY_CODE ASC,PAY_ID DESC,PAY_DATE DESC");
PreparedDBUtil pdb = DBHelper.query(sql.toString(),allotId);
if (pdb != null && pdb.size() > 0) {
ret.put("items", pdb.getAllResults()); //显示汇总的结果
ret.put("year",pdb.getString(0, 1).split("-")[0]);//年
ret.put("month", pdb.getString(0,1).split("-")[1]);//月
ret.put("day", pdb.getString(0, 1).split("-")[2]);//日
}else{
throw new BizException("未找到支付信息!");
}
return ret;
}
/**
* 支付令预览页签上的打印结束后进入修改状态的方法
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> updateViewStatus(Map<String, Object> cp,Map<String, Object> param)
throws Exception{
Map<String, Object> ret = new HashMap<String, Object>( );
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
Map userlogonEntity=(Map)cp.get("user");
String userName=PubTool.getMapValue(userlogonEntity,"userName","");
String userId=PubTool.getMapValue(userlogonEntity,"userId","");
String allotId = PubTool.getMapValue(param, "allotId", "");
sql.append("update tb_pay_info ");
sql.append(" set PRINT_ID=?,");//打印人id
sql.append(" PRINT_USERNAME=? , ");//打印人姓名
sql.append(" PRINT_DATE=sysdate,");//打印日期
sql.append(" IS_PRINT=1 ");//打印日期
sql.append(" where PAY_ID=?");
params.add(userId);
params.add(userName);
params.add(allotId);
DBHelper.update(sql.toString(),params);
ret.put("msg","打印成功!");//此时jsp页面的函数的返回值不为空了data
return ret;
}
/**
* 冲销方法
* @param cp
* @param param
* @return
* @throws Exception
*/
public Map<String, Object> writeOffPayInfo(Map<String, Object> cp,Map<String, Object> param)
throws Exception{
Map<String, Object> ret = new HashMap<String, Object>( );
StringBuilder sql = new StringBuilder();
List params = new ArrayList();
String payId = PubTool.getMapValue(param, "payId", "");
String checkAccountSQL = " select * from tb_pay_info where is_confirm = 1 and pay_id = ? ";
PreparedDBUtil pdbT = new PreparedDBUtil();
pdbT = DBHelper.query(checkAccountSQL.toString(),payId);
Object[] oT = pdbT.getAllResults();
if(oT!=null){
if(oT.length>0){
ret.put("msg", "该数据银行已经确认不可冲销!");
return ret;
}
}
String checkTwo = " select * from tb_pay_info where old_pay_id = ? ";
PreparedDBUtil pdbW = new PreparedDBUtil();
pdbW = DBHelper.query(checkTwo.toString(),payId);
Object[] oW = pdbW.getAllResults();
if(oW!=null){
if(oW.length>0){
ret.put("msg", "该数据已经有在途的冲销!");
return ret;
}
}
sql.append(" insert into tb_pay_info ");
sql.append(" (pay_id,annual,bgt_id,quota_id,agency_id,agency_item_id,zj_branch_id,zg_branch_id,paykind_id, ");
sql.append(" paytype_id,exp_eco_id,settletype_id,acctype_id,center_bank_id,pay_bank,pay_account,pay_name, ");
sql.append(" payee_bank,payee_account,payee_name,pay_money,pre_pay_money,pay_date,contract_id,flow_status, ");
sql.append(" old_pay_id,is_zfl,zfl_date,staff_id,staff_name,remark,cancel_id,is_cancel,cancel_date,settle_no, ");
sql.append(" freeze,is_sendbank,is_collect,collect_id,clear_date,is_clear,is_confirm,confirm_date,print_id,print_username, ");
sql.append(" print_date,is_print,is_realcare,is_back,notice_no,is_bkprint,bkprint_id,bkprint_username,bkprint_date) ");
sql.append(" select SEQ_TB_PAY_INFO.nextval,annual,bgt_id,quota_id,agency_id,agency_item_id,zj_branch_id,zg_branch_id,paykind_id, ");
sql.append(" paytype_id,exp_eco_id,settletype_id,acctype_id,center_bank_id,pay_bank,pay_account,pay_name, ");
sql.append(" payee_bank,payee_account,payee_name,-pay_money,-pre_pay_money,sysdate,contract_id,flow_status, ");
sql.append(" pay_id,0,zfl_date,staff_id,staff_name,remark,cancel_id,is_cancel,cancel_date,settle_no, ");
sql.append(" freeze,is_sendbank,is_collect,collect_id,clear_date,is_clear,is_confirm,confirm_date,print_id,print_username, ");
sql.append(" print_date,is_print,is_realcare,is_back,notice_no,is_bkprint,bkprint_id,bkprint_username,bkprint_date ");
sql.append(" from tb_pay_info ");
sql.append(" where pay_id = ? ");
params.add(payId);
DBHelper.update(sql.toString(),params);
ret.put("msg","操作成功!");//操作成功
return ret;
}
}