Browse Source

新增缺陷、巡检、两票、日常维护导出功能

zhongwei
tyty 1 year ago
parent
commit
4b340702c9
  1. 98
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/vo/OperDefectStatisticsExportVO.java
  2. 68
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/vo/MaintenanceExportVO.java
  3. 3
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/TaskContants.java
  4. 79
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/vo/InspectTaskExportVO.java
  5. 1
      hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java
  6. 37
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java
  7. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java
  8. 71
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java
  9. 53
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectStatisticsController.java
  10. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectStatisticsService.java
  11. 62
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java
  12. 42
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/OperMaintenanceTaskController.java
  13. 3
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java
  14. 48
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java
  15. 48
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java
  16. 6
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/IStandardTicketInfoService.java
  17. 48
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java
  18. 86
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/StandardTicketExportVO.java
  19. 52
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/controller/WorkTicketInfoController.java
  20. 3
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/IWorkTicketInfoService.java
  21. 41
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/impl/WorkTicketInfoServiceImpl.java
  22. 86
      hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/vo/WorkTicketExportVO.java

98
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/defect/vo/OperDefectStatisticsExportVO.java

@ -0,0 +1,98 @@
package com.hnac.hzims.operational.defect.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 模型VO
*
* @author Chill
*/
@Data
public class OperDefectStatisticsExportVO {
private static final long serialVersionUID = 8239436726489738763L;
@ExcelProperty(value = "序号", index = 0)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "序号")
private Integer number;
@ExcelProperty(value = "单位", index = 1)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "机构名称")
private String deptName;
@ExcelProperty(value = "缺陷编码", index = 2)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "缺陷编码")
private String defectCode;
@ExcelProperty(value = "记录人", index = 3)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "缺陷发现人")
private String finderName;
@ApiModelProperty("记录时间")
@ExcelProperty(value = "记录时间", index = 4)
@ColumnWidth(value = 20)
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
private Date findTime;
@ExcelProperty(value = "缺陷描述", index = 5)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "现象描述")
private String descripiton;
@ExcelProperty(value = "缺陷等级", index = 6)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "缺陷等级, 字段key: defectLevel")
private String defectLevel;
@ExcelProperty(value = "处理时间", index = 7)
@ColumnWidth(value = 20)
@DateTimeFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@JsonFormat(
pattern = "yyyy-MM-dd HH:mm:ss"
)
@ApiModelProperty(value = "处理时间")
private Date actStartTime;
@ExcelProperty(value = "处理人", index = 8)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "消缺处理人")
private String planHandler;
// @ExcelIgnore
// @ApiModelProperty(value = "消缺处理人")
// private String planHandlerId;
@ExcelProperty(value = "处理结果", index = 9)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "处理描述")
private String disposeDesc;
@ExcelProperty(value = "关联工作票编码", index = 10)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "操作票")
private String ticketId;
}

68
hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/maintenance/vo/MaintenanceExportVO.java

@ -0,0 +1,68 @@
package com.hnac.hzims.operational.maintenance.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @author hx
*/
@Data
public class MaintenanceExportVO {
@ExcelProperty(value = "序号", index = 0)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "序号")
private Integer number;
@ExcelProperty(value = "单位", index = 1)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "单位")
private String company;
@ExcelProperty(value = "维护类型", index = 2)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "维护类型")
private String typeCode;
@ExcelProperty(value = "维护设备", index = 3)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "维护设备")
private String refLibraryId;
@ApiModelProperty("维护内容")
@ExcelProperty(value = "维护内容", index = 4)
@ColumnWidth(value = 20)
private String title;
@ExcelProperty(value = "计划执行时间", index = 5)
@ColumnWidth(value = 20)
@ApiModelProperty("计划执行时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String planEndTime;
@ExcelProperty(value = "实际执行时间", index = 6)
@ColumnWidth(value = 20)
@ApiModelProperty("实际执行时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String executeTime;
@ExcelProperty(value = "执行人", index = 7)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "执行人")
private String disposer;
@ExcelProperty(value = "执行情况", index = 8)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "执行情况")
private String principal;
}

3
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/TaskContants.java

@ -13,7 +13,8 @@ public interface TaskContants {
// 巡检任务派发
String INSPECT_TASK_DISTRIBUTE = "taskJobDistribute";
String INSPECT_DATE_PATTERN = "yyyy年MM月dd日 HH时mm分";
String TASK_STATUS = "taskStatus";
// 日常维护任务派发
String MAINTENANCE_TASK_DISTRIBUTE = "maintenanceTaskDistribute";

79
hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/vo/InspectTaskExportVO.java

@ -0,0 +1,79 @@
package com.hnac.hzinfo.inspect.task.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @author hx
*/
@Data
public class InspectTaskExportVO {
@ExcelProperty(value = "序号", index = 0)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "序号")
private Integer number;
@ExcelProperty(value = "单位", index = 1)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "单位")
private String company;
@ExcelProperty(value = "巡检名称", index = 2)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "巡检名称")
private String planName;
@ExcelProperty(value = "计划开始时间", index = 3)
@ColumnWidth(value = 20)
@ApiModelProperty("计划开始时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String planStartTime;
@ExcelProperty(value = "计划结束时间", index = 4)
@ColumnWidth(value = 20)
@ApiModelProperty("计划结束时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String planEndTime;
@ExcelProperty(value = "实际开始时间", index = 5)
@ColumnWidth(value = 20)
@ApiModelProperty("实际开始时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String startTime;
@ExcelProperty(value = "实际结束时间", index = 6)
@ColumnWidth(value = 20)
@ApiModelProperty("实际结束时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String endTime;
@ApiModelProperty("巡检时长(分钟)")
@ExcelProperty(value = "巡检时长(分钟)", index = 7)
@ColumnWidth(value = 20)
private Long inspectTime;
@ApiModelProperty("巡检人")
@ExcelProperty(value = "巡检人", index = 8)
@ColumnWidth(value = 20)
private String userName;
@ApiModelProperty("巡检情况")
@ExcelProperty(value = "巡检情况", index = 9)
@ColumnWidth(value = 20)
private String content;
@ApiModelProperty("巡检状态")
@ExcelProperty(value = "巡检状态", index = 10)
@ColumnWidth(value = 20)
private String status;
}

1
hzims-service-api/ticket-api/src/main/java/com/hnac/hzims/ticket/constants/TicketConstants.java

@ -13,6 +13,7 @@ public interface TicketConstants {
String APP_NAME = "hzims-ticket";
String TICKET_DATE_PATTERN = "yyyy年MM月dd日 HH时mm分";
String TICKET_TYPE = "ticketType";
Integer MATTER_FINISH_STATUS = 2;

37
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.task.controller;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@ -23,6 +24,7 @@ import com.hnac.hzinfo.inspect.task.entity.TaskUserEntity;
import com.hnac.hzinfo.inspect.task.service.IEventService;
import com.hnac.hzinfo.inspect.task.service.ITaskService;
import com.hnac.hzinfo.inspect.task.service.ITaskUserService;
import com.hnac.hzinfo.inspect.task.vo.InspectTaskExportVO;
import com.hnac.hzinfo.inspect.task.vo.TaskListQuery;
import com.hnac.hzinfo.inspect.task.vo.TaskObjectVO;
import com.hnac.hzinfo.inspect.task.vo.TaskVo;
@ -143,6 +145,41 @@ public class TaskController extends BladeController {
return R.data(bladePage);
}
/**
* 巡检任务导出
*/
@PostMapping("/exportTaskList")
@ApiOperation(value = "巡检任务导出", notes = "传入计划id")
public void exportTaskList(HttpServletResponse response,@RequestBody TaskDTO task) {
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
String fileName = URLEncoder.encode("巡检任务报表", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
List<InspectTaskExportVO> list = taskService.exportTaskList(task);
if(list!=null && list.size()>0){
System.out.println("---------------- size = " + list.size());
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), InspectTaskExportVO.class).autoCloseStream(Boolean.FALSE).sheet("巡检任务报表")
.doWrite(list);
}
} catch (Exception e) {
System.out.println("exportExcel = " + e.toString());
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
Map<String, String> map = new HashMap<>();
map.put("isSuccess", "false");
map.put("msg", "巡检任务报表" + e.getMessage());
try {
response.getWriter().println(JSONUtils.toJSONString(map));
} catch (IOException e3) {
throw new ServiceException( "发生异常 :" + e.toString());
}
}
}
@GetMapping("/mainQueryPage")
@ApiOperation(value = "首页当班任务统计中巡检任务查询", notes = "首页当班任务统计中巡检任务查询")
public R<IPage<TaskVo>> mainQueryPage(TaskListQuery task, Query query) {

2
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java

@ -190,4 +190,6 @@ public interface ITaskService extends BaseService<TaskEntity> {
BladePage<TaskVo> selectPage(Page<TaskEntity> pageInfo, TaskListQuery task);
List<VoteChartVo> getTaskListStatistics(String startTime, String endTime,Long deptId);
List<InspectTaskExportVO> exportTaskList(TaskDTO task);
}

71
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java

@ -529,14 +529,24 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
query.setCurrent(taskDTO.getCurrent());
TaskEntity request = BeanUtil.copy(taskDTO,TaskEntity.class);
LambdaQueryWrapper<TaskEntity> queryWrapper = Condition.getQueryWrapper(TaskEntity.class,request);
getQueryWrapper(taskDTO, queryWrapper);
IPage page = this.page(Condition.getPage(query), queryWrapper);
List<TaskEntity> records = page.getRecords();
List<TaskVo> taskVos = getTaskVos(records);
page.setRecords(taskVos);
return page;
}
private void getQueryWrapper(TaskDTO taskDTO, LambdaQueryWrapper<TaskEntity> queryWrapper) {
queryWrapper.ge(Func.isNotEmpty(taskDTO.getPlanStartTime()),TaskEntity::getPlanStartTime, taskDTO.getPlanStartTime());
queryWrapper.le(Func.isNotEmpty(taskDTO.getPlanStartTimeEnd()),TaskEntity::getPlanStartTime, taskDTO.getPlanStartTimeEnd());
queryWrapper.eq(Func.isNotEmpty(taskDTO.getCreateDept()),TaskEntity::getCreateDept, taskDTO.getCreateDept());
queryWrapper.eq(Func.isNotEmpty(taskDTO.getStatus()),TaskEntity::getStatus, taskDTO.getStatus());
queryWrapper.in(Func.isNotEmpty(taskDTO.getIds()),TaskEntity::getId, taskDTO.getIds());
queryWrapper.orderByDesc(TaskEntity::getCreateTime);
IPage page = this.page(Condition.getPage(query), queryWrapper);
List<TaskEntity> records = page.getRecords();
}
private List<TaskVo> getTaskVos(List<TaskEntity> records) {
List<TaskVo> taskVos = records.stream().map(task -> {
TaskVo taskVo = BeanUtil.copy(task, TaskVo.class);
// 补充巡检任务人员
@ -562,8 +572,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
}
return taskVo;
}).collect(Collectors.toList());
page.setRecords(taskVos);
return page;
return taskVos;
}
@Override
@ -1008,6 +1017,60 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
return res;
}
@Override
public List<InspectTaskExportVO> exportTaskList(TaskDTO task) {
TaskEntity request = BeanUtil.copy(task,TaskEntity.class);
LambdaQueryWrapper<TaskEntity> queryWrapper = Condition.getQueryWrapper(TaskEntity.class,request);
getQueryWrapper(task, queryWrapper);
List<TaskEntity> taskEntities = super.baseMapper.selectList(queryWrapper);
List<InspectTaskExportVO> list=new ArrayList<>();
if (CollectionUtils.isNotEmpty(taskEntities)){
List<TaskVo> taskVos = getTaskVos(taskEntities);
for (int i = 0; i < taskVos.size(); i++) {
InspectTaskExportVO resEntity=new InspectTaskExportVO();
TaskVo taskVo = taskVos.get(i);
resEntity.setNumber(i+1);
if (ObjectUtil.isNotEmpty(taskVo.getCreateDept())){
R<Dept> dept = sysClient.getDept(taskVo.getCreateDept());
if (dept.isSuccess()&&ObjectUtil.isNotEmpty(dept.getData())){
resEntity.setCompany(Optional.ofNullable(dept.getData().getDeptName()).orElse(""));
}
}
resEntity.setPlanName(Optional.ofNullable( taskVo.getPlanName().toString()).orElse(""));
if (ObjectUtil.isNotEmpty(taskVo.getPlanStartTime())){
resEntity.setPlanStartTime(Optional.ofNullable(DateUtil.format(taskVo.getPlanStartTime(),TaskContants.INSPECT_DATE_PATTERN)).orElse(""));
}
if (ObjectUtil.isNotEmpty(taskVo.getPlanEndTime())){
resEntity.setPlanEndTime(Optional.ofNullable(DateUtil.format(taskVo.getPlanEndTime(),TaskContants.INSPECT_DATE_PATTERN)).orElse(""));
}
if (ObjectUtil.isNotEmpty(taskVo.getStartTime())){
resEntity.setStartTime(Optional.ofNullable(DateUtil.format(taskVo.getStartTime(),TaskContants.INSPECT_DATE_PATTERN)).orElse(""));
}
if (ObjectUtil.isNotEmpty(taskVo.getEndTime())){
resEntity.setEndTime(Optional.ofNullable(DateUtil.format(taskVo.getEndTime(),TaskContants.INSPECT_DATE_PATTERN)).orElse(""));
}
if (ObjectUtil.isNotEmpty(taskVo.getStartTime())&&ObjectUtil.isNotEmpty(taskVo.getEndTime())) {
long l = DateUtil.between(taskVo.getStartTime(), taskVo.getEndTime()).toMinutes();
resEntity.setInspectTime(Optional.ofNullable(l).orElse(0L));
}
LambdaQueryWrapper<EventEntity> queryWrapper2 = Wrappers.<EventEntity>lambdaQuery().eq(EventEntity::getTaskId,taskVo.getId()).orderByDesc(EventEntity::getCreateTime);
List<EventEntity> eventEntities = eventService.list(queryWrapper2 );
List<String> collect = eventEntities.stream().map(EventEntity::getIsProblem).collect(Collectors.toList());
if (collect.contains("1")) {
resEntity.setContent("不正常");
}else {
resEntity.setContent("正常");
}
resEntity.setUserName(Optional.ofNullable( taskVo.getUserNames()).orElse(""));
resEntity.setStatus(Optional.ofNullable(DictCache.getValue(TaskContants.TASK_STATUS, taskVo.getStatus())).orElse(""));
list.add(resEntity);
}
}
return list;
}
/**
* 巡检任务分页
*

53
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/controller/OperDefectStatisticsController.java

@ -1,5 +1,7 @@
package com.hnac.hzims.operational.defect.controller;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@ -9,6 +11,7 @@ import com.hnac.hzims.common.logs.enums.OperatorType;
import com.hnac.hzims.operational.defect.dto.OperDefectStatisticsDTO;
import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity;
import com.hnac.hzims.operational.defect.service.IOperDefectStatisticsService;
import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsExportVO;
import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsVO;
import com.hnac.hzims.operational.defect.vo.StatistictCountVo;
import com.hnac.hzims.operational.defect.wrapper.OperDefectStatisticsWrapper;
@ -19,6 +22,7 @@ import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
@ -28,7 +32,12 @@ import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
@ -89,6 +98,50 @@ public class OperDefectStatisticsController extends BladeController {
}
/**
* 分页 代码自定义代号
*/
@ApiLog
@PostMapping("/exportDefectList")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "缺陷数据导出", notes = "传入statistics")
@ApiImplicitParams({
})
@OperationAnnotation(moduleName = "缺陷数据导出",title = "缺陷数据导出",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action
= "缺陷数据导出")
public void exportDefectList(HttpServletResponse response,@RequestBody OperDefectStatisticsVO entity) {
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
String fileName = URLEncoder.encode("缺陷统计报表", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
LambdaQueryWrapper<OperDefectStatisticsEntity> queryWrapper = statisticsService.getQueryWrapper(entity);
List<OperDefectStatisticsEntity> list = statisticsService.list(queryWrapper);
List<OperDefectStatisticsExportVO> defectStatisticsExportVO = statisticsService.getDefectStatisticsExportVO(list);
if(defectStatisticsExportVO!=null && defectStatisticsExportVO.size()>0){
System.out.println("---------------- size = " + defectStatisticsExportVO.size());
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), OperDefectStatisticsExportVO.class).autoCloseStream(Boolean.FALSE).sheet("缺陷统计报表")
.doWrite(defectStatisticsExportVO);
}
} catch (Exception e) {
System.out.println("exportExcel = " + e.toString());
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
Map<String, String> map = new HashMap<>();
map.put("isSuccess", "false");
map.put("msg", "缺陷统计报表详细信息导出失败" + e.getMessage());
try {
response.getWriter().println(JSONUtils.toJSONString(map));
} catch (IOException e3) {
throw new ServiceException( "发生异常 :" + e.toString());
}
}
}
/**
* 获取设备缺陷统计数据
*/
@ApiLog

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/IOperDefectStatisticsService.java

@ -3,6 +3,7 @@ package com.hnac.hzims.operational.defect.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.hnac.hzims.operational.defect.dto.OperDefectStatisticsDTO;
import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity;
import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsExportVO;
import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsVO;
import com.hnac.hzims.operational.defect.vo.StatistictCountVo;
import org.springblade.core.mp.base.BaseService;
@ -31,5 +32,5 @@ public interface IOperDefectStatisticsService extends BaseService<OperDefectStat
*/
List<StatistictCountVo> defectStatistictCount();
List<OperDefectStatisticsExportVO> getDefectStatisticsExportVO(List<OperDefectStatisticsEntity> list);
}

62
hzims-service/operational/src/main/java/com/hnac/hzims/operational/defect/service/impl/OperDefectStatisticsServiceImpl.java

@ -1,22 +1,26 @@
package com.hnac.hzims.operational.defect.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.hnac.hzims.operational.defect.constants.DefectConstant;
import com.hnac.hzims.operational.defect.dto.OperDefectStatisticsDTO;
import com.hnac.hzims.operational.defect.entity.OperDefectStatisticsEntity;
import com.hnac.hzims.operational.defect.mapper.OperDefectStatisticsMapper;
import com.hnac.hzims.operational.defect.service.IOperDefectStatisticsService;
import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsExportVO;
import com.hnac.hzims.operational.defect.vo.OperDefectStatisticsVO;
import com.hnac.hzims.operational.defect.vo.StatistictCount;
import com.hnac.hzims.operational.defect.vo.StatistictCountVo;
import com.hnac.hzims.operational.report.service.IDeptService;
import org.apache.commons.lang3.math.NumberUtils;
import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func;
import org.springblade.system.cache.DictCache;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -34,7 +38,8 @@ public class OperDefectStatisticsServiceImpl extends BaseServiceImpl<OperDefectS
@Autowired
private ISysClient sysClient;
@Autowired
private IUserClient userClient;
/**
* 获取设备缺陷统计数据
@ -145,4 +150,55 @@ public class OperDefectStatisticsServiceImpl extends BaseServiceImpl<OperDefectS
}
@Override
public List<OperDefectStatisticsExportVO> getDefectStatisticsExportVO(List<OperDefectStatisticsEntity> list) {
List<OperDefectStatisticsExportVO> res=new ArrayList<>();
if(list!=null && list.size()>0){
for (int i = 0; i < list.size(); i++) {
OperDefectStatisticsExportVO operDefectStatisticsExportVO = new OperDefectStatisticsExportVO();
operDefectStatisticsExportVO.setNumber(i+1);
OperDefectStatisticsEntity entity = list.get(i);
Long createDept = entity.getCreateDept();
R<Dept> dept = sysClient.getDept(createDept);
if (dept.isSuccess()&& ObjectUtils.isNotEmpty(dept.getData())){
operDefectStatisticsExportVO.setDeptName(dept.getData().getDeptName());
}
operDefectStatisticsExportVO.setDefectCode(entity.getDefectCode());
if (ObjectUtils.isNotEmpty(entity.getFinder())) {
R<User> finderUser = userClient.userInfoById(entity.getFinder());
if (finderUser.isSuccess() && ObjectUtils.isNotEmpty(finderUser.getData())) {
operDefectStatisticsExportVO.setFinderName(finderUser.getData().getName());
}
}
if (StringUtils.isNotBlank(entity.getPlanHandler())) {
R<User> planHandlerUser = userClient.userInfoById(Long.valueOf(entity.getPlanHandler()));
if (planHandlerUser.isSuccess() && ObjectUtils.isNotEmpty(planHandlerUser.getData())) {
operDefectStatisticsExportVO.setPlanHandler(planHandlerUser.getData().getName());
}
}
if (ObjectUtils.isNotEmpty(entity.getFindTime())) {
operDefectStatisticsExportVO.setFindTime(entity.getFindTime());
}
if (StringUtils.isNotBlank(entity.getDescripiton())) {
operDefectStatisticsExportVO.setDescripiton(entity.getDescripiton());
}
if (StringUtils.isNotBlank(entity.getDefectLevel())) {
String level = DictCache.getValue("defectLevel",entity.getDefectLevel());
operDefectStatisticsExportVO.setDefectLevel(level);
}
if (ObjectUtils.isNotEmpty(entity.getActStartTime())) {
operDefectStatisticsExportVO.setActStartTime(entity.getActStartTime());
}
if (StringUtils.isNotBlank(entity.getDisposeDesc())) {
operDefectStatisticsExportVO.setDisposeDesc(entity.getDisposeDesc());
}
if (StringUtils.isNotBlank(entity.getTicketId())) {
operDefectStatisticsExportVO.setTicketId(entity.getTicketId());
}
res.add(operDefectStatisticsExportVO);
}
}
return res;
}
}

42
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/controller/OperMaintenanceTaskController.java

@ -1,5 +1,6 @@
package com.hnac.hzims.operational.maintenance.controller;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -15,6 +16,7 @@ import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.scheduled.MaintenanceTaskCreateTask;
import com.hnac.hzims.operational.maintenance.scheduled.MaintenanceTaskPushMsg;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.maintenance.vo.MaintenanceExportVO;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO;
import com.hnac.hzims.vo.VoteChartVo;
import io.swagger.annotations.Api;
@ -40,6 +42,7 @@ import javax.validation.Valid;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@ -117,7 +120,44 @@ public class OperMaintenanceTaskController extends BladeController {
public R<IPage<OperMaintenanceTaskVO>> list(@RequestBody OperMaintenanceTaskDTO req) {
return taskService.list(req);
}
@ApiLog
@PostMapping("/exportMaintenance")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "日常维护记录导出")
@ApiImplicitParams({
})
@OperationAnnotation(moduleName = "日常维护记录导出",title = "日常维护记录导出",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action
= "日常维护记录导出")
public void exportMaintenance(HttpServletResponse response,@RequestBody OperMaintenanceTaskDTO req) {
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
String fileName = URLEncoder.encode("日常维护记录统计报表", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
List<MaintenanceExportVO> list = taskService.exportMaintenance(req);
if(list!=null && list.size()>0){
System.out.println("---------------- size = " + list.size());
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), MaintenanceExportVO.class).autoCloseStream(Boolean.FALSE).sheet("日常维护记录统计")
.doWrite(list);
}
} catch (Exception e) {
System.out.println("exportExcel = " + e.toString());
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
Map<String, String> map = new HashMap<>();
map.put("isSuccess", "false");
map.put("msg", "日常维护记录统计报表导出失败" + e.getMessage());
try {
response.getWriter().println(JSONUtils.toJSONString(map));
} catch (IOException e3) {
throw new ServiceException( "发生异常 :" + e.toString());
}
}
}
@GetMapping("/testCreateTask")
@ApiOperationSupport(order = 60)

3
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/IOperMaintenanceTaskService.java

@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hnac.hzims.operational.main.vo.RegularWorkVO;
import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.vo.MaintenanceExportVO;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO;
import com.hnac.hzims.operational.report.vo.MaintenanceReportVO;
import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo;
@ -97,4 +98,6 @@ public interface IOperMaintenanceTaskService extends BaseService<OperMaintenance
List<VoteChartVo> getMaintenanceListStatistics(String startTime, String endTime,Long deptId);
List<MaintenanceExportVO> exportMaintenance(OperMaintenanceTaskDTO req);
}

48
hzims-service/operational/src/main/java/com/hnac/hzims/operational/maintenance/service/impl/OperMaintenanceTaskServiceImpl.java

@ -18,6 +18,7 @@ import com.hnac.hzims.operational.maintenance.dto.OperMaintenanceTaskDTO;
import com.hnac.hzims.operational.maintenance.entity.OperMaintenanceTaskEntity;
import com.hnac.hzims.operational.maintenance.mapper.OperMaintenanceTaskMapper;
import com.hnac.hzims.operational.maintenance.service.IOperMaintenanceTaskService;
import com.hnac.hzims.operational.maintenance.vo.MaintenanceExportVO;
import com.hnac.hzims.operational.maintenance.vo.OperMaintenanceTaskVO;
import com.hnac.hzims.operational.maintenance.wrapper.OperMaintenanceTaskWrapper;
import com.hnac.hzims.operational.report.vo.MaintenanceReportVO;
@ -25,6 +26,7 @@ import com.hnac.hzims.safeproduct.Constants;
import com.hnac.hzims.safeproduct.feign.IDangerSourceClient;
import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskVo;
import com.hnac.hzims.ticket.areamonthly.vo.MaintenanceTaskWithAreaVo;
import com.hnac.hzims.ticket.constants.TicketConstants;
import com.hnac.hzims.vo.SafeCheckStatisticVO;
import com.hnac.hzims.vo.VoteChartVo;
import lombok.RequiredArgsConstructor;
@ -95,6 +97,13 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl<OperMaintena
Query query=new Query();
query.setSize(req.getSize());
query.setCurrent(req.getCurrent());
Wrapper<OperMaintenanceTaskEntity> queryWrapper = getQueryWrapper(req);
IPage pages = super.page(Condition.getPage(query), queryWrapper);
pages.setRecords(OperMaintenanceTaskWrapper.build().listVO(pages.getRecords()));
return R.data(pages);
}
private static Wrapper<OperMaintenanceTaskEntity> getQueryWrapper(OperMaintenanceTaskDTO req) {
Wrapper<OperMaintenanceTaskEntity> queryWrapper = new LambdaQueryWrapper<OperMaintenanceTaskEntity>() {{
orderByDesc(OperMaintenanceTaskEntity::getDisposeTime);
if (StringUtil.isNotBlank(req.getTaskIds())) {
@ -141,10 +150,7 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl<OperMaintena
eq(OperMaintenanceTaskEntity::getFlowTaskName, req.getFlowTaskName());
}
}};
IPage pages = super.page(Condition.getPage(query), queryWrapper);
pages.setRecords(OperMaintenanceTaskWrapper.build().listVO(pages.getRecords()));
return R.data(pages);
return queryWrapper;
}
@Override
@ -446,6 +452,40 @@ public class OperMaintenanceTaskServiceImpl extends BaseServiceImpl<OperMaintena
return res;
}
@Override
public List<MaintenanceExportVO> exportMaintenance(OperMaintenanceTaskDTO req) {
Wrapper<OperMaintenanceTaskEntity> queryWrapper = getQueryWrapper(req);
List<OperMaintenanceTaskEntity> maintenanceTaskEntities = super.baseMapper.selectList(queryWrapper);
List<MaintenanceExportVO> list=new ArrayList<>();
if (CollectionUtil.isNotEmpty(maintenanceTaskEntities)){
List<OperMaintenanceTaskVO> operMaintenanceTaskVOS = OperMaintenanceTaskWrapper.build().listVO(maintenanceTaskEntities);
for (int i = 0; i < operMaintenanceTaskVOS.size(); i++) {
MaintenanceExportVO resEntity=new MaintenanceExportVO();
OperMaintenanceTaskVO maintenanceTaskVO = operMaintenanceTaskVOS.get(i);
resEntity.setNumber(i+1);
if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getCreateDept())){
R<Dept> dept = sysClient.getDept(maintenanceTaskVO.getCreateDept());
if (dept.isSuccess()&&ObjectUtil.isNotEmpty(dept.getData())){
resEntity.setCompany(Optional.ofNullable(dept.getData().getDeptName()).orElse(""));
}
}
resEntity.setTypeCode(Optional.ofNullable(DictCache.getValue(DictConstant.MAINTENANCE_TYPE_CODE, maintenanceTaskVO.getTypeCode())).orElse(""));
resEntity.setRefLibraryId(Optional.ofNullable( maintenanceTaskVO.getRefLibraryId().toString()).orElse(""));
resEntity.setTitle(Optional.ofNullable( maintenanceTaskVO.getTitle()).orElse(""));
if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getPlanEndTime())) {
resEntity.setPlanEndTime(Optional.ofNullable(DateUtil.format(maintenanceTaskVO.getPlanEndTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse(""));
}
if (ObjectUtil.isNotEmpty(maintenanceTaskVO.getExecuteTime())) {
resEntity.setExecuteTime(Optional.ofNullable(DateUtil.format(maintenanceTaskVO.getExecuteTime(), TicketConstants.TICKET_DATE_PATTERN)).orElse(""));
}
resEntity.setDisposer(Optional.ofNullable(maintenanceTaskVO.getDisposerName()).orElse(""));
resEntity.setPrincipal(Optional.ofNullable(maintenanceTaskVO.getContent()).orElse(""));
list.add(resEntity);
}
}
return list;
}
private VoteChartVo getVoteChartVo(List<OperMaintenanceTaskEntity> list) {
VoteChartVo voteChartVo = new VoteChartVo();
List<Long> finishIds = Optional.ofNullable(list).orElse(new ArrayList<>()).stream().filter(s -> s.getStatus() == 3).map(s -> s.getId()).collect(Collectors.toList());

48
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/controller/StandardTicketInfoController.java

@ -1,5 +1,7 @@
package com.hnac.hzims.ticket.standardTicket.controller;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@ -7,20 +9,22 @@ import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
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.ticket.areamonthly.vo.AreaMonthlyVo;
import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketVo;
import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketWithAreaVo;
import com.hnac.hzims.ticket.standardTicket.dto.StandardTicketInfoDto;
import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity;
import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService;
import com.hnac.hzims.ticket.standardTicket.vo.OperateVo;
import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketExportVO;
import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.BladePage;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
@ -33,6 +37,9 @@ import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -86,6 +93,45 @@ public class StandardTicketInfoController extends BladeController {
return standardTicketInfoService.queryList(req, query);
}
@ApiLog
@PostMapping("/exportStandardTicket")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "操作票导出")
@ApiImplicitParams({
})
@OperationAnnotation(moduleName = "操作票导出",title = "操作票导出",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action
= "操作票导出")
public void exportStandardTicket(HttpServletResponse response,@RequestBody StandardTicketInfoDto req) {
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
String fileName = URLEncoder.encode("操作票统计报表", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
List<StandardTicketExportVO> list = standardTicketInfoService.exportStandardTicket(req);
if(list!=null && list.size()>0){
System.out.println("---------------- size = " + list.size());
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), StandardTicketExportVO.class).autoCloseStream(Boolean.FALSE).sheet("操作票统计报表")
.doWrite(list);
}
} catch (Exception e) {
System.out.println("exportExcel = " + e.toString());
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
Map<String, String> map = new HashMap<>();
map.put("isSuccess", "false");
map.put("msg", "操作票统计报表导出失败" + e.getMessage());
try {
response.getWriter().println(JSONUtils.toJSONString(map));
} catch (IOException e3) {
throw new ServiceException( "发生异常 :" + e.toString());
}
}
}
@PostMapping("/list")
@ApiOperationSupport(order = 60)
@ApiOperation(value = "分页")

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

@ -9,10 +9,10 @@ import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketWithAreaVo;
import com.hnac.hzims.ticket.standardTicket.dto.StandardTicketInfoDto;
import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketInfoEntity;
import com.hnac.hzims.ticket.standardTicket.vo.OperateVo;
import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketExportVO;
import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO;
import com.hnac.hzims.ticket.twoTicket.vo.ticket.StandardTicketCountQueryVo;
import com.hnac.hzims.ticket.twoTicket.vo.ticket.TicketCountQueryVo;
import com.hnac.hzims.ticket.twoTicket.vo.operation.StandardTicketInfoVo;
import com.hnac.hzims.ticket.twoTicket.vo.ticket.StandardTicketCountQueryVo;
import com.hnac.hzims.ticket.workTicket.vo.TicketMonthVO;
import org.springblade.core.mp.base.BaseService;
import org.springblade.core.mp.support.BladePage;
@ -141,4 +141,6 @@ public interface IStandardTicketInfoService extends BaseService<StandardTicketIn
IPage<StandardTicketInfoVO> listByOperationTicketWithKeyword(Page<StandardTicketInfoEntity> entityPage, StandardTicketCountQueryVo ticketCountQueryVo);
IPage<StandardTicketInfoVO> operate(IPage<StandardTicketInfoEntity> page,OperateVo operate);
List<StandardTicketExportVO> exportStandardTicket(StandardTicketInfoDto entity);
}

48
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/service/impl/StandardTicketInfoServiceImpl.java

@ -1,7 +1,6 @@
package com.hnac.hzims.ticket.standardTicket.service.impl;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -9,7 +8,6 @@ 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.hnac.hzims.operational.access.entity.OperAccessTaskEntity;
import com.hnac.hzims.ticket.allTicket.entity.TicketInfoEvaluateEntity;
import com.hnac.hzims.ticket.allTicket.service.TicketInfoEvaluateService;
import com.hnac.hzims.ticket.allTicket.vo.DoublePassRateVO;
@ -26,10 +24,7 @@ import com.hnac.hzims.ticket.standardTicket.entity.StandardTicketMeasureEntity;
import com.hnac.hzims.ticket.standardTicket.mapper.StandardTicketInfoMapper;
import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketInfoService;
import com.hnac.hzims.ticket.standardTicket.service.IStandardTicketMeasureService;
import com.hnac.hzims.ticket.standardTicket.vo.OperateTicketStatisticVO;
import com.hnac.hzims.ticket.standardTicket.vo.OperateVo;
import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO;
import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketMeasureVO;
import com.hnac.hzims.ticket.standardTicket.vo.*;
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;
@ -52,7 +47,10 @@ import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.BladeUser;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springblade.core.tool.utils.CollectionUtil;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.core.tool.utils.Func;
import org.springblade.core.tool.utils.ObjectUtil;
import org.springblade.flow.core.feign.IFlowClient;
import org.springblade.flow.core.vo.ComleteTask;
import org.springblade.system.cache.DictCache;
@ -796,4 +794,40 @@ public class StandardTicketInfoServiceImpl extends BaseServiceImpl<StandardTicke
pages.setRecords(StandardTicketInfoWrapper.build().listVO(pages.getRecords()));
return pages;
}
@Override
public List<StandardTicketExportVO> exportStandardTicket(StandardTicketInfoDto entity) {
LambdaQueryWrapper<StandardTicketInfoEntity> queryWrapper = this.getQueryWrapper(entity);
queryWrapper.eq(Func.isNotEmpty(entity.getCreateDept()), StandardTicketInfoEntity::getCreateDept, entity.getCreateDept());
queryWrapper.orderByDesc(StandardTicketInfoEntity::getCreateTime);
//操作票已完成的数量
if (StringUtils.isNoneBlank(entity.getFlowTaskName())) {
queryWrapper.eq(StandardTicketInfoEntity::getFlowTaskName, entity.getFlowTaskName());
}
List<StandardTicketInfoEntity> standardTicketInfoEntities = super.baseMapper.selectList(queryWrapper);
List<StandardTicketExportVO> list=new ArrayList<>();
if (CollectionUtils.isNotEmpty(standardTicketInfoEntities)){
List<StandardTicketInfoVO> standardTicketInfoVOS = StandardTicketInfoWrapper.build().listVO(standardTicketInfoEntities);
for (int i = 0; i < standardTicketInfoVOS.size(); i++) {
StandardTicketExportVO exportVO=new StandardTicketExportVO();
StandardTicketInfoVO standardTicketInfoEntity = standardTicketInfoVOS.get(i);
exportVO.setNumber(i+1);
exportVO.setCompany( Optional.ofNullable(standardTicketInfoEntity.getCompany()).orElse(null));
exportVO.setTicketType(Optional.ofNullable(DictCache.getValue(TicketConstants.TICKET_TYPE,standardTicketInfoEntity.getTicketType())).orElse(null));
exportVO.setCode(Optional.ofNullable(standardTicketInfoEntity.getCode()).orElse(null));
exportVO.setTitle(Optional.ofNullable(standardTicketInfoEntity.getTitle()).orElse(null));
exportVO.setIssueOrderPerson(Optional.ofNullable(standardTicketInfoEntity.getIssueOrderPersonName()).orElse(null));
exportVO.setAccessOrderPerson(Optional.ofNullable(standardTicketInfoEntity.getAccessOrderPersonName()).orElse(null));
exportVO.setGuardian(Optional.ofNullable(standardTicketInfoEntity.getGuardianName()).orElse(null));
exportVO.setPrincipal(Optional.ofNullable(standardTicketInfoEntity.getPrincipalName()).orElse(null));
exportVO.setStartTime(Optional.ofNullable(DateUtil.format(standardTicketInfoEntity.getStartTime(),TicketConstants.TICKET_DATE_PATTERN)).orElse(""));
exportVO.setEndTime(Optional.ofNullable(DateUtil.format(standardTicketInfoEntity.getEndTime(),TicketConstants.TICKET_DATE_PATTERN)).orElse(""));
if (ObjectUtils.isNotEmpty(standardTicketInfoEntity.getIsEvaluate())){
exportVO.setIsEvaluate(standardTicketInfoEntity.getIsEvaluate()==0?"不合格":"合格");
}
list.add(exportVO);
}
}
return list;
}
}

86
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/standardTicket/vo/StandardTicketExportVO.java

@ -0,0 +1,86 @@
package com.hnac.hzims.ticket.standardTicket.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @author hx
*/
@Data
public class StandardTicketExportVO {
private static final long serialVersionUID = 8239436726489738763L;
@ExcelProperty(value = "序号", index = 0)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "序号")
private Integer number;
@ExcelProperty(value = "单位", index = 1)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "单位")
private String company;
@ExcelProperty(value = "票类", index = 2)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "票据类型")
private String ticketType;
@ExcelProperty(value = "操作票编号", index = 3)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "操作票编号")
private String code;
@ApiModelProperty("操作票任务")
@ExcelProperty(value = "操作票任务", index = 4)
@ColumnWidth(value = 20)
private String title;
@ExcelProperty(value = "发令人", index = 5)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "发令人")
private String issueOrderPerson;
@ExcelProperty(value = "受令人", index = 6)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "受令人")
private String accessOrderPerson;
@ExcelProperty(value = "监护人", index = 7)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "监护人")
private String guardian;
@ExcelProperty(value = "值班负责人", index = 8)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "值班负责人")
private String principal;
@ExcelProperty(value = "操作开始时间", index = 9)
@ColumnWidth(value = 20)
@ApiModelProperty("操作开始时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String startTime;
@ExcelProperty(value = "操作结束时间", index = 10)
@ColumnWidth(value = 20)
@ApiModelProperty("操作结束时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String endTime;
@ExcelProperty(value = "评价", index = 11)
@ColumnWidth(value = 20)
@ApiModelProperty("是否评价")
private String isEvaluate;
}

52
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/controller/WorkTicketInfoController.java

@ -1,6 +1,8 @@
package com.hnac.hzims.ticket.workTicket.controller;
import com.alibaba.druid.support.json.JSONUtils;
import com.alibaba.excel.EasyExcel;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
@ -9,35 +11,38 @@ import com.hnac.hzims.common.invalid.ObjectRequiredInvalid;
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.ticket.areamonthly.vo.AreaMonthlyVo;
import com.hnac.hzims.ticket.areamonthly.vo.StandardTicketWithAreaVo;
import com.hnac.hzims.ticket.areamonthly.vo.StandardWorkVo;
import com.hnac.hzims.ticket.constants.DictConstants;
import com.hnac.hzims.ticket.standardTicket.vo.OperateVo;
import com.hnac.hzims.ticket.standardTicket.vo.StandardTicketInfoVO;
import com.hnac.hzims.ticket.workTicket.dto.TicketAccessTaskDto;
import com.hnac.hzims.ticket.workTicket.dto.WorkInfoFlowDto;
import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity;
import com.hnac.hzims.ticket.workTicket.service.IWorkTicketInfoService;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketBillVO;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketExportVO;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketInfoVO;
import com.hnac.hzims.ticket.workTicket.vo.WorkVO;
import io.swagger.annotations.*;
import lombok.AllArgsConstructor;
import org.springblade.core.log.annotation.ApiLog;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.mp.support.BladePage;
import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query;
import org.springblade.core.secure.utils.AuthUtil;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*;
import org.springblade.core.tool.utils.SpringUtil;
import org.springblade.core.tool.utils.StringUtil;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import javax.validation.Valid;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -119,6 +124,45 @@ public class WorkTicketInfoController {
public void exportWorkTicketInfoPdf(@RequestParam Long id, HttpServletResponse response) {
workTicketInfoService.exportWorkTicketInfoPdf(id, response);
}
@ApiLog
@PostMapping("/exportWorkTicket")
@ApiOperationSupport(order = 2)
@ApiOperation(value = "工作票导出")
@ApiImplicitParams({
})
@OperationAnnotation(moduleName = "工作票导出",title = "工作票导出",operatorType = OperatorType.MOBILE,businessType = BusinessType.GENCODE,action
= "工作票导出")
public void exportWorkTicket(HttpServletResponse response,@RequestBody WorkTicketInfoDto req) {
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
String fileName = URLEncoder.encode("工作票统计报表", "UTF-8");
response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
List<WorkTicketExportVO> list = workTicketInfoService.exportWorkTicket(req);
if(list!=null && list.size()>0){
System.out.println("---------------- size = " + list.size());
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), WorkTicketExportVO.class).autoCloseStream(Boolean.FALSE).sheet("工作票统计报表")
.doWrite(list);
}
} catch (Exception e) {
System.out.println("exportExcel = " + e.toString());
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
Map<String, String> map = new HashMap<>();
map.put("isSuccess", "false");
map.put("msg", "工作票统计报表导出失败" + e.getMessage());
try {
response.getWriter().println(JSONUtils.toJSONString(map));
} catch (IOException e3) {
throw new ServiceException( "发生异常 :" + e.toString());
}
}
}
@GetMapping(value = "/exportWorkTicketTemplate")
@ApiOperationSupport(order = 80)

3
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/service/IWorkTicketInfoService.java

@ -10,6 +10,7 @@ import com.hnac.hzims.ticket.workTicket.dto.TicketAccessTaskDto;
import com.hnac.hzims.ticket.workTicket.dto.WorkTicketInfoDto;
import com.hnac.hzims.ticket.workTicket.entity.WorkTicketInfoEntity;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketBillVO;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketExportVO;
import com.hnac.hzims.ticket.workTicket.vo.WorkTicketInfoVO;
import com.hnac.hzims.ticket.workTicket.vo.WorkVO;
import com.hnac.hzims.vo.SafeCheckStatisticVO;
@ -182,4 +183,6 @@ public interface IWorkTicketInfoService extends BaseService<WorkTicketInfoEntity
IPage<WorkTicketInfoVO> work(IPage<WorkTicketInfoEntity> page, WorkVO work);
List<WorkTicketExportVO> exportWorkTicket(WorkTicketInfoDto req);
}

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

@ -60,6 +60,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.cache.DictCache;
import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
@ -1225,4 +1226,44 @@ public class WorkTicketInfoServiceImpl extends BaseServiceImpl<WorkTicketInfoMap
pages.setRecords(WorkTicketInfoWrapper.build().listVO(pages.getRecords()));
return pages;
}
@Override
public List<WorkTicketExportVO> exportWorkTicket(WorkTicketInfoDto req) {
LambdaQueryWrapper<WorkTicketInfoEntity> lqw = this.getQueryWrapper(req);
if (ObjectUtil.isNotEmpty(req.getCreateDept())) {
lqw.eq(WorkTicketInfoEntity::getCreateDept, req.getCreateDept());
}
//已完成的工作票
if (StringUtils.isNotEmpty(req.getFlowTaskName())) {
lqw.eq(WorkTicketInfoEntity::getFlowTaskName, req.getFlowTaskName());
}
lqw.orderByDesc(WorkTicketInfoEntity::getCreateTime).orderByDesc(WorkTicketInfoEntity::getUpdateTime);
List<WorkTicketInfoEntity> res = super.baseMapper.selectList(lqw);
List<WorkTicketExportVO> list=new ArrayList<>();
if (CollectionUtils.isNotEmpty(res)){
List<WorkTicketInfoVO> workTicketInfoVOS = WorkTicketInfoWrapper.build().listVO(res);
for (int i = 0; i < workTicketInfoVOS.size(); i++) {
WorkTicketExportVO resEntity=new WorkTicketExportVO();
WorkTicketInfoVO workTicketInfoVO = workTicketInfoVOS.get(i);
resEntity.setNumber(i+1);
resEntity.setCompany( Optional.ofNullable(workTicketInfoVO.getCompany()).orElse(""));
resEntity.setType(Optional.ofNullable(DictCache.getValue(TicketConstants.TICKET_TYPE, workTicketInfoVO.getType())).orElse(""));
resEntity.setCode(Optional.ofNullable(workTicketInfoVO.getCode()).orElse(""));
resEntity.setWorkContent(Optional.ofNullable(workTicketInfoVO.getWorkContent()).orElse(""));
resEntity.setSigner(Optional.ofNullable(workTicketInfoVO.getSignerName()).orElse(""));
resEntity.setPrincipal(Optional.ofNullable(workTicketInfoVO.getPrincipalName()).orElse(""));
resEntity.setLicensor(Optional.ofNullable(workTicketInfoVO.getLicensorName()).orElse(""));
resEntity.setClassGroupMembers(Optional.ofNullable(workTicketInfoVO.getClassGroupMembersName()).orElse(workTicketInfoVO.getClassGroupMembersManual()==null?"":workTicketInfoVO.getClassGroupMembersManual()));
resEntity.setCreateTime(Optional.ofNullable(DateUtil.format(workTicketInfoVO.getCreateTime(),TicketConstants.TICKET_DATE_PATTERN)).orElse(""));
if (ObjectUtil.isNotEmpty(workTicketInfoVO.getConfirmWorkTime())){
resEntity.setConfirmWorkTime(Optional.ofNullable(DateUtil.format(workTicketInfoVO.getConfirmWorkTime(),TicketConstants.TICKET_DATE_PATTERN)).orElse(""));
}
if (ObjectUtils.isNotEmpty(workTicketInfoVO.getIsEvaluate())){
resEntity.setIsEvaluate(workTicketInfoVO.getIsEvaluate()==0?"不合格":"合格");
}
list.add(resEntity);
}
}
return list;
}
}

86
hzims-service/ticket/src/main/java/com/hnac/hzims/ticket/workTicket/vo/WorkTicketExportVO.java

@ -0,0 +1,86 @@
package com.hnac.hzims.ticket.workTicket.vo;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
/**
* @author hx
*/
@Data
public class WorkTicketExportVO {
@ExcelProperty(value = "序号", index = 0)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "序号")
private Integer number;
@ExcelProperty(value = "单位", index = 1)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "单位")
private String company;
@ExcelProperty(value = "票类", index = 2)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "票据类型")
private String type;
@ExcelProperty(value = "工作票编号", index = 3)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "工作票编号")
private String code;
@ApiModelProperty("工作票任务")
@ExcelProperty(value = "工作票任务", index = 4)
@ColumnWidth(value = 20)
private String workContent;
@ExcelProperty(value = "签发人", index = 5)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "签发人")
private String signer;
@ExcelProperty(value = "工作负责人", index = 6)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "工作负责人")
private String principal;
@ExcelProperty(value = "工作许可人", index = 7)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "工作许可人")
private String licensor;
@ExcelProperty(value = "工作班成员", index = 8)
@ColumnWidth(value = 20)
@ApiModelProperty(value = "工作班成员")
private String classGroupMembers;
@ExcelProperty(value = "工作票开始时间", index = 9)
@ColumnWidth(value = 20)
@ApiModelProperty("工作票开始时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String createTime;
@ExcelProperty(value = "工作票结束时间", index = 10)
@ColumnWidth(value = 20)
@ApiModelProperty("工作票结束时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private String confirmWorkTime;
@ExcelProperty(value = "评价", index = 11)
@ColumnWidth(value = 20)
@ApiModelProperty("是否评价")
private String isEvaluate;
}
Loading…
Cancel
Save