zhubaomin
2025-04-07 1a2b07f01ba4616fd9e894dddf474b56d020158c
pipIrr-platform/pipIrr-web/pipIrr-web-project/src/main/java/com/dy/pipIrrProject/flowMonitoring/FlowMonitoringSv.java
New file
@@ -0,0 +1,116 @@
package com.dy.pipIrrProject.flowMonitoring;
import com.dy.common.webUtil.QueryResultVo;
import com.dy.pipIrrGlobal.daoBa.BaDistrictMapper;
import com.dy.pipIrrGlobal.daoPr.PrFlowMonitoringMapper;
import com.dy.pipIrrGlobal.pojoPr.PrFlowMonitoring;
import com.dy.pipIrrGlobal.voPr.VoFlowMonitoring;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.common.utils.PojoUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Map;
/**
 * @author ZhuBaoMin
 * @date 2024-01-04 16:11
 * @LastEditTime 2024-01-04 16:11
 * @Description
 */
@Slf4j
@Service
public class FlowMonitoringSv {
    @Autowired
    private PrFlowMonitoringMapper prFlowMonitoringMapper;
    @Autowired
    private BaDistrictMapper baDistrictMapper;
    /**
     * 根据村编号获取5级区划信息
     * @param villageId 村编号(主键)
     * @return 5级行政区划信息
     */
    public Map getDistrictsByVillageId(Long villageId) {
        return baDistrictMapper.getDistrictsByVillageId(villageId);
    }
    /**
     * 添加管网流量监测站
     * @param prFlowMonitoring 流量监测站实体
     * @return
     */
    public Integer addFlowMonitoring(PrFlowMonitoring prFlowMonitoring) {
        return prFlowMonitoringMapper.insert(prFlowMonitoring);
    }
    /**
     * 根据监测站编号删除监测站
     * @param flowMonitoringId
     * @return
     */
    public Integer deleteFlowMonitoring(Long flowMonitoringId) {
        return prFlowMonitoringMapper.deleteFlowMonitoringById(flowMonitoringId);
    }
    /**
     * 根据监测站编号获取未删除的监测站数量
     * @param flowMonitoringId 流量监测站编号
     * @return
     */
    public Integer getRecordCountOfFlowMonitoringByFlowMonitoringId(Long flowMonitoringId) {
        return prFlowMonitoringMapper.getRecordCountOfFlowMonitoringByFlowMonitoringId(flowMonitoringId);
    }
    /**
     * 得到一个流量监测站
     * @param id 监测站ID
     * @return 监测站实体
     */
    public PrFlowMonitoring selectById(Long id) {
        return prFlowMonitoringMapper.selectByPrimaryKey(id);
    }
    /**
     * 得到全部流量监测站
     * @return 监测站实体集合
     */
    public QueryResultVo<List<PrFlowMonitoring>> selectAll(){
        QueryResultVo<List<PrFlowMonitoring>> rsVo = new QueryResultVo<>() ;
        rsVo.obj = this.prFlowMonitoringMapper.selectAll() ;
        return rsVo ;
    }
    /**
     * 根据指定条件得到流量监测站实体记录
     * @param queryVo 给的条件
     * @return 监测站实体集合
     */
    public QueryResultVo<List<VoFlowMonitoring>> getPrFlowMonitorings(QueryVo queryVo){
        Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo) ;
        QueryResultVo<List<VoFlowMonitoring>> rsVo = new QueryResultVo<>() ;
        rsVo.pageSize = queryVo.pageSize ;
        rsVo.pageCurr = queryVo.pageCurr ;
        // 计算符合条件的记录数
        Integer itemTotal = prFlowMonitoringMapper.getRecordCountOfFlowMonitoring(params);
        rsVo.calculateAndSet(itemTotal.longValue(), params);
        rsVo.obj = prFlowMonitoringMapper.getPrFlowMonitoring(params);
        return rsVo ;
    }
    /**
     * 保存修改一个流量监测站实体
     * @param po 修改的内容(id不为空)
     * @return
     */
    public int update (PrFlowMonitoring po){
        return prFlowMonitoringMapper.updateByPrimaryKeySelective(po);
    }
}