Browse Source

add i18nText

master
独行之狼 4 years ago
parent
commit
696604fac4
  1. BIN
      fr-plugin-MarketUpdate-1.0/fr-plugin-MarketUpdate-1.0.jar
  2. 2
      fr-plugin-MarketUpdate-1.0/plugin.xml
  3. BIN
      install/fr-plugin-MarketUpdate-1.0.zip
  4. 2
      plugin.xml
  5. 5
      src/main/java/com/fr/plugin/market/update/FRExchangeRate.java
  6. 8
      src/main/java/com/fr/plugin/market/update/FRStockMarket.java
  7. 95
      src/main/java/com/fr/plugin/market/update/FunConstants.java
  8. 10
      src/main/java/com/fr/plugin/market/update/MyLocaleFinder.java
  9. 20
      src/main/market update.iml
  10. 6
      src/main/resources/com/fr/com.fr.plugin.market.update/imageProcess.properties
  11. 1
      src/main/resources/com/fr/com.fr.plugin.market.update/imageProcess_zh_CN.properties
  12. 4
      src/main/resources/com/fr/com.fr.plugin.market.update/marketUpdate.properties
  13. 60
      src/main/resources/com/fr/com.fr.plugin.market.update/marketUpdate_zh_CN.properties

BIN
fr-plugin-MarketUpdate-1.0/fr-plugin-MarketUpdate-1.0.jar

Binary file not shown.

2
fr-plugin-MarketUpdate-1.0/plugin.xml

@ -11,7 +11,7 @@
[2021-3-6]初始化插件。<br/>
]]></change-notes>
<extra-core>
<!--<LocaleFinder class="MyLocaleFinder"/>-->
<LocaleFinder class="com.fr.plugin.market.update.MyLocaleFinder"/>
<FunctionGroup class="com.fr.plugin.market.update.FRFinanceFunction"/>
</extra-core>
<function-recorder class="com.fr.plugin.market.update.FRFinanceFunction"/>

BIN
install/fr-plugin-MarketUpdate-1.0.zip

Binary file not shown.

2
plugin.xml

@ -11,7 +11,7 @@
[2021-3-6]初始化插件。<br/>
]]></change-notes>
<extra-core>
<!--<LocaleFinder class="MyLocaleFinder"/>-->
<LocaleFinder class="com.fr.plugin.market.update.MyLocaleFinder"/>
<FunctionGroup class="com.fr.plugin.market.update.FRFinanceFunction"/>
</extra-core>
<function-recorder class="com.fr.plugin.market.update.FRFinanceFunction"/>

5
src/main/java/com/fr/plugin/market/update/FRExchangeRate.java

@ -19,6 +19,8 @@ import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import static com.fr.plugin.market.update.FunConstants.CurrencyCodeList;
@EnableMetrics
@Authorize(callSignKey = FunConstants.PLUGIN_ID)
public class FRExchangeRate extends AbstractFunction {
@ -33,7 +35,6 @@ public class FRExchangeRate extends AbstractFunction {
}
String currencyMain = args[0].toString();
String currencyOther = args[1].toString();
FineLoggerFactory.getLogger().info("input:{}",currencyMain+currencyOther);
float result;
try {
result= getRate(currencyMain,currencyOther);
@ -47,7 +48,7 @@ public class FRExchangeRate extends AbstractFunction {
}
private final float getRate(String currencyMain ,String currencyOther) throws IOException {
if(!ArrayUtils.contains(FunConstants.CurrencyCodeList,currencyMain)||!ArrayUtils.contains(FunConstants.CurrencyCodeList,currencyOther)){
if(!ArrayUtils.contains(CurrencyCodeList,currencyMain)||!ArrayUtils.contains(CurrencyCodeList,currencyOther)){
FineLoggerFactory.getLogger().info(currencyMain+currencyOther);
return 0.0f;
}

8
src/main/java/com/fr/plugin/market/update/FRStockMarket.java

@ -15,6 +15,8 @@ import org.jsoup.nodes.Document;
import java.io.IOException;
import java.util.regex.Pattern;
import static com.fr.plugin.market.update.FunConstants.StockCity;
@EnableMetrics
@Authorize(callSignKey = FunConstants.PLUGIN_ID)
public class FRStockMarket extends AbstractFunction {
@ -31,12 +33,10 @@ public class FRStockMarket extends AbstractFunction {
String city = args[0].toString();
String stockCode = args[1].toString();
String stockArgs = args[2].toString();
FineLoggerFactory.getLogger().info("stockArgs:{}", stockArgs);
String result;
try {
result = getStock(city, stockCode, stockArgs);
} catch (IOException e) {
FineLoggerFactory.getLogger().info("getStock");
return Primitive.ERROR_VALUE;
}
if (result == FunConstants.ARGS_ERROR) {
@ -46,13 +46,13 @@ public class FRStockMarket extends AbstractFunction {
}
private final String getStock(String city, String stockCode, String stockArgs) throws IOException {
if (!ArrayUtils.contains(FunConstants.StockCity, city) || !ArrayUtils.contains(FunConstants.StockArgs, stockArgs)) {
if (!ArrayUtils.contains(StockCity, city) || !ArrayUtils.contains(FunConstants.StockArgs, stockArgs)) {
return FunConstants.ARGS_ERROR;
}
if (!FunConstants.CheckStockCode(stockCode)) {
return FunConstants.ARGS_ERROR;
}
final String cityCode = city.equals("上海") ? "sh" : "sz";
final String cityCode = city.equals(StockCity[0]) ? "sh" : "sz";
final String CHINA_BANK_URI = "http://hq.sinajs.cn/list=" + cityCode + stockCode;
return getStockData(CHINA_BANK_URI, stockArgs);

95
src/main/java/com/fr/plugin/market/update/FunConstants.java

@ -6,18 +6,19 @@ import com.fr.stable.ArrayUtils;
import com.fr.stable.fun.Authorize;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
//import static com.fr.design.i18n.Toolkit.i18nText;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.util.regex.Pattern;
import static com.fr.design.i18n.Toolkit.i18nText;
@Authorize(callSignKey = FunConstants.PLUGIN_ID)
public class FunConstants {
static final String PLUGIN_ID = "com.fr.plugin.market.update";
static final String AUTHOR_ERROR = "Plugin.Function.Market_upate_AUTHOR_ERROR";
static final String CHECK_PASS = "Plugin.Function.ImagProcess_CHECK_PASS";
static final String ARGS_ERROR= "args_error";
static final String AUTHOR_ERROR =i18nText("Plugin.Function.Market_Update_AUTHOR_ERROR");
static final String CHECK_PASS = i18nText("Plugin.Function.Market_Update_CHECK_PASS");
static final String ARGS_ERROR= i18nText("Plugin.Function.Market_Update_ArgsCountError");
//外汇
static final String[] CurrencyCodeList = new String[]{
@ -26,10 +27,46 @@ public class FunConstants {
//股市
static final String[] StockArgs={
"股票名字","今日开盘价","昨日收盘价","当前价格","今日最高价","今日最低价","竞买价","竞卖价","成交股票数","成交金额","买一手数","买一报价","买二手数","买二报价","买三手数","买三报价","买四手数","买四报价","买五手数","买五报价","卖一手数","卖一报价","卖二手数","卖二报价","卖三手数","卖三报价","卖四手数","卖四报价","卖五手数","卖五报价","日期","时间"
//"股票名字","今日开盘价","昨日收盘价","当前价格","今日最高价","今日最低价","竞买价","竞卖价","成交股票数","成交金额",
i18nText("Plugin.Function.Market_Update_Stock_Name"),
i18nText("Plugin.Function.Market_Update_Begin_Price"),
i18nText("Plugin.Function.Market_Update_End_Price"),
i18nText("Plugin.Function.Market_Update_Now_Price"),
i18nText("Plugin.Function.Market_Update_High_Price"),
i18nText("Plugin.Function.Market_Update_Low_Price"),
i18nText("Plugin.Function.Market_Update_Bid_Price"),
i18nText("Plugin.Function.Market_Update_Auction_Price"),
i18nText("Plugin.Function.Market_Update_Trade_Volume"),
i18nText("Plugin.Function.Market_Update_Trade_Amount"),
// "买一手数","买一报价","买二手数","买二报价","买三手数","买三报价","买四手数","买四报价","买五手数","买五报价",
i18nText("Plugin.Function.Market_Update_Buy_1_Number"),
i18nText("Plugin.Function.Market_Update_Buy_1_Price"),
i18nText("Plugin.Function.Market_Update_Buy_2_Number"),
i18nText("Plugin.Function.Market_Update_Buy_2_Price"),
i18nText("Plugin.Function.Market_Update_Buy_3_Number"),
i18nText("Plugin.Function.Market_Update_Buy_3_Price"),
i18nText("Plugin.Function.Market_Update_Buy_4_Number"),
i18nText("Plugin.Function.Market_Update_Buy_4_Price"),
i18nText("Plugin.Function.Market_Update_Buy_5_Number"),
i18nText("Plugin.Function.Market_Update_Buy_5_Price"),
// "卖一手数","卖一报价","卖二手数","卖二报价","卖三手数","卖三报价","卖四手数","卖四报价","卖五手数","卖五报价",
i18nText("Plugin.Function.Market_Update_Sell_1_Number"),
i18nText("Plugin.Function.Market_Update_Sell_1_Price"),
i18nText("Plugin.Function.Market_Update_Sell_2_Number"),
i18nText("Plugin.Function.Market_Update_Sell_2_Price"),
i18nText("Plugin.Function.Market_Update_Sell_3_Number"),
i18nText("Plugin.Function.Market_Update_Sell_3_Price"),
i18nText("Plugin.Function.Market_Update_Sell_4_Number"),
i18nText("Plugin.Function.Market_Update_Sell_4_Price"),
i18nText("Plugin.Function.Market_Update_Sell_5_Number"),
i18nText("Plugin.Function.Market_Update_Sell_5_Price"),
// "日期","时间"
i18nText("Plugin.Function.Market_Update_Stock_Date"),
i18nText("Plugin.Function.Market_Update_Stock_Time"),
};
static final String[] StockCity={
"上海","深圳"
// "上海","深圳",
i18nText("Plugin.Function.Market_Update_Shang_Hai"), i18nText("Plugin.Function.Market_Update_Shen_Zhen")
};
//金银
@ -37,23 +74,49 @@ public class FunConstants {
"伦敦金","伦敦银","COMEX黄金","COMEX白银","黄金T+D","白银T+D"
};
static final String[] GoldName={
"最新价","涨跌","涨跌幅","最高价","最低价","今开价","昨收价"
// "最新价","涨跌","涨跌幅","最高价","最低价","今开价","昨收价"
i18nText("Plugin.Function.Market_Update_New_Price"),
i18nText("Plugin.Function.Market_Update_Rise_Fall"),
i18nText("Plugin.Function.Market_Update_Rise_Fall_Amount"),
i18nText("Plugin.Function.Market_Update_High_Price1"),
i18nText("Plugin.Function.Market_Update_Low_Price1"),
i18nText("Plugin.Function.Market_Update_Begin_Price1"),
i18nText("Plugin.Function.Market_Update_End_Price1"),
};
//期货
static final String[] ForwardType={
"WTI原油","伦敦布伦特原油","黄金","白银","天然气","铜","美国大豆"
// "WTI原油","伦敦布伦特原油","黄金","白银","天然气","铜","美国大豆"
i18nText("Plugin.Function.Market_Update_Crude_Oil"),
i18nText("Plugin.Function.Market_Update_Brent_Oil"),
i18nText("Plugin.Function.Market_Update_Gold"),
i18nText("Plugin.Function.Market_Update_Silver"),
i18nText("Plugin.Function.Market_Update_Natural_Gas"),
i18nText("Plugin.Function.Market_Update_Copper"),
i18nText("Plugin.Function.Market_Update_Us_Soybeans"),
};
static final String[] ForwardURL={
"crude-oil","brent-oil","gold","silver","natural-gas","copper","us-soybeans"
};
static final String[] ForwardAndIndexArgs={
"最新","昨收","开盘"," 最低","最高"
// "最新","昨收","开盘","最低","最高"
i18nText("Plugin.Function.Market_Update_Forward_New_Price"),
i18nText("Plugin.Function.Market_Update_Forward_End_Price"),
i18nText("Plugin.Function.Market_Update_Forward_Begin_Price"),
i18nText("Plugin.Function.Market_Update_Forward_Low_Price"),
i18nText("Plugin.Function.Market_Update_Forward_High_Price"),
};
//指数
static final String[] IndexType={
"上证指数","富时中国A50指数","恒生指数","日经225","道琼斯30(F)","美国标普500(F)","美元指数期货"
// "上证指数","富时中国A50指数","恒生指数","日经225","道琼斯30(F)","美国标普500(F)","美元指数期货"
i18nText("Plugin.Function.Market_Update_Shanghai_Composite"),
i18nText("Plugin.Function.Market_Update_Ftse_China_A50"),
i18nText("Plugin.Function.Market_Update_Hang_Sen"),
i18nText("Plugin.Function.Market_Update_Japan_Ni225"),
i18nText("Plugin.Function.Market_Update_US_30-Futures"),
i18nText("Plugin.Function.Market_Update_US_Spx_500_futures"),
i18nText("Plugin.Function.Market_Update_US_Dollar_Index"),
};
static final String[] IndexURL={
"shanghai-composite","ftse-china-a50","hang-sen-40","japan-ni225","us-30-futures","us-spx-500-futures","us-dollar-index"
@ -84,8 +147,10 @@ public class FunConstants {
}
final String GOLD_URI = "http://www.dyhjw.com/guojijin.html";
final String CLASS_NAME="gold_price_data";
final String CSS_QUERY_NAME="[code='XAU']";
Document doc = Jsoup.connect(GOLD_URI).ignoreContentType(true).get();
String r=doc.getElementsByClass("gold_price_data").first().select("[code='XAU']").first().text();
String r=doc.getElementsByClass(CLASS_NAME).first().select(CSS_QUERY_NAME).first().text();
String[] goldData=r.split(" ");
final int goldArgsIndex = ArrayUtils.indexOf(GoldName, goldArgs)+1;
return goldData[goldArgsIndex];
@ -100,11 +165,13 @@ public class FunConstants {
final String CHINA_BANK_URI = "https://cn.investing.com/commodities/"+ForwardURL[i];
String agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Edg/89.0.774.54";
Document doc = Jsoup.connect(CHINA_BANK_URI).ignoreContentType(true).userAgent(agent).get();
if("最新".equals(forwardArgs)){
if(ForwardAndIndexArgs[0].equals(forwardArgs)){
return doc.getElementById("last_last").text();
}
final String summaryData = doc.getElementById("quotes_summary_secondary_data").select("[ dir=\"ltr\"]").text().replaceAll("- ","");
final String ELEMENT_ID="quotes_summary_secondary_data";
final String CSS_QUERY="[ dir=\"ltr\"]";
final String summaryData = doc.getElementById(ELEMENT_ID).select(CSS_QUERY).text().replaceAll("- ","");
final String[] split = summaryData.split(" ");
final int argsIndex = ArrayUtils.indexOf(ForwardAndIndexArgs, forwardArgs);
return split[argsIndex-1];
@ -119,7 +186,7 @@ public class FunConstants {
final String CHINA_BANK_URI = "https://cn.investing.com/indices/"+IndexURL[i];
String agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36 Edg/89.0.774.54";
Document doc = Jsoup.connect(CHINA_BANK_URI).ignoreContentType(true).userAgent(agent).get();
if("最新".equals(indexdArgs)){
if(ForwardAndIndexArgs[0].equals(indexdArgs)){
return doc.getElementById("last_last").text();
}

10
src/main/java/com/fr/plugin/market/update/MyLocaleFinder.java

@ -0,0 +1,10 @@
package com.fr.plugin.market.update;
import com.fr.stable.fun.impl.AbstractLocaleFinder;
public class MyLocaleFinder extends AbstractLocaleFinder {
@Override
public String find() {
return "com/fr/plugin/market/update";
}
}

20
src/main/market update.iml

@ -49,5 +49,25 @@
<SOURCES />
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../lib/fine-decision-10.0-RELEASE-20200826.160755-1740.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES>
<root url="jar://$MODULE_DIR$/../../lib/fine-decision-10.0-RELEASE-20200826.160755-1740.jar!/" />
</SOURCES>
</library>
</orderEntry>
<orderEntry type="module-library">
<library>
<CLASSES>
<root url="jar://$MODULE_DIR$/../../lib/fine-report-designer-10.0.jar!/" />
</CLASSES>
<JAVADOC />
<SOURCES />
</library>
</orderEntry>
</component>
</module>

6
src/main/resources/com/fr/com.fr.plugin.market.update/imageProcess.properties

@ -1,6 +0,0 @@
Plugin.Function.ImagProcess_ID=com.fr.plugin.function.imagProcess
Plugin.Function.ImagProcess_AUTHOR_ERROR=Error:authorization is expired
Plugin.Function.ImagProcess_CHECK_PASS=checkPass
Plugin.Function.ImagProcess_ReadImageError=Read Image Error!
Plugin.Function.ImagProcess_ArgsCountError=Args Count Error!
Plugin.Function.ImagProcess_FileNotFind=File not Find!

1
src/main/resources/com/fr/com.fr.plugin.market.update/imageProcess_zh_CN.properties

@ -1 +0,0 @@
Plugin-Test_Function_Abs=测试ABS函数

4
src/main/resources/com/fr/com.fr.plugin.market.update/marketUpdate.properties

@ -0,0 +1,4 @@
Plugin.Function.Market_Update_ID=com.fr.plugin.market.update
Plugin.Function.Market_Update_AUTHOR_ERROR=Error:authorization is expired
Plugin.Function.Market_Update_CHECK_PASS=checkPass
Plugin.Function.Market_Update_ArgsCountError=Args Count Error!

60
src/main/resources/com/fr/com.fr.plugin.market.update/marketUpdate_zh_CN.properties

@ -0,0 +1,60 @@
Plugin.Function.Market_Update_Shang_Hai=\u4e0a\u6d77
Plugin.Function.Market_Update_Shen_Zhen=\u6df1\u5733
Plugin.Function.Market_Update_Stock_Name=\u80a1\u7968\u540d\u5b57
Plugin.Function.Market_Update_Begin_Price=\u4eca\u65e5\u5f00\u76d8\u4ef7
Plugin.Function.Market_Update_End_Price=\u6628\u65e5\u6536\u76d8\u4ef7
Plugin.Function.Market_Update_Now_Price=\u5f53\u524d\u4ef7\u683c
Plugin.Function.Market_Update_High_Price=\u4eca\u65e5\u6700\u9ad8\u4ef7
Plugin.Function.Market_Update_Low_Price=\u4eca\u65e5\u6700\u4f4e\u4ef7
Plugin.Function.Market_Update_Bid_Price=\u7ade\u4e70\u4ef7
Plugin.Function.Market_Update_Auction_Price=\u7ade\u5356\u4ef7
Plugin.Function.Market_Update_Trade_Volume=\u6210\u4ea4\u80a1\u7968\u6570
Plugin.Function.Market_Update_Trade_Amount=\u6210\u4ea4\u91d1\u989d
Plugin.Function.Market_Update_Buy_1_Number=\u4e70\u4e00\u624b\u6570
Plugin.Function.Market_Update_Buy_2_Number=\u4e70\u4e8c\u624b\u6570
Plugin.Function.Market_Update_Buy_3_Number=\u4e70\u4e09\u624b\u6570
Plugin.Function.Market_Update_Buy_4_Number=\u4e70\u56db\u624b\u6570
Plugin.Function.Market_Update_Buy_5_Number=\u4e70\u4e94\u624b\u6570
Plugin.Function.Market_Update_Buy_1_Price=\u4e70\u4e00\u62a5\u4ef7
Plugin.Function.Market_Update_Buy_2_Price=\u4e70\u4e8c\u62a5\u4ef7
Plugin.Function.Market_Update_Buy_3_Price=\u4e70\u4e09\u62a5\u4ef7
Plugin.Function.Market_Update_Buy_4_Price=\u4e70\u56db\u62a5\u4ef7
Plugin.Function.Market_Update_Buy_5_Price=\u4e70\u4e94\u62a5\u4ef7
Plugin.Function.Market_Update_Sell_1_Number=\u5356\u4e00\u624b\u6570
Plugin.Function.Market_Update_Sell_1_Price=\u5356\u4e00\u62a5\u4ef7
Plugin.Function.Market_Update_Sell_2_Number=\u5356\u4e8c\u624b\u6570
Plugin.Function.Market_Update_Sell_2_Price=\u5356\u4e8c\u62a5\u4ef7
Plugin.Function.Market_Update_Sell_3_Number=\u5356\u4e09\u624b\u6570
Plugin.Function.Market_Update_Sell_3_Price=\u5356\u4e09\u62a5\u4ef7
Plugin.Function.Market_Update_Sell_4_Number=\u5356\u56db\u624b\u6570
Plugin.Function.Market_Update_Sell_4_Price=\u5356\u56db\u62a5\u4ef7
Plugin.Function.Market_Update_Sell_5_Number=\u5356\u4e94\u624b\u6570
Plugin.Function.Market_Update_Sell_5_Price=\u5356\u4e94\u62a5\u4ef7
Plugin.Function.Market_Update_Stock_Date=\u65e5\u671f
Plugin.Function.Market_Update_Stock_Time=\u65f6\u95f4
Plugin.Function.Market_Update_New_Price=\u6700\u65b0\u4ef7
Plugin.Function.Market_Update_Rise_Fall=\u6da8\u8dcc
Plugin.Function.Market_Update_Rise_Fall_Amount=\u6da8\u8dcc\u5e45
Plugin.Function.Market_Update_High_Price1=\u6700\u9ad8\u4ef7
Plugin.Function.Market_Update_Low_Price1=\u6700\u4f4e\u4ef7
Plugin.Function.Market_Update_Begin_Price1=\u4eca\u5f00\u4ef7
Plugin.Function.Market_Update_End_Price1=\u6628\u6536\u4ef7
Plugin.Function.Market_Update_Crude_Oil=\u0057\u0054\u0049\u539f\u6cb9
Plugin.Function.Market_Update_Brent_Oil=\u4f26\u6566\u5e03\u4f26\u7279\u539f\u6cb9
Plugin.Function.Market_Update_Gold=\u9ec4\u91d1
Plugin.Function.Market_Update_Silver=\u767d\u94f6
Plugin.Function.Market_Update_Natural_Gas=\u5929\u7136\u6c14
Plugin.Function.Market_Update_Copper=\u94dc
Plugin.Function.Market_Update_Us_Soybeans=\u7f8e\u56fd\u5927\u8c46
Plugin.Function.Market_Update_Forward_New_Price=\u6700\u65b0
Plugin.Function.Market_Update_Forward_End_Price=\u6628\u6536
Plugin.Function.Market_Update_Forward_Begin_Price=\u5f00\u76d8
Plugin.Function.Market_Update_Forward_Low_Price=\u6700\u4f4e
Plugin.Function.Market_Update_Forward_High_Price=\u6700\u9ad8
Plugin.Function.Market_Update_Shanghai_Composite=\u4e0a\u8bc1\u6307\u6570
Plugin.Function.Market_Update_Ftse_China_A50=\u5bcc\u65f6\u4e2d\u56fd\u0041\u0035\u0030\u6307\u6570
Plugin.Function.Market_Update_Hang_Sen=\u6052\u751f\u6307\u6570
Plugin.Function.Market_Update_Japan_Ni225=\u65e5\u7ecf\u0032\u0032\u0035
Plugin.Function.Market_Update_US_30-Futures=\u9053\u743c\u65af\u0033\u0030\u0028\u0046\u0029
Plugin.Function.Market_Update_US_Spx_500_futures=\u7f8e\u56fd\u6807\u666e\u0035\u0030\u0030\u0028\u0046\u0029
Plugin.Function.Market_Update_US_Dollar_Index=\u7f8e\u5143\u6307\u6570\u671f\u8d27
Loading…
Cancel
Save