Prechádzať zdrojové kódy

导出企业微信客户unionId

wjj 1 mesiac pred
rodič
commit
258e909176

+ 39 - 3
fs-admin/src/main/java/com/fs/qw/controller/QwExternalContactController.java

@@ -3,11 +3,13 @@ package com.fs.qw.controller;
 import java.util.List;
 import java.util.Objects;
 
+import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.util.ObjectUtil;
 import com.fs.common.exception.ServiceException;
 import com.fs.qw.param.QwExternalContactParam;
 import com.fs.qw.param.QwTagSearchParam;
 import com.fs.qw.service.IQwTagService;
+import com.fs.qw.vo.QwExternalContactUnionIdExportVO;
 import com.fs.qw.vo.QwExternalContactVO;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
@@ -86,13 +88,47 @@ public class QwExternalContactController extends BaseController
     @PreAuthorize("@ss.hasPermi('qw:externalContact:export')")
     @Log(title = "企业微信客户", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
-    public AjaxResult export(QwExternalContact qwExternalContact)
+    public AjaxResult export(QwExternalContactParam qwExternalContact)
     {
-        List<QwExternalContact> list = qwExternalContactService.selectQwExternalContactList(qwExternalContact);
-        ExcelUtil<QwExternalContact> util = new ExcelUtil<QwExternalContact>(QwExternalContact.class);
+        if (qwExternalContact.getCompanyId() == null) {
+            return AjaxResult.success();
+        }
+
+        List<QwExternalContactVO> list = qwExternalContactService.selectQwExternalContactListVO(qwExternalContact);
+        list.forEach(item->{
+
+            if (!Objects.equals(item.getTagIds(), "[]") && item.getTagIds()!=null) {
+                QwTagSearchParam param = new QwTagSearchParam();
+                Gson gson = new Gson();
+                List<String> tagIds = gson.fromJson(
+                        item.getTagIds(),
+                        new TypeToken<List<String>>() {
+                        }.getType()
+                );
+
+                param.setTagIds(tagIds);
+
+                item.setTagIdsName(iQwTagService.selectQwTagListByTagIds(param));
+            }
+        });
+        ExcelUtil<QwExternalContactVO> util = new ExcelUtil<QwExternalContactVO>(QwExternalContactVO.class);
         return util.exportExcel(list, "企业微信客户数据");
     }
 
+    /**
+     * 导出企业微信客户unionId
+     */
+    @PreAuthorize("@ss.hasPermi('qw:externalContact:export')")
+    @Log(title = "企业微信客户unionId", businessType = BusinessType.EXPORT)
+    @GetMapping("/exportUnionId")
+    public AjaxResult exportUnionId(QwExternalContactParam qwExternalContact)
+    {
+        List<QwExternalContactUnionIdExportVO> list = qwExternalContactService.selectQwExternalContactUnionIdExportVO(qwExternalContact);
+        ExcelUtil<QwExternalContactUnionIdExportVO> util = new ExcelUtil<QwExternalContactUnionIdExportVO>(QwExternalContactUnionIdExportVO.class);
+        return util.exportExcel(list, "企业微信客户unionId数据");
+    }
+
+
     /**
      * 获取企业微信客户详细信息
      */

+ 62 - 0
fs-service/src/main/java/com/fs/qw/mapper/QwExternalContactMapper.java

@@ -285,6 +285,68 @@ public interface QwExternalContactMapper extends BaseMapper<QwExternalContact> {
             "</script>"})
     List<QwExternalContactVO> selectQwExternalContactListVO(QwExternalContactParam qwExternalContact);
 
+    @Select({"<script> " +
+            "select ec.unionid from qw_external_contact ec " +
+            "left join qw_user qu on ec.user_id=qu.qw_user_id and qu.corp_id=ec.corp_id " +
+            "left join qw_dept qd on qd.dept_id=qu.department and qd.corp_id=qu.corp_id " +
+            "left join company_user cu on ec.company_user_id=cu.user_id " +
+            "<where>  \n" +
+            "            <if test=\"userId != null  and userId != ''\"> and ec.user_id   like concat( #{userId}, '%') </if>\n" +
+            "            <if test=\"qwUserName != null  and qwUserName != ''\"> and qu.qw_user_name   like concat( #{qwUserName}, '%') </if>\n" +
+            "            <if test=\"externalUserId != null  and externalUserId != ''\"> and ec.external_user_id = #{externalUserId}</if>\n" +
+            "            <if test=\"name != null  and name != ''\"> and ec.name like concat( #{name}, '%')</if>\n" +
+            "            <if test=\"type != null \"> and ec.type = #{type}</if>\n" +
+            "            <if test=\"gender != null \"> and ec.gender = #{gender}</if>\n" +
+            "            <if test=\"description != null  and description != ''\"> and ec.description = #{description}</if>\n" +
+
+            "<if test ='tagIds!=null and tagIds.size()!=0 '> " +
+            "    and (\n" +
+            "    <foreach collection='tagIds' item='item' index='index' separator=' AND '>\n" +
+            "        find_in_set(#{item}, REGEXP_REPLACE(ec.tag_ids, '[\"\\\\[\\\\]]', ''))\n" +
+            "    </foreach>\n" +
+            "    )"+
+            "</if> " +
+
+            "            <if test=\"remarkMobiles != null  and remarkMobiles != ''\"> and ec.remark_mobiles like concat( #{remarkMobiles}, '%')</if>\n" +
+            "            <if test=\"remark != null  and remark != ''\"> and ec.remark like concat('%', #{remark}, '%')</if>\n" +
+            "            <if test=\"remarkCorpName != null  and remarkCorpName != ''\"> and ec.remark_corp_name like concat('%', #{remarkCorpName}, '%')</if>\n" +
+            "            <if test=\"addWay != null \"> and ec.add_way = #{addWay}</if>\n" +
+            "            <if test=\"operUserid != null  and operUserid != ''\"> and ec.oper_userid = #{operUserid}</if>\n" +
+            "            <if test=\"corpId != null  and corpId != ''\"> and ec.corp_id = #{corpId}</if>\n" +
+            "            <if test=\"companyId != null \"> and qu.company_id = #{companyId}</if>\n" +
+            "            <if test=\"companyUserId != null \"> and ec.company_user_id = #{companyUserId}</if>\n" +
+            "            <if test=\"customerId != null \"> and ec.customer_id = #{customerId}</if>\n" +
+            "            <if test=\"status != null \"> and ec.status = #{status}</if>\n" +
+            "            <if test=\"stageStatus != null \"> and ec.stage_status = #{stageStatus}</if>\n" +
+            "            <if test=\"transferStatus != null \"> and ec.transfer_status = #{transferStatus}</if>\n" +
+            "            <if test=\"qwUserId != null \"> and ec.qw_user_id = #{qwUserId}</if>\n" +
+            "            <if test=\"level != null \"> and ec.level = #{level}</if>\n" +
+            "            <if test=\"levelType != null \"> and ec.level_type = #{levelType}</if>\n" +
+            "            <if test=\"isBind == 'isBind' \"> and ec.customer_id is not null </if> \n" +
+            "            <if test=\"isBind == 'noBind' \"> and ec.customer_id is null </if> \n" +
+            "            <if test=\"isBindMini == 'isBindMini' \"> and ec.fs_user_id is not null </if> \n" +
+            "            <if test=\"isBindMini == 'noBindMini' \"> and ec.fs_user_id is null </if> \n" +
+            "            <if test=\"lossTime != null \"> and DATE(ec.loss_time) = DATE(#{lossTime})</if>\n" +
+            "            <if test=\"createTime != null \">and DATE(ec.create_time) = DATE(#{createTime})</if>\n" +
+            "            <if test=\"delTime != null \"> and DATE(ec.del_time) = DATE(#{delTime})</if>\n" +
+            "            <if test=\"sTime != null \">  and DATE(ec.create_time) &gt;= DATE(#{sTime})</if>\n" +
+            "            <if test=\"eTime != null \">  and DATE(ec.create_time) &lt;= DATE(#{eTime})</if>\n" +
+            "            <if test=\"companyUserName != null  and companyUserName != ''\"> and cu.user_name = #{companyUserName}</if>\n" +
+            "            <if test=\"cuDeptIdList != null and !cuDeptIdList.isEmpty() and  userType != '00' \">" +
+            "               AND cu.dept_id IN " +
+            "                   <foreach collection='cuDeptIdList' item='item' open='(' separator=',' close=')'> " +
+            "                       #{item} " +
+            "                   </foreach> " +
+            "            </if>" +
+            "<if test ='companyUser!=null'> " +
+            "and (cu.nick_name like concat('%', #{companyUser}, '%') or cu.phonenumber= #{companyUser})"+
+            "</if> " +
+            " and ec.unionid is not null" +
+            "        </where>"+
+            "order by ec.create_time desc,ec.id desc"+
+            "</script>"})
+    List<QwExternalContactUnionIdExportVO> selectQwExternalContactUnionIdExportVO(QwExternalContactParam qwExternalContact);
+
 
     List<QwExternalContactVOTime> selectQwExternalContactListVOByIds(@Param("ids") List<Long> ids);
 

+ 2 - 0
fs-service/src/main/java/com/fs/qw/service/IQwExternalContactService.java

@@ -95,6 +95,8 @@ public interface IQwExternalContactService extends IService<QwExternalContact> {
 
     List<QwExternalContactVO> selectQwExternalContactListVO(QwExternalContactParam qwExternalContact);
 
+    List<QwExternalContactUnionIdExportVO> selectQwExternalContactUnionIdExportVO(QwExternalContactParam qwExternalContact);
+
     List<QwExternalContactVOTime> selectQwExternalContactListVOByIds(List<Long> ids);
 
     R syncQwExternalContact(String corpId) throws IOException;

+ 5 - 0
fs-service/src/main/java/com/fs/qw/service/impl/QwExternalContactServiceImpl.java

@@ -843,6 +843,11 @@ public class QwExternalContactServiceImpl extends ServiceImpl<QwExternalContactM
         return qwExternalContactMapper.selectQwExternalContactListVO(qwExternalContact);
     }
 
+    @Override
+    public List<QwExternalContactUnionIdExportVO> selectQwExternalContactUnionIdExportVO(QwExternalContactParam qwExternalContact) {
+        return qwExternalContactMapper.selectQwExternalContactUnionIdExportVO(qwExternalContact);
+    }
+
     @Override
     public List<QwExternalContactVOTime> selectQwExternalContactListVOByIds(List<Long> ids) {
         return qwExternalContactMapper.selectQwExternalContactListVOByIds(ids);

+ 10 - 0
fs-service/src/main/java/com/fs/qw/vo/QwExternalContactUnionIdExportVO.java

@@ -0,0 +1,10 @@
+package com.fs.qw.vo;
+
+import com.fs.common.annotation.Excel;
+import lombok.Data;
+
+@Data
+public class QwExternalContactUnionIdExportVO {
+    @Excel(name = "unionId")
+    private String unionid;
+}