1:新增海康AI

2:修改用户行为BUG
master
yangzhe123 2025-12-11 16:45:24 +08:00
parent 1c20338cbb
commit ad2aff5d3d
14 changed files with 265 additions and 20 deletions

View File

@ -137,7 +137,7 @@ public interface JcskSyRMapper extends BaseMapper<JcskSyR> {
<script> <script>
select to_char(t.tm,'YYYY-MM-DD') as tm,t.rz select to_char(t.tm,'YYYY-MM-DD') as tm,t.rz
from public.st_rsvr_r t from public.st_rsvr_r t
where to_char(t.tm, 'HH24:MI:SS') = '08:00:00' and t.stcd = #{stcd} where to_char(t.tm, 'HH24') = '08:00:00' and t.stcd = #{stcd}
<if test="obj.dateTimeRangeSo != null and obj.dateTimeRangeSo.start != null"> <if test="obj.dateTimeRangeSo != null and obj.dateTimeRangeSo.start != null">
and t.tm <![CDATA[>=]]> #{obj.dateTimeRangeSo.start} and t.tm <![CDATA[>=]]> #{obj.dateTimeRangeSo.start}
</if> </if>

View File

@ -0,0 +1,36 @@
package com.gunshi.project.hsz.controller;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R;
import com.gunshi.project.hsz.entity.so.ISCAIEventPageSo;
import com.gunshi.project.hsz.model.ISCAIEvent;
import com.gunshi.project.hsz.service.ISCAIEventService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@Tag(name = "海康ai事件Controller")
@RestController
@RequestMapping(value="/iscaiEvent")
public class ISCAIEventController {
@Autowired
private ISCAIEventService iscaiEventService;
@Operation(summary = "分页")
@PostMapping("/page")
public R<Page<ISCAIEvent>> pageInfo(@RequestBody ISCAIEventPageSo dto) {
return R.ok(iscaiEventService.pageInfo(dto));
}
@Operation(summary = "列表")
@GetMapping("/list")
public R<List<ISCAIEvent>> list() {
return R.ok(iscaiEventService.lambdaQuery().list());
}
}

View File

@ -60,6 +60,9 @@ public class ResPlanBController extends AbstractCommonFileController{
if (Objects.isNull(service.getById(dto.getId()))) { if (Objects.isNull(service.getById(dto.getId()))) {
throw new IllegalArgumentException("当前数据不存在"); throw new IllegalArgumentException("当前数据不存在");
} }
if(dto.getFiles() != null && !dto.getFiles().isEmpty()){
dto.setModitime(new Date());
}
boolean result = service.updateById(dto); boolean result = service.updateById(dto);
if (result) { if (result) {

View File

@ -0,0 +1,54 @@
package com.gunshi.project.hsz.entity.so;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.db.dto.PageSo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import java.time.LocalDateTime;
@Data
@Schema(description = "海康AI事件分页Dto")
public class ISCAIEventPageSo {
@NotNull(message = "分页参数不能为空")
@Schema(description = "分页参数")
private PageSo pageSo;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "开始时间")
private LocalDateTime startTime;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "结束时间")
private LocalDateTime endTime;
/*
,1-2-3-
*/
@Schema(description = "事件等级 1-低2-中3-高")
private Integer eventLevel;
/*
0-1-
*/
@Schema(description = "事件处理状态 0-未处理1-已处理")
private Integer handleStatus;
/*
*/
@Schema(description = "事件类型名称")
private String eventTypeName;
/*
*/
@Schema(description = "事件源名称")
private String resName;
}

View File

@ -85,7 +85,7 @@ public interface AttResBaseMapper extends BaseMapper<AttResBase> {
<if test="obj.etm != null "> <if test="obj.etm != null ">
and t.tm <![CDATA[<=]]> to_timestamp(#{obj.etm},'YYYY-MM-DD HH24:MI:SS') and t.tm <![CDATA[<=]]> to_timestamp(#{obj.etm},'YYYY-MM-DD HH24:MI:SS')
</if> </if>
and TRIM(TO_CHAR(t.tm, 'MI:SS')) = '05:00' and TRIM(TO_CHAR(t.tm, 'SS')) = '00'
order by t.tm desc order by t.tm desc
</script> </script>
""") """)
@ -230,7 +230,7 @@ public interface AttResBaseMapper extends BaseMapper<AttResBase> {
where t.stcd = #{obj.stcd} where t.stcd = #{obj.stcd}
and t.tm <![CDATA[>=]]> to_timestamp(#{obj.stm},'YYYY-MM-DD HH24:MI:SS') and t.tm <![CDATA[>=]]> to_timestamp(#{obj.stm},'YYYY-MM-DD HH24:MI:SS')
and t.tm <![CDATA[<=]]> to_timestamp(#{obj.etm},'YYYY-MM-DD HH24:MI:SS') and t.tm <![CDATA[<=]]> to_timestamp(#{obj.etm},'YYYY-MM-DD HH24:MI:SS')
and TRIM(TO_CHAR(t.tm, 'MI:SS')) = '00:00' and TRIM(TO_CHAR(t.tm, 'SS')) = '00'
order by t.tm desc order by t.tm desc
</script> </script>
""") """)

View File

@ -0,0 +1,13 @@
package com.gunshi.project.hsz.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.gunshi.project.hsz.model.ISCAIEvent;
import org.apache.ibatis.annotations.Mapper;
/**
* @author lyf
* @since 2025-11-04
*/
@Mapper
public interface ISCAIEventMapper extends BaseMapper<ISCAIEvent> {
}

View File

@ -33,13 +33,13 @@ public interface ProjectEventsMapper extends BaseMapper<ProjectEvents> {
@Select(""" @Select("""
<script> <script>
select t.id,t.report_time as eventsDate,t.maintain_content as eventsDesc,3 as type from public.maintain_service t select t.id,t.fill_time as eventsDate,t.mentence_context as eventsDesc,3 as type from public.mentence_farmer_record t
<where> <where>
<if test="obj.dateSo != null and obj.dateSo.start != null"> <if test="obj.dateSo != null and obj.dateSo.start != null">
t.report_time <![CDATA[>=]]> #{obj.dateSo.start} t.fill_time <![CDATA[>=]]> #{obj.dateSo.start}
</if> </if>
<if test="obj.dateSo != null and obj.dateSo.end != null"> <if test="obj.dateSo != null and obj.dateSo.end != null">
and t.report_time <![CDATA[<=]]> #{obj.dateSo.end} and t.fill_time <![CDATA[<=]]> #{obj.dateSo.end}
</if> </if>
</where> </where>
</script> </script>

View File

@ -0,0 +1,53 @@
package com.gunshi.project.hsz.model;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.time.LocalDateTime;
/**
* @author lyf
* @since 2025-11-04
*/
@Data
@TableName("isc_ai_event")
public class ISCAIEvent {
@TableId(value="id", type = IdType.INPUT)
private String id;
@TableField("json")
private String json;
@TableField("starttime")
private LocalDateTime startTime;
@TableField("endtime")
private LocalDateTime endTime;
/*
,1-2-3-
*/
@TableField("eventlevel")
private Integer eventLevel;
/*
0-1-
*/
@TableField("handlestatus")
private Integer handleStatus;
/*
*/
@TableField("eventtypename")
private String eventTypeName;
/*
*/
@TableField("resname")
private String resName;
/*
*/
@TableField("resindexcode")
private String resIndexCode;
}

View File

@ -53,8 +53,8 @@ public class ForecastDispatchPlanService extends ServiceImpl<ForecastDispatchPla
if(!StringUtils.isBlank(pageSo.getPlanName())){ if(!StringUtils.isBlank(pageSo.getPlanName())){
queryWrapper.like(ForecastDispatchPlan::getPlanName, pageSo.getPlanName()); queryWrapper.like(ForecastDispatchPlan::getPlanName, pageSo.getPlanName());
} }
Page<ForecastDispatchPlan> forecastDispatchPlanPage = this.baseMapper.selectPage(pageSo.getPageSo().toPage(), queryWrapper);
queryWrapper.orderByDesc(ForecastDispatchPlan::getCreateTime); queryWrapper.orderByDesc(ForecastDispatchPlan::getCreateTime);
Page<ForecastDispatchPlan> forecastDispatchPlanPage = this.baseMapper.selectPage(pageSo.getPageSo().toPage(), queryWrapper);
for (ForecastDispatchPlan record : forecastDispatchPlanPage.getRecords()) { for (ForecastDispatchPlan record : forecastDispatchPlanPage.getRecords()) {
List<ForecastDispatchCommand> forecastDispatchCommandList = forecastDispatchCommandService.lambdaQuery().eq(ForecastDispatchCommand::getPlanId, record.getId()).list(); List<ForecastDispatchCommand> forecastDispatchCommandList = forecastDispatchCommandService.lambdaQuery().eq(ForecastDispatchCommand::getPlanId, record.getId()).list();
record.setForecastDispatchCommands(forecastDispatchCommandList); record.setForecastDispatchCommands(forecastDispatchCommandList);

View File

@ -0,0 +1,49 @@
package com.gunshi.project.hsz.service;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.hsz.entity.so.ISCAIEventPageSo;
import com.gunshi.project.hsz.mapper.ISCAIEventMapper;
import com.gunshi.project.hsz.model.ISCAIEvent;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class ISCAIEventService extends ServiceImpl<ISCAIEventMapper, ISCAIEvent> {
public Page<ISCAIEvent> pageInfo(ISCAIEventPageSo dto) {
LambdaQueryWrapper<ISCAIEvent> queryWrapper = new LambdaQueryWrapper<>();
if (dto.getEventLevel() != null) {
queryWrapper.eq(ISCAIEvent::getEventLevel, dto.getEventLevel());
}
if(dto.getHandleStatus() != null){
queryWrapper.eq(ISCAIEvent::getHandleStatus, dto.getHandleStatus());
}
if(dto.getEventTypeName() != null){
queryWrapper.like(ISCAIEvent::getEventTypeName, dto.getEventTypeName());
}
if(dto.getResName() != null){
queryWrapper.like(ISCAIEvent::getResName, dto.getResName());
}
if(dto.getStartTime() != null){
queryWrapper.ge(ISCAIEvent::getStartTime, dto.getStartTime());
}
if(dto.getEndTime() != null){
queryWrapper.le(ISCAIEvent::getEndTime, dto.getEndTime());
}
queryWrapper.orderByDesc(ISCAIEvent::getStartTime);
Page<ISCAIEvent> iscaiEventPage = this.baseMapper.selectPage(dto.getPageSo().toPage(), queryWrapper);
return iscaiEventPage;
}
}

View File

@ -4,9 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.hsz.entity.so.MentenceStPageSo; import com.gunshi.project.hsz.entity.so.MentenceStPageSo;
import com.gunshi.project.hsz.mapper.MentenceFarmerRecordMapper;
import com.gunshi.project.hsz.mapper.MentencePlanDetailMapper; import com.gunshi.project.hsz.mapper.MentencePlanDetailMapper;
import com.gunshi.project.hsz.mapper.MentenceStDetailMapper; import com.gunshi.project.hsz.mapper.MentenceStDetailMapper;
import com.gunshi.project.hsz.mapper.MentenceStMapper; import com.gunshi.project.hsz.mapper.MentenceStMapper;
import com.gunshi.project.hsz.model.MentenceFarmerRecord;
import com.gunshi.project.hsz.model.MentencePlanDetail; import com.gunshi.project.hsz.model.MentencePlanDetail;
import com.gunshi.project.hsz.model.MentenceSt; import com.gunshi.project.hsz.model.MentenceSt;
import com.gunshi.project.hsz.model.MentenceStDetail; import com.gunshi.project.hsz.model.MentenceStDetail;
@ -26,6 +28,9 @@ public class MentenceStDetailService extends ServiceImpl<MentenceStDetailMapper,
@Autowired @Autowired
private MentencePlanDetailMapper mentencePlanDetailMapper; private MentencePlanDetailMapper mentencePlanDetailMapper;
@Autowired
private MentenceFarmerRecordMapper mentenceFarmerRecordMapper;
public boolean deleteById(Serializable id) { public boolean deleteById(Serializable id) {
LambdaQueryWrapper<MentencePlanDetail> queryWrapperDetail = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MentencePlanDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
queryWrapperDetail.eq(MentencePlanDetail::getMentenceStDetailId, id); queryWrapperDetail.eq(MentencePlanDetail::getMentenceStDetailId, id);
@ -56,8 +61,12 @@ public class MentenceStDetailService extends ServiceImpl<MentenceStDetailMapper,
for (MentenceStDetail record : mentenceStDetailPage.getRecords()) { for (MentenceStDetail record : mentenceStDetailPage.getRecords()) {
LambdaQueryWrapper<MentencePlanDetail> queryWrapperDetail = new LambdaQueryWrapper<>(); LambdaQueryWrapper<MentencePlanDetail> queryWrapperDetail = new LambdaQueryWrapper<>();
queryWrapperDetail.eq(MentencePlanDetail::getMentenceStDetailId, record.getId()); queryWrapperDetail.eq(MentencePlanDetail::getMentenceStDetailId, record.getId());
Long count = mentencePlanDetailMapper.selectCount(queryWrapperDetail); Long count1 = mentencePlanDetailMapper.selectCount(queryWrapperDetail);
if(count > 0) {
LambdaQueryWrapper<MentenceFarmerRecord> queryWrapperFarmerRecord = new LambdaQueryWrapper<>();
queryWrapperFarmerRecord.eq(MentenceFarmerRecord::getMentenceStDetailId,record.getId());
Long count2 = mentenceFarmerRecordMapper.selectCount(queryWrapperFarmerRecord);
if(count1 > 0 || count2 > 0) {
record.setHasUse(true); record.setHasUse(true);
} }
} }

View File

@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gunshi.project.hsz.entity.so.CommonDataPageSo; import com.gunshi.project.hsz.entity.so.CommonDataPageSo;
import com.gunshi.project.hsz.entity.vo.ProjectEventsVo; import com.gunshi.project.hsz.entity.vo.ProjectEventsVo;
import com.gunshi.project.hsz.mapper.HiddenInfoMapper;
import com.gunshi.project.hsz.mapper.ProjectEventsMapper; import com.gunshi.project.hsz.mapper.ProjectEventsMapper;
import com.gunshi.project.hsz.model.FileAssociations; import com.gunshi.project.hsz.model.FileAssociations;
import com.gunshi.project.hsz.model.HiddenInfo;
import com.gunshi.project.hsz.model.ProjectEvents; import com.gunshi.project.hsz.model.ProjectEvents;
import com.gunshi.project.hsz.model.TermiteSurvey; import com.gunshi.project.hsz.model.TermiteSurvey;
import com.gunshi.project.hsz.util.DataHandleUtil; import com.gunshi.project.hsz.util.DataHandleUtil;
@ -38,6 +40,9 @@ public class ProjectEventsService extends ServiceImpl<ProjectEventsMapper, Proje
@Autowired @Autowired
private FileAssociationsService fileService; private FileAssociationsService fileService;
@Autowired
private HiddenInfoMapper hiddenInfoMapper;
public Page<ProjectEvents> pageQuery(CommonDataPageSo page) { public Page<ProjectEvents> pageQuery(CommonDataPageSo page) {
LambdaQueryWrapper<ProjectEvents> query = Wrappers.lambdaQuery(); LambdaQueryWrapper<ProjectEvents> query = Wrappers.lambdaQuery();
if (ObjectUtils.isNotNull(page.getName())) { if (ObjectUtils.isNotNull(page.getName())) {
@ -220,6 +225,18 @@ public class ProjectEventsService extends ServiceImpl<ProjectEventsMapper, Proje
Map<String, List<FileAssociations>> map = files.stream().collect(Collectors.groupingBy(FileAssociations::getBusinessId)); Map<String, List<FileAssociations>> map = files.stream().collect(Collectors.groupingBy(FileAssociations::getBusinessId));
for (ProjectEventsVo vo : list){ for (ProjectEventsVo vo : list){
vo.setFiles(map.get(vo.getId().toString())); vo.setFiles(map.get(vo.getId().toString()));
if(vo.getType() == 3){
List<FileAssociations> fileAssociations = vo.getFiles() == null?new ArrayList<>():vo.getFiles();
//Java有Integer的缓存-128~127可以直接用==
LambdaQueryWrapper<HiddenInfo> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(HiddenInfo::getMentenceFarmerRecordId,vo.getId());
List<HiddenInfo> hiddenInfos = hiddenInfoMapper.selectList(queryWrapper);
hiddenInfos.stream().forEach(o ->{
List<FileAssociations> add = fileService.getFiles("mentenceFarmerRecord", o.getId().toString());
fileAssociations.addAll(add);
});
vo.setFiles(fileAssociations);
}
} }
} }

View File

@ -91,11 +91,16 @@ public class SysUserLoginLogController {
.collect(Collectors.toList()); .collect(Collectors.toList());
BigDecimal divisor = BigDecimal.valueOf(1000 * 60 * 60); BigDecimal divisor = BigDecimal.valueOf(1000 * 60 * 60);
vo.setWeb3Count( if(!webTimes.isEmpty()){
BigDecimal.valueOf(webTimes.stream().mapToLong(o -> o).sum()) vo.setWeb3Count(
.divide(BigDecimal.valueOf(webTimes.size()), 2, RoundingMode.HALF_UP) BigDecimal.valueOf(webTimes.stream().mapToLong(o -> o).sum())
.divide(divisor, 2, RoundingMode.HALF_UP) .divide(BigDecimal.valueOf(webTimes.size()), 2, RoundingMode.HALF_UP)
); .divide(divisor, 2, RoundingMode.HALF_UP)
);
}else{
vo.setWeb3Count(BigDecimal.ZERO);
}
vo.setApp1Count( vo.setApp1Count(
logs.stream() logs.stream()
@ -104,16 +109,21 @@ public class SysUserLoginLogController {
); );
List<Long> appTimes = logs.stream() List<Long> appTimes = logs.stream()
.filter(o -> "0".equals(o.getLoginType())) .filter(o -> "1".equals(o.getLoginType()))
.filter(o -> o.getLogoutTime() != null && o.getLoginTime() != null) .filter(o -> o.getLogoutTime() != null && o.getLoginTime() != null)
.map(o -> o.getLogoutTime().getTime() - o.getLoginTime().getTime()) .map(o -> o.getLogoutTime().getTime() - o.getLoginTime().getTime())
.collect(Collectors.toList()); .collect(Collectors.toList());
if(!appTimes.isEmpty()){
vo.setApp3Count(
BigDecimal.valueOf(appTimes.stream().mapToLong(o -> o).sum())
.divide(BigDecimal.valueOf(appTimes.size()),2, RoundingMode.HALF_UP)
.divide(divisor,2, RoundingMode.HALF_UP)
);
}else{
vo.setApp3Count(BigDecimal.ZERO);
}
vo.setApp3Count(
BigDecimal.valueOf(appTimes.stream().mapToLong(o -> o).sum())
.divide(BigDecimal.valueOf(appTimes.size()),2, RoundingMode.HALF_UP)
.divide(divisor,2, RoundingMode.HALF_UP)
);
LambdaQueryWrapper<SysVisitMenuLog> wrapperMenuLog = Wrappers.lambdaQuery(SysVisitMenuLog.class) LambdaQueryWrapper<SysVisitMenuLog> wrapperMenuLog = Wrappers.lambdaQuery(SysVisitMenuLog.class)
.eq(SysVisitMenuLog::getCreateTime, new Date()); .eq(SysVisitMenuLog::getCreateTime, new Date());

View File

@ -62,6 +62,7 @@ public class SysUserLogAspect {
} catch (ServiceException e) { } catch (ServiceException e) {
// log.info("获取登录账号id," + e.getMessage(), e); // log.info("获取登录账号id," + e.getMessage(), e);
log.info("获取登录账号id异常请重新登录"); log.info("获取登录账号id异常请重新登录");
loginUserId = 1l;
} }
if (loginUserId != null) { if (loginUserId != null) {