39 lines
1.5 KiB
Java
39 lines
1.5 KiB
Java
package cn.palmte.work.service;
|
|
|
|
import cn.palmte.work.pojo.SpaceVO;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import top.jfunc.common.db.bean.Record;
|
|
import top.jfunc.common.db.utils.Pagination;
|
|
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.function.Function;
|
|
import java.util.stream.Collectors;
|
|
|
|
@Service
|
|
public class SpaceService {
|
|
|
|
@Autowired
|
|
private Pagination pagination;
|
|
|
|
public SpaceVO getListData() {
|
|
|
|
String sql = "SELECT count(id) as sum, certainty, certainty_str as name FROM project WHERE approve_status_estimate >= 1 and approve_status_estimate <= 2 and dept_name = '销售管理部' GROUP BY certainty";
|
|
List<Record> pie = pagination.find(sql);
|
|
|
|
String sql2 = "SELECT sum(IFNULL(contract_amount,0)) as sum, avg(IFNULL(gross_profit_margin, 0)) as average, certainty, certainty_str as name FROM project WHERE approve_status_estimate >= 1 and approve_status_estimate <= 2 and dept_name = '销售管理部' GROUP BY certainty";
|
|
List<Record> bar = pagination.find(sql2);
|
|
return combineData(pie, bar);
|
|
}
|
|
|
|
private SpaceVO combineData(List<Record> pie, List<Record> bar) {
|
|
Map<String, Record> map = pie.stream().collect(Collectors.toMap(record -> String.valueOf(record.getInt("certainty")), Function.identity()));
|
|
|
|
SpaceVO spaceVO = new SpaceVO();
|
|
spaceVO.setMap(map);
|
|
spaceVO.setList(bar);
|
|
return spaceVO;
|
|
}
|
|
}
|