CommonController.java 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895
  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("rcSai") ) {
  113. downloadname = "RC_SAI检查管理导入模板.xlsx";
  114. url = "static/template/production/rcSai.xlsx";
  115. } else if( type.equals("rcSaiApply") ) {
  116. downloadname = "RC_SAI开项管理导入模板.xlsx";
  117. url = "static/template/production/rcSaiApply.xlsx";
  118. } else if( type.equals("eoegsai") ) {
  119. downloadname = "EOEG_SAI检查管理导入模板.xlsx";
  120. url = "static/template/production/eoegSai.xlsx";
  121. } else if( type.equals("eoegSaiApply") ) {
  122. downloadname = "EOEG_SAI开项管理导入模板.xlsx";
  123. url = "static/template/production/eoegSaiApply.xlsx";
  124. } else if( type.equals("rcaudit") ) {
  125. downloadname = "RC审计助手导入模板.xlsx";
  126. url = "static/template/ehs/rcaudit.xlsx";
  127. } else if( type.equals("rcauditmenu") ) {
  128. downloadname = "RC审计助手目录导入模板.xlsx";
  129. url = "static/template/ehs/rcauditmenu.xlsx";
  130. } else if( type.equals("plantproglistprocedure") ) {
  131. downloadname = "装置程序清单程序总汇导入模板.xlsx";
  132. url = "static/template/document/plantproglistprocedure.xlsx";
  133. } else if( type.equals("plantproglistform") ) {
  134. downloadname = "装置程序清单表格总汇导入模板.xlsx";
  135. url = "static/template/document/plantproglistform.xlsx";
  136. } else if( type.equals("plantproglistguide") ) {
  137. downloadname = "装置程序清单指南总汇导入模板.xlsx";
  138. url = "static/template/document/plantproglistguide.xlsx";
  139. } else if( type.equals("plantproglistbook") ) {
  140. downloadname = "装置程序清单指导书总汇导入模板.xlsx";
  141. url = "static/template/document/plantproglistbook.xlsx";
  142. } else if( type.equals("plantproglistannex") ) {
  143. downloadname = "装置程序清单附件总汇导入模板.xlsx";
  144. url = "static/template/document/plantproglistannex.xlsx";
  145. } else if( type.equals("plantproglistmaterials") ) {
  146. downloadname = "装置程序清单培训材料导入模板.xlsx";
  147. url = "static/template/document/plantproglistmaterials.xlsx";
  148. }else if( type.equals("plantproglistother") ) {
  149. downloadname = "装置程序清单其他导入模板.xlsx";
  150. url = "static/template/document/plantproglistother.xlsx";
  151. } else if( type.equals("officesupply") ) {
  152. downloadname = "办公用品管理导入模板.xlsx";
  153. url = "static/template/affair/officesupply.xlsx";
  154. } else if( type.equals("ppe") ) {
  155. downloadname = "PPE发放登记导入模板.xlsx";
  156. url = "static/template/affair/ppe.xlsx";
  157. } else if( type.equals("intercom") ) {
  158. downloadname = "对讲机管理导入模板.xlsx";
  159. url = "static/template/affair/intercom.xlsx";
  160. } else if( type.equals("kkxglcs") ) {
  161. downloadname = "可靠性管理措施导入模板.xlsx";
  162. url = "static/template/reliability/kkxglcs.xlsx";
  163. } else if( type.equals("original") ) {
  164. downloadname = "故障管理初选导入模板.xlsx";
  165. url = "static/template/reliability/original.xlsx";
  166. } else if( type.equals("abnormalreport") ) {
  167. downloadname = "异常报告管理导入模板.xlsx";
  168. url = "static/template/reliability/abnormalreport.xlsx";
  169. } else if( type.equals("assetlist") ) {
  170. downloadname = "资产清单导入模板.xlsx";
  171. url = "static/template/reliability/assetlist.xlsx";
  172. } else if( type.equals("safetyvavle") ) {
  173. downloadname = "安全阀清单导入模板.xlsx";
  174. url = "static/template/reliability/safetyvavle.xlsx";
  175. } else if( type.equals("preventivemaintenance") ) {
  176. downloadname = "预防性维修导入模板.xlsx";
  177. url = "static/template/reliability/preventivemaintenance.xlsx";
  178. } else if( type.equals("pipe") ) {
  179. downloadname = "管线清单导入模板.xlsx";
  180. url = "static/template/cui/pipe.xlsx";
  181. } else if( type.equals("pvessel") ) {
  182. downloadname = "容器清单导入模板.xlsx";
  183. url = "static/template/cui/pvessel.xlsx";
  184. } else if( type.equals("problems") ) {
  185. downloadname = "CUI问题整改跟踪清单导入模板.xlsx";
  186. url = "static/template/cui/problems.xlsx";
  187. } else if( type.equals("eyewasher") ) {
  188. downloadname = "洗眼器导入模板.xlsx";
  189. url = "static/template/ehs/eyewasher.xlsx";
  190. } else if( type.equals("firehose") ) {
  191. downloadname = "消防水带箱导入模板.xlsx";
  192. url = "static/template/ehs/firehose.xlsx";
  193. } else if( type.equals("firehydrant") ) {
  194. downloadname = "消防栓导入模板.xlsx";
  195. url = "static/template/ehs/firehydrant.xlsx";
  196. } else if( type.equals("highpresfire") ) {
  197. downloadname = "高压消防炮导入模板.xlsx";
  198. url = "static/template/ehs/highpresfire.xlsx";
  199. } else if( type.equals("fireextinguisher") ) {
  200. downloadname = "灭火器导入模板.xlsx";
  201. url = "static/template/ehs/fireextinguisher.xlsx";
  202. } else if( type.equals("autosprinkler") ) {
  203. downloadname = "自动喷淋系统导入模板.xlsx";
  204. url = "static/template/ehs/autosprinkler.xlsx";
  205. } else if( type.equals("firestandpipe") ) {
  206. downloadname = "消防竖管导入模板.xlsx";
  207. url = "static/template/ehs/firestandpipe.xlsx";
  208. } else if( type.equals("safetyapproval") ) {
  209. downloadname = "安全批文清单导入模板.xlsx";
  210. url = "static/template/ehs/safetyapproval.xlsx";
  211. } else if( type.equals("fireapproval") ) {
  212. downloadname = "消防批文清单导入模板.xlsx";
  213. url = "static/template/ehs/fireapproval.xlsx";
  214. } else if( type.equals("environapproval") ) {
  215. downloadname = "环保批文清单导入模板.xlsx";
  216. url = "static/template/ehs/environapproval.xlsx";
  217. } else if( type.equals("healthapproval") ) {
  218. downloadname = "卫生批文清单导入模板.xlsx";
  219. url = "static/template/ehs/healthapproval.xlsx";
  220. } else if( type.equals("safetyapprcont") ) {
  221. downloadname = "安全批文主要内容导入模板.xlsx";
  222. url = "static/template/ehs/safetyapprcont.xlsx";
  223. } else if( type.equals("environapprcont") ) {
  224. downloadname = "环保批文主要内容导入模板.xlsx";
  225. url = "static/template/ehs/environapprcont.xlsx";
  226. } else if( type.equals("jobticket") ) {
  227. downloadname = "工作票导入模板.xlsx";
  228. url = "static/template/ehs/jobticket.xlsx";
  229. } else if( type.equals("msds") ) {
  230. downloadname = "MSDS管理导入模板.xlsx";
  231. url = "static/template/ehs/msds.xlsx";
  232. } else if( type.equals("incidentRecords") ) {
  233. downloadname = "事故报告清单导入模板.xlsx";
  234. url = "static/template/ehs/incidentRecords.xlsx";
  235. } else if( type.equals("water") ) {
  236. downloadname = "废水风险评估导入模板.xlsx";
  237. url = "static/template/ehs/water.xlsx";
  238. } else if( type.equals("danger") ) {
  239. downloadname = "危险废物清单导入模板.xlsx";
  240. url = "static/template/ehs/danger.xlsx";
  241. } else if( type.equals("dangermonth") ) {
  242. downloadname = "危险废物出入库月报导入模板.xlsx";
  243. url = "static/template/ehs/dangermonth.xlsx";
  244. } else if( type.equals("barrelmonth") ) {
  245. downloadname = "废桶进出库统计日报导入模板.xlsx";
  246. url = "static/template/ehs/barrelmonth.xlsx";
  247. } else if( type.equals("dangerday") ) {
  248. downloadname = "危废出入库统计日报导入模板.xlsx";
  249. url = "static/template/ehs/dangerday.xlsx";
  250. } else if( type.equals("workcertificate") ) {
  251. downloadname = "作业证书一览表导入模板.xlsx";
  252. url = "static/template/training/workcertificate.xlsx";
  253. } else if( type.equals("byxworkcertificate") ) {
  254. downloadname = "苯乙烯作业证书一览表导入模板.xlsx";
  255. url = "static/template/training/byxworkcertificate.xlsx";
  256. } else if( type.equals("worklicense") ) {
  257. downloadname = "上岗证一览表导入模板.xlsx";
  258. url = "static/template/training/worklicense.xlsx";
  259. } else if( type.equals("worklicenseCertificate") ) {
  260. downloadname = "上岗证/作业证书一览表导入模板.xlsx";
  261. url = "static/template/training/worklicensecertificate.xlsx";
  262. } else if( type.equals("trainingrecords") ) {
  263. downloadname = "培训成绩导入模板.xlsx";
  264. url = "static/template/training/trainingrecords.xlsx";
  265. } else if( type.equals("training") ) {
  266. downloadname = "培训计划执行及跟踪导入模板.xlsx";
  267. url = "static/template/training/training.xlsx";
  268. } else if( type.equals("skillevaluation") ) {
  269. downloadname = "岗位人员技能评估导入模板.xlsx";
  270. url = "static/template/training/skillevaluation.xlsx";
  271. } else if( type.equals("newemployee") ) {
  272. downloadname = "新员工培训导入模板.xlsx";
  273. url = "static/template/training/newemployee.xlsx";
  274. }else if( type.equals("companyLevelRecord") ) {
  275. downloadname = "公司培训成绩导入模板.xlsx";
  276. url = "static/template/training/companyLevelRecord.xlsx";
  277. } else if( type.equals("targetlist") ) {
  278. downloadname = "目标录入导入模板.xlsm";
  279. url = "static/template/plant/targetlist.xlsm";
  280. } else if( type.equals("targetreview") ) {
  281. downloadname = "目标回顾导入模板.xlsx";
  282. url = "static/template/plant/targetreview.xlsx";
  283. } else if( type.equals("manageactivity") ) {
  284. downloadname = "管理活动抽查导入模板.xlsx";
  285. url = "static/template/plant/manageactivity.xlsx";
  286. } else if( type.equals("awardrecord") ) {
  287. downloadname = "人员嘉奖记录导入模板.xlsx";
  288. url = "static/template/plant/awardrecord.xlsx";
  289. } else if( type.equals("staffmgr") ) {
  290. downloadname = "人员信息导入模板.xlsx";
  291. url = "static/template/plant/staffmgr.xlsx";
  292. } else if( type.equals("specYlrq") ) {
  293. downloadname = "压力容器导入模板.xlsx";
  294. url = "static/template/sems/specYlrq.xlsx";
  295. } else if( type.equals("specYlgd") ) {
  296. downloadname = "压力管道导入模板.xlsx";
  297. url = "static/template/sems/specYlgd.xlsx";
  298. }else if( type.equals("specGl") ) {
  299. downloadname = "锅炉导入模板.xlsx";
  300. url = "static/template/sems/specGl.xlsx";
  301. }else if( type.equals("specDzsb") ) {
  302. downloadname = "起重机械导入模板.xlsx";
  303. url = "static/template/sems/specDzsb.xlsx";
  304. }else if( type.equals("specCc") ) {
  305. downloadname = "叉车导入模板.xlsx";
  306. url = "static/template/sems/specCc.xlsx";
  307. }else if( type.equals("specDt") ) {
  308. downloadname = "电梯导入模板.xlsx";
  309. url = "static/template/sems/specDt.xlsx";
  310. }else if( type.equals("reportYlrq") ) {
  311. downloadname = "压力容器年检报告批量导入更新模板.xlsx";
  312. url = "static/template/sems/reportYlrq.xlsx";
  313. }else if( type.equals("reportYlgd") ) {
  314. downloadname = "压力管道年检报告批量导入更新模板.xlsx";
  315. url = "static/template/sems/reportYlgd.xlsx";
  316. }else if( type.equals("thickness") ) {
  317. downloadname = "定点测厚批量导入更新模板.xlsx";
  318. url = "static/template/sems/thickness.xlsx";
  319. }else if( type.equals("thicknessData") ) {
  320. downloadname = "定点测厚数据导入模板.xlsx";
  321. url = "static/template/sems/thicknessData.xlsx";
  322. }else if( type.equals("applyLock") ) {
  323. downloadname = "锁开锁关导入模板.xlsx";
  324. url = "static/template/apply/applyLock.xlsx";
  325. }else if( type.equals("workcertificateCbps") ) {
  326. downloadname = "作业证书模板.xlsx";
  327. url = "static/template/training/workcertificateCbps.xlsx";
  328. }else if( type.equals("quality") ) {
  329. downloadname = "质量月报批量导入模板.xlsx";
  330. url = "static/template/production/quality.xlsx";
  331. }else if( type.equals("trainingMatrix") ) {
  332. downloadname = "培训矩阵导入模板.xlsx";
  333. url = "static/template/training/trainingMatrix.xlsx";
  334. }else if( type.equals("ljPlanTmpl") ) {
  335. downloadname = "裂解培训导入模板.xlsx";
  336. url = "static/template/training/bccnewDsdt.xlsx";
  337. }else if( type.equals("ysPlanTmpl") ) {
  338. downloadname = "压缩培训导入模板.xlsx";
  339. url = "static/template/training/bccnewDsdt.xlsx";
  340. }else if( type.equals("flPlanTmpl") ) {
  341. downloadname = "分离培训导入模板.xlsx";
  342. url = "static/template/training/bccnewDsdt.xlsx";
  343. }else if( type.equals("ftPlanTmpl") ) {
  344. downloadname = "芳烃培训导入模板.xlsx";
  345. url = "static/template/training/bccnewDsdt.xlsx";
  346. }else if( type.equals("jzPlanTmpl") ) {
  347. downloadname = "装置级培训导入模板.xlsx";
  348. url = "static/template/training/bccnewJz.xlsx";
  349. }else if( type.equals("trainerTmpl") ) {
  350. downloadname = "导师库导入模板.xlsx";
  351. url = "static/template/training/bccnewDsk.xlsx";
  352. }else if( type.equals("shiftRoster") ) {
  353. downloadname = "排班计划导入模板.xlsx";
  354. url = "static/template/training/roster.xlsx";
  355. }else if( type.equals("pssrTmpl") ) {
  356. downloadname = "开车条件确认表导入模板.xlsx";
  357. url = "static/template/pssr/pssrTmpl.xlsx";
  358. }else if( type.equals("pssrRegionTmpl") ) {
  359. downloadname = "PSSR区域导入模板.xlsx";
  360. url = "static/template/pssr/pssrRegionTmpl.xlsx";
  361. }else if( type.equals("overhaulExchanger") ) {
  362. downloadname = "PSSR检修项目-换热器导入模板.xlsx";
  363. url = "static/template/pssr/overhaulExchanger.xlsx";
  364. }else if( type.equals("overhaulTower") ) {
  365. downloadname = "PSSR检修项目-塔罐导入模板.xlsx";
  366. url = "static/template/pssr/overhaulTower.xlsx";
  367. }else if( type.equals("overhaulValve") ) {
  368. downloadname = "PSSR检修项目-阀门导入模板.xlsx";
  369. url = "static/template/pssr/overhaulValve.xlsx";
  370. }else if( type.equals("overhaulFilter") ) {
  371. downloadname = "PSSR检修项目-过滤器导入模板.xlsx";
  372. url = "static/template/pssr/overhaulFilter.xlsx";
  373. }else if( type.equals("pssrblind") ) {
  374. downloadname = "PSSR盲板导入模板.xlsx";
  375. url = "static/template/pssr/blind.xlsx";
  376. }else if( type.equals("overhaulExchanger2") ) {
  377. downloadname = "PSSR检修项目-电仪导入模板.xlsx";
  378. url = "static/template/pssr/overhaulExchanger.xlsx";
  379. }else if( type.equals("overhaulExchanger3") ) {
  380. downloadname = "PSSR检修项目-反应器导入模板.xlsx";
  381. url = "static/template/pssr/overhaulExchanger.xlsx";
  382. }else if( type.equals("overhaulExchanger4") ) {
  383. downloadname = "PSSR检修项目-裂解炉导入模板.xlsx";
  384. url = "static/template/pssr/overhaulExchanger.xlsx";
  385. }else if( type.equals("overhaulExchanger5") ) {
  386. downloadname = "PSSR检修项目-其它导入模板.xlsx";
  387. url = "static/template/pssr/overhaulExchanger.xlsx";
  388. }else if( type.equals("overhaulExchanger6") ) {
  389. downloadname = "PSSR检修项目-动设备导入模板.xlsx";
  390. url = "static/template/pssr/overhaulExchanger.xlsx";
  391. }else if( type.equals("overhaulExchanger7") ) {
  392. downloadname = "PSSR检修项目-安全附件导入模板.xlsx";
  393. url = "static/template/pssr/overhaulExchanger.xlsx";
  394. }else if( type.equals("overhaulExchanger8") ) {
  395. downloadname = "PSSR检修项目-管道导入模板.xlsx";
  396. url = "static/template/pssr/overhaulExchanger.xlsx";
  397. }else if( type.equals("hygiene") ) {
  398. downloadname = "PSSR现场卫生导入模板.xlsx";
  399. url = "static/template/pssr/hygiene.xlsx";
  400. }else if( type.equals("measure") ) {
  401. downloadname = "PSSR人身防护现场转动设备防护措施检查表导入模板.xlsx";
  402. url = "static/template/pssr/measure.xlsx";
  403. }else if( type.equals("protection") ) {
  404. downloadname = "PSSR人身防护现场管道和设备保温防护检查表导入模板.xlsx";
  405. url = "static/template/pssr/protection.xlsx";
  406. }else if( type.equals("cleaning") ) {
  407. downloadname = "PSSR设备清洁度导入模板.xlsx";
  408. url = "static/template/pssr/cleaning.xlsx";
  409. }else if( type.equals("airtight") ) {
  410. downloadname = "PSSR气密导入模板.xlsx";
  411. url = "static/template/pssr/airtight.xlsx";
  412. }else if( type.equals("laboratory") ) {
  413. downloadname = "PSSR实验室导入模板.xlsx";
  414. url = "static/template/pssr/laboratory.xlsx";
  415. }else if( type.equals("circuit") ) {
  416. downloadname = "PSSR短接导入模板.xlsx";
  417. url = "static/template/pssr/circuit.xlsx";
  418. }else if( type.equals("nitrogen") ) {
  419. downloadname = "PSSR氮气置换导入模板.xlsx";
  420. url = "static/template/pssr/nitrogen.xlsx";
  421. }else if( type.equals("safetyBrust") ) {
  422. downloadname = "PSSR安全设施-爆破片导入模板.xlsx";
  423. url = "static/template/pssr/safetyBrust.xlsx";
  424. }else if( type.equals("safetyBreath") ) {
  425. downloadname = "PSSR安全设施-呼吸阀导入模板.xlsx";
  426. url = "static/template/pssr/safetyBreath.xlsx";
  427. }else if( type.equals("safetyBleed") ) {
  428. downloadname = "PSSR安全设施-泄放阀导入模板.xlsx";
  429. url = "static/template/pssr/safetyBleed.xlsx";
  430. }else if( type.equals("safetyFlamearrester") ) {
  431. downloadname = "PSSR安全设施-阻火器导入模板.xlsx";
  432. url = "static/template/pssr/safetyFlamearrester.xlsx";
  433. }else if( type.equals("pumpFill") ) {//
  434. downloadname = "PSSR机泵-润滑油加注确认清单导入模板.xlsx";
  435. url = "static/template/pssr/pumpFill.xlsx";
  436. }else if( type.equals("pumpOverhaul") ) {
  437. downloadname = "PSSR机泵-检修完成确认清单导入模板.xlsx";
  438. url = "static/template/pssr/pumpOverhaul.xlsx";
  439. }else if( type.equals("pumpCleaning") ) {
  440. downloadname = "PSSR机泵-过滤器清理回装确认表导入模板.xlsx";
  441. url = "static/template/pssr/pumpCleaning.xlsx";
  442. }else if( type.equals("motor") ) {
  443. downloadname = "PSSR电机设备导入模板.xlsx";
  444. url = "static/template/pssr/motor.xlsx";
  445. }else if( type.equals("calibration") ) {
  446. downloadname = "PSSR仪表校验导入模板.xlsx";
  447. url = "static/template/pssr/calibration.xlsx";
  448. }else if( type.equals("frame") ) {
  449. downloadname = "PSSR支(吊)架导入模板.xlsx";
  450. url = "static/template/pssr/frame.xlsx";
  451. }else if( type.equals("franklinism") ) {
  452. downloadname = "PSSR静电接地,跨接导入模板.xlsx";
  453. url = "static/template/pssr/franklinism.xlsx";
  454. }else if( type.equals("gasdetector") ) {
  455. downloadname = "PSSR气体检测器导入模板.xlsx";
  456. url = "static/template/pssr/gasdetector.xlsx";
  457. }else if( type.equals("analyzer") ) {
  458. downloadname = "PSSR在线分析仪导入模板.xlsx";
  459. url = "static/template/pssr/analyzer.xlsx";
  460. }else if( type.equals("pssrFrameTmpl") ) {
  461. downloadname = "PSSR支(吊)架模板数据维护.xlsx";
  462. url = "static/template/pssr/frameModel.xlsx";
  463. }else if( type.equals("issuelist") ) {
  464. downloadname = "装置问题滚动清单导入模板.xlsx";
  465. url = "static/template/issue/issuelistTmpl.xlsx";
  466. }else if( type.equals("operationlist") ) {
  467. downloadname = "工艺事件清单导入模板.xlsx";
  468. url = "static/template/issue/OperationlistTmpl.xlsx";
  469. } else if( type.equals("eoegLock") ) {
  470. downloadname = "Eoeg锁开锁关导入模板.xlsx";
  471. url = "static/template/eoeg/eoegLock.xlsx";
  472. } else if( type.equals("maintenance") ) {
  473. downloadname = "CTM文档管理导入模板.xlsx";
  474. url = "static/template/ldpe/ldpe-maintenance.xlsx";
  475. }else if( type.equals("rel_device") ) {
  476. downloadname = "可靠性设备清单导入模板.xlsx";
  477. url = "static/template/reliability/rel_device.xlsx";
  478. }else if( type.equals("rel_compo") ) {
  479. downloadname = "可靠性部件清单导入模板.xlsx";
  480. url = "static/template/reliability/rel_compo.xlsx";
  481. }else if( type.equals("alarm") ) {
  482. downloadname = "手动启动火灾报警器基础信息导入模板.xlsx";
  483. url = "static/template/ps/dev/alarm.xlsx";
  484. }else if( type.equals("extinguisher") ) {
  485. downloadname = "现场灭火器基础信息导入模板.xlsx";
  486. url = "static/template/ps/dev/extinguisher.xlsx";
  487. }else if( type.equals("hydrant") ) {
  488. downloadname = "地上消火栓和消防水带箱基础信息导入模板.xlsx";
  489. url = "static/template/ps/dev/hydrant.xlsx";
  490. }else if( type.equals("firedoor") ) {
  491. downloadname = "安全防火门防爆门基础信息导入模板.xlsx";
  492. url = "static/template/ps/dev/firedoor.xlsx";
  493. }else if( type.equals("cabinet") ) {
  494. downloadname = "玻璃门消火栓箱和泡沫栓箱基础信息导入模板.xlsx";
  495. url = "static/template/ps/dev/cabinet.xlsx";
  496. }else if( type.equals("lift") ) {
  497. downloadname = "电梯基础信息导入模板.xlsx";
  498. url = "static/template/ps/dev/lift.xlsx";
  499. }else if( type.equals("callsystem") ) {
  500. downloadname = "消防广播系统基础信息导入模板.xlsx";
  501. url = "static/template/ps/dev/callsystem.xlsx";
  502. }else if( type.equals("fgs") ) {
  503. downloadname = "可燃气体检测器基础信息导入模板.xlsx";
  504. url = "static/template/ps/dev/fgs.xlsx";
  505. }else if( type.equals("curtain") ) {
  506. downloadname = "防火卷帘基础信息导入模板.xlsx";
  507. url = "static/template/ps/dev/curtain.xlsx";
  508. }else if( type.equals("steam") ) {
  509. downloadname = "蒸汽灭火系统基础信息导入模板.xlsx";
  510. url = "static/template/ps/dev/steam.xlsx";
  511. }else if( type.equals("monitor") ) {
  512. downloadname = "消防炮基础信息导入模板.xlsx";
  513. url = "static/template/ps/dev/monitor.xlsx";
  514. }else if( type.equals("coffer") ) {
  515. downloadname = "消防沙箱基础信息导入模板.xlsx";
  516. url = "static/template/ps/dev/coffer.xlsx";
  517. }else if( type.equals("eyewash") ) {
  518. downloadname = "洗眼器基础信息导入模板.xlsx";
  519. url = "static/template/ps/dev/eyewash.xlsx";
  520. }else if( type.equals("sump") ) {
  521. downloadname = "集水井基础信息导入模板.xlsx";
  522. url = "static/template/ps/dev/sump.xlsx";
  523. }else if( type.equals("pit") ) {
  524. downloadname = "污水坑基础信息导入模板.xlsx";
  525. url = "static/template/ps/dev/pit.xlsx";
  526. }else if( type.equals("rainvalve") ) {
  527. downloadname = "雨水阀基础信息导入模板.xlsx";
  528. url = "static/template/ps/dev/rainvalve.xlsx";
  529. }else if( type.equals("ventvalve") ) {
  530. downloadname = "通风阀基础信息导入模板.xlsx";
  531. url = "static/template/ps/dev/ventvalve.xlsx";
  532. }else if( type.equals("utilitystation") ) {
  533. downloadname = "公用站基础信息导入模板.xlsx";
  534. url = "static/template/ps/dev/utilitystation.xlsx";
  535. }
  536. InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(url);
  537. downloadFile(downloadname, is, request, response);
  538. }
  539. /**
  540. * 通用下载请求
  541. *
  542. * @param fileName 文件名称
  543. * @param delete 是否删除
  544. */
  545. @GetMapping("common/download")
  546. public void fileDownload(String fileName, Boolean delete, HttpServletResponse response, HttpServletRequest request)
  547. {
  548. try
  549. {
  550. if (!FileUtils.isValidFilename(fileName))
  551. {
  552. throw new Exception(StringUtils.format("文件名称({})非法,不允许下载。 ", fileName));
  553. }
  554. String realFileName = System.currentTimeMillis() + fileName.substring(fileName.indexOf("_") + 1);
  555. String filePath = RuoYiConfig.getDownloadPath() + fileName;
  556. response.setCharacterEncoding("utf-8");
  557. response.setContentType("multipart/form-data");
  558. response.setHeader("Content-Disposition",
  559. "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
  560. FileUtils.writeBytes(filePath, response.getOutputStream());
  561. if (delete)
  562. {
  563. FileUtils.deleteFile(filePath);
  564. }
  565. }
  566. catch (Exception e)
  567. {
  568. log.error("下载文件失败", e);
  569. }
  570. }
  571. /**
  572. * 通用上传请求
  573. */
  574. @PostMapping("/common/upload")
  575. public AjaxResult uploadFile(MultipartFile file) throws Exception
  576. {
  577. try
  578. {
  579. // 上传文件路径
  580. String filePath = RuoYiConfig.getUploadPath();
  581. // 上传并返回新文件名称
  582. String fileName = FileUploadUtils.upload(filePath, file);
  583. String url = serverConfig.getUrl() + fileName;
  584. logger.info("url:" + url);
  585. AjaxResult ajax = AjaxResult.success();
  586. ajax.put("fileName", fileName);
  587. ajax.put("url", url);
  588. return ajax;
  589. }
  590. catch (Exception e)
  591. {
  592. return AjaxResult.error(e.getMessage());
  593. }
  594. }
  595. /**
  596. * 通用上传请求(支持自定义路径)
  597. * @param file 上传的文件
  598. * @param path 自定义路径(相对路径,如 /rel/dev)
  599. */
  600. @PostMapping("/common/uploadWithPath")
  601. public AjaxResult uploadFileWithPath(MultipartFile file, @RequestParam(value = "path", required = false) String path) throws Exception
  602. {
  603. try
  604. {
  605. // 上传文件路径 = RuoYiConfig.getFilePath(path)
  606. String filePath;
  607. if (StringUtils.isNotEmpty(path))
  608. {
  609. filePath = RuoYiConfig.getFilePath(path);
  610. }
  611. else
  612. {
  613. filePath = RuoYiConfig.getUploadPath();
  614. }
  615. // 上传并返回新文件名称
  616. String fileName = FileUploadUtils.upload(filePath, file);
  617. String url = serverConfig.getUrl() + fileName;
  618. logger.info("uploadWithPath - path: " + path + ", filePath: " + filePath + ", fileName: " + fileName + ", url:" + url);
  619. AjaxResult ajax = AjaxResult.success();
  620. ajax.put("fileName", fileName);
  621. ajax.put("url", url);
  622. return ajax;
  623. }
  624. catch (Exception e)
  625. {
  626. logger.error("上传文件失败", e);
  627. return AjaxResult.error(e.getMessage());
  628. }
  629. }
  630. /**
  631. * 通用上传请求(多个)
  632. */
  633. @PostMapping("/common/uploads")
  634. public AjaxResult uploadFiles(List<MultipartFile> files, @RequestParam(value = "fileDir", required = false) String fileDir) throws Exception {
  635. try {
  636. // 上传文件路径
  637. String filePath;
  638. if (StringUtils.isNotEmpty(fileDir)) {
  639. filePath = RuoYiConfig.getUploadPath(getResource(fileDir));
  640. } else {
  641. filePath = RuoYiConfig.getUploadPath();
  642. }
  643. List<String> urls = new ArrayList<String>();
  644. List<String> fileNames = new ArrayList<String>();
  645. List<String> newFileNames = new ArrayList<String>();
  646. List<String> originalFilenames = new ArrayList<String>();
  647. for (MultipartFile file : files) {
  648. // 上传并返回新文件名称
  649. String fileName = FileUploadUtils.upload(filePath, file);
  650. String url = serverConfig.getUrl() + fileName;
  651. urls.add(url);
  652. fileNames.add(fileName);
  653. newFileNames.add(FileUtils.getName(fileName));
  654. originalFilenames.add(file.getOriginalFilename());
  655. }
  656. AjaxResult ajax = AjaxResult.success();
  657. ajax.put("urls", StringUtils.join(fileNames, FILE_DELIMETER));
  658. ajax.put("fileNames", StringUtils.join(fileNames, FILE_DELIMETER));
  659. ajax.put("newFileNames", StringUtils.join(newFileNames, FILE_DELIMETER));
  660. ajax.put("originalFilenames", StringUtils.join(originalFilenames, FILE_DELIMETER));
  661. return ajax;
  662. } catch (Exception e) {
  663. return AjaxResult.error(e.getMessage());
  664. }
  665. }
  666. private static String getResource(String type) {
  667. switch (type) {
  668. case "1":
  669. return "/annihiliator";
  670. case "12":
  671. return "/eyewash";
  672. default:
  673. return "";
  674. }
  675. }
  676. /**
  677. * 本地资源通用下载
  678. */
  679. @GetMapping("/common/download/resource")
  680. public void resourceDownload(String name, HttpServletRequest request, HttpServletResponse response) throws Exception
  681. {
  682. // 本地资源路径
  683. String localPath = RuoYiConfig.getProfile();
  684. // 数据库资源地址
  685. String downloadPath = localPath + StringUtils.substringAfter(name, Constants.RESOURCE_PREFIX);
  686. // 下载名称
  687. String downloadName = StringUtils.substringAfterLast(downloadPath, "/");
  688. response.setCharacterEncoding("utf-8");
  689. response.setContentType("multipart/form-data");
  690. response.setHeader("Content-Disposition",
  691. "attachment;fileName=" + FileUtils.setFileDownloadHeader(request, downloadName));
  692. FileUtils.writeBytes(downloadPath, response.getOutputStream());
  693. }
  694. public static void downloadFile(String filename, InputStream is, HttpServletRequest request, HttpServletResponse response) throws IOException {
  695. response.reset();
  696. if (filename.endsWith(".doc") || filename.endsWith(".docx")) {
  697. response.setContentType("application/msword;charset=utf-8");
  698. } else if (filename.endsWith(".xls") || filename.endsWith(".xlsx")) {
  699. response.setContentType("application/vnd.ms-excel;charset=utf-8");
  700. } else {
  701. response.setHeader("content-type", "application/octet-stream");
  702. }
  703. //下载文件的名称
  704. response.setHeader("Content-Disposition", "attachment;filename=" + new String(filename.getBytes("UTF-8"), "iso-8859-1"));
  705. request.setCharacterEncoding("UTF-8");
  706. ServletOutputStream out = null;
  707. BufferedInputStream bis = null;
  708. BufferedOutputStream bos = null;
  709. try {
  710. out = response.getOutputStream();
  711. bis = new BufferedInputStream(is);
  712. bos = new BufferedOutputStream(out);
  713. byte[] buff = new byte[2048];
  714. int bytesRead;
  715. while (-1 != (bytesRead = bis.read(buff, 0, buff.length))) {
  716. bos.write(buff, 0, bytesRead);
  717. }
  718. } catch (IOException e) {
  719. e.printStackTrace();
  720. } finally {
  721. try {
  722. if (bis != null) {
  723. bis.close();
  724. }
  725. if (bos != null) {
  726. bos.close();
  727. }
  728. if (is != null) {
  729. is.close();
  730. }
  731. } catch (IOException e) {
  732. e.printStackTrace();
  733. }
  734. }
  735. }
  736. // @RequestMapping("/common/download/exportDevList")
  737. // public ModelAndView exportbmy(@RequestParam Map<String, Object> params, HttpServletRequest request, HttpServletResponse response) throws ParseException {
  738. // logger.info(JSON.toJSONString(params));
  739. // String id = (String) params.get("ids");
  740. // int devType = Integer.parseInt((String) params.get("devType"));
  741. // String[] ids = id.split(",");
  742. // logger.info("ids" + ids);
  743. // int downloadType = Integer.parseInt((String) params.get("downloadType"));
  744. // logger.info("downloadType" + downloadType);
  745. // List<Object> list = new ArrayList<>();
  746. // switch (devType) {
  747. // case 1:
  748. // for (String i : ids
  749. // ) {
  750. // TSpecdevYlrq ylrqEntity = tSpecdevYlrqService.getById(i);
  751. // list.add(ylrqEntity);
  752. // }
  753. // break;
  754. // case 2:
  755. // for (String i : ids
  756. // ) {
  757. // TSpecdevYlgd ylgdEntity = tSpecdevYlgdService.getById(i);
  758. // list.add(ylgdEntity);
  759. // }
  760. // break;
  761. // case 3:
  762. // for (String i : ids
  763. // ) {
  764. // TSpecdevDzsb dzsbEntity = tSpecdevDzsbService.getById(i);
  765. // list.add(dzsbEntity);
  766. // }
  767. // break;
  768. // case 4:
  769. // for (String i : ids
  770. // ) {
  771. // TSpecdevGl glEntity = tSpecdevGlService.getById(i);
  772. // list.add(glEntity);
  773. // }
  774. // break;
  775. // case 5:
  776. // for (String i : ids
  777. // ) {
  778. // TSpecdevDt dtEntity = tSpecdevDtService.getById(i);
  779. // list.add(dtEntity);
  780. // }
  781. // break;
  782. // case 6:
  783. // for (String i : ids
  784. // ) {
  785. // TSpecdevCc ccEntity = tSpecdevCcService.getById(i);
  786. // list.add(ccEntity);
  787. // }
  788. // break;
  789. // case 7:
  790. //// for (String i : ids
  791. //// ) {
  792. //// TOtherTankEntity tankEntity = tOtherTankService.getById(i);
  793. //// list.add(tankEntity);
  794. //// }
  795. // }
  796. // if(devType == 1 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_YLRQ_UPDATE, list)); }
  797. // else if(devType == 2 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_YLGD_UPDATE, list)); }
  798. // else if(devType == 3 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_DZSB_UPDATE, list)); }
  799. // else if(devType == 4 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_GL_UPDATE, list)); }
  800. // else if(devType == 5 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_DT_UPDATE, list)); }
  801. // else if(devType == 6 && downloadType == 2){ return new ModelAndView(new JxlsView(JxlsTemplateEnum.DEV_CC_UPDATE, list)); }
  802. // return null;
  803. // }
  804. @GetMapping("/common/download/exportDevList")
  805. public AjaxResult exportbmy(TSpecdevGl tSpecdevGl) throws IOException {
  806. logger.info("kaishi");
  807. SXSSFWorkbook wb = new SXSSFWorkbook(1000);
  808. CellStyle wrapStyle = wb.createCellStyle();
  809. wrapStyle.setWrapText(true); //设置自动换行
  810. //创建sheet页
  811. Sheet sheet = wb.createSheet("sheetName");
  812. //设置列的宽度,第一个参数为列的序号,从0开始,第二参数为列宽,单位1/256个字节
  813. sheet.setColumnWidth(0, 12*256);
  814. sheet.setColumnWidth(2, 16*256);
  815. sheet.setColumnWidth(5, 12*256);
  816. sheet.setColumnWidth(6, 26*256);
  817. sheet.setColumnWidth(7, 26*256);
  818. //设置开始行和开始列
  819. int rowIndex = 0;
  820. int columnIndex = 0;
  821. Row row = sheet.createRow(rowIndex);
  822. OutputStream out = null;
  823. String filename = encodingFilename("sheetName");
  824. out = new FileOutputStream(getAbsoluteFile(filename));
  825. wb.write(out);
  826. wb.close();
  827. out.close();
  828. return AjaxResult.success(filename);
  829. }
  830. /**
  831. * 编码文件名
  832. */
  833. public String encodingFilename(String filename)
  834. {
  835. filename = UUID.randomUUID().toString() + "_" + filename + ".xlsx";
  836. return filename;
  837. }
  838. /**
  839. * 获取下载路径
  840. *
  841. * @param filename 文件名称
  842. */
  843. public String getAbsoluteFile(String filename)
  844. {
  845. String downloadPath = RuoYiConfig.getDownloadPath() + filename;
  846. File desc = new File(downloadPath);
  847. if (!desc.getParentFile().exists())
  848. {
  849. desc.getParentFile().mkdirs();
  850. }
  851. return downloadPath;
  852. }
  853. // /**
  854. // * 模拟被WAF拦截的接口(用于测试前端和APP的拦截提示)
  855. // */
  856. // @GetMapping("/common/test/blocked")
  857. // public void testBlocked(HttpServletResponse response) throws IOException
  858. // {
  859. // response.setStatus(200);
  860. // response.setContentType("text/html;charset=utf-8");
  861. // response.setHeader("X-Frame-Options", "SAMEORIGIN");
  862. // response.setHeader("X-XSS-Protection", "1; mode=block");
  863. // response.setHeader("X-Content-Type-Options", "nosniff");
  864. // response.setHeader("Cache-Control", "no-cache");
  865. // response.setHeader("Pragma", "no-cache");
  866. // response.setHeader("Connection", "close");
  867. // String html = "<html><head><title>Request Rejected</title></head><body>The requested URL was rejected. Please consult with your administrator.<br><br>Your support ID is: 88888888888888888888<br><br><a href='javascript:history.back();'>[Go Back]</a></body></html>";
  868. // response.getWriter().write(html);
  869. // }
  870. }