Browse Source

暂存2

dev
yinzuomei 5 years ago
parent
commit
1b084e639b
  1. 44
      epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java

44
epmet-module/resi-group/resi-group-server/src/main/java/com/epmet/modules/topic/controller/ResiTopicController.java

@ -1,12 +1,14 @@
package com.epmet.modules.topic.controller;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.epmet.commons.tools.annotation.LoginUser;
import com.epmet.commons.tools.security.dto.TokenDto;
import com.epmet.commons.tools.utils.Result;
import com.epmet.commons.tools.validator.ValidatorUtils;
import com.epmet.dto.result.FirstTopicShiftedToIssueApplicationResultDTO;
import com.epmet.modules.topic.service.ResiTopicService;
import com.epmet.resi.group.dto.scanapicallback.VoiceScanCallBackContentFormDTO;
import com.epmet.resi.group.dto.topic.MyCreateTopicsFormDTO;
import com.epmet.resi.group.dto.topic.ResiTopicDTO;
import com.epmet.resi.group.dto.topic.TopicInfoDTO;
@ -15,12 +17,12 @@ import com.epmet.resi.group.dto.topic.result.*;
import lombok.extern.slf4j.Slf4j;
import org.apache.http.HttpStatus;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* @Description
@ -355,16 +357,36 @@ public class ResiTopicController {
return new Result<MyPartIssueResultDTO>().ok(topicService.selectMyPartTopic(myPartIssueFormDTO));
}
/**
* @return com.epmet.commons.tools.utils.Result
* @param checksum 字符串格式由用户uid + seed + content拼成字符串通过SHA256算法生成用户UID即阿里云账号ID可以在阿里云控制台查询为防篡改您可以在获取到推送结果时按上述算法生成字符串与checksum做一次校验说明 用户UID必须是阿里云账号的UID而不是RAM用户的UID
* @param content contentJSON字符串格式请自行解析反转成JSON对象关于content结果的示例请参见查询异步检测结果的返回示例
* @author yinzuomei
* @description 测试语音异步检测回调方法
* @Date 2020/12/11 9:07
**/
@PostMapping("callBackPublishTopic")
public Result callBackPublishTopic(@RequestParam("checksum") String checksum, @RequestParam("content") String content, HttpServletResponse response){
log.info("checksum:"+checksum);
log.info("content:"+ JSON.toJSONString(content,true));
Map<String,String> map=new HashMap<>();
map.put("checksum",checksum);
map.put("content",content);
response.setStatus(HttpStatus.SC_INTERNAL_SERVER_ERROR);
return new Result<>().ok(map);
// 原因是因为传参的关系,使字符串中保留这"\"线,可以使用String.replaceAll("\\\\","");将所有的"\"线替换为空串
String contentStr=content.replaceAll("\\\\","");
List<VoiceScanCallBackContentFormDTO> formDTOList=new ArrayList<>();
if(contentStr.startsWith("[")){
log.info("入参content为数组:"+ JSON.toJSONString(contentStr,true));
List<VoiceScanCallBackContentFormDTO> list= JSONArray.parseArray(content.replaceAll("\\\\",""), VoiceScanCallBackContentFormDTO.class);
if(!CollectionUtils.isEmpty(list)){
formDTOList.addAll(list);
}
}else if(contentStr.startsWith("{")){
VoiceScanCallBackContentFormDTO formDTO= JSON.parseObject(contentStr, VoiceScanCallBackContentFormDTO.class);
log.info("入参content为对象:"+JSON.toJSONString(formDTO,true));
formDTOList.add(formDTO);
}
formDTOList.forEach(dto->{
log.info(dto.toString());
});
//TODO 判断检测任务结果,执行后续任务
response.setStatus(HttpStatus.SC_OK);
return new Result<>();
}
}

Loading…
Cancel
Save