/* * Copyright (c) 2018-2025, ztt All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * Neither the name of the pig4cloud.com developer nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. * Author: ztt */ package com.chinaztt.mes.quality.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.chinaztt.mes.quality.dto.TaskDTO; import com.chinaztt.mes.quality.entity.*; import com.chinaztt.mes.quality.mapper.*; import com.chinaztt.mes.quality.service.TaskService; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import java.time.LocalDateTime; import java.util.List; /** * 待检零件 * * @author liuth * @date 2020-10-15 13:54:42 */ @Service @AllArgsConstructor public class TaskServiceImpl extends ServiceImpl implements TaskService { private ReportItemsMapper reportItemsMapper; private TemplateMapper templateMapper; private ItemsMapper itemsMapper; private TestReportMapper reportMapper; @Override public Task getTaskById(Long id) { return baseMapper.getTaskById(id); } @Override public IPage> getTaskPage(Page page, QueryWrapper ew) { return baseMapper.getTaskPage(page,ew); } @Override public boolean fullSave(Task task) { task.setCreateTime(LocalDateTime.now()); baseMapper.insert(task); return true; } @Override public List getTaskByPartId(Long id) { List taskList =baseMapper.selectList(Wrappers.lambdaQuery().eq(Task::getPartId, id)); return taskList; } @Override public TaskDTO getFullById(Long id) { TaskDTO taskDTO = new TaskDTO(); //当不为空时获取信息 if (id != 0L) { // 获取检测任务基本信息 taskDTO = baseMapper.selectDtoById(id); //1.获取相关待检测汇报信息 List reportList=reportMapper.selectList(Wrappers.lambdaQuery().eq(TestReport::getTestTaskId, taskDTO.getId())); if (CollectionUtil.isNotEmpty(reportList)) { taskDTO.setReports(reportList); //2.获取相关汇报检测项信息 List reportItemsList= reportItemsMapper.selectList(Wrappers.lambdaQuery().eq(ReportItems::getTestReportId, reportList.get(0).getId())); if (CollectionUtil.isNotEmpty(reportItemsList)) { taskDTO.setReportItems(reportItemsList); } } // 3.获取相关检测模板信息 List