|  |  | 
 |  |  | package com.doumee.service.business.impl; | 
 |  |  |  | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.doumee.biz.system.SystemDictDataBiz; | 
 |  |  | import com.doumee.core.constants.ResponseStatus; | 
 |  |  | import com.doumee.core.exception.BusinessException; | 
 |  |  | import com.doumee.core.model.PageData; | 
 |  |  | import com.doumee.core.model.PageWrap; | 
 |  |  | import com.doumee.core.utils.Constants; | 
 |  |  | import com.doumee.core.utils.DateUtil; | 
 |  |  | import com.doumee.core.utils.Utils; | 
 |  |  | import com.doumee.dao.business.*; | 
 |  |  | import com.doumee.dao.business.dao.CompanyMapper; | 
 |  |  | import com.doumee.dao.business.dto.ApproveDTO; | 
 |  |  | import com.doumee.dao.business.join.ApproveJoinMapper; | 
 |  |  | import com.doumee.dao.business.join.CarUseBookJoinMapper; | 
 |  |  | import com.doumee.dao.business.join.VisitsJoinMapper; | 
 |  |  | import com.doumee.dao.business.model.*; | 
 |  |  | import com.doumee.dao.business.vo.ApproveDataVO; | 
 |  |  | import com.doumee.dao.system.dto.NoticesDTO; | 
 |  |  | import com.doumee.dao.system.join.NoticesJoinMapper; | 
 |  |  | import com.doumee.dao.system.model.Notices; | 
 |  |  | import com.doumee.dao.system.model.SystemUser; | 
 |  |  | import com.doumee.dao.web.response.InternalHomeVO; | 
 |  |  | import com.doumee.service.business.ApproveService; | 
 |  |  | 
 |  |  | import com.doumee.service.system.NoticesService; | 
 |  |  | import com.github.xiaoymin.knife4j.core.util.CollectionUtils; | 
 |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
 |  |  | import io.swagger.models.auth.In; | 
 |  |  | import lombok.extern.slf4j.Slf4j; | 
 |  |  | import org.apache.commons.lang3.StringUtils; | 
 |  |  | import org.apache.xpath.operations.Bool; | 
 |  |  | import org.springframework.beans.BeanUtils; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.context.annotation.Bean; | 
 |  |  | import org.springframework.stereotype.Service; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  |  | 
 |  |  | 
 |  |  |  * @date 2023/12/28 14:09 | 
 |  |  |  */ | 
 |  |  | @Service | 
 |  |  | @Slf4j | 
 |  |  | public class ApproveServiceImpl implements ApproveService { | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private VisitsMapper visitsMapper; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private VisitsJoinMapper visitsJoinMapper; | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private CarUseBookJoinMapper carUseBookJoinMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private NoticesJoinMapper noticesJoinMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PlatformBooksMapper platformBooksMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PlatformJobMapper platformJobMapper; | 
 |  |  |     @Autowired | 
 |  |  |     private PlatformLogMapper platformLogMapper; | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public Integer create(Approve approve) { | 
 |  |  | 
 |  |  |     /** | 
 |  |  |      * 内部人员H5页面首页 | 
 |  |  |      * @param memberId | 
 |  |  |      * @param isDetail 是否查询详细 1是;0否 | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public InternalHomeVO getHomeData(Integer memberId){ | 
 |  |  |     public InternalHomeVO getHomeDataH5(Integer memberId,Integer isDetail){ | 
 |  |  |         InternalHomeVO internalHomeVO = new InternalHomeVO(); | 
 |  |  |         internalHomeVO.setHomeImg(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.HOME_IMAGE).getCode()); | 
 |  |  |         internalHomeVO.setTaskNum(approveMapper.selectCount(new QueryWrapper<Approve>().lambda().eq(Approve::getChekorId,memberId).eq(Approve::getStatus,Constants.ZERO))); | 
 |  |  |         //任务数据 | 
 |  |  |         List<Notices> noticesList = noticesJoinMapper. | 
 |  |  |                 selectList(new QueryWrapper<Notices>().lambda() | 
 |  |  |                         .eq(Notices::getUserId,memberId).orderByDesc(Notices::getCreateDate)); | 
 |  |  |         internalHomeVO.setTaskNum(noticesList.size()); | 
 |  |  |         if(Constants.equalsInteger(Constants.ONE,isDetail)){ | 
 |  |  |             if(CollectionUtils.isNotEmpty(noticesList)){ | 
 |  |  |                 //待我处理的数据 | 
 |  |  |                 internalHomeVO.setNoticeWaitNum( | 
 |  |  |                         noticesList.stream().filter(i->Constants.equalsInteger(i.getUserId(),memberId) | 
 |  |  |                                 &&Constants.equalsInteger(i.getStatus(),Constants.ZERO) | 
 |  |  |                                 &&Constants.equalsInteger(i.getSendacopy(),Constants.ZERO) | 
 |  |  |                         ).count() | 
 |  |  |                 ); | 
 |  |  |                 //已处理数据 | 
 |  |  |                 internalHomeVO.setNoticeDealNum( | 
 |  |  |                         noticesList.stream().filter(i->Constants.equalsInteger(i.getUserId(),memberId) | 
 |  |  |                                 &&StringUtils.equals(i.getParam4(),i.getUserId().toString()) | 
 |  |  |                                 &&Constants.equalsInteger(i.getStatus(),Constants.ONE) | 
 |  |  |                                 &&Constants.equalsInteger(i.getSendacopy(),Constants.ZERO) | 
 |  |  |                         ).count() | 
 |  |  |                 ); | 
 |  |  |                 //我发起的数据 | 
 |  |  |                 internalHomeVO.setNoticeCreateNum( | 
 |  |  |                         noticesJoinMapper.selectCount(new QueryWrapper<Notices>().lambda().eq(Notices::getParam3,memberId)) | 
 |  |  |                 ); | 
 |  |  |                 //抄送我的数据 | 
 |  |  |                 internalHomeVO.setNoticeCopyNum( | 
 |  |  |                         noticesList.stream().filter(i->Constants.equalsInteger(i.getUserId(),memberId) | 
 |  |  |                                 &&Constants.equalsInteger(i.getSendacopy(),Constants.ONE) | 
 |  |  |                         ).count() | 
 |  |  |                 ); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return internalHomeVO; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public InternalHomeVO getHomeDataPC(NoticesDTO noticesDTO){ | 
 |  |  |         InternalHomeVO internalHomeVO = new InternalHomeVO(); | 
 |  |  |         internalHomeVO.setHomeImg(systemDictDataBiz.queryByCode(Constants.SYSTEM,Constants.HOME_IMAGE).getCode()); | 
 |  |  |         //任务数据 | 
 |  |  |         List<Notices> noticesList = noticesJoinMapper. | 
 |  |  |                 selectList(new QueryWrapper<Notices>().lambda() | 
 |  |  |                         .ge(noticesDTO.getStartDate() != null, Notices::getCreateDate, Utils.Date.getStart(noticesDTO.getStartDate() )) | 
 |  |  |                         .le(noticesDTO.getEndDate() != null,  Notices::getCreateDate, Utils.Date.getEnd(noticesDTO.getEndDate() )) | 
 |  |  |                         .eq(noticesDTO.getType() != null,  Notices::getType, noticesDTO.getType()) | 
 |  |  |                         .eq(Notices::getUserId,noticesDTO.getMemberId()) | 
 |  |  |                         .orderByDesc(Notices::getCreateDate) | 
 |  |  |                 ); | 
 |  |  |         internalHomeVO.setTaskNum(noticesList.size()); | 
 |  |  |         if(CollectionUtils.isNotEmpty(noticesList)){ | 
 |  |  |             //待我处理的数据 | 
 |  |  |             internalHomeVO.setNoticeWaitNum( | 
 |  |  |                     noticesList.stream().filter(i->Constants.equalsInteger(i.getUserId(),noticesDTO.getMemberId()) | 
 |  |  |                             &&Constants.equalsInteger(i.getStatus(),Constants.ZERO) | 
 |  |  |                             &&Constants.equalsInteger(i.getSendacopy(),Constants.ZERO) | 
 |  |  |                     ).count() | 
 |  |  |             ); | 
 |  |  |             internalHomeVO.setNoticeDealNum( | 
 |  |  |                     noticesList.stream().filter(i->Constants.equalsInteger(i.getUserId(),noticesDTO.getMemberId()) | 
 |  |  |                             &&Constants.equalsInteger(i.getStatus(),Constants.ONE) | 
 |  |  |                             &&Constants.equalsInteger(i.getSendacopy(),Constants.ZERO) | 
 |  |  |                     ).count() | 
 |  |  |             ); | 
 |  |  |  | 
 |  |  |             internalHomeVO.setNoticeCreateNum( | 
 |  |  |                     noticesJoinMapper.selectCount(new QueryWrapper<Notices>().lambda().eq(Notices::getParam3,noticesDTO.getMemberId())) | 
 |  |  |             ); | 
 |  |  |  | 
 |  |  |             internalHomeVO.setNoticeCopyNum( | 
 |  |  |                     noticesList.stream().filter(i->Constants.equalsInteger(i.getUserId(),noticesDTO.getMemberId()) | 
 |  |  |                             &&Constants.equalsInteger(i.getSendacopy(),Constants.ONE) | 
 |  |  |                     ).count() | 
 |  |  |             ); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         return internalHomeVO; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 创建审批流程 | 
 |  |  | 
 |  |  |  | 
 |  |  |         //处理抄送数据 | 
 |  |  |         if(CollectionUtils.isNotEmpty(approveCopyList)){ | 
 |  |  |             this.organizeApproveCopyData(approveTempl,approveParamList,businessId,approveList); | 
 |  |  |             this.organizeApproveCopyData(approveTempl,approveCopyList,businessId,approveList); | 
 |  |  |         } | 
 |  |  |         approveMapper.insertBatchSomeColumn(approveList); | 
 |  |  |         approveJoinMapper.insert(approveList); | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | 
 |  |  |      * @param approveList | 
 |  |  |      */ | 
 |  |  |     public void organizeApproveData(ApproveTempl approveTempl,List<ApproveParam> approveParamList,Member createMember,Integer businessId,List<Approve> approveList){ | 
 |  |  |  | 
 |  |  |         //创建默认人信息 | 
 |  |  |         Approve createUserApprove = new Approve(); | 
 |  |  |         createUserApprove.setRemark("发起申请"); | 
 |  |  |         createUserApprove.setCreateDate(new Date()); | 
 |  |  |         createUserApprove.setIsdeleted(Constants.ZERO); | 
 |  |  |         createUserApprove.setTemplatId(approveTempl.getId()); | 
 |  |  |         createUserApprove.setChekorId(createMember.getId()); | 
 |  |  |         createUserApprove.setCheckDate(createUserApprove.getCreateDate()); | 
 |  |  |         createUserApprove.setStatus(Constants.approveStatus.pass); | 
 |  |  |         createUserApprove.setTitle("发起申请"); | 
 |  |  |         createUserApprove.setStatusInfo(""); | 
 |  |  |         createUserApprove.setIsEndCheck(Constants.ZERO); | 
 |  |  |         createUserApprove.setObjId(businessId); | 
 |  |  |         createUserApprove.setLevel(-1); | 
 |  |  |         createUserApprove.setObjType(approveTempl.getType()); | 
 |  |  |         createUserApprove.setApproveType(Constants.TWO); | 
 |  |  |         createUserApprove.setDriverParam(Constants.ZERO); | 
 |  |  |         createUserApprove.setAddrParam(Constants.ZERO); | 
 |  |  |         createUserApprove.setType(Constants.ZERO); | 
 |  |  |         approveList.add(createUserApprove); | 
 |  |  |  | 
 |  |  |         //查询所有待处理人 | 
 |  |  |  | 
 |  |  |         //审批业务数据 | 
 |  |  |         for (int i = 0; i < approveParamList.size(); i++) { | 
 |  |  |             ApproveParam approveParam = approveParamList.get(i); | 
 |  |  |             List<Integer> ids = this.getApproveUserIds(approveParam,createMember); | 
 |  |  |             //生成待办 notices 表数据 | 
 |  |  |             if(i==0){ | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |             for (Integer memberId:ids) { | 
 |  |  |             List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda().in(Member::getId,ids)); | 
 |  |  |             List<String> memberNameList =memberList.stream().map(m->m.getName()).collect(Collectors.toList()); | 
 |  |  |             String memberNames = String.join(",",memberNameList); | 
 |  |  |             Integer noticeType = Constants.approveTypeToNoticeType(approveTempl.getType()); | 
 |  |  |             String title = "【访客申请】申请人 - "; | 
 |  |  |             Map<String,Object> jsonMap = new HashMap<>(); | 
 |  |  |             for (int j = 0; j < memberList.size(); j++) { | 
 |  |  |                 Member member = memberList.get(j); | 
 |  |  |                 Integer memberId = member.getId(); | 
 |  |  |                 //生成待办 notices 表数据 | 
 |  |  |                 if(i==0){ | 
 |  |  |                     if(jsonMap.isEmpty()){ | 
 |  |  |                         title = this.createNoticesData(noticeType,businessId,title,jsonMap); | 
 |  |  |                     } | 
 |  |  |                     if(j==0){ | 
 |  |  |                         //默认生成一条 申请人的数据 标记删除状态用于处理到 任务中心(我发起)使用 | 
 |  |  |                         Notices notices = new Notices(); | 
 |  |  |                         notices.setCreateDate(new Date()); | 
 |  |  |                         notices.setIsdeleted(Constants.ONE); | 
 |  |  |                         notices.setObjId(businessId); | 
 |  |  |                         notices.setObjType(noticeType); | 
 |  |  |                         notices.setType(noticeType); | 
 |  |  |                         notices.setTitle(title); | 
 |  |  |                         notices.setParam1(JSONObject.toJSONString(jsonMap)); | 
 |  |  |                         notices.setStatus(Constants.ZERO); | 
 |  |  |                         notices.setReaded(Constants.ZERO); | 
 |  |  |                         notices.setSendacopy(Constants.ZERO); | 
 |  |  |                         notices.setParam2("0"); | 
 |  |  |                         notices.setParam3(createMember.getId().toString()); | 
 |  |  |                         notices.setInfo("处理中"); | 
 |  |  |                         noticesJoinMapper.insert(notices); | 
 |  |  |                     } | 
 |  |  |                     if(CollectionUtils.isEmpty(memberList)){ | 
 |  |  |                         throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到审批人信息"); | 
 |  |  |                     } | 
 |  |  |                     Notices notices = new Notices(); | 
 |  |  |                     notices.setCreateDate(new Date()); | 
 |  |  |                     notices.setIsdeleted(Constants.ZERO); | 
 |  |  |                     notices.setObjId(businessId); | 
 |  |  |                     notices.setObjType(noticeType); | 
 |  |  |                     notices.setType(noticeType); | 
 |  |  |                     notices.setTitle(title); | 
 |  |  |                     notices.setParam1(JSONObject.toJSONString(jsonMap)); | 
 |  |  |                     notices.setUserId(memberId); | 
 |  |  |                     notices.setPalt(Constants.ZERO); | 
 |  |  |                     notices.setStatus(Constants.ZERO); | 
 |  |  |                     notices.setReaded(Constants.ZERO); | 
 |  |  |                     notices.setSendacopy(Constants.ZERO); | 
 |  |  |                     notices.setParam2("0"); | 
 |  |  |                     notices.setParam3(""); | 
 |  |  |                     notices.setParam5(memberNames); | 
 |  |  |                     notices.setRemark(member.getName()); | 
 |  |  |                     if(Constants.equalsInteger(memberNameList.size(),Constants.ONE)){ | 
 |  |  |                         notices.setInfo("待"+memberNameList.get(0)+"处理中"); | 
 |  |  |                     }else{ | 
 |  |  |                         notices.setInfo("待"+memberNameList.get(0)+"等"+memberList.size()+"人处理中"); | 
 |  |  |                     } | 
 |  |  |                     noticesJoinMapper.insert(notices); | 
 |  |  |                 } | 
 |  |  |                 Approve approve = new Approve(); | 
 |  |  |                 approve.setRemark(approveParam.getRemark()); | 
 |  |  |                 approve.setCreateDate(new Date()); | 
 |  |  | 
 |  |  |                 approve.setChekorId(memberId); | 
 |  |  |                 approve.setStatus(i==0?Constants.ONE:Constants.ZERO); | 
 |  |  |                 approve.setStatusInfo(i==0?"审批中":"待审批"); | 
 |  |  |                 approve.setTitle("审批人"); | 
 |  |  |                 approve.setIsEndCheck((i+1) == approveParamList.size()?Constants.ONE:Constants.ZERO); | 
 |  |  |                 approve.setObjId(businessId); | 
 |  |  |                 approve.setLevel(i+1); | 
 |  |  | 
 |  |  |                 approveList.add(approve); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public String createNoticesData(Integer noticeType,Integer businessId,String title,Map<String,Object> jsonMap){ | 
 |  |  |         jsonMap.clear(); | 
 |  |  |         if(Constants.equalsInteger(noticeType,Constants.noticesObjectType.visit) | 
 |  |  |                 || Constants.equalsInteger(noticeType,Constants.noticesObjectType.visitReporting)){ | 
 |  |  |             //访客记录与访客报备 | 
 |  |  |             Visits visits = visitsJoinMapper.selectJoinOne(Visits.class, | 
 |  |  |                     new MPJLambdaWrapper<Visits>().selectAll(Visits.class) | 
 |  |  |                             .selectAs(Member::getName,Visits::getReceptMemberName) | 
 |  |  |                             .selectAs(Company::getName,Visits::getReceptMemberDepartment) | 
 |  |  |                             .leftJoin(Member.class,Member::getId,Visits::getReceptMemberId) | 
 |  |  |                             .leftJoin(Company.class,Company::getId,Member::getCompanyId) | 
 |  |  |                             .eq(Visits::getId,businessId) | 
 |  |  |                             .last(" limit 1 ") | 
 |  |  |             ); | 
 |  |  |             if(Objects.isNull(visits)){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到业务数据信息"); | 
 |  |  |             } | 
 |  |  |             if(Constants.equalsInteger(noticeType,Constants.noticesObjectType.visit)){ | 
 |  |  |                 title = title + visits.getName(); | 
 |  |  |             }else{ | 
 |  |  |                 title = "【访客报备】申请人 - " + visits.getName(); | 
 |  |  |             } | 
 |  |  |             jsonMap.put("name", "访问人:" + visits.getCompanyName() + " - " + visits.getReceptMemberName()); | 
 |  |  |             jsonMap.put("sTime", "入园时间:" + DateUtil.DateToStr(visits.getStarttime() , "yyyy-MM-dd HH:mm")); | 
 |  |  |             jsonMap.put("eTime", "离园时间:" + DateUtil.DateToStr(visits.getEndtime() , "yyyy-MM-dd HH:mm")); | 
 |  |  |             jsonMap.put("reason", StringUtils.isBlank(visits.getReason())?"来访事由: - ": "来访事由:" +visits.getReason()); | 
 |  |  |             jsonMap.put("carNos", StringUtils.isBlank(visits.getCarNos())?"随行车辆: - ": "随行车辆:" +visits.getCarNos()); | 
 |  |  |         }else if(Constants.equalsInteger(noticeType,Constants.noticesObjectType.useCar)){ | 
 |  |  |             //用车申请 | 
 |  |  |             CarUseBook carUseBook = carUseBookJoinMapper.selectJoinOne(CarUseBook.class, | 
 |  |  |                     new MPJLambdaWrapper<CarUseBook>().selectAll(CarUseBook.class) | 
 |  |  |                             .selectAs(Member::getName,CarUseBook::getMemberName) | 
 |  |  |                             .selectAs(Company::getName,CarUseBook::getCompanyName) | 
 |  |  |                             .leftJoin(Member.class,Member::getId,CarUseBook::getMemberId) | 
 |  |  |                             .leftJoin(Company.class,Company::getId,Member::getCompanyId) | 
 |  |  |                             .eq(CarUseBook::getId,businessId) | 
 |  |  |                             .last(" limit 1 ") | 
 |  |  |             ); | 
 |  |  |             if(Objects.isNull(carUseBook)){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到业务数据信息"); | 
 |  |  |             } | 
 |  |  |             title = "【用车申请】申请人 - " + carUseBook.getMemberName(); | 
 |  |  |             jsonMap.put("name", "申请人:" + carUseBook.getCompanyName() + " - " + carUseBook.getMemberName()); | 
 |  |  |             jsonMap.put("sTime", "开始时间:" + DateUtil.DateToStr(carUseBook.getStartTime() , "yyyy-MM-dd HH:mm")); | 
 |  |  |             jsonMap.put("eTime", "结束时间:" + DateUtil.DateToStr(carUseBook.getEndTime() , "yyyy-MM-dd HH:mm")); | 
 |  |  |             jsonMap.put("usrNum", StringUtils.isBlank(carUseBook.getMemberIds())?"乘车人数: 0人": "乘车人数: " +carUseBook.getMemberIds().split(",").length +"人"); | 
 |  |  |             jsonMap.put("mdd", StringUtils.isBlank(carUseBook.getAddr())?"目的地: - ": "目的地:" +carUseBook.getAddr()); | 
 |  |  |         }else { | 
 |  |  |             throw new BusinessException(ResponseStatus.NOT_ALLOWED); | 
 |  |  |         } | 
 |  |  |         return title; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  | 
 |  |  |             if(CollectionUtils.isNotEmpty(memberList)){ | 
 |  |  |                 userIds.addAll(memberList.stream().map(m->m.getId()).collect(Collectors.toList())); | 
 |  |  |             } | 
 |  |  |             //公务用车 默认加入 司机抄送 | 
 |  |  |             if(approveTempl.getType()==Constants.THREE||approveTempl.getType()==Constants.FOUR){ | 
 |  |  |                 CarUseBook carUseBook = carUseBookMapper.selectById(businessId); | 
 |  |  |                 if(Objects.isNull(carUseBook)){ | 
 |  |  |                     throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"为查询到用车申请信息"); | 
 |  |  |                 } | 
 |  |  |                 CarDriver carDriver = carDriverMapper.selectById(carUseBook.getDriverId()); | 
 |  |  |                 if(Objects.isNull(carDriver)){ | 
 |  |  |                     throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"为查询到司机信息"); | 
 |  |  |                 } | 
 |  |  |                 userIds.add(carDriver.getMemberId()); | 
 |  |  |             } | 
 |  |  |             //公务用车 默认加入 司机抄送  2024年6月28日16:49:08 司机抄送修改到 审批业务时进行发送 | 
 |  |  | //            if(approveTempl.getType()==Constants.THREE||approveTempl.getType()==Constants.FOUR){ | 
 |  |  | //                CarUseBook carUseBook = carUseBookMapper.selectById(businessId); | 
 |  |  | //                if(Objects.isNull(carUseBook)){ | 
 |  |  | //                    throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"为查询到用车申请信息"); | 
 |  |  | //                } | 
 |  |  | //                CarDriver carDriver = carDriverMapper.selectById(carUseBook.getDriverId()); | 
 |  |  | //                if(Objects.isNull(carDriver)){ | 
 |  |  | //                    throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"为查询到司机信息"); | 
 |  |  | //                } | 
 |  |  | //                userIds.add(carDriver.getMemberId()); | 
 |  |  | //            } | 
 |  |  |  | 
 |  |  |             if(CollectionUtils.isNotEmpty(userIds)){ | 
 |  |  |                 for (Integer memberId:userIds) { | 
 |  |  | 
 |  |  |                     approve.setIsdeleted(Constants.ZERO); | 
 |  |  |                     approve.setTemplatId(approveTempl.getId()); | 
 |  |  |                     approve.setChekorId(memberId); | 
 |  |  |                     approve.setObjType(approveTempl.getType()); | 
 |  |  |                     approve.setObjId(businessId); | 
 |  |  |                     approve.setType(Constants.ONE); | 
 |  |  |                     approveList.add(approve); | 
 |  |  | 
 |  |  |             if(Objects.isNull(memberCompany)){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误[指定审批部门未查询到]"); | 
 |  |  |             } | 
 |  |  |             Company auditCompany = this.getAuditCompanyHead(memberCompany.getParentId(),approveParam.getObjLevel()); | 
 |  |  |             Company auditCompany = this.getAuditCompanyHead(memberCompany.getId(),approveParam.getObjLevel()); | 
 |  |  |             if(Objects.isNull(auditCompany)){ | 
 |  |  |                 //审批部门为空 自动流转下一级审批配置 | 
 |  |  |                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误[指定审批部门未查询到]"); | 
 |  |  | 
 |  |  |                 Member headMember = memberMapper.selectById(auditCompany.getHeadId()); | 
 |  |  |                 if(Objects.isNull(headMember)){ | 
 |  |  |                     //未查询到部门负责人  根据配置处理   由上级主管代替审核/直接结束流程 | 
 |  |  |                     if(approveParam.getNoleaderOpt().equals(Constants.ONE)&&!Objects.isNull(auditCompany.getParentId())){ | 
 |  |  |                     if(Constants.equalsInteger(approveParam.getNoleaderOpt(),Constants.ONE)&&Objects.nonNull(auditCompany.getParentId())){ | 
 |  |  |                         auditCompany = companyMapper.selectOne(new QueryWrapper<Company>().lambda().eq(Company::getId,auditCompany.getParentId())); | 
 |  |  |                         //无父级 直接流传下一级审批 | 
 |  |  |                         if(Objects.isNull(auditCompany)){ | 
 |  |  | 
 |  |  |                             userIds.add(headMember.getId()); | 
 |  |  |                         } | 
 |  |  |                     }else{ | 
 |  |  |                         //添加审批人 | 
 |  |  |                         userIds.add(headMember.getId()); | 
 |  |  |                         throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误[指定审批部门主管未查询到]"); | 
 |  |  |                     } | 
 |  |  |                 }else{ | 
 |  |  |                     //添加审批人 | 
 |  |  |                     userIds.add(headMember.getId()); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  | 
 |  |  |      * @param objLevel  查询级别 | 
 |  |  |      */ | 
 |  |  |     public Company getAuditCompanyHead(Integer companyId, Integer objLevel){ | 
 |  |  |         Integer queryLevel = Constants.ZERO; | 
 |  |  |         Company auditCompany =  companyMapper.selectById(companyId); | 
 |  |  |         while(queryLevel.equals(objLevel)){ | 
 |  |  |         Integer queryLevel = Constants.ONE; | 
 |  |  |         while(queryLevel<objLevel){ | 
 |  |  |             auditCompany = companyMapper.selectById(auditCompany.getParentId()); | 
 |  |  |             if(Objects.isNull(auditCompany)){ | 
 |  |  |                 return null; | 
 |  |  | 
 |  |  |         return auditCompany; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @Override | 
 |  |  |     public ApproveDataVO arrangeApprovedData(Integer businessId, Integer businessType, Integer memberId){ | 
 |  |  |         ApproveDataVO approveDateVO = new ApproveDataVO(); | 
 |  |  |         approveDateVO.setApproveList(new ArrayList<>()); | 
 |  |  |         approveDateVO.setCanBeApproved(Constants.ZERO); | 
 |  |  |         List<Approve> approveGroupList = approveJoinMapper.selectJoinList(Approve.class, | 
 |  |  |                 new MPJLambdaWrapper<Approve>(). | 
 |  |  |                         selectAll(Approve.class) | 
 |  |  |                         .selectAs(Member::getName,Approve::getMemberName) | 
 |  |  |                         .selectAs(Member::getPhone,Approve::getMemberPhone) | 
 |  |  |                         .selectAs(Member::getFaceImg,Approve::getFaceImg) | 
 |  |  |                         .selectAs(Company::getCompanyNamePath,Approve::getCompanyName) | 
 |  |  |                         .leftJoin(Member.class,Member::getId,Approve::getChekorId) | 
 |  |  |                         .leftJoin(Company.class,Company::getId,Member::getCompanyId) | 
 |  |  |                         .eq(Approve::getIsdeleted,Constants.ZERO) | 
 |  |  |                         .ne(Approve::getStatus,Constants.approveStatus.cancel) | 
 |  |  |                         .eq(Approve::getObjId,businessId) | 
 |  |  |                         .eq(Approve::getObjType,businessType) | 
 |  |  |                         .orderByAsc(Approve::getLevel) | 
 |  |  |                         .orderByAsc(Approve::getStatus) | 
 |  |  |  | 
 |  |  |         ); | 
 |  |  |  | 
 |  |  |         //查找全部levelList | 
 |  |  |         List<Approve> levelList = getLevelListFromResult(approveGroupList,approveDateVO,memberId); | 
 |  |  |         List<Approve> copyList = getAllCopyList(approveGroupList); | 
 |  |  |         //遍历level查询每一级别业务数据 | 
 |  |  |         if(levelList!=null){ | 
 |  |  |             for(Approve level:levelList){ | 
 |  |  |                 List<Approve> tlist = getLevelInfoFromList(level,approveGroupList); | 
 |  |  |                 approveDateVO.getApproveList().addAll(tlist); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //处理抄送记录 | 
 |  |  |         if (CollectionUtils.isNotEmpty(copyList)) { | 
 |  |  |             Approve waitModel = new Approve(); | 
 |  |  |             waitModel.setApproveType(Constants.ONE); | 
 |  |  |             waitModel.setCheckDate(copyList.get(Constants.ZERO).getCheckDate()); | 
 |  |  |             waitModel.setTitle("抄送人"); | 
 |  |  |             waitModel.setStatus(copyList.get(Constants.ZERO).getStatus()); | 
 |  |  |             waitModel.setType(Constants.ONE); | 
 |  |  |             waitModel.setApproveList(copyList); | 
 |  |  |             approveDateVO.getApproveList().add(waitModel); | 
 |  |  |         } | 
 |  |  |         System.out.println(JSONObject.toJSONString(approveDateVO)); | 
 |  |  |         return approveDateVO; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private List<Approve> getAllCopyList(List<Approve> approveGroupList) { | 
 |  |  |         List<Approve> copyList = new ArrayList<>(); | 
 |  |  |         if (CollectionUtils.isNotEmpty(approveGroupList)) { | 
 |  |  |             copyList.addAll(approveGroupList.stream().filter(i->Constants.equalsInteger(i.getType(),Constants.ONE)).collect(Collectors.toList())); | 
 |  |  |         } | 
 |  |  |         return copyList; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private List<Approve> getLevelInfoFromList(Approve level,List<Approve> approveGroupList) { | 
 |  |  |         List<Approve> list = new ArrayList<>(); | 
 |  |  |         if(Constants.equalsInteger(level.getApproveType(),Constants.TWO)){ | 
 |  |  |             level.setApproveType(Constants.ZERO); | 
 |  |  |             //如果是单人审批 | 
 |  |  |             list.add(level); | 
 |  |  |             return list; | 
 |  |  |         } | 
 |  |  |         //查找全部已处理的集合 | 
 |  |  |         List<Approve> passList = new ArrayList<>();//已同意的记录集 | 
 |  |  |         Approve  refuseModel = new Approve();//已拒绝的记录 | 
 |  |  |         List<Approve> waitList = new ArrayList<>();  //查询全部未处理的集合 | 
 |  |  |         List<Approve> otherPassList = new ArrayList<>();//他人已处理的记录集 | 
 |  |  |         int appType = Constants.formatIntegerNum(level.getApproveType());//当前审批类型 | 
 |  |  |         dealGroupListBiz(level,approveGroupList,passList,refuseModel,waitList,otherPassList); | 
 |  |  |         if(Objects.nonNull(refuseModel) && Objects.nonNull(refuseModel.getId())){ | 
 |  |  |             //存在拒绝的,只需要返回一条处理数据,后续不需要回显 | 
 |  |  |             refuseModel.setApproveType(Constants.ZERO); | 
 |  |  |             list.add(refuseModel); | 
 |  |  |             return list; | 
 |  |  |         } | 
 |  |  |         list.addAll(sortByCreateTime(passList)); | 
 |  |  |         if(Constants.equalsInteger(appType,Constants.ONE)){ | 
 |  |  |             //如果是会签 | 
 |  |  |             if(waitList.size()>1){ | 
 |  |  |                 Approve waitModel = new Approve(); | 
 |  |  |                 waitModel.setApproveType(Constants.ONE); | 
 |  |  |                 waitModel.setType(Constants.ZERO); | 
 |  |  |                 waitModel.setTitle(StringUtils.defaultString(level.getTitle(),"审批人")); | 
 |  |  |                 waitModel.setStatus(Constants.equalsInteger(waitList.get(Constants.ZERO).getStatus(),Constants.ONE)?Constants.ONE:Constants.ZERO); | 
 |  |  |                 waitModel.setStatusInfo("处理中"); | 
 |  |  |                 if(Constants.equalsInteger(level.getStatus(),Constants.approveStatus.auditIng) | 
 |  |  |                         ||Constants.equalsInteger(level.getStatus(),Constants.approveStatus.pass)){ | 
 |  |  |                     waitModel.setMemberName(waitList.size() +"人会签"); | 
 |  |  |                 } | 
 |  |  |                 if(CollectionUtils.isNotEmpty(waitList)){ | 
 |  |  |                     waitModel.setCreateDate(waitList.get(Constants.ZERO).getCreateDate()); | 
 |  |  |                 } | 
 |  |  |                 waitModel.setApproveList(waitList); | 
 |  |  |                 list.add(waitModel); | 
 |  |  |             }else if(waitList.size()>0){ | 
 |  |  |                 Approve approve = waitList.get(Constants.ZERO); | 
 |  |  |                 approve.setApproveType(Constants.ZERO); | 
 |  |  |                 approve.setType(Constants.ZERO); | 
 |  |  |                 list.add(approve); | 
 |  |  |             } | 
 |  |  |         }else { | 
 |  |  |             if((waitList.size()> 0 || otherPassList.size()>0)){ | 
 |  |  |                 Approve waitModel = new Approve(); | 
 |  |  |                 waitModel.setApproveType(Constants.ONE); | 
 |  |  |                 if(Constants.equalsInteger(level.getStatus(),Constants.approveStatus.pass)){ | 
 |  |  |                     waitModel.setStatus(Constants.approveStatus.pass); | 
 |  |  |                     waitModel.setType(Constants.ONE); | 
 |  |  |                     waitModel.setTitle("审批人(抄送或签审批人)"); | 
 |  |  |                 }else{ | 
 |  |  |                     waitModel.setType(Constants.ZERO); | 
 |  |  |                     waitModel.setStatusInfo(passList.size()<=0?StringUtils.defaultString(level.getTitle(),"审批人"):"抄送或签审批人"); | 
 |  |  |                     waitModel.setStatus(passList.size()>0?Constants.ONE:Constants.ZERO); | 
 |  |  |                 } | 
 |  |  |                 List<Approve> approveList = new ArrayList<>(); | 
 |  |  |                 approveList.addAll(waitList); | 
 |  |  |                 //如果是或签 | 
 |  |  |                 if(passList.size()>0){ | 
 |  |  |                     approveList.addAll(otherPassList); | 
 |  |  |                 } | 
 |  |  |                 if(CollectionUtils.isNotEmpty(approveList)){ | 
 |  |  |                     waitModel.setCreateDate(approveList.get(Constants.ZERO).getCreateDate()); | 
 |  |  |                 } | 
 |  |  |                 if(Constants.equalsInteger(waitModel.getStatus(),Constants.approveStatus.pass)){ | 
 |  |  |                     waitModel.setMemberName("已抄送"+ approveList.size() +"人"); | 
 |  |  |                 }else if(Constants.equalsInteger(waitModel.getStatus(),Constants.approveStatus.wait)){ | 
 |  |  |                     waitModel.setMemberName("处理中"); | 
 |  |  |                 } | 
 |  |  |                 waitModel.setApproveList(approveList); | 
 |  |  |                 list.add(waitModel); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         return  list; | 
 |  |  |  | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void dealGroupListBiz(Approve level, List<Approve> approveGroupList,  List<Approve> passList, Approve refuseModel, List<Approve> waitList, List<Approve> otherPassList) { | 
 |  |  |         //查询是否存在拒绝数据 | 
 |  |  |         List<Approve> levelApprove = approveGroupList.stream().filter(i->Constants.equalsInteger(i.getLevel(),level.getLevel())).collect(Collectors.toList()); | 
 |  |  |         for (Approve approve:levelApprove) { | 
 |  |  |             if(!Constants.equalsInteger(level.getLevel(),approve.getLevel())){ | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             if(Constants.equalsInteger(Constants.approveStatus.pass,approve.getStatus())){ | 
 |  |  |                 approve.setApproveType(Constants.ZERO); | 
 |  |  |                 passList.add(approve); | 
 |  |  |             }else if(Constants.equalsInteger(Constants.approveStatus.otherDeal,approve.getStatus())){ | 
 |  |  |                 otherPassList.add(approve); | 
 |  |  |             }else if(Constants.equalsInteger(Constants.approveStatus.auditIng,approve.getStatus())||Constants.equalsInteger(Constants.approveStatus.wait,approve.getStatus())){ | 
 |  |  |                 waitList.add(approve); | 
 |  |  |             }else if(Constants.equalsInteger(Constants.approveStatus.unPass,approve.getStatus())){ | 
 |  |  |                 BeanUtils.copyProperties(approve,refuseModel); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private List<Approve> sortByCreateTime(List<Approve> passList) { | 
 |  |  |         Collections.sort(passList, (a, b) -> a.getCheckDate().compareTo(b.getCheckDate())); | 
 |  |  |         return  passList; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     private List<Approve> getLevelListFromResult(List<Approve> approveGroupList,ApproveDataVO approveDataVO,Integer memberId) { | 
 |  |  |         approveDataVO.setCanBeApproved(Constants.ZERO); | 
 |  |  |         approveDataVO.setDriverParam(Constants.ZERO); | 
 |  |  |         List<Approve> approveList = new ArrayList<>(); | 
 |  |  |         String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
 |  |  |                 +systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode(); | 
 |  |  |         for (Approve approve:approveGroupList) { | 
 |  |  |             if(StringUtils.isNotBlank(approve.getFaceImg())){ | 
 |  |  |                 approve.setFaceImg(path + approve.getFaceImg()); | 
 |  |  |             } | 
 |  |  |             if(Constants.equalsInteger(approve.getType(),Constants.ONE)){ | 
 |  |  |                 continue; | 
 |  |  |             } | 
 |  |  |             if(Constants.equalsInteger(approve.getChekorId(),memberId) | 
 |  |  |                     &&Constants.equalsInteger(approve.getStatus(), Constants.ONE)){ | 
 |  |  |                 approveDataVO.setCanBeApproved(Constants.ONE); | 
 |  |  |                 approveDataVO.setDriverParam(approve.getDriverParam()); | 
 |  |  |             } | 
 |  |  |             if(notExsits(approveList,approve.getLevel())){ | 
 |  |  |                 approveList.add(approve); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         if(CollectionUtils.isEmpty(approveList)){ | 
 |  |  |          //   throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批信息:级别数据异常"); | 
 |  |  |         } | 
 |  |  |         return  approveList; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private boolean notExsits(List<Approve> approveList, Integer level) { | 
 |  |  |         for (Approve approve:approveList) { | 
 |  |  |             if(Constants.equalsInteger(approve.getLevel(),level)){ | 
 |  |  |                 return false; | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return true; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     /** | 
 |  |  |      * 整理 审批数据 | 
 |  |  | 
 |  |  |      * @param businessType | 
 |  |  |      * @return | 
 |  |  |      */ | 
 |  |  |     @Override | 
 |  |  |     public ApproveDataVO arrangeApprovedData(Integer businessId, Integer businessType, Integer memberId){ | 
 |  |  | //    @Override | 
 |  |  |     public ApproveDataVO arrangeApprovedDataOld(Integer businessId, Integer businessType, Integer memberId){ | 
 |  |  |         ApproveDataVO approveDateVO = new ApproveDataVO(); | 
 |  |  |         approveDateVO.setCanBeApproved(Constants.ZERO); | 
 |  |  |         List<Approve> approveGroupList = approveJoinMapper.selectJoinList(Approve.class, | 
 |  |  |                 new MPJLambdaWrapper<Approve>(). | 
 |  |  |                         select(Approve::getLevel,Approve::getType) | 
 |  |  |                         select(Approve::getLevel,Approve::getType,Approve::getTitle,Approve::getApproveType) | 
 |  |  |                         .eq(Approve::getIsdeleted,Constants.ZERO) | 
 |  |  |                         .eq(Approve::getObjId,businessId) | 
 |  |  |                         .isNotNull(Approve::getLevel) | 
 |  |  |                         .eq(Approve::getObjType,businessType) | 
 |  |  |                         .groupBy(Approve::getLevel,Approve::getType) | 
 |  |  |                         .groupBy(Approve::getLevel,Approve::getType,Approve::getTitle,Approve::getApproveType) | 
 |  |  |         ); | 
 |  |  |         if(CollectionUtils.isEmpty(approveGroupList)){ | 
 |  |  |             return approveDateVO; | 
 |  |  | 
 |  |  |                         .orderByAsc(Approve::getLevel) | 
 |  |  |                         .orderByAsc(Approve::getId) | 
 |  |  |         ); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode() | 
 |  |  |                 +systemDictDataBiz.queryByCode(Constants.FTP,Constants.MEMBER_IMG).getCode(); | 
 |  |  |         for (Approve approve:approveAllList ) { | 
 |  |  | 
 |  |  |         if(CollectionUtils.isEmpty(approveAllList)){ | 
 |  |  |             return approveDateVO; | 
 |  |  |         } | 
 |  |  |         List<Approve> approveList = approveAllList.stream().filter(i->i.getType().equals(Constants.ZERO)).collect(Collectors.toList()); | 
 |  |  |         List<Approve> approveList = approveAllList.stream().filter(i->Constants.equalsInteger(i.getType(),(Constants.ZERO))) | 
 |  |  |                 .collect(Collectors.toList()); | 
 |  |  |         if(CollectionUtils.isEmpty(approveList)){ | 
 |  |  |             return approveDateVO; | 
 |  |  |         } | 
 |  |  | 
 |  |  |                 .lambda() | 
 |  |  |                 .eq(Approve::getObjId,approveDTO.getObjId()) | 
 |  |  |                 .eq(Approve::getObjType,approveDTO.getObjType()) | 
 |  |  |                 .eq(Approve::getChekorId,approveDTO.getLoginUserInfo().getMemberId()) | 
 |  |  |                 .eq(Approve::getType,Constants.ZERO) | 
 |  |  |                 .eq(Approve::getStatus,Constants.approveStatus.auditIng) | 
 |  |  |                 .last(" limit 1") | 
 |  |  |         ); | 
 |  |  |         if(Objects.isNull(approve)){ | 
 |  |  | 
 |  |  |         if(!approve.getStatus().equals(Constants.ONE)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批记录状态错误!"); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         //根据审批记录查询 当前处理数据对应的 通知记录 | 
 |  |  |         Integer noticeType = Constants.approveTypeToNoticeType(approve.getObjType()); | 
 |  |  |         Notices  notices = noticesJoinMapper.selectOne(new QueryWrapper<Notices>().lambda() | 
 |  |  |                 .eq(Notices::getObjId,approve.getObjId()) | 
 |  |  |                 .eq(Notices::getObjType,noticeType) | 
 |  |  |                 .eq(Notices::getUserId,approve.getChekorId()) | 
 |  |  |                 .eq(Notices::getSendacopy,Constants.ZERO) | 
 |  |  |                 .eq(Notices::getIsdeleted,Constants.ZERO) | 
 |  |  |                 .eq(Notices::getStatus,Constants.ZERO) | 
 |  |  |                 .last(" limit 1 ") | 
 |  |  |         ); | 
 |  |  |         if(Objects.isNull(notices)){ | 
 |  |  |             log.info("未查询到通知记录"); | 
 |  |  |             return; | 
 |  |  |         } | 
 |  |  |         //处理审批信息 | 
 |  |  |         approve.setStatus(approveDTO.getStatus()); | 
 |  |  |         approve.setCheckInfo(approveDTO.getCheckInfo()); | 
 |  |  |         approve.setCheorId(approveDTO.getLoginUserInfo().getMemberId().toString()); | 
 |  |  |         approve.setCheckorName(approve.getLoginUserInfo().getRealname()); | 
 |  |  |         approve.setStatusInfo(approveDTO.getStatus()==Constants.TWO?"审批通过":approveDTO.getCheckInfo()); | 
 |  |  |         Visits visits = new Visits(); | 
 |  |  |         CarUseBook carUseBook = new CarUseBook(); | 
 |  |  |         this.dealBusinessData(approveDTO,approve,visits,carUseBook); | 
 |  |  |         approve.setCheckorName(approveDTO.getLoginUserInfo().getRealname()); | 
 |  |  |         approve.setCheckDate(new Date()); | 
 |  |  |         approve.setStatusInfo(approveDTO.getStatus()==Constants.TWO?"已同意":"已驳回"); | 
 |  |  |         //本级所有 待审批记录 | 
 |  |  |         List<Approve> approveList = approveJoinMapper.selectJoinList(Approve.class, | 
 |  |  |                 new MPJLambdaWrapper<Approve>() | 
 |  |  | 
 |  |  |                         .eq(Approve::getObjType,approveDTO.getObjType()) | 
 |  |  |                         .eq(Approve::getLevel,approve.getLevel()) | 
 |  |  |                         .eq(Approve::getStatus,Constants.ONE) | 
 |  |  |                         .eq(Approve::getType,Constants.ZERO) | 
 |  |  |                         .ne(Approve::getId,approve.getId()) | 
 |  |  |         ); | 
 |  |  |         //业务数据下配置的所有抄送记录 | 
 |  |  |         List<Approve> approveCopyList = approveJoinMapper.selectJoinList(Approve.class, | 
 |  |  |                 new MPJLambdaWrapper<Approve>() | 
 |  |  |                         .selectAll(Approve.class) | 
 |  |  |                         .eq(Approve::getIsdeleted,Constants.ZERO) | 
 |  |  |                         .eq(Approve::getObjId,approveDTO.getObjId()) | 
 |  |  |                         .eq(Approve::getObjType,approveDTO.getObjType()) | 
 |  |  |                         .eq(Approve::getType,Constants.ONE) | 
 |  |  |         ); | 
 |  |  |         //处理本次审批的业务数据 | 
 |  |  |         approveMapper.updateById(approve); | 
 |  |  | 
 |  |  |         Boolean dealBusinessBean = false; | 
 |  |  |         //审批驳回情况 | 
 |  |  |         if(approveDTO.getStatus().equals(Constants.THREE)){ | 
 |  |  |             dealBusinessBean = true; | 
 |  |  |             //修改其他所有待审批和审批中记录数据 | 
 |  |  |             approveJoinMapper.update(null,new UpdateWrapper<Approve>() | 
 |  |  |                     .lambda() | 
 |  |  |                     .set(Approve::getStatus,Constants.approveStatus.otherUnPass) | 
 |  |  |                     .set(Approve::getCheckDate,new Date()) | 
 |  |  |                     .in(Approve::getStatus,Constants.approveStatus.auditIng,Constants.approveStatus.wait) | 
 |  |  |                     .eq(Approve::getObjId,approve.getObjId()) | 
 |  |  |                     .eq(Approve::getObjType,approve.getObjType()) | 
 |  |  |                     .ne(Approve::getId,approve.getId())); | 
 |  |  |             //处理所有Notice通知为已处理 | 
 |  |  |             //修改自己的通知记录 | 
 |  |  |             noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda() | 
 |  |  |                     .set(Notices::getEditDate,new Date()) | 
 |  |  |                     .set(Notices::getParam4,approveDTO.getLoginUserInfo().getMemberId()) | 
 |  |  |                     .set(Notices::getInfo,"审批未通过") | 
 |  |  |                     .set(Notices::getReaded,Constants.ONE) | 
 |  |  |                     .set(Notices::getParam2,Constants.TWO) | 
 |  |  |                     .set(Notices::getStatus,Constants.ONE) | 
 |  |  |                     .eq(Notices::getId,notices.getId()) | 
 |  |  |             ); | 
 |  |  |             //修改 未处理的 通知数据 为抄送 | 
 |  |  |             if (!Constants.equalsInteger(approve.getApproveType(),Constants.TWO)){ | 
 |  |  |                 noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda() | 
 |  |  |                         .set(Notices::getEditDate,new Date()) | 
 |  |  |                         .set(Notices::getSendacopy,Constants.ONE) | 
 |  |  |                         .set(Notices::getStatus,Constants.ONE) | 
 |  |  |                         .set(Notices::getParam2,Constants.TWO) | 
 |  |  |                         .set(Notices::getInfo,"审批未通过") | 
 |  |  |                         .eq(Notices::getObjId,notices.getObjId()) | 
 |  |  |                         .eq(Notices::getObjType,notices.getObjType()) | 
 |  |  |                         .eq(Notices::getReaded,Constants.ZERO) | 
 |  |  |                         .ne(Notices::getId,notices.getId()) | 
 |  |  |                 ); | 
 |  |  |             } | 
 |  |  |         }else{ | 
 |  |  |             //处理其他业务数据 | 
 |  |  |             if(approve.getApproveType().equals(Constants.ZERO)&&approve.getIsEndCheck()==Constants.ONE){ | 
 |  |  |                 //或签  且 终审 | 
 |  |  |                 approveJoinMapper.update(null,new UpdateWrapper<Approve>() | 
 |  |  |                         .lambda() | 
 |  |  |                         .set(Approve::getStatus,Constants.approveStatus.otherDeal) | 
 |  |  |                         .in(Approve::getId,approveList.stream().map(m->m.getId()).collect(Collectors.toList()))); | 
 |  |  |             if((Constants.equalsInteger(approve.getApproveType(),Constants.ZERO) | 
 |  |  |                     || Constants.equalsInteger( approve.getApproveType(),Constants.TWO)) && Constants.equalsInteger(approve.getIsEndCheck(),Constants.ONE)){ | 
 |  |  |                 //或签 / 单人审 且 终审 | 
 |  |  |                 if(CollectionUtils.isNotEmpty(approveList)){ | 
 |  |  |                     approveJoinMapper.update(null,new UpdateWrapper<Approve>() | 
 |  |  |                             .lambda() | 
 |  |  |                             .set(Approve::getStatus,Constants.approveStatus.otherDeal) | 
 |  |  |                             .set(Approve::getCheckDate,new Date()) | 
 |  |  |                             .in(Approve::getId,approveList.stream().map(m->m.getId()).collect(Collectors.toList()))); | 
 |  |  |                 } | 
 |  |  |                 dealBusinessBean = true; | 
 |  |  |  | 
 |  |  |             }else if(approve.getApproveType().equals(Constants.ZERO)&&approve.getIsEndCheck()!=Constants.ONE){ | 
 |  |  |                 //或签 非终审 则开启下一步业务流程 | 
 |  |  |             }else if((approve.getApproveType().equals(Constants.ZERO) | 
 |  |  |                     || approve.getApproveType().equals(Constants.TWO)) &&approve.getIsEndCheck()!=Constants.ONE){ | 
 |  |  |                 //或签 / 单人审 非终审 则开启下一步业务流程 | 
 |  |  |                 /**处理本级数据**/ | 
 |  |  |                 approveJoinMapper.update(null,new UpdateWrapper<Approve>() | 
 |  |  |                         .lambda() | 
 |  |  |                         .set(Approve::getStatus,Constants.approveStatus.otherDeal) | 
 |  |  |                         .in(Approve::getId,approveList.stream().map(m->m.getId()).collect(Collectors.toList()))); | 
 |  |  |                 if(CollectionUtils.isNotEmpty(approveList)){ | 
 |  |  |                     approveJoinMapper.update(null,new UpdateWrapper<Approve>() | 
 |  |  |                             .lambda() | 
 |  |  |                             .set(Approve::getStatus,Constants.approveStatus.otherDeal) | 
 |  |  |                             .set(Approve::getCheckDate,new Date()) | 
 |  |  |                             .in(Approve::getId,approveList.stream().map(m->m.getId()).collect(Collectors.toList()))); | 
 |  |  |                 } | 
 |  |  |                 /**开启下一级别的数据为待审核**/ | 
 |  |  |                 approveJoinMapper.update(null,new UpdateWrapper<Approve>() | 
 |  |  |                         .lambda() | 
 |  |  |                         .set(Approve::getStatus,Constants.approveStatus.auditIng) | 
 |  |  |                         .set(Approve::getTitle,"审批人") | 
 |  |  |                         .set(Approve::getCheckDate,new Date()) | 
 |  |  |                         .eq(Approve::getStatus,Constants.approveStatus.wait) | 
 |  |  |                         .eq(Approve::getObjId,approve.getObjId()) | 
 |  |  |                         .eq(Approve::getObjType,approve.getObjType()) | 
 |  |  |                         .eq(Approve::getLevel,(approve.getLevel()+1)) | 
 |  |  |                 ); | 
 |  |  |                 if(approveDTO.getObjType().equals(Constants.approveObjectType.unConstructionVisit) | 
 |  |  |                         ||approveDTO.getObjType().equals(Constants.approveObjectType.constructionVisit) | 
 |  |  |                         ||approveDTO.getObjType().equals(Constants.approveObjectType.visitReporting)) { | 
 |  |  |                     Visits visits = visitsMapper.selectById(approve.getObjId()); | 
 |  |  |                     if(Objects.nonNull(visits)){ | 
 |  |  |                         if(Constants.equalsInteger(visits.getStatus(),Constants.ZERO)){ | 
 |  |  |                              visitsMapper.update(null,new UpdateWrapper<Visits>().lambda().set(Visits::getStatus,Constants.ONE).eq(Visits::getId,visits.getId())); | 
 |  |  |                         }else{ | 
 |  |  |                             throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到业务数据对象!请刷新重试"); | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |  | 
 |  |  |             }else if(approve.getApproveType().equals(Constants.ONE)&&approve.getIsEndCheck()==Constants.ONE){ | 
 |  |  |             //会签 且终审 | 
 |  |  |                 if(approveList.size()==Constants.ZERO){ | 
 |  |  |  | 
 |  |  |                 }else if(approveDTO.getObjType().equals(Constants.approveObjectType.cityUseCar)||approveDTO.getObjType().equals( | 
 |  |  |                         Constants.approveObjectType.unCityUseCar)){ | 
 |  |  |                     this.updDriver(approveDTO,approve,false); | 
 |  |  |                 } | 
 |  |  |             }else if(approve.getApproveType().equals(Constants.ONE)){ | 
 |  |  |                 //会签 且终审 | 
 |  |  |                 //无他人审批的情况 则修改数据状态 | 
 |  |  |                 if(Constants.equalsInteger(approveList.size(),Constants.ZERO)&&Constants.equalsInteger(approve.getIsEndCheck(),Constants.ONE)){ | 
 |  |  |                     dealBusinessBean = true; | 
 |  |  |                 }else{ | 
 |  |  |                     if(Constants.equalsInteger(approveList.size(),Constants.ZERO)&&Constants.equalsInteger(approve.getIsEndCheck(),Constants.ZERO)){ | 
 |  |  |                         /**开启下一级别的数据为待审核**/ | 
 |  |  |                         approveJoinMapper.update(null,new UpdateWrapper<Approve>() | 
 |  |  |                                 .lambda() | 
 |  |  |                                 .set(Approve::getStatus,Constants.approveStatus.auditIng) | 
 |  |  |                                 .set(Approve::getTitle,"审批人") | 
 |  |  |                                 .set(Approve::getCheckDate,new Date()) | 
 |  |  |                                 .eq(Approve::getStatus,Constants.approveStatus.wait) | 
 |  |  |                                 .eq(Approve::getObjId,approve.getObjId()) | 
 |  |  |                                 .eq(Approve::getObjType,approve.getObjType()) | 
 |  |  |                                 .eq(Approve::getLevel,(approve.getLevel()+1)) | 
 |  |  |                         ); | 
 |  |  |                     } | 
 |  |  |                     if(approveDTO.getObjType().equals(Constants.approveObjectType.cityUseCar)||approveDTO.getObjType().equals( | 
 |  |  |                             Constants.approveObjectType.unCityUseCar)){ | 
 |  |  |                         this.updDriver(approveDTO,approve,false); | 
 |  |  |                     } | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |             this.passNextNotices(dealBusinessBean,notices,approve,approveList,approveCopyList,approveDTO); | 
 |  |  |         } | 
 |  |  |  | 
 |  |  |         if(approveDTO.getObjType().equals(Constants.approveObjectType.unConstructionVisit) | 
 |  |  |                 ||approveDTO.getObjType().equals(Constants.approveObjectType.constructionVisit) | 
 |  |  |                 ||approveDTO.getObjType().equals(Constants.approveObjectType.visitReporting)){ | 
 |  |  |             // 访客 三类业务数据 | 
 |  |  |             visitsMapper.updateById(visits); | 
 |  |  |             if(dealBusinessBean){ | 
 |  |  |                 //TODO 发送审批通过消息 | 
 |  |  |  | 
 |  |  |             }else if(approveDTO.getStatus().equals(Constants.THREE)){ | 
 |  |  |                 //TODO 审批未通过通知 | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         }else if(approveDTO.getObjType().equals(Constants.approveObjectType.cityUseCar)||approveDTO.getObjType().equals( | 
 |  |  |                 Constants.approveObjectType.unCityUseCar)){ | 
 |  |  |             // 市内外用车申请 | 
 |  |  |             carUseBookMapper.updateById(carUseBook); | 
 |  |  |             if(dealBusinessBean){ | 
 |  |  |                 //TODO 发送审批通过消息 | 
 |  |  |  | 
 |  |  |             }else if(approveDTO.getStatus().equals(Constants.THREE)){ | 
 |  |  |                 //TODO 审批未通过通知 | 
 |  |  |  | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         }else if(approveDTO.getObjType().equals(Constants.approveObjectType.logisticsCarUse)){ | 
 |  |  |             //TODO  物流车预约 | 
 |  |  |  | 
 |  |  |         //处理业务数据 | 
 |  |  |         if(dealBusinessBean){ | 
 |  |  |             this.dealBusinessData(approveDTO,approve); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void dealBusinessData(ApproveDTO approveDTO,Approve approve,Visits visits,CarUseBook carUseBook){ | 
 |  |  |     /** | 
 |  |  |      * 处理待办信息 | 
 |  |  |      * @param dealBusinessBean  是否需要进行更新业务数据状态 | 
 |  |  |      * @param approve  审批记录 | 
 |  |  |      * @param approveList  同级待审批数据 | 
 |  |  |      */ | 
 |  |  |     public void passNextNotices(Boolean dealBusinessBean,Notices notices,Approve approve,List<Approve> approveList,List<Approve> copyList,ApproveDTO approveDTO){ | 
 |  |  |         //未开启下一级时,操作后的待审批人 | 
 |  |  |         String memberNames =notices.getParam5() | 
 |  |  |                 .replaceAll(","+notices.getRemark(),"") | 
 |  |  |                 .replaceAll(notices.getRemark()+",","") | 
 |  |  |                 .replaceAll(notices.getRemark(),""); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |         //1、修改自己的数据记录 | 
 |  |  |         noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda() | 
 |  |  |                 .set(Notices::getEditDate,new Date()) | 
 |  |  |                 .set(Notices::getReaded,Constants.ONE) | 
 |  |  |                 .set(Notices::getStatus,Constants.ONE) | 
 |  |  |                 .set(dealBusinessBean,Notices::getParam2,Constants.ONE) | 
 |  |  |                 .set(Notices::getParam4,approveDTO.getLoginUserInfo().getMemberId()) | 
 |  |  |                 .eq(Notices::getId,notices.getId()) | 
 |  |  |         ); | 
 |  |  |         if(Constants.equalsInteger(approve.getApproveType(),Constants.ZERO)){ | 
 |  |  |             //或签 | 
 |  |  |             //2、更新他人的同级记录 为抄送  并更新 info 信息 | 
 |  |  |             noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda() | 
 |  |  |                     .set(Notices::getEditDate,new Date()) | 
 |  |  |                     .set(Notices::getReaded,Constants.ZERO) | 
 |  |  |                     .set(Notices::getSendacopy,Constants.ONE) | 
 |  |  |                     .set(Notices::getStatus,Constants.ONE) | 
 |  |  |                     .set(Notices::getParam4,approveDTO.getLoginUserInfo().getMemberId()) | 
 |  |  |                     .set(dealBusinessBean,Notices::getParam2,Constants.ONE) | 
 |  |  |                     .eq(Notices::getObjId,notices.getObjId()) | 
 |  |  |                     .eq(Notices::getStatus,Constants.ZERO) | 
 |  |  |                     .eq(Notices::getObjType,notices.getObjType()) | 
 |  |  |                     .ne(Notices::getId,notices.getId()) | 
 |  |  |             ); | 
 |  |  |             //3、如果不是终审生成下一级的数据记录 | 
 |  |  |             if(Constants.equalsInteger(approve.getIsEndCheck(),Constants.ZERO)&&!dealBusinessBean){ | 
 |  |  |                 memberNames = this.saveNextNotice(notices,approve); | 
 |  |  |             } | 
 |  |  |         }else if(Constants.equalsInteger(approve.getApproveType(),Constants.ONE)){ | 
 |  |  |             //会签 | 
 |  |  |             //2、如果是最后一位审批人 且不是终审开启下一级数据 | 
 |  |  |             if(Constants.equalsInteger(Constants.ZERO,approveList.size())){ | 
 |  |  |                 if(Constants.equalsInteger(approve.getIsEndCheck(),Constants.ZERO)){ | 
 |  |  |                     memberNames = this.saveNextNotice(notices,approve); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         }else{ | 
 |  |  |             //单人签 | 
 |  |  |             //2、 是否是终审 开启下一级数据 | 
 |  |  |             if(Constants.equalsInteger(approve.getIsEndCheck(),Constants.ZERO)){ | 
 |  |  |                 memberNames = this.saveNextNotice(notices,approve); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         String info = ""; | 
 |  |  |         List<String> memberNameList = Arrays.asList(memberNames.split(",")); | 
 |  |  |         if(Constants.equalsInteger(memberNameList.size(),Constants.ONE)){ | 
 |  |  |             info = "待 "+memberNameList.get(0)+" 处理中"; | 
 |  |  |         }else{ | 
 |  |  |             info = "待 "+memberNameList.get(0)+" 等"+memberNameList.size()+"人处理中"; | 
 |  |  |         } | 
 |  |  |         //更新该业务数据的所有记录信息 | 
 |  |  |         noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda() | 
 |  |  |                         .set(!dealBusinessBean,Notices::getInfo,info) | 
 |  |  |                         .set(dealBusinessBean,Notices::getInfo,"审批通过") | 
 |  |  |                         .set(Notices::getParam5,memberNames) | 
 |  |  |                         .eq(Notices::getObjId,notices.getObjId()) | 
 |  |  |                         .eq(Notices::getObjType,notices.getObjType())); | 
 |  |  |  | 
 |  |  |         //终审业务 且 处理数据  进行抄送发送 | 
 |  |  |         if (Constants.equalsInteger(approve.getIsEndCheck(),Constants.ONE) && dealBusinessBean) { | 
 |  |  |             if(CollectionUtils.isNotEmpty(copyList)){ | 
 |  |  |                 for (Approve copyApprove:copyList) { | 
 |  |  |                     Notices copyNotices = new Notices(); | 
 |  |  |                     BeanUtils.copyProperties(notices,copyNotices); | 
 |  |  |                     copyNotices.setId(null); | 
 |  |  |                     copyNotices.setCreateDate(new Date()); | 
 |  |  |                     copyNotices.setEditDate(new Date()); | 
 |  |  |                     copyNotices.setParam2("2"); | 
 |  |  |                     copyNotices.setParam3(""); | 
 |  |  |                     copyNotices.setInfo("审批通过"); | 
 |  |  |                     copyNotices.setUserId(copyApprove.getChekorId()); | 
 |  |  |                     copyNotices.setStatus(Constants.ZERO); | 
 |  |  |                     copyNotices.setSendacopy(Constants.ONE); | 
 |  |  |                     copyNotices.setReaded(Constants.ZERO); | 
 |  |  |                     noticesJoinMapper.insert(copyNotices); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public String saveNextNotice(Notices notices,Approve approve){ | 
 |  |  |         List<Approve> nextApproveList = approveJoinMapper.selectJoinList(Approve.class,new MPJLambdaWrapper<Approve>() | 
 |  |  |                 .selectAll(Approve.class) | 
 |  |  |                 .selectAs(Member::getName,Approve::getMemberName) | 
 |  |  |                 .leftJoin(Member.class,Member::getId,Approve::getChekorId) | 
 |  |  |                 .eq(Approve::getObjId,approve.getObjId()) | 
 |  |  |                 .eq(Approve::getObjType,approve.getObjType()) | 
 |  |  |                 .eq(Approve::getType,Constants.ZERO) | 
 |  |  |                 .eq(Approve::getLevel,(approve.getLevel() + Constants.ONE)) | 
 |  |  |         ); | 
 |  |  |         if(CollectionUtils.isEmpty(nextApproveList)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流数据异常"); | 
 |  |  |         } | 
 |  |  |         List<String> memberNameList =nextApproveList.stream().map(m->m.getMemberName()).collect(Collectors.toList()); | 
 |  |  |         String memberNames = String.join(",",memberNameList); | 
 |  |  |         for (Approve nextDealApprove:nextApproveList) { | 
 |  |  |             Notices newNotices = new Notices(); | 
 |  |  |             BeanUtils.copyProperties(notices,newNotices); | 
 |  |  |             newNotices.setId(null); | 
 |  |  |             newNotices.setCreateDate(new Date()); | 
 |  |  |             newNotices.setParam2("0"); | 
 |  |  |             newNotices.setParam3(""); | 
 |  |  |             newNotices.setEditDate(new Date()); | 
 |  |  |             newNotices.setUserId(nextDealApprove.getChekorId()); | 
 |  |  |             newNotices.setStatus(Constants.ZERO); | 
 |  |  |             newNotices.setSendacopy(Constants.ZERO); | 
 |  |  |             newNotices.setReaded(Constants.ZERO); | 
 |  |  |             notices.setParam5(memberNames); | 
 |  |  |             notices.setRemark(nextDealApprove.getMemberName()); | 
 |  |  |             if(Constants.equalsInteger(memberNameList.size(),Constants.ONE)){ | 
 |  |  |                 notices.setInfo("待 "+memberNameList.get(0)+" 处理中"); | 
 |  |  |             }else{ | 
 |  |  |                 notices.setInfo("待 "+memberNameList.get(0)+" 等"+memberNameList.size()+"人处理中"); | 
 |  |  |             } | 
 |  |  |             noticesJoinMapper.insert(newNotices); | 
 |  |  |         } | 
 |  |  |         return memberNames; | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     public void dealBusinessData(ApproveDTO approveDTO,Approve approve){ | 
 |  |  |         if(approveDTO.getObjType().equals(Constants.approveObjectType.unConstructionVisit) | 
 |  |  |                 ||approveDTO.getObjType().equals(Constants.approveObjectType.constructionVisit) | 
 |  |  |                 ||approveDTO.getObjType().equals(Constants.approveObjectType.visitReporting)){ | 
 |  |  |             // 访客 三类业务数据 | 
 |  |  |             visits = visitsMapper.selectById(approveDTO.getObjId()); | 
 |  |  |             Visits visits = visitsMapper.selectById(approveDTO.getObjId()); | 
 |  |  |             if(Objects.isNull(visits)){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到申请记录"); | 
 |  |  |             } | 
 |  |  |             visits.setStatus(approveDTO.getStatus()); | 
 |  |  |             visits.setEditDate(new Date()); | 
 |  |  |             visits.setEditor(approveDTO.getLoginUserInfo().getMemberId()); | 
 |  |  |  | 
 |  |  |  | 
 |  |  |             visitsMapper.updateById(visits); | 
 |  |  |         }else if(approveDTO.getObjType().equals(Constants.approveObjectType.cityUseCar)||approveDTO.getObjType().equals( | 
 |  |  |                 Constants.approveObjectType.unCityUseCar)){ | 
 |  |  |             // 市内外用车申请 | 
 |  |  |             carUseBook = carUseBookMapper.selectById(approveDTO.getObjId()); | 
 |  |  |             if(Objects.isNull(carUseBook)){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到用车记录"); | 
 |  |  |             } | 
 |  |  |             carUseBook.setStatus(approveDTO.getStatus()); | 
 |  |  |             carUseBook.setEditDate(new Date()); | 
 |  |  |             carUseBook.setEditor(approveDTO.getLoginUserInfo().getMemberId()); | 
 |  |  |             //如果配置修改司机 且 入参了更换后司机信息 | 
 |  |  |             if(approveDTO.getStatus()==Constants.TWO&&approve.getDriverParam().equals(Constants.ONE)){ | 
 |  |  |                 CarDriver carDriver = carDriverMapper.selectById(approveDTO.getDriverId()); | 
 |  |  |                 if(Objects.isNull(carDriver)){ | 
 |  |  |                     throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到司机信息"); | 
 |  |  |                 } | 
 |  |  |                 carUseBook.setDriverId(carDriver.getId()); | 
 |  |  |             } | 
 |  |  |  | 
 |  |  |             this.updDriver(approveDTO,approve,true); | 
 |  |  |         }else if(approveDTO.getObjType().equals(Constants.approveObjectType.logisticsCarUse)){ | 
 |  |  |             //TODO  物流车预约 | 
 |  |  |             //物流车预约 | 
 |  |  |             PlatformBooks platformBooks = platformBooksMapper.selectById(approveDTO.getObjId()); | 
 |  |  |             if(Objects.isNull(platformBooks)){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到物流车预约记录"); | 
 |  |  |             } | 
 |  |  |             platformBooks.setStatus(approveDTO.getStatus()); | 
 |  |  |             platformBooks.setEditDate(new Date()); | 
 |  |  |             platformBooks.setEditor(approveDTO.getLoginUserInfo().getMemberId()); | 
 |  |  |  | 
 |  |  |             //生成任务记录 | 
 |  |  |             PlatformJob platformJob = platformBooks.toPlatformJob(); | 
 |  |  |             platformJobMapper.insert(platformJob); | 
 |  |  |             platformBooks.setJobId(platformJob.getId()); | 
 |  |  |             platformBooksMapper.updateById(platformBooks); | 
 |  |  |             //生成任务操作记录 | 
 |  |  |             PlatformLog platformLog = new PlatformLog(); | 
 |  |  |             platformLog.setCreateDate(new Date()); | 
 |  |  |             platformLog.setJobId(platformJob.getId()); | 
 |  |  |             platformLog.setIsdeleted(Constants.ZERO); | 
 |  |  |             platformLog.setObjType(Constants.PlatformJobStatus.WART_SIGN_IN.getKey()); | 
 |  |  |             platformLog.setObjId(platformJob.getId().toString()); | 
 |  |  |             platformLog.setAfterContent(JSONObject.toJSONString(platformJob)); | 
 |  |  |             platformLogMapper.insert(platformLog); | 
 |  |  |  | 
 |  |  |         }else{ | 
 |  |  |             throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
 |  |  |         } | 
 |  |  |         if(Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)){ | 
 |  |  |             //处理通过 显示所有的抄送记录 | 
 |  |  |             approveMapper.update(null,new UpdateWrapper<Approve>().lambda().set(Approve::getStatus,Constants.TWO) | 
 |  |  |                     .set(Approve::getCheckDate,new Date()) | 
 |  |  |                     .eq(Approve::getObjId,approve.getObjId()) | 
 |  |  |                     .eq(Approve::getObjType,approve.getObjType()) | 
 |  |  |                     .eq(Approve::getType,Constants.ONE) | 
 |  |  |             ); | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  | 
 |  |  |     public void updDriver(ApproveDTO approveDTO,Approve approve,Boolean dealBusinessBean){ | 
 |  |  |         // 市内外用车申请 | 
 |  |  |         CarUseBook carUseBook = carUseBookMapper.selectById(approveDTO.getObjId()); | 
 |  |  |         if(Objects.isNull(carUseBook)){ | 
 |  |  |             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到用车记录"); | 
 |  |  |         } | 
 |  |  |         if(dealBusinessBean){ | 
 |  |  |             carUseBook.setStatus(approveDTO.getStatus()); | 
 |  |  |         }else{ | 
 |  |  |             if(Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)){ | 
 |  |  |                 carUseBook.setStatus(Constants.ONE); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         carUseBook.setEditDate(new Date()); | 
 |  |  |         carUseBook.setEditor(approveDTO.getLoginUserInfo().getMemberId()); | 
 |  |  |         //如果配置修改司机 且 入参了更换后司机信息 | 
 |  |  |         if(approveDTO.getStatus()==Constants.TWO&&Constants.equalsInteger(approve.getDriverParam(),Constants.ONE)){ | 
 |  |  |             CarDriver carDriver = carDriverMapper.selectOne(new QueryWrapper<CarDriver>().lambda() | 
 |  |  |                     .eq(CarDriver::getIsdeleted,Constants.ZERO) | 
 |  |  |                     .eq(CarDriver::getStatus,Constants.ZERO) | 
 |  |  |                     .eq(CarDriver::getMemberId,approveDTO.getDriverId())); | 
 |  |  |             if(Objects.isNull(carDriver)){ | 
 |  |  |                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到司机信息"); | 
 |  |  |             } | 
 |  |  |              carUseBook.setDriverId(carDriver.getMemberId()); | 
 |  |  |         } | 
 |  |  |         carUseBookMapper.updateById(carUseBook); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |  |