Browse Source

fix:[模板管理]导出

master
15881625488@163.com 1 month ago
parent
commit
b1205e1bde
9 changed files with 67 additions and 54 deletions
  1. +2
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspController.java
  2. +2
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GyzjController.java
  3. +2
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/MjyController.java
  4. +1
    -1
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyFormFillController.java
  5. +6
    -3
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/StudyFormFillUtil.java
  6. +39
    -35
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/pdf/PdfBaseUtil.java
  7. +5
    -4
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/pdf/resource/Dosage.java
  8. +5
    -4
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/pdf/resource/Drug.java
  9. +5
    -4
      hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/pdf/resource/GspPdf.java

+ 2
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GspController.java View File

@ -58,7 +58,7 @@ public class GspController extends BaseController {
*/
@RequiresPermissions(value={"business:resource:mjy:xq","business:archive:mjy:xq"}, logical= Logical.OR)
@GetMapping(value = "/exportDetail")
public AjaxResult exportDetail(Long id,String lang) {
public AjaxResult exportDetail(Long id,String lang,String version) {
GspJcgj gspJcgj = new GspJcgj();
gspJcgj.setGspId(id);
List<GspJcgj> jcgjList = gspJcgjService.queryList(gspJcgj);
@ -72,6 +72,7 @@ public class GspController extends BaseController {
tzList,
jcgjList,
lang,
version,
localFilePath));
}

+ 2
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/GyzjController.java View File

@ -114,7 +114,7 @@ public class GyzjController extends BaseController
*/
@RequiresPermissions(value={"business:resource:gyzj:xq","business:archive:gyzj:xq"}, logical= Logical.OR)
@GetMapping(value = "/exportDetail")
public AjaxResult exportDetail(Long id,String lang) {
public AjaxResult exportDetail(Long id,String lang,String version) {
GyzjJcgj gyzjJcgj = new GyzjJcgj();
gyzjJcgj.setGyzjId(id);
List<GyzjJcgj> gyzjJcgjList = gyzjJcgjService.queryList(gyzjJcgj);
@ -128,6 +128,7 @@ public class GyzjController extends BaseController
gyzjTzList,
gyzjJcgjList,
lang,
version,
localFilePath));
}

+ 2
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/MjyController.java View File

@ -105,7 +105,7 @@ public class MjyController extends BaseController {
*/
@RequiresPermissions(value={"business:resource:mjy:xq","business:archive:mjy:xq"}, logical= Logical.OR)
@GetMapping(value = "/exportDetail")
public AjaxResult exportDetail(Long id,String lang) {
public AjaxResult exportDetail(Long id,String lang,String version) {
MjyJcgj mjyJcgj = new MjyJcgj();
mjyJcgj.setMjyId(id);
List<MjyJcgj> mjyJcgjList = mjyJcgjService.queryList(mjyJcgj);
@ -119,6 +119,7 @@ public class MjyController extends BaseController {
mjyTzList,
mjyJcgjList,
lang,
version,
localFilePath));
}

+ 1
- 1
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/controller/StudyFormFillController.java View File

@ -220,7 +220,7 @@ public class StudyFormFillController extends BaseController {
fileUrl = fileUrl.replaceFirst(localFilePrefix, "");
int indexOf = fileUrl.lastIndexOf("/");
String path = fileUrl.substring(0, indexOf);
String exportFileName = StudyFormFillUtil.export(form.getVersion(),form.getLang(),study.getName() + "("+study.getSn()+")"+studyFormFill.getBdmc(),
String exportFileName = StudyFormFillUtil.export(form.getVersion(),form.getLang(),study.getName() + "("+study.getSn()+") "+studyFormFill.getBdmc(),
localFilePath + fileUrl, localFilePath + File.separator + path,jcgjList,qmxxList);

+ 6
- 3
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/StudyFormFillUtil.java View File

@ -108,9 +108,9 @@ public class StudyFormFillUtil {
String sign = "hxhq";
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
sign = loginUser.getSysUser().getNickName() + " " + DateUtils.getTime();
sign = loginUser.getSysUser().getNickName() + " " + DateUtils.getTime();
}
writer.setPageEvent(new TextHeaderEvent(sign+" "+version, headerText, false));
writer.setPageEvent(new TextHeaderEvent(sign+" "+version+" ", headerText, false));
// 4. 设置PDF属性
document.addTitle("华西海圻");
document.addAuthor("华西海圻");
@ -395,9 +395,12 @@ public class StudyFormFillUtil {
// addRepeatedWatermark(content, width, height, signText);
// 添加页眉文字
if (StringUtils.isNoneBlank(headerText)) {
float pageTextWidth1 = baseFont.getWidthPoint(headerText, footerFont.getSize());
float startX1 = (document.getPageSize().getWidth() - pageTextWidth1) / 2;
PdfContentByte cb2 = writer.getDirectContent();
ColumnText.showTextAligned(cb2, Element.ALIGN_LEFT,
new Phrase(headerText, footerFont), startX, textY, 0);
new Phrase(headerText, footerFont), startX1, textY, 0);
// canvas.beginText();
// canvas.setFontAndSize(baseFont, fontSize);
// canvas.setTextMatrix(textX, textY);

+ 39
- 35
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/pdf/PdfBaseUtil.java View File

@ -234,11 +234,11 @@ public class PdfBaseUtil {
private String signText;
private String headerText;
private BaseFont baseFont;
private Boolean showHaderLine=true;
private Boolean showHaderLine = true;
private int totalPages = 0;
private PdfTemplate total;
public TextHeaderEvent(String signText, String headerText,Boolean showHaderLine) throws Exception {
public TextHeaderEvent(String signText, String headerText, Boolean showHaderLine) throws Exception {
try {
this.showHaderLine = showHaderLine;
this.signText = signText;
@ -283,14 +283,14 @@ public class PdfBaseUtil {
float pageHeight = pageSize.getHeight();
// 设置页眉参数
float topMargin = 30; // 顶部边距
float topMargin = 15; // 顶部边距
float fontSize = 12; // 字体大小
// 计算文字宽度用于居中
float textWidth = baseFont.getWidthPoint(signText, fontSize);
// 计算居中位置
float textX = (pageWidth - textWidth) / 2;
float textX = (pageSize.getLeft() + pageSize.getRight()) / 2;
float textY = pageHeight - topMargin;
// 获取画布
@ -300,7 +300,7 @@ public class PdfBaseUtil {
float y = document.bottom() - 20;
// 在每一页都重新计算确保位置准确
String pageText = "第 " + currentPage + " 页 / 共 ";
String pageText = signText+ " 第 " + currentPage + " 页 / 共 ";
BaseFont baseFont = footerFont.getBaseFont();
// 计算页面文本宽度
@ -326,38 +326,43 @@ public class PdfBaseUtil {
ColumnText.showTextAligned(cb, Element.ALIGN_LEFT,
new Phrase(" 页", footerFont), startX + pageTextWidth + totalWidth, y, 0);
PdfContentByte content = writer.getDirectContentUnder(); // 在水印层添加
// 设置透明度
PdfGState gs = new PdfGState();
float opacity = Convert.toFloat("0.3");
gs.setFillOpacity(opacity);
content.setGState(gs);
// 设置字体和颜色
content.setColorFill(BaseColor.RED);
content.setFontAndSize(baseFont, fontSize);
float width = pageSize.getWidth();
float height = pageSize.getHeight();
// 重复铺满水印
addRepeatedWatermark(content, width, height, signText);
// PdfContentByte content = writer.getDirectContentUnder(); // 在水印层添加
//
// // 设置透明度
// PdfGState gs = new PdfGState();
// float opacity = Convert.toFloat("0.3");
// gs.setFillOpacity(opacity);
// content.setGState(gs);
//
// // 设置字体和颜色
// content.setColorFill(BaseColor.RED);
// content.setFontAndSize(baseFont, fontSize);
//
// float width = pageSize.getWidth();
// float height = pageSize.getHeight();
//
// // 重复铺满水印
// addRepeatedWatermark(content, width, height, signText);
// 添加页眉文字
if(StringUtils.isNoneBlank(headerText)) {
canvas.beginText();
canvas.setFontAndSize(baseFont, fontSize);
canvas.setTextMatrix(textX, textY);
canvas.showText(headerText);
canvas.endText();
if(showHaderLine){
if (StringUtils.isNoneBlank(headerText)) {
float pageTextWidth1 = baseFont.getWidthPoint(headerText, footerFont.getSize());
float startX1 = (document.getPageSize().getWidth() - pageTextWidth1) / 2;
PdfContentByte cb2 = writer.getDirectContent();
ColumnText.showTextAligned(cb2, Element.ALIGN_LEFT,
new Phrase(headerText, footerFont), startX1, textY, 0);
// canvas.beginText();
// canvas.setFontAndSize(baseFont, fontSize);
// canvas.setTextMatrix(textX, textY);
// canvas.showText(headerText);
// canvas.endText();
if (showHaderLine) {
// 添加页眉分隔线可选
addHeaderLine(canvas, pageWidth, textY - 10);
}
}
} catch (Exception e) {
e.printStackTrace();
}
@ -374,7 +379,7 @@ public class PdfBaseUtil {
private void addRepeatedWatermark(PdfContentByte content, float width, float height, String signText) {
// 计算文字尺寸
float fontSize = Convert.toFloat("10");
float textWidth = baseFont.getWidthPoint(signText, fontSize)+50;
float textWidth = baseFont.getWidthPoint(signText, fontSize) + 50;
float textHeight = baseFont.getAscentPoint(signText, fontSize) -
baseFont.getDescentPoint(signText, fontSize);
@ -383,7 +388,7 @@ public class PdfBaseUtil {
float stepY = textHeight + 100;
// 添加重复水印
Integer two=2;
Integer two = 2;
for (float x = textWidth / two; x < width; x += stepX) {
for (float y = textHeight / two; y < height; y += stepY) {
content.beginText();
@ -408,8 +413,7 @@ public class PdfBaseUtil {
*/
private void addHeaderLine(PdfContentByte canvas, float pageWidth, float yPos) {
canvas.setLineWidth(0.5f);
canvas.moveTo(50, yPos);
canvas.lineTo(pageWidth - 50, yPos);
canvas.lineTo(pageWidth, yPos);
canvas.stroke();
}
}

+ 5
- 4
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/pdf/resource/Dosage.java View File

@ -37,7 +37,7 @@ public class Dosage {
* @param gyzj
* @return
*/
public String exportDetail(DetailDto gyzj, List<GyzjTz> gyzjTzList, List<GyzjJcgj> gyzjJcgjList, String lang, String localFilePath) {
public String exportDetail(DetailDto gyzj, List<GyzjTz> gyzjTzList, List<GyzjJcgj> gyzjJcgjList, String lang, String version,String localFilePath) {
language=lang;
Document document = null;
FileOutputStream fos = null;
@ -46,9 +46,9 @@ public class Dosage {
String sign = "hxhq";
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
sign = loginUser.getSysUser().getNickName();
sign = loginUser.getSysUser().getNickName() +" "+ PdfExportUtil.parseDateToStr(new Date());
}
document = PdfBaseUtil.init(document, fos, filePath, sign + PdfExportUtil.parseDateToStr(new Date()), getName("给药制剂详情"),false);
document = PdfBaseUtil.init(document, fos, filePath, sign +" "+version+" ", getName("给药制剂详情"),false);
// 基本信息
PdfBaseUtil.addUnderlinedTitle(document, getName("基本信息"), 10, true);
Map<String, String> formData1 = new LinkedHashMap<>();
@ -113,8 +113,9 @@ public class Dosage {
String[] headers = {getName("使用人"),getName("领取/归还人/入库申请人"),getName("发放/接收人"),getName("操作类型"),getName("表单名称"),getName("操作量"),getName("备注/原因"),getName("操作时间")};
for (String header : headers) {
PdfPCell cell = new PdfPCell(new Phrase(header, headerFont));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setPadding(8);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(BaseColor.WHITE);
cell.setBorderWidth(1);
table.addCell(cell);
}

+ 5
- 4
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/pdf/resource/Drug.java View File

@ -36,7 +36,7 @@ public class Drug {
* @param mjy
* @return
*/
public String exportDetail(DetailDto mjy, List<MjyTz> mjyTzList, List<MjyJcgj> mjyJcgjList, String lang, String localFilePath) {
public String exportDetail(DetailDto mjy, List<MjyTz> mjyTzList, List<MjyJcgj> mjyJcgjList, String lang,String version, String localFilePath) {
language=lang;
Document document = null;
FileOutputStream fos = null;
@ -45,9 +45,9 @@ public class Drug {
String sign = "hxhq" ;
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
sign = loginUser.getSysUser().getNickName();
sign = loginUser.getSysUser().getNickName()+" "+ PdfExportUtil.parseDateToStr(new Date());
}
document = PdfBaseUtil.init(document, fos, filePath, sign + PdfExportUtil.parseDateToStr(new Date()), getName("麻精药详情"),false);
document = PdfBaseUtil.init(document, fos, filePath, sign +" "+version+" ", getName("麻精药详情"),false);
// 基本信息
PdfBaseUtil.addUnderlinedTitle(document, getName("基本信息"), 10, true);
Map<String, String> formData1 = new LinkedHashMap<>();
@ -112,8 +112,9 @@ public class Drug {
String[] headers = {getName("使用人"),getName("领取/归还人"),getName("发放/接收人"),getName("操作类型"),getName("表单名称"),getName("操作量"),getName("备注/原因"),getName("操作时间")};
for (String header : headers) {
PdfPCell cell = new PdfPCell(new Phrase(header, headerFont));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setPadding(8);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(BaseColor.WHITE);
cell.setBorderWidth(1);
table.addCell(cell);
}

+ 5
- 4
hxhq-modules/hxhq-system/src/main/java/com/hxhq/business/utils/pdf/resource/GspPdf.java View File

@ -38,7 +38,7 @@ public class GspPdf {
* @param gsp
* @return
*/
public String exportDetail(GspDto gsp, List<GspTz> tzList, List<GspJcgj> jcgjList, String lang, String localFilePath) {
public String exportDetail(GspDto gsp, List<GspTz> tzList, List<GspJcgj> jcgjList, String lang,String version, String localFilePath) {
language=lang;
Document document = null;
FileOutputStream fos = null;
@ -47,9 +47,9 @@ public class GspPdf {
String sign = "hxhq";
LoginUser loginUser = SecurityUtils.getLoginUser();
if (loginUser != null) {
sign = loginUser.getSysUser().getNickName();
sign = loginUser.getSysUser().getNickName()+" "+ PdfExportUtil.parseDateToStr(new Date());
}
document = PdfBaseUtil.init(document, fos, filePath, sign + PdfExportUtil.parseDateToStr(new Date()), getName("给药制剂详情"),false);
document = PdfBaseUtil.init(document, fos, filePath, sign +" "+version+" ", getName("给药制剂详情"),false);
// 基本信息
PdfBaseUtil.addUnderlinedTitle(document, getName("基本信息"), 10, true);
Map<String, String> formData1 = new LinkedHashMap<>();
@ -106,8 +106,9 @@ public class GspPdf {
String[] headers = {getName("使用人"),getName("领取/归还人/入库申请人"),getName("发放/接收人"),getName("操作类型"),getName("表单名称"),getName("操作量"),getName("备注/原因"),getName("操作时间")};
for (String header : headers) {
PdfPCell cell = new PdfPCell(new Phrase(header, headerFont));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setPadding(8);
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(BaseColor.WHITE);
cell.setBorderWidth(1);
table.addCell(cell);
}

Loading…
Cancel
Save