#20230506 欣影管理平台拍照功能代码

jni
18616268358 2 years ago
parent 5d7f3ce1d8
commit df73f959d4

@ -9,10 +9,7 @@ import com.shxy.xymanager_common.entity.TerminalPhoto;
import com.shxy.xymanager_common.model.TerminalPhotoListForOpenModel; import com.shxy.xymanager_common.model.TerminalPhotoListForOpenModel;
import com.shxy.xymanager_common.model.TerminalPhotoListModel; import com.shxy.xymanager_common.model.TerminalPhotoListModel;
import com.shxy.xymanager_common.model.TerminalPhotosModel; import com.shxy.xymanager_common.model.TerminalPhotosModel;
import com.shxy.xymanager_common.vo.PageVo; import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_common.vo.TerminalAndChannelIdAndTimeVo;
import com.shxy.xymanager_common.vo.TerminalAndTimeForOpenVo;
import com.shxy.xymanager_common.vo.TerminalPhotoVo;
import com.shxy.xymanager_service.service.TerminalPhotoService; import com.shxy.xymanager_service.service.TerminalPhotoService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@ -63,6 +60,19 @@ public class TerminalPhotoController extends BaseController {
} }
} }
@ApiOperation(value = "拍照时间表", notes = "图片查询接口", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getPhotoTime")
@Log(title = "拍照时间表", type = "查询")
public ResponseReult<Boolean> getPhotoTime(@RequestBody @Validated TerminalPhotoTimeVo vo) {
ServiceBody<Boolean> serviceBody = terminalPhotoService.getPhotoTime(vo);
if (serviceBody.getCode() == ServiceStatus.SUCCESS) {
return ResponseReult.success(serviceBody.getData());
} else {
return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg());
}
}
@ApiOperation(value = "图片查询", notes = "图片查询接口", httpMethod = "POST") @ApiOperation(value = "图片查询", notes = "图片查询接口", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})

@ -0,0 +1,22 @@
package com.shxy.xymanager_common.dto;
import cn.hutool.core.date.DateTime;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
@Data
public class TerminalPhotoScheduleDto implements Serializable {
private String cmid;
private Short span;
private Date startTime;
private Date endTime;
private static final long serialVersionUID = 1L;
}

@ -128,6 +128,16 @@ public class MyDateUtils extends DateUtil {
return format(str, "MM/dd"); return format(str, "MM/dd");
} }
/**
* "HH/MM"
*/
public static String parseHourAndMinute(Date str) {
if (str == null) {
return null;
}
return format(str, "HH/mm");
}
/** /**
* *
*/ */

@ -0,0 +1,22 @@
package com.shxy.xymanager_common.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
@Data
@ApiModel(value = "拍照时间表请求参数", description = "拍照时间表请求参数")
public class TerminalPhotoTimeVo {
@NotNull(message = "通道号")
@ApiModelProperty(value = "通道号", example = "123455")
private Short channel;
@NotNull(message = "装置ID不能缺少")
@ApiModelProperty(value = "装置ID", example = "123455")
private Short termId;
}

@ -1,6 +1,8 @@
package com.shxy.xymanager_dao.dao; package com.shxy.xymanager_dao.dao;
import com.shxy.xymanager_common.dto.TerminalPhotoScheduleDto;
import com.shxy.xymanager_common.entity.TerminalPhoto; import com.shxy.xymanager_common.entity.TerminalPhoto;
import com.shxy.xymanager_common.vo.TerminalPhotoTimeVo;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import javax.xml.crypto.Data; import javax.xml.crypto.Data;
@ -29,4 +31,8 @@ public interface TerminalPhotoDao {
List<TerminalPhoto> selectPhotos(); List<TerminalPhoto> selectPhotos();
List<TerminalPhoto> selectPhotoListForOpen(@Param("termId") Integer terminalid,@Param("starttime") BigInteger starttime, @Param("endtime") BigInteger endtime); List<TerminalPhoto> selectPhotoListForOpen(@Param("termId") Integer terminalid,@Param("starttime") BigInteger starttime, @Param("endtime") BigInteger endtime);
List<TerminalPhotoScheduleDto> selectPhotoSchedule(TerminalPhotoTimeVo vo);
} }

@ -55,6 +55,18 @@
order by photo_time desc order by photo_time desc
</select> </select>
<select id="selectPhotoSchedule" resultType="com.shxy.xymanager_common.dto.TerminalPhotoScheduleDto">
select
t.cmdid cmid,
tscr.start_time startTime,
end_time endTime,
span
from terminal_schedule_mapper tm left join terminal_schedule_rule tscr on tm.schedule_id = tscr.schedule_id
left join terminals t on tm.term_id=t.id
where tm.term_id = #{termId} and tm.channel_id = #{channel}
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap"> <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select select

@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateTime; import cn.hutool.core.date.DateTime;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.bean.ServiceBody; import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.dto.TerminalPhotoScheduleDto;
import com.shxy.xymanager_common.entity.TerminalPhoto; import com.shxy.xymanager_common.entity.TerminalPhoto;
import com.shxy.xymanager_common.exception.Asserts; import com.shxy.xymanager_common.exception.Asserts;
import com.shxy.xymanager_common.model.TerminalPhotoListForOpenModel; import com.shxy.xymanager_common.model.TerminalPhotoListForOpenModel;
@ -11,27 +12,20 @@ import com.shxy.xymanager_common.model.TerminalPhotoListModel;
import com.shxy.xymanager_common.model.TerminalPhotosModel; import com.shxy.xymanager_common.model.TerminalPhotosModel;
import com.shxy.xymanager_common.page.PageUtils; import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.util.MyDateUtils; import com.shxy.xymanager_common.util.MyDateUtils;
import com.shxy.xymanager_common.util.ProcessExecUtils;
import com.shxy.xymanager_common.util.StringUtils; import com.shxy.xymanager_common.util.StringUtils;
import com.shxy.xymanager_common.vo.PageVo; import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_common.vo.TerminalAndChannelIdAndTimeVo;
import com.shxy.xymanager_common.vo.TerminalAndTimeForOpenVo;
import com.shxy.xymanager_common.vo.TerminalPhotoVo;
import com.shxy.xymanager_dao.dao.TerminalPhotoDao; import com.shxy.xymanager_dao.dao.TerminalPhotoDao;
import com.shxy.xymanager_service.interaction.Cma;
import com.shxy.xymanager_service.service.TerminalPhotoService; import com.shxy.xymanager_service.service.TerminalPhotoService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.sf.jsqlparser.expression.StringValue;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import javax.validation.constraints.NotEmpty;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger; import java.math.BigInteger;
import java.util.ArrayList; import java.util.*;
import java.util.Date; import java.util.stream.Collectors;
import java.util.List;
/** /**
* *
@ -156,33 +150,10 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
@Override @Override
public ServiceBody<Boolean> getLatestPhoto(TerminalPhotoVo vo) { public ServiceBody<Boolean> getLatestPhoto(TerminalPhotoVo vo) {
/* Cma cma = new Cma(server, port);*/ /* Cma cma = new Cma(server, port);*/
String line = "";
StringBuffer sb = new StringBuffer();
String result = "";
Boolean hasNew = false; Boolean hasNew = false;
try { String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=capture --cmdid="+vo.getCmdid() +"\t" +"--channel="+ vo.getChannel() +"\t"+ "--preset=255 --type=0";
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=capture --cmdid="+vo.getCmdid() +"\t" +"--channel="+ vo.getChannel() +"\t"+ "--preset=255 --type=0"; Integer result = ProcessExecUtils.exec(cmd);
Process ps = Runtime.getRuntime().exec(cmd); hasNew = result == 0?true:false;
log.info("传入cmd信息:{}",cmd);
BufferedReader reader = new BufferedReader(new InputStreamReader(ps.getInputStream()));
int sendToCode = ps.waitFor();
log.info("进程返回结果:{}",sendToCode);
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
result = sb.toString();
if(StringUtils.isNotBlank(result)){
log.info("查询最新图片结果:{}",result);
hasNew =true;
}
} catch (IOException e) {
log.error("IOException",e);
} catch (InterruptedException e) {
log.error("InterruptedException",e);
}
/* Boolean hasNew = cma.requestCapture(vo.getCmdid(), vo.getChannel(), vo.getPreset(), vo.getCaptureType());*/ /* Boolean hasNew = cma.requestCapture(vo.getCmdid(), vo.getChannel(), vo.getPreset(), vo.getCaptureType());*/
return Asserts.success(hasNew); return Asserts.success(hasNew);
} }
@ -242,4 +213,56 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
return Asserts.success(model); return Asserts.success(model);
} }
@Override
public ServiceBody<Boolean> getPhotoTime(TerminalPhotoTimeVo vo) {
List<TerminalPhotoScheduleDto> dtoList = terminalPhotoDao.selectPhotoSchedule(vo);
Map<String,List<TerminalPhotoScheduleDto>> map =dtoList.stream().collect(Collectors.groupingBy(TerminalPhotoScheduleDto :: getCmid)) ;
map.forEach((key,value) ->{
Short[] timeList = new Short[255];
int i = 0 ;
for(int j = 0; j<value.size();j++){
Short span = value.get(j).getSpan();
Date startTime = value.get(j).getStartTime();
Short startHour = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[0]);
Short startMin = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[1]);
timeList[i]= startHour;
i++;
timeList[i]= startMin;
i++;
timeList[i]= 255;
Date endTime = value.get(j).getStartTime();
Short endTimeHour = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[0]);
Short endTimeMin = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[1]);
i++;
timeList[i]= endTimeHour;
i++;
timeList[i]= endTimeMin;
i++;
timeList[i]= 255;
String spanStr;
if(span/60 > 0) {
i++;
timeList[i]= (short)(span/60);
i++;
timeList[i]= (short)(span % 60);
}else if(span<60 ){
i++;
timeList[i]= (short)0;
i++;
timeList[i]= span ;
}
i++;
timeList[i]= 255 ;
};
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=updateSchedule[0xCA] --cmdid="+key +"\t" +"--channel="+ vo.getChannel() +"\t"+ "--scheduleData="+timeList;
ProcessExecUtils.exec(cmd);
});
return Asserts.success(true);
}
} }

@ -5,10 +5,7 @@ import com.shxy.xymanager_common.entity.TerminalPhoto;
import com.shxy.xymanager_common.model.TerminalPhotoListForOpenModel; import com.shxy.xymanager_common.model.TerminalPhotoListForOpenModel;
import com.shxy.xymanager_common.model.TerminalPhotoListModel; import com.shxy.xymanager_common.model.TerminalPhotoListModel;
import com.shxy.xymanager_common.model.TerminalPhotosModel; import com.shxy.xymanager_common.model.TerminalPhotosModel;
import com.shxy.xymanager_common.vo.PageVo; import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_common.vo.TerminalAndChannelIdAndTimeVo;
import com.shxy.xymanager_common.vo.TerminalAndTimeForOpenVo;
import com.shxy.xymanager_common.vo.TerminalPhotoVo;
/** /**
* *
@ -52,4 +49,11 @@ public interface TerminalPhotoService {
*/ */
ServiceBody<TerminalPhotosModel> getPhotoBanner(PageVo vo); ServiceBody<TerminalPhotosModel> getPhotoBanner(PageVo vo);
/**
*
*
* @return
*/
ServiceBody<Boolean> getPhotoTime(TerminalPhotoTimeVo vo);
} }

Loading…
Cancel
Save