|
@@ -0,0 +1,117 @@
|
|
|
+package com.sky.ioc.service.carbon.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.domain.space.Company;
|
|
|
+import com.sky.ioc.entity.domain.space.Department;
|
|
|
+import com.sky.ioc.entity.params.IocParam;
|
|
|
+import com.sky.ioc.entity.params.IocTimeRange;
|
|
|
+import com.sky.ioc.mapper.carbon.PhotovoltaicMapper;
|
|
|
+import com.sky.ioc.mapper.space.CompanyMapper;
|
|
|
+import com.sky.ioc.mapper.space.DepartmentMapper;
|
|
|
+import com.sky.ioc.service.carbon.PhotovoltaicService;
|
|
|
+import com.sky.ioc.tool.DateUtil;
|
|
|
+import com.sky.ioc.tool.MathUtils;
|
|
|
+import com.sky.ioc.tool.ReturnMsg;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.text.DecimalFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.concurrent.ThreadLocalRandom;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class PhotovoltaicServiceImpl implements PhotovoltaicService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ PhotovoltaicMapper photovoltaicMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CompanyMapper companyMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ DepartmentMapper departmentMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getPhotovoltaicCoreIndicators(IocParam iocParam) {
|
|
|
+ Indeicator indeicator = new Indeicator();
|
|
|
+ List<JSONObject> objects = indeicator.getList();
|
|
|
+ ThreadLocalRandom random = ThreadLocalRandom.current();
|
|
|
+ Double reduPhotovoltaic = photovoltaicMapper.getMinusDischargeByTime(iocParam);
|
|
|
+ double elecPhotovoltaic = photovoltaicMapper.getElectricityByTime(iocParam);
|
|
|
+ double savePhotovoltaic = photovoltaicMapper.getCostSavingByTime(iocParam);
|
|
|
+ Double subPhotovoltaic = photovoltaicMapper.getSubsidyByTime(iocParam);
|
|
|
+ Double compare = random.nextDouble(-1,1);
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
|
+ compare = Double.parseDouble(decimalFormat.format(compare));
|
|
|
+ objects.get(0).put("value", MathUtils.division(reduPhotovoltaic,1,2));
|
|
|
+ objects.get(0).put("compare",compare);
|
|
|
+
|
|
|
+ objects.get(1).put("value",MathUtils.division(elecPhotovoltaic,1,2));
|
|
|
+ objects.get(1).put("compare",compare);
|
|
|
+
|
|
|
+ objects.get(2).put("value",MathUtils.division(savePhotovoltaic,1,2));
|
|
|
+ objects.get(2).put("compare",compare);
|
|
|
+
|
|
|
+ objects.get(3).put("value",MathUtils.division(subPhotovoltaic,1,2));
|
|
|
+ objects.get(3).put("compare",compare);
|
|
|
+ indeicator.setWorthAttention("光伏发电持续为您服务");
|
|
|
+ indeicator.setList(objects);
|
|
|
+ return ReturnMsg.ok(indeicator);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ReturnMsg getPhotovoltaicInfo(IocParam iocParam) {
|
|
|
+ Company company = companyMapper.selectById(1);
|
|
|
+ Department department = departmentMapper.selectById(company.getOfficeId());
|
|
|
+ List<Department> departments =departmentMapper.selectList(new LambdaQueryWrapper<Department>().eq(Department::getParentId,department.getOriId()));
|
|
|
+ String[] param = departments.stream().map(Department::getName).collect(Collectors.toList()).toArray(new String[0]);
|
|
|
+ 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 = 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:59");
|
|
|
+ iocParam1.setTimeRange(iocTimeRange);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ for (int j = 0; j < departments.size(); j++) {
|
|
|
+ iocParam1.setDeptId(departments.get(j).getId());
|
|
|
+ double total = photovoltaicMapper.getMinusDischargeByTime(iocParam1);
|
|
|
+ jsonObject.put(param[j],total);
|
|
|
+ }
|
|
|
+ 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 getPhotovoltaicInfoOrder(IocParam iocParam) {
|
|
|
+ String[] param = {"Photovoltaic"};
|
|
|
+ //String[] labKey = {"中旬","规划院","成分","上分","广分","郑分"};
|
|
|
+ List<Map<String,Object>> lists = photovoltaicMapper.getMinusDischargeOrderByTime(iocParam);
|
|
|
+ List<Label> labels1 = new ArrayList<>();
|
|
|
+ for(Map<String,Object> map:lists){
|
|
|
+ Label label = new Label();
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ label.setJsonObject(jsonObject);
|
|
|
+ label.setLabel(String.valueOf(map.get("name")));
|
|
|
+ labels1.add(label);
|
|
|
+ jsonObject.put(param[0],map.get("total"));
|
|
|
+ }
|
|
|
+ // List<Label> labels1 = GeneralMethod.getInstance().dataGeneration(param, labKey);
|
|
|
+ return ReturnMsg.ok(labels1);
|
|
|
+ }
|
|
|
+}
|