xw 1 天之前
父節點
當前提交
bbc598cec0

+ 0 - 4
fs-admin/src/main/java/com/fs/qw/controller/QwSopController.java

@@ -153,10 +153,6 @@ public class QwSopController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody QwSop qwSop)
     {
-        String validateMsg = qwSopService.validateBeforeSave(qwSop);
-        if (validateMsg != null) {
-            return AjaxResult.error(validateMsg);
-        }
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());

+ 10 - 1
fs-admin/src/main/java/com/fs/qw/controller/QwUserController.java

@@ -14,6 +14,7 @@ import com.fs.common.enums.BusinessType;
 import com.fs.common.exception.ServiceException;
 import com.fs.common.exception.user.UserPasswordNotMatchException;
 import com.fs.common.utils.MessageUtils;
+import com.fs.common.utils.StringUtils;
 import com.fs.common.utils.poi.ExcelUtil;
 import com.fs.company.domain.CompanyUser;
 import com.fs.company.mapper.CompanyUserMapper;
@@ -23,6 +24,7 @@ import com.fs.fastGpt.domain.FastGptRole;
 import com.fs.fastGpt.mapper.FastGptRoleMapper;
 import com.fs.framework.manager.AsyncManager;
 import com.fs.framework.manager.factory.AsyncFactory;
+import com.fs.qw.domain.QwCompany;
 import com.fs.qw.domain.QwExternalContact;
 import com.fs.qw.domain.QwUser;
 import com.fs.qw.mapper.QwCompanyMapper;
@@ -488,7 +490,6 @@ public class QwUserController extends BaseController {
     @GetMapping("/list")
     public TableDataInfo list(QwUserListParam qwUser)
     {
-        startPage();
         qwUser.setCompanyId(qwUser.getCompanyId());
         if (ObjectUtil.isNotEmpty(qwUser.getIsRemark())&&qwUser.getIsRemark().equals("1")){
             qwUser.setCompanyUserId(getLoginUser().getUser().getUserId());
@@ -497,6 +498,14 @@ public class QwUserController extends BaseController {
             qwUser.setCorpId(null);
         }
 
+        if (StringUtils.isNotEmpty(qwUser.getCorpId())) {
+            QwCompany qwCompany = qwCompanyMapper.selectQwCompanyByCorpId(qwUser.getCorpId());
+            if (qwCompany != null) {
+                qwUser.setAllowOfficial(qwCompany.getAllowOfficial());
+            }
+        }
+
+        startPage();
         List<QwUserVO> list = qwUserService.selectQwUserListVO(qwUser);
         return getDataTable(list);
     }

+ 0 - 4
fs-company/src/main/java/com/fs/company/controller/qw/QwSopController.java

@@ -247,10 +247,6 @@ public class QwSopController extends BaseController
     @PostMapping
     public AjaxResult add(@RequestBody QwSop qwSop)
     {
-        String validateMsg = qwSopService.validateBeforeSave(qwSop);
-        if (validateMsg != null) {
-            return AjaxResult.error(validateMsg);
-        }
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());

+ 9 - 1
fs-company/src/main/java/com/fs/company/controller/qw/QwUserController.java

@@ -26,6 +26,7 @@ import com.fs.framework.manager.AsyncManager;
 import com.fs.framework.manager.factory.AsyncFactory;
 import com.fs.framework.security.LoginUser;
 import com.fs.framework.service.TokenService;
+import com.fs.qw.domain.QwCompany;
 import com.fs.qw.domain.QwExternalContact;
 import com.fs.qw.domain.QwUser;
 import com.fs.qw.mapper.QwCompanyMapper;
@@ -484,7 +485,6 @@ public class QwUserController extends BaseController
     @GetMapping("/list")
     public TableDataInfo list(QwUserListParam qwUser)
     {
-        startPage();
         LoginUser loginUser = tokenService.getLoginUser(ServletUtils.getRequest());
         qwUser.setCompanyId(loginUser.getCompany().getCompanyId());
         if (ObjectUtil.isNotEmpty(qwUser.getIsRemark())&&qwUser.getIsRemark().equals("1")){
@@ -494,6 +494,14 @@ public class QwUserController extends BaseController
             qwUser.setCorpId(null);
         }
 
+        if (!StringUtil.strIsNullOrEmpty(qwUser.getCorpId())) {
+            QwCompany qwCompany = qwCompanyMapper.selectQwCompanyByCorpId(qwUser.getCorpId());
+            if (qwCompany != null) {
+                qwUser.setAllowOfficial(qwCompany.getAllowOfficial());
+            }
+        }
+
+        startPage();
         List<QwUserVO> list = qwUserService.selectQwUserListVO(qwUser);
         return getDataTable(list);
     }

+ 2 - 3
fs-qw-task/src/main/java/com/fs/app/taskService/impl/SopLogsTaskServiceImpl.java

@@ -792,10 +792,9 @@ public class SopLogsTaskServiceImpl implements SopLogsTaskService {
         Long courseId = content.getCourseId();
         Long videoId = content.getVideoId();
         Long liveId = content.getLiveId();
-        // 「可选ipad」官方群发模式:当 SOP 未绑定企微员工(qw_sop.qw_user_ids 为空)时,
-        // 强制本条规则走 isOfficial=1 官方群发,由 corpId + 官方接口承担发送,无需员工 iPad
         if (logVo != null && StringUtils.isEmpty(logVo.getQwUserIds())) {
-            content.setIsOfficial("1");
+            log.warn("SOP {} 未配置使用员工(qw_user_ids),跳过本条待发送记录生成", logVo.getSopId());
+            return;
         }
         Integer isOfficial = content.getIsOfficial() != null ? Integer.valueOf(content.getIsOfficial()) : 0;
 

+ 1 - 2
fs-service/src/main/java/com/fs/qw/mapper/QwUserMapper.java

@@ -220,7 +220,7 @@ public interface QwUserMapper extends BaseMapper<QwUser>
             "            <if test=\"deptId != null \"> and qd.dept_id = #{deptId}</if>\n" +
             "            <if test=\"deptName != null \"> and qd.dept_name like concat('%', #{deptName}, '%') </if>\n" +
             "            <if test=\"status != null \"> and qu.status = #{status}</if>\n" +
-            "            <if test=\"type != null and sendType !=null and type==2 and (sendType==2 or sendType==4 or sendType==11) \"> and qu.app_key IS NOT NULL  </if>\n" +
+            "            <if test=\"type != null and sendType !=null and type==2 and (sendType==2 or sendType==4 or sendType==11) and (allowOfficial == null or allowOfficial != 1) \"> and qu.app_key IS NOT NULL  </if>\n" +
             "</script>"})
     List<QwUserVO> selectQwUserListVO(QwUserListParam qwUser);
 
@@ -324,7 +324,6 @@ public interface QwUserMapper extends BaseMapper<QwUser>
             "            <if test=\"corpId != null \"> and qu.corp_id = #{corpId}</if>\n" +
             "            <if test=\"qwUserId != null \"> and qu.qw_user_id  like concat( #{qwUserId}, '%') </if>\n" +
             "            <if test=\"status != null \"> and qu.status = #{status}</if>\n" +
-            "            <if test=\"type != null and sendType !=null and type==2 and sendType==2 \"> and qu.app_key IS NOT NULL  </if>\n" +
             "</script>"})
     List<QwUserVO> selectAllQwUserListVO(QwUserListParam qwUser);
 

+ 6 - 0
fs-service/src/main/java/com/fs/qw/param/QwUserListParam.java

@@ -54,6 +54,12 @@ public class QwUserListParam {
 
     private Integer sendType;
 
+    /**
+     * 企微主体「可选iPad」qw_company.allow_official;为 1 时选员工列表不强制 qu.app_key(走官方群发可不绑 iPad)
+     * 由后端根据 corpId 查询主体后写入,勿由前端随意传入
+     */
+    private Integer allowOfficial;
+
     /**
      * 企业微信李的部门
      */

+ 1 - 1
fs-service/src/main/java/com/fs/sop/service/IQwSopService.java

@@ -54,7 +54,7 @@ public interface IQwSopService
     public int insertQwSop(QwSop qwSop);
 
     /**
-     * 保存/修改前置校验:当 qwUserIds 为空时,仅在「群发助手 / 课程模板」且公司开启「可选ipad」时放行
+     * 保存/修改前置校验:须配置 qw_sop.qw_user_ids(使用员工)
      *
      * @param qwSop 企微sop
      * @return null=通过;否则返回错误信息

+ 19 - 15
fs-service/src/main/java/com/fs/sop/service/impl/QwSopLogsServiceImpl.java

@@ -1998,25 +1998,29 @@ public class QwSopLogsServiceImpl extends ServiceImpl<QwSopLogsMapper, QwSopLogs
                 });
                 return;
             }
-            // 可选 iPad / 官方群发:可不选员工,qw_userid 为空时不校验 QwUser,接口侧不传 sender(见 QwApiServiceImpl#addMsgTemplateBySop)
             String rawSender = first.getQwUserid();
             String qwUserid = StringUtils.isEmpty(rawSender) ? null : rawSender.trim();
-            if (StringUtils.isNotEmpty(qwUserid) && !"null".equalsIgnoreCase(qwUserid)) {
-                QwUser qwUser = qwExternalContactService.getQwUserByRedis(corpId, qwUserid);
-                if (qwUser == null || qwUser.getIsDel() != 0) {
-                    logger.error("员工信息无效-不存在或被删除,corpId:{},userId:{}", corpId, qwUserid);
-                    logsGroup.forEach(log -> {
-                        log.setSendStatus(5L);
-                        log.setRemark("员工信息无效");
-                        updateQueue.add(log);
-                    });
-                    return;
-                }
-            } else {
-                qwUserid = null;
+            if (StringUtils.isEmpty(qwUserid) || "null".equalsIgnoreCase(qwUserid)) {
+                logger.error("发送员工未配置,corpId:{}", corpId);
+                logsGroup.forEach(log -> {
+                    log.setSendStatus(5L);
+                    log.setRemark("未配置发送员工");
+                    updateQueue.add(log);
+                });
+                return;
+            }
+            QwUser qwUser = qwExternalContactService.getQwUserByRedis(corpId, qwUserid);
+            if (qwUser == null || qwUser.getIsDel() != 0) {
+                logger.error("员工信息无效-不存在或被删除,corpId:{},userId:{}", corpId, qwUserid);
+                logsGroup.forEach(log -> {
+                    log.setSendStatus(5L);
+                    log.setRemark("员工信息无效");
+                    updateQueue.add(log);
+                });
+                return;
             }
 
-            String firstKey = corpId + "|" + (qwUserid == null ? "" : qwUserid);
+            String firstKey = corpId + "|" + qwUserid;
 
             // 提取内容与目标客户列表
             String contentJson = logsGroup.get(0).getContentJson();

+ 1 - 18
fs-service/src/main/java/com/fs/sop/service/impl/QwSopServiceImpl.java

@@ -166,24 +166,7 @@ public class QwSopServiceImpl implements IQwSopService
         if (qwSop == null) {
             return null;
         }
-
-        if (StringUtils.isNotEmpty(qwSop.getQwUserIds())) {
-            return null;
-        }
-
-        Integer sendType = null;
-        if (StringUtils.isNotEmpty(qwSop.getTempId())) {
-            QwSopTemp temp = qwSopTempMapper.selectQwSopTempById(qwSop.getTempId());
-            if (temp != null) {
-                sendType = temp.getSendType();
-            }
-        }
-        if (sendType == null || (sendType != 2 && sendType != 11)) {
-            return "请选择使用员工";
-        }
-
-        QwCompany company = qwCompanyMapper.selectQwCompanyByCorpId(qwSop.getCorpId());
-        if (company == null || !Integer.valueOf(1).equals(company.getAllowOfficial())) {
+        if (StringUtils.isEmpty(qwSop.getQwUserIds())) {
             return "请选择使用员工";
         }
         return null;

+ 1 - 2
fs-service/src/main/java/com/fs/sop/vo/SopUserLogsVo.java

@@ -50,8 +50,7 @@ public class SopUserLogsVo  {
     private Integer isSampSend;
 
     /**
-     * 该 SOP 配置的企微员工集合(qw_sop.qw_user_ids)。
-     * 为空表示「不绑ipad走官方群发」模式:运行期所有规则强制 isOfficial=1
+     * 该 SOP 配置的企微员工集合(qw_sop.qw_user_ids),保存任务时必选,未配置则不会生成待发送记录
      */
     private String qwUserIds;