供水统计
parent
dbc554408f
commit
44340d9756
|
|
@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|||
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.gunshi.core.result.R;
|
||||
import com.gunshi.db.dto.DateTimeRangeSo;
|
||||
import com.gunshi.project.xyt.entity.vo.StWaterRVo;
|
||||
import com.gunshi.project.xyt.model.StWaterR;
|
||||
import com.gunshi.project.xyt.service.StWaterRService;
|
||||
|
|
@ -19,16 +20,12 @@ import io.swagger.v3.oas.annotations.tags.Tag;
|
|||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.CrossOrigin;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 描述: 供水量表
|
||||
|
|
@ -98,4 +95,10 @@ public class StWaterRController {
|
|||
List<StWaterRVo> vos = ConvertUtil.entityToVoList(this.list(stWaterR).getData(), StWaterRVo.class);
|
||||
ExcelUtil.exportExcel(vos, filename, StWaterRVo.class, response, "供水流量表");
|
||||
}
|
||||
|
||||
@Operation(summary = "闸阀总览-供水统计")
|
||||
@PostMapping("/stat")
|
||||
public R<Map<String, BigDecimal>> stat(@RequestBody @Validated DateTimeRangeSo dateTimeRangeSo) {
|
||||
return R.ok(service.stat(dateTimeRangeSo));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,12 @@
|
|||
package com.gunshi.project.xyt.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.gunshi.db.dto.DateTimeRangeSo;
|
||||
import com.gunshi.project.xyt.model.StWaterR;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 描述: 供水量表
|
||||
|
|
@ -12,4 +16,15 @@ import org.apache.ibatis.annotations.Mapper;
|
|||
@Mapper
|
||||
public interface StWaterRMapper extends BaseMapper<StWaterR> {
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
select t.v,s.sttp as stcd from
|
||||
(select stcd,sum(v)
|
||||
from public.st_water_r t
|
||||
where tm <![CDATA[>=]]> #{obj.start} and tm <![CDATA[<=]]> #{obj.end}
|
||||
group by stcd ) t
|
||||
left join st_stbprp_b s on t.stcd = s.stcd
|
||||
</script>
|
||||
""")
|
||||
List<StWaterR> stat(DateTimeRangeSo dateTimeRangeSo);
|
||||
}
|
||||
|
|
@ -15,6 +15,7 @@ import lombok.Data;
|
|||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
|
|
@ -64,7 +65,7 @@ public class StWaterR extends GenericPageParams implements Serializable {
|
|||
@TableField(value="v")
|
||||
@Schema(description="水量")
|
||||
// @Size(max = 0,message = "水量最大长度要小于 0")
|
||||
private String v;
|
||||
private BigDecimal v;
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,18 +1,15 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.project.xyt.entity.vo.GateStautsVo;
|
||||
import com.gunshi.project.xyt.mapper.GateValveRMapper;
|
||||
import com.gunshi.project.xyt.mapper.GateValveRealMapper;
|
||||
import com.gunshi.project.xyt.model.GateValveKey;
|
||||
import com.gunshi.project.xyt.model.GateValveKeyAutoDao;
|
||||
import com.gunshi.project.xyt.model.GateValveR;
|
||||
import com.gunshi.project.xyt.model.GateValveReal;
|
||||
import com.gunshi.project.xyt.util.DateUtil;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -58,18 +55,18 @@ public class GateValveRealService extends ServiceImpl<GateValveRealMapper, GateV
|
|||
if(valveKey == null || !key.equals(valveKey.getKey())){
|
||||
throw new IllegalArgumentException("密码不正确");
|
||||
}
|
||||
//更新闸阀实时表和历史表
|
||||
GateValveR gateValveR = new GateValveR();
|
||||
BeanUtils.copyProperties(gateValveKey,gateValveR);
|
||||
gateValveR.setTm(new Date());
|
||||
gateValveRMapper.insert(gateValveR);
|
||||
|
||||
GateValveReal real = new GateValveReal();
|
||||
BeanUtils.copyProperties(gateValveKey,real);
|
||||
real.setTm(new Date());
|
||||
this.remove(new QueryWrapper<GateValveReal>().eq("valve_code",valveCode));
|
||||
this.save(real);
|
||||
return "调节闸阀成功";
|
||||
//todo 给闸阀下发调节指令
|
||||
// GateValveR gateValveR = new GateValveR();
|
||||
// BeanUtils.copyProperties(gateValveKey,gateValveR);
|
||||
// gateValveR.setTm(new Date());
|
||||
// gateValveRMapper.insert(gateValveR);
|
||||
//
|
||||
// GateValveReal real = new GateValveReal();
|
||||
// BeanUtils.copyProperties(gateValveKey,real);
|
||||
// real.setTm(new Date());
|
||||
// this.remove(new QueryWrapper<GateValveReal>().eq("valve_code",valveCode));
|
||||
// this.save(real);
|
||||
return "调节闸阀指令已下发";
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,17 @@
|
|||
package com.gunshi.project.xyt.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.gunshi.db.dto.DateTimeRangeSo;
|
||||
import com.gunshi.project.xyt.mapper.StWaterRMapper;
|
||||
import com.gunshi.project.xyt.model.StWaterR;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 描述: 供水量表
|
||||
|
|
@ -20,6 +24,11 @@ import java.util.Date;
|
|||
public class StWaterRService extends ServiceImpl<StWaterRMapper, StWaterR>
|
||||
{
|
||||
|
||||
public Map<String, BigDecimal> stat(DateTimeRangeSo dateTimeRangeSo) {
|
||||
List<StWaterR> list = baseMapper.stat(dateTimeRangeSo);
|
||||
return list.stream()
|
||||
.collect(Collectors.groupingBy(StWaterR::getStcd, Collectors.mapping(StWaterR::getV, Collectors.reducing(BigDecimal.ZERO, BigDecimal::add))));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue