| | |
| | | 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.ApproveMapper; |
| | | import com.doumee.dao.business.model.Approve; |
| | | 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.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | 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 javafx.application.Platform; |
| | | 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.util.CollectionUtils; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * 审批信息记录表Service实现 |
| | |
| | | * @date 2023/12/28 14:09 |
| | | */ |
| | | @Service |
| | | @Slf4j |
| | | public class ApproveServiceImpl implements ApproveService { |
| | | |
| | | @Autowired |
| | | private ApproveMapper approveMapper; |
| | | |
| | | @Autowired |
| | | private ApproveJoinMapper approveJoinMapper; |
| | | |
| | | @Autowired |
| | | private SystemDictDataBiz systemDictDataBiz; |
| | | |
| | | @Autowired |
| | | private ApproveTemplMapper approveTemplMapper; |
| | | |
| | | @Autowired |
| | | private ApproveParamMapper approveParamMapper; |
| | | |
| | | @Autowired |
| | | private MemberMapper memberMapper; |
| | | |
| | | @Autowired |
| | | private CompanyMapper companyMapper; |
| | | |
| | | @Autowired |
| | | private CarUseBookMapper carUseBookMapper; |
| | | |
| | | @Autowired |
| | | private CarDriverMapper carDriverMapper; |
| | | |
| | | @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; |
| | | @Autowired |
| | | private PlatformReasonMapper platformReasonMapper; |
| | | |
| | | |
| | | |
| | | @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; |
| | | } |
| | | |
| | | /** |
| | | * 创建审批流程 |
| | | * @param tempType 模板类型 0非施工人员访客申请 1施工人员访客申请 2访客报备 3公车市内用车 4公车室外用车 5市公司物流车预约 |
| | | * @param businessId 业务主键 根据 tempType |
| | | * @param createMemberId 提交流程人员 |
| | | */ |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void createApproveFlow(Integer tempType,Integer businessId,Integer createMemberId){ |
| | | //查询处理模板 |
| | | ApproveTempl approveTempl = approveTemplMapper.selectOne(new QueryWrapper<ApproveTempl>().lambda() |
| | | .eq(ApproveTempl::getType,tempType) |
| | | .eq(ApproveTempl::getIsdeleted,Constants.ZERO) |
| | | .last(" limit 1 ") |
| | | ); |
| | | if(Objects.isNull(approveTempl)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到审批流配置模板"); |
| | | } |
| | | //查询配置流程 |
| | | List<ApproveParam> approveParamAllList = approveParamMapper.selectList(new QueryWrapper<ApproveParam>() |
| | | .lambda().eq(ApproveParam::getIsdeleted,Constants.ZERO) |
| | | .eq(ApproveParam::getTemplId,approveTempl.getId()) |
| | | .orderByAsc(ApproveParam::getType) |
| | | .orderByAsc(ApproveParam::getLevel) |
| | | ); |
| | | if(Objects.isNull(approveParamAllList)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未配置审批流程"); |
| | | } |
| | | //审批配置 |
| | | List<ApproveParam> approveParamList = approveParamAllList.stream().filter(i->i.getType().equals(Constants.ZERO)).collect(Collectors.toList()); |
| | | if(Objects.isNull(approveParamList)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未配置审批流程"); |
| | | } |
| | | List<ApproveParam> approveCopyList = approveParamAllList.stream().filter(i->i.getType().equals(Constants.ONE)).collect(Collectors.toList()); |
| | | |
| | | Member createMember = memberMapper.selectById(createMemberId); |
| | | if(Objects.isNull(createMember)|| Objects.isNull(createMember.getCompanyId())){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"申请人组织信息异常"); |
| | | } |
| | | List<Approve> approveList = new ArrayList<>(); |
| | | |
| | | this.organizeApproveData(approveTempl,approveParamList,createMember,businessId,approveList); |
| | | |
| | | if(CollectionUtils.isEmpty(approveList)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误"); |
| | | } |
| | | |
| | | //处理抄送数据 |
| | | if(CollectionUtils.isNotEmpty(approveCopyList)){ |
| | | this.organizeApproveCopyData(approveTempl,approveCopyList,businessId,approveList); |
| | | } |
| | | approveJoinMapper.insert(approveList); |
| | | |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void createApproveForPlatfrom(Integer tempId,Integer businessId,Integer createMemberId){ |
| | | //查询处理模板 |
| | | ApproveTempl approveTempl = approveTemplMapper.selectById(tempId); |
| | | if(Objects.isNull(approveTempl)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到审批流配置模板"); |
| | | } |
| | | //查询配置流程 |
| | | List<ApproveParam> approveParamAllList = approveParamMapper.selectList(new QueryWrapper<ApproveParam>() |
| | | .lambda().eq(ApproveParam::getIsdeleted,Constants.ZERO) |
| | | .eq(ApproveParam::getTemplId,approveTempl.getId()) |
| | | .orderByAsc(ApproveParam::getType) |
| | | .orderByAsc(ApproveParam::getLevel) |
| | | ); |
| | | if(Objects.isNull(approveParamAllList)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未配置审批流程"); |
| | | } |
| | | //审批配置 |
| | | List<ApproveParam> approveParamList = approveParamAllList.stream().filter(i->i.getType().equals(Constants.ZERO)).collect(Collectors.toList()); |
| | | if(Objects.isNull(approveParamList)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未配置审批流程"); |
| | | } |
| | | List<ApproveParam> approveCopyList = approveParamAllList.stream().filter(i->i.getType().equals(Constants.ONE)).collect(Collectors.toList()); |
| | | |
| | | Member createMember = memberMapper.selectById(createMemberId); |
| | | if(Objects.isNull(createMember)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"申请人组织信息异常"); |
| | | } |
| | | List<Approve> approveList = new ArrayList<>(); |
| | | |
| | | this.organizeApproveData(approveTempl,approveParamList,createMember,businessId,approveList); |
| | | |
| | | if(CollectionUtils.isEmpty(approveList)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误"); |
| | | } |
| | | |
| | | //处理抄送数据 |
| | | if(CollectionUtils.isNotEmpty(approveCopyList)){ |
| | | this.organizeApproveCopyData(approveTempl,approveCopyList,businessId,approveList); |
| | | } |
| | | approveJoinMapper.insert(approveList); |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 组织审批流数据 |
| | | * @param approveTempl |
| | | * @param approveParamList |
| | | * @param createMember |
| | | * @param businessId |
| | | * @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); |
| | | 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.setIsdeleted(Constants.ZERO); |
| | | approve.setTemplatId(approveTempl.getId()); |
| | | 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); |
| | | approve.setObjType(approveTempl.getType()); |
| | | approve.setApproveType(approveParam.getApproveType()); |
| | | approve.setDriverParam(approveParam.getDriverParam()); |
| | | approve.setAddrParam(approveParam.getAddrParam()); |
| | | approve.setType(Constants.ZERO); |
| | | 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 if(Constants.equalsInteger(noticeType,Constants.noticesObjectType.reason)){ |
| | | //物流车预约 |
| | | PlatformBooks platformBooks = platformBooksMapper.selectById(businessId); |
| | | if(Objects.isNull(platformBooks)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"未查询到业务数据信息"); |
| | | } |
| | | title = "【物流车入园预约】申请人 - " + platformBooks.getDriverName(); |
| | | jsonMap.put("inType", "入库类型:"+(Constants.equalsInteger(platformBooks.getInType(),Constants.ZERO)?"整托盘":"件烟")); |
| | | jsonMap.put("totalNum", "总运输量:"+platformBooks.getTotalNum()+"万支"); |
| | | jsonMap.put("arriveDate", "到场时间:" + DateUtil.DateToStr(platformBooks.getArriveDate() , "yyyy-MM-dd HH:mm")); |
| | | jsonMap.put("carNum", "车牌照:"+platformBooks.getCarCodeFront()); |
| | | } |
| | | return title; |
| | | } |
| | | |
| | | |
| | | public void organizeApproveCopyData(ApproveTempl approveTempl,List<ApproveParam> approveCopyList,Integer businessId,List<Approve> approveList){ |
| | | for (ApproveParam approveParam:approveCopyList) { |
| | | if(StringUtils.isBlank(approveParam.getObjIds())){ |
| | | return; |
| | | } |
| | | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda() |
| | | .eq(Member::getIsdeleted,Constants.ZERO) |
| | | .eq(Member::getWorkStatus,Constants.ZERO) |
| | | .in(Member::getId,approveParam.getObjIds().split(","))); |
| | | List<Integer> userIds = new ArrayList<>(); |
| | | if(CollectionUtils.isNotEmpty(memberList)){ |
| | | userIds.addAll(memberList.stream().map(m->m.getId()).collect(Collectors.toList())); |
| | | } |
| | | //公务用车 默认加入 司机抄送 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 approve = new Approve(); |
| | | approve.setCreateDate(new Date()); |
| | | 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); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | public List<Integer> getApproveUserIds(ApproveParam approveParam,Member createMember){ |
| | | List<Integer> userIds = new ArrayList<>(); |
| | | if(approveParam.getMemberType().equals(Constants.ZERO)){ |
| | | //申请人 |
| | | userIds.add(createMember.getId()); |
| | | }else if(approveParam.getMemberType().equals(Constants.ONE)){ |
| | | //指定人员 |
| | | if(StringUtils.isBlank(approveParam.getObjIds())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"审批流配置错误[未配置指定审批人员]"); |
| | | } |
| | | List<Member> memberList = memberMapper.selectList(new QueryWrapper<Member>().lambda() |
| | | .eq(Member::getIsdeleted,Constants.ZERO) |
| | | .in(Member::getId,approveParam.getObjIds().split(","))); |
| | | if(memberList.size()!=approveParam.getObjIds().split(",").length){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误[指定审批人员信息异常]"); |
| | | } |
| | | userIds.addAll(memberList.stream().map(m->m.getId()).collect(Collectors.toList())); |
| | | }else if(approveParam.getMemberType().equals(Constants.TWO)){ |
| | | //部门主管审批 |
| | | //审批部门 |
| | | Company memberCompany = companyMapper.selectById(createMember.getCompanyId()); |
| | | if(Objects.isNull(memberCompany)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误[指定审批部门未查询到]"); |
| | | } |
| | | Company auditCompany = this.getAuditCompanyHead(memberCompany.getId(),approveParam.getObjLevel()); |
| | | if(Objects.isNull(auditCompany)){ |
| | | //审批部门为空 自动流转下一级审批配置 |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误[指定审批部门未查询到]"); |
| | | }else{ |
| | | //查询部门负责人 |
| | | Member headMember = memberMapper.selectById(auditCompany.getHeadId()); |
| | | if(Objects.isNull(headMember)){ |
| | | //未查询到部门负责人 根据配置处理 由上级主管代替审核/直接结束流程 |
| | | 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)){ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误[指定审批部门未查询到]"); |
| | | } |
| | | headMember = memberMapper.selectById(auditCompany.getHeadId()); |
| | | if(Objects.isNull(headMember)){ |
| | | //查询部门负责人 为空 自动流转下一级审批配置 |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误[指定审批部门未设置负责人]"); |
| | | }else{ |
| | | //添加审批人 |
| | | userIds.add(headMember.getId()); |
| | | } |
| | | }else{ |
| | | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"审批流配置错误[指定审批部门主管未查询到]"); |
| | | } |
| | | }else{ |
| | | //添加审批人 |
| | | userIds.add(headMember.getId()); |
| | | } |
| | | } |
| | | } |
| | | return userIds; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据配置查询上级数据 |
| | | * @param companyId 父级部门主键 |
| | | * @param objLevel 查询级别 |
| | | */ |
| | | public Company getAuditCompanyHead(Integer companyId, Integer objLevel){ |
| | | Company auditCompany = companyMapper.selectById(companyId); |
| | | Integer queryLevel = Constants.ONE; |
| | | while(queryLevel<objLevel){ |
| | | auditCompany = companyMapper.selectById(auditCompany.getParentId()); |
| | | if(Objects.isNull(auditCompany)){ |
| | | return null; |
| | | } |
| | | queryLevel = queryLevel + 1; |
| | | } |
| | | 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 businessId |
| | | * @param businessType |
| | | * @return |
| | | */ |
| | | // @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,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,Approve::getTitle,Approve::getApproveType) |
| | | ); |
| | | if(CollectionUtils.isEmpty(approveGroupList)){ |
| | | return approveDateVO; |
| | | } |
| | | //所有的审批记录 |
| | | List<Approve> approveAllList = 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::getName,Approve::getCompanyName) |
| | | .leftJoin(Member.class,Member::getId,Approve::getChekorId) |
| | | .leftJoin(Company.class,Company::getId,Member::getCompanyId) |
| | | .leftJoin(SystemUser.class,SystemUser::getMemberId,Member::getId) |
| | | .eq(Approve::getIsdeleted,Constants.ZERO) |
| | | .eq(Approve::getObjId,businessId) |
| | | .eq(Approve::getObjType,businessType) |
| | | .orderByAsc(Approve::getType) |
| | | .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(StringUtils.isNotBlank(approve.getFaceImg())){ |
| | | approve.setFaceImg(path + approve.getFaceImg()); |
| | | } |
| | | } |
| | | |
| | | if(CollectionUtils.isEmpty(approveAllList)){ |
| | | return approveDateVO; |
| | | } |
| | | List<Approve> approveList = approveAllList.stream().filter(i->Constants.equalsInteger(i.getType(),(Constants.ZERO))) |
| | | .collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(approveList)){ |
| | | return approveDateVO; |
| | | } |
| | | approveDateVO.setCanBeApproved(this.canBeApproved(approveList,memberId)); |
| | | approveDateVO.setDriverParam(this.canDriverParam(approveList,memberId)); |
| | | //根据审批级别 处理数据 |
| | | for (Approve approve:approveGroupList) { |
| | | approve.setApproveList( |
| | | approveList.stream().filter(i->Objects.nonNull(i.getLevel())&&i.getLevel().equals(approve.getLevel())).collect(Collectors.toList()) |
| | | ); |
| | | } |
| | | approveDateVO.setApproveList(approveGroupList); |
| | | approveDateVO.setCopyList(approveAllList.stream().filter(i->i.getType().equals(Constants.ONE)).collect(Collectors.toList())); |
| | | return approveDateVO; |
| | | } |
| | | |
| | | |
| | | public Integer canBeApproved(List<Approve> approveList,Integer memberId){ |
| | | //获取所有待审批的数据 |
| | | List<Approve> waitApprovedList = approveList.stream().filter(i->i.getType().equals(Constants.ZERO)&&i.getStatus().equals(Constants.ZERO)).collect(Collectors.toList()); |
| | | if(CollectionUtils.isNotEmpty(waitApprovedList)){ |
| | | //下个审批流程等级 |
| | | Integer nextApprovedLevel = waitApprovedList.get(Constants.ZERO).getLevel(); |
| | | //下个审批流程的 所有数据 |
| | | List<Approve> nextApprovedList = waitApprovedList.stream().filter(i->i.getStatus().equals(Constants.ZERO)&&i.getLevel().equals(nextApprovedLevel)).collect(Collectors.toList()); |
| | | //下个审批流程内 如果存在当前 用户的抓紧 则可以进行审批 |
| | | if(nextApprovedList.stream().filter(i->i.getChekorId().equals(memberId)).collect(Collectors.toList()).size()>0){ |
| | | return Constants.ONE; |
| | | } |
| | | } |
| | | return Constants.ZERO; |
| | | } |
| | | |
| | | public Integer canDriverParam(List<Approve> approveList,Integer memberId){ |
| | | //获取所有待审批的数据 |
| | | List<Approve> waitApprovedList = approveList.stream().filter(i->i.getType().equals(Constants.ZERO)&&i.getStatus().equals(Constants.ZERO)).collect(Collectors.toList()); |
| | | if(CollectionUtils.isNotEmpty(waitApprovedList)){ |
| | | //下个审批流程等级 |
| | | Integer nextApprovedLevel = waitApprovedList.get(Constants.ZERO).getLevel(); |
| | | //下个审批流程的 所有数据 |
| | | List<Approve> nextApprovedList = waitApprovedList.stream().filter(i->i.getStatus().equals(Constants.ZERO)&&i.getLevel().equals(nextApprovedLevel)).collect(Collectors.toList()); |
| | | //下个审批流程内 如果存在当前 用户的抓紧 则可以进行审批 |
| | | List<Approve> auditApproveList = nextApprovedList.stream().filter(i->i.getChekorId().equals(memberId)).collect(Collectors.toList()); |
| | | if(auditApproveList.size() >0){ |
| | | Approve auditApprove = auditApproveList.get(Constants.ZERO); |
| | | return auditApprove.getDriverParam(); |
| | | } |
| | | } |
| | | return Constants.ZERO; |
| | | } |
| | | |
| | | @Override |
| | | public String getApproveUserName(Integer businessId,Integer businessType){ |
| | | List<Approve> approveList = 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,businessId) |
| | | .eq(Approve::getObjType,businessType) |
| | | .eq(Approve::getType,Constants.ZERO) |
| | | .eq(Approve::getStatus,Constants.approveStatus.auditIng) |
| | | ); |
| | | if(CollectionUtils.isNotEmpty(approveList)){ |
| | | List<String> names = approveList.stream().map(m->m.getMemberName()).collect(Collectors.toList()); |
| | | return String.join(",",names); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = {Exception.class,BusinessException.class}) |
| | | public void approved(ApproveDTO approveDTO){ |
| | | if(Objects.isNull(approveDTO) |
| | | || Objects.isNull(approveDTO.getObjId()) |
| | | || Objects.isNull(approveDTO.getObjType()) |
| | | || Objects.isNull(approveDTO.getStatus()) |
| | | || Objects.isNull(approveDTO.getLoginUserInfo())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST); |
| | | } |
| | | if(approveDTO.getStatus().equals(Constants.THREE)&&StringUtils.isBlank(approveDTO.getCheckInfo())){ |
| | | throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"请输入拒绝说明"); |
| | | } |
| | | Approve approve = approveMapper.selectOne(new QueryWrapper<Approve>() |
| | | .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)){ |
| | | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到审批数据"); |
| | | } |
| | | 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(approveDTO.getLoginUserInfo().getRealname()); |
| | | approve.setCheckDate(new Date()); |
| | | approve.setStatusInfo(approveDTO.getStatus()==Constants.TWO?"已同意":"已驳回"); |
| | | //本级所有 待审批记录 |
| | | List<Approve> approveList = 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::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((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.getApproveType().equals(Constants.TWO)) &&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()))); |
| | | } |
| | | /**开启下一级别的数据为待审核**/ |
| | | 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(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(dealBusinessBean){ |
| | | this.dealBusinessData(approveDTO,approve); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 处理待办信息 |
| | | * @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 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)){ |
| | | this.updDriver(approveDTO,approve,true); |
| | | }else if(approveDTO.getObjType().equals(Constants.approveObjectType.reason)){ |
| | | //物流车预约 |
| | | 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()); |
| | | PlatformReason platformReason = platformReasonMapper.selectById(platformBooks.getReasonId()); |
| | | |
| | | //生成任务记录 |
| | | PlatformJob platformJob = platformBooks.toPlatformJob(); |
| | | platformJob.setPlatformGroupId(platformReason.getGroupId().intValue()); |
| | | platformJob.setType(Constants.platformJobType.sgscxh); |
| | | platformJob.setStatus(Constants.PlatformJobStatus.WART_SIGN_IN.getKey()); |
| | | 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.setParam4(platformJob.getCarCodeFront()); |
| | | platformLog.setContent(Constants.PlatformJobLogType.CREATE.getInfo()); |
| | | platformLog.setObjType(Constants.PlatformJobLogType.CREATE.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); |
| | | } |
| | | |
| | | |
| | | } |