ToB企服应用市场:ToB评测及商务社交产业平台
标题:
基于SpringBoot+Vue的通例应急物资管理系统
[打印本页]
作者:
老婆出轨
时间:
2024-8-17 06:48
标题:
基于SpringBoot+Vue的通例应急物资管理系统
@TOC
springboot156基于SpringBoot+Vue的通例应急物资管理系统
第一章 绪论**
1.1研究配景
近年来,第三产业发展非常迅速,诸如盘算机服务、旅游、娱乐、体育等服务行业,对整个社会的经济建设起到了极大地促进作用,这一点是毋庸置疑的。现下,国家也出台了一系列的政策来支持和鼓励第三服务产业的发展与美满,用以带动社会经济的发展[1]。所以,整体来说,国家是比力提倡发展第三方服务行业的。纵观盘算机领域的整个发展历程,从盘算机的诞生到如今,已经有几百年的汗青了,盘算机应用技术也逐步趋于成熟,并且相干的设计人员也在不断地对其进行改进和美满。再到如今,盘算机已经发展成为一个比力热门的行业了。在高校中,盘算机、人工智能等专业热度非常高,许多门生在选择专业的时间,大都优先考虑盘算机专业。在社会上,盘算机类行业也成为了比力受接待的行业,从在欣赏器中访问的网址,得手机上的各种应用步伐,再到大型的软件服务装备,基本上都离不开盘算机技术支持,以及硬件的支撑。
如今,互联网险些遍布于世界的各个角落,人工智能、大数据占据越来越紧张的地位,好比疫情期间,通过大数据技术进行筛查,确定哪些人员无接触史,哪些人员必要重点观察,由此可以在极短的时间内,以最快的速度对疫情进行防控。在这个大配景环境的推动下,本人通过学习Java语言、MySQL数据库、SSM框架等相干的盘算机技术,打好坚实的技术基础,方便后期对系统进行研发。而后再通过对系统进行分析,确定系统的总体功能需求,以及实现的大概性,方便接下来详细地设计相干的功能模块,最后乐成的研发了一款基于SpringBoot+Vue的通例应急物资管理系统。本系统改善了传统的管理模式,将原先的手工记录和管理信息,改进为使用盘算机存储和管理信息记录,极大地方便了工作人员对相干数据进行处理,为相干行业节省了不少的员工费用和管理开销,并且能够在较短的时间内相应用户的需求,这种便捷的操作,对于用户来说可以节省不少时间和精神,也省去了不少的麻烦,极大地方便了用户。
1.2研究意义
传统的信息管理模式,重要是以人力为主进行管理和控制,由工作人员负责登记用户信息,再通过对照之前的信息记录,确定是否给用户提供相干的使用需求,以及如何提供能让用户满意的使用需求。这种管理模式已经适应不了时代的变化了,正在不断地走下坡路,并且逐步被信息化管理模式所代替。所谓的信息化管理模式,是如今主流的一种管理模式,其通过与盘算机技术相联合的方式,对行业的整个工作模式和服务流程进行改进和美满。其重要通过使用盘算机等装备,将工作服务流程电子化,并且进行存储记录,用以进步行业整体的服务水平。联合盘算机技术,本人研发出一款基于SpringBoot+Vue的通例应急物资管理系统,采用电子化的方式对数据信息进行存储,便于工作人员对相干信息进行记录和管理,有利于进步相干行业的工作运营服从以及工作人员的管理速度,以此更好的满足用户的相干需求,终极达到提拔用户的使用感受的目标,由此可见设计和实现本系统具有紧张的意义和价值。
1.3国内外研究现状
1.3.1国外研究现状
美国是最先发展盘算机技术的众多国家之一,早在上个世纪,美国的盘算机技术就快速地发展起来,并且运用在军事、医院、学校、社会服务等场所。日本、德国等国家紧随厥后,不断地发展和美满盘算机技术,偏重将医疗、社会服务等领域与盘算机技术相联合[2]。而后随着社会的发展与进步,盘算机技术渐渐趋于成熟。许多发达国家在探索将盘算机技术应用于各行各业中时,从另一个角度来看,也在不断地推进相干行业的信息化管理历程,使得相干行业管理也变得更加网络化、信息化。有许多专家表示,可以联合使用图像处理软件、人工智能技术等相干工具,深度地分析通例应急物资管理系统,重要从简化运行操作,加设功能模块,美化系统界面,保障数据安全等方面,更深层次地提拔和优化系统,并且尽大概地在理想状态下做到及时的信息共享。
1.3.2国内研究现状
国内的盘算机技术的发展虽然晚于国外,尤其是美国、英国、德国等发达国家。但是我国的盘算机技术发展势头非常迅猛,近些年,也渐渐走向成熟和美满的阶段。如今,选择网上购物已经成为人们一样平常生活的一种常态趋势,固然这也离不开对于天猫、付出宝、微信等应用软件的使用[3]。许多企业联合使用了云盘算、人工智能等先进的盘算机技术,自主研发了行业相干的信息管理系统,盘算机技术渐渐趋于成熟,使用设计的功能渐渐趋于完备。联合盘算机技术,采用主流的B/S开辟结构模式开辟一款基于SpringBoot+Vue的通例应急物资管理系统。由此,本系统能够支持工作人员随时随地的通过使用欣赏器进行访问操作,支持随时随地对相干的通例应急物资信息进行管理,便于及时为用户提供一定的功能服务。并且所设计的系统基本上能够符合用户的客观使用需求,有利于充分协调相干行业的人力、财力、物力等资源,不断进步相干工作人员的管理质量和水平[4]。
1.4研究内容与方法
1.4.1研究内容
本文起首介绍了通例应急物资管理系统的研究配景与意义,其次介绍了系统的总体功能设计,接着将对系统规划好的总体功能拆分成了各个功能子模块,然后详细地对每一个小的功能子模块进行设计,最后介绍了展示设计好的功能模块以及测试结果。系统重要分为管理员脚色和用户脚色,具体的功能设计包括注册登录管理、用户信息管理、物资信息管理、物资运输管理等模块。注册登录管理功能是新用户在使用系统前,必要通过注册步骤,登记详细的信息资料,而后再通过输入正确的账号和暗码,乐成登录系统后,即可通过一系列的操作来满足自己的相干需求。用户信息管理功能是管理相干的用户信息资料,管理人员根据实际环境的必要,选择性的对用户信息记录进行更新处理。物资信息管理是管理相干的物资信息记录,保存详情的物资信息环境,方便及时相应用户的服务哀求。物资运输管理是管理相干的物资运输信息记录,方便相干人员及时查看物资运输信息,如果遇到异常的物资运输信息,可以及时对其进行处理,在较短的时间内解决题目,进步用户的使用体验。
1.4.2研究方法
本系统以B/S架构进行实现,通过使用idea工具编写相干的java代码,设计系统功能模块,再通过MySQL数据库管控数据资源,由此有利于对系统相干数据进行必要的管理和控制。系统设计的最关键的环节,则是必要通过SSM框架设计系统功能架构,再通过Tomcat服务器将系统发布到欣赏器上,以便相干用户的操作和使用。本系统的设计和实现促进了相干行业的信息化建设,有利于简化相干人员工作流程,进步工作服从,提拔工作幸福感。
1.5论文的构造结构
基于SpringBoot+Vue的通例应急物资管理系统的设计与实现的论文构造结构,大抵可以分为七个章节,具体的内容如下:
第一章为绪论,本章重要介绍了系统的配景、现状、方法等内容。根据研究配景与意义,介绍所要设计的系统的研究配景和理论依据,再通过国内外研究现状,相识当前相干的系统软件产物的实际研究环境,最后通过研究内容与方法,总体概括系统的整个开辟流程和实现步骤,为系统提供可靠的理论依据和技术支持。
第二章为相干技术介绍,本章重要介绍了开辟所使用的相干技术。本系统重要使用的开辟技术包括Java语言、SSM框架、MySQL数据库等,并且所使用的开辟模式为B/S架构。其中,Java语言具有跨平台性,可移植性高,可以支持在不同的欣赏器上运行本系统,MySQL数据库占用内存少,执行速度快,对于中小型系统的数据管理黑白常好的选择。
第三章为系统分析,系统分析阶段重要是对系统进行需求和可行性分析,规划系统的功能设计,判断系统实现的大概性。根据需求分析,确认使用者对系统的基本功能需求,再通过在经济、操作、法律上进行可行性分析,分析系统研发的实际意义和使用价值,系统性能的稳固性和功能操作的便捷性,以及乐成投入市场的大概性。
第四章为系统设计,本章重要介绍了系统的总体功能设计、数据库设计等内容。通过介绍系统的总体功能设计,规划设计出系统实际必要设计的功能模块,便于相干的技术人员后期设计系统的功能模块做好准备工作。再通过介绍数据库设计,便于设计出数据库能够存放和管控的数据表,有利于相干的设计人员管理必要的数据资源,维护和更新数据信息的安全。
第五章为系统实现,系统实现阶段重要是对物资信息管理、物资运输管理等功能模块进行论述。通过前面介绍的系统分析,功能及数据库设计等相干内容,详细地实现系统功能模块。这一过程就是系统的具体实现阶段,站在系统的整体设计角度出发,对系统的实现进行必要分析可知,这一阶段是极为紧张,直接关系到用户对系统的使用感受。
第六章为系统测试,本章重要是对测试相干的内容进行叙述。本系统重要使用功能测试的方法,查抄测验系统重要功能,测试所设计的系统功能可否正常使用,并且用户能够正常操作和使用,在系统运行过程中是否发生异常,如运行异常、数据异常、结果异常等,并且根据测试结果,给出相应的测试总结,由此得出相干结论,说明系统是否达到预期要求、设计目标。
第二章 开辟技术介绍
2.1 B/S架构
就软件开辟的现状而言,目前重要使用的系统开辟结构模式大抵可以分为C/S模式和B/S模式[5]。用户在使用基于C/S模式开辟的系统时,必须下载相应的客户端,即应用步伐,才能操作和使用软件系统的相干功能模块。从使用者的角度来看,由于下载和安装客户端的步骤比力繁琐,期间还必要确保下载网速的稳固性,以及安装步骤的正确性,进而增加了用户放弃使用该系统的大概性,由此可见C/S模式具有很大的局限性。
由于C/S模式适用于小范围的局域网,并且具有较好的通信服从,所以在从前系统规模很小的时代,重要使用C/S模式开辟系统。随着时代的发展以及社会的进步,C/S模式也越来越满足不了开辟者的设计必要,以及使用者的使用需求。当下,C/S模式已经满足不了实际的系统步伐设计要求,由此,B/S模式以C/S模式为基础而被提出,并且在近些年渐渐发展成为主流的开辟结构模式。在B/S模式下开辟的系统,不再必要用户下载和安装相应的应用步伐,直接通过使用欣赏器,输入正确的网站所在,以访问网站的形式实现系统的相干功能操作。这一特点对C/S模式下的开辟设计做出了极大的改进,固然,使用本系统的前提是确保账号和暗码是合法的。
2.2 Java语言
Java语言是一种将数据和操作方法封装成对象整体的步伐设计语言,它拥有着良好的技术体系结构。目前在市场上,很大一部分的应用系统重要使用Java语言进行开辟[6]。Java语言具有简朴易懂,操作方便,结实性强等长处,开辟人员能够在短时间内理解和掌握Java语言,并将其运用到具体的系统开辟过程中。针对于系统内存管理题目,Java语言为解决这类题目,内部提供了垃圾接纳机制。为了极大地简化了开辟编程的难易水平,Java语言还将C语言中的指针,改进成了引用,所以受到了很多开辟人员的喜爱。Java语言还具有跨平台性的特点,意味着它的可移植性非常高,这一特点有利于开辟人员更新和维护相干代码,由它所开辟的系统可以支持在不同的欣赏器中打开。因为使用Java开辟的系统兼容性较强,代码通用性较高,为了后期方便对系统进行美满和维护,所以本人终极选择使用Java语言开辟本系统。
2.3 SSM框架
SSM框架重要由Spring、SpringMVC、MyBatis这三个框架所集成的,是如今比力流行的一种Java开辟框架,能够适用于大中型的应用步伐的设计和搭建。Spring是前几十年前鼓起的一种轻量级的、开源的Java开辟框架,使用它可以解决相干的系统对象创建和对象依赖题目,并且也可以将高耦合的系统分解为低耦合的多个功能模块,方便对系统模块进行明确的分工,对功能代码进行理解和修改,这就极大地减轻了设计人员的开辟压力[7]。SpringMVC框架是基于Spring框架而被提出的,它以MVC三层架构为焦点,对Spring的相干技术进行了整合,重要针对于Web端进行技术架构,通过对相干哀求消息进行细化处理,对相干的用户哀求做出一定的相应处理。MyBatis框架是一种开源的Java持久层框架,它重要是通过改进手动设置参数和获取结果记录的方式,通过支持对数据库进行存储过程、高级映射等处理,使得数据库的操作更加定制化、透明化,因此降低了数据库访问的复杂性,进步了开辟的工作服从。
2.4 vue框架
vue框架是一种用于构建相干的用户使用界面的渐进式框架,由此便可以控制某个系统页面的标签,大概控制整个页面的不同标签,又大概控制整个前端项目标不同标签[8]。使用vue框架编写的代码,不再必要手动更新相干的控件的变量值,当与其绑定的变量值发生改变时,相干的组件会自动地进行更新。vue框架重要通过自底向上的方式对系统的用户界面进行设计和创建,而且vue框架只关注图层内容,如此一来,其不仅能够为各种支持的类库的比力复杂繁琐的单页提供相应的驱动,还能够整合第三方库大概相干的项目。因为vue框架的语法界说简朴,比力容易学习和掌握,所以相干的开辟技术人员大多选择使用vue框架编写相干的前端页面显示代码,创建相应的系统网站页面。这样的页面设计便于用户查询相干的数据信息,理解系统的操作和使用。
2.5 MySQL数据库
MySQL数据库是一种使用频繁的关系型数据库。因为其具有开源免费、占用内存少、安装简朴、操作便捷、使用灵活等长处,所以经常被运用于中小型的系统开辟中[9]。MySQL数据库可以支持多线程,在同一个时间内,能够同时相应多个用户的使用需求。MySQL数据库还自带了优化器,方便设计人员在 使用过程中,快速的查询相干的数据信息。除此之外,SQLServer数据库在当下也是使用比力频繁的,它在数据安全、系统稳固等方面照旧比力不错的,但是由于其收费使用、占用内存大、操作复杂、维护成本高, 一样平常适用于中型及以上的系统开辟中。MySQL数据库也有着许多的应用步伐接口,以供相干的编程语言使用,编写的代码具有极高的通用性和可维护性,并且MySQL数据库能够迅速的处理上千条数据记录,在系统发生故障时,能通过日志文件快速恢复。MySQL数据库与SQLServer数据库相比力,综合考虑成本开销、占用内存大小、代码通用、数据维护、操作难易水平等方面,MySQL数据库占据很大的上风,在数据库设计人员的眼中,MySQL数据库的实际运用价值极高。
第三章 系统分析
3.1系统的需求分析
需求分析阶段是设计系统功能模块的总方向,可以这样来说,系统的整个的开辟流程以及设计进度,基本上都是以需求分析为基本依据的[10]。需求分析阶段可以确定系统的基本功能设计,以及在最后的系统验收阶段,再通过对需求分析陈诉进行对比,验证系统的功能设计是否合理,可否满足用户的基本必要,终极判断总结系统是否乐成实际。本文重要通干涉卷调查的方式,来分析通例应急物资管理系统所必要的相干功能[11]。根据调查结果显示,系统用户重要有两种范例,一种是以使用为重要目标的用户脚色范例,另一种是以管理为重要目标的管理员脚色范例。本系统重要功能需求包括物资信息管理、物资运输管理等模块。其中,暗码信息、用户信息、物资信息、物资运输信息等都黑白常紧张的数据记录,在系统设计的过程中,必要进行一定的加密处理,确保数据安全性,切实的保护好用户的紧张信息。
3.2系统的可行性分析
3.2.1经济可行性
对系统进行经济可行性分析,也可以被称为对系统进行经济可行性研究,它是从社会的经济发展出发,通过研究整个的系统可行性,对成本收益环境进行全面地、具体地分析,并且根据所分析的可行性陈诉,为相干的投资者提供最科学的决策理论和最优的投资方案。本系统的开辟促进了相干行业的信息化管理,管理人员可以直接通过在欣赏器上发布通例应急物资管理系统的网站所在,用户即可根据一定的必要,有选择的对系统相干功能进行操作。这种方式突破了时间和空间的限制,可以使得相干行业在较短的时间内最大化地管理通例应急物资的相干信息。并且本系统所使用的开辟技术和相干工具,大部分是开源的、免费的,所以可以节省很大一笔开辟成本。综合上述内容分析可知,本系统的实如今经济层面上是具备可行性的。
3.2.2技术可行性
本系统是基于Java语言而进行开辟的,因为Java语言简朴易学、稳固性强、代码利用率高等特点,所以许多的开辟技术人员均喜欢使用Java语言进行系统设计。现今很多步伐系统的研究和开辟,是通过使用Java语言进行编码设计的。此外,Java语言还具有跨平台的长处,这意味着所设计的系统是与平台无关的,也就说明由Java语言开辟的系统可以支持在不同的欣赏器上运行和使用。在条件大抵雷同的环境下,对比其他数据库,本系统使用的是MySQL数据库的相干语法简朴易懂,数据库设计人员可以尽大概快的对其掌握和使用。MySQL数据库还具有占用系统内存少、功能齐备、相应速度快、使用不收费等特点,能够在极短时间内处理上千条信息记录,所以能够保证系统可以高效地运行和工作。综合上述内容分析可知,系统的实如今技术层面上是具备可行性的。
3.2.3操作可行性
如今,人们的一样平常生活已经离不开互联网的使用,在一定水平上,相干行业的信息化建设促进着社会的发展。人们通过使用手机上的应用步伐,好比,通过使用电子商务系统,可以实现网上购物、在线付出等功能;通过使用国家官方网站,可以查看最新消息,申报个人业务;通过使用医院管理系统,可以进行网上预约挂号,在线查看体检陈诉等操作。在这些应用的配景下,本系统使用的是B/S开辟结构模式,网站界面以人性化的设计为主,具有美观友爱、交互性好等长处,用户不必要掌握一定的编程技术,直接通过对系统进行简朴的功能操作,即可满足自己的使用需求。本系统还设计了一些提示信息,便于用户更好的理解系统相干功能,较快的以正确的操作方式来使用系统。综合上述内容分析可知,系统的实如今操作层面上是具备可行性的。
第四章 系统设计
4.1系统的总体功能设计
系统的总体功能设计阶段,是通过联合系统分析阶段的相干内容,对系统的整体功能设计进行规划的过程。系统的总体功能设计是系统详细功能设计的一个大方向,也就是说系统的各类子功能模块的设计,都是以总体功能设计为目标而进行的。通过对系统进行需求分析可知,可以大抵相识系统具体所必要的相干的重要功能模块。本系统重要的功能需求包括物资信息管理、物资运输管理等模块。管理员功能设计图如图4-1所示,用户功能设计图如图4-2所示。
图4-1管理员功能设计图
图4-2用户功能设计图
4.2数据库设计
4.2.1概念设计
本系统使用轻量级的MySQL数据库,对系统相干的数据信息进行管理和维护[12]。数据库设计阶段一样平常可以被分为概念设计和逻辑设计这两个阶段。概念设计阶段是对系统进行数据库设计的紧张基础,将实际世界中用户的相干需求抽象化为虚拟世界中的概念模子,为后续的逻辑设计做好准备工作。本人通过设计E-R图,详细的对系统中的实体以及实体之间的联系进行了表达。各实体信息的实体属性图如图4-3、图4-4、图4-5、图4-6、图4-7、图4-8、图4-9、图4-10所示,系统总体E-R图如图4-11所示。
图4-3管理员信息实体属性图
图4-4用户信息实体属性图
图4-5字典信息实体属性图
图4-6部分信息实体属性图
图4-7物资信息实体属性图
图4-8物资申请信息实体属性图
图4-9 物资运输信息实体属性图
图4-10健康打卡信息实体属性图
图4-11系统总体E-R图
4.2.2逻辑设计
逻辑设计阶段重要的工作是将概念设计中的E-R图,转换成方便系统进行存储和管理的二维表格形式。这一阶段也可以被称为数据库的详细设计,其直接关系到系统功能模块的正常运行、数据信息的正常更新等[13]。在设计过程中,必要充分考虑数据库的规范性和合理性,使得能够满足系统的功能和性能需求。本系统相干的数据表格设计内容如下所示。
表4-1 管理员信息表
序号列名数据范例说明答应空1idInt编号否2usernameString用户名是3passwordString暗码是4roleString脚色是5addtimeDate新增时间是 表4-2 用户信息表
序号列名数据范例说明答应空1IdIntid否2usernameString账户是3passwordString暗码是4bumen_idInteger部分是5yonghu_nameString用户姓名是6yonghu_phoneString用户手机号是7yonghu_id_numberString用户身份证号是8yonghu_photoString用户头像是9sex_typesInteger性别是10yonghu_emailString电子邮箱是11create_timeDate创建时间是 表4-3 字典信息表
序号列名数据范例说明答应空1idInt编号否2dic_codeString字段是3dic_nameString字段名是4code_indexInteger编码是5index_nameString编码名字是6super_idInteger父字段编号是7beizhuString备注是8create_timeDate创建时间是 表4-4 部分信息表
序号列名数据范例说明答应空1IdIntid否2bumen_nameString部分名称是3bumen_zhizeString部分职责是4bumen_numberInteger部分人数是5bumen_contentString部分介绍是6insert_timeDate添加时间是7create_timeDate创建时间是 表4-5 物资信息表
序号列名数据范例说明答应空1IdIntid否2wuzi_nameString物资名称是3wuzi_photoString物资照片是4wuzi_typesInteger物资范例是5wuzi_kucun_numberInteger物资库存是6wuzi_danweiString单位是7wuzi_deleteInteger逻辑删除是8wuzi_contentString物资介绍是9create_timeDate创建时间是 表4-6 物资申请信息表
序号列名数据范例说明答应空1IdIntid否2yonghu_idInteger用户是3wuzi_idInteger物资是4wuzishenqing_numberInteger申请数目是5wuzishenqing_contentString申请详情是6insert_timeDate申请时间是7wuzishenqing_yesno_typesInteger审核是8wuzishenqing_yesno_textString审核意见是9create_timeDate创建时间是 表4-7 物资运输信息表
序号列名数据范例说明答应空1IdIntid否2wuzi_idInteger物资是3wuziyunshu_uuid_numberString运输唯一编号是4wuziyunshu_quxiangString去向是5wuziyunshu_numberInteger运输数目是6wuziyunshu_contentString运输详情是7wuziyunshu_typesInteger当前状态是8insert_timeDate添加时间是9update_timeDate最后更新时间是10create_timeDate创建时间是 表4-8 健康打卡信息表
序号列名数据范例说明答应空1IdIntid否2yonghu_idInteger用户是3daka_contentString打卡备注是4insert_timedate打卡日期是5create_timeDate创建时间是
第五章 系统实现
5.1管理员脚色功能设计
5.1.1管理员首页
通过设计的首页功能模块,管理用户可以乐成登录系统,并且选择点击相干的功能模块按钮,操作和实现自己所必要的功能,管理员首页解饿设计如图5-1所示。
图5-1管理员首页界面
本功能模块的焦点代码如下:
/**
* 登录
*/
@IgnoreAuth
@PostMapping(value = "/login")
public R login(String username, String password, String captcha, HttpServletRequest request) {
UsersEntity user = usersService.selectOne(new EntityWrapper ().eq("username", username));
if(user==null || !user.getPassword().equals(password)) {
return R.error("账号或暗码不正确");
}
String token = tokenService.generateToken(user.getId(),username, "users", user.getRole());
R r = R.ok();
r.put("token", token);
r.put("role",user.getRole());
r.put("userId",user.getId());
return r;
}
/**
* 列表
*/
@RequestMapping("/page")
public R page(@RequestParam Map<String, Object> params,UsersEntity user){
EntityWrapper ew = new EntityWrapper ();
PageUtils page = usersService.queryPage(params, MPUtil.sort(MPUtil.between(MPUtil.allLike(ew, user), params), params));
return R.ok().put("data", page);
}
5.1.2个人中心
通过设计的个人中心功能模块,管理用户可以选择修改账号暗码,查看个人资料信息,通过不定期的对个人账户暗码进行更新,保障个人信息安全,修改暗码界面设计如图5-1所示,个人信息界面设计如图5-2所示。
图5-1修改暗码界面
图5-2个人信息界面
本功能模块的焦点代码如下:
/**
* 暗码重置
*/
@IgnoreAuth
@RequestMapping(value = "/resetPass")
public R resetPass(String username, HttpServletRequest request){
UsersEntity user = usersService.selectOne(new EntityWrapper ().eq("username", username));
if(user==null) {
return R.error("账号不存在");
}
user.setPassword("123456");
usersService.update(user,null);
return R.ok("暗码已重置为:123456");
}
/**
* 信息
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") String id){
UsersEntity user = usersService.selectById(id);
return R.ok().put("data", user);
}
5.1.3健康打卡管理
通过设计的健康打卡管理功能模块,管理用户可以管理相干的健康打卡信息记录,好比进行查看健康打卡的详细信息,修改健康打卡的日期信息,删除已经失效的健康打卡信息记录等操作,健康打卡管理界面设计如图5-3所示。
图5-3健康打卡管理界面
本功能模块的焦点代码如下:
/**
* 健康打卡后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody DakaEntity daka, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,daka:{}",this.getClass().getName(),daka.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
// else if("用户".equals(role))
// daka.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
//根据字段查询是否有雷同数据
Wrapper queryWrapper = new EntityWrapper ()
.notIn("id",daka.getId())
.andNew()
.eq("yonghu_id", daka.getYonghuId())
.eq("insert_time", new SimpleDateFormat("yyyy-MM-dd").format(daka.getInsertTime()))
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
DakaEntity dakaEntity = dakaService.selectOne(queryWrapper);
if(dakaEntity==null){
dakaService.updateById(daka);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有雷同数据");
}
}
5.1.4基础数据管理
通过设计的基础数据管理功能模块,管理用户可以管理相干的物资范例信息记录,好比进行查看物资范例的详细信息,修改物资范例的名称信息,删除已经失效的物资范例信息记录等操作,物资范例管理界面设计如图5-4所示。
图5-4物资范例管理界面
本功能模块的焦点代码如下:
/**
* 基础数据后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody DictionaryEntity dictionary, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,dictionary:{}",this.getClass().getName(),dictionary.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
//根据字段查询是否有雷同数据
Wrapper queryWrapper = new EntityWrapper ()
.notIn("id",dictionary.getId())
.eq("dic_code", dictionary.getDicCode())
.eq("index_name", dictionary.getIndexName())
;
if(dictionary.getDicCode().contains("_erji_types")){
queryWrapper.eq("super_id",dictionary.getSuperId());
}
logger.info("sql语句:"+queryWrapper.getSqlSegment());
DictionaryEntity dictionaryEntity = dictionaryService.selectOne(queryWrapper);
if(dictionaryEntity==null){
dictionaryService.updateById(dictionary);//根据id更新
//如果字典表修改数据的话,把数据再重新查出,放入监听器中
List dictionaryEntities = dictionaryService.selectList(new EntityWrapper ());
ServletContext servletContext = request.getServletContext();
Map<String, Map<Integer,String>> map = new HashMap<>();
for(DictionaryEntity d :dictionaryEntities){
Map<Integer, String> m = map.get(d.getDicCode());
if(m ==null || m.isEmpty()){
m = new HashMap<>();
}
m.put(d.getCodeIndex(),d.getIndexName());
map.put(d.getDicCode(),m);
}
servletContext.setAttribute("dictionaryMap",map);
return R.ok();
}else {
return R.error(511,"表中有雷同数据");
}
}
5.1.5物资管理
通过设计的物资管理功能模块,管理用户可以管理相干的物资信息记录,好比进行查看物资的详细信息,修改物资的库存信息,删除已经失效的物资信息记录等操作,物资管理界面设计如图5-5所示。
图5-5物资管理界面
本功能模块的焦点代码如下:
/**
* 物资后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody WuziEntity wuzi, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,wuzi:{}",this.getClass().getName(),wuzi.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
//根据字段查询是否有雷同数据
Wrapper queryWrapper = new EntityWrapper ()
.notIn("id",wuzi.getId())
.andNew()
.eq("wuzi_name", wuzi.getWuziName())
.eq("wuzi_types", wuzi.getWuziTypes())
.eq("wuzi_kucun_number", wuzi.getWuziKucunNumber())
.eq("wuzi_danwei", wuzi.getWuziDanwei())
.eq("wuzi_delete", wuzi.getWuziDelete())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
WuziEntity wuziEntity = wuziService.selectOne(queryWrapper);
if("".equals(wuzi.getWuziPhoto()) || "null".equals(wuzi.getWuziPhoto())){
wuzi.setWuziPhoto(null);
}
if(wuziEntity==null){
wuziService.updateById(wuzi);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有雷同数据");
}
}
5.1.6物资申请管理
通过设计的物资申请管理功能模块,管理用户可以管理相干的物资申请信息记录,好比进行查看物资申请的详细信息,修改物资的申请时间信息,删除已经失效的物资申请信息记录等操作,物资申请管理界面设计如图5-6所示。
图5-6物资申请管理界面
本功能模块的焦点代码如下:
/**
* 物资申请后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody WuzishenqingEntity wuzishenqing, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,wuzishenqing:{}",this.getClass().getName(),wuzishenqing.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
wuzishenqing.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
wuzishenqing.setInsertTime(new Date());
wuzishenqing.setWuzishenqingYesnoTypes(1);
wuzishenqing.setCreateTime(new Date());
wuzishenqingService.insert(wuzishenqing);
return R.ok();
}
/**
* 物资申请后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody WuzishenqingEntity wuzishenqing, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,wuzishenqing:{}",this.getClass().getName(),wuzishenqing.toString());
wuzishenqingService.updateById(wuzishenqing);//根据id更新
return R.ok();
}
5.1.7物资运输管理
通过设计的物资运输管理功能模块,管理用户可以管理相干的物资运输信息记录,好比进行查看物资运输的详细信息,修改物资运输的当前状态信息,删除已经失效的物资运输信息记录等操作,物资运输管理界面设计如图5-7所示。
图5-7物资运输管理界面
本功能模块的焦点代码如下:
/**
* 物资运输后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody WuziyunshuEntity wuziyunshu, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,wuziyunshu:{}",this.getClass().getName(),wuziyunshu.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
wuziyunshu.setUpdateTime(new Date());
wuziyunshu.setInsertTime(new Date());
wuziyunshu.setCreateTime(new Date());
wuziyunshuService.insert(wuziyunshu);
return R.ok();
}
/**
* 物资运输后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody WuziyunshuEntity wuziyunshu, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,wuziyunshu:{}",this.getClass().getName(),wuziyunshu.toString());
wuziyunshu.setUpdateTime(new Date());
wuziyunshuService.updateById(wuziyunshu);//根据id更新
return R.ok();
}
5.1.8用户管理
通过设计的用户管理功能模块,管理用户可以管理相干的用户信息资料,好比进行查看用户的详细资料,修改用户的联系方式,删除已经注销的用户信息记录等操作,用户管理界面设计如图5-8所示。
图5-8用户管理界面
本功能模块的焦点代码如下:
/**
* 用户后端修改
*/
@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 queryWrapper = new EntityWrapper ()
.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,"账户大概用户手机号大概用户身份证号已经被使用");
}
}
5.1.9部分管理
通过设计的部分管理功能模块,管理用户可以管理相干的部分信息记录,好比进行查看部分的详细信息,修改部分的职责信息,删除已经失效的部分信息记录等操作,部分管理界面设计如图5-9所示。
图5-9部分管理界面
本功能模块的焦点代码如下:
/**
* 部分后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody BumenEntity bumen, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,bumen:{}",this.getClass().getName(),bumen.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
// if(false)
// return R.error(511,"永远不会进入");
//根据字段查询是否有雷同数据
Wrapper queryWrapper = new EntityWrapper ()
.notIn("id",bumen.getId())
.andNew()
.eq("bumen_name", bumen.getBumenName())
.eq("bumen_zhize", bumen.getBumenZhize())
.eq("bumen_number", bumen.getBumenNumber())
;
logger.info("sql语句:"+queryWrapper.getSqlSegment());
BumenEntity bumenEntity = bumenService.selectOne(queryWrapper);
if(bumenEntity==null){
bumenService.updateById(bumen);//根据id更新
return R.ok();
}else {
return R.error(511,"表中有雷同数据");
}
}
5.2用户功能设计
5.2.1用户首页
通过设计的首页功能模块,管理用户可以乐成登录系统,并且选择点击相干的功能模块按钮,操作和实现自己所必要的功能,管理员首页解饿设计如图5-10所示。
图5-10用户首页界面
本功能模块的焦点代码如下:
/**
* 首页后端保存
*/
@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 queryWrapper = new EntityWrapper ()
.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,"账户大概用户手机号大概用户身份证号已经被使用");
}
}
5.2.2个人中心
通过设计的个人中心管理功能模块,用户可以选择查看个人资料信息,选择更新个人相干的资料信息记录;也可以选择修改账号暗码,通过不定期的对个人账户暗码进行更新,保障个人信息安全,修改暗码界面设计如图5-11所示,个人信息界面设计如图5-12所示。
图5-11修改暗码界面
图5-12个人信息界面
本功能模块的焦点代码如下:
//查询是否重复
//账户
List yonghuEntities_username = yonghuService.selectList(new EntityWrapper ().in("username", seachFields.get("username")));
if(yonghuEntities_username.size() >0 ){
ArrayList repeatFields = new ArrayList<>();
for(YonghuEntity s:yonghuEntities_username){
repeatFields.add(s.getUsername());
}
return R.error(511,"数据库的该表中的 [账户] 字段已经存在 存在数据为:"+repeatFields.toString());
}
//用户手机号
List yonghuEntities_yonghuPhone = yonghuService.selectList(new EntityWrapper ().in("yonghu_phone", seachFields.get("yonghuPhone")));
if(yonghuEntities_yonghuPhone.size() >0 ){
ArrayList repeatFields = new ArrayList<>();
for(YonghuEntity s:yonghuEntities_yonghuPhone){
repeatFields.add(s.getYonghuPhone());
}
return R.error(511,"数据库的该表中的 [用户手机号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
//用户身份证号
List yonghuEntities_yonghuIdNumber = yonghuService.selectList(new EntityWrapper ().in("yonghu_id_number", seachFields.get("yonghuIdNumber")));
if(yonghuEntities_yonghuIdNumber.size() >0 ){
ArrayList repeatFields = new ArrayList<>();
for(YonghuEntity s:yonghuEntities_yonghuIdNumber){
repeatFields.add(s.getYonghuIdNumber());
}
return R.error(511,"数据库的该表中的 [用户身份证号] 字段已经存在 存在数据为:"+repeatFields.toString());
}
yonghuService.insertBatch(yonghuList);
return R.ok();
}
5.2.3健康打卡管理
通过设计的健康打卡管理功能模块,用户可以管理相干的健康打卡信息记录,好比进行查看健康打卡的详细信息,修改健康打卡的日期信息,删除已经失效的健康打卡信息记录等操作,健康打卡管理界面设计如图5-13所示。
图5-13健康打卡管理界面
本功能模块的焦点代码如下:
/**
* 健康打卡后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
DakaEntity daka = dakaService.selectById(id);
if(daka !=null){
//entity转view
DakaView view = new DakaView();
BeanUtils.copyProperties( daka , view );//把实体数据重构到view中
//级联表
YonghuEntity yonghu = yonghuService.selectById(daka.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
5.2.4物资管理
通过设计的物资管理功能模块,管理用户可以查看相干的物资信息记录,可以查到物资名称、物资图片、物资范例、物资库存等详细信息,物资管理界面设计如图5-14所示。
图5-14物资管理界面
本功能模块的焦点代码如下:
/**
* 物资后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
WuziEntity wuzi = wuziService.selectById(id);
if(wuzi !=null){
//entity转view
WuziView view = new WuziView();
BeanUtils.copyProperties( wuzi , view );//把实体数据重构到view中
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
5.2.5物资申请管理
通过设计的物资申请管理功能模块,用户可以管理相干的物资申请信息记录,好比进行查看物资申请的详细信息,新增相干的物资申请信息记录,物资申请管理界面设计如图5-15所示。
图5-15物资申请管理界面
本功能模块的焦点代码如下:
/**
* 物资申请后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
WuzishenqingEntity wuzishenqing = wuzishenqingService.selectById(id);
if(wuzishenqing !=null){
//entity转view
WuzishenqingView view = new WuzishenqingView();
BeanUtils.copyProperties( wuzishenqing , view );//把实体数据重构到view中
//级联表
WuziEntity wuzi = wuziService.selectById(wuzishenqing.getWuziId());
if(wuzi != null){
BeanUtils.copyProperties( wuzi , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setWuziId(wuzi.getId());
}
//级联表
YonghuEntity yonghu = yonghuService.selectById(wuzishenqing.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
5.2.6物资运输管理
通过设计的物资运输管理功能模块,用户可以查看相干的物资运输信息记录,好比查到物资名称、物资图片、单位、运输数目、当前状态等详细信息,物资运输管理界面设计如图5-16所示。
图5-16物资运输管理界面
本功能模块的焦点代码如下:
/**
* 物资运输后端详情
*/
@RequestMapping("/info/{id}")
public R info(@PathVariable("id") Long id, HttpServletRequest request){
logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
WuziyunshuEntity wuziyunshu = wuziyunshuService.selectById(id);
if(wuziyunshu !=null){
//entity转view
WuziyunshuView view = new WuziyunshuView();
BeanUtils.copyProperties( wuziyunshu , view );//把实体数据重构到view中
//级联表
WuziEntity wuzi = wuziService.selectById(wuziyunshu.getWuziId());
if(wuzi != null){
BeanUtils.copyProperties( wuzi , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setWuziId(wuzi.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
MybatisPlusConfig.java
package com.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import com.baomidou.mybatisplus.mapper.MetaObjectHandler;
import com.baomidou.mybatisplus.plugins.PaginationInterceptor;
/**
* mybatis-plus配置
*/
@Configuration
public class MybatisPlusConfig {
/**
* 分页插件
*/
@Bean
public PaginationInterceptor paginationInterceptor() {
return new PaginationInterceptor();
}
}
复制代码
DictionaryServiceImpl.java
package com.service.impl;
import com.utils.StringUtil;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.util.*;
import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.transaction.annotation.Transactional;
import com.utils.PageUtils;
import com.utils.Query;
import org.springframework.web.context.ContextLoader;
import javax.servlet.ServletContext;
import javax.servlet.http.HttpServletRequest;
import com.dao.DictionaryDao;
import com.entity.DictionaryEntity;
import com.service.DictionaryService;
import com.entity.view.DictionaryView;
/**
* 字典 服务实现类
*/
@Service("dictionaryService")
@Transactional
public class DictionaryServiceImpl extends ServiceImpl<DictionaryDao, DictionaryEntity> implements DictionaryService {
@Override
public PageUtils queryPage(Map<String,Object> params) {
if(params != null && (params.get("limit") == null || params.get("page") == null)){
params.put("page","1");
params.put("limit","10");
}
Page<DictionaryView> page =new Query<DictionaryView>(params).getPage();
page.setRecords(baseMapper.selectListView(page,params));
return new PageUtils(page);
}
/**
* 赋值给字典表
* @param obj view对象
*/
public void dictionaryConvert(Object obj, HttpServletRequest request) {
try {
if (obj == null) return;
//当前view和entity中的所有types的字段
List<String> fieldNameList = new ArrayList<>();
Class tempClass = obj.getClass();
while (tempClass !=null) {
Field[] declaredFields = tempClass.getDeclaredFields();
for (Field f : declaredFields) {
f.setAccessible(true);
if (f.getType().getName().equals("java.lang.Integer") && f.getName().contains("Types")) {
fieldNameList.add(f.getName());
}
}
tempClass = tempClass.getSuperclass(); //得到父类,然后赋给自己
}
// 获取监听器中的字典表
// ServletContext servletContext = ContextLoader.getCurrentWebApplicationContext().getServletContext();
ServletContext servletContext = request.getServletContext();
Map<String, Map<Integer, String>> dictionaryMap= (Map<String, Map<Integer, String>>) servletContext.getAttribute("dictionaryMap");
//通过Types的值给Value字段赋值
for (String s : fieldNameList) {
Field types = null;
if(hasField(obj.getClass(),s)){
//判断view中有没有这个字段,有就通过反射取出字段
types= obj.getClass().getDeclaredField(s);//获取Types私有字段
}else{
//本表中没有这个字段,说明它是父表中的字段,也就是entity中的字段,从entity中取值
types=obj.getClass().getSuperclass().getDeclaredField(s);
}
Field value = obj.getClass().getDeclaredField(s.replace("Types", "Value"));//获取value私有字段
//设置权限
types.setAccessible(true);
value.setAccessible(true);
//赋值
if (StringUtil.isNotEmpty(String.valueOf(types.get(obj)))) { //types的值不为空
int i = Integer.parseInt(String.valueOf(types.get(obj)));//type
//把s1字符中的所有大写转小写,并在前面加 _
char[] chars = s.toCharArray();
StringBuffer sbf = new StringBuffer();
for(int b=0; b< chars.length; b++){
char ch = chars[b];
if(ch <= 90 && ch >= 65){
sbf.append("_");
ch += 32;
}
sbf.append(ch);
}
String s2 = dictionaryMap.get(sbf.toString()).get(i);
value.set(obj, s2);
} else {
new Exception("字典表赋值出现问题::::"+value.getName());
value.set(obj, "");
}
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (NoSuchFieldException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 判断本实体有没有这个字段
* @param c
* @param fieldName
* @return
*/
public boolean hasField(Class c, String fieldName){
Field[] fields = c.getDeclaredFields();
for (Field f : fields) {
if (fieldName.equals(f.getName())) {
return true;
}
}
return false;
}
}
复制代码
WuzishenqingController.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("/wuzishenqing")
public class WuzishenqingController {
private static final Logger logger = LoggerFactory.getLogger(WuzishenqingController.class);
@Autowired
private WuzishenqingService wuzishenqingService;
@Autowired
private TokenService tokenService;
@Autowired
private DictionaryService dictionaryService;
//级联表service
@Autowired
private WuziService wuziService;
@Autowired
private YonghuService yonghuService;
/**
* 后端列表
*/
@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 = wuzishenqingService.queryPage(params);
//字典表数据转换
List<WuzishenqingView> list =(List<WuzishenqingView>)page.getList();
for(WuzishenqingView 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);
WuzishenqingEntity wuzishenqing = wuzishenqingService.selectById(id);
if(wuzishenqing !=null){
//entity转view
WuzishenqingView view = new WuzishenqingView();
BeanUtils.copyProperties( wuzishenqing , view );//把实体数据重构到view中
//级联表
WuziEntity wuzi = wuziService.selectById(wuzishenqing.getWuziId());
if(wuzi != null){
BeanUtils.copyProperties( wuzi , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setWuziId(wuzi.getId());
}
//级联表
YonghuEntity yonghu = yonghuService.selectById(wuzishenqing.getYonghuId());
if(yonghu != null){
BeanUtils.copyProperties( yonghu , view ,new String[]{ "id", "createTime", "insertTime", "updateTime"});//把级联的数据添加到view中,并排除id和创建时间字段
view.setYonghuId(yonghu.getId());
}
//修改对应字典表字段
dictionaryService.dictionaryConvert(view, request);
return R.ok().put("data", view);
}else {
return R.error(511,"查不到数据");
}
}
/**
* 后端保存
*/
@RequestMapping("/save")
public R save(@RequestBody WuzishenqingEntity wuzishenqing, HttpServletRequest request){
logger.debug("save方法:,,Controller:{},,wuzishenqing:{}",this.getClass().getName(),wuzishenqing.toString());
String role = String.valueOf(request.getSession().getAttribute("role"));
if(false)
return R.error(511,"永远不会进入");
else if("用户".equals(role))
wuzishenqing.setYonghuId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
wuzishenqing.setInsertTime(new Date());
wuzishenqing.setWuzishenqingYesnoTypes(1);
wuzishenqing.setCreateTime(new Date());
wuzishenqingService.insert(wuzishenqing);
return R.ok();
}
/**
* 后端修改
*/
@RequestMapping("/update")
public R update(@RequestBody WuzishenqingEntity wuzishenqing, HttpServletRequest request){
logger.debug("update方法:,,Controller:{},,wuzishenqing:{}",this.getClass().getName(),wuzishenqing.toString());
wuzishenqingService.updateById(wuzishenqing);//根据id更新
return R.ok();
}
/**
* 删除
*/
@RequestMapping("/delete")
public R delete(@RequestBody Integer[] ids){
logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
wuzishenqingService.deleteBatchIds(Arrays.asList(ids));
return R.ok();
}
/**
* 批量上传
*/
@RequestMapping("/batchInsert")
public R save( String fileName){
logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
try {
List<WuzishenqingEntity> wuzishenqingList = 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("static/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){
//循环
WuzishenqingEntity wuzishenqingEntity = new WuzishenqingEntity();
// wuzishenqingEntity.setYonghuId(Integer.valueOf(data.get(0))); //用户 要改的
// wuzishenqingEntity.setWuziId(Integer.valueOf(data.get(0))); //物资 要改的
// wuzishenqingEntity.setWuzishenqingNumber(Integer.valueOf(data.get(0))); //申请数量 要改的
// wuzishenqingEntity.setWuzishenqingContent("");//照片
// wuzishenqingEntity.setInsertTime(date);//时间
// wuzishenqingEntity.setWuzishenqingYesnoTypes(Integer.valueOf(data.get(0))); //审核 要改的
// wuzishenqingEntity.setWuzishenqingYesnoText(data.get(0)); //审核意见 要改的
// wuzishenqingEntity.setCreateTime(date);//时间
wuzishenqingList.add(wuzishenqingEntity);
//把要查询是否重复的字段放入map中
}
//查询是否重复
wuzishenqingService.insertBatch(wuzishenqingList);
return R.ok();
}
}
}
}catch (Exception e){
return R.error(511,"批量插入数据异常,请联系管理员");
}
}
}
复制代码
add-or-update.vue
<template>
<div class="addEdit-block">
<el-form
class="detail-form-content"
ref="ruleForm"
:model="ruleForm"
:rules="rules"
label-width="80px"
:style="{backgroundColor:addEditForm.addEditBoxColor}"
>
<el-row>
<el-col :span="12">
<el-form-item class="input" v-if="type!='info'" label="申请状态编码" prop="codeIndex">
<el-input v-model="ruleForm.codeIndex"
placeholder="申请状态编码" clearable :readonly="ro.codeIndex"></el-input>
</el-form-item>
<div v-else>
<el-form-item class="input" label="申请状态编码" prop="codeIndex">
<el-input v-model="ruleForm.codeIndex"
placeholder="申请状态编码" readonly></el-input>
</el-form-item>
</div>
</el-col>
<el-col :span="12">
<el-form-item class="input" v-if="type!='info'" label="申请状态" prop="indexName">
<el-input v-model="ruleForm.indexName"
placeholder="申请状态" clearable :readonly="ro.indexName"></el-input>
</el-form-item>
<div v-else>
<el-form-item class="input" label="申请状态" prop="indexName">
<el-input v-model="ruleForm.indexName"
placeholder="申请状态" readonly></el-input>
</el-form-item>
</div>
</el-col>
</el-row>
<el-form-item class="btn">
<el-button v-if="type!='info'" type="primary" class="btn-success" @click="onSubmit">提交</el-button>
<el-button v-if="type!='info'" class="btn-close" @click="back()">取消</el-button>
<el-button v-if="type=='info'" class="btn-close" @click="back()">返回</el-button>
</el-form-item>
</el-form>
</div>
</template>
<script>
import styleJs from "../../../utils/style.js";
// 数字,邮件,手机,url,身份证校验
import { isNumber,isIntNumer,isEmail,isPhone, isMobile,isURL,checkIdCard } from "@/utils/validate";
export default {
data() {
let self = this
return {
addEditForm:null,
id: '',
type: '',
ro:{
codeIndex : true,
indexName : false,
superId : false,
beizhu : false,
},
ruleForm: {
codeIndex: '',
indexName: '',
superId : '',
beizhu : '',
},
rules: {
}
};
},
props: ["parent"],
computed: {
},
created() {
this.addEditForm = styleJs.addStyle();
this.addEditStyleChange()
this.addEditUploadStyleChange()
},
methods: {
// 初始化
init(id,type) {
if (id) {
this.id = id;
this.type = type;
}
if(this.type=='info'||this.type=='else'){
this.info(id);
}else{
//查询最大值 start
this.$http({
url: `dictionary/maxCodeIndex`,
method: "post",
data: {"dicCode":"wuzishenqing_yesno_types"}
}).then(({ data }) => {
if (data && data.code === 0) {
this.ruleForm.codeIndex = data.maxCodeIndex;
} else {
this.$message.error(data.msg);
}
});
//查询最大值 end
}
},
// 多级联动参数
info(id) {
this.$http({
url: `dictionary/info/${id}`,
method: "get"
}).then(({ data }) => {
if (data && data.code === 0) {
this.ruleForm = data.data;
//解决前台上传图片后台不显示的问题
let reg=new RegExp('../../../upload','g')//g代表全部
} else {
this.$message.error(data.msg);
}
});
},
// 提交
onSubmit() {
if((!this.ruleForm.indexName)){
this.$message.error('申请状态不能为空');
return
}
this.$refs["ruleForm"].validate(valid => {
if (valid) {
let ruleForm = this.ruleForm;
ruleForm["dicCode"]="wuzishenqing_yesno_types";
ruleForm["dicName"]="申请状态";
this.$http({
url: `dictionary/${!this.ruleForm.id ? "save" : "update"}`,
method: "post",
data: ruleForm
}).then(({ data }) => {
if (data && data.code === 0) {
this.$message({
message: "操作成功",
type: "success",
duration: 1500,
onClose: () => {
this.parent.showFlag = true;
this.parent.addOrUpdateFlag = false;
this.parent.dictionaryCrossAddOrUpdateFlag = false;
this.parent.search();
this.parent.contentStyleChange();
}
});
} else {
this.$message.error(data.msg);
}
});
}
});
},
// 返回
back() {
this.parent.showFlag = true;
this.parent.addOrUpdateFlag = false;
this.parent.dictionaryCrossAddOrUpdateFlag = false;
this.parent.contentStyleChange();
},
addEditStyleChange() {
this.$nextTick(()=>{
// input
document.querySelectorAll('.addEdit-block .input .el-input__inner').forEach(el=>{
el.style.height = this.addEditForm.inputHeight
el.style.color = this.addEditForm.inputFontColor
el.style.fontSize = this.addEditForm.inputFontSize
el.style.borderWidth = this.addEditForm.inputBorderWidth
el.style.borderStyle = this.addEditForm.inputBorderStyle
el.style.borderColor = this.addEditForm.inputBorderColor
el.style.borderRadius = this.addEditForm.inputBorderRadius
el.style.backgroundColor = this.addEditForm.inputBgColor
})
document.querySelectorAll('.addEdit-block .input .el-form-item__label').forEach(el=>{
el.style.lineHeight = this.addEditForm.inputHeight
el.style.color = this.addEditForm.inputLableColor
el.style.fontSize = this.addEditForm.inputLableFontSize
})
// select
document.querySelectorAll('.addEdit-block .select .el-input__inner').forEach(el=>{
el.style.height = this.addEditForm.selectHeight
el.style.color = this.addEditForm.selectFontColor
el.style.fontSize = this.addEditForm.selectFontSize
el.style.borderWidth = this.addEditForm.selectBorderWidth
el.style.borderStyle = this.addEditForm.selectBorderStyle
el.style.borderColor = this.addEditForm.selectBorderColor
el.style.borderRadius = this.addEditForm.selectBorderRadius
el.style.backgroundColor = this.addEditForm.selectBgColor
})
document.querySelectorAll('.addEdit-block .select .el-form-item__label').forEach(el=>{
el.style.lineHeight = this.addEditForm.selectHeight
el.style.color = this.addEditForm.selectLableColor
el.style.fontSize = this.addEditForm.selectLableFontSize
})
document.querySelectorAll('.addEdit-block .select .el-select__caret').forEach(el=>{
el.style.color = this.addEditForm.selectIconFontColor
el.style.fontSize = this.addEditForm.selectIconFontSize
})
// date
document.querySelectorAll('.addEdit-block .date .el-input__inner').forEach(el=>{
el.style.height = this.addEditForm.dateHeight
el.style.color = this.addEditForm.dateFontColor
el.style.fontSize = this.addEditForm.dateFontSize
el.style.borderWidth = this.addEditForm.dateBorderWidth
el.style.borderStyle = this.addEditForm.dateBorderStyle
el.style.borderColor = this.addEditForm.dateBorderColor
el.style.borderRadius = this.addEditForm.dateBorderRadius
el.style.backgroundColor = this.addEditForm.dateBgColor
})
document.querySelectorAll('.addEdit-block .date .el-form-item__label').forEach(el=>{
el.style.lineHeight = this.addEditForm.dateHeight
el.style.color = this.addEditForm.dateLableColor
el.style.fontSize = this.addEditForm.dateLableFontSize
})
document.querySelectorAll('.addEdit-block .date .el-input__icon').forEach(el=>{
el.style.color = this.addEditForm.dateIconFontColor
el.style.fontSize = this.addEditForm.dateIconFontSize
el.style.lineHeight = this.addEditForm.dateHeight
})
// upload
let iconLineHeight = parseInt(this.addEditForm.uploadHeight) - parseInt(this.addEditForm.uploadBorderWidth) * 2 + 'px'
document.querySelectorAll('.addEdit-block .upload .el-upload--picture-card').forEach(el=>{
el.style.width = this.addEditForm.uploadHeight
el.style.height = this.addEditForm.uploadHeight
el.style.borderWidth = this.addEditForm.uploadBorderWidth
el.style.borderStyle = this.addEditForm.uploadBorderStyle
el.style.borderColor = this.addEditForm.uploadBorderColor
el.style.borderRadius = this.addEditForm.uploadBorderRadius
el.style.backgroundColor = this.addEditForm.uploadBgColor
})
document.querySelectorAll('.addEdit-block .upload .el-form-item__label').forEach(el=>{
el.style.lineHeight = this.addEditForm.uploadHeight
el.style.color = this.addEditForm.uploadLableColor
el.style.fontSize = this.addEditForm.uploadLableFontSize
})
document.querySelectorAll('.addEdit-block .upload .el-icon-plus').forEach(el=>{
el.style.color = this.addEditForm.uploadIconFontColor
el.style.fontSize = this.addEditForm.uploadIconFontSize
el.style.lineHeight = iconLineHeight
el.style.display = 'block'
})
// 多文本输入框
document.querySelectorAll('.addEdit-block .textarea .el-textarea__inner').forEach(el=>{
el.style.height = this.addEditForm.textareaHeight
el.style.color = this.addEditForm.textareaFontColor
el.style.fontSize = this.addEditForm.textareaFontSize
el.style.borderWidth = this.addEditForm.textareaBorderWidth
el.style.borderStyle = this.addEditForm.textareaBorderStyle
el.style.borderColor = this.addEditForm.textareaBorderColor
el.style.borderRadius = this.addEditForm.textareaBorderRadius
el.style.backgroundColor = this.addEditForm.textareaBgColor
})
document.querySelectorAll('.addEdit-block .textarea .el-form-item__label').forEach(el=>{
// el.style.lineHeight = this.addEditForm.textareaHeight
el.style.color = this.addEditForm.textareaLableColor
el.style.fontSize = this.addEditForm.textareaLableFontSize
})
// 保存
document.querySelectorAll('.addEdit-block .btn .btn-success').forEach(el=>{
el.style.width = this.addEditForm.btnSaveWidth
el.style.height = this.addEditForm.btnSaveHeight
el.style.color = this.addEditForm.btnSaveFontColor
el.style.fontSize = this.addEditForm.btnSaveFontSize
el.style.borderWidth = this.addEditForm.btnSaveBorderWidth
el.style.borderStyle = this.addEditForm.btnSaveBorderStyle
el.style.borderColor = this.addEditForm.btnSaveBorderColor
el.style.borderRadius = this.addEditForm.btnSaveBorderRadius
el.style.backgroundColor = this.addEditForm.btnSaveBgColor
})
// 返回
document.querySelectorAll('.addEdit-block .btn .btn-close').forEach(el=>{
el.style.width = this.addEditForm.btnCancelWidth
el.style.height = this.addEditForm.btnCancelHeight
el.style.color = this.addEditForm.btnCancelFontColor
el.style.fontSize = this.addEditForm.btnCancelFontSize
el.style.borderWidth = this.addEditForm.btnCancelBorderWidth
el.style.borderStyle = this.addEditForm.btnCancelBorderStyle
el.style.borderColor = this.addEditForm.btnCancelBorderColor
el.style.borderRadius = this.addEditForm.btnCancelBorderRadius
el.style.backgroundColor = this.addEditForm.btnCancelBgColor
})
})
},
addEditUploadStyleChange() {
this.$nextTick(()=>{
document.querySelectorAll('.addEdit-block .upload .el-upload-list--picture-card .el-upload-list__item').forEach(el=>{
el.style.width = this.addEditForm.uploadHeight
el.style.height = this.addEditForm.uploadHeight
el.style.borderWidth = this.addEditForm.uploadBorderWidth
el.style.borderStyle = this.addEditForm.uploadBorderStyle
el.style.borderColor = this.addEditForm.uploadBorderColor
el.style.borderRadius = this.addEditForm.uploadBorderRadius
el.style.backgroundColor = this.addEditForm.uploadBgColor
})
})
},
}
};
</script>
<style lang="scss">
.editor{
height: 500px;
& /deep/ .ql-container {
height: 310px;
}
}
.amap-wrapper {
width: 100%;
height: 500px;
}
.search-box {
position: absolute;
}
.addEdit-block {
margin: -10px;
}
.detail-form-content {
padding: 12px;
}
.btn .el-button {
padding: 0;
}</style>
复制代码
免责声明:如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!更多信息从访问主页:qidao123.com:ToB企服之家,中国第一个企服评测及商务社交产业平台。
欢迎光临 ToB企服应用市场:ToB评测及商务社交产业平台 (https://dis.qidao123.com/)
Powered by Discuz! X3.4