|
@@ -1,7 +1,5 @@
|
|
|
package com.usky.iot.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -17,10 +15,12 @@ import com.usky.common.core.bean.ApiResult;
|
|
|
import com.usky.common.core.bean.CommonPage;
|
|
|
import com.usky.common.security.utils.SecurityUtils;
|
|
|
import com.usky.iot.domain.MceContent;
|
|
|
+import com.usky.iot.domain.MceMbuser;
|
|
|
import com.usky.iot.domain.MceReceive;
|
|
|
import com.usky.iot.domain.MceSetting;
|
|
|
import com.usky.iot.mapper.MceReceiveMapper;
|
|
|
import com.usky.iot.service.MceContentService;
|
|
|
+import com.usky.iot.service.MceMbuserService;
|
|
|
import com.usky.iot.service.MceReceiveService;
|
|
|
import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
import com.usky.iot.service.MceSettingService;
|
|
@@ -28,6 +28,7 @@ import com.usky.iot.service.config.HttpClientUtils;
|
|
|
import com.usky.system.RemoteUserService;
|
|
|
import com.usky.system.domain.SysUser;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
@@ -47,6 +48,9 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
|
|
|
@Autowired
|
|
|
private MceContentService mceContentService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private MceMbuserService mceMbuserService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RemoteUserService remoteUserService;
|
|
|
|
|
@@ -73,8 +77,9 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
|
|
|
.between(StringUtils.isNotBlank(startTime)&&StringUtils.isNotBlank(endTime),MceReceive::getCreateTime,
|
|
|
startTime,endTime)
|
|
|
.eq(StringUtils.isNotBlank(infoType),MceReceive::getInfoType, infoType)
|
|
|
-// .eq(MceReceive::getReceiverId, SecurityUtils.getUserId())
|
|
|
- .in(CollectionUtils.isNotEmpty(contentIds),MceReceive::getContentId,contentIds);
|
|
|
+ .eq(MceReceive::getReceiverId, SecurityUtils.getUserId())
|
|
|
+ .in(CollectionUtils.isNotEmpty(contentIds),MceReceive::getContentId,contentIds)
|
|
|
+ .orderByDesc(MceReceive::getId);
|
|
|
// .inSql(StringUtils.isNotBlank(infoTitle),MceReceive::getContentId,"SELECT id FROM mce_content WHERE " +
|
|
|
// "info_title like '%" + infoTitle + "%' AND tenant_id = "+SecurityUtils.getTenantId()+"");
|
|
|
page = this.page(page,lambdaQuery);
|
|
@@ -217,7 +222,6 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
|
|
|
|
|
|
@Override
|
|
|
public void add(String mceReceive){
|
|
|
- String appUrl = "https://fc-mp-85a26092-1305-4bf1-998f-b609512c8f7b.next.bspapp.com/uniPushMessage";
|
|
|
JSONObject mceReceiveVO = JSONObject.parseObject(mceReceive);
|
|
|
MceContent mceContent = new MceContent();
|
|
|
mceContent.setInfoTitle(mceReceiveVO.get("infoTitle").toString());
|
|
@@ -233,6 +237,13 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
|
|
|
ApiResult<List<SysUser>> userAllList = remoteUserService.userAllList();
|
|
|
List<SysUser> list = userAllList.getData();
|
|
|
if (CollectionUtils.isNotEmpty(list)) {
|
|
|
+ List<Integer> userIds = new ArrayList<>();
|
|
|
+ for (int g = 0; g < list.size(); g++) {
|
|
|
+ userIds.add(list.get(g).getUserId().intValue());
|
|
|
+ }
|
|
|
+ LambdaQueryWrapper<MceMbuser> lambdaQuery3 = Wrappers.lambdaQuery();
|
|
|
+ lambdaQuery3.in(MceMbuser::getUserId,userIds);
|
|
|
+ List<MceMbuser> list3 = mceMbuserService.list(lambdaQuery3);
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
MceReceive mceReceive1 = new MceReceive();
|
|
|
mceReceive1.setReceiverId(list.get(i).getUserId().intValue());
|
|
@@ -251,19 +262,18 @@ public class MceReceiveServiceImpl extends AbstractCrudService<MceReceiveMapper,
|
|
|
List<MceSetting> list1 = mceSettingService.list(lambdaQuery);
|
|
|
if (CollectionUtils.isNotEmpty(list1)){
|
|
|
JSONObject appMode = JSONObject.parseObject(list1.get(0).getAppMode());
|
|
|
- if (appMode.get(mceReceiveVO.get("infoType").toString()).equals(true)){
|
|
|
- JsonObject jsonObject = new JsonObject();
|
|
|
- jsonObject.addProperty("cids", "b9ba637d52b3eca1cd15d9d1ede4d00b");
|
|
|
- jsonObject.addProperty("title", mceReceiveVO.get("infoTitle").toString());
|
|
|
- jsonObject.addProperty("content", mceReceiveVO.get("infoContent").toString());
|
|
|
-// HashMap map1 = new HashMap();
|
|
|
-// map1.put("text", "b0e7580c39166f9f8d5ed20da807ba1f");
|
|
|
-// map.put("payload", map1);
|
|
|
- String resultString = HttpClientUtils.doPostJson(appUrl,jsonObject.toString());
|
|
|
- }
|
|
|
JSONObject wcMode = JSONObject.parseObject(list1.get(0).getWcMode());
|
|
|
- if (wcMode.get(mceReceiveVO.get("infoType").toString()).equals(true)){
|
|
|
-
|
|
|
+ for (int j = 0; j < list3.size(); j++){
|
|
|
+ if (appMode.get(mceReceiveVO.get("infoType").toString()).equals(true)){
|
|
|
+ if (list.get(i).getUserId().equals(list3.get(j).getUserId()) && StringUtils.isNotBlank(list3.get(j).getCids())){
|
|
|
+ mceContentService.sendApp(mceReceiveVO,list3.get(j).getCids(),0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (wcMode.get(mceReceiveVO.get("infoType").toString()).equals(true)){
|
|
|
+ if (list.get(i).getUserId().equals(list3.get(j).getUserId()) && StringUtils.isNotBlank(list3.get(j).getCids())){
|
|
|
+ mceContentService.sendApp(mceReceiveVO,list3.get(j).getCids(),1);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|