diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalController.java index 096dd49..3b1d535 100644 --- a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalController.java +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalController.java @@ -118,6 +118,32 @@ public class TerminalController extends BaseController { } } + @ApiOperation(value = "图像装置ID设置", notes = "图像装置ID设置", httpMethod = "POST") + @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) + @RequestMapping("/updateTerminalId") + @Log(title = "图像装置ID设置", type = "修改") + public ResponseReult updateTerminalId(@RequestBody @Validated TerminalIdUpdateVo vo) { + ServiceBody serviceBody = terminalService.updateTerminalId(vo); + if (serviceBody.getCode() == ServiceStatus.SUCCESS) { + return ResponseReult.success(serviceBody.getData()); + } else { + return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg()); + } + } + + @ApiOperation(value = "图像装置ID查询", notes = "图像装置ID查询接口", httpMethod = "POST") + @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) + @RequestMapping("/selectTerminalId") + @Log(title = "图像装置ID查询", type = "修改") + public ResponseReult selectTerminalId(@RequestBody @Validated TerminalIdUpdateVo vo) { + ServiceBody serviceBody = terminalService.updateTerminalId(vo); + if (serviceBody.getCode() == ServiceStatus.SUCCESS) { + return ResponseReult.success(serviceBody.getData()); + } else { + return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg()); + } + } + } diff --git a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalPhotoController.java b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalPhotoController.java index d0ef4d7..f6e525e 100644 --- a/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalPhotoController.java +++ b/xymanager_admin/src/main/java/com/shxy/xymanager_admin/controller/TerminalPhotoController.java @@ -58,7 +58,7 @@ public class TerminalPhotoController extends BaseController { } } - @ApiOperation(value = "拍照时间表", notes = "图片查询接口", httpMethod = "POST") + @ApiOperation(value = "拍照时间表", notes = "拍照时间表", httpMethod = "POST") @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @RequestMapping("/getPhotoTime") @Log(title = "拍照时间表", type = "查询") @@ -71,6 +71,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("/selectPhotoTime") + @Log(title = "拍照时间表查询", type = "查询") + public ResponseReult selectPhotoTime(@RequestBody @Validated TerminalReqPhotoTimeVo vo) { + ServiceBody serviceBody = terminalPhotoService.selectPhotoTime(vo); + if (serviceBody.getCode() == ServiceStatus.SUCCESS) { + return ResponseReult.success(serviceBody.getData()); + } else { + return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg()); + } + } + @ApiOperation(value = "图片查询", notes = "图片查询接口", httpMethod = "POST") @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @@ -124,12 +137,25 @@ public class TerminalPhotoController extends BaseController { } } - @ApiOperation(value = "图像采集参数列表查询", notes = "图像采集参数列表查询", httpMethod = "POST") + @ApiOperation(value = "图像采集参数查询", notes = "图像采集参数查询", httpMethod = "POST") @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @RequestMapping("/getPhotoQueryParamList") - @Log(title = "图像采集参数列表查询", type = "查询") - public ResponseReult getPhotoQueryParamList(@RequestBody @Validated PageVo vo) { - ServiceBody serviceBody = terminalPhotoService.getPhotoQueryParamList(vo); + @Log(title = "图像采集参数查询", type = "查询") + public ResponseReult getPhotoQueryParamList(@RequestParam("termId") Integer termId) { + ServiceBody serviceBody = terminalPhotoService.getPhotoQueryParam(termId); + if (serviceBody.getCode() == ServiceStatus.SUCCESS) { + return ResponseReult.success(serviceBody.getData()); + } else { + return ResponseReult.error(serviceBody.getCode(), serviceBody.getMsg()); + } + } + + @ApiOperation(value = "获取最新图片采集参数", notes = "获取最新图片采集参数", httpMethod = "POST") + @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) + @RequestMapping("/getLastedPhotoQueryParam") + @Log(title = "获取最新图片采集参数", type = "查询") + public ResponseReult getLastedPhotoQueryParam(@RequestBody @Validated ReturnedPhotoParamsVo vo) { + ServiceBody serviceBody = terminalPhotoService.getLastedPhotoQueryParam(vo); if (serviceBody.getCode() == ServiceStatus.SUCCESS) { return ResponseReult.success(serviceBody.getData()); } else { @@ -141,8 +167,8 @@ public class TerminalPhotoController extends BaseController { @ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")}) @RequestMapping("/updatePhotoParam") @Log(title = "图像采集参数设置", type = "查询") - public ResponseReult updatePhotoParam(@RequestBody @Validated PhotoParamsVo vo) { - ServiceBody serviceBody = terminalPhotoService.updatePhotoParams(vo); + public ResponseReult addOrUpdatePhotoParams(@RequestBody @Validated PhotoParamsVo vo) { + ServiceBody serviceBody = terminalPhotoService.addOrUpdatePhotoParams(vo); if (serviceBody.getCode() == ServiceStatus.SUCCESS) { return ResponseReult.success(serviceBody.getData()); } else { @@ -150,4 +176,5 @@ public class TerminalPhotoController extends BaseController { } } + } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/constant/Constants.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/constant/Constants.java index 0199086..87abb0b 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/constant/Constants.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/constant/Constants.java @@ -1,6 +1,8 @@ package com.shxy.xymanager_common.constant; +import java.util.concurrent.atomic.AtomicInteger; + /** * 通用常量信息 * @@ -158,4 +160,9 @@ public class Constants * 心跳时间全局设置 */ public static final String GLOBAL_TIME = "global.heart.beat.time"; + + /** + * 调用JNI自增ID + */ + public static AtomicInteger REQUEST_ID = new AtomicInteger(1); } \ No newline at end of file diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/PhotoTimeResultDto.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/PhotoTimeResultDto.java new file mode 100644 index 0000000..0454f7e --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/dto/PhotoTimeResultDto.java @@ -0,0 +1,17 @@ +package com.shxy.xymanager_common.dto; + +import lombok.Data; + +/** + * 线路和电压等级名称对象 + */ +@Data +public class PhotoTimeResultDto { + + private Integer hour; + + private Integer minute; + + private Integer preset; + +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalPhotosParamsModel.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalPhotosParamsModel.java index acef39f..3dfc6eb 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalPhotosParamsModel.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalPhotosParamsModel.java @@ -1,5 +1,6 @@ package com.shxy.xymanager_common.model; +import cn.hutool.core.date.DateTime; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; @@ -15,42 +16,32 @@ import java.util.List; @Data @ApiModel(value = "图片轮询列表对象", description = "图片轮询列表对象信息") public class TerminalPhotosParamsModel implements Serializable { - @ApiModelProperty(value = "总记录数", example = "120") - private long total; - @ApiModelProperty(value = "总页数", example = "120") - private int totalpage; - @ApiModelProperty(value = "当前页", example = "1") - private int currentpage; - @ApiModelProperty(value = "每页记录数", example = "1") - private int pagesize; - @ApiModelProperty(value = "照片对象", example = "[]") - private List list; - @Data - public static class PhotoParamsBean { + @ApiModelProperty(value = "装置编号", example = "123456") + private Integer termId; - @ApiModelProperty(value = "装置编号", example = "123456") - private Integer termId; + @ApiModelProperty(value = "通道编号", example = "123456") + private Integer channelId; - @ApiModelProperty(value = "通道编号", example = "123456") - private Integer channelId; + @ApiModelProperty(value = "色彩选择:0 为黑白,1 为彩色", example = "123456") + private Integer color; - @ApiModelProperty(value = "色彩选择:0 为黑白,1 为彩色", example = "123456") - private Integer color; + @ApiModelProperty(value = "自定义图像分辨率", example = "123456") + private Integer resolution; - @ApiModelProperty(value = "自定义图像分辨率", example = "123456") - private Integer resolution; + @ApiModelProperty(value = "亮度,取值范围:1~100", example = "123456") + private Integer luminance; - @ApiModelProperty(value = "亮度,取值范围:1~100", example = "123456") - private Integer luminance; + @ApiModelProperty(value = "对比度,取值范围:1~100", example = "123456") + private Integer contrast; - @ApiModelProperty(value = "对比度,取值范围:1~100", example = "123456") - private Integer contrast; + @ApiModelProperty(value = "饱和度,取值范围:1~100", example = "123456") + private Integer saturation; - @ApiModelProperty(value = "饱和度,取值范围:1~100", example = "123456") - private Integer saturation; + @ApiModelProperty(value = "心跳上送周期", example = "123456") + private String cmdId; + + @ApiModelProperty(value = "查询时间", example = "123456") + private DateTime queryTime; - @ApiModelProperty(value = "心跳上送周期", example = "123456") - private String cmdId; - } } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalPhotosTimeModel.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalPhotosTimeModel.java new file mode 100644 index 0000000..2f3c265 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/model/TerminalPhotosTimeModel.java @@ -0,0 +1,35 @@ +package com.shxy.xymanager_common.model; + +import cn.hutool.core.date.DateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * 图片轮询列表 + */ +@Data +@ApiModel(value = "拍照时间表对象", description = "拍照时间表对象信息") +public class TerminalPhotosTimeModel implements Serializable { + + @ApiModelProperty(value = "拍照时间表对象列表", example = "[]") + private List list; + + @Data + public static class PhotosTimeBean { + + @ApiModelProperty(value = "装置编号", example = "123456") + private Integer termId; + + + @ApiModelProperty(value = "自定义图像分辨率", example = "123456") + private Integer requestId; + + } + + + +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/ReturnedPhotoParamsVo.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/ReturnedPhotoParamsVo.java new file mode 100644 index 0000000..7695771 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/ReturnedPhotoParamsVo.java @@ -0,0 +1,20 @@ +package com.shxy.xymanager_common.vo; + +import cn.hutool.core.date.DateTime; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +@ApiModel(value = "返回图片查询", description = "返回图片查询") +public class ReturnedPhotoParamsVo { + @NotNull(message = "不能传入空值") + @ApiModelProperty(value = "装置id", required = true, example = "A0001") + private Integer termId; + + + @ApiModelProperty(value = "手动拍照时间", required = true, example = "A0001") + private DateTime photoTime; +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalIdUpdateVo.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalIdUpdateVo.java new file mode 100644 index 0000000..2a482b3 --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalIdUpdateVo.java @@ -0,0 +1,18 @@ +package com.shxy.xymanager_common.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(value = "装置信息对象", description = "设备信息对象描述") +public class TerminalIdUpdateVo { + @ApiModelProperty(value = "装置ID", example = "123456") + private String cmdId; + + @ApiModelProperty(value = "新装置ID", example = "123456") + private String newCmdId; + + + +} diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalPhotoTimeVo.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalPhotoTimeVo.java index ec1b389..1fbbdda 100644 --- a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalPhotoTimeVo.java +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalPhotoTimeVo.java @@ -16,7 +16,6 @@ public class TerminalPhotoTimeVo { @NotNull(message = "装置ID不能缺少") @ApiModelProperty(value = "装置ID", example = "123455") - private Short termId; - + private Integer termId; } diff --git a/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalReqPhotoTimeVo.java b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalReqPhotoTimeVo.java new file mode 100644 index 0000000..0d68b4d --- /dev/null +++ b/xymanager_common/src/main/java/com/shxy/xymanager_common/vo/TerminalReqPhotoTimeVo.java @@ -0,0 +1,26 @@ +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 TerminalReqPhotoTimeVo { + + @NotNull(message = "通道号") + @ApiModelProperty(value = "通道号", example = "123455") + private Short channel; + + @NotNull(message = "装置ID不能缺少") + @ApiModelProperty(value = "装置ID", example = "123455") + private Short termId; + + + @ApiModelProperty(value = "请求ID", example = "123455") + private String requestId; + + +} diff --git a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPhotoDao.java b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPhotoDao.java index b8e046c..f499f45 100644 --- a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPhotoDao.java +++ b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalPhotoDao.java @@ -4,7 +4,9 @@ import com.shxy.xymanager_common.dto.PhotoAndLineAndChannelDto; import com.shxy.xymanager_common.dto.PhotoParamsDto; import com.shxy.xymanager_common.dto.TerminalPhotoScheduleDto; import com.shxy.xymanager_common.entity.TerminalPhoto; +import com.shxy.xymanager_common.vo.PhotoParamsVo; import com.shxy.xymanager_common.vo.TerminalPhotoTimeVo; +import com.shxy.xymanager_common.vo.TerminalReqPhotoTimeVo; import org.apache.ibatis.annotations.Param; import javax.xml.crypto.Data; @@ -37,6 +39,15 @@ public interface TerminalPhotoDao { List selectPhotoSchedule(TerminalPhotoTimeVo vo); - List selectPhotoParams(); + PhotoParamsDto selectPhotoParams(Integer termId); + + String selectCmdIdById(Integer termId); + + Integer updateOrInsertParams(PhotoParamsVo vo); + + BigInteger getLatestPhotoParam(Integer termId); + + String getRequestResult(@Param("requestId") String requestId); + } \ No newline at end of file diff --git a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalsDao.java b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalsDao.java index 748c56c..e408f02 100644 --- a/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalsDao.java +++ b/xymanager_dao/src/main/java/com/shxy/xymanager_dao/dao/TerminalsDao.java @@ -3,6 +3,7 @@ package com.shxy.xymanager_dao.dao; import com.shxy.xymanager_common.dto.TerminalInfoDto; import com.shxy.xymanager_common.dto.TerminalsAndLineAndChannelDto; import com.shxy.xymanager_common.entity.Terminals; +import com.shxy.xymanager_common.vo.TerminalIdUpdateVo; import org.apache.ibatis.annotations.Param; import java.math.BigInteger; @@ -35,4 +36,6 @@ public interface TerminalsDao { BigInteger getUpdateTime(@Param("termId")Integer termId); + int updateCmd(TerminalIdUpdateVo vo); + } \ No newline at end of file diff --git a/xymanager_dao/src/main/resources/mappers/TerminalPhotoDao.xml b/xymanager_dao/src/main/resources/mappers/TerminalPhotoDao.xml index 7fb4915..196995c 100644 --- a/xymanager_dao/src/main/resources/mappers/TerminalPhotoDao.xml +++ b/xymanager_dao/src/main/resources/mappers/TerminalPhotoDao.xml @@ -257,12 +257,49 @@ + + + + + + + + + + insert ignore into terminal_img_params + (term_id,color,resolution,luminance,saturation) + values + (termId,color,resolution,luminance,saturation) + + + \ No newline at end of file diff --git a/xymanager_dao/src/main/resources/mappers/TerminalsDao.xml b/xymanager_dao/src/main/resources/mappers/TerminalsDao.xml index 7fe7c10..72192a1 100644 --- a/xymanager_dao/src/main/resources/mappers/TerminalsDao.xml +++ b/xymanager_dao/src/main/resources/mappers/TerminalsDao.xml @@ -408,4 +408,10 @@ from terminal_status where term_id = #{termId,jdbcType=INTEGER} + + + update terminals + set cmdid = #{newCmdId,jdbcType=VARCHAR} + where cmdid = #{cmdId,jdbcType=VARCHAR} + \ No newline at end of file diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java index b3a5c04..430ff7b 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalPhotoServiceImpl.java @@ -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 getPhotoTime(TerminalPhotoTimeVo vo) { + TerminalPhotosTimeModel model = new TerminalPhotosTimeModel(); List dtoList = terminalPhotoDao.selectPhotoSchedule(vo); - Map> 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 beanList = Lists.newArrayList(); + + for(int j = 0; j 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 getPhotoQueryParamList(PageVo vo) { + public ServiceBody 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 list = terminalPhotoDao.selectPhotoParams(); - boolean empty = CollectionUtil.isEmpty(list); - if (empty) { - model.setList(new ArrayList<>()); - } else { - List 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 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 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 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 selectPhotoTime(TerminalReqPhotoTimeVo vo) { + String result = terminalPhotoDao.getRequestResult(vo.getRequestId()); + TerminalScheduleRuleTimeListModel model = new TerminalScheduleRuleTimeListModel(); + if(StringUtils.isNotBlank(result)){ + JSONObject resultObj =JSONObject.parseObject(result); + List resultDtoList = JSONArray.parseArray(resultObj.get("groupData").toString(), PhotoTimeResultDto.class); + List 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 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 listModel = terminalScheduleRuleService.getChannelSchelduleRule(idVo); + model = listModel.getData(); + } + return Asserts.success(model); + } + + } diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalServiceImpl.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalServiceImpl.java index fb355e1..e6aee19 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalServiceImpl.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/impl/TerminalServiceImpl.java @@ -230,6 +230,20 @@ public class TerminalServiceImpl implements TerminalService { return Asserts.success(null); } + @Override + public ServiceBody updateTerminalId(TerminalIdUpdateVo vo) { + String cmd = "/usr/local/bin/xympadmn --server=127.0.0.1 --act=termid --cmdid="+vo.getCmdId()+"\t"+"--newcmdid="+vo.getNewCmdId(); + Integer retCode = ProcessExecUtils.exec(cmd); + if(retCode==0){ + int result = terminalsDao.updateCmd(vo); + if(result>0) { + return Asserts.success("装置ID修改成功"); + } + } + return Asserts.error("装置ID修改失败"); + + } + } diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalPhotoService.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalPhotoService.java index 7fef25d..e7e55e6 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalPhotoService.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalPhotoService.java @@ -68,8 +68,15 @@ public interface TerminalPhotoService { * * @return */ - ServiceBody getPhotoQueryParamList(PageVo vo); + ServiceBody getPhotoQueryParam(Integer termId); + + ServiceBody addOrUpdatePhotoParams(PhotoParamsVo vo); + + ServiceBody getLastedPhotoQueryParam(ReturnedPhotoParamsVo vo); + + + ServiceBody selectPhotoTime(TerminalReqPhotoTimeVo vo); + - ServiceBody updatePhotoParams(PhotoParamsVo vo); } diff --git a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalService.java b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalService.java index c7870b7..8ec7866 100644 --- a/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalService.java +++ b/xymanager_service/src/main/java/com/shxy/xymanager_service/service/TerminalService.java @@ -54,4 +54,12 @@ public interface TerminalService { ServiceBody getLastedTerminalStatus(TerminalStatusVo vo); + /** + * 修改装置ID + * + * @param vo + * @return + */ + ServiceBody updateTerminalId(TerminalIdUpdateVo vo); + }