diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/entity/BusinessEarlyEntity.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/entity/BusinessEarlyEntity.java new file mode 100644 index 0000000..c0b0596 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/entity/BusinessEarlyEntity.java @@ -0,0 +1,39 @@ +package com.hnac.hzims.business.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springblade.core.tenant.mp.TenantEntity; + +import javax.validation.constraints.NotNull; + + +/** + * @author ysj + */ +@Data +@TableName("hzims_business_early") +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "业务预警", description = "业务预警对象") +public class BusinessEarlyEntity extends TenantEntity { + + private static final long serialVersionUID = 1L; + + @ApiModelProperty("任务ID") + @NotNull + private Long taskId; + + @ApiModelProperty("业务类型 :0 - 固定资产 1 - 日常维护 2 - 安全工器- 具 3 - 巡检 4 - 检修 5 - 缺陷 6 - 值班") + @NotNull + private Integer businessType; + + @ApiModelProperty("预警内容") + @NotNull + private String content; + + @ApiModelProperty("机构Id") + private Long deptId; + +} \ No newline at end of file diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/BusinessEarlyClientFallback.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/BusinessEarlyClientFallback.java new file mode 100644 index 0000000..8bf7032 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/BusinessEarlyClientFallback.java @@ -0,0 +1,17 @@ +package com.hnac.hzims.business.feign; + +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import org.springblade.core.tool.api.R; +import org.springframework.stereotype.Component; + +/** + * @author hx + */ +@Component +public class BusinessEarlyClientFallback implements IBusinessEarlyClient { + + @Override + public R save(BusinessEarlyEntity entity) { + return R.status(false); + } +} \ No newline at end of file diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/IBusinessEarlyClient.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/IBusinessEarlyClient.java new file mode 100644 index 0000000..cfb3b93 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/IBusinessEarlyClient.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.business.feign; + +import com.hnac.hzims.alarm.config.constants.AlarmConstants; +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import org.springblade.core.tool.api.R; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; + +/** + * @author ysj + */ +@FeignClient( + value = AlarmConstants.APP_NAME, + fallback = BusinessEarlyClientFallback.class +) +public interface IBusinessEarlyClient { + + String API_PREFIX = "/feign/businessEarly"; + + String BUSINESS_EARLY_SAVE = API_PREFIX + "/save"; + + @PostMapping(BUSINESS_EARLY_SAVE) + R save(@RequestBody BusinessEarlyEntity entity); +} diff --git a/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/vo/BusinessEarlyVo.java b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/vo/BusinessEarlyVo.java new file mode 100644 index 0000000..7cda295 --- /dev/null +++ b/hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/vo/BusinessEarlyVo.java @@ -0,0 +1,20 @@ +package com.hnac.hzims.business.vo; + +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import io.swagger.annotations.ApiModel; +import lombok.Data; +import lombok.EqualsAndHashCode; + + +/** + * @author ysj + */ +@Data +@EqualsAndHashCode(callSuper = true) +@ApiModel(value = "告警对象", description = "各告警数据源保存对象") +public class BusinessEarlyVo extends BusinessEarlyEntity { + + private static final long serialVersionUID = 1L; + + +} \ No newline at end of file diff --git a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hazard/dto/HazardInstanceDTO.java b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hazard/dto/HazardInstanceDTO.java index f459815..6cbe9fb 100644 --- a/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hazard/dto/HazardInstanceDTO.java +++ b/hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hazard/dto/HazardInstanceDTO.java @@ -25,6 +25,9 @@ public class HazardInstanceDTO implements Serializable { @ApiModelProperty("设备名称") private String emName; + @ApiModelProperty(value = "应用类型") + private String applyType; + @ApiModelProperty("危险源列表") private List hazardList; diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/AlarmApplication.java similarity index 90% rename from hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java rename to hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/AlarmApplication.java index 9aa90e1..4e7c270 100644 --- a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/AlarmApplication.java @@ -1,4 +1,4 @@ -package com.hnac.hzims.alarm; +package com.hnac.hzims; import com.hnac.hzims.alarm.config.constants.AlarmConstants; import org.mybatis.spring.annotation.MapperScan; @@ -17,9 +17,10 @@ import javax.annotation.Resource; @EnableBladeFeign @SpringCloudApplication @MapperScan("com.hnac.hzims.**.mapper.**") -@ComponentScan(basePackages = {"com.hnac.hzims.alarm.*"}) +@ComponentScan(basePackages = {"com.hnac.hzims.alarm.*","com.hnac.hzims.business.*"}) @Resource public class AlarmApplication extends SpringBootServletInitializer { + public static void main(String[] args) { BladeApplication.run(AlarmConstants.APP_NAME, AlarmApplication.class, args); } diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/controller/BusinessEarlyController.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/controller/BusinessEarlyController.java new file mode 100644 index 0000000..f696b61 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/controller/BusinessEarlyController.java @@ -0,0 +1,41 @@ +package com.hnac.hzims.business.early.controller; + + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; +import com.hnac.hzims.business.early.service.BusinessEarlyService; +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import com.hnac.hzims.business.vo.BusinessEarlyVo; +import com.hnac.hzims.common.logs.annotation.OperationAnnotation; +import com.hnac.hzims.common.logs.enums.BusinessType; +import com.hnac.hzims.common.logs.enums.OperatorType; +import com.hnac.hzims.operational.access.vo.ConstructionVo; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import org.springblade.core.boot.ctrl.BladeController; +import org.springblade.core.mp.support.Condition; +import org.springblade.core.mp.support.Query; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author ysj + */ +@Api(tags = {"业务预警"}) +@RestController +@AllArgsConstructor +@RequestMapping("/business/early") +public class BusinessEarlyController extends BladeController { + + private final BusinessEarlyService businessEarlyService; + + @GetMapping("/list") + @ApiOperationSupport(order = 4) + @ApiOperation(value = "分页查询") + public R> list(BusinessEarlyVo early, Query query) { + return R.data(businessEarlyService.pageCondition(Condition.getPage(query), early)); + } +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/feign/BusinessEarlyClient.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/feign/BusinessEarlyClient.java new file mode 100644 index 0000000..6a60e98 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/feign/BusinessEarlyClient.java @@ -0,0 +1,33 @@ +package com.hnac.hzims.business.early.feign; + +import com.hnac.hzims.business.early.service.BusinessEarlyService; +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import com.hnac.hzims.business.feign.IBusinessEarlyClient; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.tool.api.R; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RestController; + +/** + * @author ysj + */ +@RestController +@Slf4j +@RequiredArgsConstructor +public class BusinessEarlyClient implements IBusinessEarlyClient { + + private final BusinessEarlyService businessEarlyService; + + /** + * 业务预警信息保存 + * @param entity + * @return + */ + @Override + @PostMapping(BUSINESS_EARLY_SAVE) + public R save(@RequestBody BusinessEarlyEntity entity) { + return R.status(businessEarlyService.save(entity)); + } +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.java new file mode 100644 index 0000000..0cbe996 --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.java @@ -0,0 +1,11 @@ +package com.hnac.hzims.business.early.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.hnac.hzims.business.entity.BusinessEarlyEntity; + +/** + * @author ysj + */ +public interface BusinessEarlyMapper extends BaseMapper { + +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.xml b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.xml new file mode 100644 index 0000000..7ccae0f --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/BusinessEarlyService.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/BusinessEarlyService.java new file mode 100644 index 0000000..507af9d --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/BusinessEarlyService.java @@ -0,0 +1,15 @@ +package com.hnac.hzims.business.early.service; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import com.hnac.hzims.business.vo.BusinessEarlyVo; +import com.hnac.hzims.operational.access.vo.ConstructionVo; +import org.springblade.core.mp.base.BaseService; + +/** + * @author ysj + */ +public interface BusinessEarlyService extends BaseService { + + IPage pageCondition(IPage page, BusinessEarlyVo early); +} diff --git a/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/impl/BusinessEarlyServiceImpl.java b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/impl/BusinessEarlyServiceImpl.java new file mode 100644 index 0000000..de0f0ad --- /dev/null +++ b/hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/impl/BusinessEarlyServiceImpl.java @@ -0,0 +1,25 @@ +package com.hnac.hzims.business.early.service.impl; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.hnac.hzims.business.early.mapper.BusinessEarlyMapper; +import com.hnac.hzims.business.early.service.BusinessEarlyService; +import com.hnac.hzims.business.entity.BusinessEarlyEntity; +import com.hnac.hzims.business.vo.BusinessEarlyVo; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springblade.core.mp.base.BaseServiceImpl; +import org.springframework.stereotype.Service; + +/** + * @author ysj + */ +@AllArgsConstructor +@Service +@Slf4j +public class BusinessEarlyServiceImpl extends BaseServiceImpl implements BusinessEarlyService { + + @Override + public IPage pageCondition(IPage page, BusinessEarlyVo early) { + return null; + } +} \ No newline at end of file diff --git a/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java b/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java index ffa0e00..0d3f950 100644 --- a/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java +++ b/hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java @@ -1,5 +1,6 @@ package com.hnac.hzims.alarm; +import com.hnac.hzims.AlarmApplication; import org.junit.jupiter.api.Test; import org.springframework.boot.test.context.SpringBootTest; diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/constants/RoleAliasConstants.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/constants/RoleAliasConstants.java new file mode 100644 index 0000000..33b75f2 --- /dev/null +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/constants/RoleAliasConstants.java @@ -0,0 +1,8 @@ +package com.hnac.hzims.operational.constants; + +public interface RoleAliasConstants { + + /**项目经理**/ + String PROJECT_MANAGER = "projectManager"; + +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java index 917c51c..4ae4917 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java @@ -7,6 +7,7 @@ import com.hnac.hzims.message.MessageConstants; import com.hnac.hzims.message.dto.BusinessMessageDTO; import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.operational.constants.RedisKeyConstants; +import com.hnac.hzims.operational.constants.RoleAliasConstants; import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.xxl.job.core.biz.model.ReturnT; @@ -90,7 +91,7 @@ public class MaintenanceTaskRemindHandler { XxlJobLogger.log(taskEntity.getId() +"执行人消息推送失败!"); } // 任务执行人发送短信 - R> listR = userClient.userByDeptId(CommonConstant.TENANT_ID, taskEntity.getCreateDept()); + R> listR = userClient.relationUserListByRoleAlias(CommonConstant.TENANT_ID, taskEntity.getCreateDept(), RoleAliasConstants.PROJECT_MANAGER); if(listR.isSuccess()) { request.setUserIds(listR.getData().stream().map(User::getId).map(String::valueOf).collect(Collectors.joining(","))); request.setContent("有一条待执行的日常维护任务【"+taskEntity.getTitle()+"】即将于"+ DateUtil.format(taskEntity.getPlanEndTime(),DateUtil.PATTERN_DATETIME) +"过期,请确认。"); diff --git a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/service/impl/DangerSourceServiceImpl.java b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/service/impl/DangerSourceServiceImpl.java index 6c666fe..d4a369c 100644 --- a/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/service/impl/DangerSourceServiceImpl.java +++ b/hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/service/impl/DangerSourceServiceImpl.java @@ -326,9 +326,16 @@ public class DangerSourceServiceImpl extends BaseServiceImpl sourceList = req.getHazardList().stream().map(h -> { DangerSourceEntity result = JSONObject.parseObject(JSON.toJSONString(h), DangerSourceEntity.class); + result.setId(null); result.setLibraryId(h.getId()); result.setRefDept(req.getDeptId()); result.setRefDeptName(req.getDeptName()); + result.setApplyType(req.getApplyType()); + result.setCreateTime(null); + result.setCreateDept(null); + result.setCreateUser(null); + result.setUpdateUser(null); + result.setUpdateTime(null); return result; }).collect(Collectors.toList()); return this.saveBatch(sourceList); diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java index 4f79472..d1ebfad 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java @@ -191,4 +191,11 @@ public class StandardTicketInfoController extends BladeController { public R> operate(OperateVo operate, Query query) { return R.data(standardTicketInfoService.operate(Condition.getPage(query),operate)); } + + @GetMapping("/exportOperateTicket") + @ApiOperation(value = "导出操作票") + @ApiOperationSupport(order = 12) + public void exportOperateTicket(HttpServletResponse response, @RequestParam Long ticketId) throws Exception { + standardTicketInfoService.exportOperateTicket(response,ticketId); + } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java index 6c98ccd..52a9e55 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java @@ -143,4 +143,11 @@ public interface IStandardTicketInfoService extends BaseService operate(IPage page,OperateVo operate); List exportStandardTicket(StandardTicketInfoDto entity); + + /** + * 导出操作票 + * @param response + * @param ticketId + */ + void exportOperateTicket(HttpServletResponse response, Long ticketId); } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java index f3b6699..524c43c 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java @@ -1,6 +1,7 @@ package com.hnac.hzims.ticket.standardTicket.service.impl; import cn.afterturn.easypoi.excel.entity.TemplateExportParams; +import cn.afterturn.easypoi.word.WordExportUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -8,6 +9,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.google.common.collect.Lists; import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity; import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; @@ -30,6 +32,7 @@ import com.hnac.hzims.ticket.standardTicket.wrapper.StandardTicketInfoWrapper; import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo; import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketMeasureVo; import com.hnac.hzims.ticket.twoTicket.vo.ticket.StandardTicketCountQueryVo; +import com.hnac.hzims.ticket.utils.AsposeUtil; import com.hnac.hzims.ticket.utils.ExcelUtil; import com.hnac.hzims.ticket.utils.PdfUtils; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; @@ -39,6 +42,7 @@ import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; 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.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseServiceImpl; @@ -64,6 +68,8 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.servlet.http.HttpServletResponse; +import java.io.FileOutputStream; +import java.io.IOException; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.LocalDateTime; @@ -73,6 +79,7 @@ import java.time.temporal.TemporalAdjusters; import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.stream.Collectors; +import java.util.stream.IntStream; /** * @author hx @@ -865,4 +872,69 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl params = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(detail); + params.put("measureMapList",this.convert(detail.getStandardTicketMeasureVOList())); + XWPFDocument xwpfDocument = null; + String fileName = "template/电气操作票.docx"; + try { + xwpfDocument = WordExportUtil.exportWord07(fileName, params); + } catch (Exception e) { + e.printStackTrace(); + } + String wordPath = this.getFileSavePath() + detail.getTitle() +".docx"; + try { + this.exportTicketWord(Lists.newArrayList(xwpfDocument),wordPath); + } catch (IOException e) { + throw new RuntimeException(e); + } + String pdfPath = this.getFileSavePath() + detail.getTitle() +".pdf"; + AsposeUtil.wordToPdf(wordPath,pdfPath); + PdfUtils.readPdf(response,pdfPath); + } + + private void exportTicketWord(List documents, String savePath) throws IOException { + FileOutputStream out = new FileOutputStream(savePath); + try { + for (XWPFDocument document : documents) { + document.write(out); + } + } + catch (Exception e) { + e.printStackTrace(); + } + finally { + out.close(); + } + } + + private String getFileSavePath() { + String os = System.getProperty("os.name").toLowerCase(); + if("linux".equals(os)) { + return pdfSavePath; + } + else { + return "E://template/"; + } + } + + private List convert (List list) { + if(CollectionUtil.isNotEmpty(list)) { + return IntStream.iterate(0, index -> index + 1).limit(list.size() > 25 ? list.size() : 25).mapToObj(index -> { + if(index <= list.size() - 1) { + Map result = com.hnac.hzims.ticket.utils.ObjectUtils.obj2Map(list.get(index)); + result.put("index",index + 1); + result.put("status",TicketConstants.MATTER_FINISH_STATUS == result.get("status") ? "√" : null); + return result; + } + else { + return new HashMap(); + } + }).collect(Collectors.toList()); + } + return IntStream.iterate(0,index -> index + 1).limit(4).mapToObj(index -> new HashMap()).collect(Collectors.toList()); + } } diff --git a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/ObjectUtils.java b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/ObjectUtils.java index e75fffc..c9cec46 100644 --- a/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/ObjectUtils.java +++ b/hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/ObjectUtils.java @@ -37,7 +37,7 @@ public class ObjectUtils { DateTimeToMap dateTimeToMap = field.getAnnotation(DateTimeToMap.class); LocalDateTime time = (LocalDateTime) value; if(ObjectUtil.isEmpty(dateTimeToMap)) { - result.put(field.getName(),time.format(DateUtil.TIME_FORMATTER)); + result.put(field.getName(),time.format(DateUtil.DATETIME_FORMATTER)); } else { result.putAll(LocalDateConvertMap(time,dateTimeToMap.prefix(),dateTimeToMap.split())); diff --git a/hzims-service/ticket/src/main/resources/template/电气操作票.docx b/hzims-service/ticket/src/main/resources/template/电气操作票.docx index 6ca4036..2a8cc1b 100644 Binary files a/hzims-service/ticket/src/main/resources/template/电气操作票.docx and b/hzims-service/ticket/src/main/resources/template/电气操作票.docx differ