package cn.com.countrygarden.bi.main.service.districtReport.impl;

import cn.com.countrygarden.bi.main.core.Response;
import cn.com.countrygarden.bi.main.core.Result;
import cn.com.countrygarden.bi.main.dao.districtReport.RdDistrictInfoMapper;
import cn.com.countrygarden.bi.main.dao.districtReport.RdPendingBuildingProjectMapper;
import cn.com.countrygarden.bi.main.dao.twerp.hm.ManagerMapForErpMapper;
import cn.com.countrygarden.bi.main.dto.districtReport.RdPendingBuildingProjectDTO;
import cn.com.countrygarden.bi.main.dto.districtReport.RdPendingBuildingProjectVO;
import cn.com.countrygarden.bi.main.exception.ServiceException;
import cn.com.countrygarden.bi.main.model.AccessToken;
import cn.com.countrygarden.bi.main.model.PageData;
import cn.com.countrygarden.bi.main.model.districtReport.RdDistrictInfo;
import cn.com.countrygarden.bi.main.model.districtReport.RdPendingBuildingProject;
import cn.com.countrygarden.bi.main.model.dup.DupOrgan;
import cn.com.countrygarden.bi.main.service.districtReport.RdPendingBuildingProjectService;
import cn.com.countrygarden.bi.main.service.districtReport.RdProjectpermissionService;
import cn.com.countrygarden.bi.main.util.ExportExcelUtil;
import cn.com.countrygarden.bi.main.util.erp.StringUtil;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.apache.commons.lang.StringUtils;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.BufferedInputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;

/**
 * 待收楼项目-项目交付计划-业务逻辑层实现
 *
 * @author 吕伟峰
 * @email www.justintoforest@gamail.com
 * @url 
 * @date 2019-08-14
 */
@Service
@Transactional
public class RdPendingBuildingProjectServiceImpl implements RdPendingBuildingProjectService{
    @Autowired
    private RdPendingBuildingProjectMapper rdPendingBuildingProjectMapper;

    @Autowired
    private ManagerMapForErpMapper managerMapForErpMapper;

    @Autowired
    private RdDistrictInfoMapper rdDistrictInfoMapper;

    @Autowired
    private RdProjectpermissionService rdProjectpermissionService;

    @Override
    public Result queryPageList(RdPendingBuildingProjectDTO rdPendingBuildingProjectDTO, int page, int size,AccessToken accessToken) {

        // 获取登录人的角色授权
        Map<String, Object> rolesMap = rdProjectpermissionService.findRoleInfoMap(accessToken.getUserCode());

        List<String> organCodeString=new ArrayList<>();
        List<String> commIdString=new ArrayList<>();
        List<String> principaString=new ArrayList<>();
        List<Integer> paixu=rdProjectpermissionService.roleInfoList(rolesMap);

        for (int i=0;i<paixu.size();i++) {
            if (paixu.get(i)==1||paixu.get(i)==2){
                break;
            }else if (paixu.get(i)==3){
                principaString=rdProjectpermissionService.principalList(accessToken.getUserCode());
                break;
            }else if(paixu.get(i)==4||paixu.get(i)==5){
                organCodeString=managerMapForErpMapper.organCodeString(accessToken.getUserCode(),null);
                if(organCodeString==null||organCodeString.size()==0){
                    return null;
                }
                break;
            }else if(paixu.get(i)==6){
                //throw new ServiceException("项目进度_项目用户,无法使用此模块");
               /* commIdString=managerMapForErpMapper.commIdStringName(accessToken.getUserCode());
                if(commIdString==null||commIdString.size()==0){
                    return null;
                }*/
                rdPendingBuildingProjectDTO.setCreateBy(accessToken.getUserCode());
                organCodeString=null;
                commIdString=null;
                break;
            }
        }

        if(StringUtil.isNotBlank(rdPendingBuildingProjectDTO.getContractCloseBuildingDateList())){
            String[] openDateList=rdPendingBuildingProjectDTO.getContractCloseBuildingDateList().split(",");
            rdPendingBuildingProjectDTO.setContractCloseBuildingDate1(openDateList[0]);
            rdPendingBuildingProjectDTO.setContractCloseBuildingDate2(openDateList[1]);
        }
        if(StringUtil.isNotBlank(rdPendingBuildingProjectDTO.getTemporaryCloseBuildingDateList())){
            String[] openingDateList=rdPendingBuildingProjectDTO.getTemporaryCloseBuildingDateList().split(",");
            rdPendingBuildingProjectDTO.setTemporaryCloseBuildingDate1(openingDateList[0]);
            rdPendingBuildingProjectDTO.setTemporaryCloseBuildingDate2(openingDateList[1]);
        }

        Page<Object> pageList = PageHelper.startPage(page, size);
        List<RdPendingBuildingProjectDTO> queryPageList=rdPendingBuildingProjectMapper.queryPageList(rdPendingBuildingProjectDTO,organCodeString,commIdString,principaString);
        PageData data=new PageData(pageList);
        data.setData(pageList.getResult());
        return Response.response(data);
    }

    @Override
    public Result queryById(Integer id) {
        return Response.response(rdPendingBuildingProjectMapper.queryById(id));
    }

    @Override
    public Result buildingProjectAddone(String regionCode, String districtCode, String projectName,AccessToken accessToken) {
        Map<String, Object> rolesMap = rdProjectpermissionService.findRoleInfoMap(accessToken.getUserCode());
        List<Integer> paixu=new ArrayList<>();
        for (Map.Entry<String, Object> entry : rolesMap.entrySet()) {
            if(entry.getKey().equals("project_manager_admin")){
                paixu.add(1);
            }
            if(entry.getKey().equals("project_manager_regionAdmin")){
                paixu.add(2);
            }
            if(entry.getKey().equals("project_manager_regionUser")){
                paixu.add(3);
            }
            if(entry.getKey().equals("project_manager_projectUser")){
                paixu.add(4);
            }
            if(entry.getKey().equals("role")){
                throw new ServiceException("权限不足,无法使用此模块");
            }
        }
        Collections.sort(paixu);
        String createdBy=null;
        if(paixu.get(0)==4){
            createdBy=accessToken.getUserCode();
        }
        return Response.response(rdPendingBuildingProjectMapper.buildingProjectAddone(regionCode,districtCode,projectName,createdBy));
    }

    @Override
    public Result add(RdPendingBuildingProject rdPendingBuildingProject, AccessToken accessToken) {

        int count=rdPendingBuildingProjectMapper.districtProjectName(rdPendingBuildingProject.getProjectName());
        if(count>0){
            throw new ServiceException("项目名不能重复，请核对");
        }
        rdPendingBuildingProject.setId(null);
        rdPendingBuildingProject.setCreateTime(new Date());
        rdPendingBuildingProject.setCreateBy(accessToken.getUserCode());
        rdPendingBuildingProject.setEnable(1);
        rdPendingBuildingProjectMapper.insert(rdPendingBuildingProject);
        return Response.response();
    }

    @Override
    public Result edit(RdPendingBuildingProject rdPendingBuildingProject, AccessToken accessToken) {
        rdPendingBuildingProject.setUpdateTime(new Date());
        rdPendingBuildingProjectMapper.edit(rdPendingBuildingProject);
        return Response.response();
    }

    @Override
    public Result del(Integer id,AccessToken accessToken,String updateName) {
        int count = rdPendingBuildingProjectMapper.deleteUpdate(id,accessToken.getUserCode(),updateName);
        return Response.response(count);
    }

    @Override
    public Result delpiliang(String ids,AccessToken accessToken,String updateName) {
        String[] idString=ids.split(",");
        List<String> rids =  Arrays.asList(idString);
        rdPendingBuildingProjectMapper.delpingliangtag(rids,accessToken.getUserCode(),updateName);
        return Response.response("删除成功");
    }

    @Override
    public Result excelToxls(Integer radio, MultipartFile multipartFile, String fileName, String usname, String userCode, AccessToken accessToken) {

        SimpleDateFormat dFormat = new SimpleDateFormat("yyyy/MM/dd");
        BufferedInputStream bf = null;
        Sheet sheet = null;
        Workbook xwb = null;

        try {

            // 获取登录人的角色授权
            Map<String, Object> rolesMap = rdProjectpermissionService.findRoleInfoMap(accessToken.getUserCode());

            List<String> organCodeString=new ArrayList<>();
            List<String> commIdString=new ArrayList<>();
            List<String> principaString=new ArrayList<>();
            List<Integer> paixu=rdProjectpermissionService.roleInfoList(rolesMap);

            for (int i=0;i<paixu.size();i++) {
                if (paixu.get(i)==1||paixu.get(i)==2){
                    break;
                }else if(paixu.get(i)==3){
                    principaString=rdProjectpermissionService.principalList(accessToken.getUserCode());
                    break;
                }else if(paixu.get(i)==4||paixu.get(i)==5){
                    organCodeString=managerMapForErpMapper.organCodeString(accessToken.getUserCode(),null);
                    if(organCodeString==null||organCodeString.size()==0){
                        return null;
                    }
                    break;
                }else if(paixu.get(i)==6){
                    //throw new ServiceException("项目进度_项目用户,无法使用此模块");
                    commIdString=managerMapForErpMapper.commIdString(accessToken.getUserCode());
                    if(commIdString==null||commIdString.size()==0){
                        return null;
                    }
                    organCodeString=managerMapForErpMapper.organCodeString(userCode,commIdString);
                    if(organCodeString==null||organCodeString.size()==0){
                        return null;
                    }
                    break;
                }
            }


            CommonsMultipartFile commonsMultipartFile = (CommonsMultipartFile) multipartFile;
            bf = new BufferedInputStream(commonsMultipartFile.getInputStream());
            if (fileName.endsWith("xls")) { // Excel&nbsp;2003
                xwb = new HSSFWorkbook(bf);
            } else if (fileName.endsWith("xlsx")) { // Excel 2007/2010
                xwb = new XSSFWorkbook(bf);
            }
            sheet = xwb.getSheetAt(0);//获取第几个页面0开始
            Row row = null;
            Cell cell;
            RdPendingBuildingProjectDTO rdPendingBuildingProjectDTO=null;
            RdPendingBuildingProject rdPendingBuildingProject=null;
           List<RdPendingBuildingProjectDTO> done=new ArrayList<>();
            for (int i = 0; i < sheet.getPhysicalNumberOfRows(); i++) {
                row = sheet.getRow(i+3);
                if(row==null) {
                    break;
                }
                for(int j =0;j<sheet.getRow(i+1).getPhysicalNumberOfCells();j++) {
                    cell = row.getCell(0);
                    if(cell==null) {
                        break;
                    }
                    cell.setCellType(CellType.STRING);
                    String regionName=cell.getStringCellValue();
                    if(StringUtils.isBlank(regionName)){
                        break;
                    }

                    cell = row.getCell(1);
                    cell.setCellType(CellType.STRING);
                    String districtName=cell.getStringCellValue();

                    if(StringUtils.isBlank(districtName)){
                        throw new ServiceException("第" + (i + 4) + "行" + "片区不能为空");
                    }

                    cell = row.getCell(2);
                    cell.setCellType(CellType.STRING);
                    String projectName=cell.getStringCellValue();

                    if(StringUtils.isBlank(projectName)){
                        throw new ServiceException("第" + (i + 4) + "行" + "项目不能为空");
                    }

                    cell = row.getCell(3);
                    cell.setCellType(CellType.STRING);
                    String buildingType=cell.getStringCellValue();

                    if(StringUtils.isBlank(buildingType)){
                        throw new ServiceException("第" + (i + 4) + "行" + "建筑类型不能为空");
                    }

                    cell = row.getCell(4);
                    cell.setCellType(CellType.STRING);
                    String managerArea=cell.getStringCellValue();

                    if(StringUtils.isBlank(managerArea)){
                        throw new ServiceException("第" + (i + 4) + "行" + "接管面积不能为空");
                    }

                    cell = row.getCell(5);
                    cell.setCellType(CellType.STRING);
                    String contractCloseBuildingDate=cell.getStringCellValue();

                    if(StringUtils.isBlank(contractCloseBuildingDate)){
                        throw new ServiceException("第" + (i + 4) + "行" + "合同收楼日期不能为空");
                    }

                    cell = row.getCell(6);
                    cell.setCellType(CellType.STRING);
                    String temporaryCloseBuildingDate=cell.getStringCellValue();

                    if(StringUtils.isBlank(temporaryCloseBuildingDate)){
                        throw new ServiceException("第" + (i + 4) + "行" + "暂定收楼日期不能为空");
                    }

                    cell = row.getCell(7);
                    cell.setCellType(CellType.STRING);
                    String managerHouseholdsCount=cell.getStringCellValue();

                    if(StringUtils.isBlank(managerHouseholdsCount)){
                        throw new ServiceException("第" + (i + 4) + "行" + "接管户数不能为空");
                    }

                    cell = row.getCell(8);
                    cell.setCellType(CellType.STRING);
                    String hardcoverHouseholdsCount=cell.getStringCellValue();

                    if(StringUtils.isBlank(hardcoverHouseholdsCount)){
                        throw new ServiceException("第" + (i + 4) + "行" + "精装交付户数不能为空");
                    }

                    cell = row.getCell(9);
                    cell.setCellType(CellType.STRING);
                    String hardcoverHouseholdsArea=cell.getStringCellValue();

                    if(StringUtils.isBlank(hardcoverHouseholdsArea)){
                        throw new ServiceException("第" + (i + 4) + "行" + "精装可收费面积不能为空");
                    }

                    cell = row.getCell(10);
                    cell.setCellType(CellType.STRING);
                    String blankHouseholdsCount=cell.getStringCellValue();

                    if(StringUtils.isBlank(blankHouseholdsCount)){
                        throw new ServiceException("第" + (i + 4) + "行" + "毛坯交付户数不能为空");
                    }

                    cell = row.getCell(11);
                    cell.setCellType(CellType.STRING);
                    String blankHouseholdsArea=cell.getStringCellValue();

                    if(StringUtils.isBlank(blankHouseholdsArea)){
                        throw new ServiceException("第" + (i + 4) + "行" + "毛坯可收费面积不能为空");
                    }

                    cell = row.getCell(12);
                    cell.setCellType(CellType.STRING);
                    String propertyPrice=cell.getStringCellValue();

                    if(StringUtils.isBlank(propertyPrice)){
                        throw new ServiceException("第" + (i + 4) + "行" + "物业服务费单价不能为空");
                    }

                    cell = row.getCell(13);
                    cell.setCellType(CellType.STRING);
                    String propertyArea=cell.getStringCellValue();

                    if(StringUtils.isBlank(propertyArea)){
                        throw new ServiceException("第" + (i + 4) + "行" + "物业用房面积不能为空");
                    }

                    cell = row.getCell(14);
                    cell.setCellType(CellType.STRING);
                    String serverCenterArea=cell.getStringCellValue();

                    if(StringUtils.isBlank(serverCenterArea)){
                        throw new ServiceException("第" + (i + 4) + "行" + "物业服务中心面积不能为空");
                    }

                    List<DupOrgan> result =managerMapForErpMapper.queryAllRegionRdDistrict(regionName,null,organCodeString);
                    if (result.size()==0||result==null){
                        throw new ServiceException("第" + (i + 4) + "行" + "没有该区域,或者没有该区域权限");
                    }
                   /* List<DupComm> CaseDistrictCommName=managerMapForErpMapper.queryAllCommCaseDistrictCommName(null,projectName,commIdString);
                    if (CaseDistrictCommName.size()==0||CaseDistrictCommName==null){
                        throw new ServiceException("第" + (i + 4) + "行" + "没有该项目,或者没有该项目权限");
                    }*/
                    List<RdDistrictInfo> rdDistrictInfoBown=rdDistrictInfoMapper.rdDistrictInfoBownName(regionName,districtName,principaString);
                    rdPendingBuildingProjectDTO=new RdPendingBuildingProjectDTO();

                    Date contractCloseBuilding=null;
                    Date temporaryCloseBuilding=null;
                    if (StringUtils.isNotBlank(contractCloseBuildingDate)){
                        try {
                            contractCloseBuilding = dFormat.parse(contractCloseBuildingDate);
                            rdPendingBuildingProjectDTO.setContractCloseBuildingDate(contractCloseBuilding);
                        }catch (ParseException e) {
                            throw new ServiceException("第" + (i + 4) + "行" + "时间格式错误，请按照  yyyy/MM/dd  格式添加");
                        }catch (Exception e) {
                            throw new ServiceException("第" + (i + 4) + "行" + "时间格式错误，请按照  yyyy/MM/dd  格式添加");
                        }
                    }
                    if (StringUtils.isNotBlank(temporaryCloseBuildingDate)){
                        try {
                            temporaryCloseBuilding = dFormat.parse(temporaryCloseBuildingDate);
                            rdPendingBuildingProjectDTO.setTemporaryCloseBuildingDate(temporaryCloseBuilding);
                        }catch (ParseException e) {
                            throw new ServiceException("第" + (i + 4) + "行" + "时间格式错误，请按照  yyyy/MM/dd  格式添加");
                        }catch (Exception e) {
                            throw new ServiceException("第" + (i + 4) + "行" + "时间格式错误，请按照  yyyy/MM/dd  格式添加");
                        }
                    }

                    if (result.size()==0||result==null){
                        throw new ServiceException("第" + (i + 4) + "行" + "没有该区域");
                    }

                    if (rdDistrictInfoBown.size()==0||rdDistrictInfoBown==null){
                        throw new ServiceException("第" + (i + 4) + "行" + "没有该片区或者没有该片区权限");
                    }else {
                        rdPendingBuildingProjectDTO.setRegionCode(result.get(0).getOrganCode());
                        rdPendingBuildingProjectDTO.setDistrictCode(rdDistrictInfoBown.get(0).getDistrictCode());
                        rdPendingBuildingProjectDTO.setProjectName(projectName);
                        done=rdPendingBuildingProjectMapper.BuildingProjectOne(rdPendingBuildingProjectDTO);
                    }

                    int countMp=rdDistrictInfoMapper.countProjectMp(rdDistrictInfoBown.get(0).getDistrictCode(),projectName);
                    if(countMp==0){
                        throw new ServiceException("第" + (i + 4) + "行" + "该片区下没有这项目名称");
                    }

                    if(done.size()==0||done==null){
                        rdPendingBuildingProject=new RdPendingBuildingProject();
                        rdPendingBuildingProject.setDistrictCode(rdDistrictInfoBown.get(0).getDistrictCode());
                        //rdPendingBuildingProject.setProjectCode(CaseDistrictCommName.get(0).getCommId());
                        rdPendingBuildingProject.setProjectName(projectName);
                        rdPendingBuildingProject.setBuildingType(buildingType);
                        BigDecimal ManagerAreabd=new BigDecimal(managerArea);
                        rdPendingBuildingProject.setManagerArea(ManagerAreabd);
                        rdPendingBuildingProject.setContractCloseBuildingDate(contractCloseBuilding);
                        rdPendingBuildingProject.setTemporaryCloseBuildingDate(temporaryCloseBuilding);
                        BigDecimal ManagerHouseholdsCountbd=new BigDecimal(managerHouseholdsCount);
                        rdPendingBuildingProject.setManagerHouseholdsCount(ManagerHouseholdsCountbd);
                        BigDecimal hardcoverHouseholdsCountbd=new BigDecimal(hardcoverHouseholdsCount);
                        rdPendingBuildingProject.setHardcoverHouseholdsCount(hardcoverHouseholdsCountbd);
                        BigDecimal HardcoverHouseholdsAreabd=new BigDecimal(hardcoverHouseholdsArea);
                        rdPendingBuildingProject.setHardcoverHouseholdsArea(HardcoverHouseholdsAreabd);
                        BigDecimal BlankHouseholdsCountbd=new BigDecimal(blankHouseholdsCount);
                        rdPendingBuildingProject.setBlankHouseholdsCount(BlankHouseholdsCountbd);
                        BigDecimal BlankHouseholdsAreabd=new BigDecimal(blankHouseholdsArea);
                        rdPendingBuildingProject.setBlankHouseholdsArea(BlankHouseholdsAreabd);
                        BigDecimal PropertyPricebd=new BigDecimal(propertyPrice);
                        rdPendingBuildingProject.setPropertyPrice(PropertyPricebd);
                        BigDecimal PropertyAreabd=new BigDecimal(propertyArea);
                        rdPendingBuildingProject.setPropertyArea(PropertyAreabd);
                        BigDecimal ServerCenterAreabd=new BigDecimal(serverCenterArea);
                        rdPendingBuildingProject.setServerCenterArea(ServerCenterAreabd);
                        rdPendingBuildingProject.setEnable(1);
                        rdPendingBuildingProject.setCreateTime(new Date());
                        rdPendingBuildingProject.setCreateBy(accessToken.getUserCode());
                        rdPendingBuildingProject.setCreateName(usname);
                        rdPendingBuildingProjectMapper.insert(rdPendingBuildingProject);
                    }else {
                        rdPendingBuildingProject=new RdPendingBuildingProject();
                        rdPendingBuildingProject.setId(done.get(0).getId());
                        rdPendingBuildingProject.setProjectName(projectName);
                        rdPendingBuildingProject.setBuildingType(buildingType);
                        BigDecimal ManagerAreabd=new BigDecimal(managerArea);
                        rdPendingBuildingProject.setManagerArea(ManagerAreabd);
                        rdPendingBuildingProject.setContractCloseBuildingDate(contractCloseBuilding);
                        rdPendingBuildingProject.setTemporaryCloseBuildingDate(temporaryCloseBuilding);
                        BigDecimal ManagerHouseholdsCountbd=new BigDecimal(managerHouseholdsCount);
                        rdPendingBuildingProject.setManagerHouseholdsCount(ManagerHouseholdsCountbd);
                        BigDecimal hardcoverHouseholdsCountbd=new BigDecimal(hardcoverHouseholdsCount);
                        rdPendingBuildingProject.setHardcoverHouseholdsCount(hardcoverHouseholdsCountbd);
                        BigDecimal HardcoverHouseholdsAreabd=new BigDecimal(hardcoverHouseholdsArea);
                        rdPendingBuildingProject.setHardcoverHouseholdsArea(HardcoverHouseholdsAreabd);
                        BigDecimal BlankHouseholdsCountbd=new BigDecimal(blankHouseholdsCount);
                        rdPendingBuildingProject.setBlankHouseholdsCount(BlankHouseholdsCountbd);
                        BigDecimal BlankHouseholdsAreabd=new BigDecimal(blankHouseholdsArea);
                        rdPendingBuildingProject.setBlankHouseholdsArea(BlankHouseholdsAreabd);
                        BigDecimal PropertyPricebd=new BigDecimal(propertyPrice);
                        rdPendingBuildingProject.setPropertyPrice(PropertyPricebd);
                        BigDecimal PropertyAreabd=new BigDecimal(propertyArea);
                        rdPendingBuildingProject.setPropertyArea(PropertyAreabd);
                        BigDecimal ServerCenterAreabd=new BigDecimal(serverCenterArea);
                        rdPendingBuildingProject.setServerCenterArea(ServerCenterAreabd);
                        rdPendingBuildingProject.setUpdateTime(new Date());
                        rdPendingBuildingProject.setUpdateBy(usname);
                        rdPendingBuildingProjectMapper.edit(rdPendingBuildingProject);
                    }
                    j+=14;
                }
            }
            return Response.response("导入成功");
        }catch (IOException e1) {
            e1.printStackTrace();
            throw new ServiceException("导入失败！请稍后重试！");
        }
    }

    @Override
    public HSSFWorkbook exportAllRdPendingBuildingProject(AccessToken accessToken, HttpServletResponse response) throws IOException {

        // 获取登录人的角色授权
        Map<String, Object> rolesMap = rdProjectpermissionService.findRoleInfoMap(accessToken.getUserCode());

        List<String> organCodeString=new ArrayList<>();
        List<String> commIdString=new ArrayList<>();
        List<String> principaString=new ArrayList<>();
        List<Integer> paixu=rdProjectpermissionService.roleInfoList(rolesMap);

        RdPendingBuildingProjectDTO rdPendingBuildingProjectDTO=new RdPendingBuildingProjectDTO();
        for (int i=0;i<paixu.size();i++) {
            if (paixu.get(i)==1||paixu.get(i)==2){
                break;
            }else if(paixu.get(i)==3){
                principaString=rdProjectpermissionService.principalList(accessToken.getUserCode());
                break;
            }else if(paixu.get(i)==4||paixu.get(i)==5){
                organCodeString=managerMapForErpMapper.organCodeString(accessToken.getUserCode(),null);
                if(organCodeString==null||organCodeString.size()==0){
                    return null;
                }
                break;
            }else if(paixu.get(i)==6){
               /* commIdString=managerMapForErpMapper.commIdString(accessToken.getUserCode());
                if(commIdString==null||commIdString.size()==0){
                    return null;
                }*/
                rdPendingBuildingProjectDTO.setCreateBy(accessToken.getUserCode());
                commIdString=null;
                organCodeString=null;
                break;
            }
        }
        ExportExcelUtil util = new ExportExcelUtil();
        String[] columnNamesjiaofu = {"区域名称","片区名称" ,"项目名称"  , "建筑类型" , "接管面积（万㎡）" , "合同收楼日期","暂定收楼日期","接管户数",
                "精装交付户数" ,"精装可收费面积（万㎡）","毛坯交付户数","毛坯可收费面积（万㎡）","物业费单价（元/㎡/月）","物业用房面积（㎡）","物业服务中心面积（㎡）"
        };
        Collection<RdPendingBuildingProjectVO> listjiaofu=rdPendingBuildingProjectMapper.evaluationrdUncollectedBuildingProjects(rdPendingBuildingProjectDTO,organCodeString,commIdString,principaString);
        HSSFWorkbook result1jiaofu = util.getWorkbook2003("项目交付计划", columnNamesjiaofu,listjiaofu, response.getOutputStream(), "yyyy-MM-dd HH:mm:ss", null);
        return result1jiaofu;
    }

}