Browse Source

Merge branch 'develop' of gitadmin/tuoheng_freeway into release

tags/v1.0.0^2
wanjing 1 year ago
parent
commit
583ab6ced5
1 changed files with 35 additions and 6 deletions
  1. +35
    -6
      tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/query/QueryInspectionHandleReportService.java

+ 35
- 6
tuoheng-service/tuoheng-admin/src/main/java/com/tuoheng/admin/service/report/query/QueryInspectionHandleReportService.java View File

import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.tuoheng.admin.conver.InspectionFileConverMapper; import com.tuoheng.admin.conver.InspectionFileConverMapper;
import com.tuoheng.admin.conver.ReportConverMapper; import com.tuoheng.admin.conver.ReportConverMapper;
import com.tuoheng.admin.entity.InspectionFile;
import com.tuoheng.admin.entity.InspectionFileHandle;
import com.tuoheng.admin.entity.Report;
import com.tuoheng.admin.entity.*;
import com.tuoheng.admin.enums.code.report.QueryInspectionReportCodeEnum; import com.tuoheng.admin.enums.code.report.QueryInspectionReportCodeEnum;
import com.tuoheng.admin.mapper.InspectionFileHandleMapper; import com.tuoheng.admin.mapper.InspectionFileHandleMapper;
import com.tuoheng.admin.mapper.InspectionFileMapper; import com.tuoheng.admin.mapper.InspectionFileMapper;
import com.tuoheng.admin.mapper.ReportMapper; import com.tuoheng.admin.mapper.ReportMapper;
import com.tuoheng.admin.mapper.UserMapper;
import com.tuoheng.admin.utils.CurrentUserUtil; import com.tuoheng.admin.utils.CurrentUserUtil;
import com.tuoheng.admin.vo.inspection.InspectionFileHandleReportVo; import com.tuoheng.admin.vo.inspection.InspectionFileHandleReportVo;
import com.tuoheng.admin.vo.inspection.InspectionFileReportVo; import com.tuoheng.admin.vo.inspection.InspectionFileReportVo;
@Service @Service
public class QueryInspectionHandleReportService { public class QueryInspectionHandleReportService {


@Autowired
private UserMapper userMapper;

@Autowired @Autowired
private ReportMapper reportMapper; private ReportMapper reportMapper;




List<InspectionFileReportVo> inspectionFileHandleVoList = InspectionFileConverMapper.INSTANCE.fromInspectionFileListToInspectionFileHandleVoList(inspectionFileList); List<InspectionFileReportVo> inspectionFileHandleVoList = InspectionFileConverMapper.INSTANCE.fromInspectionFileListToInspectionFileHandleVoList(inspectionFileList);


Map<String, InspectionFileHandle> inspectionFileHandleMap = this.getInspectionFileHandleMap(inspectionFileList);
List<InspectionFileHandle> inspectionFileHandleList = this.getInspectionFileHandleList(inspectionFileList);
Map<String, InspectionFileHandle> inspectionFileHandleMap = this.getInspectionFileHandleMap(inspectionFileHandleList);
Map<String, User> userMap = this.getUserMap(inspectionFileHandleList);
if (null != inspectionFileHandleMap) { if (null != inspectionFileHandleMap) {
InspectionFileHandle inspectionFileHandle; InspectionFileHandle inspectionFileHandle;
InspectionFileHandleReportVo inspectionFileHandleReportVo; InspectionFileHandleReportVo inspectionFileHandleReportVo;
handlerImageList.add(CommonConfig.imageURL + str); handlerImageList.add(CommonConfig.imageURL + str);
} }
inspectionFileHandleReportVo = new InspectionFileHandleReportVo(); inspectionFileHandleReportVo = new InspectionFileHandleReportVo();
inspectionFileHandleReportVo.setHandlerUser(inspectionFileHandle.getHandlerUser());
User user = userMap.get(inspectionFileHandle.getHandlerUser());
if (null != user) {
inspectionFileHandleReportVo.setHandlerUser(user.getRealname());
}
inspectionFileHandleReportVo.setHandlerResult(inspectionFileHandle.getHandlerResult()); inspectionFileHandleReportVo.setHandlerResult(inspectionFileHandle.getHandlerResult());
inspectionFileHandleReportVo.setHandlerTime(inspectionFileHandle.getHandlerTime()); inspectionFileHandleReportVo.setHandlerTime(inspectionFileHandle.getHandlerTime());
inspectionFileHandleReportVo.setHandlerImageList(handlerImageList); inspectionFileHandleReportVo.setHandlerImageList(handlerImageList);
return inspectionReportVo; return inspectionReportVo;
} }


private Map<String, InspectionFileHandle> getInspectionFileHandleMap(List<InspectionFile> inspectionFileList) {
private List<InspectionFileHandle> getInspectionFileHandleList(List<InspectionFile> inspectionFileList) {
List<String> inspectionFileIdList = inspectionFileList.stream().map(o -> o.getId()).collect(Collectors.toList()); List<String> inspectionFileIdList = inspectionFileList.stream().map(o -> o.getId()).collect(Collectors.toList());
List<InspectionFileHandle> inspectionFileHandleList = null; List<InspectionFileHandle> inspectionFileHandleList = null;
if (!CollectionUtil.isEmpty(inspectionFileIdList)) { if (!CollectionUtil.isEmpty(inspectionFileIdList)) {
if (CollectionUtil.isEmpty(inspectionFileIdList)) { if (CollectionUtil.isEmpty(inspectionFileIdList)) {
return null; return null;
} }
return inspectionFileHandleList;
}

private Map<String, InspectionFileHandle> getInspectionFileHandleMap(List<InspectionFileHandle> inspectionFileHandleList) {
if (CollectionUtil.isEmpty(inspectionFileHandleList)) {
return null;
}
Map<String, InspectionFileHandle> inspectionFileHandleMap = inspectionFileHandleList.stream().collect(Collectors.toMap(InspectionFileHandle::getInspectionFileId, Function.identity())); Map<String, InspectionFileHandle> inspectionFileHandleMap = inspectionFileHandleList.stream().collect(Collectors.toMap(InspectionFileHandle::getInspectionFileId, Function.identity()));
return inspectionFileHandleMap; return inspectionFileHandleMap;
} }

/**
* 获取用户列表,放到map,减少循环次数
*
* @param inspectionFileHandleList
* @return
*/
private Map<String, User> getUserMap(List<InspectionFileHandle> inspectionFileHandleList) {
List<String> userIdList = inspectionFileHandleList.stream().map(o -> o.getHandlerUser()).collect(Collectors.toList());
List<User> userList = userMapper.selectList(new LambdaQueryWrapper<User>()
.in(User::getId, userIdList)
.eq(User::getMark, 1));
Map<String, User> userMap = userList.stream().collect(Collectors.toMap(User::getId, Function.identity()));
return userMap;
}
} }

Loading…
Cancel
Save