From 17efddc6a667670dca682bf36b51a43e99615e6d Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期三, 16 十月 2024 15:59:38 +0800
Subject: [PATCH] 代码初始化

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java |  979 ++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 782 insertions(+), 197 deletions(-)

diff --git a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java
index 72e088c..1159f56 100644
--- a/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java
+++ b/server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java
@@ -4,10 +4,16 @@
 import com.doumee.biz.system.SystemDictDataBiz;
 import com.doumee.core.constants.ResponseStatus;
 import com.doumee.core.exception.BusinessException;
+import com.doumee.core.haikang.model.HKConstants;
+import com.doumee.core.haikang.model.param.BaseResponse;
+import com.doumee.core.haikang.model.param.request.ParkReservationAddRequest;
+import com.doumee.core.haikang.model.param.respose.ParkReservationAddResponse;
+import com.doumee.core.haikang.service.HKService;
 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.SmsConstants;
 import com.doumee.core.utils.Utils;
 import com.doumee.dao.business.*;
 import com.doumee.dao.business.dao.CompanyMapper;
@@ -17,6 +23,7 @@
 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;
@@ -26,13 +33,14 @@
 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.doumee.service.business.third.EmayService;
 import com.github.xiaoymin.knife4j.core.util.CollectionUtils;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
-import io.swagger.models.auth.In;
+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.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -45,6 +53,7 @@
  * @date 2023/12/28 14:09
  */
 @Service
+@Slf4j
 public class ApproveServiceImpl implements ApproveService {
 
     @Autowired
@@ -84,7 +93,35 @@
     private CarUseBookJoinMapper carUseBookJoinMapper;
     @Autowired
     private NoticesJoinMapper noticesJoinMapper;
+    @Autowired
+    private PlatformBooksMapper platformBooksMapper;
+    @Autowired
+    private PlatformJobMapper platformJobMapper;
+    @Autowired
+    private PlatformLogMapper platformLogMapper;
+    @Autowired
+    private PlatformReasonMapper platformReasonMapper;
+    @Autowired
+    private PlatformGroupMapper platformGroupMapper;
 
+
+    @Autowired
+    private ParksMapper parksMapper;
+
+    @Autowired
+    private ParkBookMapper parkBookMapper;
+
+    @Autowired
+    private VisitParkMapper visitParkMapper;
+
+    @Autowired
+    private SmsConfigMapper smsConfigMapper;
+
+    @Autowired
+    private SmsEmailMapper smsEmailMapper;
+
+    @Autowired
+    private EmayService emayService;
 
 
     @Override
@@ -232,16 +269,95 @@
     /**
      * 鍐呴儴浜哄憳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)
+                            &&Constants.equalsInteger(i.getReaded(),Constants.ZERO)
+                    ).count()
+            );
+        }
+
+        return internalHomeVO;
+    }
 
     /**
      * 鍒涘缓瀹℃壒娴佺▼
@@ -292,10 +408,55 @@
 
         //澶勭悊鎶勯�佹暟鎹�
         if(CollectionUtils.isNotEmpty(approveCopyList)){
-            this.organizeApproveCopyData(approveTempl,approveParamList,businessId,approveList);
+            this.organizeApproveCopyData(approveTempl,approveCopyList,businessId,approveList);
         }
-        approveMapper.insertBatchSomeColumn(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);
     }
 
 
@@ -308,19 +469,68 @@
      * @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 = "銆愯瀹㈢敵璇枫�戠敵璇蜂汉 - ";
+            String title = "[璁垮鐢宠]鐢宠浜�-";
             Map<String,Object> jsonMap = new HashMap<>();
-            for (int j = 0; j < ids.size(); j++) {
-                Integer memberId = ids.get(j);
+            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());
@@ -336,7 +546,14 @@
                     notices.setReaded(Constants.ZERO);
                     notices.setSendacopy(Constants.ZERO);
                     notices.setParam2("0");
-                    notices.setInfo("寰呭鐞�");
+                    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();
@@ -346,7 +563,8 @@
                 approve.setTemplatId(approveTempl.getId());
                 approve.setChekorId(memberId);
                 approve.setStatus(i==0?Constants.ONE:Constants.ZERO);
-                approve.setStatusInfo(i==0?"瀹℃壒涓�":"寰呭鎵�");
+                approve.setStatusInfo(i==0?"瀹℃壒涓�":"澶勭悊涓�");
+                approve.setTitle(StringUtils.isBlank(approveParam.getRemark())?"瀹℃壒涓�":approveParam.getRemark());
                 approve.setIsEndCheck((i+1) == approveParamList.size()?Constants.ONE:Constants.ZERO);
                 approve.setObjId(businessId);
                 approve.setLevel(i+1);
@@ -356,6 +574,19 @@
                 approve.setAddrParam(approveParam.getAddrParam());
                 approve.setType(Constants.ZERO);
                 approveList.add(approve);
+
+                if(Constants.equalsInteger(approve.getStatus(),Constants.ONE)){
+                    //鍙戦�佺煭淇¢�氱煡
+                    if(Constants.equalsInteger(noticeType,Constants.noticesObjectType.reason)){
+                        //鐗╂祦杞﹂绾�
+                        SmsEmailServiceImpl.sendPlatformBookSms(systemDictDataBiz,
+                                emayService,smsEmailMapper,smsConfigMapper,platformBooksMapper,businessId,
+                                SmsConstants.platformBookContent.platformBookWaitAudit,
+                                null,null
+                        );
+                    }
+                }
+
             }
         }
     }
@@ -382,7 +613,7 @@
             if(Constants.equalsInteger(noticeType,Constants.noticesObjectType.visit)){
                 title = title + visits.getName();
             }else{
-                title = "銆愯瀹㈡姤澶囥�戠敵璇蜂汉 - " + visits.getName();
+                title = "[璁垮鎶ュ]鐢宠浜�-" + visits.getName();
             }
             jsonMap.put("name", "璁块棶浜�:" + visits.getCompanyName() + " - " + visits.getReceptMemberName());
             jsonMap.put("sTime", "鍏ュ洯鏃堕棿:" + DateUtil.DateToStr(visits.getStarttime() , "yyyy-MM-dd HH:mm"));
@@ -403,14 +634,23 @@
             if(Objects.isNull(carUseBook)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌涓氬姟鏁版嵁淇℃伅");
             }
-            title = "銆愮敤杞︾敵璇枫�戠敵璇蜂汉 - " + carUseBook.getMemberName();
+            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);
+        }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;
     }
@@ -429,18 +669,18 @@
             if(CollectionUtils.isNotEmpty(memberList)){
                 userIds.addAll(memberList.stream().map(m->m.getId()).collect(Collectors.toList()));
             }
-            //鍏姟鐢ㄨ溅 榛樿鍔犲叆 鍙告満鎶勯��
-            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());
-            }
+            //鍏姟鐢ㄨ溅 榛樿鍔犲叆 鍙告満鎶勯��  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) {
@@ -449,6 +689,7 @@
                     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);
@@ -482,7 +723,7 @@
             if(Objects.isNull(memberCompany)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒娴侀厤缃敊璇痆鎸囧畾瀹℃壒閮ㄩ棬鏈煡璇㈠埌]");
             }
-            Company auditCompany = this.getAuditCompanyHead(memberCompany.getParentId(),approveParam.getObjLevel());
+            Company auditCompany = this.getAuditCompanyHead(memberCompany.getId(),approveParam.getObjLevel());
             if(Objects.isNull(auditCompany)){
                 //瀹℃壒閮ㄩ棬涓虹┖ 鑷姩娴佽浆涓嬩竴绾у鎵归厤缃�
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒娴侀厤缃敊璇痆鎸囧畾瀹℃壒閮ㄩ棬鏈煡璇㈠埌]");
@@ -491,7 +732,7 @@
                 Member headMember = memberMapper.selectById(auditCompany.getHeadId());
                 if(Objects.isNull(headMember)){
                     //鏈煡璇㈠埌閮ㄩ棬璐熻矗浜�  鏍规嵁閰嶇疆澶勭悊   鐢变笂绾т富绠′唬鏇垮鏍�/鐩存帴缁撴潫娴佺▼
-                    if(approveParam.getNoleaderOpt().equals(Constants.ONE)&&!Objects.isNull(auditCompany.getParentId())){
+                    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)){
@@ -506,9 +747,11 @@
                             userIds.add(headMember.getId());
                         }
                     }else{
-                        //娣诲姞瀹℃壒浜�
-                        userIds.add(headMember.getId());
+                        throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒娴侀厤缃敊璇痆鎸囧畾瀹℃壒閮ㄩ棬涓荤鏈煡璇㈠埌]");
                     }
+                }else{
+                    //娣诲姞瀹℃壒浜�
+                    userIds.add(headMember.getId());
                 }
             }
         }
@@ -523,9 +766,9 @@
      * @param objLevel  鏌ヨ绾у埆
      */
     public Company getAuditCompanyHead(Integer companyId, Integer objLevel){
-        Integer queryLevel = Constants.ZERO;
         Company auditCompany =  companyMapper.selectById(companyId);
-        while(queryLevel.equals(objLevel)){
+        Integer queryLevel = Constants.ONE;
+        while(queryLevel<objLevel){
             auditCompany = companyMapper.selectById(auditCompany.getParentId());
             if(Objects.isNull(auditCompany)){
                 return null;
@@ -550,22 +793,22 @@
                         .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鏌ヨ姣忎竴绾у埆涓氬姟鏁版嵁
-        for(Approve level:levelList){
-            List<Approve> tlist = getLevelInfoFromList(level,approveGroupList);
-            approveDateVO.getApproveList().addAll(tlist);
-            if(tlist.size() ==0
-                    ||Constants.equalsInteger(Constants.approveStatus.unPass,  tlist.get(0).getStatus())
-                    ||Constants.equalsInteger(Constants.approveStatus.cancel,  tlist.get(0).getStatus())){
-                break;
+        if(levelList!=null){
+            for(Approve level:levelList){
+                List<Approve> tlist = getLevelInfoFromList(level,approveGroupList);
+                approveDateVO.getApproveList().addAll(tlist);
             }
         }
 
@@ -573,13 +816,14 @@
         if (CollectionUtils.isNotEmpty(copyList)) {
             Approve waitModel = new Approve();
             waitModel.setApproveType(Constants.ONE);
+            waitModel.setCheckDate(copyList.get(Constants.ZERO).getCheckDate());
             waitModel.setTitle("鎶勯�佷汉");
-            waitModel.setStatus(Constants.ONE);
+            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;
     }
 
@@ -594,7 +838,7 @@
     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);
+            level.setApproveType(Constants.TWO);
             //濡傛灉鏄崟浜哄鎵�
             list.add(level);
             return list;
@@ -604,8 +848,8 @@
         Approve  refuseModel = new Approve();//宸叉嫆缁濈殑璁板綍
         List<Approve> waitList = new ArrayList<>();  //鏌ヨ鍏ㄩ儴鏈鐞嗙殑闆嗗悎
         List<Approve> otherPassList = new ArrayList<>();//浠栦汉宸插鐞嗙殑璁板綍闆�
-        List<Approve> levelApprove = approveGroupList.stream().filter(i->Constants.equalsInteger(i.getLevel(),level.getLevel())).collect(Collectors.toList());
-        dealGroupListBiz(level,levelApprove,approveGroupList,passList,refuseModel,waitList,otherPassList);
+        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);
@@ -613,35 +857,51 @@
             return list;
         }
         list.addAll(sortByCreateTime(passList));
-        if(Constants.equalsInteger(level.getApproveType(),Constants.ONE)){
+        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(Constants.equalsInteger(waitModel.getStatus(),Constants.approveStatus.wait)){
+                    waitModel.setStatusInfo("寰呭鐞�");
+                }else if(Constants.equalsInteger(waitModel.getStatus(),Constants.approveStatus.auditIng)){
+                    waitModel.setStatusInfo("澶勭悊涓�");
+                }
+
+                waitModel.setMemberName(waitList.size() +"浜轰細绛�");
+//                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);
+                waitModel.setApproveType(Constants.ZERO);
                 if(Constants.equalsInteger(level.getStatus(),Constants.approveStatus.pass)){
-                    waitModel.setStatus(Constants.approveStatus.pass);
-                    waitModel.setTitle("瀹℃壒浜猴紙鎶勯�佹垨绛惧鎵逛汉锛�");
+                    waitModel.setStatus(level.getStatus());
+                    waitModel.setType(Constants.ONE);
+                    waitModel.setCheckDate(level.getCheckDate());
+                    waitModel.setTitle(StringUtils.defaultString(level.getTitle(),"瀹℃壒浜�"));
                 }else{
-                    waitModel.setStatusInfo(passList.size()<=0?StringUtils.defaultString(level.getTitle(),"瀹℃壒浜�"):"鎶勯�佹垨绛惧鎵逛汉");
-                    waitModel.setStatus(passList.size()>0?Constants.ONE:Constants.ZERO);
+                    waitModel.setStatus(level.getStatus());
+                    waitModel.setType(Constants.ZERO);
+                    //waitModel.setStatusInfo(passList.size()<=0?StringUtils.defaultString(level.getTitle(),"瀹℃壒浜�"):"鎶勯�佹垨绛惧鎵逛汉");
+                    waitModel.setTitle(passList.size()<=0?StringUtils.defaultString(level.getTitle(),"瀹℃壒浜�"):"鎶勯�佹垨绛惧鎵逛汉");
+
                 }
                 List<Approve> approveList = new ArrayList<>();
                 approveList.addAll(waitList);
@@ -649,19 +909,21 @@
                 if(passList.size()>0){
                     approveList.addAll(otherPassList);
                 }
-                waitModel.setMemberName("宸叉妱閫�"+ approveList.size() +"浜�");
+                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(waitList.size() +"浜烘垨绛�");
+                    waitModel.setStatusInfo("寰呭鐞�");
+                }else{
+                    waitModel.setMemberName(waitList.size() +"浜烘垨绛�");
+                    waitModel.setStatusInfo("澶勭悊涓�");
+                }
                 waitModel.setApproveList(approveList);
                 list.add(waitModel);
             }
-            //濡傛灉鏄垨绛�
-//            if(otherPassList.size()>0){
-//                Approve waitModel = new Approve();
-//                waitModel.setApproveType(Constants.ONE);
-//                waitModel.setStatusInfo(StringUtils.defaultString(level.getTitle(),"瀹℃壒浜�")+"锛堟妱閫佹垨绛惧鎵逛汉锛�");
-//                waitModel.setStatus(Constants.ONE);
-//                waitModel.setApproveList(otherPassList);
-//                list.add(waitModel);
-//            }
         }
 
 
@@ -669,17 +931,22 @@
 
     }
 
-    private void dealGroupListBiz(Approve level, List<Approve> levelApprove,List<Approve> approveGroupList, List<Approve> passList, Approve refuseModel, List<Approve> waitList, List<Approve> otherPassList) {
+    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())){
-                refuseModel = approve;
+                BeanUtils.copyProperties(approve,refuseModel);
             }
         }
     }
@@ -703,7 +970,8 @@
             if(Constants.equalsInteger(approve.getType(),Constants.ONE)){
                 continue;
             }
-            if(Constants.equalsInteger(approve.getChekorId(),memberId)){
+            if(Constants.equalsInteger(approve.getChekorId(),memberId)
+                    &&Constants.equalsInteger(approve.getStatus(), Constants.ONE)){
                 approveDataVO.setCanBeApproved(Constants.ONE);
                 approveDataVO.setDriverParam(approve.getDriverParam());
             }
@@ -711,11 +979,9 @@
                 approveList.add(approve);
             }
         }
-
         if(CollectionUtils.isEmpty(approveList)){
-            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒淇℃伅锛氱骇鍒暟鎹紓甯�");
+         //   throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒淇℃伅锛氱骇鍒暟鎹紓甯�");
         }
-
         return  approveList;
     }
 
@@ -769,8 +1035,6 @@
                         .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 ) {
@@ -835,6 +1099,23 @@
         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;
+    }
 
 
 
@@ -856,6 +1137,9 @@
                 .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)){
@@ -864,17 +1148,28 @@
         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(approve.getLoginUserInfo().getRealname());
+        approve.setCheckorName(approveDTO.getLoginUserInfo().getRealname());
         approve.setCheckDate(new Date());
-        approve.setStatusInfo(approveDTO.getStatus()==Constants.TWO?"瀹℃壒閫氳繃":approveDTO.getCheckInfo());
-        Visits visits = new Visits();
-        CarUseBook carUseBook = new CarUseBook();
-        this.dealBusinessData(approveDTO,approve,visits,carUseBook);
+        approve.setStatusInfo(approveDTO.getStatus()==Constants.TWO?"宸插悓鎰�":"宸查┏鍥�");
         //鏈骇鎵�鏈� 寰呭鎵硅褰�
         List<Approve> approveList = approveJoinMapper.selectJoinList(Approve.class,
                 new MPJLambdaWrapper<Approve>()
@@ -884,7 +1179,17 @@
                         .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);
@@ -892,180 +1197,460 @@
         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()));
+            //澶勭悊鎵�鏈塏otice閫氱煡涓哄凡澶勭悊
+            //淇敼鑷繁鐨勯�氱煡璁板綍
+            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((approve.getApproveType().equals(Constants.ZERO)
-                    || approve.getApproveType().equals(Constants.TWO)) &&approve.getIsEndCheck()==Constants.ONE){
+            if((Constants.equalsInteger(approve.getApproveType(),Constants.ZERO)
+                    || Constants.equalsInteger( approve.getApproveType(),Constants.TWO)) && Constants.equalsInteger(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())));
+                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){
                 //鎴栫 / 鍗曚汉瀹� 闈炵粓瀹� 鍒欏紑鍚笅涓�姝ヤ笟鍔℃祦绋�
                 /**澶勭悊鏈骇鏁版嵁**/
-                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())));
+                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())));
+                }
                 /**寮�鍚笅涓�绾у埆鐨勬暟鎹负寰呭鏍�**/
+
+                List<Approve> waitAuditList = approveJoinMapper.selectJoinList(Approve.class,
+                        new MPJLambdaWrapper<Approve>()
+                                .selectAll(Approve.class)
+                                .selectAs(Member::getPhone,Approve::getMemberPhone)
+                                .leftJoin(Member.class,Member::getId,Approve::getChekorId)
+                                .eq(Approve::getStatus,Constants.approveStatus.wait)
+                                .eq(Approve::getObjId,approve.getObjId())
+                                .eq(Approve::getObjType,approve.getObjType())
+                                .eq(Approve::getLevel,(approve.getLevel()+1)));
+
                 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))
                 );
-                //TODO 鏇存柊娑堟伅鏁版嵁  鍙戦�佷笅涓�绾ф暟鎹秷鎭�
-            }else if(approve.getApproveType().equals(Constants.ONE)&&approve.getIsEndCheck()==Constants.ONE){
-            //浼氱 涓旂粓瀹�
-                if(approveList.size()==Constants.ZERO){
+                //鍙戦�佺煭淇¢�氱煡  涓嬬骇瀹℃壒浜�
+
+
+                List<String> memberPhone = waitAuditList.stream().filter(i->StringUtils.isNotBlank(i.getMemberPhone())).map(i->i.getMemberPhone()).collect(Collectors.toList());
+                if(approveDTO.getObjType().equals(Constants.approveObjectType.reason)){
+                    SmsEmailServiceImpl.sendPlatformBookSms(systemDictDataBiz,
+                            emayService,smsEmailMapper,smsConfigMapper,platformBooksMapper,approveDTO.getObjId(),
+                            SmsConstants.platformBookContent.platformBookWaitAudit,
+                            approveDTO.getCheckInfo(),memberPhone
+                    );
+                }
+
+
+
+
+                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 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(Notices::getInfo,Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)?"宸查�氳繃":"宸叉嫆缁�")
+                .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);
                 }
             }
         }
-
-        if(approveDTO.getObjType().equals(Constants.approveObjectType.unConstructionVisit)
-                ||approveDTO.getObjType().equals(Constants.approveObjectType.constructionVisit)
-                ||approveDTO.getObjType().equals(Constants.approveObjectType.visitReporting)){
-            // 璁垮 涓夌被涓氬姟鏁版嵁
-            visitsMapper.updateById(visits);
-            if(dealBusinessBean){
-                //TODO 鍙戦�佸鎵归�氳繃娑堟伅
-
-            }else if(approveDTO.getStatus().equals(Constants.THREE)){
-                //TODO 瀹℃壒鏈�氳繃閫氱煡
-
-            }
-        }else if(approveDTO.getObjType().equals(Constants.approveObjectType.cityUseCar)||approveDTO.getObjType().equals(
-                Constants.approveObjectType.unCityUseCar)){
-            // 甯傚唴澶栫敤杞︾敵璇�
-            carUseBookMapper.updateById(carUseBook);
-            if(dealBusinessBean){
-                //TODO 鍙戦�佸鎵归�氳繃娑堟伅
-
-            }else if(approveDTO.getStatus().equals(Constants.THREE)){
-                //TODO 瀹℃壒鏈�氳繃閫氱煡
-
-            }
-        }else if(approveDTO.getObjType().equals(Constants.approveObjectType.logisticsCarUse)){
-            //TODO  鐗╂祦杞﹂绾�
-
-        }
     }
 
-    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)
+
+
+    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(Objects.isNull(notices)){
-            return;
+        if(CollectionUtils.isEmpty(nextApproveList)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒娴佹暟鎹紓甯�");
         }
-
-
-        if(Constants.equalsInteger(approve.getApproveType(),Constants.ZERO)){
-            //鎴栫
-            //1銆佷慨鏀硅嚜宸辩殑鏁版嵁璁板綍
-
-            //2銆佹洿鏂颁粬浜虹殑鍚岀骇璁板綍 涓烘妱閫�
-
-            //3銆佸鏋滀笉鏄粓瀹$敓鎴愪笅涓�绾х殑鏁版嵁璁板綍
-
-
-        }else if(Constants.equalsInteger(approve.getApproveType(),Constants.ONE)){
-            //浼氱
-            //1銆佷慨鏀硅嚜宸辩殑鏁版嵁璁板綍
-
-            //2銆佹牴鎹槸鍚︿负鏈�鍚庝竴浣嶅鎵逛汉   濡傛灉涓嶆槸 鍒欑粨鏉�
-
-            //3銆� 濡傛灉鏄渶鍚庝竴浣嶅鎵逛汉 涓斾笉鏄粓瀹″紑鍚笅涓�绾ф暟鎹�
-
-        }else{
-            //鍗曚汉绛�
-            //1銆佷慨鏀硅嚜宸辩殑鏁版嵁璁板綍
-
-            //2銆� 鏄惁鏄粓瀹� 寮�鍚笅涓�绾ф暟鎹�
-
-
+        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);
         }
-        //涓氬姟閫氳繃 淇敼瀹℃壒瀵瑰簲娑堟伅璁板綍
-        if(Constants.equalsInteger(approve.getStatus(),Constants.approveStatus.pass)){
-
-        }
-        //
-
-        //缁堝涓氬姟 鍙戦�佹妱閫�
-        if (Constants.equalsInteger(approve.getIsEndCheck(),Constants.ONE)) {
-
-
-
-        }
-
-
-
-
-
-
-
+        return memberNames;
     }
 
-    public void dealBusinessData(ApproveDTO approveDTO,Approve approve,Visits visits,CarUseBook carUseBook){
+
+
+    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 = visitsMapper.selectById(approveDTO.getObjId());
+            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());
+            //涓嬪彂璁垮鎶ュ杞﹁締淇℃伅
+            if(Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)&&approveDTO.getObjType().equals(Constants.approveObjectType.visitReporting)){
+                Boolean sendStatus = true;
+                //鏌ヨ褰撳墠鍚敤鐨勫仠杞﹀満
+                List<Parks> parksList = parksMapper.selectList(new QueryWrapper<Parks>()
+                        .lambda()
+                        .isNotNull(Parks::getHkId)
+                        .eq(Parks::getIsdeleted,Constants.ZERO));
+                List<VisitPark> parkBookList = new ArrayList<>();
+                if(CollectionUtils.isNotEmpty(parksList)){
+                    for (Parks parks:parksList) {
+                        VisitPark visitPark = new VisitPark();
+                        visitPark.setIsdeleted(Constants.ZERO);
+                        visitPark.setCreateDate(new Date());
+                        visitPark.setVisitApplyId(visits.getId().toString());
+                        visitPark.setCarCode(visits.getCarNos());
+                        visitPark.setParkId(parks.getId().toString());
+                        visitPark.setStartTime(visits.getStarttime());
+                        visitPark.setEndTime(visits.getEndtime());
+                        visitPark.setParkHkId(parks.getHkId());
+                        visitPark.setObjType(Constants.ZERO);
 
+                        ParkReservationAddRequest request = new ParkReservationAddRequest();
+                        request.setPlateNo(visitPark.getCarCode());
+                        request.setParkSyscode(visitPark.getParkHkId());
+                        request.setPhoneNo(visits.getPhone());
+                        request.setOwner(visits.getName());
+                        request.setAllowTimes(Constants.ONE+"");
+                        request.setIsCharge(Constants.ONE+"");
+                        request.setStartTime(Objects.isNull(visitPark.getStartTime())?DateUtil.getISO8601Timestamp2(new Date()):DateUtil.getISO8601Timestamp2(visitPark.getStartTime()));
+                        request.setEndTime(Objects.isNull(visitPark.getEndTime())?"2999-12-31T00:00:00+08:00":DateUtil.getISO8601Timestamp2(visitPark.getEndTime()));
+                        BaseResponse response =  HKService.parkReservationAddition(request);
 
+                        visitPark.setHkDate(new Date());
+                        if(response!=null
+                                && StringUtils.equals(response.getCode(), HKConstants.RESPONSE_SUCCEE)){
+                            ParkReservationAddResponse parkReservationAddResponse = (ParkReservationAddResponse) response.getData();
+                            visitPark.setHkId(parkReservationAddResponse.getReserveOrderNo());
+                            visitPark.setHkStatus(Constants.ONE);
+                            visitPark.setRemark("鍖呮湡鎴愬姛");
+                        }else{
+                            visitPark.setHkStatus(Constants.TWO);
+                            visitPark.setRemark("鍖呮湡澶辫触~");
+                            //涓嬪彂澶辫触  鏍囪涓讳笟鍔$姸鎬佷负涓嬪彂澶辫触
+                            sendStatus = false;
+                        }
+                        parkBookList.add(visitPark);
+
+                    }
+                    visitParkMapper.insert(parkBookList);
+                }
+                if(sendStatus){
+                    visits.setStatus(Constants.VisitStatus.xfSuccess);
+                }else{
+                    visits.setStatus(Constants.VisitStatus.xfFail);
+                }
+            }
+
+            visitsMapper.updateById(visits);
         }else if(approveDTO.getObjType().equals(Constants.approveObjectType.cityUseCar)||approveDTO.getObjType().equals(
                 Constants.approveObjectType.unCityUseCar)){
-            // 甯傚唴澶栫敤杞︾敵璇�
-            carUseBook = carUseBookMapper.selectById(approveDTO.getObjId());
-            if(Objects.isNull(carUseBook)){
-                throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌鐢ㄨ溅璁板綍");
+            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(),"鏈煡璇㈠埌鐗╂祦杞﹂绾﹁褰�");
             }
-            carUseBook.setStatus(approveDTO.getStatus());
-            carUseBook.setEditDate(new Date());
-            carUseBook.setEditor(approveDTO.getLoginUserInfo().getMemberId());
-            //濡傛灉閰嶇疆淇敼鍙告満 涓� 鍏ュ弬浜嗘洿鎹㈠悗鍙告満淇℃伅
-            if(approveDTO.getStatus()==Constants.TWO&&approve.getDriverParam().equals(Constants.ONE)){
-                CarDriver carDriver = carDriverMapper.selectById(approveDTO.getDriverId());
-                if(Objects.isNull(carDriver)){
-                    throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌鍙告満淇℃伅");
+            platformBooks.setStatus(approveDTO.getStatus());
+            platformBooks.setEditDate(new Date());
+            platformBooks.setEditor(approveDTO.getLoginUserInfo().getMemberId());
+            platformBooksMapper.updateById(platformBooks);
+            if(Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)){
+                PlatformReason platformReason = platformReasonMapper.selectById(platformBooks.getReasonId());
+                if(Objects.isNull(platformReason)){
+                    throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍏ュ洯鍘熷洜鏁版嵁");
                 }
-                carUseBook.setDriverId(carDriver.getId());
-            }
+                PlatformGroup platformGroup = platformGroupMapper.selectById(platformReason.getGroupId());
+                if(Objects.isNull(platformGroup)){
+                    throw new BusinessException(ResponseStatus.DATA_EMPTY.getCode(),"鏈煡璇㈠埌鍏ュ洯鍘熷洜閰嶇疆鏈堝彴缁勬暟鎹�");
+                }
 
-        }else if(approveDTO.getObjType().equals(Constants.approveObjectType.logisticsCarUse)){
-            //TODO  鐗╂祦杞﹂绾�
+                //鐢熸垚浠诲姟璁板綍
+                PlatformJob platformJob = platformBooks.toPlatformJob();
+                platformJob.setId(null);
+                platformJob.setPlatformGroupId(platformReason.getGroupId().intValue());
+                if(Constants.equalsInteger(platformGroup.getType(),Constants.ZERO)){
+                    platformJob.setType(Constants.platformJobType.wxcxh);
+                }else if(Constants.equalsInteger(platformGroup.getType(),Constants.ONE)){
+                    platformJob.setType(Constants.platformJobType.wxczh);
+                }else{
+                    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);
+            }
+            //鍙戦�佺煭淇¢�氱煡
+            SmsEmailServiceImpl.sendPlatformBookSms(systemDictDataBiz,
+                    emayService,smsEmailMapper,smsConfigMapper,platformBooksMapper,platformBooks.getId(),
+                    Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)?SmsConstants.platformBookContent.platformBookAuditSuccess:
+                            SmsConstants.platformBookContent.platformBookAuditFail,
+                    approveDTO.getCheckInfo(),null
+            );
+
+            //TODO 鍙戦�佸井淇″叕浼楀彿娑堟伅
 
         }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);
     }
 
 

--
Gitblit v1.9.3