You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
4.0 KiB
113 lines
4.0 KiB
/* |
|
* Copyright (C), 2018-2020 |
|
* Project: starter |
|
* FileName: ReportRowHandler |
|
* Author: xx |
|
* Date: 2020/11/26 21:35 |
|
*/ |
|
package com.fr.plugin.isgd.service; |
|
|
|
import com.fanruan.api.i18n.I18nKit; |
|
import com.fanruan.api.log.LogKit; |
|
import com.fanruan.api.util.StringKit; |
|
import com.fr.decision.fun.impl.BaseHttpHandler; |
|
import com.fr.json.JSONException; |
|
import com.fr.json.JSONObject; |
|
import com.fr.main.workbook.ResultWorkBook; |
|
import com.fr.plugin.context.PluginContexts; |
|
import com.fr.plugin.isgd.bean.ParamColumn; |
|
import com.fr.plugin.isgd.entity.ReportIndexInfoEntity; |
|
import com.fr.plugin.isgd.menu.ParamConfig; |
|
import com.fr.plugin.isgd.provider.ProcessDBAccess; |
|
import com.fr.report.report.ECReport; |
|
import com.fr.third.springframework.web.bind.annotation.RequestMethod; |
|
import com.fr.web.core.ReportSessionIDInfor; |
|
import com.fr.web.core.SessionPoolManager; |
|
import com.fr.web.utils.WebUtils; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
import javax.servlet.http.HttpServletResponse; |
|
import java.util.List; |
|
import java.util.Map; |
|
|
|
/** |
|
* <Function Description><br> |
|
* <ReportRowHandler> |
|
* |
|
* @author xx |
|
* @since 1.0.0 |
|
*/ |
|
public class ReportRowHandler extends BaseHttpHandler { |
|
|
|
public ReportRowHandler() { |
|
} |
|
|
|
@Override |
|
public RequestMethod getMethod() { |
|
return RequestMethod.GET; |
|
} |
|
|
|
@Override |
|
public String getPath() { |
|
return "/isgd"; |
|
} |
|
|
|
@Override |
|
public boolean isPublic() { |
|
return true; |
|
} |
|
|
|
@Override |
|
public void handle(HttpServletRequest request, HttpServletResponse response) throws Exception { |
|
if (PluginContexts.currentContext() == null || !PluginContexts.currentContext().isAvailable()) { |
|
LogKit.error(I18nKit.getLocText("Plugin-isgd_Licence_Expired")); |
|
WebUtils.flushSuccessMessageAutoClose(request, response, createNoChangedResponseJSONObject()); |
|
return; |
|
} |
|
String sessionID = WebUtils.getHTTPRequestParameter(request, "sessionID"); |
|
ReportSessionIDInfor sessionIDInfo = SessionPoolManager.getSessionIDInfor(sessionID, ReportSessionIDInfor.class); |
|
ResultWorkBook resultWorkBook = sessionIDInfo.getExistWorkBook2Show(); |
|
ParamConfig paramConfig = resultWorkBook.getAttrMark(ParamConfig.XML_TAG); |
|
if (paramConfig == null) { |
|
WebUtils.flushSuccessMessageAutoClose(request, response, createNoChangedResponseJSONObject()); |
|
return; |
|
} |
|
ParamColumn paramColumn = new ParamColumn(); |
|
paramColumn.setHeaderRows(paramConfig); |
|
ECReport ecReport = resultWorkBook.getElementCaseReport(0); |
|
List<ReportIndexInfoEntity> reportIndexInfoEntities = paramColumn.getReportIndexInfoEntities(ecReport, sessionIDInfo.getRelativePath(), getUsername(resultWorkBook)); |
|
ProcessDBAccess.saveAll(reportIndexInfoEntities); |
|
WebUtils.flushSuccessMessageAutoClose(request, response, createSuccessResponseJSONObject()); |
|
} |
|
|
|
/** |
|
* 取参数FR_USERNAME或者FINE_USERNAME |
|
* |
|
* @param resultWorkBook |
|
* @return |
|
*/ |
|
private String getUsername(ResultWorkBook resultWorkBook) { |
|
Map<String, Object> parameters = resultWorkBook.getExecuteParameters(); |
|
if (parameters.containsKey("FR_USERNAME")) { |
|
return String.valueOf(parameters.get("FR_USERNAME")); |
|
} |
|
if (parameters.containsKey("FINE_USERNAME")) { |
|
return String.valueOf(parameters.get("FINE_USERNAME")); |
|
} |
|
return StringKit.EMPTY; |
|
} |
|
|
|
private JSONObject createSuccessResponseJSONObject() throws JSONException { |
|
JSONObject successJSON = JSONObject.create(); |
|
successJSON.put("errorCode", 0); |
|
successJSON.put("status", "success"); |
|
return successJSON; |
|
} |
|
|
|
private JSONObject createNoChangedResponseJSONObject() throws JSONException { |
|
JSONObject successJSON = JSONObject.create(); |
|
successJSON.put("errorCode", 1); |
|
successJSON.put("status", "noChanged"); |
|
return successJSON; |
|
} |
|
} |