123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686 |
- package com.sinosoft.am.org.linkerHistory.service;
- import java.io.File;
- import java.io.UnsupportedEncodingException;
- import java.util.ArrayList;
- import java.util.Map;
- import java.util.UUID;
- import javax.servlet.http.HttpServletRequest;
- import javax.ws.rs.POST;
- import javax.ws.rs.Path;
- import javax.ws.rs.ProduceMime;
- import javax.ws.rs.core.Context;
- import jxl.Workbook;
- import jxl.format.Alignment;
- import jxl.format.Colour;
- import jxl.format.ScriptStyle;
- import jxl.format.UnderlineStyle;
- import jxl.write.Label;
- import jxl.write.VerticalAlignment;
- import jxl.write.WritableCell;
- import jxl.write.WritableCellFeatures;
- import jxl.write.WritableCellFormat;
- import jxl.write.WritableFont;
- import jxl.write.WritableSheet;
- import jxl.write.WritableWorkbook;
- import org.jfree.util.Log;
- import com.sinosoft.am.org.linkerHistory.dao.HistoryLinkerDao;
- import com.sinosoft.lz.system.Utils;
- @SuppressWarnings("deprecation")
- @Path("/HistoryLinkerService/")
- public class HistoryLinkerService {
-
- @Context
- private org.apache.cxf.jaxrs.ext.MessageContext mc;
-
- /**
- *
- *
- * @param params
- * @return
- */
- @ProduceMime("application/json")
- @POST
- @Path("/getNewVersion/")
- public String getNewVersion(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String result = "";
- String virtual_org_id = Utils.getParameter("virtual_org_id", params) == null ? "" : Utils.getParameter("virtual_org_id", params);//查询条件
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- try {
- result=hisLinkerDao.getNewVersion(virtual_org_id);
- } catch (Exception e) {
- e.printStackTrace();
- }
- Log.info("返回的json数据为==============="+result);
- return result;
- }
-
- @ProduceMime("application/json")
- @POST
- @Path("/getEditVersion/")
- public String getEditVersion(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String result = "";
- String virtual_org_id = Utils.getParameter("virtual_org_id", params) == null ? "" : Utils.getParameter("virtual_org_id", params);//查询条件
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- try {
- result=hisLinkerDao.getEditVersion(virtual_org_id);
- } catch (Exception e) {
- e.printStackTrace();
- }
- Log.info("返回的json数据为==============="+result);
- return result;
- }
-
-
-
- @ProduceMime("application/json")
- @POST
- @Path("/selectSimpleData/")
- public String selectSimpleData(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
-
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- String year = Utils.getParameter("year", params)==null?"":Utils.getParameter("year", params);
-
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
-
- String str = "";
- str = hisLinkerDao.getSimpleData(virtual_org_id,year);
- return str;
- }
-
- @ProduceMime("application/json")
- @POST
- @Path("/getVersionInfo/")
- public String getVersionInfo(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- String v_name = Utils.getParameter("name", params)==null?"":Utils.getParameter("name", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.getVersionInfo(virtual_org_id,v_name);
- return result;
- }
-
- @ProduceMime("application/json")
- @POST
- @Path("/getEditVersionInfo/")
- public String getEditVersionInfo(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.getEditVersionInfo(virtual_org_id);
- return result;
- }
-
-
- @ProduceMime("application/text")
- @POST
- @Path("/getHistoryVersion/")
- public String getHistoryVersion(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.getHistoryVersion(virtual_org_id);
- return result;
- }
-
- @ProduceMime("application/json")
- @POST
- @Path("/getUserInfo/")
- public String getUserInfo(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String user_id = Utils.getParameter("user_id", params)==null?"":Utils.getParameter("user_id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.getUserInfo(user_id);
- return result;
- }
-
- @ProduceMime("application/text")
- @POST
- @Path("/save/")
- public String save(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String virtual_org_name = Utils.getParameter("virtual_org_name", params)==null?"":Utils.getParameter("virtual_org_name", params);
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- String entryManId = Utils.getParameter("entryManId", params)==null?"":Utils.getParameter("entryManId", params);
- String entryMan_name = Utils.getParameter("entryMan_name", params)==null?"":Utils.getParameter("entryMan_name", params);
- String mobile = Utils.getParameter("mobile", params)==null?"":Utils.getParameter("mobile", params);
- String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
- String v_remark = Utils.getParameter("v_remark", params)==null?"":Utils.getParameter("v_remark", params);
- String json = Utils.getParameter("json", params)==null?"":Utils.getParameter("json", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.save(virtual_org_name,virtual_org_id,entryManId,entryMan_name,mobile,dept_id,v_remark,json);
- return result;
- }
-
- @ProduceMime("application/text")
- @POST
- @Path("/issue/")
- public String issue(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String virtual_org_name = Utils.getParameter("virtual_org_name", params)==null?"":Utils.getParameter("virtual_org_name", params);
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- String entryManId = Utils.getParameter("entryManId", params)==null?"":Utils.getParameter("entryManId", params);
- String entryMan_name = Utils.getParameter("entryMan_name", params)==null?"":Utils.getParameter("entryMan_name", params);
- String mobile = Utils.getParameter("mobile", params)==null?"":Utils.getParameter("mobile", params);
- String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
- String v_remark = Utils.getParameter("v_remark", params)==null?"":Utils.getParameter("v_remark", params);
- String json = Utils.getParameter("json", params)==null?"":Utils.getParameter("json", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.issue(virtual_org_name,virtual_org_id,entryManId,entryMan_name,mobile,dept_id,v_remark,json);
- return result;
- }
-
-
- @ProduceMime("application/text")
- @POST
- @Path("/compareName/")
- public String compareName(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String user_id = Utils.getParameter("user_id", params)==null?"":Utils.getParameter("user_id", params);
- String user_name = Utils.getParameter("user_name", params)==null?"":Utils.getParameter("user_name", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.compareName(user_id,user_name);
- return result;
- }
- @ProduceMime("application/text")
- @POST
- @Path("/compareOrg/")
- public String compareOrg(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String user_id = Utils.getParameter("user_id", params)==null?"":Utils.getParameter("user_id", params);
- String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
- String corp_id = Utils.getParameter("corp_id", params)==null?"":Utils.getParameter("corp_id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.compareOrg(user_id,dept_id,corp_id);
- return result;
- }
- @ProduceMime("application/text")
- @POST
- @Path("/compareDept/")
- public String compareDept(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String user_id = Utils.getParameter("user_id", params)==null?"":Utils.getParameter("user_id", params);
- String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.compareDept(user_id,dept_id);
- return result;
- }
-
- @ProduceMime("application/json")
- @POST
- @Path("/getOrgInfo/")
- public String getOrgInfo(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String id = Utils.getParameter("id", params)==null?"":Utils.getParameter("id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.getOrgInfo(id);
- return result;
- }
-
- @ProduceMime("application/json")
- @POST
- @Path("/getEditOrgInfo/")
- public String getEditOrgInfo(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String id = Utils.getParameter("id", params)==null?"":Utils.getParameter("id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.getEditOrgInfo(id);
- return result;
- }
-
- @ProduceMime("application/text")
- @POST
- @Path("/getCorpName/")
- public String getCorpName(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String id = Utils.getParameter("id", params)==null?"":Utils.getParameter("id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.getCorpName(id);
- return result;
- }
-
- @ProduceMime("application/text")
- @POST
- @Path("/getDept_level/")
- public String getDept_level(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String dept_level = hisLinkerDao.getDept_level(dept_id);
- return dept_level;
- }
-
- @ProduceMime("application/text")
- @POST
- @Path("/updateRemark/")
- public String updateRemark(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- String v_remark = Utils.getParameter("v_remark", params)==null?"":Utils.getParameter("v_remark", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.updateRemark(virtual_org_id,v_remark);
- return result;
- }
-
- @ProduceMime("application/text")
- @POST
- @Path("/updateGrid/")
- public String updateGrid(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- String ids = Utils.getParameter("ids", params)==null?"":Utils.getParameter("ids", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.updateGrid(virtual_org_id,ids);
- return result;
- }
- @ProduceMime("application/text")
- @POST
- @Path("/getOrg/")
- public String getOrg(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.getOrg(dept_id);
- return result;
- }
-
- @ProduceMime("application/text")
- @POST
- @Path("/updateOrg/")
- public String updateOrg(String params) {
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String user_id = Utils.getParameter("user_id", params)==null?"":Utils.getParameter("user_id", params);
- String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
- String org_id = Utils.getParameter("org_id", params)==null?"":Utils.getParameter("org_id", params);
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- String result = hisLinkerDao.updateOrg(user_id,dept_id,org_id,virtual_org_id);
- return result;
- }
-
-
- /*
- * 导出为模板
- */
- @SuppressWarnings({ "static-access" })
- @POST
- @ProduceMime("application/text")
- @Path("/createExcel/")
- public String createExcel(String params){
-
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String condition = Utils.getParameter("condition", params)==null?"":Utils.getParameter("condition", params);
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- String virtual_org_name = Utils.getParameter("virtual_org_name", params)==null?"":Utils.getParameter("virtual_org_name", params);
- String version_name = Utils.getParameter("version_name", params)==null?"":Utils.getParameter("version_name", params);
-
- //获取要导出的数据
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- ArrayList<Map<String,String>> list =hisLinkerDao.getEditData(condition,virtual_org_id);
-
-
-
- Workbook wb = null;
- String fileName = "";
- WritableWorkbook book = null;
- WritableSheet sheet = null;
- WritableCell wc = null;
- ArrayList<String> al = new ArrayList<String>();
- if(virtual_org_name.contains("指挥中心")){
- al.add("总指挥");
- al.add("常务副总指挥");
- al.add("副总指挥");
- }else{
- al.add("主任");
- al.add("常务副主任");
- al.add("副主任");
- }
- al.add("成员");
- al.add("管理人员");
-
- HttpServletRequest req = mc.getHttpServletRequest();
- String filePath = req.getRealPath("excels");
-
- try {
- WritableCellFormat wcf = null;
- Label label = null;
- WritableCellFeatures wcfeatures = null;
-
- fileName = UUID.randomUUID().toString() + ".xlsx";
- File myFilePath = new File(filePath + File.separator + fileName);
-
- // 1.首先定义个workbook
- book = wb.createWorkbook(myFilePath);
- // 2.定义个sheet
- sheet = book.createSheet("第一页", 0);
- //设置列宽
- for(int i=0;i<7;i++){
- sheet.setColumnView(i, 25);
- }
-
- //设置标题
- sheet.mergeCells(0, 0, 6, 0);
- WritableFont titleWf = new WritableFont(WritableFont.createFont("宋体"),// 字体
- 14, // 字号
- WritableFont.BOLD, // 粗体
- false, // 斜体
- UnderlineStyle.NO_UNDERLINE, // 下划线
- Colour.BLACK, // 字体颜色
- ScriptStyle.NORMAL_SCRIPT);
- wcf = new WritableCellFormat(titleWf);
- wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
- wcf.setAlignment(Alignment.CENTRE); // 设置对齐方式
- label = new Label(0, 0,version_name,wcf);
- sheet.addCell(label);
-
- //设置表头
- WritableFont Wf = new WritableFont(WritableFont.createFont("宋体"),// 字体
- 10, // 字号
- WritableFont.BOLD, // 粗体
- false, // 斜体
- UnderlineStyle.NO_UNDERLINE, // 下划线
- Colour.BLACK, // 字体颜色
- ScriptStyle.NORMAL_SCRIPT);
- wcf = new WritableCellFormat(Wf);
- wcf.setAlignment(Alignment.CENTRE); // 设置对齐方式
- wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
- label = new Label(0,1,"应急角色",wcf);
- sheet.addCell(label);
- label = new Label(1,1,"姓名",wcf);
- sheet.addCell(label);
- label = new Label(2,1,"所属单位",wcf);
- sheet.addCell(label);
- label = new Label(3,1,"所属部门",wcf);
- sheet.addCell(label);
- label = new Label(4,1,"手机",wcf);
- sheet.addCell(label);
- label = new Label(5,1,"4a账号",wcf);
- sheet.addCell(label);
- label = new Label(6,1,"备注",wcf);
- sheet.addCell(label);
-
- for(int i=0;i<list.size();i++){
- String emc_role = "";
- if("1".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "总指挥";
- }else if("2".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "常务副总指挥";
- }else if("3".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "副总指挥";
- }else if("4".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "主任";
- }else if("5".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "常务副主任";
- }else if("6".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "副主任";
- }else if("7".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "成员";
- }else if("8".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "管理人员";
- }
-
- label = new Label(0,i+2,emc_role,wcf);
- sheet.addCell(label);
- label = new Label(1,i+2,list.get(i).get("INLINK_NAME"),wcf);
- sheet.addCell(label);
- label = new Label(2,i+2,hisLinkerDao.getSimCorp(list.get(i).get("PARENT_ORG_ID")),wcf);
- sheet.addCell(label);
- label = new Label(3,i+2,hisLinkerDao.getOrg(list.get(i).get("PARENT_DEPT_ID")),wcf);
- sheet.addCell(label);
- label = new Label(4,i+2,list.get(i).get("PHONE"),wcf);
- sheet.addCell(label);
- label = new Label(5,i+2,list.get(i).get("EMAIL"),wcf);
- sheet.addCell(label);
- label = new Label(6,i+2,list.get(i).get("MAN_REMARKS"),wcf);
- sheet.addCell(label);
- }
-
- for(int i=0;i<(list.size()+20);i++){
- wcfeatures = new WritableCellFeatures();
- wcfeatures.setDataValidationList(al);
- wc = sheet.getWritableCell(0,i+2);
- wc.setCellFeatures(wcfeatures);
- }
-
- book.write();
- book.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return fileName;
- }
-
- /*
- * 导出为通讯录
- */
- @SuppressWarnings({ "static-access" })
- @POST
- @ProduceMime("application/text")
- @Path("/createContactExcel/")
- public String createContactExcel(String params){
-
- try {
- params = java.net.URLDecoder.decode(params, "UTF-8");
- } catch (UnsupportedEncodingException e) {
- e.printStackTrace();
- }
- String condition = Utils.getParameter("condition", params)==null?"":Utils.getParameter("condition", params);
- String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
- String version_name = Utils.getParameter("version_name", params)==null?"":Utils.getParameter("version_name", params);
-
- //获取要导出的数据
- HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
- ArrayList<Map<String,String>> list =hisLinkerDao.getContactData(condition,virtual_org_id);
-
-
-
- Workbook wb = null;
- String fileName = "";
- WritableWorkbook book = null;
- WritableSheet sheet = null;
-
- HttpServletRequest req = mc.getHttpServletRequest();
- String filePath = req.getRealPath("excels");
-
- try {
- WritableCellFormat wcf = null;
- Label label = null;
-
-
- fileName = UUID.randomUUID().toString() + ".xlsx";
- File myFilePath = new File(filePath + File.separator + fileName);
-
- // 1.首先定义个workbook
- book = wb.createWorkbook(myFilePath);
- // 2.定义个sheet
- sheet = book.createSheet("第一页", 0);
- //设置列宽
- for(int i=0;i<7;i++){
- sheet.setColumnView(i, 25);
- }
-
- //设置标题
- sheet.mergeCells(0, 0, 6, 0);
- WritableFont titleWf = new WritableFont(WritableFont.createFont("宋体"),// 字体
- 14, // 字号
- WritableFont.BOLD, // 粗体
- false, // 斜体
- UnderlineStyle.NO_UNDERLINE, // 下划线
- Colour.BLACK, // 字体颜色
- ScriptStyle.NORMAL_SCRIPT);
- wcf = new WritableCellFormat(titleWf);
- wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
- wcf.setAlignment(Alignment.CENTRE); // 设置对齐方式
- label = new Label(0, 0,version_name,wcf);
- sheet.addCell(label);
-
- //设置表头
- WritableFont Wf = new WritableFont(WritableFont.createFont("宋体"),// 字体
- 10, // 字号
- WritableFont.BOLD, // 粗体
- false, // 斜体
- UnderlineStyle.NO_UNDERLINE, // 下划线
- Colour.BLACK, // 字体颜色
- ScriptStyle.NORMAL_SCRIPT);
- wcf = new WritableCellFormat(Wf);
- wcf.setAlignment(Alignment.CENTRE); // 设置对齐方式
- wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
- label = new Label(0,1,"序号",wcf);
- sheet.addCell(label);
- label = new Label(1,1,"应急角色",wcf);
- sheet.addCell(label);
- label = new Label(2,1,"姓名",wcf);
- sheet.addCell(label);
- label = new Label(3,1,"所属单位",wcf);
- sheet.addCell(label);
- label = new Label(4,1,"所属部门",wcf);
- sheet.addCell(label);
- label = new Label(5,1,"手机",wcf);
- sheet.addCell(label);
- label = new Label(6,1,"备注",wcf);
- sheet.addCell(label);
-
- for(int i=0;i<list.size();i++){
- label = new Label(0,i+2,String.valueOf(i+1),wcf);
- sheet.addCell(label);
- String emc_role = "";
- if("1".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "总指挥";
- }else if("2".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "常务副总指挥";
- }else if("3".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "副总指挥";
- }else if("4".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "主任";
- }else if("5".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "常务副主任";
- }else if("6".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "副主任";
- }else if("7".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "成员";
- }else if("8".equals(list.get(i).get("EMC_ROLE"))){
- emc_role = "管理人员";
- }
- label = new Label(1,i+2,emc_role,wcf);
- sheet.addCell(label);
- label = new Label(2,i+2,list.get(i).get("INLINK_NAME"),wcf);
- sheet.addCell(label);
- label = new Label(3,i+2,hisLinkerDao.getSimCorp(list.get(i).get("PARENT_ORG_ID")),wcf);
- sheet.addCell(label);
- label = new Label(4,i+2,hisLinkerDao.getOrg(list.get(i).get("PARENT_DEPT_ID")),wcf);
- sheet.addCell(label);
- label = new Label(5,i+2,list.get(i).get("PHONE"),wcf);
- sheet.addCell(label);
- label = new Label(6,i+2,list.get(i).get("MAN_REMARKS"),wcf);
- sheet.addCell(label);
- }
-
-
-
- book.write();
- book.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
-
- return fileName;
- }
-
-
- }
|