# 智慧社区管理系统-基础信息管理-06抄表管理

news2024/7/4 4:33:31

一后端

1:entity

package com.woniu.community.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class Records {
    private int  id;
    private int typeId;
    private Double num;
    private Double num2;
    private int  houseId;
    private String upTime;
    private String onTime;
    private String checkTime;
    private String meter;
    private String remarks;
    private String userName;
    private String numbers;
    private String typeName;


}

2:RecordsMapper

package com.woniu.community.mapper;

import com.woniu.community.entity.PropertyInfo;
import com.woniu.community.entity.Records;

import java.util.List;

public interface RecordsMapper {
    List<Records> selectAll(int start, int size , String numbers, String typeName);
    int  count(String numbers,String typeName);
    int  insertRecords(Records records);
    int  deleteRecords(int id);


}

3:IRecordsService

package com.woniu.community.service;

import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Records;

import java.util.List;

public interface IRecordsService {
   HttpResult selectAll(int pageIndex, int pageSize , String numbers, String typeName);
    HttpResult  insertRecords(Records records);
    HttpResult  deleteRecords(int id);

}

4:RecordsServiceImpl

package com.woniu.community.service.impl;

import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Records;
import com.woniu.community.mapper.RecordsMapper;
import com.woniu.community.service.IRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RecordsServiceImpl implements IRecordsService {
    @Autowired(required = false)
    private RecordsMapper recordsMapper;
    @Override
    public HttpResult selectAll(int pageIndex, int pageSize, String numbers, String typeName) {
        HttpResult result=null;
        List<Records> records = recordsMapper.selectAll((pageIndex - 1) * pageSize, pageSize, numbers, typeName);
        int count = recordsMapper.count(numbers, typeName);
        if (records!=null&&records.size()>0){
            result  =new HttpResult(records,count,200,null);
        }else{
            result  =new HttpResult(null,0,500,"没有更多数据");

        }
        return result;
    }

    @Override
    public HttpResult insertRecords(Records records) {
        HttpResult result=null;
        int count = recordsMapper.insertRecords(records);
        if (count>0){
            result=new HttpResult(null,0,200,"添加成功");
        }else{
            result=new HttpResult(null,0,500,"添加失败");

        }
        return result;
    }

    @Override
    public HttpResult deleteRecords(int id) {
        HttpResult result=null;
        int count = recordsMapper.deleteRecords(id);
        if (count>0){
            result=new HttpResult(null,0,200,"删除成功");
        }else{
            result=new HttpResult(null,0,500,"删除失败");

        }
        return result;
    }
}

5:RecordsController

package com.woniu.community.controller;

import com.woniu.community.entity.HttpResult;
import com.woniu.community.entity.Records;
import com.woniu.community.service.IRecordsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/records")
@CrossOrigin(origins = "*")
public class RecordsController {
    @Autowired
    private IRecordsService iRecordsService;
    @RequestMapping("/list")
    HttpResult selectAll(int pageIndex, int pageSize , String numbers, String typeName){
        return  iRecordsService.selectAll(pageIndex,pageSize,numbers,typeName);
    }
    @PostMapping("add")
    HttpResult  insertRecords(@RequestBody  Records records){
        return iRecordsService.insertRecords(records);
    }
    @RequestMapping("/delete")
    HttpResult  deleteRecords(int id){
        return iRecordsService.deleteRecords(id);

    }
}

6:RecordsMapper.xml

<?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="com.woniu.community.mapper.RecordsMapper">
    <resultMap id="recMap" type="Records">
        <result column="id" property="id"/>
        <result column="type_id" property="typeId"/>
        <result column="num" property="num"/>
        <result column="num2" property="num2"/>
        <result column="house_id" property="houseId"/>
        <result column="up_time" property="upTime"/>
        <result column="on_time" property="onTime"/>
        <result column="check_time" property="checkTime"/>
        <result column="meter" property="meter"/>
        <result column="remarks" property="remarks"/>
        <result column="username" property="userName"/>
        <result column="numbers" property="numbers"/>
        <result column="name" property="typeName"/>


    </resultMap>
    <select id="selectAll" resultMap="recMap">
        select h.numbers,o.username,r.*,p.name
        from  house h left join  owner o on
            o.house_id=h.id
                      left join records r on
            r.house_id=h.id
                      left join property_type p on
            r.type_id=p.id
        <where>
            <if test="numbers!=null and numbers!='null'">
                and  numbers=#{numbers}
            </if>
            <if test="typeName!=null and typeName!='null'">
                and  name=#{typeName}
            </if>
        </where>
        limit #{start},#{size}

    </select>

    <select id="count" resultType="int">
        select count(r.id)
        from  house h left join  owner o on
            o.house_id=h.id
                      left join records r on
            r.house_id=h.id
                      left join property_type p on
            r.type_id=p.id
        <where>
            <if test="numbers!=null and numbers!='null'">
                and  numbers=#{numbers}
            </if>
            <if test="typeName!=null and typeName!='null'">
                and  name=#{typeName}
            </if>
        </where>
    </select>

    <insert id="insertRecords">
        insert  into records(house_id,type_id,num,num2,check_time,meter)
        values (#{houseId},#{typeId},#{num},#{num2},#{checkTime},#{meter})
    </insert>

    <delete id="deleteRecords">
        delete from records where  id=#{id}
    </delete>


</mapper>

二 前端代码


<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="assets/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/right.css" rel="stylesheet">
    <script src="assets/jquery-3.5.1.min.js"></script>
    <script src="assets/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script src="assets/vue.min-v2.5.16.js"></script>
    <script src="assets/vue-router.min-2.7.0.js"></script>
    <script src="assets/axios.min.js"></script>
</head>
<body>
<div id="app" class="container">
    <div class="row">
        <div class="col-md-12">

            门牌号:
            <input type="text"  v-model="numbers"/>

            费用类型:
            <input type="text"  v-model="typeName"/>
            <button class="btn btn-info" @click="doQuery">搜索</button>
        </div>
        <div class="col-md-12" style="height: 50px; line-height: 50px;">
            <button class="btn btn-info" @click="doAdd">新增</button>
        </div>
    </div>
    <div class="row">
        <div class="col-md-12">
            <table class="table table-striped">
            <caption>抄表管理</caption>
                <thead>
                    <tr>
                        <th>门牌号</th>
                        <th>户主</th>
                        <th>费用类型</th>
                        <th>上次度数</th>
                        <th>本次度数</th>
                        <th>登记时间</th>
                        <th>抄表员</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <tr v-for="o in records">
                        <td>{{o.numbers}}</td>
                        <td>{{o.userName}}</td>
                        <td>{{o.typeName}}</td>
                        <td>{{o.num}}</td>
                        <td>{{o.num2}}</td>
                        <td>{{o.checkTime}}</td>
                        <td>{{o.meter}}</td>
                        <td>
                            <button class="btn btn-danger" @click="doDelete(o.id)">删除</button>
                        </td>
                    </tr>
                </tbody>
            </table>
            <ul class="pagination" v-for="p in pageNum">
                <li v-if="p==pageIndex" class="active"><a @click="doGO(p)">{{p}}</a></li>
                <li v-else="p==pageIndex"><a @click="doGO(p)">{{p}}</a></li>
            </ul>
        </div>
    </div>
</div>
<script>
    new Vue({
        el: '#app',
        data: {
            records:null,
            pageIndex:1,//当前页码
            pageSize:5,//每显示的条数
            pageTotal:0,//总条数
            pageNum:0,//分页
           numbers:null,
             typeName:null,
        },
        methods: {
            requestLIst(url){
                axios.get(url).then(response=>{
                    console.log(response.data)
                    this.records=response.data.data;//用户列表
                    this.pageTotal=response.data.pageTotal;//总条数
                    this.pageNum=Math.ceil(this.pageTotal / this.pageSize);//计算页数
                })
            },
            doDelete(id){
                var  url="http://localhost:8080/records/delete?id="+id;
                axios.get(url).then(response=>{
                    console.log(response.data)
                    if (response.data.code==200){
                        var url="http://localhost:8080/records/list?pageIndex="+this.pageIndex+"&pageSize="+this.pageSize;
                        this.requestLIst(url);
                    }else{
                        alert(response.data.msg)
                    }
                })
            },
            doGO(p){
                this.pageIndex=p;
                var url="http://localhost:8080/records/list?pageIndex="+p+"&pageSize="+this.pageSize+"&numbers="+this.numbers+"&typeName="+this.typeName;
                this.requestLIst(url);
            },
            doQuery(){
                this.doGO(1);
            },
            doAdd(){
                window.parent.main_right.location.href = "records_add_update.html";

            },

        },
        created: function () {
            var url="http://localhost:8080/records/list?pageIndex="+this.pageIndex+"&pageSize="+this.pageSize;
            this.requestLIst(url);
            }
    });
</script>
</body>
</html>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="assets/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/right.css" rel="stylesheet">
    <script src="assets/jquery-3.5.1.min.js"></script>
    <script src="assets/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
    <script src="assets/vue.min-v2.5.16.js"></script>
    <script src="assets/vue-router.min-2.7.0.js"></script>
    <script src="assets/axios.min.js"></script>
    <script src="assets/date_picker.js"></script>
</head>
<body>
<div id="app" class="container">
    <div class="row">
        <div class="col-md-8 col-md-offset-2">
            <div class="row">
                <div class="col-md-12" style="text-align: center; font-weight: bold; font-size: 18px; height: 80px; line-height: 80px;">
                    {{title}}
                </div>
            </div>
            <div class="row">
                <div class="col-md-6 col-md-offset-3" style="height: 200px;">
                  <label>门牌号:</label>
                    <select v-model="houseId">
                        <option v-for="h in houseList":value="h.id">{{h.numbers}}</option>
                    </select><br>

                    <label>费用类型:</label>
                    <select v-model="typeId">
                        <option value="2">水费</option>
                        <option value="3">电费</option>
                        <option value="1">物业费</option>
                        <option value="4">停车费</option>
                    </select><br>

                    <label>上次度数:</label>
                    <input type="text" v-model="num"><br>
                    <label>本次度数:</label>
                    <input type="text" v-model="num2"><br>
                    <label>登记时间:</label>
                    <input type="date" class="form-control" v-model="checkTime"/>
                    <label>抄表员:</label>
                    <input type="text" v-model="meter"><br>
            </div>
            <div class="row">
                <div class="col-md-6 col-md-offset-3" style="height: 80px;">
                    <button class="btn btn-primary"@click="doSave">保存</button>
                    <button class="btn btn-default" @click="doCancel">取消</button>
                </div>
            </div>
        </div>
    </div>
</div>
<script>
    new Vue({
        el: '#app',
        data: {
            title: "新增信息",

            houseList:null,
            houseId:null,
            typeId:null,
            num:null,
            num2:null,
            checkTime:null,
            meter:null,
        },
        methods: {
            requestHouse(){
                var  url="http://localhost:8080/house/list?pageIndex=1&pageSize=100";
                axios.get(url).then(response=>{
                    this.houseList=response.data.data;
                })
            },
            // requestOwner(){
            //     var  url="http://localhost:8080/owner/list?pageIndex=1&pageSize=100";
            //     axios.get(url).then(response=>{
            //         this.ownerList=response.data.data;
            //     })
            // },
            doSave(){
            axios.post("http://localhost:8080/records/add",{
                houseId:this.houseId,
                typeId:this.typeId,
                num:this.num,
                num2:this.num2,
                checkTime:this.checkTime,
                meter:this.meter,

            }).then(response=>{
                if (response.data.code==200){
                    window.parent.main_right.location.href="records_list.html";

                }else{
                    alert(response.data.msg)
                }
            })
            },
            doCancel(){
                history.go(-1);
            },
        },
        created: function () {
            this. requestHouse();
            // this. requestOwner();

        }
    });
</script>
</body>
</html>

三 页面效果

在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/59421.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

博安生物更新招股书:上半年亏1.5亿 绿叶制药与建银聚源是股东

雷递网 雷建平 12月3日山东博安生物技术股份有限公司&#xff08;简称&#xff1a;“博安生物”&#xff09;日前再次递交招股书&#xff0c;并更新招股书&#xff0c;准备在香港上市。上半年期内亏损1.53亿元博安生物是绿叶制药集团的附属公司&#xff0c;于2013年成立&#x…

远程桌面树莓派【内网穿透】

本篇文章主要分享如何在公网环境下&#xff0c;远程桌面连接家里的树莓派。 远程桌面环境&#xff0c;我们选择通过XRDP来实现&#xff0c;它内部使用的是windows远程桌面的协议。 而由于现在普遍处于大内网环境&#xff0c;绝大部分人都没有公网IP&#xff0c;所以我们这里用…

(9)点云数据处理学习——Global registration(全局注册)

1、主要参考 &#xff08;1&#xff09;官网的地址 Global registration — Open3D 0.16.0 documentation 2、作用和原理 2.1个人理解 PS理解&#xff1a;&#xff08;1&#xff09;ICP的作用是&#xff0c;2个点云数据在初步转换关系&#xff08;已知不精确&#xff09;的…

【关系抽取】TPLinker:单阶段联合抽取,并解决暴漏偏差

&#x1f50e;大家好&#xff0c;我是Sonhhxg_柒&#xff0c;希望你看完之后&#xff0c;能对你有所帮助&#xff0c;不足请指正&#xff01;共同学习交流&#x1f50e; &#x1f4dd;个人主页&#xff0d;Sonhhxg_柒的博客_CSDN博客 &#x1f4c3; &#x1f381;欢迎各位→点赞…

车载GNSS/INS/LiDAR坐标系定义与理解

目录一、基本坐标系1.1 地心惯性坐标系&#xff08;Inertial coordinate system&#xff0c;i系&#xff09;1.2 地心地固坐标系&#xff08;Earth-Centered, Earth-Fixed&#xff0c;e系&#xff09;1.3 导航坐标系&#xff08;Navigation&#xff0c;n系&#xff09;1.4 车体…

[附源码]计算机毕业设计springboot疫苗药品批量扫码识别追溯系统

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…

一、领域驱动设计核心思想与设计过程

一、软件发展的必然规律 1、软件是对真是世界的模拟&#xff0c;但真实世界软件十分复杂。 2、人在认识真实世界的时候总是有一个从简单到复杂的过程 3、软件需求的变更成为一种必然的事情&#xff0c;并且总是由简单向复杂转变 4、初期软件的业务逻辑十分简单清晰命令&#x…

C语言画直方图

前言 最近在看K&R的《C语言程序设计语言》这本书&#xff0c;第一单元的练习13要求画一个统计单词长度的直方图&#xff0c;这里忽略了计算单词长度的代码&#xff0c;假设已知单词长度存入一个digit数组中&#xff0c;根据这个数组画水平直方图和垂直直方图。实话说&…

C++11新特性-原始字面量

当我们书写文件路径的时候&#xff0c;会发现&#xff0c;文件路径无法正确输出&#xff0c;如下&#xff1a; 这是因为反斜杠本身就是转义的意思&#xff0c;如果想要输出反斜杠则需要两个反斜杠&#xff0c;如下&#xff1a; 当然这只是其中一种解决方法&#xff0c;还有一种…

实战项目如何抵御即跨站脚本(XSS)攻击

一、XSS攻击的危害 XSS攻击通常指的是通过利用网页开发时留下的漏洞&#xff0c;通过巧妙的方法注入恶意指令代码到网页&#xff0c;使用户加载并执行攻击者恶意制造的网页程序。这些恶意网页程序通常是JavaScript,但实际上也可以包括Java、VBScript、ActiveX、Flash或者甚至是…

思派健康通过上市聆讯:F轮估值17亿美元 腾讯是大股东

雷递网 雷建平 12月3日思派健康科技日前通过聆讯&#xff0c;准备在香港上市。思派健康早在2021年8月就已经递交招股书&#xff0c;这是时隔一年多后&#xff0c;这之前第三次递交招股书。这也意味着&#xff0c;时隔一年多后&#xff0c;思派健康终于要上市了。上半年亏损3.5亿…

SpringSecurity(八)【会话管理】

八、会话管理 简介 当浏览器调用登录接口登录成功之后&#xff0c;服务端会和浏览器之间创建一个会话&#xff08;Session&#xff09;&#xff0c;浏览器在每次发送请求时都会携带一个 SessionId&#xff0c;服务端则根据这个 SessionId 来判断用户身份。当浏览器关闭之后&…

从硬件角度看服务器性能调优

bios整体配置bios系统设置Hyper Thread开启超线程&#xff0c;设置后lscpu命令Thread(s) per core 值显示为 2。超线程可以理解为CPU的虚拟化&#xff0c;一颗物理CPU并行执行两条流水线指令。确认处理器基本频率及睿频频率&#xff0c;部分处理器基础频率低&#xff0c;但是睿…

看完了你还能不懂JAVA内存模型(JMM),我输了

前言 开篇一个例子&#xff0c;我看看都有谁会&#xff1f;如果不会的&#xff0c;或者不知道原理的&#xff0c;还是老老实实看完这篇文章吧。 Slf4j(topic "c.VolatileTest") public class VolatileTest { static boolean run true; public static void main(S…

基于Java+Swing实现《扫雷》游戏

基于JavaSwing实现《扫雷》游戏一、系统介绍二、功能展示三、其他系统一、系统介绍 windows自带的游戏《扫雷》是陪伴了无数人的经典游戏&#xff0c;本程序参考《扫雷》的规则进行了简化&#xff0c;用java语言实现&#xff0c;采用了swing技术进行了界面化处理&#xff0c;设…

基于蚁群算法求解运钞车路径规划问题(Matlab代码实现)

&#x1f352;&#x1f352;&#x1f352;欢迎关注&#x1f308;&#x1f308;&#x1f308; &#x1f4dd;个人主页&#xff1a;我爱Matlab &#x1f44d;点赞➕评论➕收藏 养成习惯&#xff08;一键三连&#xff09;&#x1f33b;&#x1f33b;&#x1f33b; &#x1f34c;希…

[附源码]JAVA毕业设计桔子酒店客房管理系统(系统+LW)

[附源码]JAVA毕业设计桔子酒店客房管理系统&#xff08;系统LW&#xff09; 目运行 环境项配置&#xff1a; Jdk1.8 Tomcat8.5 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目…

vue app开发调用原生方法实现权限访问授权处理(一)

vue app开发调用原生方法实现权限访问授权处理 前提&#xff1a;在写代码之前应该想清楚调用原生安卓、ios的方法&#xff0c;就应该遵循双端的方法规则&#xff0c;调用方法时应该注意&#xff0c;在这里先主要介绍一下注意事项&#xff1a; 根据App发布应用市场的要求&…

【sciter】安全应用列表控件总结

一、效果图 二、功能点 实现电脑文件拖拽进入到安全桌面,读取文件路径,生成应用。可以配置允许拖拽进入安全桌面的文件应用。点击添加图标,可以添加应用到安全桌面中。在安全桌面列表中每一个应用实现双击、失去焦点,获取焦点、右键事件在安全桌面列表中每一个应用可以实现…

[附源码]计算机毕业设计springboot疫情防控平台

项目运行 环境配置&#xff1a; Jdk1.8 Tomcat7.0 Mysql HBuilderX&#xff08;Webstorm也行&#xff09; Eclispe&#xff08;IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持&#xff09;。 项目技术&#xff1a; SSM mybatis Maven Vue 等等组成&#xff0c;B/S模式 M…