将表头表体数据导出为两个页签的excel

先建好公共的导出窗口以及导出窗口里面具体的内容,方便多个单据写导出功能:

ClientUI:

package nc.ui.jygyl.export;

import java.awt.BorderLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import nc.bs.framework.common.NCLocator;
import nc.itf.jygyl.export.IbljhandzkMaintain;
import nc.itf.uap.IUAPQueryBS;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.ui.pub.beans.MessageDialog;
import nc.ui.pub.beans.UIPanel;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.tools.BannerDialog;
import nc.vo.jygyl.export.tool.BljhExportUtils;
import nc.vo.jygyl.export.tool.GeneraloutExportUtils;
import nc.vo.jygyl.export.tool.InvCountBillExportUtils;
import nc.vo.jygyl.export.tool.PoOrderExportUtils;
import nc.vo.jygyl.export.tool.QgdExportUtils;
import nc.vo.jygyl.export.tool.SCOrderExportUtils;
import nc.vo.jygyl.export.tool.SapplyBillExportUtils;
import nc.vo.jygyl.export.tool.ZkgylExportUtils;
import nc.vo.jygyl.export.tool.m23.ArriveExportUtils;
import nc.vo.jygyl.export.tool.m45.PurchaseInExportUtils;
import nc.vo.jygyl.tool.NullValueUtils;
import nc.vo.pubapp.AppContext;
import nc.vo.pubapp.pattern.exception.ExceptionUtils;


/**
 * 业务单据导出
 * @author lyh
 * @date 2023-05-31
 */
public class ClientUI extends UIPanel{

	private static final long serialVersionUID = -7973821104724069917L;

	private BillCardPanel billCardPanel;
	private UIPanel uipanel;
	private JTextField filePath;
	private IUAPQueryBS basedao;

	public ClientUI() {
		// TODO 自动生成的构造函数存根
		setLayout(new BorderLayout());
		add(getExportOutPanel(), java.awt.BorderLayout.CENTER);
		add(getUIPanel(), java.awt.BorderLayout.NORTH);

	}

	private BillCardPanel getBillCardPanel(){
		if (billCardPanel == null) {
			billCardPanel = new BillCardPanel();
			billCardPanel.loadTemplet("zkgyldc", null, AppContext.getInstance().getPkUser(), null);
			billCardPanel.setEnabled(true);
		} 
		return billCardPanel;
	}

	private nc.ui.pub.beans.UIPanel getUIPanel() {
		if (uipanel == null) {
			uipanel = new UIPanel();
			uipanel.setLayout(new BorderLayout());
			uipanel.setBorder(BorderFactory.createTitledBorder("查询条件"));
			uipanel.add(getBillCardPanel(), java.awt.BorderLayout.CENTER);
		}
		return uipanel;
	}

	/**
	 * 导出模板
	 * @return
	 */
	private JPanel getExportOutPanel(){
		JPanel jPanel = new JPanel();
		jPanel.setLayout(null);
		jPanel.setSize(600,300);
		jPanel.setBorder(BorderFactory.createTitledBorder("导出"));
		JLabel filePathLabel = new JLabel("文件路径:");
		filePathLabel.setBounds(10, 15, 100, 20);
		filePath = new JTextField();
		filePath.setBounds(80, 15, 350, 20);
		filePath.setEditable(false);
		//选择
		getSelectFileButton().setBounds(440, 15, 120, 20);
		//导出
		getExportTxtButton().setBounds(570, 15, 80, 20);

		JTextArea content = new JTextArea(50,10);
		content.setText("");
		content.setFont(new Font("宋体",1,10));
		JScrollPane js = new JScrollPane(content);
		js.setBounds(10, 60, 770, 100);

		jPanel.add(filePathLabel);
		jPanel.add(filePath);
		jPanel.add(getSelectFileButton());	
		jPanel.add(getExportTxtButton());
		jPanel.add(js);
		jPanel.setVisible(true);
		return jPanel;
	}

	private JButton selectFileBtn = null;

	/**
	 * 选择文件按钮
	 * @return
	 */
	private JButton getSelectFileButton(){
		if(selectFileBtn == null){
			selectFileBtn = new JButton("选择路径");
			selectFileBtn.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent arg0) {
					fileSelect();
				}
			});
		}
		return selectFileBtn;
	}

	/**
	 * 选择文件
	 *
	 */
	private void fileSelect(){
		FileDialog fileDlg = new FileDialog();
		if (fileDlg.show()) {
			// 得到导入的EXCEL文件路径
			String filepath = fileDlg.getFilePath();
			filePath.setText(filepath);
		}
	}

	/**
	 * 导出按钮
	 */
	private JButton exportTxtBtn = null;
	private JButton getExportTxtButton(){
		if(exportTxtBtn == null){
			exportTxtBtn = new JButton("导出");
			exportTxtBtn.addActionListener(new ActionListener(){
				public void actionPerformed(ActionEvent arg0) {
					Thread thread = new Thread(){
						@Override
						public void run() {
							BannerDialog dialog = new BannerDialog(getParent());
							try {
								dialog.setStartText("正在导出,请稍候...");
								dialog.start();
								export();
							} catch (Exception e) {
								MessageDialog.showHintDlg(null, "", "导出失败!"+e.getMessage());
							}finally{
								dialog.end();
							}
						}
					};
					thread.start();
				}
			});
		}
		return exportTxtBtn;
	}

	/**
	 * 导出处理
	 * @throws Exception 
	 */
	public void export() throws Exception{
		//校验非空
		getBillCardPanel().dataNotNullValidate();

		if(filePath.getText() == null || filePath.getText().equals("")){
			ExceptionUtils.wrappBusinessException("请选择导出文件路径!");
		}
		//开始日期
		String startdate =  NullValueUtils.getNullStringValue(getBillCardPanel().getHeadItem("startdate").getValueObject());
		//结束日期
		String enddate = NullValueUtils.getNullStringValue(getBillCardPanel().getHeadItem("enddate").getValueObject());
		//交易类型
		String jylx = NullValueUtils.getNullStringValue(getBillCardPanel().getHeadItem("jylx").getValueObject());
		String sql = " select pk_billtypecode from bd_billtype where pk_billtypeid = '"+ jylx +"' and isnull(dr,0) = 0 ";
		String pk_billtypecode = NullValueUtils.getNullStringValue(getBaseDao().executeQuery(sql,new ColumnProcessor()));
		if(pk_billtypecode.equals("55A3-0001") || pk_billtypecode.equals("55A3-0002") || pk_billtypecode.equals("55A3-0003")){
			BljhExportUtils.getInstance().bljhExportUtils(startdate,enddate,filePath);

		}else if("61-common".equals(pk_billtypecode)){
			SCOrderExportUtils.getInstance().export(startdate, enddate, filePath);
		}else if(pk_billtypecode.equals("422X-01")){//物资需求申请
			ZkgylExportUtils.getNewInstance().zkgylExportUtils(startdate, enddate,filePath );
		}else if(pk_billtypecode.equals("20-Cxx-1") || pk_billtypecode.equals("20-Cxx-3") ){//请购单
			QgdExportUtils.getNewInstance().qgdExportUtils(startdate, enddate,filePath );	
		}else if(pk_billtypecode.equals("4455-Cxx-2") || pk_billtypecode.equals("4455-Cxx-3")){ // 出库申请单 :项目物料出库申请单、项目直采出库申请单
			SapplyBillExportUtils.getInstance().sapplyBillExport(pk_billtypecode, startdate.substring(0, 10), enddate.substring(0, 10), filePath);
		}else if(pk_billtypecode.equals("4I-02") || pk_billtypecode.equals("4I-03") || pk_billtypecode.equals("4I-Cxx-1") || pk_billtypecode.equals("4I-Cxx-2") || pk_billtypecode.equals("4I-Cxx-3") || pk_billtypecode.equals("4I-Cxx-4") || pk_billtypecode.equals("4I-Cxx-5") || pk_billtypecode.equals("4I-Cxx-99")){ // 其它出库单 :转库出库、盘亏出库、生产物料出库、项目直采出库、项目物料出库、零售物料出库、产成品出库、仓库拆分成本出库
			GeneraloutExportUtils.getInstance().generaloutExport(pk_billtypecode, startdate.substring(0, 10), enddate.substring(0, 10), filePath);
		}else if(pk_billtypecode.equals("23-Cxx-1") || pk_billtypecode.equals("23-Cxx-2") || pk_billtypecode.equals("23-Cxx-3") || pk_billtypecode.equals("23-Cxx-4")){
			ArriveExportUtils.getInstance().arriveExport(startdate,enddate,pk_billtypecode,filePath);
		}else if(pk_billtypecode.equals("45-Cxx-1") || pk_billtypecode.equals("45-Cxx-2") || pk_billtypecode.equals("45-Cxx-3") || pk_billtypecode.equals("23-Cxx-4")){
			PurchaseInExportUtils.getInstance().puechaseInExport(startdate,enddate,pk_billtypecode,filePath);
		}else if (pk_billtypecode.equals("21-Cxx-1") || pk_billtypecode.equals("21-Cxx-2") || pk_billtypecode.equals("21-Cxx-3") || pk_billtypecode.equals("21")) {
			PoOrderExportUtils.getInstance().poOrderExportUtils(startdate, enddate, filePath);			
		}else if(pk_billtypecode.equals("4R-01")){//盘点单
			InvCountBillExportUtils.getInstance().invcountBillExport(pk_billtypecode,startdate,enddate,filePath);
		}





		MessageDialog.showHintDlg(null, "", "导出成功");

	}

	private IUAPQueryBS getBaseDao(){
		if(basedao == null){
			basedao = NCLocator.getInstance().lookup(IUAPQueryBS.class);
		}
		return basedao;
	}
	private IbljhandzkMaintain service;
	private IbljhandzkMaintain getserver(){
		if(service == null){
			service = NCLocator.getInstance().lookup(IbljhandzkMaintain.class);
		}
		return service;
	}


}

FileDialog :

package nc.ui.jygyl.export;

import javax.swing.JFileChooser;

public class FileDialog {

JFileChooser jFileChooser = new JFileChooser(); 
	
	public FileDialog() {
		super();
	}
	
	public boolean show(){
		jFileChooser.removeChoosableFileFilter(jFileChooser.getAcceptAllFileFilter());
		jFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
		
		return JFileChooser.APPROVE_OPTION == jFileChooser.showOpenDialog(null);
	}
	
	public String getFilePath(){
		return jFileChooser.getSelectedFile().getAbsolutePath();
	}
}

建接口以及接口实现类,和工具类,实现类用来查询操作,工具类里面写输出的内容

 

InvCountBillExportUtils:

package nc.vo.jygyl.export.tool;

import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JTextField;
import nc.bs.framework.common.NCLocator;
import nc.itf.jygyl.export.IInvCountBillMaintain;
import nc.vo.ic.m4r.entity.InvCountBillVO;
import nc.vo.ic.m4r.entity.InvCountBodyVO;
import nc.vo.ic.m4r.entity.InvCountHeaderVO;
import nc.vo.jygyl.tool.NullValueUtils;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVOUtil;
import nc.vo.pub.lang.UFDate;
import org.apache.poi.xssf.streaming.SXSSFCell;
import org.apache.poi.xssf.streaming.SXSSFRow;
import org.apache.poi.xssf.streaming.SXSSFSheet;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFFont;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;


public class InvCountBillExportUtils {

	public static InvCountBillExportUtils instance = null;

	public static InvCountBillExportUtils getInstance() {
		if (instance == null) {
			instance = new InvCountBillExportUtils();
		}
		return instance;
	}
	/**
	 * 盘点导出
	 * @author wf
	 * @date:2023-06-01
	 */
	public void invcountBillExport(String pk_billtypecode,String startdate,String enddate,JTextField filePath) throws BusinessException{
		XSSFWorkbook xssfWorkbook = new XSSFWorkbook();
		SXSSFWorkbook wb = new SXSSFWorkbook(xssfWorkbook, 100);
		// 创建表头工作表
		SXSSFSheet wbSheet = (SXSSFSheet) wb.createSheet(getExcelSheetName());
		// 创建表体工作表
		SXSSFSheet wbSheetbody = (SXSSFSheet) wb.createSheet(getExcelSheetBodyName());
		// 设置表头默认行宽
		wbSheet.setDefaultColumnWidth(10);
		// 设置表体默认行宽
		wbSheetbody.setDefaultColumnWidth(10);
		// 标题样式(加粗,垂直居中)
		XSSFCellStyle cellStyle = (XSSFCellStyle) wb.createCellStyle();
		cellStyle.setAlignment(XSSFCellStyle.ALIGN_CENTER);// 水平居中
		XSSFFont fontStyle = (XSSFFont) wb.createFont();
		fontStyle.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
		fontStyle.setFontHeightInPoints((short) 16); // 设置标题字体大小
		cellStyle.setFont(fontStyle);
		// 设置表头样式,表头居中
		XSSFCellStyle style = (XSSFCellStyle) wb.createCellStyle();
		// 设置单元格样式
		style.setAlignment(XSSFCellStyle.ALIGN_CENTER);
		style.setVerticalAlignment(XSSFCellStyle.VERTICAL_CENTER);
		// 设置字体
		XSSFFont font = (XSSFFont) wb.createFont();
		font.setFontHeightInPoints((short) 9);
		style.setFont(font);
		// 在表头页签第1行创建rows
		SXSSFRow row = (SXSSFRow) wbSheet.createRow((int) 0);
		// 在表体页签第1行创建rows
		SXSSFRow bodyrow = (SXSSFRow) wbSheetbody.createRow((int) 0);
		// 设置列头元素
		SXSSFCell cellHead = null;
		for (int i = 0; i < getExportFieldsName().length; i++) {
			cellHead = (SXSSFCell) row.createCell(i);
			cellHead.setCellValue(getExportFieldsName()[i]);
			cellHead.setCellStyle(style);
		}
		for (int k = 0; k < getExportFieldsBodyName().length; k++) {
			cellHead = (SXSSFCell) bodyrow.createCell(k);
			cellHead.setCellValue(getExportFieldsBodyName()[k]);
			cellHead.setCellStyle(style);
		}
		//根据开始日期和结束日期查询备料计划
		InvCountBillVO[] aggvos = getService().querypdd(startdate,enddate);
		if(aggvos == null || aggvos.length == 0){
			throw new BusinessException("根据开始日期和结束日期未查询盘点单信息,导出失败!");
		}
		List<InvCountHeaderVO> headvolist = new ArrayList<InvCountHeaderVO>();
		List<InvCountBodyVO> bodyvolist = new ArrayList<InvCountBodyVO>();
		for (int i = 0; i < aggvos.length; i++) {
			InvCountBillVO aggvo = (InvCountBillVO) aggvos[i].clone();
			InvCountBodyVO[] bodyvos = (InvCountBodyVO[]) aggvo.getChildrenVO();
			updateBodyVO(bodyvos);
			updateHeadVO(aggvo.getParentVO());
			headvolist.add(aggvo.getParentVO());
			for (int j = 0; j < bodyvos.length; j++) {
				bodyvolist.add(bodyvos[j]);
			}
		}
		int nowRow = 1;
		if(headvolist.size() > 0){
			getExportHead(wbSheet,headvolist,nowRow,style);
			getExportbody(wbSheetbody,bodyvolist,nowRow,style);
		}
		try {
			FileOutputStream fout = new FileOutputStream(filePath.getText()
					+ "\\盘点信息"
					+ new UFDate().toStdString().substring(0, 10) + ".xlsx");//或是将导出文件日期命名改为开始日期结束日期startdate.substring(0, 10) + "-" + enddate.substring(0, 10)
			wb.write(fout);
			fout.close();
		} catch (Exception e) {
			// TODO 自动生成的 catch 块
			throw new BusinessException("生成excel出错:" + e.getMessage());
		}
	}

	//写入表头信息
	private void getExportHead(SXSSFSheet wbSheet,List<InvCountHeaderVO> headvolist,int nowRow,XSSFCellStyle style) {
		// 写入数据
		for (InvCountHeaderVO headerVO : headvolist) {
			// 在第2行创建rows
			SXSSFRow rows = (SXSSFRow) wbSheet.createRow(nowRow++);
			// 设置列头元素
			SXSSFCell cellHeads = null;
			// 写入数据内容
			String[] fieldsValue = new String[] {
					NullValueUtils.getNullStringValue(headerVO.getCspecialhid()),//主表主键
					NullValueUtils.getNullStringValue(headerVO.getVbillcode()),//单据号
					NullValueUtils.getNullStringValue(headerVO.getDbilldate()),//单据日期
					NullValueUtils.getNullStringValue(headerVO.getDcountdate()),//盘点日期
					NullValueUtils.getNullStringValue(headerVO.getCwarehouseid()),//仓库==
					NullValueUtils.getNullStringValue(headerVO.getCtrantypeid()),//盘点类型==
					NullValueUtils.getNullStringValue(headerVO.getCwhsmanagerid()),//库管员==
					NullValueUtils.getNullStringValue(headerVO.getCountoperator()),//盘点人==
					NullValueUtils.getNullStringValue(headerVO.getVnote()),//备注
					NullValueUtils.getNullStringValue(headerVO.getCreator()),//创建人
					NullValueUtils.getNullStringValue(headerVO.getCreationtime()),//创建时间
					NullValueUtils.getNullStringValue(headerVO.getModifier()),//最后修改人
					NullValueUtils.getNullStringValue(headerVO.getModifiedtime()),//最后修改时间
					NullValueUtils.getNullStringValue(headerVO.getBillmaker()),//制单人
					NullValueUtils.getNullStringValue(headerVO.getDmakedate()),//制单日期
					NullValueUtils.getNullStringValue(headerVO.getApprover() ),//审核
					NullValueUtils.getNullStringValue(headerVO.getTaudittime() )//审核日期
			};
			// 开始写入数据,j为列值
			for (int j = 0; j < fieldsValue.length; j++) {
				cellHeads = (SXSSFCell) rows.createCell(j);
				cellHeads.setCellValue(fieldsValue[j]);
				cellHeads.setCellStyle(style);
			}
		}

	}

	//写入表体信息
	private void getExportbody(SXSSFSheet wbSheetbody,List<InvCountBodyVO> bodyvolist,int nowRow,XSSFCellStyle style) {
		// 写入数据
		for (InvCountBodyVO itemVO : bodyvolist) {
			// 在第2行创建rows
			SXSSFRow rows = (SXSSFRow) wbSheetbody.createRow(nowRow++);
			// 设置列头元素
			SXSSFCell cellHeads = null;
			// 写入数据内容
			String[] fieldsValue = new String[] {
					NullValueUtils.getNullStringValue(itemVO.getCspecialhid()),//主表主键
					NullValueUtils.getNullStringValue(itemVO.getCspecialbid()),//子表主键
					NullValueUtils.getNullStringValue(itemVO.getCrowno()),//行号
					NullValueUtils.getNullStringValue(itemVO.getCmaterialvid()),//物料编码==
					NullValueUtils.getNullStringValue(itemVO.getCunitid()),//主单位==
					NullValueUtils.getNullStringValue(itemVO.getCastunitid()),//单位
					NullValueUtils.getNullStringValue(itemVO.getVchangerate()),//换算率
					NullValueUtils.getNullStringValue(itemVO.getVbatchcode()),//批次号
					NullValueUtils.getNullStringValue(itemVO.getClocationid()),//货位==
					NullValueUtils.getNullStringValue(itemVO.getNonhandastnum()),//账面数量
					NullValueUtils.getNullStringValue(itemVO.getNonhandnum()),//账面主数量
					NullValueUtils.getNullStringValue(itemVO.getNcountastnum()),//盘点数量
					NullValueUtils.getNullStringValue(itemVO.getNcountnum()),//盘点主数量
					NullValueUtils.getNullStringValue(itemVO.getNdiffastnum()),//差异数量
					NullValueUtils.getNullStringValue(itemVO.getNdiffnum()),//差异主数量
					NullValueUtils.getNullStringValue(itemVO.getNadjustastnum()),//调整数量
					NullValueUtils.getNullStringValue(itemVO.getNadjustnum()),//调整主数量
					NullValueUtils.getNullStringValue(itemVO.getNcostprice()),//调整单价
					NullValueUtils.getNullStringValue(itemVO.getNcostmny()),//调整金额
					NullValueUtils.getNullStringValue(itemVO.getNkeeplosrate()),//保管损失率(%)
					NullValueUtils.getNullStringValue(itemVO.getNdiffrate()),//差异率
					NullValueUtils.getNullStringValue(itemVO.getVreason()),//原因
					NullValueUtils.getNullStringValue(itemVO.getVnotebody()),//行备注

			};
			// 开始写入数据,j为列值
			for (int j = 0; j < fieldsValue.length; j++) {
				cellHeads = (SXSSFCell) rows.createCell(j);
				cellHeads.setCellValue(fieldsValue[j]);
				cellHeads.setCellStyle(style);
			}
		}

	}

	private String getExcelSheetName() {
		return "盘点单表头信息";
	}
	private String getExcelSheetBodyName() {
		return "盘点单表体信息";
	}
	private String[] getExportFieldsName() {
		return new String[] {"主表主键","单据号","单据日期","盘点日期","仓库","盘点类型","库管员","盘点人","备注", "制单人","制单日期","审批人","审批日期","创建人","创建时间","最后修改人","最后修改时间" };
	}
	private String[] getExportFieldsBodyName() {
		return new String[] {"主表主键","子表主键","行号","物料编码","主单位","单位","换算率","批次号","货位","账面数量","账面主数量","盘点数量","盘点主数量","差异数量","差异主数量","调整数量","调整主数量","调整单价","调整金额","保管损失率(%)","差异率","原因","行备注"};
	}

	private void updateHeadVO(InvCountHeaderVO headvo){
		SuperVOUtil
		.execFormulaWithVOs(
				new InvCountHeaderVO[] { headvo },
				new String[] {
						// 仓库
						"cwarehouseid ->getColValue(bd_stordoc,code,pk_stordoc,cwarehouseid)",
						// 盘点类型
						"ctrantypeid ->getColValue(bd_billtype,pk_billtypecode,pk_billtypeid,ctrantypeid )",
						// 库管员
						"cwhsmanagerid ->getColValue(bd_psndoc,code,pk_psndoc,cwhsmanagerid )",
						// 盘点人
						"countoperator ->getColValue(bd_psndoc,code,pk_psndoc,countoperator)",
						// 创建人
						"creator->getColValue(sm_user,user_code,cuserid,creator)",
						// 最后修改人
						"modifier->getColValue(sm_user,user_code,cuserid,modifier)",
						// 制单人
						"billmaker->getColValue(sm_user,user_code,cuserid,billmaker)",
						// 审批人
						"approver->getColValue(sm_user,user_code,cuserid,approver)"
				});
	}

	private void updateBodyVO(InvCountBodyVO[] bodyvos) {
		SuperVOUtil.execFormulaWithVOs(bodyvos, new String[]{			
				//物料编码
				"cmaterialvid->getcolvalue(bd_material,code,pk_material,cmaterialvid)",
				//主单位
				"cunitid ->getcolvalue(bd_measdoc,code,pk_measdoc ,cunitid )",
				//货位
				"clocationid ->getcolvalue(bd_rack,code,pk_rack,clocationid )"
		});

	}

	private IInvCountBillMaintain service;

	private IInvCountBillMaintain getService() {
		if (service == null) {
			service = NCLocator.getInstance().lookup(
					IInvCountBillMaintain.class);
		}
		return service;
	}

}

 IInvCountBillMaintain:

package nc.itf.jygyl.export;

import javax.swing.JTextField;
import nc.vo.ic.m4r.entity.InvCountBillVO;
import nc.vo.pub.BusinessException;

public interface IInvCountBillMaintain {
	/**
	 * 根据开始日期和结束日期查询盘点导出
	 * @return 
	 */
	public InvCountBillVO[] querypdd(String pk_billtypecode,String startdate,String enddate) throws BusinessException;
}

InvCountBillImpl:

package nc.impl.jygyl.export;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import javax.swing.JTextField;
import nc.bs.dao.BaseDAO;
import nc.bs.framework.common.NCLocator;
import nc.impl.pubapp.pattern.data.bill.BillQuery;
import nc.itf.jygyl.export.IInvCountBillMaintain;
import nc.itf.uap.pf.IplatFormEntry;
import nc.jdbc.framework.processor.ColumnListProcessor;
import nc.vo.ic.m4r.entity.InvCountBillVO;
import nc.vo.ic.m4r.entity.InvCountBodyVO;
import nc.vo.ic.m4r.entity.InvCountHeaderVO;
import nc.vo.jygyl.tool.NullValueUtils;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.SuperVOUtil;
import nc.vo.pub.VOStatus;
import nc.vo.pub.lang.UFDateTime;
import nc.vo.pubapp.AppContext;
import nc.vo.pubapp.pattern.pub.SqlBuilder;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
/**
 * 盘点单导出
 * @author wf
 * @date:2023-06-01
 */
public class InvCountBillImpl implements IInvCountBillMaintain{

	@Override
	public InvCountBillVO[] querypdd(String pk_billtypecode, String startdate, String enddate)
			throws BusinessException {
		// TODO 自动生成的方法存根
		InvCountBillVO[] aggvos = null;
		//根据开始日期结束日期查询备料计划主键(前面查询单据类型是找到该单据进行操作,sql中再去根据查单据类型查询一遍的原因,是在数据库中查的,此时能查询到所有数据因此要根据单据类型查询进行过滤)
		SqlBuilder sqlBuilder = new SqlBuilder();
		sqlBuilder.append("	select cspecialhid	");
		sqlBuilder.append("	  from ic_invcount_h	");
		sqlBuilder.append("	 where substring(dmakedate, 1, 10) between substring('"+startdate+"', 1, 10) and substring('"+enddate+"', 1, 10)	");
		sqlBuilder.append("	   and vtrantypecode='"+pk_billtypecode+"'	");
		sqlBuilder.append("	   and isnull(dr, 0) = 0	");
		sqlBuilder.append("	   and fbillflag  = 4	");
		List<String> list = (List<String>) getBaseDao().executeQuery(sqlBuilder.toString(), new ColumnListProcessor());
		if(list != null && list.size() > 0){
			BillQuery<InvCountBillVO> billQuery = new BillQuery<InvCountBillVO>(InvCountBillVO.class);
			aggvos = billQuery.query(list.toArray(new String[0]));
		}
		return aggvos;
	}

	private BaseDAO basedao;

	private BaseDAO getBaseDao(){
		if(basedao == null){
			basedao = new BaseDAO();
		}
		return basedao;
	}

最后记得加上upm

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值