暂降事件

This commit is contained in:
huangzj
2023-09-06 14:21:47 +08:00
parent 61a9a99e47
commit 61ebd8830e
25 changed files with 478 additions and 64 deletions

View File

@@ -5,6 +5,8 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.service.EventService;
import com.njcn.influx.pojo.dto.EventQueryDTO;
import com.njcn.influx.pojo.po.cs.EntData;
@@ -36,10 +38,24 @@ public class EventController extends BaseController {
@PostMapping("/queryEvent")
@ApiOperation("暂降事件查询")
@ApiImplicitParam(name = "eventQueryDTO", value = "暂降事件查询参数", required = true)
@Deprecated
public HttpResult<List<EntData>> queryEvent(@RequestBody EventQueryDTO eventQueryDTO) {
String methodDescribe = getMethodDescribe("queryEvent");
List<EntData> list = eventService.queryEvent(eventQueryDTO);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryEventList")
@ApiOperation("暂降事件列表查询")
@ApiImplicitParam(name = "csEventUserQueryParam", value = "暂降事件查询参数", required = true)
public HttpResult<List<EventDetailVO>> queryEventList(@RequestBody CsEventUserQueryParam csEventUserQueryParam) {
String methodDescribe = getMethodDescribe("queryEventList");
List<EventDetailVO> list = eventService.queryEventList(csEventUserQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -0,0 +1,44 @@
package com.njcn.csharmonic.controller;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* Description:
* Date: 2023/9/4 16:18【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Slf4j
@RestController
@RequestMapping("/eventUser")
@Api(tags = "暂降事件")
@AllArgsConstructor
public class EventUserController extends BaseController {
private final CsEventUserPOService csEventUserPOService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryEvent")
@ApiOperation("当天暂降事件未读消息")
@ApiImplicitParam(name = "csEventUserQueryParam", value = "暂降事件查询参数", required = true)
public HttpResult<Integer> queryEvent(@RequestBody CsEventUserQueryParam csEventUserQueryParam) {
String methodDescribe = getMethodDescribe("queryEvent");
Integer count = csEventUserPOService.queryEventCount(csEventUserQueryParam);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, count, methodDescribe);
}
}

View File

@@ -1,7 +1,12 @@
package com.njcn.csharmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
*
@@ -12,4 +17,7 @@ import com.njcn.csharmonic.pojo.po.CsEventUserPO;
* @version V1.0.0
*/
public interface CsEventUserPOMapper extends BaseMapper<CsEventUserPO> {
Integer queryEventCount(@Param("csEventUserQueryParam") CsEventUserQueryParam csEventUserQueryParam);
List<EventDetailVO> queryUserEventList(@Param("csEventUserQueryParam") CsEventUserQueryParam csEventUserQueryParam);
}

View File

@@ -4,7 +4,6 @@
<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" />
@@ -13,4 +12,38 @@
<!--@mbg.generated-->
device_id, user_id, event_id, `status`
</sql>
<select id="queryEventCount" resultType="java.lang.Integer">
select count(DISTINCT(event_id)) from cs_event_user a where 1=1
<!-- <if test="csEventUserQueryParam!=null and csEventUserQueryParam.enginnerId != null and csEventUserQueryParam.enginnerId !=''">-->
<!-- AND a.enginner_id =#{ csEventUserQueryParam.enginnerId}-->
<!-- </if>-->
<!-- <if test="csEventUserQueryParam!=null and csEventUserQueryParam.deviceId != null and csEventUserQueryParam.deviceId !=''">-->
<!-- AND a.device_id =#{ csEventUserQueryParam.deviceId}-->
<!-- </if>-->
AND a.`status`= 0
and a.user_id=#{ csEventUserQueryParam.userId}
and a.event_id in(select id FROM cs_event b where DATE(b.start_time) =DATE(NOW())
)
</select>
<select id="queryUserEventList" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">
select a.event_id id,a.user_id userId,a.status status,b.device_id deviceId,b.line_id lineId,
b.start_time startTime,b.tag tag ,b.wave_path wavePath, b.type type
from cs_event_user a inner join cs_event b on a.event_id=b.id where 1=1 and DATE(b.start_time) =DATE(NOW()) and b.tag in
<foreach collection="csEventUserQueryParam.target" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
<!-- <if test="csEventUserQueryParam!=null and csEventUserQueryParam.enginnerId != null and csEventUserQueryParam.enginnerId !=''">-->
<!-- AND a.enginner_id =#{ csEventUserQueryParam.enginnerId}-->
<!-- </if>-->
<!-- <if test="csEventUserQueryParam!=null and csEventUserQueryParam.deviceId != null and csEventUserQueryParam.deviceId !=''">-->
<!-- AND a.device_id =#{ csEventUserQueryParam.deviceId}-->
<!-- </if>-->
<if test="csEventUserQueryParam!=null and csEventUserQueryParam.status != null and csEventUserQueryParam.status !=''">
AND a.status =#{ csEventUserQueryParam.status}
</if>
and a.user_id=#{ csEventUserQueryParam.userId}
</select>
</mapper>

View File

@@ -1,4 +1,4 @@
package com.njcn.csharmonic.service.impl;
package com.njcn.csharmonic.service;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.baomidou.mybatisplus.extension.service.IService;

View File

@@ -0,0 +1,24 @@
package com.njcn.csharmonic.service;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import java.util.List;
/**
*
* Description:
* Date: 2023/9/4 15:15【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CsEventUserPOService extends IService<CsEventUserPO>{
Integer queryEventCount(CsEventUserQueryParam csEventUserQueryParam);
List<EventDetailVO> queryUserEventList(CsEventUserQueryParam csEventUserQueryParam);
}

View File

@@ -1,21 +0,0 @@
package com.njcn.csharmonic.service;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.mapper.CsEventUserPOMapper;
import com.njcn.csharmonic.service.impl.CsEventUserPOService;
/**
*
* Description:
* Date: 2023/9/4 15:15【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, CsEventUserPO> implements CsEventUserPOService{
}

View File

@@ -1,5 +1,7 @@
package com.njcn.csharmonic.service;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.influx.pojo.dto.EventQueryDTO;
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
import com.njcn.influx.pojo.po.cs.EntData;
@@ -16,4 +18,7 @@ import java.util.List;
public interface EventService {
List<EntData> queryEvent(EventQueryDTO eventQueryDTO);
List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam);
}

View File

@@ -1,12 +1,10 @@
package com.njcn.csharmonic.service;
package com.njcn.csharmonic.service.impl;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csharmonic.mapper.CsEventPOMapper;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.service.impl.CsEventPOService;
import com.njcn.csharmonic.service.CsEventPOService;
/**
*
* Description:

View File

@@ -1,16 +0,0 @@
package com.njcn.csharmonic.service.impl;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.baomidou.mybatisplus.extension.service.IService;
/**
*
* Description:
* Date: 2023/9/4 15:15【需求编号】
*
* @author clam
* @version V1.0.0
*/
public interface CsEventUserPOService extends IService<CsEventUserPO>{
}

View File

@@ -0,0 +1,52 @@
package com.njcn.csharmonic.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.pojo.po.DictData;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.stream.Collectors;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.mapper.CsEventUserPOMapper;
import com.njcn.csharmonic.service.CsEventUserPOService;
/**
*
* Description:
* Date: 2023/9/4 15:15【需求编号】
*
* @author clam
* @version V1.0.0
*/
@Service
@RequiredArgsConstructor
public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, CsEventUserPO> implements CsEventUserPOService{
private final DicDataFeignClient dicDataFeignClient;
@Override
public Integer queryEventCount(CsEventUserQueryParam csEventUserQueryParam) {
csEventUserQueryParam.setUserId(RequestUtil.getUserIndex());
Integer integer = this.getBaseMapper().queryEventCount(csEventUserQueryParam);
return integer;
}
@Override
public List<EventDetailVO> queryUserEventList(CsEventUserQueryParam csEventUserQueryParam) {
csEventUserQueryParam.setUserId(RequestUtil.getUserIndex());
if(CollectionUtil.isEmpty(csEventUserQueryParam.getTarget())){
/*获取所有暂态事件类型*/
List<DictData> data = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.APP_EVENT.getCode()).getData();
List<String> collect = data.stream().map(DictData::getCode).collect(Collectors.toList());
csEventUserQueryParam.setTarget(collect);
}
List<EventDetailVO> list = this.getBaseMapper().queryUserEventList(csEventUserQueryParam);
return list;
}
}

View File

@@ -2,18 +2,30 @@ package com.njcn.csharmonic.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.NjcnBeanUtil;
import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.csharmonic.service.EventService;
import com.njcn.influx.pojo.dto.EventDataSetDTO;
import com.njcn.influx.pojo.dto.EventQueryDTO;
import com.njcn.influx.pojo.po.cs.EntData;
import com.njcn.influx.service.EvtDataService;
import com.njcn.system.api.EleEvtFeignClient;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.po.EleEvtParm;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
@@ -29,8 +41,11 @@ import java.util.stream.Collectors;
public class EventServiceImpl implements EventService {
private final EvtDataService evtDataService;
private final CsLineFeignClient csLineFeignClient;
private final EpdFeignClient epdFeignClient;
private final CsLedgerFeignClient csLedgerFeignClient;
private final EpdFeignClient epdFeignClient;
private final CsEventUserPOService csEventUserPOService;
private final EleEvtFeignClient eleEvtFeignClient;
@Override
public List<EntData> queryEvent(EventQueryDTO eventQueryDTO) {
@@ -49,4 +64,33 @@ public class EventServiceImpl implements EventService {
List<EntData> eventData = evtDataService.getEventData(eventQueryDTO);
return eventData;
}
@Override
public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
List<EventDetailVO> list = csEventUserPOService.queryUserEventList(csEventUserQueryParam);
list.forEach(temp->{
DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData();
temp.setEquipmentName(devDetail.getEquipmentName());
temp.setProjectId(devDetail.getProjectId());
temp.setProjectName(devDetail.getProjectName());
temp.setEngineeringid(devDetail.getEngineeringid());
temp.setEngineeringName(devDetail.getEngineeringName());
EleEpdPqd data = epdFeignClient.findByName(temp.getTag()).getData();
List<EleEvtParm> data1 = eleEvtFeignClient.queryByPid(data.getId()).getData();
List<EventDataSetDTO> eventDataSetDTOS = new ArrayList<>();
for (EleEvtParm eleEvtParm : data1) {
EventDataSetDTO eventDataSetDTO = new EventDataSetDTO();
BeanUtils.copyProperties(eleEvtParm,eventDataSetDTO);
EventDataSetDTO evtData = evtDataService.getEventDataSet("evt_data", temp.getId(), eleEvtParm.getName());
eventDataSetDTO.setValue(evtData.getValue());
eventDataSetDTOS.add(eventDataSetDTO);
}
temp.setDataSet(eventDataSetDTOS);
});
return list;
}
}