Commit d61a52e2 by leejoker

Merge remote-tracking branch 'origin/back_end_dev' into back_end_dev

2 parents 740b9259 af1af0f0
package com.linkwechat.web.controller.wecom; package com.linkwechat.web.controller.wecom;
import cn.hutool.core.collection.CollectionUtil;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.core.controller.BaseController; import com.linkwechat.common.core.controller.BaseController;
import com.linkwechat.common.core.domain.AjaxResult; import com.linkwechat.common.core.domain.AjaxResult;
...@@ -7,6 +8,7 @@ import com.linkwechat.common.core.page.TableDataInfo; ...@@ -7,6 +8,7 @@ import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.common.exception.wecom.WeComException; import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import com.linkwechat.common.utils.file.FileUtils;
import com.linkwechat.wecom.domain.WeCommunityNewGroup; import com.linkwechat.wecom.domain.WeCommunityNewGroup;
import com.linkwechat.wecom.domain.WeEmpleCode; import com.linkwechat.wecom.domain.WeEmpleCode;
import com.linkwechat.wecom.domain.dto.WeCommunityNewGroupDto; import com.linkwechat.wecom.domain.dto.WeCommunityNewGroupDto;
...@@ -21,9 +23,17 @@ import org.springframework.stereotype.Controller; ...@@ -21,9 +23,17 @@ import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
/** /**
* 社群运营 新客自动拉群 Controller * 社群运营 新客自动拉群 Controller
...@@ -110,4 +120,72 @@ public class WeCommunityNewGroupController extends BaseController { ...@@ -110,4 +120,72 @@ public class WeCommunityNewGroupController extends BaseController {
} }
/**
* 员工活码批量下载
*
* @param ids 新客自动拉群ids
* @param request 请求
* @param response 输出
* @throws Exception
*/
@ApiOperation(value = "员工活码批量下载",httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:code:downloadBatch')")
@Log(title = "员工活码批量下载", businessType = BusinessType.OTHER)
@GetMapping("/downloadBatch")
public void downloadBatch(String ids, HttpServletRequest request, HttpServletResponse response){
List<String> idList = Arrays.stream(Optional.ofNullable(ids).orElse("").split(","))
.filter(StringUtils::isNotEmpty).collect(Collectors.toList());
try {
List<WeCommunityNewGroupVo> weCommunityNewGroupVos = weCommunityNewGroupService.selectWeCommunityNewGroupByIds(idList);
//zip输出流
ZipOutputStream zos = new ZipOutputStream(response.getOutputStream());
if (CollectionUtil.isNotEmpty(weCommunityNewGroupVos)){
for (WeCommunityNewGroupVo communityNewGroupVo : weCommunityNewGroupVos){
String qrCode = communityNewGroupVo.getQrCode();
if (StringUtils.isEmpty(qrCode)){
continue;
}
URL url = new URL(qrCode);
//每个二维码名称
String fileName =communityNewGroupVo.getEmpleCodeName()+communityNewGroupVo.getActivityScene()+".jpg";
zos.putNextEntry(new ZipEntry(fileName));
InputStream fis = url.openConnection().getInputStream();
byte[] buffer = new byte[1024];
int r = 0;
while ((r = fis.read(buffer)) != -1) {
zos.write(buffer, 0, r);
}
fis.close();
}
}
//关闭zip输出流
zos.flush();
zos.close();
} catch (IOException e) {
e.printStackTrace();
} catch (Exception e){
e.printStackTrace();
}
}
@ApiOperation(value = "员工活码下载",httpMethod = "GET")
@PreAuthorize("@ss.hasPermi('wecom:code:download')")
@Log(title = "员工活码下载", businessType = BusinessType.OTHER)
@GetMapping("/download")
public void download(String id, HttpServletRequest request, HttpServletResponse response){
WeCommunityNewGroupVo communityNewGroupVo=weCommunityNewGroupService.selectWeCommunityNewGroupById(Long.valueOf(id));
if (StringUtils.isEmpty(communityNewGroupVo.getQrCode())){
return;
}else {
try {
FileUtils.downloadFile(communityNewGroupVo.getQrCode(), response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
}
} }
...@@ -38,4 +38,12 @@ public interface WeCommunityNewGroupMapper extends BaseMapper<WeCommunityNewGrou ...@@ -38,4 +38,12 @@ public interface WeCommunityNewGroupMapper extends BaseMapper<WeCommunityNewGrou
*/ */
int batchRemoveWeCommunityNewGroupIds(List<String> idList); int batchRemoveWeCommunityNewGroupIds(List<String> idList);
/**
* 通过id查询新客自动拉群信息列表
*
* @param ids id列表
* @return {@link WeCommunityNewGroup} 新客自动拉群信息
*/
List<WeCommunityNewGroupVo> selectWeCommunityNewGroupByIds(@Param("ids") List<String> ids);
} }
...@@ -33,6 +33,7 @@ public interface IWeCommunityNewGroupService extends IService<WeCommunityNewGrou ...@@ -33,6 +33,7 @@ public interface IWeCommunityNewGroupService extends IService<WeCommunityNewGrou
/** /**
* 获取新客自动拉群详细信息 * 获取新客自动拉群详细信息
*
* @param newGroupId 主键id * @param newGroupId 主键id
* @return {@link WeCommunityNewGroupVo} 自动拉群信息 * @return {@link WeCommunityNewGroupVo} 自动拉群信息
*/ */
...@@ -40,6 +41,7 @@ public interface IWeCommunityNewGroupService extends IService<WeCommunityNewGrou ...@@ -40,6 +41,7 @@ public interface IWeCommunityNewGroupService extends IService<WeCommunityNewGrou
/** /**
* 修改新客自动拉群 * 修改新客自动拉群
*
* @param communityNewGroupDto 信息 * @param communityNewGroupDto 信息
* @return 结果 * @return 结果
*/ */
...@@ -51,5 +53,22 @@ public interface IWeCommunityNewGroupService extends IService<WeCommunityNewGrou ...@@ -51,5 +53,22 @@ public interface IWeCommunityNewGroupService extends IService<WeCommunityNewGrou
* @param idList id列表 * @param idList id列表
* @return * @return
*/ */
int batchRemoveWeCommunityNewGroupIds(List<String> idList); int batchRemoveWeCommunityNewGroupIds(List<String> idList);
/**
* 通过id查询新客自动拉群信息
*
* @param id id
* @return {@link WeCommunityNewGroup} 新客自动拉群信息
*/
WeCommunityNewGroupVo selectWeCommunityNewGroupById(long id);
/**
* 通过id查询新客自动拉群信息列表
*
* @param ids id列表
* @return {@link WeCommunityNewGroup} 新客自动拉群信息
*/
List<WeCommunityNewGroupVo> selectWeCommunityNewGroupByIds(List<String> ids);
} }
...@@ -32,7 +32,7 @@ import java.util.stream.Collectors; ...@@ -32,7 +32,7 @@ import java.util.stream.Collectors;
*/ */
@Service @Service
@Slf4j @Slf4j
public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewGroupMapper, WeCommunityNewGroup> implements IWeCommunityNewGroupService { public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewGroupMapper, WeCommunityNewGroup> implements IWeCommunityNewGroupService {
@Autowired @Autowired
private WeGroupCodeMapper weGroupCodeMapper; private WeGroupCodeMapper weGroupCodeMapper;
...@@ -61,7 +61,7 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG ...@@ -61,7 +61,7 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG
//检查群活码是否存在 //检查群活码是否存在
WeGroupCode weGroupCode = weGroupCodeMapper.selectWeGroupCodeById(communityNewGroupDto.getGroupCodeId()); WeGroupCode weGroupCode = weGroupCodeMapper.selectWeGroupCodeById(communityNewGroupDto.getGroupCodeId());
if(null!=weGroupCode){ if (null != weGroupCode) {
throw new WeComException("群活码不存在!"); throw new WeComException("群活码不存在!");
} }
WeEmpleCode weEmpleCode = getWeEmpleCode(communityNewGroupDto); WeEmpleCode weEmpleCode = getWeEmpleCode(communityNewGroupDto);
...@@ -71,7 +71,7 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG ...@@ -71,7 +71,7 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG
WeExternalContactDto qrCode = weEmpleCodeService.getQrCode(weContactWay); WeExternalContactDto qrCode = weEmpleCodeService.getQrCode(weContactWay);
//保存新客自动拉群信息 //保存新客自动拉群信息
WeCommunityNewGroup communityNewGroup=new WeCommunityNewGroup(); WeCommunityNewGroup communityNewGroup = new WeCommunityNewGroup();
communityNewGroup.setNewGroupId(weGroupCode.getId()); communityNewGroup.setNewGroupId(weGroupCode.getId());
communityNewGroup.setEmpleCodeName(communityNewGroupDto.getActivityScene()); communityNewGroup.setEmpleCodeName(communityNewGroupDto.getActivityScene());
communityNewGroup.setDelFlag(0); communityNewGroup.setDelFlag(0);
...@@ -117,7 +117,7 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG ...@@ -117,7 +117,7 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG
@Override @Override
public List<WeCommunityNewGroupVo> selectWeCommunityNewGroupList(WeCommunityNewGroup communityNewGroup) { public List<WeCommunityNewGroupVo> selectWeCommunityNewGroupList(WeCommunityNewGroup communityNewGroup) {
List<WeCommunityNewGroupVo> weCommunityNewGroupVos = weCommunityNewGroupMapper.selectWeCommunityNewGroupList(communityNewGroup); List<WeCommunityNewGroupVo> weCommunityNewGroupVos = weCommunityNewGroupMapper.selectWeCommunityNewGroupList(communityNewGroup);
if(CollectionUtil.isNotEmpty(weCommunityNewGroupVos)){ if (CollectionUtil.isNotEmpty(weCommunityNewGroupVos)) {
List<Long> newGroupIdList = weCommunityNewGroupVos.stream().map(WeCommunityNewGroupVo::getNewGroupId).collect(Collectors.toList()); List<Long> newGroupIdList = weCommunityNewGroupVos.stream().map(WeCommunityNewGroupVo::getNewGroupId).collect(Collectors.toList());
List<WeEmpleCodeUseScop> useScopList = iWeEmpleCodeUseScopService.selectWeEmpleCodeUseScopListByIds(newGroupIdList); List<WeEmpleCodeUseScop> useScopList = iWeEmpleCodeUseScopService.selectWeEmpleCodeUseScopListByIds(newGroupIdList);
List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.selectWeEmpleCodeTagListByIds(newGroupIdList); List<WeEmpleCodeTag> tagList = weEmpleCodeTagService.selectWeEmpleCodeTagListByIds(newGroupIdList);
...@@ -139,7 +139,7 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG ...@@ -139,7 +139,7 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG
@Override @Override
public WeCommunityNewGroupVo selectWeCommunityNewGroupById(Long newGroupId) { public WeCommunityNewGroupVo selectWeCommunityNewGroupById(Long newGroupId) {
WeCommunityNewGroupVo weCommunityNewGroupVo = weCommunityNewGroupMapper.selectWeCommunityNewGroupById(newGroupId); WeCommunityNewGroupVo weCommunityNewGroupVo = weCommunityNewGroupMapper.selectWeCommunityNewGroupById(newGroupId);
if(null!=weCommunityNewGroupVo){ if (null != weCommunityNewGroupVo) {
List<WeGroupCodeActual> weGroupCodeActuals = getWeGroupCodeActuals(weCommunityNewGroupVo); List<WeGroupCodeActual> weGroupCodeActuals = getWeGroupCodeActuals(weCommunityNewGroupVo);
weCommunityNewGroupVo.setWeGroupUserScops(weGroupCodeActuals); weCommunityNewGroupVo.setWeGroupUserScops(weGroupCodeActuals);
List<WeEmpleCodeUseScop> useScopList = iWeEmpleCodeUseScopService.selectWeEmpleCodeUseScopListByIds(Lists.newArrayList(weCommunityNewGroupVo.getNewGroupId())); List<WeEmpleCodeUseScop> useScopList = iWeEmpleCodeUseScopService.selectWeEmpleCodeUseScopListByIds(Lists.newArrayList(weCommunityNewGroupVo.getNewGroupId()));
...@@ -166,13 +166,13 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG ...@@ -166,13 +166,13 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG
//检查群活码是否存在 //检查群活码是否存在
WeGroupCode weGroupCode = weGroupCodeMapper.selectWeGroupCodeById(communityNewGroupDto.getGroupCodeId()); WeGroupCode weGroupCode = weGroupCodeMapper.selectWeGroupCodeById(communityNewGroupDto.getGroupCodeId());
if(null!=weGroupCode){ if (null != weGroupCode) {
throw new WeComException("群活码不存在!"); throw new WeComException("群活码不存在!");
} }
//查询新客自动拉群信息 //查询新客自动拉群信息
WeCommunityNewGroup communityNewGroup = weCommunityNewGroupMapper.selectById(communityNewGroupDto.getGroupCodeId()); WeCommunityNewGroup communityNewGroup = weCommunityNewGroupMapper.selectById(communityNewGroupDto.getGroupCodeId());
if(null!=communityNewGroup){ if (null != communityNewGroup) {
throw new WeComException("信息不存在!"); throw new WeComException("信息不存在!");
} }
...@@ -216,4 +216,13 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG ...@@ -216,4 +216,13 @@ public class WeCommunityNewGroupServiceImpl extends ServiceImpl<WeCommunityNewG
return weCommunityNewGroupMapper.batchRemoveWeCommunityNewGroupIds(idList); return weCommunityNewGroupMapper.batchRemoveWeCommunityNewGroupIds(idList);
} }
@Override
public WeCommunityNewGroupVo selectWeCommunityNewGroupById(long id) {
return weCommunityNewGroupMapper.selectWeCommunityNewGroupById(id);
}
@Override
public List<WeCommunityNewGroupVo> selectWeCommunityNewGroupByIds(List<String> ids) {
return weCommunityNewGroupMapper.selectWeCommunityNewGroupByIds(ids);
}
} }
...@@ -5,23 +5,21 @@ ...@@ -5,23 +5,21 @@
<mapper namespace="com.linkwechat.wecom.mapper.WeCommunityNewGroupMapper"> <mapper namespace="com.linkwechat.wecom.mapper.WeCommunityNewGroupMapper">
<sql id="selectSql"> <sql id="selectSql">
SELECT SELECT new_group_id,
new_group_id, emple_code_name,
emple_code_name, group_code_id,
group_code_id, create_by,
create_by, create_time,
create_time, update_by,
update_by, update_time,
update_time, del_flag,
del_flag, activity_scene,
activity_scene, welcome_msg,
welcome_msg, qr_code,
qr_code, is_join_confirm_friends,
is_join_confirm_friends, media_id,
media_id, join_friend_nums
join_friend_nums FROM we_community_new_group
FROM
we_community_new_group
</sql> </sql>
<update id="batchRemoveWeCommunityNewGroupIds"> <update id="batchRemoveWeCommunityNewGroupIds">
update we_community_new_group set update we_community_new_group set
...@@ -29,29 +27,29 @@ ...@@ -29,29 +27,29 @@
where new_group_id in where new_group_id in
<foreach collection="ids" item="id" index="index" <foreach collection="ids" item="id" index="index"
separator="," open="(" close=")"> separator="," open="(" close=")">
#{newGroupId} #{id}
</foreach> </foreach>
</update> </update>
<select id="selectWeCommunityNewGroupList" <select id="selectWeCommunityNewGroupList"
resultType="com.linkwechat.wecom.domain.vo.WeCommunityNewGroupVo"> resultType="com.linkwechat.wecom.domain.vo.WeCommunityNewGroupVo">
<include refid="selectSql"/> <include refid="selectSql"/>
<where> <where>
del_flag = 0 del_flag = 0
<if test="empleCodeName!=null and empleCodeName!=''"> <if test="empleCodeName!=null and empleCodeName!=''">
AND emple_code_name LIKE CONCAT("%",#{empleCodeName},"%") AND emple_code_name LIKE CONCAT("%",#{empleCodeName},"%")
</if> </if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 --> <if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d') AND date_format(create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if> </if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 --> <if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d') AND date_format(create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if> </if>
<if test="createBy!=null and createBy!=''"> <if test="createBy!=null and createBy!=''">
AND create_by LIKE CONCAT("%",#{createBy},"%") AND create_by LIKE CONCAT("%",#{createBy},"%")
</if> </if>
</where> </where>
</select> </select>
<select id="selectWeCommunityNewGroupById" <select id="selectWeCommunityNewGroupById"
...@@ -62,4 +60,15 @@ ...@@ -62,4 +60,15 @@
</where> </where>
</select> </select>
<select id="selectWeCommunityNewGroupByIds" resultType="com.linkwechat.wecom.domain.vo.WeCommunityNewGroupVo">
<include refid="selectSql"/>
<where>
new_group_id in
<foreach collection="ids" item="id" index="index"
separator="," open="(" close=")">
#{id}
</foreach>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!