请求参数不校验的bug修改

jni
liuguijing 2 years ago
parent 6294e02b06
commit d6b87adcea

@ -6,10 +6,12 @@ import com.shxy.xymanager_common.base.ResponseReult;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.bean.ServiceStatus;
import com.shxy.xymanager_common.entity.TerminalPhoto;
import com.shxy.xymanager_common.model.TerminalPhotoListForOpenModel;
import com.shxy.xymanager_common.model.TerminalPhotoListModel;
import com.shxy.xymanager_common.model.TerminalPhotosModel;
import com.shxy.xymanager_common.vo.PageVo;
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 io.swagger.annotations.Api;
@ -25,6 +27,7 @@ import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@Api(value = "图片接口", tags = "图片接口相关")
@RestController
@Slf4j
@ -74,6 +77,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("/getPhotoListForOpen")
@Log(title = "图片查询给第三方", type = "查询")
public ResponseReult<TerminalPhotoListForOpenModel> getPhotoListForOpen(@RequestBody @Validated TerminalAndTimeForOpenVo vo) {
ServiceBody<TerminalPhotoListForOpenModel> serviceBody = terminalPhotoService.getPhotoListForOpen(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 = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/getReturnedPhoto")

@ -32,10 +32,6 @@ public class UploadController extends BaseController {
@Autowired
UploadService uploadService;
@ApiOperation(value = "上传APK", notes = "上传APK接口", httpMethod = "POST")
@ApiResponses({@ApiResponse(code = 200, message = "请求成功"), @ApiResponse(code = 400, message = "请求参数没填好"), @ApiResponse(code = 404, message = "请求路径没有或页面跳转路径不对")})
@RequestMapping("/uploadApk")

@ -99,6 +99,11 @@
<artifactId>jna</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
</dependencies>
<build>

@ -1,6 +1,7 @@
package com.shxy.xymanager_common.exception;
import com.shxy.xymanager_common.base.ResponseReult;
import org.springframework.validation.BindException;
import org.springframework.validation.BindingResult;
import org.springframework.validation.FieldError;
import org.springframework.web.bind.MethodArgumentNotValidException;
@ -12,7 +13,7 @@ import java.sql.SQLException;
/**
*
* Created by macro on 2020/2/27.
* Created by on 2023/5/8.
*/
@ControllerAdvice
public class GlobalExceptionHandler {
@ -54,7 +55,7 @@ public class GlobalExceptionHandler {
//
// @ResponseBody
// @ExceptionHandler(value = BindException.class)
// public CommonResult handleValidException(BindException e) {
// public ResponseReult handleValidException(BindException e) {
// BindingResult bindingResult = e.getBindingResult();
// String message = null;
// if (bindingResult.hasErrors()) {
@ -63,6 +64,6 @@ public class GlobalExceptionHandler {
// message = fieldError.getField()+fieldError.getDefaultMessage();
// }
// }
// return CommonResult.validateFailed(message);
// return ResponseReult.error(message);
// }
}

@ -0,0 +1,67 @@
package com.shxy.xymanager_common.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
*
*/
@Data
@ApiModel(value = "图片列表第三方对象", description = "图片列表第三方对象信息")
public class TerminalPhotoListForOpenModel 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<PhotoBean> list;
@Data
public static class PhotoBean {
@ApiModelProperty(value = "图片id", example = "12321")
private Long id;
@ApiModelProperty(value = "装置编号", example = "123456")
private Integer termId;
@ApiModelProperty(value = "通道编号", example = "123456")
private Integer channelId;
@ApiModelProperty(value = "预置位编号", example = "123456")
private Integer presetId;
@ApiModelProperty(value = "宽度", example = "123456")
private Integer width;
@ApiModelProperty(value = "高度", example = "123456")
private Integer height;
@ApiModelProperty(value = "大小", example = "123456")
private Integer fileSize;
@ApiModelProperty(value = "拍照时间", example = "123456")
private Date photoTime;
@ApiModelProperty(value = "接收时间", example = "123456")
private Date recvTime;
@ApiModelProperty(value = "照片路径", example = "123456")
private String path;
@ApiModelProperty(value = "拍照方式", example = "123456")
private Integer manualRequest;
}
}

@ -3,6 +3,7 @@ package com.shxy.xymanager_common.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotNull;
import java.util.Date;

@ -0,0 +1,36 @@
package com.shxy.xymanager_common.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
@Data
@ApiModel(value = "装置和查询时间提供给第三方", description = "装置和查询时间提供给第三方")
public class TerminalAndTimeForOpenVo {
@NotNull(message = "装置编号不能缺少")
@ApiModelProperty(value = "装置编号", example = "123455")
private Integer terminalid;
@NotEmpty(message = "查询开始时间不能缺少")
@ApiModelProperty(value = "查询开始时间", example = "123455")
private Date starttime;
@NotEmpty(message = "查询结束时间不能缺少")
@ApiModelProperty(value = "查询结束时间", example = "123455")
private Date endtime;
@Min(value = 1, message = "分页位置最小从1开始")
@ApiModelProperty(value = "分页位置从1开始", required = true, example = "1")
private int pageindex;
@Min(value = 1, message = "分页大小最小为1")
@ApiModelProperty(value = "分页大小", required = true, example = "1")
private int pagesize;
}

@ -27,4 +27,6 @@ public interface TerminalPhotoDao {
TerminalPhoto getLatestPhoto(@Param("termId") String termId);
List<TerminalPhoto> selectPhotos();
List<TerminalPhoto> selectPhotoListForOpen(@Param("termId") Integer terminalid,@Param("starttime") BigInteger starttime, @Param("endtime") BigInteger endtime);
}

@ -47,6 +47,15 @@
order by create_time desc limit 1
</select>
<select id="selectPhotoListForOpen" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>
from terminal_photos
where term_id = #{termId} and photo_time between #{starttime} and #{endtime}
order by photo_time desc
</select>
<select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
select
<include refid="Base_Column_List"/>

@ -7,11 +7,9 @@ import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.dto.LineAndDyNameDto;
import com.shxy.xymanager_common.entity.Lines;
import com.shxy.xymanager_common.entity.TerminalPhoto;
import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.exception.Asserts;
import com.shxy.xymanager_common.model.LineListModel;
import com.shxy.xymanager_common.model.TerminalPhotoListModel;
import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_dao.dao.LinesDao;
@ -134,10 +132,14 @@ public class LineServiceImpl implements LineService {
*/
@Override
public ServiceBody<String> getLineAndGt(LineAndGtAndChannelVo vo) {
// Integer dyid = vo.getDyid();
// Integer lineid = vo.getLineid();
// Integer towerid = vo.getTowerid();
// vo.
Integer dyid = vo.getDyid();
Integer lineid = vo.getLineid();
Integer towerid = vo.getTowerid();
Integer channelid = vo.getChannelid();
//查询所有
if (BeanUtil.isEmpty(dyid) && BeanUtil.isEmpty(lineid) && BeanUtil.isEmpty(towerid) && BeanUtil.isEmpty(channelid)) {
}
// linesDao.selectByPrimaryKey()
return null;

@ -6,6 +6,7 @@ import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.entity.TerminalPhoto;
import com.shxy.xymanager_common.exception.Asserts;
import com.shxy.xymanager_common.model.TerminalPhotoListForOpenModel;
import com.shxy.xymanager_common.model.TerminalPhotoListModel;
import com.shxy.xymanager_common.model.TerminalPhotosModel;
import com.shxy.xymanager_common.page.PageUtils;
@ -13,6 +14,7 @@ import com.shxy.xymanager_common.util.MyDateUtils;
import com.shxy.xymanager_common.util.StringUtils;
import com.shxy.xymanager_common.vo.PageVo;
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_service.interaction.Cma;
@ -22,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import javax.validation.constraints.NotEmpty;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
@ -67,7 +70,7 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
boolean empty1 = CollectionUtil.isEmpty(vo.getChannelid());
List<TerminalPhoto> list = new ArrayList<>();
if (!empty1) {
list = terminalPhotoDao.selectPhotoList(vo.getTerminalid(), vo.getChannelid(), start, end);
list = terminalPhotoDao.selectPhotoList(vo.getTerminalid(), vo.getChannelid(), start, end);
}
boolean empty = CollectionUtil.isEmpty(list);
model.setTime(vo.getTime());
@ -97,11 +100,64 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
return Asserts.success(model);
}
/**
*
*
* @param vo
* @return
*/
@Override
public ServiceBody<TerminalPhotoListForOpenModel> getPhotoListForOpen(TerminalAndTimeForOpenVo vo) {
TerminalPhotoListForOpenModel model = new TerminalPhotoListForOpenModel();
int pageindex = vo.getPageindex();
int pagesize = vo.getPagesize();
PageUtils.SetPage(pageindex, pagesize);
Date starttime = vo.getStarttime();
Date endtime = vo.getEndtime();
BigInteger start = MyDateUtils.TimeMillSecond2Second(DateTime.of(starttime));
BigInteger end = MyDateUtils.TimeMillSecond2Second(DateTime.of(endtime));
List<TerminalPhoto> list = terminalPhotoDao.selectPhotoListForOpen(vo.getTerminalid(), start, end);
boolean empty = CollectionUtil.isEmpty(list);
if (empty) {
model.setList(new ArrayList<>());
} else {
List<TerminalPhotoListForOpenModel.PhotoBean> beans = new ArrayList<>();
for (TerminalPhoto item : list) {
TerminalPhotoListForOpenModel.PhotoBean photoBean = new TerminalPhotoListForOpenModel.PhotoBean();
photoBean.setChannelId(item.getChannelId());
photoBean.setFileSize(item.getFileSize());
photoBean.setHeight(item.getHeight());
photoBean.setPath(photoaddress + item.getPath());
photoBean.setId(item.getId());
photoBean.setTermId(item.getTermId());
photoBean.setWidth(item.getWidth());
photoBean.setPresetId(item.getPresetId());
BigInteger phototime = MyDateUtils.TimeSecond2MillSecond(item.getPhotoTime().longValue());
photoBean.setPhotoTime(MyDateUtils.date(phototime.longValue()));
BigInteger rectime = MyDateUtils.TimeSecond2MillSecond(item.getRecvTime().longValue());
photoBean.setRecvTime(MyDateUtils.date(rectime.longValue()));
beans.add(photoBean);
}
model.setList(beans);
}
PageInfo pageData = PageUtils.getPageData(list);
int currentpage = pageData.getPageNum();
model.setCurrentpage(currentpage);
long total = pageData.getTotal();
model.setTotal(total);
int pageSize = pageData.getPageSize();
model.setPagesize(pageSize);
int pages = pageData.getPages();
model.setTotalpage(pages);
return Asserts.success(model);
}
@Override
public ServiceBody<Boolean> getLatestPhoto(TerminalPhotoVo vo) {
/* Cma cma = new Cma(server, port);*/
String[] cmd = {"sh","/usr/local/bin/xympadmn",server,String.valueOf(port)};
ProcessBuilder builder = new ProcessBuilder("/bin/chmod", "755","/usr/local/bin/xympadmn");
/* Cma cma = new Cma(server, port);*/
String[] cmd = {"sh", "/usr/local/bin/xympadmn", server, String.valueOf(port)};
ProcessBuilder builder = new ProcessBuilder("/bin/chmod", "755", "/usr/local/bin/xympadmn");
String line = "";
StringBuffer sb = new StringBuffer();
String result = "";
@ -116,17 +172,17 @@ public class TerminalPhotoServiceImpl implements TerminalPhotoService {
sb.append(line).append("\n");
}
result = sb.toString();
if(StringUtils.isNotBlank(result)){
hasNew =true;
if (StringUtils.isNotBlank(result)) {
hasNew = true;
}
} catch (IOException e) {
log.error("IOException",e);
log.error("IOException", e);
} catch (InterruptedException e) {
log.error("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);
}

@ -9,6 +9,7 @@ import cn.hutool.core.date.DateUtil;
import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.dto.ScheduleAndRuleDto;
import com.shxy.xymanager_common.dto.ScheduleRuleDto;
import com.shxy.xymanager_common.entity.TerminalSchedule;
import com.shxy.xymanager_common.entity.TerminalScheduleMapper;
import com.shxy.xymanager_common.entity.TerminalScheduleRule;
@ -249,15 +250,18 @@ public class TerminalScheduleRuleServiceImpl implements TerminalScheduleRuleServ
model.setList(new ArrayList<>());
} else {
Integer scheduleId = mapper.getScheduleId();
TerminalScheduleRule bean = terminalScheduleRuleDao.selectByPrimaryKey(scheduleId);
Time startTime = bean.getStartTime();
Time endTime = bean.getEndTime();
Integer span = bean.getSpan();
List<DateTime> dateTimes = MyDateUtils.rangeToList(startTime, endTime, DateField.MINUTE, span);
ScheduleAndRuleDto bean = terminalScheduleDao.selectSingle(scheduleId, CommonStatus.EFFECTIVE.value());
List<ScheduleRuleDto> list = bean.getList();
ArrayList<String> timelist = new ArrayList<>();
for (DateTime item : dateTimes) {
String dateTime = DateUtil.formatTime(item);
timelist.add(dateTime);
for (ScheduleRuleDto item : list) {
Time startTime = item.getStartTime();
Time endTime = item.getEndTime();
Integer span = item.getSpan();
List<DateTime> dateTimes = MyDateUtils.rangeToList(startTime, endTime, DateField.MINUTE, span);
for (DateTime data : dateTimes) {
String dateTime = DateUtil.formatTime(data);
timelist.add(dateTime);
}
}
model.setList(timelist);
}

@ -5,33 +5,19 @@ import cn.hutool.core.bean.copier.CopyOptions;
import cn.hutool.core.collection.CollectionUtil;
import com.github.pagehelper.PageInfo;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.dto.LineAndDyNameDto;
import com.shxy.xymanager_common.dto.TerminalApkInfoDto;
import com.shxy.xymanager_common.dto.TowerDto;
import com.shxy.xymanager_common.entity.Lines;
import com.shxy.xymanager_common.entity.TerminalUpload;
import com.shxy.xymanager_common.entity.Tower;
import com.shxy.xymanager_common.enums.CommonStatus;
import com.shxy.xymanager_common.exception.Asserts;
import com.shxy.xymanager_common.model.LineListModel;
import com.shxy.xymanager_common.model.TerminalApkInfoListModel;
import com.shxy.xymanager_common.model.TowerListModel;
import com.shxy.xymanager_common.page.PageUtils;
import com.shxy.xymanager_common.util.UploadUtils;
import com.shxy.xymanager_common.vo.*;
import com.shxy.xymanager_dao.dao.TerminalUploadDao;
import com.shxy.xymanager_dao.dao.TerminalsDao;
import com.shxy.xymanager_dao.dao.TowerDao;
import com.shxy.xymanager_service.interaction.Cma;
import com.shxy.xymanager_service.service.TowerService;
import com.shxy.xymanager_service.service.UploadService;
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.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@ -2,10 +2,12 @@ package com.shxy.xymanager_service.service;
import com.shxy.xymanager_common.bean.ServiceBody;
import com.shxy.xymanager_common.entity.TerminalPhoto;
import com.shxy.xymanager_common.model.TerminalPhotoListForOpenModel;
import com.shxy.xymanager_common.model.TerminalPhotoListModel;
import com.shxy.xymanager_common.model.TerminalPhotosModel;
import com.shxy.xymanager_common.vo.PageVo;
import com.shxy.xymanager_common.vo.TerminalAndChannelIdAndTimeVo;
import com.shxy.xymanager_common.vo.TerminalAndTimeForOpenVo;
import com.shxy.xymanager_common.vo.TerminalPhotoVo;
/**
@ -21,6 +23,13 @@ public interface TerminalPhotoService {
*/
ServiceBody<TerminalPhotoListModel> getTerminalPhotoList(TerminalAndChannelIdAndTimeVo vo);
/**
* id
*
* @return
*/
ServiceBody<TerminalPhotoListForOpenModel> getPhotoListForOpen(TerminalAndTimeForOpenVo vo);
/**
* id
*

Loading…
Cancel
Save