|
@@ -9,6 +9,8 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.tofly.api.WarningInfoClient;
|
|
|
+import com.tofly.common.core.entity.ResultRespone;
|
|
|
import com.tofly.common.oauth.util.SecurityUtils;
|
|
|
import com.tofly.notice.commons.CommonConstants;
|
|
|
import com.tofly.notice.config.ParameterConfig;
|
|
@@ -17,6 +19,7 @@ import com.tofly.notice.dto.TidingsSavtDto;
|
|
|
import com.tofly.notice.entity.Tidings;
|
|
|
import com.tofly.notice.service.TidingsService;
|
|
|
import com.tofly.notice.utils.SnowflakeUtils;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -34,6 +37,7 @@ import java.util.stream.Collectors;
|
|
|
* @author xqf
|
|
|
* @date Fri Oct 08 00:00:00 CST 2021
|
|
|
*/
|
|
|
+@Slf4j
|
|
|
@Service("tidingsService")
|
|
|
public class TidingsServiceImpl extends ServiceImpl<TidingsMapper, Tidings> implements TidingsService {
|
|
|
|
|
@@ -42,6 +46,8 @@ public class TidingsServiceImpl extends ServiceImpl<TidingsMapper, Tidings> impl
|
|
|
*/
|
|
|
@Autowired
|
|
|
private ParameterConfig parameterConfig;
|
|
|
+ @Autowired
|
|
|
+ private WarningInfoClient warningInfoClient;
|
|
|
|
|
|
* 查询消息列表
|
|
|
* @param page 分页
|
|
@@ -78,6 +84,19 @@ public class TidingsServiceImpl extends ServiceImpl<TidingsMapper, Tidings> impl
|
|
|
|
|
|
@Override
|
|
|
public boolean signRead(Long projectId) {
|
|
|
+
|
|
|
+ List<Long> list = this.listObjs(new QueryWrapper<Tidings>().select("distinct DATA_ID ").lambda().eq(Tidings::getProjectId,projectId)
|
|
|
+ .eq(Tidings::getIsreceive,CommonConstants.ZERO_SHORT).and(r->r.eq(Tidings::getReceiveUser, SecurityUtils.getUserId())
|
|
|
+ .or(j->j.isNull(Tidings::getReceiveUser).in(Tidings::getReceiveRole,SecurityUtils.getRoles()))
|
|
|
+
|
|
|
+ .or(j->j.isNull(Tidings::getReceiveUser).isNull(Tidings::getReceiveRole)))
|
|
|
+ ,o -> {
|
|
|
+ return Long.parseLong(String.valueOf(o));
|
|
|
+ });
|
|
|
+ if(!signReadWarning(list)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
return this.update(new UpdateWrapper<Tidings>().lambda().set(Tidings::getIsreceive,CommonConstants.ONE_SHORT)
|
|
|
.set(Tidings::getHandleUser,SecurityUtils.getUserId()).set(Tidings::getHandleTime,new Date())
|
|
|
.eq(Tidings::getProjectId,projectId)
|
|
@@ -87,6 +106,21 @@ public class TidingsServiceImpl extends ServiceImpl<TidingsMapper, Tidings> impl
|
|
|
.or(j->j.isNull(Tidings::getReceiveUser).isNull(Tidings::getReceiveRole))));
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ * 调用接口修改告警状态
|
|
|
+ * @param list
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private boolean signReadWarning(List<Long> list){
|
|
|
+ if(list!=null&&!list.isEmpty()) {
|
|
|
+ String ids = StringUtils.join(list,",");
|
|
|
+ ResultRespone respone = warningInfoClient.warningSignRead(ids);
|
|
|
+ if(respone!=null){
|
|
|
+ return (boolean) respone.getResult();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
* 保存消息
|
|
@@ -112,6 +146,14 @@ public class TidingsServiceImpl extends ServiceImpl<TidingsMapper, Tidings> impl
|
|
|
*/
|
|
|
@Override
|
|
|
public boolean readTidings(Long id) {
|
|
|
+ Long dataid = this.getObj(new QueryWrapper<Tidings>().select("distinct DATA_ID ").lambda().eq(Tidings::getId,id)
|
|
|
+ .eq(Tidings::getIsreceive,CommonConstants.ZERO_SHORT)
|
|
|
+ ,o -> {
|
|
|
+ return Long.parseLong(String.valueOf(o));
|
|
|
+ });
|
|
|
+ if(!signReadWarning(Arrays.asList(dataid))){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
return this.update(new UpdateWrapper<Tidings>().lambda().set(Tidings::getIsreceive,CommonConstants.ONE_SHORT)
|
|
|
.set(Tidings::getHandleUser,SecurityUtils.getUserId()).set(Tidings::getHandleTime,new Date())
|
|
|
.eq(Tidings::getId,id).eq(Tidings::getIsreceive,CommonConstants.ZERO_SHORT));
|
|
@@ -125,9 +167,25 @@ public class TidingsServiceImpl extends ServiceImpl<TidingsMapper, Tidings> impl
|
|
|
@Override
|
|
|
public Object batchReadTidings(String ids) {
|
|
|
try {
|
|
|
- List<Integer> list_id = strToListInt(ids);
|
|
|
+ List<Long> list_id = strToListInt(ids);
|
|
|
+ if(list_id==null||list_id.isEmpty()){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ List<Long> list = this.listObjs(new QueryWrapper<Tidings>().select("distinct DATA_ID ").lambda()
|
|
|
+ .eq(list_id.size()==1,Tidings::getId,list_id.get(0))
|
|
|
+ .in(list_id.size()>1,Tidings::getId,list_id)
|
|
|
+ .eq(Tidings::getIsreceive,CommonConstants.ZERO_SHORT)
|
|
|
+ ,o -> {
|
|
|
+ return Long.parseLong(String.valueOf(o));
|
|
|
+ });
|
|
|
+ if(!signReadWarning(list)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
return this.baseMapper.update(new Tidings(),new UpdateWrapper<Tidings>().lambda().set(Tidings::getIsreceive,CommonConstants.ONE_SHORT)
|
|
|
- .set(Tidings::getHandleUser,SecurityUtils.getUserId()).set(Tidings::getHandleTime,new Date()).in(Tidings::getId,list_id)
|
|
|
+ .set(Tidings::getHandleUser,SecurityUtils.getUserId()).set(Tidings::getHandleTime,new Date())
|
|
|
+ .eq(list_id.size()==1,Tidings::getId,list_id.get(0))
|
|
|
+ .in(list_id.size()>1,Tidings::getId,list_id)
|
|
|
.eq(Tidings::getIsreceive,CommonConstants.ZERO_SHORT));
|
|
|
}catch (Exception e){
|
|
|
log.error("异常:",e);
|
|
@@ -138,7 +196,13 @@ public class TidingsServiceImpl extends ServiceImpl<TidingsMapper, Tidings> impl
|
|
|
@Override
|
|
|
public Object batchDataReadTidings(String ids) {
|
|
|
try {
|
|
|
- List<Integer> list_id = strToListInt(ids);
|
|
|
+ List<Long> list_id = strToListInt(ids);
|
|
|
+ if(list_id==null||list_id.isEmpty()){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ if(!signReadWarning(list_id)){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
return this.baseMapper.update(new Tidings(),new UpdateWrapper<Tidings>().lambda().set(Tidings::getIsreceive,CommonConstants.ONE_SHORT)
|
|
|
.set(Tidings::getHandleUser,SecurityUtils.getUserId()).set(Tidings::getHandleTime,new Date()).in(Tidings::getDataId,list_id)
|
|
|
.eq(Tidings::getIsreceive,CommonConstants.ZERO_SHORT));
|
|
@@ -154,9 +218,9 @@ public class TidingsServiceImpl extends ServiceImpl<TidingsMapper, Tidings> impl
|
|
|
* @param str
|
|
|
* @return
|
|
|
*/
|
|
|
- public static List<Integer> strToListInt(String str){
|
|
|
+ public static List<Long> strToListInt(String str){
|
|
|
List<String> strs = Arrays.asList(str.split(CommonConstants.CSV));
|
|
|
- return strs.stream().map(st->Integer.parseInt(st)).collect(Collectors.toList());
|
|
|
+ return strs.stream().map(st->Long.parseLong(st)).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
|