@Override
public AlmModel pxeltioC(PixelRatioCollectBean bean) {
String gainSelector;
switch (bean.getGainSelector()) {
case 1:
gainSelector = "B";
break;
case 2:
gainSelector = "Sytem";
break;
case 3:
gainSelector = "ll";
break;
default:
gainSelector = "RB";
break;
}
// EntityProduct product = productMapper.selectByPrimaryKey(bean.getProductId());
// return "采功";
Map<String, Object> map = new HashMap<>();
Map<String, Object> map_collect = new HashMap<>();
map.put("m", "pixel_ratio_collect");
// map_collect.put("entity_product_id", bean.getProductId());
map_collect.put("product_no", bean.getProductNo());
map_collect.put("position_en_name", bean.getPositionEnName());
map_collect.put("line_step_length", bean.getLineStepLength());
map_collect.put("exposure_time", bean.getExposureTime());
map_collect.put("gain_selector", gainSelector);
map_collect.put("gain", String.valueOf(bean.getGain()));
map_collect.put("line_x_start", bean.getLineXStart() * 100);
map_collect.put("line_y_start", bean.getLineYStart() * 100);
map_collect.put("line_z", bean.getLineZ() * 100);
map_collect.put("length", bean.getLength());
map_collect.put("width", bean.getWidth());
map_collect.put("acquisition_line_rate", bean.getAcquisitionLineRate());
map_collect.put("line_spatial", bean.getLineSpatial());
map_collect.put("black_level", bean.getBlackLevel());
map_collect.put("drop_axis_x", bean.getDropAxisX());
map_collect.put("drop_axis_y", bean.getDropAxisY());
map_collect.put("pick_axis_x", bean.getPickAxisX());
map_collect.put("pick_axis_y", bean.getPickAxisY());
Float trayHeight = bean.getTrayHeight();
Integer trayHeightToInt = trayHeight == null ? 0 : (int) (trayHeight * 100);
map_collect.put("tray_height", trayHeightToInt);
map.put("p", map_collect);
logger.info(JSON.toJSONString(map));
HttpEntity<String> entity = new HttpEntity<>(JSON.toJSONString(map));
ResponseEntity<String> responseEntity = restTemplate.postForEntity(aiPath, entity, String.class);
System.out.println(responseEntity.getBody());
if (responseEntity.getBody() != null) {
return JSON.parseObject(responseEntity.getBody(), AlgohmModel.class);
// if ("success".equals(activation.getStatus())) {
// return activation.getMessage();
// } else {
// throw new RuntimeException("AI:" + activation.getMessage());
// }
} else {
throw new RuntimeException("异常,返回结果为空");
}
}
springBoot restTemplate post请求
最新推荐文章于 2025-02-23 12:15:03 发布