k94314517
2024-10-18 0ddf64959252ef28c6050bbe0c0c64f99468ed25
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/hksync/HkSyncPushServiceImpl.java
@@ -22,6 +22,7 @@
import com.doumee.dao.business.join.VisitsJoinMapper;
import com.doumee.dao.business.model.*;
import com.doumee.dao.web.reqeust.SavePlatformWarnEventDTO;
import com.doumee.service.business.PlatformJobService;
import com.doumee.service.business.impl.PlatformWarnEventServiceImpl;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.extern.slf4j.Slf4j;
@@ -29,11 +30,11 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
 * 访客权限组信息表Service实现
@@ -86,6 +87,8 @@
    private PlatformLogMapper platformLogMapper;
    @Autowired
    private PlatformWarnEventServiceImpl platformWarnEventService;
    @Autowired
    private PlatformJobService platformJobService;
    /**
     * 海康门禁事件推送
     * @param param
@@ -494,7 +497,7 @@
                delRetentionLis.add(visits.getMemberId());
                //如果是访客通行
                if(request.getData()!=null&&request.getData().getParamValues()!=null &&
                        StringUtils.equals(request.getData().getParamValues().getInOrOut(),"1")){
                        StringUtils.equals(request.getData().getParamValues().getInOrOut(),"0")){
                    //如果是访客登记,录入人员的在场数据记录
                    Retention r = getRetentionModelByVisitRequest(visits, request.getHappenTime(),request.getSrcType());
                    r.setCarNo(request.getData().getParamValues().getPlateNos());
@@ -505,7 +508,7 @@
                    inoutDayCount.setInVisitorNum(Constants.formatIntegerNum(inoutDayCount.getInVisitorNum())+1);
                }
                if(request.getData()!=null&&request.getData().getParamValues()!=null &&
                         StringUtils.equals(request.getData().getParamValues().getInOrOut(),"2")){
                         !StringUtils.equals(request.getData().getParamValues().getInOrOut(),"0")){
                    inoutDayCount.setOutVisitorNum(Constants.formatIntegerNum(inoutDayCount.getOutVisitorNum())+1);
                }
            }
@@ -571,6 +574,7 @@
        event.setPhotoUrl(getHkImgUrl(detail.getFacePic()));
        event.setPersonName(detail.getVisitorName());
        event.setCarNo(detail.getPlateNo());
        event.setRemark(JSONObject.toJSONString(request));
        event.setInvoicesNo(request.getData().getVisitorInvoices().getInvoicesNo());//访客单号
        event.setIdType(detail.getCertType());
        String idnum = detail.getCertNo();
@@ -821,6 +825,75 @@
                    .last("limit 1" ));
            if(cars!=null){
                event.setMemberId(cars.getMemberId());
                    if(Constants.formatIntegerNum(request.getEventType()) == HKConstants.EventTypes.PARK_PASS_IN.getKey()){
                        if(carsMapper.selectCount(new QueryWrapper<Cars>()
                                .lambda().eq(Cars::getCode,event.getPlateNos())
                                .eq(Cars::getType,Constants.ONE)
                                .eq(Cars::getIsdeleted,Constants.ZERO)
                        )>Constants.ZERO){
                            //自有车进场  查询当前是否有待签到的任务
                            //查询车辆当前是否存在进行中的任务
                            if(platformJobMapper.selectCount(new QueryWrapper<PlatformJob>().lambda()
                                    .eq(PlatformJob::getCarCodeFront,event.getPlateNos())
                                    .eq(PlatformJob::getIsdeleted,Constants.ZERO)
                                    .in(PlatformJob::getStatus,
                                            Constants.PlatformJobStatus.IN_WAIT.getKey(),
                                            Constants.PlatformJobStatus.CALLED.getKey(),
                                            Constants.PlatformJobStatus.WORKING.getKey(),
                                            Constants.PlatformJobStatus.DONE.getKey(),
                                            Constants.PlatformJobStatus.TRANSFERING.getKey(),
                                            Constants.PlatformJobStatus.EXCEPTION.getKey(),
                                            Constants.PlatformJobStatus.AUTHED_LEAVE.getKey()
                                    )
                            )==Constants.ZERO){
                                PlatformJob platformJob = platformJobMapper.selectOne(new QueryWrapper<PlatformJob>().lambda()
                                        .eq(PlatformJob::getCarCodeFront,event.getPlateNos())
                                        .eq(PlatformJob::getIsdeleted,Constants.ZERO)
                                        .in(PlatformJob::getStatus,
                                                Constants.PlatformJobStatus.WAIT_CONFIRM.getKey(),
                                                Constants.PlatformJobStatus.WART_SIGN_IN.getKey()
                                        )
                                        .orderByAsc(PlatformJob::getCreateDate)
                                        .last(" limit 1")
                                );
                                if(Objects.nonNull(platformJob)){
                                    platformJob.setStatus(Constants.PlatformJobStatus.WAIT_CALL.getKey());
                                    platformJob.setArriveDate(new Date());
                                    platformJob.setSingType(Constants.TWO);
                                    platformJob.setSignDate(new Date());
                                    List<PlatformJob> signList = platformJobMapper.selectList(new QueryWrapper<PlatformJob>().lambda().apply(" DATE(SIGN_DATE) = DATE(NOW()) and sign_date is not null  "));
                                    if(CollectionUtils.isEmpty(signList)){
                                        platformJob.setSignNum(Constants.ONE);
                                    } else{
                                        int maxNumber = Collections.max(signList.stream().map(i->i.getSignNum()).collect(Collectors.toList()));
                                        platformJob.setSignNum(maxNumber + Constants.ONE);
                                    }
                                    platformJobMapper.updateById(platformJob);
                                }
                            }
                        }
                    }else if(Constants.formatIntegerNum(request.getEventType()) == HKConstants.EventTypes.PARK_PASS_OUT.getKey()){
                        //离场判断是否存在未离场的订单数据 处理订单数据
                        List<PlatformJob> platformJobList = platformJobMapper.selectList(new QueryWrapper<PlatformJob>().lambda()
                                .eq(PlatformJob::getCarCodeFront,event.getPlateNos())
                                .eq(PlatformJob::getIsdeleted,Constants.ZERO)
                                .in(PlatformJob::getStatus,
                                        Constants.PlatformJobStatus.DONE.getKey(),
                                        Constants.PlatformJobStatus.AUTHED_LEAVE.getKey()
                                ));
                        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(platformJobList)){
                            for (PlatformJob platformJob:platformJobList) {
                                platformJob.setStatus(Constants.PlatformJobStatus.LEAVED.getKey());
                                platformJob.setOutDate(new Date());
                                platformJob.setEditDate(new Date());
                                platformJob.setOutType(Constants.ZERO);
                                platformJobMapper.updateById(platformJob);
                                //清空授权
                                platformJobService.cancelInPark(platformJob);
                            }
                        }
                    }
            }else{
                Visits visits =  visitsMapper.selectOne(new QueryWrapper<Visits>().lambda()
                        .eq(Visits::getCarNos,event.getPlateNos())