From c5dfc09145e4e10f99dbf388a4a1433b5c2973e5 Mon Sep 17 00:00:00 2001
From: BAOLH <baolh@yhzhg.cn>
Date: Tue, 10 Nov 2026 01:40:38 +0000
Subject: [PATCH] 适应高版本Nodejs对应修改(二)

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java |  129 ++++++++++++++++++++-----------------------
 1 files changed, 60 insertions(+), 69 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java
index fc054f4..c938638 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java
@@ -1,31 +1,28 @@
 /*
-*  Copyright 2019-2020 Zheng Jie
-*
-*  Licensed under the Apache License, Version 2.0 (the "License");
-*  you may not use this file except in compliance with the License.
-*  You may obtain a copy of the License at
-*
-*  http://www.apache.org/licenses/LICENSE-2.0
-*
-*  Unless required by applicable law or agreed to in writing, software
-*  distributed under the License is distributed on an "AS IS" BASIS,
-*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-*  See the License for the specific language governing permissions and
-*  limitations under the License.
-*/
+ *  Copyright 2019-2020 Zheng Jie
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
 package me.zhengjie.modules.system.service.impl;
 
-import me.zhengjie.modules.business.service.BusinessPlanService;
-import me.zhengjie.modules.business.service.dto.BusinessPlanDto;
 import me.zhengjie.modules.constant.Constant;
-import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
+import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
 import me.zhengjie.modules.system.domain.CustomerResources;
 import me.zhengjie.modules.system.domain.CustomerResourcesUser;
 import me.zhengjie.modules.system.domain.User;
 import me.zhengjie.modules.system.repository.CustomerResourcesUserRepository;
 import me.zhengjie.modules.system.repository.UserRepository;
-import me.zhengjie.utils.ValidationUtil;
-import me.zhengjie.utils.FileUtil;
+import me.zhengjie.utils.*;
 import lombok.RequiredArgsConstructor;
 import me.zhengjie.modules.system.repository.CustomerResourcesRepository;
 import me.zhengjie.modules.system.service.CustomerResourcesService;
@@ -37,8 +34,6 @@
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.data.domain.Page;
 import org.springframework.data.domain.Pageable;
-import me.zhengjie.utils.PageUtil;
-import me.zhengjie.utils.QueryHelp;
 
 import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
@@ -48,11 +43,11 @@
 import javax.servlet.http.HttpServletResponse;
 
 /**
-* @website https://eladmin.vip
-* @description 服务实现
-* @author wcd
-* @date 2023-02-02
-**/
+ * @author wcd
+ * @website https://eladmin.vip
+ * @description 服务实现
+ * @date 2023-02-02
+ **/
 @Service
 @Transactional
 @RequiredArgsConstructor
@@ -61,23 +56,18 @@
     private final CustomerResourcesRepository customerResourcesRepository;
     private final CustomerResourcesMapper customerResourcesMapper;
     private final UserRepository userRepository;
-    private final OpaiDingTalkService opaiDingTalkService;
+    private final WeComServiceImpl weComService;
     private final CustomerResourcesUserRepository customerResourcesUserRepository;
-    private final BusinessPlanService businessPlanService;
 
     @Override
-    public Map<String,Object> queryAll(CustomerResourcesQueryCriteria criteria, Pageable pageable){
-        Page<CustomerResources> page = customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+    public Map<String, Object> queryAll(CustomerResourcesQueryCriteria criteria, Pageable pageable) {
+        Page<CustomerResources> page = customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
         // 将实体类转换为DTO(重写)
-        Function<CustomerResources, CustomerResourcesDto> func = new Function<CustomerResources, CustomerResourcesDto>(){
+        Function<CustomerResources, CustomerResourcesDto> func = new Function<CustomerResources, CustomerResourcesDto>() {
             @Override
             public CustomerResourcesDto apply(CustomerResources t) {
                 // 将实体类转换成DTO
                 CustomerResourcesDto customerResourcesDto = customerResourcesMapper.toDto(t);
-
-                // 获取营业计划
-                BusinessPlanDto businessPlanDto = businessPlanService.findById(customerResourcesDto.getBusinessPlanId());
-                customerResourcesDto.setBusinessPlanContent(businessPlanDto.getBusinessContent());
 
                 // 返回处理好的DTO
                 return customerResourcesDto;
@@ -87,15 +77,15 @@
     }
 
     @Override
-    public List<CustomerResourcesDto> queryAll(CustomerResourcesQueryCriteria criteria){
-        return customerResourcesMapper.toDto(customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+    public List<CustomerResourcesDto> queryAll(CustomerResourcesQueryCriteria criteria) {
+        return customerResourcesMapper.toDto(customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
     }
 
     @Override
     @Transactional
     public CustomerResourcesDto findById(Long id) {
         CustomerResources customerResources = customerResourcesRepository.findById(id).orElseGet(CustomerResources::new);
-        ValidationUtil.isNull(customerResources.getId(),"CustomerResources","id",id);
+        ValidationUtil.isNull(customerResources.getId(), "CustomerResources", "id", id);
         return customerResourcesMapper.toDto(customerResources);
     }
 
@@ -103,15 +93,15 @@
     @Transactional(rollbackFor = Exception.class)
     public void create(CustomerResources resources) throws Exception {
         // 提醒时间为空,状态为提醒说明是立即提醒,发送钉钉消息
-        if(ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)){
-            // 调用
-            resources = setDingding(resources);
+        if (ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)) {
+            // 发送通知
+            resources = sendNotice(resources);
         }
         // 保存
         customerResourcesRepository.save(resources);
         // 中间表添加数据
-        if(resources.getRemindPeople().size() != 0){
-            for(int i = 0; i < resources.getRemindPeople().size(); i++){
+        if (resources.getRemindPeople().size() != 0) {
+            for (int i = 0; i < resources.getRemindPeople().size(); i++) {
                 // 中间表添加数据
                 CustomerResourcesUser customerResourcesUser = new CustomerResourcesUser();
                 customerResourcesUser.setCustomerResourcesId(resources.getId());
@@ -125,24 +115,24 @@
     @Transactional(rollbackFor = Exception.class)
     public void update(CustomerResources resources) throws Exception {
         CustomerResources customerResources = customerResourcesRepository.findById(resources.getId()).orElseGet(CustomerResources::new);
-        ValidationUtil.isNull( customerResources.getId(),"CustomerResources","id",resources.getId());
+        ValidationUtil.isNull(customerResources.getId(), "CustomerResources", "id", resources.getId());
         customerResources.copy(resources);
         // 提醒时间为空,状态为提醒说明是立即提醒,发送钉钉消息
-        if(ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)){
-            // 调用
-            customerResources = setDingding(customerResources);
-        }else if(resources.getRemind().equals(Constant.RESOURCES_TYPE_NOREMIND)){
+        if (ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)) {
+            // 发送通知
+            customerResources = sendNotice(customerResources);
+        } else if (resources.getRemind().equals(Constant.RESOURCES_TYPE_NOREMIND)) {
             customerResources.setOpeningTime(null);
         }
         customerResourcesRepository.save(customerResources);
         // 删除中间表数据
         List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(customerResources.getId());
-        for(int i = 0; i < customerResourcesUserList.size(); i++){
+        for (int i = 0; i < customerResourcesUserList.size(); i++) {
             customerResourcesUserRepository.deleteByCustomerResourcesId(customerResourcesUserList.get(i).getCustomerResourcesId());
         }
         // 中间表添加数据
-        if(resources.getRemindPeople().size() != 0){
-            for(int i = 0; i < resources.getRemindPeople().size(); i++){
+        if (resources.getRemindPeople().size() != 0) {
+            for (int i = 0; i < resources.getRemindPeople().size(); i++) {
                 // 中间表添加数据
                 CustomerResourcesUser customerResourcesUser = new CustomerResourcesUser();
                 customerResourcesUser.setCustomerResourcesId(resources.getId());
@@ -153,32 +143,32 @@
     }
 
     /**
-     * 发送钉钉(公共)
+     * 向其他应用发送通知公共方法
+     *
      * @param resources
-     * @return
-     * @throws Exception
      */
-    public CustomerResources setDingding(CustomerResources resources) throws Exception {
+    public CustomerResources sendNotice(CustomerResources resources) {
         // 获取当前时间
         SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         String time = sf.format(new Date());
         resources.setOpeningTime(Timestamp.valueOf(time));
-        // 获取存储用户钉钉号
-        List<String> dingDingList = new ArrayList<>();
-        if(resources.getRemindPeople().size() != 0){
-            for(Long userId : resources.getRemindPeople()){
+        // 获取存储用户企微ID
+        List<String> weComList = new ArrayList<>();
+        if (resources.getRemindPeople().size() != 0) {
+            for (Long userId : resources.getRemindPeople()) {
                 // 查询用户
                 User user = userRepository.findById(userId).orElseGet(User::new);
-                if(ObjectUtils.isNotEmpty(user.getDingding())){
-                    dingDingList.add(user.getDingding());
+                if (StringUtils.isNotBlank(user.getWeComId())) {
+                    weComList.add(user.getWeComId());
                 }
             }
         }
-        // 发送内容至钉钉
-        opaiDingTalkService.sendNotice(dingDingList, "客户资源管理提示", "### 客户资源管理提示  \n  >" +
-                "  \n  标题:"   + resources.getTitle() +
-                "  \n  分类: " + resources.getClassification() +
-                "  \n  客户资源有变动,请登录PMS系统查看。", "card");
+        // 发送内容至企微
+        weComService.sendNotice(weComList, "客户资源管理提示", String.format("<div class=\"normal\">标题:%s</div>" +
+                        "<div class=\"normal\">分类:%s</div>" +
+                        "<div class=\"highlight\">客户资源有变动,请登录PMS系统查看。</div>",
+                resources.getTitle(),
+                resources.getClassification()), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
         return resources;
     }
 
@@ -187,7 +177,7 @@
         for (Long id : ids) {
             // 查询中间表
             List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(id);
-            for(int i = 0; i < customerResourcesUserList.size(); i++){
+            for (int i = 0; i < customerResourcesUserList.size(); i++) {
                 customerResourcesUserRepository.deleteByCustomerResourcesId(customerResourcesUserList.get(i).getCustomerResourcesId());
             }
             customerResourcesRepository.deleteById(id);
@@ -198,7 +188,7 @@
     public void download(List<CustomerResourcesDto> all, HttpServletResponse response) throws IOException {
         List<Map<String, Object>> list = new ArrayList<>();
         for (CustomerResourcesDto customerResources : all) {
-            Map<String,Object> map = new LinkedHashMap<>();
+            Map<String, Object> map = new LinkedHashMap<>();
             map.put("标题", customerResources.getTitle());
             map.put("分类", customerResources.getClassification());
             map.put("记录时间", customerResources.getRecordTime());
@@ -216,6 +206,7 @@
 
     /**
      * 查询被提醒人
+     *
      * @param resources
      * @return
      */
@@ -225,7 +216,7 @@
         List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(resources.getId());
         // 用户信息
         List<User> userList = new ArrayList<>();
-        for(int i = 0; i < customerResourcesUserList.size(); i++){
+        for (int i = 0; i < customerResourcesUserList.size(); i++) {
             // 查询用户表
             User user = userRepository.findById(customerResourcesUserList.get(i).getUserId()).orElseGet(User::new);
             userList.add(user);

--
Gitblit v1.9.3