diff --git a/src/main/java/com/iflytop/handacid/app/controller/DeviceController.java b/src/main/java/com/iflytop/handacid/app/controller/DeviceController.java index 44d6e91..db14dd2 100644 --- a/src/main/java/com/iflytop/handacid/app/controller/DeviceController.java +++ b/src/main/java/com/iflytop/handacid/app/controller/DeviceController.java @@ -5,6 +5,7 @@ import com.iflytop.handacid.app.core.state.DeviceState; import com.iflytop.handacid.app.model.bo.SyncOperationsChannel; import com.iflytop.handacid.app.model.dto.SyncOperationsDTO; import com.iflytop.handacid.common.result.Result; +import com.iflytop.handacid.common.service.SolutionService; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.tags.Tag; import lombok.RequiredArgsConstructor; @@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.*; @Slf4j public class DeviceController { private final DeviceState deviceState; + private final SolutionService solutionService; @Operation(summary = "获取当前设备状态") @GetMapping("/device-status") diff --git a/src/main/java/com/iflytop/handacid/app/controller/FormulationController.java b/src/main/java/com/iflytop/handacid/app/controller/FormulationController.java index f68496c..c60eabc 100644 --- a/src/main/java/com/iflytop/handacid/app/controller/FormulationController.java +++ b/src/main/java/com/iflytop/handacid/app/controller/FormulationController.java @@ -33,7 +33,7 @@ public class FormulationController { @PostMapping("/page") @Operation(summary = "获取分页数据") public PageResult getPage(BasePageQuery query) { - return PageResult.success(formulationService.selectPageVo(query)); + return PageResult.success(null); } /* @GetMapping("/list") diff --git a/src/main/java/com/iflytop/handacid/app/controller/ReceiveRecordController.java b/src/main/java/com/iflytop/handacid/app/controller/ReceiveRecordController.java index 54c5252..7240e34 100644 --- a/src/main/java/com/iflytop/handacid/app/controller/ReceiveRecordController.java +++ b/src/main/java/com/iflytop/handacid/app/controller/ReceiveRecordController.java @@ -57,7 +57,7 @@ public class ReceiveRecordController { } @PostMapping - @Operation(summary = "新增记录") + @Operation(summary = "领取溶液") public Result create(@RequestBody ReceiveRecord receiveRecord) { boolean flag = receiveRecordService.save(receiveRecord); return flag? Result.success("添加成功") : Result.failed("添加失败"); diff --git a/src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java b/src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java index 3bac625..2327506 100644 --- a/src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java +++ b/src/main/java/com/iflytop/handacid/app/service/DeviceInitService.java @@ -5,7 +5,9 @@ import com.iflytop.handacid.app.common.enums.ChannelCode; import com.iflytop.handacid.app.core.state.ChannelState; import com.iflytop.handacid.app.core.state.DeviceState; import com.iflytop.handacid.common.model.entity.Channel; +import com.iflytop.handacid.common.model.entity.Solution; import com.iflytop.handacid.common.service.ChannelService; +import com.iflytop.handacid.common.service.SolutionService; import com.iflytop.handacid.hardware.service.AppEventBusService; import com.iflytop.handacid.hardware.type.appevent.A8kCanBusOnConnectEvent; import com.iflytop.handacid.hardware.type.appevent.AppEvent; @@ -24,6 +26,8 @@ public class DeviceInitService { private final DeviceState deviceState; private final ObjectProvider channelStateObjectProvider; private final ChannelService channelService; + private final SolutionService solutionService; + @PostConstruct public void init() { @@ -54,7 +58,8 @@ public class DeviceInitService { for (ChannelCode code : ChannelCode.values()) { //初始化通道 Channel channel = channelService.getOne(new LambdaQueryWrapper<>(new Channel()).eq(Channel::getCode, code)); - ChannelState channelState = channelStateObjectProvider.getObject(code, channel.getVolume(), channel.getSolutionId(), channel.getSolutionName(), channel.getConcentration()); + Solution solution = solutionService.getById(channel.getSolutionId()); + ChannelState channelState = channelStateObjectProvider.getObject(code, channel.getVolume(), solution.getId(), solution.getName(), solution.getConcentration()); deviceState.getChannelStateMap().put(code, channelState); } log.info("初始化 initDeviceState完毕"); diff --git a/src/main/java/com/iflytop/handacid/common/mapper/FormulationMapper.java b/src/main/java/com/iflytop/handacid/common/mapper/FormulationMapper.java index 18cee71..0a17903 100644 --- a/src/main/java/com/iflytop/handacid/common/mapper/FormulationMapper.java +++ b/src/main/java/com/iflytop/handacid/common/mapper/FormulationMapper.java @@ -12,5 +12,4 @@ import org.apache.ibatis.annotations.*; */ @Mapper public interface FormulationMapper extends BaseMapper { - IPage selectPageVo(IPage page); } \ No newline at end of file diff --git a/src/main/java/com/iflytop/handacid/common/mapper/FormulationMapper.xml b/src/main/java/com/iflytop/handacid/common/mapper/FormulationMapper.xml deleted file mode 100644 index 33ecc3c..0000000 --- a/src/main/java/com/iflytop/handacid/common/mapper/FormulationMapper.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main/java/com/iflytop/handacid/common/service/FormulationService.java b/src/main/java/com/iflytop/handacid/common/service/FormulationService.java index 7017109..ea93d0a 100644 --- a/src/main/java/com/iflytop/handacid/common/service/FormulationService.java +++ b/src/main/java/com/iflytop/handacid/common/service/FormulationService.java @@ -1,30 +1,16 @@ package com.iflytop.handacid.common.service; -import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; -import com.baomidou.mybatisplus.core.metadata.IPage; -import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.iflytop.handacid.common.base.BasePageQuery; import com.iflytop.handacid.common.mapper.FormulationMapper; import com.iflytop.handacid.common.model.entity.Formulation; -import com.iflytop.handacid.common.model.vo.FormulationVO; -import com.iflytop.handacid.common.result.PageResult; import lombok.RequiredArgsConstructor; import org.springframework.stereotype.Service; -import java.util.List; - /** * 配方接口服务 */ @Service @RequiredArgsConstructor public class FormulationService extends ServiceImpl { - private final FormulationMapper formulationMapper; - public IPage selectPageVo(BasePageQuery query) { - IPage page = new Page<>(); - page.setSize(query.getPageSize()); - page.setCurrent(query.getPageNum()); - return formulationMapper.selectPageVo(page); - } + } diff --git a/src/main/resources/sql/init.sql b/src/main/resources/sql/init.sql index 933ef79..428bf2f 100644 --- a/src/main/resources/sql/init.sql +++ b/src/main/resources/sql/init.sql @@ -1,99 +1,74 @@ --- ---------------------------- --- Table structure for audit_record --- ---------------------------- -CREATE TABLE IF NOT EXISTS audit_record ( - id INTEGER NOT NULL PRIMARY KEY, - user_id INTEGER, - user_name TEXT, - solution_id INTEGER, - solution_name TEXT, - concentration TEXT, - channel_id INTEGER, - volume TEXT, - create_time DATE DEFAULT CURRENT_TIMESTAMP, - update_time DATE DEFAULT CURRENT_TIMESTAMP +-- 审计记录(使用记录) +CREATE TABLE IF NOT EXISTS audit_record( + id INTEGER PRIMARY KEY AUTOINCREMENT, + user_id INTEGER,--用户ID + user_nickname TEXT,--用户昵称 + solution_id INTEGER,--溶液id + solution_name TEXT,--溶液名称 + concentration TEXT,--溶液浓度 + channel_code TEXT,--通道code + volume TEXT,--使用溶液量 + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); --- ---------------------------- --- Table structure for channel --- ---------------------------- +-- 领取记录(加液记录) +CREATE TABLE IF NOT EXISTS receive_record ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + receiver_id INTEGER,--领取人id + receiver_nickname TEXT,--领取人昵称 + solution_id INTEGER,--溶液id + concentration TEXT,--溶液浓度 + volume REAL,--领取量 + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + +-- 通道 CREATE TABLE IF NOT EXISTS channel ( - id INTEGER NOT NULL PRIMARY KEY, - name TEXT, - solution_id INTEGER, - solution_name TEXT, - concentration TEXT, - code TEXT, - volume DOUBLE, - create_time DATE DEFAULT CURRENT_TIMESTAMP, - update_time DATE DEFAULT CURRENT_TIMESTAMP + id INTEGER PRIMARY KEY AUTOINCREMENT, + name TEXT,--通道名称 + code TEXT,--通道code + solution_id INTEGER,--绑定的溶液id + concentration TEXT,--绑定的溶液浓度 + volume REAL,--剩余溶液量 + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); --- ---------------------------- --- Records of channel --- ---------------------------- INSERT OR IGNORE INTO channel ( - id, name, solution_id, solution_name, concentration, code, volume + id, name, solution_id, code, volume ) VALUES - (1, '通道一', 1, '盐酸', '15%', 'CHANNEL_1', 5000), - (2, '通道二', 1, '盐酸', '15%', 'CHANNEL_2', 5000), - (3, '通道三', 1, '盐酸', '15%', 'CHANNEL_3', 5000), - (4, '通道四', 1, '盐酸', '15%', 'CHANNEL_4', 5000); + (1, '通道一', 1, 'CHANNEL_1', 5000), + (2, '通道二', 1, 'CHANNEL_2', 5000), + (3, '通道三', 1, 'CHANNEL_3', 5000), + (4, '通道四', 1, 'CHANNEL_4', 5000); --- ---------------------------- --- Table structure for formulation --- ---------------------------- --- drop table IF EXISTS formulation; +-- 配方 CREATE TABLE IF NOT EXISTS formulation ( - id INTEGER NOT NULL PRIMARY KEY, - volume DOUBLE, - solution_id INTEGER, - revolutions DOUBLE, - create_time DATE DEFAULT CURRENT_TIMESTAMP, - update_time DATE DEFAULT CURRENT_TIMESTAMP -); - --- ---------------------------- --- Table structure for receive_record --- ---------------------------- -CREATE TABLE IF NOT EXISTS receive_record ( - id INTEGER NOT NULL PRIMARY KEY, - user_id INTEGER, - user_name TEXT, - receiver TEXT, - receiver_id INTEGER, - solution_id INTEGER, - solution_name TEXT, - concentration TEXT, - channel_id INTEGER, - volume DOUBLE, - create_time DATE DEFAULT CURRENT_TIMESTAMP, - update_time DATE DEFAULT CURRENT_TIMESTAMP + id INTEGER PRIMARY KEY AUTOINCREMENT, + volume REAL,--加液量 + solution_id INTEGER,--溶液id + concentration REAL,--溶液浓度 + revolutions REAL,--对应转数 + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); --- ---------------------------- --- Table structure for solution --- ---------------------------- --- drop table IF EXISTS solution; +-- 溶液 CREATE TABLE IF NOT EXISTS solution ( id INTEGER PRIMARY KEY AUTOINCREMENT, - name TEXT, - concentration DOUBLE, - scale DOUBLE, + name TEXT,--溶液名称 create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); --- ---------------------------- --- Records of solution --- ---------------------------- INSERT OR IGNORE INTO solution (id, name, concentration, scale) VALUES (1, '盐酸', 15, 1.1), (2, '硫酸', 10, 1.2); --- ---------------------------- --- Table structure for system_config --- ---------------------------- + +-- 系统配置 CREATE TABLE IF NOT EXISTS system_config ( id INTEGER PRIMARY KEY AUTOINCREMENT, key TEXT, @@ -102,15 +77,8 @@ CREATE TABLE IF NOT EXISTS system_config ( create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); --- ---------------------------- --- Records of system_config --- ---------------------------- - - --- ---------------------------- --- Table structure for system_log --- ---------------------------- +-- 系统日志 CREATE TABLE IF NOT EXISTS system_log ( id INTEGER PRIMARY KEY AUTOINCREMENT, title TEXT, @@ -119,35 +87,29 @@ CREATE TABLE IF NOT EXISTS system_log ( update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); --- ---------------------------- --- Table structure for user --- ---------------------------- +-- 用户 CREATE TABLE IF NOT EXISTS user ( id INTEGER PRIMARY KEY AUTOINCREMENT, - username TEXT UNIQUE, - nickname TEXT, - password TEXT, - role TEXT, - fixed_user TEXT DEFAULT 'DISABLE', - deleted TEXT DEFAULT 'DISABLE', + username TEXT UNIQUE, --用户账号 + nickname TEXT,--用户昵称 + password TEXT,--密码 + role TEXT,--角色 + fixed_user TEXT DEFAULT 'DISABLE',--是否内置用户 + deleted TEXT DEFAULT 'DISABLE',--逻辑删除 create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); --- ---------------------------- --- Records of user --- ---------------------------- + INSERT OR IGNORE INTO user ( id, username, nickname, password, role, fixed_user, deleted ) VALUES (1, 'admin', 'Admin', '9973', 'ADMIN', 'ENABLE', 'DISABLE'), (2, 'test', 'test', '9973', 'ADMIN', 'ENABLE', 'DISABLE'); --- ---------------------------- --- Table structure for zapp_sub_module_reg_initial_value --- ---------------------------- + CREATE TABLE IF NOT EXISTS zapp_sub_module_reg_initial_value ( - id INTEGER PRIMARY KEY, + id INTEGER PRIMARY KEY AUTOINCREMENT, mid TEXT, regIndex TEXT, regInitVal INTEGER