中国红客联盟 首页 资讯 国内安全 查看内容

ssm469基于web的农产品质量安全检测网站设计与实现+vue

2025-3-3 09:54| 发布者: Honkers| 查看: 125| 评论: 0

摘要: 博主介绍:专注于Java(springboot ssm 等开发框架) vue  .net  php phython node.js    uniapp 微信小程序 等诸多技术领域和毕业项目实战、企业信息化系统建设,从业十五余年开发设计

博主介绍:专注于Java(springboot ssm 等开发框架) vue  .net  php phython node.js    uniapp 微信小程序 等诸多技术领域和毕业项目实战、企业信息化系统建设,从业十五余年开发设计教学工作
☆☆☆ 精彩专栏推荐订阅☆☆☆☆☆不然下次找不到哟
我的博客空间发布了2000+毕设题目 方便大家学习使用
感兴趣的可以先收藏起来,还有大家在毕设选题,项目以及论文编写等相关问题都可以给我留言咨询,希望帮助更多的人
更多项目地址 介绍  
文末下方有源码获取地址

ssm469基于web的农产品质量安全检测网站设计与实现+vue 计算机设计源码

4.2功能结构设计

为了让系统的编码可以顺利进行,特意对本系统功能进行细分设计,设计的系统功能结构见下图。

图4.1 系统功能结构图

4.3 数据库设计

开发一个系统也需要提前设计数据库。这里的数据库是相关数据的集合,存储在一起的这些数据也是按照一定的组织方式进行的。目前,数据库能够服务于多种应用程序,则是源于它存储方式最佳,具备数据冗余率低的优势。虽然数据库为程序提供信息存储服务,但它与程序之间也可以保持较高的独立性。总而言之,数据库经历了很长一段时间的发展,从最初的不为人知,到现在的人尽皆知,其相关技术也越发成熟,同时也拥有着坚实的理论基础。

4.3.1 数据库概念设计

这部分内容需要借助数据库关系图来完成,也需要使用专门绘制数据库关系图的工具,比如Visio工具就可以设计E-R图(数据库关系图)。设计数据库,也需要按照设计的流程进行,首先还是要根据需求完成实体的确定,分析实体具有的特征,还有对实体间的关联关系进行确定。最后才是使用E-R模型的表示方法,绘制本系统的E-R图。不管是使用亿图软件,还是Visio工具,对于E-R模型的表示符号都一样,通常矩形代表实体,实体间存在的关系用菱形符号表示,实体的属性也就是实体的特征用符号椭圆表示。最后使用直线将矩形,菱形和椭圆等符号连接起来。接下来就开始对本系统的E-R图进行绘制。

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


图4.1 论坛实体属性图

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


图4.2 用户实体属性图

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


图4.3 公告实体属性图

(4)下图是字典表实体和其具备的属性。


图4.4 字典表实体属性图

(5)下图是留言版实体和其具备的属性。


图4.5 留言版实体属性图

4.3.2 数据库物理设计

作为程序后台的支持,本数据库也需要设计数据存储的结构。而数据存储结构的设计就包括了数据表结构的设计和创建。数据表结构包括了字段,数据类型,还有字段的取值范围等信息。而E-R模型中的实体就是一张表,实体的特征就可以作为该表中的字段,根据本程序信息存储要求,设计每个字段需要的类型,还有该字段的取值范围等。每当设计完成一张数据表,就需要及时保存在数据库里面,并对该设计的数据表准确命名,要求设置的数据表的名称尽量不要是中文,而且要方便记忆。因为在程序编码阶段,通过SQL语句可以把程序里面的数据写入在各个数据表里面,而这个环节需要使用到数据表的名称。如果数据表名称是中文的话,可能会乱码并影响程序运行。下面就以表格形式展示设计的结果。

表4.1产品追溯表

序号

列名

数据类型

说明

允许空

1

Id

Int

id

2

chanpin_uuid_number

String

追溯码

3

chanpin_name

String

产品名称

4

chanpin_types

Integer

产品类型

5

chanpin_photo

String

产品图片

6

chanpin_zhongzhi

String

种植企业

7

chanpin_jiagong

String

加工企业

8

chanpin_yunshu

String

运输企业

9

chanpin_xiaoshou

String

销售企业

10

chanpin_yuancailiao

String

主要原材料

11

chanpin_zhongzi

String

种子

12

chanpin_feiliao

String

肥料

13

chanpin_nongyao

String

农药

14

chanpin_number

Integer

数量

15

chanpin_danwei

String

单位

16

chanpin_time

Date

生产日期

17

chanpin_baozhi

Integer

保质期

18

create_time

Date

创建时间

表4.2字典表表

序号

列名

数据类型

说明

允许空

1

Id

Int

id

2

dic_code

String

字段

3

dic_name

String

字段名

4

code_index

Integer

编码

5

index_name

String

编码名字

6

super_id

Integer

父字段id

7

beizhu

String

备注

8

create_time

Date

创建时间

表4.3论坛表

序号

列名

数据类型

说明

允许空

1

Id

Int

id

2

forum_name

String

帖子标题

3

yonghu_id

Integer

用户

4

users_id

Integer

管理员

5

forum_content

String

发布内容

6

super_ids

Integer

父id

7

forum_state_types

Integer

帖子状态

8

insert_time

Date

发帖时间

9

update_time

Date

修改时间

10

create_time

Date

创建时间

表4.4留言版表

序号

列名

数据类型

说明

允许空

1

Id

Int

id

2

yonghu_id

Integer

用户

3

liuyan_name

String

留言标题

4

liuyan_text

String

留言内容

5

reply_text

String

回复内容

6

insert_time

Date

留言时间

7

update_time

Date

回复时间

8

create_time

Date

创建时间

表4.5公告表

序号

列名

数据类型

说明

允许空

1

Id

Int

id

2

news_name

String

公告标题

3

news_types

Integer

公告类型

4

news_photo

String

公告图片

5

insert_time

Date

公告时间

6

news_content

String

公告详情

7

create_time

Date

创建时间

表4.6用户表

序号

列名

数据类型

说明

允许空

1

Id

Int

id

2

yonghu_name

String

用户姓名

3

yonghu_photo

String

头像

4

yonghu_phone

String

用户手机号

5

yonghu_id_number

String

用户身份证号

6

yonghu_email

String

邮箱

7

yonghu_delete

Integer

假删

8

create_time

Date

创建时间

表4.7用户表表

序号

列名

数据类型

说明

允许空

1

Id

Int

id

2

username

String

用户名

3

password

String

密码

4

role

String

角色

5

addtime

Date

新增时间

5 系统实现

这个环节需要使用前面的设计方案,包括对系统模块的设计,还有对程序后台的数据支持的数据库的设计等。不过这部分内容还是强调系统编码人员的开发能力,要把前面设计的内容通过编码的形式以一个完整的,可以运行的系统呈现出来。

功能模块的实现

5.1用户信息管理

如图5.1显示的就是用户信息管理页面,此页面提供给管理员的功能有:用户信息的查询管理,可以删除用户信息、修改用户信息、新增用户信息,

还进行了对用户名称的模糊查询的条件

图5.1 用户信息管理页面

5.2 产品追溯管理

如图5.2显示的就是产品追溯管理页面,此页面提供给管理员的功能有:查看已发布的产品追溯数据,修改产品追溯,产品追溯作废,即可删除,还进行了对产品追溯名称的模糊查询 产品追溯信息的类型查询等等一些条件。

图5.2 产品追溯管理页面

[code] 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); @Autowired private ChanpinService chanpinService; @Autowired private TokenService tokenService; @Autowired private DictionaryService dictionaryService; //级联表service @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 = 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_uuid_number", chanpin.getChanpinUuidNumber()) .eq("chanpin_name", chanpin.getChanpinName()) .eq("chanpin_types", chanpin.getChanpinTypes()) .eq("chanpin_zhongzhi", chanpin.getChanpinZhongzhi()) .eq("chanpin_jiagong", chanpin.getChanpinJiagong()) .eq("chanpin_yunshu", chanpin.getChanpinYunshu()) .eq("chanpin_xiaoshou", chanpin.getChanpinXiaoshou()) .eq("chanpin_yuancailiao", chanpin.getChanpinYuancailiao()) .eq("chanpin_zhongzi", chanpin.getChanpinZhongzi()) .eq("chanpin_feiliao", chanpin.getChanpinFeiliao()) .eq("chanpin_nongyao", chanpin.getChanpinNongyao()) .eq("chanpin_number", chanpin.getChanpinNumber()) .eq("chanpin_danwei", chanpin.getChanpinDanwei()) .eq("chanpin_time", new SimpleDateFormat("yyyy-MM-dd").format(chanpin.getChanpinTime())) .eq("chanpin_baozhi", chanpin.getChanpinBaozhi()) ; logger.info("sql语句:"+queryWrapper.getSqlSegment()); ChanpinEntity chanpinEntity = chanpinService.selectOne(queryWrapper); if(chanpinEntity==null){ 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){ logger.debug("update方法:,,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>() .notIn("id",chanpin.getId()) .andNew() .eq("chanpin_uuid_number", chanpin.getChanpinUuidNumber()) .eq("chanpin_name", chanpin.getChanpinName()) .eq("chanpin_types", chanpin.getChanpinTypes()) .eq("chanpin_zhongzhi", chanpin.getChanpinZhongzhi()) .eq("chanpin_jiagong", chanpin.getChanpinJiagong()) .eq("chanpin_yunshu", chanpin.getChanpinYunshu()) .eq("chanpin_xiaoshou", chanpin.getChanpinXiaoshou()) .eq("chanpin_yuancailiao", chanpin.getChanpinYuancailiao()) .eq("chanpin_zhongzi", chanpin.getChanpinZhongzi()) .eq("chanpin_feiliao", chanpin.getChanpinFeiliao()) .eq("chanpin_nongyao", chanpin.getChanpinNongyao()) .eq("chanpin_number", chanpin.getChanpinNumber()) .eq("chanpin_danwei", chanpin.getChanpinDanwei()) .eq("chanpin_time", new SimpleDateFormat("yyyy-MM-dd").format(chanpin.getChanpinTime())) .eq("chanpin_baozhi", chanpin.getChanpinBaozhi()) ; logger.info("sql语句:"+queryWrapper.getSqlSegment()); ChanpinEntity chanpinEntity = chanpinService.selectOne(queryWrapper); if("".equals(chanpin.getChanpinPhoto()) || "null".equals(chanpin.getChanpinPhoto())){ chanpin.setChanpinPhoto(null); } if(chanpinEntity==null){ chanpinService.updateById(chanpin);//根据id更新 return R.ok(); }else { return R.error(511,"表中有相同数据"); } } /** * 删除 */ @RequestMapping("/delete") public R delete(@RequestBody Integer[] ids){ logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString()); chanpinService.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<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.setChanpinUuidNumber(data.get(0)); //追溯码 要改的 // chanpinEntity.setChanpinName(data.get(0)); //产品名称 要改的 // chanpinEntity.setChanpinTypes(Integer.valueOf(data.get(0))); //产品类型 要改的 // chanpinEntity.setChanpinPhoto("");//照片 // chanpinEntity.setChanpinZhongzhi(data.get(0)); //种植企业 要改的 // chanpinEntity.setChanpinJiagong(data.get(0)); //加工企业 要改的 // chanpinEntity.setChanpinYunshu(data.get(0)); //运输企业 要改的 // chanpinEntity.setChanpinXiaoshou(data.get(0)); //销售企业 要改的 // chanpinEntity.setChanpinYuancailiao(data.get(0)); //主要原材料 要改的 // chanpinEntity.setChanpinZhongzi(data.get(0)); //种子 要改的 // chanpinEntity.setChanpinFeiliao(data.get(0)); //肥料 要改的 // chanpinEntity.setChanpinNongyao(data.get(0)); //农药 要改的 // chanpinEntity.setChanpinNumber(Integer.valueOf(data.get(0))); //数量 要改的 // chanpinEntity.setChanpinDanwei(data.get(0)); //单位 要改的 // chanpinEntity.setChanpinTime(new Date(data.get(0))); //生产日期 要改的 // chanpinEntity.setChanpinBaozhi(Integer.valueOf(data.get(0))); //保质期(天) 要改的 // 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){ 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)); // 没有指定排序字段就默认id倒序 if(StringUtil.isEmpty(String.valueOf(params.get("orderBy")))){ params.put("orderBy","id"); } 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("/detail/{id}") public R detail(@PathVariable("id") Long id, HttpServletRequest request){ logger.debug("detail方法:,,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("/add") public R add(@RequestBody ChanpinEntity chanpin, HttpServletRequest request){ logger.debug("add方法:,,Controller:{},,chanpin:{}",this.getClass().getName(),chanpin.toString()); Wrapper<ChanpinEntity> queryWrapper = new EntityWrapper<ChanpinEntity>() .eq("chanpin_uuid_number", chanpin.getChanpinUuidNumber()) .eq("chanpin_name", chanpin.getChanpinName()) .eq("chanpin_types", chanpin.getChanpinTypes()) .eq("chanpin_zhongzhi", chanpin.getChanpinZhongzhi()) .eq("chanpin_jiagong", chanpin.getChanpinJiagong()) .eq("chanpin_yunshu", chanpin.getChanpinYunshu()) .eq("chanpin_xiaoshou", chanpin.getChanpinXiaoshou()) .eq("chanpin_yuancailiao", chanpin.getChanpinYuancailiao()) .eq("chanpin_zhongzi", chanpin.getChanpinZhongzi()) .eq("chanpin_feiliao", chanpin.getChanpinFeiliao()) .eq("chanpin_nongyao", chanpin.getChanpinNongyao()) .eq("chanpin_number", chanpin.getChanpinNumber()) .eq("chanpin_danwei", chanpin.getChanpinDanwei()) .eq("chanpin_baozhi", chanpin.getChanpinBaozhi()) ; logger.info("sql语句:"+queryWrapper.getSqlSegment()); ChanpinEntity chanpinEntity = chanpinService.selectOne(queryWrapper); if(chanpinEntity==null){ chanpin.setCreateTime(new Date()); chanpinService.insert(chanpin); return R.ok(); }else { return R.error(511,"表中有相同数据"); } } } [/code]

5.3产品类型管理

如图5.3显示的就是产品类型管理页面,此页面提供给管理员的功能有:根据产品类型进行条件查询,还可以对产品类型进行新增、修改、查询操作等等。

图5.3 产品类型管理页面


大家点赞、收藏、关注、评论啦  其他的定制服务 商务合作  下方联系卡片↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓ 或者私信作者
 


免责声明:本内容来源于网络,如果侵犯了您的权益,请联系站长,我们会及时删除侵权内容,谢谢合作!

路过

雷人

握手

鲜花

鸡蛋

发表评论

中国红客联盟公众号

联系站长QQ:5520533

admin@chnhonker.com
Copyright © 2001-2025 Discuz Team. Powered by Discuz! X3.5 ( 粤ICP备13060014号 )|天天打卡 本站已运行