Java tutorial
/* @(#) * * Project:NEBMis * * Modify Information: * ============================================================================= * Author Date Description * ------------ ---------- --------------------------------------------------- * PanShuang 2010-8-26 first release * * * Copyright Notice: * ============================================================================= * Copyright 2010 allinfinance, Inc. All rights reserved. * * This software is the confidential and proprietary information of * Shanghai allinfinance Co., Ltd. ("Confidential Information"). * You shall not disclose such Confidential Information and shall use it * only in accordance with the terms of the license agreement you entered * into with allinfinance. * * Warning: * ============================================================================= * */ package com.allinfinance.bo.impl.risk; import java.io.File; import java.io.FileInputStream; import java.util.List; import org.apache.poi.hssf.usermodel.HSSFCell; import org.apache.poi.hssf.usermodel.HSSFRow; import org.apache.poi.hssf.usermodel.HSSFSheet; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import com.allinfinance.bo.risk.T40202BO; import com.allinfinance.common.Constants; import com.allinfinance.common.Operator; import com.allinfinance.dao.iface.risk.TblCtlMchtInfDAO; import com.allinfinance.po.TblCtlMchtInf; import com.allinfinance.system.util.CommonFunction; /** * Title: ???? * * Description: * * Copyright: Copyright (c) 2010-8-26 * * Company: Shanghai allinfinance Co., Ltd. * * @author PanShuang * * @version 1.0 */ public class T40202BOTarget implements T40202BO { private TblCtlMchtInfDAO tblCtlMchtInfDAO; /* (non-Javadoc) * @see com.allinfinance.bo.T40202BO#add(com.allinfinance.po.TblCtlMchtInf) */ public String add(TblCtlMchtInf tblCtlMchtInf) throws Exception { // tblCtlMchtInf.setSaLimitAmt(CommonFunction.transYuanToFen(tblCtlMchtInf.getSaLimitAmt())); tblCtlMchtInfDAO.save(tblCtlMchtInf); return Constants.SUCCESS_CODE; } /* (non-Javadoc) * @see com.allinfinance.bo.T40202BO#get(java.lang.String) */ public TblCtlMchtInf get(String key) { return tblCtlMchtInfDAO.get(key); } /* (non-Javadoc) * @see com.allinfinance.bo.T40202BO#update(com.allinfinance.po.TblCtlMchtInf) */ public String update(TblCtlMchtInf tblCtlMchtInf) throws Exception { // tblCtlMchtInf.setSaLimitAmt(CommonFunction.transYuanToFen(tblCtlMchtInf.getSaLimitAmt())); tblCtlMchtInfDAO.update(tblCtlMchtInf); return Constants.SUCCESS_CODE; } /* (non-Javadoc) * @see com.allinfinance.bo.T40202BO#importFile(java.util.List, java.util.List, com.allinfinance.common.Operator) */ @SuppressWarnings("unchecked") public String importFile(List<File> fileList, List<String> fileNameList, Operator operator) throws Exception { HSSFWorkbook workbook = null; HSSFSheet sheet = null; HSSFRow row = null; // ? String returnMsg = ""; // ?? int fileNameIndex = 0; // ?? String fileName = null; String sql = null; // List<Object[]> dataList = null; // ?? String saMerNo = null; // ?? String saMerChName = null; // ?? String saMerEnName = null; // ? String saZoneNo = null; // ?? String saLimitAmt = null; // ? String saAction = null; // String saBrhId = operator.getOprBrhId(); // ? String saOprId = operator.getOprId(); // String saInitTime = CommonFunction.getCurrentDateTime(); TblCtlMchtInf tblCtlMchtInf = null; FileInputStream fileInputStream = null; for (File file : fileList) { fileInputStream = new FileInputStream(file); workbook = new HSSFWorkbook(fileInputStream); sheet = workbook.getSheetAt(0); fileName = fileNameList.get(fileNameIndex); for (int rowIndex = sheet.getFirstRowNum(); rowIndex <= sheet.getLastRowNum(); rowIndex++) { row = sheet.getRow(rowIndex); for (int i = row.getFirstCellNum(); i < row.getLastCellNum(); i++) if (row.getCell(i).getCellType() != HSSFCell.CELL_TYPE_STRING) returnMsg += "[ " + fileName + " ]" + (row.getRowNum() + 1) + "" + "" + (i + 1) + "???<br>"; if (!"".equals(returnMsg)) return returnMsg; saMerNo = row.getCell(0).getStringCellValue(); // ? if (saMerNo.getBytes().length > 15) return "[ " + fileName + " ]" + (row.getRowNum() + 1) + "???<br>"; sql = "select mcht_nm,eng_name,bank_no from TBL_MCHT_BASE_INF where MCHT_NO = '" + saMerNo + "'"; dataList = CommonFunction.getCommQueryDAO().findBySQLQuery(sql); if (dataList.size() == 0) return "[ " + fileName + " ]" + (row.getRowNum() + 1) + "??<br>"; // ?? saMerChName = dataList.get(0)[0].toString(); // ?? saMerEnName = dataList.get(0)[1].toString(); saZoneNo = dataList.get(0)[2].toString(); saLimitAmt = row.getCell(1).getStringCellValue(); // saLimitAmt = CommonFunction.transYuanToFen(saLimitAmt); // ?? if (!CommonFunction.isAllDigit(saLimitAmt)) return "[ " + fileName + " ]" + (row.getRowNum() + 1) + "????<br>"; if (saLimitAmt.getBytes().length > 12) return "[ " + fileName + " ]" + (row.getRowNum() + 1) + "???<br>"; saAction = row.getCell(2).getStringCellValue(); // ? if (!("1".equals(saAction) || "2".equals(saAction) || "3".equals(saAction) || "4".equals(saAction))) return "[ " + fileName + " ]" + (row.getRowNum() + 1) + "???<br>"; // ?????? tblCtlMchtInf = new TblCtlMchtInf(); tblCtlMchtInf.setId(saMerNo); tblCtlMchtInf.setSaMerChName(saMerChName); tblCtlMchtInf.setSaMerEnName(saMerEnName); tblCtlMchtInf.setSaZoneNo(saZoneNo); tblCtlMchtInf.setSaLimitAmt(saLimitAmt); tblCtlMchtInf.setSaAction(saAction); tblCtlMchtInf.setSaInitZoneNo(saBrhId); tblCtlMchtInf.setSaInitOprId(saOprId); tblCtlMchtInf.setSaInitTime(saInitTime); tblCtlMchtInfDAO.saveOrUpdate(tblCtlMchtInf); } fileInputStream.close(); fileNameIndex++; } return Constants.SUCCESS_CODE; } /** * @return the tblCtlMchtInfDAO */ public TblCtlMchtInfDAO getTblCtlMchtInfDAO() { return tblCtlMchtInfDAO; } /** * @param tblCtlMchtInfDAO the tblCtlMchtInfDAO to set */ public void setTblCtlMchtInfDAO(TblCtlMchtInfDAO tblCtlMchtInfDAO) { this.tblCtlMchtInfDAO = tblCtlMchtInfDAO; } /* * (non-Javadoc) * @see com.allinfinance.bo.T40202BO#delete(java.lang.String) */ public void delete(String key) { tblCtlMchtInfDAO.delete(key); } }