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

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.tofly.api.DepartmentClient;
import com.tofly.api.UserClent;
import com.tofly.common.oauth.util.SecurityUtils;
import com.tofly.gpsboot.common.Constant;
import com.tofly.gpsboot.common.system.*;
import com.tofly.gpsboot.service.maintain.RepairplanyearService;
import com.tofly.gpsboot.util.DateTimeUtil;
import com.tofly.pojo.comm.vo.AuditVo;
import com.tofly.pojo.maintain.dto.RepairplanDto;
import com.tofly.pojo.maintain.vo.*;
import com.tofly.gpsboot.exception.BusinessException;
import com.tofly.gpsboot.mapper.maintain.RepairplanMapper;
import com.tofly.gpsboot.service.comm.IAuditService;
import com.tofly.gpsboot.service.comm.IDisposeDateService;
import com.tofly.gpsboot.service.maintain.RepairplanService;
import com.tofly.gpsboot.service.maintain.RepairplandetailService;
import com.tofly.pojo.User;
import com.tofly.pojo.comm.Audit;
import com.tofly.pojo.maintain.Repairplan;
import com.tofly.pojo.maintain.Repairplandetail;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.*;
import java.util.stream.Collectors;


/**
 * 抢维修月度计划记录信息表
 *
 * @author admin
 * @date Tue Apr 06 00:00:00 CST 2021
 */
@Service("repairplanService")
public class RepairplanServiceImpl extends ServiceImpl<RepairplanMapper, Repairplan> implements RepairplanService {

    @Autowired
    private RepairplandetailService repairplandetailService;
    @Autowired
    private UserClent userClent;
    @Autowired
    private IAuditService iAuditService;
    @Autowired
    private DepartmentClient departmentClient;
    @Autowired
    private IDisposeDateService iDisposeDateService;

    @Autowired
    private RepairplanyearService repairplanyearService;
    @Autowired
    private RepairplanMapper repairplanMapper;


    @Override
    public List<RepairplanVo> viewConversion(List<Repairplan> infoList) {
        List<RepairplanVo> infoVoList = new ArrayList<>();
        infoList.forEach(info -> {
            RepairplanVo baseInfo = JSON.parseObject(JSON.toJSONString(info), RepairplanVo.class);
            // 添加上报人名称 转换上报状态/是否查看/计划状态

            Long submitUser = info.getSubmitUser();
            if (null != submitUser && 0 != submitUser) {
                User userSubmit = userClent.getById(submitUser).getResult();
                baseInfo.setSubmitUserName(userSubmit.getRealName());
            }
            User userSubmit = userClent.getById(info.getCreateUser()).getResult();
            if (null != userSubmit) {
                baseInfo.setCreateUserName(userSubmit.getRealName());
            }

            baseInfo.setIssubmit(IsSubmitEnum.getCodeForValue(info.getIssubmit()));
            baseInfo.setPlanState(AuditSateEnum.getCodeForValue(info.getPlanState()));
            // 返回月详情
            baseInfo.setRepairplandetailVoList(repairplandetailService.viewConversion(repairplandetailService.list(new QueryWrapper<Repairplandetail>().lambda().eq(Repairplandetail::getYearId,info.getId()))));
            // 返回当前审批链
            List<Audit> list = iAuditService.list(new QueryWrapper<Audit>().lambda().eq(Audit::getAuditPlanId, info.getId()).eq(Audit::getAuditType, AuditTypeEnum.AUDIT_TYPE_REPAIR_MONTH_PLAN.getCode()));
            if (null != list && list.size() > 0) {
                baseInfo.setAuditVoList(iAuditService.viewConversion(list));
            }
            infoVoList.add(baseInfo);
        });
        return infoVoList;
    }

    @Override
    public String savaYearPlanInfo(RepairplanDto parDto) throws BusinessException {
        // 判断当前用户,部门下是否创建对应的月计划
        Set<Long> userIdList = departmentClient.getDeptUserList(String.valueOf(SecurityUtils.getUserDeptId())).getResult().stream().map(User::getId).collect(Collectors.toSet());
        // 是否新增
        boolean flag = false;
        // 判断当前年份/月份是否存在
        List<Repairplan> repairplan = this.list(new QueryWrapper<Repairplan>().lambda().eq(Repairplan::getYear, parDto.getYear()).eq(Repairplan::getMonth, parDto.getMonth()).in(Repairplan::getCreateUser, userIdList));
        Long resultId = null;
        if (null != repairplan && repairplan.size() > 0) {
            resultId = repairplan.get(0).getId();
            flag = true;
        } else {
            // 判断当前详情计划传入是否为空值(前端调用抢维修年计划详情去单独新增)
//            if (null == parDto.getPlanyeardetailList() || parDto.getPlanyeardetailList().size() == 0) {
//                throw new BusinessException(Constant.PLAN_REPAIR_YEAR_DETAIL_NULL_CODE, Constant.PLAN_REPAIR_YEAR_DETAIL_NULL);
//            }

            // JSON转换
            Repairplan planyear = JSON.parseObject(JSON.toJSONString(parDto), Repairplan.class);
            // 上报状态数据库默认值设为 0 未上报 审核意见数据库默认值设为 0 未审核 是否接收查看数据库默认值设为 0：未查看
            this.save(planyear);

            //            List<Repairplandetail> planyeardetailList = parDto.getPlanyeardetailList();
//            if(null!=planyeardetailList && planyeardetailList.size()>0){
//                List<Repairplandetail> planetoids = JSONArray.parseArray(JSON.toJSONString(planyeardetailList), Repairplandetail.class);
//                planetoids.forEach(info -> {
//                    info.setYearId(id);
//                    repairplandetailService.save(info);
//                });
//            }
            resultId = planyear.getId();

        }

        return resultId + Constant.CSV + flag;
    }

    @Override
    public Page<RepairplanVo> getRepairPlanPage(Page page, RepairplanDto parDto) {
        Repairplan repairorder = JSONObject.parseObject(JSON.toJSONString(parDto), Repairplan.class);
        Date signStartTime = parDto.getStartSubmitTime();
        Date signEndTime = parDto.getEndSubmitTime();
        String state = parDto.getPlanState();
        String years = parDto.getYears();
        String months = parDto.getMonths();
        QueryWrapper<Repairplan> queryWrapper = new QueryWrapper<>();
        // 当前部门下用户才有权限
        Long departmentId = SecurityUtils.getUser().getDepartmentId();
        Set<Long> userIdList = departmentClient.getDeptUserList(String.valueOf(departmentId)).getResult().stream().map(User::getId).collect(Collectors.toSet());
        if (null != signStartTime) {
            queryWrapper.ge("SUBMIT_TIME", signStartTime);
            repairorder.setSubmitTime(null);
        }
        if(null != signEndTime){
            queryWrapper.le("SUBMIT_TIME", signEndTime);
            repairorder.setSubmitTime(null);
        }

        if (!StringUtils.isEmpty(years)) {
            List<String> yearList = Arrays.stream(years.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("YEAR", yearList);
            repairorder.setYear(null);
        }

        if (!StringUtils.isEmpty(months)) {
            List<String> monthList = Arrays.stream(months.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("MONTH", monthList);
            repairorder.setMonth(null);
        }
        if (!StringUtils.isEmpty(state)) {
            List<String> stateList = Arrays.stream(state.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("PLAN_STATE", stateList);
            repairorder.setPlanState(null);
        }
        Long deptUserId = parDto.getDeptUserId();
        Long chargeUserId = parDto.getChargeUserId();
        Set<Long> planYearIdList = new HashSet<>();

        if (null != deptUserId) {
            planYearIdList.addAll(iAuditService.list(new QueryWrapper<Audit>().lambda().eq(Audit::getAuditUser, deptUserId).eq(Audit::getAuditType, AuditTypeEnum.AUDIT_TYPE_REPAIR_MONTH_PLAN.getCode())).stream().map(Audit::getAuditPlanId).collect(Collectors.toSet()));
        }
        if (null != chargeUserId) {
            planYearIdList.addAll(iAuditService.list(new QueryWrapper<Audit>().lambda().eq(Audit::getAuditUser, chargeUserId).eq(Audit::getAuditType, AuditTypeEnum.AUDIT_TYPE_REPAIR_MONTH_PLAN.getCode())).stream().map(Audit::getAuditPlanId).collect(Collectors.toSet()));
        }
        if (null == deptUserId && null == chargeUserId) {
//            // 由于分管经理不属于当前部门,根据当前登录用户需要获取相关计划id列表
//            Set<Long> collect = iAuditService.list(new QueryWrapper<Audit>().lambda().eq(Audit::getAuditUser, SecurityUtils.getUserId()).eq(Audit::getAuditType, AuditTypeEnum.AUDIT_TYPE_REPAIR_MONTH_PLAN.getCode())).stream().map(Audit::getAuditPlanId).collect(Collectors.toSet());
//            // 获取当前用户列表创建的年计划id列表
            Set<Long> userPlanIdList = this.list(new QueryWrapper<Repairplan>().lambda().in(Repairplan::getCreateUser, userIdList)).stream().map(Repairplan::getId).collect(Collectors.toSet());
//            userPlanIdList.addAll(collect);
            if (userPlanIdList.size() > 0) {
                planYearIdList.addAll(userPlanIdList);
            }


        }
        if (planYearIdList.size() > 0) {
            queryWrapper.in("ID", planYearIdList);
        } else {
            return null;
        }
        queryWrapper.orderByDesc("YEAR").orderByDesc("MONTH");
        queryWrapper.setEntity(repairorder);
        Page infoPageList = this.page(page, queryWrapper);
        infoPageList.setRecords(this.viewConversion(infoPageList.getRecords()));
        return infoPageList;
    }

    @Override
    public Page<RepairplanVo> getAuditList(Page page, RepairplanDto dto) {
        Repairplan repairorder = JSONObject.parseObject(JSON.toJSONString(dto), Repairplan.class);
        Date signStartTime = dto.getStartSubmitTime();
        Date signEndTime = dto.getEndSubmitTime();
        String state = dto.getPlanState();
        String years = dto.getYears();
        String months = dto.getMonths();
        QueryWrapper<Repairplan> queryWrapper = new QueryWrapper<>();
        Set<Long> collect = iAuditService.list(new QueryWrapper<Audit>().lambda()
                .eq(Audit::getAuditUser, SecurityUtils.getUserId())
                .eq(Audit::getAuditType, AuditTypeEnum.AUDIT_TYPE_REPAIR_MONTH_PLAN.getCode()))
                .stream().map(Audit::getAuditPlanId).collect(Collectors.toSet());
        if (collect.size() > 0) {
            queryWrapper.in("ID", collect);
        } else {
            return null;
        }
        if (!StringUtils.isEmpty(years)) {
            List<String> yearList = Arrays.stream(years.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("YEAR", yearList);
            repairorder.setYear(null);
        }

        if (!StringUtils.isEmpty(months)) {
            List<String> monthList = Arrays.stream(months.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("MONTH", monthList);
            repairorder.setMonth(null);
        }
         if (null != signStartTime) {
            queryWrapper.ge("SUBMIT_TIME", signStartTime);
            repairorder.setSubmitTime(null);
        }
        if(null != signEndTime){
            queryWrapper.le("SUBMIT_TIME", signEndTime);
            repairorder.setSubmitTime(null);
        }
        if (!StringUtils.isEmpty(state)) {
            List<String> stateList = Arrays.stream(state.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("PLAN_STATE", stateList);
            repairorder.setPlanState(null);
        }
        queryWrapper.orderByDesc("YEAR").orderByDesc("MONTH");
        queryWrapper.setEntity(repairorder);
        Page infoPageList = this.page(page, queryWrapper);
        infoPageList.setRecords(this.viewConversion(infoPageList.getRecords()));
        return infoPageList;
    }

    @Override
    public Page<RepairplanVo> getAllList(Page page, RepairplanDto parDto) {
        Repairplan repairorder = JSONObject.parseObject(JSON.toJSONString(parDto), Repairplan.class);
        Date signStartTime = parDto.getStartSubmitTime();
        Date signEndTime = parDto.getEndSubmitTime();
        String state = parDto.getPlanState();
        String years = parDto.getYears();
        String months = parDto.getMonths();
        QueryWrapper<Repairplan> queryWrapper = new QueryWrapper<>();
        // 当前部门下用户才有权限
        Long departmentId = SecurityUtils.getUser().getDepartmentId();
        Set<Long> userIdList = departmentClient.getDeptUserList(String.valueOf(departmentId)).getResult().stream().map(User::getId).collect(Collectors.toSet());
         if (null != signStartTime) {
            queryWrapper.ge("SUBMIT_TIME", signStartTime);
            repairorder.setSubmitTime(null);
        }
        if(null != signEndTime){
            queryWrapper.le("SUBMIT_TIME", signEndTime);
            repairorder.setSubmitTime(null);
        }
        if (!StringUtils.isEmpty(state)) {
            List<String> stateList = Arrays.stream(state.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("PLAN_STATE", stateList);
            repairorder.setPlanState(null);
        }
        if (!StringUtils.isEmpty(years)) {
            List<String> yearList = Arrays.stream(years.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("YEAR", yearList);
            repairorder.setYear(null);
        }

        if (!StringUtils.isEmpty(months)) {
            List<String> monthList = Arrays.stream(months.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("MONTH", monthList);
            repairorder.setMonth(null);
        }
        Long deptUserId = parDto.getDeptUserId();
        Long chargeUserId = parDto.getChargeUserId();
        Set<Long> planYearIdList = new HashSet<>();

        if (null != deptUserId) {
            planYearIdList.addAll(iAuditService.list(new QueryWrapper<Audit>().lambda().eq(Audit::getAuditUser, deptUserId).eq(Audit::getAuditType, AuditTypeEnum.AUDIT_TYPE_REPAIR_MONTH_PLAN.getCode())).stream().map(Audit::getAuditPlanId).collect(Collectors.toSet()));
        }
        if (null != chargeUserId) {
            planYearIdList.addAll(iAuditService.list(new QueryWrapper<Audit>().lambda().eq(Audit::getAuditUser, chargeUserId).eq(Audit::getAuditType, AuditTypeEnum.AUDIT_TYPE_REPAIR_MONTH_PLAN.getCode())).stream().map(Audit::getAuditPlanId).collect(Collectors.toSet()));
        }
        if (null == deptUserId && null == chargeUserId) {
            // 由于分管经理不属于当前部门,根据当前登录用户需要获取相关计划id列表
            Set<Long> collect = iAuditService.list(new QueryWrapper<Audit>().lambda().eq(Audit::getAuditUser, SecurityUtils.getUserId()).eq(Audit::getAuditType, AuditTypeEnum.AUDIT_TYPE_REPAIR_MONTH_PLAN.getCode())).stream().map(Audit::getAuditPlanId).collect(Collectors.toSet());
            // 获取当前用户列表创建的年计划id列表
            Set<Long> userPlanIdList = this.list(new QueryWrapper<Repairplan>().lambda().in(Repairplan::getCreateUser, userIdList)).stream().map(Repairplan::getId).collect(Collectors.toSet());
            userPlanIdList.addAll(collect);
            if (userPlanIdList.size() > 0) {
                planYearIdList.addAll(userPlanIdList);
            }
        }
        if (planYearIdList.size() > 0) {
            queryWrapper.in("ID", planYearIdList);
        } else {
            return null;
        }
        queryWrapper.orderByDesc("YEAR").orderByDesc("MONTH");
        queryWrapper.setEntity(repairorder);
        Page infoPageList = this.page(page, queryWrapper);
        infoPageList.setRecords(this.viewConversion(infoPageList.getRecords()));
        return infoPageList;
    }

    @Override
    public Page<RepairplanVo> getNeedAuditList(Page page, RepairplanDto dto) {
        Repairplan repairorder = JSONObject.parseObject(JSON.toJSONString(dto), Repairplan.class);
        Date signStartTime = dto.getStartSubmitTime();
        Date signEndTime = dto.getEndSubmitTime();
        String state = dto.getPlanState();
        String years = dto.getYears();
        String months = dto.getMonths();
        QueryWrapper<Repairplan> queryWrapper = new QueryWrapper<>();
        Set<Long> collect = iAuditService.list(new QueryWrapper<Audit>().lambda()
                .eq(Audit::getAuditUser, SecurityUtils.getUserId())
                .eq(Audit::getAuditState, AuditSateEnum.AUDIT_UNCOMMITTED.getCode())
                .eq(Audit::getAuditType, AuditTypeEnum.AUDIT_TYPE_REPAIR_MONTH_PLAN.getCode()))
                .stream().map(Audit::getAuditPlanId).collect(Collectors.toSet());
        if (collect.size() > 0) {
            queryWrapper.in("ID", collect);
        } else {
            return null;
        }
        if (!StringUtils.isEmpty(years)) {
            List<String> yearList = Arrays.stream(years.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("YEAR", yearList);
            repairorder.setYear(null);
        }

        if (!StringUtils.isEmpty(months)) {
            List<String> monthList = Arrays.stream(months.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("MONTH", monthList);
            repairorder.setMonth(null);
        }
         if (null != signStartTime) {
            queryWrapper.ge("SUBMIT_TIME", signStartTime);
            repairorder.setSubmitTime(null);
        }
        if(null != signEndTime){
            queryWrapper.le("SUBMIT_TIME", signEndTime);
            repairorder.setSubmitTime(null);
        }
        if (!StringUtils.isEmpty(state)) {
            List<String> stateList = Arrays.stream(state.split(Constant.CSV)).map(String::trim)
                    .collect(Collectors.toList());
            queryWrapper.in("PLAN_STATE", stateList);
            repairorder.setPlanState(null);
        }
        queryWrapper.orderByDesc("YEAR").orderByDesc("MONTH");
        queryWrapper.setEntity(repairorder);
        Page infoPageList = this.page(page, queryWrapper);
        infoPageList.setRecords(this.viewConversion(infoPageList.getRecords()));
        return infoPageList;
    }

    @Override
    public Page<RepairplanVo> getNowAuditPageList(Page page, List<Long> repairPlanIdList) {
        QueryWrapper<Repairplan> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("ID",repairPlanIdList);
        queryWrapper.orderByDesc("YEAR").orderByDesc("MONTH");
        Page infoPageList = this.page(page, queryWrapper);
        infoPageList.setRecords(this.viewConversion(infoPageList.getRecords()));
        return infoPageList;
    }


    @Override
    public RepairplanVo getYearPlanInfo(Long id) throws BusinessException {
        Repairplan info = this.getById(id);
        Optional.ofNullable(info).orElseThrow(() -> new BusinessException(Constant.PLAN_REPAIR_MONTH_NULL_CODE, Constant.PLAN_REPAIR_MONTH_NULL));
        List<Repairplan> repairplanList = new ArrayList<>();
        repairplanList.add(info);
        RepairplanVo planyearVo = viewConversion(repairplanList).get(0);

        List<Repairplandetail> list = repairplandetailService.list(new QueryWrapper<Repairplandetail>().lambda().eq(Repairplandetail::getYearId, info.getId()));
        planyearVo.setRepairplandetailVoList(repairplandetailService.viewConversion(list));
        return planyearVo;
    }

    @Override
    public void updateYearPlanInfo(RepairplanDto parDto) throws BusinessException {
        if (!iDisposeDateService.isDisposePermissions(parDto.getCreateUser())) {
            throw new BusinessException(Constant.IS_DISPOSE_PERMISSIONS_NULL_CODE, Constant.IS_DISPOSE_PERMISSIONS_NULL);

        }
        // 判断当前年计划上报状态是否未上报
        if (!ReportSateEnum.REPORT_UNCOMMITTED.getCode().equals(parDto.getIssubmit())) {
            throw new BusinessException(Constant.PLAN_UPDATE_REPORT_UNCOMMITTED_CODE, Constant.PLAN_UPDATE_REPORT_UNCOMMITTED);
        }
        Repairplan planyear = JSON.parseObject(JSON.toJSONString(parDto), Repairplan.class);
        this.updateById(planyear);
    }

    @Override
    public void deleteYearPlanInfo(List<Long> idList) throws BusinessException {
        List<Repairplan> planYearList = this.list(new QueryWrapper<Repairplan>().lambda().in(Repairplan::getId, idList));
        planYearList.forEach(info -> {
            if (!iDisposeDateService.isDisposePermissions(info.getCreateUser())) {
                throw new BusinessException(Constant.IS_DISPOSE_PERMISSIONS_NULL_CODE, Constant.IS_DISPOSE_PERMISSIONS_NULL);

            }
            // 判断当前年计划上报状态是否是未上报
            if (!ReportSateEnum.REPORT_UNCOMMITTED.getCode().equals(info.getIssubmit())) {
                throw new BusinessException(Constant.PLAN_DELETE_REPORT_UNCOMMITTED_CODE, Constant.PLAN_DELETE_REPORT_UNCOMMITTED);
            }
            List<Repairplandetail> list = repairplandetailService.list(new QueryWrapper<Repairplandetail>().lambda().in(Repairplandetail::getYearId, idList));
            if (Optional.ofNullable(list).isPresent()) {
                List<Long> ids = list.stream().map(Repairplandetail::getYearId).collect(Collectors.toList());
                repairplandetailService.removeByIds(ids);
            }
        });
        this.removeByIds(idList);
    }


    @Override
    public List<Map<String, Object>> getExportData(String dto, String templateFlag) {
        List<Map<String, Object>> returnMap = new ArrayList<>();
        Map<String, Object> parentMap = new HashMap<>(12);
        // 只导出数据,没有模板
        Repairplan repairplan = JSONObject.parseObject(dto, Repairplan.class);
        Long id = repairplan.getId();
        if (!StringUtils.isEmpty(id)) {
            List<RepairplanVo> repairplanVos = repairplanMapper.getRepairPlanVoList(id);
            RepairplanVo repairplanVo = repairplanVos.get(0);
            ExcelExportRepairBasePlan basePlan = new ExcelExportRepairBasePlan();
            // 增加年/月/年备注/计划制定人/上报时间
            basePlan.setYear(repairplanVo.getYear());
            basePlan.setMonth(repairplanVo.getMonth());
//            Repairplanyear repairplanyear = repairplanyearService.getById(repairplan.getYearId());
//            basePlan.setNote(repairplanyear.getNote());
            basePlan.setCreateUserName(repairplanVo.getCreateUserName());
            Date submitTime = repairplanVo.getSubmitTime();
            if(null!=submitTime){
                basePlan.setSubmitTime(DateTimeUtil.getLocalDateTime(DateTimeUtil.fromLong2LocalDateTime(submitTime.getTime()), DateTimeUtil.FULL_FORMAT));
            }
            // 获取当前年计划审批链
            List<AuditVo> auditVoList = repairplanVo.getAuditVoList();
            if (null != auditVoList) {
                // 增加部门审核意见/部门审核说明/部门审批人/部门审批时间/分管审核意见/分管审核说明/分管审批人/分管审批时间
                auditVoList.forEach(info -> {
                    Date auditTime = info.getAuditTime();
                    if (0 == info.getAuditLevel()) {
                        basePlan.setAuditDeptResult(info.getAuditStateName());
                        basePlan.setAuditDeptNote(info.getAuditNote());
                        basePlan.setAuditDeptUser(info.getAuditUserName());
                        if(null!=auditTime){
                            basePlan.setAuditDeptTime(DateTimeUtil.getLocalDateTime(DateTimeUtil.fromLong2LocalDateTime(auditTime.getTime()), DateTimeUtil.FULL_FORMAT));
                        }
                    } else {
                        basePlan.setAuditChargeResult(info.getAuditStateName());
                        basePlan.setAuditChargeNote(info.getAuditNote());
                        basePlan.setAuditChargeUser(info.getAuditUserName());
                        if(null!=auditTime){
                            basePlan.setAuditChargeTime(DateTimeUtil.getLocalDateTime(DateTimeUtil.fromLong2LocalDateTime(auditTime.getTime()), DateTimeUtil.FULL_FORMAT));
                        }
                    }
                });
            }
            // 增加基础信息
            List<ExcelExportRepairBasePlan> basePlanList = new ArrayList<>();
            basePlanList.add(basePlan);
            parentMap.put("base", basePlanList);
            List<RepairplandetailVo> details = repairplanVo.getRepairplandetailVoList();
            if (null != details) {
                // 增加详情
                parentMap.put("list", details);

            }
        } else {
            throw new BusinessException(Constant.EXCEL_EXPORT_REPAIR_MONTH_PLAN_ID_NULL_ERROR_CODE, Constant.EXCEL_EXPORT_REPAIR_MONTH_PLAN_ID_NULL_ERROR);
        }
        returnMap.add(parentMap);
        return returnMap;
    }

    @Override
    public Boolean excelDataStorage(List<Object> dataList) {
        return null;
    }
}
