Browse Source

巡检任务统计

zhongwei
ty 10 months ago
parent
commit
f8e5c61f66
  1. 4
      hzims-service-api/inspect-api/src/main/java/com/hnac/hzinfo/inspect/task/vo/InspectTaskExportVO.java
  2. 14
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/controller/TaskController.java
  3. 4
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.java
  4. 26
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml
  5. 2
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/ITaskService.java
  6. 63
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/service/impl/TaskServiceImpl.java

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

@ -71,5 +71,9 @@ public class InspectTaskExportVO {
@ExcelProperty(value = "巡检状态", index = 9)
@ColumnWidth(value = 20)
private String status;
@ApiModelProperty("巡检类型")
@ExcelProperty(value = "巡检类型", index = 10)
@ColumnWidth(value = 20)
private String type;
}

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

@ -120,7 +120,7 @@ public class TaskController extends BladeController {
@PostMapping("/listPage")
@ApiOperation(value = "巡检任务分页查询-站长级", notes = "传入task")
@ApiOperationSupport(order = 1)
public R<IPage<TaskVo>> listPage(@RequestBody TaskDTO taskDTO) {
public R<BladePage<TaskVo>> listPage(@RequestBody TaskDTO taskDTO) {
return R.data(taskService.page(taskDTO));
}
@ -158,12 +158,12 @@ public class TaskController extends BladeController {
@ApiOperation(value = "巡检任务导出", notes = "传入计划id")
public void exportTaskList(HttpServletResponse response,@RequestBody TaskDTO task) {
try {
if(ObjectUtils.isEmpty(task.getStartTime())&&ObjectUtils.isEmpty(task.getEndTime())){
LocalDateTime date = LocalDateTime.now();
LocalDateTime firstDay = date.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0);
task.setStartTime(firstDay);
task.setEndTime(date);
}
// if(ObjectUtils.isEmpty(task.getStartTime())&&ObjectUtils.isEmpty(task.getEndTime())){
// LocalDateTime date = LocalDateTime.now();
// LocalDateTime firstDay = date.with(TemporalAdjusters.firstDayOfMonth()).withHour(0).withMinute(0).withSecond(0);
// task.setStartTime(firstDay);
// task.setEndTime(date);
// }
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("UTF-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系

4
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.java

@ -1,5 +1,6 @@
package com.hnac.hzinfo.inspect.task.mapper;
import com.hnac.hzinfo.inspect.task.dto.TaskDTO;
import com.hnac.hzinfo.inspect.task.vo.TaskCountVO;
import com.hnac.hzinfo.inspect.task.vo.TaskOfflineVO;
import org.springblade.core.datascope.annotation.UserDataAuth;
@ -27,6 +28,9 @@ public interface TaskMapper extends UserDataScopeBaseMapper<TaskEntity> {
*/
List<TaskVo> getListPage(@Param("page") IPage<TaskVo> page, @Param("task") TaskListQuery task);
List<TaskVo> getAllPageList(@Param("page") IPage<TaskVo> page, @Param("task") TaskDTO taskDTO);
List<TaskVo> getAllExportList(@Param("task") TaskDTO taskDTO);
List<TaskVo> mainQueryPage(@Param("page") IPage<TaskVo> page, @Param("task") TaskListQuery task);
/**

26
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/task/mapper/TaskMapper.xml

@ -173,6 +173,32 @@
</if>
order by t.UPDATE_TIME desc
</select>
<select id="getAllPageList" parameterType="com.hnac.hzinfo.inspect.task.vo.TaskListQuery" resultType="com.hnac.hzinfo.inspect.task.vo.TaskVo">
SELECT t.*,u.USER_ID as useIds,u.USER_NAME from HZ_ST_EX_TASK t
LEFT JOIN HZ_ST_EX_TASK_USER u on t.ID=u.TASK_ID
and u.IS_DELETED=0
where t.IS_DELETED=0
<if test="task.userId != null ">
and u.USER_ID=#{task.userId}
</if>
<include refid="getTaskListSql"></include>
order by t.UPDATE_TIME desc
</select>
<select id="getAllExportList" resultType="com.hnac.hzinfo.inspect.task.vo.TaskVo">
SELECT t.*,b.USER_ID as userIds,(SELECT group_concat(u .user_name) FROM HZ_ST_EX_TASK_USER u WHERE t.ID=u.TASK_ID
<if test="task.userId != null ">
and u.USER_ID=#{task.userId}
</if>) AS userNames from HZ_ST_EX_TASK t
LEFT JOIN HZ_ST_EX_TASK_USER b on t.ID=b.TASK_ID
and b.IS_DELETED=0
where t.IS_DELETED=0
<if test="task.userId != null ">
and u.USER_ID=#{task.userId}
</if>
<include refid="getTaskListSql"></include>
GROUP BY t.id
order by t.UPDATE_TIME desc
</select>
<select id="getListPageOfTaskRecord" parameterType="com.hnac.hzinfo.inspect.task.vo.TaskListQuery" resultType="com.hnac.hzinfo.inspect.task.entity.TaskEntity">

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

@ -64,7 +64,7 @@ public interface ITaskService extends BaseService<TaskEntity> {
*/
List<TaskObjectVO> getTaskById(Long id);
IPage<TaskVo> page(TaskDTO taskDTO);
BladePage<TaskVo> page(TaskDTO taskDTO);
/**
* PC端任务列表

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

@ -524,18 +524,24 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
}
@Override
public IPage<TaskVo> page(TaskDTO taskDTO) {
public BladePage<TaskVo> page(TaskDTO taskDTO) {
Query query = new Query();
query.setSize(taskDTO.getSize());
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;
IPage<TaskVo> pages = Condition.getPage(query);
List<TaskVo> list = this.baseMapper.getAllPageList(pages,taskDTO);
list = list.stream().map(taskVo -> {
// 获取机器人信息
if (taskVo.getAutoVideo().equals(PlanContants.InspectTypeEnum.ROBOT.getVal()) ) {
if (Func.isNotEmpty( ObjectUtil.isNotEmpty(taskVo.getUserId()))) {
taskVo.setRobot(robotService.getDetailByUserId(taskVo.getUserId()));
}
}
return taskVo;
}).collect(Collectors.toList());
pages.setRecords(list);
BladePage<TaskVo> bladePage = BladePage.of(pages);
return bladePage;
}
private void getQueryWrapper(TaskDTO taskDTO, LambdaQueryWrapper<TaskEntity> queryWrapper) {
@ -1020,10 +1026,7 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
@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<TaskVo> taskEntities = super.baseMapper.getAllExportList(task);
List<InspectTaskExportVO> list=new ArrayList<>();
if (CollectionUtils.isNotEmpty(taskEntities)){
list=taskEntities.parallelStream().map(taskVo -> {
@ -1062,22 +1065,26 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, TaskEntity> imp
} else {
resEntity.setContent("正常");
}
if(ObjectUtil.isNotEmpty(taskVo.getId())) {
List<TaskUserEntity> taskUserList = taskUserService.list(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, taskVo.getId()));
if (CollectionUtil.isNotEmpty(taskUserList)) {
// 获取巡检任务人员名称
String userNames = taskUserList.stream().filter(Func::isNotEmpty).map(TaskUserEntity::getUserId).filter(Func::isNotEmpty)
.map(userId -> {
User user = UserCache.getUser(userId);
if (ObjectUtil.isEmpty(user)) {
return "";
}
return user.getName();
}).collect(Collectors.joining(","));
resEntity.setUserName(userNames);
}
}
if (ObjectUtil.isNotEmpty(taskVo.getUserNames())) {
resEntity.setUserName(taskVo.getUserNames());
}
// if(ObjectUtil.isNotEmpty(taskVo.getId())) {
// List<TaskUserEntity> taskUserList = taskUserService.list(Wrappers.<TaskUserEntity>lambdaQuery().eq(TaskUserEntity::getTaskId, taskVo.getId()));
// if (CollectionUtil.isNotEmpty(taskUserList)) {
// // 获取巡检任务人员名称
// String userNames = taskUserList.stream().filter(Func::isNotEmpty).map(TaskUserEntity::getUserId).filter(Func::isNotEmpty)
// .map(userId -> {
// User user = UserCache.getUser(userId);
// if (ObjectUtil.isEmpty(user)) {
// return "";
// }
// return user.getName();
// }).collect(Collectors.joining(","));
// resEntity.setUserName(userNames);
// }
// }
resEntity.setStatus(Optional.ofNullable(DictCache.getValue(TaskContants.TASK_STATUS, taskVo.getStatus())).orElse(""));
resEntity.setType(Optional.ofNullable(DictCache.getValue(TaskContants.INSPECT_TASK_TYPE, taskVo.getStatus())).orElse(""));
return resEntity;
}catch (Exception e){
log.error("巡检导出失败---》param"+taskVo+"报错信息:"+e.getStackTrace());

Loading…
Cancel
Save