|  |  |  | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.metadata.IPage; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
|---|
|  |  |  | import com.doumee.service.business.third.EmayService; | 
|---|
|  |  |  | import com.github.yulichang.wrapper.MPJLambdaWrapper; | 
|---|
|  |  |  | import org.apache.commons.lang3.StringUtils; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | 
|---|
|  |  |  | import org.springframework.util.CollectionUtils; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.math.BigDecimal; | 
|---|
|  |  |  | import java.util.Arrays; | 
|---|
|  |  |  | import java.util.Date; | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  | import java.util.Objects; | 
|---|
|  |  |  | import java.util.*; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * 月台入园预约信息表Service实现 | 
|---|
|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WxNoticeConfigMapper wxNoticeConfigMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private ApproveMapper approveMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(PlatformBooks platformBooks) { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | .set(PlatformBooks::getEditDate,date) | 
|---|
|  |  |  | .set(PlatformBooks::getEditor,user.getId()) | 
|---|
|  |  |  | .eq(PlatformBooks::getId,id)); | 
|---|
|  |  |  | platformJobMapper.update(null,new UpdateWrapper<PlatformJob>().lambda() | 
|---|
|  |  |  | .set(PlatformJob::getIsdeleted,Constants.ONE) | 
|---|
|  |  |  | .set(PlatformJob::getEditDate,new Date()) | 
|---|
|  |  |  | .set(PlatformJob::getEditor,user.getId()) | 
|---|
|  |  |  | .eq(PlatformJob::getBookId,id) | 
|---|
|  |  |  | .eq(PlatformJob::getIsdeleted,Constants.ZERO)); | 
|---|
|  |  |  | if(model.getJobId()!=null){ | 
|---|
|  |  |  | platformJobMapper.update(null,new UpdateWrapper<PlatformJob>().lambda() | 
|---|
|  |  |  | .set(PlatformJob::getIsdeleted,Constants.ONE) | 
|---|
|  |  |  | .set(PlatformJob::getEditDate,new Date()) | 
|---|
|  |  |  | .set(PlatformJob::getEditor,user.getId()) | 
|---|
|  |  |  | .eq(PlatformJob::getId,model.getJobId()) | 
|---|
|  |  |  | .eq(PlatformJob::getIsdeleted,Constants.ZERO)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String[] params = new String[3]; | 
|---|
|  |  |  | params[0] = user.getRealname(); | 
|---|
|  |  |  | params[1]=DateUtil.getPlusTime2(date); | 
|---|
|  |  |  | params[2]="【合同号:"+model.getContractNum()+"】-【司机:"+model.getDriverName()+" "+model.getDriverPhone()+"】-【车牌好: "+model.getPlateNum()+"】"; | 
|---|
|  |  |  | //记录删除日志 | 
|---|
|  |  |  | UserActionServiceImpl.saveUserActionBiz(user,id,Constants.UserActionType.PLATFROM_BOOK_DEL,userActionMapper,date,params, JSONObject.toJSONString(model)); | 
|---|
|  |  |  | //标记任务记录 | 
|---|
|  |  |  | VisitsServiceImpl.dealCancelNoticesData(noticesJoinMapper,approveMapper,"系统删除",model.getId(), | 
|---|
|  |  |  | Constants.approveObjectType.reason, | 
|---|
|  |  |  | Constants.noticesObjectType.reason | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void delete(PlatformBooks platformBooks) { | 
|---|
|  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public PageData<PlatformBooks> findPage(PageWrap<PlatformBooks> pageWrap) { | 
|---|
|  |  |  | IPage<PlatformBooks> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity()); | 
|---|
|  |  |  | QueryWrapper<PlatformBooks> queryWrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | MPJLambdaWrapper<PlatformBooks> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | pageWrap.getModel().setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | queryWrapper.lambda() | 
|---|
|  |  |  | queryWrapper | 
|---|
|  |  |  | .selectAll(PlatformBooks.class) | 
|---|
|  |  |  | .selectAs(PlatformJob::getStatus,PlatformBooks::getJobStatus) | 
|---|
|  |  |  | .selectAs(SystemUser::getRealname,PlatformBooks::getEditUserName) | 
|---|
|  |  |  | .leftJoin(PlatformJob.class,PlatformJob::getId,PlatformBooks::getJobId) | 
|---|
|  |  |  | .leftJoin(SystemUser.class,SystemUser::getId,PlatformJob::getEditDate) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getId() != null, PlatformBooks::getId, pageWrap.getModel().getId()) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getCreator() != null, PlatformBooks::getCreator, pageWrap.getModel().getCreator()) | 
|---|
|  |  |  | .ge(pageWrap.getModel().getCreateDate() != null, PlatformBooks::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate())) | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(pageWrap.getModel().getName() != null, PlatformBooks::getName, pageWrap.getModel().getName()) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getRemark() != null, PlatformBooks::getRemark, pageWrap.getModel().getRemark()) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getStatus() != null, PlatformBooks::getStatus, pageWrap.getModel().getStatus()) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getContractNum() != null, PlatformBooks::getContractNum, pageWrap.getModel().getContractNum()) | 
|---|
|  |  |  | .like(pageWrap.getModel().getContractNum() != null, PlatformBooks::getContractNum, pageWrap.getModel().getContractNum()) | 
|---|
|  |  |  | .ge(pageWrap.getModel().getArriveDate() != null, PlatformBooks::getArriveDate, Utils.Date.getStart(pageWrap.getModel().getArriveDate())) | 
|---|
|  |  |  | .le(pageWrap.getModel().getArriveDate() != null, PlatformBooks::getArriveDate, Utils.Date.getEnd(pageWrap.getModel().getArriveDate())) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getInType() != null, PlatformBooks::getInType, pageWrap.getModel().getInType()) | 
|---|
|  |  |  | 
|---|
|  |  |  | .eq(pageWrap.getModel().getPlateNum() != null, PlatformBooks::getPlateNum, pageWrap.getModel().getPlateNum()) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getDriverPhone() != null, PlatformBooks::getDriverPhone, pageWrap.getModel().getDriverPhone()) | 
|---|
|  |  |  | .ge(pageWrap.getModel().getQueryDate() != null, PlatformBooks::getCreateDate, pageWrap.getModel().getQueryDate()) | 
|---|
|  |  |  | .ge(pageWrap.getModel().getArriveDateStart() != null, PlatformBooks::getArriveDate, Utils.Date.getStart(pageWrap.getModel().getArriveDateStart())) | 
|---|
|  |  |  | .le(pageWrap.getModel().getArriveDateEnd() != null, PlatformBooks::getArriveDate, Utils.Date.getEnd(pageWrap.getModel().getArriveDateEnd())) | 
|---|
|  |  |  | .ge(pageWrap.getModel().getArriveDateStart() != null, PlatformBooks::getArriveDate, pageWrap.getModel().getArriveDateStart()) | 
|---|
|  |  |  | .le(pageWrap.getModel().getArriveDateEnd() != null, PlatformBooks::getArriveDate, pageWrap.getModel().getArriveDateEnd()) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getReasonId() != null, PlatformBooks::getReasonId, pageWrap.getModel().getReasonId()) | 
|---|
|  |  |  | .eq(pageWrap.getModel().getJobStatus() != null, PlatformJob::getStatus, pageWrap.getModel().getJobStatus()) | 
|---|
|  |  |  | .orderByDesc(PlatformBooks::getCreateDate) | 
|---|
|  |  |  | ; | 
|---|
|  |  |  | PageData<PlatformBooks> pageData = PageData.from(platformBooksMapper.selectPage(page, queryWrapper)); | 
|---|
|  |  |  | PageData<PlatformBooks> pageData = PageData.from(platformBooksMapper.selectJoinPage(page,PlatformBooks.class, queryWrapper)); | 
|---|
|  |  |  | for (PlatformBooks platformBooks:pageData.getRecords()) { | 
|---|
|  |  |  | if(Constants.equalsInteger(platformBooks.getStatus(),Constants.ONE)||Constants.equalsInteger(platformBooks.getStatus(),Constants.ZERO)){ | 
|---|
|  |  |  | String auditName = approveService.getApproveUserName(platformBooks.getId(),Constants.approveObjectType.reason); | 
|---|
|  |  |  | 
|---|
|  |  |  | if(Objects.isNull(platformReason)|| !Constants.equalsInteger(platformReason.getIsdeleted(),Constants.ZERO)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"入园原因信息异常,请刷新重试"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(platformBooksApplyDTO.getTotalNum().compareTo(platformReason.getLimitNum())>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"任务量超出单日可作业量,请修改后重新输入!"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | PlatformGroup platformGroup= platformGroupMapper.selectById(platformReason.getGroupId()); | 
|---|
|  |  |  | if(Objects.isNull(platformGroup)){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"未查询到绑定月台组数据"); | 
|---|
|  |  |  | 
|---|
|  |  |  | wxPlatNotice.sendPlatformBookTemplateNotice(systemDictDataBiz, | 
|---|
|  |  |  | wxNoticeConfigMapper, platformBooks, | 
|---|
|  |  |  | WxPlatConstants.platformBookContent.platformBookUpload, | 
|---|
|  |  |  | systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(), | 
|---|
|  |  |  | Arrays.asList(driver.getOpenid().split(",")),0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return platformBooks.getId(); | 
|---|
|  |  |  | 
|---|
|  |  |  | || Objects.isNull(platformBooksApplyDTO.getDriverId()) | 
|---|
|  |  |  | || StringUtils.isBlank(platformBooksApplyDTO.getDriverPhone()) | 
|---|
|  |  |  | || StringUtils.isBlank(platformBooksApplyDTO.getDriverName()) | 
|---|
|  |  |  | || StringUtils.isBlank(platformBooksApplyDTO.getTransportImg()) | 
|---|
|  |  |  | ){ | 
|---|
|  |  |  | || StringUtils.isBlank(platformBooksApplyDTO.getTransportImg())){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.BAD_REQUEST); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //查询车辆是否为自有车 | 
|---|
|  |  |  | 
|---|
|  |  |  | platformBooks.setReasonId(null); | 
|---|
|  |  |  | platformBooks.setInReason(null); | 
|---|
|  |  |  | platformBooksMapper.updateById(platformBooks); | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Map<String,Object> jsonMap = new HashMap<>(); | 
|---|
|  |  |  | String title = ApproveServiceImpl.creatPlatformBookNotice(platformBooks,jsonMap); | 
|---|
|  |  |  | noticesJoinMapper.update(null,new UpdateWrapper<Notices>().lambda() | 
|---|
|  |  |  | .set(Notices::getParam1,JSONObject.toJSONString(jsonMap)) | 
|---|
|  |  |  | .set(Notices::getTitle,title) | 
|---|
|  |  |  | .eq(Notices::getObjType,Constants.noticesObjectType.reason) | 
|---|
|  |  |  | .eq(Notices::getTitle,title) | 
|---|
|  |  |  | .eq(Notices::getObjId,platformBooks.getId()) | 
|---|
|  |  |  | ); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return platformBooks.getId(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|