装置文件夹新建、删除
This commit is contained in:
@@ -82,4 +82,32 @@ public class AskDeviceDataController extends BaseController {
|
||||
askDeviceDataService.rebootDevice(nDid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/createFolder")
|
||||
@ApiOperation("创建文件")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "nDid", value = "nDid", required = true),
|
||||
@ApiImplicitParam(name = "path", value = "文件路径", required = true)
|
||||
})
|
||||
public HttpResult<String> createFolder(@RequestParam("nDid") String nDid, @RequestParam("path") String path){
|
||||
String methodDescribe = getMethodDescribe("createFolder");
|
||||
askDeviceDataService.createFolder(nDid,path);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/deleteFolder")
|
||||
@ApiOperation("删除文件")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "nDid", value = "nDid", required = true),
|
||||
@ApiImplicitParam(name = "path", value = "文件路径", required = true)
|
||||
})
|
||||
public HttpResult<String> deleteFolder(@RequestParam("nDid") String nDid, @RequestParam("path") String path){
|
||||
String methodDescribe = getMethodDescribe("deleteFolder");
|
||||
askDeviceDataService.deleteFolder(nDid,path);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -622,6 +622,14 @@ public class MqttMessageHandler {
|
||||
redisUtil.saveByKeyWithExpire(AppRedisKey.UPLOAD,fileRedisDto,10L);
|
||||
redisUtil.saveByKeyWithExpire("uploading","uploading",20L);
|
||||
break;
|
||||
case 4660:
|
||||
log.info("设备目录/文件删除应答");
|
||||
redisUtil.saveByKeyWithExpire( "deleteDir"+ nDid,fileDto.getCode(),10L);
|
||||
break;
|
||||
case 4661:
|
||||
log.info("设备目录创建应答");
|
||||
redisUtil.saveByKeyWithExpire( "createDir"+ nDid,fileDto.getCode(),10L);
|
||||
break;
|
||||
case 4662:
|
||||
log.info("装置根目录应答");
|
||||
redisUtil.saveByKeyWithExpire(AppRedisKey.DEVICE_ROOT_PATH + nDid,fileDto.getMsg().getName(),10L);
|
||||
|
||||
@@ -12,4 +12,8 @@ public interface AskDeviceDataService {
|
||||
boolean downloadFile(String nDid, String name, Integer size, String fileCheck);
|
||||
|
||||
void rebootDevice(String nDid);
|
||||
|
||||
void createFolder(String nDid, String path);
|
||||
|
||||
void deleteFolder(String nDid, String path);
|
||||
}
|
||||
|
||||
@@ -142,6 +142,52 @@ public class AskDeviceDataServiceImpl implements AskDeviceDataService {
|
||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,mid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void createFolder(String nDid, String path) {
|
||||
Object object = getDeviceMid(nDid);
|
||||
if (!Objects.isNull(object)) {
|
||||
mid = (Integer) object;
|
||||
}
|
||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||
reqAndResParam.setMid(mid);
|
||||
reqAndResParam.setDid(0);
|
||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||
reqAndResParam.setExpire(-1);
|
||||
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_12.getCode()));
|
||||
String json = String.format("{\"Name\":\"%s\"}", path);
|
||||
JSONObject jsonObject = JSONObject.fromObject(json);
|
||||
reqAndResParam.setMsg(jsonObject);
|
||||
publisher.send("/Pfm/DevFileCmd/V1/" + nDid, new Gson().toJson(reqAndResParam), 1, false);
|
||||
mid = mid + 1;
|
||||
if (mid > 10000) {
|
||||
mid = 1;
|
||||
}
|
||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,mid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteFolder(String nDid, String path) {
|
||||
Object object = getDeviceMid(nDid);
|
||||
if (!Objects.isNull(object)) {
|
||||
mid = (Integer) object;
|
||||
}
|
||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||
reqAndResParam.setMid(mid);
|
||||
reqAndResParam.setDid(0);
|
||||
reqAndResParam.setPri(AccessEnum.FIRST_CHANNEL.getCode());
|
||||
reqAndResParam.setExpire(-1);
|
||||
reqAndResParam.setType(Integer.parseInt(TypeEnum.TYPE_11.getCode()));
|
||||
String json = String.format("{\"Name\":\"%s\"}", path);
|
||||
JSONObject jsonObject = JSONObject.fromObject(json);
|
||||
reqAndResParam.setMsg(jsonObject);
|
||||
publisher.send("/Pfm/DevFileCmd/V1/" + nDid, new Gson().toJson(reqAndResParam), 1, false);
|
||||
mid = mid + 1;
|
||||
if (mid > 10000) {
|
||||
mid = 1;
|
||||
}
|
||||
redisUtil.saveByKey(AppRedisKey.DEVICE_MID + nDid,mid);
|
||||
}
|
||||
|
||||
public Object getDeviceMid(String nDid) {
|
||||
return redisUtil.getObjectByKey(AppRedisKey.DEVICE_MID + nDid);
|
||||
}
|
||||
|
||||
@@ -268,9 +268,9 @@ public class CsDevModelServiceImpl implements ICsDevModelService {
|
||||
*/
|
||||
public void sendNextStep(DeviceLogDTO logDto, String path, MultipartFile file, int length, byte[] bytes, Integer offset, String version, String id, int mid, String fileCheck, boolean result) {
|
||||
try {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int i = 0; i < 30; i++) {
|
||||
if (result) {
|
||||
Thread.sleep(5000);
|
||||
Thread.sleep(10000);
|
||||
} else {
|
||||
Thread.sleep(2000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user