| | |
| | | package org.jeecg.modules.qms.controller; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.io.IOException; |
| | | import java.io.UnsupportedEncodingException; |
| | | import java.net.URLDecoder; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.common.constant.CommonConstant; |
| | |
| | | import org.jeecg.modules.qms.entity.InspectionItem; |
| | | import org.jeecg.modules.qms.entity.InspectionTools; |
| | | import org.jeecg.modules.qms.service.IInspectionItemService; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | |
| | | QueryWrapper<InspectionItem> queryWrapper = QueryGenerator.initQueryWrapper(inspectionItem, req.getParameterMap()); |
| | | Page<InspectionItem> page = new Page<InspectionItem>(pageNo, pageSize); |
| | | IPage<InspectionItem> pageList = inspectionItemService.page(page, queryWrapper); |
| | | List<InspectionItem> records = pageList.getRecords(); |
| | | Set<String> uniqueToolIds = records.stream() |
| | | .map(InspectionItem::getInspectionTools) |
| | | .filter(StringUtils::isNotBlank) |
| | | .flatMap(tools -> Arrays.stream(tools.split(","))) |
| | | .map(String::trim) |
| | | .collect(Collectors.toSet()); |
| | | Map<String, String> toolIdNameMap = inspectionToolsService.listByIds(uniqueToolIds).stream() |
| | | .collect(Collectors.toMap(InspectionTools::getId, InspectionTools::getToolName)); |
| | | |
| | | records.forEach(record -> { |
| | | String inspectionTools = record.getInspectionTools(); |
| | | if (StringUtils.isNotBlank(inspectionTools)) { |
| | | String toolNames = Arrays.stream(inspectionTools.split(",")) |
| | | .map(String::trim) |
| | | .map(toolIdNameMap::get) |
| | | .filter(Objects::nonNull) |
| | | .collect(Collectors.joining(",")); |
| | | record.setInspectionToolNames(toolNames); |
| | | } |
| | | }); |
| | | return Result.OK(pageList); |
| | | } |
| | | |