Browse Source

平台升级:inspect依赖修改

zhongwei
ty 5 months ago
parent
commit
dd131e0396
  1. 16
      hzims-service/inspect/pom.xml
  2. 9
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java
  3. 5
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotTaskController.java
  4. 23
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java
  5. 22
      hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/UserFaceDataServiceImpl.java

16
hzims-service/inspect/pom.xml

@ -69,7 +69,6 @@
<dependency> <dependency>
<groupId>org.eclipse.paho</groupId> <groupId>org.eclipse.paho</groupId>
<artifactId>org.eclipse.paho.client.mqttv3</artifactId> <artifactId>org.eclipse.paho.client.mqttv3</artifactId>
<version>1.2.1</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.xuxueli</groupId> <groupId>com.xuxueli</groupId>
@ -85,11 +84,11 @@
<artifactId>ehcache-core</artifactId> <artifactId>ehcache-core</artifactId>
<version>2.6.9</version> <version>2.6.9</version>
</dependency> </dependency>
<dependency> <!-- <dependency>-->
<groupId>io.minio</groupId> <!-- <groupId>io.minio</groupId>-->
<artifactId>minio</artifactId> <!-- <artifactId>minio</artifactId>-->
<version>6.0.7</version> <!-- <version>6.0.7</version>-->
</dependency> <!-- </dependency>-->
<!--短信发送平台 Start 引用后有druid版本冲突--> <!--短信发送平台 Start 引用后有druid版本冲突-->
<!--<dependency>--> <!--<dependency>-->
<!--<groupId>com.hnac.hzinfo</groupId>--> <!--<groupId>com.hnac.hzinfo</groupId>-->
@ -137,6 +136,11 @@
<artifactId>commons-compress</artifactId> <artifactId>commons-compress</artifactId>
<version>1.18</version> <version>1.18</version>
</dependency> </dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>4.9.3</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

9
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotController.java

@ -29,6 +29,7 @@ import org.springblade.core.oss.OssTemplate;
import org.springblade.core.oss.model.BladeFile; import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.resource.feign.IOssClient;
import org.springblade.system.user.cache.UserCache; import org.springblade.system.user.cache.UserCache;
import org.springblade.system.user.entity.User; import org.springblade.system.user.entity.User;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
@ -56,7 +57,7 @@ import java.util.Optional;
public class RobotController extends BladeController { public class RobotController extends BladeController {
private final IRobotService st_robotService; private final IRobotService st_robotService;
private final OssTemplate ossTemplate; private final IOssClient ossTemplate;
/** /**
@ -147,9 +148,9 @@ public class RobotController extends BladeController {
public R<BladeFile> putFileMore(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file, public R<BladeFile> putFileMore(@ApiParam(value = "上传文件", required = true) @RequestParam MultipartFile file,
@ApiParam(value = "其他参数,标准json格式", required = true) @RequestParam String jsonPara) { @ApiParam(value = "其他参数,标准json格式", required = true) @RequestParam String jsonPara) {
String type = file.getContentType(); String type = file.getContentType();
BladeFile bladeFile = ossTemplate.putFile(file); R<BladeFile> bladeFile = ossTemplate.putFile(file);
bladeFile.setName(bladeFile.getName() + "; 上传的其他参数:" + jsonPara + "; type = " + type); bladeFile.getData().setName(bladeFile.getData().getName() + "; 上传的其他参数:" + jsonPara + "; type = " + type);
return R.data(bladeFile); return bladeFile;
} }
@PostMapping("/generateDeviceInstance") @PostMapping("/generateDeviceInstance")

5
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/controller/RobotTaskController.java

@ -17,6 +17,7 @@ import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.tool.api.R; import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.mqtt.producer.IMqttSender; import org.springblade.mqtt.producer.IMqttSender;
import org.springblade.resource.feign.IOssClient;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
@ -40,7 +41,7 @@ import java.util.Map;
public class RobotTaskController extends BladeController { public class RobotTaskController extends BladeController {
private final IRobotTaskService robot_taskService; private final IRobotTaskService robot_taskService;
private final OssTemplate ossTemplate; private final IOssClient ossTemplate;
// @Autowired // @Autowired
// BladeLogger logger; // BladeLogger logger;
@ -155,7 +156,7 @@ public class RobotTaskController extends BladeController {
@GetMapping("/putFileTest") @GetMapping("/putFileTest")
@ApiOperation(value = "测试minio文件上传", notes = "测试minio文件上传") @ApiOperation(value = "测试minio文件上传", notes = "测试minio文件上传")
public R<BladeFile> putFile(@ApiParam(value = "文件", required = true) @RequestParam MultipartFile file) { public R<BladeFile> putFile(@ApiParam(value = "文件", required = true) @RequestParam MultipartFile file) {
return R.data(ossTemplate.putFile(file)); return ossTemplate.putFile(file);
} }
/** /**

23
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/RobotTaskServiceImpl.java

@ -35,19 +35,19 @@ import com.hnac.hzinfo.inspect.ai.entity.RobotTaskEntity;
import com.hnac.hzinfo.inspect.ai.mapper.RobotTaskMapper; import com.hnac.hzinfo.inspect.ai.mapper.RobotTaskMapper;
import com.hnac.hzinfo.inspect.ai.service.IRobotTaskService; import com.hnac.hzinfo.inspect.ai.service.IRobotTaskService;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.oss.OssTemplate;
import org.springblade.core.oss.model.BladeFile; import org.springblade.core.oss.model.BladeFile;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.jackson.JsonUtil; import org.springblade.core.tool.jackson.JsonUtil;
import org.springblade.core.tool.utils.BeanUtil; import org.springblade.core.tool.utils.BeanUtil;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springblade.mqtt.producer.IMqttSender; import org.springblade.mqtt.producer.IMqttSender;
import org.springblade.resource.feign.IOssClient;
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.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import java.io.ByteArrayInputStream;
import java.util.*; import java.util.*;
/** /**
@ -71,7 +71,7 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
@Autowired @Autowired
IClockService clockService; IClockService clockService;
@Autowired @Autowired
OssTemplate ossTemplate; IOssClient ossTemplate;
@Autowired @Autowired
ITaskUserService taskUserService; ITaskUserService taskUserService;
@Autowired @Autowired
@ -358,22 +358,22 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
switch (ObjContants.RobotCheckTypeEnum.getType(type)){ switch (ObjContants.RobotCheckTypeEnum.getType(type)){
case PICTURE: case PICTURE:
/** 拍照 */ /** 拍照 */
BladeFile bladeFile = ossTemplate.putFile(file); R<BladeFile> bladeFile = ossTemplate.putFile(file);
handlePicData(object, bladeFile.getLink()); handlePicData(object, bladeFile.getData().getLink());
break; break;
case THERMAL: case THERMAL:
/** 热成像 */ /** 热成像 */
handleThermalData(file, object); handleThermalData(file, object);
break; break;
case IDENTIFY: case IDENTIFY:
BladeFile bladeFile2 = ossTemplate.putFile(file); R<BladeFile> bladeFile2 = ossTemplate.putFile(file);
/** 识别 */ /** 识别 */
handleIdentifyData(object, bladeFile2.getLink()); handleIdentifyData(object, bladeFile2.getData().getLink());
break; break;
case VOICE: case VOICE:
/** 声音 */ /** 声音 */
BladeFile bladeFile3 = ossTemplate.putFile(file); R<BladeFile> bladeFile3 = ossTemplate.putFile(file);
handleVoiceData(object, bladeFile3.getLink()); handleVoiceData(object, bladeFile3.getData().getLink());
break; break;
} }
} }
@ -567,8 +567,9 @@ public class RobotTaskServiceImpl extends ServiceImpl<RobotTaskMapper, RobotTask
/** 图片 */ /** 图片 */
byte[] picTemp = new byte[ints[3]]; byte[] picTemp = new byte[ints[3]];
System.arraycopy(dat, 16 + ints[2], picTemp, 0, ints[3]); System.arraycopy(dat, 16 + ints[2], picTemp, 0, ints[3]);
MultipartFile multipartFile=new MockMultipartFile("thermal.png", picTemp);
/** 上传文件 */ /** 上传文件 */
BladeFile bladeFile = ossTemplate.putFile("thermal.png",new ByteArrayInputStream(picTemp)); BladeFile bladeFile = ossTemplate.putFile( multipartFile).getData();
picUrl = bladeFile.getLink(); picUrl = bladeFile.getLink();
}catch (Exception ex){ }catch (Exception ex){
throw new ServiceException("机器人巡检热成像返回文件格式不正确 —— " + ex.getMessage()); throw new ServiceException("机器人巡检热成像返回文件格式不正确 —— " + ex.getMessage());

22
hzims-service/inspect/src/main/java/com/hnac/hzinfo/inspect/ai/service/impl/UserFaceDataServiceImpl.java

@ -1,6 +1,7 @@
package com.hnac.hzinfo.inspect.ai.service.impl; package com.hnac.hzinfo.inspect.ai.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.google.common.base.Functions; import com.google.common.base.Functions;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import com.hnac.hzinfo.inspect.ai.config.FaceConfig; import com.hnac.hzinfo.inspect.ai.config.FaceConfig;
@ -9,12 +10,13 @@ import com.hnac.hzinfo.inspect.ai.entity.UserFaceDataEntity;
import com.hnac.hzinfo.inspect.ai.mapper.UserFaceDataMapper; import com.hnac.hzinfo.inspect.ai.mapper.UserFaceDataMapper;
import com.hnac.hzinfo.inspect.ai.service.IUserFaceDataService; import com.hnac.hzinfo.inspect.ai.service.IUserFaceDataService;
import com.hnac.hzinfo.inspect.ai.util.BigDecimalUtil; import com.hnac.hzinfo.inspect.ai.util.BigDecimalUtil;
import com.hnac.hzinfo.inspect.utils.HttpClientUtils;
import okhttp3.MediaType; import okhttp3.MediaType;
import okhttp3.MultipartBody; import okhttp3.MultipartBody;
import okhttp3.RequestBody; import okhttp3.RequestBody;
import org.springblade.core.http.HttpRequest; //import org.springblade.core.http.HttpRequest;
import org.springblade.core.http.LogLevel; //import org.springblade.core.http.LogLevel;
import org.springblade.core.mp.base.BaseServiceImpl; //import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.tool.utils.Func; import org.springblade.core.tool.utils.Func;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -31,7 +33,7 @@ import java.util.stream.Collectors;
* @author py * @author py
*/ */
@Service @Service
public class UserFaceDataServiceImpl extends BaseServiceImpl<UserFaceDataMapper, UserFaceDataEntity> implements IUserFaceDataService { public class UserFaceDataServiceImpl extends ServiceImpl<UserFaceDataMapper, UserFaceDataEntity> implements IUserFaceDataService {
@Autowired @Autowired
private FaceConfig config; private FaceConfig config;
@ -86,15 +88,9 @@ public class UserFaceDataServiceImpl extends BaseServiceImpl<UserFaceDataMapper,
.setType(MultipartBody.FORM) .setType(MultipartBody.FORM)
.addFormDataPart("file", "test.jpg", body) .addFormDataPart("file", "test.jpg", body)
.build(); .build();
FaceResponse result = HttpRequest.post(config.baseAddUrl("/getcode")) String uri = config.baseAddUrl("/getcode");
// 设定全局日志级别 NONE,BASIC,HEADERS,BODY, 默认:NONE FaceResponse result = HttpClientUtils.post(uri,multipartBody,FaceResponse.class);
.log(LogLevel.BASIC)
.body(multipartBody)
.execute()
.onFailed(((request, e) -> {
System.out.println("获取人脸DATA失败:" + e.toString());
}))
.asValue(FaceResponse.class);
if(Func.isEmpty(result) || Func.isEmpty(result.getData())){ if(Func.isEmpty(result) || Func.isEmpty(result.getData())){
return null; return null;
} }

Loading…
Cancel
Save