2 Комити 58e4b6815d ... 3cf176bcc8

Аутор SHA1 Порука Датум
  吴树波 3cf176bcc8 Merge remote-tracking branch 'origin/master' into matser пре 22 часа
  吴树波 bb76c18773 个微SOP пре 22 часа

+ 2 - 2
fs-company/src/main/java/com/fs/company/controller/wx/controller/WxSopController.java

@@ -66,12 +66,12 @@ public class WxSopController extends BaseController
     }
 
     /**
-     * 获取个微SOP详细信息
+     * 获取个微SOP详细信息(含执行账号 companyUserIds)
      */
     @GetMapping(value = "/{id}")
     public AjaxResult getInfo(@PathVariable("id") Long id)
     {
-        return AjaxResult.success(wxSopService.selectWxSopById(id));
+        return AjaxResult.success(wxSopService.selectWxSopDetailById(id));
     }
 
     /**

+ 11 - 0
fs-service/src/main/java/com/fs/wx/sop/domain/WxSop.java

@@ -2,7 +2,11 @@ package com.fs.wx.sop.domain;
 
 import java.time.LocalDate;
 import java.util.Date;
+import java.util.List;
+import java.util.Map;
+
 import com.fasterxml.jackson.annotation.JsonFormat;
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fs.common.annotation.Excel;
 import com.fs.common.core.domain.BaseEntityTow;
@@ -57,5 +61,12 @@ public class WxSop extends BaseEntityTow {
     @Excel(name = "营期开始时间", width = 30, dateFormat = "yyyy-MM-dd")
     private LocalDate startTime;
 
+    /** 执行账号ID,逗号分隔(入库) */
+    @Excel(name = "执行账号ID")
+    private String accountIds;
+
+    /** 执行账号列表(不入库,用于编辑回显) */
+    @TableField(exist = false)
+    private List<Map<String, Object>> selectedQwUsers;
 
 }

+ 3 - 0
fs-service/src/main/java/com/fs/wx/sop/mapper/WxSopMapper.java

@@ -2,6 +2,8 @@ package com.fs.wx.sop.mapper;
 
 import java.util.List;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.fs.common.annotation.DataSource;
+import com.fs.common.enums.DataSourceType;
 import com.fs.wx.sop.domain.WxSop;
 
 /**
@@ -17,6 +19,7 @@ public interface WxSopMapper extends BaseMapper<WxSop>{
      * @param id 个微SOP主键
      * @return 个微SOP
      */
+    @DataSource(DataSourceType.SOP)
     WxSop selectWxSopById(Long id);
 
     /**

+ 8 - 0
fs-service/src/main/java/com/fs/wx/sop/mapper/WxSopUserMapper.java

@@ -58,4 +58,12 @@ public interface WxSopUserMapper extends BaseMapper<WxSopUser>{
      * @return 结果
      */
     int deleteWxSopUserByIds(Long[] ids);
+
+    /**
+     * 根据SOP ID删除执行账号
+     * 
+     * @param sopId SOP主键
+     * @return 结果
+     */
+    int deleteBySopId(Long sopId);
 }

+ 8 - 0
fs-service/src/main/java/com/fs/wx/sop/service/IWxSopService.java

@@ -19,6 +19,14 @@ public interface IWxSopService extends IService<WxSop>{
      */
     WxSop selectWxSopById(Long id);
 
+    /**
+     * 查询个微SOP详情(含执行账号 companyUserIds)
+     * 
+     * @param id 个微SOP主键
+     * @return 个微SOP
+     */
+    WxSop selectWxSopDetailById(Long id);
+
     /**
      * 查询个微SOP列表
      * 

+ 60 - 2
fs-service/src/main/java/com/fs/wx/sop/service/impl/WxSopServiceImpl.java

@@ -1,10 +1,18 @@
 package com.fs.wx.sop.service.impl;
 
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
+import com.fs.company.domain.CompanyWxAccount;
+import com.fs.company.service.ICompanyWxAccountService;
 import com.fs.common.annotation.DataSource;
 import com.fs.common.enums.DataSourceType;
 import com.fs.common.utils.DateUtils;
+import com.fs.common.utils.StringUtils;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -21,6 +29,9 @@ import com.fs.wx.sop.service.IWxSopService;
 @Service
 public class WxSopServiceImpl extends ServiceImpl<WxSopMapper, WxSop> implements IWxSopService {
 
+    @Autowired
+    private ICompanyWxAccountService companyWxAccountService;
+
     /**
      * 查询个微SOP
      * 
@@ -34,6 +45,47 @@ public class WxSopServiceImpl extends ServiceImpl<WxSopMapper, WxSop> implements
         return baseMapper.selectWxSopById(id);
     }
 
+    @Override
+    public WxSop selectWxSopDetailById(Long id)
+    {
+        WxSop wxSop = baseMapper.selectWxSopById(id);
+        if (wxSop != null) {
+            fillSelectedQwUsers(wxSop);
+        }
+        return wxSop;
+    }
+
+    /**
+     * 填充执行账号 selectedQwUsers(从 accountIds 解析并查询账号详情)
+     */
+    private void fillSelectedQwUsers(WxSop wxSop) {
+        String accountIdsStr = wxSop.getAccountIds();
+        if (StringUtils.isEmpty(accountIdsStr)) {
+            return;
+        }
+        List<Long> accountIds = Arrays.stream(accountIdsStr.split(","))
+            .map(String::trim)
+            .filter(s -> !s.isEmpty())
+            .map(Long::parseLong)
+            .collect(Collectors.toList());
+        if (accountIds.isEmpty()) {
+            return;
+        }
+        List<CompanyWxAccount> accounts = (List<CompanyWxAccount>) companyWxAccountService.listByIds(accountIds);
+        if (accounts != null) {
+            List<Map<String, Object>> selectedQwUsers = new ArrayList<>();
+            for (CompanyWxAccount acc : accounts) {
+                Map<String, Object> m = new HashMap<>();
+                m.put("id", acc.getId());
+                m.put("wxNickName", acc.getWxNickName());
+                m.put("wxNo", acc.getWxNo());
+                m.put("companyUserName", acc.getCompanyUserId() != null ? String.valueOf(acc.getCompanyUserId()) : null);
+                selectedQwUsers.add(m);
+            }
+            wxSop.setSelectedQwUsers(selectedQwUsers);
+        }
+    }
+
     /**
      * 查询个微SOP列表
      * 
@@ -48,7 +100,13 @@ public class WxSopServiceImpl extends ServiceImpl<WxSopMapper, WxSop> implements
     }
 
     /**
-     * 新增个微SOP
+     * 新增个微SOP(含执行账号保存到 wx_sop_user)
+     * 
+     * @param wxSop 个微SOP
+     * @return 结果
+     */
+    /**
+     * 新增个微SOP(accountIds 直接入库到 wx_sop.account_ids)
      * 
      * @param wxSop 个微SOP
      * @return 结果
@@ -62,7 +120,7 @@ public class WxSopServiceImpl extends ServiceImpl<WxSopMapper, WxSop> implements
     }
 
     /**
-     * 修改个微SOP
+     * 修改个微SOP(accountIds 直接入库到 wx_sop.account_ids)
      * 
      * @param wxSop 个微SOP
      * @return 结果

+ 24 - 1
fs-service/src/main/resources/db/20260226-个微SOP表结构.sql

@@ -1,6 +1,25 @@
 -- 个微SOP表结构(his_sop 数据库)
--- 执行前请确认已切换到 his_sop 数据库
+-- 对应 @DataSource(DataSourceType.SOP),请在 SOP 数据源对应的数据库中执行
 
+-- 执行账号表
+CREATE TABLE IF NOT EXISTS `wx_sop_user` (
+  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
+  `type` int(11) DEFAULT NULL COMMENT '类型(0个人1群聊)',
+  `sop_id` bigint(20) DEFAULT NULL COMMENT '任务ID',
+  `account_id` bigint(20) DEFAULT NULL COMMENT '个微账号ID',
+  `start_time` date DEFAULT NULL COMMENT '营期时间',
+  `chat_id` varchar(100) DEFAULT NULL COMMENT '群聊ID',
+  `status` int(11) DEFAULT NULL COMMENT '状态(0正常1暂停)',
+  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+  `create_by` varchar(64) DEFAULT NULL COMMENT '创建者',
+  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
+  `update_by` varchar(64) DEFAULT NULL COMMENT '更新者',
+  `remark` varchar(500) DEFAULT NULL COMMENT '备注',
+  PRIMARY KEY (`id`),
+  KEY `idx_sop_id` (`sop_id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='个微SOP执行账号表';
+
+-- 个微SOP主表
 CREATE TABLE IF NOT EXISTS `wx_sop` (
   `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键ID',
   `name` varchar(100) DEFAULT NULL COMMENT '名称',
@@ -12,6 +31,7 @@ CREATE TABLE IF NOT EXISTS `wx_sop` (
   `is_fixed` int(11) DEFAULT NULL COMMENT '是否固定营期(0否1是)',
   `expiry_time` int(11) DEFAULT NULL COMMENT '过期时间(小时)',
   `start_time` date DEFAULT NULL COMMENT '营期开始时间',
+  `account_ids` varchar(500) DEFAULT NULL COMMENT '执行账号ID,逗号分隔',
   `create_time` datetime DEFAULT NULL COMMENT '创建时间',
   `create_by` varchar(64) DEFAULT NULL COMMENT '创建者',
   `update_time` datetime DEFAULT NULL COMMENT '更新时间',
@@ -20,3 +40,6 @@ CREATE TABLE IF NOT EXISTS `wx_sop` (
   PRIMARY KEY (`id`),
   KEY `idx_company_id` (`company_id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='个微SOP表';
+
+-- 若 wx_sop 表已存在且无 account_ids 字段,可执行:
+-- ALTER TABLE wx_sop ADD COLUMN account_ids varchar(500) DEFAULT NULL COMMENT '执行账号ID,逗号分隔' AFTER start_time;

+ 6 - 1
fs-service/src/main/resources/mapper/wx/WxSopMapper.xml

@@ -15,6 +15,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="isFixed"    column="is_fixed"    />
         <result property="expiryTime"    column="expiry_time"    />
         <result property="startTime"    column="start_time"    />
+        <result property="accountIds"    column="account_ids"    />
         <result property="createTime"    column="create_time"    />
         <result property="createBy"    column="create_by"    />
         <result property="updateTime"    column="update_time"    />
@@ -23,7 +24,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectWxSopVo">
-        select id, name, filter_type, select_tags, exclude_tags, temp_id, company_id, is_fixed, expiry_time, start_time, create_time, create_by, update_time, update_by, remark from wx_sop
+        select id, name, filter_type, select_tags, exclude_tags, temp_id, company_id, is_fixed, expiry_time, start_time, account_ids, create_time, create_by, update_time, update_by, remark from wx_sop
     </sql>
 
     <select id="selectWxSopList" parameterType="WxSop" resultMap="WxSopResult">
@@ -38,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isFixed != null "> and is_fixed = #{isFixed}</if>
             <if test="expiryTime != null "> and expiry_time = #{expiryTime}</if>
             <if test="startTime != null "> and start_time = #{startTime}</if>
+            <if test="accountIds != null  and accountIds != ''"> and account_ids = #{accountIds}</if>
         </where>
     </select>
     
@@ -58,6 +60,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isFixed != null">is_fixed,</if>
             <if test="expiryTime != null">expiry_time,</if>
             <if test="startTime != null">start_time,</if>
+            <if test="accountIds != null">account_ids,</if>
             <if test="createTime != null">create_time,</if>
             <if test="createBy != null">create_by,</if>
             <if test="updateTime != null">update_time,</if>
@@ -74,6 +77,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isFixed != null">#{isFixed},</if>
             <if test="expiryTime != null">#{expiryTime},</if>
             <if test="startTime != null">#{startTime},</if>
+            <if test="accountIds != null">#{accountIds},</if>
             <if test="createTime != null">#{createTime},</if>
             <if test="createBy != null">#{createBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
@@ -94,6 +98,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="isFixed != null">is_fixed = #{isFixed},</if>
             <if test="expiryTime != null">expiry_time = #{expiryTime},</if>
             <if test="startTime != null">start_time = #{startTime},</if>
+            <if test="accountIds != null">account_ids = #{accountIds},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
             <if test="createBy != null">create_by = #{createBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>

+ 4 - 0
fs-service/src/main/resources/mapper/wx/WxSopUserMapper.xml

@@ -98,4 +98,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             #{id}
         </foreach>
     </delete>
+
+    <delete id="deleteBySopId" parameterType="Long">
+        delete from wx_sop_user where sop_id = #{sopId}
+    </delete>
 </mapper>