diff --git a/doc/项目信息管理API接口文档.md b/doc/项目信息管理API接口文档.md new file mode 100644 index 0000000..d3f6932 --- /dev/null +++ b/doc/项目信息管理API接口文档.md @@ -0,0 +1,357 @@ +# 项目信息管理 API 接口文档 + +## 基础信息 + +- **模块名称**: 项目信息管理 +- **基础路径**: `/project/info` +- **权限标识前缀**: `project:info` + +--- + +## 1. 查询项目信息列表 + +### 接口描述 +分页查询项目信息列表,支持按项目名称、项目负责人模糊查询,以及按安装日期范围查询。 + +### 请求信息 +- **接口路径**: `/project/info/list` +- **请求方式**: `GET` +- **权限要求**: `project:info:list` + +### 请求参数 + +| 参数名 | 类型 | 必填 | 说明 | 示例值 | +|--------|------|------|------|--------| +| pageNum | Integer | 否 | 页码,默认1 | 1 | +| pageSize | Integer | 否 | 每页条数,默认10 | 10 | +| projectName | String | 否 | 项目名称(模糊查询) | 豪生酒店 | +| projectManager | String | 否 | 项目负责人(模糊查询) | 张三 | +| params[beginTime] | String | 否 | 安装日期开始时间(格式:yyyy-MM-dd) | 2025-01-01 | +| params[endTime] | String | 否 | 安装日期结束时间(格式:yyyy-MM-dd) | 2025-12-31 | + +### 请求示例 +``` +GET /project/info/list?pageNum=1&pageSize=10&projectName=豪生&projectManager=张¶ms[beginTime]=2025-01-01¶ms[endTime]=2025-12-31 +``` + +### 响应参数 + +| 参数名 | 类型 | 说明 | +|--------|------|------| +| code | Integer | 状态码(200成功) | +| msg | String | 返回消息 | +| total | Long | 总记录数 | +| rows | Array | 数据列表 | + +**rows数组元素结构**: + +| 参数名 | 类型 | 说明 | +|--------|------|------| +| id | String | 项目ID(UUID) | +| projectCode | String | 用户项目编码 | +| projectName | String | 项目名称 | +| projectAddress | String | 项目地址 | +| installDate | String | 安装日期(yyyy-MM-dd HH:mm:ss) | +| acceptanceDate | String | 验收日期(yyyy-MM-dd HH:mm:ss) | +| onlineDate | String | 上线日期(yyyy-MM-dd HH:mm:ss) | +| deviceCount | Integer | 设备数量 | +| onlineDeviceCount | Integer | 在线设备数量 | +| offlineDeviceCount | Integer | 离线设备数量 | +| gatewayCount | Integer | 网关数量 | +| onlineGatewayCount | Integer | 在线网关数量 | +| offlineGatewayCount | Integer | 离线网关数量 | +| projectManager | String | 项目负责人 | +| electricityPrice | BigDecimal | 电单价 | +| createBy | String | 创建者 | +| createTime | String | 创建时间 | +| updateBy | String | 更新者 | +| updateTime | String | 更新时间 | +| remark | String | 备注 | + +### 响应示例 +```json +{ + "code": 200, + "msg": "查询成功", + "total": 2, + "rows": [ + { + "id": "550e8400-e29b-41d4-a716-446655440000", + "projectCode": "PROJ2025001", + "projectName": "梅州豪生酒店节能改造项目", + "projectAddress": "广东省梅州市梅江区江南街道", + "installDate": "2025-03-15 10:00:00", + "acceptanceDate": "2025-06-20 14:30:00", + "onlineDate": "2025-07-01 09:00:00", + "deviceCount": 150, + "onlineDeviceCount": 145, + "offlineDeviceCount": 5, + "gatewayCount": 10, + "onlineGatewayCount": 10, + "offlineGatewayCount": 0, + "projectManager": "张三", + "electricityPrice": 0.85, + "createBy": "admin", + "createTime": "2025-03-10 08:30:00", + "updateBy": "admin", + "updateTime": "2025-07-01 10:00:00", + "remark": "一期工程项目" + } + ] +} +``` + +--- + +## 2. 查询项目详情 + +### 接口描述 +根据项目ID查询单个项目的详细信息。 + +### 请求信息 +- **接口路径**: `/project/info/{id}` +- **请求方式**: `GET` +- **权限要求**: `project:info:query` + +### 路径参数 + +| 参数名 | 类型 | 必填 | 说明 | 示例值 | +|--------|------|------|------|--------| +| id | String | 是 | 项目ID(UUID) | 550e8400-e29b-41d4-a716-446655440000 | + +### 请求示例 +``` +GET /project/info/550e8400-e29b-41d4-a716-446655440000 +``` + +### 响应参数 +同列表查询的单条记录结构 + +### 响应示例 +```json +{ + "code": 200, + "msg": "操作成功", + "data": { + "id": "550e8400-e29b-41d4-a716-446655440000", + "projectCode": "PROJ2025001", + "projectName": "梅州豪生酒店节能改造项目", + "projectAddress": "广东省梅州市梅江区江南街道", + "installDate": "2025-03-15 10:00:00", + "acceptanceDate": "2025-06-20 14:30:00", + "onlineDate": "2025-07-01 09:00:00", + "deviceCount": 150, + "onlineDeviceCount": 145, + "offlineDeviceCount": 5, + "gatewayCount": 10, + "onlineGatewayCount": 10, + "offlineGatewayCount": 0, + "projectManager": "张三", + "electricityPrice": 0.85, + "createBy": "admin", + "createTime": "2025-03-10 08:30:00", + "updateBy": "admin", + "updateTime": "2025-07-01 10:00:00", + "remark": "一期工程项目" + } +} +``` + +--- + +## 3. 新增项目信息 + +### 接口描述 +创建新的项目信息记录。 + +### 请求信息 +- **接口路径**: `/project/info` +- **请求方式**: `POST` +- **权限要求**: `project:info:add` +- **Content-Type**: `application/json` + +### 请求参数(Body) + +| 参数名 | 类型 | 必填 | 说明 | 示例值 | +|--------|------|------|------|--------| +| projectCode | String | 是 | 用户项目编码 | PROJ2025002 | +| projectName | String | 是 | 项目名称 | 某某酒店项目 | +| projectAddress | String | 否 | 项目地址 | 广东省深圳市南山区 | +| installDate | String | 否 | 安装日期(yyyy-MM-dd HH:mm:ss) | 2025-08-01 10:00:00 | +| acceptanceDate | String | 否 | 验收日期(yyyy-MM-dd HH:mm:ss) | 2025-10-01 14:30:00 | +| onlineDate | String | 否 | 上线日期(yyyy-MM-dd HH:mm:ss) | 2025-10-15 09:00:00 | +| deviceCount | Integer | 否 | 设备数量,默认0 | 100 | +| onlineDeviceCount | Integer | 否 | 在线设备数量,默认0 | 95 | +| offlineDeviceCount | Integer | 否 | 离线设备数量,默认0 | 5 | +| gatewayCount | Integer | 否 | 网关数量,默认0 | 8 | +| onlineGatewayCount | Integer | 否 | 在线网关数量,默认0 | 8 | +| offlineGatewayCount | Integer | 否 | 离线网关数量,默认0 | 0 | +| projectManager | String | 否 | 项目负责人 | 李四 | +| electricityPrice | BigDecimal | 否 | 电单价 | 0.75 | +| remark | String | 否 | 备注 | 二期工程 | + +### 请求示例 +```json +{ + "projectCode": "PROJ2025002", + "projectName": "深圳某某酒店节能改造项目", + "projectAddress": "广东省深圳市南山区科技园", + "installDate": "2025-08-01 10:00:00", + "acceptanceDate": "2025-10-01 14:30:00", + "onlineDate": "2025-10-15 09:00:00", + "deviceCount": 100, + "onlineDeviceCount": 95, + "offlineDeviceCount": 5, + "gatewayCount": 8, + "onlineGatewayCount": 8, + "offlineGatewayCount": 0, + "projectManager": "李四", + "electricityPrice": 0.75, + "remark": "二期工程" +} +``` + +### 响应参数 + +| 参数名 | 类型 | 说明 | +|--------|------|------| +| code | Integer | 状态码(200成功) | +| msg | String | 返回消息 | +| data | Object | 返回数据(包含新增记录的ID) | + +### 响应示例 +```json +{ + "code": 200, + "msg": "操作成功", + "data": { + "id": "660e8400-e29b-41d4-a716-446655440001" + } +} +``` + +--- + +## 4. 修改项目信息 + +### 接口描述 +更新已存在的项目信息记录。 + +### 请求信息 +- **接口路径**: `/project/info` +- **请求方式**: `PUT` +- **权限要求**: `project:info:edit` +- **Content-Type**: `application/json` + +### 请求参数(Body) + +| 参数名 | 类型 | 必填 | 说明 | 示例值 | +|--------|------|------|------|--------| +| id | String | 是 | 项目ID(UUID) | 550e8400-e29b-41d4-a716-446655440000 | +| projectCode | String | 否 | 用户项目编码 | PROJ2025001 | +| projectName | String | 否 | 项目名称 | 梅州豪生酒店节能改造项目(修改后) | +| projectAddress | String | 否 | 项目地址 | 广东省梅州市梅江区江南街道(修改后) | +| installDate | String | 否 | 安装日期 | 2025-03-15 10:00:00 | +| acceptanceDate | String | 否 | 验收日期 | 2025-06-20 14:30:00 | +| onlineDate | String | 否 | 上线日期 | 2025-07-01 09:00:00 | +| deviceCount | Integer | 否 | 设备数量 | 160 | +| onlineDeviceCount | Integer | 否 | 在线设备数量 | 155 | +| offlineDeviceCount | Integer | 否 | 离线设备数量 | 5 | +| gatewayCount | Integer | 否 | 网关数量 | 12 | +| onlineGatewayCount | Integer | 否 | 在线网关数量 | 12 | +| offlineGatewayCount | Integer | 否 | 离线网关数量 | 0 | +| projectManager | String | 否 | 项目负责人 | 王五 | +| electricityPrice | BigDecimal | 否 | 电单价 | 0.90 | +| remark | String | 否 | 备注 | 一期工程扩建 | + +### 请求示例 +```json +{ + "id": "550e8400-e29b-41d4-a716-446655440000", + "projectCode": "PROJ2025001", + "projectName": "梅州豪生酒店节能改造项目(扩建)", + "projectAddress": "广东省梅州市梅江区江南街道", + "deviceCount": 160, + "onlineDeviceCount": 155, + "offlineDeviceCount": 5, + "gatewayCount": 12, + "onlineGatewayCount": 12, + "offlineGatewayCount": 0, + "projectManager": "王五", + "electricityPrice": 0.90, + "remark": "一期工程扩建" +} +``` + +### 响应示例 +```json +{ + "code": 200, + "msg": "操作成功" +} +``` + +--- + +## 5. 删除项目信息 + +### 接口描述 +批量删除项目信息记录。 + +### 请求信息 +- **接口路径**: `/project/info/{ids}` +- **请求方式**: `DELETE` +- **权限要求**: `project:info:remove` + +### 路径参数 + +| 参数名 | 类型 | 必填 | 说明 | 示例值 | +|--------|------|------|------|--------| +| ids | String[] | 是 | 项目ID数组(多个ID用逗号分隔) | 550e8400-e29b-41d4-a716-446655440000,660e8400-e29b-41d4-a716-446655440001 | + +### 请求示例 +``` +DELETE /project/info/550e8400-e29b-41d4-a716-446655440000,660e8400-e29b-41d4-a716-446655440001 +``` + +### 响应示例 +```json +{ + "code": 200, + "msg": "操作成功" +} +``` + +--- + +## 通用说明 + +### 状态码说明 + +| 状态码 | 说明 | +|--------|------| +| 200 | 操作成功 | +| 401 | 未授权,需要登录 | +| 403 | 无权限访问 | +| 404 | 资源不存在 | +| 500 | 服务器内部错误 | + +### 日期格式 +所有日期时间字段统一使用格式:`yyyy-MM-dd HH:mm:ss` + +### 注意事项 +1. 所有写操作(新增、修改、删除)都需要相应的权限 +2. ID由系统自动生成UUID,无需前端传入 +3. 新增和修改操作会自动记录创建人/更新人和时间 +4. 列表查询支持分页,默认每页10条 +5. 查询条件可以组合使用,未传递的条件不参与过滤 +6. 数值类型字段(设备数量、网关数量等)默认为0 +7. 电单价保留4位小数精度 + +### 权限配置 +在系统中需要配置以下权限菜单: +- `project:info:list` - 项目信息查询 +- `project:info:query` - 项目详情查询 +- `project:info:add` - 项目新增 +- `project:info:edit` - 项目修改 +- `project:info:remove` - 项目删除 diff --git a/mh-admin/src/test/java/com/mh/MHApplicationTest.java b/mh-admin/src/test/java/com/mh/MHApplicationTest.java index 29d889d..c4c753d 100644 --- a/mh-admin/src/test/java/com/mh/MHApplicationTest.java +++ b/mh-admin/src/test/java/com/mh/MHApplicationTest.java @@ -11,6 +11,7 @@ import com.mh.common.core.domain.vo.EnergyQueryVO; import com.mh.common.utils.DateUtils; import com.mh.common.utils.StringUtils; import com.mh.quartz.task.DealDataTask; +import com.mh.quartz.task.DealOnOrOffData; import com.mh.quartz.task.GetWeatherDataTask; import com.mh.quartz.task.HotWaterTask; import com.mh.system.mapper.device.DataProcessMapper; @@ -25,6 +26,8 @@ import com.mh.system.service.report.IReportHotWaterService; import jakarta.annotation.Resource; import org.checkerframework.checker.units.qual.A; import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.web.client.RestTemplate; @@ -42,6 +45,7 @@ import java.util.List; @SpringBootTest public class MHApplicationTest { + private static final Logger log = LoggerFactory.getLogger(MHApplicationTest.class); @Autowired private IDeviceQrManageService deviceQrManageService; @@ -66,6 +70,14 @@ public class MHApplicationTest { @Autowired private IComprehensiveReportService comprehensiveReportService; + @Autowired + private DealOnOrOffData dealOnOrOffData; + + @Test + public void setDealOnOrOffData() throws Exception { + dealOnOrOffData.dealDeviceLedger(); + } + @Test public void comprehensiveReport() { long startTime = System.currentTimeMillis(); diff --git a/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceLedger.java b/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceLedger.java index e88d45b..ee35ec1 100644 --- a/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceLedger.java +++ b/mh-common/src/main/java/com/mh/common/core/domain/entity/DeviceLedger.java @@ -110,6 +110,87 @@ public class DeviceLedger extends BaseEntity { */ private Integer orderNum; + // 增加所属分区ID、安装位置、生产日期、购置日期、品牌责任人这些属性值 + /** + * 所属分区ID + */ + private String zoneId; + + /** + * 安装位置 + */ + private String installLocation; + + /** + * 生产日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date productionTime; + + /** + * 购置日期 + */ + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date purchaseTime; + + /** + * 品牌 + */ + private String brand; + + /** + * 品牌负责人 + */ + private String personInCharge; + + public String getZoneId() { + return zoneId; + } + + public void setZoneId(String zoneId) { + this.zoneId = zoneId; + } + + public String getInstallLocation() { + return installLocation; + } + + public void setInstallLocation(String installLocation) { + this.installLocation = installLocation; + } + + public Date getProductionTime() { + return productionTime; + } + + public void setProductionTime(Date productionTime) { + this.productionTime = productionTime; + } + + public Date getPurchaseTime() { + return purchaseTime; + } + + public void setPurchaseTime(Date purchaseTime) { + this.purchaseTime = purchaseTime; + } + + public String getBrand() { + return brand; + } + + public void setBrand(String brand) { + this.brand = brand; + } + + public String getPersonInCharge() { + return personInCharge; + } + + public void setPersonInCharge(String personInCharge) { + this.personInCharge = personInCharge; + } + public Integer getOrderNum() { return orderNum; } diff --git a/mh-quartz/src/main/java/com/mh/quartz/task/DealOnOrOffData.java b/mh-quartz/src/main/java/com/mh/quartz/task/DealOnOrOffData.java index 389ae67..dbf930e 100644 --- a/mh-quartz/src/main/java/com/mh/quartz/task/DealOnOrOffData.java +++ b/mh-quartz/src/main/java/com/mh/quartz/task/DealOnOrOffData.java @@ -24,6 +24,9 @@ public class DealOnOrOffData { public void dealDeviceLedger() { log.info("处理设备在线状态数据"); deviceLedgerService.updateDeviceLedgerStatus(); + //TODO 更新project_info的设备数,在线设备数,离线设备数,网关数量,在线网关数,离线网关数 + // 目前只有一个项目,只需要处理一个 + deviceLedgerService.updateProjectInfo(); } } diff --git a/mh-system/src/main/java/com/mh/system/service/device/IDeviceLedgerService.java b/mh-system/src/main/java/com/mh/system/service/device/IDeviceLedgerService.java index 15d61aa..221c803 100644 --- a/mh-system/src/main/java/com/mh/system/service/device/IDeviceLedgerService.java +++ b/mh-system/src/main/java/com/mh/system/service/device/IDeviceLedgerService.java @@ -28,4 +28,6 @@ public interface IDeviceLedgerService { List deviceState(String systemType); void createOrUpdateDeviceState(); + + void updateProjectInfo(); } diff --git a/mh-system/src/main/java/com/mh/system/service/device/impl/DeviceLedgerServiceImpl.java b/mh-system/src/main/java/com/mh/system/service/device/impl/DeviceLedgerServiceImpl.java index d5e0154..239527e 100644 --- a/mh-system/src/main/java/com/mh/system/service/device/impl/DeviceLedgerServiceImpl.java +++ b/mh-system/src/main/java/com/mh/system/service/device/impl/DeviceLedgerServiceImpl.java @@ -3,16 +3,23 @@ package com.mh.system.service.device.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mh.common.core.domain.entity.DeviceState; import com.mh.common.core.domain.entity.DeviceLedger; +import com.mh.common.core.domain.entity.GatewayManage; +import com.mh.common.core.domain.entity.ProjectInfo; import com.mh.common.utils.StringUtils; import com.mh.system.mapper.device.CollectionParamsManageMapper; import com.mh.system.mapper.device.DeviceLedgerMapper; import com.mh.system.mapper.device.DeviceStateMapper; +import com.mh.system.mapper.device.GatewayManageMapper; +import com.mh.system.mapper.project.ProjectInfoMapper; import com.mh.system.service.device.IDeviceLedgerService; import jakarta.annotation.Resource; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.stereotype.Service; import java.time.LocalDate; import java.time.format.DateTimeFormatter; +import java.util.Date; import java.util.List; /** @@ -25,6 +32,7 @@ import java.util.List; @Service public class DeviceLedgerServiceImpl implements IDeviceLedgerService { + private static final Logger log = LoggerFactory.getLogger(DeviceLedgerServiceImpl.class); @Resource private DeviceLedgerMapper deviceLedgerMapper; @@ -34,6 +42,40 @@ public class DeviceLedgerServiceImpl implements IDeviceLedgerService { @Resource private CollectionParamsManageMapper collectionParamsManageMapper; + @Resource + private GatewayManageMapper gatewayManageMapper; + + @Resource + private ProjectInfoMapper projectInfoMapper; + + @Override + public void updateProjectInfo() { + List deviceLedgers = deviceLedgerMapper.selectList(new QueryWrapper<>()); +// if (!deviceLedgers.isEmpty()) { + // 设备 + int deviceCount = deviceLedgers.size(); + long onlineDeviceCount = deviceLedgers.stream().filter(deviceLedger -> deviceLedger.getStatus() == 0).count(); + long offlineDeviceCount = deviceLedgers.stream().filter(deviceLedger -> deviceLedger.getStatus() == 1).count(); +// } + // 网关 + List gatewayManages = gatewayManageMapper.selectList(new QueryWrapper<>()); +// if (!gatewayManages.isEmpty()) { + int gatewayCount = gatewayManages.size(); + long onlineGatewayCount = gatewayManages.stream().filter(gatewayManage -> gatewayManage.getStatus() == 0).count(); + long offlineGatewayCount = gatewayManages.stream().filter(gatewayManage -> gatewayManage.getStatus() == 1).count(); +// } + projectInfoMapper.selectList(new QueryWrapper<>()).forEach(projectInfo -> { + projectInfo.setDeviceCount(deviceCount); + projectInfo.setOnlineDeviceCount((int) onlineDeviceCount); + projectInfo.setOfflineDeviceCount((int) offlineDeviceCount); + projectInfo.setGatewayCount(gatewayCount); + projectInfo.setOnlineGatewayCount((int) onlineGatewayCount); + projectInfo.setOfflineGatewayCount((int) offlineGatewayCount); + projectInfo.setUpdateTime(new Date()); + projectInfoMapper.updateById(projectInfo); + }); + } + @Override public List deviceState(String systemType) { if (StringUtils.isEmpty(systemType)) { @@ -53,9 +95,15 @@ public class DeviceLedgerServiceImpl implements IDeviceLedgerService { // 先从采集点为中查询,看看当天是否有数据上来 List deviceLedgerList = collectionParamsManageMapper.OffLine(); // 开始根据id更新设备台账状态 - for (String deviceLedgerId : deviceLedgerList) { - deviceLedgerMapper.updateOnlineOrOfflineStatus(deviceLedgerId, 1); - } + deviceLedgerMapper.selectList(new QueryWrapper<>()).forEach(deviceLedger -> { + // 判断查询出来的id是否在deviceLedgerList,如果存在则更新为离线 + if (deviceLedgerList.contains(deviceLedger.getId())) { + deviceLedgerMapper.updateOnlineOrOfflineStatus(deviceLedger.getId(), 1); + } else { + // 不在则更新为在线 + deviceLedgerMapper.updateOnlineOrOfflineStatus(deviceLedger.getId(), 0); + } + }); } @Override @@ -76,6 +124,22 @@ public class DeviceLedgerServiceImpl implements IDeviceLedgerService { if (!StringUtils.isEmpty(ledgerInfo.getDeviceType())) { queryWrapper.eq("device_type", ledgerInfo.getDeviceType()); } + // 所属分区ID + if (!StringUtils.isEmpty(ledgerInfo.getZoneId())) { + queryWrapper.eq("zone_id", ledgerInfo.getZoneId()); + } + // 安装位置 + if (!StringUtils.isEmpty(ledgerInfo.getInstallLocation())) { + queryWrapper.like("install_location", ledgerInfo.getInstallLocation()); + } + // 品牌 + if (!StringUtils.isEmpty(ledgerInfo.getBrand())) { + queryWrapper.eq("brand", ledgerInfo.getBrand()); + } + // 品牌负责人 + if (!StringUtils.isEmpty(ledgerInfo.getPersonInCharge())) { + queryWrapper.like("person_in_charge", ledgerInfo.getPersonInCharge()); + } // 出入库时间范围 if (ledgerInfo.getParams() != null && !ledgerInfo.getParams().isEmpty()) { String beginTimeStr = (String) ledgerInfo.getParams().get("beginTime"); diff --git a/sql/device_ledger_add_fields.sql b/sql/device_ledger_add_fields.sql new file mode 100644 index 0000000..4c010c7 --- /dev/null +++ b/sql/device_ledger_add_fields.sql @@ -0,0 +1,28 @@ +-- 为device_ledger表添加新字段 +-- 执行日期: 2026-06-11 + +-- 添加所属分区ID字段 +ALTER TABLE device_ledger ADD COLUMN IF NOT EXISTS zone_id VARCHAR(255); + +-- 添加安装位置字段 +ALTER TABLE device_ledger ADD COLUMN IF NOT EXISTS install_location VARCHAR(500); + +-- 添加生产日期字段 +ALTER TABLE device_ledger ADD COLUMN IF NOT EXISTS production_time TIMESTAMP; + +-- 添加购置日期字段 +ALTER TABLE device_ledger ADD COLUMN IF NOT EXISTS purchase_time TIMESTAMP; + +-- 添加品牌字段 +ALTER TABLE device_ledger ADD COLUMN IF NOT EXISTS brand VARCHAR(255); + +-- 添加品牌负责人字段 +ALTER TABLE device_ledger ADD COLUMN IF NOT EXISTS person_in_charge VARCHAR(255); + +-- 添加字段注释 +COMMENT ON COLUMN device_ledger.zone_id IS '所属分区ID'; +COMMENT ON COLUMN device_ledger.install_location IS '安装位置'; +COMMENT ON COLUMN device_ledger.production_time IS '生产日期'; +COMMENT ON COLUMN device_ledger.purchase_time IS '购置日期'; +COMMENT ON COLUMN device_ledger.brand IS '品牌'; +COMMENT ON COLUMN device_ledger.person_in_charge IS '品牌负责人'; diff --git a/sql/project_info.sql b/sql/project_info.sql new file mode 100644 index 0000000..d9b6f7d --- /dev/null +++ b/sql/project_info.sql @@ -0,0 +1,54 @@ +-- 创建项目信息表 +-- 执行日期: 2026-06-11 + +CREATE TABLE IF NOT EXISTS project_info ( + id VARCHAR(36) PRIMARY KEY, + project_code VARCHAR(100) NOT NULL, + project_name VARCHAR(255) NOT NULL, + project_address VARCHAR(500), + install_date TIMESTAMP, + acceptance_date TIMESTAMP, + online_date TIMESTAMP, + device_count INTEGER DEFAULT 0, + online_device_count INTEGER DEFAULT 0, + offline_device_count INTEGER DEFAULT 0, + gateway_count INTEGER DEFAULT 0, + online_gateway_count INTEGER DEFAULT 0, + offline_gateway_count INTEGER DEFAULT 0, + project_manager VARCHAR(100), + electricity_price DECIMAL(10, 4), + create_by VARCHAR(64), + create_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + update_by VARCHAR(64), + update_time TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + remark VARCHAR(500) +); + +-- 添加字段注释 +COMMENT ON TABLE project_info IS '项目信息表'; +COMMENT ON COLUMN project_info.id IS '主键ID'; +COMMENT ON COLUMN project_info.project_code IS '用户项目编码'; +COMMENT ON COLUMN project_info.project_name IS '项目名称'; +COMMENT ON COLUMN project_info.project_address IS '项目地址'; +COMMENT ON COLUMN project_info.install_date IS '安装日期'; +COMMENT ON COLUMN project_info.acceptance_date IS '验收日期'; +COMMENT ON COLUMN project_info.online_date IS '上线日期'; +COMMENT ON COLUMN project_info.device_count IS '设备数量'; +COMMENT ON COLUMN project_info.online_device_count IS '在线设备数量'; +COMMENT ON COLUMN project_info.offline_device_count IS '离线设备数量'; +COMMENT ON COLUMN project_info.gateway_count IS '网关数量'; +COMMENT ON COLUMN project_info.online_gateway_count IS '在线网关数量'; +COMMENT ON COLUMN project_info.offline_gateway_count IS '离线网关数量'; +COMMENT ON COLUMN project_info.project_manager IS '项目负责人'; +COMMENT ON COLUMN project_info.electricity_price IS '电单价'; +COMMENT ON COLUMN project_info.create_by IS '创建者'; +COMMENT ON COLUMN project_info.create_time IS '创建时间'; +COMMENT ON COLUMN project_info.update_by IS '更新者'; +COMMENT ON COLUMN project_info.update_time IS '更新时间'; +COMMENT ON COLUMN project_info.remark IS '备注'; + +-- 创建索引 +CREATE INDEX IF NOT EXISTS idx_project_code ON project_info(project_code); +CREATE INDEX IF NOT EXISTS idx_project_name ON project_info(project_name); +CREATE INDEX IF NOT EXISTS idx_project_manager ON project_info(project_manager); +CREATE INDEX IF NOT EXISTS idx_install_date ON project_info(install_date);