修复朋友圈等bug

1 parent 361cda45
Showing 22 changed files with 425 additions and 16 deletions
...@@ -74,7 +74,7 @@ public class WeMomentsController extends BaseController { ...@@ -74,7 +74,7 @@ public class WeMomentsController extends BaseController {
* @return * @return
*/ */
@PostMapping("/addOrUpdate") @PostMapping("/addOrUpdate")
public AjaxResult addOrUpdate(@RequestBody WeMoments weMoments){ public AjaxResult addOrUpdate(@RequestBody WeMoments weMoments) throws InterruptedException {
iWeMomentsService.addOrUpdateMoments(weMoments); iWeMomentsService.addOrUpdateMoments(weMoments);
......
...@@ -276,6 +276,21 @@ ...@@ -276,6 +276,21 @@
<artifactId>spring-test</artifactId> <artifactId>spring-test</artifactId>
</dependency> </dependency>
<!-- mp3文件支持(如语音时长)-->
<dependency>
<groupId>org</groupId>
<artifactId>jaudiotagger</artifactId>
<version>2.0.1</version>
</dependency>
<!-- mp4文件支持(如语音时长)-->
<dependency>
<groupId>com.googlecode.mp4parser</groupId>
<artifactId>isoparser</artifactId>
<version>1.1.22</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -4,6 +4,7 @@ import java.lang.management.ManagementFactory; ...@@ -4,6 +4,7 @@ import java.lang.management.ManagementFactory;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar; import java.util.Calendar;
...@@ -398,7 +399,22 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils ...@@ -398,7 +399,22 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils
public static String getBeforeByDayTime(int day){ public static String getBeforeByDayTime(int day){
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
now = now.minus(-day, ChronoUnit.DAYS); now = now.minus(-day, ChronoUnit.DAYS);
return now.toString(); return now.toString();
} }
/**
* 当前时间向推N天
* 获取时间戳
* @param day 小时
* @return String
*/
public static Long getBeforeByDayLongTime(int day){
LocalDateTime now = LocalDateTime.now();
now = now.minus(-day, ChronoUnit.DAYS);
return now.toEpochSecond(ZoneOffset.of("+8"));
}
} }
package com.linkwechat.common.utils.file;
import org.jaudiotagger.audio.AudioFileIO;
import org.jaudiotagger.audio.mp3.MP3AudioHeader;
import org.jaudiotagger.audio.mp3.MP3File;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import java.io.File;
public class AudioUtil {
/**
* 获取语音文件播放时长(秒) 支持wav 格式
* @param filePath
* @return
*/
public static Float getDuration(String filePath){
try{
File destFile = new File(filePath);
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(destFile);
AudioFormat format = audioInputStream.getFormat();
long audioFileLength = destFile.length();
int frameSize = format.getFrameSize();
float frameRate = format.getFrameRate();
float durationInSeconds = (audioFileLength / (frameSize * frameRate));
return durationInSeconds;
}catch (Exception e){
e.printStackTrace();
return 0f;
}
}
/**
* 获取mp3语音文件播放时长(秒) mp3
* @param filePath
* @return
*/
public static Float getMp3Duration(String filePath){
try {
File mp3File = new File(filePath);
MP3File f = (MP3File) AudioFileIO.read(mp3File);
MP3AudioHeader audioHeader = (MP3AudioHeader)f.getAudioHeader();
return Float.parseFloat(audioHeader.getTrackLength()+"");
} catch(Exception e) {
e.printStackTrace();
return 0f;
}
}
/**
* 获取mp3语音文件播放时长(秒)
* @param mp3File
* @return
*/
public static Float getMp3Duration(File mp3File){
try {
//File mp3File = new File(filePath);
MP3File f = (MP3File) AudioFileIO.read(mp3File);
MP3AudioHeader audioHeader = (MP3AudioHeader)f.getAudioHeader();
return Float.parseFloat(audioHeader.getTrackLength()+"");
} catch(Exception e) {
e.printStackTrace();
return 0f;
}
}
/**
* 得到pcm文件的毫秒数
*
* pcm文件音频时长计算
* 同图像bmp文件一样,pcm文件保存的是未压缩的音频信息。 16bits 编码是指,每次采样的音频信息用2个字节保存。可以对比下bmp文件用分别用2个字节保存RGB颜色的信息。 16000采样率 是指 1秒钟采样 16000次。常见的音频是44100HZ,即一秒采样44100次。 单声道: 只有一个声道。
*
* 根据这些信息,我们可以计算: 1秒的16000采样率音频文件大小是 2*16000 = 32000字节 ,约为32K 1秒的8000采样率音频文件大小是 2*8000 = 16000字节 ,约为 16K
*
* 如果已知录音时长,可以根据文件的大小计算采样率是否正常。
* @param filePath
* @return
*/
public static long getPCMDurationMilliSecond(String filePath) {
File file = new File(filePath);
//得到多少秒
long second = file.length() / 32000 ;
long milliSecond = Math.round((file.length() % 32000) / 32000.0 * 1000 ) ;
return second * 1000 + milliSecond;
}
}
...@@ -212,6 +212,7 @@ public class FileUploadUtils { ...@@ -212,6 +212,7 @@ public class FileUploadUtils {
// 指定要上传到 COS 上对象键 // 指定要上传到 COS 上对象键
ObjectMetadata objectMetadata = new ObjectMetadata(); ObjectMetadata objectMetadata = new ObjectMetadata();
InputStream inputStream = file.getInputStream();
PutObjectRequest putObjectRequest = new PutObjectRequest(cosConfig.getBucketName(), fileName,file.getInputStream(),objectMetadata); PutObjectRequest putObjectRequest = new PutObjectRequest(cosConfig.getBucketName(), fileName,file.getInputStream(),objectMetadata);
PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest); PutObjectResult putObjectResult = cosClient.putObject(putObjectRequest);
log.info("{}",cosConfig.getCosImgUrlPrefix()+fileName); log.info("{}",cosConfig.getCosImgUrlPrefix()+fileName);
......
package com.linkwechat.common.utils.file; package com.linkwechat.common.utils.file;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import java.io.*; import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
...@@ -241,4 +242,47 @@ public class FileUtils extends org.apache.commons.io.FileUtils ...@@ -241,4 +242,47 @@ public class FileUtils extends org.apache.commons.io.FileUtils
} }
return filename; return filename;
} }
/**
* MultipartFile 转化为file
* @param multiFile
* @return
*/
public static File MultipartFileToFile(MultipartFile multiFile) {
// 获取文件名
String fileName = multiFile.getOriginalFilename();
// 获取文件后缀
String prefix = fileName.substring(fileName.lastIndexOf("."));
// 若需要防止生成的临时文件重复,可以在文件名后添加随机码
try {
File file = File.createTempFile(fileName, prefix);
multiFile.transferTo(file);
return file;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 获取视频或者语音时长
* @param multiFile
* @return
* @throws IOException
*/
public static long getVideoOrVoice(MultipartFile multiFile) throws IOException {
long duration_new =0;
// 将MultipartFile file转换成为File
File f_file = MultipartFileToFile(multiFile);
String path = f_file.getCanonicalPath();
duration_new = VideoUtil.getDuration(path);
f_file.delete();
return duration_new;
}
} }
package com.linkwechat.common.utils.file;
import com.coremedia.iso.IsoFile;
import java.io.IOException;
class VideoUtil{
/**
* 获取视频文件的播放长度(mp4、mov格式)
* @param videoPath
* @return 单位为毫秒
*/
public static long getMp4Duration(String videoPath) throws IOException {
IsoFile isoFile = new IsoFile(videoPath);
long lengthInSeconds =
isoFile.getMovieBox().getMovieHeaderBox().getDuration() /
isoFile.getMovieBox().getMovieHeaderBox().getTimescale();
return lengthInSeconds;
}
/**
* 得到语音或视频文件时长,单位秒
* @param filePath
* @return
* @throws IOException
*/
public static long getDuration(String filePath) throws IOException {
String format = getVideoFormat(filePath);
long result = 0;
if("wav".equals(format)){
result = AudioUtil.getDuration(filePath).intValue();
}else if("mp3".equals(format)){
result = AudioUtil.getMp3Duration(filePath).intValue();
}else if("m4a".equals(format)) {
result = VideoUtil.getMp4Duration(filePath);
}else if("mov".equals(format)){
result = VideoUtil.getMp4Duration(filePath);
}else if("mp4".equals(format)){
result = VideoUtil.getMp4Duration(filePath);
}
return result;
}
/**
* 得到语音或视频文件时长,单位秒
* @param filePath
* @return
* @throws IOException
*/
public static long getDuration(String filePath,String format) throws IOException {
long result = 0;
if("wav".equals(format)){
result = AudioUtil.getDuration(filePath).intValue();
}else if("mp3".equals(format)){
result = AudioUtil.getMp3Duration(filePath).intValue();
}else if("m4a".equals(format)) {
result = VideoUtil.getMp4Duration(filePath);
}else if("mov".equals(format)){
result = VideoUtil.getMp4Duration(filePath);
}else if("mp4".equals(format)){
result = VideoUtil.getMp4Duration(filePath);
}
return result;
}
/**
* 得到文件格式
* @param path
* @return
*/
public static String getVideoFormat(String path){
return path.toLowerCase().substring(path.toLowerCase().lastIndexOf(".") + 1);
}
}
package com.linkwechat.common.utils.img; package com.linkwechat.common.utils.img;
import com.qcloud.cos.utils.IOUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItem;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import javax.swing.*; import javax.swing.*;
...@@ -8,14 +15,17 @@ import java.awt.*; ...@@ -8,14 +15,17 @@ import java.awt.*;
import java.awt.image.BufferedImage; import java.awt.image.BufferedImage;
import java.io.*; import java.io.*;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URL;
import java.nio.ByteBuffer; import java.nio.ByteBuffer;
import java.nio.channels.FileChannel; import java.nio.channels.FileChannel;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Random; import java.util.Random;
import java.util.stream.Stream; import java.util.stream.Stream;
@Slf4j
public class ImageUtils { public class ImageUtils {
private final static JLabel J_LABEL = new JLabel(); private final static JLabel J_LABEL = new JLabel();
...@@ -677,5 +687,92 @@ public class ImageUtils { ...@@ -677,5 +687,92 @@ public class ImageUtils {
this.value = value; this.value = value;
} }
} }
/**
* 根据url 拉取文件
* @param url
* @return
* @throws Exception
*/
public static File getFile(String url) throws Exception {
//对本地文件命名
String fileName = url.substring(url.lastIndexOf("."),url.length());
File file = null;
URL urlfile;
InputStream inStream = null;
OutputStream os = null;
try {
file = File.createTempFile("fwj_url", fileName);
//下载
urlfile = new URL(url);
inStream = urlfile.openStream();
os = new FileOutputStream(file);
int bytesRead = 0;
byte[] buffer = new byte[8192];
while ((bytesRead = inStream.read(buffer, 0, 8192)) != -1) {
os.write(buffer, 0, bytesRead);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (null != os) {
os.close();
}
if (null != inStream) {
inStream.close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
return file;
}
/**
* 根据url获取图片并转换为multipartFile类型
* @param url
* @return
*/
public static MultipartFile getMultipartFile(String url) {
FileInputStream inputStream = null;
OutputStream outputStream = null;
try {
File file = getFile(url);
System.out.println(file.toPath());
FileItem fileItem = new DiskFileItem("formFieldName",//form表单文件控件的名字随便起
Files.probeContentType(file.toPath()),//文件类型
false, //是否是表单字段
file.getName(),//原始文件名
(int) file.length(),//Interger的最大值可以存储两部1G的电影
file.getParentFile());//文件会在哪个目录创建
//为DiskFileItem的OutputStream赋值
inputStream = new FileInputStream(file);
outputStream = fileItem.getOutputStream();
IOUtils.copy(inputStream, outputStream);
return new CommonsMultipartFile(fileItem);
} catch (Exception e) {
log.error("文件类型转换失败" + e.getMessage());
return null;
} finally {
try {
if (null != inputStream) {
inputStream.close();
}
if (null != outputStream) {
outputStream.close();
}
} catch (IOException e) {
log.error(">>文件流关闭失败" + e.getMessage());
}
}
}
} }
...@@ -64,4 +64,10 @@ public class SysFile ...@@ -64,4 +64,10 @@ public class SysFile
private String imgUrlPrefix; private String imgUrlPrefix;
/**
* 语音或者视频时长
*/
private Long timeLong;
} }
...@@ -3,6 +3,7 @@ package com.linkwechat.framework.web.service; ...@@ -3,6 +3,7 @@ package com.linkwechat.framework.web.service;
import com.linkwechat.common.annotation.Log; import com.linkwechat.common.annotation.Log;
import com.linkwechat.common.config.RuoYiConfig; import com.linkwechat.common.config.RuoYiConfig;
import com.linkwechat.common.exception.file.InvalidExtensionException;
import com.linkwechat.common.utils.OsUtils; import com.linkwechat.common.utils.OsUtils;
import com.linkwechat.common.utils.file.FileUploadUtils; import com.linkwechat.common.utils.file.FileUploadUtils;
import com.linkwechat.common.utils.file.FileUtils; import com.linkwechat.common.utils.file.FileUtils;
...@@ -43,7 +44,7 @@ public class FileService { ...@@ -43,7 +44,7 @@ public class FileService {
* @return * @return
* @throws IOException * @throws IOException
*/ */
public SysFile upload(MultipartFile file) throws Exception { public SysFile upload(MultipartFile file) throws IOException, InvalidExtensionException {
try { try {
FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION); FileUploadUtils.assertAllowed(file, MimeTypeUtils.DEFAULT_ALLOWED_EXTENSION);
...@@ -61,9 +62,15 @@ public class FileService { ...@@ -61,9 +62,15 @@ public class FileService {
fileName = FileUploadUtils.upload(osFile.getPath(), file); fileName = FileUploadUtils.upload(osFile.getPath(), file);
imgUrlPrefix = ruoYiConfig.getFile().getImgUrlPrefix(); imgUrlPrefix = ruoYiConfig.getFile().getImgUrlPrefix();
} }
return SysFile.builder() return SysFile.builder()
.fileName(fileName) .fileName(fileName)
.imgUrlPrefix(imgUrlPrefix) .imgUrlPrefix(imgUrlPrefix)
// .timeLong(
// FileUploadUtils.isAllowedExtension(FileUploadUtils.getExtension(file),
// MimeTypeUtils.MEDIA_EXTENSION
// )?FileUtils.getVideoOrVoice(file):new Long(0)
// )
.build(); .build();
}catch (Exception e){ }catch (Exception e){
......
package com.linkwechat.wecom.client; package com.linkwechat.wecom.client;
import com.dtflys.forest.annotation.*; import com.dtflys.forest.annotation.*;
import com.linkwechat.wecom.domain.dto.GroupWelcomeTplDto;
import com.linkwechat.wecom.domain.dto.WeResultDto;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupDetail; import com.linkwechat.wecom.domain.dto.customer.CustomerGroupDetail;
import com.linkwechat.wecom.domain.dto.customer.CustomerGroupList; import com.linkwechat.wecom.domain.dto.customer.CustomerGroupList;
import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor; import com.linkwechat.wecom.interceptor.WeAccessTokenInterceptor;
...@@ -36,4 +38,22 @@ public interface WeCustomerGroupClient { ...@@ -36,4 +38,22 @@ public interface WeCustomerGroupClient {
type = "POST" type = "POST"
) )
CustomerGroupDetail groupChatDetail(@JSONBody CustomerGroupDetail.Params params); CustomerGroupDetail groupChatDetail(@JSONBody CustomerGroupDetail.Params params);
/**
* 添加入群欢迎语模版
* @param groupWelcomeTplDto
* @return
*/
@Post(url = "/externalcontact/group_welcome_template/add")
GroupWelcomeTplDto addGroupWelcomeTpl(@JSONBody GroupWelcomeTplDto groupWelcomeTplDto);
/**
* 编辑入群欢迎语模版
* @param groupWelcomeTplDto
* @return
*/
@Post(url = "/externalcontact/group_welcome_template/edit")
WeResultDto updateGroupWelcomeTpl(@JSONBody GroupWelcomeTplDto groupWelcomeTplDto);
} }
\ No newline at end of file \ No newline at end of file
...@@ -12,6 +12,7 @@ import lombok.Data; ...@@ -12,6 +12,7 @@ import lombok.Data;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.experimental.SuperBuilder; import lombok.experimental.SuperBuilder;
import java.util.Date;
import java.util.List; import java.util.List;
/** /**
...@@ -63,13 +64,18 @@ public class WeMoments extends BaseEntity { ...@@ -63,13 +64,18 @@ public class WeMoments extends BaseEntity {
@TableLogic @TableLogic
private Integer delFlag; private Integer delFlag;
/**异步任务id,最大长度为64字节,24小时有效;可使用获取发表朋友圈任务结果查询任务状态*/
private String jobId; /**是否是在lw平台发布的:1:是;0:否; */
private Boolean isLwPush;
@TableId @TableId
private String momentId; private String momentId;
//发布时间
private Date pushTime;
/**评论数*/ /**评论数*/
@TableField(exist = false) @TableField(exist = false)
private Integer commentNum; private Integer commentNum;
...@@ -98,13 +104,16 @@ public class WeMoments extends BaseEntity { ...@@ -98,13 +104,16 @@ public class WeMoments extends BaseEntity {
@Data @Data
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public static class OtherContent{ public static class OtherContent{
//附件类型:1:image 2:video 3:link //附件类型:1:image 2:video 3:link 4:text
private String annexType; private String annexType;
//资源url //资源url
...@@ -113,7 +122,7 @@ public class WeMoments extends BaseEntity { ...@@ -113,7 +122,7 @@ public class WeMoments extends BaseEntity {
//资源id //资源id
// private String annexMediaid; // private String annexMediaid;
//如视频封面,图文标题 //如视频封面,图文标题,文字内容
private String other; private String other;
} }
......
package com.linkwechat.wecom.domain; import com.baomidou.mybatisplus.annotation.TableField;import com.baomidou.mybatisplus.annotation.TableId;import com.baomidou.mybatisplus.annotation.TableLogic;import com.baomidou.mybatisplus.annotation.TableName;import com.linkwechat.common.core.domain.BaseEntity;import com.linkwechat.common.utils.SnowFlakeUtil;import com.linkwechat.wecom.handler.GenericTypeHandler;import io.swagger.models.auth.In;import lombok.Data; import java.util.List; /** * 欢迎语模板对象 we_msg_tlp * * @author ruoyi * @date 2020-10-04 */@Data@TableName(value = "we_msg_tlp",autoResultMap = true)public class WeMsgTlp extends BaseEntity{ private static final long serialVersionUID = 1L; /** $column.columnComment */ @TableId private Long id; /** 欢迎语 */ private String welcomeMsg; /**图片url*/ private String picUrl; /**图文*/ @TableField(typeHandler = GenericTypeHandler.class) private List<ImageText> imageText; /**小程序*/ @TableField(typeHandler = GenericTypeHandler.class) private List<Applet> applet; /** 0:正常;1:删除; */ @TableLogic private Integer delFlag; /** 欢迎语模板类型:1:活码欢迎语;2:员工欢迎语;3:入群欢迎语 */ private Integer welcomeMsgTplType; /**用户名 */ private String userNames; /**用户id,用逗号隔开*/ private String userIds; @Data public static class Applet{ //小程序标题 private String appTile; //小程序id private String appId; //小程序路径 private String appPath; //小程序图片 private String appPic; } @Data public static class ImageText{ //图文标题 private String imageTextTile; //图文url private String imageTextUrl; } }
\ No newline at end of file \ No newline at end of file
package com.linkwechat.wecom.domain; import com.baomidou.mybatisplus.annotation.TableField;import com.baomidou.mybatisplus.annotation.TableId;import com.baomidou.mybatisplus.annotation.TableLogic;import com.baomidou.mybatisplus.annotation.TableName;import com.linkwechat.common.core.domain.BaseEntity;import com.linkwechat.common.utils.SnowFlakeUtil;import com.linkwechat.wecom.handler.GenericTypeHandler;import io.swagger.models.auth.In;import lombok.Data; import java.util.List; /** * 欢迎语模板对象 we_msg_tlp * * @author ruoyi * @date 2020-10-04 */@Data@TableName(value = "we_msg_tlp",autoResultMap = true)public class WeMsgTlp extends BaseEntity{ private static final long serialVersionUID = 1L; /** $column.columnComment */ @TableId private Long id; /** 欢迎语 */ private String welcomeMsg; /**图片url*/ private String picUrl; /**图文*/ @TableField(typeHandler = GenericTypeHandler.class) private List<ImageText> imageText; /**小程序*/ @TableField(typeHandler = GenericTypeHandler.class) private List<Applet> applet; /** 0:正常;1:删除; */ @TableLogic private Integer delFlag; /** 欢迎语模板类型:1:活码欢迎语;2:员工欢迎语;3:入群欢迎语 */ private Integer welcomeMsgTplType; /**用户名 */ private String userNames; /**用户id,用逗号隔开*/ private String userIds; /**群欢迎语模版id*/ private String templateId; @Data public static class Applet{ //小程序标题 private String appTile; //小程序id private String appId; //小程序路径 private String appPath; //小程序图片 private String appPic; } @Data public static class ImageText{ //图文标题 private String imageTextTile; //图文url private String imageTextUrl; } }
\ No newline at end of file \ No newline at end of file
......
...@@ -38,7 +38,7 @@ public class WeCropGroupTagDto { ...@@ -38,7 +38,7 @@ public class WeCropGroupTagDto {
*/ */
public static WeCropGroupTagDto transformAddTag(WeTagGroup weTagGroup){ public static WeCropGroupTagDto transformAddTag(WeTagGroup weTagGroup){
WeCropGroupTagDto weCropGroupTagDto=WeCropGroupTagDto.builder() WeCropGroupTagDto weCropGroupTagDto=WeCropGroupTagDto.builder()
.group_id(weTagGroup.getGroupId()) // .group_id(weTagGroup.getGroupId())
.group_name(weTagGroup.getGourpName()) .group_name(weTagGroup.getGourpName())
.build(); .build();
List<WeTag> newAddWeTag = weTagGroup.getAddWeTags(); List<WeTag> newAddWeTag = weTagGroup.getAddWeTags();
......
...@@ -11,4 +11,6 @@ public interface WeMomentsMapper extends BaseMapper<WeMoments> { ...@@ -11,4 +11,6 @@ public interface WeMomentsMapper extends BaseMapper<WeMoments> {
List<WeMoments> findMoments(WeMoments weMoments); List<WeMoments> findMoments(WeMoments weMoments);
WeMoments findMomentsDetail(@Param("momentId") String momentId); WeMoments findMomentsDetail(@Param("momentId") String momentId);
void removePushLwPush();
} }
...@@ -11,7 +11,7 @@ public interface IWeMomentsService extends IService<WeMoments> { ...@@ -11,7 +11,7 @@ public interface IWeMomentsService extends IService<WeMoments> {
List<WeMoments> findMoments(WeMoments weMoments); List<WeMoments> findMoments(WeMoments weMoments);
void addOrUpdateMoments(WeMoments weMoments); void addOrUpdateMoments(WeMoments weMoments) throws InterruptedException;
void synchPersonMoments(Integer filterType); void synchPersonMoments(Integer filterType);
......
...@@ -514,7 +514,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -514,7 +514,6 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void getCustomersInfoAndSynchWeCustomer(String externalUserid,String userId) { public void getCustomersInfoAndSynchWeCustomer(String externalUserid,String userId) {
//获取指定客户的详情 //获取指定客户的详情
ExternalUserDetail externalUserDetail = weCustomerClient.get(externalUserid); ExternalUserDetail externalUserDetail = weCustomerClient.get(externalUserid);
...@@ -524,6 +523,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto ...@@ -524,6 +523,7 @@ public class WeCustomerServiceImpl extends ServiceImpl<WeCustomerMapper, WeCusto
BeanUtils.copyPropertiesASM(externalUserDetail.getExternal_contact(), weCustomer); BeanUtils.copyPropertiesASM(externalUserDetail.getExternal_contact(), weCustomer);
weCustomer.setFirstUserId(userId); weCustomer.setFirstUserId(userId);
weCustomer.setCustomerName(externalUserDetail.getExternal_contact().getName()); weCustomer.setCustomerName(externalUserDetail.getExternal_contact().getName());
weCustomer.setCustomerType(externalUserDetail.getExternal_contact().getType());
List<ExternalUserDetail.FollowUser> follow_user = externalUserDetail.getFollow_user(); List<ExternalUserDetail.FollowUser> follow_user = externalUserDetail.getFollow_user();
if(CollectionUtil.isNotEmpty(follow_user)){ if(CollectionUtil.isNotEmpty(follow_user)){
ExternalUserDetail.FollowUser followUser = follow_user.stream().filter(e -> e.getUserid().equals(userId)).findFirst().get(); ExternalUserDetail.FollowUser followUser = follow_user.stream().filter(e -> e.getUserid().equals(userId)).findFirst().get();
......
package com.linkwechat.wecom.service.impl; import java.util.List;import java.util.stream.Collectors; import cn.hutool.core.collection.CollectionUtil;import cn.hutool.core.collection.ListUtil;import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;import com.linkwechat.common.utils.StringUtils;import com.linkwechat.wecom.domain.WeUser;import com.linkwechat.wecom.service.IWeUserService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import com.linkwechat.wecom.mapper.WeMsgTlpMapper;import com.linkwechat.wecom.domain.WeMsgTlp;import com.linkwechat.wecom.service.IWeMsgTlpService;import org.springframework.transaction.annotation.Transactional; /** * 欢迎语模板Service业务层处理 * * @author ruoyi * @date 2020-10-04 */@Servicepublic class WeMsgTlpServiceImpl extends ServiceImpl<WeMsgTlpMapper,WeMsgTlp> implements IWeMsgTlpService{ @Autowired private IWeUserService iWeUserService; /** * 新增欢迎语模板 * * @param weMsgTlp 欢迎语模板 * @return 结果 */ @Override @Transactional public void addorUpdate(WeMsgTlp weMsgTlp) { if(weMsgTlp.getWelcomeMsgTplType() .equals(new Integer(2))) { String userIds = weMsgTlp.getUserIds(); if (StringUtils.isNotEmpty(userIds)) { List<WeUser> weUsers = iWeUserService.listByIds( ListUtil.toList(userIds.split(",")) ); if (CollectionUtil.isNotEmpty(weUsers)) { weMsgTlp.setUserNames(String.join(",", weUsers.stream().map(WeUser::getName).collect(Collectors.toList()))); } } } this.saveOrUpdate(weMsgTlp); } }
\ No newline at end of file \ No newline at end of file
package com.linkwechat.wecom.service.impl; import java.util.List;import java.util.stream.Collectors; import cn.hutool.core.collection.CollectionUtil;import cn.hutool.core.collection.ListUtil;import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;import com.linkwechat.common.constant.WeConstans;import com.linkwechat.common.enums.MediaType;import com.linkwechat.common.utils.StringUtils;import com.linkwechat.common.utils.img.ImageUtils;import com.linkwechat.wecom.client.WeCustomerGroupClient;import com.linkwechat.wecom.client.WeMediaClient;import com.linkwechat.wecom.domain.WeUser;import com.linkwechat.wecom.domain.dto.GroupWelcomeTplDto;import com.linkwechat.wecom.domain.dto.WeMediaDto;import com.linkwechat.wecom.service.IWeMaterialService;import com.linkwechat.wecom.service.IWeUserService;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import com.linkwechat.wecom.mapper.WeMsgTlpMapper;import com.linkwechat.wecom.domain.WeMsgTlp;import com.linkwechat.wecom.service.IWeMsgTlpService;import org.springframework.transaction.annotation.Transactional; /** * 欢迎语模板Service业务层处理 * * @author ruoyi * @date 2020-10-04 */@Servicepublic class WeMsgTlpServiceImpl extends ServiceImpl<WeMsgTlpMapper,WeMsgTlp> implements IWeMsgTlpService{ @Autowired private IWeUserService iWeUserService; @Autowired private WeMediaClient weMediaClient; @Autowired private IWeMaterialService materialService; @Autowired private WeCustomerGroupClient weCustomerGroupClient; /** * 新增欢迎语模板 * * @param weMsgTlp 欢迎语模板 * @return 结果 */ @Override @Transactional public void addorUpdate(WeMsgTlp weMsgTlp) { if(weMsgTlp.getWelcomeMsgTplType() .equals(new Integer(2))) { String userIds = weMsgTlp.getUserIds(); if (StringUtils.isNotEmpty(userIds)) { List<WeUser> weUsers = iWeUserService.listByIds( ListUtil.toList(userIds.split(",")) ); if (CollectionUtil.isNotEmpty(weUsers)) { weMsgTlp.setUserNames(String.join(",", weUsers.stream().map(WeUser::getName).collect(Collectors.toList()))); } } } if(this.saveOrUpdate(weMsgTlp)){//入群欢迎语 if(weMsgTlp.getWelcomeMsgTplType() .equals(new Integer(3))){ GroupWelcomeTplDto tplDto=new GroupWelcomeTplDto(); tplDto.setText( GroupWelcomeTplDto.Text.builder() .content(weMsgTlp.getWelcomeMsg()) .build() ); //图片 String picUrl = weMsgTlp.getPicUrl(); if(StringUtils.isNotEmpty(picUrl)){ ListUtil.toList(picUrl.split(",")).stream().forEach(k->{ WeMediaDto uploadimg = weMediaClient.uploadimg( ImageUtils.getMultipartFile(k) ); if(uploadimg.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)){ tplDto.setImage( GroupWelcomeTplDto.Image.builder() .pic_url(uploadimg.getUrl()) .build() ); } }); } //图文 List<WeMsgTlp.ImageText> imageText = weMsgTlp.getImageText(); if(CollectionUtil.isNotEmpty(imageText)){ imageText.stream().forEach(k->{ tplDto.setLink( GroupWelcomeTplDto.Link.builder() .title(k.getImageTextTile()) .url(k.getImageTextUrl()) .build() ); }); } //小程序 List<WeMsgTlp.Applet> applet = weMsgTlp.getApplet(); if(CollectionUtil.isNotEmpty(applet)){ applet.stream().forEach(k->{ WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(k.getAppPic(), MediaType.IMAGE.getMediaType() , k.getAppTile()); if(weMediaDto.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)){ tplDto.setMiniprogram( GroupWelcomeTplDto.Miniprogram.builder() .appid(k.getAppId()) .page(k.getAppPath()) .pic_media_id(weMediaDto.getMedia_id()) .title(k.getAppTile()) .build() ); } }); } WeMsgTlp oldWeMsgTlp = this.getById(weMsgTlp.getId()); if(null != oldWeMsgTlp){ tplDto.setTemplate_id(oldWeMsgTlp.getTemplateId()); weCustomerGroupClient.updateGroupWelcomeTpl(tplDto); }else{ GroupWelcomeTplDto tplDto1 = weCustomerGroupClient.addGroupWelcomeTpl(tplDto); if(tplDto1.getErrcode().equals(WeConstans.WE_SUCCESS_CODE)){ weMsgTlp.setTemplateId(tplDto1.getTemplate_id()); } this.updateById(weMsgTlp); } } } } }
\ No newline at end of file \ No newline at end of file
......
...@@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ...@@ -8,7 +8,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
SELECT SELECT
wc.avatar, wc.avatar,
wc.`name` as customerName, wc.`name` as customerName,
wc.customer_type, wc.customer_type as customerType,
if(wt.tag_type=1,GROUP_CONCAT(wt.`tag_id`),null ) as tagIds, if(wt.tag_type=1,GROUP_CONCAT(wt.`tag_id`),null ) as tagIds,
if(wt.tag_type=1,GROUP_CONCAT(wt.`name`),null ) as tagNames, if(wt.tag_type=1,GROUP_CONCAT(wt.`name`),null ) as tagNames,
if(wt.tag_type=3,GROUP_CONCAT(wt.`tag_id`),null ) as personTagIds, if(wt.tag_type=3,GROUP_CONCAT(wt.`tag_id`),null ) as personTagIds,
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
</if> </if>
</where> </where>
GROUP BY wg.chat_id GROUP BY wg.chat_id
ORDER BY wg.create_time DESC
</select> </select>
......
...@@ -13,10 +13,10 @@ ...@@ -13,10 +13,10 @@
(SELECT GROUP_CONCAT(wu.user_id) FROM we_user wu WHERE FIND_IN_SET(wu.user_id,wm.no_add_user)) as noAddUser, (SELECT GROUP_CONCAT(wu.user_id) FROM we_user wu WHERE FIND_IN_SET(wu.user_id,wm.no_add_user)) as noAddUser,
(SELECT GROUP_CONCAT(wu.user_name) FROM we_user wu WHERE FIND_IN_SET(wu.user_id,wm.add_user)) as addUserName, (SELECT GROUP_CONCAT(wu.user_name) FROM we_user wu WHERE FIND_IN_SET(wu.user_id,wm.add_user)) as addUserName,
(SELECT GROUP_CONCAT(wu.user_id) FROM we_user wu WHERE FIND_IN_SET(wu.user_id,wm.add_user)) as addUser, (SELECT GROUP_CONCAT(wu.user_id) FROM we_user wu WHERE FIND_IN_SET(wu.user_id,wm.add_user)) as addUser,
create_time, push_time as createTime,
moment_id, moment_id,
(SELECT count(*) FROM we_moments_interacte wmi WHERE wmi.moment_id=wm.moment_id and wmi.interacte_type=0) as commentNum, (SELECT count(*) FROM we_moments_interacte wmi WHERE wmi.moment_id=wm.moment_id and wmi.interacte_type=0) as commentNum,
(SELECT count(*) FROM we_moments_interacte wmi WHERE wmi.moment_id=wm.moment_id and wmi.interacte_type=1) as pointNum (SELECT count(*) FROM we_moments_interacte wmi WHERE wmi.moment_id=wm.moment_id and wmi.interacte_user_type=1 and wmi.interacte_type=1) as pointNum
FROM FROM
we_moments wm we_moments wm
<where> <where>
...@@ -27,10 +27,10 @@ ...@@ -27,10 +27,10 @@
AND wm.creator=#{creator} AND wm.creator=#{creator}
</if> </if>
<if test="beginTime !=null and beginTime !='' and endTime !=null and endTime !='' "> <if test="beginTime !=null and beginTime !='' and endTime !=null and endTime !='' ">
AND date_format(wm.create_time ,'%Y-%m-%d') BETWEEN #{beginTime} AND #{endTime} AND date_format(wm.push_time ,'%Y-%m-%d') BETWEEN #{beginTime} AND #{endTime}
</if> </if>
</where> </where>
order by wm.create_time desc order by wm.push_time desc
</select> </select>
...@@ -71,5 +71,9 @@ ...@@ -71,5 +71,9 @@
where wm.moment_id=#{momentId} where wm.moment_id=#{momentId}
</select> </select>
<select id="removePushLwPush">
DELETE FROM we_moments WHERE is_lw_push=1
</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!