| | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | import com.jcraft.jsch.SftpException; |
| | | import com.panzhihua.common.utlis.*; |
| | | import org.apache.commons.io.FileUtils; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | |
| | | import com.panzhihua.common.model.vos.community.*; |
| | | import com.panzhihua.common.service.community.CommunityService; |
| | | import com.panzhihua.common.service.partybuilding.PartyBuildingService; |
| | | import com.panzhihua.common.utlis.HttpUtils; |
| | | import com.panzhihua.common.utlis.SFTPUtil; |
| | | import com.panzhihua.common.utlis.StringUtils; |
| | | import com.panzhihua.community_backstage.excel.CustomSheetWriteHandler; |
| | | |
| | | import freemarker.template.Configuration; |
| | |
| | | @PostMapping("/export/safetyWorkRecord") |
| | | public R exportSafetyWorkRecord(@RequestBody List<Long> ids) { |
| | | Long communityId = this.getLoginUserInfo().getCommunityId(); |
| | | List<String> downLoadUrl = new ArrayList<>(); |
| | | try { |
| | | for (Long id : ids) { |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | String property = System.getProperty("user.dir"); |
| | | String sourceFile =property+File.separator+"word"+File.separator+System.currentTimeMillis()+File.separator; |
| | | String zipFile=property+File.separator+"zip"+File.separator; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | for (Long id : ids) { |
| | | try { |
| | | Map<String, Object> dataMap = new HashMap<String, Object>(); |
| | | ComSwSafetyWorkRecordVO comSwSafetyWorkRecordVO = JSONObject.parseObject( |
| | | JSONObject.toJSONString(communityService.detailSafetyWorkRecord(id, communityId).getData()), |
| | | ComSwSafetyWorkRecordVO.class); |
| | | // 生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | String name = "安全工作记录_" + comSwSafetyWorkRecordVO.getId() + ".doc"; |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream = null; |
| | | File file0=new File("d:/safetyWork/file"); |
| | | if(!file0.isDirectory()&&!file0.exists()){ |
| | | file0.mkdirs(); |
| | | } |
| | | file0 = new File(sourceFile); |
| | | if(!file0.isDirectory()&&!file0.exists()){ |
| | | file0.mkdirs(); |
| | | } |
| | |
| | | // 输出文档路径及名称 |
| | | // File outFile = new File("mnt/data/web/excel/安全工作记录_" + comSwSafetyWorkRecordVO.getId() + |
| | | // ".doc"); |
| | | File file = new File(fileName); |
| | | File file = new File(sourceFile + name); |
| | | |
| | | // 以utf-8的编码读取ftl文件 |
| | | Template template = configuration.getTemplate("安全工作记录.ftl", "utf-8"); |
| | |
| | | new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8), 10240); |
| | | template.process(dataMap, out); |
| | | out.close(); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | // inputStream = new FileInputStream(file); |
| | | // sftp.uploadMore(ftpUrl, name, inputStream); |
| | | // sftp.logout(); |
| | | // inputStream.close(); |
| | | // String absolutePath = file.getAbsolutePath(); |
| | | // boolean delete = file.delete(); |
| | | // log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | downLoadUrl.add(excelUrl + name); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | } |
| | | return R.ok(downLoadUrl); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | } |
| | | return R.fail(); |
| | | FileUtil.compressToZip(sourceFile,zipFile,"安全工作记录.zip"); |
| | | String currentDateString = String.valueOf(System.currentTimeMillis()); |
| | | String name = "安全工作记录_"+ currentDateString+".zip"; |
| | | try { |
| | | InputStream inputStream=new FileInputStream(zipFile+"安全工作记录.zip"); |
| | | sftp.uploadMore(ftpUrl, name , inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | FileUtils.deleteDirectory(new File(property+File.separator+"word"+File.separator)); |
| | | FileUtils.deleteDirectory(new File(zipFile)); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (SftpException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok(excelUrl + name); |
| | | } |
| | | |
| | | @ApiOperation(value = "下载巡查记录报告") |
| | | @PostMapping("/export/patrolRecord") |
| | | public R exportPatrolRecord(@RequestBody List<Long> ids) { |
| | | Long communityId = this.getLoginUserInfo().getCommunityId(); |
| | | List<String> downLoadUrl = new ArrayList<>(); |
| | | try { |
| | | for (Long id : ids) { |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | String property = System.getProperty("user.dir"); |
| | | String sourceFile =property+File.separator+"word"+File.separator+System.currentTimeMillis()+File.separator; |
| | | String zipFile=property+File.separator+"zip"+File.separator; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | for (Long id : ids) { |
| | | try { |
| | | Map<String, Object> dataMap = new HashMap<String, Object>(); |
| | | ComSwPatrolRecordVO comSwPatrolRecordVO = |
| | | JSONObject.parseObject(JSONObject.toJSONString(communityService.detailPatrolRecord(id).getData()), |
| | | ComSwPatrolRecordVO.class); |
| | | // 生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | String name = "巡查记录_" + comSwPatrolRecordVO.getId() + ".doc"; |
| | | |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream = null; |
| | | File file0=new File("d:/patrolRecord/file"); |
| | | if(!file0.isDirectory()&&!file0.exists()){ |
| | | file0.mkdirs(); |
| | | } |
| | | file0 = new File(sourceFile); |
| | | if(!file0.isDirectory()&&!file0.exists()){ |
| | | file0.mkdirs(); |
| | | } |
| | |
| | | // 输出文档路径及名称 |
| | | // File outFile = new File("mnt/data/web/excel/安全工作记录_" + comSwSafetyWorkRecordVO.getId() + |
| | | // ".doc"); |
| | | File file = new File(fileName); |
| | | File file = new File(sourceFile + name); |
| | | |
| | | // 以utf-8的编码读取ftl文件 |
| | | Template template = configuration.getTemplate("巡查记录.ftl", "utf-8"); |
| | |
| | | new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8), 10240); |
| | | template.process(dataMap, out); |
| | | out.close(); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | // inputStream = new FileInputStream(file); |
| | | // sftp.uploadMore(ftpUrl, name, inputStream); |
| | | // sftp.logout(); |
| | | // inputStream.close(); |
| | | // String absolutePath = file.getAbsolutePath(); |
| | | // boolean delete = file.delete(); |
| | | // log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | |
| | | } |
| | | } |
| | | } |
| | | downLoadUrl.add(excelUrl + name); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | } |
| | | return R.ok(downLoadUrl); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | } |
| | | return R.fail(); |
| | | FileUtil.compressToZip(sourceFile,zipFile,"巡查记录.zip"); |
| | | String currentDateString = String.valueOf(System.currentTimeMillis()); |
| | | String name = "巡查记录_"+ currentDateString+".zip"; |
| | | try { |
| | | InputStream inputStream=new FileInputStream(zipFile+"巡查记录.zip"); |
| | | sftp.uploadMore(ftpUrl, name , inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | FileUtils.deleteDirectory(new File(property+File.separator+"word"+File.separator)); |
| | | FileUtils.deleteDirectory(new File(zipFile)); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (SftpException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok(excelUrl + name); |
| | | } |
| | | |
| | | @ApiOperation(value = "下载隐患报告") |
| | | @PostMapping("/export/DangerReport") |
| | | public R exportDangerReport(@RequestBody List<Long> ids) { |
| | | Long communityId = this.getLoginUserInfo().getCommunityId(); |
| | | List<String> downLoadUrl = new ArrayList<>(); |
| | | try { |
| | | for (Long id : ids) { |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | Map<String, Object> dataMap = new HashMap<String, Object>(); |
| | | ComSwDangerReportVO comSwDangerReportVO = |
| | | JSONObject.parseObject(JSONObject.toJSONString(communityService.detailDangerReport(id).getData()), |
| | | ComSwDangerReportVO.class); |
| | | // 生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | String name = "隐患报告_" + comSwDangerReportVO.getId() + ".doc"; |
| | | SFTPUtil sftp = new SFTPUtil(userName, password, host, port); |
| | | sftp.login(); |
| | | String property = System.getProperty("user.dir"); |
| | | String sourceFile =property+File.separator+"word"+File.separator+System.currentTimeMillis()+File.separator; |
| | | String zipFile=property+File.separator+"zip"+File.separator; |
| | | String ftpUrl = "/mnt/data/web/excel/"; |
| | | for (Long id : ids) { |
| | | try { |
| | | Map<String, Object> dataMap = new HashMap<String, Object>(); |
| | | ComSwDangerReportVO comSwDangerReportVO = |
| | | JSONObject.parseObject(JSONObject.toJSONString(communityService.detailDangerReport(id).getData()), |
| | | ComSwDangerReportVO.class); |
| | | // 生成动态模板excel通过ftp工具上传到主节点,然后返回模板下载地址 |
| | | String name = "隐患报告_" + comSwDangerReportVO.getId() + ".doc"; |
| | | |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | String property = System.getProperty("user.dir"); |
| | | String fileName = property + File.separator + name; |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream = null; |
| | | File file0=new File("d:/dangerReport/file"); |
| | | if(!file0.isDirectory()&&!file0.exists()){ |
| | | file0.mkdirs(); |
| | | boolean existDir = sftp.isExistDir(ftpUrl + name); |
| | | if (!existDir) { |
| | | // 这里 需要指定写用哪个class去写 |
| | | ExcelWriter excelWriter = null; |
| | | InputStream inputStream = null; |
| | | File file0=new File("d:/dangerReport/file"); |
| | | if(!file0.isDirectory()&&!file0.exists()){ |
| | | file0.mkdirs(); |
| | | } |
| | | file0 = new File(sourceFile); |
| | | if(!file0.isDirectory()&&!file0.exists()){ |
| | | file0.mkdirs(); |
| | | } |
| | | sftp.download("/mnt/data/web/", "隐患报告.ftl", "d:/dangerReport/file/隐患报告.ftl"); |
| | | sftp.download("/mnt/data/web/", "blank.jpg", "d:/dangerReport/file/blank.jpg"); |
| | | try { |
| | | // 日期 |
| | | dataMap.put("date", comSwDangerReportVO.getCheckTime()); |
| | | // 巡查类型 |
| | | dataMap.put("patrolType", comSwDangerReportVO.getPatrolType()); |
| | | // 地址 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getAddress())) { |
| | | dataMap.put("address", comSwDangerReportVO.getAddress()); |
| | | }else { |
| | | dataMap.put("address", ""); |
| | | } |
| | | sftp.download("/mnt/data/web/", "隐患报告.ftl", "d:/dangerReport/file/隐患报告.ftl"); |
| | | sftp.download("/mnt/data/web/", "blank.jpg", "d:/dangerReport/file/blank.jpg"); |
| | | try { |
| | | // 日期 |
| | | dataMap.put("date", comSwDangerReportVO.getCheckTime()); |
| | | // 巡查类型 |
| | | dataMap.put("patrolType", comSwDangerReportVO.getPatrolType()); |
| | | // 地址 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getAddress())) { |
| | | dataMap.put("address", comSwDangerReportVO.getAddress()); |
| | | }else { |
| | | dataMap.put("address", ""); |
| | | } |
| | | // 隐患名称 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getDangerName())) { |
| | | dataMap.put("dangerName", comSwDangerReportVO.getDangerName()); |
| | | }else { |
| | | dataMap.put("dangerName", ""); |
| | | } |
| | | // 排查时间 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getCheckTime())) { |
| | | dataMap.put("checkTime", comSwDangerReportVO.getCheckTime()); |
| | | }else { |
| | | dataMap.put("checkTime", ""); |
| | | } |
| | | // 排查人员 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getPPersonName())) { |
| | | dataMap.put("ppersonName", comSwDangerReportVO.getPPersonName()); |
| | | }else { |
| | | dataMap.put("ppersonName", ""); |
| | | } |
| | | // 填报人员 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getCreateName())) { |
| | | dataMap.put("createName", comSwDangerReportVO.getCreateName()); |
| | | }else { |
| | | dataMap.put("createName", ""); |
| | | } |
| | | // 填报时间 |
| | | dataMap.put("createAt", |
| | | new SimpleDateFormat("yyyy-MM-dd").format(comSwDangerReportVO.getCreateAt())); |
| | | // 隐患编号 |
| | | dataMap.put("dangerNo", comSwDangerReportVO.getDangerNo()); |
| | | // 主体部门、单位或个人全称 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getUnitName())) { |
| | | dataMap.put("unitName", comSwDangerReportVO.getUnitName()); |
| | | } else { |
| | | dataMap.put("unitName", ""); |
| | | } |
| | | // 隐患简述 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getDagerDescription())) { |
| | | dataMap.put("dagerDescription", comSwDangerReportVO.getDagerDescription()); |
| | | } else { |
| | | dataMap.put("dagerDescription", ""); |
| | | } |
| | | // 已采取的措施 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getTakeSteps())) { |
| | | dataMap.put("takeSteps", comSwDangerReportVO.getTakeSteps()); |
| | | } else { |
| | | dataMap.put("takeSteps", ""); |
| | | } |
| | | // 措施照片 |
| | | List<String> stepsPhoto = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getStepsPhoto())) { |
| | | stepsPhoto = Arrays.asList(comSwDangerReportVO.getStepsPhoto().split(",")); |
| | | } |
| | | if (stepsPhoto.size() != 0 && null != stepsPhoto) { |
| | | if (stepsPhoto.size() == 1) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 1) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 1) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 2) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 2) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 2) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 3) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 3) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 3) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 4) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 4) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 4) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 5) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 5) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 5) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 6) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 6) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 6) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 7) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 7) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 7) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 8) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 8) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 8) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 9) { |
| | | for (int i = 0; i < 9; i++) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | // 隐患名称 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getDangerName())) { |
| | | dataMap.put("dangerName", comSwDangerReportVO.getDangerName()); |
| | | }else { |
| | | dataMap.put("dangerName", ""); |
| | | } |
| | | // 排查时间 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getCheckTime())) { |
| | | dataMap.put("checkTime", comSwDangerReportVO.getCheckTime()); |
| | | }else { |
| | | dataMap.put("checkTime", ""); |
| | | } |
| | | // 排查人员 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getPPersonName())) { |
| | | dataMap.put("ppersonName", comSwDangerReportVO.getPPersonName()); |
| | | }else { |
| | | dataMap.put("ppersonName", ""); |
| | | } |
| | | // 填报人员 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getCreateName())) { |
| | | dataMap.put("createName", comSwDangerReportVO.getCreateName()); |
| | | }else { |
| | | dataMap.put("createName", ""); |
| | | } |
| | | // 填报时间 |
| | | dataMap.put("createAt", |
| | | new SimpleDateFormat("yyyy-MM-dd").format(comSwDangerReportVO.getCreateAt())); |
| | | // 隐患编号 |
| | | dataMap.put("dangerNo", comSwDangerReportVO.getDangerNo()); |
| | | // 主体部门、单位或个人全称 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getUnitName())) { |
| | | dataMap.put("unitName", comSwDangerReportVO.getUnitName()); |
| | | } else { |
| | | dataMap.put("unitName", ""); |
| | | } |
| | | // 隐患简述 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getDagerDescription())) { |
| | | dataMap.put("dagerDescription", comSwDangerReportVO.getDagerDescription()); |
| | | } else { |
| | | dataMap.put("dagerDescription", ""); |
| | | } |
| | | // 已采取的措施 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getTakeSteps())) { |
| | | dataMap.put("takeSteps", comSwDangerReportVO.getTakeSteps()); |
| | | } else { |
| | | dataMap.put("takeSteps", ""); |
| | | } |
| | | // 措施照片 |
| | | List<String> stepsPhoto = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getStepsPhoto())) { |
| | | stepsPhoto = Arrays.asList(comSwDangerReportVO.getStepsPhoto().split(",")); |
| | | } |
| | | if (stepsPhoto.size() != 0 && null != stepsPhoto) { |
| | | if (stepsPhoto.size() == 1) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 1) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } else { |
| | | for (int i = 0; i < 9; i++) { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | // 社区处理建议 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getCommunitySuggestion())) { |
| | | dataMap.put("communitySuggestion", comSwDangerReportVO.getCommunitySuggestion()); |
| | | } else { |
| | | dataMap.put("communitySuggestion", ""); |
| | | } |
| | | // 街道安全管理人员建议 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getStreetSuggestion())) { |
| | | dataMap.put("streetSuggestion", comSwDangerReportVO.getStreetSuggestion()); |
| | | } else { |
| | | dataMap.put("streetSuggestion", ""); |
| | | } |
| | | // 领导意见 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getLeaderSuggestion())) { |
| | | dataMap.put("leaderSuggestion", comSwDangerReportVO.getLeaderSuggestion()); |
| | | } else { |
| | | dataMap.put("leaderSuggestion", ""); |
| | | } |
| | | // 承办记录 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getUndertakeRecord())) { |
| | | dataMap.put("undertakeRecord", comSwDangerReportVO.getUndertakeRecord()); |
| | | } else { |
| | | dataMap.put("undertakeRecord", ""); |
| | | } |
| | | // 巡查记录 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getRecordContent())) { |
| | | dataMap.put("recordContent", comSwDangerReportVO.getRecordContent()); |
| | | } else { |
| | | dataMap.put("recordContent", ""); |
| | | } |
| | | // 发现记录 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getFindRecord())) { |
| | | dataMap.put("findRecord", comSwDangerReportVO.getFindRecord()); |
| | | } else { |
| | | dataMap.put("findRecord", ""); |
| | | } |
| | | // 记录照片 |
| | | List<String> photo = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getRecordPhoto())) { |
| | | photo = Arrays.asList(comSwDangerReportVO.getRecordPhoto().split(",")); |
| | | } |
| | | if (photo.size() != 0 && null != photo) { |
| | | if (photo.size() == 1) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 1) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | if (i < 1) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (photo.size() == 2) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 2) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 2) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 2) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (photo.size() == 3) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 3) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 2) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (photo.size() == 4) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 4) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 3) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 3) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (photo.size() == 5) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 5) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 3) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (photo.size() == 6) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 6) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 4) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 4) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (photo.size() == 7) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 7) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 4) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (photo.size() == 8) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 8) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 5) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 5) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | if (photo.size() == 9) { |
| | | for (int i = 0; i < 9; i++) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 5) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 6) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 6) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 6) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 7) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 7) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 7) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 8) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 8) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 8) { |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (stepsPhoto.size() == 9) { |
| | | for (int i = 0; i < 9; i++) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 19), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | downloadPicture(stepsPhoto.get(i), comSwDangerReportVO.getId() + "_steps_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 1), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_steps_" + i + ".jpg")); |
| | | } |
| | | } |
| | | } else { |
| | | for (int i = 0; i < 9; i++) { |
| | | dataMap.put("imgStr" + (i + 1), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | for (int i = 0; i < 9; i++) { |
| | | dataMap.put("imgStr" + (i + 19), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | // 社区处理建议 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getCommunitySuggestion())) { |
| | | dataMap.put("communitySuggestion", comSwDangerReportVO.getCommunitySuggestion()); |
| | | } else { |
| | | dataMap.put("communitySuggestion", ""); |
| | | } |
| | | // 街道安全管理人员建议 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getStreetSuggestion())) { |
| | | dataMap.put("streetSuggestion", comSwDangerReportVO.getStreetSuggestion()); |
| | | } else { |
| | | dataMap.put("streetSuggestion", ""); |
| | | } |
| | | // 领导意见 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getLeaderSuggestion())) { |
| | | dataMap.put("leaderSuggestion", comSwDangerReportVO.getLeaderSuggestion()); |
| | | } else { |
| | | dataMap.put("leaderSuggestion", ""); |
| | | } |
| | | // 承办记录 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getUndertakeRecord())) { |
| | | dataMap.put("undertakeRecord", comSwDangerReportVO.getUndertakeRecord()); |
| | | } else { |
| | | dataMap.put("undertakeRecord", ""); |
| | | } |
| | | // 巡查记录 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getRecordContent())) { |
| | | dataMap.put("recordContent", comSwDangerReportVO.getRecordContent()); |
| | | } else { |
| | | dataMap.put("recordContent", ""); |
| | | } |
| | | // 发现记录 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getFindRecord())) { |
| | | dataMap.put("findRecord", comSwDangerReportVO.getFindRecord()); |
| | | } else { |
| | | dataMap.put("findRecord", ""); |
| | | } |
| | | // 记录照片 |
| | | List<String> photo = new ArrayList<>(); |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getRecordPhoto())) { |
| | | photo = Arrays.asList(comSwDangerReportVO.getRecordPhoto().split(",")); |
| | | } |
| | | if (photo.size() != 0 && null != photo) { |
| | | if (photo.size() == 1) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 1) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } else { |
| | | } |
| | | if (photo.size() == 2) { |
| | | for (int i = 0; i < 9; i++) { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | if (i < 2) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | // 备注 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getRemark())) { |
| | | dataMap.put("remark", comSwDangerReportVO.getRemark()); |
| | | } else { |
| | | dataMap.put("remark", ""); |
| | | if (photo.size() == 3) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 3) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | // 整改时间 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyTime())) { |
| | | dataMap.put("rectifyTime", comSwDangerReportVO.getRectifyTime()); |
| | | } else { |
| | | dataMap.put("rectifyTime", ""); |
| | | if (photo.size() == 4) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 4) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | // 整改人员 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getDPersonName())) { |
| | | dataMap.put("dpersonName", comSwDangerReportVO.getDPersonName()); |
| | | } else { |
| | | dataMap.put("dpersonName", ""); |
| | | if (photo.size() == 5) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 5) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | |
| | | // 获取请求url |
| | | String url = Constants.G_D_WEATHER_URL; |
| | | // 获取请求参数 |
| | | String param = "key=" + Constants.G_D_WEATHER_KEY + "&city=510400"; |
| | | String result = HttpUtils.sendGet(url, param); |
| | | R r = R.ok(JSON.parseObject(result)); |
| | | WeatherVO weatherVO = |
| | | JSONObject.parseObject(JSONObject.toJSONString(r.getData()), WeatherVO.class); |
| | | if (null != weatherVO) { |
| | | LiveVO liveVO = weatherVO.getLives().get(0); |
| | | // 城市 |
| | | dataMap.put("city", liveVO.getCity()); |
| | | // 天气 |
| | | dataMap.put("weather", liveVO.getWeather()); |
| | | // 温度 |
| | | dataMap.put("temperature", liveVO.getTemperature()); |
| | | // 风向 |
| | | dataMap.put("winddirection", liveVO.getWinddirection()); |
| | | // 风力 |
| | | dataMap.put("windpower", liveVO.getWindpower()); |
| | | if (photo.size() == 6) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 6) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | Configuration configuration = new Configuration(new Version("2.3.0")); |
| | | |
| | | configuration.setDefaultEncoding("utf-8"); |
| | | /** |
| | | * 以下是两种指定ftl文件所在目录路径的方式,注意这两种方式都是 指定ftl文件所在目录的路径,而不是ftl文件的路径 |
| | | */ |
| | | // 指定路径的第一种方式(根据某个类的相对路径指定) |
| | | // configuration.setClassForTemplateLoading(this.getClass(), ""); |
| | | |
| | | // 指定路径的第二种方式,我的路径是C:/a.ftl |
| | | configuration.setDirectoryForTemplateLoading(new File("d:/dangerReport/file/")); |
| | | |
| | | // 输出文档路径及名称 |
| | | // File outFile = new File("mnt/data/web/excel/安全工作记录_" + comSwSafetyWorkRecordVO.getId() + |
| | | // ".doc"); |
| | | File file = new File(fileName); |
| | | |
| | | // 以utf-8的编码读取ftl文件 |
| | | Template template = configuration.getTemplate("隐患报告.ftl", "utf-8"); |
| | | Writer out = new BufferedWriter( |
| | | new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8), 10240); |
| | | template.process(dataMap, out); |
| | | out.close(); |
| | | inputStream = new FileInputStream(file); |
| | | sftp.uploadMore(ftpUrl, name, inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | String absolutePath = file.getAbsolutePath(); |
| | | boolean delete = file.delete(); |
| | | log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | | inputStream.close(); |
| | | if (photo.size() == 7) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 7) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (photo.size() == 8) { |
| | | for (int i = 0; i < 9; i++) { |
| | | if (i < 8) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } else { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | } |
| | | if (photo.size() == 9) { |
| | | for (int i = 0; i < 9; i++) { |
| | | downloadPicture(photo.get(i), comSwDangerReportVO.getId() + "_find_" + i, "d:/dangerReport/file/"); |
| | | dataMap.put("imgStr" + (i + 10), |
| | | getImageStr("d:/dangerReport/file/" + comSwDangerReportVO.getId() + "_find_" + i + ".jpg")); |
| | | } |
| | | } |
| | | } else { |
| | | for (int i = 0; i < 9; i++) { |
| | | dataMap.put("imgStr" + (i + 10), getImageStr("d:/dangerReport/file/blank.jpg")); |
| | | } |
| | | } |
| | | // 备注 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getRemark())) { |
| | | dataMap.put("remark", comSwDangerReportVO.getRemark()); |
| | | } else { |
| | | dataMap.put("remark", ""); |
| | | } |
| | | // 整改时间 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getRectifyTime())) { |
| | | dataMap.put("rectifyTime", comSwDangerReportVO.getRectifyTime()); |
| | | } else { |
| | | dataMap.put("rectifyTime", ""); |
| | | } |
| | | // 整改人员 |
| | | if (StringUtils.isNotEmpty(comSwDangerReportVO.getDPersonName())) { |
| | | dataMap.put("dpersonName", comSwDangerReportVO.getDPersonName()); |
| | | } else { |
| | | dataMap.put("dpersonName", ""); |
| | | } |
| | | |
| | | // 获取请求url |
| | | String url = Constants.G_D_WEATHER_URL; |
| | | // 获取请求参数 |
| | | String param = "key=" + Constants.G_D_WEATHER_KEY + "&city=510400"; |
| | | String result = HttpUtils.sendGet(url, param); |
| | | R r = R.ok(JSON.parseObject(result)); |
| | | WeatherVO weatherVO = |
| | | JSONObject.parseObject(JSONObject.toJSONString(r.getData()), WeatherVO.class); |
| | | if (null != weatherVO) { |
| | | LiveVO liveVO = weatherVO.getLives().get(0); |
| | | // 城市 |
| | | dataMap.put("city", liveVO.getCity()); |
| | | // 天气 |
| | | dataMap.put("weather", liveVO.getWeather()); |
| | | // 温度 |
| | | dataMap.put("temperature", liveVO.getTemperature()); |
| | | // 风向 |
| | | dataMap.put("winddirection", liveVO.getWinddirection()); |
| | | // 风力 |
| | | dataMap.put("windpower", liveVO.getWindpower()); |
| | | } |
| | | Configuration configuration = new Configuration(new Version("2.3.0")); |
| | | |
| | | configuration.setDefaultEncoding("utf-8"); |
| | | /** |
| | | * 以下是两种指定ftl文件所在目录路径的方式,注意这两种方式都是 指定ftl文件所在目录的路径,而不是ftl文件的路径 |
| | | */ |
| | | // 指定路径的第一种方式(根据某个类的相对路径指定) |
| | | // configuration.setClassForTemplateLoading(this.getClass(), ""); |
| | | |
| | | // 指定路径的第二种方式,我的路径是C:/a.ftl |
| | | configuration.setDirectoryForTemplateLoading(new File("d:/dangerReport/file/")); |
| | | |
| | | // 输出文档路径及名称 |
| | | // File outFile = new File("mnt/data/web/excel/安全工作记录_" + comSwSafetyWorkRecordVO.getId() + |
| | | // ".doc"); |
| | | File file = new File(sourceFile+name); |
| | | |
| | | // 以utf-8的编码读取ftl文件 |
| | | Template template = configuration.getTemplate("隐患报告.ftl", "utf-8"); |
| | | Writer out = new BufferedWriter( |
| | | new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8), 10240); |
| | | template.process(dataMap, out); |
| | | out.close(); |
| | | // inputStream = new FileInputStream(file); |
| | | // sftp.uploadMore(ftpUrl, name, inputStream); |
| | | // sftp.logout(); |
| | | // inputStream.close(); |
| | | // String absolutePath = file.getAbsolutePath(); |
| | | // boolean delete = file.delete(); |
| | | // log.info("删除excel【{}】结果【{}】", absolutePath, delete); |
| | | } finally { |
| | | // 千万别忘记finish 会帮忙关闭流 |
| | | if (inputStream != null) { |
| | | inputStream.close(); |
| | | } |
| | | } |
| | | downLoadUrl.add(excelUrl + name); |
| | | } |
| | | return R.ok(downLoadUrl); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | log.error("文件传输失败【{}】", e.getMessage()); |
| | | } |
| | | } |
| | | return R.fail(); |
| | | FileUtil.compressToZip(sourceFile,zipFile,"隐患报告.zip"); |
| | | String currentDateString = String.valueOf(System.currentTimeMillis()); |
| | | String name = "隐患报告_"+ currentDateString+".zip"; |
| | | try { |
| | | InputStream inputStream=new FileInputStream(zipFile+"隐患报告.zip"); |
| | | sftp.uploadMore(ftpUrl, name , inputStream); |
| | | sftp.logout(); |
| | | inputStream.close(); |
| | | FileUtils.deleteDirectory(new File(property+File.separator+"word"+File.separator)); |
| | | FileUtils.deleteDirectory(new File(zipFile)); |
| | | } catch (FileNotFoundException e) { |
| | | e.printStackTrace(); |
| | | } catch (SftpException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return R.ok(excelUrl + name); |
| | | } |
| | | |
| | | private List<List<String>> headDataFilling() { |