4fb712387052157a0cc650bccec3b92d406a24ad.svn-base 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686
  1. package com.sinosoft.am.org.linkerHistory.service;
  2. import java.io.File;
  3. import java.io.UnsupportedEncodingException;
  4. import java.util.ArrayList;
  5. import java.util.Map;
  6. import java.util.UUID;
  7. import javax.servlet.http.HttpServletRequest;
  8. import javax.ws.rs.POST;
  9. import javax.ws.rs.Path;
  10. import javax.ws.rs.ProduceMime;
  11. import javax.ws.rs.core.Context;
  12. import jxl.Workbook;
  13. import jxl.format.Alignment;
  14. import jxl.format.Colour;
  15. import jxl.format.ScriptStyle;
  16. import jxl.format.UnderlineStyle;
  17. import jxl.write.Label;
  18. import jxl.write.VerticalAlignment;
  19. import jxl.write.WritableCell;
  20. import jxl.write.WritableCellFeatures;
  21. import jxl.write.WritableCellFormat;
  22. import jxl.write.WritableFont;
  23. import jxl.write.WritableSheet;
  24. import jxl.write.WritableWorkbook;
  25. import org.jfree.util.Log;
  26. import com.sinosoft.am.org.linkerHistory.dao.HistoryLinkerDao;
  27. import com.sinosoft.lz.system.Utils;
  28. @SuppressWarnings("deprecation")
  29. @Path("/HistoryLinkerService/")
  30. public class HistoryLinkerService {
  31. @Context
  32. private org.apache.cxf.jaxrs.ext.MessageContext mc;
  33. /**
  34. *
  35. *
  36. * @param params
  37. * @return
  38. */
  39. @ProduceMime("application/json")
  40. @POST
  41. @Path("/getNewVersion/")
  42. public String getNewVersion(String params) {
  43. try {
  44. params = java.net.URLDecoder.decode(params, "UTF-8");
  45. } catch (UnsupportedEncodingException e) {
  46. e.printStackTrace();
  47. }
  48. String result = "";
  49. String virtual_org_id = Utils.getParameter("virtual_org_id", params) == null ? "" : Utils.getParameter("virtual_org_id", params);//查询条件
  50. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  51. try {
  52. result=hisLinkerDao.getNewVersion(virtual_org_id);
  53. } catch (Exception e) {
  54. e.printStackTrace();
  55. }
  56. Log.info("返回的json数据为==============="+result);
  57. return result;
  58. }
  59. @ProduceMime("application/json")
  60. @POST
  61. @Path("/getEditVersion/")
  62. public String getEditVersion(String params) {
  63. try {
  64. params = java.net.URLDecoder.decode(params, "UTF-8");
  65. } catch (UnsupportedEncodingException e) {
  66. e.printStackTrace();
  67. }
  68. String result = "";
  69. String virtual_org_id = Utils.getParameter("virtual_org_id", params) == null ? "" : Utils.getParameter("virtual_org_id", params);//查询条件
  70. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  71. try {
  72. result=hisLinkerDao.getEditVersion(virtual_org_id);
  73. } catch (Exception e) {
  74. e.printStackTrace();
  75. }
  76. Log.info("返回的json数据为==============="+result);
  77. return result;
  78. }
  79. @ProduceMime("application/json")
  80. @POST
  81. @Path("/selectSimpleData/")
  82. public String selectSimpleData(String params) {
  83. try {
  84. params = java.net.URLDecoder.decode(params, "UTF-8");
  85. } catch (UnsupportedEncodingException e) {
  86. e.printStackTrace();
  87. }
  88. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  89. String year = Utils.getParameter("year", params)==null?"":Utils.getParameter("year", params);
  90. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  91. String str = "";
  92. str = hisLinkerDao.getSimpleData(virtual_org_id,year);
  93. return str;
  94. }
  95. @ProduceMime("application/json")
  96. @POST
  97. @Path("/getVersionInfo/")
  98. public String getVersionInfo(String params) {
  99. try {
  100. params = java.net.URLDecoder.decode(params, "UTF-8");
  101. } catch (UnsupportedEncodingException e) {
  102. e.printStackTrace();
  103. }
  104. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  105. String v_name = Utils.getParameter("name", params)==null?"":Utils.getParameter("name", params);
  106. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  107. String result = hisLinkerDao.getVersionInfo(virtual_org_id,v_name);
  108. return result;
  109. }
  110. @ProduceMime("application/json")
  111. @POST
  112. @Path("/getEditVersionInfo/")
  113. public String getEditVersionInfo(String params) {
  114. try {
  115. params = java.net.URLDecoder.decode(params, "UTF-8");
  116. } catch (UnsupportedEncodingException e) {
  117. e.printStackTrace();
  118. }
  119. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  120. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  121. String result = hisLinkerDao.getEditVersionInfo(virtual_org_id);
  122. return result;
  123. }
  124. @ProduceMime("application/text")
  125. @POST
  126. @Path("/getHistoryVersion/")
  127. public String getHistoryVersion(String params) {
  128. try {
  129. params = java.net.URLDecoder.decode(params, "UTF-8");
  130. } catch (UnsupportedEncodingException e) {
  131. e.printStackTrace();
  132. }
  133. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  134. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  135. String result = hisLinkerDao.getHistoryVersion(virtual_org_id);
  136. return result;
  137. }
  138. @ProduceMime("application/json")
  139. @POST
  140. @Path("/getUserInfo/")
  141. public String getUserInfo(String params) {
  142. try {
  143. params = java.net.URLDecoder.decode(params, "UTF-8");
  144. } catch (UnsupportedEncodingException e) {
  145. e.printStackTrace();
  146. }
  147. String user_id = Utils.getParameter("user_id", params)==null?"":Utils.getParameter("user_id", params);
  148. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  149. String result = hisLinkerDao.getUserInfo(user_id);
  150. return result;
  151. }
  152. @ProduceMime("application/text")
  153. @POST
  154. @Path("/save/")
  155. public String save(String params) {
  156. try {
  157. params = java.net.URLDecoder.decode(params, "UTF-8");
  158. } catch (UnsupportedEncodingException e) {
  159. e.printStackTrace();
  160. }
  161. String virtual_org_name = Utils.getParameter("virtual_org_name", params)==null?"":Utils.getParameter("virtual_org_name", params);
  162. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  163. String entryManId = Utils.getParameter("entryManId", params)==null?"":Utils.getParameter("entryManId", params);
  164. String entryMan_name = Utils.getParameter("entryMan_name", params)==null?"":Utils.getParameter("entryMan_name", params);
  165. String mobile = Utils.getParameter("mobile", params)==null?"":Utils.getParameter("mobile", params);
  166. String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
  167. String v_remark = Utils.getParameter("v_remark", params)==null?"":Utils.getParameter("v_remark", params);
  168. String json = Utils.getParameter("json", params)==null?"":Utils.getParameter("json", params);
  169. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  170. String result = hisLinkerDao.save(virtual_org_name,virtual_org_id,entryManId,entryMan_name,mobile,dept_id,v_remark,json);
  171. return result;
  172. }
  173. @ProduceMime("application/text")
  174. @POST
  175. @Path("/issue/")
  176. public String issue(String params) {
  177. try {
  178. params = java.net.URLDecoder.decode(params, "UTF-8");
  179. } catch (UnsupportedEncodingException e) {
  180. e.printStackTrace();
  181. }
  182. String virtual_org_name = Utils.getParameter("virtual_org_name", params)==null?"":Utils.getParameter("virtual_org_name", params);
  183. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  184. String entryManId = Utils.getParameter("entryManId", params)==null?"":Utils.getParameter("entryManId", params);
  185. String entryMan_name = Utils.getParameter("entryMan_name", params)==null?"":Utils.getParameter("entryMan_name", params);
  186. String mobile = Utils.getParameter("mobile", params)==null?"":Utils.getParameter("mobile", params);
  187. String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
  188. String v_remark = Utils.getParameter("v_remark", params)==null?"":Utils.getParameter("v_remark", params);
  189. String json = Utils.getParameter("json", params)==null?"":Utils.getParameter("json", params);
  190. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  191. String result = hisLinkerDao.issue(virtual_org_name,virtual_org_id,entryManId,entryMan_name,mobile,dept_id,v_remark,json);
  192. return result;
  193. }
  194. @ProduceMime("application/text")
  195. @POST
  196. @Path("/compareName/")
  197. public String compareName(String params) {
  198. try {
  199. params = java.net.URLDecoder.decode(params, "UTF-8");
  200. } catch (UnsupportedEncodingException e) {
  201. e.printStackTrace();
  202. }
  203. String user_id = Utils.getParameter("user_id", params)==null?"":Utils.getParameter("user_id", params);
  204. String user_name = Utils.getParameter("user_name", params)==null?"":Utils.getParameter("user_name", params);
  205. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  206. String result = hisLinkerDao.compareName(user_id,user_name);
  207. return result;
  208. }
  209. @ProduceMime("application/text")
  210. @POST
  211. @Path("/compareOrg/")
  212. public String compareOrg(String params) {
  213. try {
  214. params = java.net.URLDecoder.decode(params, "UTF-8");
  215. } catch (UnsupportedEncodingException e) {
  216. e.printStackTrace();
  217. }
  218. String user_id = Utils.getParameter("user_id", params)==null?"":Utils.getParameter("user_id", params);
  219. String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
  220. String corp_id = Utils.getParameter("corp_id", params)==null?"":Utils.getParameter("corp_id", params);
  221. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  222. String result = hisLinkerDao.compareOrg(user_id,dept_id,corp_id);
  223. return result;
  224. }
  225. @ProduceMime("application/text")
  226. @POST
  227. @Path("/compareDept/")
  228. public String compareDept(String params) {
  229. try {
  230. params = java.net.URLDecoder.decode(params, "UTF-8");
  231. } catch (UnsupportedEncodingException e) {
  232. e.printStackTrace();
  233. }
  234. String user_id = Utils.getParameter("user_id", params)==null?"":Utils.getParameter("user_id", params);
  235. String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
  236. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  237. String result = hisLinkerDao.compareDept(user_id,dept_id);
  238. return result;
  239. }
  240. @ProduceMime("application/json")
  241. @POST
  242. @Path("/getOrgInfo/")
  243. public String getOrgInfo(String params) {
  244. try {
  245. params = java.net.URLDecoder.decode(params, "UTF-8");
  246. } catch (UnsupportedEncodingException e) {
  247. e.printStackTrace();
  248. }
  249. String id = Utils.getParameter("id", params)==null?"":Utils.getParameter("id", params);
  250. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  251. String result = hisLinkerDao.getOrgInfo(id);
  252. return result;
  253. }
  254. @ProduceMime("application/json")
  255. @POST
  256. @Path("/getEditOrgInfo/")
  257. public String getEditOrgInfo(String params) {
  258. try {
  259. params = java.net.URLDecoder.decode(params, "UTF-8");
  260. } catch (UnsupportedEncodingException e) {
  261. e.printStackTrace();
  262. }
  263. String id = Utils.getParameter("id", params)==null?"":Utils.getParameter("id", params);
  264. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  265. String result = hisLinkerDao.getEditOrgInfo(id);
  266. return result;
  267. }
  268. @ProduceMime("application/text")
  269. @POST
  270. @Path("/getCorpName/")
  271. public String getCorpName(String params) {
  272. try {
  273. params = java.net.URLDecoder.decode(params, "UTF-8");
  274. } catch (UnsupportedEncodingException e) {
  275. e.printStackTrace();
  276. }
  277. String id = Utils.getParameter("id", params)==null?"":Utils.getParameter("id", params);
  278. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  279. String result = hisLinkerDao.getCorpName(id);
  280. return result;
  281. }
  282. @ProduceMime("application/text")
  283. @POST
  284. @Path("/getDept_level/")
  285. public String getDept_level(String params) {
  286. try {
  287. params = java.net.URLDecoder.decode(params, "UTF-8");
  288. } catch (UnsupportedEncodingException e) {
  289. e.printStackTrace();
  290. }
  291. String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
  292. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  293. String dept_level = hisLinkerDao.getDept_level(dept_id);
  294. return dept_level;
  295. }
  296. @ProduceMime("application/text")
  297. @POST
  298. @Path("/updateRemark/")
  299. public String updateRemark(String params) {
  300. try {
  301. params = java.net.URLDecoder.decode(params, "UTF-8");
  302. } catch (UnsupportedEncodingException e) {
  303. e.printStackTrace();
  304. }
  305. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  306. String v_remark = Utils.getParameter("v_remark", params)==null?"":Utils.getParameter("v_remark", params);
  307. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  308. String result = hisLinkerDao.updateRemark(virtual_org_id,v_remark);
  309. return result;
  310. }
  311. @ProduceMime("application/text")
  312. @POST
  313. @Path("/updateGrid/")
  314. public String updateGrid(String params) {
  315. try {
  316. params = java.net.URLDecoder.decode(params, "UTF-8");
  317. } catch (UnsupportedEncodingException e) {
  318. e.printStackTrace();
  319. }
  320. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  321. String ids = Utils.getParameter("ids", params)==null?"":Utils.getParameter("ids", params);
  322. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  323. String result = hisLinkerDao.updateGrid(virtual_org_id,ids);
  324. return result;
  325. }
  326. @ProduceMime("application/text")
  327. @POST
  328. @Path("/getOrg/")
  329. public String getOrg(String params) {
  330. try {
  331. params = java.net.URLDecoder.decode(params, "UTF-8");
  332. } catch (UnsupportedEncodingException e) {
  333. e.printStackTrace();
  334. }
  335. String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
  336. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  337. String result = hisLinkerDao.getOrg(dept_id);
  338. return result;
  339. }
  340. @ProduceMime("application/text")
  341. @POST
  342. @Path("/updateOrg/")
  343. public String updateOrg(String params) {
  344. try {
  345. params = java.net.URLDecoder.decode(params, "UTF-8");
  346. } catch (UnsupportedEncodingException e) {
  347. e.printStackTrace();
  348. }
  349. String user_id = Utils.getParameter("user_id", params)==null?"":Utils.getParameter("user_id", params);
  350. String dept_id = Utils.getParameter("dept_id", params)==null?"":Utils.getParameter("dept_id", params);
  351. String org_id = Utils.getParameter("org_id", params)==null?"":Utils.getParameter("org_id", params);
  352. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  353. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  354. String result = hisLinkerDao.updateOrg(user_id,dept_id,org_id,virtual_org_id);
  355. return result;
  356. }
  357. /*
  358. * 导出为模板
  359. */
  360. @SuppressWarnings({ "static-access" })
  361. @POST
  362. @ProduceMime("application/text")
  363. @Path("/createExcel/")
  364. public String createExcel(String params){
  365. try {
  366. params = java.net.URLDecoder.decode(params, "UTF-8");
  367. } catch (UnsupportedEncodingException e) {
  368. e.printStackTrace();
  369. }
  370. String condition = Utils.getParameter("condition", params)==null?"":Utils.getParameter("condition", params);
  371. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  372. String virtual_org_name = Utils.getParameter("virtual_org_name", params)==null?"":Utils.getParameter("virtual_org_name", params);
  373. String version_name = Utils.getParameter("version_name", params)==null?"":Utils.getParameter("version_name", params);
  374. //获取要导出的数据
  375. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  376. ArrayList<Map<String,String>> list =hisLinkerDao.getEditData(condition,virtual_org_id);
  377. Workbook wb = null;
  378. String fileName = "";
  379. WritableWorkbook book = null;
  380. WritableSheet sheet = null;
  381. WritableCell wc = null;
  382. ArrayList<String> al = new ArrayList<String>();
  383. if(virtual_org_name.contains("指挥中心")){
  384. al.add("总指挥");
  385. al.add("常务副总指挥");
  386. al.add("副总指挥");
  387. }else{
  388. al.add("主任");
  389. al.add("常务副主任");
  390. al.add("副主任");
  391. }
  392. al.add("成员");
  393. al.add("管理人员");
  394. HttpServletRequest req = mc.getHttpServletRequest();
  395. String filePath = req.getRealPath("excels");
  396. try {
  397. WritableCellFormat wcf = null;
  398. Label label = null;
  399. WritableCellFeatures wcfeatures = null;
  400. fileName = UUID.randomUUID().toString() + ".xlsx";
  401. File myFilePath = new File(filePath + File.separator + fileName);
  402. // 1.首先定义个workbook
  403. book = wb.createWorkbook(myFilePath);
  404. // 2.定义个sheet
  405. sheet = book.createSheet("第一页", 0);
  406. //设置列宽
  407. for(int i=0;i<7;i++){
  408. sheet.setColumnView(i, 25);
  409. }
  410. //设置标题
  411. sheet.mergeCells(0, 0, 6, 0);
  412. WritableFont titleWf = new WritableFont(WritableFont.createFont("宋体"),// 字体
  413. 14, // 字号
  414. WritableFont.BOLD, // 粗体
  415. false, // 斜体
  416. UnderlineStyle.NO_UNDERLINE, // 下划线
  417. Colour.BLACK, // 字体颜色
  418. ScriptStyle.NORMAL_SCRIPT);
  419. wcf = new WritableCellFormat(titleWf);
  420. wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
  421. wcf.setAlignment(Alignment.CENTRE); // 设置对齐方式
  422. label = new Label(0, 0,version_name,wcf);
  423. sheet.addCell(label);
  424. //设置表头
  425. WritableFont Wf = new WritableFont(WritableFont.createFont("宋体"),// 字体
  426. 10, // 字号
  427. WritableFont.BOLD, // 粗体
  428. false, // 斜体
  429. UnderlineStyle.NO_UNDERLINE, // 下划线
  430. Colour.BLACK, // 字体颜色
  431. ScriptStyle.NORMAL_SCRIPT);
  432. wcf = new WritableCellFormat(Wf);
  433. wcf.setAlignment(Alignment.CENTRE); // 设置对齐方式
  434. wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
  435. label = new Label(0,1,"应急角色",wcf);
  436. sheet.addCell(label);
  437. label = new Label(1,1,"姓名",wcf);
  438. sheet.addCell(label);
  439. label = new Label(2,1,"所属单位",wcf);
  440. sheet.addCell(label);
  441. label = new Label(3,1,"所属部门",wcf);
  442. sheet.addCell(label);
  443. label = new Label(4,1,"手机",wcf);
  444. sheet.addCell(label);
  445. label = new Label(5,1,"4a账号",wcf);
  446. sheet.addCell(label);
  447. label = new Label(6,1,"备注",wcf);
  448. sheet.addCell(label);
  449. for(int i=0;i<list.size();i++){
  450. String emc_role = "";
  451. if("1".equals(list.get(i).get("EMC_ROLE"))){
  452. emc_role = "总指挥";
  453. }else if("2".equals(list.get(i).get("EMC_ROLE"))){
  454. emc_role = "常务副总指挥";
  455. }else if("3".equals(list.get(i).get("EMC_ROLE"))){
  456. emc_role = "副总指挥";
  457. }else if("4".equals(list.get(i).get("EMC_ROLE"))){
  458. emc_role = "主任";
  459. }else if("5".equals(list.get(i).get("EMC_ROLE"))){
  460. emc_role = "常务副主任";
  461. }else if("6".equals(list.get(i).get("EMC_ROLE"))){
  462. emc_role = "副主任";
  463. }else if("7".equals(list.get(i).get("EMC_ROLE"))){
  464. emc_role = "成员";
  465. }else if("8".equals(list.get(i).get("EMC_ROLE"))){
  466. emc_role = "管理人员";
  467. }
  468. label = new Label(0,i+2,emc_role,wcf);
  469. sheet.addCell(label);
  470. label = new Label(1,i+2,list.get(i).get("INLINK_NAME"),wcf);
  471. sheet.addCell(label);
  472. label = new Label(2,i+2,hisLinkerDao.getSimCorp(list.get(i).get("PARENT_ORG_ID")),wcf);
  473. sheet.addCell(label);
  474. label = new Label(3,i+2,hisLinkerDao.getOrg(list.get(i).get("PARENT_DEPT_ID")),wcf);
  475. sheet.addCell(label);
  476. label = new Label(4,i+2,list.get(i).get("PHONE"),wcf);
  477. sheet.addCell(label);
  478. label = new Label(5,i+2,list.get(i).get("EMAIL"),wcf);
  479. sheet.addCell(label);
  480. label = new Label(6,i+2,list.get(i).get("MAN_REMARKS"),wcf);
  481. sheet.addCell(label);
  482. }
  483. for(int i=0;i<(list.size()+20);i++){
  484. wcfeatures = new WritableCellFeatures();
  485. wcfeatures.setDataValidationList(al);
  486. wc = sheet.getWritableCell(0,i+2);
  487. wc.setCellFeatures(wcfeatures);
  488. }
  489. book.write();
  490. book.close();
  491. } catch (Exception e) {
  492. e.printStackTrace();
  493. }
  494. return fileName;
  495. }
  496. /*
  497. * 导出为通讯录
  498. */
  499. @SuppressWarnings({ "static-access" })
  500. @POST
  501. @ProduceMime("application/text")
  502. @Path("/createContactExcel/")
  503. public String createContactExcel(String params){
  504. try {
  505. params = java.net.URLDecoder.decode(params, "UTF-8");
  506. } catch (UnsupportedEncodingException e) {
  507. e.printStackTrace();
  508. }
  509. String condition = Utils.getParameter("condition", params)==null?"":Utils.getParameter("condition", params);
  510. String virtual_org_id = Utils.getParameter("virtual_org_id", params)==null?"":Utils.getParameter("virtual_org_id", params);
  511. String version_name = Utils.getParameter("version_name", params)==null?"":Utils.getParameter("version_name", params);
  512. //获取要导出的数据
  513. HistoryLinkerDao hisLinkerDao = new HistoryLinkerDao();
  514. ArrayList<Map<String,String>> list =hisLinkerDao.getContactData(condition,virtual_org_id);
  515. Workbook wb = null;
  516. String fileName = "";
  517. WritableWorkbook book = null;
  518. WritableSheet sheet = null;
  519. HttpServletRequest req = mc.getHttpServletRequest();
  520. String filePath = req.getRealPath("excels");
  521. try {
  522. WritableCellFormat wcf = null;
  523. Label label = null;
  524. fileName = UUID.randomUUID().toString() + ".xlsx";
  525. File myFilePath = new File(filePath + File.separator + fileName);
  526. // 1.首先定义个workbook
  527. book = wb.createWorkbook(myFilePath);
  528. // 2.定义个sheet
  529. sheet = book.createSheet("第一页", 0);
  530. //设置列宽
  531. for(int i=0;i<7;i++){
  532. sheet.setColumnView(i, 25);
  533. }
  534. //设置标题
  535. sheet.mergeCells(0, 0, 6, 0);
  536. WritableFont titleWf = new WritableFont(WritableFont.createFont("宋体"),// 字体
  537. 14, // 字号
  538. WritableFont.BOLD, // 粗体
  539. false, // 斜体
  540. UnderlineStyle.NO_UNDERLINE, // 下划线
  541. Colour.BLACK, // 字体颜色
  542. ScriptStyle.NORMAL_SCRIPT);
  543. wcf = new WritableCellFormat(titleWf);
  544. wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
  545. wcf.setAlignment(Alignment.CENTRE); // 设置对齐方式
  546. label = new Label(0, 0,version_name,wcf);
  547. sheet.addCell(label);
  548. //设置表头
  549. WritableFont Wf = new WritableFont(WritableFont.createFont("宋体"),// 字体
  550. 10, // 字号
  551. WritableFont.BOLD, // 粗体
  552. false, // 斜体
  553. UnderlineStyle.NO_UNDERLINE, // 下划线
  554. Colour.BLACK, // 字体颜色
  555. ScriptStyle.NORMAL_SCRIPT);
  556. wcf = new WritableCellFormat(Wf);
  557. wcf.setAlignment(Alignment.CENTRE); // 设置对齐方式
  558. wcf.setVerticalAlignment(VerticalAlignment.CENTRE);
  559. label = new Label(0,1,"序号",wcf);
  560. sheet.addCell(label);
  561. label = new Label(1,1,"应急角色",wcf);
  562. sheet.addCell(label);
  563. label = new Label(2,1,"姓名",wcf);
  564. sheet.addCell(label);
  565. label = new Label(3,1,"所属单位",wcf);
  566. sheet.addCell(label);
  567. label = new Label(4,1,"所属部门",wcf);
  568. sheet.addCell(label);
  569. label = new Label(5,1,"手机",wcf);
  570. sheet.addCell(label);
  571. label = new Label(6,1,"备注",wcf);
  572. sheet.addCell(label);
  573. for(int i=0;i<list.size();i++){
  574. label = new Label(0,i+2,String.valueOf(i+1),wcf);
  575. sheet.addCell(label);
  576. String emc_role = "";
  577. if("1".equals(list.get(i).get("EMC_ROLE"))){
  578. emc_role = "总指挥";
  579. }else if("2".equals(list.get(i).get("EMC_ROLE"))){
  580. emc_role = "常务副总指挥";
  581. }else if("3".equals(list.get(i).get("EMC_ROLE"))){
  582. emc_role = "副总指挥";
  583. }else if("4".equals(list.get(i).get("EMC_ROLE"))){
  584. emc_role = "主任";
  585. }else if("5".equals(list.get(i).get("EMC_ROLE"))){
  586. emc_role = "常务副主任";
  587. }else if("6".equals(list.get(i).get("EMC_ROLE"))){
  588. emc_role = "副主任";
  589. }else if("7".equals(list.get(i).get("EMC_ROLE"))){
  590. emc_role = "成员";
  591. }else if("8".equals(list.get(i).get("EMC_ROLE"))){
  592. emc_role = "管理人员";
  593. }
  594. label = new Label(1,i+2,emc_role,wcf);
  595. sheet.addCell(label);
  596. label = new Label(2,i+2,list.get(i).get("INLINK_NAME"),wcf);
  597. sheet.addCell(label);
  598. label = new Label(3,i+2,hisLinkerDao.getSimCorp(list.get(i).get("PARENT_ORG_ID")),wcf);
  599. sheet.addCell(label);
  600. label = new Label(4,i+2,hisLinkerDao.getOrg(list.get(i).get("PARENT_DEPT_ID")),wcf);
  601. sheet.addCell(label);
  602. label = new Label(5,i+2,list.get(i).get("PHONE"),wcf);
  603. sheet.addCell(label);
  604. label = new Label(6,i+2,list.get(i).get("MAN_REMARKS"),wcf);
  605. sheet.addCell(label);
  606. }
  607. book.write();
  608. book.close();
  609. } catch (Exception e) {
  610. e.printStackTrace();
  611. }
  612. return fileName;
  613. }
  614. }