|
@@ -1,12 +1,14 @@
|
|
|
package com.sky.ioc.service.assets.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.sky.ioc.entity.Indeicator;
|
|
|
import com.sky.ioc.entity.Label;
|
|
|
import com.sky.ioc.entity.Cake;
|
|
|
import com.sky.ioc.entity.domain.operation.Asset;
|
|
|
import com.sky.ioc.entity.domain.operation.Investment;
|
|
|
import com.sky.ioc.entity.params.IocParam;
|
|
|
+import com.sky.ioc.entity.params.IocTimeRange;
|
|
|
import com.sky.ioc.mapper.operation.AssetMapper;
|
|
|
import com.sky.ioc.mapper.operation.InvestmentMapper;
|
|
|
import com.sky.ioc.service.assets.AssetService;
|
|
@@ -213,18 +215,47 @@ public class AssetServiceImpl implements AssetService {
|
|
|
|
|
|
@Override
|
|
|
public ReturnMsg getAssetAnalysis(IocParam iocParam) {
|
|
|
- String[] param = {"investment1","investment2","investment3","investment4","rateReturn"};
|
|
|
+ // String[] param = {"investment1","investment2","investment3","investment4","rateReturn"};
|
|
|
+ List<Investment> investments = investmentMapper.listByTime(iocParam);
|
|
|
String startStr = iocParam.getTimeRange().getStartDate();
|
|
|
String endStr = iocParam.getTimeRange().getEndDate();
|
|
|
List<String> lists = DateUtil.getBetweenDays(startStr, endStr);
|
|
|
String[] labKey = lists.toArray(new String[0]);
|
|
|
- List<Label> labels1 = GeneralMethod.getInstance().dataGeneration(param, labKey);
|
|
|
+ List<Label> labels1 = new ArrayList<>();
|
|
|
+ for (int i = 0; i < labKey.length; i++) {
|
|
|
+ Label label = new Label();
|
|
|
+ IocParam iocParam1 = new IocParam();
|
|
|
+ IocTimeRange iocTimeRange = new IocTimeRange();
|
|
|
+ iocTimeRange.setStartDate(labKey[i]+" 00:00:00");
|
|
|
+ iocTimeRange.setEndDate(labKey[i]+" 23:59:00");
|
|
|
+ iocParam1.setTimeRange(iocTimeRange);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ for (int j = 0; j < investments.size(); j++) {
|
|
|
+ // int i1 = random.nextInt(50, 150);
|
|
|
+ String name = investments.get(j).getName();
|
|
|
+ Investment investment = investmentMapper.getByTimeAndName(iocParam1,name);
|
|
|
+ if(investment!=null){
|
|
|
+ jsonObject.put("investment"+j,investment.getMoney());
|
|
|
+ }else{
|
|
|
+ jsonObject.put("investment"+j,0);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ double rateReturn = investmentMapper.avgReturnByTime(iocParam1);
|
|
|
+ jsonObject.put("rateReturn",MathUtils.division(rateReturn,1,2));
|
|
|
+ label.setJsonObject(jsonObject);
|
|
|
+ label.setLabel(labKey[i]);
|
|
|
+ labels1.add(label);
|
|
|
+ }
|
|
|
+
|
|
|
+ // List<Label> labels1 = GeneralMethod.getInstance().dataGeneration(param, labKey);
|
|
|
return ReturnMsg.ok(labels1);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ReturnMsg getAssetShareRanking(IocParam iocParam) {
|
|
|
List<Cake> list = new ArrayList<>();
|
|
|
+
|
|
|
list.add(new Cake("资产1"));
|
|
|
list.add(new Cake("资产2"));
|
|
|
list.add(new Cake("资产3"));
|