From 36f9ad308e0fc808c07ba3e859292ee420183d0b Mon Sep 17 00:00:00 2001
From: k94314517 <8417338+k94314517@user.noreply.gitee.com>
Date: 星期二, 10 十二月 2024 18:22:08 +0800
Subject: [PATCH] 代码初始化

---
 server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/ApproveServiceImpl.java |  123 +++++++++++++++++++++++++++++++++-------
 1 files changed, 100 insertions(+), 23 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 7d1f53c..eea3e40 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
@@ -15,8 +15,12 @@
 import com.doumee.core.utils.DateUtil;
 import com.doumee.core.utils.SmsConstants;
 import com.doumee.core.utils.Utils;
+import com.doumee.core.wx.wxPlat.WxPlatConstants;
+import com.doumee.core.wx.wxPlat.WxPlatNotice;
 import com.doumee.dao.business.*;
 import com.doumee.dao.business.dao.CompanyMapper;
+import com.doumee.dao.business.dao.SmsConfigMapper;
+import com.doumee.dao.business.dao.SmsEmailMapper;
 import com.doumee.dao.business.dto.ApproveDTO;
 import com.doumee.dao.business.join.ApproveJoinMapper;
 import com.doumee.dao.business.join.CarUseBookJoinMapper;
@@ -40,7 +44,6 @@
 import org.apache.commons.lang3.StringUtils;
 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;
 
@@ -64,6 +67,8 @@
 
     @Autowired
     private SystemDictDataBiz systemDictDataBiz;
+    @Autowired
+    private WxNoticeConfigMapper wxNoticeConfigMapper;
 
     @Autowired
     private ApproveTemplMapper approveTemplMapper;
@@ -103,44 +108,32 @@
     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
     public Integer create(Approve approve) {
         approveMapper.insert(approve);
         return approve.getId();
     }
-
     @Override
     public void deleteById(Integer id) {
         approveMapper.deleteById(id);
     }
-
     @Override
     public void delete(Approve approve) {
         UpdateWrapper<Approve> deleteWrapper = new UpdateWrapper<>(approve);
         approveMapper.delete(deleteWrapper);
     }
-
     @Override
     public void deleteByIdInBatch(List<Integer> ids) {
         if (CollectionUtils.isEmpty(ids)) {
@@ -285,14 +278,16 @@
             if(CollectionUtils.isNotEmpty(noticesList)){
                 //寰呮垜澶勭悊鐨勬暟鎹�
                 internalHomeVO.setNoticeWaitNum(
-                        noticesList.stream().filter(i->Constants.equalsInteger(i.getUserId(),memberId)
+                        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)
+                        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)
@@ -303,9 +298,10 @@
                         noticesJoinMapper.selectCount(new QueryWrapper<Notices>().lambda().eq(Notices::getParam3,memberId))
                 );
                 //鎶勯�佹垜鐨勬暟鎹�
-                internalHomeVO.setNoticeCopyNum(
+                 internalHomeVO.setNoticeCopyNum(
                         noticesList.stream().filter(i->Constants.equalsInteger(i.getUserId(),memberId)
                                 &&Constants.equalsInteger(i.getSendacopy(),Constants.ONE)
+                                &&Constants.equalsInteger(i.getReaded(),Constants.ZERO)
                         ).count()
                 );
             }
@@ -492,12 +488,18 @@
         approveList.add(createUserApprove);
 
         //鏌ヨ鎵�鏈夊緟澶勭悊浜�
-
+        String token = systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode();
         //瀹℃壒涓氬姟鏁版嵁
         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<Member> memberList = memberMapper.selectJoinList(Member.class,
+                    new MPJLambdaWrapper<Member>()
+                            .selectAll(Member.class)
+                            .selectAs(SystemUser::getOpenid,Member::getSystemOpenid)
+                            .leftJoin(SystemUser.class,SystemUser::getMemberId,Member::getId)
+                            .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());
@@ -563,7 +565,7 @@
                 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);
@@ -575,6 +577,7 @@
                 approve.setType(Constants.ZERO);
                 approveList.add(approve);
 
+                WxPlatNotice wxPlatNotice = new WxPlatNotice();
                 if(Constants.equalsInteger(approve.getStatus(),Constants.ONE) && StringUtils.isNotBlank(member.getPhone())){
                     //鍙戦�佺煭淇¢�氱煡
                     if(Constants.equalsInteger(noticeType,Constants.noticesObjectType.reason)){
@@ -584,13 +587,32 @@
                                 SmsConstants.platformBookContent.platformBookWaitAudit,
                                 null,Arrays.asList(member.getPhone().split(","))
                         );
+                        //鍏紬鍙烽�氱煡
+                        if(StringUtils.isNotBlank(member.getOpenid())){
+                            wxPlatNotice.sendPlatformBookTemplateNotice(
+                                    wxNoticeConfigMapper,
+                                    platformBooksMapper.selectById(businessId),
+                                    WxPlatConstants.platformBookContent.platformBookWaitAudit,
+                                    token,
+                                    Arrays.asList(member.getOpenid().split(",")),
+                                    Constants.ONE);
+                        }
                     }else if(Constants.equalsInteger(noticeType,Constants.noticesObjectType.visit)){
                         //璁垮鐢宠
+                        //鐭俊閫氱煡
                         SmsEmailServiceImpl.sendVisitSms(systemDictDataBiz,
                                 emayService,smsEmailMapper,smsConfigMapper,visitsMapper,businessId,
                                 SmsConstants.visitContent.visitNotice,
                                 null,Arrays.asList(member.getPhone().split(","))
                         );
+                        //鍏紬鍙烽�氱煡
+                        if(StringUtils.isNotBlank(member.getSystemOpenid())){
+                            wxPlatNotice.sendVisitTemplateNotice(
+                                    wxNoticeConfigMapper,visitsMapper.selectById(businessId), WxPlatConstants.visitContent.visitWaitAudit,
+                                    token,
+                                    Arrays.asList(member.getSystemOpenid().split(","))
+                            );
+                        }
                     }else if(Constants.equalsInteger(noticeType,Constants.noticesObjectType.visitReporting)){
                         //璁垮鎶ュ
                         SmsEmailServiceImpl.sendVisitReportSms(systemDictDataBiz,
@@ -598,6 +620,14 @@
                                 SmsConstants.visitReportingContent.visitReportingNotice,
                                 null,Arrays.asList(member.getPhone().split(","))
                         );
+                        //鍏紬鍙烽�氱煡
+                        if(StringUtils.isNotBlank(member.getSystemOpenid())){
+                            wxPlatNotice.sendVisitTemplateNotice(
+                                    wxNoticeConfigMapper,visitsMapper.selectById(businessId), WxPlatConstants.visitReportContent.visitReportWaitAudit,
+                                    token,
+                                    Arrays.asList(member.getSystemOpenid().split(","))
+                            );
+                        }
                     }else if(Constants.equalsInteger(noticeType,Constants.noticesObjectType.useCar)){
                         //鐢ㄨ溅鐢宠
                         SmsEmailServiceImpl.sendCarUseSms(systemDictDataBiz,
@@ -605,6 +635,16 @@
                                 SmsConstants.carUseBookContent.carUseBookWaitAudit,
                                 null,Arrays.asList(member.getPhone().split(","))
                         );
+                        //鍏紬鍙烽�氱煡
+                        if(StringUtils.isNotBlank(member.getSystemOpenid())){
+                            wxPlatNotice.sendCarUseBookTemplateNotice(
+                                    wxNoticeConfigMapper,
+                                    carUseBookMapper.selectById(businessId),
+                                    WxPlatConstants.carUseBookContent.carUseBookWaitAudit,
+                                    token,
+                                    Arrays.asList(member.getSystemOpenid().split(",")),
+                                    Constants.ONE);
+                        }
                     }
                 }
 
@@ -788,6 +828,9 @@
      * @param objLevel  鏌ヨ绾у埆
      */
     public Company getAuditCompanyHead(Integer companyId, Integer objLevel){
+        if(Objects.isNull(objLevel)||Objects.isNull(companyId)){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"瀹℃壒娴侀厤缃紓甯革紝璇疯仈绯荤鐞嗗憳");
+        }
         Company auditCompany =  companyMapper.selectById(companyId);
         Integer queryLevel = Constants.ONE;
         while(queryLevel<objLevel){
@@ -921,7 +964,6 @@
                 }else{
                     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(),"瀹℃壒浜�"):"鎶勯�佹垨绛惧鎵逛汉");
 
                 }
@@ -1508,6 +1550,7 @@
 
 
     public void dealBusinessData(ApproveDTO approveDTO,Approve approve){
+        WxPlatNotice wxPlatNotice = new WxPlatNotice();
         if(approveDTO.getObjType().equals(Constants.approveObjectType.unConstructionVisit)
                 ||approveDTO.getObjType().equals(Constants.approveObjectType.constructionVisit)
                 ||approveDTO.getObjType().equals(Constants.approveObjectType.visitReporting)){
@@ -1577,6 +1620,7 @@
                 }
             }
             //璁垮鎶ュ
+            String objCode = "";
             if(approveDTO.getObjType().equals(Constants.approveObjectType.visitReporting)){
                 //鍙戦�佺煭淇¢�氱煡
                 SmsEmailServiceImpl.sendVisitReportSms(systemDictDataBiz,
@@ -1585,6 +1629,9 @@
                                 SmsConstants.visitReportingContent.visitReportingAuditFail,
                         approveDTO.getCheckInfo(),null
                 );
+                objCode =  Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)?
+                        WxPlatConstants.visitReportContent.visitReportAuditSuccess:WxPlatConstants.visitReportContent.visitReportAuditFail;
+
             }else{ //璁垮鐢宠
                 //鍙戦�佺煭淇¢�氱煡
                 SmsEmailServiceImpl.sendVisitSms(systemDictDataBiz,
@@ -1593,15 +1640,28 @@
                                 SmsConstants.visitContent.visitAuditFail,
                         approveDTO.getCheckInfo(),null
                 );
+                objCode =  Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)? WxPlatConstants.visitContent.visitAuditSuccess:
+                        WxPlatConstants.visitContent.visitAuditFail;
+            }
+            visitsMapper.updateById(visits);
+            //鍙戦�佸井淇″叕浼楀彿
+            if(StringUtils.isNotBlank(objCode)){
+                if(Objects.nonNull(visits) && StringUtils.isNotBlank(visits.getOpenid())){
+                    wxPlatNotice.sendVisitTemplateNotice(
+                            wxNoticeConfigMapper,visits, objCode,
+                            systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
+                            Arrays.asList(visits.getOpenid().split(","))
+                    );
+                }
             }
 
-            visitsMapper.updateById(visits);
         }else if(approveDTO.getObjType().equals(Constants.approveObjectType.cityUseCar)||approveDTO.getObjType().equals(
                 Constants.approveObjectType.unCityUseCar)){
             this.updDriver(approveDTO,approve,true);
             CarUseBook carUseBook = carUseBookJoinMapper.selectById(approveDTO.getObjId());
             if(Objects.nonNull(carUseBook)){
                 Member member = memberMapper.selectById(carUseBook.getMemberId());
+                //鍙戦�侀�氱煡鐭伅
                 if(Objects.nonNull(member)&&StringUtils.isNotBlank(member.getPhone())){
                     SmsEmailServiceImpl.sendCarUseSms(systemDictDataBiz,
                             emayService,smsEmailMapper,smsConfigMapper,carUseBookMapper,approveDTO.getObjId(),
@@ -1609,6 +1669,14 @@
                                     SmsConstants.carUseBookContent.carUseBookAuditFail,
                             approveDTO.getCheckInfo(),Arrays.asList(member.getPhone().split(","))
                     );
+                }
+                if(StringUtils.isNotBlank(member.getOpenid())){
+                    //鍙戦�佸井淇″叕浼楀彿閫氱煡
+                    wxPlatNotice.sendCarUseBookTemplateNotice(
+                            wxNoticeConfigMapper,carUseBook,
+                            Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)?WxPlatConstants.carUseBookContent.carUseBookAuditSuccess: WxPlatConstants.carUseBookContent.carUseBookAuditFail,
+                            systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
+                            Arrays.asList(member.getOpenid().split(",")),0);
                 }
             }
 
@@ -1667,7 +1735,16 @@
                     approveDTO.getCheckInfo(),null
             );
 
-            //TODO 鍙戦�佸井淇″叕浼楀彿娑堟伅
+            //鍙戦�佸井淇″叕浼楀彿娑堟伅
+            Member member = memberMapper.selectById(platformBooks.getDriverId() );
+            if(Objects.nonNull(member) && StringUtils.isNotBlank(member.getOpenid())){
+                //鍙戦�佸井淇″叕浼楀彿閫氱煡
+                wxPlatNotice.sendPlatformBookTemplateNotice(
+                        wxNoticeConfigMapper,platformBooks,
+                        Constants.equalsInteger(approveDTO.getStatus(),Constants.TWO)?WxPlatConstants.platformBookContent.platformBookAuditSuccess: WxPlatConstants.platformBookContent.platformBookAuditFail,
+                        systemDictDataBiz.queryByCode(Constants.WX_PLATFORM,Constants.WX_PLATFORM_ACCESS_TOKEN).getCode(),
+                        Arrays.asList(member.getOpenid().split(",")),0);
+            }
 
         }else{
             throw new BusinessException(ResponseStatus.BAD_REQUEST);
@@ -1703,7 +1780,7 @@
         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::getStatus,Constants.ZERO)
                     .eq(CarDriver::getMemberId,approveDTO.getDriverId()));
             if(Objects.isNull(carDriver)){
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鏈煡璇㈠埌鍙告満淇℃伅");

--
Gitblit v1.9.3