|
@@ -1,10 +1,16 @@
|
|
|
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.CarCarbonMapper;
|
|
|
+import com.sky.ioc.mapper.space.CompanyMapper;
|
|
|
+import com.sky.ioc.mapper.space.DepartmentMapper;
|
|
|
import com.sky.ioc.service.carbon.CarCarbonService;
|
|
|
import com.sky.ioc.tool.DateUtil;
|
|
|
import com.sky.ioc.tool.GeneralMethod;
|
|
@@ -14,7 +20,11 @@ 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 CarCarbonServiceImpl implements CarCarbonService {
|
|
@@ -22,13 +32,19 @@ public class CarCarbonServiceImpl implements CarCarbonService {
|
|
|
@Autowired
|
|
|
CarCarbonMapper carCarbonMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ DepartmentMapper departmentMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ CompanyMapper companyMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public ReturnMsg getVehicleCoreIndicators(IocParam iocParam) {
|
|
|
Indeicator indeicator = new Indeicator();
|
|
|
List<JSONObject> objects = indeicator.getList();
|
|
|
int days = DateUtil.daysBetween(iocParam.getTimeRange().getStartDate(),iocParam.getTimeRange().getEndDate());
|
|
|
long totalMile = carCarbonMapper.getMileageByTime(iocParam);
|
|
|
- long totalDischarge = carCarbonMapper.getDischargeByTime(iocParam);
|
|
|
+ double totalDischarge = carCarbonMapper.getDischargeByTime(iocParam);
|
|
|
long totalHours = carCarbonMapper.getHoursByTime(iocParam);
|
|
|
float compare = (float) Math.random();
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#.0");
|
|
@@ -52,12 +68,52 @@ public class CarCarbonServiceImpl implements CarCarbonService {
|
|
|
|
|
|
@Override
|
|
|
public ReturnMsg getVehicleInfo(IocParam iocParam) {
|
|
|
- String[] param = {"中迅","北京规划院","郑分","广分","上分","成分"};
|
|
|
+ // String[] param = {"中迅","北京规划院","郑分","广分","上分","成分"};
|
|
|
+ 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 = 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:59");
|
|
|
+ iocParam1.setTimeRange(iocTimeRange);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ for (int j = 0; j < departments.size(); j++) {
|
|
|
+ iocParam1.setDeptId(departments.get(j).getId());
|
|
|
+ double total = carCarbonMapper.getDischargeByTime(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 getVehicleInfoOrder(IocParam iocParam) {
|
|
|
+ String[] param = {"Vehicle"};
|
|
|
+ // String[] labKey = {"中旬","规划院","成分","上分","广分","郑分"};
|
|
|
+ List<Map<String,Object>> lists = carCarbonMapper.getDischargeOrderByTime(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);
|
|
|
}
|
|
|
}
|