基于Java企业项目管理系统--论文pf

@TOC

springboot527基于Java企业项目管理系统--论文pf

第1章 绪论

1.1 课题背景

二十一世纪互联网的出现,改变了几千年以来人们的生活,不仅仅是生活物资的丰富,还有精神层次的丰富。在互联网诞生之前,地域位置往往是人们思想上不可跨域的鸿沟,信息的传播速度极慢,信息处理的速度和要求还是通过人们骑马或者是信鸽传递,这些信息传递都是不可控制的,中间很有可能丢失,信息的传递水平决定了人们生活的水平。如今大家都在使用互联网软件产品,从内部管理设置计算机管理,提高内部信息化的管理水准,从外部市场也可以用计算机获取相关数据进行处理,如今各行各业已经严重依赖于计算机了。

本课题研究和开发企业项目管理系统,让安装在计算机上的该系统变成管理人员的小帮手,提高企业项目管理系统信息处理速度,规范企业项目管理系统信息处理流程,让管理人员的产出效益更高。

1.2 课题意义

传统处理数据,必须是一张张纸,然后处理完毕又是统计在一张张纸上面,不断的重复处理,最终有个结果给最高层作为参考,这个模式在互联网没有出现之前,是一种常见的事情,信息管理的效率提不上去,人多不一定力量大,因为人多肯定更加消耗资源,并且因为人类需要休息,需要管理,思想会不统一,会偷懒,所以人们研究出专门帮助人们计算的机器,就是计算机的前身,到了互联网时代,人们发现完全可以让程序供应商提供解决方案,自己挑选自己合适的方案来提高自己的产出比。所以在日常工作和生活中会发现各种各样方便人们的工具。

本课题研发的企业项目管理系统,就是提供企业项目管理系统信息处理的解决方案,它可以短时间处理完信息,并且这些信息都有专门的存储设备,而且数据的备份和迁移都可以设定为无人值守,从人力角度和信息处理角度以及信息安全角度,企业项目管理系统是完胜传统纸质操作的。

1.3 研究内容

本文对企业项目管理系统的设计与实现分成六个章节来说明。

第1章:研究企业项目管理系统的背景,以及开发企业项目管理系统的意义。

第2章:对开发企业项目管理系统的环境还有技术进行说明。

第3章:分析企业项目管理系统的可行性,性能,流程以及功能。

第4章:设计企业项目管理系统的功能结构,设计数据库E-R图以及对数据表的存储结构进行设计。

第5章:实现企业项目管理系统的功能并进行功能界面展示。

第6章:对系统测试进行阐述,以及对本系统部分功能进行检测。

第2章 开发环境与技术

本章节对开发企业项目管理系统需要搭建的开发环境,还有企业项目管理系统开发中使用的编程技术等进行阐述。

2.1 MySQL数据库

本课题研究研发的应用程序在数据操作里是难以预测的,而且常常产生变化。没有办法直接从word里写数据信息,这不但不安全,并且难以实现应用程序的功能。想要实现运用所需要的文件存储功能,就必定要选择专业数据库存储软件。大部分,应用程序达到的功能并不太繁杂,市场中所有关系数据库手机软件都能实现。但MySQL数据库,安装文件小,组装速度更快,使用方便,即便组装问题改进,不用再次安装操作系统,也不会影响电脑中第三方软件的运转,损耗网络资源少,最主要的是功能充分满足设计定位,因此最终选择MySQL数据库做为软件开发技术所需要的数据库。

2.2 Java语言

Java语言已经存在了25年有余。通过这些年的发展趋势,it行业在市场占有率上仍然占据一半,仍然受到了很多程序员的工作钟爱。许多从业者都是在学习培训。近年来随着从业者的提高,Java语言的位置并没减少,算得上是常青藤。Java语言学习培训比较简单,自然,它是对于C前辈们的 而言的,C 语言非常强劲。Java取消了许多CJava 特点,如go 这种阐述,也取消了主文件,让所有文件夹全是类,类是二维数组以及各种对象,也使Java处理一些对象的引入和回收利用,让开发者只需建立对象,应用对象,编写代码逻辑,不需要留意性能,让各种各样文件存储给Java自己解决,你能花很多时间科学研究应用软件相互关系,使研发更为集中化,如同跑车驾驶员一样,只要了解各种汽车的性能,实际操作,不需要科学研究如何生产车轮子,使软件开发更为详尽。

2.4 Spring Boot框架

在过去的两三年的Spring生态系统中,最令人兴奋的是Spring Boot框架。或许从取名上能够得知这一框架设计初心:快速开启Spring运用。因此Spring 实质上,Boot应用程序是一个根据Spring框架的应用程序。这是Spring“协议书先于配置”理论的良好实践物质。可以帮助开发者迅速、更有效地搭建根据Spring生态系统的应用程序。

Spring Boot有什么魔法?全自动配置、发展依靠、Actuator、命令行界面(CLI) 是Spring Boot最主要的四个核心特点,在其中CLI是Spring Boot的能选特点尽管功能齐全,却也引入了一套非传统的开发模型,因此本系列文章只注重别的三个特点。如标题,文中是本系列的第一部分,将为您开启Spring Boot大门口,关键为您进一步分析启动过程及全自动配置完成基本原理。把握这一部分主要内容,了解一些Spring框架的基本知识,也会让你游刃有余。

2.5 B/S框架

B/S架构是互联网行业区别C/S架构,用以叙述浏览器与服务器之间的架构方式。一般来说,挑选B/S架构的主要原因是维修方便。当软件开发时,能够在本地进行检测。一般综合开发工具都有各自的开发与一键部署。当地浏览器能够及时出效果。测试工程师有专业的网络服务器,仅需布署就可以。假如正中间有什么问题,能够整顿。应用软件更新,只需后台维护编码,顾客依然应用以前的浏览器开展访问,因此客户端十分方便。现在市面上大部分每一个电脑操作系统服务平台只要是有窗口模式,除开命令行操作页面对话框,窗口模式可以放置浏览器,因此一切带窗口模式的计算机操作系统自已的浏览器或其它生产商的浏览器,或挪动浏览器,都能够访问网络服务器。访问网络服务器占用客户端网络资源非常少,不易出差错。即便客户端有问题,也仅需重新装系统,随后组装浏览器就可以。在程序流程性能和用户体验层面,挑选B/S架构开发设计应用软件特别适合如今的社会的主力发展趋向。

第3章 系统分析

本文作者在确定了研究的课题之后,从各大数字图书馆下载文献来阅读,并了解同类型的网站具备的大致功能,然后具体事务具体分析,得出本系统要研究的具体功能与性能。虽然分析系统这一阶段性工作主要是确定功能,但它却影响着后面系统开发环节的进展,系统分析这个环节是不能少的。

3.1 系统可行性分析

3.1.1技术可行性分析

研发设计程序流程挑选面向对象设计、功能齐全、简单实用的Java编程设计核心理念。MySQL数据库存储数据。Idea工具作为编程软件,win10计算机操作系统作为应用系统,以及数据库可视化工具等技术职称。一般来说,该程序流程的开发能够从技术上开展是可行的。

3.1.2经济可行性分析

开发的程序并不是向着商业服务程序方向设计与开发的,反而是做为毕业设计论文新项目开发的,主要运用于检测孩子在学校所学的知识,也锻练用户们使用互联网、书籍和别的方法进行自学能力。因而,该程序软件的开发不容易涉及到边际效益,也不会为软件的挑选付钱。你可以在开发软件的官网上下载所需要的软件,并根据要求的安装方法将软件安装在你的电脑中。一般来说,开发这一程序并没有经济发展开支。

3.1.3运行可行性分析

由于程序软件就是针对大部分一般操作用户,考虑到他的知识与文化水准,尤其开发了一个可操作度高的程序软件,能够轻而易举地让用户应用,数据可视化操作页面。一般来说,从用户操作程序的角度看,这一程序其实并不难操作。只需用户开启程序,就能避免专职人员学习培训开展程序作用操作,可以得出程序软件能够开发和操作。

3.2 系统流程

流程图这样的工具可以直观反映出系统内部的操作逻辑,可以帮助用户更好的理解系统。

3.2.1 操作信息流程

具体操作流程见下图

图3.1 操作流程图

3.2.2 登录信息流程

登录模块流程见下图

图3.2 登录流程图

3.2.3 删除信息流程

删除流程见下图。

图3.3 删除信息流程图

3.3 性能需求

需求分析报告包含依据用户的实际需要制订作用,及其将要定制的系统的性能需求分析报告。因而,在一般剖析系统时,一方面要剖析系统的功效,另一方面要搞清楚系统的性能。终究,一个性能好一点的系统的设计开发可以确保系统质量以及稳定性。

下面,从易学易用性、系统时间特性、系统稳定性等多个方面系统性能展开分析表明。

(1)系统容积规定:明确系统进行数据处理方法容量更大化。换句话说,假如系统建立模型容量临界点超出这一临界点,系统可能设备异常。

(2)系统精度规定:明确传送数据所需要的精度值,包含数值计算方法的精度值、数据信息精度系数的设定等。

(3)时长特点规定:系统建立模型有时限要求,那也是系统的时间也特点。一般剖析数据处理方法的时间也,设定用户标准的响应速度,及其系统在超负荷运行中能够偏移的范围值,要提前剖析明确。

(4)适应能力规定:当系统应对系统环境变化时,其融入这些变化的能力也要根据参数信息来反映。比如,应对变动的必须,系统必须通过强调必须设计方案的一个过程或系统来适应变化来反映系统的适应能力。

(5)易学易用性:除开作用应该考虑用户要求外,人机交互设计还要考虑到用户的用户习惯,包含界面风格、页面色彩选择与色彩搭配。尝试让用户接受简单学习后单独实际操作系统。

(6)系统稳定性:针对新手来说,容易出现一个问题,那便是产品设计开发的系统,由于人工操作失误奔溃,有的还会造成电脑崩溃。这种情况也说明了容错机制能力低系统不靠谱。

第4章 系统设计

用户对着浏览器操作,肯定会出现某些不可预料的问题,但是不代表着系统对于用户在浏览器上的操作不进行处理,所以说,要提前考虑可能会出现的问题。

4.1 系统设计思想

企业项目管理系统选用B/S架构设计,即网页和网站架构模式开发方式。这类系统构造可以理解为对 C/S 系统构造的改变与推广能够进行信息分布式计算,能够降低资源成本,提升定制的系统性能。在这样的设计下,极少有事务管理在前面完成,关键事务逻辑性大部分要在服务器端达到的。

系统的性能层为表明给用户的页面,用以表明和理解用户的数据,回到用户所提供的数据,交到系统解决,给予用户与系统间的互动操作面板;系统通讯层承担为性能层给予后面数据,并联接性能层和系统后台间的通讯,选用HTTP/HTTPS协议书,系统控制层主要从事从HTTP要求中获得信息,获取主要参数,并把它发放给不一样的处理方法服务项目(service层),并把service层处理过的数据返回前面(本系统应用JSON数据);系统的业务逻辑层的主要功能是挑选用户的键入信息,完成具体业务逻辑,及其数据浏览;系统数据浏览层主要从事实际操作数据,为业务逻辑层或控制层给予数据服务项目;系统数据库是系统存放数据的区域。完成特殊业务需要数据适用,必须纪录信息才能达到业务流程。

4.2 功能结构设计

图4.1即为设计的管理员功能结构,管理员权限操作的功能包括管理公告,管理企业项目管理系统信息,包括项目管理,培训管理,项目申报管理,薪资管理等,可以管理公告。

结构设计图

图4.1 管理员功能结构

4.3 数据库设计

企业项目管理系统运行中产生的数据需要按照提前设置的存储规则进行保存,设计出一个符合项目的最优数据存储格式,因为它能减少用户的等待时间,还可以对系统的请求在最短时间内进行响应。所以,对数据库设计时,需要对功能需求进行详细的拆分,以及对业务状态的细分,然后设计具体的存储规则,保证数据库能正常运作,缩短数据处理时间,并在一定程度上降低数据冗余,节省存储空间。

4.3.1 数据库概念设计

实体-联系图还有一个名称即E-R图,是Entity Relationship Diagram各英文单词首字母的缩写,它这种概念模型通常用于对现实世界进行描述。同时它还是一种能够直观表达数据中实体,联系,属性的有效手段。绘制E-R图能够选择的工具也有很多,但是Office Visio 这款软件在E-R图的绘制上一般都是作为首选工具,因为它是基于可视化处理,使用它创建E-R图非常简单。使用基本的E-R图构成元素,比如椭圆,菱形,矩形,还有实线段来表达对应的信息,椭圆代表属性,即实体的特征,矩形代表实体,即数据库中的一个具体数据表,菱形代表实体中相互关系,实线段主要是完成椭圆,矩形,菱形的连接。

(1)下图是论坛实体和其具备的属性。

C:/Users/Administrator/Desktop/temp111\1\____img\论坛.jpg 论坛实体属性图

(2)下图是用户实体和其具备的属性。

C:/Users/Administrator/Desktop/temp111\1\____img\用户.jpg 用户实体属性图

(3)下图是公告实体和其具备的属性。

C:/Users/Administrator/Desktop/temp111\1\____img\公告.jpg 公告实体属性图

(4)下图是项目实体和其具备的属性。

C:/Users/Administrator/Desktop/temp111\1\____img\项目.jpg 项目实体属性图

(5)下图是操作日志实体和其具备的属性。

C:/Users/Administrator/Desktop/temp111\1\____img\操作日志.jpg 操作日志实体属性图

(6)下图是项目申报实体和其具备的属性。

C:/Users/Administrator/Desktop/temp111\1\____img\项目申报.jpg 项目申报实体属性图

4.3.2 数据库物理设计

本小节主要任务即是根据上述内容进行数据存储结构的设计,实体的属性就用来表示字段名称,不同的字段表示的数据类型以及取值都不相同,以及该表各个字段是否能够保持空等进行说明,设计完成一张数据表的结构之后,在保存时同样要命名,尽量选择英文名称进行命名并保存,还不容易导致系统出错。接下来就对设计的表进行简单说明。

表4.1操作日志表

序号列名数据类型说明允许空
1IdIntid
2caozuorizhi_this_biaoString操作人所在表
3caozuorizhi_caozuobiaoString操作表
4caozuorizhi_caozuozhanghuString操作账户
5caozuorizhi_caozuoleixingString操作类型
6caozuorizhi_textString操作内容
7insert_timeDate操作时间
8create_timeDate创建时间

表4.2字典表

序号列名数据类型说明允许空
1IdIntid
2dic_codeString字段
3dic_nameString字段名
4code_indexInteger编码
5index_nameString编码名字
6super_idInteger父字段id
7beizhuString备注
8create_timeDate创建时间

表4.3论坛表

序号列名数据类型说明允许空
1IdIntid
2forum_nameString帖子标题
3yonghu_idInteger用户
4users_idInteger管理员
5forum_contentString发布内容
6super_idsInteger父id
7forum_state_typesInteger帖子状态
8insert_timeDate发帖时间
9update_timeDate修改时间
10create_timeDate创建时间

表4.4公告表

序号列名数据类型说明允许空
1IdIntid
2gonggao_nameString公告名称
3gonggao_photoString公告图片
4gonggao_typesInteger公告类型
5insert_timeDate发布时间
6gonggao_contentString公告详情
7create_timeDate创建时间

表4.5项目表

序号列名数据类型说明允许空
1IdIntid
2xiangmu_nameString项目名称
3xiangmu_uuid_numberString项目编号
4xiangmu_photoString项目照片
5xiangmu_typesInteger项目类型
6xiangmu_fileString项目文件
7xiangmu_contentString项目介绍
8xiangmu_deleteInteger逻辑删除
9insert_timeDate录入时间
10create_timeDate创建时间

表4.6项目申报表

序号列名数据类型说明允许空
1IdIntid
2xiangmu_yuyue_uuid_numberString报名编号
3xiangmu_idInteger项目
4yonghu_idInteger用户
5xiangmu_yuyue_textString申报理由
6xiangmu_fileString附件
7xiangmu_yuyue_yesno_typesInteger报名状态
8xiangmu_yuyue_yesno_textString审核回复
9xiangmu_yuyue_shenhe_timeDate审核时间
10insert_timeDate项目申报时间
11create_timeDate创建时间

表4.7用户表

序号列名数据类型说明允许空
1IdIntid
2yonghu_nameString用户姓名
3yonghu_phoneString用户手机号
4yonghu_id_numberString用户身份证号
5yonghu_photoString用户头像
6yonghu_emailString用户邮箱
7create_timeDate创建时间

表4.8管理员表

序号列名数据类型说明允许空
1IdIntid
2usernameString儿童名
3passwordString密码
4roleString角色
5addtimeDate新增时间

第5章 系统实现

编程人员在搭建的开发环境中,会让各种编程技术一起呈现出最终效果。本节就展示关键部分的页面效果。

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 公告类型管理界面

XiangmuServiceImpl.java
package com.service.impl;

import com.utils.StringUtil;
import com.service.DictionaryService;
import com.utils.ClazzDiff;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
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 org.springframework.lang.Nullable;
import org.springframework.util.Assert;
import com.dao.XiangmuDao;
import com.entity.XiangmuEntity;
import com.service.XiangmuService;
import com.entity.view.XiangmuView;

/**
 * 项目 服务实现类
 */
@Service("xiangmuService")
@Transactional
public class XiangmuServiceImpl extends ServiceImpl<XiangmuDao, XiangmuEntity> implements XiangmuService {

    @Override
    public PageUtils queryPage(Map<String,Object> params) {
        Page<XiangmuView> page =new Query<XiangmuView>(params).getPage();
        page.setRecords(baseMapper.selectListView(page,params));
        return new PageUtils(page);
    }


}

GonggaoController.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("/gonggao")
public class GonggaoController {
    private static final Logger logger = LoggerFactory.getLogger(GonggaoController.class);

    private static final String TABLE_NAME = "gonggao";

    @Autowired
    private GonggaoService gonggaoService;


    @Autowired
    private TokenService tokenService;

    @Autowired
    private CaozuorizhiService caozuorizhiService;//操作日志
    @Autowired
    private DictionaryService dictionaryService;//字典
    @Autowired
    private ForumService forumService;//论坛
    @Autowired
    private XiangmuService xiangmuService;//项目
    @Autowired
    private XiangmuYuyueService xiangmuYuyueService;//项目申报
    @Autowired
    private YonghuService yonghuService;//用户
    @Autowired
    private UsersService usersService;//管理员


    /**
    * 后端列表
    */
    @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"));
        CommonUtil.checkMap(params);
        PageUtils page = gonggaoService.queryPage(params);

        //字典表数据转换
        List<GonggaoView> list =(List<GonggaoView>)page.getList();
        for(GonggaoView c:list){
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(c, request);
        }
        caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"列表查询",list.toString());
        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);
        GonggaoEntity gonggao = gonggaoService.selectById(id);
        if(gonggao !=null){
            //entity转view
            GonggaoView view = new GonggaoView();
            BeanUtils.copyProperties( gonggao , view );//把实体数据重构到view中
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
    caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"单条数据查看",view.toString());
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

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

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

        Wrapper<GonggaoEntity> queryWrapper = new EntityWrapper<GonggaoEntity>()
            .eq("gonggao_name", gonggao.getGonggaoName())
            .eq("gonggao_types", gonggao.getGonggaoTypes())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        GonggaoEntity gonggaoEntity = gonggaoService.selectOne(queryWrapper);
        if(gonggaoEntity==null){
            gonggao.setInsertTime(new Date());
            gonggao.setCreateTime(new Date());
            gonggaoService.insert(gonggao);
            caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"新增",gonggao.toString());
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

    /**
    * 后端修改
    */
    @RequestMapping("/update")
    public R update(@RequestBody GonggaoEntity gonggao, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
        logger.debug("update方法:,,Controller:{},,gonggao:{}",this.getClass().getName(),gonggao.toString());
        GonggaoEntity oldGonggaoEntity = gonggaoService.selectById(gonggao.getId());//查询原先数据

        String role = String.valueOf(request.getSession().getAttribute("role"));
//        if(false)
//            return R.error(511,"永远不会进入");
        if("".equals(gonggao.getGonggaoPhoto()) || "null".equals(gonggao.getGonggaoPhoto())){
                gonggao.setGonggaoPhoto(null);
        }

            gonggaoService.updateById(gonggao);//根据id更新
            List<String> strings = caozuorizhiService.clazzDiff(gonggao, oldGonggaoEntity, request,new String[]{"updateTime"});
            caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"修改",strings.toString());
            return R.ok();
    }



    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        List<GonggaoEntity> oldGonggaoList =gonggaoService.selectBatchIds(Arrays.asList(ids));//要删除的数据
        gonggaoService.deleteBatchIds(Arrays.asList(ids));

        caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"删除",oldGonggaoList.toString());
        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");
        //.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
        try {
            List<GonggaoEntity> gonggaoList = 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){
                            //循环
                            GonggaoEntity gonggaoEntity = new GonggaoEntity();
//                            gonggaoEntity.setGonggaoName(data.get(0));                    //公告名称 要改的
//                            gonggaoEntity.setGonggaoPhoto("");//详情和图片
//                            gonggaoEntity.setGonggaoTypes(Integer.valueOf(data.get(0)));   //公告类型 要改的
//                            gonggaoEntity.setInsertTime(date);//时间
//                            gonggaoEntity.setGonggaoContent("");//详情和图片
//                            gonggaoEntity.setCreateTime(date);//时间
                            gonggaoList.add(gonggaoEntity);


                            //把要查询是否重复的字段放入map中
                        }

                        //查询是否重复
                        gonggaoService.insertBatch(gonggaoList);
                        caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"批量新增",gonggaoList.toString());
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }




    /**
    * 前端列表
    */
    @IgnoreAuth
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params, HttpServletRequest request){
        logger.debug("list方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));

        CommonUtil.checkMap(params);
        PageUtils page = gonggaoService.queryPage(params);

        //字典表数据转换
        List<GonggaoView> list =(List<GonggaoView>)page.getList();
        for(GonggaoView c:list)
            dictionaryService.dictionaryConvert(c, request); //修改对应字典表字段

        caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"列表查询",list.toString());
        return R.ok().put("data", page);
    }

    /**
    * 前端详情
    */
    @RequestMapping("/detail/{id}")
    public R detail(@PathVariable("id") Long id, HttpServletRequest request){
        logger.debug("detail方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
        GonggaoEntity gonggao = gonggaoService.selectById(id);
            if(gonggao !=null){


                //entity转view
                GonggaoView view = new GonggaoView();
                BeanUtils.copyProperties( gonggao , view );//把实体数据重构到view中

                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                    caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"单条数据查看",view.toString());
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    }


    /**
    * 前端保存
    */
    @RequestMapping("/add")
    public R add(@RequestBody GonggaoEntity gonggao, HttpServletRequest request){
        logger.debug("add方法:,,Controller:{},,gonggao:{}",this.getClass().getName(),gonggao.toString());
        Wrapper<GonggaoEntity> queryWrapper = new EntityWrapper<GonggaoEntity>()
            .eq("gonggao_name", gonggao.getGonggaoName())
            .eq("gonggao_types", gonggao.getGonggaoTypes())
//            .notIn("gonggao_types", new Integer[]{102})
            ;
        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        GonggaoEntity gonggaoEntity = gonggaoService.selectOne(queryWrapper);
        if(gonggaoEntity==null){
            gonggao.setInsertTime(new Date());
            gonggao.setCreateTime(new Date());
        gonggaoService.insert(gonggao);

            caozuorizhiService.insertCaozuorizhi(String.valueOf(request.getSession().getAttribute("role")),TABLE_NAME,String.valueOf(request.getSession().getAttribute("username")),"前台新增",gonggao.toString());
            return R.ok();
        }else {
            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="auto"
        >
            <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-col :span="12">
                    <el-form-item class="input" v-if="type!='info'"  label="备注" prop="beizhu">
                        <el-input v-model="ruleForm.beizhu"
                                  placeholder="备注" clearable  :readonly="ro.beizhu"></el-input>
                    </el-form-item>
                    <div v-else>
                        <el-form-item class="input" label="备注" prop="beizhu">
                            <el-input v-model="ruleForm.beizhu"
                                      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: {
                    /*beizhu: [
                        { required: true, message: '备注不能为空', trigger: 'blur' },
                        {  pattern: /^[1-9]\d*$/,
                            message: '备注只能为正整数',
                            trigger: 'blur'
                        }
                    ],*/
                }
            };
        },
        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":"sex_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"]="sex_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;
	background-color: transparent;
}
.btn .el-button {
  padding: 0;
}</style>

声明

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

  • 9
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值