【若依RuoYi-Vue | 项目实战】帝可得后台管理系统(一)

本文涉及的产品
对象存储 OSS,20GB 3个月
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
简介: 在学习完 若依环境搭建 和 若依二次开发案例 后,我们将基于若依脚手架完成一个关于智能货柜的项目实战——帝可得!帝可得是一个基于物联网概念下的智能售货机运营管理系统。本文将带领大家使用若依框架从0到1进行项目开发与测试。


在学习完 若依环境搭建若依二次开发案例 后,我们将基于若依脚手架完成一个关于智能货柜的项目实战——帝可得!


一、项目背景介绍

1、什么是帝可得?

帝可得是一个基于物联网概念下的智能售货机运营管理系统

2、物联网

物联网(IoT:Internet of Things)简单来说,就是让各种物品通过互联网连接起来,实现信息的交换和通信。

这个概念听起来可能有点抽象,但我们可以把它想象成一个超级大的社交网络。不过,这个网络里的成员不是人类,而是各种物品。比如,你的冰箱、洗衣机、甚至是你的汽车,它们都可以通过互联网互相交流信息,就像是它们自己在聊天一样。

物联网的神奇之处在于,它能够让这些物品变得更加“聪明”。它们能够感知周围的环境,并且能够根据情况自动做出反应。举个例子,如果你的家里安装了智能家居系统,当你下班回家的路上,家里的空调就能提前开启,自动调整到你喜欢的温度,让你一回到家就能感受到舒适的环境。

总的来说将现实物体赋予感知、通信和智能化的能力,为人们提供更加智能化和便利的生活和工作环境

应用场景:智能家居、共享充电中、智能售货机

3、售货机术语

区域管理: 为了更高效地进行经营管理,公司将运营范围划分为若干个逻辑区域。这些区域的划分基于业务需求,可能与地理上的行政区域有所区别,以确保更合理的资源分配和更高效的运营管理。

点位选择: 点位指的是智能售货机的具体放置位置。选择点位时,我们会考虑人流量、目标顾客群体、可见度以及便利性等因素,以最大化售货机的使用效率和顾客的购买体验。

售货机功能: 智能售货机就像是一个自动的小店,里面摆满了各种商品。顾客想要什么,直接在机器上选,然后机器就会把商品送到他们手中,就像是一个自动化的仓库。

货道设计:售货机里面的货道,你可以想象成超市里的那种货架。每一层都有好几个位置可以放商品,这样就能放很多种不同的商品,而且每一层都能放很多,这样顾客的选择就会更多。

4、角色与功能

一个完整的售货机系统由五端五角色组成:

  1. 管理员:对基础数据(区域、点位、设备、货道、商品等)进行管理,创建工单(指派运维或运营人员),查看订单,查看各种统计报表。
  2. 运维人员:投放设备、撤除设备、维修设备。
  3. 运营人员:补货。
  4. 合作商:仅提供点位,坐收渔翁之利。
  5. 消费者:  在小程序或屏幕端下单购买商品。

5、业务流程

整个工程中,主要对核心的业务进行实现,主要包含下面的业务流程:

(1)平台管理员:主要作用有基础数据的管理和创建工单排除员工完成维修或补货。

(2)运营人员:主要作用是处理运营工单业务(补货等操作)

(3)运维人员:主要作用是处理运维工单业务(设备维修等操作)

(4)消费者:供C端用户使用。消费者扫描售货机上的二维码可以打开此端。主要作用是完成在售货机的购物操作。

(1)平台管理员

上图中的简要流程:

①:平台管理人员登录到系统管理后台系统

②:创建区域数据

③:创建区域下点位数据

④:添加运维/运营人员

⑤:创建售货机信息

⑥:设置售货机点位信息

⑦:创建运维投放工单,由运维人员开始投放设备(安装设备)

⑧:设置售卖的商品信息

⑨:创建运营补货工单,由运营人员开始投放商品信息

(2)运维人员

上图中的简要流程:

①:运维人员通过App登录运营系统

②:在App对派送过来的工单进行处理

③:接受工单后在指定的投放点安装售货机

④:拒绝工单该运维人员的工单结束

(3)运营人员

上图中的简要流程:

①:运营人员通过App登录运营系统

②:在App对派送过来的工单进行处理

③:接受工单后在指定的售货机的商品进行补货

④:拒绝工单该运维人员的工单结束

(4)消费者

上图中的简要流程:

方式一:

①:用户通过售货机二维码进行购买商品

②:扫码后在手机端微信小程序选择商品

③:支付成功后在售货机取货

方式二:

①:用户在售货机上选择商品

②:在选择商品后扫码支付商品的二维码

③:支付成功后在售货机取货

6、产品原型

帝可得项目产品原型设计:https://codesign.qq.com/s/426304924036117

7、库表设计

一个区域可以有多个点位

一个点位可以有多个售货机

一个售货机有多个货道

多个货道可以放置同一样商品

一个商品类型下有多个商品

一个售货机类型下有多个售货机

一个合作商有多个点位

合作商和区域之间没有关系,因为合作商拥有的多个点位可以分布在不同的区域

每个区域下有多个运维和运营人员,他们来负责这个区域下的设备的运维和运营


二、项目环境搭建

1、搭建后端项目

(1)Git克隆并初始化项目

后端仓库地址:https://gitee.com/yudian1991/dkd-parent.git

首先登录gitee账号,将项目Fork到自己的远程仓库。

Fork完成后,在IDEA中选择Get from VCS,复制粘贴自己刚刚克隆好的仓库地址。

使用idea打开项目后,等待环境检查(主要是Maven下载项目依赖),如果模块名没有加粗,可以先clean后install。

(2)MySQL导入与配置

  1. 创建数据库create schema dkd;
  2. 执行下图的sql脚本文件,完成导入

  1. dkd-admin模块下,编辑resources目录下的application-druid.yml,修改数据库连接

(3)Redis配置与启动

本项目Redis部署在Linux中,使用的版本为6.2.6,在redis解压目录下,编辑redis.conf配置文件,设置redis密码。

设置Redis密码是为了增强数据安全性、防止未授权访问和保护关键信息,从而确保应用程序的稳定性和合规性。

  • 配置redis.conf:
vim redis.conf
# 按/xxx就可以查找xxx相关的字段。然后按n查找下一个,N查找上一个。:noh取消高亮显示。
# 允许访问(监听)的地址,默认是127.0.0.1,会导致只能在本地访问。修改为0.0.0.0则可以在任意IP访问,生产环境不要设置为0.0.0.0
bind 0.0.0.0
# 守护进程,修改为yes后即可后台运行
daemonize yes
# 密码,设置后访问Redis必须输入密码
requirepass redispassword
  • 启动redis:
# 进入redis安装目录,redis.conf所在目录
cd /usr/local/src/redis-6.2.6
# 启动redis
redis-server redis.conf
# 查看Redis进程是否启动
ps -ef | grep redis

2、搭建前端项目

(1)Git克隆并初始化项目

前端仓库地址:https://gitee.com/yudian1991/dkd-vue.git

同样将项目Fork到自己的远程仓库,打开vscode,源代码管理->克隆仓库,并选择克隆存储位置。

(2)安装依赖

npm下载第三方依赖慢的解决方案:

# 查看当前设置的npm镜像源地址 默认是https://registry.npmjs.org/
npm config get registry
# 将npm的镜像源切换至淘宝镜像,切换后,再次运行npm install
npm config set registry https://registry.npmmirror.com
# npm -v如果大于7,就可以使用并行安装cnpm,安装完成后,可以使用cnpm i命令来替代npm i命令进行包的安装
npm install cnpm -g --registry=https://registry.npmmirror.com

npm install安装依赖完成后会生成一个node_modules文件夹。

(3)运行前端项目

# 启动前端服务
npm run dev

打开浏览器,输入:([http://localhost:80) 默认账户/密码 admin/admin123)若能正确展示登录页面,并能成功登录,菜单及页面展示正常,表明环境搭建成功。


三、点位管理

1、需求说明

业务场景: 假设我们的公司现在有一个宏伟的计划——在北京发展业务。首先,我们需要确定几个有潜力的区域,这些区域可能是人流量大、消费能力高的商业区或居民区。然后,我们要与这些区域内的潜在合作商进行洽谈,比如商场、写字楼、学校等地方的管理者或所有者。

一旦我们与合作商达成协议,确定了合作的细节和点位,我们就可以安排工作人员去投放智能售货机了。这些点位将成为我们智能售货机的“家”,为消费者提供便捷的购买服务。

点位管理主要涉及到三个功能模块,业务流程如下:

  1. 登录系统:后台管理人员登录后台系统
  2. 新增区域: 后台管理人员可以添加区域范围,区域范围与运维/运维人员挂钩,区域下可关联点位。
  3. 新增合作商: 管理人员可以添加合作商,合作商与点位进行关联。
  4. 新增区域点位: 后台管理人员可以在特定区域内新增点位,这些点位是放置智能售货机的具体位置。

2、库表设计

CREATE TABLE `tb_region` (
  `id` INT AUTO_INCREMENT COMMENT '主键id' PRIMARY KEY,
  `region_name` VARCHAR(255) NOT NULL COMMENT '区域名称',
  `create_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `create_by` VARCHAR(64) COMMENT '创建人',
  `update_by` VARCHAR(64) COMMENT '修改人',
  `remark` TEXT COMMENT '备注'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='区域表';
-- 插入测试数据
INSERT INTO `tb_region` (`region_name`,`remark`) VALUES ('北京市朝阳区','北京市朝阳区'), ('北京市海淀区','北京市海淀区'), ('北京市东城区','北京市东城区');
CREATE TABLE `tb_partner` (
  `id` INT AUTO_INCREMENT COMMENT '主键id' PRIMARY KEY,
  `partner_name` VARCHAR(255) NOT NULL COMMENT '合作商名称',
  `contact_person` VARCHAR(64) COMMENT '联系人',
  `contact_phone` VARCHAR(15) COMMENT '联系电话',
  `profit_ratio` INT COMMENT '分成比例',
  `account` VARCHAR(64) COMMENT '账号',
  `password` VARCHAR(64) COMMENT '密码',
  `create_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `create_by` VARCHAR(64) COMMENT '创建人',
  `update_by` VARCHAR(64) COMMENT '修改人',
  `remark` TEXT COMMENT '备注'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='合作商表';
-- 插入测试数据
INSERT INTO `tb_partner` (`partner_name`, `contact_person`, `contact_phone`, `profit_ratio`, `account`, `password`) VALUES
('合作商A', '张三', '13800138000', 30, 'a001', 'pwdA'),
('合作商B', '李四', '13912345678', 25, 'b002', 'pwdB');
CREATE TABLE `tb_node` (
  `id` INT AUTO_INCREMENT COMMENT '主键id' PRIMARY KEY,
  `node_name` VARCHAR(255) NOT NULL COMMENT '点位名称',
  `address` VARCHAR(255) NOT NULL COMMENT '详细地址',
  `business_type` INT COMMENT '商圈类型',
  `region_id` INT COMMENT '区域ID',
  `partner_id` INT COMMENT '合作商ID',
  `create_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
  `create_by` VARCHAR(64) COMMENT '创建人',
  `update_by` VARCHAR(64) COMMENT '修改人',
  `remark` TEXT COMMENT '备注',
  FOREIGN KEY (`region_id`) REFERENCES `tb_region`(`id`) ON DELETE CASCADE ON UPDATE CASCADE,
  FOREIGN KEY (`partner_id`) REFERENCES `tb_partner`(`id`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='点位表';
-- 插入测试数据
-- 假设区域ID为1对应'北京市朝阳区',合作商ID为1对应'合作商A'
INSERT INTO `tb_node` (`node_name`, `address`, `business_type`, `region_id`, `partner_id`) VALUES
('三里屯点位', '北京市朝阳区三里屯路', 1, 1, 1),
('五道口点位', '北京市海淀区五道口', 2, 2, 2);

对于点位管理数据模型,下面是示意图:

3、生成基础代码

使用若依代码生成器,生成区域管理、合作商管理、点位管理前后端基础代码,并导入到项目中:

(1)创建目录菜单

创建点位管理目录菜单

(2)添加数据字典

先创建商圈的字典类型

再创建商圈的字典数据

(3)配置代码生成信息

导入三张表

配置区域表(参考原型)

配置合作商表(参考原型)

配置点位表(参考原型)

(4)下载代码并导入项目

选中三张表生成下载

解压ruoyi.zip得到前后端代码和动态菜单sql

执行动态菜单sql脚本,执行完成后刷新页面,并调整二级菜单显示顺序和图标

完成前后端代码导入

4、区域管理改造

(1)基础页面

  • 需求:参考页面原型,完成基础布局展示改造

  • 代码实现:

在region/index.vue视图组件中修改:将id改为序号显示,移除修改删除的图标

<!-- 区域列表 -->
<el-table v-loading="loading" :data="regionList" @selection-change="handleSelectionChange">
  <el-table-column type="selection" width="55" align="center" />
  <el-table-column label="序号" type="index" width="50" align="center" prop="id" />
  <el-table-column label="区域名称" align="center" prop="regionName" />
  <el-table-column label="备注" align="center" prop="remark" />
  <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
    <template #default="scope">
      <el-button link type="primary" @click="handleUpdate(scope.row)" v-hasPermi="['manage:region:edit']">修改</el-button>
      <el-button link type="primary" @click="handleDelete(scope.row)" v-hasPermi="['manage:region:remove']">删除</el-button>
    </template>
  </el-table-column>
</el-table>

(2)需求列表

  • 需求:区域列表查询中,需要显示每个区域点位数

  • 接口文档:

  • 实现此功能也有多种方案:

(1)同步存储:在区域表中有点位数的字段,当点位发生变化时,同步区域表中的点位数。

  • 优点:由于是单表查询操作,查询列表效率最高。
  • 缺点:需要在点位增删改时修改区域表中的数据,有额外的开销,数据也可能不一致。

(2)关联查询:编写关联查询语句,在mapper 层封装。

  • 优点:实时查询,数据100%正确,不需要单独维护。
  • 缺点:SQL语句较复杂,如果数据量大,性能比较低。

区域和点位表,记录个数都不是很多,所以我们采用关联查询这种方案。

  • SQL

SQL查询:先聚合统计每个区域的点位数,然后与区域表进行关联查询

-- 先聚合统计每个区域下的点位数,确定分组字段region_id
select region_id,count(*) as node_count from tb_node group by region_id;
-- 与区域表进行关联查询
select r.id,r.region_name,r.remark,ifnull(n.node_count, 0) as node_count
from tb_region r left join (select region_id,count(*) as node_count from tb_node group by region_id) n
on r.id = n.region_id;
-- 或者先关联查询后分组写法
select r.id,r.region_name,r.remark,count(n.id) as node_count from tb_region r left join tb_node n on r.id = n.region_id group by r.id;
  • RegionVo

根据接口文档和sql创建RegionVo,用于映射数据库返回的结果

  • RegionMapper
/**
 * 查询区域管理列表
 * @param region
 * @return RegionVo集合
 */
public List<RegionVo> selectRegionVoList(Region region);
  • RegionMapper.xml
<select id="selectRegionVoList" resultType="com.dkd.manage.domain.vo.RegionVo">
select r.id,r.region_name,r.remark,ifnull(n.node_count,0) as node_count from tb_region r
    left join (select region_id,count(*) as node_count from tb_node group by region_id) n on r.id=n.region_id
    <where>
       <if test="regionName != null  and regionName != ''"> and r.region_name like concat('%', #{regionName}, '%')</if>
    </where>
</select>
<!-- 或者 -->
<select id="selectRegionVoList" resultType="com.dkd.manage.domain.vo.RegionVo">
  select r.id,r.region_name,r.remark,count(n.id) as node_count from tb_region r left join tb_node n on r.id = n.region_id
  <where>
      <if test="regionName != null  and regionName != ''"> and r.region_name like concat('%', #{regionName}, '%')</if>
  </where>
  group by r.id
</select>

注意:SQL语句最后不能加分号,因为使用了pagehelper分页插件,会动态拼接limit关键字。

  • mybatis-config.xml

  • IRegionService
/**
 * 查询区域管理列表
 * @param region
 * @return RegionVo集合
 */
public List<RegionVo> selectRegionVoList(Region region);
  • RegionServiceImpl
/**
 * 查询区域管理列表
 * @param region
 * @return RegionVo集合
 */
@Override
public List<RegionVo> selectRegionVoList(Region region) {
    return regionMapper.selectRegionVoList(region);
}
  • RegionController
/**
 * 查询区域管理列表
 */
@PreAuthorize("@ss.hasPermi('manage:region:list')")
@GetMapping("/list")
public TableDataInfo list(Region region)
{
    startPage();
    List<RegionVo> voList = regionService.selectRegionVoList(region);
    return getDataTable(voList);
}
  • region/index.vue
<!-- 区域列表 -->
<el-table v-loading="loading" :data="regionList" @selection-change="handleSelectionChange">
  <el-table-column type="selection" width="55" align="center" />
  <el-table-column label="序号" type="index" width="50" align="center" prop="id" />
  <el-table-column label="区域名称" align="center" prop="regionName" />
  <el-table-column label="点位数" align="center" prop="nodeCount" />
  <el-table-column label="备注说明" align="center" prop="remark" />
  <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
    <template #default="scope">
      <el-button link type="primary"  @click="handleUpdate(scope.row)" v-hasPermi="['manage:region:edit']">修改</el-button>
      <el-button link type="primary"  @click="handleDelete(scope.row)" v-hasPermi="['manage:region:remove']">删除</el-button>
    </template>
  </el-table-column>
</el-table>

小技巧:若依提供了热部署插件,在修改完若依后端代码后,如果没有新文件创建的话,可以按Ctrl+F9进行代码的热更新,不需要重启项目。

5、合作商管理改造

(1)基础页面

  • 需求:参考页面原型,完成基础布局展示改造

  • 代码实现:

在partner/index.vue视图组件中

<!-- 搜索区域 -->
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="90px">
    <el-form-item label="合作商名称" prop="name">
        <el-input
                  v-model="queryParams.partnerName" placeholder="请输入合作商名称"
                  clearable @keyup.enter="handleQuery"/>
    </el-form-item>
    <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
    </el-form-item>
</el-form>
<!-- 合作商列表 -->
<el-table v-loading="loading" :data="partnerList" @selection-change="handleSelectionChange">
  <el-table-column type="selection" width="55" align="center" />
  <el-table-column label="序号" type="index" width="50" align="center" prop="id" />
  <el-table-column label="合作商名称" align="center" prop="partnerName" />
  <el-table-column label="账号" align="center" prop="account" />
  <el-table-column label="分成比例" align="center" prop="profitRatio" >
    <template #default="scope">{{scope.row.profitRatio}}%</template>
  </el-table-column>
  <el-table-column label="联系人" align="center" prop="contactPerson" />
  <el-table-column label="联系电话" align="center" prop="contactPhone" />
  <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
    <template #default="scope">
      <el-button link type="primary"  @click="handleUpdate(scope.row)" v-hasPermi="['manage:partner:edit']">修改</el-button>
      <el-button link type="primary"  @click="handleDelete(scope.row)" v-hasPermi="['manage:partner:remove']">删除</el-button>
    </template>
  </el-table-column>
</el-table>
<!-- 添加或修改合作商管理对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
  <el-form ref="partnerRef" :model="form" :rules="rules" label-width="100px">
    <el-form-item label="合作商名称" prop="partnerName">
      <el-input v-model="form.partnerName" placeholder="请输入合作商名称" />
    </el-form-item>
    <el-form-item label="联系人" prop="contactPerson">
      <el-input v-model="form.contactPerson" placeholder="请输入联系人" />
    </el-form-item>
    <el-form-item label="联系电话" prop="contactPhone">
      <el-input v-model="form.contactPhone" placeholder="请输入联系电话" />
    </el-form-item>
    <el-form-item label="创建时间" prop="contactPhone" v-if="form.id!=null">
      {{form.createTime}}
    </el-form-item>
    <el-form-item label="分成比例" prop="profitRatio">
      <el-input v-model="form.profitRatio" placeholder="请输入分成比例" />
    </el-form-item>
    <el-form-item label="账号" prop="account" v-if="form.id==null">
      <el-input v-model="form.account" placeholder="请输入账号" />
    </el-form-item>
    <el-form-item label="密码" prop="password" v-if="form.id==null">
      <el-input v-model="form.password" type="password" placeholder="请输入密码" />
    </el-form-item>
  </el-form>
  <template #footer>
    <div class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </template>
</el-dialog>
</div>
</template>

为保证数据安全性,防止将密码直接进行明文存储,在PartnerServiceImpl的新增方法中修改

/**
 * 新增合作商
 *
 * @param partner 合作商
 * @return 结果
 */
@Override
public int insertPartner(Partner partner) {
    // 使用SecurityUtil工具类,对密码加密
    partner.setPassword(SecurityUtils.encryptPassword(partner.getPassword()));
    partner.setCreateTime(DateUtils.getNowDate());
    return partnerMapper.insertPartner(partner);
}

(2)查看详情

在partner/index.vue视图组件中

<el-button link type="primary" @click="getPartnerInfo(scope.row)" v-hasPermi="['manage:partner:query']">查看详情</el-button>
<!-- 栅格布局:查看合作商详情 -->
<el-dialog title="合作商详情" v-model="partnerInfoOpen" width="500px" append-to-body>
    <el-row>
        <el-col :span="12">合作商名称:{{ form.partnerName }}</el-col>
        <el-col :span="12">联系人:{{ form.contactPerson }}</el-col>
    </el-row>
    <el-row>
        <el-col :span="12">联系电话:{{ form.contactPhone }}</el-col>
        <el-col :span="12">分成比例:{{ form.profitRatio }}%</el-col>
    </el-row>
</el-dialog>
<!-- 美化后:查看合作商详情对话框 -->
<el-dialog title="合作商详情" v-model="partnerInfoOpen" width="500px" append-to-body>
    <!-- 使用el-descriptions组件以卡片形式展示信息,更加整洁 -->
    <el-descriptions :column="2" border>
        <el-descriptions-item label="合作商名称">{{ form.partnerName }}</el-descriptions-item>
        <el-descriptions-item label="联系人">{{ form.contactPerson }}</el-descriptions-item>
        <el-descriptions-item label="联系电话">{{ form.contactPhone }}</el-descriptions-item>
        <el-descriptions-item label="分成比例">{{ form.profitRatio }}%</el-descriptions-item>
    </el-descriptions>
</el-dialog>
<script>
    /* 查看合作商详情 */
    const partnerInfoOpen = ref(false);
    function getPartnerInfo(row) {
        reset();
        const _id = row.id;
        getPartner(_id).then(response => {
            form.value = response.data;
            partnerInfoOpen.value = true;
        });
    }
</script>

(3)合作商列表

  • 需求:合作商列表中统计每个合作商关联的点位数
  • 实现思路:与区域列表实现方式相同。

  • SQL

SQL查询:先聚合统计每个合作商的点位数,然后与合作商表进行关联查询

-- 查询合作商表的所有信息,同时显示每个合作商的点位数
-- SQL方案1:
-- 1.先聚合统计每个合作商的点位数
-- 确定查询的表 tb_node,确定分组字段 partner_id
SELECT partner_id, COUNT(1) AS node_count from tb_node group by partner_id;
-- 2.然后与合作商表进行关联查询
select p.*,ifnull(n.node_count,0) 
from tb_partner p left join (SELECT partner_id, COUNT(1) AS node_count from tb_node group by partner_id) n 
on n.partner_id = p.id;
-- SQL方案2:
select p.*, count(n.id) as node_count from tb_partner p left join tb_node n on p.id = n.partner_id group by p.id;
  • PartnerVo

根据接口文档和sql创建PartnerVo

@Data
public class PartnerVo extends Partner {
    // 点位数量
    private Integer nodeCount;
}
  • PartnerMapper和PartnerMapper.xml
/**
 * 查询合作商管理列表
 * @param partner
 * @return partnerVo集合
 */
public List<PartnerVo> selectPartnerVoList(Partner partner);
<select id="selectPartnerVoList" resultType="com.dkd.manage.domain.vo.PartnerVo">
    SELECT p.*, COUNT(n.id) AS node_count FROM tb_partner p
    LEFT JOIN tb_node n ON p.id = n.partner_id
    <where>
        <if test="partnerName != null  and partnerName != ''">and partner_name like concat('%', #{partnerName},'%')
        </if>
    </where>
    GROUP BY p.id
</select>
  • IPartnerService和PartnerServiceImpl
/**
 * 查询合作商管理列表
 * @param partner
 * @return partnerVo集合
 */
public List<PartnerVo> selectPartnerVoList(Partner partner);
/**
 * 查询合作商管理列表
 * @param partner
 * @return partnerVo集合
 */
@Override
public List<PartnerVo> selectPartnerVoList(Partner partner) {
    return partnerMapper.selectPartnerVoList(partner);
}
  • PartnerController
/**
 * 查询合作商管理列表
 */
@PreAuthorize("@ss.hasPermi('manage:partner:list')")
@GetMapping("/list")
public TableDataInfo list(Partner partner) {
    startPage();
    List<PartnerVo> voList = partnerService.selectPartnerVoList(partner);
    return getDataTable(voList);
}
  • region/index.vue
<!-- 合作商列表 -->
<el-table v-loading="loading" :data="partnerList" @selection-change="handleSelectionChange">
    <el-table-column type="selection" width="55" align="center" />
    <el-table-column label="序号" type="index" width="50" align="center" prop="id" />
    <el-table-column label="合作商名称" align="center" prop="partnerName" />
    <el-table-column label="点位数" align="center" prop="nodeCount" />
    <el-table-column label="账号" align="center" prop="account" />
    <el-table-column label="分成比例" align="center" prop="profitRatio" >
        <template #default="scope">{{ scope.row.profitRatio }}%</template>
    </el-table-column>
    <el-table-column label="联系人" align="center" prop="contactPerson" />
    <el-table-column label="联系电话" align="center" prop="contactPhone" />
    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
            <el-button link type="primary"  @click="getParnterInfo(scope.row)" v-hasPermi="['manage:partner:query']">查看详情</el-button>
            <el-button link type="primary"  @click="handleUpdate(scope.row)" v-hasPermi="['manage:partner:edit']">修改</el-button>
            <el-button link type="primary"  @click="handleDelete(scope.row)" v-hasPermi="['manage:partner:remove']">删除</el-button>
        </template>
    </el-table-column>
</el-table>

(4)重置密码

  • 接口文档:

  • 后端部分

在PartnerController中

/**
* 重置合作商密码,重置后密码默认为123456
* @param id
* @return
*/
@PreAuthorize("@ss.hasPermi('manage:partner:edit')")
@Log(title = "合作商管理", businessType = BusinessType.UPDATE)
@PutMapping("resetPwd/{id}")
public AjaxResult resetPwd(@PathVariable Long id) {
    Partner partner = new Partner();
    partner.setId(id);
    partner.setPassword(SecurityUtils.encryptPassword("123456"));
    return toAjax(partnerService.updatePartner(partner));
}
  • 前端部分

在manage/partner.js请求api中

// 重置合作商密码
export function resetPartnerPwd(id){
  return request({
    url: '/manage/partner/resetPwd/' + id,
    method: 'put'
  })
}

在partner/index.vue视图组件中

<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="300px">
    <template #default="scope">
    <el-button link type="primary" @click="resetPwd(scope.row)" v-hasPermi="['manage:partner:edit']">重置密码</el-button>
    </template>
</el-table-column>
<script>
    import { listPartner, getPartner, delPartner, addPartner, updatePartner,resetPartnerPwd } from "@/api/manage/partner";
    /* 重置合作商密码 */
    function resetPwd(row) {
        proxy.$modal.confirm('你确定要重置该合作商密码吗?').then(function () {
            return resetPartnerPwd(row.id);
        }).then(() => {
            proxy.$modal.msgSuccess("重置成功");
        }).catch(() => { });
    }
</script>

6、点位管理改造

(1)基础页面

  • 需求:参考页面原型,完成基础布局展示改造

  • 代码实现

在node/index.vue视图组件中

<!-- 搜索区域 -->
<el-form :model="queryParams" ref="queryRef" :inline="true" v-show="showSearch" label-width="68px">
    <el-form-item label="点位名称" prop="nodeName">
        <el-input v-model="queryParams.nodeName" placeholder="请输入点位名称" clearable @keyup.enter="handleQuery" />
    </el-form-item>
    <el-form-item label="区域搜索" prop="regionId">
        <!-- <el-input v-model="queryParams.regionId" placeholder="请输入区域ID" clearable @keyup.enter="handleQuery" /> -->
        <el-select v-model="queryParams.regionId" placeholder="请选择区域" clearable>
            <el-option v-for="item in regionList" :key="item.id" :label="item.regionName" :value="item.id"></el-option>
        </el-select>
    </el-form-item>
    <el-form-item>
        <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
        <el-button icon="Refresh" @click="resetQuery">重置</el-button>
    </el-form-item>
</el-form>
<!-- 点位列表 -->
<el-table v-loading="loading" :data="nodeList" @selection-change="handleSelectionChange">
    <el-table-column type="selection" width="55" align="center" />
    <el-table-column label="序号" type="index" width="50" align="center" prop="id" />
    <el-table-column label="点位名称" align="center" prop="nodeName" />
    <el-table-column label="区域ID" align="center" prop="regionId" />
    <el-table-column label="商圈类型" align="center" prop="businessType">
        <template #default="scope">
<dict-tag :options="business_type" :value="scope.row.businessType" />
        </template>
    </el-table-column>
    <el-table-column label="合作商ID" align="center" prop="partnerId" />
    <el-table-column label="详细地址" align="center" prop="address" show-overflow-tooltip/>
    <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
        <template #default="scope">
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['manage:node:edit']">修改</el-button>
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['manage:node:remove']">删除</el-button>
        </template>
    </el-table-column>
</el-table>
<!-- 添加或修改点位管理对话框 -->
<el-dialog :title="title" v-model="open" width="500px" append-to-body>
  <el-form ref="nodeRef" :model="form" :rules="rules" label-width="100px">
    <el-form-item label="点位名称" prop="nodeName">
      <el-input v-model="form.nodeName" placeholder="请输入点位名称" />
    </el-form-item>
    <el-form-item label="所在区域" prop="regionId">
      <!-- <el-input v-model="form.regionId" placeholder="请输入区域ID" /> -->
        <el-select v-model="form.regionId" placeholder="请选择区域" clearable>
        <el-option v-for="item in regionList" :key="item.id" :label="item.regionName" :value="item.id"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="商圈类型" prop="businessType">
      <el-select v-model="form.businessType" placeholder="请选择商圈类型">
        <el-option v-for="dict in business_type" :key="dict.value" :label="dict.label"
          :value="parseInt(dict.value)"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="归属合作商" prop="partnerId">
      <!-- <el-input v-model="form.partnerId" placeholder="请输入合作商ID" /> -->
        <el-select v-model="form.partnerId" placeholder="请选择合作商" clearable>
        <el-option v-for="item in partnerList" :key="item.id" :label="item.partnerName" :value="item.id"></el-option>
      </el-select>
    </el-form-item>
    <el-form-item label="详细地址" prop="address">
      <el-input type="textarea" v-model="form.address" placeholder="请输入详细地址" />
    </el-form-item>
  </el-form>
  <template #footer>
    <div class="dialog-footer">
      <el-button type="primary" @click="submitForm">确 定</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </template>
</el-dialog>
<script setup name="Node">
    import { listPartner } from "@/api/manage/partner";
    import { listRegion } from "@/api/manage/region";
    import { loadAllParams } from "@/api/page";
    /* 查询所有的条件对象 */
    /* const loadAllParams = reactive({
      pageNum: 1,
      pageSize: 10000,
    }); */
    /* 查询合作商列表  */
    const partnerList = ref([]);
    function getPartnerList() {
        listPartner(loadAllParams).then(response => {
            partnerList.value = response.rows;
        });
    }
    getPartnerList();
    /* 查询区域列表 */
    const regionList = ref([]);
    function getRegionList() {
        listRegion(loadAllParams).then(response => {
            regionList.value = response.rows;
        });
    }
    getRegionList();    
</script>

在api/page.js中,抽取一个查询参数响应式对象,查询列表中的所有的数据项(往后查1w条,相当于模拟查所有)

export const loadAllParams = reactive({
  pageNum: 1,
  pageSize: 10000,
});

(2)点位列表

  • 需求:在区域详情中,需要显示每个点位的设备数

  • 在点位列表查询中,会关联显示区域、商圈等信息

  • 接口文档:

  • 实现思路

关联查询(保证实时性场景):对于设备数量的统计,我们需要执行关联查询,在mapper 层封装。

关联实体:对于区域和合作商的数据,我们会采用Mybatis提供的嵌套查询功能。

MyBatis 嵌套查询就是将原来多表查询中的联合查询语句拆成单个表的查询,再使用mybatis的语法嵌套在一 起,通过定义resultMapsql语句中的associationcollection元素来实现嵌套查询。

将后续开发要用的SQL建表语句一并导入数据库中

-- MySQL dump 10.13  Distrib 8.0.31, for Win64 (x86_64)
--
-- Host: 127.0.0.1    Database: dkd-v3
-- ------------------------------------------------------
-- Server version 8.0.31
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!50503 SET NAMES utf8mb4 */;
/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */;
/*!40103 SET TIME_ZONE='+00:00' */;
/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */;
/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
--
-- Table structure for table `tb_vendout_running`
--
DROP TABLE IF EXISTS `tb_vendout_running`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_vendout_running` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT 'id',
  `order_no` varchar(38) NOT NULL DEFAULT '' COMMENT '订单编号',
  `inner_code` varchar(15) NOT NULL COMMENT '售货机编号',
  `channel_code` varchar(10) DEFAULT NULL COMMENT '货道编号',
  `status` char(1) DEFAULT NULL COMMENT '状态',
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1665296081440129026 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='出货流水';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_vendout_running`
--
LOCK TABLES `tb_vendout_running` WRITE;
/*!40000 ALTER TABLE `tb_vendout_running` DISABLE KEYS */;
INSERT INTO `tb_vendout_running` VALUES (1640253535886454786,'A1000001972287294582300','A1000001',NULL,'1','2023-03-27 07:24:52','2023-03-27 07:24:52'),(1640294341087305730,'A1000001982025093546600','A1000001',NULL,'0','2023-03-27 10:07:01','2023-03-27 10:07:01'),(1640295508953505793,'A1000001982308461482000','A1000001',NULL,'0','2023-03-27 10:11:39','2023-03-27 10:11:39'),(1665193032268836866,'A10000011867384516930600','A1000001',NULL,'0','2023-06-04 03:05:31','2023-06-04 03:05:31'),(1665193181468618753,'A10000011867429590093200','A1000001',NULL,'0','2023-06-04 03:06:07','2023-06-04 03:06:07'),(1665194583502811137,'A10000011867548883835400','A1000001',NULL,'0','2023-06-04 03:11:41','2023-06-04 03:11:41'),(1665197927541698561,'A10000011868551878012500','A1000001',NULL,'0','2023-06-04 03:24:58','2023-06-04 03:24:58'),(1665200173490827265,'A10000011869054027266500','A1000001',NULL,'0','2023-06-04 03:33:54','2023-06-04 03:33:54'),(1665295023343058946,'A10000011891589370978600','A1000001',NULL,'1','2023-06-04 09:50:48','2023-06-04 09:51:34'),(1665296081440129025,'A10000011891956192562900','A1000001',NULL,'0','2023-06-04 09:55:00','2023-06-04 09:55:00');
/*!40000 ALTER TABLE `tb_vendout_running` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_sku`
--
DROP TABLE IF EXISTS `tb_sku`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_sku` (
  `sku_id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `sku_name` varchar(50) NOT NULL COMMENT '商品名称',
  `sku_image` varchar(500) NOT NULL COMMENT '商品图片',
  `brand_Name` varchar(50) NOT NULL COMMENT '品牌',
  `unit` varchar(20) DEFAULT NULL COMMENT '规格(净含量)',
  `price` int NOT NULL DEFAULT '1' COMMENT '商品价格,单位分',
  `class_id` int NOT NULL COMMENT '商品类型Id',
  `is_discount` tinyint(1) DEFAULT '0' COMMENT '是否打折促销',
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`sku_id`),
  UNIQUE KEY `tb_sku_sku_name_uindex` (`sku_name`),
  KEY `sku_sku_class_ClassId_fk` (`class_id`),
  CONSTRAINT `tb_sku_ibfk_1` FOREIGN KEY (`class_id`) REFERENCES `tb_sku_class` (`class_id`)
) ENGINE=InnoDB AUTO_INCREMENT=12 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_sku`
--
LOCK TABLES `tb_sku` WRITE;
/*!40000 ALTER TABLE `tb_sku` DISABLE KEYS */;
INSERT INTO `tb_sku` VALUES (1,'可口可乐','https://likede2-java.itheima.net/image/product1.png','可口可乐','550ML',200,1,1,'2020-09-14 01:14:17','2024-05-14 02:47:42'),(2,'康师傅','https://likede2-java.itheima.net/image/product2.png','可口可乐','330ML',200,1,0,'2020-09-14 01:15:43','2024-05-14 02:47:52'),(3,'统一奶茶','https://likede2-java.itheima.net/image/product3.png','可口可乐','500ML',100,1,0,'2020-09-16 06:41:50','2020-09-16 06:41:50'),(4,'青梅绿茶','https://likede2-java.itheima.net/image/product4.png','可口可乐','500ML',200,1,0,'2020-11-20 10:27:35','2020-11-20 10:27:35'),(5,'冰糖雪梨','https://likede2-java.itheima.net/image/product5.png','冰糖雪梨','500ML',250,1,0,'2020-12-18 06:03:41','2024-05-14 02:47:28'),(6,'怡宝至尊','https://likede2-java.itheima.net/image/product6.png','怡宝','500ML',200,1,0,'2020-12-18 06:04:02','2024-05-14 02:47:35'),(7,'一百橙汁','https://likede2-java.itheima.net/image/product7.png','100橙汁自然纯','500ML',100,1,0,'2020-12-18 06:04:26','2020-12-18 06:04:26'),(8,'魔力花茶','https://likede2-java.itheima.net/image/product8.png','茉莉花茶','500ML',100,1,0,'2020-12-18 06:04:45','2020-12-18 06:04:45'),(9,'新星巴克','https://likede2-java.itheima.net/image/product9.png','星巴克','500ML',100,1,0,'2020-12-18 06:05:01','2020-12-18 06:05:01');
/*!40000 ALTER TABLE `tb_sku` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_order_collect`
--
DROP TABLE IF EXISTS `tb_order_collect`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_order_collect` (
  `id` bigint NOT NULL COMMENT 'Id',
  `partner_id` int DEFAULT NULL COMMENT '合作商Id',
  `partner_name` varchar(100) DEFAULT NULL COMMENT '合作商名称',
  `order_total_money` bigint DEFAULT NULL COMMENT '日订单收入总金额(平台端总数)',
  `order_date` date DEFAULT NULL COMMENT '发生日期',
  `total_bill` int DEFAULT '0' COMMENT '分成总金额',
  `node_id` int DEFAULT NULL,
  `node_name` varchar(50) DEFAULT NULL COMMENT '点位',
  `order_count` int DEFAULT NULL COMMENT '订单数',
  `ratio` int DEFAULT NULL COMMENT '分成比例',
  `region_name` varchar(50) DEFAULT NULL COMMENT '区域名称',
  PRIMARY KEY (`id`),
  UNIQUE KEY `tb_order_collect_id_uindex` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='合作商订单汇总表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_order_collect`
--
LOCK TABLES `tb_order_collect` WRITE;
/*!40000 ALTER TABLE `tb_order_collect` DISABLE KEYS */;
INSERT INTO `tb_order_collect` VALUES (1701144293748969474,1,'金燕龙合作商',6,'2023-09-27',0,1,'龙门石窟',3,15,'昌平'),(1701167701270380546,1,'金燕龙合作商',1,'2023-09-27',0,1,'龙门石窟',3,15,'顺义'),(1701168456614256642,1,'金燕龙合作商',2,'2023-09-27',0,1,'龙门石窟',3,15,'海淀'),(1701168704594092033,1,'金燕龙合作商',4,'2023-09-27',0,1,'龙门石窟',3,15,'东城'),(1701168956252332033,1,'金燕龙合作商',5,'2023-09-27',0,1,'龙门石窟',3,15,'朝阳');
/*!40000 ALTER TABLE `tb_order_collect` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_vending_machine`
--
DROP TABLE IF EXISTS `tb_vending_machine`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_vending_machine` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `inner_code` varchar(15) DEFAULT '000' COMMENT '设备编号',
  `channel_max_capacity` int DEFAULT NULL COMMENT '设备容量',
  `node_id` int NOT NULL COMMENT '点位Id',
  `addr` varchar(100) DEFAULT NULL COMMENT '详细地址',
  `last_supply_time` datetime NOT NULL DEFAULT '2000-01-01 00:00:00' COMMENT '上次补货时间',
  `business_type` int NOT NULL COMMENT '商圈类型',
  `region_id` int NOT NULL COMMENT '区域Id',
  `partner_id` int NOT NULL COMMENT '合作商Id',
  `vm_type_id` int NOT NULL DEFAULT '0' COMMENT '设备型号',
  `vm_status` int NOT NULL DEFAULT '0' COMMENT '设备状态,0:未投放;1-运营;3-撤机',
  `running_status` varchar(100) DEFAULT NULL COMMENT '运行状态',
  `longitudes` double DEFAULT '0' COMMENT '经度',
  `latitude` double DEFAULT '0' COMMENT '维度',
  `client_id` varchar(50) DEFAULT NULL COMMENT '客户端连接Id,做emq认证用',
  `policy_id` bigint DEFAULT NULL COMMENT '策略id',
  `create_time` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `vendingmachine_VmId_uindex` (`inner_code`),
  KEY `vendingmachine_node_Id_fk` (`node_id`),
  KEY `vendingmachine_vmtype_TypeId_fk` (`vm_type_id`),
  KEY `policy_id` (`policy_id`),
  CONSTRAINT `tb_vending_machine_ibfk_1` FOREIGN KEY (`vm_type_id`) REFERENCES `tb_vm_type` (`id`),
  CONSTRAINT `tb_vending_machine_ibfk_2` FOREIGN KEY (`node_id`) REFERENCES `tb_node` (`id`),
  CONSTRAINT `tb_vending_machine_ibfk_3` FOREIGN KEY (`policy_id`) REFERENCES `tb_policy` (`policy_id`)
) ENGINE=InnoDB AUTO_INCREMENT=112 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='设备表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_vending_machine`
--
LOCK TABLES `tb_vending_machine` WRITE;
/*!40000 ALTER TABLE `tb_vending_machine` DISABLE KEYS */;
INSERT INTO `tb_vending_machine` VALUES (80,'A1000001',10,2,'顺义奥林匹克水上公园','2023-03-22 00:00:00',1,3,28,1,1,'{\"statusCode\":\"1001\",\"status\":true}',0,0,'70122567fcc13e7615e7239812c20448',1,'2020-12-18 07:49:03','2024-05-14 01:21:58'),(86,'aim5xu4I',10,2,'北京市海淀区西直门北大街32号','2000-01-01 00:00:00',2,1,1,2,1,'{\"statusCode\":\"1001\",\"status\":true}',0,0,'9d1d927b2651dba9f117a9801e7fd916',1,'2020-12-18 02:39:22','2024-05-14 01:24:53'),(87,'5cy5BdUs',10,2,'北京市海淀区西直门北大街32号','2022-12-05 00:00:00',2,1,1,2,1,'{\"statusCode\":\"1001\",\"status\":true}',0,0,'fdf33db4de889d6c31fe6351a7333072',2,'2020-12-18 02:39:22','2024-05-12 15:19:10'),(88,'tCeiyxLx',10,1,'北京市昌平区建材城西路22号','2000-01-01 00:00:00',2,1,1,1,1,'{\"statusCode\":\"1001\",\"status\":true}',0,0,'0805f7585e4366b021268f8850d1e091',1,'2020-09-10 01:41:02','2024-05-14 01:24:55'),(89,'bR1cfQRa',10,2,'北京市海淀区西直门北大街32号','2000-01-01 00:00:00',2,1,1,2,1,'{\"statusCode\":\"1001\",\"status\":true}',0,0,'e4e02a07b11865bf262afb5d4507e7b3',1,'2020-12-18 02:39:22','2024-05-14 01:24:56'),(90,'RhLWjaeR',10,1,'北京市昌平区建材城西路22号','2000-01-01 00:00:00',2,1,1,1,1,'{\"statusCode\":\"1001\",\"status\":true}',0,0,'0cc9e22badf6a0f41b5fad2c8b788fcd',2,'2020-09-10 01:41:02','2024-05-14 01:25:07'),(91,'qUObmvbM',10,2,'北京市海淀区西直门北大街32号','2022-12-06 00:00:00',2,1,1,2,1,'{\"statusCode\":\"1001\",\"status\":true}',0,0,'34a1779725b4e06edd7cac8a518474f1',2,'2020-12-18 02:39:22','2024-05-14 01:25:11'),(92,'tU6K5IHg',10,1,'北京市昌平区建材城西路22号','2000-01-01 00:00:00',2,1,1,2,1,'{\"statusCode\":\"1001\",\"status\":true}',0,0,'fbb7f7c0bfd38785866844f983b3a887',5,'2020-09-10 01:41:02','2024-05-14 01:25:14'),(93,'iSzMcQXJ',10,1,'北京市昌平区建材城西路22号','2000-01-01 00:00:00',2,1,1,1,1,'{\"statusCode\":\"1001\",\"status\":true}',0,0,'7c6f5ad6edd6e161d6ca8b94d0324fe5',2,'2020-09-10 01:41:02','2024-05-14 01:25:19'),(105,'nf2UVwi5',8,2,'北京顺义区国际鲜花港','2000-01-01 00:00:00',1,3,1,4,0,NULL,0,0,NULL,NULL,'2020-12-18 07:48:13','2024-05-13 10:47:32'),(106,'vWgqPhpu',10,1,'北京市昌平区建材城西路22号','2024-05-18 15:26:37',2,1,1,1,1,NULL,0,0,NULL,NULL,'2020-09-10 01:41:02','2024-05-12 15:20:41'),(107,'SFNuCUe8',8,1,'北京市昌平区建材城西路22号','2000-01-01 00:00:00',2,1,1,4,0,NULL,0,0,NULL,NULL,'2020-09-10 01:41:02','2024-05-12 15:20:41'),(111,'K6YYXHLY',10,2,'北京顺义区国际鲜花港','2000-01-01 00:00:00',1,3,1,1,0,'{\"statusCode\":\"1001\",\"status\":true}',0,0,NULL,NULL,'2020-12-18 07:48:13','2024-05-19 07:32:27');
/*!40000 ALTER TABLE `tb_vending_machine` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_task_collect`
--
DROP TABLE IF EXISTS `tb_task_collect`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_task_collect` (
  `id` int NOT NULL AUTO_INCREMENT,
  `user_id` int DEFAULT NULL,
  `finish_count` int DEFAULT '0' COMMENT '当日工单完成数',
  `progress_count` int DEFAULT '0' COMMENT '当日进行中的工单数',
  `cancel_count` int DEFAULT '0' COMMENT '当日取消工单数',
  `collect_date` date DEFAULT NULL COMMENT '汇总的日期',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=90 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='工单按日统计表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_task_collect`
--
LOCK TABLES `tb_task_collect` WRITE;
/*!40000 ALTER TABLE `tb_task_collect` DISABLE KEYS */;
INSERT INTO `tb_task_collect` VALUES (89,NULL,0,0,0,NULL);
/*!40000 ALTER TABLE `tb_task_collect` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_channel`
--
DROP TABLE IF EXISTS `tb_channel`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_channel` (
  `id` bigint NOT NULL AUTO_INCREMENT COMMENT '主键',
  `channel_code` varchar(10) NOT NULL COMMENT '货道编号',
  `sku_id` bigint DEFAULT '0' COMMENT '商品Id',
  `vm_id` bigint NOT NULL COMMENT '售货机Id',
  `inner_code` varchar(15) NOT NULL COMMENT '售货机软编号',
  `max_capacity` int NOT NULL DEFAULT '0' COMMENT '货道最大容量',
  `current_capacity` int DEFAULT '0' COMMENT '货道当前容量',
  `last_supply_time` datetime DEFAULT NULL COMMENT '上次补货时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  PRIMARY KEY (`id`),
  KEY `channel_vendingmachine_Id_fk` (`vm_id`),
  KEY `tb_channel_inner_code_index` (`inner_code`),
  CONSTRAINT `tb_channel_ibfk_1` FOREIGN KEY (`vm_id`) REFERENCES `tb_vending_machine` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=5209 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='售货机货道表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_channel`
--
LOCK TABLES `tb_channel` WRITE;
/*!40000 ALTER TABLE `tb_channel` DISABLE KEYS */;
INSERT INTO `tb_channel` VALUES (4703,'1-1',9,80,'A1000001',10,8,'2023-03-22 17:16:46','2022-05-11 12:12:40','2024-05-19 16:05:35'),(4704,'1-2',2,80,'A1000001',10,2,'2023-03-22 17:16:46','2022-05-11 12:12:40','2024-05-19 16:05:35'),(4705,'1-3',2,80,'A1000001',10,6,'2023-03-22 17:16:46','2022-05-11 12:12:40','2024-05-19 16:05:35'),(4706,'1-4',4,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4707,'1-5',3,80,'A1000001',10,9,'2023-03-22 17:16:46','2022-05-11 12:12:40','2024-05-19 16:05:35'),(4708,'1-6',4,80,'A1000001',10,4,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4709,'2-1',1,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4710,'2-2',6,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4711,'2-3',8,80,'A1000001',10,0,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4712,'2-4',9,80,'A1000001',10,9,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4713,'2-5',2,80,'A1000001',10,6,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4714,'2-6',4,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4715,'3-1',7,80,'A1000001',10,5,'2023-03-22 17:16:46','2022-05-11 12:12:40','2024-05-19 16:05:35'),(4716,'3-2',6,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4717,'3-3',3,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4718,'3-4',2,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4719,'3-5',2,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4720,'3-6',1,80,'A1000001',10,10,'2023-03-22 17:16:46','2022-05-11 12:12:40','2024-05-19 16:05:35'),(4721,'4-1',2,80,'A1000001',10,1,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4722,'4-2',4,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4723,'4-3',5,80,'A1000001',10,6,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4724,'4-4',6,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4725,'4-5',6,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4726,'4-6',6,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4727,'5-1',6,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4728,'5-2',6,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4729,'5-3',6,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4730,'5-4',6,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4731,'5-5',9,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4732,'5-6',6,80,'A1000001',10,10,NULL,'2022-05-11 12:12:40','2024-05-19 16:05:35'),(4883,'1-1',5,86,'aim5xu4I',10,10,NULL,'2022-12-05 17:01:38','2022-12-05 17:01:38'),(4884,'1-2',1,86,'aim5xu4I',10,10,NULL,'2022-12-05 17:01:38','2022-12-05 17:01:38'),(4885,'2-1',0,86,'aim5xu4I',10,10,NULL,'2022-12-05 17:01:38','2022-12-05 17:01:38'),(4886,'2-2',0,86,'aim5xu4I',10,10,NULL,'2022-12-05 17:01:38','2022-12-05 17:01:38'),(4887,'1-1',5,87,'5cy5BdUs',10,10,'2022-12-05 21:45:36','2022-12-05 21:35:56','2022-12-05 21:45:36'),(4888,'1-2',1,87,'5cy5BdUs',10,10,'2022-12-05 21:45:36','2022-12-05 21:35:56','2022-12-05 21:45:36'),(4889,'2-1',0,87,'5cy5BdUs',10,10,NULL,'2022-12-05 21:35:56','2022-12-05 21:35:56'),(4890,'2-2',0,87,'5cy5BdUs',10,10,NULL,'2022-12-05 21:35:56','2022-12-05 21:35:56'),(4891,'1-1',2,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4892,'1-2',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4893,'1-3',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4894,'1-4',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4895,'1-5',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4896,'1-6',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4897,'2-1',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4898,'2-2',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4899,'2-3',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4900,'2-4',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4901,'2-5',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4902,'2-6',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4903,'3-1',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4904,'3-2',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4905,'3-3',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4906,'3-4',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4907,'3-5',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4908,'3-6',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4909,'4-1',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4910,'4-2',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4911,'4-3',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4912,'4-4',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4913,'4-5',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4914,'4-6',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4915,'5-1',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4916,'5-2',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4917,'5-3',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4918,'5-4',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4919,'5-5',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4920,'5-6',0,88,'tCeiyxLx',10,10,NULL,'2022-12-05 22:39:26','2024-05-16 22:02:27'),(4921,'1-1',2,89,'bR1cfQRa',10,10,NULL,'2022-12-06 10:06:11','2023-09-22 15:43:44'),(4922,'1-2',0,89,'bR1cfQRa',10,10,NULL,'2022-12-06 10:06:11','2022-12-06 10:06:11'),(4923,'2-1',0,89,'bR1cfQRa',10,10,NULL,'2022-12-06 10:06:11','2022-12-06 10:06:11'),(4924,'2-2',0,89,'bR1cfQRa',10,10,NULL,'2022-12-06 10:06:11','2022-12-06 10:06:11'),(4925,'1-1',2,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4926,'1-2',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4927,'1-3',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4928,'1-4',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4929,'1-5',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4930,'1-6',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4931,'2-1',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4932,'2-2',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4933,'2-3',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4934,'2-4',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4935,'2-5',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4936,'2-6',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4937,'3-1',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4938,'3-2',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4939,'3-3',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4940,'3-4',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4941,'3-5',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4942,'3-6',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4943,'4-1',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4944,'4-2',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4945,'4-3',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4946,'4-4',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4947,'4-5',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4948,'4-6',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4949,'5-1',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4950,'5-2',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4951,'5-3',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4952,'5-4',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4953,'5-5',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4954,'5-6',0,90,'RhLWjaeR',10,10,NULL,'2022-12-06 10:17:32','2024-05-15 16:31:18'),(4955,'1-1',5,91,'qUObmvbM',10,10,'2022-12-06 15:11:20','2022-12-06 14:58:46','2022-12-06 15:11:20'),(4956,'1-2',1,91,'qUObmvbM',10,10,'2022-12-06 15:11:20','2022-12-06 14:58:46','2022-12-06 15:11:20'),(4957,'2-1',0,91,'qUObmvbM',10,10,NULL,'2022-12-06 14:58:46','2022-12-06 14:58:46'),(4958,'2-2',0,91,'qUObmvbM',10,10,NULL,'2022-12-06 14:58:46','2022-12-06 14:58:46'),(4959,'1-1',0,92,'tU6K5IHg',10,0,NULL,'2023-01-03 19:37:43','2023-01-03 19:37:43'),(4960,'1-2',0,92,'tU6K5IHg',10,0,NULL,'2023-01-03 19:37:43','2023-01-03 19:37:43'),(4961,'2-1',0,92,'tU6K5IHg',10,0,NULL,'2023-01-03 19:37:43','2023-01-03 19:37:43'),(4962,'2-2',0,92,'tU6K5IHg',10,0,NULL,'2023-01-03 19:37:43','2023-01-03 19:37:43'),(4963,'1-1',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4964,'1-2',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4965,'1-3',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4966,'1-4',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4967,'1-5',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4968,'1-6',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4969,'2-1',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4970,'2-2',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4971,'2-3',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4972,'2-4',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4973,'2-5',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4974,'2-6',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4975,'3-1',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4976,'3-2',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4977,'3-3',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4978,'3-4',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4979,'3-5',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4980,'3-6',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4981,'4-1',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4982,'4-2',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4983,'4-3',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4984,'4-4',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4985,'4-5',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4986,'4-6',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4987,'5-1',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4988,'5-2',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4989,'5-3',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4990,'5-4',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4991,'5-5',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(4992,'5-6',0,93,'iSzMcQXJ',10,0,NULL,'2023-02-01 11:16:02','2023-02-01 11:16:02'),(5027,'1-1',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5028,'1-2',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5029,'1-3',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5030,'1-4',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5031,'2-1',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5032,'2-2',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5033,'2-3',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5034,'2-4',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5035,'3-1',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5036,'3-2',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5037,'3-3',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5038,'3-4',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5039,'4-1',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5040,'4-2',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5041,'4-3',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5042,'4-4',0,105,'nf2UVwi5',8,0,NULL,'2024-05-13 21:37:53',NULL),(5043,'1-1',1,106,'vWgqPhpu',10,5,'2024-05-18 15:26:37','2024-05-15 14:26:08','2024-05-18 15:02:48'),(5044,'1-2',2,106,'vWgqPhpu',10,5,'2024-05-18 15:26:37','2024-05-15 14:26:08','2024-05-18 15:02:48'),(5045,'1-3',3,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5046,'1-4',8,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5047,'1-5',6,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5048,'1-6',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5049,'2-1',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5050,'2-2',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5051,'2-3',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5052,'2-4',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5053,'2-5',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5054,'2-6',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5055,'3-1',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5056,'3-2',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5057,'3-3',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5058,'3-4',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5059,'3-5',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5060,'3-6',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5061,'4-1',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5062,'4-2',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5063,'4-3',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5064,'4-4',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5065,'4-5',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5066,'4-6',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5067,'5-1',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5068,'5-2',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5069,'5-3',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5070,'5-4',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5071,'5-5',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5072,'5-6',0,106,'vWgqPhpu',10,0,NULL,'2024-05-15 14:26:08','2024-05-18 15:02:48'),(5073,'1-1',1,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5074,'1-2',2,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5075,'1-3',2,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5076,'1-4',4,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5077,'2-1',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5078,'2-2',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5079,'2-3',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5080,'2-4',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5081,'3-1',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5082,'3-2',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5083,'3-3',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5084,'3-4',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5085,'4-1',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5086,'4-2',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5087,'4-3',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5088,'4-4',0,107,'SFNuCUe8',8,0,NULL,'2024-05-15 14:26:48','2024-05-15 16:19:18'),(5179,'1-1',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5180,'1-2',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5181,'1-3',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5182,'1-4',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5183,'1-5',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5184,'1-6',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5185,'2-1',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5186,'2-2',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5187,'2-3',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5188,'2-4',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5189,'2-5',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5190,'2-6',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5191,'3-1',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5192,'3-2',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5193,'3-3',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5194,'3-4',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5195,'3-5',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5196,'3-6',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5197,'4-1',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5198,'4-2',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5199,'4-3',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5200,'4-4',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5201,'4-5',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5202,'4-6',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5203,'5-1',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5204,'5-2',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5205,'5-3',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5206,'5-4',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5207,'5-5',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27'),(5208,'5-6',0,111,'K6YYXHLY',10,0,NULL,'2024-05-19 15:28:27','2024-05-19 15:28:27');
/*!40000 ALTER TABLE `tb_channel` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_order_month_collect`
--
DROP TABLE IF EXISTS `tb_order_month_collect`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_order_month_collect` (
  `id` bigint NOT NULL COMMENT 'id',
  `partner_id` int DEFAULT NULL COMMENT '合作商Id',
  `partner_name` varchar(100) DEFAULT NULL COMMENT '合作商名称',
  `region_id` int DEFAULT NULL COMMENT '区域Id',
  `region_name` varchar(50) DEFAULT NULL COMMENT '地区名称',
  `order_total_money` bigint DEFAULT NULL COMMENT '订单总金额',
  `order_total_count` bigint DEFAULT NULL COMMENT '订单总数',
  `month` int DEFAULT NULL COMMENT '月份',
  `year` int DEFAULT NULL COMMENT '年份',
  PRIMARY KEY (`id`),
  UNIQUE KEY `tb_order_month_collect_id_uindex` (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='按月统计各公司销售情况表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_order_month_collect`
--
LOCK TABLES `tb_order_month_collect` WRITE;
/*!40000 ALTER TABLE `tb_order_month_collect` DISABLE KEYS */;
/*!40000 ALTER TABLE `tb_order_month_collect` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_policy`
--
DROP TABLE IF EXISTS `tb_policy`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_policy` (
  `policy_id` bigint NOT NULL AUTO_INCREMENT COMMENT '策略id',
  `policy_name` varchar(30) DEFAULT NULL COMMENT '策略名称',
  `discount` int DEFAULT NULL COMMENT '策略方案,如:80代表8折',
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`policy_id`),
  UNIQUE KEY `tb_policy_policy_name_uindex` (`policy_name`)
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='策略表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_policy`
--
LOCK TABLES `tb_policy` WRITE;
/*!40000 ALTER TABLE `tb_policy` DISABLE KEYS */;
INSERT INTO `tb_policy` VALUES (1,'九折优惠',90,'2020-09-14 02:51:05','2021-02-01 08:25:06'),(2,'八折优惠',80,'2020-12-18 06:10:39','2020-12-18 06:10:39'),(5,'冬季折扣',70,'2021-01-11 07:29:32','2024-05-13 14:15:32'),(9,'清爽夏日',50,'2021-02-01 08:23:10','2024-05-13 14:15:51');
/*!40000 ALTER TABLE `tb_policy` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_task_details`
--
DROP TABLE IF EXISTS `tb_task_details`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_task_details` (
  `details_id` bigint NOT NULL AUTO_INCREMENT,
  `task_id` bigint DEFAULT NULL COMMENT '工单Id',
  `channel_code` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '货道编号',
  `expect_capacity` int NOT NULL DEFAULT '0' COMMENT '补货期望容量',
  `sku_id` bigint DEFAULT NULL COMMENT '商品Id',
  `sku_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  `sku_image` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL,
  PRIMARY KEY (`details_id`),
  KEY `taskdetails_task_TaskId_fk` (`task_id`),
  CONSTRAINT `taskdetails_task_TaskId_fk` FOREIGN KEY (`task_id`) REFERENCES `tb_task` (`task_id`)
) ENGINE=InnoDB AUTO_INCREMENT=3770 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='工单详情,只有补货工单才有';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_task_details`
--
LOCK TABLES `tb_task_details` WRITE;
/*!40000 ALTER TABLE `tb_task_details` DISABLE KEYS */;
INSERT INTO `tb_task_details` VALUES (3750,526,'1-1',8,1,'可口可乐','https://likede2-java.itheima.net/image/product1.png'),(3751,526,'1-2',9,1,'可口可乐','https://likede2-java.itheima.net/image/product1.png'),(3752,526,'1-3',1,2,'小康师傅','https://likede2-java.itheima.net/image/product2.png'),(3753,526,'1-5',6,3,'统一奶茶','https://likede2-java.itheima.net/image/product3.png'),(3754,526,'3-1',1,7,'一百橙汁','https://likede2-java.itheima.net/image/product7.png'),(3755,526,'3-6',10,1,'可口可乐','https://likede2-java.itheima.net/image/product1.png'),(3768,542,'1-1',5,1,'可口可乐','https://likede2-java.itheima.net/image/product1.png'),(3769,542,'1-2',5,2,'康师傅','https://likede2-java.itheima.net/image/product2.png');
/*!40000 ALTER TABLE `tb_task_details` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_job`
--
DROP TABLE IF EXISTS `tb_job`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_job` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `alert_value` int DEFAULT '0' COMMENT '警戒值百分比',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='自动补货任务';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_job`
--
LOCK TABLES `tb_job` WRITE;
/*!40000 ALTER TABLE `tb_job` DISABLE KEYS */;
INSERT INTO `tb_job` VALUES (1,80);
/*!40000 ALTER TABLE `tb_job` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_vm_type`
--
DROP TABLE IF EXISTS `tb_vm_type`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_vm_type` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `name` varchar(15) NOT NULL COMMENT '型号名称',
  `model` varchar(20) DEFAULT NULL COMMENT '型号编码',
  `image` varchar(500) DEFAULT NULL COMMENT '设备图片',
  `vm_row` int NOT NULL DEFAULT '1' COMMENT '货道行',
  `vm_col` int NOT NULL DEFAULT '1' COMMENT '货道列',
  `channel_max_capacity` int DEFAULT '0' COMMENT '设备容量',
  PRIMARY KEY (`id`),
  UNIQUE KEY `tb_vm_type_name_uindex` (`name`),
  UNIQUE KEY `tb_vm_type_model_uindex` (`model`)
) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='设备类型表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_vm_type`
--
LOCK TABLES `tb_vm_type` WRITE;
/*!40000 ALTER TABLE `tb_vm_type` DISABLE KEYS */;
INSERT INTO `tb_vm_type` VALUES (1,'饮料机','CZ-10011','https://sy-192-ys.oss-cn-beijing.aliyuncs.com/images/2024/05/15/1715762932971.png',5,6,10),(2,'综合机','CZ-10012','https://sy-192-ys.oss-cn-beijing.aliyuncs.com/images/2024/05/15/1715762984492.png',2,2,10),(3,'零食机','CZ-10013','https://sy-192-ys.oss-cn-beijing.aliyuncs.com/images/2024/05/15/1715763009476.png',2,5,5),(4,'果蔬机','CZ-10014','https://sy-192-ys.oss-cn-beijing.aliyuncs.com/images/2024/05/15/1715763319518.png\n',4,4,8);
/*!40000 ALTER TABLE `tb_vm_type` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_task`
--
DROP TABLE IF EXISTS `tb_task`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_task` (
  `task_id` bigint NOT NULL AUTO_INCREMENT COMMENT '工单ID',
  `task_code` varchar(40) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL COMMENT '工单编号',
  `task_status` int DEFAULT NULL COMMENT '工单状态',
  `create_type` int DEFAULT NULL COMMENT '创建类型 0:自动 1:手动',
  `inner_code` varchar(15) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '售货机编码',
  `user_id` int DEFAULT NULL COMMENT '执行人id',
  `user_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '执行人名称',
  `region_id` bigint DEFAULT NULL COMMENT '所属区域Id',
  `desc` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '备注',
  `product_type_id` int DEFAULT '1' COMMENT '工单类型id',
  `assignor_id` int DEFAULT NULL COMMENT '指派人Id',
  `addr` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '地址',
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '更新时间',
  PRIMARY KEY (`task_id`),
  UNIQUE KEY `tb_task_task_code_uindex` (`task_code`),
  KEY `task_productiontype_TypeId_fk` (`product_type_id`),
  KEY `task_taskstatustype_StatusID_fk` (`task_status`),
  KEY `task_tasktype_TypeId_fk` (`create_type`)
) ENGINE=InnoDB AUTO_INCREMENT=544 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='工单表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_task`
--
LOCK TABLES `tb_task` WRITE;
/*!40000 ALTER TABLE `tb_task` DISABLE KEYS */;
INSERT INTO `tb_task` VALUES (523,'202303220001',4,1,'RhLWjaeR',8,'许褚',1,'投放',1,1,'河南省-洛阳市-龙门石窟','2023-03-22 07:51:54','2023-03-22 07:57:05'),(524,'202303220002',4,1,'iSzMcQXJ',8,'许褚',1,'投放',1,1,'河南省-洛阳市-龙门石窟','2023-03-22 08:02:26','2023-03-22 08:13:24'),(525,'202303220003',4,1,'iSzMcQXJ',8,'许褚',1,'11',1,1,'河南省-洛阳市-龙门石窟','2023-03-22 09:11:22','2023-03-22 09:12:15'),(526,'202303220004',4,1,'A1000001',6,'曹操',1,'1',2,1,'河南省-洛阳市-龙门石窟','2023-03-22 09:14:45','2023-03-22 09:16:46'),(527,'202303240001',4,1,'A1000001',9,'张辽',1,'111',3,1,'河南省-洛阳市-龙门石窟','2023-03-24 02:41:10','2023-03-24 02:41:10'),(528,'202303240002',4,1,'Ut548Hpf',8,'许褚',1,'111',3,1,'河南省-洛阳市-洛阳白云山','2023-03-24 02:42:50','2023-03-24 02:42:50'),(529,'202303240003',4,1,'aim5xu4I',50,'孙一百',1,'111',3,1,'河南省-洛阳市-洛阳白云山','2023-03-24 02:43:43','2023-03-24 02:43:43'),(530,'202303240004',4,1,'5cy5BdUs',50,'孙一百',1,'111',3,1,'河南省-洛阳市-洛阳白云山','2023-03-24 02:44:26','2023-03-24 02:44:26'),(531,'202303240005',1,0,'A1000001',50,'孙一百',1,'{\"innerCode\":\"A1000001\",\"statusInfo\":[{\"statusCode\":\"1001\",\"status\":true},{\"statusCode\":\"1002\",\"status\":false},{\"statusCode\":\"1003\",\"status\":true}]}',3,0,'河南省-洛阳市-龙门石窟','2023-03-24 10:04:44','2023-03-24 10:04:44'),(533,'202309200001',3,1,'RhLWjaeR',8,'许褚',1,'',1,1,'河南省-洛阳市-龙门石窟','2023-09-20 08:30:53','2024-05-18 08:08:00'),(535,'202405170001',4,1,'vWgqPhpu',8,'许褚',1,'不想干了',1,1,'北京市昌平区建材城西路22号','2024-05-17 06:39:26',NULL),(542,'202405180001',4,1,'vWgqPhpu',6,'曹操',1,'卖完货了',2,1,'北京市昌平区建材城西路22号','2024-05-18 07:13:05',NULL),(543,'202405190001',1,1,'K6YYXHLY',13,'陆逊',3,'',1,1,'北京顺义区国际鲜花港','2024-05-19 10:45:06','2024-05-19 13:13:16');
/*!40000 ALTER TABLE `tb_task` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_sku_class`
--
DROP TABLE IF EXISTS `tb_sku_class`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_sku_class` (
  `class_id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `class_name` varchar(50) DEFAULT '' COMMENT '类别名称',
  `parent_id` int DEFAULT '0' COMMENT '上级id',
  PRIMARY KEY (`class_id`),
  UNIQUE KEY `tb_sku_class_class_name_uindex` (`class_name`)
) ENGINE=InnoDB AUTO_INCREMENT=15 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='商品类型表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_sku_class`
--
LOCK TABLES `tb_sku_class` WRITE;
/*!40000 ALTER TABLE `tb_sku_class` DISABLE KEYS */;
INSERT INTO `tb_sku_class` VALUES (1,'饮料',0),(2,'零食',0),(3,'食品',0),(4,'玩具',0),(14,'化妆品',0);
/*!40000 ALTER TABLE `tb_sku_class` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_order`
--
DROP TABLE IF EXISTS `tb_order`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_order` (
  `id` bigint NOT NULL COMMENT '主键',
  `order_no` varchar(50) NOT NULL COMMENT '订单编号',
  `third_no` varchar(34) DEFAULT NULL COMMENT '第三方平台单号',
  `inner_code` varchar(15) DEFAULT NULL COMMENT '机器编号',
  `channel_code` varchar(10) DEFAULT NULL COMMENT '货道编号',
  `sku_id` bigint DEFAULT NULL COMMENT 'skuId',
  `sku_name` varchar(20) DEFAULT NULL COMMENT '商品名称',
  `class_id` int DEFAULT NULL COMMENT '商品类别Id',
  `status` int DEFAULT NULL COMMENT '订单状态:0-待支付;1-支付完成;2-出货成功;3-出货失败;4-已取消',
  `amount` int NOT NULL DEFAULT '0' COMMENT '支付金额',
  `price` int NOT NULL DEFAULT '0' COMMENT '商品金额',
  `pay_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '支付类型,1支付宝 2微信',
  `pay_status` int DEFAULT '0' COMMENT '支付状态,0-未支付;1-支付完成;2-退款中;3-退款完成',
  `bill` int DEFAULT '0' COMMENT '合作商账单金额',
  `addr` varchar(200) DEFAULT NULL COMMENT '点位地址',
  `region_id` bigint DEFAULT NULL COMMENT '所属区域Id',
  `region_name` varchar(50) DEFAULT NULL COMMENT '区域名称',
  `business_type` int DEFAULT NULL COMMENT '所属商圈',
  `partner_id` int DEFAULT NULL COMMENT '合作商Id',
  `open_id` varchar(200) DEFAULT NULL COMMENT '跨站身份验证',
  `node_id` bigint DEFAULT NULL COMMENT '点位Id',
  `node_name` varchar(50) DEFAULT NULL COMMENT '点位名称',
  `cancel_desc` varchar(200) DEFAULT '' COMMENT '取消原因',
  `create_time` timestamp NULL DEFAULT NULL COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `Order_OrderNo_uindex` (`order_no`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='订单表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_order`
--
LOCK TABLES `tb_order` WRITE;
/*!40000 ALTER TABLE `tb_order` DISABLE KEYS */;
INSERT INTO `tb_order` VALUES (1639542977692344321,'A1000001802891882192300',NULL,'A1000001',NULL,3,'统一奶茶',1,1,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','1','2023-03-25 08:21:22','2023-03-25 08:21:51'),(1639551491689062401,'A1000001804921842908200',NULL,'A1000001',NULL,2,'小康师傅',1,4,1,1,'wxpay',0,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','2','2023-03-25 08:55:12','2023-03-25 09:00:13'),(1639551769091940353,'A1000001804987986430800',NULL,'A1000001',NULL,7,'一百橙汁',1,4,1,1,'wxpay',0,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-03-25 08:56:18','2023-03-25 09:01:19'),(1639570465608884226,'A1000001809445445129300',NULL,'A1000001',NULL,2,'小康师傅',1,4,1,1,'wxpay',0,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-03-25 10:10:35','2023-03-25 10:11:05'),(1640253438704431106,'A1000001972287294582300',NULL,'A1000001',NULL,1,'可口可乐',1,2,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-03-27 07:24:29','2023-03-27 07:24:52'),(1640291223389851650,'A1000001981295877562800',NULL,'A1000001',NULL,1,'可口可乐',1,4,1,1,'wxpay',0,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-03-27 09:54:37','2023-03-27 09:59:39'),(1640291496925581313,'A1000001981361996771600',NULL,'A1000001',NULL,1,'可口可乐',1,4,1,1,'wxpay',0,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-03-27 09:55:43','2023-03-27 10:00:44'),(1640292440643940353,'A1000001981586907029400',NULL,'A1000001',NULL,1,'可口可乐',1,4,1,1,'alipay',0,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-03-27 09:59:28','2023-03-27 10:04:29'),(1640294278558597121,'A1000001982025093546600',NULL,'A1000001',NULL,1,'可口可乐',1,1,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-03-27 10:06:46','2023-03-27 10:06:59'),(1640295466658119682,'A1000001982308461482000',NULL,'A1000001',NULL,1,'可口可乐',1,3,1,1,'wxpay',3,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-03-27 10:11:29','2023-03-27 10:11:56'),(1665192943211196418,'A10000011867384516930600',NULL,'A1000001',NULL,2,'小康师傅',1,1,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-06-04 03:05:10','2023-06-04 03:05:30'),(1665193128339386370,'A10000011867429590093200',NULL,'A1000001',NULL,3,'统一奶茶',1,1,1,1,'alipay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-06-04 03:05:54','2023-06-04 03:06:07'),(1665193628363337730,'A10000011867548883835400',NULL,'A1000001',NULL,1,'可口可乐',1,1,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-06-04 03:07:53','2023-06-04 03:11:41'),(1665197835275415554,'A10000011868551878012500',NULL,'A1000001',NULL,2,'小康师傅',1,1,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'oJ9WJ5MhIS-hiwuUX0GmsHDzqTyQ',1,'龙门石窟','','2023-06-04 03:24:36','2023-06-04 03:24:58'),(1665199941424197633,'A10000011869054027266500',NULL,'A1000001',NULL,2,'小康师傅',1,1,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'oJ9WJ5MhIS-hiwuUX0GmsHDzqTyQ',1,'龙门石窟','','2023-06-04 03:32:59','2023-06-04 03:33:54'),(1665294465416785921,'A10000011891589370978600',NULL,'A1000001',NULL,9,'新星巴克',1,2,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-06-04 09:48:35','2023-06-04 09:51:34'),(1665296000083259393,'A10000011891956192562900',NULL,'A1000001',NULL,9,'新星巴克',1,3,1,1,'wxpay',3,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-06-04 09:54:41','2023-06-04 09:55:42'),(1699412789128679425,'A100000132363273473600',NULL,'A1000001',NULL,3,'统一奶茶',1,0,1,1,'wxpay',0,0,NULL,1,NULL,1,1,'',1,'龙门石窟','','2023-09-06 13:22:37','2023-09-06 13:22:37'),(1699413852900573185,'A100000132616927206000',NULL,'A1000001','1-8',3,'统一奶茶',1,1,1,1,'wxpay',1,0,NULL,1,NULL,1,1,'',1,'龙门石窟','','2023-09-06 13:26:51','2023-09-06 13:27:51'),(1699609497649393665,'A100000179261600800100',NULL,'A1000001','1-3',2,'小康师傅',NULL,1,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-09-07 02:24:16','2023-09-07 02:25:17'),(1699665320891179009,'A100000192570825504800',NULL,'A1000001','1-5',3,'统一奶茶',NULL,0,1,1,'alipay',0,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-09-07 06:06:05','2023-09-07 06:06:05'),(1699666273908350978,'A100000192798155831900',NULL,'A1000001','1-3',2,'小康师傅',NULL,2,1,1,'alipay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-09-07 06:09:53','2023-09-07 06:12:18'),(1699667483335909378,'A100000193086524012200',NULL,'A1000001','1-1',1,'可口可乐',NULL,2,1,1,'alipay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-09-10 06:14:41','2023-09-07 06:15:51'),(1700104081533829121,'A1000001197178608837400',NULL,'A1000001','1-5',3,'统一奶茶',NULL,2,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-09-10 11:09:34','2023-09-08 11:10:36'),(1700104233585737730,'A1000001197215723001700',NULL,'A1000001','1-1',1,'可口可乐',NULL,2,1,1,'wxpay',1,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-09-10 11:10:10','2023-09-08 11:11:11'),(1702608867975180289,'A1000001794398419433700',NULL,'A1000001','2-2',6,'怡宝至尊',NULL,2,3,1,'wxpay',0,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-09-15 09:02:42','2023-09-15 09:02:42'),(1702614203809349633,'A1000001795671154933400',NULL,'A1000001','1-3',2,'小康师傅',NULL,0,1,1,'alipay',0,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-09-15 09:23:54','2023-09-15 09:23:54'),(1702615729550376962,'A1000001796034964829100',NULL,'A1000001','2-3',8,'魔力花茶',NULL,4,1,1,'alipay',0,0,'河南省-洛阳市-龙门石窟',1,NULL,1,1,'',1,'龙门石窟','','2023-09-15 09:29:58','2023-09-15 09:30:58');
/*!40000 ALTER TABLE `tb_order` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_role`
--
DROP TABLE IF EXISTS `tb_role`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_role` (
  `role_id` int NOT NULL AUTO_INCREMENT,
  `role_code` varchar(50) DEFAULT NULL COMMENT '角色编码\n',
  `role_name` varchar(50) DEFAULT NULL COMMENT '角色名称\n',
  PRIMARY KEY (`role_id`),
  UNIQUE KEY `tb_role_role_code_uindex` (`role_code`),
  UNIQUE KEY `tb_role_role_name_uindex` (`role_name`)
) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='工单角色表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_role`
--
LOCK TABLES `tb_role` WRITE;
/*!40000 ALTER TABLE `tb_role` DISABLE KEYS */;
INSERT INTO `tb_role` VALUES (1,'1001','工单管理员'),(2,'1002','运营员'),(3,'1003','维修员');
/*!40000 ALTER TABLE `tb_role` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_task_type`
--
DROP TABLE IF EXISTS `tb_task_type`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_task_type` (
  `type_id` int NOT NULL,
  `type_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT '类型名称',
  `type` int DEFAULT '1' COMMENT '工单类型。1:维修工单;2:运营工单',
  PRIMARY KEY (`type_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='工单类型';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_task_type`
--
LOCK TABLES `tb_task_type` WRITE;
/*!40000 ALTER TABLE `tb_task_type` DISABLE KEYS */;
INSERT INTO `tb_task_type` VALUES (1,'投放工单',1),(2,'补货工单',2),(3,'维修工单',1),(4,'撤机工单',1);
/*!40000 ALTER TABLE `tb_task_type` ENABLE KEYS */;
UNLOCK TABLES;
--
-- Table structure for table `tb_emp`
--
DROP TABLE IF EXISTS `tb_emp`;
/*!40101 SET @saved_cs_client     = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `tb_emp` (
  `id` int NOT NULL AUTO_INCREMENT COMMENT '主键',
  `user_name` varchar(50) NOT NULL COMMENT '员工名称',
  `region_id` int DEFAULT NULL COMMENT '所属区域Id',
  `region_name` varchar(50) DEFAULT NULL COMMENT '区域名称',
  `role_id` int DEFAULT NULL COMMENT '角色id',
  `role_code` varchar(10) DEFAULT NULL COMMENT '角色编号',
  `role_name` varchar(50) DEFAULT NULL COMMENT '角色名称',
  `mobile` varchar(15) DEFAULT NULL COMMENT '联系电话',
  `image` varchar(500) DEFAULT NULL COMMENT '员工头像',
  `status` tinyint DEFAULT '1' COMMENT '是否启用',
  `create_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
  `update_time` timestamp NULL DEFAULT CURRENT_TIMESTAMP COMMENT '修改时间',
  PRIMARY KEY (`id`),
  UNIQUE KEY `tb_user_Id_uindex` (`id`),
  UNIQUE KEY `tb_user_user_name_uindex` (`user_name`),
  UNIQUE KEY `tb_user_mobile_uindex` (`mobile`),
  KEY `role_id` (`role_id`),
  KEY `region_id` (`region_id`),
  CONSTRAINT `tb_emp_ibfk_1` FOREIGN KEY (`role_id`) REFERENCES `tb_role` (`role_id`),
  CONSTRAINT `tb_emp_ibfk_2` FOREIGN KEY (`region_id`) REFERENCES `tb_region` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=55 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='工单员工表';
/*!40101 SET character_set_client = @saved_cs_client */;
--
-- Dumping data for table `tb_emp`
--
LOCK TABLES `tb_emp` WRITE;
/*!40000 ALTER TABLE `tb_emp` DISABLE KEYS */;
INSERT INTO `tb_emp` VALUES (2,'刘备',2,'北京市海淀区',2,'1002','运营员','13800000001','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:04'),(3,'关羽',2,'北京市海淀区',2,'1002','运营员','13800000002','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:06'),(4,'张飞',2,'北京市海淀区',3,'1003','维修员','13800000003','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:08'),(5,'赵云',2,'北京市海淀区',3,'1003','维修员','13800000004','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:10'),(6,'曹操',1,'北京市朝阳区',2,'1002','运营员','13900139001','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:11'),(7,'夏侯惇',1,'北京市朝阳区',2,'1002','运营员','13900000002','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:13'),(8,'许褚',1,'北京市朝阳区',3,'1003','维修员','13900139003','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:15'),(9,'张辽',1,'北京市朝阳区',3,'1003','维修员','13900000004','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:17'),(10,'孙权',3,'北京市西城区',2,'1002','运营员','13700000001','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:19'),(11,'周瑜',3,'北京市西城区',2,'1002','运营员','13700000002','http://likede2-java.itheima.net/image/avatar.png',0,'2024-06-10 07:06:58','2024-06-10 08:11:21'),(12,'吕蒙',3,'北京市西城区',3,'1003','维修员','13700000003','http://likede2-java.itheima.net/image/avatar.png',0,'2024-06-10 07:06:58','2024-06-10 08:11:24'),(13,'陆逊',3,'北京市西城区',3,'1003','维修员','13700000005','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:26'),(50,'孙一百',1,'北京市朝阳区',3,'1003','维修员','13700137009','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:28'),(51,'马超',2,'北京市海淀区',3,'1003','维修员','13900002222','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:30'),(52,'黄忠',2,'北京市海淀区',2,'1002','运营员','13900005555','http://likede2-java.itheima.net/image/avatar.png',1,'2024-06-10 07:06:58','2024-06-10 08:11:31'),(53,'测试员工',1,'北京市朝阳区',1,'1001','工单管理员','15100000001','/profile/upload/2024/05/18/4e7f3a15429bfda99bce42a18cdd1jpeg_20240518103539A002.jpeg',1,'2024-06-10 07:06:58','2024-06-10 08:11:33');
/*!40000 ALTER TABLE `tb_emp` ENABLE KEYS */;
UNLOCK TABLES;
/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */;
/*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2024-06-11 20:41:57

-- 查询并显示点位表所有的字段信息,同时显示每个点位的设备数量
SELECT
    n.id,
    n.node_name,
    n.address,
    n.business_type,
    n.region_id,
    n.partner_id,
    n.create_time,
    n.update_time,
    n.create_by,
    n.update_by,
    n.remark,
    COUNT(v.id) AS vm_count
FROM
    tb_node n
LEFT JOIN
    tb_vending_machine v ON n.id = v.node_id
GROUP BY
    n.id;
-- 根据区域id查询区域信息
select * from tb_region where id = 1;
-- 根据合作商id查询合作商信息
select * from tb_partner where id = 1;
  • NodeVo
@Data
public class NodeVo extends Node {
    // 设备数量
    private int vmCount;
    // 区域
    private Region region;
    // 合作商
    private Partner partner;
}
  • NodeMapper
/**
 * 查询点位管理列表
 * @param node
 * @return NodeVo集合
 */
public List<NodeVo> selectNodeVoList(Node node);
  • NodeMapper.xml
<!-- 手动映射封装,为了实现多表的嵌套组合查询 -->
<resultMap id="NodeVoResult" type="NodeVo">
    <!-- Node基本信息 -->
    <result property="id"    column="id"    />
    <result property="nodeName"    column="node_name"    />
    <result property="address"    column="address"    />
    <result property="businessType"    column="business_type"    />
    <result property="regionId"    column="region_id"    />
    <result property="partnerId"    column="partner_id"    />
    <result property="createTime"    column="create_time"    />
    <result property="updateTime"    column="update_time"    />
    <result property="createBy"    column="create_by"    />
    <result property="updateBy"    column="update_by"    />
    <result property="remark"    column="remark"    />
    <!-- 关联查询设备数量 -->
    <result property="vmCount" column="vm_count" />
    <!-- Mybatis嵌套查询一的一方association:多对一映射 -->
    <!--
        property:NodeVo的属性变量名
        javaType:NodeVo的属性变量类型
        column:外键作为查询条件(where后的条件)
        select:子查询的Mapper接口的"全类名.方法名",底层反射调用,将查询结果返回给NodeVo的实体类属性中,完成嵌套关联的组合映射
    -->
    <association property="region" javaType="Region" column="region_id" select="com.dkd.manage.mapper.RegionMapper.selectRegionById" />
    <association property="partner" javaType="Partner" column="partner_id" select="com.dkd.manage.mapper.PartnerMapper.selectPartnerById" />
</resultMap>
<select id="selectNodeVoList" resultMap="NodeVoResult">
    SELECT
        n.id,
        n.node_name,
        n.address,
        n.business_type,
        n.region_id,
        n.partner_id,
        n.create_time,
        n.update_time,
        n.create_by,
        n.update_by,
        n.remark,
        COUNT(v.id) AS vm_count
    FROM
        tb_node n
            LEFT JOIN
        tb_vending_machine v ON n.id = v.node_id
    <where>
        <if test="nodeName != null  and nodeName != ''"> and n.node_name like concat('%', #{nodeName}, '%')</if>
        <if test="regionId != null "> and n.region_id = #{regionId}</if>
        <if test="partnerId != null "> and n.partner_id = #{partnerId}</if>
    </where>
    GROUP BY n.id
</select>
  • INodeService
/**
 * 查询点位管理列表
 * @param node
 * @return NodeVo集合
 */
public List<NodeVo> selectNodeVoList(Node node);
  • NodeServiceImpl
/**
 * 查询点位管理列表
 *
 * @param node
 * @return NodeVo集合
 */
@Override
public List<NodeVo> selectNodeVoList(Node node) {
    return nodeMapper.selectNodeVoList(node);
}
  • NodeController
/**
* 查询点位管理列表
*/
@PreAuthorize("@ss.hasPermi('manage:node:list')")
@GetMapping("/list")
public TableDataInfo list(Node node) {
    startPage();
    List<NodeVo> voList = nodeService.selectNodeVoList(node);
    return getDataTable(voList);
}
  • node/index.vue
<!-- 点位列表 -->
<el-table v-loading="loading" :data="nodeList" @selection-change="handleSelectionChange">
  <el-table-column type="selection" width="55" align="center" />
  <el-table-column label="序号" type="index" width="50" align="center" prop="id" />
  <el-table-column label="点位名称" align="center" prop="nodeName" />
  <el-table-column label="所在区域" align="center" prop="region.regionName" />
  <el-table-column label="商圈类型" align="center" prop="businessType">
    <template #default="scope">
      <dict-tag :options="business_type" :value="scope.row.businessType" />
    </template>
  </el-table-column>
  <el-table-column label="合作商" align="center" prop="partner.partnerName" />
  <el-table-column label="详细地址" align="center" prop="address" show-overflow-tooltip="true"/>
  <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
    <template #default="scope">
      <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['manage:node:edit']">修改</el-button>
      <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['manage:node:remove']">删除</el-button>
    </template>
  </el-table-column>
</el-table>

7、区域查看详情

在region/index.vue视图组件中修改

<el-button link type="primary" @click="getRegionInfo(scope.row)" v-hasPermi="['manage:node:list']">查看详情</el-button>
<!-- 查看详情对话框 -->
<el-dialog title="区域详情" v-model="regionInfoOpen" width="500px" append-to-body>
    <el-form-item label="区域名称" prop="regionName">
        <el-input v-model="form.regionName" disabled />
    </el-form-item>
    <label>包含点位:</label>
    <el-table :data="nodeList">
        <el-table-column label="序号" type="index" width="50" align="center" />
        <el-table-column label="点位名称" align="center" prop="nodeName" />
        <el-table-column label="设备数量" align="center" prop="vmCount" />
    </el-table>
</el-dialog>
<script>
    import { listNode } from "@/api/manage/node";
    import { loadAllParams } from "@/api/page";
    
    /* 查看详情按钮操作 */
    const nodeList = ref([]);
    const regionInfoOpen = ref(false);
    function getRegionInfo(row) {
        // 查询区域信息
        reset();
        const _id = row.id
        getRegion(_id).then(response => {
            form.value = response.data;
        });
        // 查询点位列表
        loadAllParams.regionId = row.id;
        listNode(loadAllParams).then(response => {
            nodeList.value = response.rows;
        });
        regionInfoOpen.value = true;
</script>

8、数据完整性

现在我们要思考一个问题,当我们删除区域或合作商数据时,与之关联的点位数据该如何处理?

由于我们在创建点位表时设置了外键约束,并配置了级联删除操作,所以删除区域或合作商会导致其关联的点位数据一并被删除。从技术角度来看,这是符合数据库的外键约束规则的。

但是,从业务角度来看,这种做法可能不太合适。想象一下,如果一个区域下有多个点位,一次误操作就可能导致所有的点位数据及其关联的设备信息被一并删除,这显然是我们不愿意看到的。

因此,我们需要对级联操作进行修改,将其改为限制删除。这样,当尝试删除一个区域或合作商时,如果它下面还有关联的点位数据,数据库将不会允许删除操作,并会给出错误提示。

MySQL外键约束操作规则

  • CASCADE(级联操作):当父表中的某行记录被删除或更新时,与其关联的所有子表中的匹配行也会自动被删除或更新。这种方式适用于希望保持数据一致性的场景,即父记录不存在时,相关的子记录也应该被移除。
  • SET NULL(设为空):若父表中的记录被删除或更新,子表中对应的外键字段会被设置为NULL。选择此选项的前提是子表的外键列允许为NULL值。这适用于那些子记录不再需要明确关联到任何父记录的情况。
  • RESTRICT(限制):在尝试删除或更新父表中的记录之前,数据库首先检查是否有相关联的子记录存在。如果有,则拒绝执行删除或更新操作,以防止意外丢失数据或破坏数据关系的完整性。这是一种保守策略,确保数据间的引用完整性。
  • NO ACTION(无操作):在标准SQL中,NO ACTION是一个关键字,它要求数据库在父表记录被删除或更新前,检查是否会影响子表中的相关记录。在MySQL中,NO ACTION的行为与RESTRICT相同,即如果子表中有匹配的行,则禁止执行父表的删除或更新操作。这意味着如果存在依赖关系,操作将被阻止,从而保护数据的参照完整性。

修改完毕后,如果你尝试进行删除操作,会发现数据库的完整性约束生效了,它会阻止删除操作并给出错误提示。但是,这个错误提示信息可能对于用户来说不够友好,可能会让用户感到困惑。

SQLIntegrityConstraintViolationException是Java中的一个异常类,这个类通常用于表示SQL数据库操作中的完整性约束违反异常

例如:外键约束唯一约束等。当数据库操作违反了这些约束时,就会抛出这个异常。

这个错误是由于外键约束导致的。它表明在删除或更新父表的行时,存在外键约束,子表中的相关行会受到影响。所以在删除tb_region表中的行时,tb_node表中的region_id外键约束会阻止操作。

如果使用Spring框架进行数据库操作,可能会先遇到DataIntegrityViolationException,它是对SQLIntegrityConstraintViolationException的一个更高层次的抽象,旨在提供一种更加面向应用的错误表示。而SQLIntegrityConstraintViolationException是更底层的异常,直接来源于数据库驱动,包含更多底层数据库相关的细节。

在实际开发中,推荐捕获并处理DataIntegrityViolationException,因为它更符合Spring应用的异常处理模式,同时也可以通过其内部的cause(原因)属性来获取具体的SQLIntegrityConstraintViolationException,进而获取详细的错误信息。

为了提升用户体验,我们可以使用Spring Boot框架的全局异常处理器来捕获这些错误信息,并返回更友好的提示信息给用户。当用户遇到这种情况时,他们将收到一个清晰、易懂的提示,告知他们操作无法完成的原因。

修改全局异常处理器,在dkd-framework模块下添加以下内容

/**
* 数据完整性异常
*/
@ExceptionHandler(DataIntegrityViolationException.class)
public AjaxResult handleDataIntegrityViolationException(DataIntegrityViolationException e) {
    log.error(e.getMessage(), e);
    if (e.getMessage().contains("foreign")) {
        return AjaxResult.error("外键约束异常,无法删除,有其他数据引用");
    }
    return AjaxResult.error("数据完整性异常,您的操作违反了数据库中的完整性约束");
}

本次我们通过若依完成了帝可得的后台管理系统的项目环境搭建,并实现了点位管理(包含区域管理、点位管理、合作商管理)模块的开发和改造。下期我们将继续完成人员管理、设备管理等模块的开发。


相关文章
运维 前端开发 Java
10 1
|
16小时前
|
存储 SQL 前端开发
【若依RuoYi-Vue | 项目实战】帝可得后台管理系统(二)
接着上回的【若依RuoYi-Vue | 项目实战】基于若依的帝可得后台管理系统(一),本次我们继续完成人员管理、设备管理、策略管理模块的开发。
【若依RuoYi-Vue | 项目实战】帝可得后台管理系统(二)
|
16小时前
|
监控 NoSQL Java
若依RuoYi项目环境搭建教程(RuoYi-Vue + RuoYi-Vue3版本)
若依(RuoYi)是一款基于Spring Boot和Vue.js的开源Java快速开发脚手架,支持OAuth2、JWT鉴权,集成多种安全框架和持久化框架。它提供了系统管理、监控管理、任务调度、代码生成等常用功能模块,适合中小型公司快速搭建Web应用。本文主要介绍若依框架的特点、版本发展、优缺点及项目部署步骤,帮助开发者快速上手并部署若依项目。
若依RuoYi项目环境搭建教程(RuoYi-Vue + RuoYi-Vue3版本)
|
7月前
|
存储 缓存 前端开发
毕业设计|SpringBoot+Vue的前后端分离个人博客系统
毕业设计|SpringBoot+Vue的前后端分离个人博客系统
131 0
|
7月前
|
JavaScript 前端开发 Java
博客管理系统|基于SpringBoot+Vue+ElementUI个人博客系统的设计与实现
博客管理系统|基于SpringBoot+Vue+ElementUI个人博客系统的设计与实现
307 0
|
监控 JavaScript NoSQL
Springboot+vue前后端分离考试系统
Springboot+vue前后端分离考试系统
149 0
Springboot+vue前后端分离考试系统
|
前端开发 JavaScript Java
前后端分离实现在线音乐网站-springboot+vue
前后端分离实现在线音乐网站-springboot+vue
224 0
前后端分离实现在线音乐网站-springboot+vue
|
前端开发 JavaScript
Vue+ElementUI 搭建后台管理系统(实战系列一)
Vue+ElementUI 搭建后台管理系统(实战系列一)
110 0
|
JSON JavaScript API
Vue+ElementUI 搭建后台管理系统(实战系列四)
Vue+ElementUI 搭建后台管理系统(实战系列四)
152 0
Vue+ElementUI 搭建后台管理系统(实战系列四)
|
存储 JavaScript 前端开发
Vue+ElementUI 搭建后台管理系统(实战系列二)
Vue+ElementUI 搭建后台管理系统(实战系列二)
152 0