com.sany.appbom.service.AppBomServiceImpl.java Source code

Java tutorial

Introduction

Here is the source code for com.sany.appbom.service.AppBomServiceImpl.java

Source

/*
 * @(#)AppBomServiceImpl.java
 * 
 * Copyright @ 2001-2011 SANY Group Co.,Ltd.
 * All right reserved.
 * 
 * ?????
 * ??????
 * This software is the confidential and proprietary information
 * of SANY Group Co, Ltd. 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
 * SANY Group Co, Ltd.
 */
package com.sany.appbom.service;

import java.util.List;

import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
import org.apache.poi.xssf.usermodel.XSSFSheet;

import com.frameworkset.orm.transaction.TransactionManager;
import com.frameworkset.util.ListInfo;
import com.sany.appbom.entity.AppBom;
import com.sany.appbom.entity.AppBomCondition;

public class AppBomServiceImpl {
    private com.frameworkset.common.poolman.ConfigSQLExecutor executor;

    /**
     * ?sql?????
     * @throws AppBomException 
     */
    public boolean delete(String id) throws AppBomException {
        try {
            executor.delete("deleteByKey", id);
        } catch (Throwable e) {
            throw new AppBomException("delete appbom failed::id=" + id, e);
        }
        return true;
    }

    /**
     * ?sql????????
     * ???????
     * @param beans
     * @return
     * @throws AppBomException 
     */
    public boolean deletebatch(String... ids) throws AppBomException {
        TransactionManager tm = new TransactionManager();
        try {
            tm.begin();
            executor.deleteByKeys("deleteByKey", ids);
            tm.commit();
        } catch (Throwable e) {

            throw new AppBomException("batch delete appbom failed::ids=" + ids, e);
        } finally {
            tm.release();
        }

        return true;
    }

    /**
     * ?
     * @param idmap
     * @return
     * @throws AppBomException 
     */
    public AppBom getAppBom(String id) throws AppBomException {
        try {
            AppBom bean = executor.queryObject(AppBom.class, "selectById", id);
            return bean;
        } catch (Throwable e) {
            throw new AppBomException("get appbom failed:id=" + id, e);
        }

    }

    /**
     * ?
     * @param bean
     * @return
     * @throws AppBomException 
     */
    public boolean update(AppBom bean) throws AppBomException {

        try {
            executor.updateBean("updateAppBom", bean);
        } catch (Throwable e) {

            throw new AppBomException("update appbom failed:id=" + bean.getId(), e);
        }
        return true;
    }

    /**
     * ?
     * @param bean
     * @return
     * @throws AppBomException 
     */
    public boolean addBom(AppBom bean) throws AppBomException {

        try {
            //PrimaryKey?id
            //         String uuid="";
            //         if(bean.getId()==null||"".equals(bean.getId())){
            //            uuid=DBUtil.getPool().getIdGenerator().getNextId();
            //            bean.setId(uuid);
            //         }
            executor.insertBean("batchsave", bean);
        } catch (Throwable e) {
            throw new AppBomException("add appbom failed:", e);
        }
        return true;
    }

    /**
     * ??
     * @param offset ???
     * @param pagesize ?
     * @param appcondition
     * @return
     * @throws AppBomException 
     */
    public ListInfo queryListInfoBean(long offset, int pagesize, AppBomCondition appcondition)
            throws AppBomException {
        ListInfo datas = null;
        try {
            datas = executor.queryListInfoBean(AppBom.class, "queryListAppBom", offset, pagesize, appcondition);
        } catch (Exception e) {
            throw new AppBomException("pagine query appbom failed:", e);
        }
        return datas;
    }

    /**
     * ???
     * @param appcondition
     * @return
     * @throws AppBomException 
     */
    public List<AppBom> queryListBean(AppBomCondition appcondition) throws AppBomException {

        List<AppBom> beans = null;
        try {
            beans = executor.queryListBean(AppBom.class, "queryListAppBom", appcondition);
        } catch (Exception e) {
            throw new AppBomException("query appbom failed:", e);
        }
        return beans;
    }

    /**
     * ???
     * @param appcondition
     * @return
     * @throws AppBomException 
     */
    public int queryCntByCondition(AppBomCondition appcondition) throws AppBomException {
        int cnt = 0;
        try {
            cnt = executor.queryTFieldBean(int.class, "queryCntByCondition", appcondition);
        } catch (Exception e) {
            throw new AppBomException("count appbom failed:", e);
        }
        return cnt;
    }

    /**
     * ??
     * @param map
     * @return
     * @throws AppBomException 
     */
    public int checkBmExist(String bm) throws AppBomException {
        int cnt = 0;
        try {
            cnt = executor.queryTField(int.class, "CheckBmExist", bm);
        } catch (Exception e) {
            throw new AppBomException("check Bm Exist failed:", e);
        }
        return cnt;
    }

    /**
     * ?
     * @param soft_level
     * @return
     */
    public String getSoftLevel(Integer soft_level) {
        String ret = "";
        switch (soft_level) {
        case 1:
            ret = "";
            break;
        case 2:
            ret = "";
            break;
        case 3:
            ret = "";
            break;
        case 10:
            ret = "";
            break;
        }
        return ret;
    }

    /**
     * ??
     * @param soft_level
     * @return
     */
    public String getState(Integer state) {
        String ret = "";
        switch (state) {
        case 1:
            ret = "";
            break;
        case 2:
            ret = "?";
            break;
        case 3:
            ret = "??";
            break;
        case 4:
            ret = "?";
            break;
        case 5:
            ret = "";
            break;
        case 6:
            ret = "?";
            break;
        case 7:
            ret = "";
            break;
        }
        return ret;
    }

    /**
     * ??
     * @param soft_level
     * @return
     */
    public String getRdType(Integer rd_type) {
        String ret = "";
        switch (rd_type) {
        case 1:
            ret = "";
            break;
        case 2:
            ret = "";
            break;
        case 3:
            ret = "?";
            break;
        case 4:
            ret = "";
            break;
        case 5:
            ret = "+";
            break;
        }
        return ret;
    }

    /**
     * ?
     * @param soft_level
     * @return
     */
    public String getPlanType(Integer plan_type) {
        String ret = "";
        switch (plan_type) {
        case 1:
            ret = "";
            break;
        case 2:
            ret = "";
            break;
        case 3:
            ret = "";
            break;
        case 10:
            ret = "";
            break;
        }
        return ret;
    }

    /**
     * ???
     * @param soft_level
     * @return
     */
    public String getManageScope(Integer manage_scope) {
        String ret = "";
        switch (manage_scope) {
        case 1:
            ret = "?";
            break;
        case 2:
            ret = "?+?";
            break;
        case 3:
            ret = "?+?+";
            break;
        case 4:
            ret = "?+?++UI";
            break;
        }
        return ret;
    }

    public void setExcelData(Workbook workbook, boolean is2003, List<AppBom> beans) {
        try {
            Sheet sheet = null;
            CellStyle cellStyle = null;
            Font font = null;
            if (is2003) {
                sheet = (HSSFSheet) workbook.getSheetAt(0);

            } else {
                sheet = (XSSFSheet) workbook.getSheetAt(0);
                cellStyle = (XSSFCellStyle) workbook.createCellStyle();
            }
            for (int i = 0; i < beans.size(); i++) {
                AppBom bom = beans.get(i);
                Row row = null;
                row = sheet.createRow(i + 2);
                row.setHeight((short) 450);
                row.createCell(0).setCellValue(bom.getBm());
                row.createCell(1).setCellValue(bom.getApp_name_en());
                row.createCell(2).setCellValue(bom.getApply_domain());
                row.createCell(3).setCellValue(bom.getApp_name());
                row.createCell(4).setCellValue(bom.getDescription());
                row.createCell(5).setCellValue(getSoftLevel(bom.getSoft_level()));
                row.createCell(6).setCellValue(bom.getSupplier());
                row.createCell(7).setCellValue(bom.getStart_year());
                row.createCell(8).setCellValue(getState(bom.getState()));
                row.createCell(9).setCellValue(getRdType(bom.getRd_type()));
                row.createCell(10).setCellValue(bom.getVersion_no());
                row.createCell(11).setCellValue(bom.getDomain_url());
                row.createCell(12).setCellValue(bom.getStruct_mode());
                row.createCell(13).setCellValue(bom.getSoft_language());
                row.createCell(14).setCellValue(bom.getDevelop_tool());
                row.createCell(15).setCellValue(bom.getDb_type());
                row.createCell(16).setCellValue(bom.getDepartment_develop());
                row.createCell(17).setCellValue(bom.getProduct_manager());
                row.createCell(18).setCellValue(bom.getDepartment_maintain());
                row.createCell(19).setCellValue(bom.getSys_manager());
                row.createCell(20).setCellValue(getPlanType(bom.getPlan_type()));
                row.createCell(21).setCellValue(bom.getEvolve_strategy());
                row.createCell(22).setCellValue(bom.getEvolve_plan());
                row.createCell(23).setCellValue(bom.getEvolve_depart());
                row.createCell(24).setCellValue(getManageScope(bom.getManage_scope()));
                row.createCell(25).setCellValue(bom.getMain_description());
            }
        } catch (Exception e) {
            e.printStackTrace();

        } finally {

        }
    }

    /**
     * 
     * @return
     */
    public com.frameworkset.common.poolman.ConfigSQLExecutor getExecutor() {
        return executor;
    }

    public void setExecutor(com.frameworkset.common.poolman.ConfigSQLExecutor executor) {
        this.executor = executor;
    }

    public String sayMvsHello(String duoduo) {
        return "Hello," + duoduo;
    }
}