Commit 24b84b3f authored by Cheng's avatar Cheng

Orange Heap

parent 9536f537
package pwc.taxtech.atms.orangeheap.controller;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import pwc.taxtech.atms.orangeheap.dto.ApiResultDto;
import pwc.taxtech.atms.orangeheap.service.OrangeHeapService;
import javax.annotation.Resource;
@RestController
@RequestMapping("/OrangeHeap/tableau")
public class OrangeHeapController {
@Resource
private OrangeHeapService tableauService;
@ResponseBody
@GetMapping("unreturnedTax")
public ApiResultDto getUnreturnedTax() {
return ApiResultDto.success(tableauService.getUnreturnedTax().orElse(StringUtils.EMPTY));
}
}
package pwc.taxtech.atms.orangeheap.dto;
import org.apache.commons.lang3.StringUtils;
public class ApiResultDto {
private int code;
private Object data;
private String message;
public static final int SUCCESS = 0; //接口成功code
public static final int FAILED = -1; //通用失败code
/**
* 返回成功
*
* @param data data
* @return ApiResultDto
*/
public static ApiResultDto success(Object data) {
return new ApiResultDto(SUCCESS, data, StringUtils.EMPTY);
}
/**
* 返回成功
*
* @return ApiResultDto
*/
public static ApiResultDto success() {
return new ApiResultDto(SUCCESS, null, StringUtils.EMPTY);
}
/**
* 返回失败
*
* @param code fail code
* @param message msg
* @return ApiResultDto
*/
public static ApiResultDto fail(int code, String message) {
return new ApiResultDto(code, null, message);
}
/**
* 返回失败
*
* @param message msg
* @return ApiResultDto
*/
public static ApiResultDto fail(String message) {
return new ApiResultDto(FAILED, null, message);
}
public static ApiResultDto fail() {
return new ApiResultDto(FAILED, null, StringUtils.EMPTY);
}
public ApiResultDto() {
}
public ApiResultDto(int code, Object data, String message) {
this.code = code;
this.data = data;
this.message = message;
}
public int getCode() {
return code;
}
public void setCode(int code) {
this.code = code;
}
public Object getData() {
return data;
}
public void setData(Object data) {
this.data = data;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
}
package pwc.taxtech.atms.orangeheap.service;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import pwc.taxtech.atms.web.OrangeHeapConfig;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Optional;
@Service
public class OrangeHeapService {
@Resource
private OrangeHeapConfig systemConfig;
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
public Optional<String> getTicket(String username) {
CloseableHttpClient httpClient = null;
try {
String ticketUrl = String.format(systemConfig.getTableauGetTicket(), username);
httpClient = HttpClients.createDefault();
HttpPost httpPost = new HttpPost(ticketUrl);
HttpResponse httpResponse = httpClient.execute(httpPost);
String response = IOUtils.toString(httpResponse.getEntity().getContent(), "UTF-8");
return StringUtils.equals(response, "-1") ? Optional.empty() : Optional.of(response);
} catch (Exception e) {
logger.error("getTicket error.", e);
} finally {
if (null != httpClient) {
try {
httpClient.close();
} catch (IOException e) {
logger.error("close httpClient error.", e);
}
}
}
return Optional.empty();
}
public Optional<String> getUnreturnedTax() {
// Optional<String> optional = authUserHelper.getCurrentAuditor();
Optional<String> optional = Optional.of("admin");
return optional.map(s -> String.format(systemConfig.getTableauUnreturnedTax(),
getTicket(s).orElse(StringUtils.EMPTY)));
}
}
package pwc.taxtech.atms.web;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
@Configuration
public class OrangeHeapConfig {
@Value("${longi_api_basic_user}")
private String longiApiBasicUser;
@Value("${longi_api_basic_pwd}")
private String longiApiBasicPwd;
@Value("${longi_api_gl_balance}")
private String longiApiGlBalance;
//tableau相关配置
@Value("${tableau_get_ticket}")
private String tableauGetTicket;
@Value("${tableau_unreturned_tax}")
private String tableauUnreturnedTax;
@Value("${tableau_tax_comparison}")
private String tableauTaxComparison;
@Value("${tableau_other_countries}")
private String tableauOtherCountries;
@Value("${tableau_cost_analysis}")
private String tableauCostAnalysis;
@Value("${tableau_profit_and_loss}")
private String tableauProfitAndLoss;
@Value("${tableau_other_domestic_data}")
private String tableauOtherDomesticData;
@Value("${tableau_doc_situation}")
private String tableauDocSituation;
@Value("${tableau_global_overview}")
private String tableauGlobalOverview;
@Value("${tableau_mexican_tax}")
private String tableauMexicanTax;
@Value("${tableau_australian_tax}")
private String tableauAustralianTax;
@Value("${tableau_brazilian_tax}")
private String tableauBrazilianTax;
public String getLongiApiBasicUser() {
return this.longiApiBasicUser;
}
public void setLongiApiBasicUser(String longiApiBasicUser) {
this.longiApiBasicUser = longiApiBasicUser;
}
public String getLongiApiBasicPwd() {
return this.longiApiBasicPwd;
}
public void setLongiApiBasicPwd(String longiApiBasicPwd) {
this.longiApiBasicPwd = longiApiBasicPwd;
}
public String getLongiApiGlBalance() {
return this.longiApiGlBalance;
}
public void setLongiApiGlBalance(String longiApiGlBalance) {
this.longiApiGlBalance = longiApiGlBalance;
}
public String getTableauGetTicket() {
return this.tableauGetTicket;
}
public void setTableauGetTicket(String tableauGetTicket) {
this.tableauGetTicket = tableauGetTicket;
}
public String getTableauUnreturnedTax() {
return this.tableauUnreturnedTax;
}
public void setTableauUnreturnedTax(String tableauUnreturnedTax) {
this.tableauUnreturnedTax = tableauUnreturnedTax;
}
public String getTableauTaxComparison() {
return this.tableauTaxComparison;
}
public void setTableauTaxComparison(String tableauTaxComparison) {
this.tableauTaxComparison = tableauTaxComparison;
}
public String getTableauOtherCountries() {
return this.tableauOtherCountries;
}
public void setTableauOtherCountries(String tableauOtherCountries) {
this.tableauOtherCountries = tableauOtherCountries;
}
public String getTableauCostAnalysis() {
return this.tableauCostAnalysis;
}
public void setTableauCostAnalysis(String tableauCostAnalysis) {
this.tableauCostAnalysis = tableauCostAnalysis;
}
public String getTableauProfitAndLoss() {
return this.tableauProfitAndLoss;
}
public void setTableauProfitAndLoss(String tableauProfitAndLoss) {
this.tableauProfitAndLoss = tableauProfitAndLoss;
}
public String getTableauOtherDomesticData() {
return this.tableauOtherDomesticData;
}
public void setTableauOtherDomesticData(String tableauOtherDomesticData) {
this.tableauOtherDomesticData = tableauOtherDomesticData;
}
public String getTableauDocSituation() {
return this.tableauDocSituation;
}
public void setTableauDocSituation(String tableauDocSituation) {
this.tableauDocSituation = tableauDocSituation;
}
public String getTableauGlobalOverview() {
return this.tableauGlobalOverview;
}
public void setTableauGlobalOverview(String tableauGlobalOverview) {
this.tableauGlobalOverview = tableauGlobalOverview;
}
public String getTableauMexicanTax() {
return this.tableauMexicanTax;
}
public void setTableauMexicanTax(String tableauMexicanTax) {
this.tableauMexicanTax = tableauMexicanTax;
}
public String getTableauAustralianTax() {
return this.tableauAustralianTax;
}
public void setTableauAustralianTax(String tableauAustralianTax) {
this.tableauAustralianTax = tableauAustralianTax;
}
public String getTableauBrazilianTax() {
return this.tableauBrazilianTax;
}
public void setTableauBrazilianTax(String tableauBrazilianTax) {
this.tableauBrazilianTax = tableauBrazilianTax;
}
}
\ No newline at end of file
......@@ -14,3 +14,24 @@ get_user_info_url=${get_user_info_url}
app_id=${app_id}
app_key=${app_key}
cookie.maxAgeSeconds=${cookie.maxAgeSeconds}
# Tableau Settings
# Longi config
longi_api_basic_user=${longi_api_basic_user}
longi_api_basic_pwd=${longi_api_basic_pwd}
longi_api_gl_balance=${longi_api_gl_balance}
#tableau config
tableau_get_ticket=${tableau_get_ticket}
tableau_unreturned_tax=${tableau_unreturned_tax}
tableau_tax_comparison=${tableau_tax_comparison}
tableau_other_countries=${tableau_other_countries}
tableau_cost_analysis=${tableau_cost_analysis}
tableau_profit_and_loss=${tableau_profit_and_loss}
tableau_other_domestic_data=${tableau_other_domestic_data}
tableau_doc_situation=${tableau_doc_situation}
tableau_global_overview=${tableau_global_overview}
tableau_mexican_tax=${tableau_mexican_tax}
tableau_australian_tax=${tableau_australian_tax}
tableau_brazilian_tax=${tableau_brazilian_tax}
\ No newline at end of file
......@@ -12,4 +12,24 @@ check_ticket=false
get_user_info_url=http://mis.diditaxi.com.cn/auth/sso/api/
app_id=2500
app_key=983258e7fd04d7fa0534735f7b1c33f3
cookie.maxAgeSeconds=86400
\ No newline at end of file
cookie.maxAgeSeconds=86400
# Tableau Setting
# Longi config
longi_api_basic_user=
longi_api_basic_pwd=
longi_api_gl_balance=http://39.105.197.175:13001/ETMSSB/Erp/GLBalance/ProxyServices/ErpQueryGLBalanceSoapProxy?wsdl
#tableau config
tableau_get_ticket=http://47.94.233.173:16010/trusted?username=%s
tableau_unreturned_tax=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/sheet8?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
tableau_tax_comparison=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/sheet14?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
tableau_other_countries=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/Others?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
tableau_cost_analysis=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/sheet19?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
tableau_profit_and_loss=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/sheet26?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
tableau_other_domestic_data=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/sheet32?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
tableau_doc_situation=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/sheet40?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
tableau_global_overview=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/InternationalOverview?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
tableau_mexican_tax=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/Mexico?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
tableau_australian_tax=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/Australia?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
tableau_brazilian_tax=http://10.158.230.16:8890/trusted/%s/views/Didi_Tax_20190307/Brazil?iframeSizedToWindow=true&:embed=y&:showAppBanner=false&:display_count=no&:showVizHome=no&:toolbar=no
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment