From 26087cf344224d029a1d4ca879682c52b8968a17 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期一, 19 八月 2024 11:35:53 +0800
Subject: [PATCH] 最新版本
---
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java | 264 ++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 251 insertions(+), 13 deletions(-)
diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java
index b561c14..f8860db 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/PlatformJobServiceImpl.java
@@ -1,31 +1,66 @@
package com.doumee.service.business.impl;
+import cn.hutool.crypto.asymmetric.Sign;
+import com.doumee.biz.system.SystemDictDataBiz;
+import com.doumee.core.constants.ResponseStatus;
+import com.doumee.core.exception.BusinessException;
+import com.doumee.core.model.LoginUserInfo;
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.PositionUtil;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.PlatformJobMapper;
+import com.doumee.dao.business.PlatformMapper;
+import com.doumee.dao.business.join.PlatformJobJoinMapper;
+import com.doumee.dao.business.model.Platform;
+import com.doumee.dao.business.model.PlatformBooks;
import com.doumee.dao.business.model.PlatformJob;
+import com.doumee.dao.business.model.PlatformReason;
+import com.doumee.dao.web.reqeust.JobDetailDTO;
+import com.doumee.dao.web.reqeust.LineUpDetailDTO;
+import com.doumee.dao.web.reqeust.SignInDTO;
+import com.doumee.dao.web.response.DriverHomeVO;
+import com.doumee.dao.web.response.LineUpVO;
import com.doumee.service.business.PlatformJobService;
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.github.yulichang.wrapper.MPJLambdaWrapper;
+import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
+import java.math.BigDecimal;
+import java.util.Date;
import java.util.List;
+import java.util.Objects;
+import java.util.stream.Collectors;
/**
* 鏈堝彴璋冨害浣滀笟淇℃伅琛⊿ervice瀹炵幇
* @author 姹熻箘韫�
- * @since 2024/04/28 16:06
+ * @date 2024/06/28 10:03
*/
@Service
public class PlatformJobServiceImpl implements PlatformJobService {
@Autowired
private PlatformJobMapper platformJobMapper;
+
+ @Autowired
+ private PlatformJobJoinMapper platformJobJoinMapper;
+
+ @Autowired
+ private SystemDictDataBiz systemDictDataBiz;
+
+ @Autowired
+ private PlatformMapper platformMapper;
+
@Override
public Integer create(PlatformJob platformJob) {
@@ -102,23 +137,22 @@
.eq(pageWrap.getModel().getRemark() != null, PlatformJob::getRemark, pageWrap.getModel().getRemark())
.eq(pageWrap.getModel().getStatus() != null, PlatformJob::getStatus, pageWrap.getModel().getStatus())
.eq(pageWrap.getModel().getSortnum() != null, PlatformJob::getSortnum, pageWrap.getModel().getSortnum())
- .eq(pageWrap.getModel().getStartTime() != null, PlatformJob::getStartTime, pageWrap.getModel().getStartTime())
- .eq(pageWrap.getModel().getEndTime() != null, PlatformJob::getEndTime, pageWrap.getModel().getEndTime())
- .eq(pageWrap.getModel().getDeviceIds() != null, PlatformJob::getDeviceIds, pageWrap.getModel().getDeviceIds())
- .eq(pageWrap.getModel().getScreenIds() != null, PlatformJob::getScreenIds, pageWrap.getModel().getScreenIds())
- .eq(pageWrap.getModel().getWorkingNum() != null, PlatformJob::getWorkingNum, pageWrap.getModel().getWorkingNum())
- .eq(pageWrap.getModel().getBroadcastNum() != null, PlatformJob::getBroadcastNum, pageWrap.getModel().getBroadcastNum())
- .eq(pageWrap.getModel().getBroadcastIds() != null, PlatformJob::getBroadcastIds, pageWrap.getModel().getBroadcastIds())
- .eq(pageWrap.getModel().getBroadcastInfo() != null, PlatformJob::getBroadcastInfo, pageWrap.getModel().getBroadcastInfo())
- .eq(pageWrap.getModel().getBroadcastHkstatus() != null, PlatformJob::getBroadcastHkstatus, pageWrap.getModel().getBroadcastHkstatus())
- .ge(pageWrap.getModel().getBroadcastHkdate() != null, PlatformJob::getBroadcastHkdate, Utils.Date.getStart(pageWrap.getModel().getBroadcastHkdate()))
- .le(pageWrap.getModel().getBroadcastHkdate() != null, PlatformJob::getBroadcastHkdate, Utils.Date.getEnd(pageWrap.getModel().getBroadcastHkdate()))
- .eq(pageWrap.getModel().getBroadcastHkinfo() != null, PlatformJob::getBroadcastHkinfo, pageWrap.getModel().getBroadcastHkinfo())
+ .eq(pageWrap.getModel().getCode() != null, PlatformJob::getCode, pageWrap.getModel().getCode())
+ .eq(pageWrap.getModel().getBillCode() != null, PlatformJob::getBillCode, pageWrap.getModel().getBillCode())
+ .eq(pageWrap.getModel().getDriverId() != null, PlatformJob::getDriverId, pageWrap.getModel().getDriverId())
+ .eq(pageWrap.getModel().getDriverName() != null, PlatformJob::getDriverName, pageWrap.getModel().getDriverName())
+ .eq(pageWrap.getModel().getPlateNum() != null, PlatformJob::getPlateNum, pageWrap.getModel().getPlateNum())
+ .eq(pageWrap.getModel().getDrivierPhone() != null, PlatformJob::getDrivierPhone, pageWrap.getModel().getDrivierPhone())
.ge(pageWrap.getModel().getSignDate() != null, PlatformJob::getSignDate, Utils.Date.getStart(pageWrap.getModel().getSignDate()))
.le(pageWrap.getModel().getSignDate() != null, PlatformJob::getSignDate, Utils.Date.getEnd(pageWrap.getModel().getSignDate()))
.eq(pageWrap.getModel().getSingType() != null, PlatformJob::getSingType, pageWrap.getModel().getSingType())
.eq(pageWrap.getModel().getSignDistance() != null, PlatformJob::getSignDistance, pageWrap.getModel().getSignDistance())
+ .eq(pageWrap.getModel().getPlatformNames() != null, PlatformJob::getPlatformNames, pageWrap.getModel().getPlatformNames())
+ .eq(pageWrap.getModel().getPlatforms() != null, PlatformJob::getPlatforms, pageWrap.getModel().getPlatforms())
.eq(pageWrap.getModel().getPlatformId() != null, PlatformJob::getPlatformId, pageWrap.getModel().getPlatformId())
+ .ge(pageWrap.getModel().getInwaitDate() != null, PlatformJob::getInwaitDate, Utils.Date.getStart(pageWrap.getModel().getInwaitDate()))
+ .le(pageWrap.getModel().getInwaitDate() != null, PlatformJob::getInwaitDate, Utils.Date.getEnd(pageWrap.getModel().getInwaitDate()))
+ .eq(pageWrap.getModel().getInwaitUserId() != null, PlatformJob::getInwaitUserId, pageWrap.getModel().getInwaitUserId())
.ge(pageWrap.getModel().getCallDate() != null, PlatformJob::getCallDate, Utils.Date.getStart(pageWrap.getModel().getCallDate()))
.le(pageWrap.getModel().getCallDate() != null, PlatformJob::getCallDate, Utils.Date.getEnd(pageWrap.getModel().getCallDate()))
.eq(pageWrap.getModel().getCallUserId() != null, PlatformJob::getCallUserId, pageWrap.getModel().getCallUserId())
@@ -158,6 +192,11 @@
.eq(pageWrap.getModel().getCancelUserId() != null, PlatformJob::getCancelUserId, pageWrap.getModel().getCancelUserId())
.eq(pageWrap.getModel().getCancelInfo() != null, PlatformJob::getCancelInfo, pageWrap.getModel().getCancelInfo())
.eq(pageWrap.getModel().getReason() != null, PlatformJob::getReason, pageWrap.getModel().getReason())
+ .eq(pageWrap.getModel().getContractNum() != null, PlatformJob::getContractNum, pageWrap.getModel().getContractNum())
+ .ge(pageWrap.getModel().getArriveDate() != null, PlatformJob::getArriveDate, Utils.Date.getStart(pageWrap.getModel().getArriveDate()))
+ .le(pageWrap.getModel().getArriveDate() != null, PlatformJob::getArriveDate, Utils.Date.getEnd(pageWrap.getModel().getArriveDate()))
+ .eq(pageWrap.getModel().getInType() != null, PlatformJob::getInType, pageWrap.getModel().getInType())
+ .eq(pageWrap.getModel().getTotalNum() != null, PlatformJob::getTotalNum, pageWrap.getModel().getTotalNum())
;
for(PageWrap.SortData sortData: pageWrap.getSorts()) {
if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
@@ -174,4 +213,203 @@
QueryWrapper<PlatformJob> wrapper = new QueryWrapper<>(platformJob);
return platformJobMapper.selectCount(wrapper);
}
+
+ //TODO
+ @Override
+ public DriverHomeVO getDriverHome(Integer memberId){
+ DriverHomeVO driverHomeVO = new DriverHomeVO();
+ //TODO 杞挱鍥�
+
+ List<PlatformJob> platformJobList = platformJobMapper.selectList(new QueryWrapper<PlatformJob>()
+ .lambda()
+ .eq(PlatformJob::getDriverId,memberId)
+// .like(PlatformJob::get)
+ .orderByDesc(PlatformJob::getId));
+ driverHomeVO.setPlatformJobList(platformJobList);
+
+
+ return driverHomeVO;
+ }
+
+
+ /**
+ * 璺濈绛惧埌
+ * @param signInDTO
+ */
+ @Override
+ @Transactional(rollbackFor = {BusinessException.class,Exception.class})
+ public void signIn(SignInDTO signInDTO){
+ if(Objects.isNull(signInDTO)
+ || Objects.isNull(signInDTO.getSignType())
+ || Objects.isNull(signInDTO.getJobId())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ PlatformJob platformJob = platformJobMapper.selectById(signInDTO.getJobId());
+ if(Objects.isNull(platformJob)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+ if(!Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WART_SIGN_IN.getKey())){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"涓氬姟鐘舵�佸凡娴佽浆锛岃鍒锋柊鏌ョ湅");
+ }
+ if(Constants.equalsInteger(signInDTO.getSignType(),Constants.ZERO)){
+ this.distanceSignIn(signInDTO,platformJob);
+ }else if(Constants.equalsInteger(signInDTO.getSignType(),Constants.ONE)){
+ this.sceneSignIn(signInDTO);
+ }
+ platformJob.setSignDate(new Date());
+ platformJob.setSingType(Constants.ZERO);
+ platformJob.setStatus(Constants.PlatformJobStatus.WAIT_CALL.getKey());
+ platformJobMapper.updateById(platformJob);
+ }
+
+
+ public void distanceSignIn(SignInDTO signInDTO , PlatformJob platformJob){
+ if(Objects.isNull(signInDTO.getLat())
+ || Objects.isNull(signInDTO.getLnt())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"缁忕含搴︿俊鎭紓甯�");
+ }
+ //鑾峰彇绛惧埌鐐圭殑缁忕含搴�
+ Double lat = Double.parseDouble(systemDictDataBiz.queryByCode(Constants.PLATFORM,Constants.SIGN_IN_PLACE_LAT).getCode());
+ Double lnt = Double.parseDouble(systemDictDataBiz.queryByCode(Constants.PLATFORM,Constants.SIGN_IN_PLACE_LNT).getCode());
+ BigDecimal distance = new BigDecimal(systemDictDataBiz.queryByCode(Constants.PLATFORM,Constants.SIGN_IN_PLACE_DISTANCE).getCode());
+ //鑾峰彇2涓偣鐨勮窛绂籜绫�
+ Double getDistanceDouble = PositionUtil.getDistance(signInDTO.getLnt(),signInDTO.getLat(),lnt,lat);
+ //杞崲km
+ BigDecimal getDistance = BigDecimal.valueOf(getDistanceDouble).divide(new BigDecimal(1000),2,BigDecimal.ROUND_HALF_UP);
+ if(distance.compareTo(getDistance)<Constants.ZERO){
+ throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瓒呭嚭鍙鍒拌窛绂伙紝鍙鍒拌窛绂籟"+distance+"]鍏噷]");
+ }
+ platformJob.setSignDistance(BigDecimal.valueOf(getDistanceDouble));
+ }
+
+ public void sceneSignIn(SignInDTO signInDTO){
+ if( StringUtils.isNotBlank(signInDTO.getQrCodeKey())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ if(!signInDTO.getQrCodeKey().equals(systemDictDataBiz.queryByCode(Constants.PLATFORM,Constants.SIGN_IN_QRCODE).getCode())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST.getCode(),"浜岀淮鐮佸凡杩囨湡,璇峰埛鏂伴噸璇�");
+ }
+ }
+
+
+ @Override
+ public PlatformJob getDetail(JobDetailDTO jobDetailDTO){
+ if(Objects.isNull(jobDetailDTO)
+ || Objects.isNull(jobDetailDTO.getJobId())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ PlatformJob platformJob = platformJobMapper.selectById(jobDetailDTO.getJobId());
+ if(Objects.isNull(platformJob)){
+ throw new BusinessException(ResponseStatus.DATA_EMPTY);
+ }
+ if(Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WART_SIGN_IN.getKey())){
+ //寰呯鍒� 璁$畻璺濈
+ if(Objects.nonNull(jobDetailDTO.getLnt())&&Objects.nonNull(jobDetailDTO.getLat())){
+ //鑾峰彇绛惧埌鐐圭殑缁忕含搴�
+ Double lat = Double.parseDouble(systemDictDataBiz.queryByCode(Constants.PLATFORM,Constants.SIGN_IN_PLACE_LAT).getCode());
+ Double lnt = Double.parseDouble(systemDictDataBiz.queryByCode(Constants.PLATFORM,Constants.SIGN_IN_PLACE_LNT).getCode());
+ //鑾峰彇2涓偣鐨勮窛绂籜绫�
+ Double getDistanceDouble = PositionUtil.getDistance(jobDetailDTO.getLnt(),jobDetailDTO.getLat(),lnt,lat);
+ //杞崲km
+ BigDecimal getDistance = BigDecimal.valueOf(getDistanceDouble).divide(new BigDecimal(1000),2,BigDecimal.ROUND_HALF_UP);
+ platformJob.setGetDistance(getDistance);
+ }
+ }else if( Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WAIT_CALL.getKey())
+ || Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.IN_WAIT.getKey())
+ ){//鏌ヨ鎺掗槦鎯呭喌
+ Long lineUpNum = platformJobMapper.selectCount(new QueryWrapper<PlatformJob>().lambda()
+ .eq(PlatformJob::getIsdeleted,Constants.ZERO)
+ .in(PlatformJob::getStatus,Constants.PlatformJobStatus.WAIT_CALL.getKey()
+ ,Constants.PlatformJobStatus.IN_WAIT.getKey()
+ ,Constants.PlatformJobStatus.TRANSFERING.getKey())
+ .gt(PlatformJob::getSignDate,platformJob.getSignDate())
+ .like(PlatformJob::getArriveDate,DateUtil.getDate(platformJob.getArriveDate(),"yyyy-MM-dd")));
+ platformJob.setLineUpNum(lineUpNum);
+ }else if(Constants.equalsInteger(platformJob.getStatus(),Constants.PlatformJobStatus.WORKING.getKey())){
+ //浣滀笟鏈堝彴淇℃伅
+ Platform platform = platformMapper.selectById(platformJob.getPlatformId());
+ if(Objects.nonNull(platform)){
+ platformJob.setPlatformName(platform.getName());
+ }
+ }
+ return platformJob;
+ }
+
+
+
+ @Override
+ public LineUpVO lineUpDetail(LineUpDetailDTO lineUpDetailDTO){
+ if(Objects.isNull(lineUpDetailDTO)
+ || Objects.isNull(lineUpDetailDTO.getQueryType())){
+ throw new BusinessException(ResponseStatus.BAD_REQUEST);
+ }
+ LineUpVO lineUpVO = new LineUpVO();
+ //鏌ヨ鎵�鏈変换鍔�
+ List<PlatformJob> platformJobList = platformJobJoinMapper.selectJoinList(PlatformJob.class,
+ new MPJLambdaWrapper<PlatformJob>()
+ .selectAll(PlatformJob.class)
+ .selectAs(PlatformReason::getGroupId,PlatformJob::getGroupId)
+ .leftJoin(PlatformBooks.class,PlatformBooks::getJobId,PlatformJob::getId)
+ .leftJoin(PlatformReason.class,PlatformReason::getId,PlatformBooks::getReasonId)
+ .eq(PlatformJob::getIsdeleted,Constants.ZERO)
+ .eq(Constants.equalsInteger(lineUpDetailDTO.getQueryType(),Constants.ZERO)
+ ,PlatformJob::getDrivierPhone,lineUpDetailDTO.getMobile())
+ .eq(Constants.equalsInteger(lineUpDetailDTO.getQueryType(),Constants.ONE)
+ ,PlatformJob::getId,lineUpDetailDTO.getJobId())
+ .in(PlatformJob::getStatus,Constants.PlatformJobStatus.WAIT_CALL.getKey(),
+ Constants.PlatformJobStatus.IN_WAIT.getKey(),
+ Constants.PlatformJobStatus.CALLED.getKey())
+ .orderByAsc(PlatformJob::getSignDate)
+ );
+ //鑾峰彇鎵�鏈夋湀鍙�
+ List<Integer> platformIdList = platformJobList.stream().map(m->m.getGroupId()).collect(Collectors.toList());
+ List<Platform> platformList = platformMapper.selectList(new QueryWrapper<Platform>().lambda()
+ .eq(Platform::getIsdeleted,Constants.ZERO)
+ .in(Platform::getId,platformIdList));
+
+ for (Platform platform:platformList) {
+ //鏌ヨ鏈湀鍙颁笅 鑷繁鐨勬暟鎹� 鏈�鏃╃鍒扮殑
+ PlatformJob platformJob = platformJobList.stream().filter(i->Constants.equalsInteger(i.getGroupId(),platform.getId())).findFirst().orElse(null);
+ //鏌ヨ鍦ㄥ綋鍓嶆湀鍙颁笅 绛惧埌鎺掗槦杞﹁締鏁版嵁
+ List<PlatformJob> platformJobSignInList = platformJobJoinMapper.selectJoinList(PlatformJob.class,
+ new MPJLambdaWrapper<PlatformJob>()
+ .selectAll(PlatformJob.class)
+ .selectAs(PlatformReason::getGroupId,PlatformJob::getGroupId)
+ .leftJoin(PlatformBooks.class,PlatformBooks::getJobId,PlatformJob::getId)
+ .leftJoin(PlatformReason.class,PlatformReason::getId,PlatformBooks::getReasonId)
+ .eq(PlatformJob::getIsdeleted,Constants.ZERO)
+ .ge(Objects.nonNull(platformJob),PlatformJob::getSignDate,DateUtil.getDate(platformJob.getSignDate(),"yyyy-MM-dd HH:mm:ss"))
+ .in(PlatformJob::getStatus,Constants.PlatformJobStatus.WAIT_CALL.getKey(),
+ Constants.PlatformJobStatus.IN_WAIT.getKey(),
+ Constants.PlatformJobStatus.CALLED.getKey())
+ .orderByDesc(PlatformJob::getSignDate));
+ platform.setSignJobList(platformJobSignInList);
+ //鏌ヨ褰撳墠鏈堝彴涓�
+ List<PlatformJob> platformJobWorkList = platformJobJoinMapper.selectJoinList(PlatformJob.class,
+ new MPJLambdaWrapper<PlatformJob>()
+ .selectAll(PlatformJob.class)
+ .selectAs(PlatformReason::getGroupId,PlatformJob::getGroupId)
+ .leftJoin(PlatformBooks.class,PlatformBooks::getJobId,PlatformJob::getId)
+ .leftJoin(PlatformReason.class,PlatformReason::getId,PlatformBooks::getReasonId)
+ .eq(PlatformJob::getIsdeleted,Constants.ZERO)
+ .eq(PlatformJob::getStatus,Constants.PlatformJobStatus.WORKING.getKey())
+ .orderByDesc(PlatformJob::getSignDate));
+ platform.setSignJobList(platformJobSignInList);
+ platform.setWorkJobList(platformJobWorkList);
+ }
+
+
+
+
+
+
+
+ lineUpVO.setPlatformList(platformList);
+
+
+ return lineUpVO;
+ }
+
+
+
}
--
Gitblit v1.9.3