/** * 功能:获取部门盘点设备明细Excel文件 * * @return File * @throws DataTransException */ public File getExportFile() throws DataTransException { File file = null; try { CostCheckResultModel modelProducer = (CostCheckResultModel) sqlProducer; SQLModel sqlModel = modelProducer.getPageQueryModel(); String reportTitle = "盘点结果报表(按部门)"; String fileName = reportTitle + ".xls"; String filePath = WorldConstant.USER_HOME; filePath += WorldConstant.FILE_SEPARATOR; filePath += fileName; TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setSourceConn(conn); rule.setTarFile(filePath); DataRange range = new DataRange(); rule.setDataRange(range); rule.setFieldMap(getFieldMap()); CustomTransData custData = new CustomTransData(); custData.setReportTitle(reportTitle); custData.setReportPerson(userAccount.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); rule.setCalPattern(LINE_PATTERN); TransferFactory factory = new TransferFactory(); DataTransfer transfer = factory.getTransfer(rule); transfer.transData(); file = (File) transfer.getTransResult(); } catch (SQLModelException ex) { ex.printLog(); throw new DataTransException(ex); } return file; }
/** * 功能:插入ets_item_info * * @throws QueryException * @throws DataHandleException */ private void insertEtsItemInfo(EtsItemInfoDTO etsItemInfo) throws DataHandleException { SQLModel sqlModel = null; try { sqlModel = modelProducer.getItemCreateModel(etsItemInfo); DBOperator.updateRecord(sqlModel, conn); } catch (SQLModelException ex) { ex.printLog(); throw new DataHandleException(ex); } }
/** * 功能:插入ETS_PA_PROJECTS_ALL * * @throws QueryException * @throws DataHandleException */ private void insertProjectInfo(EtsItemInfoDTO itemDTO, EtsFaAssetsDTO faDTO) throws DataHandleException { SQLModel sqlModel = null; try { sqlModel = modelProducer.getProjectCreateModel(itemDTO, faDTO); DBOperator.updateRecord(sqlModel, conn); } catch (SQLModelException ex) { ex.printLog(); throw new DataHandleException(ex); } }
/** * 功能:导出Excel文件。 * * @return File * @throws com.sino.base.exception.DataTransException */ public File exportFile() throws DataTransException { File file = null; try { DataTransfer transfer = null; SQLModel sqlModel = sqlProducer.getPageQueryModel(); TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setCalPattern(CalendarConstant.LINE_PATTERN); rule.setSourceConn(conn); String fileName = "基站地点统计表.xls"; String filePath = WorldConstant.USER_HOME; filePath += WorldConstant.FILE_SEPARATOR; filePath += fileName; rule.setTarFile(filePath); DataRange range = new DataRange(); rule.setDataRange(range); Map fieldMap = new HashMap(); fieldMap.put("WORKORDER_OBJECT_CODE", "地点编号"); fieldMap.put("WORKORDER_OBJECT_NAME", "地点简称"); fieldMap.put("WORKORDER_OBJECT_LOCATION", "所在地点"); fieldMap.put("ORGANIZATION_ID", "组织ID"); fieldMap.put("COUNTY_NAME", "所在区县"); fieldMap.put("DISABLE_DATE", "失效日期"); fieldMap.put("CATEGORY_NAME", "地点类别"); // fieldMap.put("IS_TEMP_ADDR", "是否临时地点"); fieldMap.put("CREATION_DATE", "创建日期"); fieldMap.put("CREATED_BY", "创建人"); fieldMap.put("PROJECT_NAME", "所属工程"); rule.setFieldMap(fieldMap); CustomTransData custData = new CustomTransData(); custData.setReportTitle(fileName); custData.setReportPerson(sfUser.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); /*rule.setSheetSize(1000);*/ // 设置分页显示 TransferFactory factory = new TransferFactory(); transfer = factory.getTransfer(rule); transfer.transData(); file = (File) transfer.getTransResult(); } catch (SQLModelException ex) { ex.printLog(); throw new DataTransException(ex); } return file; }
/** * 功能:导出Excel文件。 * * @return File * @throws com.sino.base.exception.DataTransException */ public File exportFileM() throws DataTransException { File file = null; try { // SQLModel sqlModel = sqlProducer.getPageQueryModel(); //获得查询的sql AmsHouseInfoDTO HLDTO = (AmsHouseInfoDTO) dtoParameter; GetMisHousInfoModel updateEII = new GetMisHousInfoModel(userAccount, HLDTO); SQLModel sqlModel = updateEII.getDispositionModel(); TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setCalPattern(CalendarConstant.LINE_PATTERN); rule.setSourceConn(conn); String fileName = "房屋土地信息表.xls"; String filePath = WorldConstant.USER_HOME; filePath += WorldConstant.FILE_SEPARATOR; filePath += fileName; rule.setTarFile(filePath); DataRange range = new DataRange(); rule.setDataRange(range); Map fieldMap = new HashMap(); fieldMap.put("BARCODE", "条码"); fieldMap.put("ITEM_NAME", "名称"); fieldMap.put("ITEM_SPEC", "型号"); fieldMap.put("HOUSE_ADDRESS", "地点"); fieldMap.put("HOUSE_AREA", "房屋面积"); fieldMap.put("OCCUPY_AREA", "占地面积"); fieldMap.put("OFFICE_USAGE", "用途"); fieldMap.put("OFFICE_TYPE", "类型"); fieldMap.put("HOUSE_CERTIFICATE_NO", "房产证号"); fieldMap.put("LAND_CERTFICATE_NO", "土地证号"); fieldMap.put("ATTRIBUTE2", "是否处理"); rule.setFieldMap(fieldMap); CustomTransData custData = new CustomTransData(); custData.setReportTitle("房屋土地信息表"); custData.setReportPerson(userAccount.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); TransferFactory factory = new TransferFactory(); DataTransfer transfer = factory.getTransfer(rule); transfer.transData(); file = (File) transfer.getTransResult(); } catch (SQLModelException ex) { ex.printLog(); throw new DataTransException(ex); } return file; }
public File exportFile() throws DataTransException { File file = null; try { SQLModel sqlModel = sqlProducer.getPageQueryModel(); TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setSourceConn(conn); String fileName = "备件业务单据统计表.xls"; String filePath = WorldConstant.USER_HOME; filePath += WorldConstant.FILE_SEPARATOR; filePath += fileName; rule.setTarFile(filePath); DataRange range = new DataRange(); rule.setDataRange(range); Map fieldMap = new HashMap(); fieldMap.put("TRANS_NO", "单据号"); fieldMap.put("CREATED_USER", "创建人"); fieldMap.put("CREATION_DATE", "创建日期"); fieldMap.put("TRANS_STATUS_NAME", "单据状态"); fieldMap.put("TRANS_TYPE_NAME", "单据类型"); rule.setFieldMap(fieldMap); CustomTransData custData = new CustomTransData(); custData.setReportTitle(fileName); custData.setReportPerson(sfUser.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); /*rule.setSheetSize(1000);*/ // 设置分页显示 TransferFactory factory = new TransferFactory(); DataTransfer transfer = factory.getTransfer(rule); transfer.transData(); file = (File) transfer.getTransResult(); } catch (SQLModelException ex) { ex.printLog(); throw new DataTransException(ex); } return file; }
/** * 功能:导出未处理的Excel文件。 * * @return File * @throws com.sino.base.exception.DataTransException */ public File exportMisFile() throws DataTransException { File file = null; try { SQLModel sqlModel = sqlProducer.getPageQueryModel(); // 获得查询的sql TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setCalPattern(CalendarConstant.LINE_PATTERN); rule.setSourceConn(conn); String fileName = "未导入房屋土地信息表.xls"; String filePath = WorldConstant.USER_HOME; filePath += WorldConstant.FILE_SEPARATOR; filePath += fileName; rule.setTarFile(filePath); DataRange range = new DataRange(); rule.setDataRange(range); Map fieldMap = new HashMap(); fieldMap.put("TAG_NUMBER", "条码"); fieldMap.put("ASSETS_DESCRIPTION", "名称"); fieldMap.put("MODEL_NUMBER", "型号"); fieldMap.put("ASSIGNED_TO_NAME", "责任人"); fieldMap.put("DATE_PLACED_IN_SERVICE", "启用日期"); fieldMap.put("ASSETS_LOCATION", "地点"); rule.setFieldMap(fieldMap); CustomTransData custData = new CustomTransData(); custData.setReportTitle("信息表"); custData.setReportPerson(userAccount.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); TransferFactory factory = new TransferFactory(); DataTransfer transfer = factory.getTransfer(rule); transfer.transData(); file = (File) transfer.getTransResult(); } catch (SQLModelException ex) { ex.printLog(); throw new DataTransException(ex); } return file; }
public File exportFile() throws DataTransException { File file = null; try { ItemInfoDTO itemInfoDto = (ItemInfoDTO) dtoParameter; if (itemInfoDto.getQryType().equals(WebAttrConstant.BY_DAIWEI)) { SQLModel sqlModel = sqlProducer.getPageQueryModel(); TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setCalPattern(CalendarConstant.LINE_PATTERN); rule.setSourceConn(conn); String fileName = "设备信息.xls"; String filePath = WorldConstant.USER_HOME; filePath += WorldConstant.FILE_SEPARATOR; filePath += fileName; rule.setTarFile(filePath); DataRange range = new DataRange(); rule.setDataRange(range); Map fieldMap = new HashMap(); // fieldMap.put("ORG_NAME", "公司"); fieldMap.put("BARCODE", "条码"); fieldMap.put("ITEM_NAME", "设备名称"); fieldMap.put("ITEM_SPEC", "规格型号"); fieldMap.put("WORKORDER_OBJECT_CODE", "地点编号"); fieldMap.put("WORKORDER_OBJECT_LOCATION", "所在地点"); fieldMap.put("NAME", "代维公司"); rule.setFieldMap(fieldMap); CustomTransData custData = new CustomTransData(); custData.setReportTitle("设备信息"); custData.setReportPerson(sfUser.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); TransferFactory factory = new TransferFactory(); DataTransfer transfer = factory.getTransfer(rule); transfer.transData(); file = (File) transfer.getTransResult(); } else { SQLModel sqlModel = sqlProducer.getPageQueryModel(); TransRule rule = new TransRule(); rule.setDataSource(sqlModel); rule.setCalPattern(CalendarConstant.LINE_PATTERN); rule.setSourceConn(conn); String fileName = "设备信息.xls"; String filePath = WorldConstant.USER_HOME; filePath += WorldConstant.FILE_SEPARATOR; filePath += fileName; rule.setTarFile(filePath); DataRange range = new DataRange(); rule.setDataRange(range); Map fieldMap = new HashMap(); // fieldMap.put("ORG_NAME", "公司"); fieldMap.put("BARCODE", "条码"); fieldMap.put("ITEM_NAME", "设备名称"); fieldMap.put("ITEM_SPEC", "规格型号"); fieldMap.put("ITEM_CATEGORY", "设备分类"); fieldMap.put("START_DATE", "启用日期"); fieldMap.put("PROJECT_NAME", "所属工程"); fieldMap.put("WORKORDER_OBJECT_NAME", "所属地点"); fieldMap.put("COUNTY_NAME", "所属区县"); rule.setFieldMap(fieldMap); CustomTransData custData = new CustomTransData(); custData.setReportTitle("设备信息"); custData.setReportPerson(sfUser.getUsername()); custData.setNeedReportDate(true); rule.setCustData(custData); TransferFactory factory = new TransferFactory(); DataTransfer transfer = factory.getTransfer(rule); transfer.transData(); file = (File) transfer.getTransResult(); } } catch (SQLModelException ex) { ex.printLog(); throw new DataTransException(ex); } return file; }
public void performTask(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String forwardURL = ""; Message message = SessionUtil.getMessage(req); Connection conn = null; try { SfUserDTO user = (SfUserDTO) getUserAccount(req); Request2DTO req2DTO = new Request2DTO(); req2DTO.setDTOClassName(AmsVendorInfoDTO.class.getName()); AmsVendorInfoDTO dto = (AmsVendorInfoDTO) req2DTO.getDTO(req); String action = dto.getAct(); conn = getDBConnection(req); SpareVendorDAO rptDAO = new SpareVendorDAO(user, dto, conn); if (action.equals("")) { req.setAttribute(QueryConstant.QUERY_DTO, dto); forwardURL = AssetsURLList.SPARE_VENDOR_QUERY; } else if (action.equals(AssetsActionConstant.QUERY_ACTION)) { BaseSQLProducer sqlProducer = new SpareVendorModel(user, dto); PageQueryDAO pageDAO = new PageQueryDAO(req, conn, sqlProducer); pageDAO.setCalPattern(LINE_PATTERN); pageDAO.produceWebData(); req.setAttribute(QueryConstant.QUERY_DTO, dto); forwardURL = AssetsURLList.SPARE_VENDOR_QUERY; } else if (action.equals(WebActionConstant.NEW_ACTION)) { String VendorId = rptDAO.getVendorId(); dto.setVendorId(VendorId); req.setAttribute(QueryConstant.QUERY_DTO, dto); forwardURL = AssetsURLList.SPARE_VENDOR_INFO; } else if (action.equals(WebActionConstant.CREATE_ACTION)) { rptDAO.setServletConfig(getServletConfig(req)); rptDAO.createData(); message = rptDAO.getMessage(); forwardURL = AssetsURLList.SPARE_VENDOR_SERVLET; } else if (action.equals(WebActionConstant.UPDATE_ACTION)) { rptDAO.setServletConfig(getServletConfig(req)); rptDAO.updateData(); message = rptDAO.getMessage(); forwardURL = AssetsURLList.SPARE_VENDOR_SERVLET; } else if (action.equals(AssetsActionConstant.DETAIL_ACTION)) { rptDAO.setDTOClassName(AmsVendorInfoDTO.class.getName()); AmsVendorInfoDTO ridDto = (AmsVendorInfoDTO) rptDAO.getDataByPrimaryKey(); if (ridDto == null) { dto = new AmsVendorInfoDTO(); message = getMessage(MsgKeyConstant.DATA_NOT_EXIST); message.setIsError(true); } req.setAttribute(QueryConstant.QUERY_DTO, ridDto); forwardURL = AssetsURLList.SPARE_VENDOR_INFO; } else if (action.equals(WebActionConstant.DELETE_ACTION)) { rptDAO.deleteData(); message = rptDAO.getMessage(); forwardURL = AssetsURLList.SPARE_VENDOR_SERVLET; } else if (action.equals("verifyworkNo")) { String vendorName = req.getParameter("vendorName"); boolean success = rptDAO.doVerify(vendorName); PrintWriter out = res.getWriter(); if (success) { out.print("Y"); } out.flush(); out.close(); } else { message = getMessage(MsgKeyConstant.INVALID_REQ); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } } catch (PoolPassivateException ex) { ex.printLog(); message = getMessage(AssetsMessageKeys.POOL_PASSIVATE_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (DTOException ex) { ex.printLog(); message = getMessage(AssetsMessageKeys.DTO_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (QueryException ex) { ex.printLog(); message = getMessage(AssetsMessageKeys.QUERY_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (DataHandleException ex) { ex.printLog(); message = getMessage(AssetsMessageKeys.COMMON_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (SQLModelException ex) { ex.printLog(); message = getMessage(AssetsMessageKeys.COMMON_ERROR); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (ContainerException e) { e.printStackTrace(); } finally { closeDBConnection(conn); setHandleMessage(req, message); if (!StrUtil.isEmpty(forwardURL)) { ServletForwarder forwarder = new ServletForwarder(req, res); forwarder.forwardView(forwardURL); } } }
public void performTask(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { String forwardURL = ""; Message message = SessionUtil.getMessage(req); String action = StrUtil.nullToString(req.getParameter("act")); Connection conn = null; try { SfUserDTO user = (SfUserDTO) SessionUtil.getUserAccount(req); AmsItemAllocateHDTO dtoParameter = null; Request2DTO req2DTO = new Request2DTO(); req2DTO.setDTOClassName(AmsItemAllocateHDTO.class.getName()); dtoParameter = (AmsItemAllocateHDTO) req2DTO.getDTO(req); conn = getDBConnection(req); OptionProducer optProducer = new OptionProducer(user, conn); if (action.equals("")) { String orderStatus = optProducer.getDictOption("SPARE_ORDER_STATUS", dtoParameter.getTransStatus()); req.setAttribute(WebAttrConstant.TRANS_STATUS, orderStatus); String invOption = optProducer.getInvOption(dtoParameter.getFromObjectNo()); req.setAttribute(WebAttrConstant.INV_OPTION, invOption); forwardURL = "/nm/spare2/bjdbdy.jsp"; } else if (action.equals(WebActionConstant.QUERY_ACTION)) { BaseSQLProducer sqlProducer = new BjdbdyModel(user, dtoParameter); PageQueryDAO pageDAO = new PageQueryDAO(req, conn, sqlProducer); pageDAO.setCalPattern(CalendarConstant.LINE_PATTERN); pageDAO.produceWebData(); String orderStatus = optProducer.getDictOption("SPARE_ORDER_STATUS", dtoParameter.getTransStatus()); req.setAttribute(WebAttrConstant.TRANS_STATUS, orderStatus); String invOption = optProducer.getInvOption(dtoParameter.getFromObjectNo()); req.setAttribute(WebAttrConstant.INV_OPTION, invOption); forwardURL = "/nm/spare2/bjdbdy.jsp"; } else if (action.equals(WebActionConstant.DETAIL_ACTION)) { BjswjyckDAO itemTransHDAO = new BjswjyckDAO(user, dtoParameter, conn); itemTransHDAO.setDTOClassName(AmsItemAllocateHDTO.class.getName()); AmsItemAllocateHDTO amsItemTransH = (AmsItemAllocateHDTO) itemTransHDAO.getDataByPrimaryKey(); if (amsItemTransH == null) { amsItemTransH = new AmsItemAllocateHDTO(); message = getMessage(MsgKeyConstant.DATA_NOT_EXIST); message.setIsError(true); } req.setAttribute("AIT_HEADER", amsItemTransH); String freightDate = req.getParameter("freightDate"); WebPageView wpv = new WebPageView(req, conn); wpv.setPrintProp(true); BaseSQLProducer sqlProducer = new BjswjyckModel(user, dtoParameter); wpv.produceWebData(sqlProducer.getDataByForeignKeyModel(dtoParameter.getTransId())); forwardURL = "/nm/spare2/bjdbdyDetail.jsp"; } else { message = getMessage(MsgKeyConstant.INVALID_REQ); message.setIsError(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } } catch (PoolPassivateException ex) { ex.printLog(); message = getMessage(MsgKeyConstant.POOL_PASSIVATE_ERROR); message.setIsError(true); message.setNeedBack(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (DTOException ex) { ex.printLog(); message = getMessage(MsgKeyConstant.DTO_ERROR); message.setIsError(true); message.setNeedBack(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (QueryException ex) { ex.printLog(); message = getMessage(MsgKeyConstant.QUERY_ERROR); message.setIsError(true); message.setNeedBack(true); forwardURL = MessageConstant.MSG_PRC_SERVLET; } catch (SQLModelException e) { e .printStackTrace(); // To change body of catch statement use File | Settings | File // Templates. } finally { DBManager.closeDBConnection(conn); setHandleMessage(req, message); ServletForwarder forwarder = new ServletForwarder(req, res); forwarder.forwardView(forwardURL); } }