供水统计
parent
ce8a24a72e
commit
190b2faeef
|
|
@ -6,8 +6,10 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
||||||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.gunshi.core.result.R;
|
import com.gunshi.core.result.R;
|
||||||
|
import com.gunshi.project.hsz.entity.vo.StWaterRRVo;
|
||||||
import com.gunshi.project.hsz.entity.vo.StWaterRReorganizeVo;
|
import com.gunshi.project.hsz.entity.vo.StWaterRReorganizeVo;
|
||||||
import com.gunshi.project.hsz.entity.vo.StWaterRReorganizeYearVo;
|
import com.gunshi.project.hsz.entity.vo.StWaterRReorganizeYearVo;
|
||||||
|
import com.gunshi.project.hsz.entity.vo.StWaterRVo;
|
||||||
import com.gunshi.project.hsz.model.StWaterRReorganize;
|
import com.gunshi.project.hsz.model.StWaterRReorganize;
|
||||||
import com.gunshi.project.hsz.service.StWaterRReorganizeService;
|
import com.gunshi.project.hsz.service.StWaterRReorganizeService;
|
||||||
import com.gunshi.project.hsz.util.ConvertUtil;
|
import com.gunshi.project.hsz.util.ConvertUtil;
|
||||||
|
|
@ -31,6 +33,7 @@ import org.springframework.web.bind.annotation.RequestParam;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
/**
|
/**
|
||||||
|
|
@ -67,68 +70,191 @@ public class StWaterRReorganizeController {
|
||||||
return R.ok(service.removeById(id));
|
return R.ok(service.removeById(id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Operation(summary = "列表")
|
||||||
|
// @PostMapping("/list")
|
||||||
|
// public R<List<StWaterRReorganize>> list(@RequestBody @Validated StWaterRReorganize stWaterRReorganize) {
|
||||||
|
// String searchType = stWaterRReorganize.getSearchType();
|
||||||
|
// String groupBy = "";
|
||||||
|
// if("2".equals(searchType)){
|
||||||
|
// groupBy = "LEFT(tm, 10)";
|
||||||
|
// } else if("3".equals(searchType)){
|
||||||
|
// groupBy = "LEFT(tm, 7)";
|
||||||
|
// } else if("4".equals(searchType)){
|
||||||
|
// groupBy = "LEFT(tm, 4)";
|
||||||
|
// } else {
|
||||||
|
// groupBy = "LEFT(tm, 13)";
|
||||||
|
// }
|
||||||
|
// QueryWrapper<StWaterRReorganize> wrapper = new QueryWrapper<StWaterRReorganize>()
|
||||||
|
// .select(groupBy + " tm,ROUND( AVG ( ecology_q ), 2 ) ecology_q,SUM ( ecology_v ) ecology_v,ROUND( AVG ( life_q ), 2 ) life_q,SUM ( life_v ) life_v,SUM ( sum_v ) sum_v")
|
||||||
|
// .ge(ObjectUtils.isNotNull(stWaterRReorganize.getStartTime()), "tm", stWaterRReorganize.getStartTime())
|
||||||
|
// .le(ObjectUtils.isNotNull(stWaterRReorganize.getEndTime()), "tm", stWaterRReorganize.getEndTime())
|
||||||
|
// .groupBy(groupBy);
|
||||||
|
// if(StringUtils.isNotBlank(stWaterRReorganize.getOrderField())){
|
||||||
|
// wrapper.orderBy(true, ObjectUtils.isEmpty(stWaterRReorganize.getIsAsc()) ? false : stWaterRReorganize.getIsAsc(), stWaterRReorganize.getOrderField());
|
||||||
|
// }
|
||||||
|
// List<StWaterRReorganize> list = service.list(wrapper);
|
||||||
|
// if(CollectionUtils.isNotEmpty(list)){
|
||||||
|
// for(StWaterRReorganize dto : list){
|
||||||
|
// dto.setSumV(dto.getEcologyV().add(dto.getLifeV()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return R.ok(list);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// @Operation(summary = "分页")
|
||||||
|
// @PostMapping("/page")
|
||||||
|
// public R<Page<StWaterRReorganize>> page(@RequestBody @Validated StWaterRReorganize stWaterRReorganize) {
|
||||||
|
// String searchType = stWaterRReorganize.getSearchType();
|
||||||
|
// String groupBy = "";
|
||||||
|
// if("2".equals(searchType)){
|
||||||
|
// groupBy = "LEFT(tm, 10)";
|
||||||
|
// } else if("3".equals(searchType)){
|
||||||
|
// groupBy = "LEFT(tm, 7)";
|
||||||
|
// } else if("4".equals(searchType)){
|
||||||
|
// groupBy = "LEFT(tm, 4)";
|
||||||
|
// } else {
|
||||||
|
// groupBy = "LEFT(tm, 13)";
|
||||||
|
// }
|
||||||
|
// QueryWrapper<StWaterRReorganize> wrapper = new QueryWrapper<StWaterRReorganize>()
|
||||||
|
// .select(groupBy + " tm,ROUND( AVG ( ecology_q ), 2 ) ecology_q,SUM ( ecology_v ) ecology_v,ROUND( AVG ( life_q ), 2 ) life_q,SUM ( life_v ) life_v,SUM ( sum_v ) sum_v")
|
||||||
|
// .ge(ObjectUtils.isNotNull(stWaterRReorganize.getStartTime()), "tm", stWaterRReorganize.getStartTime())
|
||||||
|
// .le(ObjectUtils.isNotNull(stWaterRReorganize.getEndTime()), "tm", stWaterRReorganize.getEndTime())
|
||||||
|
// .groupBy(groupBy);
|
||||||
|
// if(StringUtils.isNotBlank(stWaterRReorganize.getOrderField())){
|
||||||
|
// wrapper.orderBy(true, ObjectUtils.isEmpty(stWaterRReorganize.getIsAsc()) ? false : stWaterRReorganize.getIsAsc(), stWaterRReorganize.getOrderField());
|
||||||
|
// }
|
||||||
|
// Page<StWaterRReorganize> page = service.page(stWaterRReorganize.getPageSo().toPage(), wrapper);
|
||||||
|
// if(CollectionUtils.isNotEmpty(page.getRecords())){
|
||||||
|
// for(StWaterRReorganize dto : page.getRecords()){
|
||||||
|
// dto.setSumV(dto.getEcologyV().add(dto.getLifeV()));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return R.ok(page);
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "列表")
|
@Operation(summary = "列表")
|
||||||
@PostMapping("/list")
|
@PostMapping("/list")
|
||||||
public R<List<StWaterRReorganize>> list(@RequestBody @Validated StWaterRReorganize stWaterRReorganize) {
|
public R<List<StWaterRReorganize>> list(@RequestBody @Validated StWaterRReorganize stWaterRReorganize) {
|
||||||
String searchType = stWaterRReorganize.getSearchType();
|
String searchType = stWaterRReorganize.getSearchType();
|
||||||
String groupBy = "";
|
String groupBy = "";
|
||||||
if("2".equals(searchType)){
|
if("2".equals(searchType)){
|
||||||
groupBy = "LEFT(tm, 10)";
|
groupBy = "LEFT(tm, 10)"; // 按天分组
|
||||||
} else if("3".equals(searchType)){
|
} else if("3".equals(searchType)){
|
||||||
groupBy = "LEFT(tm, 7)";
|
groupBy = "LEFT(tm, 7)"; // 按月分组
|
||||||
} else if("4".equals(searchType)){
|
} else if("4".equals(searchType)){
|
||||||
groupBy = "LEFT(tm, 4)";
|
groupBy = "LEFT(tm, 4)"; // 按年分组
|
||||||
} else {
|
} else {
|
||||||
groupBy = "LEFT(tm, 13)";
|
groupBy = "LEFT(tm, 13)"; // 默认按小时分组
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryWrapper<StWaterRReorganize> wrapper = new QueryWrapper<StWaterRReorganize>()
|
QueryWrapper<StWaterRReorganize> wrapper = new QueryWrapper<StWaterRReorganize>()
|
||||||
.select(groupBy + " tm,ROUND( AVG ( ecology_q ), 2 ) ecology_q,SUM ( ecology_v ) ecology_v,ROUND( AVG ( life_q ), 2 ) life_q,SUM ( life_v ) life_v,SUM ( sum_v ) sum_v")
|
.select(groupBy + " tm," +
|
||||||
|
"ROUND(AVG(mci1_q), 2) mci1_q, SUM(mci1_v) mci1_v," +
|
||||||
|
"ROUND(AVG(mci2_q), 2) mci2_q, SUM(mci2_v) mci2_v," +
|
||||||
|
"ROUND(AVG(ecology_q), 2) ecology_q, SUM(ecology_v) ecology_v")
|
||||||
.ge(ObjectUtils.isNotNull(stWaterRReorganize.getStartTime()), "tm", stWaterRReorganize.getStartTime())
|
.ge(ObjectUtils.isNotNull(stWaterRReorganize.getStartTime()), "tm", stWaterRReorganize.getStartTime())
|
||||||
.le(ObjectUtils.isNotNull(stWaterRReorganize.getEndTime()), "tm", stWaterRReorganize.getEndTime())
|
.le(ObjectUtils.isNotNull(stWaterRReorganize.getEndTime()), "tm", stWaterRReorganize.getEndTime())
|
||||||
.groupBy(groupBy);
|
.groupBy(groupBy);
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(stWaterRReorganize.getOrderField())){
|
if(StringUtils.isNotBlank(stWaterRReorganize.getOrderField())){
|
||||||
wrapper.orderBy(true, ObjectUtils.isEmpty(stWaterRReorganize.getIsAsc()) ? false : stWaterRReorganize.getIsAsc(), stWaterRReorganize.getOrderField());
|
wrapper.orderBy(true, ObjectUtils.isEmpty(stWaterRReorganize.getIsAsc()) ? false : stWaterRReorganize.getIsAsc(),
|
||||||
|
stWaterRReorganize.getOrderField());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<StWaterRReorganize> list = service.list(wrapper);
|
List<StWaterRReorganize> list = service.list(wrapper);
|
||||||
|
|
||||||
|
// 计算总量(如果需要的话)
|
||||||
if(CollectionUtils.isNotEmpty(list)){
|
if(CollectionUtils.isNotEmpty(list)){
|
||||||
for(StWaterRReorganize dto : list){
|
for(StWaterRReorganize dto : list){
|
||||||
dto.setSumV(dto.getEcologyV().add(dto.getLifeV()));
|
// 如果需要计算总量,可以在这里添加
|
||||||
|
dto.setSumV(dto.getMci1V().add(dto.getMci2V()).add(dto.getEcologyV()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return R.ok(list);
|
return R.ok(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "供水统计")
|
||||||
|
@PostMapping("/count")
|
||||||
|
public R<StWaterRRVo> count(@RequestBody @Validated StWaterRReorganize stWaterRReorganize ){
|
||||||
|
String searchType = stWaterRReorganize.getSearchType();
|
||||||
|
String groupBy = "";
|
||||||
|
if("2".equals(searchType)){
|
||||||
|
groupBy = "LEFT(tm, 10)"; // 按天分组
|
||||||
|
} else if("3".equals(searchType)){
|
||||||
|
groupBy = "LEFT(tm, 7)"; // 按月分组
|
||||||
|
} else if("4".equals(searchType)){
|
||||||
|
groupBy = "LEFT(tm, 4)"; // 按年分组
|
||||||
|
} else {
|
||||||
|
groupBy = "LEFT(tm, 13)"; // 默认按小时分组
|
||||||
|
}
|
||||||
|
|
||||||
|
QueryWrapper<StWaterRReorganize> wrapper = new QueryWrapper<StWaterRReorganize>()
|
||||||
|
.select(groupBy + " tm," +
|
||||||
|
"ROUND(AVG(mci1_q), 2) mci1_q, SUM(mci1_v) mci1_v," +
|
||||||
|
"ROUND(AVG(mci2_q), 2) mci2_q, SUM(mci2_v) mci2_v," +
|
||||||
|
"ROUND(AVG(ecology_q), 2) ecology_q, SUM(ecology_v) ecology_v")
|
||||||
|
.ge(ObjectUtils.isNotNull(stWaterRReorganize.getStartTime()), "tm", stWaterRReorganize.getStartTime())
|
||||||
|
.le(ObjectUtils.isNotNull(stWaterRReorganize.getEndTime()), "tm", stWaterRReorganize.getEndTime())
|
||||||
|
.groupBy(groupBy);
|
||||||
|
|
||||||
|
if(StringUtils.isNotBlank(stWaterRReorganize.getOrderField())){
|
||||||
|
wrapper.orderBy(true, ObjectUtils.isEmpty(stWaterRReorganize.getIsAsc()) ? false : stWaterRReorganize.getIsAsc(),
|
||||||
|
stWaterRReorganize.getOrderField());
|
||||||
|
}
|
||||||
|
|
||||||
|
List<StWaterRReorganize> list = service.list(wrapper);
|
||||||
|
StWaterRRVo vo = new StWaterRRVo();
|
||||||
|
for (StWaterRReorganize entity : list) {
|
||||||
|
vo.setMci1VSum(vo.getMci2VSum().add(entity.getMci1V()));
|
||||||
|
vo.setMci2VSum(vo.getMci2VSum().add(entity.getMci2V()));
|
||||||
|
vo.setEcologyVSum(vo.getEcologyVSum().add(entity.getEcologyV()));
|
||||||
|
}
|
||||||
|
return R.ok(vo);
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "分页")
|
@Operation(summary = "分页")
|
||||||
@PostMapping("/page")
|
@PostMapping("/page")
|
||||||
public R<Page<StWaterRReorganize>> page(@RequestBody @Validated StWaterRReorganize stWaterRReorganize) {
|
public R<Page<StWaterRReorganize>> page(@RequestBody @Validated StWaterRReorganize stWaterRReorganize) {
|
||||||
String searchType = stWaterRReorganize.getSearchType();
|
String searchType = stWaterRReorganize.getSearchType();
|
||||||
String groupBy = "";
|
String groupBy = "";
|
||||||
if("2".equals(searchType)){
|
if("2".equals(searchType)){
|
||||||
groupBy = "LEFT(tm, 10)";
|
groupBy = "LEFT(tm, 10)"; // 按天分组
|
||||||
} else if("3".equals(searchType)){
|
} else if("3".equals(searchType)){
|
||||||
groupBy = "LEFT(tm, 7)";
|
groupBy = "LEFT(tm, 7)"; // 按月分组
|
||||||
} else if("4".equals(searchType)){
|
} else if("4".equals(searchType)){
|
||||||
groupBy = "LEFT(tm, 4)";
|
groupBy = "LEFT(tm, 4)"; // 按年分组
|
||||||
} else {
|
} else {
|
||||||
groupBy = "LEFT(tm, 13)";
|
groupBy = "LEFT(tm, 13)"; // 默认按小时分组
|
||||||
}
|
}
|
||||||
|
|
||||||
QueryWrapper<StWaterRReorganize> wrapper = new QueryWrapper<StWaterRReorganize>()
|
QueryWrapper<StWaterRReorganize> wrapper = new QueryWrapper<StWaterRReorganize>()
|
||||||
.select(groupBy + " tm,ROUND( AVG ( ecology_q ), 2 ) ecology_q,SUM ( ecology_v ) ecology_v,ROUND( AVG ( life_q ), 2 ) life_q,SUM ( life_v ) life_v,SUM ( sum_v ) sum_v")
|
.select(groupBy + " tm," +
|
||||||
.ge(ObjectUtils.isNotNull(stWaterRReorganize.getStartTime()), "tm", stWaterRReorganize.getStartTime())
|
"ROUND(AVG(mci1_q), 2) mci1_q, SUM(mci1_v) mci1_v," +
|
||||||
.le(ObjectUtils.isNotNull(stWaterRReorganize.getEndTime()), "tm", stWaterRReorganize.getEndTime())
|
"ROUND(AVG(mci2_q), 2) mci2_q, SUM(mci2_v) mci2_v," +
|
||||||
.groupBy(groupBy);
|
"ROUND(AVG(ecology_q), 2) ecology_q, SUM(ecology_v) ecology_v")
|
||||||
|
.ge(ObjectUtils.isNotNull(stWaterRReorganize.getStartTime()), "tm", stWaterRReorganize.getStartTime())
|
||||||
|
.le(ObjectUtils.isNotNull(stWaterRReorganize.getEndTime()), "tm", stWaterRReorganize.getEndTime())
|
||||||
|
.groupBy(groupBy);
|
||||||
|
|
||||||
if(StringUtils.isNotBlank(stWaterRReorganize.getOrderField())){
|
if(StringUtils.isNotBlank(stWaterRReorganize.getOrderField())){
|
||||||
wrapper.orderBy(true, ObjectUtils.isEmpty(stWaterRReorganize.getIsAsc()) ? false : stWaterRReorganize.getIsAsc(), stWaterRReorganize.getOrderField());
|
wrapper.orderBy(true, ObjectUtils.isEmpty(stWaterRReorganize.getIsAsc()) ? false : stWaterRReorganize.getIsAsc(),
|
||||||
|
stWaterRReorganize.getOrderField());
|
||||||
}
|
}
|
||||||
|
|
||||||
Page<StWaterRReorganize> page = service.page(stWaterRReorganize.getPageSo().toPage(), wrapper);
|
Page<StWaterRReorganize> page = service.page(stWaterRReorganize.getPageSo().toPage(), wrapper);
|
||||||
|
|
||||||
|
// 计算总量(如果需要的话)
|
||||||
if(CollectionUtils.isNotEmpty(page.getRecords())){
|
if(CollectionUtils.isNotEmpty(page.getRecords())){
|
||||||
for(StWaterRReorganize dto : page.getRecords()){
|
for(StWaterRReorganize dto : page.getRecords()){
|
||||||
dto.setSumV(dto.getEcologyV().add(dto.getLifeV()));
|
//水量小计
|
||||||
|
dto.setSumV(dto.getMci1V().add(dto.getMci2V()).add(dto.getEcologyV()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return R.ok(page);
|
return R.ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Operation(summary = "供水水方数据导出")
|
@Operation(summary = "供水水方数据导出")
|
||||||
@PostMapping("/exportWaterRReorganizeDataExcel")
|
@PostMapping("/exportWaterRReorganizeDataExcel")
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,35 @@
|
||||||
|
package com.gunshi.project.hsz.entity.vo;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.gunshi.project.hsz.entity.page.GenericPageParams;
|
||||||
|
import com.gunshi.project.hsz.model.StWaterRReorganize;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class StWaterRRVo extends GenericPageParams {
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "干渠1灌溉供水总合计")
|
||||||
|
private BigDecimal mci1VSum = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "干渠2灌溉供水总合计")
|
||||||
|
private BigDecimal mci2VSum = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "生态供水合计")
|
||||||
|
private BigDecimal ecologyVSum = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
@TableField(exist = false)
|
||||||
|
@Schema(description = "供水总合计")
|
||||||
|
private BigDecimal totalSum = BigDecimal.ZERO;
|
||||||
|
|
||||||
|
|
||||||
|
// List<StWaterRReorganize> list;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -35,16 +35,28 @@ public class StWaterRReorganizeVo {
|
||||||
private BigDecimal ecologyV;
|
private BigDecimal ecologyV;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流量(生活供水)
|
* 干渠灌溉流量1
|
||||||
*/
|
*/
|
||||||
@ExcelProperty({"${title}", "生活供水", "流量(m³/s)"})
|
@ExcelProperty({"${title}", "干渠灌溉流量1", "流量(m³/s)"})
|
||||||
private BigDecimal lifeQ;
|
private BigDecimal mci1Q;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 水量(生活供水)
|
* 干渠灌溉水量1
|
||||||
*/
|
*/
|
||||||
@ExcelProperty({"${title}", "生活供水", "水量(万m³)"})
|
@ExcelProperty({"${title}", "干渠灌溉水量1", "水量(万m³)"})
|
||||||
private BigDecimal lifeV;
|
private BigDecimal mci1V;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 干渠灌溉流量1
|
||||||
|
*/
|
||||||
|
@ExcelProperty({"${title}", "干渠灌溉流量2", "流量(m³/s)"})
|
||||||
|
private BigDecimal mci2Q;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 干渠灌溉水量1
|
||||||
|
*/
|
||||||
|
@ExcelProperty({"${title}", "干渠灌溉水量2", "水量(万m³)"})
|
||||||
|
private BigDecimal mci2V;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 水量小计
|
* 水量小计
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,62 @@ public class StWaterRReorganizeYearVo {
|
||||||
@ExcelProperty({"${title}", "时间"})
|
@ExcelProperty({"${title}", "时间"})
|
||||||
private String tm;
|
private String tm;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年度占比(干渠灌溉1)
|
||||||
|
*/
|
||||||
|
@Schema(description="年度占比(干渠灌溉1)")
|
||||||
|
@ExcelProperty({"${title}", "干渠灌溉1", "年度占比"})
|
||||||
|
private String mci1YearRateV;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 水量(干渠灌溉1)
|
||||||
|
*/
|
||||||
|
@Schema(description="水量(干渠灌溉1)")
|
||||||
|
@ExcelProperty({"${title}", "干渠灌溉1", "水量"})
|
||||||
|
private String mci1V;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同比(干渠灌溉1)
|
||||||
|
*/
|
||||||
|
@Schema(description="同比(干渠灌溉1)")
|
||||||
|
@ExcelProperty({"${title}", "干渠灌溉1", "同比"})
|
||||||
|
private String mci1YoyV;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环比(干渠灌溉1)
|
||||||
|
*/
|
||||||
|
@Schema(description="环比(干渠灌溉1)")
|
||||||
|
@ExcelProperty({"${title}", "干渠灌溉1", "环比"})
|
||||||
|
private String mci1QoqV;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 年度占比(干渠灌溉2)
|
||||||
|
*/
|
||||||
|
@Schema(description="年度占比(干渠灌溉2)")
|
||||||
|
@ExcelProperty({"${title}", "干渠灌溉2", "年度占比"})
|
||||||
|
private String mci2YearRateV;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 水量(干渠灌溉2)
|
||||||
|
*/
|
||||||
|
@Schema(description="水量(干渠灌溉2)")
|
||||||
|
@ExcelProperty({"${title}", "干渠灌溉2", "水量"})
|
||||||
|
private String mci2V;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 同比(干渠灌溉2)
|
||||||
|
*/
|
||||||
|
@Schema(description="同比(干渠灌溉2)")
|
||||||
|
@ExcelProperty({"${title}", "干渠灌溉2", "同比"})
|
||||||
|
private String mci2YoyV;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 环比(干渠灌溉2)
|
||||||
|
*/
|
||||||
|
@Schema(description="环比(干渠灌溉2)")
|
||||||
|
@ExcelProperty({"${title}", "干渠灌溉2", "环比"})
|
||||||
|
private String mci2QoqV;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 年度占比(生态供水)
|
* 年度占比(生态供水)
|
||||||
*/
|
*/
|
||||||
|
|
@ -48,31 +104,63 @@ public class StWaterRReorganizeYearVo {
|
||||||
@ExcelProperty({"${title}", "生态供水", "环比"})
|
@ExcelProperty({"${title}", "生态供水", "环比"})
|
||||||
private String ecologyQoqV;
|
private String ecologyQoqV;
|
||||||
|
|
||||||
/**
|
// @Schema(description="时间")
|
||||||
* 年度占比(生活供水)
|
// @ExcelProperty({"${title}", "时间"})
|
||||||
*/
|
// private String tm;
|
||||||
@Schema(description="年度占比(生活供水)")
|
//
|
||||||
@ExcelProperty({"${title}", "生活供水", "年度占比"})
|
// /**
|
||||||
private String lifeYearRateV;
|
// * 年度占比(生态供水)
|
||||||
|
// */
|
||||||
/**
|
// @Schema(description="年度占比(生态供水)")
|
||||||
* 水量(生活供水)
|
// @ExcelProperty({"${title}", "生态供水", "年度占比"})
|
||||||
*/
|
// private String ecologyYearRateV;
|
||||||
@Schema(description="水量(生活供水)")
|
//
|
||||||
@ExcelProperty({"${title}", "生活供水", "水量"})
|
// /**
|
||||||
private String lifeV;
|
// * 水量(生态供水)
|
||||||
|
// */
|
||||||
/**
|
// @Schema(description="水量(生态供水)")
|
||||||
* 同比(生活供水)
|
// @ExcelProperty({"${title}", "生态供水", "水量"})
|
||||||
*/
|
// private String ecologyV;
|
||||||
@Schema(description="同比(生活供水)")
|
//
|
||||||
@ExcelProperty({"${title}", "生活供水", "同比"})
|
// /**
|
||||||
private String lifeYoyV;
|
// * 同比(生态供水)
|
||||||
|
// */
|
||||||
/**
|
// @Schema(description="同比(生态供水)")
|
||||||
* 环比(生活供水)
|
// @ExcelProperty({"${title}", "生态供水", "同比"})
|
||||||
*/
|
// private String ecologyYoyV;
|
||||||
@Schema(description="环比(生活供水)")
|
//
|
||||||
@ExcelProperty({"${title}", "生活供水", "环比"})
|
// /**
|
||||||
private String lifeQoqV;
|
// * 环比(生态供水)
|
||||||
|
// */
|
||||||
|
// @Schema(description="环比(生态供水)")
|
||||||
|
// @ExcelProperty({"${title}", "生态供水", "环比"})
|
||||||
|
// private String ecologyQoqV;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 年度占比(生活供水)
|
||||||
|
// */
|
||||||
|
// @Schema(description="年度占比(生活供水)")
|
||||||
|
// @ExcelProperty({"${title}", "生活供水", "年度占比"})
|
||||||
|
// private String lifeYearRateV;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 水量(生活供水)
|
||||||
|
// */
|
||||||
|
// @Schema(description="水量(生活供水)")
|
||||||
|
// @ExcelProperty({"${title}", "生活供水", "水量"})
|
||||||
|
// private String lifeV;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 同比(生活供水)
|
||||||
|
// */
|
||||||
|
// @Schema(description="同比(生活供水)")
|
||||||
|
// @ExcelProperty({"${title}", "生活供水", "同比"})
|
||||||
|
// private String lifeYoyV;
|
||||||
|
//
|
||||||
|
// /**
|
||||||
|
// * 环比(生活供水)
|
||||||
|
// */
|
||||||
|
// @Schema(description="环比(生活供水)")
|
||||||
|
// @ExcelProperty({"${title}", "生活供水", "环比"})
|
||||||
|
// private String lifeQoqV;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,18 +57,33 @@ public class StWaterRReorganize extends GenericPageParams implements Serializabl
|
||||||
private BigDecimal ecologyV;
|
private BigDecimal ecologyV;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流量(生活供水)
|
* 干渠灌溉流量1
|
||||||
*/
|
*/
|
||||||
@TableField(value="life_q")
|
@TableField(value="mci1_q")
|
||||||
@Schema(description="流量(生活供水)")
|
@Schema(description="流量(生活供水)")
|
||||||
private BigDecimal lifeQ;
|
private BigDecimal mci1Q;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 水量(生活供水)
|
* 干渠灌溉水量1
|
||||||
*/
|
*/
|
||||||
@TableField(value="life_v")
|
@TableField(value="mci1_v")
|
||||||
@Schema(description="水量(生活供水)")
|
@Schema(description="水量(生活供水)")
|
||||||
private BigDecimal lifeV;
|
private BigDecimal mci1V;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 干渠灌溉流量2
|
||||||
|
*/
|
||||||
|
@TableField(value="mci2_q")
|
||||||
|
@Schema(description="流量(生活供水)")
|
||||||
|
private BigDecimal mci2Q;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 干渠灌溉水量2
|
||||||
|
*/
|
||||||
|
@TableField(value="mci2_v")
|
||||||
|
@Schema(description="水量(生活供水)")
|
||||||
|
private BigDecimal mci2V;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 水量小计
|
* 水量小计
|
||||||
|
|
@ -100,4 +115,5 @@ public class StWaterRReorganize extends GenericPageParams implements Serializabl
|
||||||
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
|
||||||
@TableField(exist = false)
|
@TableField(exist = false)
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,122 +25,279 @@ import java.util.List;
|
||||||
public class StWaterRReorganizeService extends ServiceImpl<StWaterRReorganizeMapper, StWaterRReorganize>
|
public class StWaterRReorganizeService extends ServiceImpl<StWaterRReorganizeMapper, StWaterRReorganize>
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// public List<StWaterRReorganizeYearVo> getYearStatisticAnalysis(int year, List<StWaterRReorganizeYearVo> resList) {
|
||||||
|
// // 查询 选择年 数据
|
||||||
|
// QueryWrapper<StWaterRReorganize> nowYearQw = new QueryWrapper<StWaterRReorganize>()
|
||||||
|
// .select("LEFT(tm, 7) tm,ROUND( AVG ( ecology_q ), 2 ) ecology_q,SUM ( ecology_v ) ecology_v,ROUND( AVG ( life_q ), 2 ) life_q,SUM ( life_v ) life_v,SUM ( sum_v ) sum_v")
|
||||||
|
// .eq("LEFT(tm, 4)", String.valueOf(year)).groupBy("LEFT(tm, 7)").orderBy(true, true, "tm");
|
||||||
|
// List<StWaterRReorganize> nowYearList = this.list(nowYearQw);
|
||||||
|
//
|
||||||
|
// // 查询 选择年的前一年 数据
|
||||||
|
// QueryWrapper<StWaterRReorganize> lastYearQw = new QueryWrapper<StWaterRReorganize>()
|
||||||
|
// .select("LEFT(tm, 7) tm,ROUND( AVG ( ecology_q ), 2 ) ecology_q,SUM ( ecology_v ) ecology_v,ROUND( AVG ( life_q ), 2 ) life_q,SUM ( life_v ) life_v,SUM ( sum_v ) sum_v")
|
||||||
|
// .eq("LEFT(tm, 4)", String.valueOf(year - 1)).groupBy("LEFT(tm, 7)").orderBy(true, true, "tm");
|
||||||
|
// List<StWaterRReorganize> lastYearList = this.list(lastYearQw);
|
||||||
|
//
|
||||||
|
// // 组装VO
|
||||||
|
// if(CollectionUtils.isNotEmpty(nowYearList)){
|
||||||
|
// BigDecimal ecologyVSum = nowYearList.stream().map(StWaterRReorganize::getEcologyV).reduce(BigDecimal.ZERO, BigDecimal::add);// 年度生态水量的和
|
||||||
|
// BigDecimal lifeVSum = nowYearList.stream().map(StWaterRReorganize::getLifeV).reduce(BigDecimal.ZERO, BigDecimal::add);// 年度生活水量的和
|
||||||
|
// for(int i = 0; i < nowYearList.size(); i++){
|
||||||
|
// String jiantou = "";
|
||||||
|
// StWaterRReorganizeYearVo vo = new StWaterRReorganizeYearVo();
|
||||||
|
// StWaterRReorganize nowStwrr = nowYearList.get(i);
|
||||||
|
// vo.setTm(nowStwrr.getTm());
|
||||||
|
// vo.setEcologyYearRateV(nowStwrr.getEcologyV().divide(ecologyVSum, 1, BigDecimal.ROUND_HALF_UP).toString().concat("%"));
|
||||||
|
// vo.setEcologyV(nowStwrr.getEcologyV().toString());
|
||||||
|
// vo.setLifeYearRateV(nowStwrr.getEcologyV().divide(lifeVSum, 1, BigDecimal.ROUND_HALF_UP).toString().concat("%"));
|
||||||
|
// vo.setLifeV(nowStwrr.getLifeV().toString());
|
||||||
|
//
|
||||||
|
// StWaterRReorganize lastStwrr = lastYearList.stream()
|
||||||
|
// .filter(item -> nowStwrr.getTm()
|
||||||
|
// .equals(String.valueOf((Integer.valueOf(item.getTm().substring(0, 4)) + 1))
|
||||||
|
// .concat(item.getTm().substring(4, 7)))).findAny().orElse(null);
|
||||||
|
// // 生态同比 (本期数 - 同期数) / 同期数 × 100%
|
||||||
|
// if(ObjectUtils.isEmpty(lastStwrr) || lastStwrr.getEcologyV().compareTo(BigDecimal.ZERO) == 0){
|
||||||
|
// vo.setEcologyYoyV("-");
|
||||||
|
// } else {
|
||||||
|
// BigDecimal ecologyYoyV = (nowStwrr.getEcologyV().subtract(lastStwrr.getEcologyV())).divide(lastStwrr.getEcologyV(), 1, BigDecimal.ROUND_HALF_UP);
|
||||||
|
// jiantou = "";
|
||||||
|
// if(ecologyYoyV.compareTo(BigDecimal.ZERO) == 0){
|
||||||
|
// jiantou = "↔";
|
||||||
|
// vo.setEcologyYoyV(jiantou);
|
||||||
|
// } else {
|
||||||
|
// if(ecologyYoyV.compareTo(BigDecimal.ZERO) < 0){
|
||||||
|
// jiantou = "↓";
|
||||||
|
// } else if(ecologyYoyV.compareTo(BigDecimal.ZERO) > 0){
|
||||||
|
// jiantou = "↑";
|
||||||
|
// }
|
||||||
|
// vo.setEcologyYoyV(jiantou.concat(ecologyYoyV.abs().toString()).concat("%"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // 生活同比 (本期数 - 同期数) / 同期数 × 100%
|
||||||
|
// if(ObjectUtils.isEmpty(lastStwrr) || lastStwrr.getLifeV().compareTo(BigDecimal.ZERO) == 0){
|
||||||
|
// vo.setLifeYoyV("-");
|
||||||
|
// } else {
|
||||||
|
// BigDecimal lifeYoyV = (nowStwrr.getLifeV().subtract(lastStwrr.getLifeV())).divide(lastStwrr.getLifeV(), 1, BigDecimal.ROUND_HALF_UP);
|
||||||
|
// jiantou = "";
|
||||||
|
// if(lifeYoyV.compareTo(BigDecimal.ZERO) == 0){
|
||||||
|
// jiantou = "↔";
|
||||||
|
// vo.setLifeYoyV(jiantou);
|
||||||
|
// } else {
|
||||||
|
// if(lifeYoyV.compareTo(BigDecimal.ZERO) < 0){
|
||||||
|
// jiantou = "↓";
|
||||||
|
// } else if(lifeYoyV.compareTo(BigDecimal.ZERO) > 0){
|
||||||
|
// jiantou = "↑";
|
||||||
|
// }
|
||||||
|
// vo.setLifeYoyV(jiantou.concat(lifeYoyV.abs().toString()).concat("%"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // 环比 (本期数 - 上期数) / 上期数 × 100%
|
||||||
|
// StWaterRReorganize lastOneStwrr;
|
||||||
|
// // 如果是1月,需要拿到去年12月的
|
||||||
|
// if(i == 0 && nowStwrr.getTm().contains("-01")){
|
||||||
|
// lastOneStwrr = lastYearList.stream().filter(item -> item.getTm().contains("-12")).findAny().orElse(null);
|
||||||
|
// } else {
|
||||||
|
// lastOneStwrr = nowYearList.get(i-1);
|
||||||
|
// }
|
||||||
|
// // 生态
|
||||||
|
// if(ObjectUtils.isEmpty(lastOneStwrr) || lastOneStwrr.getEcologyV().compareTo(BigDecimal.ZERO) == 0){
|
||||||
|
// vo.setEcologyQoqV("-");
|
||||||
|
// } else {
|
||||||
|
// BigDecimal ecologyQoqV = (nowStwrr.getEcologyV().subtract(lastOneStwrr.getEcologyV())).divide(lastOneStwrr.getEcologyV(), 1, BigDecimal.ROUND_HALF_UP);
|
||||||
|
// jiantou = "";
|
||||||
|
// if(ecologyQoqV.compareTo(BigDecimal.ZERO) == 0){
|
||||||
|
// jiantou = "↔";
|
||||||
|
// vo.setEcologyQoqV(jiantou);
|
||||||
|
// } else {
|
||||||
|
// if(ecologyQoqV.compareTo(BigDecimal.ZERO) < 0){
|
||||||
|
// jiantou = "↓";
|
||||||
|
// } else if(ecologyQoqV.compareTo(BigDecimal.ZERO) > 0){
|
||||||
|
// jiantou = "↑";
|
||||||
|
// }
|
||||||
|
// vo.setEcologyQoqV(jiantou.concat(ecologyQoqV.abs().toString()).concat("%"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// // 生活
|
||||||
|
// if(ObjectUtils.isEmpty(lastOneStwrr) || lastOneStwrr.getLifeV().compareTo(BigDecimal.ZERO) == 0){
|
||||||
|
// vo.setLifeQoqV("-");
|
||||||
|
// } else {
|
||||||
|
// BigDecimal lifeQoqV = (nowStwrr.getLifeV().subtract(lastOneStwrr.getLifeV())).divide(lastOneStwrr.getLifeV(), 1, BigDecimal.ROUND_HALF_UP);
|
||||||
|
// jiantou = "";
|
||||||
|
// if(lifeQoqV.compareTo(BigDecimal.ZERO) == 0){
|
||||||
|
// jiantou = "↔";
|
||||||
|
// vo.setLifeQoqV(jiantou);
|
||||||
|
// } else {
|
||||||
|
// if(lifeQoqV.compareTo(BigDecimal.ZERO) < 0){
|
||||||
|
// jiantou = "↓";
|
||||||
|
// } else if(lifeQoqV.compareTo(BigDecimal.ZERO) > 0){
|
||||||
|
// jiantou = "↑";
|
||||||
|
// }
|
||||||
|
// vo.setLifeQoqV(jiantou.concat(lifeQoqV.abs().toString()).concat("%"));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// resList.add(vo);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// return resList;
|
||||||
|
// }
|
||||||
|
|
||||||
public List<StWaterRReorganizeYearVo> getYearStatisticAnalysis(int year, List<StWaterRReorganizeYearVo> resList) {
|
public List<StWaterRReorganizeYearVo> getYearStatisticAnalysis(int year, List<StWaterRReorganizeYearVo> resList) {
|
||||||
// 查询 选择年 数据
|
// 查询 选择年 数据
|
||||||
QueryWrapper<StWaterRReorganize> nowYearQw = new QueryWrapper<StWaterRReorganize>()
|
QueryWrapper<StWaterRReorganize> nowYearQw = new QueryWrapper<StWaterRReorganize>()
|
||||||
.select("LEFT(tm, 7) tm,ROUND( AVG ( ecology_q ), 2 ) ecology_q,SUM ( ecology_v ) ecology_v,ROUND( AVG ( life_q ), 2 ) life_q,SUM ( life_v ) life_v,SUM ( sum_v ) sum_v")
|
.select("LEFT(tm, 7) tm," +
|
||||||
.eq("LEFT(tm, 4)", String.valueOf(year)).groupBy("LEFT(tm, 7)").orderBy(true, true, "tm");
|
"ROUND(AVG(mci1_q), 2) mci1_q, SUM(mci1_v) mci1_v," +
|
||||||
|
"ROUND(AVG(mci2_q), 2) mci2_q, SUM(mci2_v) mci2_v," +
|
||||||
|
"ROUND(AVG(ecology_q), 2) ecology_q, SUM(ecology_v) ecology_v")
|
||||||
|
.eq("LEFT(tm, 4)", String.valueOf(year))
|
||||||
|
.groupBy("LEFT(tm, 7)")
|
||||||
|
.orderBy(true, true, "tm");
|
||||||
List<StWaterRReorganize> nowYearList = this.list(nowYearQw);
|
List<StWaterRReorganize> nowYearList = this.list(nowYearQw);
|
||||||
|
|
||||||
// 查询 选择年的前一年 数据
|
// 查询 选择年的前一年 数据
|
||||||
QueryWrapper<StWaterRReorganize> lastYearQw = new QueryWrapper<StWaterRReorganize>()
|
QueryWrapper<StWaterRReorganize> lastYearQw = new QueryWrapper<StWaterRReorganize>()
|
||||||
.select("LEFT(tm, 7) tm,ROUND( AVG ( ecology_q ), 2 ) ecology_q,SUM ( ecology_v ) ecology_v,ROUND( AVG ( life_q ), 2 ) life_q,SUM ( life_v ) life_v,SUM ( sum_v ) sum_v")
|
.select("LEFT(tm, 7) tm," +
|
||||||
.eq("LEFT(tm, 4)", String.valueOf(year - 1)).groupBy("LEFT(tm, 7)").orderBy(true, true, "tm");
|
"ROUND(AVG(mci1_q), 2) mci1_q, SUM(mci1_v) mci1_v," +
|
||||||
|
"ROUND(AVG(mci2_q), 2) mci2_q, SUM(mci2_v) mci2_v," +
|
||||||
|
"ROUND(AVG(ecology_q), 2) ecology_q, SUM(ecology_v) ecology_v")
|
||||||
|
.eq("LEFT(tm, 4)", String.valueOf(year - 1))
|
||||||
|
.groupBy("LEFT(tm, 7)")
|
||||||
|
.orderBy(true, true, "tm");
|
||||||
List<StWaterRReorganize> lastYearList = this.list(lastYearQw);
|
List<StWaterRReorganize> lastYearList = this.list(lastYearQw);
|
||||||
|
|
||||||
// 组装VO
|
// 组装VO
|
||||||
if(CollectionUtils.isNotEmpty(nowYearList)){
|
if (CollectionUtils.isNotEmpty(nowYearList)) {
|
||||||
BigDecimal ecologyVSum = nowYearList.stream().map(StWaterRReorganize::getEcologyV).reduce(BigDecimal.ZERO, BigDecimal::add);// 年度生态水量的和
|
// 计算年度总量
|
||||||
BigDecimal lifeVSum = nowYearList.stream().map(StWaterRReorganize::getLifeV).reduce(BigDecimal.ZERO, BigDecimal::add);// 年度生活水量的和
|
BigDecimal mci1VSum = nowYearList.stream().map(StWaterRReorganize::getMci1V).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
for(int i = 0; i < nowYearList.size(); i++){
|
BigDecimal mci2VSum = nowYearList.stream().map(StWaterRReorganize::getMci2V).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
BigDecimal ecologyVSum = nowYearList.stream().map(StWaterRReorganize::getEcologyV).reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
|
||||||
|
for (int i = 0; i < nowYearList.size(); i++) {
|
||||||
String jiantou = "";
|
String jiantou = "";
|
||||||
StWaterRReorganizeYearVo vo = new StWaterRReorganizeYearVo();
|
StWaterRReorganizeYearVo vo = new StWaterRReorganizeYearVo();
|
||||||
StWaterRReorganize nowStwrr = nowYearList.get(i);
|
StWaterRReorganize nowStwrr = nowYearList.get(i);
|
||||||
vo.setTm(nowStwrr.getTm());
|
vo.setTm(nowStwrr.getTm());
|
||||||
vo.setEcologyYearRateV(nowStwrr.getEcologyV().divide(ecologyVSum, 1, BigDecimal.ROUND_HALF_UP).toString().concat("%"));
|
|
||||||
vo.setEcologyV(nowStwrr.getEcologyV().toString());
|
|
||||||
vo.setLifeYearRateV(nowStwrr.getEcologyV().divide(lifeVSum, 1, BigDecimal.ROUND_HALF_UP).toString().concat("%"));
|
|
||||||
vo.setLifeV(nowStwrr.getLifeV().toString());
|
|
||||||
|
|
||||||
|
// 干渠灌溉1数据
|
||||||
|
vo.setMci1YearRateV(nowStwrr.getMci1V().divide(mci1VSum, 4, BigDecimal.ROUND_HALF_UP)
|
||||||
|
.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP).toString().concat("%"));
|
||||||
|
vo.setMci1V(nowStwrr.getMci1V().toString());
|
||||||
|
|
||||||
|
// 干渠灌溉2数据
|
||||||
|
vo.setMci2YearRateV(nowStwrr.getMci2V().divide(mci2VSum, 4, BigDecimal.ROUND_HALF_UP)
|
||||||
|
.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP).toString().concat("%"));
|
||||||
|
vo.setMci2V(nowStwrr.getMci2V().toString());
|
||||||
|
|
||||||
|
// 生态数据
|
||||||
|
vo.setEcologyYearRateV(nowStwrr.getEcologyV().divide(ecologyVSum, 4, BigDecimal.ROUND_HALF_UP)
|
||||||
|
.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP).toString().concat("%"));
|
||||||
|
vo.setEcologyV(nowStwrr.getEcologyV().toString());
|
||||||
|
|
||||||
|
// 查找去年同期数据
|
||||||
StWaterRReorganize lastStwrr = lastYearList.stream()
|
StWaterRReorganize lastStwrr = lastYearList.stream()
|
||||||
.filter(item -> nowStwrr.getTm()
|
.filter(item -> nowStwrr.getTm()
|
||||||
.equals(String.valueOf((Integer.valueOf(item.getTm().substring(0, 4)) + 1))
|
.equals(String.valueOf((Integer.valueOf(item.getTm().substring(0, 4)) + 1))
|
||||||
.concat(item.getTm().substring(4, 7)))).findAny().orElse(null);
|
.concat(item.getTm().substring(4, 7)))).findAny().orElse(null);
|
||||||
// 生态同比 (本期数 - 同期数) / 同期数 × 100%
|
|
||||||
if(ObjectUtils.isEmpty(lastStwrr) || lastStwrr.getEcologyV().compareTo(BigDecimal.ZERO) == 0){
|
// 干渠灌溉1同比
|
||||||
|
if (ObjectUtils.isEmpty(lastStwrr) || lastStwrr.getMci1V().compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
vo.setMci1YoyV("-");
|
||||||
|
} else {
|
||||||
|
BigDecimal mci1YoyV = (nowStwrr.getMci1V().subtract(lastStwrr.getMci1V()))
|
||||||
|
.divide(lastStwrr.getMci1V(), 4, BigDecimal.ROUND_HALF_UP)
|
||||||
|
.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP);
|
||||||
|
jiantou = getArrowSymbol(mci1YoyV);
|
||||||
|
vo.setMci1YoyV(formatChangeRate(jiantou, mci1YoyV));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 干渠灌溉2同比
|
||||||
|
if (ObjectUtils.isEmpty(lastStwrr) || lastStwrr.getMci2V().compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
vo.setMci2YoyV("-");
|
||||||
|
} else {
|
||||||
|
BigDecimal mci2YoyV = (nowStwrr.getMci2V().subtract(lastStwrr.getMci2V()))
|
||||||
|
.divide(lastStwrr.getMci2V(), 4, BigDecimal.ROUND_HALF_UP)
|
||||||
|
.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP);
|
||||||
|
jiantou = getArrowSymbol(mci2YoyV);
|
||||||
|
vo.setMci2YoyV(formatChangeRate(jiantou, mci2YoyV));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生态同比
|
||||||
|
if (ObjectUtils.isEmpty(lastStwrr) || lastStwrr.getEcologyV().compareTo(BigDecimal.ZERO) == 0) {
|
||||||
vo.setEcologyYoyV("-");
|
vo.setEcologyYoyV("-");
|
||||||
} else {
|
} else {
|
||||||
BigDecimal ecologyYoyV = (nowStwrr.getEcologyV().subtract(lastStwrr.getEcologyV())).divide(lastStwrr.getEcologyV(), 1, BigDecimal.ROUND_HALF_UP);
|
BigDecimal ecologyYoyV = (nowStwrr.getEcologyV().subtract(lastStwrr.getEcologyV()))
|
||||||
jiantou = "";
|
.divide(lastStwrr.getEcologyV(), 4, BigDecimal.ROUND_HALF_UP)
|
||||||
if(ecologyYoyV.compareTo(BigDecimal.ZERO) == 0){
|
.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP);
|
||||||
jiantou = "↔";
|
jiantou = getArrowSymbol(ecologyYoyV);
|
||||||
vo.setEcologyYoyV(jiantou);
|
vo.setEcologyYoyV(formatChangeRate(jiantou, ecologyYoyV));
|
||||||
} else {
|
|
||||||
if(ecologyYoyV.compareTo(BigDecimal.ZERO) < 0){
|
|
||||||
jiantou = "↓";
|
|
||||||
} else if(ecologyYoyV.compareTo(BigDecimal.ZERO) > 0){
|
|
||||||
jiantou = "↑";
|
|
||||||
}
|
|
||||||
vo.setEcologyYoyV(jiantou.concat(ecologyYoyV.abs().toString()).concat("%"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
// 生活同比 (本期数 - 同期数) / 同期数 × 100%
|
|
||||||
if(ObjectUtils.isEmpty(lastStwrr) || lastStwrr.getLifeV().compareTo(BigDecimal.ZERO) == 0){
|
// 环比处理(查找上期数据)
|
||||||
vo.setLifeYoyV("-");
|
|
||||||
} else {
|
|
||||||
BigDecimal lifeYoyV = (nowStwrr.getLifeV().subtract(lastStwrr.getLifeV())).divide(lastStwrr.getLifeV(), 1, BigDecimal.ROUND_HALF_UP);
|
|
||||||
jiantou = "";
|
|
||||||
if(lifeYoyV.compareTo(BigDecimal.ZERO) == 0){
|
|
||||||
jiantou = "↔";
|
|
||||||
vo.setLifeYoyV(jiantou);
|
|
||||||
} else {
|
|
||||||
if(lifeYoyV.compareTo(BigDecimal.ZERO) < 0){
|
|
||||||
jiantou = "↓";
|
|
||||||
} else if(lifeYoyV.compareTo(BigDecimal.ZERO) > 0){
|
|
||||||
jiantou = "↑";
|
|
||||||
}
|
|
||||||
vo.setLifeYoyV(jiantou.concat(lifeYoyV.abs().toString()).concat("%"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 环比 (本期数 - 上期数) / 上期数 × 100%
|
|
||||||
StWaterRReorganize lastOneStwrr;
|
StWaterRReorganize lastOneStwrr;
|
||||||
// 如果是1月,需要拿到去年12月的
|
if (i == 0 && nowStwrr.getTm().contains("-01")) {
|
||||||
if(i == 0 && nowStwrr.getTm().contains("-01")){
|
|
||||||
lastOneStwrr = lastYearList.stream().filter(item -> item.getTm().contains("-12")).findAny().orElse(null);
|
lastOneStwrr = lastYearList.stream().filter(item -> item.getTm().contains("-12")).findAny().orElse(null);
|
||||||
} else {
|
} else {
|
||||||
lastOneStwrr = nowYearList.get(i-1);
|
lastOneStwrr = (i > 0) ? nowYearList.get(i - 1) : null;
|
||||||
}
|
}
|
||||||
// 生态
|
|
||||||
if(ObjectUtils.isEmpty(lastOneStwrr) || lastOneStwrr.getEcologyV().compareTo(BigDecimal.ZERO) == 0){
|
// 干渠灌溉1环比
|
||||||
|
if (ObjectUtils.isEmpty(lastOneStwrr) || lastOneStwrr.getMci1V().compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
vo.setMci1QoqV("-");
|
||||||
|
} else {
|
||||||
|
BigDecimal mci1QoqV = (nowStwrr.getMci1V().subtract(lastOneStwrr.getMci1V()))
|
||||||
|
.divide(lastOneStwrr.getMci1V(), 4, BigDecimal.ROUND_HALF_UP)
|
||||||
|
.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP);
|
||||||
|
jiantou = getArrowSymbol(mci1QoqV);
|
||||||
|
vo.setMci1QoqV(formatChangeRate(jiantou, mci1QoqV));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 干渠灌溉2环比
|
||||||
|
if (ObjectUtils.isEmpty(lastOneStwrr) || lastOneStwrr.getMci2V().compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
vo.setMci2QoqV("-");
|
||||||
|
} else {
|
||||||
|
BigDecimal mci2QoqV = (nowStwrr.getMci2V().subtract(lastOneStwrr.getMci2V()))
|
||||||
|
.divide(lastOneStwrr.getMci2V(), 4, BigDecimal.ROUND_HALF_UP)
|
||||||
|
.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP);
|
||||||
|
jiantou = getArrowSymbol(mci2QoqV);
|
||||||
|
vo.setMci2QoqV(formatChangeRate(jiantou, mci2QoqV));
|
||||||
|
}
|
||||||
|
|
||||||
|
// 生态环比
|
||||||
|
if (ObjectUtils.isEmpty(lastOneStwrr) || lastOneStwrr.getEcologyV().compareTo(BigDecimal.ZERO) == 0) {
|
||||||
vo.setEcologyQoqV("-");
|
vo.setEcologyQoqV("-");
|
||||||
} else {
|
} else {
|
||||||
BigDecimal ecologyQoqV = (nowStwrr.getEcologyV().subtract(lastOneStwrr.getEcologyV())).divide(lastOneStwrr.getEcologyV(), 1, BigDecimal.ROUND_HALF_UP);
|
BigDecimal ecologyQoqV = (nowStwrr.getEcologyV().subtract(lastOneStwrr.getEcologyV()))
|
||||||
jiantou = "";
|
.divide(lastOneStwrr.getEcologyV(), 4, BigDecimal.ROUND_HALF_UP)
|
||||||
if(ecologyQoqV.compareTo(BigDecimal.ZERO) == 0){
|
.multiply(new BigDecimal(100)).setScale(1, BigDecimal.ROUND_HALF_UP);
|
||||||
jiantou = "↔";
|
jiantou = getArrowSymbol(ecologyQoqV);
|
||||||
vo.setEcologyQoqV(jiantou);
|
vo.setEcologyQoqV(formatChangeRate(jiantou, ecologyQoqV));
|
||||||
} else {
|
|
||||||
if(ecologyQoqV.compareTo(BigDecimal.ZERO) < 0){
|
|
||||||
jiantou = "↓";
|
|
||||||
} else if(ecologyQoqV.compareTo(BigDecimal.ZERO) > 0){
|
|
||||||
jiantou = "↑";
|
|
||||||
}
|
|
||||||
vo.setEcologyQoqV(jiantou.concat(ecologyQoqV.abs().toString()).concat("%"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 生活
|
|
||||||
if(ObjectUtils.isEmpty(lastOneStwrr) || lastOneStwrr.getLifeV().compareTo(BigDecimal.ZERO) == 0){
|
|
||||||
vo.setLifeQoqV("-");
|
|
||||||
} else {
|
|
||||||
BigDecimal lifeQoqV = (nowStwrr.getLifeV().subtract(lastOneStwrr.getLifeV())).divide(lastOneStwrr.getLifeV(), 1, BigDecimal.ROUND_HALF_UP);
|
|
||||||
jiantou = "";
|
|
||||||
if(lifeQoqV.compareTo(BigDecimal.ZERO) == 0){
|
|
||||||
jiantou = "↔";
|
|
||||||
vo.setLifeQoqV(jiantou);
|
|
||||||
} else {
|
|
||||||
if(lifeQoqV.compareTo(BigDecimal.ZERO) < 0){
|
|
||||||
jiantou = "↓";
|
|
||||||
} else if(lifeQoqV.compareTo(BigDecimal.ZERO) > 0){
|
|
||||||
jiantou = "↑";
|
|
||||||
}
|
|
||||||
vo.setLifeQoqV(jiantou.concat(lifeQoqV.abs().toString()).concat("%"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resList.add(vo);
|
resList.add(vo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return resList;
|
return resList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 辅助方法:获取箭头符号
|
||||||
|
private String getArrowSymbol(BigDecimal value) {
|
||||||
|
if (value.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
return "↔";
|
||||||
|
} else if (value.compareTo(BigDecimal.ZERO) < 0) {
|
||||||
|
return "↓";
|
||||||
|
} else {
|
||||||
|
return "↑";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 辅助方法:格式化变化率
|
||||||
|
private String formatChangeRate(String arrow, BigDecimal value) {
|
||||||
|
if ("↔".equals(arrow)) {
|
||||||
|
return arrow;
|
||||||
|
} else {
|
||||||
|
return arrow.concat(value.abs().toString()).concat("%");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue