Newer
Older
huludao / src / main / java / com / newfiber / modules / inspection / service / impl / EquTechnologicalProcessTemplateServiceImpl.java
package com.newfiber.modules.inspection.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.newfiber.modules.inspection.dao.EquTechnologicalProcessTemplateDao;
import com.newfiber.modules.inspection.entity.EquTechnologicalProcessTemplateEntity;
import com.newfiber.modules.inspection.service.EquTechnologicalProcessTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;


@Service("equTechnologicalProcessTemplateService")
public class EquTechnologicalProcessTemplateServiceImpl extends ServiceImpl<EquTechnologicalProcessTemplateDao, EquTechnologicalProcessTemplateEntity> implements EquTechnologicalProcessTemplateService {

    @Autowired
    private EquTechnologicalProcessTemplateDao templateDao;

    @Override
    public List<Map<String, Object>> queryList() {
        /**获取全部流程模版信息*/
        List<EquTechnologicalProcessTemplateEntity> entityList = templateDao.selectList(new QueryWrapper<EquTechnologicalProcessTemplateEntity>().orderByAsc("order_num"));

        List<String> templateNos = entityList.stream().map(EquTechnologicalProcessTemplateEntity::getTemplateNo).distinct().collect(Collectors.toList());

        /**返回集合*/
        List<Map<String, Object>> resultList = new ArrayList<>();
        for (String templateNo : templateNos) {

            List<EquTechnologicalProcessTemplateEntity> collect = entityList.stream().filter(s -> s.getTemplateNo().equals(templateNo)).collect(Collectors.toList());
            Map<String, Object> map = new HashMap<>();
            map.put("templateName", collect.get(0).getTemplateName());
            map.put("templateNo", collect.get(0).getTemplateNo());
            map.put("cTime", collect.get(0).getCreateTime());
            map.put("details", collect);
            resultList.add(map);
        }
        return resultList;
    }

}