Commit 54b8ebc1 authored by KeYong's avatar KeYong

Merge branch 'develop_dl_plan6' of http://39.98.45.134:8090/moa/amos-boot-biz into develop_dl_plan6

parents dbedd5cf 66fdf612
...@@ -79,7 +79,7 @@ public class ControllerAop { ...@@ -79,7 +79,7 @@ public class ControllerAop {
// 不需要添加请求头的接口 // 不需要添加请求头的接口
String[] url = new String[]{"/api/user/save/curCompany", "/jcs/command/lookHtmlText", String[] url = new String[]{"/api/user/save/curCompany", "/jcs/command/lookHtmlText",
"/jcs/common/duty-person/findByDutyAreaId", "/tzs/wechatBack", "/tzs/elevator/getElevatorInfo", "/jcs/common/duty-person/findByDutyAreaId", "/tzs/wechatBack", "/tzs/elevator/getElevatorInfo",
"/openapi/bizToken/applyToken"}; "/openapi/bizToken/applyToken","/fire-patrol-report/download","/fire-patrol-report/allPage"};
// 获取请求路径 // 获取请求路径
for (String uri : url) { for (String uri : url) {
if (request.getRequestURI().indexOf(uri) != -1) { if (request.getRequestURI().indexOf(uri) != -1) {
......
...@@ -8,10 +8,12 @@ import lombok.Data; ...@@ -8,10 +8,12 @@ import lombok.Data;
public class AnalysisReportLogDto extends AnalysisReportLog{ public class AnalysisReportLogDto extends AnalysisReportLog{
private static final long serialVersionUID = 214456306850625504L; private static final long serialVersionUID = 214456306850625504L;
@ApiModelProperty(value = "主键") @ApiModelProperty(value = "换流站编码")
String reportName; private String stationCode;
@ApiModelProperty(value = "主键") @ApiModelProperty(value = "报告名称")
String stationName; private String reportName;
@ApiModelProperty(value = "主键") @ApiModelProperty(value = "换流站名称")
String reportTypeName; private String stationName;
@ApiModelProperty(value = "报告类型名称")
private String reportTypeName;
} }
...@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.common.entity; ...@@ -2,6 +2,7 @@ package com.yeejoin.equipmanage.common.entity;
import java.util.Date; import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.annotation.FillCommonUserField; import com.yeejoin.amos.boot.biz.common.annotation.FillCommonUserField;
import com.yeejoin.equipmanage.common.entity.publics.BaseEntity; import com.yeejoin.equipmanage.common.entity.publics.BaseEntity;
...@@ -46,5 +47,4 @@ public class AnalysisReportLog extends BaseEntity { ...@@ -46,5 +47,4 @@ public class AnalysisReportLog extends BaseEntity {
@ApiModelProperty(value = "结束时间") @ApiModelProperty(value = "结束时间")
private Date endDate; private Date endDate;
} }
package com.yeejoin.equipmanage.common.utils; package com.yeejoin.equipmanage.common.utils;
import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.Writer; import java.io.Writer;
import java.net.URL; import java.net.URL;
...@@ -13,17 +15,18 @@ import java.net.URLEncoder; ...@@ -13,17 +15,18 @@ import java.net.URLEncoder;
import java.util.Map; import java.util.Map;
import java.util.Properties; import java.util.Properties;
import javax.annotation.PostConstruct;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Value; import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.springframework.core.io.support.PropertiesLoaderUtils; import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.http.MediaType;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.Template; import freemarker.template.Template;
import net.bytebuddy.asm.Advice.This;
import sun.misc.BASE64Encoder; import sun.misc.BASE64Encoder;
public class WordTemplateUtils { public class WordTemplateUtils {
...@@ -93,6 +96,37 @@ public class WordTemplateUtils { ...@@ -93,6 +96,37 @@ public class WordTemplateUtils {
file.delete(); }// 删除临时文件 file.delete(); }// 删除临时文件
} }
} }
public FileItem getWordFileItem(Map map,String title,String ftlFile) throws IOException {
URL resourcePath = this.getClass().getClassLoader().getResource("ftl");
configuration.setDirectoryForTemplateLoading(new File(resourcePath.getPath()));
Template freemarkerTemplate = configuration.getTemplate(ftlFile);
FileItemFactory factory = new DiskFileItemFactory(16, null);
String textFieldName = "file";
FileItem item = factory.createItem(textFieldName, MediaType.MULTIPART_FORM_DATA_VALUE, true, title);
File file = null;
int bytesRead = 0;
byte[] buffer = new byte[10 * 1024 * 1024];
InputStream fin = null;
OutputStream os = null;
try {
// 调用工具类的createDoc方法生成Word文档
file = createDoc(map, freemarkerTemplate);
fin = new FileInputStream(file);
os = item.getOutputStream();
while ((bytesRead = fin.read(buffer,0,8192)) != -1) {
os.write(buffer,0,bytesRead);
}
return item;
} finally {
if (fin != null){
fin.close();}
if (os != null){
os.close();}
if (file != null){
file.delete(); }// 删除临时文件
}
}
private static File createDoc(Map<?, ?> dataMap, Template template) { private static File createDoc(Map<?, ?> dataMap, Template template) {
String name = "sellPlan.doc"; String name = "sellPlan.doc";
...@@ -109,7 +143,53 @@ public class WordTemplateUtils { ...@@ -109,7 +143,53 @@ public class WordTemplateUtils {
} }
return f; return f;
} }
public boolean wordTopdfByAspose(InputStream inputStream, OutputStream outputStream) {
// 验证License 若不验证则转化出的pdf文档会有水印产生
if (!getLicense()) {
return false;
}
try {
// 将源文件保存在com.aspose.words.Document中,具体的转换格式依靠里面的save方法
com.aspose.words.Document doc = new com.aspose.words.Document(inputStream);
// 全面支持DOC, DOCX, OOXML, RTF HTML, OpenDocument, PDF,EPUB, XPS, SWF 相互转换
doc.save(outputStream, SaveFormat.PDF);
} catch (Exception e) {
e.printStackTrace();
return false;
}finally {
if (outputStream != null) {
try {
outputStream.flush();
outputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return true;
}
// 官方文档的要求 无需理会
public static boolean getLicense() {
boolean result = false;
try {
String s = "<License><Data><Products><Product>Aspose.Total for Java</Product><Product>Aspose.Words for Java</Product></Products><EditionType>Enterprise</EditionType><SubscriptionExpiry>20991231</SubscriptionExpiry><LicenseExpiry>20991231</LicenseExpiry><SerialNumber>8bfe198c-7f0c-4ef8-8ff0-acc3237bf0d7</SerialNumber></Data><Signature>sNLLKGMUdF0r8O1kKilWAGdgfs2BvJb/2Xp8p5iuDVfZXmhppo+d0Ran1P9TKdjV4ABwAgKXxJ3jcQTqE/2IRfqwnPf8itN8aFZlV3TJPYeD3yWE7IT55Gz6EijUpC7aKeoohTb4w2fpox58wWoF3SNp6sK6jDfiAUGEHYJ9pjU=</Signature></License>";
ByteArrayInputStream is = new ByteArrayInputStream(s.getBytes());
License aposeLic = new License();
aposeLic.setLicense(is);
result = true;
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
// 获得图片的base64码 // 获得图片的base64码
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public String getImageBase(String src) { public String getImageBase(String src) {
......
package com.yeejoin.equipmanage.controller; package com.yeejoin.equipmanage.controller;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
...@@ -17,6 +19,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation; ...@@ -17,6 +19,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto; import com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto;
import com.yeejoin.equipmanage.common.entity.AnalysisReportLog;
import com.yeejoin.equipmanage.service.IFirePatrolReportService; import com.yeejoin.equipmanage.service.IFirePatrolReportService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -41,18 +44,43 @@ public class FirePatrolReportController { ...@@ -41,18 +44,43 @@ public class FirePatrolReportController {
@GetMapping(value = "/download") @GetMapping(value = "/download")
@TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false) @TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false)
public void download(HttpServletRequest request, HttpServletResponse response, public void download(HttpServletRequest request, HttpServletResponse response,
@ApiParam(value = "换流站编码", required = true) @RequestParam String code, @ApiParam(value = "换流站编码", required = true) @RequestParam String stationCode,
@ApiParam(value = "开始日期", required = true) @RequestParam @DateTimeFormat(pattern="yyyy-MM-dd")Date startDate, @ApiParam(value = "开始日期", required = true) @RequestParam @DateTimeFormat(pattern="yyyy-MM-dd")Date startDate,
@ApiParam(value = "结束日期", required = true) @RequestParam @DateTimeFormat(pattern="yyyy-MM-dd")Date endDate) { @ApiParam(value = "结束日期", required = true) @RequestParam @DateTimeFormat(pattern="yyyy-MM-dd")Date endDate) {
iFirePatrolReportService.download(request, response, code, startDate, endDate); iFirePatrolReportService.download(request, response, stationCode, startDate, endDate);
} }
@ApiOperation(value = "预览报表", notes = "预览报表")
@GetMapping(value = "/preview")
@TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false)
public String preview(
@ApiParam(value = "换流站编码", required = true) @RequestParam String stationCode,
@ApiParam(value = "开始日期", required = true) @RequestParam @DateTimeFormat(pattern="yyyy-MM-dd")Date startDate,
@ApiParam(value = "结束日期", required = true) @RequestParam @DateTimeFormat(pattern="yyyy-MM-dd")Date endDate) {
return iFirePatrolReportService.preview(stationCode, startDate, endDate);
}
@SuppressWarnings("unchecked")
@ApiOperation(value = "所有站查询列表", notes = "所有站查询列表") @ApiOperation(value = "所有站查询列表", notes = "所有站查询列表")
@GetMapping(value = "/all-page") @GetMapping(value = "/allPage")
@TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false) @TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false)
public IPage<AnalysisReportLogDto> allPage(Page page, @RequestParam Integer reportType, public IPage<AnalysisReportLogDto> allPage(Page page, @RequestParam Integer reportType,
@ApiParam(value = "开始日期", required = false) @RequestParam @DateTimeFormat(pattern="yyyy-MM-dd")Date startDate, @ApiParam(value = "开始日期", required = false) @RequestParam(required = false) @DateTimeFormat(pattern="yyyy-MM-dd")Date startDate,
@ApiParam(value = "结束日期", required = false) @RequestParam @DateTimeFormat(pattern="yyyy-MM-dd")Date endDate) { @ApiParam(value = "结束日期", required = false) @RequestParam(required = false) @DateTimeFormat(pattern="yyyy-MM-dd")Date endDate,
return iFirePatrolReportService.allPage(page,reportType, startDate, endDate); @ApiParam(value = "换流站编码", required = false) @RequestParam(required = false) String stationCode) {
return iFirePatrolReportService.allPage(page,reportType, startDate, endDate,stationCode);
} }
// /**
// * 分页接口
// */
// @ApiOperation(httpMethod = "GET", value = "单站查询列表", notes = "单站查询列表")
// @GetMapping(value = "/listPage")
// @TycloudOperation(ApiLevel = UserType.PUBLIC, needAuth = false)
// public IPage<AnalysisReportLog> listPage(Page page, @RequestParam Integer reportType,
// @ApiParam(value = "开始日期", required = false) @RequestParam @DateTimeFormat(pattern="yyyy-MM-dd")Date startDate,
// @ApiParam(value = "结束日期", required = false) @RequestParam @DateTimeFormat(pattern="yyyy-MM-dd")Date endDate,
// @RequestParam String stationCode) throws ParseException {
// return iFirePatrolReportService.listPage(page,reportType, startDate, endDate,stationCode);
// }
} }
package com.yeejoin.equipmanage.mapper; package com.yeejoin.equipmanage.mapper;
import java.util.Date; import java.util.Date;
import java.util.Map;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
...@@ -19,5 +20,7 @@ import com.yeejoin.equipmanage.common.entity.AnalysisReportLog; ...@@ -19,5 +20,7 @@ import com.yeejoin.equipmanage.common.entity.AnalysisReportLog;
public interface AnalysisReportLogMapper extends BaseMapper<AnalysisReportLog> { public interface AnalysisReportLogMapper extends BaseMapper<AnalysisReportLog> {
IPage<AnalysisReportLogDto> allPage(Page<AnalysisReportLogDto> page, @Param("analysisReportLog")AnalysisReportLog analysisReportLog); IPage<AnalysisReportLogDto> allPage(Page<AnalysisReportLogDto> page, @Param("analysisReportLog")AnalysisReportLog analysisReportLog);
Map<String,Object> getStation(String stationCode);
} }
...@@ -14,7 +14,9 @@ public interface IFirePatrolReportService { ...@@ -14,7 +14,9 @@ public interface IFirePatrolReportService {
void download(HttpServletRequest request, HttpServletResponse response,String code,Date startDate,Date endDate); void download(HttpServletRequest request, HttpServletResponse response,String code,Date startDate,Date endDate);
IPage<AnalysisReportLogDto> allPage(Page<AnalysisReportLogDto> page, Integer reportType,Date startDate,Date endDate); String preview(String code,Date startDate,Date endDate);
IPage<AnalysisReportLogDto> allPage(Page<AnalysisReportLogDto> page, Integer reportType,Date startDate,Date endDate,String stationCode);
//IPage<AnalysisReportLogDto> listPage(Page<AnalysisReportLogDto> page, Integer reportType,Date startDate,Date endDate,String stationCode);
} }
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<select id="allPage" resultType="com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto"> <select id="allPage" resultType="com.yeejoin.equipmanage.common.dto.AnalysisReportLogDto">
SELECT SELECT
*, *,
cb_org_usr.biz_org_code AS stationCode,
'消防巡查报表' AS reportName, '消防巡查报表' AS reportName,
cb_org_usr.biz_org_name AS stationName, cb_org_usr.biz_org_name AS stationName,
(CASE wl_analysis_report_log.report_type (CASE wl_analysis_report_log.report_type
...@@ -26,6 +27,13 @@ ...@@ -26,6 +27,13 @@
<if test="analysisReportLog.endDate != null"> <if test="analysisReportLog.endDate != null">
AND DATE_FORMAT(wl_analysis_report_log.end_date, '%Y-%m-%d') &lt;= DATE_FORMAT(#{analysisReportLog.endDate}, '%Y-%m-%d') AND DATE_FORMAT(wl_analysis_report_log.end_date, '%Y-%m-%d') &lt;= DATE_FORMAT(#{analysisReportLog.endDate}, '%Y-%m-%d')
</if> </if>
<if test="analysisReportLog.stationCode != null">
AND cb_org_usr.biz_org_code = #{analysisReportLog.stationCode}
</if>
</where> </where>
</select> </select>
<select id="getStation" resultType="Map">
SELECT * FROM cb_org_usr WHERE biz_org_code = #{stationCode}
</select>
</mapper> </mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment