Commit 505231d0 authored by jichao's avatar jichao

改bug

parent 29057a6f
......@@ -37,12 +37,12 @@ public class BusSavingServiceImpl implements BusSavingService {
public PersistModel update(List<BusSaving> busSavingList) {
int result = 0;
String message = "";
Example example = new Example(BusSaving.class);
Example.Criteria criteria = example.createCriteria();
for (BusSaving busSaving : busSavingList) {
String id = busSaving.getId();
criteria.andEqualTo("id", id);
if (StringUtils.isNotEmpty(id)) {
Example example = new Example(BusSaving.class);
Example.Criteria criteria = example.createCriteria();
criteria.andEqualTo("id", id);
result += busSavingRepository.updateByExampleSelective(busSaving, example);
message = "更新成功";
} else {
......
......@@ -43,12 +43,11 @@ public class OverViewController {
@ApiOperation(value="运行费用统计", notes="运行费用统计")
@ApiImplicitParams({@ApiImplicitParam(name = "proId", value = "项目类型主键", required = true, dataType = "字符串"),
@ApiImplicitParam(name = "type", value = "水电气类型,1:水,2:电,3:气", required = true, dataType = "数字"),
@ApiImplicitParam(name = "date", value = "0:今日,-1:昨日,1:明日", required = true, dataType = "数字")
})
@RequestMapping("/countDailyPrice")
public Result countDailyPrice(@RequestParam String proId, @RequestParam Integer type, @RequestParam Integer date) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, overViewServiceImpl.countDailyPrice(proId, type, date));
public Result countDailyPrice(@RequestParam String proId, @RequestParam Integer date) {
return Result.builder(new PersistModel(1), MessageConstant.MESSAGE_ALERT_SUCCESS, MessageConstant.MESSAGE_ALERT_ERROR, overViewServiceImpl.countDailyPrice(proId, date));
}
@ApiOperation(value="耗能拆分统计", notes="耗能拆分统计")
......
......@@ -28,8 +28,8 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
"sum(GAS) as gas,sum(GAS_MONEY) as gasMoney" +
" from energy_count_m e " +
"where e.PRO_ID=#{proId} and `year`=#{year}" +
"<if test=\"day != null\"> and `day`=${day} group by e.`day`</if>" +
"<if test=\"mon != null\"> and mon=${mon} group by e.mon</if></script>")
"<if test=\"day != null\"> and `day`=#{day} group by e.`day`</if>" +
"<if test=\"mon != null\"> and mon=#{mon} group by e.mon</if></script>")
@ResultMap("BaseResultMap")
EnergyCountM countAmountAndPrice(EnergyCountM energyCountM);
......@@ -39,11 +39,9 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @return
*/
@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`+0 asc</script>")
"sum(e.WATER_MONEY)+sum(e.ELEC_MONEY)+sum(e.GAS_MONEY) 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`+0 asc</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> countDailyPrice(EnergyCountMVo energyCountMVo);
......@@ -53,7 +51,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @return
*/
@Select("<script>select if(sum(e.WATER) is null, 0, sum(e.WATER)) ENERGY from energy_count_m e " +
"where e.`DAY`=${day} and e.MON=${mon} and e.`YEAR`=#{year} and e.PRO_ID=#{proId}</script>")
"where e.`DAY`=#{day} and e.MON=#{mon} and e.`YEAR`=#{year} and e.PRO_ID=#{proId}</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> countEnergySplitWater(EnergyCountMVo energyCountMVo);
......@@ -67,7 +65,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
"<if test=\"type == 3\">sum(e.GAS) ENERGY </if>" +
"from bus_device d,bus_device_meter dm,energy_count_m e " +
"where d.DEV_NUM=dm.DEV_NUM and dm.MET_NUM=e.MET_NUM and " +
"e.`DAY`=${day} and e.MON=${mon} and e.`YEAR`=#{year} and e.PRO_ID=#{proId} " +
"e.`DAY`=#{day} and e.MON=#{mon} and e.`YEAR`=#{year} and e.PRO_ID=#{proId} " +
"group by d.DEV_NM</script>")
@ResultMap("resultMapVo")
List<EnergyCountMVo> countEnergySplitElecGas(EnergyCountMVo energyCountMVo);
......@@ -80,7 +78,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
@Select("<script>select a.* from (" +
"select e.`DAY`," +
"sum(e.WATER_MONEY)+sum(e.ELEC_MONEY)+sum(e.GAS_MONEY) MONEY" +
" from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=${mon}" +
" 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`+0 asc) a order by a.MONEY desc</script>")
@ResultMap("resultMapVo")
......@@ -95,7 +93,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`+0 asc</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);
......@@ -114,7 +112,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @param energyCountM
* @return
*/
@Select("<script>select SUM(e.WATER) WATER,SUM(e.ELEC) ELEC,SUM(e.GAS) GAS from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=${mon} and e.`DAY`=${day}</script>")
@Select("<script>select SUM(e.WATER) WATER,SUM(e.ELEC) ELEC,SUM(e.GAS) GAS from energy_count_m e where e.PRO_ID=#{proId} and e.`YEAR`=#{year} and e.MON=#{mon} and e.`DAY`=#{day}</script>")
@ResultMap("BaseResultMap")
EnergyCountM countEnergyDay(EnergyCountM energyCountM);
......@@ -132,7 +130,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @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>")
@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);
......@@ -141,7 +139,7 @@ public interface EnergyCountMRepository extends BaseMapper<EnergyCountM> {
* @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>")
@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);
......
......@@ -35,7 +35,7 @@ public interface OverViewService {
* @param type
* @return
*/
List<EnergyCountMVo> countDailyPrice(String proId, Integer type, Integer date);
List<EnergyCountMVo> countDailyPrice(String proId, Integer date);
/**
* 耗能拆分统计
......@@ -51,7 +51,7 @@ public interface OverViewService {
* @param date
* @return
*/
Integer getPriceRank(String proId, Integer date);
Map<String, Object> getPriceRank(String proId, Integer date);
/**
* 建筑单位面积用量标准
......
......@@ -318,11 +318,10 @@ public class OverViewServiceImpl implements OverViewService {
}
@Override
public List<EnergyCountMVo> countDailyPrice(String proId, Integer type, Integer date) {
public List<EnergyCountMVo> countDailyPrice(String proId, Integer date) {
Map<String, String> cal = this.getTime(date);
EnergyCountMVo e = new EnergyCountMVo();
e.setProId(proId);
e.setType(type);
e.setYear(cal.get("year"));
e.setMon(cal.get("month"));
e.setDay(cal.get("day"));
......@@ -368,7 +367,11 @@ public class OverViewServiceImpl implements OverViewService {
}
@Override
public Integer getPriceRank(String proId, Integer date) {
public Map<String, Object> getPriceRank(String proId, Integer date) {
//返回值 价格 排名
Map<String, Object> result = new HashMap<>();
result.put("money", 0);
result.put("rank", 1);
Map<String, String> cal = this.getTime(date);
String day = cal.get("day");
EnergyCountMVo e = new EnergyCountMVo();
......@@ -381,10 +384,12 @@ public class OverViewServiceImpl implements OverViewService {
for (int i = 0; i < list.size(); i++) {
EnergyCountMVo energyCountMVo = list.get(i);
String eDay = energyCountMVo.getDay();
if(StringUtils.equals(day, eDay))
return i + 1;
if(StringUtils.equals(day, eDay)) {
result.put("money", energyCountMVo.getMoney());
result.put("rank", i + 1);
}
}
return 1;
return result;
}
@Override
......
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