Commit c20a8fda authored by gaoliwei's avatar gaoliwei

Merge branch 'develop' of ssh://103.249.252.28:10022/wangxiahui/zhny into develop

parents ac5c74e2 47087c2f
......@@ -20,7 +20,7 @@ public interface BusDeviceFaultRepository extends BaseMapper<BusDeviceFault> {
* @param busDeviceFaultVo
* @return 日期,次数的list
*/
@Select("<script>select date_format(b.TM,'%e') `day`,count(*) NUM from bus_device_fault b where b.PRO_ID=#{proId} and date_format(b.TM,'%Y-%c')=#{date} group by date_format(b.TM,'%e')</script>")
@Select("<script>select date_format(b.TM,'%e') `day`,count(*) NUM from bus_device_fault b where b.PRO_ID=#{proId} and date_format(b.TM,'%Y-%c')=#{date} group by date_format(b.TM,'%e')+0 asc</script>")
@ResultMap(value = "vo")
List<BusDeviceFaultVo> statFault(BusDeviceFaultVo busDeviceFaultVo);
......
......@@ -131,4 +131,35 @@ public class OverViewController {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, overViewServiceImpl.statEmissionDay(proId, year, month));
}
/** -------------碳排放量--------------- */
@ApiOperation(value="年用能计划", notes="年用能计划")
@ApiImplicitParams({@ApiImplicitParam(name = "proId", value = "项目类型主键", required = true, dataType = "字符串"),
@ApiImplicitParam(name = "year", value = "年份,如:2018", required = true, dataType = "字符串或数字")
})
@RequestMapping("/statEnergyPlanYear")
public Result statEnergyPlanYear(@RequestParam String proId, @RequestParam String year) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, overViewServiceImpl.statEnergyPlanYear(proId, year));
}
@ApiOperation(value="月用能计划", notes="月用能计划")
@ApiImplicitParams({@ApiImplicitParam(name = "proId", value = "项目类型主键", required = true, dataType = "字符串"),
@ApiImplicitParam(name = "year", value = "年份,如:2018", required = true, dataType = "字符串或数字"),
@ApiImplicitParam(name = "month", value = "月份,如:6", required = true, dataType = "字符串或数字")
})
@RequestMapping("/statEnergyPlanMonth")
public Result statEnergyPlanMonth(@RequestParam String proId, @RequestParam String year, @RequestParam String month) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, overViewServiceImpl.statEnergyPlanMonth(proId, year, month));
}
@ApiOperation(value="日用能计划", notes="日用能计划")
@ApiImplicitParams({@ApiImplicitParam(name = "proId", value = "项目类型主键", required = true, dataType = "字符串"),
@ApiImplicitParam(name = "year", value = "年份,如:2018", required = true, dataType = "字符串或数字"),
@ApiImplicitParam(name = "month", value = "月份,如:6", required = true, dataType = "字符串或数字"),
@ApiImplicitParam(name = "day", value = "日,如:1", required = true, dataType = "字符串或数字")
})
@RequestMapping("/statEnergyPlanDay")
public Result statEnergyPlanDay(@RequestParam String proId, @RequestParam String year, @RequestParam String month, @RequestParam String day) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, overViewServiceImpl.statEnergyPlanDay(proId, year, month, day));
}
}
package org.rcisoft.business.overview.dao;
import org.rcisoft.business.overview.entity.BusEnergyplanV;
import org.rcisoft.business.overview.vo.BusEnergyPlanVo;
import org.rcisoft.core.base.BaseMapper;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* Created with on 2018-4-19 9:20:45.
*/
@Repository
public interface BusEnergyplanVRepository extends BaseMapper<BusEnergyplanV> {
@Select("<script>select date_format(b.TM,'%c') MON,sum(b.ENERGY_MONEY) ENERGY_MONEY from bus_energyplan_v b,bus_device d where b.DEV_NUM=d.DEV_ID and d.PRO_ID=#{proId} and date_format(b.TM,'%Y')=#{time} group by date_format(b.TM,'%c') order by date_format(b.TM,'%c')+0 asc</script>")
@ResultMap(value = "vo")
List<BusEnergyPlanVo> statEnergyPlanYear(BusEnergyPlanVo busEnergyPlanVo);
@Select("<script>select date_format(b.TM,'%e') `DAY`,sum(b.ENERGY_MONEY) ENERGY_MONEY from bus_energyplan_v b,bus_device d where b.DEV_NUM=d.DEV_ID and d.PRO_ID=#{proId} and date_format(b.TM,'%Y-%c')=#{time} group by date_format(b.TM,'%e') order by date_format(b.TM,'%e')+0 asc</script>")
@ResultMap(value = "vo")
List<BusEnergyPlanVo> statEnergyPlanMonth(BusEnergyPlanVo busEnergyPlanVo);
@Select("<script>select date_format(b.TM,'%k') `HOUR`,sum(b.ENERGY_MONEY) ENERGY_MONEY from bus_energyplan_v b,bus_device d where b.DEV_NUM=d.DEV_ID and d.PRO_ID=#{proId} and date_format(b.TM,'%Y-%c-%e')=#{time} group by date_format(b.TM,'%k') order by date_format(b.TM,'%k')+0 asc</script>")
@ResultMap(value = "vo")
List<BusEnergyPlanVo> statEnergyPlanDay(BusEnergyPlanVo busEnergyPlanVo);
}
......@@ -38,12 +38,12 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @param energyCountMVo
* @return
*/
@Select("<script>select e.HOUR," +
@Select("<script>select e.`HOUR`," +
"<if test=\"type == 1\">sum(e.WATER_MONEY)</if>" +
"<if test=\"type == 2\">sum(e.ELEC_MONEY)</if>" +
"<if test=\"type == 3\">sum(e.GAS_MONEY)</if>" +
" as MONEY from ENERGY_COUNT_M e" +
" where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} and e.`DAY`=#{day} group by e.HOUR</script>")
" where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} and e.`DAY`=#{day} group by e.`HOUR`+0 asc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> countDailyPrice(EnergyCountMVo energyCountMVo);
......@@ -73,7 +73,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
"<if test=\"type == 3\">sum(e.GAS_MONEY)</if>" +
" as MONEY from ENERGY_COUNT_M e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon}" +
"<if test=\"hour != null\"> and e.HOUR &lt;= #{hour}</if>" +
" group by e.`DAY`) a order by a.MONEY desc</script>")
" group by e.`DAY`+0 asc) a order by a.MONEY desc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> getPriceRank(EnergyCountMVo energyCountMVo);
......@@ -86,7 +86,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
"<if test=\"type == 1\">sum(e.WATER)</if>" +
"<if test=\"type == 2\">sum(e.ELEC)</if>" +
"<if test=\"type == 3\">sum(e.GAS)</if>" +
" as ENERGY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} group by e.`DAY`</script>")
" as ENERGY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} group by e.`DAY`+0 asc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> getEnergyCompare(EnergyCountMVo energyCountMVo);
......@@ -96,7 +96,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @return
*/
@Select("<script>select e.MON,sum(e.WATER) as WATER,sum(e.ELEC) as ELEC,sum(e.GAS) as GAS from energy_count_m e" +
" where e.PRO_ID=#{proId} and e.`YEAR`=#{year} group by e.MON</script>")
" where e.PRO_ID=#{proId} and e.`YEAR`=#{year} group by e.MON+0 asc</script>")
@ResultMap("BaseResultMap")
List<EnergyCountM> getEnergyMonth(EnergyCountM energyCountM);
......@@ -109,4 +109,31 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
@ResultMap("BaseResultMap")
EnergyCountM countEnergyDay(EnergyCountM energyCountM);
/**
* 年用能计划
* @param energyCountMVo
* @return
*/
@Select("<script>select e.MON,sum(if(e.WATER_MONEY is null,0,e.WATER_MONEY))+sum(if(e.ELEC_MONEY is null,0,e.ELEC_MONEY))+sum(if(e.GAS_MONEY is null,0,e.GAS_MONEY)) MONEY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} group by e.MON+0 asc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> statEnergyPlanYear(EnergyCountMVo energyCountMVo);
/**
* 月用能计划
* @param energyCountMVo
* @return
*/
@Select("<script>select e.`DAY`,sum(if(e.WATER_MONEY is null,0,e.WATER_MONEY))+sum(if(e.ELEC_MONEY is null,0,e.ELEC_MONEY))+sum(if(e.GAS_MONEY is null,0,e.GAS_MONEY)) MONEY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} group by e.`DAY`+0 asc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> statEnergyPlanMonth(EnergyCountMVo energyCountMVo);
/**
* 日用能计划
* @param energyCountMVo
* @return
*/
@Select("<script>select e.`HOUR`,sum(if(e.WATER_MONEY is null,0,e.WATER_MONEY))+sum(if(e.ELEC_MONEY is null,0,e.ELEC_MONEY))+sum(if(e.GAS_MONEY is null,0,e.GAS_MONEY)) MONEY from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} and e.`DAY`=#{day} group by e.`HOUR`+0 asc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> statEnergyPlanDay(EnergyCountMVo energyCountMVo);
}
......@@ -38,7 +38,7 @@ public interface EnergyEmissionRealRepository extends BaseMapper<EnergyEmissionR
* @param energyEmissionReal
* @return
*/
@Select("<script>select e.MON,sum(e.EMISSION) as EMISSION from energy_emission_real e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} group by e.MON</script>")
@Select("<script>select e.MON,sum(e.EMISSION) as EMISSION from energy_emission_real e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} group by e.MON asc</script>")
@ResultMap(value = "BaseResultMap" )
List<EnergyEmissionReal> statEmissionMonth(EnergyEmissionReal energyEmissionReal);
......@@ -47,7 +47,7 @@ public interface EnergyEmissionRealRepository extends BaseMapper<EnergyEmissionR
* @param energyEmissionReal
* @return
*/
@Select("<script>select e.`DAY`,sum(e.EMISSION) as EMISSION from energy_emission_real e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} group by e.`DAY`</script>")
@Select("<script>select e.`DAY`,sum(e.EMISSION) as EMISSION from energy_emission_real e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} group by e.`DAY` asc</script>")
@ResultMap(value = "BaseResultMap" )
List<EnergyEmissionReal> statEmissionDay(EnergyEmissionReal energyEmissionReal);
......
package org.rcisoft.business.overview.entity;
import lombok.*;
import org.rcisoft.core.entity.IdNotDataEntity;
import javax.persistence.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
/**
* Created with on 2018-4-19 9:20:45.
*/
@Entity
@Data
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "bus_energyplan_v")
public class BusEnergyplanV implements Serializable {
@Id
private Integer id;
private String devNum;
private Date tm;
private BigDecimal energyPower;
private BigDecimal energyGas;
private BigDecimal energyMoney;
}
......@@ -21,11 +21,22 @@ import java.util.List;
@Table(name = "energy_count_m")
public class EnergyCountM implements Serializable {
public EnergyCountM(String proId, String day, String mon, String year) {
public EnergyCountM(String proId, String year) {
this.proId = proId;
this.day = day;
this.year = year;
}
public EnergyCountM(String proId, String year, String mon) {
this.proId = proId;
this.year = year;
this.mon = mon;
}
public EnergyCountM(String proId, String year, String mon, String day) {
this.proId = proId;
this.year = year;
this.mon = mon;
this.day = day;
}
@Id
......
......@@ -122,4 +122,31 @@ public interface OverViewService {
*/
PersistModel statEmission();
/**
* 年用能计划
* @param proId
* @param year
* @return
*/
Map<String, Object> statEnergyPlanYear(String proId, String year);
/**
* 月用能计划
* @param proId
* @param year
* @param month
* @return
*/
Map<String, Object> statEnergyPlanMonth( String proId, String year, String month);
/**
* 日用能计划
* @param proId
* @param year
* @param month
* @param day
* @return
*/
Map<String, Object> statEnergyPlanDay( String proId, String year, String month, String day);
}
......@@ -2,9 +2,11 @@ package org.rcisoft.business.overview.service.impl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.formula.functions.T;
import org.rcisoft.business.overview.dao.*;
import org.rcisoft.business.overview.entity.*;
import org.rcisoft.business.overview.service.OverViewService;
import org.rcisoft.business.overview.vo.BusEnergyPlanVo;
import org.rcisoft.business.overview.vo.BusProjectAreaVo;
import org.rcisoft.business.overview.vo.EnergyCountMVo;
import org.rcisoft.business.overview.vo.EnergyPriceVo;
......@@ -16,6 +18,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.math.BigDecimal;
import java.util.*;
/**
......@@ -41,6 +44,8 @@ public class OverViewServiceImpl implements OverViewService {
private EnergyEmissionTotalRepository energyEmissionTotalRepository;
@Autowired
private EnergyEmissionPlanRepository energyEmissionPlanRepository;
@Autowired
private BusEnergyplanVRepository busEnergyplanVRepository;
private Calendar getBeforeDay(Calendar cl, int time){
int day = cl.get(Calendar.DATE);
......@@ -79,10 +84,34 @@ public class OverViewServiceImpl implements OverViewService {
return result;
}
//查询当月的天数
private int getCurrentMonthDateCount(Object year, Object month){
Calendar cal = Calendar.getInstance();
if(year != null){
if (year instanceof Integer){
cal.set(Calendar.YEAR, (Integer) year);
}else if (year instanceof String){
cal.set(Calendar.YEAR, Integer.parseInt((String) year));
}
}
if(month != null){
if (month instanceof Integer) cal.set(Calendar.MONTH, (Integer) month - 1);
else if (month instanceof String) cal.set(Calendar.MONTH, Integer.parseInt((String) month) - 1);
}
return cal.getActualMaximum(Calendar.DATE);
}
public static void main(String[] args){
// OverViewServiceImpl o = new OverViewServiceImpl();
// Map<String, String> time = o.getTime("2016", "3", null, 0, -1, 0);
// System.out.println(time.get("year") + "-" + time.get("month") + "-" + time.get("day"));
// Calendar cal = Calendar.getInstance();
// int maxDate = cal.getActualMaximum(Calendar.DATE);
// System.out.println(maxDate);
OverViewServiceImpl o = new OverViewServiceImpl();
Map<String, String> time = o.getTime("2016", "3", null, 0, -1, 0);
System.out.println(time.get("year") + "-" + time.get("month") + "-" + time.get("day"));
// System.out.println(o.getCurrentMonthDateCount("2018", null));
}
private String getType(String type) {
......@@ -102,63 +131,137 @@ public class OverViewServiceImpl implements OverViewService {
return type;
}
private List<Float> getFloatList(List<EnergyCountMVo> list){
private List<BigDecimal> getEnergyMoneyResult(List<EnergyCountMVo> list, int num) {
BigDecimal zero = new BigDecimal(0);
List<BigDecimal> resultList = new ArrayList<BigDecimal>();
if(list != null && list.size() > 0){
int size = list.size();
int j = 1;
for (int i = 0; i < size; i++) {
EnergyCountMVo e = list.get(i);
int temp = 0;
switch (num) {
case 24:
temp = Integer.parseInt(e.getHour()) + 1;
break;
case 12:
temp = Integer.parseInt(e.getMon());
break;
default:
temp = Integer.parseInt(e.getDay());
break;
}
while (temp > j++){
resultList.add(zero);
}
resultList.add(e.getMoney());
if(i == size - 1){
while (temp++ < num){
resultList.add(zero);
}
}
}
}else{
for (int i = 0; i < num; i++) {
resultList.add(zero);
}
}
return resultList;
}
//小时:24,日:其他,月:12
private List<Float> getEnergyResult(List<EnergyCountMVo> list, int num){
List<Float> resultList = new ArrayList<Float>();
if(list != null && list.size() > 0){
int size = list.size();
// Integer start = Integer.parseInt(list.get(0).getDay());
// Integer end = Integer.parseInt(list.get(size - 1).getDay());
// for (int i = 1; i < start; i++) {
// resultList.add(0f);
// }
// for (int i = 0; i < size; i++) {
// resultList.add(list.get(i).getEnergy());
// }
// for (int i = end; i < 31; i++) {
// resultList.add(0f);
// }
int j = 1;
for (int i = 0; i < size; i++) {
EnergyCountMVo e = list.get(i);
int day = Integer.parseInt(e.getDay());
while (day > j++){
int temp = 0;
switch (num) {
case 24:
temp = Integer.parseInt(e.getHour()) + 1;
break;
case 12:
temp = Integer.parseInt(e.getMon());
break;
default:
temp = Integer.parseInt(e.getDay());
break;
}
while (temp > j++){
resultList.add(0f);
}
resultList.add(e.getEnergy());
if(i == size - 1){
while (day++ < 31){
while (temp++ < num){
resultList.add(0f);
}
}
}
}else{
for (int i = 0; i < 31; i++) {
for (int i = 0; i < num; i++) {
resultList.add(0f);
}
}
return resultList;
}
//月传12,日传31
private List<BigDecimal> getPlanResult(List<BusEnergyPlanVo> list, int num){
BigDecimal zero = new BigDecimal(0);
List<BigDecimal> resultList = new ArrayList<BigDecimal>();
if(list != null && list.size() > 0){
int size = list.size();
int j = 1;
for (int i = 0; i < size; i++) {
BusEnergyPlanVo b = list.get(i);
int temp = 0;
switch (num) {
case 24:
temp = Integer.parseInt(b.getHour()) + 1;
break;
case 12:
temp = Integer.parseInt(b.getMon());
break;
default:
temp = Integer.parseInt(b.getDay());
break;
}
while (temp > j++){
resultList.add(zero);
}
resultList.add(b.getEnergyMoney());
if(i == size - 1){
while (temp++ < num){
resultList.add(zero);
}
}
}
}else{
for (int i = 0; i < num; i++) {
resultList.add(zero);
}
}
return resultList;
}
//日:其他,月:12
private List<Float> getEmissionResult(List<EnergyEmissionReal> list, int num) {
List<Float> resultList = new ArrayList<Float>();
if(list != null && list.size() > 0){
int size = list.size();
// Integer start = num == 12 ? list.get(0).getMon() : list.get(0).getDay();
// Integer end = num == 12 ? list.get(size - 1).getMon() : list.get(size - 1).getDay();
// for (int i = 1; i < start; i++) {
// resultList.add(0f);
// }
// for (int i = 0; i < size; i++) {
// resultList.add(list.get(i).getEmission());
// }
// for (int i = end; i < num; i++) {
// resultList.add(0f);
// }
int j = 1;
for (int i = 0; i < size; i++) {
EnergyEmissionReal e = list.get(i);
int temp = num == 12 ? e.getMon() : e.getDay();
int temp = 0;
switch (num) {
case 12:
temp = e.getMon();
break;
default:
temp = e.getDay();
break;
}
while (temp > j++){
resultList.add(0f);
}
......@@ -304,6 +407,7 @@ public class OverViewServiceImpl implements OverViewService {
@Override
public Map<String, Object> getEnergyCompare(String proId, String year, String month, Integer type, Integer cType) {
int dateCount = this.getCurrentMonthDateCount(year, month);
//返回值
Map<String, Object> result = new HashMap<String, Object>();
//添加当前年月
......@@ -317,7 +421,7 @@ public class OverViewServiceImpl implements OverViewService {
//查找现在的数据
List<EnergyCountMVo> nowCompare = energyCountMRepository.getEnergyCompare(e);
//现在数据最后返回的对象
List<Float> nowReturn = this.getFloatList(nowCompare);
List<Float> nowReturn = this.getEnergyResult(nowCompare, dateCount);
//查找需要比较的数据
Map<String, String> time = null;
//同比,环比,确定时间
......@@ -331,11 +435,11 @@ public class OverViewServiceImpl implements OverViewService {
String c_month = time.get("month");
e.setYear(c_year);
e.setMon(c_month);
//添加当前年月
//添加年月
result.put("cYear", c_year);
result.put("cMonth", c_month);
List<EnergyCountMVo> lastCompare = energyCountMRepository.getEnergyCompare(e);
List<Float> lastReturn = this.getFloatList(lastCompare);
List<Float> lastReturn = this.getEnergyResult(lastCompare, dateCount);
//差值
List<Float> diffReturn = new ArrayList<Float>();
for (int i = 0; i < nowReturn.size(); i++) {
......@@ -425,17 +529,17 @@ public class OverViewServiceImpl implements OverViewService {
EnergyEmissionReal e_now = new EnergyEmissionReal(proId, year);
EnergyEmissionReal year_now = energyEmissionRealRepository.statEnergyEmissionReal(e_now);
if(year_now != null) result.put("year_now", year_now.getEmission());
else result.put("year_now", 0);
else result.put("year_now", 0f);
//当月
e_now.setMon(month);
EnergyEmissionReal month_now = energyEmissionRealRepository.statEnergyEmissionReal(e_now);
if(month_now != null) result.put("month_now", month_now.getEmission());
else result.put("month_now", 0);
else result.put("month_now", 0f);
//当日
e_now.setDay(day);
EnergyEmissionReal day_now = energyEmissionRealRepository.queryEnergyEmissionReal(e_now);
if(day_now != null) result.put("day_now", day_now.getEmission());
else result.put("day_now", 0);
else result.put("day_now", 0f);
//同比年
EnergyEmissionReal e_same = new EnergyEmissionReal(proId, year - 1);
EnergyEmissionReal year_same = energyEmissionRealRepository.statEnergyEmissionReal(e_same);
......@@ -482,7 +586,7 @@ public class OverViewServiceImpl implements OverViewService {
@Override
public List<Float> statEmissionDay(String proId, int year, int month) {
return this.getEmissionResult(energyEmissionRealRepository.statEmissionDay(new EnergyEmissionReal(proId, year, month)), 31);
return this.getEmissionResult(energyEmissionRealRepository.statEmissionDay(new EnergyEmissionReal(proId, year, month)), this.getCurrentMonthDateCount(year, month));
}
@Transactional(propagation = Propagation.REQUIRED,isolation = Isolation.DEFAULT)
......@@ -527,4 +631,52 @@ public class OverViewServiceImpl implements OverViewService {
return new PersistModel(result);
}
private Map<String, Object> getEnergyPlanResult(List<BigDecimal> planList, List<BigDecimal> realList) {
//达标月数,未达标月数
int standard = 0, excessive = 0;
int size = realList.size();
for (int i = 0; i < size; i++) {
if(realList.get(i).compareTo(planList.get(i)) > 0){
excessive++;
}else{
standard++;
}
}
//返回结果
Map<String, Object> result = new HashMap<String, Object>();
result.put("plan", planList);
result.put("real", realList);
result.put("running", size);
result.put("standard", standard);
result.put("excessive", excessive);
return result;
}
@Override
public Map<String, Object> statEnergyPlanYear(String proId, String year) {
//查计划
List<BigDecimal> planList = this.getPlanResult(busEnergyplanVRepository.statEnergyPlanYear(new BusEnergyPlanVo(proId, year)), 12);
//查实际
List<BigDecimal> realList = this.getEnergyMoneyResult(energyCountMRepository.statEnergyPlanYear(new EnergyCountMVo(proId, year)), 12);
return this.getEnergyPlanResult(planList, realList);
}
@Override
public Map<String, Object> statEnergyPlanMonth(String proId, String year, String month) {
int dateCount = this.getCurrentMonthDateCount(year, month);
List<BigDecimal> planList = this.getPlanResult(busEnergyplanVRepository.statEnergyPlanMonth(new BusEnergyPlanVo(proId, year + "-" + month)), dateCount);
List<BigDecimal> realList = this.getEnergyMoneyResult(energyCountMRepository.statEnergyPlanMonth(new EnergyCountMVo(proId, year, month)), dateCount);
return this.getEnergyPlanResult(planList, realList);
}
@Override
public Map<String, Object> statEnergyPlanDay(String proId, String year, String month, String day) {
List<BigDecimal> planList = this.getPlanResult(busEnergyplanVRepository.statEnergyPlanDay(new BusEnergyPlanVo(proId, year + "-" + month + "-" + day)), 24);
List<BigDecimal> realList = this.getEnergyMoneyResult(energyCountMRepository.statEnergyPlanDay(new EnergyCountMVo(proId, year, month, day)), 24);
Map<String, Object> result = new HashMap<String, Object>();
result.put("plan", planList);
result.put("real", realList);
return result;
}
}
package org.rcisoft.business.overview.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.rcisoft.business.overview.entity.BusEnergyplanV;
import java.math.BigDecimal;
import java.util.Date;
/**
* Created by JiChao on 2018/4/18.
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class BusEnergyPlanVo extends BusEnergyplanV {
public BusEnergyPlanVo(String proId, String time) {
super();
this.proId = proId;
this.time = time;
}
private String year, mon, day, hour, time;
private String proId;
}
package org.rcisoft.business.overview.vo;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.rcisoft.business.overview.entity.EnergyCountM;
import java.math.BigDecimal;
......@@ -8,9 +10,23 @@ import java.math.BigDecimal;
/**
* Created by JiChao on 2018/4/12.
*/
@NoArgsConstructor
@AllArgsConstructor
@Data
public class EnergyCountMVo extends EnergyCountM {
public EnergyCountMVo(String proId, String year){
super(proId, year);
}
public EnergyCountMVo(String proId, String year, String mon){
super(proId, year, mon);
}
public EnergyCountMVo(String proId, String year, String mon, String day){
super(proId, year, mon, day);
}
//水电气区分
private Integer type;
//费用
......
......@@ -4,6 +4,7 @@
<select id="listProjectInformationByYear" resultType="map">
SELECT
(select count(*) from bus_project) as total,
PRO_NM,
BLD_LOCAL,
bbt.BLD_TP_NM,
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.rcisoft.business.overview.dao.BusEnergyplanVRepository">
<resultMap id="BaseResultMap" type="org.rcisoft.business.overview.entity.BusEnergyplanV">
<id column="ID" jdbcType="INTEGER" property="id"/>
<result column="DEV_NUM" jdbcType="VARCHAR" property="devNum"/>
<result column="TM" jdbcType="TIMESTAMP" property="tm"/>
<result column="ENERGY_POWER" jdbcType="DECIMAL" property="energyPower"/>
<result column="ENERGY_GAS" jdbcType="DECIMAL" property="energyGas"/>
<result column="ENERGY_MONEY" jdbcType="DECIMAL" property="energyMoney"/>
</resultMap>
<resultMap id="vo" type="org.rcisoft.business.overview.vo.BusEnergyPlanVo">
<result column="HOUR" jdbcType="VARCHAR" property="hour"/>
<result column="YEAR" jdbcType="VARCHAR" property="year"/>
<result column="MON" jdbcType="VARCHAR" property="mon"/>
<result column="DAY" jdbcType="VARCHAR" property="day"/>
<result column="ENERGY_MONEY" jdbcType="DECIMAL" property="energyMoney"/>
</resultMap>
<!--<cache type="${corePackag!}.util.RedisCache"/>-->
</mapper>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment