- 浏览: 56421 次
文章分类
- 全部博客 (46)
- java邮件组件 (1)
- java excel上传 (3)
- java 导出excel (1)
- java文件上传 (1)
- java文件上传、下载 (1)
- mytatis插件 (1)
- jquery.validate.min.js 非空验证 (1)
- 常用js工具 (2)
- 编程规范 (1)
- art.dialog页面 (1)
- java常量配置 (1)
- 框架知识 (2)
- web页面前段技术 (3)
- Method方法反射机制 (1)
- 数据库 (5)
- java解析excel数据 (1)
- java 反射 (1)
- spring 注解 (2)
- mybatis (4)
- Eclipse 模板 (1)
- web页面前端技术 (3)
- java 1.8 (1)
- 111111 (0)
- EL (1)
- mysql 分页 (1)
- excel导出 (1)
- 页面通用查询保存方法 (1)
- 自动创建数据库脚本 (1)
- 重复提交后台校验 (1)
- maven (1)
最新评论
<%@ page language="java" pageEncoding="UTF-8"%> <%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>开票申请</title> <link rel="stylesheet" type="text/css" href="${contextPath}/pc-rs/novatar.frameimpl/scripts/static/css/style.css" /> <script type="text/javascript" src="${contextPath}/pc-rs/novatar.frameimpl/scripts/static/js/src/fm.selectator.jquery.js"></script> <script type="text/javascript" src="${contextPath}/pc-rs/novatar.frameimpl/scripts/p2/output/billingApply.js"></script> <style type="text/css"> #selectTable .tr { height:85px; } </style> <script type="text/javascript"> var _myDialog = null; var _myDialogSepareteDialog = null; var impData = null; jQuery(document).ready(function(){ $(".tab_content").hide(); $("#con1 div.tab_content:first").show(); $("#custType").change(function() { $(".tab_content").hide(); if($("#custType").val() == '月结账号') { $("#con1 div.tab_content:first").show(); } else { $("#con1 #tab_2").show(); } }); $("#dataGridTable1").jqGrid({ datatype: "local", multiselect: true, colModel:[ {label:'ID', name:'ID',hidden:true,key:true}, {label:'IS_MAIN', name:'IS_MAIN',hidden:true}, {label:'月结账号', name:'Z_CUSTOMER_NO',width:80}, {label:'月结账号名称', name:'Z_CDH_NAME',width:80}, /* {label:'关联账号名称', name:'',width:80}, */ {label:'企业名片代码', name:'NAMECARD_ID',width:80}, {label:'所属期间', name:'BELONG_DATE',width:60}, {label:'结算网点编码', name:'BILL_PRCTR',width:80}, {label:'业务类型', name:'BUSINESS_TYPE',width:60}, {label:'发票类型', name:'INVOICE_TYPE',width:60,formatter:function(cellval, options, row) { var content = ""; if(row.INVOICE_TYPE == 'V1' || row.INVOICE_TYPE == 'v1') { content = "专票"; } else if(row.INVOICE_TYPE == 'V2' || row.INVOICE_TYPE == 'v2') { content = "普票"; } else if(row.INVOICE_TYPE == 'V3' || row.INVOICE_TYPE == 'v3'){ content = "电子发票"; } else { content = row.INVOICE_TYPE; } return content; }}, {label:'应收金额', name:'WRBTR',width:60}, {label:'未开票金额', name:'TSL_MONTH_UNBILL',width:60}, {label:'开票金额', name:'TSK_MONTH_BILL',width:70,formatter:function(cellval, options, row) { if (row.TSK_MONTH_BILL > 0) { return row.TSK_MONTH_BILL; } else { var content = "<input type='text' value='"+row.TSL_MONTH_UNBILL+"' id='TSK_MONTH_BILL_"+row.ID+"' name = 'TSK_MONTH_BILL_" + row.ID +"' onkeypress='keyPress()'/>"; return content; } }}, {label:'差异原因', name:'DIFF_REASON',width:80,formatter:function(cellval, options, row) { if (row.DIFF_REASON != null) { return row.DIFF_REASON; } else { var content = "<select id = 'DIFF_REASON_"+row.ID+"' name = 'DIFF_REASON_" + row.ID + "'><option value=''>请选择</option><option value='A'>账单金额或应收金额需调整</option><option value='B'>运单挂错月结号</option><option value='C'>退换票</option><option value='E'>理赔</option></select>"; // 如果是补开才添加 if ($("#REBILL_FLAG").val()) { content = "<select id = 'DIFF_REASON_"+row.ID+"' name = 'DIFF_REASON_" + row.ID + "'><option value=''>请选择</option><option value='A'>账单金额或应收金额需调整</option><option value='B'>运单挂错月结号</option><option value='C'>退换票</option><option value='D'>正常补开</option><option value='E'>理赔</option></select>"; } return content; } }}, {label:'是否直寄', name:'IS_POST',width:80,formatter:function(cellval, options, row) { return row.IS_POST == 'X' ? '是':'否'; }}, {label:'票面备注', name:'TICKETS_BACK',width:80,formatter:function(cellval, options, row) { var content = "<input type='text' id = 'TICKETS_BACK_"+row.ID+"' name = 'TICKETS_BACK_" + row.ID + "'/>"; return content; }}, {label:'税号', name:'Z_TAX_ID',width:80}, {label:'地址&电话', name:'ADDR_TEL',width:80}, {label:'开户行&账号', name:'BANK_ACCOUNT',width:80}, {label:'货物或应税劳务名称', name:'MAKTX',width:80}, {label:'单位', name:'MEINS',width:50,formatter:function(cellval, options, row) { var value = (row.MEINS === undefined) ? "": row.MEINS; var content = "<input type='text' id = 'MEINS_"+row.ID+"' name = 'MEINS_" + row.ID + "' value='"+value+"'/>"; return content; }}, {label:'单价', name:'UNITPE',width:50,formatter:function(cellval, options, row) { var value = (row.UNITPE === undefined) ? "": row.UNITPE; var content = "<input type='text' id = 'UNITPE_"+row.ID+"' name = 'UNITPE_" + row.ID + "' value='"+value+"'/>"; return content; }}, {label:'数量', name:'FKIMG',width:50,formatter:function(cellval, options, row) { var value = (row.FKIMG === undefined) ? "": row.FKIMG; var content = "<input type='text' id = 'FKIMG_"+row.ID+"' name = 'FKIMG_" + row.ID + "' value='"+value+"'/>"; return content; }}, {label:'规格', name:'MSPEC',width:50,formatter:function(cellval, options, row) { var value = (row.MSPEC === undefined) ? "": row.MSPEC; var content = "<input type='text' id = 'MSPEC_"+row.ID+"' name = 'MSPEC_" + row.ID + "' value='"+value+"'/>"; return content; }}, {label:'申请人员备注', name:'applierBack',width:80,formatter:function(cellval, options, row) { var content = "<input type='text' id = 'applierBack_"+row.ID+"' name = 'applierBack_" + row.ID + "'/>"; return content; }}, {label:'驳回原因', name:'REJECT_REASON'}, ], rowNum:30, rowList:[10,20,30,50,100], jsonReader : { root : 'expData.page.data', page : 'expData.page.index', total : 'expData.page.total', records : 'expData.page.totalRecord', repeatitems : false }, rownumbers: true, pager: '#pgtoolbar1', viewrecords: true, height: 400, shrinkToFit: false, autoScroll: true, subGrid : true,//子表格启用 subGridOptions : {//子表格选项 plusicon : "ace-icon fa fa-plus center bigger-110 blue",//展开图标 minusicon : "ace-icon fa fa-minus center bigger-110 blue",//收缩图标 openicon : "ace-icon fa fa-chevron-right center orange"//打开时左侧图标 }, subGridRowExpanded: function (subgrid_id, rowId) { var subgrid_table_id; subgrid_table_id = subgrid_id+"_t"; jQuery("#"+subgrid_id).html("<table id='"+subgrid_table_id+"' class='scroll'></table>"); jQuery("#"+subgrid_table_id).jqGrid({ url : "${contextPath}/service/pageReq?random="+ Math.random(), postData : { needcontrolprocess : "billingApplyBusiness.querySubAccount", content : "headerId:" + rowId //TODO 查询添加纳税主体权限 }, colModel:[ {label:'SUB_XH', name:'SUB_XH',hidden:true,key:true}, {label:'', name:'',width:80}, {label:'', name:'',width:80}, {label:'关联账号名称', name:'sub_Z_CDH_NAME',width:80}, {label:'所属期间', name:'sub_BELONG_DATE',width:60}, {label:'结算网点编码', name:'sub_BILL_PRCTR',width:80}, {label:'业务类型', name:'sub_BUSINESS_TYPE',width:60,formatter:function(cellval, options, row) { var content = ""; if(row.sub_BUSINESS_TYPE == '01') { content = "运费"; } else if(row.sub_BUSINESS_TYPE == '07'){ content = "税金"; } else if(row.sub_BUSINESS_TYPE == '08'){ content = "仓储"; } else if(row.sub_BUSINESS_TYPE == '09'){ content = "租赁"; } else if(row.sub_BUSINESS_TYPE == '10'){ content = "佣金"; } else if(row.sub_BUSINESS_TYPE == '11'){ content = "数据灯塔服务费"; } else if(row.sub_BUSINESS_TYPE == 'A1'){ content = "资产"; } else if(row.sub_BUSINESS_TYPE == 'A2'){ content = "物资"; } else { content = row.sub_BUSINESS_TYPE; } return content; }}, {label:'发票类型', name:'sub_INVOICE_TYPE',width:60,formatter:function(cellval, options, row) { var content = ""; if(row.sub_INVOICE_TYPE == 'V1') { content = "专票"; } else if(row.sub_INVOICE_TYPE == 'V2') { content = "普票"; } else if((row.sub_INVOICE_TYPE == 'V3')){ content = "电子发票"; } else { content = row.sub_INVOICE_TYPE; } return content; }}, {label:'应收金额', name:'sub_WRBTR',width:60}, {label:'未开票金额', name:'sub_TSL_MONTH_UNBILL',width:60}, {label:'开票金额', name:'sub_TSK_MONTH_BILL',width:70,formatter:function(cellval, options, row) { var content = "<input type='text' SUB_DATA_ID='"+row.sub_ID+"_"+row.SUB_XH+"' id='SUB_TSK_MONTH_BILL_"+row.sub_ID+"' name = 'SUB_TSK_MONTH_BILL_" + row.sub_ID +"' onkeypress='keyPress()'/>"; return content; }}, {label:'差异原因', name:'sub_DIFF_REASON',width:80,formatter:function(cellval, options, row) { /* var content = "<input type='text' SUB_DATA_ID='"+row.sub_ID+"_"+row.SUB_XH+"' id = 'SUB_DIFF_REASON_"+row.sub_ID+"' name = 'SUB_DIFF_REASON_" + row.sub_ID + "'/>"; return content; */ var content = "<select SUB_DATA_ID='"+row.sub_ID+"_"+row.SUB_XH+"' id = 'SUB_DIFF_REASON_"+row.sub_ID+"' name = 'SUB_DIFF_REASON_" + row.sub_ID + "'><option value=''>请选择</option><option value='A'>账单金额或应收金额需调整</option><option value='B'>运单挂错月结号</option><option value='C'>退换票</option><option value='E'>理赔</option></select>"; // 如果是补开才添加 if ($("#REBILL_FLAG").val()) { var content = "<select SUB_DATA_ID='"+row.sub_ID+"_"+row.SUB_XH+"' id = 'SUB_DIFF_REASON_"+row.sub_ID+"' name = 'SUB_DIFF_REASON_" + row.sub_ID + "'><option value=''>请选择</option><option value='A'>账单金额或应收金额需调整</option><option value='B'>运单挂错月结号</option><option value='C'>退换票</option><option value='D'>正常补开</option><option value='E'>理赔</option></select>"; } return content; }}, {label:'票面备注', name:'sub_TICKETS_BACK',width:80,formatter:function(cellval, options, row) { var content = "<input type='text' SUB_DATA_ID='"+row.sub_ID+"_"+row.SUB_XH+"' id = 'SUB_TICKETS_BACK_"+row.sub_ID+"' name = 'SUB_TICKETS_BACK_" + row.sub_ID + "'/>"; return content; }}, {label:'税号', name:'sub_Z_TAX_ID',width:80}, {label:'地址&电话', name:'sub_ADDR_TEL',width:80}, {label:'开户行&账号', name:'sub_BANK_ACCOUNT',width:80}, {label:'货物或应税劳务名称', name:'sub_MAKTX',width:80}, {label:'单位', name:'sub_MEINS',width:50,formatter:function(cellval, options, row) { var value = (row.sub_MEINS === undefined) ? "": row.sub_MEINS; var content = "<input type='text' SUB_DATA_TYPE='"+row.sub_BUSINESS_TYPE+"' id = 'sub_MEINS_"+row.sub_ID+"' name = 'sub_MEINS_" + row.sub_ID + "' value='"+value+"'/>"; return content; }}, {label:'单价', name:'sub_UNITPE',width:50,formatter:function(cellval, options, row) { var value = (row.sub_UNITPE === undefined) ? "": row.sub_UNITPE; var content = "<input type='text' id = 'sub_UNITPE_"+row.sub_ID+"' name = 'sub_UNITPE_" + row.sub_ID + "' value='"+value+"'/>"; return content; }}, {label:'数量', name:'sub_FKIMG',width:50,formatter:function(cellval, options, row) { var value = (row.sub_FKIMG === undefined) ? "": row.sub_FKIMG; var content = "<input type='text' id = 'sub_FKIMG_"+row.sub_ID+"' name = 'sub_FKIMG_" + row.sub_ID + "' value='"+value+"'/>"; return content; }}, {label:'规格', name:'sub_MSPEC',width:50,formatter:function(cellval, options, row) { var value = (row.sub_MSPEC === undefined) ? "": row.sub_MSPEC; var content = "<input type='text' id = 'sub_MSPEC_"+row.sub_ID+"' name = 'sub_MSPEC_" + row.sub_ID + "' value='"+value+"'/>"; return content; }}, /* {label:'单位', name:'sub_MEINS',width:50}, {label:'单价', name:'sub_UNITPE',width:50}, {label:'数量', name:'sub_FKIMG',width:50}, {label:'规格', name:'sub_MSPEC',width:50}, */ {label:'申请人员备注', name:'sub_applierBack',width:80,formatter:function(cellval, options, row) { var content = "<input type='text' SUB_DATA_ID='"+row.sub_ID+"_"+row.SUB_XH+"' id = 'SUB_applierBack_"+row.sub_ID+"' name = 'SUB_applierBack_" + row.sub_ID + "'/>"; return content; }} ], datatype: "json", height: '100%', rowNum: 1000, shrinkToFit: false, autoScroll: true, //rownumbers: true, jsonReader : { root : 'expData.page', repeatitems : false } }); }, loadComplete: function(xhr) { var ids = $("#dataGridTable1").jqGrid('getDataIDs'); for(var i=0; i<ids.length; i++) { var rowData = $("#dataGridTable1").jqGrid('getRowData',ids[i]); var IS_MAIN = rowData.IS_MAIN; if (IS_MAIN < 2) { $('#' + ids[i]).find("span").hide(); $('#' + ids[i]).find("a").attr("onclick", "null"); } } } }); $("#dataGridTable2").jqGrid({ datatype: "local", multiselect: true, colModel:[ {label:'ID', name:'ID',key:true,hidden:true}, {label:'点部', name:'BRANCH'}, {label:'申请期间', name:'BELONG_DATE'}, {label:'开票名称', name:'CUST_NAME',width:140}, {label:'纳税人识别号', name:'TAXPAY_ID',width:140}, {label:'收票方地址&电话', name:'ADDR'}, {label:'银行名称&账号', name:'ACCOUNT_NO'}, {label:'开票金额', name:'TAXAMT'}, {label:'发票类型', name:'INVOICE_TYPE',formatter:function(cellval, options, row) { var content = ""; if(row.INVOICE_TYPE == 'V1') { content = "专票"; } else if(row.INVOICE_TYPE == 'V2') { content = "普票"; } else if(row.INVOICE_TYPE == 'V3'){ content = "电子发票"; } else { content = row.INVOICE_TYPE; } return content; }}, {label:'运单号', name:'BILL_NO'}, {label:'货物或应税劳务名称', name:'DES'}, {label:'规格', name:'SPEC'}, {label:'单位', name:'UNIT'}, {label:'单价', name:'UNIT_PRICE'}, {label:'数量', name:'AMOUNT'}, {label:'收款人', name:'PAYEE'}, {label:'复核', name:'RECHECKER'}, {label:'备注', name:'REMARK'}, {label:'税率', name:'RETE'}, {label:'收件人地址', name:'RECV_ADDR'}, {label:'收件人姓名', name:'RECV_NAME'}, {label:'收件人电话', name:'RECV_TEL'}, {label:'驳回原因', name:'REJECT_REASON'}, {label:'异常备注', name:'EXCEP_REMARK'}, {label:'月结账号', name:'SETTLEMENT'}, ], rowNum:30, rowList:[10,20,30,50,100], jsonReader : { root : 'expData.page.data', page : 'expData.page.index', total : 'expData.page.total', records : 'expData.page.totalRecord', repeatitems : false }, rownumbers: true, pager: '#pgtoolbar2', viewrecords: true, height: 400 }); $("#dataForm1").validator({},{ callback : function(results){ $('#dataGridTable1').jqGrid('setGridParam', {page:1}); doSearch('commonSearch'); } }); $('#reset-btn1').click(function() { $("#BUSINESS_TYPE").selectator('destroy'); $("#BUSINESS_TYPE").val(""); $("#BUSINESS_TYPE").find("option").attr("selected",false); $("#BUSINESS_TYPE").selectator({ height: '20', showAllOptionsOnFocus: true, keepOpen: true }); $("#BILL_PRCTR").selectator('destroy'); $("#BILL_PRCTR").val(""); $("#BILL_PRCTR").selectator({ height: '20', showAllOptionsOnFocus: true, keepOpen: true }); $("#selectTable #startDate #endDate #Z_CUSTOMER_NO").val(""); }); $("#export-btn1").click(function() { var params = $('#params').val(); if (params) { params = "&content=" + params; params = "&needcontrolprocess=billingApplyBusiness.exportOuterCust" + params; art.dialog({ title : '消息', content: '确定要导出吗?', lock : true, ok: function () { this.title('导出中').content('导出中...'); var url = '${contextPath}/service/export?random='+ Math.random() + params; window.open(url, "_self"); return true; }, cancel: true }); } else { art.dialog({ title : '消息', content: '先查询才可以导出', lock : true, ok: function () { return true; } }); } }); $("#search-btn2").click(function() { $("#REBILL_FLAG").val("REBILL"); $('#dataGridTable1').jqGrid('setGridParam', {page:1}); doSearch('reBillSearch'); }); //加载网点 get_BILL_PRCTR(); //业务类型 get_BUSINESS_TYPE(); $("#BUSINESS_TYPE").selectator({ height: '20', showAllOptionsOnFocus: true, keepOpen: true }); $("#BILL_PRCTR").selectator({ height: '20', showAllOptionsOnFocus: true, keepOpen: true }); // 账期设置默认值 $("#startDate").val(getBeforeMonth()); }); function doSearch(searchType) { if(searchType != 'reBillSearch') { $("#REBILL_FLAG").val(""); } var params = insFormvalue(); params += "|searchType:" + searchType; $('#params').val(params); var pageCount = $('#dataGridTable1').jqGrid('getGridParam', 'page'); $("#dataGridTable1").clearGridData(); $("#dataGridTable1").jqGrid("setGridParam", { url : "${contextPath}/service/pageReq?random="+ Math.random(), page : pageCount, postData : { needcontrolprocess : "billingApplyBusiness.queryUnbilled", content : params //TODO 查询添加纳税主体权限 }, datatype: "json" }).trigger("reloadGrid"); } function doSearchDesperse() { // 当前查询状态; $("#queryStatus").val($("#KP_FLAG").val()); var params = formValue($("#dataForm2")); var pageCount = $('#dataGridTable2').jqGrid('getGridParam', 'page'); $("#dataGridTable2").clearGridData(); $("#dataGridTable2").jqGrid("setGridParam", { url : "${contextPath}/service/pageReq?random="+ Math.random(), page : pageCount, postData : { needcontrolprocess : "billingApplyBusiness.queryUnbilledDesperse", content : params //TODO 查询权限 }, datatype: "json" }).trigger("reloadGrid"); $("#allSelect").attr("checked", false); } function showDialog(params, options) { _myDialog = art.dialog(options);// 初始化一个带有loading图标的空对话框 jQuery.ajax({ url : "${contextPath}/service/page?name=" + params, success : function(data) { _myDialog.content(data);// 填充对话框内容 } }); } function insFormvalue(){ var param = ""; param += $("#BILL_PRCTR").attr("name") + ":" + ($("#BILL_PRCTR").val() == null ? "" : $("#BILL_PRCTR").val()) + "|"; param += $("#Z_CUSTOMER_NO").attr("name") + ":" + $("#Z_CUSTOMER_NO").val() + "|"; param += $("#BUSINESS_TYPE").attr("name") + ":" + ($("#BUSINESS_TYPE").val() == null ? "" : $("#BUSINESS_TYPE").val()) + "|"; param += $("#startDate").attr("name") + ":" + $("#startDate").val() + "|"; param += $("#endDate").attr("name") + ":" + $("#endDate").val() + "|"; param += $("#REJECT").attr("name") + ":" + $("#REJECT").val() + "|"; param += $("#ZZPERSR").attr("name") + ":" + $("#ZZPERSR").val() + "|"; param += $("#BILL_STATUS").attr("name") + ":" + ($("#BILL_STATUS").val() == null ? "" : $("#BILL_STATUS").val()); return param; } //@ sourceURL=billingApply.js </script> </head> <body> <div class="modal"> <div class="modal-header r_location"> <i class="r_txtico"></i>税务管理 > 开票申请 </div> <!-- start --> <select id="custType" class="form-control" style="width:90px;height:25px;padding:0px;margin-bottom: 0px;"> <option value="月结账号">月结账号</option> <option value="散单">散单</option> </select> <div id="con1" class="tab_container"> <div id="tab_1" class="tab_content" style="display: block; "> <form id="dataForm1" class="view vt1"> <table id="selectTable" class="table"> <tr> <td class="title">网点:</td> <td class="content"> <select class="form-control" name="BILL_PRCTR" id="BILL_PRCTR" style="width:110px;height:25px;padding:0px" multiple> </select> </td> <td class="title">客户:</td> <td class="content"> <input class="form-control" name="Z_CUSTOMER_NO" id="Z_CUSTOMER_NO" style="width:120px;height:25px;padding:0px" placeholder="多个客户,用','分隔"/> </td> <td class="title">业务类型:</td> <td class="content"> <select class="form-control" name="BUSINESS_TYPE" id="BUSINESS_TYPE" style="width:110px;height:25px;padding:0px" multiple> </select> </td> </tr> <tr> <td class="title">账期:</td> <td class="content"> <input type="text" class="form-control Wdate" style="width:65px;" id="startDate" name="startDate" onclick="WdatePicker({dateFmt:'yyyyMM'})"> - <input type="text" class="form-control Wdate" style="width:65px;" id="endDate" name="endDate" onclick="WdatePicker({dateFmt:'yyyyMM',minDate:'#F{$dp.$D(\'startDate\',{M:-0});}'})"> </td> <td class="title">是否驳回:</td> <td class="content"> <select class="form-control" name="REJECT" id="REJECT" style="width:120px;height:25px;padding:0px"> <option value="">--选择--</option> <option value="1">是</option><option value="0">否</option> </select> </td> <td class="title">业务员:</td> <td class="content"> <input class="form-control" name="ZZPERSR" id="ZZPERSR" style="width:120px;height:25px;padding:0px" placeholder="多个用','分隔"/> </td> </tr> <tr> <td></td> <td class="content" colspan="5"> <input type="button" class="btn_blue m-r15 submitBtn" value="查 询" id="search-btn1"> <input type="reset" class="btn_gray m-r15" value="重 置" id="reset-btn1"> <input type="button" class="btn_gray m-r15" value="合并" id="post-btn2" onclick="postSelf('merged')"> <input type="button" class="btn_gray m-r15" value="拆分" id="seprate-btn1" onclick="separate()"/> </td> </tr> </table> </form> <div class="modal-body"> <div class="m-t10"> <div class="clearfix table_fn"> <span class="l"></span> <span class="r"> <input type="button" class="btn_gray m-r15" value="提交" id="post-btn1" onclick="postSelf('alone')"> <input type="button" class="btn_gray m-r15" value="导出" id="export-btn1" /> <input type="button" class="btn_gray m-r15" value="导入" id="import-btn2" onclick="importExcel2()"/> <%-- <shiro:hasPermission name="/page/b/b16/export"> </shiro:hasPermission> --%> </span> </div> <div class="clearfix"> <table id="dataGridTable1"></table> <div id="pgtoolbar1" class="pgtoolbar"></div> </div> </div> </div> <input type="hidden" id="params"> <input type="hidden" id="REBILL_FLAG"/> </div> <div id="tab_2" class="tab_content" style="display: block; "> <form id="dataForm2"> <table id="selectTable" class="table"> <tr> <td class="title">点部:</td> <td class="content"> <input type="text" name="BRANCH" id="BRANCH" class="form-control"/> </td> <td class="title">客户名称:</td> <td class="content"> <input type="text" name="CUST_NAME" id="CUST_NAME" class="form-control"/> </td> <td class="title">纳税人识别号:</td> <td class="content"> <input type="text" name="TAXPAY_ID" id="TAXPAY_ID" class="form-control"/> </td> </tr> <tr> <td class="title">发票状态:</td> <td class="content"> <select class="form-control" name="KP_FLAG" id="KP_FLAG" style="width:110px;height:25px;padding:0px"> <option value="01" selected>未提交</option> <option value="02">已提交</option> <!-- <option value="03">冲销</option> --> </select> </td> <td class="title">申请期间:</td> <td class="content"> <input type="text" class="form-control Wdate" style="width:150px;" id="BELONG_DATE" name="BELONG_DATE" onclick="WdatePicker({dateFmt:'yyyyMM'})" /> </td> <td class="title">是否驳回:</td> <td class="content"> <select class="form-control" name="REJECT_D" id="REJECT_D" style="width:120px;height:25px;padding:0px"> <option >--选择--</option> <option value="1">是</option> <option value="0">否</option> </select> </td> </tr> <tr> <td></td> <td class="content" colspan="3"> <input type="button" class="btn_blue m-r15" value="查 询" id="search-btn3" onclick="doSearchDesperse()"> <input type="reset" class="btn_gray m-r15" value="重 置" id="reset-btn2"> <input type="button" class="btn_gray m-r15" value="提交" id="post-btnDesperse" onclick="postDesperse()"> </td> </tr> </table> </form> <div class="modal-body"> <div class="m-t10"> <div class="clearfix table_fn"> <span class="l"> <label><input id="allSelect" name="allSelect" type="checkbox" value="" />全选</label> </span> <span class="r"> <a href="${contextPath}/down_p2/dispersing_model.xls" style="margin-top: 30px;font-size: 15px;">导入模板下载</a> <input type="button" class="btn_gray m-r15" value="散单导入" id="import-btn1" onclick="importExcel()"/> <input type="button" class="btn_gray m-r15" value="删除" id="delete-btn1" onclick="deleteRecord()"/> </span> </div> <div class="clearfix"> <table id="dataGridTable2"></table> <div id="pgtoolbar2" class="pgtoolbar"></div> </div> </div> </div> </div> </div> </div> <div id="import-content" style="display:none;"> <form id="upForm" action="#" method="post" enctype="multipart/form-data"> <ul class="all_list"> <li class="m-t10"> <span class="all_title"></span> <input type="file" name="excel" id="excel" class="all_input v-m" style="width: 300px" /> <input type="button" id="upBtn" value="上传" class="btn_big submitBtn v-m" onclick="import_apply()"/> </li> </ul> </form> </div> <div id="import-content2" style="display:none;"> <form id="upForm" action="#" method="post" enctype="multipart/form-data"> <ul class="all_list"> <li class="m-t10"> <span class="all_title"></span> <input type="file" name="excel" id="excel2" class="all_input v-m" style="width: 300px" /> <input type="button" id="upBtn" value="上传" class="btn_big submitBtn v-m" onclick="import_apply2()"/> </li> </ul> </form> </div> <div class="countly_title" style="display: none;">开票申请</div> <input type="hidden" id="queryStatus"> </body> <jsp:include page="../../../myCountlyStart.jsp"></jsp:include> <script type="text/javascript" src="${contextPath}/pc-rs/novatar.frameimpl/scripts/static/js/lib/formSerialize.js"></script> <link rel="stylesheet" type="text/css" href="${contextPath}/pc-rs/novatar.frameimpl/scripts/static/css/fm.selectator.jquery.css" /> <script type="text/javascript" src="${contextPath}/pc-rs/novatar.frameimpl/scripts/static/js/lib/jquery.jqGrid.js"></script> <script type="text/javascript" src="${contextPath}/pc-rs/novatar.frameimpl/scripts/p2/output/p2_gride.js"></script> </html>
////////////////////////////////////
function get_BILL_PRCTR () { $("#BILL_PRCTR").empty(); $.ajax({ url: contextPath + "/service/pageReq", type : "POST", dataType : "json", async : false, //异步 data: { needcontrolprocess: "billingApplyBusiness.getCommonList", content : "queryType:BILL_PRCTR" //TODO 网点 }, success: function(result) { var status = result.status; if ("FAIL" != status) { try { var data = result.expData.resultList; $.each(data, function(i,n) { $("#BILL_PRCTR").append('<option value="' + n.BILL_PRCTR + '"> ' + n.BILL_PRCTR + '</option>'); }); } catch(e) {} } } }); } function get_BUSINESS_TYPE() { $("#BUSINESS_TYPE").empty(); $.ajax({ url: contextPath + "/service/pageReq", type : "POST", dataType : "json", async : false, //异步 data: { needcontrolprocess: "billingApplyBusiness.getCommonList", content : "queryType:BUSINESS_TYPE" //TODO 客户 }, success: function(result) { var status = result.status; if ("FAIL" != status) { try { var data = result.expData.resultList; $.each(data, function(i,n) { // 默认选择运费 if(n.BUSINESS_TYPE == "01") { $("#BUSINESS_TYPE").append('<option selected value="' + n.BUSINESS_TYPE + '"> ' + n.BUSINESS_DESC + '</option>'); } else { $("#BUSINESS_TYPE").append('<option value="' + n.BUSINESS_TYPE + '"> ' + n.BUSINESS_DESC + '</option>'); } }); } catch(e) {} } } }); } function get_BILL_STATUS() { $("#BILL_STATUS").empty(); $("#KP_FLAG").empty(); $.ajax({ url: contextPath + "/service/pageReq", type : "POST", dataType : "json", async : false, //异步 data: { needcontrolprocess: "billingApplyBusiness.getBillStatusList", content : "queryType:BILL_STATUS" //TODO 状态 }, success: function(result) { var status = result.status; if ("FAIL" != status) { try { var data = result.expData.resultList.split(","); for(var i = 0; i < data.length; i++) { var value = data[i].split("="); $("#BILL_STATUS").append('<option value="' + value[0] + '"> ' + value[1] + '</option>'); $("#KP_FLAG").append('<option value="' + value[0] + '"> ' + value[1] + '</option>'); } } catch(e) {} } } }); } function keyPress() { var keyCode = event.keyCode; if ( (keyCode >= 48 && keyCode <= 57) || keyCode == 46 || keyCode == 13 || keyCode == 45) { event.returnValue = true; } else { event.returnValue = false; } } function postSelf(obj) { // 上传 if (impData) { call_imp_func(impData); } else { // 获取选择行主键数组 var ids = $('#dataGridTable1').jqGrid('getGridParam','selarrrow'); if(ids == "" || ids == null) { art.dialog({ title : '消息', width : '300px', content: "至少选择一行", lock : true, ok:true }); } else { if(obj == 'merged' && ids.length == 1) { art.dialog({ title : '消息', width : '300px', content: "合并提交请选择多行", lock : true, ok:true }); return; } else if(obj == 'merged' && ids.length > 1) { if(!checkIfAllowed(ids)) return; } // 主账号开票金额 var TSK_MONTH_BILL = []; // 所属期间 var bellong_date = []; // 主账号差异原因 var DIFF_REASON = []; // 主账号票面备注 var TICKETS_BACK = []; // 主账号申请人员备注 var applierBack = []; // 单位 var MEINS = []; // 单价 var UNITPE = []; // 数量 var FKIMG = []; // 规格 var MSPEC = []; var sub_MEINS = []; var sub_UNITPE = []; var sub_FKIMG = []; var sub_MSPEC = []; // 子账号数组 var sub_ID = []; // 子账号开票金额 var SUB_TSK_MONTH_BILL = []; // 子账号差异原因 var SUB_DIFF_REASON = []; // 子账号票面备注 var SUB_TICKETS_BACK = []; // 子账号申请人员备注 var SUB_applierBack = []; var sub_type = []; var AMOUNT_RECEIVABLE; var j=0,k=0,m=0,n=0,r=0,s=0,t=0,u=0,w=0,d=0; var subCount = 0; //循环校验数据 for(var i=0; i<ids.length; i++) { //未开总金额 AMOUNT_RECEIVABLE = $("#dataGridTable1").jqGrid('getCell',ids[i],'TSL_MONTH_UNBILL'); // 主账号开票金额 TSK_MONTH_BILL[i] = $("#TSK_MONTH_BILL_" + ids[i]).val() == "" ? 0:$("#TSK_MONTH_BILL_" + ids[i]).val(); // 主账号差异原因 DIFF_REASON[i] = $("#DIFF_REASON_" + ids[i]).val(); // 需求变更,取消次校验 /*if (rebillFlag) { if (TSK_MONTH_BILL[i] != "0" && DIFF_REASON[i] == '') { art.dialog({ title : '消息', width : '300px', content: "补开必须输入差异原因", lock : true, ok:true }); return; } }*/ // 主账号票面备注 TICKETS_BACK[i] = $("#TICKETS_BACK_" + ids[i]).val(); // 主账号申请人员备注 applierBack[i] = $("#applierBack_" + ids[i]).val(); MEINS[i] = $("#MEINS_" + ids[i]).val(); UNITPE[i] = $("#UNITPE_" + ids[i]).val(); FKIMG[i] = $("#FKIMG_" + ids[i]).val(); MSPEC[i] = $("#MSPEC_" + ids[i]).val(); // 所属期间 bellong_date[i] = $("#dataGridTable1").jqGrid('getCell',ids[i],'BELONG_DATE'); //子账号开票金额 var sub_amt_sum = 0; var sub_amt_sum_temp = []; $("input[name='SUB_TSK_MONTH_BILL_"+ids[i]+"']").each(function(i) { SUB_TSK_MONTH_BILL[j++] = parseFloat($(this).val() == "" ? 0:$(this).val()); sub_amt_sum_temp[i] = parseFloat($(this).val() == "" ? 0:$(this).val()); sub_ID[k++] = $(this).attr("SUB_DATA_ID"); sub_amt_sum += parseFloat($(this).val() == "" ? 0:$(this).val()); //subCount = sub_amt_sum_temp.length; }); if (subCount == 0 && sub_amt_sum_temp.length > 0) { subCount = sub_amt_sum_temp.length; } // 子账号差异原因 var sub_diff_reason_temp = []; $("select[name='SUB_DIFF_REASON_"+ids[i]+"']").each(function(i) { SUB_DIFF_REASON[m++] = $(this).val(); sub_diff_reason_temp[i] = $(this).val(); }); // 子账号票面备注 $("input[name='SUB_TICKETS_BACK_"+ids[i]+"']").each(function(i) { SUB_TICKETS_BACK[n++] = $(this).val(); }); // 子账号申请人员备注 $("input[name='SUB_applierBack_"+ids[i]+"']").each(function(i) { SUB_applierBack[r++] = $(this).val(); }); $("input[name='sub_MEINS_"+ids[i]+"']").each(function(i) { sub_MEINS[s++] = $(this).val(); sub_type[d++] = $(this).attr("SUB_DATA_TYPE"); }); $("input[name='sub_UNITPE_"+ids[i]+"']").each(function(i) { sub_UNITPE[t++] = $(this).val(); }); $("input[name='sub_FKIMG_"+ids[i]+"']").each(function(i) { sub_FKIMG[u++] = $(this).val(); }); $("input[name='sub_MSPEC_"+ids[i]+"']").each(function(i) { sub_MSPEC[w++] = $(this).val(); }); // 判断是否存在差异 if(!checkAmount(AMOUNT_RECEIVABLE,TSK_MONTH_BILL[i],DIFF_REASON[i],sub_amt_sum,sub_amt_sum_temp,sub_diff_reason_temp)) { return; } } // 如果是合并,判断不同月份的同一子账号,单位,单价,数量,规格必须相同; if (obj == 'merged') { var result = checkMergedCondition(sub_ID,sub_type,SUB_TICKETS_BACK,SUB_TSK_MONTH_BILL, sub_MEINS,sub_UNITPE,sub_FKIMG,sub_MSPEC,subCount); if (!result) { return; } } var params = "ids:" + ids + "|TSK_MONTH_BILL:" + TSK_MONTH_BILL + "|DIFF_REASON:" + DIFF_REASON +"|TICKETS_BACK:" + TICKETS_BACK + "|applierBack:" + applierBack + "|sub_ID:" + sub_ID +"|SUB_TSK_MONTH_BILL:" + SUB_TSK_MONTH_BILL + "|SUB_DIFF_REASON:" + SUB_DIFF_REASON +"|SUB_TICKETS_BACK:" + SUB_TICKETS_BACK + "|SUB_applierBack:" + SUB_applierBack +"|postType:" + obj + "|bellong_date:" + bellong_date + "|REBILL_FLAG:" + $("#REBILL_FLAG").val() +"|MEINS:"+ MEINS + "|UNITPE:" + UNITPE + "|FKIMG:" + FKIMG + "|MSPEC:" + MSPEC +"|sub_MEINS:" +sub_MEINS + "|sub_UNITPE:" + sub_UNITPE + "|sub_FKIMG:" + sub_FKIMG + "|sub_MSPEC:" + sub_MSPEC; // 提示信息 var remindMsg; if(obj == 'merged') remindMsg = '<font color="red">所选数据将合并开为一张发票,是否确定要提交?</font>'; else remindMsg = '是否提交开票数据'; //提交数据后台生产发票批 art.dialog({ title : '消息', content: remindMsg, lock : true, ok: function () { this.title('提交中').content('提交中...'); $.ajax({ url: contextPath + '/service/pageReq', type : 'post', dataType : "json", data: { needcontrolprocess : "billingApplyBusiness.createBillBatchSelf", content : params }, success: function(result) { if (result.status == 'FAIL') { art.dialog({ title : '消息', width : '300px', content: result.processMsg, lock : true, ok: true }); } else { art.dialog({ title : '消息', content: '申请成功!', lock : true, ok: function () { doSearch(); } }); } } }); }, cancel: true }); } } } function checkAmount(AMOUNT_RECEIVABLE, TSK_MONTH_BILL, DIFF_REASON,sub_amt_sum,sub_amt_sum_temp,sub_diff_reason_temp) { if(parseFloat(TSK_MONTH_BILL)+sub_amt_sum <= 0) { art.dialog({ title : '消息', width : '300px', content: "请检查月结账号,开票金额合计不允许小于0", lock : true, ok:true }); return false; } else { if(parseFloat(AMOUNT_RECEIVABLE) < parseFloat(TSK_MONTH_BILL)+sub_amt_sum) { if(parseFloat(TSK_MONTH_BILL) > 0) { if(DIFF_REASON == null || $.trim(DIFF_REASON) == '' ) { art.dialog({ title : '消息', width : '300px', content: "开票金额大于未开金额,请分别输入差异原因", lock : true, ok:true }); return false; } } for(var i=0; i<sub_diff_reason_temp.length; i++) { if(parseFloat(sub_amt_sum_temp[i]) > 0) { if(sub_diff_reason_temp[i] == null || $.trim(sub_diff_reason_temp[i]) == '') { art.dialog({ title : '消息', width : '300px', content: "开票金额大于未开金额,请输入差异原因", lock : true, ok:true }); // 添加红色提醒样式 return false; } } } } } return true; } //校验是否同月结客户,同发票类型 function checkIfAllowed(ids) { var cust_no = $("#dataGridTable1").jqGrid('getCell',ids[0],'Z_CDH_NAME'); var is_post = $("#dataGridTable1").jqGrid('getCell',ids[0],'IS_POST'); var inv_type = $("#dataGridTable1").jqGrid('getCell',ids[0],'INVOICE_TYPE'); var TICKETS_BACK = $("#TICKETS_BACK_" + ids[0]).val(); var MEINS = $("#MEINS_" + ids[0]).val(); var UNITPE = $("#UNITPE_" + ids[0]).val(); var FKIMG = $("#FKIMG_" + ids[0]).val(); var MSPEC = $("#MSPEC_" + ids[0]).val(); var BUSINESS_TYPE = $("#dataGridTable1").jqGrid('getCell',ids[0],'BUSINESS_TYPE'); var TSK_MONTH_BILL = $.trim($("#TSK_MONTH_BILL_" + ids[0]).val()); for(var i=1; i<ids.length; i++) { var current_is_post = $("#dataGridTable1").jqGrid('getCell',ids[i],'IS_POST'); var current_BUSINESS_TYPE = $("#dataGridTable1").jqGrid('getCell',ids[i],'BUSINESS_TYPE'); var current_TSK_MONTH_BILL = $.trim($("#TSK_MONTH_BILL_" + ids[i]).val()); var current_MEINS = $("#MEINS_" + ids[i]).val(); var current_UNITPE = $("#UNITPE_" + ids[i]).val(); var current_FKIMG = $("#FKIMG_" + ids[i]).val(); var current_MSPEC = $("#MSPEC_" + ids[i]).val(); if (TSK_MONTH_BILL == "" && parseFloat(current_TSK_MONTH_BILL) > 0) { // TSK_MONTH_BILL = current_TSK_MONTH_BILL; BUSINESS_TYPE = current_BUSINESS_TYPE; MEINS = current_MEINS; UNITPE = current_UNITPE; FKIMG = current_FKIMG; MSPEC = current_MSPEC; TICKETS_BACK = $("#TICKETS_BACK_" + ids[i]).val(); } if(cust_no != $("#dataGridTable1").jqGrid('getCell',ids[i],'Z_CDH_NAME') || inv_type != $("#dataGridTable1").jqGrid('getCell',ids[i],'INVOICE_TYPE') || TICKETS_BACK != $("#TICKETS_BACK_" + ids[i]).val() || is_post != current_is_post) { art.dialog({ title : '消息', width : '300px', content: "合并提交必须为同一月结名称、相同发票类型、相同票面信息、相同寄送方式!", lock : true, ok:true }); return false; } // 相同业务类型,单位,单价,数量,规格必须相同; if(BUSINESS_TYPE == current_BUSINESS_TYPE && parseFloat(current_TSK_MONTH_BILL) > 0) { if (MEINS != current_MEINS || UNITPE != current_UNITPE || FKIMG != current_FKIMG || MSPEC != current_MSPEC) { art.dialog({ title : '消息', width : '300px', content: "合并提交,同一客户的同一业务类型,单位、单价、数量、规格必须相同", lock : true, ok:true }); return false; } } } return true; } function separate() { var rebillFlag = $("#REBILL_FLAG").val(); if (rebillFlag) { art.dialog({ title : '消息', width : '300px', content: "点击查询后在拆分", lock : true, ok:true }); return; } var ids = $('#dataGridTable1').jqGrid('getGridParam','selarrrow'); if(ids.length == 0) { art.dialog({ title : '消息', width : '300px', content: "请选择一条记录进行拆分!", lock : true, ok:true }); return; } else if(ids.length > 1) { art.dialog({ title : '消息', width : '300px', content: "只能选择一条记录进行拆分!", lock : true, ok:true }); return; } /*var rowdata = $('#dataGridTable1').jqGrid('getRowData',ids[0]); rowdata.WRBTR = ''; rowdata.TSL_MONTH_UNBILL = '';*/ // $("#dataGridTable1").jqGrid("addRowData", rowid, dataRow, "after", selectedId); // $("#dataGridTable1").jqGrid("addRowData", ids[0], rowdata, "after", ids[0]); goToPage(contextPath + '/service/page?name=home_p2/outputVat/billingApply/separatPage',ids[0]); } /*跳转到页面*/ function goToPage(url, id) { var options = { title : "开票数据拆分", top : "5%", width : 1000, lock : true, height: 'auto' } url += "&headerId=" + id ; _myDialogSepareteDialog = art.dialog(options); jQuery.ajax({ url : url, success : function(data) { _myDialogSepareteDialog.content(data); } }); } // _myDialog function goToPage2(url, headerId) { var options = { title : "添加子账号", top : "5%", width : '1000px', lock : true, height: 'auto' } url += "&headerId=" + headerId; _myDialogSepareteDialog = art.dialog(options); jQuery.ajax({ url : url, success : function(data) { _myDialogSepareteDialog.content(data); } }); } function postSeparate() { var ids = $('#dataGridTable1').jqGrid('getGridParam','selarrrow'); if(ids.length == 0) { art.dialog({ title : '消息', width : '300px', content: "请选择一条记录进行拆分提交!", lock : true, ok:true }); return; } else if(ids.length > 1) { art.dialog({ title : '消息', width : '300px', content: "只能选择一条记录进行拆分提交!", lock : true, ok:true }); return; } var id = ids[0]; // 主账号开票金额 var TSK_MONTH_BILL = []; // 主账号差异原因 var DIFF_REASON = []; // 主账号票面备注 var TICKETS_BACK = []; // 主账号申请人员备注 var applierBack = []; // 未开票金额 var AMOUNT_RECEIVABLE = $("#dataGridTable1").jqGrid('getCell',id,'TSL_MONTH_UNBILL'); var sumAMT = 0; $("input[name='TSK_MONTH_BILL_" + id + "']").each(function (index, n) { TSK_MONTH_BILL[index] = n.value; sumAMT += parseFloat(n.value); }); $("input[name='DIFF_REASON_" + id + "']").each(function (index, n) { DIFF_REASON[index] = n.value; }); $("input[name='TICKETS_BACK_" + id + "']").each(function (index, n) { TICKETS_BACK[index] = n.value; }); $("input[name='applierBack_" + id + "']").each(function (index, n) { applierBack[index] = n.value; }); if(!checkAmount2(parseFloat(AMOUNT_RECEIVABLE), sumAMT, DIFF_REASON)) { return; } var params = "headerId:" + id + "|TSK_MONTH_BILL:" + TSK_MONTH_BILL + "|DIFF_REASON:" + DIFF_REASON +"|TICKETS_BACK:" + TICKETS_BACK + "|applierBack:" + applierBack + "|REBILL_FLAG:" + $("#REBILL_FLAG").val(); art.dialog({ title : '消息', content: '确定要提交吗?', lock : true, ok: function () { this.title('提交中').content('提交中...'); $.ajax({ url: contextPath + '/service/pageReq', type : 'post', dataType : "json", data: { needcontrolprocess : "billingApplyBusiness.createBillBatchSeparate", content : params }, success: function(result) { if (result.status == 'FAIL') { art.dialog({ title : '消息', width : '300px', content: result.processMsg, lock : true, ok: true }); } else { art.dialog({ title : '消息', content: '申请成功!', lock : true, ok: function () { doSearch(); } }); } } }); }, cancel: true }); } function checkAmount2(AMOUNT_RECEIVABLE, sumAMT, DIFF_REASON) { if(AMOUNT_RECEIVABLE != sumAMT){ for(var i=0; i<DIFF_REASON.length; i++) { if(DIFF_REASON == null || $.trim(DIFF_REASON[i]) == "") { art.dialog({ title : '消息', width : '300px', content: "开票金额不等于未开金额,请输入每条开票记录差异原因!", lock : true, ok:true }); return false; } } } return true; } function importExcel() { _myDialog = art.dialog({ id:"firstD", title : '导入', width : '700px', content: $('#import-content').html(), lock : true }); } function import_apply() { if($("#excel").val()==''){ art.dialog({ content : "请选择文件", lock : true }); return; } art.dialog({ width : "200px", content:"文件加载成功,是否确定导入", lock : true, button: [ {name:'是', callback:function (){ var content = ""; window.setTimeout(function(){ $("#upForm").ajaxSubmit({ url : contextPath + "/service/file_upload", type : 'post', data : {"content":content,"needcontrolprocess": "billingApplyBusiness.desperseBillImport"}, success : function(data) { data = eval("(" + data + ")"); var dialog = art.dialog.get('importing_dialog'); dialog.close(); if (data) { art.dialog({ title : "提示", width : "350px", content : data.message, ok : function() { if(data.code == 'FAIL') { return true; } else { _myDialog.close(); doSearchDesperse(); } }, lock : true }); } } }); },10); art.dialog({ id : "importing_dialog", title : "提示", width : "200px", content : "正在导入,请稍等...", lock : true }); }, focus: true }, {name:'否'} ] }); } function importExcel2() { _myDialog = art.dialog({ id:"firstD", title : '导入', width : '700px', content: $('#import-content2').html(), lock : true }); } function import_apply2() { if($("#excel2").val()==''){ art.dialog({ content : "请选择文件", lock : true }); return; } art.dialog({ width : "200px", content:"文件加载成功,是否确定导入", lock : true, button: [ {name:'是', callback:function (){ var content = ""; window.setTimeout(function(){ $("#upForm").ajaxSubmit({ url : contextPath + "/service/file_upload_bean", type : 'post', data : {"content":content,"needcontrolprocess": "billingApplyBusiness.importMonthCust"}, success : function(data) { data = eval("(" + data + ")"); var dialog = art.dialog.get('importing_dialog'); dialog.close(); art.dialog({ title : '消息', content: data.processMsg, lock : true, ok: function () { _myDialog.close(); } }); if (data) { impData = data.expData.page; $("#dataGridTable1").clearGridData(); $("#dataGridTable1").jqGrid('setGridParam', {datatype:'local', data:impData, rowNum:10000}).trigger('reloadGrid', [{page:1}]); } } }); },10); art.dialog({ id : "importing_dialog", title : "提示", width : "200px", content : "正在导入,请稍等...", lock : true }); }, focus: true }, {name:'否'} ] }); } function deleteRecord() { // 如果已提交,不能删除 if ($("#queryStatus").val() == '02') { art.dialog({ title : '消息', width : '300px', content: "已提交的行不允许删除", lock : true, ok:true }); return; } // 获取要删除的id数组 var ids = $('#dataGridTable2').jqGrid('getGridParam','selarrrow'); if(ids.length == 0) { art.dialog({ title : '消息', width : '300px', content: "请选择需要删除的行!", lock : true, ok:true }); return; } art.dialog({ title : '消息', content: '确定要删除吗?', lock : true, ok: function () { this.title('删除中').content('删除中...'); $.ajax({ url: contextPath + '/service/pageReq', type : 'post', dataType : "json", data: { needcontrolprocess : "billingApplyBusiness.deleteDesperseRecord", content : "ids:" + ids }, success: function(result) { if (result.status == 'FAIL') { art.dialog({ title : '消息', width : '300px', content: result.processMsg, lock : true, ok: true }); } else { art.dialog({ title : '消息', content: '删除成功!', lock : true, ok: function () { doSearchDesperse(); } }); } } }); }, cancel: true }); } // 散单提交 function postDesperse() { // 已提交的行禁止再次提交 if ($("#queryStatus").val() == '02') { art.dialog({ title : '消息', width : '300px', content: "已提交的行不允许再次提交,请导入新的开票信息再提交", lock : true, ok:true }); return; } var selectAllFlag = $("#allSelect").attr("checked"); // 获取要删除的id数组 var ids = $('#dataGridTable2').jqGrid('getGridParam','selarrrow'); if(ids.length == 0 && selectAllFlag != "checked") { art.dialog({ title : '消息', width : '300px', content: "请选择需要提交的行!", lock : true, ok:true }); return; } art.dialog({ title : '消息', content: '确定要提交吗?', lock : true, ok: function () { this.title('提交中').content('提交中...'); $.ajax({ url: contextPath + '/service/pageReq', type : 'post', dataType : "json", data: { needcontrolprocess : "billingApplyBusiness.createDesporseBatch", content : "ids:" + ids + "|selectAllFlag:" + selectAllFlag }, success: function(result) { if (result.status == 'FAIL') { art.dialog({ title : '消息', width : '300px', content: result.processMsg, lock : true, ok: true }); } else { art.dialog({ title : '消息', content: '提交成功!', lock : true, ok: function () { doSearchDesperse(); } }); } } }); }, cancel: true }); } function checkMergedCondition(sub_ID,sub_type,SUB_TICKETS_BACK,SUB_TSK_MONTH_BILL, sub_MEINS,sub_UNITPE,sub_FKIMG,sub_MSPEC,subCount) { for (var i=0; i< subCount; i++) { var sub_bus_type = sub_type[i]; var sub_tickets = SUB_TICKETS_BACK[i]; var sub_tsk_month = SUB_TSK_MONTH_BILL[i]; var sub_m = sub_MEINS[i]; var sub_u= sub_UNITPE[i]; var sub_f = sub_FKIMG[i]; var sub_ms = sub_MSPEC[i]; for (var j=i; j<sub_ID.length; j+=subCount) { var current_sub_bus_type = sub_type[j]; var current_sub_tickets = SUB_TICKETS_BACK[j]; var current_sub_tsk_month = SUB_TSK_MONTH_BILL[j]; var current_sub_m = sub_MEINS[j]; var current_sub_u = sub_UNITPE[j]; var current_sub_f = sub_FKIMG[j]; var current_sub_ms = sub_MSPEC[j]; if (sub_tsk_month == 0 && current_sub_tsk_month != 0) { sub_bus_type = current_sub_bus_type; sub_tickets = current_sub_tickets; sub_tsk_month = current_sub_tsk_month; sub_m = current_sub_m; sub_u = current_sub_u; sub_f = current_sub_f; sub_ms = current_sub_ms; } if (sub_tickets != current_sub_tickets) { art.dialog({ title : '消息', width : '300px', content: "合并提交,同一关联账号票面备注必需相同", lock : true, ok:true }); return false; } if (sub_bus_type == current_sub_bus_type && sub_tsk_month != 0) { if (sub_m != current_sub_m || sub_u != current_sub_u || sub_f != current_sub_f || sub_ms != current_sub_ms) { art.dialog({ title : '消息', width : '300px', content: "合并提交,同一客户的同一业务类型,单位、单价、数量、规格必须相同", lock : true, ok:true }); return false; } } } } return true; } // 获取上一个月 function getBeforeMonth() { var curr_date = new Date(); var curr_year = curr_date.getFullYear(); var curr_month = curr_date.getMonth(); if (curr_month == 0) { curr_year -= 1; curr_month = 12; } curr_month = curr_month < 10 ? "0" + curr_month : curr_month; return curr_year + "" + curr_month; } // 添加子账号 function addSubAccount() { var ids = $('#dataGridTable1').jqGrid('getGridParam','selarrrow'); if (ids.length == 0) { art.dialog({ title : '消息', width : '300px', content: "请选择一条记录进行添加!", lock : true, ok:true }); return; } else if (ids.length > 1) { art.dialog({ title : '消息', width : '300px', content: "只能选择一条记录进行添加!", lock : true, ok:true }); return; } // var cust_no = $("#dataGridTable1").jqGrid('getCell',ids[0],'Z_CUSTOMER_NO'); // var query_date = $("#dataGridTable1").jqGrid('getCell',ids[0],'BELONG_DATE'); goToPage2(contextPath + '/service/page?name=home_p2/outputVat/billingApply/addSubAccPage', ids[0]); } // 还原已开票未开金额 function addNewRecord() { if(!$("#REBILL_FLAG").val()) { art.dialog({ title : '消息', width : '300px', content: "请点击补开查询后在还原未开金额!", lock : true, ok:true }); return; } var ids = $('#dataGridTable1').jqGrid('getGridParam','selarrrow'); if(ids.length == 0) { art.dialog({ title : '消息', width : '300px', content: "请选择需要还原的行!", lock : true, ok:true }); return; } art.dialog({ title : '消息', content: '确定要还原吗?', lock : true, ok: function () { $.ajax({ url: contextPath + '/service/pageReq', type : 'post', dataType : "json", data: { needcontrolprocess : "billingApplyBusiness.addNewApply", content : "ids:" + ids }, success: function(result) { if (result.status == 'FAIL') { art.dialog({ title : '消息', width : '300px', content: result.processMsg, lock : true, ok: true }); } else { art.dialog({ title : '消息', content: '还原成功!', lock : true, ok: function () { doSearch('reBillSearch'); } }); } } }); }, cancel: true }); } function call_imp_func(objData) { art.dialog({ title : '消息', content: '确定要提交吗?', lock : true, ok: function () { this.title('提交中').content('提交中...'); $.ajax({ url: contextPath + '/service/pageReq', type : 'post', dataType : "json", data: { needcontrolprocess : "billingApplyBusiness.impCreateBatch", content : "impData:" + JSON.stringify(objData) }, success: function(result) { if (result.status == 'FAIL') { art.dialog({ title : '消息', width : '300px', content: result.processMsg, lock : true, ok: true }); } else { art.dialog({ title : '消息', content: '提交成功!', lock : true, ok: function () { impData = null; $("#dataGridTable1").clearGridData(); } }); } } }); }, cancel: true }); } //@ sourceURL=billingApply2.js
/////////////
/** * ================================================================= * 版权所有 2011-2020 泰海网络支付服务有限公司,并保留所有权利 * ----------------------------------------------------------------- * 这不是一个自由软件!您不能在任何未经允许的前提下对程序代码进行修改和使用; * 不允许对程序代码以任何形式任何目的的再发布 * ================================================================= */ package com.sf.novatar.tpl.controller; import java.io.IOException; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import javax.annotation.Resource; import javax.servlet.http.Cookie; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import com.sf.novatar.tpl.bean.BeanBase; import com.sf.novatar.tpl.enums.BusinessStatus; import com.sf.novatar.tpl.p2.business.BillInvBusiness; import com.sf.novatar.tpl.service.IService; import com.sf.novatar.tpl.util.StringUtil; import com.sf.novatar.tpl.util.UserUtil; import com.sf.novatar.tpl.util.Util; import com.sf.novatar.tpl.util.ViewExcel; import com.sfpay.framework.base.exception.ServiceException; import com.sfpay.framework.base.utils.StringUtils; import com.sfpay.framework2.core.util.JsonUtil; import com.sfpay.framework2.web.json.JsonMessage; /** * 类说明:<br> * * * <p> * 详细描述:<br> * * * </p> * * @author 608279 向鹏 * * CreateDate: May 20, 2015 */ @Controller @RequestMapping("/service") public class ServiceController extends BaseController { private final static Logger logger = LoggerFactory .getLogger(ServiceController.class); @Resource(name = "billInvBusiness") private BillInvBusiness billInvBusiness; @Resource private IService service; /** * 进页面方法 方法说明:<br> * * @param bean * @return */ @RequestMapping("/page") public String page(BeanBase bean, Model model) { // 1.判断是否发送CORE // 2.无需调核心则找CONTROLL处理类 /* * try { service.service(bean); } catch (Exception e) { * logger.info(bean.getProcessMsg(), e); } */ return bean.getName(); } @RequestMapping("/modelView") public ModelAndView modelView(BeanBase bean) { ModelAndView mv = new ModelAndView(bean.getName()); bean.setDatas(Util.converToBean(bean)); mv.getModel().putAll(bean.getDatas().get(0)); return mv; } /** * 业务处理方法 方法说明:<br> * * @param bean * @return */ @RequestMapping(value = "/pageReq") @ResponseBody public Object pageReq(BeanBase bean, HttpServletRequest request, HttpServletResponse response) { // 1.判断是否发送CORE // 2.无需调核心则找CONTROLL处理类 String splitRegex = ";"; String message = "操作成功"; String result = repeatSubmitPreCheck(bean.getRepeatCheckBuz(), request, response); if (!StringUtil.areBlank(result)) { bean.setStatus(BusinessStatus.FAIL); bean.setProcessMsg("请不要重复提交"); return bean; } try { String processorName = bean.getNeedcontrolprocess(); String createId = UserUtil.getCurrentUser().getCreateId(); if (StringUtils.isEmpty(processorName)) { bean.setContent(bean.getContent() + createId); bean = service.service(bean); } else { String[] contents = bean.getContent().split(splitRegex); int length = contents.length; for (int i = 0; i < length; i++) { contents[i] += createId; } bean.setContent(org.apache.commons.lang3.StringUtils.join( contents, splitRegex)); process(bean); bean.setStatus(BusinessStatus.FINLISH); if (org.apache.commons.lang3.StringUtils.isBlank(bean .getProcessMsg())) { bean.setProcessMsg(message); } } } catch (Throwable e) { logger.error(e.getMessage(), e); bean.setStatus(BusinessStatus.FAIL); String msg = e.getMessage(); if (!StringUtil.areBlank(msg) && msg.length() > 64 && (e instanceof ServiceException == false)) { msg = "处理失败,请联系管理员"; } bean.setProcessMsg(msg); } finally { // repeatSubmitPostCheck(bean.getRepeatCheckBuz(), request); } return bean; } /** * 业务处理方法 导出:<br> * * @param bean * @return */ @SuppressWarnings("unchecked") @RequestMapping("/export") public ModelAndView export(BeanBase bean, HttpServletRequest request) { Map<String, Object> map = null; try { bean.setContent(bean.getContent() + getCreateId()); String processorName = bean.getNeedcontrolprocess(); if (StringUtils.isEmpty(processorName)) { bean = service.service(bean); } else { process(bean); } map = (Map<String, Object>) bean.getExpData().get("excelData"); } catch (Throwable e) { logger.info(e.getMessage(), e); bean.setStatus(BusinessStatus.FAIL); bean.setProcessMsg(e.getMessage()); } return new ModelAndView(new ViewExcel(), map); } /** * 业务处理方法 导出:<br> * * @param bean * @return */ @SuppressWarnings("unchecked") @RequestMapping("/exportForInv") public ModelAndView exportForInv(BeanBase bean, HttpServletRequest request) { Map<String, Object> map = null; try { billInvBusiness.invExport(bean); map = (Map<String, Object>) bean.getExpData().get("excelData"); } catch (Throwable e) { logger.info(e.getMessage(), e); bean.setStatus(BusinessStatus.FAIL); bean.setProcessMsg(e.getMessage()); } return new ModelAndView(new ViewExcel(), map); } /** * 模板导出:<br> * * @param bean * @return */ @RequestMapping("/template_export") public ModelAndView template_export(BeanBase bean) { ModelAndView modelview = null; try { process(bean); modelview = (ModelAndView) bean.getExpData().get("modelview"); } catch (Throwable e) { logger.info(e.getMessage(), e); bean.setStatus(BusinessStatus.FAIL); bean.setProcessMsg(e.getMessage()); } return modelview; } /** * 模板导入:<br> * * @param bean * @return */ @RequestMapping("/template_import") @ResponseBody public Object template_import(BeanBase bean, HttpServletRequest request) { try { bean.setContent(bean.getContent() + getCreateId()); String processorName = bean.getNeedcontrolprocess(); if (StringUtils.isEmpty(processorName)) { bean = service.service(bean); } else { process(bean); } } catch (Throwable e) { logger.error(e.getMessage(), e); bean.setStatus(BusinessStatus.FAIL); bean.setProcessMsg(e.getMessage()); } return bean; } /** * 文件上传 * * @param bean * @param request * @param response */ @RequestMapping("/file_upload") public void ajaxfileupload(BeanBase bean, HttpServletRequest request, HttpServletResponse response) { response.setContentType("text/html;charset=utf-8"); String result = repeatSubmitPreCheck(bean.getRepeatCheckBuz(), request, response); if (!StringUtil.areBlank(result)) { bean.setStatus(BusinessStatus.FAIL); bean.setProcessMsg("请不要重复提交"); return; } JsonMessage jsonMessage = new JsonMessage(); try { bean.setContent(bean.getContent() + getCreateId()); String processorName = bean.getNeedcontrolprocess(); if (StringUtils.isEmpty(processorName)) { bean = service.service(bean); } else { process(bean); } jsonMessage.setCode("FINISH"); jsonMessage.setMessage("上传成功"); } catch (Throwable e) { logger.error(e.getMessage(), e); jsonMessage.setCode("FAIL"); if (e instanceof ServiceException) { jsonMessage.setMessage(e.getMessage()); } else { jsonMessage.setMessage("上传失败"); } } try { response.getWriter().write(JsonUtil.toJSONString(jsonMessage)); } catch (IOException e) { logger.error(e.getMessage(), e); e.printStackTrace(); } } /** * 文件上传 * * @param bean * @param request * @param response */ @RequestMapping("/file_upload_bean") @ResponseBody public Object ajaxfileupload_bean(BeanBase bean, HttpServletRequest request, HttpServletResponse response) { response.setContentType("text/html;charset=utf-8"); String result = repeatSubmitPreCheck(bean.getRepeatCheckBuz(), request, response); if (!StringUtil.areBlank(result)) { bean.setStatus(BusinessStatus.FAIL); bean.setProcessMsg("请不要重复提交"); return bean; } try { bean.setContent(bean.getContent() + getCreateId()); String processorName = bean.getNeedcontrolprocess(); if (StringUtils.isEmpty(processorName)) { bean = service.service(bean); } else { process(bean); } bean.setStatus(BusinessStatus.FINLISH); bean.setProcessMsg("上传成功"); } catch (Throwable e) { logger.error(e.getMessage(), e); bean.setStatus(BusinessStatus.FAIL); if (e instanceof ServiceException) { bean.setProcessMsg(e.getMessage()); } else { bean.setProcessMsg("上传失败"); } } return bean; } /** * 文件上传 * * @param bean * @param request * @param response */ @RequestMapping("/ajax_form_submit") public void ajaxformSubmit(BeanBase bean, HttpServletRequest request, HttpServletResponse response) { response.setContentType("text/html;charset=utf-8"); String splitRegex = ";"; String result = repeatSubmitPreCheck(bean.getRepeatCheckBuz(), request, response); if (!StringUtil.areBlank(result)) { bean.setStatus(BusinessStatus.FAIL); bean.setProcessMsg("请不要重复提交"); return; } try { String processorName = bean.getNeedcontrolprocess(); String createId = UserUtil.getCurrentUser().getCreateId(); if (StringUtils.isEmpty(processorName)) { bean = service.service(bean); } else { String[] contents = bean.getContent().split(splitRegex); int length = contents.length; for (int i = 0; i < length; i++) { contents[i] += createId; } bean.setContent(org.apache.commons.lang3.StringUtils.join( contents, splitRegex)); process(bean); } bean.setStatus(BusinessStatus.FINLISH); if (org.apache.commons.lang3.StringUtils.isBlank(bean .getProcessMsg())) { bean.setProcessMsg("操作成功"); } } catch (Throwable e) { logger.error(e.getMessage(), e); bean.setStatus(BusinessStatus.FAIL); if (e instanceof ServiceException) { bean.setProcessMsg(e.getMessage()); } else { bean.setProcessMsg("操作失败"); } } try { response.getWriter().write(JsonUtil.toJSONString(bean)); } catch (IOException e) { logger.error(e.getMessage(), e); e.printStackTrace(); } } /** * 防重复前置检查 * * @param buzCode * @param request * void */ @SuppressWarnings("unchecked") private String repeatSubmitPreCheck(String buzCode, HttpServletRequest request, HttpServletResponse response) { if (!StringUtil.areBlank(buzCode)) { Map<String, Integer> map = (Map<String, Integer>) request .getSession().getAttribute("repeatSubmit"); if (map == null) { map = new ConcurrentHashMap<String, Integer>(); request.getSession().setAttribute("repeatSubmit", map); } Integer submitTargetVersion = map.get(buzCode); if (submitTargetVersion == null) { submitTargetVersion = 0; } Cookie tarC = null; Integer submitSourceVersion = 0; for (Cookie c : request.getCookies()) { if (c.getName().equalsIgnoreCase("repeatSubmit")) { submitSourceVersion = Integer.parseInt(c.getValue()); tarC = c; break; } } if (submitSourceVersion < submitTargetVersion) { return "请不要重复提交"; } else { map.put(buzCode, submitSourceVersion + 1); if (tarC == null) { tarC = new Cookie("repeatSubmit", String.valueOf(submitSourceVersion + 1)); } else { tarC.setValue(String.valueOf(submitSourceVersion + 1)); } response.addCookie(tarC); } } return null; } } ////////////// /* * Copyright (c) 2016, S.F. Express Inc. All rights reserved. */ package com.sf.novatar.tpl.p2.business; import java.math.BigDecimal; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.HashMap; import java.util.List; import java.util.Map; import org.apache.commons.lang.StringUtils; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.dao.DuplicateKeyException; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import com.alibaba.fastjson.JSON; import com.sf.novatar.tpl.bean.BeanBase; import com.sf.novatar.tpl.bean.BusinessBase; import com.sf.novatar.tpl.constants.BillingApplyConstants; import com.sf.novatar.tpl.enums.BusinessStatus; import com.sf.novatar.tpl.p2.dao.IBillingApplyDao; import com.sf.novatar.tpl.page.PageHandler; import com.sf.novatar.tpl.page.PageSplit; import com.sf.novatar.tpl.util.AbstractExcelReader; import com.sf.novatar.tpl.util.Configuration; import com.sf.novatar.tpl.util.DateUtils; import com.sf.novatar.tpl.util.StringUtil; import com.sf.novatar.tpl.util.TaxPayUtil; import com.sf.novatar.tpl.util.UserUtil; import com.sf.novatar.tpl.util.XslUtil; import com.sfpay.framework.base.exception.ServiceException; /** * 描述:开票申请业务类 * * <pre>HISTORY * **************************************************************************** * ID DATE PERSON REASON * 1 2016年11月24日 80001092 Create * **************************************************************************** * </pre> * @author 80001092 * @since 1.0 */ @Service("billingApplyBusiness") public class BillingApplyBusiness extends BusinessBase { private static final Logger logger = LoggerFactory.getLogger(BillingApplyBusiness.class); static final String ERR_TAX_PAY_ID_FORMAT = "税号格式不对,包含特殊符号"; static final String CUSTTYPE = "custType"; static final String INV_TYPE_E_I = "E/I"; static final String INV_TYPE_S = "S"; @Autowired private IBillingApplyDao billingApplyDao; @Override public void beforcheck(BeanBase bean) { // } @Override public void process(BeanBase bean) { // } @Override public void afterprocess(BeanBase bean) { // } /** * 80001092 方法说明:查看待开票记录 * @param bean * void */ public void queryUnbilled (BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String searchType = paramMap.get("searchType"); // String bill_STATUS = paramMap.get("BILL_STATUS"); /*if(StringUtil.areBlank(bill_STATUS)){ throw new ServiceException("查询待开票信息失败:状态不允许为空!"); }*/ paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); try { paramMap.put("billTaxPaySub", StringUtil.addDimmer(paramMap.get("BILL_TAX_PAY_SUB"), ",", "'")); paramMap.put("billPrctr", StringUtil.addDimmer(paramMap.get("BILL_PRCTR"), ",", "'")); paramMap.put("zCustomerNo", StringUtil.addDimmer(paramMap.get("Z_CUSTOMER_NO"), ",", "'")); paramMap.put("businessType", StringUtil.addDimmer(paramMap.get("BUSINESS_TYPE"), ",", "'")); paramMap.put("billBukrs", StringUtil.addDimmer(paramMap.get("BILL_BUKRS"), ",", "'")); paramMap.put("ZZPERSR", StringUtil.addDimmer(paramMap.get("ZZPERSR"), ",", "'")); if("reBillSearch".equals(searchType)) { bean.getExpData().put("page", PageHandler.execute(new PageSplit<Map<String, Object>>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCountReBill(paramMap); } @Override public List<Map<String, Object>> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getBillListRebill(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } else { bean.getExpData().put("page", PageHandler.execute(new PageSplit<Map<String, Object>>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCount(paramMap); } @Override public List<Map<String, Object>> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getBillList(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } } catch (Exception e) { logger.error("查询开票申请失败!"); throw new ServiceException("查询开票申请失败:", e.getMessage()); } } /** * 80001092 方法说明:通用查询条件 (未添加权限) * @param bean * void */ public void getCommonList(BeanBase bean) { try { HashMap<String, String> map = bean.getDatas().get(0); map.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); String queryType = map.get("queryType"); List<Map<String, String>> resultList = null; if ("acturalBillTaxPaySub".equals(queryType)) { resultList = billingApplyDao.getActuralBilTaxPaySub(map); } else if ("BILL_PRCTR".equals(queryType)) { resultList = billingApplyDao.getBILLPRCTR(map); } else if ("Z_CUSTOMER_NO".equals(queryType)) { resultList = billingApplyDao.getZCUSTOMERNO(map); } else if ("BUSINESS_TYPE".equals(queryType)) { resultList = billingApplyDao.getBUSINESSTYPE(map); } else if ("BILL_BUKRS".equals(queryType)) { resultList = billingApplyDao.getBILLBUKRS(map); } else if ("A_BILL_TAX_PAY_SUB".equals(queryType)) { resultList = billingApplyDao.markedCancelA_BILL_TAX_PAY_SUB(map); } else if ("A_BILL_PRCTR".equals(queryType)) { resultList = billingApplyDao.markedCancelA_BILL_PRCTR(map); } else if ("KUNNR".equals(queryType)) { resultList = billingApplyDao.markedCancelKUNNR(map); } else if ("ZDEINVID".equals(queryType)) { resultList = billingApplyDao.markedCancelZDEINVID(map); } else if ("ZINV_NUMBER".equals(queryType)) { resultList = billingApplyDao.markedCancelZINV_NUMBER(map); } else if ("ZINV_CODE".equals(queryType)) { resultList = billingApplyDao.markedCancelZINV_CODE(map); } else if ("WAYBILL_NO".equals(queryType)) { resultList = billingApplyDao.markedCancelWAYBILL_NO(map); } else if ("WAYBILL_ORDER_NO".equals(queryType)) { resultList = billingApplyDao.markedCancelWAYBILL_ORDER_NO(map); } else if ("ZZPERSR".equals(queryType)) { resultList = billingApplyDao.getZZPERSR(map); } else if ("getInvTaxPaySub".equals(queryType)) { resultList = billingApplyDao.getInvTaxPaySub(map); } bean.getExpData().put("resultList", resultList); } catch (Exception e) { throw new ServiceException("获取查询条件失败:", e.getMessage()); } } /** * 80001092 方法说明:查询开票状态 * @param bean * void */ public void getBillStatusList(BeanBase bean) { try { String statusList = Configuration.getConfig("BILL_STATUS"); bean.getExpData().put("resultList", statusList); } catch (Exception e) { throw new ServiceException("获取开票状态失败:", e.getMessage()); } } /** * 80001092 方法说明:月结创建发票批 * @param bean * void */ @Transactional public void createBillBatchSelf(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); try { String[] ids = paramMap.get("ids").split(",",-1); if(ids.length < 1 || StringUtil.areBlank(ids[0])) { throw new ServiceException("获取提交数据失败"); } String[] TSK_MONTH_BILL = paramMap.get("TSK_MONTH_BILL").split(",",-1); String[] DIFF_REASON = paramMap.get("DIFF_REASON").split(",",-1); String[] TICKETS_BACK = paramMap.get("TICKETS_BACK").split(",",-1); String[] applierBack = paramMap.get("applierBack").split(",",-1); String[] bellong_date = paramMap.get("bellong_date").split(",",-1); String[] sub_ID = paramMap.get("sub_ID").split(",",-1); String[] SUB_TSK_MONTH_BILL = paramMap.get("SUB_TSK_MONTH_BILL").split(",",-1); String[] SUB_DIFF_REASON = paramMap.get("SUB_DIFF_REASON").split(",",-1); String[] SUB_TICKETS_BACK = paramMap.get("SUB_TICKETS_BACK").split(",",-1); String[] SUB_applierBack = paramMap.get("SUB_applierBack").split(",",-1); String REBILL_FLAG = paramMap.get("REBILL_FLAG"); // 新添加需求,实现单位,单价,数量,规格的编辑 String[] MEINS = paramMap.get("MEINS").split(",",-1); String[] UNITPE = paramMap.get("UNITPE").split(",",-1); String[] FKIMG = paramMap.get("FKIMG").split(",",-1); String[] MSPEC = paramMap.get("MSPEC").split(",",-1); String[] sub_MEINS = paramMap.get("sub_MEINS").split(",",-1); String[] sub_UNITPE = paramMap.get("sub_UNITPE").split(",",-1); String[] sub_FKIMG = paramMap.get("sub_FKIMG").split(",",-1); String[] sub_MSPEC = paramMap.get("sub_MSPEC").split(",",-1); // 前台提交方式 String postType = paramMap.get("postType"); // 创建发票批 if("alone".equals(postType)) { // 提交 for(int i=0; i<ids.length; i++) { createBillingBatch(ids[i],TSK_MONTH_BILL[i],DIFF_REASON[i],TICKETS_BACK[i],applierBack[i], sub_ID,SUB_TSK_MONTH_BILL,SUB_DIFF_REASON,SUB_TICKETS_BACK,SUB_applierBack,REBILL_FLAG, MEINS[i],UNITPE[i],FKIMG[i],MSPEC[i],sub_MEINS,sub_UNITPE,sub_FKIMG,sub_MSPEC); } } else if("merged".equals(postType)) { // 合并提交 createBillingBatchMerged(ids,TSK_MONTH_BILL,DIFF_REASON,TICKETS_BACK,applierBack, bellong_date,sub_ID,SUB_TSK_MONTH_BILL,SUB_DIFF_REASON,SUB_TICKETS_BACK, SUB_applierBack,REBILL_FLAG,MEINS,UNITPE,FKIMG,MSPEC,sub_MEINS,sub_UNITPE,sub_FKIMG,sub_MSPEC); } } catch (Exception e) { logger.error("生产发票批失败!"); throw new ServiceException("生成发票批失败:" + e.getMessage()); } } /** * 80001092 方法说明:和并提交创建发票批,形式发票表不做合并 * @param ids * @param tSK_MONTH_BILL * @param dIFF_REASON * @param tICKETS_BACK * @param applierBack * @param sub_ID * @param sUB_TSK_MONTH_BILL * @param sUB_DIFF_REASON * @param sUB_TICKETS_BACK * @param sUB_applierBack * void */ private void createBillingBatchMerged(String[] ids, String[] tSK_MONTH_BILL, String[] dIFF_REASON, String[] tICKETS_BACK, String[] applierBack, String[] bellong_date, String[] sub_ID, String[] sUB_TSK_MONTH_BILL, String[] sUB_DIFF_REASON, String[] sUB_TICKETS_BACK, String[] sUB_applierBack, String REBILL_FLAG, String[] MEINS, String[] UNITPE, String[] FKIMG, String[] MSPEC, String[] sub_MEINS, String[] sub_UNITPE, String[] sub_FKIMG, String[] sub_MSPEC) { //checkIfHaveBilled(ids, REBILL_FLAG); // 发票批次号 String ZDEINVID = new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()) + new Double(Math.floor(Math.random()*10)).intValue(); // 流水号 int j = 2; // 开票金额之和 double mainAccountSUMAMT = 0.0; List<Map<String, Object>> listSubAccount = billingApplyDao.querySubAccount(ids[0]); // 存放子账号序号 Map<String, Integer> subAccountNum = new HashMap<String, Integer>(); for (int i=0; i<listSubAccount.size(); i++) { subAccountNum.put(listSubAccount.get(i).get("SUB_XH").toString(), j++); } Map<String, Double> subAMT = new HashMap<String, Double>(); // 子账号循环生成形式发票 if(sub_ID.length > 0 && sub_ID[0] != "") { for(int i=0; i<sub_ID.length; i++) { // 为0不创建 if(StringUtils.isBlank(sUB_TSK_MONTH_BILL[i]) || 0 == Double.parseDouble(sUB_TSK_MONTH_BILL[i])) { continue; } if(subAMT.get(sub_ID[i].split("_")[0]) != null) { subAMT.put(sub_ID[i].split("_")[0], subAMT.get(sub_ID[i].split("_")[0]) + Double.parseDouble(sUB_TSK_MONTH_BILL[i])); } else { subAMT.put(sub_ID[i].split("_")[0], Double.parseDouble(sUB_TSK_MONTH_BILL[i])); } Map<String, Object> mapSubInfo = getSubAccountInfo(sub_ID[i].split("_")[0],sub_ID[i].split("_")[1]); mainAccountSUMAMT += Double.parseDouble(sUB_TSK_MONTH_BILL[i]); mapSubInfo.put("ZDEINVID", ZDEINVID); mapSubInfo.put("ZDEINVID_XH", subAccountNum.get(sub_ID[i].split("_")[1])); mapSubInfo.put("SUB_TSK_MONTH_BILL", sUB_TSK_MONTH_BILL[i]); mapSubInfo.put("SUB_DIFF_REASON", sUB_DIFF_REASON[i]); mapSubInfo.put("SUB_TICKETS_BACK", sUB_TICKETS_BACK[i]); mapSubInfo.put("sub_applierBack", sUB_applierBack[i]); mapSubInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); mapSubInfo.put("MEINS", sub_MEINS[i]); mapSubInfo.put("UNITPE", sub_UNITPE[i]); mapSubInfo.put("FKIMG", sub_FKIMG[i]); mapSubInfo.put("MSPEC", sub_MSPEC[i]); billingApplyDao.createFormBillSubAccount(mapSubInfo); } } //int subAccount = sub_ID.length/ids.length; Map<String, Object> mapInfo = new HashMap<String, Object>(); for(int i=0; i<ids.length; i++) { mainAccountSUMAMT += Double.parseDouble(tSK_MONTH_BILL[i]); double sumMonthAMT = Double.parseDouble(tSK_MONTH_BILL[i]); /*for(int c=i*subAccount; c<(i+1)*subAccount; c++) { sumMonthAMT += Double.parseDouble(sUB_TSK_MONTH_BILL[c]); }*/ if(subAMT.get(ids[i]) != null) { sumMonthAMT += subAMT.get(ids[i]); } mapInfo = getBatchInfoById(ids[i]); mapInfo.put("billAMT", sumMonthAMT); mapInfo.put("ZDEINVID", ZDEINVID); mapInfo.put("ZDEINVID_XH", 1); mapInfo.put("TAXSUM", tSK_MONTH_BILL[i]); mapInfo.put("DIFF_REASON", dIFF_REASON[i]); mapInfo.put("TICKETS_BACK", tICKETS_BACK[i]); mapInfo.put("APPLIER_BACK", applierBack[i]); mapInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); mapInfo.put("MEINS", MEINS[i]); mapInfo.put("UNITPE", UNITPE[i]); mapInfo.put("FKIMG", FKIMG[i]); mapInfo.put("MSPEC", MSPEC[i]); if (StringUtils.isNotBlank(tSK_MONTH_BILL[i]) && 0 != Double.parseDouble(tSK_MONTH_BILL[i])) { billingApplyDao.createFormBill(mapInfo); } billingApplyDao.updateBillSum(mapInfo); } mapInfo.put("INV_TARGET", BillingApplyConstants.INV_TARGET_E); //外部 mapInfo.put("billAMT", mainAccountSUMAMT); mapInfo.put("BEGIN_PERIOD",bellong_date[0]); mapInfo.put("END_PERIOD",bellong_date[ids.length-1]); mapInfo.put("currentStep", queryCurrentStepFromStep(mapInfo.get("BILL_PRCTR").toString(), BillingApplyConstants.INV_TARGET_OUTER)); billingApplyDao.createMainAccountBatch(mapInfo); if (StringUtil.areBlank(REBILL_FLAG)) { billingApplyDao.updateBatchId(addQuotes(ids), ZDEINVID); billingApplyDao.updateBillItemBacthId(addQuotes(ids), ZDEINVID); } Map<String, Object> flowLogMap = billingApplyDao.getModuleConfig("TAX_10_01"); billingApplyDao.insertBatchFlowLog(mapInfo, flowLogMap); /* for( int i=0; i<subAccount; i++ ) { double subInnerSumAMT = 0.0; for(int k=i; k<sub_ID.length; k+=subAccount) { mainSubAccountSUMAMT += Double.parseDouble(sUB_TSK_MONTH_BILL[k]); subInnerSumAMT += Double.parseDouble(sUB_TSK_MONTH_BILL[k]); // 插入合并提交记录表 Map<String, Object> mapMergeDetail = new HashMap<String, Object>(); mapMergeDetail.put("subId", sub_ID[k]); mapMergeDetail.put("subDate", bellong_date[k/subAccount]); mapMergeDetail.put("sub_applierBack", sUB_applierBack[k]); mapMergeDetail.put("sub_TICKETS_BACK", sUB_TICKETS_BACK[k]); mapMergeDetail.put("sub_DIFF_REASON", sUB_DIFF_REASON[k]); mapMergeDetail.put("sub_TSK_MONTH_BILL", Double.parseDouble(sUB_TSK_MONTH_BILL[k])); billingApplyDao.insertMergeDeatil(mapMergeDetail); } // 插入形式发票表 Map<String, Object> mapSubInfo = getSubAccountInfo(sub_ID[i].split("_")[0],sub_ID[i].split("_")[1]); mapSubInfo.put("ZDEINVID", ZDEINVID); mapSubInfo.put("ZDEINVID_XH", j++); mapSubInfo.put("SUB_TSK_MONTH_BILL", subInnerSumAMT); mapSubInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); billingApplyDao.createFormBillSubAccount(mapSubInfo); }*/ } /** * 80001092 方法说明:查询月结账号子账号 * @param bean * void */ public void querySubAccount(BeanBase bean) { try { List<Map<String, Object>> listSubAccount = billingApplyDao.querySubAccount(bean.getDatas().get(0).get("headerId")); bean.getExpData().put("page", listSubAccount); } catch (Exception e) { throw new ServiceException("查找子账户失败:" + e.getMessage()); } } /** * 80001092 方法说明:创建发票批 * void */ private void createBillingBatch(String headerID, String billAMT, String diffReason, String ticketsBack, String applierBack, String[] subId, String[] SUB_TSK_MONTH_BILL, String[] SUB_DIFF_REASON, String[] SUB_TICKETS_BACK, String[] sub_applierBack, String REBILL_FLAG, String MEINS, String UNITPE, String FKIMG, String MSPEC, String[] sub_MEINS, String[] sub_UNITPE, String[] sub_FKIMG, String[] sub_MSPEC) { //查询当前月结账号当前月份是否已创建发票批 String kp_flag = billingApplyDao.getKPFlag(headerID); if("01".equals(kp_flag)) { // 未开票 // 子账号流水号 int j = 2; //发票批次号 String ZDEINVID = new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()) + new Double(Math.floor(Math.random()*10)).intValue(); // 存放子账号开票金额之和 double subAccountSUMAMT = 0; // insert into p2_ztax_form_bill 子账号 for(int i=0; i<subId.length; i++) { if(subId[i] != "" && subId[i].split("_")[0].equals(headerID)) { // 为0不创建 if(StringUtils.isBlank(SUB_TSK_MONTH_BILL[i]) || 0 == Double.parseDouble(SUB_TSK_MONTH_BILL[i])) { continue; } subAccountSUMAMT += Double.parseDouble(SUB_TSK_MONTH_BILL[i]); //查找每一个子账号的形式发票信息 Map<String, Object> mapSubInfo = getSubAccountInfo(subId[i].split("_")[0],subId[i].split("_")[1]); mapSubInfo.put("ZDEINVID", ZDEINVID); mapSubInfo.put("ZDEINVID_XH", j++); mapSubInfo.put("SUB_TSK_MONTH_BILL", SUB_TSK_MONTH_BILL[i]); mapSubInfo.put("SUB_DIFF_REASON", SUB_DIFF_REASON[i]); mapSubInfo.put("SUB_TICKETS_BACK", SUB_TICKETS_BACK[i]); mapSubInfo.put("sub_applierBack", sub_applierBack[i]); mapSubInfo.put("subId", subId[i]); mapSubInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); mapSubInfo.put("MEINS", sub_MEINS[i]); mapSubInfo.put("UNITPE", sub_UNITPE[i]); mapSubInfo.put("FKIMG", sub_FKIMG[i]); mapSubInfo.put("MSPEC", sub_MSPEC[i]); billingApplyDao.createFormBillSubAccount(mapSubInfo); } } Map<String, Object> mapInfo = getBatchInfoById(headerID); String nextSetp = queryNextStep("20"); //mapInfo.put("currentStep", queryCurrentStep("02", "E/S")); mapInfo.put("currentStep", queryCurrentStepFromStep(mapInfo.get("BILL_PRCTR").toString(), BillingApplyConstants.INV_TARGET_OUTER)); mapInfo.put("nextSetp", nextSetp); mapInfo.put("ZDEINVID", ZDEINVID); mapInfo.put("ZDEINVID_XH", '1'); mapInfo.put("INV_TARGET", BillingApplyConstants.INV_TARGET_E); //外部 mapInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); // billAMT存放开票金额汇总 mapInfo.put("billAMT", Double.parseDouble(billAMT) + subAccountSUMAMT); mapInfo.put("TAXSUM", Double.parseDouble(billAMT)); mapInfo.put("DIFF_REASON", diffReason); mapInfo.put("TICKETS_BACK", ticketsBack); mapInfo.put("APPLIER_BACK", applierBack); mapInfo.put("BEGIN_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); mapInfo.put("END_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); mapInfo.put("MEINS", MEINS); mapInfo.put("UNITPE", UNITPE); mapInfo.put("FKIMG", FKIMG); mapInfo.put("MSPEC", MSPEC); //insert into p2_tax_bill_batch billingApplyDao.createMainAccountBatch(mapInfo); //insert into p2_ztax_form_bill 主账号 if(StringUtils.isNotBlank(billAMT) && 0 != Double.parseDouble(billAMT)) { billingApplyDao.createFormBill(mapInfo); } if (StringUtil.areBlank(REBILL_FLAG)) { // update p2_tax_bill_item billingApplyDao.updateBillItemBatchId(mapInfo.get("ZBILL_NO").toString(), ZDEINVID); // update p2_ztax_bill_header billingApplyDao.updateBatchId("'" + headerID + "'", ZDEINVID); } // update p2_ztax_bill_sum 应开扣减,已开增加 billingApplyDao.updateBillSum(mapInfo); // 流转日志 Map<String, Object> flowLogMap = billingApplyDao.getModuleConfig("TAX_10_02"); billingApplyDao.insertBatchFlowLog(mapInfo, flowLogMap); } else { throw new ServiceException("存在已经开票的月份,请查询后重新创建!"); } } /** * 80001092 方法说明:创建发票批需要的信息 * @param headerID * @return * List<Map<String,Object>> */ private Map<String, Object> getBatchInfoById(String headerID) { return billingApplyDao.getInfoForCreateBatch(headerID); } private Map<String, Object> getSubAccountInfo(String headerId, String subId) { return billingApplyDao.getSubAccountInfo(headerId, subId); } /** * 80001092 方法说明:校验合并提交时,是否有月份已经开票 * @param ids * void */ @SuppressWarnings("unused") private void checkIfHaveBilled(String[] ids, String REBILL_FLAG) { if(ids == null || ids.length == 0) { throw new ServiceException("请选择需要合并提交的月结账号!"); } List<Map<String, String>> kpFlagList = billingApplyDao.getKPFlagList(ids); for(int i=0; i<kpFlagList.size(); i++) { if("Y".equals(kpFlagList.get(0).get("kp_flag")) && StringUtils.isBlank(REBILL_FLAG)) { // 如果存在已经开票的月份 throw new ServiceException("已经存在申请过的月份,请查询后重新提交!"); } } } /** * 80001092 方法说明:添加引号 * @param str * @return * String */ private String addQuotes(String[] str) { StringBuffer sb = new StringBuffer(); for(String s : str) { sb.append("'").append(s).append("'").append(","); } return sb.deleteCharAt(sb.length() - 1).toString(); } /** * 80001092 方法说明:拆分生成发票批 * @param bean * void */ @Transactional public void createBillBatchSeparate(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String headerId = paramMap.get("headerId"); try { //查询当前月结账号当前月份是否已创建发票批 String kp_flag = billingApplyDao.getKPFlag(headerId); if("01".equals(kp_flag)) { String[] TSK_MONTH_BILL = paramMap.get("TSK_MONTH_BILL").split(",",-1); String[] DIFF_REASON = paramMap.get("DIFF_REASON").split(",",-1); String[] TICKETS_BACK = paramMap.get("TICKETS_BACK").split(",",-1); String[] applierBack = paramMap.get("applierBack").split(",",-1); // 发票批次号 String ZDEINVID = new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()) + new Double(Math.floor(Math.random()*10)).intValue(); Map<String, Object> mapInfo = getBatchInfoById(headerId); mapInfo.put("ZDEINVID", ZDEINVID); mapInfo.put("INV_TARGET", BillingApplyConstants.INV_TARGET_E); //外部 mapInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); double billAMT = createFormBillSeparate(mapInfo, TSK_MONTH_BILL, DIFF_REASON, TICKETS_BACK, applierBack); mapInfo.put("billAMT", billAMT); mapInfo.put("BEGIN_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); mapInfo.put("END_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); billingApplyDao.createMainAccountBatch(mapInfo); billingApplyDao.updateBillItemBatchId(mapInfo.get("ZBILL_NO").toString(), ZDEINVID); billingApplyDao.updateBatchId("'" + headerId + "'", ZDEINVID); billingApplyDao.updateBillSum(mapInfo); insertBatchFlowLog(mapInfo, "TAX_10_03"); } else { throw new ServiceException("该月结账号本月已经提交!"); } } catch (Exception e) { logger.error("拆分提交生成发票批出错!"); throw new ServiceException("拆分生成发票批失败"); } } /** * 80001092 方法说明:拆分生成形式发票表 * @param mapInfo * @param tSK_MONTH_BILL * @param dIFF_REASON * @param tICKETS_BACK * @param applierBack * void */ private double createFormBillSeparate(Map<String, Object> mapInfo, String[] tSK_MONTH_BILL, String[] dIFF_REASON, String[] tICKETS_BACK, String[] applierBack) { double billAMT = 0.0; // 子账号流水 int j = 1; for(int i=0; i<tSK_MONTH_BILL.length; i++) { billAMT += Double.parseDouble(tSK_MONTH_BILL[i]); mapInfo.put("TAXSUM", Double.parseDouble(tSK_MONTH_BILL[i])); mapInfo.put("DIFF_REASON", dIFF_REASON[i]); mapInfo.put("TICKETS_BACK", tICKETS_BACK[i]); mapInfo.put("APPLIER_BACK", applierBack[i]); mapInfo.put("ZDEINVID_XH", j++); billingApplyDao.createFormBill(mapInfo); } return billAMT; } /** * 80001092 方法说明:散单导入 * @param bean * void */ @Transactional public void desperseBillImport(BeanBase bean) { try { new AbstractExcelReader() { @Override public void doParse(Workbook workbook) { insertBill(check(workbook)); } }.Reader();; } catch (Exception e) { String errorMsg = "EXCEL上传失败:<br>"; String errMsgDinamic = e.getMessage(); if (StringUtil.areNotBlank(errMsgDinamic)) { errorMsg += errMsgDinamic; } else { errorMsg += "请确保最后一行数据之后没有空白数据"; } logger.error(errorMsg, e); if (e instanceof DuplicateKeyException) { throw new ServiceException("导入的Excel存在重复的数据,去掉重复数据后在导入"); } else { throw new ServiceException(errorMsg); } } bean.setStatus(BusinessStatus.FINLISH); bean.setProcessMsg("导入完成!"); } /** * 80001092 方法说明:插入数据 * @param check * void */ private void insertBill(List<Map<String, String>> excelValueList) { billingApplyDao.insertBill(excelValueList); } /** * 80001092 方法说明:导入数据校验 * @param workbook * @return * Object */ private List<Map<String, String>> check(Workbook workBook) { List<Map<String, String>> excelValueList = null; // 待导入的数据 int import_wb_sheetNos = workBook.getNumberOfSheets(); if (import_wb_sheetNos == 0) { throw new ServiceException("待导入的数据为空"); } excelValueList = new ArrayList<>(); // 当前权限的网点 List<Map<String, String>> branchList = billingApplyDao. getCurrentAuthBranch(UserUtil.getCurrentUser().getEmpCode()); // 合并后的业务类型 // List<Map<String, String>> businessType = billingApplyDao.getAllBusinessType(); for(int i=0; i<import_wb_sheetNos; i++) { Cell cell = null; String ORDER_NUM = null; String BRANCH = null; String SETTLEMENT = null; String CUST_NAME = null; String TAXPAY_ID = null; String TAXAMT = null; String INVOICE_TYPE = null; String BELONG_DATE = null; String DES = null; String REMARK = null; String EXCEP_REMARK = null; String ADDR = null; String TEL = null; String BANK_NAME = null; String ACCOUNT_NO = null; String SPEC = null; String UNIT = null; String UNIT_PRICE = null; String AMOUNT = null; String PAYEE = null; String RECHECKER = null; String RETE = null; String RECV_ADDR = null; String RECV_TEL = null; String RECV_NAME = null; String RECV_EMAIL = null; String NAMECARD_ID = null; String IF_REPEAT = null; String BILL_NO = null; Sheet sheet = workBook.getSheetAt(i); for(int line=1, count=sheet.getLastRowNum()+1; line<count; line++) { Row row = sheet.getRow(line); int j = 0; cell = row.getCell(j++); BRANCH = getCellValue(cell); cell = row.getCell(j++); CUST_NAME = getCellValue(cell); if (StringUtil.areBlank(BRANCH, CUST_NAME)) { continue; } if(StringUtil.areBlank(BRANCH)) { String message = workBook.getSheetName(i) + "的第" + line + "行,点部代码不能为空"; throw new ServiceException(message); } else { boolean temp = false; for(int k=0; k<branchList.size(); k++) { if(branchList.get(k).containsValue(BRANCH)) { temp = true; break; } } if(!temp) { throw new ServiceException("当前没有权限上传网点"+BRANCH); } } if(StringUtil.areBlank(CUST_NAME)) { String message = workBook.getSheetName(i) + "的第" + line + "行,客户名称不能为空"; throw new ServiceException(message); } else { CUST_NAME = CUST_NAME.replace(" ",""); } cell = row.getCell(j++); TAXPAY_ID = getCellValue(cell); if(!TaxPayUtil.check(TAXPAY_ID)){ throw new ServiceException(ERR_TAX_PAY_ID_FORMAT); } cell = row.getCell(j++); ADDR = getCellValue(cell); cell = row.getCell(j++); ACCOUNT_NO = getCellValue(cell); cell = row.getCell(j++); if(cell == null || cell.getCellType() != Cell.CELL_TYPE_NUMERIC) { String message = workBook.getSheetName(i) + "的第" + line + "行,开票金额必须为有效数值"; throw new ServiceException(message); } if(cell.getNumericCellValue() == 0) { String message = workBook.getSheetName(i) + "的第" + line + "行,开票金额必须为有效数值"; throw new ServiceException(message); } TAXAMT = getCellValue(cell); cell = row.getCell(j++); INVOICE_TYPE = getCellValue(cell); if(StringUtil.areBlank(INVOICE_TYPE)) { String message = workBook.getSheetName(i) + "的第" + line + "行,发票类型不能为空"; throw new ServiceException(message); } else { if(!"专票".equals(INVOICE_TYPE) && !"普票".equals(INVOICE_TYPE)) { throw new ServiceException("发票类型请填专票或普票"); } if ("专票".equals(INVOICE_TYPE)) { INVOICE_TYPE = "V1"; if (!StringUtil.areNotBlank(TAXPAY_ID, ACCOUNT_NO, ADDR)) { throw new ServiceException("专票请填写纳税人识别号,开户行及账号,地址及电话"); } } else { INVOICE_TYPE = "V2"; } } cell = row.getCell(j++); BILL_NO = getCellValue(cell); cell = row.getCell(j++); BELONG_DATE = XslUtil.getCellString(cell); if(StringUtil.areBlank(BELONG_DATE)) { String message = workBook.getSheetName(i) + "的第" + line + "行,月结款所属期不能为空"; throw new ServiceException(message); } else if (BELONG_DATE.contains("-")) { String errorMessage = workBook.getSheetName(i) + "的第" + line + "行,月结款所属期格式错误,必须为[yyyyMM]"; throw new ServiceException(errorMessage); } try { DateUtils.parseDate(BELONG_DATE, "yyyyMM"); if (BELONG_DATE.length() < 6) { String errorMessage = workBook.getSheetName(i) + "的第" + line + "行,月结款所属期格式错误,必须为[yyyyMM]"; throw new ServiceException(errorMessage); } } catch (Exception e) { String errorMessage = workBook.getSheetName(i) + "的第" + line + "行,月结款所属期格式错误,必须为[yyyyMM]"; throw new ServiceException(errorMessage); } cell = row.getCell(j++); EXCEP_REMARK = getCellValue(cell); cell = row.getCell(j++); NAMECARD_ID = getCellValue(cell); cell = row.getCell(j++); DES = getCellValue(cell); cell = row.getCell(j++); RETE = getCellValue(cell); /*if (StringUtil.areBlank(RETE)) { RETE = "0"; }*/ cell = row.getCell(j++); SPEC = getCellValue(cell); cell = row.getCell(j++); UNIT = getCellValue(cell); cell = row.getCell(j++); UNIT_PRICE = getCellValue(cell); cell = row.getCell(j++); AMOUNT = getCellValue(cell); cell = row.getCell(j++); RECV_ADDR = getCellValue(cell); cell = row.getCell(j++); RECV_NAME = getCellValue(cell); cell = row.getCell(j++); RECV_TEL = XslUtil.getCellString(cell); cell = row.getCell(j); RECV_EMAIL = getCellValue(cell); /* cell = row.getCell(3); BELONG_DATE = getCellValue(cell); if(StringUtil.areBlank(BELONG_DATE)) { String message = workBook.getSheetName(i) + "的第" + line + "行,月结款所属期不能为空"; throw new ServiceException(message); } else if (BELONG_DATE.contains("-")) { String errorMessage = workBook.getSheetName(i) + "的第" + line + "行,月结款所属期格式错误,必须为[yyyyMM]"; throw new ServiceException(errorMessage); } try { DateUtils.parseDate(BELONG_DATE, "yyyyMM"); } catch (Exception e) { String errorMessage = workBook.getSheetName(i) + "的第" + line + "行,月结款所属期格式错误,必须为[yyyyMM]"; throw new ServiceException(errorMessage); } cell = row.getCell(4); EXCEP_REMARK = getCellValue(cell); cell = row.getCell(5); SETTLEMENT = getCellValue(cell); cell = row.getCell(6); cell = row.getCell(7); NAMECARD_ID = getCellValue(cell); if(StringUtil.areBlank(NAMECARD_ID)) { String message = workBook.getSheetName(i) + "的第" + line + "行,企业名片代码不能为空"; throw new ServiceException(message); } // 暂时取消必填和位数校验 if(StringUtil.areBlank(TAXPAY_ID) && "V1".equals(INVOICE_TYPE) && StringUtil.areBlank(NAMECARD_ID)) { String message = workBook.getSheetName(i) + "的第" + line + "行,纳税人识别号不能为空"; throw new ServiceException(message); } else { // 大于15位 if(TAXPAY_ID.length() < 15) { throw new ServiceException("税号至少15位"); } } cell = row.getCell(9); ADDR = getCellValue(cell); if(StringUtil.areBlank(ADDR) && "V1".equals(INVOICE_TYPE) && StringUtil.areBlank(NAMECARD_ID)) { String message = workBook.getSheetName(i) + "的第" + line + "行,地址不能为空"; throw new ServiceException(message); } cell = row.getCell(10); TEL = getCellValue(cell); if(StringUtil.areBlank(ADDR, TEL) && "V1".equals(INVOICE_TYPE) && StringUtil.areBlank(NAMECARD_ID)) { } cell = row.getCell(11); ACCOUNT_NO = getCellValue(cell); if(StringUtil.areBlank(ACCOUNT_NO) && "V1".equals(INVOICE_TYPE) && StringUtil.areBlank(NAMECARD_ID)) { String message = workBook.getSheetName(i) + "的第" + line + "行,开户行账号不能为空"; throw new ServiceException(message); } cell = row.getCell(12); BANK_NAME = getCellValue(cell); if(StringUtil.areBlank(BANK_NAME, ACCOUNT_NO) && "V1".equals(INVOICE_TYPE) && StringUtil.areBlank(NAMECARD_ID)) { String message = workBook.getSheetName(i) + "的第" + line + "行,开户行账号和名称不能都为空"; throw new ServiceException(message); } cell = row.getCell(14); DES = getCellValue(cell); if(StringUtil.areBlank(DES)) { String message = workBook.getSheetName(i) + "的第" + line + "行,货物或应税劳务名称不能为空"; throw new ServiceException(message); } else { // 校验类型是否存在 boolean temp = false; for(int k=0; k<businessType.size(); k++) { if(businessType.get(k).containsValue(DES)) { temp = true; break; } } if(!temp) { throw new ServiceException("请输入正确的货物或应税劳务名称"); } } cell = row.getCell(15); SPEC = getCellValue(cell); cell = row.getCell(16); UNIT = getCellValue(cell); cell = row.getCell(17); if(cell == null) { UNIT_PRICE = ""; } else { try { cell.setCellType(Cell.CELL_TYPE_NUMERIC); UNIT_PRICE = String.valueOf(cell.getNumericCellValue()); } catch (Exception e) { String message = workBook.getSheetName(i) + "的第" + line + "行,单价必须为有效数值"; throw new ServiceException(message); } } cell = row.getCell(18); if(cell == null) { AMOUNT = ""; } else { try { cell.setCellType(Cell.CELL_TYPE_NUMERIC); AMOUNT = String.valueOf(cell.getNumericCellValue()); } catch (Exception e) { String message = workBook.getSheetName(i) + "的第" + line + "行,数量必须为有效数值"; throw new ServiceException(message); } } cell = row.getCell(19); PAYEE = getCellValue(cell); cell = row.getCell(20); RECHECKER = getCellValue(cell); cell = row.getCell(21); REMARK = getCellValue(cell); cell = row.getCell(22); if(cell == null || cell.getCellType() != Cell.CELL_TYPE_NUMERIC) { String message = workBook.getSheetName(i) + "的第" + line + "行,税率必须为有效数值"; throw new ServiceException(message); } if(cell.getNumericCellValue() == 0) { String message = workBook.getSheetName(i) + "的第" + line + "行,税率必须为有效数值"; throw new ServiceException(message); } RETE = getCellValue(cell); cell = row.getCell(23); RECV_ADDR = getCellValue(cell); if(StringUtil.areBlank(RECV_ADDR)) { String message = workBook.getSheetName(i) + "的第" + line + "行,收件人地址不能为空"; throw new ServiceException(message); } cell = row.getCell(24); RECV_NAME = getCellValue(cell); if(StringUtil.areBlank(RECV_NAME)) { String message = workBook.getSheetName(i) + "的第" + line + "行,收件人名称不能为空"; throw new ServiceException(message); } cell = row.getCell(25); RECV_TEL = getCellValue(cell); if(StringUtil.areBlank(RECV_TEL)) { String message = workBook.getSheetName(i) + "的第" + line + "行,收件人电话不能为空"; throw new ServiceException(message); } cell = row.getCell(26); RECV_EMAIL = getCellValue(cell);*/ // 是否申请过 if (ifHaveApply(CUST_NAME, TAXAMT, BELONG_DATE)) { IF_REPEAT = "Y"; } Map<String, String> map = new HashMap<String, String>(); map.put("ORDER_NUM", ORDER_NUM); map.put("BRANCH", BRANCH); map.put("SETTLEMENT", SETTLEMENT); map.put("CUST_NAME", CUST_NAME); map.put("TAXPAY_ID", TAXPAY_ID); map.put("TAXAMT", TAXAMT); map.put("INVOICE_TYPE", INVOICE_TYPE); map.put("BELONG_DATE", BELONG_DATE); map.put("DES", DES); map.put("REMARK", REMARK); map.put("CREATE_ID", UserUtil.getCurrentUser().getEmpCode()); map.put("EXCEP_REMARK", EXCEP_REMARK); map.put("ADDR", ADDR); map.put("TEL", TEL); map.put("BANK_NAME", BANK_NAME); map.put("ACCOUNT_NO", ACCOUNT_NO); map.put("SPEC", SPEC); map.put("UNIT", UNIT); map.put("UNIT_PRICE", UNIT_PRICE); map.put("AMOUNT", AMOUNT); map.put("PAYEE", PAYEE); map.put("RECHECKER", RECHECKER); map.put("RETE", RETE); map.put("RECV_ADDR", RECV_ADDR); map.put("RECV_TEL", RECV_TEL); map.put("RECV_NAME", RECV_NAME); map.put("RECV_EMAIL", RECV_EMAIL); map.put("NAMECARD_ID", NAMECARD_ID); map.put("IF_REPEAT", IF_REPEAT); map.put("BILL_NO", BILL_NO); excelValueList.add(map); } } return excelValueList; } /** * 2016年12月8日 80001092 方法说明:查询散单 * @param bean * void */ public void queryUnbilledDesperse(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); try { bean.getExpData().put("page", PageHandler.execute(new PageSplit<Map<String, Object>>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCountDesperse(paramMap); } @Override public List<Map<String, Object>> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getBillListDesperse(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } catch (Exception e) { logger.error("查询散单待开票失败"); throw new ServiceException("查询失败",e.getMessage()); } } /** * 2016年12月9日 80001092 方法说明:散单删除 * @param bean * void */ public void deleteDesperseRecord(BeanBase bean) { String idsString = bean.getDatas().get(0).get("ids"); if(StringUtil.areBlank(idsString)) { throw new ServiceException("请选择需要删除的记录"); } String ids = StringUtil.addDimmer(idsString, ",", "'"); try { billingApplyDao.deleteDesperseRecord(ids); } catch (Exception e) { logger.error("删除失败,sql异常"); throw new ServiceException(""); } } /** * 2016年12月9日 80001092 方法说明:生成散单发票批 * @param base * void */ @Transactional public void createDesporseBatch(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String selectAllFlag = paramMap.get("selectAllFlag"); String idsString = paramMap.get("ids"); if(StringUtil.areBlank(idsString) && !"checked".equals(selectAllFlag)) { throw new ServiceException("请选择需要提交的记录"); } String ids = StringUtil.addDimmer(idsString, ",", "'"); if ("checked".equals(selectAllFlag)) { // 全选 ids = null; } List<Map<String, Object>> listRecord = billingApplyDao. getBillListDesperseByIds(ids,UserUtil.getCurrentUser().getEmpCode()); if(listRecord == null || listRecord.size() == 0) { throw new ServiceException("获取开票信息时失败,暂时无法提交"); } for(int i=0,count=listRecord.size(); i<count; i++){ Map<String, Object> mapInfo = listRecord.get(i); if("02".equals(mapInfo.get("KP_FLAG").toString())) { throw new ServiceException("已经提交的行禁止再次提交"); } // 发票批次号 String ZDEINVID = new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()) + new Double(Math.floor(Math.random()*10)).intValue(); String nextStep = queryNextStep("20"); //mapInfo.put("currentStep", queryCurrentStep("02", "E/S")); mapInfo.put("currentStep", queryCurrentStepFromStep(mapInfo.get("BRANCH").toString(), BillingApplyConstants.INV_TARGET_OUTER)); mapInfo.put("nextStep", nextStep); mapInfo.put("ZDEINVID", ZDEINVID); mapInfo.put("INV_TARGET", BillingApplyConstants.INV_TARGET_S); //外部 mapInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); try { billingApplyDao.createDisperseBillBath(mapInfo); billingApplyDao.createDisperseFormBill(mapInfo); billingApplyDao.updateDisperseKPFlag(mapInfo.get("ID").toString(), ZDEINVID); // 散单生成发票批日志 insertBatchFlowLog(mapInfo, "TAX_11_02"); } catch (Exception e) { logger.error("散单发票批生成失败"); throw new ServiceException("散单发票批生成失败",e.getMessage()); } } } /** * 2016年12月10日 80001092 方法说明:获取单元格值 * @param cell * @return * String */ private String getCellValue(Cell cell) { if(cell == null) { return ""; } String cellValue = ""; switch (cell.getCellType()) { case Cell.CELL_TYPE_STRING: cellValue =cell.getStringCellValue().trim(); break; case Cell.CELL_TYPE_NUMERIC: cellValue = String.valueOf(cell.getNumericCellValue()); break; } return cellValue; } /** * 2016年12月13日 80001092 方法说明:查询关联方待开票记录 * @param bean * void */ public void queryRelatedUnbill(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); paramMap.put("billTaxPaySub", StringUtil.addDimmer(paramMap.get("BILL_TAX_PAY_SUB"), ",", "'")); paramMap.put("invTaxPaySub", StringUtil.addDimmer(paramMap.get("INV_TAX_PAY_SUB"), ",", "'")); paramMap.put("billPrctr", StringUtil.addDimmer(paramMap.get("BILL_PRCTR"), ",", "'")); paramMap.put("zCustomerNo", StringUtil.addDimmer(paramMap.get("Z_CUSTOMER_NO"), ",", "'")); paramMap.put("businessType", StringUtil.addDimmer(paramMap.get("BUSINESS_TYPE"), ",", "'")); paramMap.put("billBukrs", StringUtil.addDimmer(paramMap.get("ORG_BUKRS"), ",", "'")); try { bean.getExpData().put("page", PageHandler.execute(new PageSplit<Map<String, Object>>() { @Override public int queryTotalCount() { return billingApplyDao.getRelatedTotalCount(paramMap); } @Override public List<Map<String, Object>> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getRelatedBillList(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } catch (Exception e) { logger.error("查询待开记录失败!"); throw new ServiceException("查询待开票记录失败",e.getMessage()); } } /** * 2016年12月15日 80001092 方法说明:查看关联方待开票明细 * @param bean * void */ public void queryRelatedDetail(BeanBase bean) { String headerId = bean.getDatas().get(0).get("headerId"); if(StringUtil.areBlank(headerId)) { throw new ServiceException("暂时无法查询明细"); } try { bean.getExpData().put("page", PageHandler.execute(new PageSplit<Map<String, Object>>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCountRelatedDeatail(headerId); } @Override public List<Map<String, Object>> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getBillListRelatedDeatail(headerId, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } catch (Exception e) { logger.error("查询关联方待开票明细错误"); throw new ServiceException("暂时无法查看明细", e.getMessage()); } } /** * 2016年12月19日 80001092 方法说明:关联方开票申请 * @param bean * void */ @Transactional public void createRelatedBillBatchSelf(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String[] ids = paramMap.get("ids").split(",",-1); String[] busType = paramMap.get("rBUSINESS_TYPE").split(",",-1); /*String[] TSK_MONTH_BILL = paramMap.get("TSK_MONTH_BILL").split(",",-1); String[] TICKETS_BACK = paramMap.get("TICKETS_BACK").split(",",-1); String[] applierBack = paramMap.get("applierBack").split(",",-1); String[] bellong_date = paramMap.get("bellong_date").split(",",-1);*/ String postType = paramMap.get("postType"); String nextStep = queryNextStep("30"); try { if("alone".equals(postType)) { // 单独提交 for(int i=0; i<ids.length; i++) { createRelatedBillingBatch(ids[i],nextStep,busType[i]); } } else if("merged".equals(postType)) { // 合并提交 createRelatedBillingBatchMerged(ids,nextStep,busType); } } catch (Exception e) { logger.error("关联方开票失败!"); throw new ServiceException("生成发票批失败", e.getMessage()); } } /** * 2016年12月19日 80001092 方法说明:创建关联方发票批 * @param string * @param string2 * @param string3 * @param string4 * void */ private void createRelatedBillingBatch(String id,String nextStep,String busType) { String kp_flag = billingApplyDao.getKPFlag(id); if("01".equals(kp_flag)) { // 未开票 //发票批次号 // String ZDEINVID = new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()) + new Double(Math.floor(Math.random()*10)).intValue(); // insert into p2_ztax_form_bill 子账号 Map<String, Object> mapInfo = billingApplyDao.getInfoForCreateRelatedBath(id); if (mapInfo == null) { throw new ServiceException("开票信息不完整,无法开票!"); } String ZDEINVID = createBatchId(mapInfo); mapInfo.put("ZDEINVID", ZDEINVID); mapInfo.put("TICKETS_BACK", ZDEINVID); mapInfo.put("nextStep", nextStep); //mapInfo.put("ZDEINVID_XH", '1'); mapInfo.put("INV_TARGET", BillingApplyConstants.INV_TARGET_I); //内部 mapInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); //mapInfo.put("billAMT",TSK_MONTH_BILL); //mapInfo.put("APPLIER_BACK", applierBack); //mapInfo.put("TICKETS_BACK", TICKETS_BACK); mapInfo.put("billAMT",mapInfo.get("WRBTR")); mapInfo.put("BEGIN_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); mapInfo.put("END_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); //insert into p2_tax_bill_batch billingApplyDao.createRelatedBatch(mapInfo); //insert into p2_ztax_form_bill 主账号 // 子账号,01,07,08,09,10,11,99, List<Map<String, Object>> itemList = billingApplyDao.getBillListRelatedDeatailByGroup(id); Map<String, Object> tempMap = null; for (int i=0; i<itemList.size(); i++) { tempMap = itemList.get(i); tempMap.put("ZDEINVID_XH", 1); // 除了物资和资产,数量置为0; if (!"A1".equals(busType) && !"A2".equals(busType)) { tempMap.put("FKIMG", 1); } billingApplyDao.createRelatedFormBill(mapInfo,tempMap); } // update p2_tax_bill_item billingApplyDao.updateBillItemBatchId(mapInfo.get("ZBILL_NO").toString(), ZDEINVID); // update p2_ztax_bill_header billingApplyDao.updateBatchId("'" + id + "'", ZDEINVID); // update p2_ztax_bill_sum 应开扣减,已开增加 billingApplyDao.updateBillSum(mapInfo); // billBatch flow log insertBatchFlowLog(mapInfo, "TAX_31_01"); tempMap = null; mapInfo = null; itemList.clear(); } else { throw new ServiceException("存在已经提交过的开票月份,请查询后重新创建!"); } } /** * 2016年12月19日 80001092 方法说明:下一部 * @param currentStep * @return * String */ private String queryNextStep(String currentStep) { return billingApplyDao.getNextStep(currentStep); } /*private String queryCurrentStep(String original_status, String target) { return billingApplyDao.getCurrentStep(original_status, target); }*/ /** * 2017年3月14日 80001092 方法说明:从权限表查当前步骤 * @param branch * @param target * @return * String */ private String queryCurrentStepFromStep(String branch, String target) { return billingApplyDao.getCurrentStep2(branch, target); } /** * 2016年12月19日 80001092 方法说明:关联方合并提交 * @param ids * @param TSK_MONTH_BILL * @param TICKETS_BACK * @param APPLIER_BACK * @param bellong_date * @param nextStep * void */ private void createRelatedBillingBatchMerged(String[] ids, String nextStep, String[] busType) { //List<Map<String, String>> kpFlagList = billingApplyDao.getKPFlagList(ids); /*for(int i=0; i<kpFlagList.size(); i++) { if("02".equals(kpFlagList.get(0).get("kp_flag"))) { // 如果存在已经开票的月份 throw new ServiceException("已经存在申请过的月份,请查询后重新提交!"); } }*/ if (ids.length <= 1) { throw new ServiceException("合并提交请选择多个"); } // 开票总金额 double mainAccountSUMAMT = 0.0; Map<String, Object> mapInfo = billingApplyDao.getInfoForCreateRelatedBath(ids[0]); Map<String, Object> tempMap = null; List<Map<String, Object>> itemList = null; // String ZDEINVID = new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()) + new Double(Math.floor(Math.random()*10)).intValue(); String ZDEINVID = createBatchId(mapInfo); // int count = 1; String BEGIN_PERIOD = ""; String END_PERIOD = ""; String temp_PERIOD = ""; for(int i=0; i<ids.length; i++) { mapInfo = billingApplyDao.getInfoForCreateRelatedBath(ids[i]); temp_PERIOD = mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString(); if (i == 0) { BEGIN_PERIOD = temp_PERIOD; END_PERIOD = temp_PERIOD; } else { if (temp_PERIOD.compareTo(BEGIN_PERIOD) < 0) { BEGIN_PERIOD = temp_PERIOD; } else if (temp_PERIOD.compareTo(END_PERIOD) > 0) { END_PERIOD = temp_PERIOD; } } mapInfo.put("ZDEINVID", ZDEINVID); mapInfo.put("TICKETS_BACK", ZDEINVID); itemList = billingApplyDao.getBillListRelatedDeatailByGroup(ids[i]); for (int j=0; j<itemList.size(); j++) { tempMap = itemList.get(j); tempMap.put("ZDEINVID_XH", 1); // 除了物资和资产,数量置为0; if (!"A1".equals(busType) && !"A2".equals(busType)) { tempMap.put("FKIMG", 1); } billingApplyDao.createRelatedFormBill(mapInfo,tempMap); } mainAccountSUMAMT += Double.parseDouble(mapInfo.get("WRBTR").toString()); //double sumMonthAMT = Double.parseDouble(TSK_MONTH_BILL[i]); mapInfo.put("billAMT", mapInfo.get("WRBTR")); billingApplyDao.updateBillSum(mapInfo); } mapInfo.put("nextSetp", nextStep); mapInfo.put("INV_TARGET", BillingApplyConstants.INV_TARGET_I); //内部 mapInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); mapInfo.put("billAMT", mainAccountSUMAMT); //mapInfo.put("TAXSUM", mainAccountSUMAMT); mapInfo.put("BEGIN_PERIOD",BEGIN_PERIOD); mapInfo.put("END_PERIOD",END_PERIOD); billingApplyDao.createRekatedMainAccountBatchMerged(mapInfo); billingApplyDao.updateBatchId(addQuotes(ids), ZDEINVID); billingApplyDao.updateBillItemBacthId(addQuotes(ids), ZDEINVID); insertBatchFlowLog(mapInfo, "TAX_31_02"); tempMap = null; mapInfo = null; itemList.clear(); } /** * 2016年12月21日 80001092 方法说明:插入日志方法 * @param map * @param code * void */ private void insertBatchFlowLog(Map<String, Object> map, String code) { Map<String, Object> flowLogMap = billingApplyDao.getModuleConfig(code); billingApplyDao.insertBatchFlowLog(map, flowLogMap); } /** * 2016年12月27日 80001092 方法说明:查询查分开票信息 * @param bean * void */ public void getHeaderAndSubaccount(BeanBase bean) { String headerId = bean.getDatas().get(0).get("headerId"); String queryType = bean.getDatas().get(0).get("REBILL_FLAG"); Map<String, Object> headerData = null; List<Map<String, Object>> listSubAccount = null; try { if("REBILL".equals(queryType)) { // 补开 headerData = billingApplyDao.getHeaderInfoRebill(headerId); } else { headerData = billingApplyDao.getHeaderInfo(headerId); } listSubAccount = billingApplyDao.querySubAccount(headerId); } catch(Exception e) { throw new ServiceException("数据库连接异常,稍后重试"); } bean.getExpData().put("listSubAccount", listSubAccount); bean.getExpData().put("headerData", headerData); } /** * 2016年12月29日 80001092 方法说明:新实现拆分(申请和补开申请访问同方法),生成一个发票批 * @param bean * void */ @Transactional public void newSepareteMethod(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String headerId = paramMap.get("headerId"); String REBILL_FLAG = paramMap.get("REBILL_FLAG"); String totalAMT = paramMap.get("totalAMT"); //查询当前月结账号当前月份是否已创建发票批 String kp_flag = billingApplyDao.getKPFlag(headerId); if("01".equals(kp_flag)) { // 未开票 String[] TSK_MONTH_BILL = paramMap.get("TSK_MONTH_BILL").split(",",-1); String DIFF_REASON = paramMap.get("DIFF_REASON"); String[] TICKETS_BACK = paramMap.get("TICKETS_BACK").split(",",-1); String[] applierBack = paramMap.get("applierBack").split(",",-1); String[] sub_ID = paramMap.get("sub_ID").split(",",-1); String[] SUB_TSK_MONTH_BILL = paramMap.get("SUB_TSK_MONTH_BILL").split(",",-1); /*String[] SUB_DIFF_REASON = paramMap.get("SUB_DIFF_REASON").split(",",-1);*/ String[] SUB_TICKETS_BACK = paramMap.get("SUB_TICKETS_BACK").split(",",-1); String[] SUB_applierBack = paramMap.get("SUB_applierBack").split(",",-1); // 新增单位,单价,数量,规格编辑 String[] MEINS = paramMap.get("MEINS").split(",",-1); String[] UNITPE = paramMap.get("UNITPE").split(",",-1); String[] FKIMG = paramMap.get("FKIMG").split(",",-1); String[] MSPEC = paramMap.get("MSPEC").split(",",-1); String[] sub_MEINS = paramMap.get("sub_MEINS").split(",",-1); String[] sub_UNITPE = paramMap.get("sub_UNITPE").split(",",-1); String[] sub_FKIMG = paramMap.get("sub_FKIMG").split(",",-1); String[] sub_MSPEC = paramMap.get("sub_MSPEC").split(",",-1); //发票批次号 String ZDEINVID = new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()) + new Double(Math.floor(Math.random()*10)).intValue(); int j = 1; Map<String, Object> mapInfo = getBatchInfoById(headerId); String nextSetp = queryNextStep("20"); mapInfo.put("nextSetp", nextSetp); // mapInfo.put("currentStep", queryCurrentStep("02", "E/S")); mapInfo.put("currentStep", queryCurrentStepFromStep(mapInfo.get("BILL_PRCTR").toString(), BillingApplyConstants.INV_TARGET_OUTER)); mapInfo.put("ZDEINVID", ZDEINVID); mapInfo.put("INV_TARGET", BillingApplyConstants.INV_TARGET_E); //外部 mapInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); // billAMT存放开票金额汇总 mapInfo.put("billAMT", Double.parseDouble(totalAMT)); mapInfo.put("BEGIN_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); mapInfo.put("END_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); //insert into p2_tax_bill_batch billingApplyDao.createMainAccountBatch(mapInfo); // update p2_ztax_bill_sum 应开扣减,已开增加 billingApplyDao.updateBillSum(mapInfo); if (StringUtil.areBlank(REBILL_FLAG)) { // update p2_tax_bill_item billingApplyDao.updateBillItemBatchId(mapInfo.get("ZBILL_NO").toString(), ZDEINVID); // update p2_ztax_bill_header billingApplyDao.updateBatchId("'" + headerId + "'", ZDEINVID); } // 流转日志 insertBatchFlowLog(mapInfo, "TAX_10_03"); // 生成形式发票 for(int i=0; i<TSK_MONTH_BILL.length; i++) { if(StringUtils.isBlank(TSK_MONTH_BILL[i]) || 0 == Double.parseDouble(TSK_MONTH_BILL[i])) { continue; } mapInfo.put("ZDEINVID_XH", j++); mapInfo.put("TAXSUM", Double.parseDouble(TSK_MONTH_BILL[i])); mapInfo.put("DIFF_REASON", DIFF_REASON); mapInfo.put("TICKETS_BACK", TICKETS_BACK[i]); mapInfo.put("APPLIER_BACK", applierBack[i]); mapInfo.put("MEINS", MEINS[i]); mapInfo.put("UNITPE", UNITPE[i]); mapInfo.put("FKIMG", FKIMG[i]); mapInfo.put("MSPEC", MSPEC[i]); //insert into p2_ztax_form_bill 主账号 billingApplyDao.createFormBill(mapInfo); } for(int i=0; i<sub_ID.length; i++) { // 为0不创建 if(StringUtils.isBlank(SUB_TSK_MONTH_BILL[i]) || 0 == Double.parseDouble(SUB_TSK_MONTH_BILL[i])) { continue; } Map<String, Object> mapSubInfo = getSubAccountInfo(headerId, sub_ID[i]); mapSubInfo.put("ZDEINVID", ZDEINVID); mapSubInfo.put("ZDEINVID_XH", j++); mapSubInfo.put("SUB_TSK_MONTH_BILL", SUB_TSK_MONTH_BILL[i]); mapSubInfo.put("SUB_DIFF_REASON", DIFF_REASON); mapSubInfo.put("SUB_TICKETS_BACK", SUB_TICKETS_BACK[i]); mapSubInfo.put("sub_applierBack", SUB_applierBack[i]); mapSubInfo.put("MEINS", sub_MEINS[i]); mapSubInfo.put("UNITPE", sub_UNITPE[i]); mapSubInfo.put("FKIMG", sub_FKIMG[i]); mapSubInfo.put("MSPEC", sub_MSPEC[i]); mapSubInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); billingApplyDao.createFormBillSubAccount(mapSubInfo); } } else { throw new ServiceException("该月份已经生成发票批,请查询后重新创建!"); } } /** * 2017年1月7日 80001092 方法说明:查询作废遗失发票 * @param bean * void */ public void queryMarkedCancleList(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); try { bean.getExpData().put("page", PageHandler.execute(new PageSplit<Map<String, Object>>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCountMarkedCancl(paramMap); } @Override public List<Map<String, Object>> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getMarkedCancleList(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } catch (Exception e) { logger.error("查询实物发票信息失败!"); throw new ServiceException("数据库访问异常,暂时无法查询",e); } } /** * 2017年1月7日 80001092 方法说明:打标识 * @param bean * void */ @Transactional public void doMark(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String selectAllFlag = paramMap.get("selectAllFlag"); String ids = StringUtil.addDimmer(paramMap.get("ids"), ",", "'"); List<Map<String, String>> compareData = new ArrayList<Map<String, String>>(); if (StringUtil.areNotBlank(ids)) { compareData = billingApplyDao.getCompareData(ids); } for (int i=0; i<compareData.size(); i++) { String tempId = billingApplyDao.getAllID(compareData.get(i).get("ZINV_CODE"), compareData.get(i).get("ZINV_NUMBER")); if(StringUtil.areNotBlank(tempId)) { ids += "," + StringUtil.addDimmer(tempId, ",", "'"); } } if(!"checked".equals(selectAllFlag)) { paramMap.put("ids", ids); } paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); try { billingApplyDao.doMarkList(paramMap); } catch (Exception e) { logger.error("实物发票打标识失败!"); throw new ServiceException("数据库访问异常,暂时无法操作",e); } } /** * 2017年1月9日 80001092 方法说明:查询导入遗失发票 * @param bean * void */ public void queryImportCancleLoseInv(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); try { bean.getExpData().put("page", PageHandler.execute(new PageSplit<Map<String, Object>>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCountImportCancleLose(paramMap); } @Override public List<Map<String, Object>> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getImportCancleLoseList(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } catch (Exception e) { logger.error("导入作废发票查询失败!"); throw new ServiceException("数据库访问异常,暂时无法查询",e); } } /** * 2017年1月9日 80001092 方法说明:导入作废遗失发票 * @param bean * void */ @Transactional public void cancleLoseInvImport(BeanBase bean) { try { new AbstractExcelReader() { @Override public void doParse(Workbook workbook) { insertCancleLoseInv(checkCancleLose(workbook)); } }.Reader();; } catch (Exception e) { String errorMsg = "EXCEL上传失败:<br>" + e.getMessage(); logger.error(errorMsg, e); if (e instanceof DuplicateKeyException) { throw new ServiceException("EXCEL上传失败:导入的Excel存在重复的数据,去掉重复数据后在导入"); } else { throw new ServiceException(errorMsg); } } bean.setStatus(BusinessStatus.FINLISH); bean.setProcessMsg("导入完成!"); } private void insertCancleLoseInv(List<Map<String, String>> list) { billingApplyDao.insertCancleLoseInv(list); } /** * 2017年1月16日 80001092 方法说明:待完成 * @param workBook * @return * List<Map<String,String>> */ private List<Map<String, String>> checkCancleLose(Workbook workBook) { List<Map<String, String>> excelValueList = null; // 待导入的数据 int import_wb_sheetNos = workBook.getNumberOfSheets(); if (import_wb_sheetNos == 0) { throw new ServiceException("待导入的数据为空"); } excelValueList = new ArrayList<>(); String currentEmpCode = UserUtil.getCurrentUser().getEmpCode(); // 当前登陆用户拥有的实物发票权限 List<Map<String, Object>> dataList = billingApplyDao.getAuthDataList(currentEmpCode); // 已经导入系统的作废作负发票 List<Map<String, Object>> dataHaveImp = billingApplyDao.getDataHaveImp(currentEmpCode); // 本次导入的旧发票代码 Map<String, String> codeOldToal = new HashMap<String, String>(); // 本次导入的新发票代码 Map<String, String> codeNewToal = new HashMap<String, String>(); for(int i=0; i<import_wb_sheetNos; i++) { Cell cell = null; String INV_TYPE = null; String ZINV_CODE = null; String ZINV_NUMBER = null; String KP_DATE = null; String UNTAX_AMT = null; String TAX_AMT = null; String OP_ZINV_CODE = null; String OP_ZINV_NUMBER = null; String HQZF_FLAG = null; String DZF_FLAG = null; String list_BILL_STATUS = null; String a_bill_tax_pay_sub = null; String a_bill_prctr = null; Sheet sheet = workBook.getSheetAt(i); for(int line=1, count=sheet.getLastRowNum()+1; line<count; line++) { Row row = sheet.getRow(line); cell = row.getCell(0); INV_TYPE = getCellValue(cell); cell = row.getCell(1); ZINV_CODE = getCellValue(cell); //去除空行 if (StringUtil.areBlank(INV_TYPE, ZINV_CODE)) { continue; } if (StringUtil.areBlank(INV_TYPE)) { throw new ServiceException("发票类型不能为空!"); } if (!BillingApplyConstants.INV_IMPORT_HC.equals(INV_TYPE) && !BillingApplyConstants.INV_IMPORT_ZF.equals(INV_TYPE)) { throw new ServiceException("Excel请输入正确的发票种类:红冲或作废"); } if (StringUtil.areBlank(ZINV_CODE)) { throw new ServiceException("发票代码不能为空!"); } cell = row.getCell(2); ZINV_NUMBER = getCellValue(cell); if (StringUtil.areBlank(ZINV_NUMBER)) { throw new ServiceException("发票代码不能为空!"); } cell = row.getCell(3); KP_DATE = getCellValue(cell); if (StringUtil.areBlank(KP_DATE)) { throw new ServiceException("开票日期不能为空!"); } try { DateUtils.parseDate(KP_DATE, "yyyy-MM-dd"); } catch (Exception e) { String errorMessage = workBook.getSheetName(i) + "的第" + line + "行,开票日期格式错误,必须为[yyyy-MM-dd]"; throw new ServiceException(errorMessage); } cell = row.getCell(4); UNTAX_AMT = getCellValue(cell); try { Double.parseDouble(UNTAX_AMT); } catch (Exception e) { String message = workBook.getSheetName(i) + "的第" + line + "行,不含税金额必须为有效数值"; throw new ServiceException(message); } if (BillingApplyConstants.INV_IMPORT_HC.equals(INV_TYPE) && !UNTAX_AMT.contains("-")) { String message = workBook.getSheetName(i) + "的第" + line + "行,不含税金额必须为负数"; throw new ServiceException(message); } cell = row.getCell(5); TAX_AMT = getCellValue(cell); try { Double.parseDouble(TAX_AMT); } catch (Exception e) { String message = workBook.getSheetName(i) + "的第" + line + "行,税金必须为有效数值"; throw new ServiceException(message); } if (BillingApplyConstants.INV_IMPORT_HC.equals(INV_TYPE) && !TAX_AMT.contains("-")) { String message = workBook.getSheetName(i) + "的第" + line + "行,税金必须为负数"; throw new ServiceException(message); } cell = row.getCell(6); OP_ZINV_CODE = getCellValue(cell); cell = row.getCell(7); OP_ZINV_NUMBER = getCellValue(cell); // 校验是否重复导入 if (codeOldToal.get(OP_ZINV_CODE+OP_ZINV_NUMBER) == null) { if (StringUtil.areNotBlank(OP_ZINV_CODE, OP_ZINV_NUMBER)) { codeOldToal.put(OP_ZINV_CODE+OP_ZINV_NUMBER, OP_ZINV_CODE+OP_ZINV_NUMBER); } } else { throw new ServiceException("发票代码"+ OP_ZINV_CODE +"发票号码" + OP_ZINV_NUMBER +"不能重复!"); } if (codeNewToal.get(ZINV_CODE + ZINV_NUMBER) == null) { if (StringUtil.areNotBlank(ZINV_CODE, ZINV_NUMBER)) { codeNewToal.put(ZINV_CODE + ZINV_NUMBER, ZINV_CODE + ZINV_NUMBER); } } else { throw new ServiceException("发票代码"+ ZINV_CODE +"发票号码" + ZINV_NUMBER +"不能重复!"); } // 负数发票 if (BillingApplyConstants.INV_IMPORT_HC.equals(INV_TYPE)) { if (StringUtil.areBlank(OP_ZINV_CODE)) { throw new ServiceException("导入红冲发票类型,负数发票对应的正数发票代码不能为空!"); } if (StringUtil.areBlank(OP_ZINV_NUMBER)) { throw new ServiceException("导入红冲发票类型,负数发票对应的正数发票号码不能为空!"); } } // 校验发票号码、代码是否存在 boolean ifExicts = false; String tempUNTAX_AMT = null; String tempTAX_AMT = null; String tempStatus = null; String ID = null; String ZDEINVID = null; String KUNNR = null; String ZTAXTYPE = null; String target = null; Map<String, Object> tempMap = new HashMap<String, Object>(); // 判断是否已经导入过 for ( int j=0; j<dataHaveImp.size(); j++ ) { tempMap = dataHaveImp.get(j); if (BillingApplyConstants.INV_IMPORT_HC.equals(INV_TYPE)) { if (OP_ZINV_CODE.equals(String.valueOf(tempMap.get("OP_ZINV_CODE"))) && OP_ZINV_NUMBER.equals(String.valueOf(tempMap.get("OP_ZINV_NUMBER")))) { throw new ServiceException("发票代码" + OP_ZINV_CODE + "发票号码" + OP_ZINV_NUMBER + "已经导入过,禁止重复导入"); } } if (BillingApplyConstants.INV_IMPORT_ZF.equals(INV_TYPE)) { if (ZINV_CODE.equals(String.valueOf(tempMap.get("ZINV_CODE"))) && ZINV_NUMBER.equals(String.valueOf(tempMap.get("ZINV_NUMBER")))) { throw new ServiceException("发票代码" + ZINV_CODE + "发票号码" + ZINV_NUMBER + "已经导入过,禁止重复导入"); } } } // 如果是红冲,判断是否空白 if (BillingApplyConstants.INV_IMPORT_HC.equals(INV_TYPE)) { for (int j=0; j<dataList.size(); j++) { tempMap = dataList.get(j); if (tempMap.containsValue(ZINV_CODE) && tempMap.containsValue(ZINV_NUMBER)) { throw new ServiceException("红冲发票代码" + ZINV_CODE + "发票号码" + ZINV_NUMBER + "已经开过票,请输入新的发票代码、号码"); } } } for (int j=0; j<dataList.size(); j++) { // 用值相等判断 tempMap = dataList.get(j); if (BillingApplyConstants.INV_IMPORT_HC.equals(INV_TYPE)) { if (tempMap.containsValue(OP_ZINV_CODE) && tempMap.containsValue(OP_ZINV_NUMBER)) { ifExicts = true; } } if (BillingApplyConstants.INV_IMPORT_ZF.equals(INV_TYPE)) { if (tempMap.containsValue(ZINV_CODE) && tempMap.containsValue(ZINV_NUMBER)) { ifExicts = true; } } if (ifExicts) { tempUNTAX_AMT = tempMap.get("NETWR") == null ? "0" : tempMap.get("NETWR").toString(); tempTAX_AMT = tempMap.get("TAXAMT") == null ? "0" : tempMap.get("TAXAMT").toString(); tempStatus = tempMap.get("CANCLE_FLAG") == null ? "" : tempMap.get("CANCLE_FLAG").toString(); ID = tempMap.get("ID").toString(); ZDEINVID = tempMap.get("ZDEINVID").toString(); KUNNR = tempMap.get("KUNNR") == null ? "" : tempMap.get("KUNNR").toString(); ZTAXTYPE = tempMap.get("ZTAXTYPE") == null ? "" : tempMap.get("ZTAXTYPE").toString(); list_BILL_STATUS = tempMap.get("list_BILL_STATUS") == null ? "" : tempMap.get("list_BILL_STATUS").toString(); a_bill_tax_pay_sub = String.valueOf(tempMap.get("A_BILL_TAX_PAY_SUB")); a_bill_prctr = String.valueOf(tempMap.get("A_BILL_PRCTR")); target = tempMap.get("INV_TARGET").toString(); break; } } if (ifExicts) { // 发票号码、代码匹配成功 比较金额 double currentUntax = Math.abs(Double.parseDouble(UNTAX_AMT)); double currentTax = Math.abs(Double.parseDouble(TAX_AMT)); double tempUntax = Double.parseDouble(tempUNTAX_AMT); double tempTax = Double.parseDouble(tempTAX_AMT); if (currentUntax == tempUntax && currentTax == tempTax) { // 金额匹配成功 // 红冲作废标识不需要 HQZF_FLAG = "Y"; if ("Y".equals(tempStatus)) { // 有待作废标识 DZF_FLAG = "Y"; } // 更新汇总表,扣减已开金额;如果是月结客户 暂时不处理,添加确认步骤 /*if (BillingApplyConstants.INV_TARGET_E.equals(tempMap.get("INV_TARGET").toString())) { // 更新实物发票,BILL_STATUS置为”已红冲“ billingApplyDao.updateBillListStatus(ID, INV_TYPE, currentEmpCode); updateBillSumAMT(ZDEINVID, KUNNR, ZTAXTYPE, tempUntax + tempTax); // 方法2 使用BidDecimal精确计算,暂未启用 // updateBillSumAMT2(ZDEINVID, KUNNR, ZTAXTYPE, tempUntax, tempTax); } else if (BillingApplyConstants.INV_TARGET_S.equals(tempMap.get("INV_TARGET").toString())) { // 更新实物发票,BILL_STATUS置为”已红冲“ billingApplyDao.updateBillListStatus(ID, INV_TYPE, currentEmpCode); } else if (BillingApplyConstants.INV_TARGET_I.equals(tempMap.get("INV_TARGET").toString())) { //关联方 if (BillingApplyConstants.INV_REPALCE.equals(list_BILL_STATUS)) { // 如果是负数 if (BillingApplyConstants.INV_TYPE_MINUS.equals(INV_TYPE)) { billingApplyDao.updateBillListStatus2(OP_ZINV_CODE, OP_ZINV_NUMBER, INV_TYPE, currentEmpCode); } // 如果是作废 if (BillingApplyConstants.INV_TYPE_INVALID.equals(INV_TYPE)) { billingApplyDao.updateBillListStatus2(ZINV_CODE, ZINV_NUMBER, INV_TYPE, currentEmpCode); } } }*/ } else { // 金额匹配失败 String alertMsg = null; if (BillingApplyConstants.INV_IMPORT_HC.equals(INV_TYPE)) { alertMsg = workBook.getSheetName(i) + "的第" + line + "行,正数发票代码:" + OP_ZINV_CODE + ";发票号码:" + OP_ZINV_NUMBER + "金额不匹配"; } else { alertMsg = workBook.getSheetName(i) + "的第" + line + "行,发票代码:" + ZINV_CODE + ";发票号码:" + ZINV_NUMBER + "金额不匹配"; } throw new ServiceException(alertMsg); } Map<String, String> map = new HashMap<String, String>(); map.put("INV_TYPE", INV_TYPE); map.put("ZINV_CODE", ZINV_CODE); map.put("ZINV_NUMBER", ZINV_NUMBER); map.put("KP_DATE", KP_DATE); map.put("UNTAX_AMT", UNTAX_AMT); map.put("TAX_AMT", TAX_AMT); map.put("OP_ZINV_CODE", OP_ZINV_CODE); map.put("OP_ZINV_NUMBER", OP_ZINV_NUMBER); map.put("HQZF_FLAG", HQZF_FLAG); map.put("DZF_FLAG", DZF_FLAG); map.put("currentEmpCode", currentEmpCode); map.put("a_bill_tax_pay_sub", a_bill_tax_pay_sub); map.put("a_bill_prctr", a_bill_prctr); map.put("listId", ID); map.put("ZDEINVID", ZDEINVID); map.put("KUNNR", KUNNR); map.put("ZTAXTYPE", ZTAXTYPE); map.put("target", target); map.put("list_BILL_STATUS", list_BILL_STATUS); map.put("totalAMT", String.valueOf(tempUntax + tempTax)); excelValueList.add(map); } else { // 不存在 String message = null; if (BillingApplyConstants.INV_IMPORT_ZF.equals(INV_TYPE)) { message = workBook.getSheetName(i) + "的第" + line + "行,发票代码:" + ZINV_CODE + ";发票号码:" + ZINV_NUMBER + "对应的实物发票不存在"; } else { message = workBook.getSheetName(i) + "的第" + line + "行,正数发票代码:" + OP_ZINV_CODE + ";发票号码:" + OP_ZINV_NUMBER + "对应的实物发票不存在"; } throw new ServiceException(message); } } } return excelValueList; } /** * 2017年3月31日 80001092 方法说明:更新汇总表,扣减已开金额; * @param zDEINVID * @param kUNNR * @param zTAXTYPE * @param tempUntax * @param tempTax * void */ @SuppressWarnings("unused") private void updateBillSumAMT2(String zDEINVID, String kUNNR, String zTAXTYPE, double tempUntax, double tempTax) { Map<String, String> param = billingApplyDao.getQueryCondition(zDEINVID); param.put("KUNNR", kUNNR); Map<String, Object> billSum = billingApplyDao.getUpdateLine(param); if (billSum == null) { throw new ServiceException("缺少必须维护的信息,无法获取导入的作废作负发票的客户信息"); } int end = Integer.parseInt(param.get("endMonth").toString()); int begin = Integer.parseInt(param.get("beginMonth").toString()); BigDecimal untax = new BigDecimal(tempUntax); BigDecimal tax = new BigDecimal(tempTax); BigDecimal amt = tax.add(untax); for (int month = end; month>=begin; month--) { BigDecimal currWk = new BigDecimal(0); if (month < 10) { currWk = new BigDecimal(String.valueOf(billSum.get("TWK0" + month))); if (currWk.compareTo(BigDecimal.ZERO) < 0) { if (amt.compareTo(currWk.abs()) > 0) { amt = amt.subtract(currWk.abs()); billSum.put("TSK0" + month, billSum.get("TSL0" + month)); } else { // 停止 billSum.put("TSK0" + month, new BigDecimal(String.valueOf(billSum.get("TSK0" + month))).subtract(amt)); amt.setScale(0); break; } } } else { currWk = new BigDecimal(String.valueOf(billSum.get("TWK" + month))); if (currWk.compareTo(BigDecimal.ZERO) < 0) { if (amt.compareTo(currWk.abs()) > 0) { amt = amt.subtract(currWk.abs()); billSum.put("TSK" + month, billSum.get("TSL" + month)); } else { // 停止 billSum.put("TSK" + month, new BigDecimal(String.valueOf(billSum.get("TSK" + month))).subtract(amt)); amt.setScale(0); break; } } } } // 如果amt > 0 if (amt.compareTo(BigDecimal.ZERO) > 0) { for (int month = end; month>=begin; month-- ) { if (month < 10) { amt = amt.subtract(new BigDecimal(String.valueOf(billSum.get("TSK0" + month)))); if (amt.compareTo(BigDecimal.ZERO) < 0) { billSum.put("TSK0" + month, amt.abs()); break; } else { billSum.put("TSK0" + month, 0); } } else { amt = amt.subtract(new BigDecimal(String.valueOf(billSum.get("TSK" + month)))); if (amt.compareTo(BigDecimal.ZERO) < 0) { billSum.put("TSK" + month, amt.abs()); break; } else { billSum.put("TSK" + month, 0); } } } } } /** * 2017年1月17日 80001092 方法说明:更新汇总表,扣减已开金额; * @param iD list表ID * void */ private void updateBillSumAMT(String ZDEINVID, String KUNNR, String ZTAXTYPE, double amt) { Map<String, String> param = billingApplyDao.getQueryCondition(ZDEINVID); param.put("KUNNR", KUNNR); // param.put("ZTAXTYPE", ZTAXTYPE); Map<String, Object> billSum = billingApplyDao.getUpdateLine(param); if (billSum == null) { throw new ServiceException("缺少必须维护的信息,无法获取导入的作废作负发票的客户信息"); } int end = Integer.parseInt(param.get("endMonth").toString()); int begin = Integer.parseInt(param.get("beginMonth").toString()); for (int month = end; month>=begin; month--) { double currWk = 0; if (month < 10) { currWk = Double.parseDouble(billSum.get("TWK0" + month).toString()); if (currWk < 0) { if (amt > Math.abs(currWk)) { amt = amt - Math.abs(currWk); billSum.put("TSK0" + month, billSum.get("TSL0" + month)); } else { // 停止 billSum.put("TSK0" + month, Double.parseDouble(billSum.get("TSK0" + month).toString()) - amt); amt = 0; break; } } } else { currWk = Double.parseDouble(billSum.get("TWK" + month).toString()); if (currWk < 0) { if (amt > Math.abs(currWk)) { amt = amt - Math.abs(currWk); billSum.put("TSK" + month, billSum.get("TSL" + month)); } else { // 停止 billSum.put("TSK" + month, Double.parseDouble(billSum.get("TSK" + month).toString()) - amt); amt = 0; break; } } } } // 如果amt > 0 if (amt > 0) { for (int month = end; month>=begin; month-- ) { if (month < 10) { amt = amt - Double.parseDouble(billSum.get("TSK0" + month).toString()); if (amt < 0) { billSum.put("TSK0" + month, Math.abs(amt)); break; } else { billSum.put("TSK0" + month, 0); } } else { amt = amt - Double.parseDouble(billSum.get("TSK" + month).toString()); if (amt < 0) { billSum.put("TSK" + month, Math.abs(amt)); break; } else { billSum.put("TSK" + month, 0); } } } } billSum.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); // 更新sum表 billingApplyDao.updateBillSumAMT(billSum); } /** * 2017年2月7日 80001092 方法说明:根据纳税主体找地区代码 p2_qb_prctr_inv_num * @param taxpay * @return * String */ private String createBatchId(Map<String, Object> map) { String id; if (map.get("ZONE_CODE") != null) { id = map.get("ZONE_CODE").toString() + new SimpleDateFormat("yyMMdd").format(new Date()) + new Double(Math.floor(Math.random()*100000)).intValue(); } else { id = map.get("ORG_TAX_PAY_SUB").toString() + new SimpleDateFormat("yyMMdd").format(new Date()) + new Double(Math.floor(Math.random()*10000)).intValue(); } return id; } /** * 2017年2月21日 80001092 方法说明:添加子账号 * @param bean * void */ public void getRelatedSubAccount(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String cust_no_text = paramMap.get("subAccount"); if (StringUtils.isBlank(cust_no_text)) { throw new ServiceException("子账号不能为空"); } String cust_no = addDolt(cust_no_text); String main_cust_no = cust_no.substring(cust_no.lastIndexOf(",")+2, cust_no.lastIndexOf("'")); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); paramMap.put("cust_no", cust_no); try { List<Map<String, Object>> listSubAccount = billingApplyDao.getActuralSubCustNo(paramMap); Map<String, Object> first = listSubAccount.get(0); Map<String, Object> main; for (int i=0; i<listSubAccount.size(); i++) { if (main_cust_no.equals(listSubAccount.get(i).get("Z_CUSTOMER_NO"))) { main = listSubAccount.get(i); listSubAccount.set(0, main); listSubAccount.set(i, first); } } bean.getExpData().put("page", listSubAccount); } catch (Exception e) { throw new ServiceException("查找子账户失败:" + e.getMessage()); } } /** * 2017年2月23日 80001092 方法说明:获取主账号及输入的子账号 * @param bean * void */ public void getRelatedSubAndHeader(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String headerId = paramMap.get("headerId"); String queryType = paramMap.get("REBILL_FLAG"); String cust_no = addDolt(paramMap.get("subAccount")); Map<String, Object> headerData = null; List<Map<String, Object>> listSubAccount = null; try { if("REBILL".equals(queryType)) { // 补开 headerData = billingApplyDao.getHeaderInfoRebill(headerId); } else { headerData = billingApplyDao.getHeaderInfo(headerId); } listSubAccount = billingApplyDao.querySubAccountActural(cust_no); } catch(Exception e) { throw new ServiceException("获取子客户月结账号信息失败,检查输入的子账号月结客户号是否正确"); } bean.getExpData().put("listSubAccount", listSubAccount); bean.getExpData().put("headerData", headerData); } /** * 2017年2月22日 80001092 方法说明:给子账号添加分号 * @param cust_no_text * @return * String */ private String addDolt(String cust_no_text) { String[] temp = cust_no_text.split(" "); StringBuilder sb = new StringBuilder(); for (int i=0; i<temp.length; i++) { if (StringUtil.areNotBlank(temp[i])) { sb.append("'" + temp[i] + "',"); } } return sb.substring(0, sb.length()-1); } /** * 2017年2月23日 80001092 方法说明:创建关联子账号的发票批 * @param bean * void */ @Transactional public void createSubBillBatch(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String headerId = paramMap.get("headerId"); String REBILL_FLAG = paramMap.get("REBILL_FLAG"); String totalAMT = paramMap.get("totalAMT"); //查询当前月结账号当前月份是否已创建发票批 String kp_flag = billingApplyDao.getKPFlag(headerId); if("01".equals(kp_flag)) { // 未开票 String[] TSK_MONTH_BILL = paramMap.get("TSK_MONTH_BILL").split(",",-1); String DIFF_REASON = paramMap.get("DIFF_REASON"); String[] TICKETS_BACK = paramMap.get("TICKETS_BACK").split(",",-1); String[] applierBack = paramMap.get("applierBack").split(",",-1); String[] Z_CUSTOMER_NO = paramMap.get("Z_CUSTOMER_NO").split(",",-1); String[] MEINS = paramMap.get("MEINS").split(",",-1); String[] UNITPE = paramMap.get("UNITPE").split(",",-1); String[] FKIMG = paramMap.get("FKIMG").split(",",-1); String[] MSPEC = paramMap.get("MSPEC").split(",",-1); //发票批次号 String ZDEINVID = new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()) + new Double(Math.floor(Math.random()*10)).intValue(); int j = 1; Map<String, Object> mapInfo = getBatchInfoById(headerId); String nextSetp = queryNextStep("20"); // mapInfo.put("currentStep", queryCurrentStep("02", "E/S")); mapInfo.put("currentStep", queryCurrentStepFromStep(mapInfo.get("BILL_PRCTR").toString(), BillingApplyConstants.INV_TARGET_OUTER)); mapInfo.put("nextSetp", nextSetp); mapInfo.put("ZDEINVID", ZDEINVID); mapInfo.put("INV_TARGET", BillingApplyConstants.INV_TARGET_E); //外部 mapInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); // billAMT存放开票金额汇总 mapInfo.put("billAMT", Double.parseDouble(totalAMT)); mapInfo.put("BEGIN_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); mapInfo.put("END_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); //insert into p2_tax_bill_batch billingApplyDao.createMainAccountBatch(mapInfo); // update p2_ztax_bill_sum 应开扣减,已开增加 billingApplyDao.updateBillSum(mapInfo); if (StringUtil.areBlank(REBILL_FLAG)) { // update p2_tax_bill_item billingApplyDao.updateBillItemBatchId(mapInfo.get("ZBILL_NO").toString(), ZDEINVID); // update p2_ztax_bill_header billingApplyDao.updateBatchId("'" + headerId + "'", ZDEINVID); } // 流转日志 insertBatchFlowLog(mapInfo, "TAX_10_03"); // 生成形式发票 if(StringUtils.isNotBlank(TSK_MONTH_BILL[0]) && 0 != Double.parseDouble(TSK_MONTH_BILL[0])) { mapInfo.put("ZDEINVID_XH", j++); mapInfo.put("TAXSUM", Double.parseDouble(TSK_MONTH_BILL[0])); mapInfo.put("DIFF_REASON", DIFF_REASON); mapInfo.put("TICKETS_BACK", TICKETS_BACK[0]); mapInfo.put("APPLIER_BACK", applierBack[0]); mapInfo.put("MEINS", MEINS[0]); mapInfo.put("UNITPE", UNITPE[0]); mapInfo.put("FKIMG", FKIMG[0]); mapInfo.put("MSPEC", MSPEC[0]); //insert into p2_ztax_form_bill 主账号 billingApplyDao.createFormBill(mapInfo); } for(int i=1; i<TSK_MONTH_BILL.length; i++) { // 为0不创建 if(StringUtils.isBlank(TSK_MONTH_BILL[i]) || 0 == Double.parseDouble(TSK_MONTH_BILL[i])) { continue; } Map<String, Object> mapSubInfo = billingApplyDao.querySubAccountActural("'"+Z_CUSTOMER_NO[i]+"'").get(0); mapSubInfo.put("MATNR", mapInfo.get("MATNR")); mapSubInfo.put("MAKTX", mapInfo.get("MAKTX")); mapSubInfo.put("GJAHR", mapInfo.get("GJAHR")); mapSubInfo.put("MONAT", mapInfo.get("MONAT")); mapSubInfo.put("BUSINESS_TYPE", mapInfo.get("BUSINESS_TYPE")); mapSubInfo.put("ZDEINVID", ZDEINVID); mapSubInfo.put("ZDEINVID_XH", j++); mapSubInfo.put("SUB_TSK_MONTH_BILL", TSK_MONTH_BILL[i]); mapSubInfo.put("SUB_DIFF_REASON", DIFF_REASON); mapSubInfo.put("SUB_TICKETS_BACK", TICKETS_BACK[i]); mapSubInfo.put("sub_applierBack", applierBack[i]); mapSubInfo.put("MEINS", MEINS[i]); mapSubInfo.put("UNITPE", UNITPE[i]); mapSubInfo.put("FKIMG", FKIMG[i]); mapSubInfo.put("MSPEC", MSPEC[i]); mapSubInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); billingApplyDao.createFormBillSubAccount(mapSubInfo); } } else { throw new ServiceException("该月份已经生成发票批,请查询后重新创建!"); } } /** * 2017年2月27日 80001092 方法说明:是否有申请 * @param name * @param amt * @param date * @return * boolean */ private boolean ifHaveApply(String name, String amt, String date) { boolean result = false; String startDate; String year = date.substring(0, 4); String month = date.substring(4); if (Integer.parseInt(month) == 1) { year = String.valueOf(Integer.parseInt(year) - 1); startDate = year + "12"; } else { startDate = year + String.valueOf(Integer.parseInt(month) - 1); } int count = billingApplyDao.getCountFromMonthCustM(name, amt, startDate, date); int count2 = billingApplyDao.getCountFromDesperse(name, amt, startDate, date); if (count >= 1 || count2 >= 1) { result = true; } return result; } /** * 2017年2月28日 80001092 方法说明:标识作废遗失发票导出 * @param bean * void */ public void exportMarkList(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); Map<String, Object> map = new HashMap<String, Object>(); List<String[]> excel = new ArrayList<String[]>(); final String[] cellsTitle = {"应收所属起始时间","应收所属结束时间","发票代码","发票号码","月结账号名称", "关联账号名称","净值","税金","发票状态","待作废标识","遗失标识"}; final Map<Integer, String> header = new HashMap<Integer, String>(); //报表头部 header.put(cellsTitle.length, "标识作废遗失发票"); String[] cells = null; List<Map<String, Object>> list = null; list = billingApplyDao.getMarkedCancleList(paramMap, 0, Integer.MAX_VALUE); for (Map<String, Object> data : list) { cells = new String[cellsTitle.length]; int i = 0; cells[i++] = getData(data, "BEGIN_PERIOD"); cells[i++] = getData(data, "END_PERIOD"); cells[i++] = getData(data, "ZINV_CODE"); cells[i++] = getData(data, "ZINV_NUMBER"); cells[i++] = getData(data, "Z_CDH_NAME"); cells[i++] = getData(data, "SUB_Z_CDH_NAME"); cells[i++] = getData(data, "NETWR"); cells[i++] = getData(data, "TAXAMT"); cells[i++] = getData(data, "BILL_SETUP_DES"); cells[i++] = getData(data, "CANCLE_FLAG"); cells[i++] = getData(data, "LOSE_FLAG"); excel.add(cells); } map.put("orgCode", "sheet1"); map.put("data", excel); map.put("header", header); //统计头部 map.put("cellsTitle", cellsTitle); map.put("fileName", "标识作废遗失发票_" + DateUtils.formatDate(new Date(), "yyyy-MM-dd")); bean.getExpData().put("excelData", map); } private String getData(Map<String, Object> data, String key) { return data.get(key) == null ? "" : data.get(key).toString(); } /** * 2017年3月29日 80001092 方法说明:关联方导出 * @param bean * void */ public void export(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); paramMap.put("billTaxPaySub", StringUtil.addDimmer(paramMap.get("BILL_TAX_PAY_SUB"), ",", "'")); paramMap.put("invTaxPaySub", StringUtil.addDimmer(paramMap.get("INV_TAX_PAY_SUB"), ",", "'")); paramMap.put("billPrctr", StringUtil.addDimmer(paramMap.get("BILL_PRCTR"), ",", "'")); paramMap.put("zCustomerNo", StringUtil.addDimmer(paramMap.get("Z_CUSTOMER_NO"), ",", "'")); paramMap.put("businessType", StringUtil.addDimmer(paramMap.get("BUSINESS_TYPE"), ",", "'")); paramMap.put("billBukrs", StringUtil.addDimmer(paramMap.get("ORG_BUKRS"), ",", "'")); Map<String, Object> map = new HashMap<String, Object>(); List<String[]> excel = new ArrayList<String[]>(); final String[] cellsTitle = {"业务类型","所属时间","业务开票主体","实际开票主体","实际收票主体", "业务收票放账套号","发票类型","税号","地址&电话","开户行&账号","开票金额"}; final Map<Integer, String> header = new HashMap<Integer, String>(); //报表头部 header.put(cellsTitle.length, "关联方开票信息导出"); String[] cells = null; List<Map<String, Object>> list = billingApplyDao.getRelatedBillList(paramMap, 0, Integer.MAX_VALUE); for (Map<String, Object> data : list) { cells = new String[cellsTitle.length]; int i = 0; cells[i++] = getData(data, "BUSINESS_TYPE"); cells[i++] = getData(data, "BELONG_DATE"); cells[i++] = getData(data, "ORG_TAX_PAY_NAME"); cells[i++] = getData(data, "BILL_TAX_PAY_NAME"); cells[i++] = getData(data, "TAX_PAY_NAME"); cells[i++] = getData(data, "Z_CUSTOMER_NO"); cells[i++] = getData(data, "ZTAXTYPE"); if (BillingApplyConstants.INV_TYPE_SPECIAL.equals(cells[i-1])) { cells[i-1] = "专票"; } if (BillingApplyConstants.INV_TYPE_COMMON.equals(cells[i-1])) { cells[i-1] = "普票"; } cells[i++] = getData(data, "TAXPAYER_ID_NAT"); cells[i++] = getData(data, "ADDR_TEL"); cells[i++] = getData(data, "BANK_ACCOUNT"); cells[i++] = getData(data, "WRBTR"); excel.add(cells); } map.put("orgCode", "sheet1"); map.put("data", excel); map.put("header", header); //统计头部 map.put("cellsTitle", cellsTitle); map.put("fileName", "关联方开票信息_" + DateUtils.formatDate(new Date(), "yyyy-MM-dd")); bean.getExpData().put("excelData", map); } /** * 2017年4月7日 80001092 方法说明:还原未开票金额 * @param bean * void */ @Transactional public void addNewApply(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String[] ids = paramMap.get("ids").split(",",-1); if (StringUtil.areBlank(ids) || ids.length < 1) { throw new ServiceException("获取待还原数据失败"); } String empCode = UserUtil.getCurrentUser().getEmpCode(); Map<String, Object> hAndIMap; try { for (int i=0; i<ids.length; i++) { hAndIMap = billingApplyDao.getHeaderById(ids[i]); hAndIMap.put(empCode, empCode); hAndIMap.put("ZBILL_NO", new SimpleDateFormat("ddHHmmssSSS").format( new Date()) + new Double(Math.floor(Math.random()*10)).intValue()); billingApplyDao.addHeader(hAndIMap); billingApplyDao.addItem(hAndIMap); billingApplyDao.updateHeader(ids[i]); } } catch (Exception e) { throw new ServiceException("还原数据时出错"); } } /** * 2017年4月12日 80001092 方法说明:删除选择行 * @param bean * void */ @Transactional public void deleteImport(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String selectAllFlag = paramMap.get("selectAllFlag"); String idsString = paramMap.get("ids"); if(StringUtil.areBlank(idsString) && !"checked".equals(selectAllFlag)) { throw new ServiceException("请选择需要提交的记录"); } String ids = StringUtil.addDimmer(idsString, ",", "'"); if ("checked".equals(selectAllFlag)) { // 全选 ids = ""; } paramMap.put("ids", ids); paramMap.put("empCode", UserUtil.getCurrentUser().getEmpCode()); billingApplyDao.deleteImport(paramMap); } /** * 2017年4月12日 80001092 方法说明:确认作废红冲 * @param bean * void */ @Transactional public void confirmInv(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String selectAllFlag = paramMap.get("selectAllFlag"); String idsString = paramMap.get("ids"); if(StringUtil.areBlank(idsString) && !"checked".equals(selectAllFlag)) { throw new ServiceException("请选择需要确认的记录"); } String HC_UNTAX_AMT = paramMap.get("HC_UNTAX_AMT"); String HC_TAX_AMT = paramMap.get("HC_TAX_AMT"); String ZF_UNTAX_AMT = paramMap.get("ZF_UNTAX_AMT"); String ZF_TAX_AMT = paramMap.get("ZF_TAX_AMT"); BigDecimal hcTotal = new BigDecimal(HC_UNTAX_AMT).add(new BigDecimal(HC_TAX_AMT)).abs(); BigDecimal zfTotal = new BigDecimal(ZF_UNTAX_AMT).add(new BigDecimal(ZF_TAX_AMT)).abs(); BigDecimal hcImp = new BigDecimal(0); BigDecimal zfImp = new BigDecimal(0); String currentEmpCode = UserUtil.getCurrentUser().getEmpCode(); String ids = StringUtil.addDimmer(idsString, ",", "'"); if ("checked".equals(selectAllFlag)) { // 全选 ids = ""; } paramMap.put("ids", ids); paramMap.put("empCode", currentEmpCode); // 加上日期限制,否则越来越大 List<Map<String, Object>> conList = billingApplyDao.getConfirmList(paramMap); Map<String, Object> entryMap = null; try { for (int i=0; i<conList.size(); i++) { entryMap = conList.get(i); if (BillingApplyConstants.INV_TYPE_MINUS_CHN.equals(String.valueOf(entryMap.get("INV_TYPE")))) { hcImp = hcImp.add(new BigDecimal(String.valueOf(entryMap.get("TOTALAMT")))); } else if (BillingApplyConstants.INV_TYPE_INVALID_CHN.equals(String.valueOf(entryMap.get("INV_TYPE")))) { zfImp = zfImp.add(new BigDecimal(String.valueOf(entryMap.get("TOTALAMT")))); } } if (hcTotal.compareTo(hcImp.abs()) != 0 || zfTotal.compareTo(zfImp.abs()) != 0) { throw new ServiceException("输入的总金额与需要确认的总金额不相等"); } for (int i=0; i<conList.size(); i++) { entryMap = conList.get(i); if (BillingApplyConstants.INV_TARGET_E.equals(String.valueOf(entryMap.get("TARGET")))) { // 更新实物发票,BILL_STATUS置为”已红冲“ billingApplyDao.updateBillListStatus(String.valueOf(entryMap.get("LIST_ID")), String.valueOf(entryMap.get("INV_TYPE")), currentEmpCode); updateBillSumAMT(String.valueOf(entryMap.get("ZDEINVID")), String.valueOf(entryMap.get("KUNNR")), String.valueOf(entryMap.get("ZTAXTYPE")), Double.parseDouble(String.valueOf(entryMap.get("TOTALAMT")))); // 方法2 使用BidDecimal精确计算,暂未启用 // updateBillSumAMT2(ZDEINVID, KUNNR, ZTAXTYPE, tempUntax, tempTax); } else if (BillingApplyConstants.INV_TARGET_S.equals(String.valueOf(entryMap.get("TARGET")))) { // 更新实物发票,BILL_STATUS置为”已红冲“ billingApplyDao.updateBillListStatus(String.valueOf(entryMap.get("LIST_ID")), String.valueOf(entryMap.get("INV_TYPE")), currentEmpCode); } else if (BillingApplyConstants.INV_TARGET_I.equals(String.valueOf(entryMap.get("TARGET")))) { //关联方 if (BillingApplyConstants.INV_REPALCE.equals(String.valueOf(entryMap.get("LIST_BILL_STATUS")))) { // 如果是负数 if (BillingApplyConstants.INV_TYPE_MINUS_CHN.equals(String.valueOf(entryMap.get("INV_TYPE")))) { billingApplyDao.updateBillListStatus2(String.valueOf(entryMap.get("OP_ZINV_CODE")), String.valueOf(entryMap.get("OP_ZINV_NUMBER")), String.valueOf(entryMap.get("INV_TYPE")), currentEmpCode); } // 如果是作废 if (BillingApplyConstants.INV_TYPE_INVALID_CHN.equals(String.valueOf(entryMap.get("INV_TYPE")))) { billingApplyDao.updateBillListStatus2(String.valueOf(entryMap.get("ZINV_CODE")), String.valueOf(entryMap.get("ZINV_NUMBER")), String.valueOf(entryMap.get("INV_TYPE")), currentEmpCode); } } } billingApplyDao.confirmInv(entryMap.get("ID").toString(), currentEmpCode); } entryMap = null; } catch (Exception e) { throw new ServiceException("数据还原失败,请联系系统管理员"); } } /** * 2017年4月14日 80001092 方法说明:发票状态查询报表 * @param bean * void */ public void queryAllBillStatus(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); /*String startDate = paramMap.get("startDate"); if (StringUtil.areNotBlank(startDate)) { startDate = startDate + "-01"; } paramMap.put("startDate", startDate);*/ String custType = paramMap.get(CUSTTYPE); paramMap.put("empCode", UserUtil.getCurrentUser().getEmpCode()); if(INV_TYPE_E_I.equals(custType)){ bean.getExpData().put("page", PageHandler.execute(new PageSplit<Map<String, Object>>() { @Override public int queryTotalCount() { return billingApplyDao.getAllBillStatusTotalCount(paramMap); } @Override public List<Map<String, Object>> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getAllBillStatus(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } else { bean.getExpData().put("page", PageHandler.execute(new PageSplit<Map<String, Object>>() { @Override public int queryTotalCount() { return billingApplyDao.getAllSingleBillStatusTotalCount(paramMap); } @Override public List<Map<String, Object>> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getAllSingleBillStatus(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } } /** * 2017年4月19日 80001092 方法说明:导出 * @param bean * void */ public void exportBillAllStatus(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String startDate = paramMap.get("startDate"); if (StringUtil.areNotBlank(startDate)) { startDate = startDate + "-01"; } paramMap.put("startDate", startDate); paramMap.put("empCode", UserUtil.getCurrentUser().getEmpCode()); Map<String, Object> map = new HashMap<String, Object>(); List<String[]> excel = new ArrayList<String[]>(); final String[] cellsTitle = {"网点","申请人","月结账号","纳税人识别号","开户行", "地址电话","名称","业务类型", "所属账期","应收金额","申请金额","差异金额","申请日期","开票人","开票日期", "发票状态","发票类型","寄送状态","运单号码","收件人","签收状态","发票批", "发票批次号"}; final Map<Integer, String> header = new HashMap<Integer, String>(); //报表头部 header.put(cellsTitle.length, "发票状态查询导出"); String[] cells = null; List<Map<String, Object>> list = null; String custType = paramMap.get(CUSTTYPE); if(INV_TYPE_E_I.equals(custType)){ list = billingApplyDao.getAllBillStatus(paramMap, 0, Integer.MAX_VALUE); }else{ list = billingApplyDao.getAllSingleBillStatus(paramMap, 0, Integer.MAX_VALUE); } for (Map<String, Object> data : list) { cells = new String[cellsTitle.length]; int i = 0; cells[i++] = getData(data, "A_BILL_PRCTR"); cells[i++] = getData(data, "CREATE_ID"); cells[i++] = getData(data, "KUNNR"); cells[i++] = getData(data, "BILL_TAX_ID"); cells[i++] = getData(data, "nameAndAcco"); cells[i++] = getData(data, "addAndTel"); cells[i++] = getData(data, "INV_TAX_NAME"); cells[i++] = getData(data, "BUSINESS_DESC"); cells[i++] = getData(data, "PERIOD"); cells[i++] = getData(data, "TSL"); cells[i++] = getData(data, "TAXSUM"); cells[i++] = getData(data, "DIFF_TSL"); cells[i++] = getData(data, "CREATE_TIME"); cells[i++] = getData(data, "BILL_CLARK"); cells[i++] = getData(data, "BILL_DATE"); cells[i++] = getData(data, "BILL_SETUP_DES"); cells[i++] = getData(data, "ZTAXTYPE"); cells[i++] = getData(data, "POST_STATUS"); cells[i++] = getData(data, "WAYBILL_NO"); cells[i++] = getData(data, "RECEIVER"); cells[i++] = getData(data, "RECV_STATUS"); cells[i++] = getData(data, "ZDEINVID"); cells[i++] = getData(data, "ZDEINVID_XH"); excel.add(cells); } map.put("orgCode", "sheet1"); map.put("data", excel); map.put("header", header); //统计头部 map.put("cellsTitle", cellsTitle); map.put("fileName", "发票状态查询_" + DateUtils.formatDate(new Date(), "yyyy-MM-dd")); bean.getExpData().put("excelData", map); } /** * 2017年4月25日 80001092 方法说明:发票明细查询报表 * @param bean * void */ public void queryInvDetailReport(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); paramMap.put("empCode", UserUtil.getCurrentUser().getEmpCode()); bean.getExpData().put("page", PageHandler.execute(new PageSplit<Map<String, Object>>() { @Override public int queryTotalCount() { return billingApplyDao.getInvDetailTotalCount(paramMap); } @Override public List<Map<String, Object>> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getInvDetail(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } /** * 2017年4月25日 80001092 方法说明:export * @param bean * void */ public void exportInvDetail(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); paramMap.put("empCode", UserUtil.getCurrentUser().getEmpCode()); Map<String, Object> map = new HashMap<String, Object>(); List<String[]> excel = new ArrayList<String[]>(); final String[] cellsTitle = {"发票代码","发票号码","名称","发票类型", "发票金额","发票状态","运单号码","收件人","发票批","商品名称","税额", "税率","开票日期"}; final Map<Integer, String> header = new HashMap<Integer, String>(); //报表头部 header.put(cellsTitle.length, "发票明细查询导出"); String[] cells = null; List<Map<String, Object>> list = null; list = billingApplyDao.getInvDetail(paramMap, 0, Integer.MAX_VALUE); for (Map<String, Object> data : list) { cells = new String[cellsTitle.length]; int i = 0; cells[i++] = getData(data, "ZINV_CODE"); cells[i++] = getData(data, "ZINV_NUMBER"); cells[i++] = getData(data, "INV_TAX_NAME"); cells[i++] = getData(data, "ZTAXTYPE"); cells[i++] = getData(data, "NETWR"); cells[i++] = getData(data, "BILL_SETUP_DES"); cells[i++] = getData(data, "WAYBILL_NO"); cells[i++] = getData(data, "RECEIVER"); cells[i++] = getData(data, "ZDEINVID"); cells[i++] = getData(data, "MAKTX"); cells[i++] = getData(data, "TAXAMT"); cells[i++] = getData(data, "TAXRATE"); cells[i++] = getData(data, "IVDATE"); excel.add(cells); } map.put("orgCode", "sheet1"); map.put("data", excel); map.put("header", header); //统计头部 map.put("cellsTitle", cellsTitle); map.put("fileName", "发票明细查询_" + DateUtils.formatDate(new Date(), "yyyy-MM-dd")); bean.getExpData().put("excelData", map); } /** * 2017年5月5日 80001092 方法说明:月结开票导出 * @param bean * void */ public void exportOuterCust(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String searchType = paramMap.get("searchType"); if("reBillSearch".equals(searchType)) { throw new ServiceException("补开查询结果不能导出"); } paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); paramMap.put("billTaxPaySub", StringUtil.addDimmer(paramMap.get("BILL_TAX_PAY_SUB"), ",", "'")); paramMap.put("billPrctr", StringUtil.addDimmer(paramMap.get("BILL_PRCTR"), ",", "'")); paramMap.put("zCustomerNo", StringUtil.addDimmer(paramMap.get("Z_CUSTOMER_NO"), ",", "'")); paramMap.put("businessType", StringUtil.addDimmer(paramMap.get("BUSINESS_TYPE"), ",", "'")); paramMap.put("billBukrs", StringUtil.addDimmer(paramMap.get("BILL_BUKRS"), ",", "'")); paramMap.put("ZZPERSR", StringUtil.addDimmer(paramMap.get("ZZPERSR"), ",", "'")); Map<String, Object> map = new HashMap<String, Object>(); List<String[]> excel = new ArrayList<String[]>(); final String[] cellsTitle = {"业务号","序号","月结账号","月结账号名称","所属期间","结算网点编码", "业务类型","发票类型","应收金额","未开票金额","开票金额","差异原因","票面备注","纳税人识别号", "地址及电话","开户行及账号","货物或应税劳务名称","单位","单价","数量","规格","申请人员备注", "驳回原因","企业名片代码","是否直寄"}; final Map<Integer, String> header = new HashMap<Integer, String>(); //报表头部 header.put(cellsTitle.length, "月结客户开票信息导出"); String[] cells = null; boolean subFlag = false; Map<String, String> idMap = new HashMap<String, String >(); List<Map<String, Object>> list = billingApplyDao.getBillListExport(paramMap); for (Map<String, Object> data : list) { cells = new String[cellsTitle.length]; int i = 0; cells[i++] = getData(data, "ID"); if (idMap.get(cells[0]) != null) { subFlag = true; } cells[i++] = getData(data, "SUB_XH"); cells[i++] = getData(data, "Z_CUSTOMER_NO"); cells[i++] = getData(data, "Z_CDH_NAME"); cells[i++] = getData(data, "BELONG_DATE"); cells[i++] = getData(data, "BILL_PRCTR"); cells[i++] = getData(data, "BUSINESS_TYPE"); cells[i++] = getData(data, "INVOICE_TYPE"); if (BillingApplyConstants.INV_TYPE_SPECIAL.equals(cells[i-1])) { cells[i-1] = "专票"; } if (BillingApplyConstants.INV_TYPE_COMMON.equals(cells[i-1])) { cells[i-1] = "普票"; } if (subFlag) { cells[i++] = ""; cells[i++] = ""; cells[i++] = ""; } else { cells[i++] = getData(data, "WRBTR"); cells[i++] = getData(data, "TSL_MONTH_UNBILL"); cells[i++] = getData(data, "TSL_MONTH_UNBILL"); } cells[i++] = getData(data, "DIFF_REASON"); cells[i++] = getData(data, "TICKETS_BACK"); cells[i++] = getData(data, "Z_TAX_ID"); cells[i++] = getData(data, "ADDR_TEL"); cells[i++] = getData(data, "BANK_ACCOUNT"); cells[i++] = getData(data, "MAKTX"); cells[i++] = getData(data, "MEINS"); cells[i++] = getData(data, "UNITPE"); cells[i++] = getData(data, "FKIMG"); cells[i++] = getData(data, "MSPEC"); cells[i++] = getData(data, "applierBack"); cells[i++] = getData(data, "REJECT_REASON"); cells[i++] = getData(data, "NAMECARD_ID"); cells[i] = getData(data, "IS_POST"); if ("X".equals(cells[i])) { cells[i] = "是"; } else { cells[i] = "否"; } subFlag = false; idMap.put(cells[0], cells[0]); excel.add(cells); } map.put("orgCode", "sheet1"); map.put("data", excel); map.put("header", header); //统计头部 map.put("cellsTitle", cellsTitle); map.put("fileName", "月结开票信息_" + DateUtils.formatDate(new Date(), "yyyy-MM-dd")); bean.getExpData().put("excelData", map); } /** * 2017年5月9日 80001092 方法说明:月结开票信息导入 * @param bean * void */ @Transactional public void importMonthCust(BeanBase bean) { try { new AbstractExcelReader() { @Override public void doParse(Workbook workbook) { checkImpt(workbook, bean); } }.Reader();; } catch (Exception e) { String errorMsg = "EXCEL上传失败:<br>"; String errMsgDinamic = e.getMessage(); if (StringUtil.areNotBlank(errMsgDinamic)) { errorMsg += errMsgDinamic; } else { errorMsg += "请确保最后一行数据之后没有空白数据"; } logger.error(errorMsg, e); if (e instanceof DuplicateKeyException) { throw new ServiceException("导入的Excel存在重复的数据,去掉重复数据后在导入"); } else { throw new ServiceException(errorMsg); } } bean.setStatus(BusinessStatus.FINLISH); bean.setProcessMsg("导入完成!"); } /** * 2017年5月9日 80001092 方法说明:校验上传数据 * @param workbook * @param bean * void */ /** * 2017年5月11日 80001092 方法说明: * @param workBook * @param bean * void */ /** * 2017年5月11日 80001092 方法说明: * @param workBook * @param bean * void */ private void checkImpt(Workbook workBook, BeanBase bean) { List<Map<String, String>> excelValueList = null; // 待导入的数据 int import_wb_sheetNos = workBook.getNumberOfSheets(); if (import_wb_sheetNos == 0) { throw new ServiceException("待导入的数据为空"); } excelValueList = new ArrayList<>(); Cell cell = null; String ID = null; String SUB_XH = null; String Z_CUSTOMER_NO = null; String Z_CDH_NAME = null; String BELONG_DATE = null; String BILL_PRCTR = null; String INVOICE_TYPE = null; String BUSINESS_TYPE = null; String Z_TAX_ID = null; String IS_POST = null; String ADDR_TEL = null; String BANK_ACCOUNT = null; String MAKTX = null; String WRBTR = null; String MEINS = null; String UNITPE = null; String FKIMG = null; String MSPEC = null; String NETWR = null; String TAXRATE = null; String TAXAMT = null; String REJECT_REASON = null; String NAMECARD_ID = null; String TSL_MONTH_UNBILL = null; String TSK_MONTH_BILL = null; String DIFF_REASON = null; String TICKETS_BACK = null; String applierBack = null; Sheet sheet = workBook.getSheetAt(0); Map<String, String> map = null; Map<String, String> idMap = new HashMap<String, String>(); for(int line=2, count=sheet.getLastRowNum()+1; line<count; line++) { Row row = sheet.getRow(line); int j = 0; cell = row.getCell(j++); ID = getCellValue(cell); cell = row.getCell(j++); SUB_XH = getCellValue(cell); cell = row.getCell(j++); Z_CUSTOMER_NO = getCellValue(cell); if (StringUtil.areBlank(ID, SUB_XH, Z_CUSTOMER_NO)) { continue; } if (StringUtil.areBlank(ID)) { throw new ServiceException("业务号不允许为空"); } if (StringUtil.areBlank(SUB_XH)) { throw new ServiceException("序号不允许为空"); } if (idMap.get(ID + SUB_XH) == null) { idMap.put(ID + SUB_XH, ID); } else { throw new ServiceException("业务号" + ID + "序号" + SUB_XH+ "出现重复,不能上传"); } // 校验ID是否存在 if (checkIfExcits(ID, SUB_XH) < 1) { throw new ServiceException("业务号" + ID + "序号" + SUB_XH + "在系统中不存在,这两列数据不允许修改值,要维持导出原值"); } cell = row.getCell(j++); Z_CDH_NAME = getCellValue(cell); cell = row.getCell(j++); BELONG_DATE = XslUtil.getCellString(cell); cell = row.getCell(j++); BILL_PRCTR = getCellValue(cell); cell = row.getCell(j++); BUSINESS_TYPE = getCellValue(cell); cell = row.getCell(j++); INVOICE_TYPE = getCellValue(cell); if (BillingApplyConstants.INV_TYPE_SPECIAL_NAME.equals(INVOICE_TYPE)) { INVOICE_TYPE = BillingApplyConstants.INV_TYPE_SPECIAL; } else if (BillingApplyConstants.INV_TYPE_COMMON_NAME.equals(INVOICE_TYPE)) { INVOICE_TYPE = BillingApplyConstants.INV_TYPE_COMMON; } cell = row.getCell(j++); WRBTR = getCellValue(cell); cell = row.getCell(j++); TSL_MONTH_UNBILL = getCellValue(cell); cell = row.getCell(j++); TSK_MONTH_BILL = getCellValue(cell); if (StringUtil.areBlank(TSK_MONTH_BILL)) { throw new ServiceException("开票金额不能为空,不开票请填0或删除该行"); } cell = row.getCell(j++); DIFF_REASON = getCellValue(cell); try { if (StringUtil.areNotBlank(Z_CUSTOMER_NO) && Double.parseDouble(TSK_MONTH_BILL) - Double.parseDouble(TSL_MONTH_UNBILL) > 0) { if (StringUtil.areBlank(DIFF_REASON)) { throw new ServiceException("开票金额大于未开票金额必须输入差异原因"); } } } catch (Exception e) { throw new ServiceException("开票金额不是正确的数值,不开票请填0"); } if (StringUtil.areNotBlank(DIFF_REASON)) { switch(DIFF_REASON) { case "账单金额或应收金额需调整": break; case "运单挂错月结号": break; case "退换票": break; case "理赔": break; default : throw new ServiceException("差异原因请输入:账单金额或应收金额需调整、运单挂错月结号、退换票、理赔中的一个"); } } cell = row.getCell(j++); TICKETS_BACK = getCellValue(cell); cell = row.getCell(j++); Z_TAX_ID = getCellValue(cell); if(!TaxPayUtil.check(Z_TAX_ID)){ throw new ServiceException(ERR_TAX_PAY_ID_FORMAT); } cell = row.getCell(j++); ADDR_TEL = getCellValue(cell); cell = row.getCell(j++); BANK_ACCOUNT = getCellValue(cell); cell = row.getCell(j++); MAKTX = getCellValue(cell); cell = row.getCell(j++); MEINS = getCellValue(cell); cell = row.getCell(j++); UNITPE = getCellValue(cell); cell = row.getCell(j++); FKIMG = getCellValue(cell); cell = row.getCell(j++); MSPEC = getCellValue(cell); cell = row.getCell(j++); applierBack = getCellValue(cell); cell = row.getCell(j++); REJECT_REASON = getCellValue(cell); cell = row.getCell(j++); NAMECARD_ID = getCellValue(cell); cell = row.getCell(j++); IS_POST = getCellValue(cell); if ("是".equals(IS_POST)) { IS_POST = "X"; } else { IS_POST = ""; } map = new HashMap<String, String>(); map.put("ID", ID); map.put("SUB_XH", SUB_XH); map.put("Z_CUSTOMER_NO", Z_CUSTOMER_NO); map.put("Z_CDH_NAME", Z_CDH_NAME); map.put("BELONG_DATE", BELONG_DATE); map.put("BILL_PRCTR", BILL_PRCTR); map.put("INVOICE_TYPE", INVOICE_TYPE); map.put("BUSINESS_TYPE", BUSINESS_TYPE); map.put("Z_TAX_ID", Z_TAX_ID); map.put("IS_POST", IS_POST); map.put("ADDR_TEL", ADDR_TEL); map.put("BANK_ACCOUNT", BANK_ACCOUNT); map.put("MAKTX", MAKTX); map.put("WRBTR", WRBTR); map.put("MEINS", MEINS); map.put("UNITPE", UNITPE); map.put("FKIMG", FKIMG); map.put("MSPEC", MSPEC); map.put("NETWR", NETWR); map.put("TAXRATE", TAXRATE); map.put("TAXAMT", TAXAMT); map.put("REJECT_REASON", REJECT_REASON); map.put("NAMECARD_ID", NAMECARD_ID); map.put("TSL_MONTH_UNBILL", TSL_MONTH_UNBILL); map.put("TSK_MONTH_BILL", TSK_MONTH_BILL); map.put("DIFF_REASON", DIFF_REASON); map.put("TICKETS_BACK", TICKETS_BACK); map.put("applierBack", applierBack); excelValueList.add(map); } bean.getExpData().put("page", excelValueList); } /** * 2017年5月10日 80001092 方法说明:导入创建发票批 * @param bean * void */ @SuppressWarnings("unchecked") @Transactional public void impCreateBatch(BeanBase bean) { Map<String, String> paramMap = bean.getDatas().get(0); String impData = paramMap.get("IMPDATA"); List<Map<String, String>> listData = (List<Map<String, String>>) JSON.parse(impData); String kp_flag = null; String ID = null; String subXH = null; Map<String, String> batchMap = new HashMap<String, String>(); Map<String, Integer> batchXhMap = new HashMap<String, Integer>(); // 导出的excel如果在主账号和子账号之间插入其他月结账号行或调整顺序,开票结果可能会出现错误; for (Map<String, String> map : listData) { ID = map.get("ID"); subXH = map.get("SUB_XH"); kp_flag = billingApplyDao.getKPFlag(ID); if ("01".equals(kp_flag) || !"0".equals(subXH)) { if ("0".equals(subXH)) { //发票批次号 String ZDEINVID = new SimpleDateFormat("yyMMddHHmmssSSS").format(new Date()) + new Double(Math.floor(Math.random()*10)).intValue(); batchMap.put(ID, ZDEINVID); Map<String, Object> mapInfo = getBatchInfoById(ID); String nextSetp = queryNextStep("20"); mapInfo.put("currentStep", queryCurrentStepFromStep(mapInfo.get("BILL_PRCTR").toString(), BillingApplyConstants.INV_TARGET_OUTER)); mapInfo.put("nextSetp", nextSetp); mapInfo.put("ZDEINVID", ZDEINVID); mapInfo.put("ZDEINVID_XH", '1'); mapInfo.put("INV_TARGET", BillingApplyConstants.INV_TARGET_E); //外部 mapInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); mapInfo.put("billAMT", map.get("TSK_MONTH_BILL")); mapInfo.put("TAXSUM", map.get("TSK_MONTH_BILL")); mapInfo.put("DIFF_REASON", valTrans(map.get("DIFF_REASON"))); mapInfo.put("TICKETS_BACK", map.get("TICKETS_BACK")); mapInfo.put("APPLIER_BACK", map.get("applierBack")); mapInfo.put("BEGIN_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); mapInfo.put("END_PERIOD", mapInfo.get("GJAHR").toString() + mapInfo.get("MONAT").toString()); mapInfo.put("MEINS", map.get("MEINS")); mapInfo.put("UNITPE", map.get("UNITPE")); mapInfo.put("FKIMG", map.get("FKIMG")); mapInfo.put("MSPEC", map.get("MSPEC")); billingApplyDao.createMainAccountBatch(mapInfo); if(0 != Double.parseDouble(map.get("TSK_MONTH_BILL"))) { //insert into p2_ztax_form_bill 主账号 billingApplyDao.createFormBill(mapInfo); // update p2_ztax_bill_sum 应开扣减,已开增加 billingApplyDao.updateBillSum(mapInfo); } // update p2_tax_bill_item billingApplyDao.updateBillItemBatchId(mapInfo.get("ZBILL_NO").toString(), ZDEINVID); // update p2_ztax_bill_header billingApplyDao.updateBatchId("'" + ID + "'", ZDEINVID); // 流转日志 Map<String, Object> flowLogMap = billingApplyDao.getModuleConfig("TAX_10_02"); billingApplyDao.insertBatchFlowLog(mapInfo, flowLogMap); } else { // 开票金额为0,不创建 // 判断是否有主账号 if (batchMap.get(ID) == null) { throw new ServiceException("业务号" + ID + "月结客户" + map.get("Z_CUSTOMER_NO") + "的主账号不能删除,与子账号一同上传,并且主账号在前,如主账号不开票,金额填0"); } Map<String, Object> mapSubInfo = getSubAccountInfo(ID, subXH); if(StringUtils.isBlank(map.get("TSK_MONTH_BILL")) || 0 == Double.parseDouble(map.get("TSK_MONTH_BILL"))) { continue; } if (batchXhMap.get(batchMap.get(ID)) == null) { batchXhMap.put(batchMap.get(ID), 2); } else { batchXhMap.put(batchMap.get(ID), batchXhMap.get(batchMap.get(ID)) + 1); } mapSubInfo.put("ZDEINVID", batchMap.get(ID)); mapSubInfo.put("ZDEINVID_XH", batchXhMap.get(batchMap.get(ID))); mapSubInfo.put("SUB_TSK_MONTH_BILL", map.get("TSK_MONTH_BILL")); mapSubInfo.put("SUB_DIFF_REASON", valTrans(map.get("DIFF_REASON"))); mapSubInfo.put("SUB_TICKETS_BACK", map.get("TICKETS_BACK")); mapSubInfo.put("sub_applierBack", map.get("applierBack")); mapSubInfo.put("subId", subXH); mapSubInfo.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); mapSubInfo.put("MEINS", map.get("MEINS")); mapSubInfo.put("UNITPE", map.get("UNITPE")); mapSubInfo.put("FKIMG", map.get("FKIMG")); mapSubInfo.put("MSPEC", map.get("MSPEC")); billingApplyDao.createFormBillSubAccount(mapSubInfo); Map<String, Object> mapInfo = getBatchInfoById(ID); mapInfo.put("billAMT", map.get("TSK_MONTH_BILL")); billingApplyDao.updateBillSum(mapInfo); billingApplyDao.updateBatchNET(mapSubInfo); } } else { throw new ServiceException("业务号" + ID + "月结客户" + map.get("Z_CUSTOMER_NO") + "已经提交过,删除该业务号的所有行在上传"); } } } private String valTrans(String DIFF_REASON) { // 常量后续定义 if ("账单金额或应收金额需调整".equals(DIFF_REASON)) { DIFF_REASON = "A"; } else if ("运单挂错月结号".equals(DIFF_REASON)) { DIFF_REASON = "B"; } else if ("退换票".equals(DIFF_REASON)) { DIFF_REASON = "C"; } else if ("理赔".equals(DIFF_REASON)) { DIFF_REASON = "E"; } else { DIFF_REASON = ""; } return DIFF_REASON; } /** * 2017年5月11日 80001092 方法说明:是否存在 * @param id * @param sUB_XH * @return * int */ private int checkIfExcits(String id, String sUB_XH) { return billingApplyDao.getCountHeader(id, sUB_XH); } }
相关推荐
在jqGrid应用中,Model代表数据模型,View是用户界面,Controller负责协调Model和View之间的交互。 接下来,dialog组件是jQuery UI的一部分,它允许创建可定制的对话框,通常用于显示额外的信息或执行特殊操作。在...
### MVC + Jqgrid + 存储过程应用详解 在本篇内容中,我们将深入探讨一个结合了MVC架构、JqGrid插件以及SQL Server存储过程的应用案例。该案例展示了如何在一个MVC项目中利用JqGrid进行数据展示,并通过存储过程...
通过以上步骤,我们可以构建一个基础的JQGrid应用,包括JSON数据的加载、增删改查操作、下拉框和文本框的使用等。随着对JQGrid的深入学习,我们可以进一步定制样式、优化性能,甚至实现更复杂的功能,比如分组、排序...
6. **sample_project**:示例项目文件夹,包含一个完整的JqGrid应用实例,供开发者参考和学习。 7. **js**:JavaScript库和JqGrid相关的脚本文件,包括JqGrid的核心脚本和其他辅助脚本。 综上所述,JqGrid for ASP...
jqGrid是一款功能强大的JavaScript数据网格插件,常用于在网页上展示、操作和管理大量结构化数据。它基于jQuery库,提供了丰富...无论是在Ubuntu还是Windows环境下,开发者都可以参考这个示例来搭建自己的jqGrid应用。
通过正确加载语言文件、配置初始化选项以及可能的自定义翻译,我们可以创建一个能适应多种语言环境的JqGrid应用。这不仅提高了用户体验,也增强了应用的全球化适应性。在实际开发中,可以根据项目需求调整和扩展这些...
总之,这个压缩包提供了一个基础的jqGrid应用实例,适合初学者学习和理解如何在HTML5环境中集成和使用jqGrid。通过研究和修改这个示例,你可以掌握如何动态加载数据、实现搜索和排序功能,以及如何定制和美化表格。...
在"jqGrid实例demo"中,我们可以看到一个实际的jqGrid应用示例,帮助我们理解和学习如何在项目中运用这个工具。 1. **安装与引入** 在开始使用jqGrid前,我们需要下载jqGrid的JavaScript和CSS文件,并将其引入到...
在实际应用中,以XML数据获取方式为例,开发者需要配置后台页面(如XMLData.aspx)并确保其返回数据格式与xmlReader要求的格式匹配。xmlReader的配置项包括字段映射、页码、数据总条数、记录数等关键信息。 以上...
通过上述步骤,我们不仅完成了开发环境的搭建,还构建了一个基本的jqGrid应用示例。这些内容覆盖了从环境配置到具体项目实施的全过程,对于初学者来说是非常有价值的参考资料。同时,也提醒开发人员在实际项目中遵循...
首先,我们来看一下S1SH中jqGrid应用的基本步骤: 1. **Action层控制**:当用户发起请求时,Action层接收请求并处理。在提供的代码示例中,`query`方法被调用,返回一个ActionForward对象,指定要跳转的页面。例如...
在"jqGrid表格应用——新增与删除数据"这个主题中,我们可以探讨以下知识点: 1. **jqGrid的基本结构**:jqGrid的HTML结构通常包括一个`<table>`元素,以及必要的CSS和JavaScript引用。例如,`index.html`可能包含`...
JqGrid是一款强大的JavaScript表格插件,用于在Web应用程序中展示和操作数据。它基于jQuery库,提供了丰富的功能,如数据排序、筛选、分页、编辑、添加、删除和保存等,极大地增强了网页中表格的交互性和数据管理...
它基于jQuery库,提供了许多强大的功能,例如排序、过滤、编辑、分页等,使得开发者可以快速创建复杂的表格应用程序。本文将详细介绍jQgrid的中文文档API,涵盖了其原理、使用方法、参数配置、事件处理、数据处理、...
1. **jqGrid 简介**:jqGrid 是一款基于 jQuery 的开源网格插件,它提供了数据管理、排序、搜索、分页等功能,广泛应用于数据密集型应用。jqGrid4.6 是其一个稳定版本,具有良好的兼容性和丰富的特性。 2. **可编辑...
JqGrid是一款强大的JavaScript数据网格组件,用于在Web应用程序中展示和操作数据。它基于jQuery库,提供了丰富的功能,如分页、排序、过滤、编辑和格式化数据。本中文API文档将帮助开发者深入理解并有效利用JqGrid的...
jqGrid是一个用于Web应用程序的JavaScript表格插件,它遵循典型的B/S(浏览器/服务器)架构。在这种架构中,服务器端负责数据管理,而客户端则用于数据展示和用户交互。jqGrid可以简化数据库信息的展示,并能将...
jqGrid 是一个基于 jQuery 的数据网格插件,用于在...在实际应用中,你可以根据项目需求选择合适的组件和配置,以实现高效的数据管理界面。通过深入理解 jqGrid 的 API 和各种选项,可以定制化地满足不同场景的需求。
这个"jqGrid demo (完整版)"提供了一个全面的示例,可以帮助开发者更好地理解和应用 jqGrid,无论是在 PHP 或 JSP 环境中。 1. **jqGrid 简介** jqGrid 提供了丰富的功能,包括分页、排序、搜索、编辑、添加、...