小型企业客户关系管理系统pf

@TOC

springboot457小型企业客户关系管理系统pf

绪论

1.1 研究背景

当前社会各行业领域竞争压力非常大,随着当前时代的信息化,科学化发展,让社会各行业领域都争相使用新的信息技术,对行业内的各种相关数据进行科学化,规范化管理。这样的大环境让那些止步不前,不接受信息改革带来的信息技术的企业随时面临被淘汰,被取代的风险。所以当今,各个行业领域,不管是传统的教育行业,餐饮行业,还是旅游行业,医疗行业等领域都将使用新的信息技术进行信息革命,改变传统的纸质化,需要人手工处理工作事务的办公环境。软件信息技术能够覆盖社会各行业领域是时代的发展要求,各种数据以及文件真正实现电子化是信息社会发展的不可逆转的必然趋势。本小型企业客户关系管理系统也是紧跟科学技术的发展,运用当今一流的软件技术实现软件系统的开发,让小型企业客户关系管理系统完全通过管理系统实现科学化,规范化,程序化管理。从而帮助信息管理者节省事务处理的时间,降低数据处理的错误率,对于基础数据的管理水平可以起到促进作用,也从一定程度上对随意的业务管理工作进行了避免,同时,小型企业客户关系管理系统的数据库里面存储的各种动态信息,也为上层管理人员作出重大决策提供了大量的事实依据。总之,小型企业客户关系管理系统是一款可以真正提升管理者的办公效率的软件系统。

1.2 目的和意义

信息数据的处理完全依赖人工进行操作,会耗费大量的人工成本,特别是面对大量的数据信息时,传统人工操作不仅不能对数据的出错率进行保证,还容易出现各种信息资源的低利用率与低安全性问题。更有甚者,耽误大量的宝贵时间,尤其是对信息的更新,归纳与统计更是耗财耗力的过程。所以电子化信息管理的出现就能缓解以及改变传统人工方式面临的处境,一方面可以确保信息数据在短时间被高效处理,还能节省人力成本,另一方面可以确保信息数据的安全性,可靠性,并可以实现信息数据的快速检索与修改操作,这些优点是之前的旧操作模式无法比拟的。因此小型企业客户关系管理系统为数据信息的管理模式的升级与改革提供了重要的窗口。

1.3 论文结构安排

为了帮助用户更好的了解和理解程序的开发流程与相关内容,本文将通过六个章节进行内容阐述。

第一章:描述了程序的开发背景,程序运用于现实生活的目的与意义,以及程序文档的结构安排信息;

第二章:描述了程序的开发环境,包括程序开发涉及到的技术,程序开发使用的数据存储工具等信息;

第三章:描述了程序着手进行开发时,会面临的可行性问题,并对程序功能以及性能要求进行描述;

第四章:描述了程序大功能模块下的功能细分信息,以及存储程序数据的数据库表文件结构的设计信息等;

第五章:描述了程序的功能实现界面的内容,也对程序操作人员操作的部分功能进行了描述;

第六章:描述了程序功能的测试内容,并介绍了系统测试的概念与方法。

2 相关技术

2.1 VUE介绍

Vue是一套用以搭建操作界面的渐进架构。与其它大中型架构不一样的是,Vue 他们被设计成能够由下而上逐级运用。Vue 关键设计只注重网页视图效果展示,不但好用,并且易于与第三方框架和插件集成以现代工具等都/支持库配合使用。

2.2 MySQL数据库

MySQL是微软公司研发的平台软件,能够为消费者提供高效率的智能数据,数据信息十分靠谱。使用这些开展文件存储能够满足公共性企业经营管理各种各样数据信息的需要。是改进和更新使企业可以有效地运作重要应用软件,减少给用户发送短信的费用和数据信息管理方法基础设施。因而,挑选MySQL开展在线系统后台系统开发设计是非常有帮助的。这是一个很好的软件挑选。

2.3 Java语言

Java经过了20多年的发展,在各个领域都有一套解决的方案,成为企业主力开发的语言。Java跨平台,可运行在不同的服务器上。Java提供了大量的API扩展,语言强大。使用Java语言可以利用强大的类机制和框架,进行面向对象快速开发,进行敏捷迭代和开发,让开发人员专注于流浪动物领养系统的逻辑开发,同时,较好的安全机制和跨平台特性,可以让流浪动物领养系统可以较好适应移动OS平台。同时,Java语言的内置多线程支持也可以提供语言学习系统支持,同时多任务发生能够较好的调度。基于Java语言的Java、J2EE等成熟框架,都为Java开发提供了最好的选择。

3 系统分析

对于小型企业客户关系管理系统开发设计到的流程有,分析系统的功能,设计系统的结构,设计数据库,编码以及测试,其中,在系统分析中,所做的工作包括功能的确定,性能的分析等。

3.1.1技术可行性分析

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

3.1.2经济可行性分析

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

3.1.3运行可行性分析

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

3.2 系统性能分析

3.2.1系统安全性

该程序不允许别的来访者窃取程序里的隐秘信息,也不允许别的操作工操作过程别的管理方案的用户操作过程实际效果。为了能真真正正清除这种情况,我们要在程序开发设计与设计以前考虑到程序安全性。

3.2.2数据完整性

提到数据完整性,大家不得不提到常用程序流程表格作用。这种表格通常是获取大部分客户的数据信息,大部分客户应该根据表格的需求填写自已的名字信息和联系电话信息,有一些会出现额外信息填写规定,务必填写这个选项,不需要填写这个选项。假如大部分客户为了能保护好自己的个人隐私,但又不想被其他人搔扰,不填写必须的项目及别的信息,大部分客户在最后递交这一表格时,通常不可以递交。

数据库安全不仅仅局限于申请办理数据完整性,还仅限于系统内全部信息数据的联系,并要求不用出差错。

由于数据统计分析表中间会有一定的联络,因此同一个数据信息出现在另一个表中,因此这俩表中记载的同一个数据信息应当是一样的。在不同表中,不可能有同样的数据信息。

3.2.3系统可扩展性

一切都在发展趋势,程序员开发软件也要带上开发逻辑思维开展软件开发实际操作,那样开发的程序在符合业务需求的时候也会进行一定的程序更新和更新。不论是作用改善或是数据库系统更新,初始程序都能在初始的前提下迭代升级。让开发的程序你走越走越远。那也是消费者对程序软件应用的需求。

3.3 系统流程分析

假如管理员想电脑操作系统所提供的作用,管理员必须在系统登录界面填好管理员登陆的账户信息以及相应的登陆密码信息。管理员必须保证它们都能身份证验证的账号密码信息的准确性,让管理员根据登陆界面进到后台管理操作面板。图3.1是开发的程序软件流浪动物领养系统操作流程图。

图3.1 系统操作流程图

3.3.1系统登录流程

登陆系统流程表如下图所展示。

图3.2 系统登录流程图

3.3.2信息添加流程

信息添加过程如图所展示。

图3.3 添加信息流程图

3.3.3信息删除流程

删除信息删除全过程如图所展示。

图3.4 信息删除流程图

3.4 系统非功能需求分析

(1)完好性规定

此次研发的小型企业客户关系管理系统中记载的数据信息不可以维持为空,数据信息务必恰当查验。系统中数据联系不可以出差错,也无法弹冠相庆。数据分析表中同一数据信息在各个数据分析表里的表明具体内容应同样。

(2)技术性能

当用户操作小型企业客户关系管理系统的各部分时,弹出来界面的响应速度不可以过长,最好是保持在3秒,较大限定数值4秒,给用户一个良好的程序流程感受。该系统还应当可以另外带上多人合作浏览小型企业客户关系管理系统。

(3)界面要求

小型企业客户关系管理系统界面设计方案应注意用户的日常操作习惯性,如导航条设计方案不可以在右边,彻底违背用户应用页面的操作习惯性,作用导航栏字体样式和色彩应更为醒目,便捷用户非常容易寻找,防止用户消耗太多的时间开展作用操作。

(4)安全规定

确保小型企业客户关系管理系统的安全性,给用户一种靠谱、可信赖的觉得,系统在运行中,不可以一直出差错,与用户作用界面互动,及时沟通信息内容,系统设定登陆页面,使非系统用户无法打开系统作用界面。系统用户还填写用户名登陆密码方可进入系统主界面,充分保证系统数据信息处在运行状态。

4 系统设计

4.1 总体功能

小型企业客户关系管理系统是根据需求定制开发,开发软件选用idea平台配合MySQL数据库进行开发环境的搭建操作,网站采用为微信小程序结构进行开发,用户通过小程序访问项目,管理人员通过访问系统数据仅仅需要在客户端安装谷歌浏览器或者是当下常用浏览器就可以访问网站后台管理内容。

4.2 系统概要设计

本次拟开发的系统为了节约开发成本,也为了后期在维护和升级上的便利性,打算通过浏览器来实现系统功能界面的展示,让程序软件的主要事务集中在后台的服务器端处理,前端部分只用处理少量的事务逻辑。下面使用一张图(如图4.2所示)来说明程序的工作原理。

图4.2 程序工作的原理图

4.3 系统功能结构设计

在分析并得出使用者对程序的功能要求时,就可以进行程序设计了。如图4.3展示的就是管理员功能结构图,管理员在后台主要管理产品管理、产品订单管理、字典管理、公告管理、客户管理、反馈建议管理、客户走访管理、员工管理、管理员管理等。

结构设计图

图4.3 管理员功能结构图

4.4 数据库设计

程序功能操作不管是添加,修改,还是删除等功能产生的数据都是经由数据库进行数据保存和更新的,所以一个数据库设计的好坏也是程序是否好坏的判定标准,因为程序的成功,有一半的功劳都是靠数据库的优秀设计。数据库一旦设计得良好是可以减轻开发人员的开发负担的。

4.4.1 数据库E-R图设计

E-R 图分成实体、实体属性和实体之间的关系三个部分。一般来说,方形表明实体,椭圆型表明属性,边角表明关联性。在E中-R 在图上,实体是目标。比如,学生们、人员能够代表实体,E-R 图属性代表数据对象具有的属性,E-R 相片之间的关系是实体之间的关系。

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

C:/Users/Administrator/Desktop/temp111\6.1\____img\产品.jpg

产品实体属性图

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

C:/Users/Administrator/Desktop/temp111\6.1\____img\公告.jpg

公告实体属性图

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

C:/Users/Administrator/Desktop/temp111\6.1\____img\员工.jpg

员工实体属性图

(4)下图是反馈建议实体和其具备的属性。

C:/Users/Administrator/Desktop/temp111\6.1\____img\反馈建议.jpg

反馈建议实体属性图

(5)下图是产品订单实体和其具备的属性。

C:/Users/Administrator/Desktop/temp111\6.1\____img\产品订单.jpg

产品订单实体属性图

(6)下图是客户走访实体和其具备的属性。

C:/Users/Administrator/Desktop/temp111\6.1\____img\客户走访.jpg

客户走访实体属性图

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

C:/Users/Administrator/Desktop/temp111\6.1\____img\客户.jpg

客户实体属性图

4.4.2 数据库表结构设计

数据库系统一旦选定之后,需要根据程序要求在数据库中建立数据库文件,并在已经完成创建的数据库文件里面,为程序运行中产生的数据建立对应的数据表格,数据表结构设计就是对创建的数据表格进行字段设计,字段长度设计,字段类型设计等,当数据表格合理设计完成之后,才能正常存储相关程序运行产生的数据信息。

表4.1产品表

序号列名数据类型说明允许空
1IdIntid
2chanpin_nameString产品名称
3chanpin_uuid_numberString产品编号
4chanpin_photoString产品照片
5chanpin_danweiString单位
6chanpin_typesInteger产品类型
7chanpin_old_moneyBigDecimal产品原价
8chanpin_new_moneyBigDecimal现价
9chanpin_cangkuString所属仓库
10chanpin_contentString产品介绍
11insert_timeDate录入时间
12create_timeDate创建时间

表4.2产品订单表

序号列名数据类型说明允许空
1IdIntid
2yuangong_idInteger员工
3chanpin_idInteger产品
4kehu_idInteger客户
5chanpin_dingdan_uuid_numberString销售编号
6chanpin_dingdan_xiaoshou_typesInteger销售类型
7chanpin_dingdan_xiaoshoufangshi_typesInteger销售方式
8chanpin_dingdan_kuaidigongsiString快递公司
9chanpin_dingdan_danhaoString快递单号
10chanpin_dingdan_numberInteger销售数量
11chanpin_dingdan_jineBigDecimal销售金额
12chanpin_dingdan_timeDate销售时间
13chanpin_dingdan_typesInteger销售状态
14chanpin_dingdan_contentString销售备注
15insert_timeDate录入时间
16create_timeDate创建时间

表4.3字典表

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

表4.4公告表

序号列名数据类型说明允许空
1IdIntid
2gonggao_nameString公告名称
3gonggao_fileString附件
4gonggao_typesInteger公告类型
5gonggao_timeDate公告执行时间
6gonggao_contentString公告详情
7insert_timeDate发布时间
8create_timeDate创建时间

表4.5客户表

序号列名数据类型说明允许空
1IdIntid
2yuangong_idInteger员工
3kehu_uuid_numberString客户编号
4kehu_nameString客户姓名
5kehu_phoneString客户手机号
6kehu_id_numberString客户身份证号
7kehu_photoString客户照片
8sex_typesInteger性别
9kehu_emailString客户邮箱
10kehu_addressString住址
11hangye_typesInteger行业
12zhiwei_typesInteger职位
13diqu_typesInteger地区
14create_timeDate创建时间

表4.6反馈建议表

序号列名数据类型说明允许空
1IdIntid
2kehu_idInteger客户
3yuangong_idInteger员工
4kehu_fankui_uuid_numberString客户反馈编号
5kehu_fankui_nameString客户反馈标题
6kehu_fankui_fileString反馈附件
7kehu_fankui_typesInteger客户反馈类型
8fuwu_timeDate客户反馈时间
9kehu_fankui_contentString客户反馈内容
10kehu_fankuizhuangtai_typesInteger反馈状态
11insert_timeDate录入时间
12create_timeDate创建时间

表4.7客户走访表

序号列名数据类型说明允许空
1IdIntid
2kehu_idInteger客户
3yuangong_idInteger员工
4kehu_zoufang_uuid_numberString客户走访编号
5kehu_zoufang_nameString客户走访标题
6kehu_zoufang_fileString走访附件
7kehu_zoufang_typesInteger客户走访类型
8fuwu_timeDate客户走访时间
9kehu_zoufang_contentString客户走访内容
10insert_timeDate录入时间
11create_timeDate创建时间

表4.8员工表

序号列名数据类型说明允许空
1IdIntid
2yuangong_uuid_numberString员工编号
3yuangong_nameString员工姓名
4yuangong_phoneString员工手机号
5yuangong_id_numberString员工身份证号
6yuangong_photoString员工头像
7yuangong_emailString员工邮箱
8jinyong_typesInteger账户状态
9create_timeDate创建时间

表4.9管理员表

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

5 系统实现

系统实现部分就是将系统分析,系统设计部分的内容通过编码进行功能实现,以一个实际应用系统的形式展示系统分析与系统设计的结果。前面提到的系统分析,系统设计最主要还是进行功能,系统操作逻辑的设计,也包括了存储数据的数据库方面的设计等内容,系统实现就是一个最终的实施阶段,将前面的设计成果进行物理转化,最终出具可以运用于实际的软件系统。

5.1 管理员功能介绍

5.1.1 客户列表

如图5.1显示的就是客户列表页面,此页面提供给管理员的功能有:查看客户、新增客户、修改客户、删除客户等。

图5.1 客户列表页面

5.1.2 公告信息管理

公告信息管理页面提供的功能操作有:新增公告,修改公告,删除公告操作。下图就是公告信息管理页面。

图5.3 公告信息管理页面

5.1.3公告类型管理

公告类型管理页面显示所有公告类型,在此页面既可以让管理员添加新的公告信息类型,也能对已有的公告类型信息执行编辑更新,失效的公告类型信息也能让管理员快速删除。下图就是公告类型管理页面。

图5.3 公告类型列表页面

5.1.4 反馈建议管理

如图5.4显示的就是反馈建议管理页面,此页面提供给管理员的功能有:新增反馈建议,修改反馈建议,删除反馈建议。

图5.4反馈建议管理页面

5.1.5 反馈建议类型管理

如图5.5显示的就是反馈建议类型管理页面,此页面提供给管理员的功能有:新增反馈建议类型,修改反馈建议类型,删除反馈建议类型。

图5.5 反馈建议类型管理页面

系统

KehuServiceImpl.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.KehuDao;
import com.entity.KehuEntity;
import com.service.KehuService;
import com.entity.view.KehuView;

/**
 * 客户 服务实现类
 */
@Service("kehuService")
@Transactional
public class KehuServiceImpl extends ServiceImpl<KehuDao, KehuEntity> implements KehuService {

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


}

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

    private static final String TABLE_NAME = "chanpin";

    @Autowired
    private ChanpinService chanpinService;


    @Autowired
    private TokenService tokenService;

    @Autowired
    private ChanpinDingdanService chanpinDingdanService;//产品订单
    @Autowired
    private DictionaryService dictionaryService;//字典
    @Autowired
    private GonggaoService gonggaoService;//公告
    @Autowired
    private KehuService kehuService;//客户
    @Autowired
    private KehuFankuiService kehuFankuiService;//反馈建议
    @Autowired
    private KehuZoufangService kehuZoufangService;//客户走访
    @Autowired
    private YuangongService yuangongService;//员工
    @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("yuangongId",request.getSession().getAttribute("userId"));
        CommonUtil.checkMap(params);
        PageUtils page = chanpinService.queryPage(params);

        //字典表数据转换
        List<ChanpinView> list =(List<ChanpinView>)page.getList();
        for(ChanpinView 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);
        ChanpinEntity chanpin = chanpinService.selectById(id);
        if(chanpin !=null){
            //entity转view
            ChanpinView view = new ChanpinView();
            BeanUtils.copyProperties( chanpin , view );//把实体数据重构到view中
            //修改对应字典表字段
            dictionaryService.dictionaryConvert(view, request);
            return R.ok().put("data", view);
        }else {
            return R.error(511,"查不到数据");
        }

    }

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

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

        Wrapper<ChanpinEntity> queryWrapper = new EntityWrapper<ChanpinEntity>()
            .eq("chanpin_name", chanpin.getChanpinName())
            .eq("chanpin_danwei", chanpin.getChanpinDanwei())
            .eq("chanpin_types", chanpin.getChanpinTypes())
            .eq("chanpin_cangku", chanpin.getChanpinCangku())
            ;

        logger.info("sql语句:"+queryWrapper.getSqlSegment());
        ChanpinEntity chanpinEntity = chanpinService.selectOne(queryWrapper);
        if(chanpinEntity==null){
            chanpin.setInsertTime(new Date());
            chanpin.setCreateTime(new Date());
            chanpinService.insert(chanpin);
            return R.ok();
        }else {
            return R.error(511,"表中有相同数据");
        }
    }

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

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

            chanpinService.updateById(chanpin);//根据id更新
            return R.ok();
    }



    /**
    * 删除
    */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
        logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
        List<ChanpinEntity> oldChanpinList =chanpinService.selectBatchIds(Arrays.asList(ids));//要删除的数据
        chanpinService.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 yuangongId = 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<ChanpinEntity> chanpinList = 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){
                            //循环
                            ChanpinEntity chanpinEntity = new ChanpinEntity();
//                            chanpinEntity.setChanpinName(data.get(0));                    //产品名称 要改的
//                            chanpinEntity.setChanpinUuidNumber(data.get(0));                    //产品编号 要改的
//                            chanpinEntity.setChanpinPhoto("");//详情和图片
//                            chanpinEntity.setChanpinDanwei(data.get(0));                    //单位 要改的
//                            chanpinEntity.setChanpinTypes(Integer.valueOf(data.get(0)));   //产品类型 要改的
//                            chanpinEntity.setChanpinOldMoney(data.get(0));                    //产品原价 要改的
//                            chanpinEntity.setChanpinNewMoney(data.get(0));                    //现价 要改的
//                            chanpinEntity.setChanpinCangku(data.get(0));                    //所属仓库 要改的
//                            chanpinEntity.setChanpinContent("");//详情和图片
//                            chanpinEntity.setInsertTime(date);//时间
//                            chanpinEntity.setCreateTime(date);//时间
                            chanpinList.add(chanpinEntity);


                            //把要查询是否重复的字段放入map中
                                //产品编号
                                if(seachFields.containsKey("chanpinUuidNumber")){
                                    List<String> chanpinUuidNumber = seachFields.get("chanpinUuidNumber");
                                    chanpinUuidNumber.add(data.get(0));//要改的
                                }else{
                                    List<String> chanpinUuidNumber = new ArrayList<>();
                                    chanpinUuidNumber.add(data.get(0));//要改的
                                    seachFields.put("chanpinUuidNumber",chanpinUuidNumber);
                                }
                        }

                        //查询是否重复
                         //产品编号
                        List<ChanpinEntity> chanpinEntities_chanpinUuidNumber = chanpinService.selectList(new EntityWrapper<ChanpinEntity>().in("chanpin_uuid_number", seachFields.get("chanpinUuidNumber")));
                        if(chanpinEntities_chanpinUuidNumber.size() >0 ){
                            ArrayList<String> repeatFields = new ArrayList<>();
                            for(ChanpinEntity s:chanpinEntities_chanpinUuidNumber){
                                repeatFields.add(s.getChanpinUuidNumber());
                            }
                            return R.error(511,"数据库的该表中的 [产品编号] 字段已经存在 存在数据为:"+repeatFields.toString());
                        }
                        chanpinService.insertBatch(chanpinList);
                        return R.ok();
                    }
                }
            }
        }catch (Exception e){
            e.printStackTrace();
            return R.error(511,"批量插入数据异常,请联系管理员");
        }
    }




}


BaiduUtil.java
package com.utils;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.json.JSONObject;


/**
* @author yangliyuan
* @version 创建时间:2020年2月7日 下午9:37:05
* 类说明 : 
*/

public class BaiduUtil {
	
    /**
     * 根据经纬度获得省市区信息
     * @param lon 纬度
     * @param lat 经度
     * @param coordtype 经纬度坐标系
     * @return
     */
    public static Map<String, String> getCityByLonLat(String key, String lng, String lat) {
        String location = lat + "," + lng;
        try {
            //拼装url
            String url = "http://api.map.baidu.com/reverse_geocoding/v3/?ak="+key+"&output=json&coordtype=wgs84ll&location="+location;
            String result = HttpClientUtils.doGet(url);
            JSONObject o = new JSONObject(result);
            Map<String, String> area = new HashMap<>();
			area.put("province", o.getJSONObject("result").getJSONObject("addressComponent").getString("province"));
			area.put("city", o.getJSONObject("result").getJSONObject("addressComponent").getString("city"));
			area.put("district", o.getJSONObject("result").getJSONObject("addressComponent").getString("district"));
			area.put("street", o.getJSONObject("result").getJSONObject("addressComponent").getString("street"));
            return area;
        }catch (Exception e) {
            e.printStackTrace();
        }
        return null;
    }

    /**
	     * 获取API访问token
	     * 该token有一定的有效期,需要自行管理,当失效时需重新获取.
	     * @param ak - 百度云官网获取的 API Key
	     * @param sk - 百度云官网获取的 Securet Key
	     * @return assess_token
	     */
    public static String getAuth(String ak, String sk) {
        // 获取token地址
        String authHost = "https://aip.baidubce.com/oauth/2.0/token?";
        String getAccessTokenUrl = authHost
                // 1. grant_type为固定参数
                + "grant_type=client_credentials"
                // 2. 官网获取的 API Key
                + "&client_id=" + ak
                // 3. 官网获取的 Secret Key
                + "&client_secret=" + sk;
        try {
            URL realUrl = new URL(getAccessTokenUrl);
            // 打开和URL之间的连接
            HttpURLConnection connection = (HttpURLConnection) realUrl.openConnection();
            connection.setRequestMethod("GET");
            connection.connect();
            // 获取所有响应头字段
            Map<String, List<String>> map = connection.getHeaderFields();
            // 遍历所有的响应头字段
            for (String key : map.keySet()) {
                System.err.println(key + "--->" + map.get(key));
            }
            // 定义 BufferedReader输入流来读取URL的响应
            BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
            String result = "";
            String line;
            while ((line = in.readLine()) != null) {
                result += line;
            }
            /**
             * 返回结果示例
             */
            System.err.println("result:" + result);
            org.json.JSONObject jsonObject = new org.json.JSONObject(result);
            String access_token = jsonObject.getString("access_token");
            return access_token;
        } catch (Exception e) {
            System.err.printf("获取token失败!");
            e.printStackTrace(System.err);
        }
        return null;
    }

}

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":"diqu_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"]="diqu_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>

声明

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值