| | |
| | | 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.join.NoticesJoinMapper; |
| | |
| | | private VisitsMapper visitsMapper; |
| | | |
| | | @Autowired |
| | | private VisitsJoinMapper visitsJoinMapper; |
| | | |
| | | @Autowired |
| | | private CarUseBookJoinMapper carUseBookJoinMapper; |
| | | @Autowired |
| | | private NoticesJoinMapper noticesJoinMapper; |
| | | |
| | | |
| | | |
| | | @Override |
| | | public Integer create(Approve approve) { |
| | |
| | | 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) { |
| | | Integer noticeType = Constants.approveTypeToNoticeType(approveTempl.getType()); |
| | | String title = "【访客申请】申请人 - "; |
| | | Map<String,Object> jsonMap = new HashMap<>(); |
| | | for (int j = 0; j < ids.size(); j++) { |
| | | Integer memberId = ids.get(j); |
| | | //生成待办 notices 表数据 |
| | | if(i==0){ |
| | | if(jsonMap.isEmpty()){ |
| | | title = this.createNoticesData(noticeType,businessId,title,jsonMap); |
| | | } |
| | | 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.setInfo("待处理"); |
| | | noticesJoinMapper.insert(notices); |
| | | } |
| | | Approve approve = new Approve(); |
| | | approve.setRemark(approveParam.getRemark()); |
| | | approve.setCreateDate(new Date()); |
| | |
| | | } |
| | | } |
| | | |
| | | public void createNoticesData(List<Approve> approveList){ |
| | | for (Approve approve:approveList) { |
| | | Notices notices = new Notices(); |
| | | notices.setCreateDate(new Date()); |
| | | notices.setIsdeleted(Constants.ZERO); |
| | | notices.setObjId(approve.getObjId()); |
| | | notices.setObjId(approve.getApproveType()); |
| | | if(Constants.equalsInteger(approve.getType(),Constants.approveObjectType.unConstructionVisit) |
| | | || Constants.equalsInteger(approve.getType(),Constants.approveObjectType.constructionVisit)){ |
| | | notices.setType(Constants.ZERO); |
| | | }else if(Constants.equalsInteger(approve.getType(),Constants.approveObjectType.visitReporting)){ |
| | | notices.setType(Constants.ONE); |
| | | |
| | | |
| | | 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((waitList.size()> 0 || otherPassList.size()>0)){ |
| | | Approve waitModel = new Approve(); |
| | | waitModel.setApproveType(Constants.ONE); |
| | | waitModel.setStatusInfo(passList.size()<=0?StringUtils.defaultString(level.getTitle(),"审批人"):"抄送或签审批人"); |
| | | waitModel.setStatus(passList.size()>0?Constants.ONE:Constants.ZERO); |
| | | if(Constants.equalsInteger(level.getStatus(),Constants.approveStatus.pass)){ |
| | | waitModel.setStatus(Constants.approveStatus.pass); |
| | | waitModel.setStatusInfo("抄送或签审批人"); |
| | | }else{ |
| | | 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); |
| | | //如果是或签 |
| | |
| | | .ne(Approve::getId,approve.getId())); |
| | | }else{ |
| | | //处理其他业务数据 |
| | | if(approve.getApproveType().equals(Constants.ZERO)&&approve.getIsEndCheck()==Constants.ONE){ |
| | | //或签 且 终审 |
| | | 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()))); |
| | | 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() |
| | |
| | | .eq(Approve::getObjType,approve.getObjType()) |
| | | .eq(Approve::getLevel,(approve.getLevel()+1)) |
| | | ); |
| | | |
| | | //TODO 更新消息数据 发送下一级数据消息 |
| | | }else if(approve.getApproveType().equals(Constants.ONE)&&approve.getIsEndCheck()==Constants.ONE){ |
| | | //会签 且终审 |
| | | if(approveList.size()==Constants.ZERO){ |
| | |
| | | //TODO 审批未通过通知 |
| | | |
| | | } |
| | | |
| | | |
| | | }else if(approveDTO.getObjType().equals(Constants.approveObjectType.cityUseCar)||approveDTO.getObjType().equals( |
| | | Constants.approveObjectType.unCityUseCar)){ |
| | | // 市内外用车申请 |
| | |
| | | } |
| | | } |
| | | |
| | | public void passNextNotices(Boolean dealBusinessBean,Approve approve){ |
| | | //根据审批记录查询 通知记录 |
| | | 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) |
| | | ); |
| | | if(Objects.isNull(notices)){ |
| | | return; |
| | | } |
| | | |
| | | |
| | | if(Constants.equalsInteger(approve.getApproveType(),Constants.ZERO)){ |
| | | //或签 |
| | | //1、修改自己的数据记录 |
| | | |
| | | //2、更新他人的同级记录 为抄送 |
| | | |
| | | //3、如果不是终审生成下一级的数据记录 |
| | | |
| | | |
| | | }else if(Constants.equalsInteger(approve.getApproveType(),Constants.ONE)){ |
| | | //会签 |
| | | //1、修改自己的数据记录 |
| | | |
| | | //2、根据是否为最后一位审批人 如果不是 则结束 |
| | | |
| | | //3、 如果是最后一位审批人 且不是终审开启下一级数据 |
| | | |
| | | }else{ |
| | | //单人签 |
| | | //1、修改自己的数据记录 |
| | | |
| | | //2、 是否是终审 开启下一级数据 |
| | | |
| | | |
| | | } |
| | | //业务通过 修改审批对应消息记录 |
| | | if(Constants.equalsInteger(approve.getStatus(),Constants.approveStatus.pass)){ |
| | | |
| | | } |
| | | // |
| | | |
| | | //终审业务 发送抄送 |
| | | if (Constants.equalsInteger(approve.getIsEndCheck(),Constants.ONE)) { |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | } |
| | | |
| | | public void dealBusinessData(ApproveDTO approveDTO,Approve approve,Visits visits,CarUseBook carUseBook){ |
| | | if(approveDTO.getObjType().equals(Constants.approveObjectType.unConstructionVisit) |
| | | ||approveDTO.getObjType().equals(Constants.approveObjectType.constructionVisit) |