forms.SrmHome.SrmAdministration.java Source code

Java tutorial

Introduction

Here is the source code for forms.SrmHome.SrmAdministration.java

Source

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package forms.SrmHome;

import common.AjaxResponse;
import common.LanguageNational;
import java.io.OutputStream;
import java.sql.SQLException;
import java.text.ParseException;
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 java.util.logging.Level;
import java.util.logging.Logger;
import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFRichTextString;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import srm.entity.CUX_PON_ZB_HEADERS_ALL;
import srm.entity.CUX_SRM_ATTACHMENT;
import srm.entity.CUX_TS_HEADERS_ALL;
import srm.entity.CUX_ZB_HEADERS_ALL;
import srm.service.CuxZbService;
import srm.service.CuxZbServiceImpl;
import xx.mvc.context.ActionContext;
import xx.mvc.file.MultipartFile;
import xx.mvc.util.FormUtil;

/**
 * ??
 *
 * @author zac2078106
 */
public class SrmAdministration {

    private final CuxZbService zbService = new CuxZbServiceImpl();

    public void onLoad(Map mapRequest, Map mapResponse) {
        try {
            List<CUX_TS_HEADERS_ALL> tsHeaders = zbService.getTsHeadersAll();
            if (tsHeaders == null || tsHeaders.isEmpty()) {
                AjaxResponse.jsonTOView(" ");
            } else {
                mapRequest.put("tsHeaders", tsHeaders);
            }
            List<Map> list_tsHeaders = new ArrayList();
            for (int i = 0; i < tsHeaders.size(); i++) {
                Map map = new HashMap();
                int id = tsHeaders.get(i).getTs_header_id();
                String type = tsHeaders.get(i).getTs_type();//
                String comp_feed_type = tsHeaders.get(i).getComp_feed_type();//??
                String title = tsHeaders.get(i).getTs_title();//
                String people = tsHeaders.get(i).getTs_contact();//
                Date date = tsHeaders.get(i).getTs_date();//
                String reply = tsHeaders.get(i).getTs_reply();//???
                String reply_contact = tsHeaders.get(i).getTs_reply_contact();//??
                Date reply_date = tsHeaders.get(i).getTs_to_time();//?
                String description = tsHeaders.get(i).getTs_description();//
                map.put("id", id);
                map.put("type", type);
                map.put("comp_feed_type", comp_feed_type);
                map.put("title", title);
                map.put("people", people);
                map.put("date", new SimpleDateFormat("yyyy-MM-dd").format(date));
                map.put("reply", reply);
                map.put("reply_contact", reply_contact);
                map.put("reply_date", new SimpleDateFormat("yyyy-MM-dd").format(reply_date));
                map.put("description", description);
                list_tsHeaders.add(map);
            }
            mapRequest.put("json_tsHeaders", JSONArray.fromObject(list_tsHeaders));
            //?
            List<CUX_ZB_HEADERS_ALL> zbHeaders = zbService.getZbHeadersAll();
            if (zbHeaders == null || zbHeaders.isEmpty()) {
                AjaxResponse.jsonTOView(" ");
            } else {
                mapRequest.put("zbHeaders", zbHeaders);
            }
            List<Map> list_ponHeaders = new ArrayList();
            for (int i = 0; i < zbHeaders.size(); i++) {
                Map map = new HashMap();
                Map ponMap = new HashMap();
                int zb_header_id = zbHeaders.get(i).getZb_header_id();
                map.put("zb_header_id", zb_header_id);
                List<CUX_PON_ZB_HEADERS_ALL> ponHeaders = zbService.getPonZbHeadersAllById(map);
                ponMap.put("zb_header_id", zb_header_id);
                ponMap.put("ponHeaders", ponHeaders);
                list_ponHeaders.add(ponMap);
            }
            mapRequest.put("json_ponHeaders", JSONArray.fromObject(list_ponHeaders));

            List<Map> list_zbHeaders = new ArrayList();
            for (int i = 0; i < zbHeaders.size(); i++) {
                Map map = new HashMap();
                int zb_header_id = zbHeaders.get(i).getZb_header_id();//id
                int num = 0;
                String zb_type = zbHeaders.get(i).getZb_type();//
                String zb_project_description = zbHeaders.get(i).getZb_project_description();//??
                String zb_project_no = zbHeaders.get(i).getZb_project_no();//?
                String zb_project_address = zbHeaders.get(i).getZb_project_address();//
                Date zb_enrol_end_date = zbHeaders.get(i).getZb_enrol_end_date();//??
                Date zb_creation_date = zbHeaders.get(i).getZb_creation_date();//?
                String zb_buyer = zbHeaders.get(i).getZb_buyer();//??
                String zb_status = zbHeaders.get(i).getZb_status();//?

                map.put("zb_header_id", zb_header_id);
                map.put("num", num);
                map.put("zb_type", zb_type);
                map.put("zb_project_description", zb_project_description);
                map.put("zb_project_no", zb_project_no);
                map.put("zb_project_address", zb_project_address);
                map.put("zb_enrol_end_date", new SimpleDateFormat("yyyy-MM-dd").format(zb_enrol_end_date));
                map.put("zb_creation_date", new SimpleDateFormat("yyyy-MM-dd").format(zb_creation_date));
                map.put("zb_buyer", zb_buyer);
                map.put("zb_status", zb_status);
                list_zbHeaders.add(map);
            }
            JSONArray json_zbHeaders = JSONArray.fromObject(list_zbHeaders);
            //json??
            mapRequest.put("json_zbHeaders", json_zbHeaders);
        } catch (Exception ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * ???
     *
     * @param mapRequest
     * @param mapResponse
     */
    public void submit_publish(Map mapRequest, Map mapResponse) {
        String zb_type = FormUtil.getStr("zb_type", mapRequest);//
        String zb_project_description = FormUtil.getStr("zb_project_description", mapRequest);//??
        String zb_project_no = FormUtil.getStr("zb_project_no", mapRequest);//?
        String zb_project_city = FormUtil.getStr("zb_project_city", mapRequest);//
        String zb_project_date = FormUtil.getStr("zb_project_date", mapRequest);///
        String zb_project_address = FormUtil.getStr("zb_project_address", mapRequest);///
        String zb_flie_je = FormUtil.getStr("zb_flie_je", mapRequest);//
        String zb_vendor_bond = FormUtil.getStr("zb_vendor_bond", mapRequest);//??
        String zb_corporation = FormUtil.getStr("zb_corporation", mapRequest);//??
        String zb_buyer = FormUtil.getStr("zb_buyer", mapRequest);//??/
        String zb_contactor = FormUtil.getStr("zb_contactor", mapRequest);//?
        String zb_tel = FormUtil.getStr("zb_tel", mapRequest);//??
        String zb_mail = FormUtil.getStr("zb_mail", mapRequest);//
        String zb_answer_date = FormUtil.getStr("zb_answer_date", mapRequest);//
        String zb_bid_start_date = FormUtil.getStr("zb_bid_start_date", mapRequest);//
        String zb_bid_end_date = FormUtil.getStr("zb_bid_end_date", mapRequest);//
        String zb_open_date = FormUtil.getStr("zb_open_date", mapRequest);//
        String zb_appeal_date = FormUtil.getStr("zb_appeal_date", mapRequest);//
        String zb_enrol_end_date = FormUtil.getStr("zb_enrol_end_date", mapRequest);//??
        String zb_memo = FormUtil.getStr("zb_memo", mapRequest);//

        //?
        String[] filenames = FormUtil.getStrArr("filenamelist", mapRequest);//??
        String[] file_ids = FormUtil.getStrArr("fileidlist", mapRequest);//ID

        CUX_ZB_HEADERS_ALL zbheaders = new CUX_ZB_HEADERS_ALL();
        List<CUX_SRM_ATTACHMENT> srmAtts = new ArrayList<CUX_SRM_ATTACHMENT>();
        try {
            String seq_id = zbService.getZbHeadersID();//??ID
            int zb_header_id = Integer.valueOf(seq_id);
            zbheaders.setZb_header_id(zb_header_id);
            zbheaders.setZb_type(zb_type);//
            zbheaders.setZb_project_description(zb_project_description);//??
            zbheaders.setZb_project_no(zb_project_no);//?
            zbheaders.setZb_project_city(zb_project_city);//
            zbheaders.setZb_project_date(new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(zb_project_date));/////
            zbheaders.setZb_project_address(zb_project_address);///
            zbheaders.setZb_flie_je(zb_flie_je);//
            zbheaders.setZb_vendor_bond(zb_vendor_bond);//??
            zbheaders.setZb_corporation(zb_corporation);//??
            zbheaders.setZb_buyer(zb_buyer);//??/
            zbheaders.setZb_contactor(zb_contactor);//?
            zbheaders.setZb_tel(zb_tel);//??
            zbheaders.setZb_mail(zb_mail);//
            zbheaders.setZb_answer_date(new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(zb_answer_date));//
            zbheaders.setZb_bid_start_date(new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(zb_bid_start_date));//
            zbheaders.setZb_bid_end_date(new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(zb_bid_end_date));//
            zbheaders.setZb_open_date(new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(zb_open_date));//
            zbheaders.setZb_appeal_date(new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(zb_appeal_date));//
            zbheaders.setZb_enrol_end_date(new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(zb_enrol_end_date));//??
            zbheaders.setZb_memo(zb_memo);//

            zbheaders.setZb_created_by(1);
            zbheaders.setZb_creation_date(new Date());
            zbheaders.setZb_last_updated_by(1);
            zbheaders.setZb_last_update_date(new Date());
            zbheaders.setApprove_by(0);

            if (file_ids != null && file_ids.length > 0) {
                for (int j = 0; j < file_ids.length; j++) {
                    CUX_SRM_ATTACHMENT srmAtt = new CUX_SRM_ATTACHMENT();
                    String newfilename = file_ids[j] + filenames[j].substring(filenames[j].indexOf("."));
                    String path = "D:\\srm_upload\\zbfile\\" + newfilename;
                    srmAtt.setId(Integer.valueOf(file_ids[j]));
                    srmAtt.setRealfilename(filenames[j]);
                    srmAtt.setHeader_id(zb_header_id);
                    srmAtt.setDel(0);
                    srmAtt.setFiletype("ZB_FILE");//
                    srmAtt.setCreated_by(59200);
                    srmAtt.setCreation_date(new Date());
                    srmAtt.setLast_updated_by(1);
                    srmAtt.setLast_update_date(new Date());
                    srmAtt.setFilename(newfilename);//??
                    srmAtt.setFilepath(path);//
                    srmAtts.add(srmAtt);
                }
            }
        } catch (Exception ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            boolean flag = zbService.insertZbHeadersAll(zbheaders, srmAtts);
            if (flag) {
                AjaxResponse.writeOutString(
                        "<script>window.location.href='../SrmHome/SrmAdministration.jsp';</script>");
            } else {
                AjaxResponse.writeOutString(
                        "<script>window.location.href='../SrmHome/SrmAdministration.jsp';</script>");
                throw new Exception("?");
            }
        } catch (Exception ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    /**
     * ??????
     * @param mapRequest
     * @param mapResponse 
     */
    public void delete_zbHeaders(Map mapRequest, Map mapResponse) {
        String zb_header_id = FormUtil.getStr("id", mapRequest);//?ID
        Map map = new HashMap();
        map.put("zb_header_id", Integer.parseInt(zb_header_id));
        try {
            boolean flag = zbService.deleteCuxHeadersAll(map);
            if (!flag) {
                throw new Exception("");
            }
        } catch (Exception ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    /**
     * ??json?
     * @param mapRequest
     * @param mapResponce 
     */
    public void get_jsonHeaders(Map mapRequest, Map mapResponce) {
        try {
            Map map = new HashMap();
            List<CUX_ZB_HEADERS_ALL> zbHeaders = zbService.getZbHeadersAll();
            List<Map> list_ponHeaders = new ArrayList();
            for (int i = 0; i < zbHeaders.size(); i++) {
                Map map1 = new HashMap();
                Map ponMap = new HashMap();
                int zb_header_id = zbHeaders.get(i).getZb_header_id();
                map1.put("zb_header_id", zb_header_id);
                List<CUX_PON_ZB_HEADERS_ALL> ponHeaders = zbService.getPonZbHeadersAllById(map1);
                ponMap.put("zb_header_id", zb_header_id);
                ponMap.put("ponHeaders", ponHeaders);
                list_ponHeaders.add(ponMap);
            }
            map.put("list_ponHeaders", list_ponHeaders);
            List<Map> list_zbHeaders = new ArrayList();
            for (int i = 0; i < zbHeaders.size(); i++) {
                Map mapa = new HashMap();
                int zb_header_id = zbHeaders.get(i).getZb_header_id();//id
                int num = 0;
                String zb_type = zbHeaders.get(i).getZb_type();//
                String zb_project_description = zbHeaders.get(i).getZb_project_description();//??
                String zb_project_no = zbHeaders.get(i).getZb_project_no();//?
                String zb_project_address = zbHeaders.get(i).getZb_project_address();//
                Date zb_enrol_end_date = zbHeaders.get(i).getZb_enrol_end_date();//??
                Date zb_creation_date = zbHeaders.get(i).getZb_creation_date();//?
                String zb_buyer = zbHeaders.get(i).getZb_buyer();//??
                String zb_status = zbHeaders.get(i).getZb_status();//?

                mapa.put("zb_header_id", zb_header_id);
                mapa.put("num", num);
                mapa.put("zb_type", zb_type);
                mapa.put("zb_project_description", zb_project_description);
                mapa.put("zb_project_no", zb_project_no);
                mapa.put("zb_project_address", zb_project_address);
                mapa.put("zb_enrol_end_date", new SimpleDateFormat("yyyy-MM-dd").format(zb_enrol_end_date));
                mapa.put("zb_creation_date", new SimpleDateFormat("yyyy-MM-dd").format(zb_creation_date));
                mapa.put("zb_buyer", zb_buyer);
                mapa.put("zb_status", zb_status);
                list_zbHeaders.add(mapa);
            }
            map.put("list_zbHeaders", list_zbHeaders);
            AjaxResponse.jsonTOView(map);
        } catch (Exception ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * ????
     *
     * @param mapRequest
     * @param mapResponse
     */
    public void reply_complaint(Map mapRequest, Map mapResponse) {
        String ts_header_id = FormUtil.getStr("ts_header_id", mapRequest);//ID
        String ts_reply_contact = FormUtil.getStr("ts_reply_contact", mapRequest);//?
        Map map = new HashMap();
        map.put("ts_header_id", ts_header_id);
        map.put("ts_reply_contact", ts_reply_contact);
        map.put("ts_to_time", new Date());
        map.put("last_update_date", new Date());
        map.put("ts_reply", "");
        map.put("created_by", 1);
        map.put("reply_person", "sysadmin");
        try {
            boolean flag = zbService.updateCuxTsHeadersAllByID(map);
            if (!flag) {
                throw new Exception("??");
            }
        } catch (Exception ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * ??
     * @param mapRequest
     * @param mapResponse
     * 
     */
    public void findTsHeadersListByItems(Map mapRequest, Map mapResponse) {
        try {
            String ts_type = FormUtil.getStr("ts_type", mapRequest).trim();
            String ts_title = FormUtil.getStr("ts_title", mapRequest).trim();
            String ts_reply = FormUtil.getStr("ts_reply", mapRequest).trim();
            String ts_contact = FormUtil.getStr("ts_contact", mapRequest).trim();
            String create_start = FormUtil.getStr("ts_create_start", mapRequest).trim();
            String ts_code = FormUtil.getStr("ts_code", mapRequest).trim();
            Date tcreate_start = null;
            if (!create_start.isEmpty()) {
                tcreate_start = new SimpleDateFormat("yyyy-MM-dd").parse(create_start);
            }
            String create_end = FormUtil.getStr("ts_create_end", mapRequest).trim();
            Date tcreate_end = null;
            if (!create_end.isEmpty()) {
                tcreate_end = new SimpleDateFormat("yyyy-MM-dd").parse(create_end);
            }
            Map map = new HashMap();
            map.put("ts_type", ts_type);
            map.put("ts_title", ts_title);
            map.put("ts_reply", ts_reply);
            map.put("ts_contact", ts_contact);
            map.put("create_start", tcreate_start);
            map.put("create_end", tcreate_end);
            map.put("ts_code", ts_code);
            List<CUX_TS_HEADERS_ALL> tsListByItems = zbService.findTsHeadersListByItems(map);
            if (tsListByItems == null || tsListByItems.isEmpty()) {
                AjaxResponse.jsonTOView("");
                //throw new Exception(LanguageNational.getValue("?"));
            }
            List<Map> list_tsHeadersItems = new ArrayList();
            for (CUX_TS_HEADERS_ALL tslist : tsListByItems) {
                Map ts_Lists = new HashMap();
                int ts_headers_id = tslist.getTs_header_id();//ID
                String comp_feed_type = tslist.getComp_feed_type();//??
                String tsType = tslist.getTs_type();//
                String tsTitle = tslist.getTs_title();//
                String tsDescription = tslist.getTs_description();//
                String tsTel = tslist.getTs_tel();//??
                String tsContact = tslist.getTs_contact();//?
                String tsDate = new SimpleDateFormat("yyyy-MM-dd").format(tslist.getTs_date());//
                String tsCreate = new SimpleDateFormat("yyyy-MM-dd").format(tslist.getCreate_date());//?
                String tsReply = tslist.getTs_reply();//??
                String tsReply_contact = tslist.getTs_reply_contact();//?
                String tsCompany = tslist.getTs_company();//???
                String tsMail = tslist.getTs_mail();//E-mail
                String tsTotime = new SimpleDateFormat("yyyy-MM-dd").format(tslist.getTs_to_time());//?
                ts_Lists.put("ts_type", tsType);
                ts_Lists.put("ts_headers_id", ts_headers_id);
                ts_Lists.put("comp_feed_type", comp_feed_type);
                ts_Lists.put("ts_contact", tsContact);
                ts_Lists.put("ts_title", tsTitle);
                ts_Lists.put("ts_description", tsDescription);
                ts_Lists.put("ts_tel", tsTel);
                ts_Lists.put("ts_date", tsDate);
                ts_Lists.put("ts_create", tsCreate);
                if (tsReply == null) {
                    ts_Lists.put("ts_reply", "?");
                } else {
                    ts_Lists.put("ts_reply", tsReply);
                }
                ts_Lists.put("ts_reply_contact", tsReply_contact);
                ts_Lists.put("ts_company", tsCompany);
                ts_Lists.put("ts_mail", tsMail);
                ts_Lists.put("ts_to_time", tsTotime);
                list_tsHeadersItems.add(ts_Lists);
            }
            Map tsMap = new HashMap();
            tsMap.put("list_tsHeadersItems", list_tsHeadersItems);
            AjaxResponse.jsonTOView(tsMap);
        } catch (SQLException ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        } catch (ParseException ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * ????
     * @param mapRequest
     * @param mapResponse 
     */
    public void findZbHeadersListByItems(Map mapRequest, Map mapResponse) {
        try {
            String zb_type = FormUtil.getStr("zb_type", mapRequest).trim();//
            String zb_project_description = FormUtil.getStr("zb_project_description", mapRequest).trim();//??
            String zb_project_no = FormUtil.getStr("zb_project_no", mapRequest).trim();//?
            String zb_enrol_end_date = "";
            zb_enrol_end_date = FormUtil.getStr("zb_enrol_end_date", mapRequest).trim();//??
            Date enrol_end_date = null;
            if (!zb_enrol_end_date.isEmpty()) {
                enrol_end_date = new SimpleDateFormat("yyyy-MM-dd").parse(zb_enrol_end_date);
            }
            String zb_creation_date = "";
            zb_creation_date = FormUtil.getStr("zb_creation_date", mapRequest).trim();//?
            Date creation_date = null;
            if (!zb_creation_date.isEmpty()) {
                creation_date = new SimpleDateFormat("yyyy-MM-dd").parse(zb_creation_date);
            }
            String zb_project_address = FormUtil.getStr("zb_project_address", mapRequest).trim();//
            String zb_start_person = FormUtil.getStr("zb_start_person", mapRequest).trim();//?
            String zb_buyer = FormUtil.getStr("zb_buyer", mapRequest).trim();//??/
            Map map = new HashMap();
            map.put("zb_type", zb_type);
            map.put("zb_project_description", zb_project_description);
            map.put("zb_project_no", zb_project_no);
            map.put("zb_enrol_end_date", zb_enrol_end_date);
            map.put("zb_creation_date", zb_creation_date);
            map.put("zb_project_address", zb_project_address);
            map.put("zb_start_person", zb_start_person);
            map.put("zb_buyer", zb_buyer);
            List<CUX_ZB_HEADERS_ALL> zbHeadersByItems = zbService.findZbHeadersListByItems(map);
            if (zbHeadersByItems == null || zbHeadersByItems.isEmpty()) {
                AjaxResponse.jsonTOView("");
            }
            List<Map> list_zbHeadersByItems = new ArrayList();
            for (CUX_ZB_HEADERS_ALL zblist : zbHeadersByItems) {
                Map zb_lists = new HashMap();
                int tzb_headers_id = zblist.getZb_header_id();
                String tzb_type = zblist.getZb_type();
                String tzb_project_description = zblist.getZb_project_description();
                String tzb_project_no = zblist.getZb_project_no();
                String tzb_project_address = zblist.getZb_project_address();
                String tzb_enrol_end_date = new SimpleDateFormat("yyyy-MM-dd HH:mm")
                        .format(zblist.getZb_enrol_end_date());
                String tzb_creation_date = new SimpleDateFormat("yyyy-MM-dd HH:mm")
                        .format(zblist.getZb_creation_date());
                String tzb_buyer = zblist.getZb_buyer();
                String tzb_status = zblist.getZb_status();
                zb_lists.put("zb_headers_id", tzb_headers_id);
                zb_lists.put("zb_type", tzb_type);
                zb_lists.put("zb_project_description", tzb_project_description);
                zb_lists.put("zb_project_no", tzb_project_no);
                zb_lists.put("zb_project_address", tzb_project_address);
                zb_lists.put("zb_enrol_end_date", tzb_enrol_end_date);
                zb_lists.put("zb_creation_date", tzb_creation_date);
                zb_lists.put("zb_buyer", tzb_buyer);
                zb_lists.put("zb_status", tzb_status);
                list_zbHeadersByItems.add(zb_lists);
            }
            Map zbMap = new HashMap();
            zbMap.put("list_zbHeadersByItems", list_zbHeadersByItems);
            AjaxResponse.jsonTOView(zbMap);
        } catch (ParseException ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        } catch (SQLException ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        } catch (java.lang.Exception ex) {
            Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    /**
     * 
     * @param mapRequest
     * @param mapResponse 
     */
    public void upload_zbFile(Map mapRequest, Map mapResponse) {
        MultipartFile singleFile = ((MultipartFile[]) mapRequest.get("zbfileinput"))[0];//
        Map map = new HashMap();
        if (singleFile != null) {
            try {
                String filename = singleFile.getOriginalFilename();
                String file_id = zbService.getFileID();//?ID
                singleFile.saveTo("D:\\srm_upload\\zbfile\\" + file_id + filename.substring(filename.indexOf(".")));
                map.put("filename", filename);
                map.put("file_id", file_id);
                AjaxResponse.jsonTOView(map);
            } catch (Exception ex) {
                Logger.getLogger(SrmAdministration.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    }

    /**
     * ID
     * @param mapRequest
     * @param mapResponse 
     */
    public void getSrmAttachment(Map mapRequest, Map mapResponse) {
        String header_id = FormUtil.getStr("header_id", mapRequest);
        String filetype = FormUtil.getStr("filetype", mapRequest);
        Map map = new HashMap();
        map.put("header_id", header_id);
        map.put("filetype", filetype);
        try {
            List<CUX_SRM_ATTACHMENT> srmatts = zbService.getSrmAtt(map);
            if (srmatts != null && !srmatts.isEmpty()) {
                mapRequest.put("srmatts", srmatts);
                List srmattslist = new ArrayList();
                for (CUX_SRM_ATTACHMENT srmatt : srmatts) {
                    Map maptp = new HashMap();
                    String filepath = srmatt.getFilepath();
                    String realfilename = srmatt.getRealfilename();
                    String filename = srmatt.getFilename();
                    String code = srmatt.getAttribute1();//?
                    int id = srmatt.getId();
                    maptp.put("filepath", filepath);
                    maptp.put("realfilename", realfilename);
                    maptp.put("filename", filename);
                    maptp.put("code", code);
                    maptp.put("id", id);
                    //                    maptp.put("header_id",header_id);
                    srmattslist.add(maptp);
                }
                Map attmap = new HashMap();
                attmap.put("srmattslist", srmattslist);
                attmap.put("header_id", header_id);
                AjaxResponse.jsonTOView(attmap);
            }
        } catch (SQLException ex) {
            Logger.getLogger(Login.class.getName()).log(Level.SEVERE, null, ex);
        }

    }

    /**
     * excel
     * @param mapRequest
     * @param mapResponse
     * @throws Exception 
     */
    public void exportExcel(Map mapRequest, Map mapResponse) throws Exception {
        HttpServletResponse response;
        OutputStream outStream = null;
        String zb_header_id = FormUtil.getStr("id", mapRequest);
        Map map = new HashMap();
        map.put("zb_header_id", zb_header_id);
        try {
            List<CUX_PON_ZB_HEADERS_ALL> ponHeaders = zbService.getPonZbHeadersAllById(map);
            //?????excel
            if (ponHeaders != null && ponHeaders.size() > 0) {
                HSSFWorkbook wb = new HSSFWorkbook();//
                HSSFSheet sheet = null;
                HSSFCellStyle style = wb.createCellStyle();
                style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
                style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
                style.setBorderRight(HSSFCellStyle.BORDER_THIN);
                style.setBorderTop(HSSFCellStyle.BORDER_THIN);
                sheet = wb.createSheet();
                //?
                //??Excel
                HSSFRow rowTable = sheet.createRow(0);//?
                rowTable.createCell((short) 0).setCellValue(new HSSFRichTextString("??"));
                rowTable.createCell((short) 1).setCellValue(new HSSFRichTextString("?"));
                rowTable.createCell((short) 2).setCellValue(new HSSFRichTextString("??"));
                rowTable.createCell((short) 3).setCellValue(new HSSFRichTextString("?"));
                rowTable.createCell((short) 4).setCellValue(new HSSFRichTextString("??"));
                rowTable.createCell((short) 5).setCellValue(new HSSFRichTextString("?"));
                rowTable.createCell((short) 6).setCellValue(new HSSFRichTextString("?BYD"));
                rowTable.createCell((short) 7).setCellValue(new HSSFRichTextString("?"));
                rowTable.createCell((short) 8).setCellValue(new HSSFRichTextString(""));
                //                rowTable.createCell((short) 9).setCellValue(new HSSFRichTextString(""));

                //??
                int START_ROW_NUMBER = 1;//2??
                for (int i = 0; i < ponHeaders.size(); i++) {
                    CUX_PON_ZB_HEADERS_ALL pon = ponHeaders.get(i);
                    //??
                    HSSFRow rowIndex = sheet.createRow(START_ROW_NUMBER + i);
                    HSSFCell zb_project_description = rowIndex.createCell((short) 0);
                    zb_project_description.setCellStyle(style);
                    zb_project_description.setCellValue(new HSSFRichTextString(pon.getZb_project_description()));//??
                    HSSFCell zb_project_no = rowIndex.createCell((short) 1);
                    zb_project_no.setCellStyle(style);
                    zb_project_no.setCellValue(new HSSFRichTextString(pon.getZb_project_no()));//?
                    HSSFCell description = rowIndex.createCell((short) 2);
                    description.setCellStyle(style);
                    description.setCellValue(new HSSFRichTextString(pon.getDescription()));//??
                    HSSFCell contactor = rowIndex.createCell((short) 3);
                    contactor.setCellStyle(style);
                    contactor.setCellValue(new HSSFRichTextString(pon.getContactor()));//?
                    HSSFCell tel = rowIndex.createCell((short) 4);
                    tel.setCellStyle(style);
                    tel.setCellValue(new HSSFRichTextString(pon.getTel()));//??
                    HSSFCell mail = rowIndex.createCell((short) 5);
                    mail.setCellStyle(style);
                    mail.setCellValue(new HSSFRichTextString(pon.getMail()));//?
                    HSSFCell status = rowIndex.createCell((short) 6);
                    status.setCellStyle(style);
                    status.setCellValue(new HSSFRichTextString(pon.getStatus()));//?BYD
                    HSSFCell item_type = rowIndex.createCell((short) 7);
                    item_type.setCellStyle(style);
                    item_type.setCellValue(new HSSFRichTextString(pon.getItem_type()));//?
                    HSSFCell memo = rowIndex.createCell((short) 8);
                    memo.setCellStyle(style);
                    memo.setCellValue(new HSSFRichTextString(pon.getMemo()));//
                    //                    HSSFCell attachemnt = rowIndex.createCell((short) 9);
                    //                    attachemnt.setCellStyle(style);
                    //                    attachemnt.setCellValue(new HSSFRichTextString(""));//

                }
                response = ActionContext.getResponse();
                response.reset();
                response.setContentType("application/vnd.ms-excel;charset=utf-8");
                response.setHeader("Content-Disposition", "attachment;Filename=applicationform.xls");//??
                response.setHeader("Pragma", "public");
                response.setHeader("Cache-Control", "max-age=30");
                outStream = response.getOutputStream();//?
                wb.write(outStream);//  ??
            }
        } finally {
            if (outStream != null) {
                outStream.close();
            }
        }

        //        return null;
    }

    /**
     * ??String date ----> Date date
     *
     * @param date_string
     * @return Date
     * @throws Exception
     */
    public Date parseStringToDate(String date_string) throws Exception {
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        return sdf.parse(date_string);
    }
}