jqgrid应用

阅读更多
<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags"%>



	
	开票申请
	
		
	
	
	



 







    
	
	


////////////////////////////////////
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('');
					});
				} 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('');
						} else {
							$("#BUSINESS_TYPE").append('');
						}
					});
				} 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('');
						$("#KP_FLAG").append('');
					}
				} 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 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 = '所选数据将合并开为一张发票,是否确定要提交?';
			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 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 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 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;

/**
 * 类说明:
* * *

* 详细描述:
* * *

* * @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; /** * 进页面方法 方法说明:
* * @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; } /** * 业务处理方法 方法说明:
* * @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; } /** * 业务处理方法 导出:
* * @param bean * @return */ @SuppressWarnings("unchecked") @RequestMapping("/export") public ModelAndView export(BeanBase bean, HttpServletRequest request) { Map 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) 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); } /** * 业务处理方法 导出:
* * @param bean * @return */ @SuppressWarnings("unchecked") @RequestMapping("/exportForInv") public ModelAndView exportForInv(BeanBase bean, HttpServletRequest request) { Map map = null; try { billInvBusiness.invExport(bean); map = (Map) 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); } /** * 模板导出:
* * @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; } /** * 模板导入:
* * @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 map = (Map) request .getSession().getAttribute("repeatSubmit"); if (map == null) { map = new ConcurrentHashMap(); 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; /** * 描述:开票申请业务类 * *
HISTORY
 * ****************************************************************************
 *  ID   DATE           PERSON          REASON
 *  1    2016年11月24日      80001092         Create
 * ****************************************************************************
 * 
* @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 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>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCountReBill(paramMap); } @Override public List> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getBillListRebill(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } else { bean.getExpData().put("page", PageHandler.execute(new PageSplit>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCount(paramMap); } @Override public List> 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 map = bean.getDatas().get(0); map.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); String queryType = map.get("queryType"); List> 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 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> listSubAccount = billingApplyDao.querySubAccount(ids[0]); // 存放子账号序号 Map subAccountNum = new HashMap(); for (int i=0; i subAMT = new HashMap(); // 子账号循环生成形式发票 if(sub_ID.length > 0 && sub_ID[0] != "") { for(int i=0; i 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 mapInfo = new HashMap(); for(int i=0; i flowLogMap = billingApplyDao.getModuleConfig("TAX_10_01"); billingApplyDao.insertBatchFlowLog(mapInfo, flowLogMap); /* for( int i=0; i mapMergeDetail = new HashMap(); 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 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> 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 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 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 flowLogMap = billingApplyDao.getModuleConfig("TAX_10_02"); billingApplyDao.insertBatchFlowLog(mapInfo, flowLogMap); } else { throw new ServiceException("存在已经开票的月份,请查询后重新创建!"); } } /** * 80001092 方法说明:创建发票批需要的信息 * @param headerID * @return * List> */ private Map getBatchInfoById(String headerID) { return billingApplyDao.getInfoForCreateBatch(headerID); } private Map 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> kpFlagList = billingApplyDao.getKPFlagList(ids); for(int i=0; i 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 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 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> excelValueList) { billingApplyDao.insertBill(excelValueList); } /** * 80001092 方法说明:导入数据校验 * @param workbook * @return * Object */ private List> check(Workbook workBook) { List> excelValueList = null; // 待导入的数据 int import_wb_sheetNos = workBook.getNumberOfSheets(); if (import_wb_sheetNos == 0) { throw new ServiceException("待导入的数据为空"); } excelValueList = new ArrayList<>(); // 当前权限的网点 List> branchList = billingApplyDao. getCurrentAuthBranch(UserUtil.getCurrentUser().getEmpCode()); // 合并后的业务类型 // List> businessType = billingApplyDao.getAllBusinessType(); for(int i=0; i map = new HashMap(); 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 paramMap = bean.getDatas().get(0); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); try { bean.getExpData().put("page", PageHandler.execute(new PageSplit>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCountDesperse(paramMap); } @Override public List> 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 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> listRecord = billingApplyDao. getBillListDesperseByIds(ids,UserUtil.getCurrentUser().getEmpCode()); if(listRecord == null || listRecord.size() == 0) { throw new ServiceException("获取开票信息时失败,暂时无法提交"); } for(int i=0,count=listRecord.size(); i 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 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>() { @Override public int queryTotalCount() { return billingApplyDao.getRelatedTotalCount(paramMap); } @Override public List> 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>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCountRelatedDeatail(headerId); } @Override public List> 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 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 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> itemList = billingApplyDao.getBillListRelatedDeatailByGroup(id); Map tempMap = null; for (int i=0; i> kpFlagList = billingApplyDao.getKPFlagList(ids); /*for(int i=0; i mapInfo = billingApplyDao.getInfoForCreateRelatedBath(ids[0]); Map tempMap = null; List> 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 0) { END_PERIOD = temp_PERIOD; } } mapInfo.put("ZDEINVID", ZDEINVID); mapInfo.put("TICKETS_BACK", ZDEINVID); itemList = billingApplyDao.getBillListRelatedDeatailByGroup(ids[i]); for (int j=0; j map, String code) { Map 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 headerData = null; List> 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 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 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 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 paramMap = bean.getDatas().get(0); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); try { bean.getExpData().put("page", PageHandler.execute(new PageSplit>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCountMarkedCancl(paramMap); } @Override public List> 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 paramMap = bean.getDatas().get(0); String selectAllFlag = paramMap.get("selectAllFlag"); String ids = StringUtil.addDimmer(paramMap.get("ids"), ",", "'"); List> compareData = new ArrayList>(); if (StringUtil.areNotBlank(ids)) { compareData = billingApplyDao.getCompareData(ids); } for (int i=0; i paramMap = bean.getDatas().get(0); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); try { bean.getExpData().put("page", PageHandler.execute(new PageSplit>() { @Override public int queryTotalCount() { return billingApplyDao.getTotalCountImportCancleLose(paramMap); } @Override public List> 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上传失败:
" + 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> list) { billingApplyDao.insertCancleLoseInv(list); } /** * 2017年1月16日 80001092 方法说明:待完成 * @param workBook * @return * List> */ private List> checkCancleLose(Workbook workBook) { List> 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> dataList = billingApplyDao.getAuthDataList(currentEmpCode); // 已经导入系统的作废作负发票 List> dataHaveImp = billingApplyDao.getDataHaveImp(currentEmpCode); // 本次导入的旧发票代码 Map codeOldToal = new HashMap(); // 本次导入的新发票代码 Map codeNewToal = new HashMap(); for(int i=0; i tempMap = new HashMap(); // 判断是否已经导入过 for ( int j=0; j map = new HashMap(); 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 param = billingApplyDao.getQueryCondition(zDEINVID); param.put("KUNNR", kUNNR); Map 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 param = billingApplyDao.getQueryCondition(ZDEINVID); param.put("KUNNR", KUNNR); // param.put("ZTAXTYPE", ZTAXTYPE); Map 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 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 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> listSubAccount = billingApplyDao.getActuralSubCustNo(paramMap); Map first = listSubAccount.get(0); Map main; for (int i=0; i paramMap = bean.getDatas().get(0); String headerId = paramMap.get("headerId"); String queryType = paramMap.get("REBILL_FLAG"); String cust_no = addDolt(paramMap.get("subAccount")); Map headerData = null; List> 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 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 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 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 paramMap = bean.getDatas().get(0); paramMap.put("currentEmpCode", UserUtil.getCurrentUser().getEmpCode()); Map map = new HashMap(); List excel = new ArrayList(); final String[] cellsTitle = {"应收所属起始时间","应收所属结束时间","发票代码","发票号码","月结账号名称", "关联账号名称","净值","税金","发票状态","待作废标识","遗失标识"}; final Map header = new HashMap(); //报表头部 header.put(cellsTitle.length, "标识作废遗失发票"); String[] cells = null; List> list = null; list = billingApplyDao.getMarkedCancleList(paramMap, 0, Integer.MAX_VALUE); for (Map 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 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 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 map = new HashMap(); List excel = new ArrayList(); final String[] cellsTitle = {"业务类型","所属时间","业务开票主体","实际开票主体","实际收票主体", "业务收票放账套号","发票类型","税号","地址&电话","开户行&账号","开票金额"}; final Map header = new HashMap(); //报表头部 header.put(cellsTitle.length, "关联方开票信息导出"); String[] cells = null; List> list = billingApplyDao.getRelatedBillList(paramMap, 0, Integer.MAX_VALUE); for (Map 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 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 hAndIMap; try { for (int i=0; i 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 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> conList = billingApplyDao.getConfirmList(paramMap); Map entryMap = null; try { for (int i=0; i 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>() { @Override public int queryTotalCount() { return billingApplyDao.getAllBillStatusTotalCount(paramMap); } @Override public List> queryPageList(int pageStart, int pageSize) { return billingApplyDao.getAllBillStatus(paramMap, pageStart, pageSize); } }, bean.getRows(), bean.getPage())); } else { bean.getExpData().put("page", PageHandler.execute(new PageSplit>() { @Override public int queryTotalCount() { return billingApplyDao.getAllSingleBillStatusTotalCount(paramMap); } @Override public List> 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 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 map = new HashMap(); List excel = new ArrayList(); final String[] cellsTitle = {"网点","申请人","月结账号","纳税人识别号","开户行", "地址电话","名称","业务类型", "所属账期","应收金额","申请金额","差异金额","申请日期","开票人","开票日期", "发票状态","发票类型","寄送状态","运单号码","收件人","签收状态","发票批", "发票批次号"}; final Map header = new HashMap(); //报表头部 header.put(cellsTitle.length, "发票状态查询导出"); String[] cells = null; List> 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 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 paramMap = bean.getDatas().get(0); paramMap.put("empCode", UserUtil.getCurrentUser().getEmpCode()); bean.getExpData().put("page", PageHandler.execute(new PageSplit>() { @Override public int queryTotalCount() { return billingApplyDao.getInvDetailTotalCount(paramMap); } @Override public List> 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 paramMap = bean.getDatas().get(0); paramMap.put("empCode", UserUtil.getCurrentUser().getEmpCode()); Map map = new HashMap(); List excel = new ArrayList(); final String[] cellsTitle = {"发票代码","发票号码","名称","发票类型", "发票金额","发票状态","运单号码","收件人","发票批","商品名称","税额", "税率","开票日期"}; final Map header = new HashMap(); //报表头部 header.put(cellsTitle.length, "发票明细查询导出"); String[] cells = null; List> list = null; list = billingApplyDao.getInvDetail(paramMap, 0, Integer.MAX_VALUE); for (Map 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 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 map = new HashMap(); List excel = new ArrayList(); final String[] cellsTitle = {"业务号","序号","月结账号","月结账号名称","所属期间","结算网点编码", "业务类型","发票类型","应收金额","未开票金额","开票金额","差异原因","票面备注","纳税人识别号", "地址及电话","开户行及账号","货物或应税劳务名称","单位","单价","数量","规格","申请人员备注", "驳回原因","企业名片代码","是否直寄"}; final Map header = new HashMap(); //报表头部 header.put(cellsTitle.length, "月结客户开票信息导出"); String[] cells = null; boolean subFlag = false; Map idMap = new HashMap(); List> list = billingApplyDao.getBillListExport(paramMap); for (Map 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上传失败:
"; 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> 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 map = null; Map idMap = new HashMap(); for(int line=2, count=sheet.getLastRowNum()+1; line 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(); 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 paramMap = bean.getDatas().get(0); String impData = paramMap.get("IMPDATA"); List> listData = (List>) JSON.parse(impData); String kp_flag = null; String ID = null; String subXH = null; Map batchMap = new HashMap(); Map batchXhMap = new HashMap(); // 导出的excel如果在主账号和子账号之间插入其他月结账号行或调整顺序,开票结果可能会出现错误; for (Map 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 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 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 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 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); } }

你可能感兴趣的:(json,jquery)