/*
 * Author: wangjian
 * 生成ServiceImpl
 */
package com.tofly.gpsboot.service.maintain.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.tofly.api.UserClent;
import com.tofly.pojo.User;
import com.tofly.pojo.maintain.vo.RepairrebutVo;
import com.tofly.gpsboot.mapper.maintain.RepairrebutMapper;
import com.tofly.gpsboot.service.maintain.RepairrebutService;
import com.tofly.pojo.maintain.Repairrebut;
import com.tofly.pojo.maintain.vo.RepairrelayVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;


/**
 * 抢维修工单驳回记录信息表
 *
 * @author admin
 * @date Tue Apr 06 00:00:00 CST 2021
 */
@Service("repairrebutService")
public class RepairrebutServiceImpl extends ServiceImpl<RepairrebutMapper, Repairrebut> implements RepairrebutService {
    @Autowired
    private UserClent userClent;
    @Override
    public List<RepairrebutVo> viewConversion(List<Repairrebut> infoList) {
        List<RepairrebutVo> repairrebutVoList = new ArrayList<>();
        infoList.forEach(info->{
            RepairrebutVo baseInfo = JSON.parseObject(JSON.toJSONString(info), RepairrebutVo.class);
            User userCu = userClent.getById(info.getCreateUser()).getResult();
            if(null!=userCu){
                baseInfo.setCreateUserName(userCu.getRealName());
            }
            repairrebutVoList.add(baseInfo);
        });
        repairrebutVoList.sort(Comparator.comparing(RepairrebutVo::getCreateTime).reversed());
        return repairrebutVoList;
    }
}
