1、修改服务接口异常信息处理,异常信息直接抛出至controller,列表界面显示异常信息.

This commit is contained in:
zhangwei
2018-05-28 11:40:58 +08:00
parent 4930cd4c61
commit a038523e6f
6 changed files with 49 additions and 58 deletions

View File

@@ -90,7 +90,7 @@ public class ConfigServiceUtil {
* @param type 1是compileid,2是groupid,3是regionid
* @return
*/
public static List<Integer> getId(int type,int num) throws Exception {
public static List<Integer> getId(int type,int num) throws MaatConvertException {
String result = null;
String url = "";
List<Integer> list = new ArrayList();
@@ -133,7 +133,7 @@ public class ConfigServiceUtil {
* @return
* @throws Exception
*/
public static ToMaatResult postMaatCfg(String params) throws Exception{
public static ToMaatResult postMaatCfg(String params) throws MaatConvertException{
String result = null;
ToMaatResult bean = null;
String url = Constants.SERVICE_URL+Constants.MAAT_CFG;
@@ -157,7 +157,7 @@ public class ConfigServiceUtil {
* @return
* @throws Exception
*/
public static ToMaatResult postCallbackCfg(String params) throws Exception{
public static ToMaatResult postCallbackCfg(String params) throws MaatConvertException{
String result = null;
ToMaatResult bean = null;
String url = Constants.SERVICE_URL+Constants.CALLBACK_CFG;
@@ -182,7 +182,7 @@ public class ConfigServiceUtil {
* @return
* @throws Exception
*/
public static ToMaatResult postFileCfg(String params,File file,JSONObject fileDesc) throws Exception{
public static ToMaatResult postFileCfg(String params,File file,JSONObject fileDesc) throws MaatConvertException{
String result = null;
ToMaatResult bean = null;
String url = Constants.SERVICE_URL+Constants.FILE_UPLOAD_CFG;
@@ -209,7 +209,7 @@ public class ConfigServiceUtil {
* @param type,1表示maat配置取消2表示回调配置取消
* @return
*/
public static ToMaatResult delete(String params,Integer type){
public static ToMaatResult delete(String params,Integer type) throws MaatConvertException{
String result = null;
ToMaatResult bean = null;
String url = Constants.SERVICE_URL;
@@ -239,7 +239,7 @@ public class ConfigServiceUtil {
* @param type,1表示maat配置取消2表示回调配置取消
* @return
*/
public static ToMaatResult put(String params,Integer type){
public static ToMaatResult put(String params,Integer type) throws MaatConvertException{
String result = null;
ToMaatResult bean = null;
String url = Constants.SERVICE_URL;
@@ -268,7 +268,7 @@ public class ConfigServiceUtil {
* @return
* @throws Exception
*/
public static ToMaatResult getFileDigest(String params,File file,Map<String, Object> fileDesc) throws Exception{
public static ToMaatResult getFileDigest(String params,File file,Map<String, Object> fileDesc) throws MaatConvertException{
String result = null;
ToMaatResult bean = null;
String url = Constants.SERVICE_URL+Constants.FILE_DIGEST_CFG;

View File

@@ -19,6 +19,7 @@ import org.springframework.util.FileCopyUtils;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -147,7 +148,7 @@ public class AvController extends BaseController {
* @return
*/
@RequestMapping(value = {"/sample/auditAvFileSample"})
public String auditAvFileSample(Integer isAudit,Integer isValid,String ids,Integer functionId){
public String auditAvFileSample(Integer isAudit,Integer isValid,String ids,Integer functionId, RedirectAttributes redirectAttributes){
// avCfgService.auditAvFileSample(isAudit,isValid,ids);
AvFileSampleCfg entity = new AvFileSampleCfg();
String[] idArray = ids.split(",");
@@ -159,9 +160,9 @@ public class AvController extends BaseController {
entity.setAuditTime(new Date());
String oldSrcUrl = entity.getSrcPath();
String oldSampleUrl = entity.getSamplePath();
if(isAudit==1){
//音视频文件上传接口调用
try {
try {
if(isAudit==1){
//音视频文件上传接口调用
File srcFile = new File(oldSrcUrl);
Map<String,Object> srcMap = new HashMap();
srcMap.put("filetype", FileUtils.getSuffix(srcFile.getName(), false));
@@ -178,7 +179,7 @@ public class AvController extends BaseController {
ResponseData data = result1.getData();
srcAccessUrl=data.getAccessUrl();
entity.setSrcUrl(srcAccessUrl);
// entity.setSrcPath("");
// entity.setSrcPath("");
}
File sampleFile = new File(oldSampleUrl);
Map<String,Object> sampleMap = new HashMap();
@@ -197,23 +198,22 @@ public class AvController extends BaseController {
ResponseData data = result2.getData();
sampleAccessUrl = data.getAccessUrl();
entity.setSampleUrl(sampleAccessUrl);
// entity.setSamplePath("");
// entity.setSamplePath("");
}
} catch (Exception e) {
e.printStackTrace();
logger.info("音视频文件样例配置下发失败");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
}
avCfgService.auditAvFileSample(entity,isAudit);
//删除本地源文件和样例文件
if(!oldSrcUrl.equals(entity.getSrcUrl())){
FileUtils.deleteFile(oldSrcUrl);
}
if(!oldSampleUrl.equals(entity.getSampleUrl())){
FileUtils.deleteFile(oldSampleUrl);
avCfgService.auditAvFileSample(entity,isAudit);
//删除本地源文件和样例文件
if(!oldSrcUrl.equals(entity.getSrcUrl())){
FileUtils.deleteFile(oldSrcUrl);
}
if(!oldSampleUrl.equals(entity.getSampleUrl())){
FileUtils.deleteFile(oldSampleUrl);
}
} catch (MaatConvertException e) {
e.printStackTrace();
logger.info("音视频文件样例配置下发失败:"+e.getMessage());
addMessage(redirectAttributes, e.getMessage());
}
}
return "redirect:" + adminPath +"/ntc/av/sample/fileSampleList?functionId="+functionId;
@@ -234,7 +234,7 @@ public class AvController extends BaseController {
* @return
*/
@RequestMapping(value = {"/sample/auditAvSignSample"})
public String auditAvSignSample(Integer isAudit,Integer isValid,String ids,Integer functionId){
public String auditAvSignSample(Integer isAudit,Integer isValid,String ids,Integer functionId, RedirectAttributes redirectAttributes){
// avCfgService.auditAvSignSample(isAudit,isValid,ids);
AvSignSampleCfg entity = new AvSignSampleCfg();
String[] idArray = ids.split(",");
@@ -244,7 +244,13 @@ public class AvController extends BaseController {
entity.setIsValid(isValid);
entity.setAuditorId(UserUtils.getUser().getId());
entity.setAuditTime(new Date());
avCfgService.auditAvSignSample(entity,isAudit);
try {
avCfgService.auditAvSignSample(entity,isAudit);
} catch (MaatConvertException e) {
e.printStackTrace();
logger.info("音视频标识样例配置下发失败:"+e.getMessage());
addMessage(redirectAttributes, e.getMessage());
}
}
return "redirect:" + adminPath +"/ntc/av/sample/signSampleList?functionId="+functionId;
}

View File

@@ -141,7 +141,7 @@ public class AvCfgService extends BaseService{
}
public void auditAvFileSample(AvFileSampleCfg entity,Integer isAudit){
public void auditAvFileSample(AvFileSampleCfg entity,Integer isAudit) throws MaatConvertException{
//修改数据库审核状态信息
avCfgDao.auditAvFileSample(entity);
List<AvFileSampleCfg> list = new ArrayList<AvFileSampleCfg>();
@@ -152,27 +152,16 @@ public class AvCfgService extends BaseService{
String json=gsonToJson(list);
logger.info("音视频文件样例下发配置参数:"+json);
//调用服务接口下发配置
try {
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
logger.info("音视频文件样例配置下发响应信息:"+result.getMsg());
} catch (Exception e) {
e.printStackTrace();
logger.info("音视频文件样例配置下发失败");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
ToMaatResult result = ConfigServiceUtil.postCallbackCfg(json);
logger.info("音视频文件样例配置下发响应信息:"+result.getMsg());
}else if(isAudit==3){
//调用服务接口取消配置
String json=gsonToJson(list);
logger.info("音视频文件样例下发配置参数:"+json);
//调用服务接口下发配置
try {
ToMaatResult result = ConfigServiceUtil.put(json,2);
logger.info("音视频文件样例取消配置响应信息:"+result.getMsg());
} catch (Exception e) {
e.printStackTrace();
logger.info("音视频文件样取消配置失败");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
ToMaatResult result = ConfigServiceUtil.put(json,2);
logger.info("音视频文件样例取消配置响应信息:"+result.getMsg());
}
}
public void updateAvSignSampleValid(Integer isAudit,Integer isValid,String ids){
@@ -187,7 +176,7 @@ public class AvCfgService extends BaseService{
avCfgDao.updateAvSignSampleValid(entity);
}
}
public void auditAvSignSample(AvSignSampleCfg entity,Integer isAudit){
public void auditAvSignSample(AvSignSampleCfg entity,Integer isAudit) throws MaatConvertException{
avCfgDao.auditAvSignSample(entity);
List<AvSignSampleCfg> list = new ArrayList<AvSignSampleCfg>();
list.add(entity);
@@ -209,14 +198,8 @@ public class AvCfgService extends BaseService{
String json=gsonToJson(list);
logger.info("标志样例下发配置参数:"+json);
//调用服务接口取消配置
try {
ToMaatResult result = ConfigServiceUtil.put(json, 2);
logger.info("音视频标志样例配置取消配置响应信息:"+result.getMsg());
} catch (Exception e) {
e.printStackTrace();
logger.info("音视频标志样例取消配置失败");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
ToMaatResult result = ConfigServiceUtil.put(json, 2);
logger.info("音视频标志样例配置取消配置响应信息:"+result.getMsg());
}
}

View File

@@ -219,14 +219,14 @@ clusterBStartTime=1503504000725
isCommit=true
############################################################################################################################################
############################################################################################################################################
httpUrl=http://10.0.6.201:8090/galaxy/service/cfg/v1/
httpUrl=http://10.0.6.249:8080/galaxy/service/cfg/v1/
maatCfg=configSources
fileUploadCfg=fileUploadSources
callbackCfg=commonSources
fileDigestCfg=fileDigestSources
configIdSources=configPzIdSources
client_connect_timeout=1000
client_read_timeout=1000
client_connect_timeout=300000
client_read_timeout=300000
#use elasticsearch or not#
isUseES=false

View File

@@ -264,6 +264,7 @@
</form:form>
</div>
<div class="table-responsive">
<sys:message content="${message}" />
<table id="contentTable" class="table table-striped table-bordered table-condensed text-nowrap">
<thead>
<tr>

View File

@@ -268,6 +268,7 @@
</form:form>
</div>
<div class="table-responsive">
<sys:message content="${message}" />
<table id="contentTable" class="table table-striped table-bordered table-condensed text-nowrap">
<thead>
<tr>
@@ -374,7 +375,7 @@
class="tooltips" data-flag="false" data-html="true" data-placement="top">
${fns:abbr(lableInfo,20)}
</a>
</td>
</td>
<%-- <td>${cfg.areaEffectiveIds }</td> --%>
<td>
<c:if test="${cfg.isValid==0}"><spring:message code="no"/></c:if>