CommonController.java 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769
  1. package com.ruoyi.project.common;
  2. import com.ruoyi.common.constant.Constants;
  3. import com.ruoyi.common.utils.StringUtils;
  4. import com.ruoyi.common.utils.file.FileUploadUtils;
  5. import com.ruoyi.common.utils.file.FileUtils;
  6. import com.ruoyi.framework.config.RuoYiConfig;
  7. import com.ruoyi.framework.config.ServerConfig;
  8. import com.ruoyi.framework.web.controller.BaseController;
  9. import com.ruoyi.framework.web.domain.AjaxResult;
  10. import com.ruoyi.project.sems.domain.TSpecdevGl;
  11. import com.ruoyi.project.sems.service.*;
  12. import org.apache.poi.ss.usermodel.CellStyle;
  13. import org.apache.poi.ss.usermodel.Row;
  14. import org.apache.poi.ss.usermodel.Sheet;
  15. import org.apache.poi.xssf.streaming.SXSSFWorkbook;
  16. import org.slf4j.Logger;
  17. import org.slf4j.LoggerFactory;
  18. import org.springframework.beans.factory.annotation.Autowired;
  19. import org.springframework.web.bind.annotation.*;
  20. import org.springframework.web.multipart.MultipartFile;
  21. import javax.servlet.ServletOutputStream;
  22. import javax.servlet.http.HttpServletRequest;
  23. import javax.servlet.http.HttpServletResponse;
  24. import java.io.*;
  25. import java.util.ArrayList;
  26. import java.util.List;
  27. import java.util.UUID;
  28. /**
  29. * 通用请求处理
  30. *
  31. * @author ruoyi
  32. */
  33. @RestController
  34. public class CommonController extends BaseController
  35. {
  36. private static final Logger log = LoggerFactory.getLogger(CommonController.class);
  37. private static final String FILE_DELIMETER = ",";
  38. @Autowired
  39. private ServerConfig serverConfig;
  40. @Autowired
  41. private ITSpecdevYlrqService tSpecdevYlrqService;
  42. @Autowired
  43. private ITSpecdevYlgdService tSpecdevYlgdService;
  44. @Autowired
  45. private ITSpecdevGlService tSpecdevGlService;
  46. @Autowired
  47. private ITSpecdevDzsbService tSpecdevDzsbService;
  48. @Autowired
  49. private ITSpecdevDtService tSpecdevDtService;
  50. @Autowired
  51. private ITSpecdevCcService tSpecdevCcService;
  52. /**
  53. * 导入下载模板
  54. */
  55. @RequestMapping("common/template")
  56. @ResponseBody
  57. public void template(String type,HttpServletRequest request, HttpServletResponse response) throws IOException
  58. {
  59. String downloadname = "";
  60. String url = "";
  61. if ( type.equals("alarmmodify") ) {
  62. downloadname = "报警值管理导入模板.xlsx";
  63. url = "static/template/process/alarmmodify.xlsx";
  64. } else if( type.equals("publicdoc") ) {
  65. downloadname = "公共文档管理导入模板.xlsx";
  66. url = "static/template/document/publicdoc.xlsx";
  67. } else if( type.equals("publicdocmenu") ) {
  68. downloadname = "公共文档目录管理导入模板.xlsx";
  69. url = "static/template/document/publicdocmenu.xlsx";
  70. } else if( type.equals("permanentMoc") ) {
  71. downloadname = "永久MOC导入模板.xlsx";
  72. url = "static/template/process/moc/permanentMoc.xlsx";
  73. } else if( type.equals("temporaryMoc") ) {
  74. downloadname = "临时MOC导入模板.xlsx";
  75. url = "static/template/process/moc/temporaryMoc.xlsx";
  76. } else if( type.equals("aquifier") ) {
  77. downloadname = "临时MOC-带压消漏清单导入模板.xlsx";
  78. url = "static/template/process/moc/aquifier.xlsx";
  79. } else if( type.equals("facility") ) {
  80. downloadname = "临时MOC-临时设施及其它导入模板.xlsx";
  81. url = "static/template/process/moc/facility.xlsx";
  82. } else if( type.equals("interlock") ) {
  83. downloadname = "临时MOC-仪表联锁旁路导入模板.xlsx";
  84. url = "static/template/process/moc/interlock.xlsx";
  85. } else if( type.equals("accident") ) {
  86. downloadname = "隐患排查导入模板.xlsx";
  87. url = "static/template/production/accident.xlsx";
  88. } else if( type.equals("blind") ) {
  89. downloadname = "盲板清单导入模板.xlsx";
  90. url = "static/template/production/blind.xlsx";
  91. } else if( type.equals("我的机器") ) {
  92. downloadname = "5S管理我的机器导入模板.xlsx";
  93. url = "static/template/production/wsglmachine.xlsx";
  94. } else if( type.equals("我的区域") ) {
  95. downloadname = "5S管理我的区域导入模板.xlsx";
  96. url = "static/template/production/wsglarea.xlsx";
  97. } else if( type.equals("day") ) {
  98. downloadname = "报警统计(昨天)导入模板.xlsx";
  99. url = "static/template/production/alarmstatistics.xlsx";
  100. } else if( type.equals("month") ) {
  101. downloadname = "报警统计(上月)导入模板.xlsx";
  102. url = "static/template/production/alarmstatistics.xlsx";
  103. } else if( type.equals("lbnhjstj") ) {
  104. downloadname = "能耗管理统计导入模板.xlsx";
  105. url = "static/template/production/lbnhjstj.xlsx";
  106. } else if( type.equals("sai") ) {
  107. downloadname = "SAI检查管理导入模板.xlsx";
  108. url = "static/template/production/sai.xlsx";
  109. } else if( type.equals("saiApply") ) {
  110. downloadname = "SAI开项管理导入模板.xlsx";
  111. url = "static/template/production/saiApply.xlsx";
  112. } else if( type.equals("eoegsai") ) {
  113. downloadname = "EOEG SAI检查管理导入模板.xlsx";
  114. url = "static/template/production/eoegSai.xlsx";
  115. } else if( type.equals("eoegSaiApply") ) {
  116. downloadname = "EOEG SAI开项管理导入模板.xlsx";
  117. url = "static/template/production/eoegSaiApply.xlsx";
  118. } else if( type.equals("rcaudit") ) {
  119. downloadname = "RC审计助手导入模板.xlsx";
  120. url = "static/template/ehs/rcaudit.xlsx";
  121. } else if( type.equals("rcauditmenu") ) {
  122. downloadname = "RC审计助手目录导入模板.xlsx";
  123. url = "static/template/ehs/rcauditmenu.xlsx";
  124. } else if( type.equals("plantproglistprocedure") ) {
  125. downloadname = "装置程序清单程序总汇导入模板.xlsx";
  126. url = "static/template/document/plantproglistprocedure.xlsx";
  127. } else if( type.equals("plantproglistform") ) {
  128. downloadname = "装置程序清单表格总汇导入模板.xlsx";
  129. url = "static/template/document/plantproglistform.xlsx";
  130. } else if( type.equals("plantproglistguide") ) {
  131. downloadname = "装置程序清单指南总汇导入模板.xlsx";
  132. url = "static/template/document/plantproglistguide.xlsx";
  133. } else if( type.equals("plantproglistbook") ) {
  134. downloadname = "装置程序清单指导书总汇导入模板.xlsx";
  135. url = "static/template/document/plantproglistbook.xlsx";
  136. } else if( type.equals("plantproglistannex") ) {
  137. downloadname = "装置程序清单附件总汇导入模板.xlsx";
  138. url = "static/template/document/plantproglistannex.xlsx";
  139. } else if( type.equals("plantproglistmaterials") ) {
  140. downloadname = "装置程序清单培训材料导入模板.xlsx";
  141. url = "static/template/document/plantproglistmaterials.xlsx";
  142. } else if( type.equals("officesupply") ) {
  143. downloadname = "办公用品管理导入模板.xlsx";
  144. url = "static/template/affair/officesupply.xlsx";
  145. } else if( type.equals("ppe") ) {
  146. downloadname = "PPE发放登记导入模板.xlsx";
  147. url = "static/template/affair/ppe.xlsx";
  148. } else if( type.equals("intercom") ) {
  149. downloadname = "对讲机管理导入模板.xlsx";
  150. url = "static/template/affair/intercom.xlsx";
  151. } else if( type.equals("kkxglcs") ) {
  152. downloadname = "可靠性管理措施导入模板.xlsx";
  153. url = "static/template/reliability/kkxglcs.xlsx";
  154. } else if( type.equals("original") ) {
  155. downloadname = "故障管理初选导入模板.xlsx";
  156. url = "static/template/reliability/original.xlsx";
  157. } else if( type.equals("abnormalreport") ) {
  158. downloadname = "异常报告管理导入模板.xlsx";
  159. url = "static/template/reliability/abnormalreport.xlsx";
  160. } else if( type.equals("assetlist") ) {
  161. downloadname = "资产清单导入模板.xlsx";
  162. url = "static/template/reliability/assetlist.xlsx";
  163. } else if( type.equals("safetyvavle") ) {
  164. downloadname = "安全阀清单导入模板.xlsx";
  165. url = "static/template/reliability/safetyvavle.xlsx";
  166. } else if( type.equals("preventivemaintenance") ) {
  167. downloadname = "预防性维修导入模板.xlsx";
  168. url = "static/template/reliability/preventivemaintenance.xlsx";
  169. } else if( type.equals("pipe") ) {
  170. downloadname = "管线清单导入模板.xlsx";
  171. url = "static/template/cui/pipe.xlsx";
  172. } else if( type.equals("pvessel") ) {
  173. downloadname = "容器清单导入模板.xlsx";
  174. url = "static/template/cui/pvessel.xlsx";
  175. } else if( type.equals("problems") ) {
  176. downloadname = "CUI问题整改跟踪清单导入模板.xlsx";
  177. url = "static/template/cui/problems.xlsx";
  178. } else if( type.equals("eyewasher") ) {
  179. downloadname = "洗眼器导入模板.xlsx";
  180. url = "static/template/ehs/eyewasher.xlsx";
  181. } else if( type.equals("firehose") ) {
  182. downloadname = "消防水带箱导入模板.xlsx";
  183. url = "static/template/ehs/firehose.xlsx";
  184. } else if( type.equals("firehydrant") ) {
  185. downloadname = "消防栓导入模板.xlsx";
  186. url = "static/template/ehs/firehydrant.xlsx";
  187. } else if( type.equals("highpresfire") ) {
  188. downloadname = "高压消防炮导入模板.xlsx";
  189. url = "static/template/ehs/highpresfire.xlsx";
  190. } else if( type.equals("fireextinguisher") ) {
  191. downloadname = "灭火器导入模板.xlsx";
  192. url = "static/template/ehs/fireextinguisher.xlsx";
  193. } else if( type.equals("autosprinkler") ) {
  194. downloadname = "自动喷淋系统导入模板.xlsx";
  195. url = "static/template/ehs/autosprinkler.xlsx";
  196. } else if( type.equals("firestandpipe") ) {
  197. downloadname = "消防竖管导入模板.xlsx";
  198. url = "static/template/ehs/firestandpipe.xlsx";
  199. } else if( type.equals("safetyapproval") ) {
  200. downloadname = "安全批文清单导入模板.xlsx";
  201. url = "static/template/ehs/safetyapproval.xlsx";
  202. } else if( type.equals("fireapproval") ) {
  203. downloadname = "消防批文清单导入模板.xlsx";
  204. url = "static/template/ehs/fireapproval.xlsx";
  205. } else if( type.equals("environapproval") ) {
  206. downloadname = "环保批文清单导入模板.xlsx";
  207. url = "static/template/ehs/environapproval.xlsx";
  208. } else if( type.equals("healthapproval") ) {
  209. downloadname = "卫生批文清单导入模板.xlsx";
  210. url = "static/template/ehs/healthapproval.xlsx";
  211. } else if( type.equals("safetyapprcont") ) {
  212. downloadname = "安全批文主要内容导入模板.xlsx";
  213. url = "static/template/ehs/safetyapprcont.xlsx";
  214. } else if( type.equals("environapprcont") ) {
  215. downloadname = "环保批文主要内容导入模板.xlsx";
  216. url = "static/template/ehs/environapprcont.xlsx";
  217. } else if( type.equals("jobticket") ) {
  218. downloadname = "工作票导入模板.xlsx";
  219. url = "static/template/ehs/jobticket.xlsx";
  220. } else if( type.equals("msds") ) {
  221. downloadname = "MSDS管理导入模板.xlsx";
  222. url = "static/template/ehs/msds.xlsx";
  223. } else if( type.equals("incidentRecords") ) {
  224. downloadname = "事故报告清单导入模板.xlsx";
  225. url = "static/template/ehs/incidentRecords.xlsx";
  226. } else if( type.equals("water") ) {
  227. downloadname = "废水风险评估导入模板.xlsx";
  228. url = "static/template/ehs/water.xlsx";
  229. } else if( type.equals("danger") ) {
  230. downloadname = "危险废物清单导入模板.xlsx";
  231. url = "static/template/ehs/danger.xlsx";
  232. } else if( type.equals("dangermonth") ) {
  233. downloadname = "危险废物出入库月报导入模板.xlsx";
  234. url = "static/template/ehs/dangermonth.xlsx";
  235. } else if( type.equals("barrelmonth") ) {
  236. downloadname = "废桶进出库统计日报导入模板.xlsx";
  237. url = "static/template/ehs/barrelmonth.xlsx";
  238. } else if( type.equals("dangerday") ) {
  239. downloadname = "危废出入库统计日报导入模板.xlsx";
  240. url = "static/template/ehs/dangerday.xlsx";
  241. } else if( type.equals("workcertificate") ) {
  242. downloadname = "作业证书一览表导入模板.xlsx";
  243. url = "static/template/training/workcertificate.xlsx";
  244. } else if( type.equals("byxworkcertificate") ) {
  245. downloadname = "苯乙烯作业证书一览表导入模板.xlsx";
  246. url = "static/template/training/byxworkcertificate.xlsx";
  247. } else if( type.equals("worklicense") ) {
  248. downloadname = "上岗证一览表导入模板.xlsx";
  249. url = "static/template/training/worklicense.xlsx";
  250. } else if( type.equals("worklicenseCertificate") ) {
  251. downloadname = "上岗证/作业证书一览表导入模板.xlsx";
  252. url = "static/template/training/worklicensecertificate.xlsx";
  253. } else if( type.equals("trainingrecords") ) {
  254. downloadname = "培训成绩导入模板.xlsx";
  255. url = "static/template/training/trainingrecords.xlsx";
  256. } else if( type.equals("training") ) {
  257. downloadname = "培训计划执行及跟踪导入模板.xlsx";
  258. url = "static/template/training/training.xlsx";
  259. } else if( type.equals("skillevaluation") ) {
  260. downloadname = "岗位人员技能评估导入模板.xlsx";
  261. url = "static/template/training/skillevaluation.xlsx";
  262. } else if( type.equals("newemployee") ) {
  263. downloadname = "新员工培训导入模板.xlsx";
  264. url = "static/template/training/newemployee.xlsx";
  265. }else if( type.equals("companyLevelRecord") ) {
  266. downloadname = "公司培训成绩导入模板.xlsx";
  267. url = "static/template/training/companyLevelRecord.xlsx";
  268. } else if( type.equals("targetlist") ) {
  269. downloadname = "目标录入导入模板.xlsm";
  270. url = "static/template/plant/targetlist.xlsm";
  271. } else if( type.equals("targetreview") ) {
  272. downloadname = "目标回顾导入模板.xlsx";
  273. url = "static/template/plant/targetreview.xlsx";
  274. } else if( type.equals("manageactivity") ) {
  275. downloadname = "管理活动抽查导入模板.xlsx";
  276. url = "static/template/plant/manageactivity.xlsx";
  277. } else if( type.equals("awardrecord") ) {
  278. downloadname = "人员嘉奖记录导入模板.xlsx";
  279. url = "static/template/plant/awardrecord.xlsx";
  280. } else if( type.equals("staffmgr") ) {
  281. downloadname = "人员信息导入模板.xlsx";
  282. url = "static/template/plant/staffmgr.xlsx";
  283. } else if( type.equals("specYlrq") ) {
  284. downloadname = "压力容器导入模板.xlsx";
  285. url = "static/template/sems/specYlrq.xlsx";
  286. } else if( type.equals("specYlgd") ) {
  287. downloadname = "压力管道导入模板.xlsx";
  288. url = "static/template/sems/specYlgd.xlsx";
  289. }else if( type.equals("specGl") ) {
  290. downloadname = "锅炉导入模板.xlsx";
  291. url = "static/template/sems/specGl.xlsx";
  292. }else if( type.equals("specDzsb") ) {
  293. downloadname = "起重机械导入模板.xlsx";
  294. url = "static/template/sems/specDzsb.xlsx";
  295. }else if( type.equals("specCc") ) {
  296. downloadname = "叉车导入模板.xlsx";
  297. url = "static/template/sems/specCc.xlsx";
  298. }else if( type.equals("specDt") ) {
  299. downloadname = "电梯导入模板.xlsx";
  300. url = "static/template/sems/specDt.xlsx";
  301. }else if( type.equals("reportYlrq") ) {
  302. downloadname = "压力容器年检报告批量导入更新模板.xlsx";
  303. url = "static/template/sems/reportYlrq.xlsx";
  304. }else if( type.equals("reportYlgd") ) {
  305. downloadname = "压力管道年检报告批量导入更新模板.xlsx";
  306. url = "static/template/sems/reportYlgd.xlsx";
  307. }else if( type.equals("thickness") ) {
  308. downloadname = "定点测厚批量导入更新模板.xlsx";
  309. url = "static/template/sems/thickness.xlsx";
  310. }else if( type.equals("thicknessData") ) {
  311. downloadname = "定点测厚数据导入模板.xlsx";
  312. url = "static/template/sems/thicknessData.xlsx";
  313. }else if( type.equals("applyLock") ) {
  314. downloadname = "锁开锁关导入模板.xlsx";
  315. url = "static/template/apply/applyLock.xlsx";
  316. }else if( type.equals("workcertificateCbps") ) {
  317. downloadname = "作业证书模板.xlsx";
  318. url = "static/template/training/workcertificateCbps.xlsx";
  319. }else if( type.equals("quality") ) {
  320. downloadname = "质量月报批量导入模板.xlsx";
  321. url = "static/template/production/quality.xlsx";
  322. }else if( type.equals("trainingMatrix") ) {
  323. downloadname = "培训矩阵导入模板.xlsx";
  324. url = "static/template/training/trainingMatrix.xlsx";
  325. }else if( type.equals("ljPlanTmpl") ) {
  326. downloadname = "裂解培训导入模板.xlsx";
  327. url = "static/template/training/bccnewDsdt.xlsx";
  328. }else if( type.equals("ysPlanTmpl") ) {
  329. downloadname = "压缩培训导入模板.xlsx";
  330. url = "static/template/training/bccnewDsdt.xlsx";
  331. }else if( type.equals("flPlanTmpl") ) {
  332. downloadname = "分离培训导入模板.xlsx";
  333. url = "static/template/training/bccnewDsdt.xlsx";
  334. }else if( type.equals("ftPlanTmpl") ) {
  335. downloadname = "芳烃培训导入模板.xlsx";
  336. url = "static/template/training/bccnewDsdt.xlsx";
  337. }else if( type.equals("jzPlanTmpl") ) {
  338. downloadname = "装置级培训导入模板.xlsx";
  339. url = "static/template/training/bccnewJz.xlsx";
  340. }else if( type.equals("trainerTmpl") ) {
  341. downloadname = "导师库导入模板.xlsx";
  342. url = "static/template/training/bccnewDsk.xlsx";
  343. }else if( type.equals("shiftRoster") ) {
  344. downloadname = "排班计划导入模板.xlsx";
  345. url = "static/template/training/roster.xlsx";
  346. }else if( type.equals("pssrTmpl") ) {
  347. downloadname = "开车条件确认表导入模板.xlsx";
  348. url = "static/template/pssr/pssrTmpl.xlsx";
  349. }else if( type.equals("pssrRegionTmpl") ) {
  350. downloadname = "PSSR区域导入模板.xlsx";
  351. url = "static/template/pssr/pssrRegionTmpl.xlsx";
  352. }else if( type.equals("overhaulExchanger") ) {
  353. downloadname = "PSSR检修项目-换热器导入模板.xlsx";
  354. url = "static/template/pssr/overhaulExchanger.xlsx";
  355. }else if( type.equals("overhaulTower") ) {
  356. downloadname = "PSSR检修项目-塔罐导入模板.xlsx";
  357. url = "static/template/pssr/overhaulTower.xlsx";
  358. }else if( type.equals("overhaulValve") ) {
  359. downloadname = "PSSR检修项目-阀门导入模板.xlsx";
  360. url = "static/template/pssr/overhaulValve.xlsx";
  361. }else if( type.equals("overhaulFilter") ) {
  362. downloadname = "PSSR检修项目-过滤器导入模板.xlsx";
  363. url = "static/template/pssr/overhaulFilter.xlsx";
  364. }else if( type.equals("pssrblind") ) {
  365. downloadname = "PSSR盲板导入模板.xlsx";
  366. url = "static/template/pssr/blind.xlsx";
  367. }else if( type.equals("overhaulExchanger2") ) {
  368. downloadname = "PSSR检修项目-电仪导入模板.xlsx";
  369. url = "static/template/pssr/overhaulExchanger.xlsx";
  370. }else if( type.equals("overhaulExchanger3") ) {
  371. downloadname = "PSSR检修项目-反应器导入模板.xlsx";
  372. url = "static/template/pssr/overhaulExchanger.xlsx";
  373. }else if( type.equals("overhaulExchanger4") ) {
  374. downloadname = "PSSR检修项目-裂解炉导入模板.xlsx";
  375. url = "static/template/pssr/overhaulExchanger.xlsx";
  376. }else if( type.equals("overhaulExchanger5") ) {
  377. downloadname = "PSSR检修项目-其它导入模板.xlsx";
  378. url = "static/template/pssr/overhaulExchanger.xlsx";
  379. }else if( type.equals("overhaulExchanger6") ) {
  380. downloadname = "PSSR检修项目-动设备导入模板.xlsx";
  381. url = "static/template/pssr/overhaulExchanger.xlsx";
  382. }else if( type.equals("overhaulExchanger7") ) {
  383. downloadname = "PSSR检修项目-安全附件导入模板.xlsx";
  384. url = "static/template/pssr/overhaulExchanger.xlsx";
  385. }else if( type.equals("overhaulExchanger8") ) {
  386. downloadname = "PSSR检修项目-管道导入模板.xlsx";
  387. url = "static/template/pssr/overhaulExchanger.xlsx";
  388. }else if( type.equals("hygiene") ) {
  389. downloadname = "PSSR现场卫生导入模板.xlsx";
  390. url = "static/template/pssr/hygiene.xlsx";
  391. }else if( type.equals("measure") ) {
  392. downloadname = "PSSR人身防护现场转动设备防护措施检查表导入模板.xlsx";
  393. url = "static/template/pssr/measure.xlsx";
  394. }else if( type.equals("protection") ) {
  395. downloadname = "PSSR人身防护现场管道和设备保温防护检查表导入模板.xlsx";
  396. url = "static/template/pssr/protection.xlsx";
  397. }else if( type.equals("cleaning") ) {
  398. downloadname = "PSSR设备清洁度导入模板.xlsx";
  399. url = "static/template/pssr/cleaning.xlsx";
  400. }else if( type.equals("airtight") ) {
  401. downloadname = "PSSR气密导入模板.xlsx";
  402. url = "static/template/pssr/airtight.xlsx";
  403. }else if( type.equals("laboratory") ) {
  404. downloadname = "PSSR实验室导入模板.xlsx";
  405. url = "static/template/pssr/laboratory.xlsx";
  406. }else if( type.equals("circuit") ) {
  407. downloadname = "PSSR短接导入模板.xlsx";
  408. url = "static/template/pssr/circuit.xlsx";
  409. }else if( type.equals("nitrogen") ) {
  410. downloadname = "PSSR氮气置换导入模板.xlsx";
  411. url = "static/template/pssr/nitrogen.xlsx";
  412. }else if( type.equals("safetyBrust") ) {
  413. downloadname = "PSSR安全设施-爆破片导入模板.xlsx";
  414. url = "static/template/pssr/safetyBrust.xlsx";
  415. }else if( type.equals("safetyBreath") ) {
  416. downloadname = "PSSR安全设施-呼吸阀导入模板.xlsx";
  417. url = "static/template/pssr/safetyBreath.xlsx";
  418. }else if( type.equals("safetyBleed") ) {
  419. downloadname = "PSSR安全设施-泄放阀导入模板.xlsx";
  420. url = "static/template/pssr/safetyBleed.xlsx";
  421. }else if( type.equals("safetyFlamearrester") ) {
  422. downloadname = "PSSR安全设施-阻火器导入模板.xlsx";
  423. url = "static/template/pssr/safetyFlamearrester.xlsx";
  424. }else if( type.equals("pumpFill") ) {//
  425. downloadname = "PSSR机泵-润滑油加注确认清单导入模板.xlsx";
  426. url = "static/template/pssr/pumpFill.xlsx";
  427. }else if( type.equals("pumpOverhaul") ) {
  428. downloadname = "PSSR机泵-检修完成确认清单导入模板.xlsx";
  429. url = "static/template/pssr/pumpOverhaul.xlsx";
  430. }else if( type.equals("pumpCleaning") ) {
  431. downloadname = "PSSR机泵-过滤器清理回装确认表导入模板.xlsx";
  432. url = "static/template/pssr/pumpCleaning.xlsx";
  433. }else if( type.equals("motor") ) {
  434. downloadname = "PSSR电机设备导入模板.xlsx";
  435. url = "static/template/pssr/motor.xlsx";
  436. }else if( type.equals("calibration") ) {
  437. downloadname = "PSSR仪表校验导入模板.xlsx";
  438. url = "static/template/pssr/calibration.xlsx";
  439. }else if( type.equals("frame") ) {
  440. downloadname = "PSSR支(吊)架导入模板.xlsx";
  441. url = "static/template/pssr/frame.xlsx";
  442. }else if( type.equals("franklinism") ) {
  443. downloadname = "PSSR静电接地,跨接导入模板.xlsx";
  444. url = "static/template/pssr/franklinism.xlsx";
  445. }else if( type.equals("gasdetector") ) {
  446. downloadname = "PSSR气体检测器导入模板.xlsx";
  447. url = "static/template/pssr/gasdetector.xlsx";
  448. }else if( type.equals("analyzer") ) {
  449. downloadname = "PSSR在线分析仪导入模板.xlsx";
  450. url = "static/template/pssr/analyzer.xlsx";
  451. }else if( type.equals("pssrFrameTmpl") ) {
  452. downloadname = "PSSR支(吊)架模板数据维护.xlsx";
  453. url = "static/template/pssr/frameModel.xlsx";
  454. }else if( type.equals("issuelist") ) {
  455. downloadname = "装置问题滚动清单导入模板.xlsx";
  456. url = "static/template/issue/issuelistTmpl.xlsx";
  457. }else if( type.equals("operationlist") ) {
  458. downloadname = "工艺事件清单导入模板.xlsx";
  459. url = "static/template/issue/OperationlistTmpl.xlsx";
  460. } else if( type.equals("eoegLock") ) {
  461. downloadname = "Eoeg锁开锁关导入模板.xlsx";
  462. url = "static/template/eoeg/eoegLock.xlsx";
  463. }
  464. InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(url);
  465. downloadFile(downloadname, is, request, response);
  466. }
  467. /**
  468. * 通用下载请求
  469. *
  470. * @param fileName 文件名称
  471. * @param delete 是否删除
  472. */
  473. @GetMapping("common/download")
  474. public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
  475. {
  476. try
  477. {
  478. if (!FileUtils.isValidFilename(fileName))
  479. {
  480. throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
  481. }
  482. String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
  483. String filePath = RuoYiConfig.getDownloadPath() + fileName;
  484. response.setCharacterEncoding("utf-8");
  485. response.setContentType("multipart/form-data");
  486. response.setHeader("Content-Disposition",
  487. "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
  488. FileUtils.writeBytes(filePath, response.getOutputStream());
  489. if (delete)
  490. {
  491. FileUtils.deleteFile(filePath);
  492. }
  493. }
  494. catch (Exception e)
  495. {
  496. log.error("下载文件失败", e);
  497. }
  498. }
  499. /**
  500. * 通用上传请求
  501. */
  502. @PostMapping("/common/upload")
  503. public AjaxResult uploadFile(MultipartFile file) throws Exception
  504. {
  505. try
  506. {
  507. // 上传文件路径
  508. String filePath = RuoYiConfig.getUploadPath();
  509. // 上传并返回新文件名称
  510. String fileName = FileUploadUtils.upload(filePath, file);
  511. String url = serverConfig.getUrl() + fileName;
  512. logger.info("url:" + url);
  513. AjaxResult ajax = AjaxResult.success();
  514. ajax.put("fileName", fileName);
  515. ajax.put("url", url);
  516. return ajax;
  517. }
  518. catch (Exception e)
  519. {
  520. return AjaxResult.error(e.getMessage());
  521. }
  522. }
  523. /**
  524. * 通用上传请求(多个)
  525. */
  526. @PostMapping("/common/uploads")
  527. public AjaxResult uploadFiles(List<MultipartFile> files, @RequestParam(value = "fileDir", required = false) String fileDir) throws Exception {
  528. try {
  529. // 上传文件路径
  530. String filePath;
  531. if (StringUtils.isNotEmpty(fileDir)) {
  532. filePath = RuoYiConfig.getUploadPath(getResource(fileDir));
  533. } else {
  534. filePath = RuoYiConfig.getUploadPath();
  535. }
  536. List<String> urls = new ArrayList<String>();
  537. List<String> fileNames = new ArrayList<String>();
  538. List<String> newFileNames = new ArrayList<String>();
  539. List<String> originalFilenames = new ArrayList<String>();
  540. for (MultipartFile file : files) {
  541. // 上传并返回新文件名称
  542. String fileName = FileUploadUtils.upload(filePath, file);
  543. String url = serverConfig.getUrl() + fileName;
  544. urls.add(url);
  545. fileNames.add(fileName);
  546. newFileNames.add(FileUtils.getName(fileName));
  547. originalFilenames.add(file.getOriginalFilename());
  548. }
  549. AjaxResult ajax = AjaxResult.success();
  550. ajax.put("urls", StringUtils.join(fileNames, FILE_DELIMETER));
  551. ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
  552. ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
  553. ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
  554. return ajax;
  555. } catch (Exception e) {
  556. return AjaxResult.error(e.getMessage());
  557. }
  558. }
  559. private static String getResource(String type) {
  560. switch (type) {
  561. case "1":
  562. return "/annihiliator";
  563. case "12":
  564. return "/eyewash";
  565. default:
  566. return "";
  567. }
  568. }
  569. /**
  570. * 本地资源通用下载
  571. */
  572. @GetMapping("/common/download/resource")
  573. public void resourceDownload(String name, HttpServletRequest request, HttpServletResponse response) throws Exception
  574. {
  575. // 本地资源路径
  576. String localPath = RuoYiConfig.getProfile();
  577. // 数据库资源地址
  578. String downloadPath = localPath + StringUtils.substringAfter(name, Constants.RESOURCE_PREFIX);
  579. // 下载名称
  580. String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
  581. response.setCharacterEncoding("utf-8");
  582. response.setContentType("multipart/form-data");
  583. response.setHeader("Content-Disposition",
  584. "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
  585. FileUtils.writeBytes(downloadPath, response.getOutputStream());
  586. }
  587. public static void downloadFile(String filename, InputStream is, HttpServletRequest request, HttpServletResponse response) throws IOException {
  588. response.reset();
  589. if (filename.endsWith(".doc") || filename.endsWith(".docx")) {
  590. response.setContentType("application/msword;charset=utf-8");
  591. } else if (filename.endsWith(".xls") || filename.endsWith(".xlsx")) {
  592. response.setContentType("application/vnd.ms-excel;charset=utf-8");
  593. } else {
  594. response.setHeader("content-type", "application/octet-stream");
  595. }
  596. //下载文件的名称
  597. response.setHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes("UTF-8"), "iso-8859-1"));
  598. request.setCharacterEncoding("UTF-8");
  599. ServletOutputStream out = null;
  600. BufferedInputStream bis = null;
  601. BufferedOutputStream bos = null;
  602. try {
  603. out = response.getOutputStream();
  604. bis = new BufferedInputStream(is);
  605. bos = new BufferedOutputStream(out);
  606. byte[] buff = new byte[2048];
  607. int bytesRead;
  608. while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
  609. bos.write(buff, 0, bytesRead);
  610. }
  611. } catch (IOException e) {
  612. e.printStackTrace();
  613. } finally {
  614. try {
  615. if (bis != null) {
  616. bis.close();
  617. }
  618. if (bos != null) {
  619. bos.close();
  620. }
  621. if (is != null) {
  622. is.close();
  623. }
  624. } catch (IOException e) {
  625. e.printStackTrace();
  626. }
  627. }
  628. }
  629. // @RequestMapping("/common/download/exportDevList")
  630. // public ModelAndView exportbmy(@RequestParam Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) throws ParseException {
  631. // logger.info(JSON.toJSONString(params));
  632. // String id = (String) params.get("ids");
  633. // int devType = Integer.parseInt((String) params.get("devType"));
  634. // String[] ids = id.split(",");
  635. // logger.info("ids" + ids);
  636. // int downloadType = Integer.parseInt((String) params.get("downloadType"));
  637. // logger.info("downloadType" + downloadType);
  638. // List<Object> list = new ArrayList<>();
  639. // switch (devType) {
  640. // case 1:
  641. // for (String i : ids
  642. // ) {
  643. // TSpecdevYlrq ylrqEntity = tSpecdevYlrqService.getById(i);
  644. // list.add(ylrqEntity);
  645. // }
  646. // break;
  647. // case 2:
  648. // for (String i : ids
  649. // ) {
  650. // TSpecdevYlgd ylgdEntity = tSpecdevYlgdService.getById(i);
  651. // list.add(ylgdEntity);
  652. // }
  653. // break;
  654. // case 3:
  655. // for (String i : ids
  656. // ) {
  657. // TSpecdevDzsb dzsbEntity = tSpecdevDzsbService.getById(i);
  658. // list.add(dzsbEntity);
  659. // }
  660. // break;
  661. // case 4:
  662. // for (String i : ids
  663. // ) {
  664. // TSpecdevGl glEntity = tSpecdevGlService.getById(i);
  665. // list.add(glEntity);
  666. // }
  667. // break;
  668. // case 5:
  669. // for (String i : ids
  670. // ) {
  671. // TSpecdevDt dtEntity = tSpecdevDtService.getById(i);
  672. // list.add(dtEntity);
  673. // }
  674. // break;
  675. // case 6:
  676. // for (String i : ids
  677. // ) {
  678. // TSpecdevCc ccEntity = tSpecdevCcService.getById(i);
  679. // list.add(ccEntity);
  680. // }
  681. // break;
  682. // case 7:
  683. //// for (String i : ids
  684. //// ) {
  685. //// TOtherTankEntity tankEntity = tOtherTankService.getById(i);
  686. //// list.add(tankEntity);
  687. //// }
  688. // }
  689. // if(devType == 1 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_YLRQ_UPDATE, list)); }
  690. // else if(devType == 2 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_YLGD_UPDATE, list)); }
  691. // else if(devType == 3 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_DZSB_UPDATE, list)); }
  692. // else if(devType == 4 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_GL_UPDATE, list)); }
  693. // else if(devType == 5 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_DT_UPDATE, list)); }
  694. // else if(devType == 6 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_CC_UPDATE, list)); }
  695. // return null;
  696. // }
  697. @GetMapping("/common/download/exportDevList")
  698. public AjaxResult exportbmy(TSpecdevGl tSpecdevGl) throws IOException {
  699. logger.info("kaishi");
  700. SXSSFWorkbook wb = new SXSSFWorkbook(1000);
  701. CellStyle wrapStyle = wb.createCellStyle();
  702. wrapStyle.setWrapText(true); //设置自动换行
  703. //创建sheet页
  704. Sheet sheet = wb.createSheet("sheetName");
  705. //设置列的宽度,第一个参数为列的序号,从0开始,第二参数为列宽,单位1/256个字节
  706. sheet.setColumnWidth(0, 12*256);
  707. sheet.setColumnWidth(2, 16*256);
  708. sheet.setColumnWidth(5, 12*256);
  709. sheet.setColumnWidth(6, 26*256);
  710. sheet.setColumnWidth(7, 26*256);
  711. //设置开始行和开始列
  712. int rowIndex = 0;
  713. int columnIndex = 0;
  714. Row row = sheet.createRow(rowIndex);
  715. OutputStream out = null;
  716. String filename = encodingFilename("sheetName");
  717. out = new FileOutputStream(getAbsoluteFile(filename));
  718. wb.write(out);
  719. wb.close();
  720. out.close();
  721. return AjaxResult.success(filename);
  722. }
  723. /**
  724. * 编码文件名
  725. */
  726. public String encodingFilename(String filename)
  727. {
  728. filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx";
  729. return filename;
  730. }
  731. /**
  732. * 获取下载路径
  733. *
  734. * @param filename 文件名称
  735. */
  736. public String getAbsoluteFile(String filename)
  737. {
  738. String downloadPath = RuoYiConfig.getDownloadPath() + filename;
  739. File desc = new File(downloadPath);
  740. if (!desc.getParentFile().exists())
  741. {
  742. desc.getParentFile().mkdirs();
  743. }
  744. return downloadPath;
  745. }
  746. }