package org.jeecg.modules.projectManagement.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.jeecg.modules.projectManagement.entity.*;
import org.jeecg.modules.projectManagement.mapper.FdClinicalProjectMilestonesItemsMapper;
import org.jeecg.modules.projectManagement.mapper.FdClinicalProjectMilestonesMapper;
import org.jeecg.modules.basedata.service.*;
import org.jeecg.modules.projectManagement.mapper.FdMilestonesProgressChangeMapper;
import org.jeecg.modules.projectManagement.service.*;
import org.jeecg.modules.system.entity.SysUser;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.*;

/**
 * @Description: 临床项目里程碑
 * @author： jeecg-boot
 * @date： 2019-06-03
 * @version： V1.0
 */
@Service
@Transactional
public class FdClinicalProjectMilestonesServiceImpl extends ServiceImpl<FdClinicalProjectMilestonesMapper, FdClinicalProjectMilestones> implements IFdClinicalProjectMilestonesService {

    @Resource
    FdClinicalProjectMilestonesMapper fdClinicalProjectMilestonesMapper;

    @Resource
    IFdClinicalProjectMilestonesService fdClinicalProjectMilestonesService;

    @Resource
    IFdClinicalProjectMilestonesItemsService fdClinicalProjectMilestonesItemsService;

    @Resource
    IFdProjectFileService fdProjectFileService;

    @Resource
    IFdContractService fdContractService;

    @Resource
    IFdMilestoneTemplateService fdMilestoneTemplateService;

    @Resource
    FdClinicalProjectMilestonesItemsMapper fdClinicalProjectMilestonesItemsMapper;
    @Resource
    IFdProjectFileMembersService fdProjectFileMembersService;
    @Resource
    IFdContractProportionService iFdContractProportionService;
    @Resource
    IFdMilestonesProgressChangeService iFdMilestonesProgressChangeService;
    @Resource
    FdMilestonesProgressChangeMapper fdMilestonesProgressChangeMapper;
    @Resource
    IFdBioanalysisSampleMilestonesService iFdBioanalysisSampleMilestonesService;

    @Override
    public IPage<FdClinicalProjectMilestones> findByPage(Page<FdClinicalProjectMilestones> page, QueryWrapper<FdClinicalProjectMilestones> queryWrapper) {
        return fdClinicalProjectMilestonesMapper.findByPage(page, queryWrapper);
    }

    /**
     * @return void
     * @Author gurui
     * @Description //TODO  添加项目里程碑 同时添加 项目里程碑明细
     * @Date 11:01 2019/6/4
     * @Param [fdClinicalProjectMilestones]
     **/
    @Override
    public void addAll(FdClinicalProjectMilestones fdClinicalProjectMilestones) {
        //查询项目档案的成员
        LambdaQueryWrapper<FdProjectFileMembers> projectFileMembersLambdaQueryWrapper = new LambdaQueryWrapper<>();
        projectFileMembersLambdaQueryWrapper.eq(FdProjectFileMembers::getProjectId, fdClinicalProjectMilestones.getPkProjectFile());
        List<FdProjectFileMembers> projectFileMembersList = fdProjectFileMembersService.list(projectFileMembersLambdaQueryWrapper);
        //获取成员id
        int ii = 0;
        String personnelIds = "";
        for (FdProjectFileMembers fdProjectFileMembers : projectFileMembersList) {
            if (ii == 0) {
                personnelIds = fdProjectFileMembers.getPersonnelName();
            } else {
                personnelIds = personnelIds + "," + fdProjectFileMembers.getPersonnelName();
            }
            ii++;
        }
        //获取项目经理id、
        // FdProjectFile fdProjectFile = fdClinicalProjectMilestonesMapper.getProjectQuotationByContractId(fdClinicalProjectMilestones.getPkProjectFile());
        FdProjectFile fdProjectFile=fdProjectFileService.getById(fdClinicalProjectMilestones.getPkProjectFile());
        fdClinicalProjectMilestones.setProjectManagerId(fdProjectFile.getProjectManagerId());
        fdClinicalProjectMilestones.setPersonnelIds(personnelIds);
        //新增
        if (fdClinicalProjectMilestones.getId() == null || fdClinicalProjectMilestones.getId() == "") {
            fdClinicalProjectMilestones.setDelFlag("0");
            fdClinicalProjectMilestonesService.save(fdClinicalProjectMilestones);
        } else {
            //修改
            fdClinicalProjectMilestonesService.updateById(fdClinicalProjectMilestones);
            LambdaQueryWrapper<FdClinicalProjectMilestonesItems> queryWrapper1 = new LambdaQueryWrapper<>();
            queryWrapper1.eq(FdClinicalProjectMilestonesItems::getPkClinicalProjectMilestones, fdClinicalProjectMilestones.getId());
            fdClinicalProjectMilestonesItemsService.remove(queryWrapper1);

        }
        //保存模板类型集合
        List<FdClinicalProjectMilestonesItems> fdClinicalProjectMilestonesItemsList = fdClinicalProjectMilestones.getFdClinicalProjectMilestonesItemsList();
        int i = 1;
        for (FdClinicalProjectMilestonesItems fdClinicalProjectMilestonesItems : fdClinicalProjectMilestonesItemsList) {
            fdClinicalProjectMilestonesItems.setPid(fdClinicalProjectMilestonesItems.getId());
            fdClinicalProjectMilestonesItems.setId("");
            fdClinicalProjectMilestonesItems.setSort(i + "");
            fdClinicalProjectMilestonesItems.setCreateBy("");
            fdClinicalProjectMilestonesItems.setCreateTime(null);
            fdClinicalProjectMilestonesItems.setPkClinicalProjectMilestones(fdClinicalProjectMilestones.getId());
            i++;
        }
        //添加模板项
        fdClinicalProjectMilestonesItemsService.saveBatch(fdClinicalProjectMilestonesItemsList);
        getIdUpdatePid(fdClinicalProjectMilestonesItemsList);
        fdClinicalProjectMilestonesItemsMapper.parentIdBatch(fdClinicalProjectMilestonesItemsList);
    }

    /***
     * @Title:详情修改
            * @Description:TODO
            * @param fdClinicalProjectMilestones
            * @return void
            * @exception
            * @author 陈创
            * @date 2019/9/24 16:28
            * @updatehistory:
     *   2019/9/24 16:28 修改
            */
    @Override
    public void viewUpdateMilestonesItems(FdClinicalProjectMilestones fdClinicalProjectMilestones) {
        //主表修改
        FdClinicalProjectMilestones fdClinicalProjectMilestones1=new FdClinicalProjectMilestones();
        fdClinicalProjectMilestones1.setId(fdClinicalProjectMilestones.getId());
        fdClinicalProjectMilestones1.setOverallProgress(fdClinicalProjectMilestones.getOverallProgress());
        //获取
        contractOverallProgress(fdClinicalProjectMilestones1);
        fdClinicalProjectMilestonesMapper.updateById(fdClinicalProjectMilestones1);

        //--子表保存
        LambdaQueryWrapper<FdClinicalProjectMilestonesItems> queryWrapper1 = new LambdaQueryWrapper<>();
        queryWrapper1.eq(FdClinicalProjectMilestonesItems::getPkClinicalProjectMilestones, fdClinicalProjectMilestones.getId());
        fdClinicalProjectMilestonesItemsService.remove(queryWrapper1);
        //保存模板类型集合
        int i = 1;
        List<FdClinicalProjectMilestonesItems> fdClinicalProjectMilestonesItemsList = fdClinicalProjectMilestones.getFdClinicalProjectMilestonesItemsList();
        for (FdClinicalProjectMilestonesItems fdClinicalProjectMilestonesItems : fdClinicalProjectMilestonesItemsList) {
            fdClinicalProjectMilestonesItems.setPid(fdClinicalProjectMilestonesItems.getId());
            fdClinicalProjectMilestonesItems.setId("");
            fdClinicalProjectMilestonesItems.setSort(i + "");
            fdClinicalProjectMilestonesItems.setPkClinicalProjectMilestones(fdClinicalProjectMilestones.getId());
            i++;
        }
        //添加模板项
        fdClinicalProjectMilestonesItemsService.saveBatch(fdClinicalProjectMilestonesItemsList);
        getIdUpdatePid(fdClinicalProjectMilestonesItemsList);
        fdClinicalProjectMilestonesItemsMapper.parentIdBatch(fdClinicalProjectMilestonesItemsList);
    }


    /***
     * @Title:根据合同比例计算合同里程碑总进度并查询里程碑项目进度是否有改变是否记录
            * @Description:TODO
            * @param fdClinicalProjectMilestones
            * @return void
            * @exception
            * @author 陈创
            * @date 2019/9/24 16:11
            * @updatehistory:
     *   2019/9/24 16:11 修改
            */
    public void contractOverallProgress(FdClinicalProjectMilestones fdClinicalProjectMilestones){
        //根据id查询里程碑对象
        FdClinicalProjectMilestones fdClinicalProjectMilestonesById=fdClinicalProjectMilestonesMapper.selectById(fdClinicalProjectMilestones.getId());
        //当前里程碑总进度
        double overallProgress=Double.parseDouble(fdClinicalProjectMilestones.getOverallProgress());
        //查询合同里程碑比例
        LambdaQueryWrapper<FdContractProportion> fdContractClauseLambdaQueryWrapper=new LambdaQueryWrapper<>();
        fdContractClauseLambdaQueryWrapper.eq(FdContractProportion::getContractId,fdClinicalProjectMilestonesById.getPkContract());
        //比例集合
        List<FdContractProportion> fdContractProportionList=iFdContractProportionService.list(fdContractClauseLambdaQueryWrapper);
        if(!fdContractProportionList.isEmpty()&&fdContractProportionList.size()>0){
            double clinPro=0.00;
            //循环比例集合
            for(FdContractProportion fdContractProportion:fdContractProportionList){
                //获取临床比例
                if(fdContractProportion.getProportionItem().equals("临床项目")){
                    String clinProS=fdContractProportion.getProportion().replace("%","");
                    //临床比例
                    clinPro=Double.parseDouble(clinProS);
                    //获取根据合同比例算出的总进度
                    fdClinicalProjectMilestones.setContractOverallProgress(String.format("%.2f",(clinPro*overallProgress)/100));
                }
            }
        }

        //记录项目进度有变化的里程碑项目
        saveMilestoneProgressChange(fdClinicalProjectMilestones,fdClinicalProjectMilestonesById);
    }

    /***
     * @Title:记录进度变化的里程碑
            * @Description:TODO
            * @param fdClinicalProjectMilestones, fdClinicalProjectMilestonesById]
            * @return void
            * @exception 
            * @author 陈创
            * @date 2019/9/24 16:26
            * @updatehistory:
     *   2019/9/24 16:26 新增
            */
    public void saveMilestoneProgressChange(FdClinicalProjectMilestones fdClinicalProjectMilestones,FdClinicalProjectMilestones fdClinicalProjectMilestonesById){
        if(StringUtils.isNotBlank(fdClinicalProjectMilestones.getOverallProgress())) {
            //判断现在的项目进度是否与之前进度不一样
            if (!fdClinicalProjectMilestonesById.getOverallProgress().equals(fdClinicalProjectMilestones.getOverallProgress())) {
                FdMilestonesProgressChange fdMilestonesProgressChange = new FdMilestonesProgressChange();
                fdMilestonesProgressChange.setMilestonesId(fdClinicalProjectMilestones.getId());
                fdMilestonesProgressChange.setChangeTime(new Date());
                iFdMilestonesProgressChangeService.save(fdMilestonesProgressChange);
            }
        }
    }

    /***
     * @Title:查询已审核的项目报价的合同
     * @Description:TODO
     * @param
     * @return java.util.List<org.jeecg.modules.projectManagement.entity.FdContract>
     * @exception
     * @author 陈创
     * @date 2019/7/7 17:33
     * @updatehistory:
     *   2019/7/7 17:33 新增
     */
    @Override
    public List<FdContract> getFileContractList() {
        List<FdContract> fdContractList = fdClinicalProjectMilestonesMapper.getFileContractList();
        List<FdContract> fdContractList1 = new ArrayList<>();
        //当前登陆用户信息
        SysUser user = (SysUser) SecurityUtils.getSubject().getPrincipal();
        if (user.getUsername().equals("admin")) {
            fdContractList1 = fdContractList;
        } else {
            if (fdContractList != null && fdContractList.size() > 0) {
                //循环项目档案中合同数据
                for (FdContract fdContract : fdContractList) {
                    //获取项目档案的分配人员IDs
                    String personnelWithAuthorityIds = fdContract.getPersonnelWithAuthorityIds();
                    //判断是否为空
                    if (personnelWithAuthorityIds != null && personnelWithAuthorityIds != "") {
                        //存在ids中则拿到合同对象
                        if(personnelWithAuthorityIds.indexOf(user.getPersonnelId())!=-1){
                            fdContractList1.add(fdContract);
                        }
                        // FdContract fdContract1 = new FdContract();
                        // //截取IDS，循环
                        // for (String perId : personnelWithAuthorityIds.split(",")) {
                        //     //判断当前登陆人员是否存在ID是中
                        //     if (perId.equals(user.getPersonnelId())) {
                        //         fdContract1 = fdContract;
                        //     }
                        // }
                        // fdContractList1.add(fdContract1);
                    }

                }
            }
        }

        return fdContractList1;
    }

    /**
     * @return java.util.List<org.jeecg.modules.projectManagement.entity.FdClinicalProjectMilestones>
     * @Author gurui
     * @Description //TODO 根据临床里程碑id查询里程碑模板类型
     * @Date 11:26 2019/6/19
     * @Param [id]
     **/
    @Override
    public List<FdClinicalProjectMilestones> getByMilestonesId(String id) {
        return fdClinicalProjectMilestonesMapper.getByMilestonesId(id);
    }


    /***
     * @Title:根据合同id查询相关信息
     * @Description:TODO
     * @param projectFileId
     * @return org.jeecg.modules.projectManagement.entity.FdContract
     * @exception
     * @author 陈创
     * @date 2019/6/19 16:44
     * @updatehistory:
     *   2019/6/19 16:44 查询
     */
    @Override
    public FdClinicalProjectMilestones getClinicalByConId(String projectFileId) {
        return fdClinicalProjectMilestonesMapper.getClinicalByConId(projectFileId);
    }

    /**
     * @return void
     * @Author gurui
     * @Description //TODO 删除里程碑同时删除模板项
     * @Date 17:53 2019/6/26
     * @Param [id]
     **/
    @Override
    public void deleteAll(String id) {
        //根据id查询里程碑
        FdClinicalProjectMilestones clinicalProjectMilestones = fdClinicalProjectMilestonesMapper.selectById(id);
        //查询模板项
        LambdaQueryWrapper<FdClinicalProjectMilestonesItems> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(FdClinicalProjectMilestonesItems::getPkClinicalProjectMilestones, clinicalProjectMilestones.getId());
        //删除里程碑项目模板
        fdClinicalProjectMilestonesItemsService.remove(queryWrapper);
        //删除里程碑
        fdClinicalProjectMilestonesService.removeById(id);
    }

    /**
     * @return void
     * @Author gurui
     * @Description //TODO 根据里程碑id复制一条一样的数据
     * @Date 13:26 2019/6/28
     * @Param [id]
     **/
    @Override
    public void copy(String id) {
        //根据id获取里程碑
        FdClinicalProjectMilestones fdClinicalProjectMilestones = fdClinicalProjectMilestonesMapper.selectById(id);
        //根据模板保存
        fdClinicalProjectMilestones.setId("");
        fdClinicalProjectMilestones.setCreateTime(null);
        fdClinicalProjectMilestones.setClinicalCode(fdClinicalProjectMilestones.getClinicalCode() + "(副本)");
        fdClinicalProjectMilestones.setOverallProgress(null);
        fdClinicalProjectMilestones.setContractOverallProgress(null);
        fdClinicalProjectMilestonesService.save(fdClinicalProjectMilestones);
        //里程碑明细
        LambdaQueryWrapper<FdClinicalProjectMilestonesItems> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.eq(FdClinicalProjectMilestonesItems::getPkClinicalProjectMilestones, id);
        List<FdClinicalProjectMilestonesItems> fdClinicalProjectMilestonesItems = fdClinicalProjectMilestonesItemsService.list(queryWrapper);
        // fdClinicalProjectMilestones.setFdClinicalProjectMilestonesItemsList(fdClinicalProjectMilestonesItems);
        for (FdClinicalProjectMilestonesItems fdClinicalProjectMilestonesItems1 : fdClinicalProjectMilestonesItems) {
            fdClinicalProjectMilestonesItems1.setPid(fdClinicalProjectMilestonesItems1.getId());
            fdClinicalProjectMilestonesItems1.setId("");
            fdClinicalProjectMilestonesItems1.setCreateBy("");
            fdClinicalProjectMilestonesItems1.setCreateTime(null);
            fdClinicalProjectMilestonesItems1.setPkClinicalProjectMilestones(fdClinicalProjectMilestones.getId());
            fdClinicalProjectMilestonesItems1.setActualStartTime(null);
            fdClinicalProjectMilestonesItems1.setActualEndTime(null);
            fdClinicalProjectMilestonesItems1.setCompletionTimeDifference(null);
            fdClinicalProjectMilestonesItems1.setClinicalUrl(null);
            fdClinicalProjectMilestonesItems1.setProjectProgress(null);
        }
        fdClinicalProjectMilestonesItemsService.saveBatch(fdClinicalProjectMilestonesItems);
        getIdUpdatePid(fdClinicalProjectMilestonesItems);
        fdClinicalProjectMilestonesItemsMapper.parentIdBatch(fdClinicalProjectMilestonesItems);
    }

    void getIdUpdatePid(List<FdClinicalProjectMilestonesItems> list) {
        for (FdClinicalProjectMilestonesItems fdClinicalProjectMilestonesItems : list) {
            for (FdClinicalProjectMilestonesItems fdClinicalProjectMilestonesItems1 : list) {
                if (fdClinicalProjectMilestonesItems.getPid().equals(fdClinicalProjectMilestonesItems1.getParentId())) {
                    fdClinicalProjectMilestonesItems1.setParentId(fdClinicalProjectMilestonesItems.getId());
                }
            }
        }
    }

    /**
     * @return java.util.Map<java.lang.String   ,   java.lang.Object>
     * @Author gurui
     * @Description //TODO 批量弃审数据 使其状态为0
     * @Date 13:49 2019/6/28
     * @Param [list]
     **/
    @Override
    public Map<String, Object> auditBatch(List<String> ids) {
        Map<String, Object> map = new HashMap<>();
        String unAudit = " ";//可审计
        String audit = " ";//已审计
        //根据多个id查询报价对象集合
        List<FdClinicalProjectMilestones> fdClinicalProjectMilestonesList = fdClinicalProjectMilestonesMapper.selectBatchIds(ids);
        //修改
        if (fdClinicalProjectMilestonesList == null || fdClinicalProjectMilestonesList.isEmpty()) {
            audit += "未找到修改数据</br>";
        } else {
            //判断哪些可关闭哪些不可关闭
            for (FdClinicalProjectMilestones fdClinicalProjectMilestones : fdClinicalProjectMilestonesList) {
                if (fdClinicalProjectMilestones.getStatus().equals("0")) {
                    audit += fdClinicalProjectMilestones.getProjectName() + "，";
                } else {
                    unAudit += fdClinicalProjectMilestones.getProjectName() + "，";
                }
            }
            //可关闭存在则操作数据库修改
            if (!unAudit.equals("")) {
                fdClinicalProjectMilestonesMapper.auditBatch(ids);
            }
        }
        //去掉最后一个"，"号
        audit = audit.substring(0, audit.length() - 1);
        unAudit = unAudit.substring(0, unAudit.length() - 1);
        //加关键词
        if (!unAudit.equals("")) {
            unAudit = unAudit + "弃审核成功";
        }
        if (!audit.equals("")) {
            audit = "其中:" + audit + "已处于未审核状态。<br> ";
        }
        map.put("msg", unAudit + audit);
        return map;
    }

    /**
     * @return java.util.Map<java.lang.String   ,   java.lang.Object>
     * @Author gurui
     * @Description //TODO 批量审核数据 使其状态为1
     * @Date 13:50 2019/6/28
     * @Param [list]
     **/
    @Override
    public Map<String, Object> reviewBatch(List<String> ids) {
        Map<String, Object> map = new HashMap<>();
        String unReview = " "; //未审核
        String review = " "; //已审核
        //根据多个id查询报价对象集合
        List<FdClinicalProjectMilestones> fdClinicalProjectMilestonesList = fdClinicalProjectMilestonesMapper.selectBatchIds(ids);
        //修改
        if (fdClinicalProjectMilestonesList == null || fdClinicalProjectMilestonesList.isEmpty()) {
            review += "未找到修改数据</br>";
        } else {
            //判断哪些已审核哪些未审核
            for (FdClinicalProjectMilestones fdClinicalProjectMilestones : fdClinicalProjectMilestonesList) {
                if (fdClinicalProjectMilestones.getStatus().equals("0")) {
                    unReview += fdClinicalProjectMilestones.getProjectName();
                }
                if (fdClinicalProjectMilestones.getStatus().equals("1")) {
                    review += fdClinicalProjectMilestones.getProjectName();
                }
                if (fdClinicalProjectMilestones.getStatus().equals("2")) {
                    throw new RuntimeException("已关闭！无法审核");
                }
                if (fdClinicalProjectMilestones.getStatus().equals("3")) {
                    throw new RuntimeException("已转合同！无法审核");
                }
            }
            //去掉最后一个","号
            unReview = unReview.substring(0, unReview.length() - 1);
            review = review.substring(0, review.length() - 1);
            //操作数据库将未审核的修改成已审核
            if (!unReview.equals("")) {
                fdClinicalProjectMilestonesMapper.reviewBatch(ids);
            }
        }
        //加关键词
        if (!unReview.equals("")) {
            unReview = unReview + "审核成功";
        }
        if (!review.equals("")) {
            review = "其中：" + review + "已审核。<br>";
        }
        map.put("msg", unReview + review);
        return map;
    }

    /***
     * @Title:生物分析里程碑进度变化报表
     * @Description:TODO
     * @param endDate, endDate]
     * @return java.util.List<org.jeecg.modules.projectManagement.entity.FdBioanalysisSampleMilestones>
     * @exception
     * @author 陈创
     * @date 2019/9/24 18:26
     * @updatehistory:
     *   2019/9/24 18:26 新增
     */
    @Override
    public List<FdClinicalProjectMilestones> progressReport(String startDate, String endDate) {
        //记录进度变动的数据
        List<FdMilestonesProgressChange> fdMilestonesProgressChangeList=fdMilestonesProgressChangeMapper.getByChangeTime(startDate,endDate);
        //全部临床里程碑进度
        LambdaQueryWrapper<FdClinicalProjectMilestones> queryWrapperClinMil=new LambdaQueryWrapper<>();
        queryWrapperClinMil.eq(FdClinicalProjectMilestones::getDelFlag,"0");
        List<FdClinicalProjectMilestones> fdClinicalProjectMilestonesList=fdClinicalProjectMilestonesService.list(queryWrapperClinMil);
        //获取报表数据
        List<FdClinicalProjectMilestones> fdClinicalProjectMilestonesListResult=new ArrayList<>();
        if(!fdMilestonesProgressChangeList.isEmpty()&&fdMilestonesProgressChangeList.size()>0&&!fdClinicalProjectMilestonesList.isEmpty()&&fdClinicalProjectMilestonesList.size()>0){
            bioProgressList(fdMilestonesProgressChangeList,fdClinicalProjectMilestonesList,fdClinicalProjectMilestonesListResult);
        }
        return fdClinicalProjectMilestonesListResult;
    }

    /***
     * @Title:获取进度有变化的里程碑数据
     * @Description:TODO
     * @param fdMilestonesProgressChangeList, fdBioanalysisSampleMilestonesList, fdBioanalysisSampleMilestonesListResult]
     * @return void
     * @exception
     * @author 陈创
     * @date 2019/9/24 18:25
     * @updatehistory:
     *   2019/9/24 18:25 新增
     */
    public void bioProgressList(List<FdMilestonesProgressChange> fdMilestonesProgressChangeList,List<FdClinicalProjectMilestones> fdClinicalProjectMilestonesList,List<FdClinicalProjectMilestones> fdClinicalProjectMilestonesListResult){
        //循环进度有变化的记录数据
        for(FdMilestonesProgressChange fdMilestonesProgressChange:fdMilestonesProgressChangeList){
            //变动里程碑id
            String changeMilestonesId=fdMilestonesProgressChange.getMilestonesId();
            //循环全部临床里程碑
            for(FdClinicalProjectMilestones fdClinicalProjectMilestones:fdClinicalProjectMilestonesList){
                //临床里程碑id
                String cliMilestonesId=fdClinicalProjectMilestones.getId();
                //记录中存在则获取
                if(changeMilestonesId.equals(cliMilestonesId)){
                    fdClinicalProjectMilestonesListResult.add(fdClinicalProjectMilestones);
                }
            }
        }
    }

    /***
     * @Title:生物分析以及临床进度变化数据报表
            * @Description:TODO
            * @param startDate, endDate]
            * @return java.util.List<org.jeecg.modules.projectManagement.entity.FdClinicalProjectMilestones>
            * @exception
            * @author 陈创
            * @date 2019/9/24 19:40
            * @updatehistory:
     *   2019/9/24 19:40 新增
            */
    @Override
    public List<FdClinicalProjectMilestones> clinAndBioProgressReport(String startDate, String endDate){
        //临床进度变化数据
        List<FdClinicalProjectMilestones> clinicalProjectMilestonesList=fdClinicalProjectMilestonesService.progressReport(startDate,endDate);
        //生物分析进度变化数据
        List<FdBioanalysisSampleMilestones> bioanalysisSampleMilestonesList=iFdBioanalysisSampleMilestonesService.progressReport(startDate,endDate);
        if(!bioanalysisSampleMilestonesList.isEmpty()&&bioanalysisSampleMilestonesList.size()>0){
            //循环生物分析进度变化数据
            for(FdBioanalysisSampleMilestones fdBioanalysisSampleMilestones:bioanalysisSampleMilestonesList){
                //存取到临床集合中
                FdClinicalProjectMilestones fdClinicalProjectMilestones=new FdClinicalProjectMilestones();
                fdClinicalProjectMilestones.setContractCode(fdBioanalysisSampleMilestones.getContractCode());
                fdClinicalProjectMilestones.setCreateTime(fdBioanalysisSampleMilestones.getCreateTime());
                fdClinicalProjectMilestones.setContractOverallProgress(fdBioanalysisSampleMilestones.getContractOverallProgress());
                clinicalProjectMilestonesList.add(fdClinicalProjectMilestones);
            }
        }
        return clinicalProjectMilestonesList;
    }

    @Override
    public List<FdClinicalProjectMilestones> getMainExport(FdClinicalProjectMilestones fdClinicalProjectMilestones) {
        return fdClinicalProjectMilestonesMapper.getMainExport(fdClinicalProjectMilestones);
    }

}
