事件
This commit is contained in:
@@ -41,6 +41,12 @@
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>user-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
||||
@@ -34,4 +34,7 @@ public class ProjectEquipmentQueryParm {
|
||||
|
||||
@ApiModelProperty(value="项目类别")
|
||||
private String projectType;
|
||||
|
||||
@ApiModelProperty(value="运行状态")
|
||||
private String runStatus;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
* Date: 2023/7/5 15:09【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
|
||||
@Data
|
||||
public class DevUserVO {
|
||||
//
|
||||
@ApiModelProperty(value = "devId")
|
||||
private String devId;
|
||||
private User masterUser;
|
||||
private List<User> subUsers;
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -8,6 +8,7 @@ import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.enums.DeviceOperate;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.vo.DevCountVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevUserVO;
|
||||
import com.njcn.csdevice.service.CsDeviceUserPOService;
|
||||
import com.njcn.web.advice.DeviceLog;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
@@ -112,11 +113,21 @@ public class DeviceUserController extends BaseController {
|
||||
@ApiOperation("取消分享")
|
||||
@ApiImplicitParam(name = "eid", value = "设备Id", required = true)
|
||||
@DeviceLog(operateType = DeviceOperate.CANCELSHARE)
|
||||
public HttpResult<Boolean> cancelShare(@RequestParam("eid") String eid){
|
||||
public HttpResult<Boolean> cancelShare(@RequestParam("eid") String eid ,@RequestParam("userId") String userId){
|
||||
String methodDescribe = getMethodDescribe("cancelShare");
|
||||
Boolean flag = csDeviceUserPOService.cancelShare (eid,userId);
|
||||
|
||||
Boolean flag = csDeviceUserPOService.cancelShare (eid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
}
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryUserById")
|
||||
@ApiOperation("设备主子用户关系")
|
||||
@ApiImplicitParam(name = "devId", value = "设备Id", required = true)
|
||||
public HttpResult<DevUserVO> queryUserById(@RequestParam("devId") String devId){
|
||||
String methodDescribe = getMethodDescribe("queryUserById");
|
||||
|
||||
DevUserVO devUserVO = csDeviceUserPOService.queryUserById (devId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, devUserVO, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -61,6 +61,9 @@
|
||||
<if test="projectEquipmentQueryParm!=null and projectEquipmentQueryParm.engineerId != null and projectEquipmentQueryParm.engineerId !=''">
|
||||
AND a.id = #{projectEquipmentQueryParm.engineerId}
|
||||
</if>
|
||||
<if test="projectEquipmentQueryParm!=null and projectEquipmentQueryParm.runStatus != null and projectEquipmentQueryParm.runStatus !=''">
|
||||
AND c.run_status = #{projectEquipmentQueryParm.engineerId}
|
||||
</if>
|
||||
and c.id in
|
||||
<foreach collection="device" item="item" open="(" close=")" separator=",">
|
||||
#{item}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.csdevice.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.vo.DevCountVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevUserVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,7 +30,7 @@ public interface CsDeviceUserPOService extends IService<CsDeviceUserPO>{
|
||||
|
||||
Boolean delete(String eid);
|
||||
|
||||
Boolean cancelShare(String eid);
|
||||
Boolean cancelShare(String eid,String userId);
|
||||
/**
|
||||
* @Description: 设备恢复
|
||||
* @Param:
|
||||
@@ -38,4 +39,6 @@ public interface CsDeviceUserPOService extends IService<CsDeviceUserPO>{
|
||||
* @Date: 2023/7/27
|
||||
*/
|
||||
Boolean recovery(String eid);
|
||||
|
||||
DevUserVO queryUserById(String devId);
|
||||
}
|
||||
|
||||
@@ -16,11 +16,14 @@ import com.njcn.csdevice.mapper.CsMarketDataMapper;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevCountVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevUserVO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.cswarn.api.CsEquipmentAlarmFeignClient;
|
||||
import com.njcn.cswarn.pojo.parm.CsEquipmentAlarmParm;
|
||||
import com.njcn.cswarn.pojo.vo.CsEquipmentAlarmVO;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -58,6 +61,9 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final CsMarketDataMapper csMarketDataMapper;
|
||||
|
||||
private final UserFeignClient userFeignClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean add(String id) {
|
||||
@@ -288,17 +294,17 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public Boolean cancelShare(String eid) {
|
||||
public Boolean cancelShare(String eid,String userId) {
|
||||
String userIndex = RequestUtil.getUserIndex();
|
||||
//主用户
|
||||
if(Objects.equals(isPrimaryUser(eid),"1")){
|
||||
this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).ne(CsDeviceUserPO::getSubUserId,userIndex).set(CsDeviceUserPO::getStatus,"0").update();
|
||||
}
|
||||
//子用户
|
||||
else if (Objects.equals(isPrimaryUser(eid),"0")) {
|
||||
this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getSubUserId,userIndex).set(CsDeviceUserPO::getStatus,"0").update();
|
||||
// //主用户
|
||||
// if(Objects.equals(isPrimaryUser(eid),"1")){
|
||||
// this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).ne(CsDeviceUserPO::getSubUserId,userIndex).set(CsDeviceUserPO::getStatus,"0").update();
|
||||
// }
|
||||
// //子用户
|
||||
// else if (Objects.equals(isPrimaryUser(eid),"0")) {
|
||||
this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).eq(CsDeviceUserPO::getSubUserId,userId).set(CsDeviceUserPO::getStatus,"0").update();
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -318,4 +324,22 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
this.lambdaUpdate().eq(CsDeviceUserPO::getDeviceId, eid).set(CsDeviceUserPO::getStatus,"1").update();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DevUserVO queryUserById(String devId) {
|
||||
List<CsDeviceUserPO> list = this.lambdaQuery().eq(CsDeviceUserPO::getDeviceId, devId).eq(CsDeviceUserPO::getStatus, "1").list();
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
throw new BusinessException(AlgorithmResponseEnum.DATA_ARRAY_MISSING);
|
||||
}
|
||||
List<String> collect = list.stream().map(CsDeviceUserPO::getSubUserId).distinct().collect(Collectors.toList());
|
||||
List<User> data = userFeignClient.getUserByIdList(collect).getData();
|
||||
String primaryUserId = list.get(0).getPrimaryUserId();
|
||||
List<User> subUser = data.stream().filter(temp -> !Objects.equals(temp.getId(), primaryUserId)).collect(Collectors.toList());
|
||||
List<User> primaryUser = data.stream().filter(temp -> Objects.equals(temp.getId(), primaryUserId)).collect(Collectors.toList());
|
||||
DevUserVO devUser = new DevUserVO();
|
||||
devUser.setDevId(devId);
|
||||
devUser.setSubUsers(subUser);
|
||||
devUser.setMasterUser(primaryUser.get(0));
|
||||
return devUser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@@ -75,6 +76,10 @@ public class MqttMessageHandler {
|
||||
public void responseTopoData(String topic, @NamedValue("devId") String devId, MqttMessage message, @Payload String payload) {
|
||||
List<ThdDataVO> result = new ArrayList<>();
|
||||
List<ThdDataVO> tempList = new ArrayList<>();
|
||||
ExecutorService executorService = new ThreadPoolExecutor(40, 400,
|
||||
1, TimeUnit.MINUTES, new ArrayBlockingQueue<>(100, true),
|
||||
Executors.defaultThreadFactory(), new ThreadPoolExecutor.AbortPolicy());
|
||||
List<Future<List<ThdDataVO>>> resultList = new ArrayList< Future<List<ThdDataVO>>>();
|
||||
|
||||
//1.查询拓扑图配置的指标:拓扑图扑图配置:7677f94c749dedaff30f911949cbd724
|
||||
List<EleEpdPqd> data = csStatisticalSetFeignClient.queryStatisticalSelect("7677f94c749dedaff30f911949cbd724").getData();
|
||||
@@ -86,8 +91,8 @@ public class MqttMessageHandler {
|
||||
commonStatisticalQueryParam.setStatisticalId(temp.getId());
|
||||
commonStatisticalQueryParam.setValueType("avg");
|
||||
commonStatisticalQueryParam.setFrequency(i+"");
|
||||
List<ThdDataVO> thdDataVOS = stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
|
||||
tempList.addAll(thdDataVOS);
|
||||
Future<List<ThdDataVO>> listFuture= executorService.submit(new TaskWithResult(commonStatisticalQueryParam));
|
||||
resultList.add(listFuture);
|
||||
}
|
||||
|
||||
|
||||
@@ -96,11 +101,22 @@ public class MqttMessageHandler {
|
||||
commonStatisticalQueryParam.setDevId(devId);
|
||||
commonStatisticalQueryParam.setStatisticalId(temp.getId());
|
||||
commonStatisticalQueryParam.setValueType("avg");
|
||||
List<ThdDataVO> thdDataVOS = stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
|
||||
tempList.addAll(thdDataVOS);
|
||||
Future<List<ThdDataVO>> listFuture= executorService.submit(new TaskWithResult(commonStatisticalQueryParam));
|
||||
resultList.add(listFuture);
|
||||
}
|
||||
|
||||
});
|
||||
executorService.shutdown();
|
||||
|
||||
resultList.forEach(temp->{
|
||||
try {
|
||||
tempList.addAll(temp.get());
|
||||
} catch (InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (ExecutionException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
});
|
||||
//过滤M相
|
||||
List<ThdDataVO> m = tempList.stream().filter(temp -> Objects.equals(temp.getPhase(), "M")).collect(Collectors.toList());
|
||||
m.stream().forEach(temp->{
|
||||
@@ -198,4 +214,26 @@ public class MqttMessageHandler {
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
class TaskWithResult implements Callable<List<ThdDataVO>> {
|
||||
private CommonStatisticalQueryParam commonStatisticalQueryParam;
|
||||
|
||||
public TaskWithResult(CommonStatisticalQueryParam commonStatisticalQueryParam) {
|
||||
this.commonStatisticalQueryParam = commonStatisticalQueryParam;
|
||||
}
|
||||
|
||||
/**
|
||||
* 任务的具体过程,一旦任务传给ExecutorService的submit方法,则该方法自动在一个线程上执行。
|
||||
*
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@Override
|
||||
public List<ThdDataVO> call() throws Exception {
|
||||
List<ThdDataVO> thdDataVOList = new ArrayList<>();
|
||||
thdDataVOList = stableDataService.queryFisrtCommonStatistical(commonStatisticalQueryParam);
|
||||
|
||||
return thdDataVOList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.csharmonic.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/9/4 15:15【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsEventPOMapper extends BaseMapper<CsEventPO> {
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.csharmonic.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
* Date: 2023/9/4 15:15【需求编号】
|
||||
*
|
||||
* @author clam
|
||||
* @version V1.0.0
|
||||
*/
|
||||
public interface CsEventUserPOMapper extends BaseMapper<CsEventUserPO> {
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.csharmonic.mapper.CsEventPOMapper">
|
||||
<resultMap id="BaseResultMap" type="com.njcn.csharmonic.pojo.po.CsEventPO">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table cs_event-->
|
||||
<id column="id" jdbcType="VARCHAR" property="id" />
|
||||
<result column="line_id" jdbcType="VARCHAR" property="lineId" />
|
||||
<result column="device_id" jdbcType="VARCHAR" property="deviceId" />
|
||||
<result column="start_time" jdbcType="TIMESTAMP" property="startTime" />
|
||||
<result column="tag" jdbcType="VARCHAR" property="tag" />
|
||||
<result column="wave_id" jdbcType="VARCHAR" property="waveId" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
id, line_id, device_id, start_time, tag, wave_id
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -0,0 +1,16 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.csharmonic.mapper.CsEventUserPOMapper">
|
||||
<resultMap id="BaseResultMap" type="com.njcn.csharmonic.pojo.po.CsEventUserPO">
|
||||
<!--@mbg.generated-->
|
||||
<!--@Table cs_event_user-->
|
||||
<result column="device_id" jdbcType="VARCHAR" property="deviceId" />
|
||||
<result column="user_id" jdbcType="VARCHAR" property="userId" />
|
||||
<result column="event_id" jdbcType="VARCHAR" property="eventId" />
|
||||
<result column="status" jdbcType="INTEGER" property="status" />
|
||||
</resultMap>
|
||||
<sql id="Base_Column_List">
|
||||
<!--@mbg.generated-->
|
||||
device_id, user_id, event_id, `status`
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -21,6 +21,7 @@ import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
Reference in New Issue
Block a user