Browse Source

工作票预览

zhongwei
段飞宇 2 years ago
parent
commit
7ea6756ea2
  1. 3
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/WorkTicketConstants.java
  2. 64
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java
  3. 17
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketPrincipalChangeEntity.java
  4. 1
      hzims-service/hzims-middle/src/main/resources/application.yml
  5. 4
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java
  6. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/properties/TicketProperties.java
  7. 5
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java
  8. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java
  9. 103
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java
  10. 132
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/PdfUtils.java
  11. 30
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java
  12. BIN
      hzims-service/ticket/src/main/resources/template/新电气第一种工作票模板.xlsx
  13. BIN
      hzims-service/ticket/src/main/resources/template/第一种工作票.docx

3
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/WorkTicketConstants.java

@ -18,7 +18,8 @@ public interface WorkTicketConstants {
/**第二种安措**/
TWO("2","matterLibraryListTwo"),
/**第三种安措**/
THREE("3","matterLibraryListThree")
THREE("3","matterLibraryListThree"),
FOUR("4","matterLibraryListFour")
;
@Getter
private String type;

64
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketInfoEntity.java

@ -3,6 +3,7 @@ package com.hnac.hzims.ticket.workTicket.entity;
import java.time.LocalDateTime;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@ -191,6 +192,11 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
private Long signer;
@TableField(exist = false)
@ApiModelProperty(value = "签发人名称")
private String signerName;
/**
* 签发人签发时间
*/
@ -229,6 +235,14 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
@JsonSerialize(nullsUsing = NullSerializer.class)
private Long licensor;
@TableField(exist = false)
@ApiModelProperty(value = "许可人名称")
@JsonSerialize(nullsUsing = NullSerializer.class)
private String licensorName;
/**
* 许可时间
*/
@ -282,51 +296,21 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
/**
* 批准工作结束时间
* 值班负责人名称
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("批准工作结束时间")
private LocalDateTime watchPrincipalEndTime;
@TableField(exist = false)
@ApiModelProperty("值班负责人名称")
private String watchPrincipalName;
/**
* 开工时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("开工时间")
private LocalDateTime startDateTime;
/**
* 收工时间
* 批准工作结束时间
*/
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@ApiModelProperty("收工时间")
private LocalDateTime endDateTime;
/**
* 工作票结束时间
*/
@ApiModelProperty("工作票结束时间")
private LocalDateTime workTicketEndTime;
/**
* 备注
*/
@ApiModelProperty("备注")
private String content;
@ApiModelProperty("批准工作结束时间")
private LocalDateTime watchPrincipalEndTime;
/**
* 交底内容
*/
@ApiModelProperty("交底内容")
private String tellContent;
/**
@ -401,7 +385,6 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
private Boolean signFlag;
/**
* 运行人员是否通过
*/
@ -409,8 +392,6 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
private Boolean recieveFlag;
/**
* 工作确认是否通过 input= 延期 input=转移 input 通过
*/
@ -439,8 +420,6 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
private String flowTaskName;
/**
* 当前任务名
*/
@ -448,5 +427,4 @@ public class WorkTicketInfoEntity extends TenantEntity implements Serializable {
private String flowTaskId;
}

17
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/workTicket/entity/WorkTicketPrincipalChangeEntity.java

@ -3,6 +3,7 @@ package com.hnac.hzims.ticket.workTicket.entity;
import java.time.LocalDateTime;
import java.io.Serializable;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@ -43,9 +44,25 @@ public class WorkTicketPrincipalChangeEntity extends TenantEntity implements Ser
@QueryField(condition = SqlCondition.EQUAL)
private Long initialPrincipal;
@TableField(exist = false)
@ApiModelProperty("原负责人名称")
private String initialPrincipalName;
@ApiModelProperty("变更负责人")
@JsonSerialize(nullsUsing = NullSerializer.class)
@QueryField(condition = SqlCondition.EQUAL)
private Long changePrincipal;
@TableField(exist = false)
@ApiModelProperty("变更负责人名称")
private String changePrincipalName;
@ApiModelProperty("变动时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime principalChangeTime;
}

1
hzims-service/hzims-middle/src/main/resources/application.yml

@ -2,6 +2,7 @@
server:
port: 8400
#数据源配置
spring:
main:

4
hzims-service/operational/src/main/java/com/hnac/hzims/operational/alert/service/impl/HistoryAbnormalAlarmServiceImpl.java

@ -10,7 +10,9 @@ import com.hnac.hzims.operational.alert.entity.HistoryAbnormalAlarmEntity;
import com.hnac.hzims.operational.alert.mapper.HistoryAbnormalAlarmMapper;
import com.hnac.hzims.operational.alert.service.AlarmHandleService;
import com.hnac.hzims.operational.alert.service.HistoryAbnormalAlarmService;
import com.hnac.hzims.operational.alert.vo.*;
import com.hnac.hzims.operational.alert.vo.AlarmDataVo;
import com.hnac.hzims.operational.alert.vo.AlarmParamVo;
import com.hnac.hzims.operational.alert.vo.AlarmReustVo;
import com.hnac.hzims.operational.config.vo.AlarmDataPageVo;
import com.hnac.hzims.operational.config.vo.AlarmVo;
import com.hnac.hzims.operational.config.vo.IntelligentAlarmCountVo;

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/processflow/properties/TicketProperties.java

@ -1,5 +1,6 @@
package com.hnac.hzims.ticket.processflow.properties;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.boot.context.properties.ConfigurationProperties;
@ -18,7 +19,6 @@ import java.util.List;
@Data
@Accessors(chain = true)
@Component
//@NacosPropertySource(dataId = "hzims-ticket-dev.yaml", autoRefreshed = true)
@ConfigurationProperties(prefix = "ticket")
@RefreshScope
public class TicketProperties {

5
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/controller/TicketProcessController.java

@ -58,8 +58,9 @@ public class TicketProcessController {
@GetMapping("/preview")
@ApiOperation(value = "预览")
@ApiOperationSupport(order = 11)
public void preview(@RequestParam @ApiParam("票据类型") String ticketType, @RequestParam @ApiParam("票据ID") Long ticketId) {
ticketProcessService.preview(ticketType,ticketId);
public R preview(@RequestParam @ApiParam("票据类型") String ticketType, @RequestParam @ApiParam("票据ID") Long ticketId) {
String preview = ticketProcessService.preview(ticketType, ticketId);
return R.data(preview);
}

2
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/TicketProcessService.java

@ -30,5 +30,5 @@ public interface TicketProcessService {
* @param ticketType
* @param ticketId
*/
void preview(String ticketType, Long ticketId);
String preview(String ticketType, Long ticketId);
}

103
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/twoTicket/service/impl/TicketProcessServiceImpl.java

@ -1,8 +1,7 @@
package com.hnac.hzims.ticket.twoTicket.service.impl;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import cn.afterturn.easypoi.word.WordExportUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@ -36,7 +35,7 @@ import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
@ -123,11 +122,9 @@ public class TicketProcessServiceImpl implements TicketProcessService {
private final IWorkTicketInfoService ticketInfoService;
@Value("${hzims.ticket.path.pdf.savePath}")
private String pdfSavePath;
@Value("${hzims.ticket.path.word.templatePath}")
private String templatePath;
@Value("${hzims.ticket.path.xlsx.savePath}")
private String xlsSavePath;
/**
* 启动开票流程
@ -348,17 +345,13 @@ public class TicketProcessServiceImpl implements TicketProcessService {
User user = UserCache.getUser(workTicket.getStepOperator());
if (StringUtils.isNotEmpty(nextStepOperator)) {
Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ?
nextStepOperator.substring(9) : null);
Long taskUser = NumberUtils.createLong(nextStepOperator.startsWith("taskUser_") ? nextStepOperator.substring(9) : null);
//下一个审批人
User stepUser = UserCache.getUser(taskUser);
flowDescription = "审批中,当前环节是".concat(description)
.concat(",当前审批人是").concat(user.getName())
.concat(",下一个审批人是").concat(stepUser.getName()).concat("待审批");
flowDescription = "审批中,当前环节是".concat(description).concat(",当前审批人是").concat(user.getName()).concat(",下一个审批人是").concat(stepUser.getName()).concat("待审批");
workTicket.setNextStepOperator(taskUser);
} else {
flowDescription = "审批中,当前环节是".concat(description)
.concat(",审批人是").concat(user.getName());
flowDescription = "审批中,当前环节是".concat(description).concat(",审批人是").concat(user.getName());
}
//如果taskId为空 或 flowStatus = 99
if (StringUtils.isEmpty(taskId) || 99 == flowStatus) {
@ -609,39 +602,32 @@ public class TicketProcessServiceImpl implements TicketProcessService {
*/
@SneakyThrows
@Override
public void preview(String ticketType, Long ticketId) {
public String preview(String ticketType, Long ticketId) {
WorkTicketVo workTicketVo = ticketInfoService.selectDetailsById(ticketId);
//将查询的数据转换为map
Map<String, Object> workTicketInfoMap = this.convertMap(workTicketVo);
workTicketInfoMap.put("name", 22);
String fileName = TicketConstants.WordFileNameEnum.getFileNameByType(ticketType) + PdfUtils.XLSX_SUFFIX;
log.info("工作票模板为:{}", fileName);
TemplateExportParams templateExportParams = new TemplateExportParams("template/新电气第一种工作票模板.xlsx", true);
Workbook workbook = null;
try {
workbook = ExcelExportUtil.exportExcel(templateExportParams, workTicketInfoMap);
} catch (Exception e) {
e.printStackTrace();
XWPFDocument doc = WordExportUtil.exportWord07("template/电气第一种工作票模版.docx", workTicketInfoMap);
FileOutputStream fos = null;
String name = null;
String os = System.getProperty("os.name");
//Windows操作系统
if (os != null && os.toLowerCase().startsWith("windows")) {
log.info("当前系统版本是:{}", os);
name = "D:/导出excel/电气第一种工作票模版.docx";
fos = new FileOutputStream(name);
} else {
//其它操作系统
log.info("当前系统版本是:{}", os);
String prefix = IdWorker.get32UUID();
name = templatePath + prefix + ".docx";
fos = new FileOutputStream(name);
}
FileOutputStream fos = new FileOutputStream("F:\\idea项目\\flowable\\demo\\src\\main\\resources\\新电气第一种工作票模板5" +
".xlsx");
workbook.write(fos);
// //上传xlsx至服务器
// try {
// ExcelUtil.upload(workbook, xlsSavePath, workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.XLSX_SUFFIX);
// } catch (Exception e) {
// e.printStackTrace();
// }
// //将xlsx文件转换为pdf并保存
// String pdfFileName = workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.PDF_SUFFIX;
// String xlsFileName = workTicketVo.getWorkTicket().getWorkContent() + PdfUtils.XLSX_SUFFIX;
// PdfUtils.convertPdf(xlsSavePath, xlsFileName, pdfSavePath, pdfFileName);
// String savePath = pdfSavePath + pdfFileName;
// // 设置response参数,可以打开下载页面
// ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
// HttpServletResponse response = servletRequestAttributes.getResponse();
// PdfUtils.readPdf(response, savePath);
doc.write(fos);
fos.close();
return name;
}
@ -650,7 +636,7 @@ public class TicketProcessServiceImpl implements TicketProcessService {
Map<String, Object> result = new HashMap<>();
WorkTicketInfoEntity workTicket = workTicketVo.getWorkTicket();
//1. 工作对象
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMap(workTicket);
Map<String, Object> workTicketInfoMap = PdfUtils.objectToMap(workTicket, true);
//2. 安全措施
List<WorkTicketSafetyMeasureEntity> safetyMeasuresList = workTicketVo.getSafetyMeasuresList();
@ -658,13 +644,25 @@ public class TicketProcessServiceImpl implements TicketProcessService {
Map<String, List<WorkTicketSafetyMeasureEntity>> measureMap = safetyMeasuresList.stream().collect(Collectors.groupingBy(WorkTicketSafetyMeasureEntity::getType));
Arrays.stream(WorkTicketConstants.WorkTicketMeasureTypeEnum.class.getEnumConstants()).forEach(measureEnum -> {
if (CollectionUtil.isNotEmpty(measureMap.get(measureEnum.getType()))) {
List<Map<String, Object>> mapList = measureMap.get(measureEnum.getType()).stream().map(measureVO -> {
Map<String, Object> map = PdfUtils.objectToMap(measureVO);
List<Map<String, Object>> mapList = new ArrayList<>();
int tempIndex = 1, index = 1;
List<WorkTicketSafetyMeasureEntity> workTicketSafetyMeasureEntities = measureMap.get(measureEnum.getType());
for (WorkTicketSafetyMeasureEntity measureVO : workTicketSafetyMeasureEntities) {
String type = measureEnum.getType();
if (tempIndex != Integer.valueOf(type)) {
index = 1;
tempIndex++;
}
Map<String, Object> map = PdfUtils.objectToMap(measureVO, true);
map.put("index", index);
map.put("safetyMeasure", ObjectUtil.isNotEmpty(map.get("measure")) ? map.get("measure") : null);
String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus().equals(measureVO.getStatus()) ? TicketConstants.SafetyMeasureStatusEnum.FINISH.getDescribe() : " ";
String status = TicketConstants.SafetyMeasureStatusEnum.FINISH.getStatus().equals(measureVO.getStatus()) ? "√" : ";
map.put("status", status);
return map;
}).collect(Collectors.toList());
mapList.add(map);
index++;
}
workTicketInfoMap.put(measureEnum.getConvertAttributes(), mapList);
} else {
workTicketInfoMap.put(measureEnum.getConvertAttributes(), new ArrayList<Map<String, String>>(1));
@ -681,21 +679,26 @@ public class TicketProcessServiceImpl implements TicketProcessService {
//4. 工作票延期
WorkTicketDelayEntity workTicketDelay = workTicketVo.getWorkTicketDelay();
if (ObjectUtils.isNotEmpty(workTicketDelay)) {
result.putAll(PdfUtils.objectToMap(workTicketDelay));
result.putAll(PdfUtils.objectToMap(workTicketDelay, true));
} else {
result.putAll(PdfUtils.objectToMap(new WorkTicketDelayEntity(), true));
}
//5. 工作结束
WorkTicketFinish workTicketFinish = workTicketVo.getWorkTicketFinish();
if (ObjectUtils.isNotEmpty(workTicketFinish)) {
result.putAll(PdfUtils.objectToMap(workTicketFinish));
result.putAll(PdfUtils.objectToMap(workTicketFinish, true));
} else {
result.putAll(PdfUtils.objectToMap(new WorkTicketFinish(), true));
}
//5. 工作票负责人变更
WorkTicketPrincipalChangeEntity workTicketPrincipalChange = workTicketVo.getWorkTicketPrincipalChange();
if (ObjectUtils.isNotEmpty(workTicketPrincipalChange)) {
result.putAll(PdfUtils.objectToMap(workTicketPrincipalChange));
result.putAll(PdfUtils.objectToMap(workTicketPrincipalChange, true));
} else {
result.putAll(PdfUtils.objectToMap(new WorkTicketPrincipalChangeEntity(), true));
}
return result;
}

132
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/PdfUtils.java

@ -32,7 +32,7 @@ import java.util.stream.Collectors;
@Slf4j
public class PdfUtils {
/**文件后缀名**/
/** 文件后缀名 **/
public static String DOC_SUFFIX = ".doc";
public static String DOCX_SUFFIX = ".docx";
public static String XLS_SUFFIX = ".xls";
@ -47,14 +47,14 @@ public class PdfUtils {
* @param saveFileName 转换为pdf后的文件名称
* @return
*/
public static void convertPdf (String templatePath, String templateFileName, String savePath, String saveFileName) {
public static void convertPdf(String templatePath, String templateFileName, String savePath, String saveFileName) {
String templateFilePath = templatePath + templateFileName;
String saveFilePath = savePath + saveFileName;
log.info("转换前的文件为:{};转换后的路径为:{}",templateFilePath,saveFilePath);
log.info("转换前的文件为:{};转换后的路径为:{}", templateFilePath, saveFilePath);
File templateFile = new File(templateFilePath);
File saveFile = new File(saveFilePath);
//获取文件类型
String fileType = templateFileName.substring(templateFileName.lastIndexOf("."),templateFileName.length());
String fileType = templateFileName.substring(templateFileName.lastIndexOf("."), templateFileName.length());
InputStream inputStream = null;
OutputStream outputStream = null;
try {
@ -62,52 +62,51 @@ public class PdfUtils {
inputStream = new FileInputStream(templateFile);
outputStream = new FileOutputStream(saveFile);
//document4j 转换 pdf linux环境下不支持
if(DOCX_SUFFIX.equals(fileType)) {
if (DOCX_SUFFIX.equals(fileType)) {
IConverter converter = LocalConverter.builder().build();
converter.convert(inputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
converter.shutDown();
}else if(DOC_SUFFIX.equals(fileType)){
} else if (DOC_SUFFIX.equals(fileType)) {
IConverter converter = LocalConverter.builder().build();
converter.convert(inputStream).as(DocumentType.DOC).to(outputStream).as(DocumentType.PDF).execute();
converter.shutDown();
}else if(XLS_SUFFIX.equals(fileType)){
} else if (XLS_SUFFIX.equals(fileType)) {
IConverter converter = LocalConverter.builder().build();
converter.convert(inputStream).as(DocumentType.XLS).to(outputStream).as(DocumentType.PDF).execute();
converter.shutDown();
}else if(XLSX_SUFFIX.equals(fileType)){
} else if (XLSX_SUFFIX.equals(fileType)) {
//此方式行不通
//converter.convert(inputStream).as(DocumentType.XLSX).to(outputStream).as(DocumentType.PDF).execute();
Workbook wb = new Workbook();
wb.loadFromFile(templateFilePath);
wb.saveToFile(saveFilePath,FileFormat.PDF);
wb.saveToFile(saveFilePath, FileFormat.PDF);
}
}
catch (Exception e) {
log.error("转换失败,错误信息为:{}",e.getMessage());
} catch (Exception e) {
log.error("转换失败,错误信息为:{}", e.getMessage());
throw new ServiceException(e.getMessage());
}
finally {
} finally {
inputStream.close();
outputStream.close();
}
}
catch(IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 对象转化为Map 并设置默认值
*
* @param obj
* @return
* @throws Exception
*/
public static Map<String, Object> objectToMap(Object obj) {
Map<String, Object> result = new HashMap<>();
if(ObjectUtil.isNotEmpty(obj) && null != obj.getClass()) {
if (ObjectUtil.isNotEmpty(obj) && null != obj.getClass()) {
Class clazz = obj.getClass();
List<Field> fieldList = new ArrayList<>();
while(clazz != null) {
while (clazz != null) {
fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
clazz = clazz.getSuperclass();
}
@ -121,28 +120,89 @@ public class PdfUtils {
throw new ServiceException("获取属性性出错");
}
//若为list则不处理
if(value instanceof List){
return ;
if (value instanceof List) {
return;
}
//若为时间格式则进行格式化
if(value instanceof LocalDateTime){
if (value instanceof LocalDateTime) {
value = DateUtil.format((LocalDateTime) value, TicketConstants.TICKET_DATE_PATTERN);
}
if(value instanceof Date){
if (value instanceof Date) {
value = DateUtil.format((Date) value, TicketConstants.TICKET_DATE_PATTERN);
}
if ((ObjectUtils.isEmpty(value) || value == "") && StringUtil.isNoneBlank(field.getName())){
//如果value为空直接跳出
// if ((ObjectUtils.isEmpty(value) || value == "") && StringUtil.isNoneBlank(field.getName())){
// return;
// }
//属性上是否加入DefaultValue注解 若加入 则判断是否定义属性名以及值 若未定义则取原属性名及值
if (ObjectUtil.isNotEmpty(defaultValue)) {
result.put(StringUtil.isNoneBlank(defaultValue.name()) ? defaultValue.name() : field.getName(),
ObjectUtil.isNotEmpty(defaultValue.value()) ? defaultValue.value() : value);
} else {
result.put(field.getName(), Optional.ofNullable(value).orElse(" "));
}
});
}
return result;
}
/**
* 对象转化为Map 并设置默认值
*
* @param obj
* @return
* @throws Exception
*/
public static Map<String, Object> objectToMap(Object obj, boolean isWordFlag) {
Map<String, Object> result = new HashMap<>();
if (ObjectUtil.isNotEmpty(obj) && null != obj.getClass()) {
Class clazz = obj.getClass();
List<Field> fieldList = new ArrayList<>();
while (clazz != null) {
fieldList.addAll(Arrays.asList(clazz.getDeclaredFields()));
clazz = clazz.getSuperclass();
}
fieldList.forEach(field -> {
field.setAccessible(true);
DefaultValue defaultValue = field.getAnnotation(DefaultValue.class);
Object value;
try {
value = field.get(obj);
} catch (IllegalAccessException e) {
throw new ServiceException("获取属性性出错");
}
//若为list则不处理
if (value instanceof List) {
return;
}
//若为时间格式则进行格式化
if (value instanceof LocalDateTime) {
value = DateUtil.format((LocalDateTime) value, TicketConstants.TICKET_DATE_PATTERN);
}
if (value instanceof Date) {
value = DateUtil.format((Date) value, TicketConstants.TICKET_DATE_PATTERN);
}
//如果value为空直接跳出
// if ((ObjectUtils.isEmpty(value) || value == "") && StringUtil.isNoneBlank(field.getName())){
// return;
// }
//属性上是否加入DefaultValue注解 若加入 则判断是否定义属性名以及值 若未定义则取原属性名及值
if(ObjectUtil.isNotEmpty(defaultValue)){
if (ObjectUtil.isNotEmpty(defaultValue)) {
result.put(StringUtil.isNoneBlank(defaultValue.name()) ? defaultValue.name() : field.getName(),
ObjectUtil.isNotEmpty(defaultValue.value()) ? defaultValue.value() : value);
} else {
if (isWordFlag) {
//如果导出word为null会出现{{ ,value设置"\u00A0"
result.put(field.getName(), Optional.ofNullable(value).orElse("\u00A0"));
} else {
result.put(field.getName(), Optional.ofNullable(value).orElse(" "));
}
else {
result.put(field.getName(), Optional.ofNullable(value).orElse(""));
}
});
}
@ -163,20 +223,18 @@ public class PdfUtils {
outputStream = response.getOutputStream();
IOUtils.write(IOUtils.toByteArray(fileInputStream), outputStream);
response.setHeader("Content-Disposition",
"inline; filename= " + URLEncoder.encode( file.getName() , "UTF-8"));
"inline; filename= " + URLEncoder.encode(file.getName(), "UTF-8"));
outputStream.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
finally {
try{
} finally {
try {
fileInputStream.close();
outputStream.close();
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
}
@ -195,20 +253,18 @@ public class PdfUtils {
fileInputStream = new FileInputStream(file);
outputStream = response.getOutputStream();
IOUtils.write(IOUtils.toByteArray(fileInputStream), outputStream);
response.setHeader("Content-Disposition", "inline; filename= " + URLEncoder.encode( file.getName() , "UTF-8"));
response.setHeader("Content-Disposition", "inline; filename= " + URLEncoder.encode(file.getName(), "UTF-8"));
outputStream.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
finally {
try{
} finally {
try {
fileInputStream.close();
outputStream.close();
}
catch (IOException e) {
} catch (IOException e) {
e.printStackTrace();
}
}

30
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java

@ -55,6 +55,7 @@ import org.springblade.core.tool.utils.*;
import org.springblade.flow.core.entity.BladeFlow;
import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.vo.ComleteTask;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.BeanUtils;
@ -937,6 +938,22 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
if (ObjectUtils.isEmpty(workTicketInfo)) {
throw new ServiceException("未查询到ticketId对应的信息");
}
//赋值签发人
if (workTicketInfo.getSigner() != null){
workTicketInfo.setSignerName(UserCache.getUser(workTicketInfo.getSigner()).getName());
}
//赋值许可人名称
if (workTicketInfo.getLicensor() != null){
workTicketInfo.setLicensorName(UserCache.getUser(workTicketInfo.getLicensor()).getName());
}
// 负责值班负责人
if (workTicketInfo.getWatchPrincipal() != null){
workTicketInfo.setWatchPrincipalName(UserCache.getUser(workTicketInfo.getWatchPrincipal()).getName());
}
workTicketVo.setWorkTicket(workTicketInfo);
//2. 安全措施数组
@ -977,6 +994,19 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
WorkTicketPrincipalChangeEntity workTicketPrincipalChangeEntity =
workTicketPrincipalChangeService.selectByTicketId(ticketId);
if (ObjectUtils.isNotEmpty(workTicketPrincipalChangeEntity)) {
//原负责人
if (workTicketPrincipalChangeEntity.getInitialPrincipal() != null){
workTicketPrincipalChangeEntity.setInitialPrincipalName(
UserCache.getUser(workTicketPrincipalChangeEntity.getInitialPrincipal()).getName()
);
}
//变更负责人
if (workTicketPrincipalChangeEntity.getChangePrincipal() != null){
workTicketPrincipalChangeEntity.setChangePrincipalName(
UserCache.getUser(workTicketPrincipalChangeEntity.getChangePrincipal()).getName()
);
}
workTicketVo.setWorkTicketPrincipalChange(workTicketPrincipalChangeEntity);
}

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

Binary file not shown.

BIN
hzims-service/ticket/src/main/resources/template/第一种工作票.docx

Binary file not shown.
Loading…
Cancel
Save