如何使用ssm实现小区物业管理系统

186 篇文章 0 订阅
132 篇文章 0 订阅

@TOC

ssm733小区物业管理系统+jsp

第一章 绪论

1.1 研究背景

在现在社会,对于信息处理方面,是有很高的要求的,因为信息的产生是无时无刻的,并且信息产生的数量是呈几何形式的增加,而增加的信息如何存储以及短时间分析检索,也是有时效性的,所以,不管是任何的企业和个人,只要需要处理信息,必然是要寻找到一个适合自己的解决方案,而软件开发商和数据库提供商就是为了解决这些问题。相比之前人工信息处理的水平,现代的信息处理方法是完胜以前的信息处理方法。开发一个符合自己需求的信息管理系统,可以把整个信息处理的过程变得很有规范,并且很有水准,让整个信息处理变成一个自动化的过程,并且在数据处理结果之中直接设定好检索标准,或者是多条件检索标准,通过数据分析获得自己需要的内容,这都是信息化的好处。当一切信息数据存在小小的存储介质之中,那么数据迁移备份的重要性也变得更加简洁,可以设置自动化远程备份,自动化远程处理,不管是使用过程还是维护过程,都会变得更加的高效和整洁,最重要的成本上面的控制,可以极限减少,开源节流,不外如是,减少社会资源的浪费,也是计算机技术的存在的一个优势。所以,对于小区物业信息的管理,一方面为了提高小区物业信息的管理水平,另一方面为了提高小区物业信息的维护水平,小区物业管理系统的开发就显得十分有必要了。

1.2 研究意义

小区物业管理系统不仅可以保证信息安全的前提下提高信息处理水平,更重要的是提高了信息使用者以及所有者的管理水平。信息的出现,必须经过人为的处理,人们才能接受和使用,所以提高了信息处理水准就显得极为重要。采用计算机技术,会发现在数据传递方面,有着急速的传递,不管是距离多远,都可以实时抵达,不管数据量多大,都能在短时间进行处理完毕,让人为的可出错性变低,工作量变少。小区物业管理系统的出现,让小区物业信息的管理跟上了信息时代的步伐,不仅可以在全时间段提供着稳定的处理速度以及处理水准,更能完美的保证了数据的可靠性。不仅如此,小区物业管理系统在使用上面也是得心应手,操作起来极其的简单,只要认识字就行,页面设计相当不错,不用过多的考虑或者寻找,就能使用。总而言之,小区物业管理系统在信息资源的处理方面,表现是极其的出色,不仅提高了管理水准,也让数据的迁移变得更加方便。

1.3 研究内容

本文总共分六章来对小区物业管理系统进行介绍,研究内容具体安排如下:

第一章:通过资料查询,和对调研资料的总结,对小区物业管理系统的背景和小区物业管理系统的意义进行说明;

第二章:选择适合本系统的技术和工具并对其进行说明;

第三章:分析小区物业管理系统开发可行性问题,研究本系统的性能,对本系统使用者的功能进行分析。

第四章:细分功能,利用功能结构图来展示系统的详细功能,同时设计数据库,包括E-R图和数据表的设计;

第五章:展示小区物业管理系统的实现界面和实现的功能;

第六章:测试小区物业管理系统,检测系统的功能能否可用,以及发现并解决系统功能运行的问题。

第二章 开发环境与技术

小区物业管理系统的开发需要的软件环境和技术下面将介绍一下。

2.1 Java语言

Java语言流行至今,依然是后台程序开发人员从业者需要学习的技能之一,并且可以不断的进行深造,可以用Java解决各种各样的问题。Java是一种面向对象的语言,这一点对Java语言的发展功不可没。万物皆对象,很生动的对自然存在的各种环境,各种问题提供了一个解决思路,人类对世界的认知就是从一个一个事物慢慢领悟的,对行为的认知就是事物之间的联系进行认知的,对各种事物之间的联系组成了人类对世界的认知。而Java语言关于编程描述的方法,符合人类对自然界的认知方法。一切自然界的信息如果要进行存储处理,如果只是信息存储的话,也需要对其定义,信息即数据,进而推导,符合数据要求格式的类型,就是符合人类认知事物的类型。Java语言面向对象就是这样理解的,符合人类正常思维。Java不仅仅是运行不挑环境,开发符合人类正常认知,并且还衍生出其他的好的特性,比如安全系数比较高,因为不牵扯到硬件指针,不存在直接访问内存,这样应对计算机病毒的入侵有着很好的防范。Java是一种很好的开发语言。

2.2 JDK简介

JDK这个是Java开发所必须的东西。Java开发必须用JDK,运行必须用JRE,而JDK往往携带了JRE环境,也就是说只要安装了JDK就不需要再去重复性的安装JRE,所以JDK这款开发Java的必备品也就很受欢迎。一台电脑上可以安装多个版本的JDK,并且可以对不同的项目指定不同的JDK,这一点做的相当的友好。如果一台电脑默认没有安装过JDK是不需要配置环境变量,就可以直接访问JDK的,这一点对于初学者来讲,起码配置环境变量方面就方便了很多。JDK目前最新版本是JDK17,版本已经很高了,但是不管是学习还是使用,一般都喜欢用比较稳定的版本,比如JDK1.7或者JDK1.8版本。

2.3 Eclipse开发工具

对于用于开发Java语言的工具来讲,从一开始就是MyEclipse,因为是开源免费的,许多教学机构或者是学校,如果大批量用收费的开发工具来进行讲课,是一种资金的浪费,所以选择MyEclipse作为开发工具,是许多Java学习人员的入门必备。但是随着Java语言功能越来越多,MyEclipse虽然是免费的,但是如果项目需要某些插件的话,需要手动去对应插件的官网进行下载,有时候插件还会被屏蔽,不仅仅在配置开发环境方面造成一定的困难,还会让开发的雄心变弱。Eclipse就在这样的情况下诞生了,秉承于MyEclipse的操作习惯,把一些常用的插件给集成到一个软件里,比如常用的JDK,Tomcat等插件,直接安装Eclipse就可以使用,不需要另外的安装其他的插件,会让使用过MyEclipse的人员用起来很顺手,操作也比较简单。在公司里进行开发也有很多程序员用的都是Eclipse作为开发工具,有效的提升开发效率。可以同时开发许多项目,不同的项目可以选择不同的工作空间,每个独立的工作空间都可以进行单独的配置,可以对Tomcat端口进行修改,也可以在同一个Tomcat里面启动很多个网站项目,在操作方面更加便捷。

第三章 系统分析

一般来说,开发系统不是一拍脑袋就解决的事情,需要有个严谨的分析,并且逐条实现的过程,而系统分析只是系统开发的前奏而已,后续还会有相关的系统实现,系统设计等。

3.1可行性分析

系统是否可以正常实现操作流程,实现操作目的,符合操作流程,这些都可以提前进行分析论证。提前进行分析在开发之前是很重要的,并且进行书面记载,有助于开发流程的缜密性。

3.1.1运行可行性分析

开发小区物业管理系统必然是有运行条件的,开发条件和运行条件都可以进行分析。首先从运行角度上讲,只是作为一个小区物业管理系统的运行环境,不是超大型商业项目,只是运行一个毕业设计,数据量有限,并发条件有限,所以用常规的内存大于4G,CPU双核以上,基本上就能满足运行的硬件需要,硬盘的话常规的大于60G的即可。

3.1.2技术可行性分析

一切可以实现B/S模式的技术很多,而正好在学校就学习了相关的开发技术,采用已经有基础的学习来进行扩展更丰富的功能,从技术上面是不需要太多的重复性投入,可以更快的进行开发,技术可行。

3.1.3经济可行性分析

经济主要考虑投入与获利之间的比例问题,小区物业管理系统开发投入只需要现有的,不必要另外购买的电脑就可以进行使用,一切开放性所用到的工具和资料都可以在图书馆以及互联网上面得到相应的免费资讯,这些都决定了经济上面的投入是不需要太多的。项目功能属于常规功能,没有多并发超用户同时访问的需求,所以也不需要考虑太多的资金投入,所以经济可行。

通过各个方面的研究分析,确定了开发之前这些可行性分析是很有必要的,增加了开发的信心,提高了开发效率,让开发的流程更加的具体化。

3.2系统流程分析

本项目在处理数据方面,必须规定其流程,要让每个步骤都要符合设定预期。注册的结果可以说只有两种结果,一个是成功,一个是失败,成功就会把注册时候输入的数据写入到数据库表里存储,如果失败则提示提示失败,并且不写入数据库。因为两种结果,所以要对数据的合法性进行判断,而数据的合法性需要对每条信息进行判断,主要对哪条信息判断,这些都要有流程。

图3.1用户注册流程图

登录是所有系统必不可少的功能之一。虽然不起眼,但是却是一件不可缺少的事情,登录的作用主要代表着当前操作用户是某人,当然,登录的时候是需要输入账号和密码的,都正确才可以登录,登录的时候会对输入的信息进行判断的。

图3.2 用户登录流程图

数据的添加是一件比较严肃的事情,必须判断正确与否,不然随意的添加可能会导致数据库设定与实际数据输入要求不一致,导致数据丢失的问题,所以必须根据数据设定要求,在输入数据的时候就进行判断输入信息是否合法。

图3.3 信息添加流程图

3.3 系统性能分析

在软件开发的环节,有一个很重要的步骤,那就是关于性能需求分析的环节。如果不对软件的性能需求进行分析和预估,那么后果是很严重的。比如国内的12306,如果只是一个用户登录注册,查票购票退票,那么很容易开发出来,但是同时几百万人次的不同操作,如果没有对这个需求的提前分析预估,还是按照十个八个的并发操作进行软件开发,那肯定是上线就崩溃直接就下线的结果。所以说性能需求是很重要的一个环节。一般系统需求从下面几个角度同时考虑。

3.3.1系统的安全性

一个系统是否安全,不仅仅只是考虑用户的密码是否经过了加密,也更需要考虑数据存储的安全性,比如可以把数据库专门放到一个局域网里的服务器,让主服务器代码远程连接数据库,因为代码服务器与数据服务器的物理分离,如果代码服务器被破解,起码用户数据还有机会保存。

3.3.2系统易维护性

系统长时间运营,肯定需要进行维护。那么维护所需要带来的是性能的提升还是并发数量的提升,这些都是需要考虑的,系统不仅仅要容易维护,数据容易迁移备份,还要符合其他特性。

3.3.3系统可扩展性

系统的功能不可能一成不变的,随时可能会加一些其他的模块,比如有些商场用户积分的问题,这些开始都没有这项设定,后续想加的功能,那么就需要在不改变其原来的功能的前提下,对积分相关模块进行升级,这些就是系统设计之初需要考虑的问题,尽量开发模块化。

综上所述,性能需求必须在符合业务逻辑之外,考虑是否会出现其他的各种情况的一种分析,还必须能解决可能会出现的问题的一种需求分析。所以说,系统的性能需求分析是必不可少的一个环节。

3.4系统功能分析

系统功能主要针对主要模块功能进行分析,暂时不考虑非典型性的问题,只要能满足正确操作流程即可。

小区物业管理系统设置的角色有管理员,用户等。

(1)管理员

管理员增删改查报修信息,房屋信息,收费信息,停车位信息以及投诉信息,管理用户等。对管理员的功能进行分析之后,将使用图3.4的管理员用例图来描述管理员的功能。

图3.4 管理员用例图

(2)用户

用户查看停车位信息,查看收费信息,添加报修信息,添加投诉信息,查看房屋信息等。对用户的功能进行分析之后,将使用图3.5的用户用例图来描述用户的功能。

图3.5 用户用例图

第四章 系统设计

不管是好用还是不好用的系统,在如今的互联网时代都会被广而告之,但是能留存下来的,必然是好用的,并且好看的系统,不好用并且不好看的系统用户会逐渐抛弃的。所以,开发的系统必须是有主题的,要打开系统就明白这个系统主要的作用和功能,所以设计这方面需要下苦功夫的。

4.1界面设计原则

一般都是图片,文字以及各种输入框和按钮等组成的界面,每个界面的内容都大不相同,如何设计成页面的统一,操作的统一,这是下面需要讨论的问题。

第一点:界面设计必须符合人体工程学。人体工程学是一门入微级别的学问,主要考虑人类在各种工作状态下如何提高生产效率。所以说,界面设计的首要目的,就是为了提升效率。

第二点:有效导航是必须的。导航的目的,就是帮助操作人员的记忆能力,提高操作效率而生的,所以导航一定要设置的符合模块的功能,让用户一看到导航就会知道是哪个模块,需要哪些操作,这些步骤是必不可少的,如果把所有功能放到一个页面呈现平面化布局,肯定不合适,所以合适的导航能够帮助工作。

第三点:界面设计的统一性。统一性不是说背景图片是同一个图片或者背景是同一个色系,而是说让操作系统统一。比如导航就统一用树状结构,有模块有层次,理解容易。多项搜索如果一行放不下,就收起,可以选择多项也可以模糊查询,这些都要符合人类正常认知才可以。

所以说,系统设计的核心就是界面设计,主要的业务处理逻辑只要能处理,需要下大力气的还是页面设计。

4.2功能模块设计

本小节运用功能结构图来描述管理员具备的详细的功能,对管理员的功能结构图绘制结果如图4.1所示。管理员增删改查报修信息,房屋信息,收费信息,停车位信息以及投诉信息,管理用户等。

图4.1 管理员功能结构图

本小节运用功能结构图来描述用户具备的详细的功能,对用户的功能结构图绘制结果如图4.2所示。用户查看停车位信息,查看收费信息,添加报修信息,添加投诉信息,查看房屋信息等。

图4.2 用户功能结构图

4.3数据库设计

在系统后台选择数据库的时候,首先第一条就是要满足使用需要,只要满足使用需要,再对数据库的使用友好度和性能上进行分析。选择当前分布最广发的关系型数据库是完全能满足需要的,并且在数据的设计上也有完美的设计顺序,最重要的是符合人们的直观要求。

4.3.1数据库E-R图

下面主要是描述E-R图模型的。对于用户的需求,要具体化,比如有个角色需要有登录,那么最基本的设定必须有账号和密码,那么像姓名,性别其他的对象关系,其实是有从属关系的,通过这样具体化分析,可以得到数据的格式要求,并且能得到数据之间的直接关系。然后可以通过专业的Visio工具来进行E-R图的创建,遵守约定的E-R图表达方式,就可以对数据进行图标形式的描述,并且之间的关系更容易理解。

(1)图4.4即为报修这个实体所拥有的属性值。

图4.4 报修实体属性图

(2)图4.5即为管理员这个实体所拥有的属性值。

图4.5 管理员实体属性图

(3)图4.6即为投诉这个实体所拥有的属性值。

图4.6 投诉实体属性图

  1. 图4.7即为用户这个实体所拥有的属性值。

图4.7 用户实体属性图

(5)图4.8即为上面介绍的实体中存在的联系。

图4.8 实体间关系E-R图

4.3.2 数据库表结构

在程序开发的过程中,系统设计里面包含有数据库的设计,一般都在功能设计的后面进行数据设计,为什么有这样的顺序呢?那是有原因的。数据库设计不能凭空想象,必须符合数据的定义,而数据只是在使用过程之中产生,其实并没有具体化的表现,所以要把数据进行结构的整理,字段的规划。比如用户账号可能是中文或者英文,以及数字形式存在,更或者可能包含一些符号,那么账号字段的设计就只能是文本形式存在,不能是数据形式或者是时间形式存在,以此类推,数据表结构的设计就是在对系统的具体实现数据进行描述规划的一种行为。所以在这个环节尤其要注意,否则可能使用过程中会发现很多不可预料的问题。

对本系统的数据库的要求就是,要严格遵循数据实现原则,符合数据定义范式。对每个表都要进行具体分析,并且表之间的关系更应该有逻辑性,如果违反前面的要求,那么数据很有可能出现问题,所以要把数据之间的关系用E-R图形式画出来,这样理解起来更直观,更不容易出错,效率也更高。

表4.1 报修表

字段注释类型
id (主键)主键int(11)
yonghu_id用户int(11)
baoxiu_uuid_number报修编号varchar(200)
baoxiu_name报修名称varchar(200)
baoxiu_types报修类型int(11)
baoxiu_content报修详情text
chuli_types是否处理int(11)
chuli_content处理结果text
insert_time报修时间timestamp
create_time创建时间timestamp

表4.2 房屋表

字段注释类型
id (主键)主键int(11)
yonghu_id用户int(11)
fangwu_uuid_number房屋编号varchar(200)
fangwu_loudong楼栋varchar(200)
fangwu_danyuan单元varchar(200)
fangwu_fanghao房号varchar(200)
fangwu_content房屋备注text
insert_time添加时间timestamp
create_time创建时间timestamp

表4.3 收费表

字段注释类型
id (主键)主键int(11)
yonghu_id用户int(11)
shoufei_uuid_number收费编号varchar(200)
shoufei_name收费名称varchar(200)
shoufei_types收费类型int(11)
shoufei_jine收费金额decimal(10,2)
shoufei_content收费详情text
jiaofei_types是否缴费int(11)
insert_time添加时间timestamp
create_time创建时间timestamp

表4.4 停车位表

字段注释类型
id (主键)主键int(11)
yonghu_id用户int(11)
tingchewei_uuid_number停车位编号varchar(200)
tingchewei_address停车位位置varchar(200)
tingchewei_content停车位备注text
insert_time添加时间timestamp
create_time创建时间timestamp

表4.5 投诉表

字段注释类型
id (主键)主键int(11)
yonghu_id用户int(11)
tousu_uuid_number投诉编号varchar(200)
tousu_name投诉名称varchar(200)
tousu_types投诉类型int(11)
tousu_content投诉详情text
chuli_types是否处理int(11)
chuli_content处理结果text
insert_time投诉时间timestamp
create_time创建时间timestamp

表4.6 管理员表

字段注释类型
id (主键)主键bigint(20)
username用户名varchar(100)
password密码varchar(100)
role角色varchar(100)
addtime新增时间timestamp

表4.7 用户表

字段注释类型
id (主键)主键int(11)
username账户varchar(200)
password密码varchar(200)
yonghu_name用户姓名varchar(200)
yonghu_phone用户手机号varchar(200)
yonghu_id_number用户身份证号varchar(200)
yonghu_photo用户头像varchar(200)
sex_types性别int(11)
yonghu_email电子邮箱varchar(200)
create_time创建时间timestamp

打开新的 phpMyAdmin 窗口

第五章 系统实现

程序开发人员对功能具体实现后,都要描述自己编写的功能实现,一般都通过文字描述功能,实现用图片截图的形式出现,通过这样的设定,可以让更多得人明白系统的实现结果,达到更容易理解程序操作的目的。

5.1 管理员功能实现

5.1.1 房屋管理

管理员点击导航栏的房屋管理链接就进入房屋管理界面。房屋管理界面如图5.1所示。本功能允许管理员对房屋的楼栋,单元,房屋编号等信息进行添加,或修改有错误数据的房屋信息。

图5.1 房屋管理界面

5.1.2 停车位管理

管理员点击导航栏的停车位管理链接就进入停车位管理界面。停车位管理界面如图5.2所示。本功能允许管理员添加停车位的位置,停车位编号,用户姓名等信息,可以修改停车位信息。

图5.2 停车位管理界面

5.1.3 收费管理

管理员点击导航栏的收费管理链接就进入收费管理界面。收费管理界面如图5.3所示。本功能允许管理员添加收费金额,收费编号,收费名称,用户姓名等信息,可以对已经缴费的用户设置已缴费状态,管理员也能修改收费信息。

图5.3 收费管理界面

5.1.4 投诉管理

管理员点击导航栏的投诉管理链接就进入投诉管理界面。投诉管理界面如图5.4所示。投诉信息需要管理员查看和处理,未处理的投诉信息显示为待处理状态,已经处理的投诉信息显示为已处理状态,管理员也能删除投诉信息。

图5.4 投诉管理界面

5.2 用户功能实现

5.2.1 报修管理

用户点击导航栏的报修管理链接就进入报修管理界面。报修管理界面如图5.5所示。本功能允许用户添加报修信息,对报修的类型,报修名称等信息进行登记,用户提交报修信息之后,就需要等待管理员的处理。

图5.5 报修管理界面

5.2.2 投诉管理

用户点击导航栏的投诉管理链接就进入投诉管理界面。投诉管理界面如图5.6所示。本功能允许用户添加投诉信息,包括投诉名称,投诉类型等信息,提交投诉信息之后,用户只需等待管理员处理。

图5.6 投诉管理界面

5.2.3 收费查看

用户点击导航栏的收费查看链接就进入收费查看界面。收费查看界面如图5.7所示。本功能允许用户查询收费信息,查看收费名称,收费金额以及是否缴费等信息。

图5.7 收费查看界面

5.2.4 停车位查看

用户点击导航栏的停车位查看链接就进入停车位查看界面。停车位查看界面如图5.8所示。本功能允许用户查询停车位信息,查看停车位位置,停车位编号等信息。

图5.8 停车位查看界面

CommonServiceImpl.java

package com.service.impl;


import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.dao.CommonDao;
import com.service.CommonService;


/**
 * 系统用户
 * @author
 * @date
 */
@Service("commonService")
public class CommonServiceImpl implements CommonService {
	
	@Autowired
	private CommonDao commonDao;

	@Override
	public List<String> getOption(Map<String, Object> params) {
		return commonDao.getOption(params);
	}
	
	@Override
	public Map<String, Object> getFollowByOption(Map<String, Object> params) {
		return commonDao.getFollowByOption(params);
	}


	/**
	 tableName 查询表
	 condition1 条件1
	 condition1Value 条件1值
	 average 计算平均评分
	 * */
	public Map<String, Object> queryScore(Map<String, Object> params){
		return commonDao.queryScore(params);
	}
	
	@Override
	public void sh(Map<String, Object> params) {
		commonDao.sh(params); 
	}

	@Override
	public int remindCount(Map<String, Object> params) {
		return commonDao.remindCount(params);
	}

	@Override
	public Map<String, Object> selectCal(Map<String, Object> params) {
		return commonDao.selectCal(params);
	}
	
	@Override
	public List<Map<String, Object>> selectGroup(Map<String, Object> params) {
		return commonDao.selectGroup(params);
	}
	
	@Override
	public List<Map<String, Object>> selectValue(Map<String, Object> params) {
		return commonDao.selectValue(params);
	}

	@Override
	public List<Map<String, Object>> chartBoth(Map<String, Object> params) {
		return commonDao.chartBoth(params);
	}

	@Override
	public List<Map<String, Object>> chartOne(Map<String, Object> params) {
		return commonDao.chartOne(params);
	}


	/**
	 * 新的级联字典表的  分组求和统计
	 * @param params
	 * @return
	 */
	@Override
	public List<Map<String, Object>> newSelectGroupSum(Map<String, Object> params) {
		return commonDao.newSelectGroupSum(params);
	}


	/**
	 * 新的级联字典表的  分组条数统计
	 * @param params
	 * @return
	 */
	@Override
	public List<Map<String, Object>> newSelectGroupCount(Map<String, Object> params) {
		return commonDao.newSelectGroupCount(params);
	}

	/**
	 * 当前表的日期分组求和
	 * @param params
	 * @return
	 */
	@Override
	public List<Map<String, Object>> newSelectDateGroupSum(Map<String, Object> params) {
		return commonDao.newSelectDateGroupSum(params);
	}


	/**
	 * 查询字典表的分组统计总条数
	 * @param params
	 * @return
	 */
	@Override
	public List<Map<String, Object>> newSelectDateGroupCount(Map<String, Object> params) {
		return commonDao.newSelectDateGroupCount(params);
	}

	@Override
	public int plusCloumNumber(Map<String, Object> params) {
		return commonDao.plusCloumNumber(params);
	}
	@Override
	public int reduceCloumNumber(Map<String, Object> params) {
		return commonDao.reduceCloumNumber(params);
	}
	@Override
	public int updateCloumValue(Map<String, Object> params) {
		return commonDao.updateCloumValue(params);
	}

/**
 * 饼状图
 * -- 饼状图  查询当前表
 -- 				查询字典表【月】
 -- 				 统计   -- 查询某个月的每个类型的订单销售数量
 -- 				 求和   -- 查询某个月的每个类型的订单销售额
 -- 				查询某个字符串【月】
 -- 				 统计   -- 查询某个月的每个员工的订单销售数量
 -- 				 求和   -- 查询某个月的每个员工的订单销售额
 -- 				查询时间【年】
 -- 				 统计 	-- 查询每个月的订单销售数量
 -- 				 求和 	-- 查询每个月的订单销售额
 -- 饼状图  查询级联表
 -- 				查询字典表
 -- 				 统计  	-- 查询某个月的每个类型的订单销售数量
 -- 				 求和   -- 查询某个月的每个类型的订单销售额
 -- 				查询某个字符串
 -- 				 统计   -- 查询某个月的每个员工的订单销售数量
 -- 				 求和   -- 查询某个月的每个员工的订单销售额
 -- 				查询时间
 -- 				 统计 	-- 统计每个月的订单销售数量
 -- 				 求和 	-- 查询每个月的订单销售额
 */


/**
 * 柱状图
 -- 柱状图  查询当前表
 --             某个【年,月】
 -- 			 当前表 2 级联表 1
 -- 						统计
 --   						【日期,字符串,下拉框】
 -- 						求和
 --   						【日期,字符串,下拉框】
 -- 柱状图  查询级联表
 -- 					某个【年,月】
 -- 						统计
 --   						【日期,字符串,下拉框】
 -- 						求和
 --   						【日期,字符串,下拉框】
 */
	/**
	 * 柱状图求和
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> barSum(Map<String, Object> params){
		return commonDao.barSum(params);
	}

	/**
	 * 柱状图统计
	 * @param params
	 * @return
	 */
	public List<Map<String, Object>> barCount(Map<String, Object> params){
		return commonDao.barCount(params);
	}

}

ConfigController.java

package com.controller;


import java.util.Arrays;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
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.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.annotation.IgnoreAuth;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.entity.ConfigEntity;
import com.service.ConfigService;
import com.utils.PageUtils;
import com.utils.R;
import com.utils.ValidatorUtils;

/**
 * 登录相关
 */
@RequestMapping("config")
@RestController
public class ConfigController{
	
	@Autowired
	private ConfigService configService;

	/**
     * 列表
     */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params,ConfigEntity config){
        EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
    	PageUtils page = configService.queryPage(params);
        return R.ok().put("data", page);
    }
    
	/**
     * 列表
     */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params,ConfigEntity config){
        EntityWrapper<ConfigEntity> ew = new EntityWrapper<ConfigEntity>();
    	PageUtils page = configService.queryPage(params);
        return R.ok().put("data", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") String id){
        ConfigEntity config = configService.selectById(id);
        return R.ok().put("data", config);
    }
    
    /**
     * 详情
     */
    @IgnoreAuth
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") String id){
        ConfigEntity config = configService.selectById(id);
        return R.ok().put("data", config);
    }
    
    /**
     * 根据name获取信息
     */
    @RequestMapping("/info")
    public R infoByName(@RequestParam String name){
        ConfigEntity config = configService.selectOne(new EntityWrapper<ConfigEntity>().eq("name", "faceFile"));
        return R.ok().put("data", config);
    }
    
    /**
     * 保存
     */
    @PostMapping("/save")
    public R save(@RequestBody ConfigEntity config){
//    	ValidatorUtils.validateEntity(config);
    	configService.insert(config);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody ConfigEntity config){
//        ValidatorUtils.validateEntity(config);
        configService.updateById(config);//全部更新
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Long[] ids){
    	configService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }
}

YonghuController.java

package com.controller;

import java.io.File;
import java.math.BigDecimal;
import java.net.URL;
import java.text.SimpleDateFormat;
import com.alibaba.fastjson.JSONObject;
import java.util.*;
import org.springframework.beans.BeanUtils;
import javax.servlet.http.HttpServletRequest;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import com.service.TokenService;
import com.utils.*;
import java.lang.reflect.InvocationTargetException;

import com.service.DictionaryService;
import org.apache.commons.lang3.StringUtils;
import com.annotation.IgnoreAuth;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.entity.*;
import com.entity.view.*;
import com.service.*;
import com.utils.PageUtils;
import com.utils.R;
import com.alibaba.fastjson.*;

/**
 * 用户
 * 后端接口
 * @author
 * @email
*/
@RestController
@Controller
@RequestMapping("/yonghu")
public class YonghuController {
    private static final Logger logger = LoggerFactory.getLogger(YonghuController.class);

    @Autowired
    private YonghuService yonghuService;


    @Autowired
    private TokenService tokenService;
    @Autowired
    private DictionaryService dictionaryService;

    //级联表service



    /**
    * 后端列表
    */
    @RequestMapping("/page")
    public R page(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永不会进入");
        else if("用户".equals(role))
            params.put("yonghuId",request.getSession().getAttribute("userId"));
        if(params.get("orderBy")==null || params.get("orderBy")==""){
            params.put("orderBy","id");
        }
        PageUtils page = yonghuService.queryPage(params);

        //字典表数据转换
        List<YonghuView> list =(List<YonghuView>)page.getList();
        for(YonghuView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        return R.ok().put("data", page);
    }

    /**
    * 后端详情
    */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        YonghuEntity yonghu = yonghuService.selectById(id);
        if(yonghu !=null){
            //entity转view
            YonghuView view = new YonghuView();
            BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

    /**
    * 后端保存
    */
    @RequestMapping("/save")
    public R save(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
        logger.debug("save方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
        if(false)
            return R.error(511,"永远不会进入");

        Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
            .eq("username", yonghu.getUsername())
            .or()
            .eq("yonghu_phone", yonghu.getYonghuPhone())
            .or()
            .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
        if(yonghuEntity==null){
            yonghu.setCreateTime(new Date());
            yonghu.setPassword("123456");
            yonghuService.insert(yonghu);
            return R.ok();
        }else {
            return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody YonghuEntity yonghu, HttpServletRequest request){
        logger.debug("update方法:,,Controller:{},,yonghu:{}",this.getClass().getName(),yonghu.toString());

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
        //根据字段查询是否有相同数据
        Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
            .notIn("id",yonghu.getId())
            .andNew()
            .eq("username", yonghu.getUsername())
            .or()
            .eq("yonghu_phone", yonghu.getYonghuPhone())
            .or()
            .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
        if("".equals(yonghu.getYonghuPhoto()) || "null".equals(yonghu.getYonghuPhoto())){
                yonghu.setYonghuPhoto(null);
        }
        if(yonghuEntity==null){
            yonghuService.updateById(yonghu);//根据id更新
            return R.ok();
        }else {
            return R.error(511,"账户或者用户手机号或者用户身份证号已经被使用");
        }
    }



    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        yonghuService.deleteBatchIds(Arrays.asList(ids));
        return R.ok();
    }


    /**
     * 批量上传
     */
    @RequestMapping("/batchInsert")
    public R save( String fileName, HttpServletRequest request){
        logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
        Integer yonghuId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        try {
            List<YonghuEntity> yonghuList = new ArrayList<>();//上传的东西
            Map<String, List<String>> seachFields= new HashMap<>();//要查询的字段
            Date date = new Date();
            int lastIndexOf = fileName.lastIndexOf(".");
            if(lastIndexOf == -1){
                return R.error(511,"该文件没有后缀");
            }else{
                String suffix = fileName.substring(lastIndexOf);
                if(!".xls".equals(suffix)){
                    return R.error(511,"只支持后缀为xls的excel文件");
                }else{
                    URL resource = this.getClass().getClassLoader().getResource("../../upload/" + fileName);//获取文件路径
                    File file = new File(resource.getFile());
                    if(!file.exists()){
                        return R.error(511,"找不到上传文件,请联系管理员");
                    }else{
                        List<List<String>> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                        dataList.remove(0);//删除第一行,因为第一行是提示
                        for(List<String> data:dataList){
                            //循环
                            YonghuEntity yonghuEntity = new YonghuEntity();
//                            yonghuEntity.setUsername(data.get(0));                    //账户 要改的
//                            //yonghuEntity.setPassword("123456");//密码
//                            yonghuEntity.setYonghuName(data.get(0));                    //用户姓名 要改的
//                            yonghuEntity.setYonghuPhone(data.get(0));                    //用户手机号 要改的
//                            yonghuEntity.setYonghuIdNumber(data.get(0));                    //用户身份证号 要改的
//                            yonghuEntity.setYonghuPhoto("");//详情和图片
//                            yonghuEntity.setSexTypes(Integer.valueOf(data.get(0)));   //性别 要改的
//                            yonghuEntity.setYonghuEmail(data.get(0));                    //电子邮箱 要改的
//                            yonghuEntity.setCreateTime(date);//时间
                            yonghuList.add(yonghuEntity);


                            //把要查询是否重复的字段放入map中
                                //账户
                                if(seachFields.containsKey("username")){
                                    List<String> username = seachFields.get("username");
                                    username.add(data.get(0));//要改的
                                }else{
                                    List<String> username = new ArrayList<>();
                                    username.add(data.get(0));//要改的
                                    seachFields.put("username",username);
                                }
                                //用户手机号
                                if(seachFields.containsKey("yonghuPhone")){
                                    List<String> yonghuPhone = seachFields.get("yonghuPhone");
                                    yonghuPhone.add(data.get(0));//要改的
                                }else{
                                    List<String> yonghuPhone = new ArrayList<>();
                                    yonghuPhone.add(data.get(0));//要改的
                                    seachFields.put("yonghuPhone",yonghuPhone);
                                }
                                //用户身份证号
                                if(seachFields.containsKey("yonghuIdNumber")){
                                    List<String> yonghuIdNumber = seachFields.get("yonghuIdNumber");
                                    yonghuIdNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> yonghuIdNumber = new ArrayList<>();
                                    yonghuIdNumber.add(data.get(0));//要改的
                                    seachFields.put("yonghuIdNumber",yonghuIdNumber);
                                }
                        }

                        //查询是否重复
                         //账户
                        List<YonghuEntity> yonghuEntities_username = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("username", seachFields.get("username")));
                        if(yonghuEntities_username.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(YonghuEntity s:yonghuEntities_username){
                                repeatFields.add(s.getUsername());
                            }
                            return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                         //用户手机号
                        List<YonghuEntity> yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_phone", seachFields.get("yonghuPhone")));
                        if(yonghuEntities_yonghuPhone.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(YonghuEntity s:yonghuEntities_yonghuPhone){
                                repeatFields.add(s.getYonghuPhone());
                            }
                            return R.error(511,"数据库的该表中的 [用户手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                         //用户身份证号
                        List<YonghuEntity> yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper<YonghuEntity>().in("yonghu_id_number", seachFields.get("yonghuIdNumber")));
                        if(yonghuEntities_yonghuIdNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(YonghuEntity s:yonghuEntities_yonghuIdNumber){
                                repeatFields.add(s.getYonghuIdNumber());
                            }
                            return R.error(511,"数据库的该表中的 [用户身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        yonghuService.insertBatch(yonghuList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }


    /**
    * 登录
    */
    @IgnoreAuth
    @RequestMapping(value = "/login")
    public R login(String username, String password, String captcha, HttpServletRequest request) {
        YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
        if(yonghu==null || !yonghu.getPassword().equals(password))
            return R.error("账号或密码不正确");
        //  // 获取监听器中的字典表
        // ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
        // Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
        // Map<Integer, String> role_types = dictionaryMap.get("role_types");
        // role_types.get(.getRoleTypes());
        String token = tokenService.generateToken(yonghu.getId(),username, "yonghu", "用户");
        R r = R.ok();
        r.put("token", token);
        r.put("role","用户");
        r.put("username",yonghu.getYonghuName());
        r.put("tableName","yonghu");
        r.put("userId",yonghu.getId());
        return r;
    }

    /**
    * 注册
    */
    @IgnoreAuth
    @PostMapping(value = "/register")
    public R register(@RequestBody YonghuEntity yonghu){
//    	ValidatorUtils.validateEntity(user);
        Wrapper<YonghuEntity> queryWrapper = new EntityWrapper<YonghuEntity>()
            .eq("username", yonghu.getUsername())
            .or()
            .eq("yonghu_phone", yonghu.getYonghuPhone())
            .or()
            .eq("yonghu_id_number", yonghu.getYonghuIdNumber())
            ;
        YonghuEntity yonghuEntity = yonghuService.selectOne(queryWrapper);
        if(yonghuEntity != null)
            return R.error("账户或者用户手机号或者用户身份证号已经被使用");
        yonghu.setCreateTime(new Date());
        yonghuService.insert(yonghu);
        return R.ok();
    }

    /**
     * 重置密码
     */
    @GetMapping(value = "/resetPassword")
    public R resetPassword(Integer  id){
        YonghuEntity yonghu = new YonghuEntity();
        yonghu.setPassword("123456");
        yonghu.setId(id);
        yonghuService.updateById(yonghu);
        return R.ok();
    }


    /**
     * 忘记密码
     */
    @IgnoreAuth
    @RequestMapping(value = "/resetPass")
    public R resetPass(String username, HttpServletRequest request) {
        YonghuEntity yonghu = yonghuService.selectOne(new EntityWrapper<YonghuEntity>().eq("username", username));
        if(yonghu!=null){
            yonghu.setPassword("123456");
            boolean b = yonghuService.updateById(yonghu);
            if(!b){
               return R.error();
            }
        }else{
           return R.error("账号不存在");
        }
        return R.ok();
    }


    /**
    * 获取用户的session用户信息
    */
    @RequestMapping("/session")
    public R getCurrYonghu(HttpServletRequest request){
        Integer id = (Integer)request.getSession().getAttribute("userId");
        YonghuEntity yonghu = yonghuService.selectById(id);
        if(yonghu !=null){
            //entity转view
            YonghuView view = new YonghuView();
            BeanUtils.copyProperties( yonghu , view );//把实体数据重构到view中

            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }
    }


    /**
    * 退出
    */
    @GetMapping(value = "logout")
    public R logout(HttpServletRequest request) {
        request.getSession().invalidate();
        return R.ok("退出成功");
    }





}

list.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="zh-cn">


<head>
    <%@ include file="../../static/head.jsp" %>
    <!-- font-awesome -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/css/font-awesome.min.css">

    <!-- layui -->
    <link rel="stylesheet" href="${pageContext.request.contextPath}/resources/layui/css/layui.css">
    <script src="${pageContext.request.contextPath}/resources/layui/layui.js"></script>
</head>
<style>

</style>
<body>
<!-- Pre Loader -->
<div class="loading">
    <div class="spinner">
        <div class="double-bounce1"></div>
        <div class="double-bounce2"></div>
    </div>
</div>
<!--/Pre Loader -->
<div class="wrapper">
    <!-- Page Content -->
    <div id="content">
        <!-- Top Navigation -->
        <%@ include file="../../static/topNav.jsp" %>
        <!-- Menu -->
        <div class="container menu-nav">
            <nav class="navbar navbar-expand-lg lochana-bg text-white">
                <button class="navbar-toggler" type="button" data-toggle="collapse"
                        data-target="#navbarSupportedContent"
                        aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
                    <span class="ti-menu text-white"></span>
                </button>
                <div class="collapse navbar-collapse" id="navbarSupportedContent">
                    <ul id="navUl" class="navbar-nav mr-auto">
                    </ul>
                </div>
            </nav>
        </div>
        <!-- /Menu -->
        <!-- Breadcrumb -->
        <!-- Page Title -->
        <div class="container mt-0">
            <div class="row breadcrumb-bar">
                <div class="col-md-6">
                    <h3 class="block-title">报修类型管理</h3>
                </div>
                <div class="col-md-6">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item">
                            <a href="${pageContext.request.contextPath}/index.jsp">
                                <span class="ti-home"></span>
                            </a>
                        </li>
                        <li class="breadcrumb-item">报修类型管理</li>
                        <li class="breadcrumb-item active">报修类型列表</li>
                    </ol>
                </div>
            </div>
        </div>
        <!-- /Page Title -->

        <!-- /Breadcrumb -->
        <!-- Main Content -->
        <div class="container">

            <div class="row">
                <!-- Widget Item -->
                <div class="col-md-12">
                    <div class="widget-area-2 lochana-box-shadow">
                        <h3 class="widget-title">报修类型列表</h3>
                        <div class="table-responsive mb-3">
                            <div class="col-sm-12">
                                <div class="layui-inline" style="margin-bottom: 10px;">
                                    报修类型名称
                                    <div class="layui-input-inline">
                                        <input type="text" id="indexNameSearch" style="width: 140px;" class="form-control form-control-sm"
                                               placeholder="报修类型名称" aria-controls="tableId">
                                    </div>
                                </div>

                                <div class="layui-inline" style="margin-left: 30px;margin-bottom: 10px;">
                                    <button onclick="search()" type="button" class="btn btn-primary">查询</button>
                                    <button onclick="add()" type="button" class="btn btn-success 新增">添加</button>
                                    <button onclick="deleteMore()" type="button" class="btn btn-danger 删除">批量删除</button>
                                </div>
                            </div>
                            <table id="tableId" class="table table-bordered table-striped">
                                <thead>
                                <tr>
                                    <th class="no-sort" style="min-width: 35px;">
                                        <div class="custom-control custom-checkbox">
                                            <input class="custom-control-input" type="checkbox" id="select-all"
                                                   onclick="chooseAll()">
                                            <label class="custom-control-label" for="select-all"></label>
                                        </div>
                                    </th>

                                    <th >报修类型编码</th>
                                    <th >报修类型名称</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody id="thisTbody">
                                </tbody>
                            </table>
                            <div class="col-md-6 col-sm-3">
                                <div class="dataTables_length" id="tableId_length">

                                    <select name="tableId_length" aria-controls="tableId" id="selectPageSize"
                                            onchange="changePageSize()">
                                        <option value="10">10</option>
                                        <option value="25">25</option>
                                        <option value="50">50</option>
                                        <option value="100">100</option>
                                    </select>
                                    条 每页

                                </div>
                            </div>
                            <nav aria-label="Page navigation example">
                                <ul class="pagination justify-content-end">
                                    <li class="page-item" id="tableId_previous" onclick="pageNumChange('pre')">
                                        <a class="page-link" href="#" tabindex="-1">上一页</a>
                                    </li>

                                    <li class="page-item" id="tableId_next" onclick="pageNumChange('next')">
                                        <a class="page-link" href="#">下一页</a>
                                    </li>
                                </ul>
                            </nav>
                        </div>
                    </div>
                </div>
                <!-- /Widget Item -->
            </div>
        </div>
        <!-- /Main Content -->

    </div>
    <!-- /Page Content -->
</div>
<!-- Back to Top -->
<a id="back-to-top" href="#" class="back-to-top">
    <span class="ti-angle-up"></span>
</a>
<!-- /Back to Top -->
<%@ include file="../../static/foot.jsp" %>
<script language="javascript" type="text/javascript"
        src="${pageContext.request.contextPath}/resources/My97DatePicker/WdatePicker.js"></script>

<script>
    <%@ include file="../../utils/menu.jsp"%>
            <%@ include file="../../static/setMenu.js"%>
            <%@ include file="../../utils/baseUrl.jsp"%>
            <%@ include file="../../static/getRoleButtons.js"%>
            <%@ include file="../../static/crossBtnControl.js"%>
    var tableName = "dictionaryBaoxiu";
    var pageType = "list";
    var searchForm = {key: ""};
    var pageIndex = 1;
    var pageSize = 10;
    var totalPage = 0;
    var dataList = [];
    var sortColumn = '';
    var sortOrder = '';
    var ids = [];
    var checkAll = false;



    function init() {
        // 满足条件渲染提醒接口
    }

    // 改变每页记录条数
    function changePageSize() {
        var selection = document.getElementById('selectPageSize');
        var index = selection.selectedIndex;
        pageSize = selection.options[index].value;
        getDataList();
    }



    // 查询
    function search() {
        searchForm = {key: ""};

                     
        //编码名字
        var indexNameSearchInput = $('#indexNameSearch');
        if( indexNameSearchInput != null){
            if (indexNameSearchInput.val() != null && indexNameSearchInput.val() != '') {
                searchForm.indexName = $('#indexNameSearch').val();
            }
        }
                getDataList();
    }

    // 获取数据列表
    function getDataList() {
        http("dictionary/page", "GET", {
            page: pageIndex,
            limit: pageSize,
            sort: sortColumn,
            order: sortOrder,
            //本表的
            dicCode: "baoxiu_types",//编码名字
            dicName: "报修类型",//汉字名字
            indexName:searchForm.indexName,
            //级联表的

        }, (res) => {
            if(res.code == 0) {
                clear();
                $("#thisTbody").html("");
                dataList = res.data.list;
                totalPage = res.data.totalPage;
                for (var i = 0; i < dataList.length; i++) { //遍历一下表格数据  
                    var trow = setDataRow(dataList[i], i); //定义一个方法,返回tr数据 
                    $('#thisTbody').append(trow);
                }
                pagination(); //渲染翻页组件
                getRoleButtons();// 权限按钮控制
            }
        });
    }

    // 渲染表格数据
    function setDataRow(item, number) {
        //创建行 
        var row = document.createElement('tr');
        row.setAttribute('class', 'useOnce');
        //创建勾选框
        var checkbox = document.createElement('td');
        var checkboxDiv = document.createElement('div');
        checkboxDiv.setAttribute("class", "custom-control custom-checkbox");
        var checkboxInput = document.createElement('input');
        checkboxInput.setAttribute("class", "custom-control-input");
        checkboxInput.setAttribute("type", "checkbox");
        checkboxInput.setAttribute('name', 'chk');
        checkboxInput.setAttribute('value', item.id);
        checkboxInput.setAttribute("id", number);
        checkboxDiv.appendChild(checkboxInput);
        var checkboxLabel = document.createElement('label');
        checkboxLabel.setAttribute("class", "custom-control-label");
        checkboxLabel.setAttribute("for", number);
        checkboxDiv.appendChild(checkboxLabel);
        checkbox.appendChild(checkboxDiv);
        row.appendChild(checkbox)


        //编码
        var codeIndexCell = document.createElement('td');
        codeIndexCell.innerHTML = item.codeIndex;
        row.appendChild(codeIndexCell);

        //类型
        var indexNameCell = document.createElement('td');
        indexNameCell.innerHTML = item.indexName;
        row.appendChild(indexNameCell);



        //每行按钮
        var btnGroup = document.createElement('td');

        //详情按钮
        var detailBtn = document.createElement('button');
        var detailAttr = "detail(" + item.id + ')';
        detailBtn.setAttribute("type", "button");
        detailBtn.setAttribute("class", "btn btn-info btn-sm 查看");
        detailBtn.setAttribute("onclick", detailAttr);
        detailBtn.innerHTML = "查看"
        btnGroup.appendChild(detailBtn)
        //修改按钮
        var editBtn = document.createElement('button');
        var editAttr = 'edit(' + item.id + ')';
        editBtn.setAttribute("type", "button");
        editBtn.setAttribute("class", "btn btn-warning btn-sm 修改");
        editBtn.setAttribute("onclick", editAttr);
        editBtn.innerHTML = "修改"
        btnGroup.appendChild(editBtn)
        //删除按钮
        var deleteBtn = document.createElement('button');
        var deleteAttr = 'remove(' + item.id + ')';
        deleteBtn.setAttribute("type", "button");
        deleteBtn.setAttribute("class", "btn btn-danger btn-sm 删除");
        deleteBtn.setAttribute("onclick", deleteAttr);
        deleteBtn.innerHTML = "删除"
        btnGroup.appendChild(deleteBtn)

        row.appendChild(btnGroup)
        return row;
    }


    // 翻页
    function pageNumChange(val) {
        if (val == 'pre') {
            pageIndex--;
        } else if (val == 'next') {
            pageIndex++;
        } else {
            pageIndex = val;
        }
        getDataList();
    }

    // 下载
    function download(url) {
        window.open(url);
    }

    // 渲染翻页组件
    function pagination() {
        var beginIndex = pageIndex;
        var endIndex = pageIndex;
        var point = 4;
        //计算页码
        for (var i = 0; i < 3; i++) {
            if (endIndex == totalPage) {
                break;
            }
            endIndex++;
            point--;
        }
        for (var i = 0; i < 3; i++) {
            if (beginIndex == 1) {
                break;
            }
            beginIndex--;
            point--;
        }
        if (point > 0) {
            while (point > 0) {
                if (endIndex == totalPage) {
                    break;
                }
                endIndex++;
                point--;
            }
            while (point > 0) {
                if (beginIndex == 1) {
                    break;
                }
                beginIndex--;
                point--
            }
        }
        // 是否显示 前一页 按钮
        if (pageIndex > 1) {
            $('#tableId_previous').show();
        } else {
            $('#tableId_previous').hide();
        }
        // 渲染页码按钮
        for (var i = beginIndex; i <= endIndex; i++) {
            var pageNum = document.createElement('li');
            pageNum.setAttribute('onclick', "pageNumChange(" + i + ")");
            if (pageIndex == i) {
                pageNum.setAttribute('class', 'paginate_button page-item active useOnce');
            } else {
                pageNum.setAttribute('class', 'paginate_button page-item useOnce');
            }
            var pageHref = document.createElement('a');
            pageHref.setAttribute('class', 'page-link');
            pageHref.setAttribute('href', '#');
            pageHref.setAttribute('aria-controls', 'tableId');
            pageHref.setAttribute('data-dt-idx', i);
            pageHref.setAttribute('tabindex', 0);
            pageHref.innerHTML = i;
            pageNum.appendChild(pageHref);
            $('#tableId_next').before(pageNum);
        }
        // 是否显示 下一页 按钮
        if (pageIndex < totalPage) {
            $('#tableId_next').show();
            $('#tableId_next a').attr('data-dt-idx', endIndex + 1);
        } else {
            $('#tableId_next').hide();
        }
        var pageNumInfo = "当前第 " + pageIndex + " 页,共 " + totalPage + " 页";
        $('#tableId_info').html(pageNumInfo);
    }

    // 跳转到指定页
    function toThatPage() {
        //var index = document.getElementById('pageIndexInput').value;
        if (index < 0 || index > totalPage) {
            alert('请输入正确的页码');
        } else {
            pageNumChange(index);
        }
    }

    // 全选/全不选
    function chooseAll() {
        checkAll = !checkAll;
        var boxs = document.getElementsByName("chk");
        for (var i = 0; i < boxs.length; i++) {
            boxs[i].checked = checkAll;
        }
    }

    // 批量删除
    function deleteMore() {
        ids = []
        var boxs = document.getElementsByName("chk");
        for (var i = 0; i < boxs.length; i++) {
            if (boxs[i].checked) {
                ids.push(boxs[i].value)
            }
        }
        if (ids.length == 0) {
            alert('请勾选要删除的记录');
        } else {
            remove(ids);
        }
    }

    // 删除
    function remove(id) {
        var mymessage = confirm("真的要删除吗?");
        if (mymessage == true) {
            var paramArray = [];
            if (id == ids) {
                paramArray = id;
            } else {
                paramArray.push(id);
            }
            httpJson("dictionary/delete", "POST", paramArray, (res) => {
                if(res.code == 0){
                    getDataList();
                    alert('删除成功');
                }
            });
        } else {
            alert("已取消操作");
        }
    }

    // 用户登出
    <%@ include file="../../static/logout.jsp"%>

    //修改
    function edit(id) {
        window.sessionStorage.setItem('updateId', id)
        window.location.href = "add-or-update.jsp"
    }

    //清除会重复渲染的节点
    function clear() {
        var elements = document.getElementsByClassName('useOnce');
        for (var i = elements.length - 1; i >= 0; i--) {
            elements[i].parentNode.removeChild(elements[i]);
        }
    }

    //添加
    function add() {
        window.sessionStorage.setItem("adddictionary", "adddictionary");
        window.location.href = "add-or-update.jsp"
    }

    //报表
    function graph() {
        window.location.href = "graph.jsp"
    }

    // 查看详情
    function detail(id) {
        window.sessionStorage.setItem("updateId", id);
        window.location.href = "info.jsp";
    }


    $(document).ready(function () {
        //激活翻页按钮
        $('#tableId_previous').attr('class', 'paginate_button page-item previous')
        $('#tableId_next').attr('class', 'paginate_button page-item next')
        //隐藏原生搜索框
        $('#tableId_filter').hide()
        //设置右上角用户名
        $('.dropdown-menu h5').html(window.sessionStorage.getItem('username'))
        //设置项目名
        $('.sidebar-header h3 a').html(projectName)
        setMenu();
        init();

        getDataList();
                                                             
                        
    <%@ include file="../../static/myInfo.js"%>
    });
</script>
</body>

</html>


声明

本博客适用于广泛的学术和教育用途,包括但不限于个人学习、开发设计,产品设计。仅供学习参考,旨在为读者提供深入理解和学术研究的材料。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值