|
|
|
@ -1,14 +1,20 @@
|
|
|
|
|
package com.shxy.xymanager_service.impl;
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
|
|
import cn.hutool.core.date.DateField;
|
|
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.github.pagehelper.Constant;
|
|
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
import com.shxy.xymanager_common.bean.ServiceBody;
|
|
|
|
|
import com.shxy.xymanager_common.dto.PhotoAndLineAndChannelDto;
|
|
|
|
|
import com.shxy.xymanager_common.dto.PhotoParamsDto;
|
|
|
|
|
import com.shxy.xymanager_common.dto.TerminalApkInfoDto;
|
|
|
|
|
import com.shxy.xymanager_common.dto.PhotoTimeResultDto;
|
|
|
|
|
import com.shxy.xymanager_common.dto.TerminalPhotoScheduleDto;
|
|
|
|
|
import com.shxy.xymanager_common.entity.Lines;
|
|
|
|
|
import com.shxy.xymanager_common.entity.TerminalChannels;
|
|
|
|
@ -20,20 +26,24 @@ import com.shxy.xymanager_common.model.*;
|
|
|
|
|
import com.shxy.xymanager_common.page.PageUtils;
|
|
|
|
|
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.vo.*;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.LinesDao;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalChannelsDao;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalPhotoDao;
|
|
|
|
|
import com.shxy.xymanager_dao.dao.TerminalsDao;
|
|
|
|
|
import com.shxy.xymanager_service.service.TerminalPhotoService;
|
|
|
|
|
import com.shxy.xymanager_service.service.TerminalScheduleRuleService;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.math.BigInteger;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 装置图片实现层
|
|
|
|
@ -54,6 +64,9 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
|
|
|
|
|
@Autowired
|
|
|
|
|
TerminalChannelsDao terminalChannelsDao;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
TerminalScheduleRuleService terminalScheduleRuleService;
|
|
|
|
|
|
|
|
|
|
@Value("${cma.server}")
|
|
|
|
|
private String server;
|
|
|
|
|
|
|
|
|
@ -62,6 +75,7 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
|
|
|
|
|
|
|
|
|
|
@Value("${photo.address}")
|
|
|
|
|
private String photoaddress;
|
|
|
|
|
|
|
|
|
|
@Value("${video.address}")
|
|
|
|
|
private String videoaddress;
|
|
|
|
|
|
|
|
|
@ -339,80 +353,115 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<Boolean> getPhotoTime(TerminalPhotoTimeVo vo) {
|
|
|
|
|
TerminalPhotosTimeModel model = new TerminalPhotosTimeModel();
|
|
|
|
|
List<TerminalPhotoScheduleDto> dtoList = terminalPhotoDao.selectPhotoSchedule(vo);
|
|
|
|
|
Map<String, List<TerminalPhotoScheduleDto>> map = dtoList.stream().collect(Collectors.groupingBy(TerminalPhotoScheduleDto::getCmid));
|
|
|
|
|
map.forEach((key, value) -> {
|
|
|
|
|
|
|
|
|
|
for (int j = 0; j < value.size(); j++) {
|
|
|
|
|
Short span = value.get(j).getSpan();
|
|
|
|
|
Date startTime = value.get(j).getStartTime();
|
|
|
|
|
List<TerminalPhotosTimeModel.PhotosTimeBean> beanList = Lists.newArrayList();
|
|
|
|
|
|
|
|
|
|
for(int j = 0; j<dtoList.size();j++){
|
|
|
|
|
TerminalPhotosTimeModel.PhotosTimeBean bean = new TerminalPhotosTimeModel.PhotosTimeBean();
|
|
|
|
|
Short span = dtoList.get(j).getSpan();
|
|
|
|
|
Date startTime = dtoList.get(j).getStartTime();
|
|
|
|
|
Short startHour = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[0]);
|
|
|
|
|
Short startMin = Short.parseShort(MyDateUtils.parseHourAndMinute(startTime).split("/")[1]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date endTime = value.get(j).getEndTime();
|
|
|
|
|
Date endTime = dtoList.get(j).getEndTime();
|
|
|
|
|
Short endTimeHour = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[0]);
|
|
|
|
|
Short endTimeMin = Short.parseShort(MyDateUtils.parseHourAndMinute(endTime).split("/")[1]);
|
|
|
|
|
|
|
|
|
|
Short span1 = -1;
|
|
|
|
|
Short span2 = -1;
|
|
|
|
|
if (span / 60 > 0) {
|
|
|
|
|
span1 = (short) (span / 60);
|
|
|
|
|
span2 = (short) (span % 60);
|
|
|
|
|
} else if (span < 60) {
|
|
|
|
|
span1 = (short) 0;
|
|
|
|
|
Short span1 =-1;
|
|
|
|
|
Short span2 =-1;
|
|
|
|
|
if(span/60 > 0) {
|
|
|
|
|
span1 =(short)(span/60);
|
|
|
|
|
span2 =(short)(span % 60);
|
|
|
|
|
}else if(span<60 ){
|
|
|
|
|
span1 = (short)0;
|
|
|
|
|
span2 = span;
|
|
|
|
|
}
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=schedule --cmdid=" + key + "\t" + "--channel=" + vo.getChannel() + "\t"
|
|
|
|
|
+ "--group=3 --hour1=" + startHour + "\t" + "--min1=" + startMin + "\t" + "--preset1=255 --hour2=" + endTimeHour + "\t" + "--min2=" + endTimeMin + "\t"
|
|
|
|
|
+ "--preset2=255 --hour3=" + span1 + "\t" + "--min3=" + span2 + "\t" + "--preset3=255";
|
|
|
|
|
ProcessExecUtils.exec(cmd);
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=schedule --cmdid="+dtoList.get(j).getCmid() +"\t" +"--channel="+ vo.getChannel() +"\t"
|
|
|
|
|
+ "--group=3 --hour1=" + startHour +"\t"+ "--min1=" + startMin +"\t"+ "--preset1=255 --hour2=" + endTimeHour +"\t"+ "--min2=" + endTimeMin +"\t"
|
|
|
|
|
+"--preset2=255 --hour3=" + span1 +"\t" + "--min3=" + span2 +"\t"+"--preset3=255";
|
|
|
|
|
ProcessExecUtils.exec(cmd);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return Asserts.success(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<TerminalPhotosParamsModel> getPhotoQueryParamList(PageVo vo) {
|
|
|
|
|
public ServiceBody<TerminalPhotosParamsModel> getPhotoQueryParam(Integer termId) {
|
|
|
|
|
String cmdId = terminalPhotoDao.selectCmdIdById(termId);
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=imgparams --cmdid="+cmdId +"\t" +"--flag=1 --rf=7";
|
|
|
|
|
ProcessExecUtils.exec(cmd);
|
|
|
|
|
TerminalPhotosParamsModel model = new TerminalPhotosParamsModel();
|
|
|
|
|
int pageindex = vo.getPageindex();
|
|
|
|
|
int pagesize = vo.getPagesize();
|
|
|
|
|
PageUtils.SetPage(pageindex, pagesize);
|
|
|
|
|
List<PhotoParamsDto> list = terminalPhotoDao.selectPhotoParams();
|
|
|
|
|
boolean empty = CollectionUtil.isEmpty(list);
|
|
|
|
|
if (empty) {
|
|
|
|
|
model.setList(new ArrayList<>());
|
|
|
|
|
} else {
|
|
|
|
|
List<TerminalPhotosParamsModel.PhotoParamsBean> beans = BeanUtil.copyToList(list, TerminalPhotosParamsModel.PhotoParamsBean.class, CopyOptions.create().ignoreCase());
|
|
|
|
|
model.setList(beans);
|
|
|
|
|
PhotoParamsDto dto= terminalPhotoDao.selectPhotoParams(termId);
|
|
|
|
|
if(dto!=null) {
|
|
|
|
|
BeanUtils.copyProperties(dto, model);
|
|
|
|
|
DateTime now = DateTime.now();
|
|
|
|
|
model.setQueryTime(now);
|
|
|
|
|
}
|
|
|
|
|
PageInfo pageData = PageUtils.getPageData(list);
|
|
|
|
|
int currentpage = pageData.getPageNum();
|
|
|
|
|
model.setCurrentpage(currentpage);
|
|
|
|
|
long total = pageData.getTotal();
|
|
|
|
|
model.setTotal(total);
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int pageSize = pageData.getPageSize();
|
|
|
|
|
model.setPagesize(pageSize);
|
|
|
|
|
int pages = pageData.getPages();
|
|
|
|
|
model.setTotalpage(pages);
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<String> addOrUpdatePhotoParams(PhotoParamsVo vo) {
|
|
|
|
|
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
Integer result = terminalPhotoDao.updateOrInsertParams(vo);
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=imgparams --cmdid="+vo.getCmdId() +"\t" +"--color=" +vo.getColor() +"\t" + "--resolution="+ vo.getResolution() +"\t"
|
|
|
|
|
+ "--luminance=" + vo.getLuminance() +"\t"+ "-contrast=" + vo.getContrast() +"\t"+ "--saturation=" + vo.getSaturation();
|
|
|
|
|
ProcessExecUtils.exec(cmd);
|
|
|
|
|
if(result>0){
|
|
|
|
|
return Asserts.success("操作成功");
|
|
|
|
|
}
|
|
|
|
|
return Asserts.error("操作失败");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<String> updatePhotoParams(PhotoParamsVo vo) {
|
|
|
|
|
String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --port=6891 --act=imgparams --cmdid=" + vo.getCmdId() + "\t" + "--color=" + vo.getColor() + "\t" + "--resolution=" + vo.getResolution() + "\t"
|
|
|
|
|
+ "--luminance=" + vo.getLuminance() + "\t" + "-contrast=" + vo.getContrast() + "\t" + "--saturation=" + vo.getSaturation();
|
|
|
|
|
Integer recode = ProcessExecUtils.exec(cmd);
|
|
|
|
|
if (recode == 0) {
|
|
|
|
|
return Asserts.success("更新成功");
|
|
|
|
|
public ServiceBody<TerminalPhotosParamsModel> getLastedPhotoQueryParam(ReturnedPhotoParamsVo vo) {
|
|
|
|
|
Boolean hasNew;
|
|
|
|
|
BigInteger photoTime = terminalPhotoDao.getLatestPhotoParam(vo.getTermId());
|
|
|
|
|
BigInteger localPhotoTime = MyDateUtils.TimeMillSecond2Second(vo.getPhotoTime());
|
|
|
|
|
hasNew = photoTime.compareTo(localPhotoTime)<0?false:true;
|
|
|
|
|
if(hasNew){
|
|
|
|
|
PhotoParamsDto dto= terminalPhotoDao.selectPhotoParams(vo.getTermId());
|
|
|
|
|
if(null!=dto){
|
|
|
|
|
TerminalPhotosParamsModel model = new TerminalPhotosParamsModel();
|
|
|
|
|
BeanUtils.copyProperties(dto,model);
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return Asserts.error("更新失败");
|
|
|
|
|
return Asserts.success(null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ServiceBody<TerminalScheduleRuleTimeListModel> selectPhotoTime(TerminalReqPhotoTimeVo vo) {
|
|
|
|
|
String result = terminalPhotoDao.getRequestResult(vo.getRequestId());
|
|
|
|
|
TerminalScheduleRuleTimeListModel model = new TerminalScheduleRuleTimeListModel();
|
|
|
|
|
if(StringUtils.isNotBlank(result)){
|
|
|
|
|
JSONObject resultObj =JSONObject.parseObject(result);
|
|
|
|
|
List<PhotoTimeResultDto> resultDtoList = JSONArray.parseArray(resultObj.get("groupData").toString(), PhotoTimeResultDto.class);
|
|
|
|
|
List<String> resultList = Lists.newArrayList();
|
|
|
|
|
String startTimeStr = resultDtoList.get(0).getHour()+":"+resultDtoList.get(0).getMinute()+":00";
|
|
|
|
|
String endTimeStr = resultDtoList.get(1).getHour()+":"+resultDtoList.get(1).getMinute()+":00";
|
|
|
|
|
Date startTime = DateUtil.parseTime(startTimeStr);
|
|
|
|
|
Date endTime = DateUtil.parseTime(endTimeStr);
|
|
|
|
|
Integer span = resultDtoList.get(2).getHour()*60+resultDtoList.get(2).getMinute();
|
|
|
|
|
List<DateTime> dateTimes = MyDateUtils.rangeToList(startTime, endTime, DateField.MINUTE, span);
|
|
|
|
|
for (DateTime data : dateTimes) {
|
|
|
|
|
String dateTime = DateUtil.formatTime(data);
|
|
|
|
|
resultList.add(dateTime);
|
|
|
|
|
}
|
|
|
|
|
model.setList(resultList);
|
|
|
|
|
}else {
|
|
|
|
|
TerminalAndChannelIdVo idVo = new TerminalAndChannelIdVo();
|
|
|
|
|
BeanUtils.copyProperties(vo,idVo);
|
|
|
|
|
ServiceBody<TerminalScheduleRuleTimeListModel> listModel = terminalScheduleRuleService.getChannelSchelduleRule(idVo);
|
|
|
|
|
model = listModel.getData();
|
|
|
|
|
}
|
|
|
|
|
return Asserts.success(model);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|