Commit c7d88cff by 徐高华

Merge branch 'feature/xgh/20250609' into 'master'

Feature/xgh/20250609

See merge request !2958
parents c42aa1bb 60aa928b
......@@ -94,4 +94,7 @@ public interface MaterialApiService {
* @param qdto
*/
void materialSortCategory(MaterialCategorySortQDTO qdto);
//mediaType1群发 2朋友圈
public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) ;
}
......@@ -247,6 +247,11 @@
<artifactId>task-allocation-sdk</artifactId>
<version>${task-allocation-sdk}</version>
</dependency>
<dependency>
<groupId>com.gic</groupId>
<artifactId>gic-canvas-api</artifactId>
<version>${gic-canvas-api}</version>
</dependency>
</dependencies>
<build>
......
......@@ -42,6 +42,7 @@ public interface GroupChatPlanService {
void stopByMsgid(Long planId);
String getQwMsgId(String staffId , Date sendTime, GroupMessageServiceImpl.GroupMsgChatType groupMsgChatType) ;
String getQwMsgId(String staffId , Date sendTime, GroupMessageServiceImpl.GroupMsgChatType groupMsgChatType , String enterpriseId , String taskId) ;
void noticeTimer(String params);
......
......@@ -7,6 +7,10 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;
import com.gic.canvas.api.dto.node.CanvasNodeDTO;
import com.gic.canvas.api.dto.node.QWMassContactNodeDTO;
import com.gic.canvas.api.dto.node.extract.MaterialExternalResources;
import com.gic.canvas.api.service.CanvasApiService;
import com.gic.enterprise.api.dto.EnterpriseDTO;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.manage.api.dto.CommonMQDTO;
......@@ -29,6 +33,8 @@ import com.gic.haoban.manage.service.service.content.impl.GroupMessageServiceImp
import com.gic.haoban.manage.service.util.StreamUtils;
import com.gic.haoban.task.api.dto.TaskSettingDTO;
import com.gic.haoban.task.api.service.SettingApiService;
import com.gic.haoban.task.manage.api.dto.MarketClueTaskDTO;
import com.gic.haoban.task.manage.api.service.IMarketClueTaskApiService;
import com.gic.haoban.task.manage.api.service.QywxGroupSendCanvasApiService;
import com.gic.thirdparty.cloudfile.CloudFileUtil;
import com.gic.thirdparty.cloudfile.enums.CloudFileBusinessOptEnum;
......@@ -142,6 +148,10 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
private SettingApiService settingApiService ;
@Autowired
private QwMomentPlanAttendMapper qwMomentPlanAttendMapper ;
@Autowired
private IMarketClueTaskApiService marketClueTaskApiService ;
@Autowired
private CanvasApiService canvasApiService ;
private static GicMQClient mqClient = GICMQClientUtil.getClientInstance();
......@@ -896,7 +906,7 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
@Override
public String getQwMsgId(String staffId , Date sendTime, GroupMessageServiceImpl.GroupMsgChatType groupMsgChatType) {
Date startTime = DateUtil.addNumForSecond(sendTime,-30) ;
Date endTime = DateUtil.addNumForMinute(sendTime,1) ;
Date endTime = DateUtil.addNumForMinute(sendTime,2) ;
TabHaobanStaff staff = this.staffMapper.selectByPrimaryKey(staffId) ;
String wxEnterpriseId = staff.getWxEnterpriseId() ;
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
......@@ -916,6 +926,94 @@ public class GroupChatPlanServiceImpl implements GroupChatPlanService {
return null ;
}
@Override
public String getQwMsgId(String staffId, Date sendTime, GroupMessageServiceImpl.GroupMsgChatType groupMsgChatType, String enterpriseId, String taskId) {
Date startTime = DateUtil.addNumForSecond(sendTime,-120) ;
Date endTime = DateUtil.addNumForMinute(sendTime,1) ;
TabHaobanStaff staff = this.staffMapper.selectByPrimaryKey(staffId) ;
String wxEnterpriseId = staff.getWxEnterpriseId() ;
WxEnterpriseQwDTO qwDTO = this.wxEnterpriseService.getQwInfo(wxEnterpriseId) ;
String wxUserId = staff.getWxUserId() ;
if(qwDTO.needOpenUserId3th()) {
wxUserId = staff.getWxOpenUseId() ;
}
// 发送到群
List<QywxGroupMessageInfoDTO> msgList = this.queryGroupMsg(groupMsgChatType,startTime, endTime, qwDTO, wxUserId);
if(CollectionUtils.isNotEmpty(msgList)) {
if(msgList.size()==0) {
return msgList.get(0).getMsgId() ;
}else {
List<MaterialExternalResources> taskList = this.getTaskList(taskId,enterpriseId) ;
if(CollectionUtils.isEmpty(taskList)) {
return null ;
}
String taskText = this.getTaskText(taskList) ;
int count = this.getTaskNum(taskList) ;
if(StringUtils.isNotBlank(taskText)) {
logger.info("taskText={}",taskText);
int matchNum = 0 ;
String msgid = null ;
for(QywxGroupMessageInfoDTO item : msgList) {
if(item.getDataStr().contains(taskText)) {
JSONObject j = JSONObject.parseObject(item.getDataStr()) ;
int size = j.getJSONArray("attachments").size() ;
if(size == count) {
msgid = item.getMsgId();
matchNum = matchNum + 1;
}
}
}
logger.info("matchNum=",matchNum);
if(matchNum == 1) {
return msgid ;
}
}
DingUtils.send("企微查询到多个群发任务,无法匹配",false);
return null ;
}
}
return null ;
}
private List<MaterialExternalResources> getTaskList(String taskId , String enterpriseId) {
MarketClueTaskDTO task = this.marketClueTaskApiService.getMarketClueTaskDTO(taskId, enterpriseId);
Long canvasId = task.getCanvasId();
Long nodeId = task.getNodeId();
ServiceResponse<CanvasNodeDTO<?>> nodeResp = this.canvasApiService.getCanvasNodeByNodeId(canvasId, nodeId);
logger.info("群发节点={}", JSONObject.toJSONString(nodeResp));
ServiceResponse<CanvasNodeDTO<QWMassContactNodeDTO>> massNodeResp = this.canvasApiService.convertToQWMassContactNode(nodeResp.getResult());
QWMassContactNodeDTO nodeDTO = massNodeResp.getResult().getNodeInfo();
List<MaterialExternalResources> canvasMaterialList = nodeDTO.getMaterialResourcesList();
return canvasMaterialList;
}
private String getTaskText(List<MaterialExternalResources> canvasMaterialList) {
// 1:文本,2:图片,3:网页,4:视频,5:文件, 6: 小程序,7:卡券
String s = "";
for(MaterialExternalResources res : canvasMaterialList) {
// 素材类型,1:文本,2:图片,3:网页,4:视频,5:文件, 6: 小程序,7:卡券
if(res.getMaterialType()==1) {
s = res.getContentText() ;
JSONObject json = new JSONObject() ;
json.put("content",s) ;
return json.toJSONString() ;
}
}
return s ;
}
private int getTaskNum(List<MaterialExternalResources> canvasMaterialList) {
// 1:文本,2:图片,3:网页,4:视频,5:文件, 6: 小程序,7:卡券
int num = 0 ;
for(MaterialExternalResources res : canvasMaterialList) {
// 素材类型,1:文本,2:图片,3:网页,4:视频,5:文件, 6: 小程序,7:卡券
if(res.getMaterialType()!=1) {
num = num + 1;
}
}
return num ;
}
private List<QywxGroupMessageInfoDTO> queryGroupMsg(GroupMessageServiceImpl.GroupMsgChatType groupMsgChatType, Date startTime, Date endTime , WxEnterpriseQwDTO qwDTO , String qwUserId) {
QywxGroupMessageQDTO qdto = new QywxGroupMessageQDTO();
qdto.setCorpid(qwDTO.getThirdCorpid());
......
......@@ -170,7 +170,7 @@ public class MaterialServiceImpl implements MaterialService {
return "";
}
public JSONResponse reUpdalodMetailJson(String materialId,int from) {
public JSONResponse reUpdalodMetailJson(String materialId,int from) {
JSONResponse jp = new JSONResponse() ;
MaterialDTO old = null ;
TabMaterialContent entity =null ;
......
......@@ -565,4 +565,15 @@ public class MaterialApiServiceImpl implements MaterialApiService {
return com.gic.api.base.commons.ServiceResponse.failure("9999", "获取图片失败,请稍后再试");
}
}
@Override
public List<String> getImageMediaId(String wxEnterpriseId, List<ContentMaterialDTO> imageList, int mediaType) {
List<String> list = this.materialService.getImageMediaId(wxEnterpriseId, imageList, mediaType);
if(CollectionUtils.isNotEmpty(list)) {
list.forEach(materialId -> {
materialService.getHasChangeMadieMaterialById(materialId, 2);
}) ;
}
return list ;
}
}
......@@ -780,7 +780,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
this.updateMemberGrowth(enterpriseId,memberId,clerkId);
}
String storeId = staffClerkRelationDTO.getStoreId();
this.saveExternalClerk(memberId, staffId, dto, staffClerkRelationDTO , 1);
this.saveExternalClerk(memberId, staffId, dto, staffClerkRelationDTO , 1 , 0);
// this.sendWelcome(dto, qwDTO, enterpriseId, staffId, clerkId,memberId);
//同步好友标签
this.pushTagSync(memberId, wxEnterpriseId, enterpriseId,null);
......@@ -812,7 +812,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
addDelFriendEvent(unionId, clerkId, wxEnterpriseId, enterpriseId, memberId, storeId, 1 , externalUserid,bo.isNewFlag());
return memberId;
}
private void saveExternalClerk(String memberId ,String staffId , MemberUnionidRelatedDTO dto , StaffClerkRelationDTO staffClerkRelation , int status) {
private void saveExternalClerk(String memberId ,String staffId , MemberUnionidRelatedDTO dto , StaffClerkRelationDTO staffClerkRelation , int status , int isFlush) {
String wxEnterpriseId = dto.getWxEnterpriseId() ;
String externalUserid = dto.getExternalUserid();
String relationKey = SecureUtil.md5(staffId + externalUserid);
......@@ -854,7 +854,13 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
if(exsitDTO.getStatusFlag()==1) {
if(StringUtils.isEmpty(exsitDTO.getSelfExternalUserid())) {
exsitDTO.setSelfExternalUserid(dto.getSelfExternalUserid());
exsitDTO.setExternalStatus(1);
if(isFlush==1) {
if(null == exsitDTO.getExternalStatus() || exsitDTO.getExternalStatus() !=3) {
exsitDTO.setExternalStatus(1);
}
}else {
exsitDTO.setExternalStatus(1);
}
this.externalClerkRelatedService.update(exsitDTO);
}
/* if(!dto.isFlush()) {
......@@ -976,7 +982,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
//发送欢迎语
// sendWelcome(dto, qwDTO, enterpriseId, staffId, clerkId,null);
//保存好友关系
this.saveExternalClerk(null, staffId, dto, staffClerkRelationDTO, 4);
this.saveExternalClerk(null, staffId, dto, staffClerkRelationDTO, 4 , 0);
}
/**
* 组装数据
......@@ -1582,7 +1588,7 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
if(StringUtils.isBlank(memberId)) {
statusFlag = 3 ;
}
this.saveExternalClerk(memberId, staffId, unionDTO, staffClerkRelation, statusFlag);
this.saveExternalClerk(memberId, staffId, unionDTO, staffClerkRelation, statusFlag , 1);
if(StringUtils.isNotBlank(memberId)) {
if(null == RedisUtil.getCache("zhuan_self")) {
this.pushTagSync(memberId, wxEnterpriseId, enterpriseId,dto.getExternalUseridInfo());
......@@ -1714,6 +1720,22 @@ public class MemberUnionidRelatedApiServiceImpl implements MemberUnionidRelatedA
}
memberApiService.updateMemberQywxEveryOccasion(related.getEnterpriseId(), memberId, 0, date,null);
}
//添加日志
WxUserAddLogQDTO wxUserAddLogQDTO = new WxUserAddLogQDTO();
wxUserAddLogQDTO.setWxEnterpriseId(wxEnterpriseId);
wxUserAddLogQDTO.setEnterpriseId(related.getEnterpriseId());
wxUserAddLogQDTO.setMemberId(related.getMemberId());
wxUserAddLogQDTO.setUnionid(related.getUnionid());
wxUserAddLogQDTO.setDelFlag(true);
wxUserAddLogQDTO.setExternalUserid(related.getExternalUserId());
wxUserAddLogQDTO.setStaffId(related.getStaffId());
wxUserAddLogQDTO.setClerkId(related.getClerkId());
if(null != related.getAddTime()) {
wxUserAddLogQDTO.setQwAddTime(related.getAddTime());
}
wxUserAddLogQDTO.setFriendClerkId(related.getClerkId());
wxUserAddLogQDTO.setFriendStoreId(related.getStoreId());
wxUserAddLogService.save(wxUserAddLogQDTO);
}
}
......
......@@ -265,5 +265,7 @@
<dubbo:reference interface="com.gic.haoban.task.api.service.TelTaskApiService" id="telTaskApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference interface="com.gic.haoban.task.manage.api.service.IMarketTaskMemberApiService" id="iMarketTaskMemberApiService"/>
<dubbo:reference id="settingApiService" interface="com.gic.haoban.task.api.service.SettingApiService" timeout="10000" retries="0" />
<dubbo:reference interface="com.gic.haoban.task.manage.api.service.IMarketClueTaskApiService" id="iMarketClueTaskApiService" timeout="10000" retries="0" check="false" />
<dubbo:reference id="canvasApiService" interface="com.gic.canvas.api.service.CanvasApiService" timeout="10000" retries="0" check="false"/>
</beans>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment