Browse Source

# 第一种工作票预览

zhongwei
haungxing 12 months ago
parent
commit
3bdee311f9
  1. 14
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/annotation/DateTimeToMap.java
  2. 21
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java
  3. 57
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/ObjectUtils.java
  4. 15
      hzims-service/ticket/src/main/resources/License.xml
  5. BIN
      hzims-service/ticket/src/main/resources/template/电气第一种工作票模版新.docx
  6. 2
      pom.xml

14
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/annotation/DateTimeToMap.java

@ -0,0 +1,14 @@
package com.hnac.hzims.ticket.annotation;
import java.lang.annotation.*;
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface DateTimeToMap {
String prefix() default "";
String split() default "_";
}

21
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/FirstWorkTicketServiceImpl.java

@ -320,24 +320,22 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa
put("l_minuter","13");
put("licensorName","杨汪洋");
put("principalName1","杨汪洋");
put("groundNum","11");
put("dismantleNum","12");
put("retainNum","8");
put("brakeNumber","A7758258");
put("licensorName2","A7758258");
put("isSafety ","☑");
put("isHazard","☑");
put("isRailway","☑");
put("isLimited","☑");
}};
try {
response.setHeader("content-disposition", "attachment;filename=" + new String("电气第一种工作票模版新.docx".getBytes(), "ISO8859-1"));
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
XWPFDocument xwpfDocument = null;
try {
xwpfDocument = WordExportUtil.exportWord07("template/电气第一种工作票模版新.docx", params);
} catch (Exception e) {
throw new RuntimeException(e);
}
try {
xwpfDocument.write(response.getOutputStream());
} catch (IOException e) {
throw new RuntimeException(e);
}
String wordPath = "E://template/" + params.get("code") + "_" + params.get("addressEquName") +".docx";
String pdfPath = "E://template/" + params.get("code") + "_" + params.get("addressEquName") +".pdf";
// String pdfPath = pdfSavePath + "/" + params.get("code") + "_" + params.get("addressEquName") +".pdf";
@ -361,6 +359,7 @@ public class FirstWorkTicketServiceImpl extends BaseServiceImpl<WorkTicketInfoMa
}
}
AsposeUtil.wordToPdf(wordPath,pdfPath);
PdfUtils.readPdf(response,pdfPath);
}
@Override

57
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/ObjectUtils.java

@ -0,0 +1,57 @@
package com.hnac.hzims.ticket.utils;
import com.hnac.hzims.ticket.annotation.DateTimeToMap;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.ObjectUtil;
import java.lang.reflect.Field;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;
public class ObjectUtils {
public static Map obj2Map(Object obj) {
if(ObjectUtil.isNotEmpty(obj) && null != obj.getClass()) {
Map result = new HashMap();
List<Field> fieldList = new ArrayList<>();
Class<?> clazz = obj.getClass();
while(clazz != null) {
fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
clazz = clazz.getSuperclass();
}
fieldList.forEach(field -> {
field.setAccessible(true);
Object value;
try {
value = field.get(obj);
} catch (IllegalAccessException e) {
throw new ServiceException("获取属性性出错");
}
if(value instanceof List) {
List<Map> list = ((List<?>) value).stream().map(ObjectUtils::obj2Map).collect(Collectors.toList());
result.put(field.getName(),list);
}
else if(value instanceof LocalDateTime) {
DateTimeToMap dateTimeToMap = field.getAnnotation(DateTimeToMap.class);
LocalDateTime time = (LocalDateTime) value;
if(ObjectUtil.isEmpty(dateTimeToMap)) {
result.put(field.getName(),time.format(DateUtil.TIME_FORMATTER));
}
else {
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"year",time.getYear());
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"month",time.getMonth());
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"day",time.getDayOfMonth());
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"hour",time.getHour());
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"minute",time.getMinute());
result.put(dateTimeToMap.prefix()+dateTimeToMap.split()+"second",time.getSecond());
}
}
});
return result;
}
return null;
}
}

15
hzims-service/ticket/src/main/resources/License.xml

@ -0,0 +1,15 @@
<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>

BIN
hzims-service/ticket/src/main/resources/template/电气第一种工作票模版新.docx

Binary file not shown.

2
pom.xml

@ -16,7 +16,7 @@
<properties>
<bladex.project.version>5.0.1.RELEASE</bladex.project.version>
<!--数据平台接口版本-->
<hzinfo.data.sdk.version>5.0.3.RELEASE</hzinfo.data.sdk.version>
<hzinfo.data.sdk.version>5.1.0.RELEASE</hzinfo.data.sdk.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>

Loading…
Cancel
Save