| | |
| | | package com.lf.server.service.sys; |
| | | |
| | | import com.lf.server.entity.all.StaticData; |
| | | import com.lf.server.entity.ctrl.CountEntity; |
| | | import com.lf.server.entity.data.DownloadEntity; |
| | | import com.lf.server.entity.sys.AttachEntity; |
| | | import com.lf.server.entity.sys.ReportEntity; |
| | | import com.lf.server.entity.sys.UserEntity; |
| | | import com.lf.server.helper.*; |
| | | import com.lf.server.mapper.sys.ReportMapper; |
| | | import com.lf.server.service.data.DownloadService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | |
| | | |
| | | @Autowired |
| | | PathHelper pathHelper; |
| | | |
| | | @Autowired |
| | | DownloadService downloadService; |
| | | |
| | | @Override |
| | | public Integer selectCount(String name) { |
| | |
| | | /** |
| | | * 创建报告 |
| | | */ |
| | | public void createReport(ReportEntity re, HttpServletResponse res) throws Exception { |
| | | public void createReport(UserEntity ue, ReportEntity re, HttpServletResponse res) throws Exception { |
| | | AttachEntity ae = attachService.selectByGuid(re.getGuid()); |
| | | if (null == ae) { |
| | | return; |
| | |
| | | |
| | | String source = pathHelper.getConfig().getUploadPath() + File.separator + ae.getPath(); |
| | | String targetName = StringHelper.YMDHMS2_FORMAT.format(new Date()) + FileHelper.getExtension(ae.getName()); |
| | | String target = pathHelper.getShareFullPath() + File.separator + targetName; |
| | | String target = pathHelper.getDownloadFullPath() + File.separator + targetName; |
| | | |
| | | File sourceFile = new File(source); |
| | | if (!sourceFile.exists() || sourceFile.isDirectory()) { |
| | |
| | | return; |
| | | } |
| | | |
| | | WebHelper.download(target, targetName, res); |
| | | DownloadEntity de = getDownloadEntity(ue, target); |
| | | int rows = downloadService.insert(de); |
| | | if (rows > 0) { |
| | | WebHelper.download(target, targetName, res); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 生成报告 |
| | | */ |
| | | private void generateReport(String source, String target, ReportEntity re) { |
| | | if ("1".equals(re.getType())) { |
| | | if (StaticData.S1.equals(re.getType())) { |
| | | switch (re.getCode()) { |
| | | case "countOperates ": |
| | | createCountOperatesWord(source, target); |
| | |
| | | |
| | | WordHelper.generateWord(source, target, null, addList); |
| | | } |
| | | |
| | | /** |
| | | * 获取下载实体类 |
| | | */ |
| | | private DownloadEntity getDownloadEntity(UserEntity ue, String file) { |
| | | DownloadEntity de = new DownloadEntity(); |
| | | de.setName(FileHelper.getFileName(file)); |
| | | de.setType(6); |
| | | de.setSizes(FileHelper.sizeToMb(new File(file).length())); |
| | | de.setDepid(ue.getDepid()); |
| | | de.setDcount(1); |
| | | de.setPwd(null); |
| | | de.setUrl(FileHelper.getRelativePath(file)); |
| | | de.setDescr("统计报告"); |
| | | de.setGuid(FileHelper.getFileMd5(file)); |
| | | de.setCreateUser(ue.getId()); |
| | | // de.setGeom(null) |
| | | |
| | | return de; |
| | | } |
| | | } |