Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
ty 11 months ago
parent
commit
d76bbb85f1
  1. 39
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/entity/BusinessEarlyEntity.java
  2. 17
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/BusinessEarlyClientFallback.java
  3. 25
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/feign/IBusinessEarlyClient.java
  4. 20
      hzims-service-api/alarm-api/src/main/java/com/hnac/hzims/business/vo/BusinessEarlyVo.java
  5. 3
      hzims-service-api/safeproduct-api/src/main/java/com/hnac/hzims/safeproduct/hazard/dto/HazardInstanceDTO.java
  6. 5
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/AlarmApplication.java
  7. 41
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/controller/BusinessEarlyController.java
  8. 33
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/feign/BusinessEarlyClient.java
  9. 11
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.java
  10. 6
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.xml
  11. 15
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/BusinessEarlyService.java
  12. 25
      hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/service/impl/BusinessEarlyServiceImpl.java
  13. 1
      hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java
  14. 8
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/constants/RoleAliasConstants.java
  15. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/scheduled/MaintenanceTaskRemindHandler.java
  16. 7
      hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/service/impl/DangerSourceServiceImpl.java
  17. 7
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java
  18. 7
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java
  19. 72
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java
  20. 2
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/utils/ObjectUtils.java
  21. BIN
      hzims-service/ticket/src/main/resources/template/电气操作票.docx

39
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;
}

17
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<Boolean> save(BusinessEarlyEntity entity) {
return R.status(false);
}
}

25
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<Boolean> save(@RequestBody BusinessEarlyEntity entity);
}

20
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;
}

3
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("设备名称") @ApiModelProperty("设备名称")
private String emName; private String emName;
@ApiModelProperty(value = "应用类型")
private String applyType;
@ApiModelProperty("危险源列表") @ApiModelProperty("危险源列表")
private List<HazardLibraryDTO> hazardList; private List<HazardLibraryDTO> hazardList;

5
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/alarm/AlarmApplication.java → 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 com.hnac.hzims.alarm.config.constants.AlarmConstants;
import org.mybatis.spring.annotation.MapperScan; import org.mybatis.spring.annotation.MapperScan;
@ -17,9 +17,10 @@ import javax.annotation.Resource;
@EnableBladeFeign @EnableBladeFeign
@SpringCloudApplication @SpringCloudApplication
@MapperScan("com.hnac.hzims.**.mapper.**") @MapperScan("com.hnac.hzims.**.mapper.**")
@ComponentScan(basePackages = {"com.hnac.hzims.alarm.*"}) @ComponentScan(basePackages = {"com.hnac.hzims.alarm.*","com.hnac.hzims.business.*"})
@Resource @Resource
public class AlarmApplication extends SpringBootServletInitializer { public class AlarmApplication extends SpringBootServletInitializer {
public static void main(String[] args) { public static void main(String[] args) {
BladeApplication.run(AlarmConstants.APP_NAME, AlarmApplication.class, args); BladeApplication.run(AlarmConstants.APP_NAME, AlarmApplication.class, args);
} }

41
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<IPage<BusinessEarlyVo>> list(BusinessEarlyVo early, Query query) {
return R.data(businessEarlyService.pageCondition(Condition.getPage(query), early));
}
}

33
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<Boolean> save(@RequestBody BusinessEarlyEntity entity) {
return R.status(businessEarlyService.save(entity));
}
}

11
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<BusinessEarlyEntity> {
}

6
hzims-service/hzims-alarm/src/main/java/com/hnac/hzims/business/early/mapper/BusinessEarlyMapper.xml

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hnac.hzims.business.early.mapper.BusinessEarlyMapper">
</mapper>

15
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<BusinessEarlyEntity> {
IPage<BusinessEarlyVo> pageCondition(IPage<BusinessEarlyVo> page, BusinessEarlyVo early);
}

25
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<BusinessEarlyMapper, BusinessEarlyEntity> implements BusinessEarlyService {
@Override
public IPage<BusinessEarlyVo> pageCondition(IPage<BusinessEarlyVo> page, BusinessEarlyVo early) {
return null;
}
}

1
hzims-service/hzims-alarm/src/test/java/com/hnac/hzims/alarm/MiddleApplicationTests.java

@ -1,5 +1,6 @@
package com.hnac.hzims.alarm; package com.hnac.hzims.alarm;
import com.hnac.hzims.AlarmApplication;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;

8
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";
}

3
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.dto.BusinessMessageDTO;
import com.hnac.hzims.message.fegin.IMessageClient; import com.hnac.hzims.message.fegin.IMessageClient;
import com.hnac.hzims.operational.constants.RedisKeyConstants; 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.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService; import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.xxl.job.core.biz.model.ReturnT; import com.xxl.job.core.biz.model.ReturnT;
@ -90,7 +91,7 @@ public class MaintenanceTaskRemindHandler {
XxlJobLogger.log(taskEntity.getId() +"执行人消息推送失败!"); XxlJobLogger.log(taskEntity.getId() +"执行人消息推送失败!");
} }
// 任务执行人发送短信 // 任务执行人发送短信
R<List<User>> listR = userClient.userByDeptId(CommonConstant.TENANT_ID, taskEntity.getCreateDept()); R<List<User>> listR = userClient.relationUserListByRoleAlias(CommonConstant.TENANT_ID, taskEntity.getCreateDept(), RoleAliasConstants.PROJECT_MANAGER);
if(listR.isSuccess()) { if(listR.isSuccess()) {
request.setUserIds(listR.getData().stream().map(User::getId).map(String::valueOf).collect(Collectors.joining(","))); 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) +"过期,请确认。"); request.setContent("有一条待执行的日常维护任务【"+taskEntity.getTitle()+"】即将于"+ DateUtil.format(taskEntity.getPlanEndTime(),DateUtil.PATTERN_DATETIME) +"过期,请确认。");

7
hzims-service/safeproduct/src/main/java/com/hnac/hzims/safeproduct/hazard/service/impl/DangerSourceServiceImpl.java

@ -326,9 +326,16 @@ public class DangerSourceServiceImpl extends BaseServiceImpl<DangerSourceMapper,
public Boolean importDangerSource(HazardInstanceDTO req) { public Boolean importDangerSource(HazardInstanceDTO req) {
List<DangerSourceEntity> sourceList = req.getHazardList().stream().map(h -> { List<DangerSourceEntity> sourceList = req.getHazardList().stream().map(h -> {
DangerSourceEntity result = JSONObject.parseObject(JSON.toJSONString(h), DangerSourceEntity.class); DangerSourceEntity result = JSONObject.parseObject(JSON.toJSONString(h), DangerSourceEntity.class);
result.setId(null);
result.setLibraryId(h.getId()); result.setLibraryId(h.getId());
result.setRefDept(req.getDeptId()); result.setRefDept(req.getDeptId());
result.setRefDeptName(req.getDeptName()); 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; return result;
}).collect(Collectors.toList()); }).collect(Collectors.toList());
return this.saveBatch(sourceList); return this.saveBatch(sourceList);

7
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<IPage<StandardTicketInfoVO>> operate(OperateVo operate, Query query) { public R<IPage<StandardTicketInfoVO>> operate(OperateVo operate, Query query) {
return R.data(standardTicketInfoService.operate(Condition.getPage(query),operate)); 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);
}
} }

7
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java

@ -143,4 +143,11 @@ public interface IStandardTicketInfoService extends BaseService<StandardTicketIn
IPage<StandardTicketInfoVO> operate(IPage<StandardTicketInfoEntity> page,OperateVo operate); IPage<StandardTicketInfoVO> operate(IPage<StandardTicketInfoEntity> page,OperateVo operate);
List<StandardTicketExportVO> exportStandardTicket(StandardTicketInfoDto entity); List<StandardTicketExportVO> exportStandardTicket(StandardTicketInfoDto entity);
/**
* 导出操作票
* @param response
* @param ticketId
*/
void exportOperateTicket(HttpServletResponse response, Long ticketId);
} }

72
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; package com.hnac.hzims.ticket.standardTicket.service.impl;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; 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.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; 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.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.entity.TicketInfoEvaluateEntity;
import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService; import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService;
import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO; 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.StandardTicketInfoVo;
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketMeasureVo; import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketMeasureVo;
import com.hnac.hzims.ticket.twoTicket.vo.ticket.StandardTicketCountQueryVo; 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.ExcelUtil;
import com.hnac.hzims.ticket.utils.PdfUtils; import com.hnac.hzims.ticket.utils.PdfUtils;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity; import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity;
@ -39,6 +42,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook; 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.log.exception.ServiceException;
import org.springblade.core.mp.base.BaseEntity; import org.springblade.core.mp.base.BaseEntity;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
@ -64,6 +68,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.math.RoundingMode; import java.math.RoundingMode;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -73,6 +79,7 @@ import java.time.temporal.TemporalAdjusters;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream;
/** /**
* @author hx * @author hx
@ -865,4 +872,69 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
return list; return list;
} }
} }
@Override
public void exportOperateTicket(HttpServletResponse response, Long ticketId) {
StandardTicketInfoVO detail = this.detail(ticketId).getData();
Map<String,Object> 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<XWPFDocument> 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<Map> convert (List<? extends Object> 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());
}
} }

2
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); DateTimeToMap dateTimeToMap = field.getAnnotation(DateTimeToMap.class);
LocalDateTime time = (LocalDateTime) value; LocalDateTime time = (LocalDateTime) value;
if(ObjectUtil.isEmpty(dateTimeToMap)) { if(ObjectUtil.isEmpty(dateTimeToMap)) {
result.put(field.getName(),time.format(DateUtil.TIME_FORMATTER)); result.put(field.getName(),time.format(DateUtil.DATETIME_FORMATTER));
} }
else { else {
result.putAll(LocalDateConvertMap(time,dateTimeToMap.prefix(),dateTimeToMap.split())); result.putAll(LocalDateConvertMap(time,dateTimeToMap.prefix(),dateTimeToMap.split()));

BIN
hzims-service/ticket/src/main/resources/template/电气操作票.docx

Binary file not shown.
Loading…
Cancel
Save