Commit 83c14a37 by xinlaa

Merge branch 'master' of https://gitee.com/LinkWeChat/link-wechat into master

2 parents 1c056ab0 a20dbd92
Showing 23 changed files with 285 additions and 43 deletions
...@@ -210,7 +210,7 @@ com.linkwechat ...@@ -210,7 +210,7 @@ com.linkwechat
### 联系作者加入群 ### 联系作者加入群
![输入图片说明](https://images.gitee.com/uploads/images/2020/1217/152441_79fbd2f6_409467.png "屏幕截图.png") ![输入图片说明](https://images.gitee.com/uploads/images/2020/1226/183631_251ea80c_409467.png "屏幕截图.png")
### 特别鸣谢 ### 特别鸣谢
......
...@@ -4,16 +4,18 @@ import com.fasterxml.jackson.core.JsonProcessingException; ...@@ -4,16 +4,18 @@ import com.fasterxml.jackson.core.JsonProcessingException;
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;
import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.WeCustomer;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto; import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import com.linkwechat.wecom.service.IWeCustomerMessagePushService; import com.linkwechat.wecom.service.IWeCustomerMessagePushService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import java.util.List;
import org.springframework.web.bind.annotation.RestController;
/** /**
* @description: 企业微信 群发消息 controller * @description: 企业微信 群发消息 controller
...@@ -45,4 +47,20 @@ public class WeCustomerMessagePushController extends BaseController { ...@@ -45,4 +47,20 @@ public class WeCustomerMessagePushController extends BaseController {
return AjaxResult.success(); return AjaxResult.success();
} }
/**
* 群发消息列表
*/
@PreAuthorize("@ss.hasPermi('system:push:list')")
@GetMapping(value = "/list")
public TableDataInfo list(@RequestParam(value = "sender",required = false) String sender
,@RequestParam(value = "content",required = false) String content
,@RequestParam(value = "pushType",required = false) String pushType
,@RequestParam(value = "beginTime",required = false) String beginTime
,@RequestParam(value = "endTime",required = false) String endTime) {
startPage();
List<CustomerMessagePushVo> list = weCustomerMessagePushService.customerMessagePushs(sender,content,pushType,beginTime,endTime);
return getDataTable(list);
}
} }
...@@ -7,6 +7,7 @@ import com.linkwechat.common.core.page.TableDataInfo; ...@@ -7,6 +7,7 @@ import com.linkwechat.common.core.page.TableDataInfo;
import com.linkwechat.common.enums.BusinessType; import com.linkwechat.common.enums.BusinessType;
import com.linkwechat.wecom.domain.WeMaterial; import com.linkwechat.wecom.domain.WeMaterial;
import com.linkwechat.wecom.domain.dto.ResetCategoryDto; import com.linkwechat.wecom.domain.dto.ResetCategoryDto;
import com.linkwechat.wecom.domain.dto.WeMediaDto;
import com.linkwechat.wecom.domain.vo.WeMaterialFileVO; import com.linkwechat.wecom.domain.vo.WeMaterialFileVO;
import com.linkwechat.wecom.service.IWeMaterialService; import com.linkwechat.wecom.service.IWeMaterialService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -111,5 +112,13 @@ public class WeMaterialController extends BaseController { ...@@ -111,5 +112,13 @@ public class WeMaterialController extends BaseController {
return AjaxResult.success(); return AjaxResult.success();
} }
@PreAuthorize("@ss.hasPermi('wechat:material:temporaryMaterialMediaId')")
@Log(title = "获取素材media_id", businessType = BusinessType.OTHER)
@PutMapping("/temporaryMaterialMediaId")
@ApiOperation("获取素材media_id")
public AjaxResult temporaryMaterialMediaId(@RequestParam(value = "url") String url, @RequestParam(value = "type") String type,@RequestParam(value = "name") String name){
WeMediaDto weMediaDto = materialService.uploadTemporaryMaterial(url, type,name);
return AjaxResult.success(weMediaDto);
}
} }
...@@ -138,6 +138,7 @@ ...@@ -138,6 +138,7 @@
<dependency> <dependency>
<groupId>com.dtflys.forest</groupId> <groupId>com.dtflys.forest</groupId>
<artifactId>spring-boot-starter-forest</artifactId> <artifactId>spring-boot-starter-forest</artifactId>
<version>1.5.0-RC1</version>
</dependency> </dependency>
<dependency> <dependency>
......
...@@ -19,6 +19,7 @@ import java.util.List; ...@@ -19,6 +19,7 @@ import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import java.util.stream.Collectors;
/** /**
* @author sxw * @author sxw
...@@ -82,6 +83,27 @@ public class FinanceUtils { ...@@ -82,6 +83,27 @@ public class FinanceUtils {
JSONObject jsonObject = decryptChatRecord(sdk, data.getString("encrypt_random_key"), JSONObject jsonObject = decryptChatRecord(sdk, data.getString("encrypt_random_key"),
data.getString("encrypt_chat_msg"), privateKey); data.getString("encrypt_chat_msg"), privateKey);
jsonObject.put("seq", LocalSEQ); jsonObject.put("seq", LocalSEQ);
jsonObject.put("totype","0");
if (StringUtils.isEmpty(jsonObject.getString("roomid"))){
JSONArray tolist = jsonObject.getJSONArray("tolist");
Optional.ofNullable(tolist).ifPresent(itemList ->{
List<String> isEType = itemList.stream().map(item -> (String) item).filter(item ->
StringUtils.isNotEmpty(item) &&
("wo".equals(item.substring(0, 2)) || "wm".equals(item.substring(0, 2))))
.collect(Collectors.toList());
List<String> isExtype = itemList.stream().map(item -> (String) item).filter(item ->
StringUtils.isNotEmpty(item) && "wb".equals(item.substring(0, 2)))
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(isEType)){
jsonObject.put("totype","1");
return;
}
if (CollectionUtil.isNotEmpty(isExtype)){
jsonObject.put("totype","2");
return;
}
});
}
elasticSearchEntity.setData(jsonObject); elasticSearchEntity.setData(jsonObject);
elasticSearchEntity.setId(jsonObject.getString("msgid")); elasticSearchEntity.setId(jsonObject.getString("msgid"));
resList.add(elasticSearchEntity); resList.add(elasticSearchEntity);
...@@ -94,16 +116,6 @@ public class FinanceUtils { ...@@ -94,16 +116,6 @@ public class FinanceUtils {
return resList; return resList;
} }
public static void main(String[] args) {
String secret = "_Ruv_TD_GzE4wJLvhMv4MeYkjM81_IJFDPcsUiss9fw";
initSDK("ww24262ce93851488f", secret);
//getChatData(0,"","");
// getMediaData("CiBkZDk3ZmJjMTlhYjU1YWJiNDQ4MjI3NWRlMzk1NmMzYxI4TkRkZk56ZzRNVE13TURVNU5Ua3lOVFEyTlY4NU5ERTBOekUwTWpaZk1UWXdOemt4TkRrMU1BPT0aIDBiMzY3YjkyNzE5ZDE3ZWU4NjkyNTVlYzJkNTlmNjI3",
// "", "", "");
}
/** /**
* @param sdk 初始化时候获取到的值 * @param sdk 初始化时候获取到的值
* @param ncrypt_random_key 企业微信返回的随机密钥 * @param ncrypt_random_key 企业微信返回的随机密钥
......
...@@ -56,11 +56,13 @@ ...@@ -56,11 +56,13 @@
<dependency> <dependency>
<groupId>net.java.dev.jna</groupId> <groupId>net.java.dev.jna</groupId>
<artifactId>jna</artifactId> <artifactId>jna</artifactId>
<version>5.6.0</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.java.dev.jna</groupId> <groupId>net.java.dev.jna</groupId>
<artifactId>jna-platform</artifactId> <artifactId>jna-platform</artifactId>
<version>5.6.0</version>
</dependency> </dependency>
<!-- 系统模块--> <!-- 系统模块-->
......
...@@ -41,7 +41,7 @@ export default { ...@@ -41,7 +41,7 @@ export default {
this.loading = true this.loading = true
getDetail(id).then(({ data }) => { getDetail(id).then(({ data }) => {
this.form = data this.form = data
this.materialSelected = data.weMaterial.materialUrl this.materialSelected = data.weMaterial ==null?"":data.weMaterial.materialUrl
this.loading = false this.loading = false
}) })
}, },
......
...@@ -22,6 +22,11 @@ ...@@ -22,6 +22,11 @@
<groupId>com.linkwechat</groupId> <groupId>com.linkwechat</groupId>
<artifactId>linkwe-common</artifactId> <artifactId>linkwe-common</artifactId>
</dependency> </dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>5.2.9.RELEASE</version>
</dependency>
</dependencies> </dependencies>
......
...@@ -6,6 +6,9 @@ import com.dtflys.forest.annotation.Query; ...@@ -6,6 +6,9 @@ import com.dtflys.forest.annotation.Query;
import com.linkwechat.wecom.domain.dto.WeMediaDto; import com.linkwechat.wecom.domain.dto.WeMediaDto;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.File;
import java.io.InputStream;
/** /**
* 素材管理 * 素材管理
* @Author: Robin * @Author: Robin
...@@ -16,12 +19,12 @@ public interface WeMediaClient { ...@@ -16,12 +19,12 @@ public interface WeMediaClient {
/** /**
* 上传临时素材 * 上传临时素材
* @param multipartFile * @param file
* @param type * @param type
* @return * @return
*/ */
@Post(url="/media/upload") @Post(url="/media/upload")
WeMediaDto upload(@DataFile(value = "file") MultipartFile multipartFile, @Query("type") String type); WeMediaDto upload(@DataFile(value = "media") File file, @Query("type") String type);
/** /**
* 上传图片 * 上传图片
...@@ -30,4 +33,14 @@ public interface WeMediaClient { ...@@ -30,4 +33,14 @@ public interface WeMediaClient {
*/ */
@Post(url="/media/uploadimg") @Post(url="/media/uploadimg")
WeMediaDto uploadimg(@DataFile(value = "file") MultipartFile multipartFile); WeMediaDto uploadimg(@DataFile(value = "file") MultipartFile multipartFile);
/**
* 上传临时素材
* Inputstream 对象
* 使用byte数组和Inputstream对象时一定要定义fileName属性
*/
@Post(url = "/media/upload")
WeMediaDto upload(@DataFile(value = "media", fileName = "${1}") InputStream file, String filename, @Query("type") String type);
} }
...@@ -57,6 +57,22 @@ public class WeCustomerMessage extends BaseEntity { ...@@ -57,6 +57,22 @@ public class WeCustomerMessage extends BaseEntity {
private String msgid; private String msgid;
/** /**
* 发送情况
* ps:显示样式
*
* 1)定时任务 发送时间:2020-12-25 10:00:00
* 2) 预计发送3190人,已成功发送0人
* 3)预计发送2个群,已成功发送0个群
*
*/
private String sendInfo;
/**
* 消息内容
*/
private String content;
/**
* 0 未删除 1 已删除 * 0 未删除 1 已删除
*/ */
private int delFlag; private int delFlag;
......
package com.linkwechat.wecom.domain.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.util.Date;
/**
* 群发消息任务
*/
@Data
public class CustomerMessagePushVo {
/**
* 消息id
*/
private Long messageId;
/**
* 消息类型 0 文本消息 1 图片消息 2 链接消息 3 小程序消息
*/
private String messageType;
/**
* 消息内容
*/
private String content;
/**
* 群发类型 0 发给客户 1 发给客户群
*/
private String pushType;
/**
* 消息范围 0 全部客户 1 指定客户
*/
private String pushRange;
/**
* 创建人
*/
private String sender;
/**
* 创建时间
*/
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date sendTime;
/**
* 发送情况
* ps:显示样式
*
* 1)定时任务 发送时间:2020-12-25 10:00:00
* 2) 预计发送3190人,已成功发送0人
* 3)预计发送2个群,已成功发送0个群
*
*/
private String sendInfo;
}
...@@ -181,7 +181,7 @@ public class WeEventChangeExternalContactImpl implements WeCallBackEventFactory ...@@ -181,7 +181,7 @@ public class WeEventChangeExternalContactImpl implements WeCallBackEventFactory
} }
if(StringUtils.isNotEmpty(messageMap.getCategoryId())){ if(StringUtils.isNotEmpty(messageMap.getCategoryId())){
WeMediaDto weMediaDto = weMaterialService WeMediaDto weMediaDto = weMaterialService
.uploadTemporaryMaterial(messageMap.getMaterialUrl(), MediaType.IMAGE.getMediaType()); .uploadTemporaryMaterial(messageMap.getMaterialUrl(),messageMap.getMaterialName(), MediaType.IMAGE.getMediaType());
Optional.ofNullable(weMediaDto).ifPresent(media ->{ Optional.ofNullable(weMediaDto).ifPresent(media ->{
weWelcomeMsgBuilder.image(WeWelcomeMsg.Image.builder().media_id(media.getMedia_id()) weWelcomeMsgBuilder.image(WeWelcomeMsg.Image.builder().media_id(media.getMedia_id())
.pic_url(media.getUrl()).build()); .pic_url(media.getUrl()).build());
......
...@@ -5,6 +5,7 @@ import com.dtflys.forest.exceptions.ForestRuntimeException; ...@@ -5,6 +5,7 @@ import com.dtflys.forest.exceptions.ForestRuntimeException;
import com.dtflys.forest.http.ForestRequest; import com.dtflys.forest.http.ForestRequest;
import com.dtflys.forest.http.ForestResponse; import com.dtflys.forest.http.ForestResponse;
import com.dtflys.forest.interceptor.Interceptor; import com.dtflys.forest.interceptor.Interceptor;
import com.dtflys.forest.multipart.ForestMultipart;
import com.dtflys.forest.utils.ForestDataType; import com.dtflys.forest.utils.ForestDataType;
import com.linkwechat.common.config.WeComeConfig; import com.linkwechat.common.config.WeComeConfig;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
...@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -14,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
/** /**
* @description: 微信token拦截器 * @description: 微信token拦截器
...@@ -38,16 +40,15 @@ public class WeAccessTokenInterceptor implements Interceptor{ ...@@ -38,16 +40,15 @@ public class WeAccessTokenInterceptor implements Interceptor{
*/ */
@Override @Override
public boolean beforeExecute(ForestRequest request) { public boolean beforeExecute(ForestRequest request) {
request.setDataType(ForestDataType.JSON);
String uri=request.getUrl().replace("http://",""); String uri=request.getUrl().replace("http://","");
//request.setContentType("application/json");
if(!Arrays.asList(weComeConfig.getFileUplodUrl()).contains(uri)){
request.setDataType(ForestDataType.JSON);
request.setContentType("application/json"); request.setContentType("application/json");
// if(Arrays.asList(weComeConfig.getFileUplodUrl()).contains(uri)){ }
// request.setContentType("application/json");
// }else{
// request.setContentType("multipart/form-data");
// }
......
...@@ -2,6 +2,10 @@ package com.linkwechat.wecom.mapper; ...@@ -2,6 +2,10 @@ package com.linkwechat.wecom.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.linkwechat.wecom.domain.WeCustomerMessageOriginal; import com.linkwechat.wecom.domain.WeCustomerMessageOriginal;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 群发消息 原始数据信息表 Mapper接口 * 群发消息 原始数据信息表 Mapper接口
...@@ -10,4 +14,18 @@ import com.linkwechat.wecom.domain.WeCustomerMessageOriginal; ...@@ -10,4 +14,18 @@ import com.linkwechat.wecom.domain.WeCustomerMessageOriginal;
* @date 2020-12-08 * @date 2020-12-08
*/ */
public interface WeCustomerMessageOriginalMapper extends BaseMapper<WeCustomerMessageOriginal> { public interface WeCustomerMessageOriginalMapper extends BaseMapper<WeCustomerMessageOriginal> {
/**
* 群发消息列表
*
* @param sender 创建人
* @param content 内容
* @param pushType 群发类型
* @param beginTime 开始时间
* @param endTime 结束时间
* @return {@link CustomerMessagePushVo}s
*/
public List<CustomerMessagePushVo> selectCustomerMessagePushs(@Param("sender") String sender,@Param("content") String content
,@Param("pushType") String pushType, @Param("beginTime") String beginTime,@Param("endTime") String endTime);
} }
...@@ -2,6 +2,10 @@ package com.linkwechat.wecom.service; ...@@ -2,6 +2,10 @@ package com.linkwechat.wecom.service;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.linkwechat.wecom.domain.WeCustomerMessageOriginal; import com.linkwechat.wecom.domain.WeCustomerMessageOriginal;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import java.util.List;
/** /**
* 群发消息 原始数据信息表 we_customer_messageOriginal * 群发消息 原始数据信息表 we_customer_messageOriginal
* *
...@@ -15,4 +19,17 @@ public interface IWeCustomerMessageOriginalService extends IService<WeCustomerMe ...@@ -15,4 +19,17 @@ public interface IWeCustomerMessageOriginalService extends IService<WeCustomerMe
* @return * @return
*/ */
int saveWeCustomerMessageOriginal(WeCustomerMessageOriginal weCustomerMessageOriginal); int saveWeCustomerMessageOriginal(WeCustomerMessageOriginal weCustomerMessageOriginal);
/**
* 群发消息列表
*
* @param sender 创建人
* @param content 内容
* @param pushType 群发类型
* @param beginTime 开始时间
* @param endTime 结束时间
* @return {@link CustomerMessagePushVo}s
*/
List<CustomerMessagePushVo> customerMessagePushs(String sender,String content,String pushType,String beginTime,String endTime);
} }
...@@ -3,6 +3,9 @@ package com.linkwechat.wecom.service; ...@@ -3,6 +3,9 @@ package com.linkwechat.wecom.service;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto; import com.linkwechat.wecom.domain.dto.message.CustomerMessagePushDto;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import java.util.List;
/** /**
* @description: 群发消息服务类 * @description: 群发消息服务类
...@@ -18,4 +21,16 @@ public interface IWeCustomerMessagePushService { ...@@ -18,4 +21,16 @@ public interface IWeCustomerMessagePushService {
*/ */
public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException; public void addWeCustomerMessagePush(CustomerMessagePushDto customerMessagePushDto) throws JsonProcessingException;
/**
* 群发消息列表
*
* @param sender 创建人
* @param content 内容
* @param pushType 群发类型
* @param beginTime 开始时间
* @param endTime 结束时间
* @return {@link CustomerMessagePushVo}s
*/
public List<CustomerMessagePushVo> customerMessagePushs(String sender,String content,String pushType,String beginTime,String endTime);
} }
...@@ -92,4 +92,14 @@ public interface IWeMaterialService { ...@@ -92,4 +92,14 @@ public interface IWeMaterialService {
*/ */
public WeMediaDto uploadTemporaryMaterial(String url, String type); public WeMediaDto uploadTemporaryMaterial(String url, String type);
/**
* 上传企微临时素材
* @param url 素材路径
* @param type 素材类型
* @param name 素材名称
* @return
*/
public WeMediaDto uploadTemporaryMaterial(String url, String type,String name);
} }
...@@ -2,11 +2,14 @@ package com.linkwechat.wecom.service.impl; ...@@ -2,11 +2,14 @@ package com.linkwechat.wecom.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linkwechat.wecom.domain.WeCustomerMessageOriginal; import com.linkwechat.wecom.domain.WeCustomerMessageOriginal;
import com.linkwechat.wecom.domain.vo.CustomerMessagePushVo;
import com.linkwechat.wecom.mapper.WeCustomerMessageOriginalMapper; import com.linkwechat.wecom.mapper.WeCustomerMessageOriginalMapper;
import com.linkwechat.wecom.service.IWeCustomerMessageOriginalService; import com.linkwechat.wecom.service.IWeCustomerMessageOriginalService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
/** /**
* 群发消息 原始数据信息表 we_customer_messageOriginal * 群发消息 原始数据信息表 we_customer_messageOriginal
* *
...@@ -14,7 +17,7 @@ import org.springframework.stereotype.Service; ...@@ -14,7 +17,7 @@ import org.springframework.stereotype.Service;
* @date 2020-12-12 * @date 2020-12-12
*/ */
@Service @Service
public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomerMessageOriginalMapper,WeCustomerMessageOriginal>implements IWeCustomerMessageOriginalService { public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustomerMessageOriginalMapper, WeCustomerMessageOriginal> implements IWeCustomerMessageOriginalService {
@Autowired @Autowired
private WeCustomerMessageOriginalMapper weCustomerMessageOriginalMapper; private WeCustomerMessageOriginalMapper weCustomerMessageOriginalMapper;
...@@ -24,5 +27,10 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustome ...@@ -24,5 +27,10 @@ public class WeCustomerMessageOriginalServiceImpl extends ServiceImpl<WeCustome
return weCustomerMessageOriginalMapper.insert(weCustomerMessageOriginal); return weCustomerMessageOriginalMapper.insert(weCustomerMessageOriginal);
} }
@Override
public List<CustomerMessagePushVo> customerMessagePushs(String sender, String content, String pushType, String beginTime, String endTime) {
return weCustomerMessageOriginalMapper.selectCustomerMessagePushs(sender, content, pushType, beginTime, endTime);
}
} }
...@@ -5,7 +5,6 @@ import cn.hutool.core.date.DateUtil; ...@@ -5,7 +5,6 @@ import cn.hutool.core.date.DateUtil;
import com.linkwechat.common.config.RuoYiConfig; import com.linkwechat.common.config.RuoYiConfig;
import com.linkwechat.common.config.ServerConfig; import com.linkwechat.common.config.ServerConfig;
import com.linkwechat.common.constant.WeConstans; import com.linkwechat.common.constant.WeConstans;
import com.linkwechat.common.enums.MediaType;
import com.linkwechat.common.exception.wecom.WeComException; import com.linkwechat.common.exception.wecom.WeComException;
import com.linkwechat.common.utils.SnowFlakeUtil; import com.linkwechat.common.utils.SnowFlakeUtil;
import com.linkwechat.common.utils.StringUtils; import com.linkwechat.common.utils.StringUtils;
...@@ -17,18 +16,13 @@ import com.linkwechat.wecom.domain.vo.WeMaterialFileVO; ...@@ -17,18 +16,13 @@ import com.linkwechat.wecom.domain.vo.WeMaterialFileVO;
import com.linkwechat.wecom.mapper.WeMaterialMapper; import com.linkwechat.wecom.mapper.WeMaterialMapper;
import com.linkwechat.wecom.service.IWeMaterialService; import com.linkwechat.wecom.service.IWeMaterialService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileItemFactory;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.http.entity.ContentType;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.net.HttpURLConnection;
import java.io.FileNotFoundException; 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.Optional;
...@@ -61,7 +55,7 @@ public class WeMaterialServiceImpl implements IWeMaterialService { ...@@ -61,7 +55,7 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
// 上传文件路径 // 上传文件路径
String filePath = RuoYiConfig.getUploadPath(); String filePath = RuoYiConfig.getUploadPath();
String fileName = ""; String fileName = "";
if (MediaType.FILE.getType().equals(type)) { if (com.linkwechat.common.enums.MediaType .FILE.getType().equals(type)) {
fileName = FileUploadUtils.uploadFile(file); fileName = FileUploadUtils.uploadFile(file);
} else { } else {
// 上传并返回新文件名称 // 上传并返回新文件名称
...@@ -69,7 +63,7 @@ public class WeMaterialServiceImpl implements IWeMaterialService { ...@@ -69,7 +63,7 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
} }
String url = serverConfig.getUrl() + fileName; String url = serverConfig.getUrl() + fileName;
//上传临时素材 //上传临时素材
Optional<MediaType> mediaType = MediaType.of(type); Optional<com.linkwechat.common.enums.MediaType > mediaType = com.linkwechat.common.enums.MediaType .of(type);
if (!mediaType.isPresent()) { if (!mediaType.isPresent()) {
throw new WeComException("媒体类型出错!"); throw new WeComException("媒体类型出错!");
} }
...@@ -131,17 +125,32 @@ public class WeMaterialServiceImpl implements IWeMaterialService { ...@@ -131,17 +125,32 @@ public class WeMaterialServiceImpl implements IWeMaterialService {
public WeMediaDto uploadTemporaryMaterial(String url, String type) { public WeMediaDto uploadTemporaryMaterial(String url, String type) {
try { try {
File file = new File(url); File file = new File(url);
FileItemFactory factory = new DiskFileItemFactory(16, null); return weMediaClient.upload(file, type);
FileItem item=factory.createItem(file.getName(),"text/plain",true,file.getName());
MultipartFile multipartFile = new CommonsMultipartFile(item);
return weMediaClient.upload(multipartFile, type);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
log.error("上传临时文件失败......url:{},type:{},ex:{},st:{}",url,type,e.getMessage(),e.getStackTrace()); log.error("上传临时文件失败......url:{},type:{},ex:{},st:{}",url,type,e.getMessage(),e.getStackTrace());
} }
return null; return null;
} }
@Override
public WeMediaDto uploadTemporaryMaterial(String url, String type, String name) {
HttpURLConnection conn = null;
try{
URL materialUrl = new URL(url);
conn = (HttpURLConnection) materialUrl.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(20 * 1000);
return weMediaClient.upload(conn.getInputStream(), name, type);
}catch (Exception e){
e.printStackTrace();
log.error("上传临时文件失败......url:{},type:{},name:{},ex:{},st:{}",url,type,name,e.getMessage(),e.getStackTrace());
}finally {
if (conn !=null){
conn = null;
}
}
return null;
}
} }
...@@ -3,4 +3,29 @@ ...@@ -3,4 +3,29 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.linkwechat.wecom.mapper.WeCustomerMessageOriginalMapper"> <mapper namespace="com.linkwechat.wecom.mapper.WeCustomerMessageOriginalMapper">
<select id="selectCustomerMessagePushs" resultType="com.linkwechat.wecom.domain.vo.CustomerMessagePushVo">
SELECT
wcmo.push_type,wcmo.message_type,wcmo.push_range,wcmo.create_by sender,wcmo.create_time
sendTime,wcm.message_id,wcm.content,wcm.send_info
FROM we_customer_messageOriginal wcmo LEFT JOIN we_customer_message wcm ON
wcmo.message_original_Id=wcm.original_id
<where>
<if test="sender!=null and sender!=''">
AND wcmo.create_by LIKE CONCAT('%',#{sender},'%')
</if>
<if test="content!=null and content!=''">
AND wcm.content LIKE CONCAT('%',#{content},'%')
</if>
<if test="pushType!=null and pushType!=''">
AND wcmo.push_type=#{pushType}
</if>
<if test="beginTime != null and beginTime != ''"><!-- 开始时间检索 -->
AND date_format(wcmo.create_time,'%y%m%d') &gt;= date_format(#{beginTime},'%y%m%d')
</if>
<if test="endTime != null and endTime != ''"><!-- 结束时间检索 -->
AND date_format(wcmo.create_time,'%y%m%d') &lt;= date_format(#{endTime},'%y%m%d')
</if>
</where>
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<description>若依管理系统</description> <description>若依管理系统</description>
<properties> <properties>
<springboot.vaerion>2.2.1.RELEASE</springboot.vaerion> <springboot.vaerion>2.3.7.RELEASE</springboot.vaerion>
<linkwe.version>3.1.0</linkwe.version> <linkwe.version>3.1.0</linkwe.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<poi.version>3.17</poi.version> <poi.version>3.17</poi.version>
<velocity.version>1.7</velocity.version> <velocity.version>1.7</velocity.version>
<jwt.version>0.9.0</jwt.version> <jwt.version>0.9.0</jwt.version>
<forest.version>1.4.0</forest.version> <forest.version>1.5.0-RC1</forest.version>
<lombok.version>1.18.16</lombok.version> <lombok.version>1.18.16</lombok.version>
<reflectasm.version>1.11.9</reflectasm.version> <reflectasm.version>1.11.9</reflectasm.version>
<hutool.version>5.4.1</hutool.version> <hutool.version>5.4.1</hutool.version>
......
This diff could not be displayed because it is too large.
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!