Commit dee159df by sunxiwang

Merge remote-tracking branch 'origin/master'

2 parents 8d7ab65d cc4f54bb
...@@ -33,6 +33,8 @@ public class WeCustomerController extends BaseController ...@@ -33,6 +33,8 @@ public class WeCustomerController extends BaseController
@Autowired @Autowired
private IWeCustomerService weCustomerService; private IWeCustomerService weCustomerService;
/** /**
* 查询企业微信客户列表 * 查询企业微信客户列表
*/ */
...@@ -41,6 +43,7 @@ public class WeCustomerController extends BaseController ...@@ -41,6 +43,7 @@ public class WeCustomerController extends BaseController
public TableDataInfo list(WeCustomer weCustomer) public TableDataInfo list(WeCustomer weCustomer)
{ {
startPage(); startPage();
List<WeCustomer> list = weCustomerService.selectWeCustomerList(weCustomer); List<WeCustomer> list = weCustomerService.selectWeCustomerList(weCustomer);
return getDataTable(list); return getDataTable(list);
} }
......
...@@ -7,8 +7,11 @@ import com.linkwechat.common.core.controller.BaseController; ...@@ -7,8 +7,11 @@ import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
import com.linkwechat.common.core.page.TableDataInfo; import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.utils.Threads;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.context.SecurityContext;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping; import org.springframework.web.bind.annotation.PutMapping;
...@@ -41,6 +44,19 @@ public class WeTagGroupController extends BaseController ...@@ -41,6 +44,19 @@ public class WeTagGroupController extends BaseController
public TableDataInfo list(WeTagGroup weTagGroup) public TableDataInfo list(WeTagGroup weTagGroup)
{ {
startPage(); startPage();
SecurityContext securityContext = SecurityContextHolder.getContext();
//异步同步一下标签库,解决标签不同步问题
Threads.SINGLE_THREAD_POOL.execute(new Runnable() {
@Override
public void run() {
SecurityContextHolder.setContext(securityContext);
weTagGroupService.synchWeTags();
}
});
return getDataTable( return getDataTable(
weTagGroupService.selectWeTagGroupList(weTagGroup) weTagGroupService.selectWeTagGroupList(weTagGroup)
); );
......
...@@ -156,4 +156,8 @@ public class Constants ...@@ -156,4 +156,8 @@ public class Constants
} }
...@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.api.R; ...@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper; import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.common.constant.Constants; import com.linkwechat.common.constant.Constants;
import com.linkwechat.common.constant.UserConstants;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.utils.SecurityUtils; import com.linkwechat.common.utils.SecurityUtils;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
...@@ -203,7 +204,6 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr ...@@ -203,7 +204,6 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr
@Transactional @Transactional
public void synchWeTags() { public void synchWeTags() {
WeCropGroupTagListDto weCropGroupTagListDto = weCropTagClient.getAllCorpTagList(); WeCropGroupTagListDto weCropGroupTagListDto = weCropTagClient.getAllCorpTagList();
if(weCropGroupTagListDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)){ if(weCropGroupTagListDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)){
...@@ -248,17 +248,43 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr ...@@ -248,17 +248,43 @@ public class WeTagGroupServiceImpl extends ServiceImpl<WeTagGroupMapper,WeTagGr
} }
this.saveOrUpdateBatch(weTagGroups);
List<WeTag> weTags = //先逻辑删除不存在得组
weTagGroups.stream().map(WeTagGroup::getWeTags).collect(ArrayList::new, ArrayList::addAll, ArrayList::addAll); if(CollectionUtil.isNotEmpty(weTagGroups)){
if(CollectionUtil.isNotEmpty(weTags)){
List<WeTagGroup> noExist
= this.list(new LambdaQueryWrapper<WeTagGroup>().notIn(WeTagGroup::getGroupId, weTagGroups.stream().map(WeTagGroup::getGroupId).collect(Collectors.toList())));
//企业微信端删除得标签
if(CollectionUtil.isNotEmpty(noExist)){
noExist.stream().forEach(k->k.setStatus(Constants.DELETE_CODE));
this.updateBatchById(noExist);
}
this.saveOrUpdateBatch(weTagGroups);
List<WeTag> weTags =
weTagGroups.stream().map(WeTagGroup::getWeTags).collect(ArrayList::new, ArrayList::addAll, ArrayList::addAll);
if(CollectionUtil.isNotEmpty(weTags)){
List<WeTag> noExistWeTags
= iWeTagService.list(new LambdaQueryWrapper<WeTag>().notIn(WeTag::getTagId, weTags.stream().map(WeTag::getTagId).collect(Collectors.toList())));
if(CollectionUtil.isNotEmpty(noExistWeTags)){
noExistWeTags.stream().forEach(k->k.setStatus(Constants.DELETE_CODE));
iWeTagService.updateBatchById(noExistWeTags);
}
iWeTagService.saveOrUpdateBatch(weTags);
}
iWeTagService.saveOrUpdateBatch(weTags);
} }
} }
......
...@@ -28,92 +28,190 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -28,92 +28,190 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="status" column="status" /> <result property="status" column="status" />
<result property="userName" column="user_name"/> <result property="userName" column="user_name"/>
<result property="department" column="department"/> <result property="department" column="department"/>
<collection property="weFlowerCustomerTagRels" ofType="com.linkwechat.wecom.domain.WeFlowerCustomerTagRel"> <collection property="weFlowerCustomerTagRels" javaType="ArrayList"
<result property="flowerCustomerRelId" column="flower_customer_rel_id" /> column="{id = wfcrId}" select="selectWeCustomerTags">
<result property="tagId" column="tag_id" />
<result property="createTime" column="create_time" />
<result property="tagName" column="tagName"/>
</collection> </collection>
</collection> </collection>
</resultMap> </resultMap>
<resultMap id="weFlowerCustomerRelsMapper" type="com.linkwechat.wecom.domain.WeFlowerCustomerTagRel">
<result property="flowerCustomerRelId" column="flower_customer_rel_id" />
<result property="tagId" column="tag_id" />
<result property="createTime" column="create_time" />
<result property="tagName" column="tagName"/>
</resultMap>
<sql id="selectWeCustomerVo"> <sql id="selectWeCustomerVo">
select external_userid, name, avatar, type, gender, unionid, birthday, corp_name, corp_full_name, position from we_customer select external_userid, name, avatar, type, gender, unionid, birthday, corp_name, corp_full_name, position from we_customer
</sql> </sql>
<select id="selectWeCustomerList" parameterType="WeCustomer" resultMap="WeCustomerResult"> <select id="selectWeCustomerList" parameterType="WeCustomer" resultMap="WeCustomerResult">
SELECT SELECT
wc.external_userid, DISTINCT wc.external_userid,
wc.`name`, wc.`name`,
wc.avatar, wc.avatar,
wc.type, wc.type,
wc.gender, wc.gender,
wc.unionid, wc.unionid,
wc.birthday, wc.birthday,
wc.corp_name, wc.corp_name,
wc.corp_full_name, wc.corp_full_name,
wc.position, wc.position,
wfcr.id as wfcrId, wfcr.id as wfcrId,
wfcr.user_id, wfcr.user_id,
wfcr.remark, wfcr.remark,
wfcr.description, wfcr.description,
wfcr.create_time, wfcr.create_time,
wfcr.remark_corp_name, wfcr.remark_corp_name,
wfcr.oper_userid, wfcr.oper_userid,
wfcr.add_way, wfcr.add_way,
wfcr.state, wfcr.state,
wfcr.status, wfcr.status,
wu.user_name, wu.user_name,
wfcrf.flower_customer_rel_id, (SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department
wt.tag_id, FROM
wt.`name` as tagName,
(SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department
FROM
we_customer wc we_customer wc
LEFT JOIN we_flower_customer_rel wfcr ON wc.external_userid=wfcr.external_userid LEFT JOIN we_flower_customer_rel wfcr ON wc.external_userid=wfcr.external_userid
LEFT JOIN we_user wu ON wu.user_id=wfcr.user_id LEFT JOIN we_user wu ON wu.user_id=wfcr.user_id
LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.flower_customer_rel_id = wfcr.id LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.flower_customer_rel_id = wfcr.id
INNER JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id LEFT JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id
<where> <where>
<if test="name != null and name !=''"> <if test="name != null and name !=''">
AND wc.name like concat('%', #{name}, '%') AND wc.name like concat('%', #{name}, '%')
</if> </if>
<if test="userIds != null and userIds !=''"> <if test="userIds != null and userIds !=''">
<if test="userIds.indexOf(',') != -1"> <if test="userIds.indexOf(',') != -1">
and wfcr.user_id in AND wfcr.user_id in
<foreach item="item" index="index" collection="userIds.split(',')" open="(" separator="," close=")"> <foreach item="item" index="index" collection="userIds.split(',')" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
</if> </if>
<if test="userIds.indexOf(',') == -1"> <if test="userIds.indexOf(',') == -1">
and wfcr.user_id=#{userIds} AND wfcr.user_id=#{userIds}
</if>
</if>
<if test="tagIds != null and tagIds !=''">
<if test="tagIds.indexOf(',') != -1">
and wt.tag_id in
<foreach item="item" index="index" collection="tagIds.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="tagIds.indexOf(',') == -1">
and wt.tag_id=#{tagIds}
</if> </if>
</if> </if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 --> <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d') AND date_format(wfcr.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(wfcr.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if> </if>
<if test="status != null and status !=''"> <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND wfcr.status = #{status} AND date_format(wfcr.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if> </if>
<if test="tagIds != null and tagIds !=''">
<if test="tagIds.indexOf(',') != -1">
AND wt.tag_id in
<foreach item="item" index="index" collection="tagIds.split(',')" open="(" separator="," close=")">
#{item}
</foreach>
</if>
<if test="tagIds.indexOf(',') == -1">
AND wt.tag_id=#{tagIds}
</if>
</if>
</where> </where>
ORDER BY wfcr.create_time DESC
<!-- SELECT-->
<!-- wc.external_userid,-->
<!-- wc.`name`,-->
<!-- wc.avatar,-->
<!-- wc.type,-->
<!-- wc.gender,-->
<!-- wc.unionid,-->
<!-- wc.birthday,-->
<!-- wc.corp_name,-->
<!-- wc.corp_full_name,-->
<!-- wc.position,-->
<!-- wfcr.id as wfcrId,-->
<!-- wfcr.user_id,-->
<!-- wfcr.remark,-->
<!-- wfcr.description,-->
<!-- wfcr.create_time,-->
<!-- wfcr.remark_corp_name,-->
<!-- wfcr.oper_userid,-->
<!-- wfcr.add_way,-->
<!-- wfcr.state,-->
<!-- wfcr.status,-->
<!-- wu.user_name,-->
<!-- wfcrf.flower_customer_rel_id,-->
<!-- wt.tag_id,-->
<!-- wt.`name` as tagName,-->
<!-- (SELECT GROUP_CONCAT(wd.`name`) FROM we_department wd WHERE wd.id=wu.department) as department-->
<!-- FROM-->
<!-- we_customer wc-->
<!-- LEFT JOIN we_flower_customer_rel wfcr ON wc.external_userid=wfcr.external_userid-->
<!-- LEFT JOIN we_user wu ON wu.user_id=wfcr.user_id-->
<!-- LEFT JOIN we_flower_customer_tag_rel wfcrf ON wfcrf.flower_customer_rel_id = wfcr.id-->
<!-- INNER JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id-->
<!-- <where>-->
<!-- <if test="name != null and name !=''">-->
<!-- AND wc.name like concat('%', #{name}, '%')-->
<!-- </if>-->
<!-- <if test="userIds != null and userIds !=''">-->
<!-- <if test="userIds.indexOf(',') != -1">-->
<!-- and wfcr.user_id in-->
<!-- <foreach item="item" index="index" collection="userIds.split(',')" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="userIds.indexOf(',') == -1">-->
<!-- and wfcr.user_id=#{userIds}-->
<!-- </if>-->
<!-- </if>-->
<!-- <if test="tagIds != null and tagIds !=''">-->
<!-- <if test="tagIds.indexOf(',') != -1">-->
<!-- and wt.tag_id in-->
<!-- <foreach item="item" index="index" collection="tagIds.split(',')" open="(" separator="," close=")">-->
<!-- #{item}-->
<!-- </foreach>-->
<!-- </if>-->
<!-- <if test="tagIds.indexOf(',') == -1">-->
<!-- and wt.tag_id=#{tagIds}-->
<!-- </if>-->
<!-- </if>-->
<!-- <if test="beginTime != null and beginTime != ''">&lt;!&ndash; 开始时间检索 &ndash;&gt;-->
<!-- AND date_format(wfcr.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')-->
<!-- </if>-->
<!-- <if test="endTime != null and endTime != ''">&lt;!&ndash; 结束时间检索 &ndash;&gt;-->
<!-- AND date_format(wfcr.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')-->
<!-- </if>-->
<!-- <if test="status != null and status !=''">-->
<!-- AND wfcr.status = #{status}-->
<!-- </if>-->
<!-- </where>-->
</select>
<select id="selectWeCustomerTags" resultMap="weFlowerCustomerRelsMapper">
SELECT
wfcrf.flower_customer_rel_id,
wt.tag_id,
wt.`name` as tagName
FROM
we_flower_customer_tag_rel wfcrf
LEFT JOIN we_tag wt ON wt.tag_id = wfcrf.tag_id
where wfcrf.flower_customer_rel_id=#{id}
</select> </select>
<select id="selectWeCustomerById" parameterType="String" resultMap="WeCustomerResult"> <select id="selectWeCustomerById" parameterType="String" resultMap="WeCustomerResult">
<include refid="selectWeCustomerVo"/> <include refid="selectWeCustomerVo"/>
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!