提交 1e92a3b2 authored 作者: luojie's avatar luojie

新增汇率实时更新

上级 68a11027
...@@ -44,12 +44,6 @@ public class Test { ...@@ -44,12 +44,6 @@ public class Test {
todayEnd.set(Calendar.MILLISECOND, 999); todayEnd.set(Calendar.MILLISECOND, 999);
return todayEnd.getTime(); return todayEnd.getTime();
} }
@org.junit.jupiter.api.Test
public void test() {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
// tbCfOrderService.updateExpressStatuss(list);
}
*/ */
......
package com.platform.task;
import com.platform.entity.TbCfFeeEntity;
import com.platform.service.TbCfFeeService;
import com.platform.utils.util.HttpUtils;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
/**
* 物流状态定时修改
*/
@Component("FeeTask")
public class FeeTask {
@Autowired
private TbCfFeeService tbCfFeeService;
@Scheduled(cron = "0 0/20 * * * ? ")
public void FeeTask() {
String url="http://op.juhe.cn/onebox/exchange/currency";
Map<String,String> parameters=new HashMap<>();
parameters.put("from","CNY");
parameters.put("to","USD");
parameters.put("key","01a825bc0e074568e7bcec48fdb5f482");
String s = HttpUtils.sendGet(url,parameters);
JSONArray result = JSONObject.fromObject(s).getJSONArray("result");
Map<String,String> map = (Map<String, String>) result.get(1);
String result1 = map.get("result").substring(0,4);
BigDecimal fee=new BigDecimal(result1);
TbCfFeeEntity tbFee =new TbCfFeeEntity();
tbFee.setFeeId("54sda4fa5dsa4f");
tbFee.setFeeRate(fee);
tbCfFeeService.update(tbFee);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论