diff --git a/pom.xml b/pom.xml index f05decc..d34587f 100644 --- a/pom.xml +++ b/pom.xml @@ -27,6 +27,15 @@ 1.0-SNAPSHOT + + + com.alibaba + easyexcel + 3.3.2 + + @@ -48,6 +57,14 @@ + + org.apache.maven.plugins + maven-compiler-plugin + + 15 + 15 + + diff --git a/src/main/java/com/gunshi/project/xyt/controller/WaterQualityController.java b/src/main/java/com/gunshi/project/xyt/controller/WaterQualityController.java new file mode 100644 index 0000000..827f0ab --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/controller/WaterQualityController.java @@ -0,0 +1,95 @@ +package com.gunshi.project.xyt.controller; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.gunshi.core.result.R; +import com.gunshi.project.xyt.model.StWaterQualityR; +import com.gunshi.project.xyt.service.WaterQualityService; +import com.gunshi.project.xyt.so.WaterQualityPageSo; +import com.gunshi.project.xyt.validate.markers.QueryPage; +import com.gunshi.project.xyt.validate.markers.QueryTimeRange; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.servlet.http.HttpServletResponse; +import lombok.Data; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; + +/** + * Description: + * Created by xusan on 2024/1/23 + * + * @author xusan + * @version 1.0 + */ +@RestController +@Slf4j +@Tag(name = "水质整编接口-controller", description = "水质整编接口") +@Data +@RequestMapping("/waterQuality") +public class WaterQualityController { + + private final WaterQualityService waterqualityService; + +// @Operation(summary = "新增水质监测数据") +// @ApiResponses(value = { +// @ApiResponse(responseCode = "200",description = "成功") +// }) +// @PostMapping("/add") +// public R add(@RequestBody @Validated StWaterQualityR organization){ +// return R.ok(waterqualityService.add(organization)); +// } +// +// @Operation(summary = "更新水质监测数据") +// @ApiResponses(value = { +// @ApiResponse(responseCode = "200",description = "成功") +// }) +// @PostMapping("/update") +// public R update(@RequestBody @Validated StWaterQualityR organization){ +// return R.ok(waterqualityService.update(organization)); +// } +// +// @Operation(summary = "根据id删除水质监测数据") +// @Parameter(name = "id", description = "水质监测数据id") +// @DeleteMapping("/delete") +// public R delete(@RequestParam("id") String orgCode){ +// return R.ok(waterqualityService.delete(orgCode)); +// } + + @Operation(summary = "水质监测数据分页查询") + @PostMapping("/page") + public R> page( + @Validated({QueryPage.class, QueryTimeRange.class}) @RequestBody + WaterQualityPageSo waterQualityPageSo + ) { + return R.ok(waterqualityService.page(waterQualityPageSo)); + } + + @Operation(summary = "水质监测数据导出") + @GetMapping("/export") + public void export(WaterQualityPageSo waterQualityPageSo, HttpServletResponse response) { + waterqualityService.export(waterQualityPageSo, response); + } + + @Operation(summary = "水质监测数据导入") + @GetMapping("/import") + public R importExcel(@RequestParam("file") MultipartFile file) { + if (file.isEmpty()) { + return R.error(400, "请选择上传文件"); + } + + try { + + return R.ok( waterqualityService.importExcel(file)); + + } catch (IOException e) { + + return R.error(500, "文件上传失败: " + e.getMessage()); + + } + } + +} diff --git a/src/main/java/com/gunshi/project/xyt/mapper/WaterQualityMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/WaterQualityMapper.java new file mode 100644 index 0000000..26cc3a0 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/mapper/WaterQualityMapper.java @@ -0,0 +1,16 @@ +package com.gunshi.project.xyt.mapper; + +import com.gunshi.db.dao.IMapper; +import com.gunshi.project.xyt.model.StWaterQualityR; +import org.apache.ibatis.annotations.Mapper; + +/** + * Description: + * Created by XuSan on 2024/1/23. + * + * @author XuSan + * @version 1.0 + */ +@Mapper +public interface WaterQualityMapper extends IMapper { +} diff --git a/src/main/java/com/gunshi/project/xyt/model/StWaterQualityR.java b/src/main/java/com/gunshi/project/xyt/model/StWaterQualityR.java new file mode 100644 index 0000000..1f5a67e --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/model/StWaterQualityR.java @@ -0,0 +1,280 @@ +package com.gunshi.project.xyt.model; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * Description: + * Created by XuSan on 2024/1/23. + * + * @author XuSan + * @version 1.0 + */ +/** + * 水质自动监测数据表 + */ +@Data +@TableName(value = "ST_WATER_QUALITY_R") +@Schema(description = "水质自动监测数据表") +public class StWaterQualityR { + + /** + * 主键id + */ + @TableId(value = "ID", type = IdType.AUTO) + @Schema(description = "主键id") + @ExcelProperty("编号") + private Integer id; + + /** + * 站码 + */ + @TableField(value = "STCD") + @Schema(description = "站码") + @ExcelProperty("站码") + private String stcd; + + /** + * 采样时间 + */ + @TableField(value = "SPT") + @Schema(description = "采样时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8") + @ExcelProperty("采样时间") + private LocalDateTime spt; + + /** + * 水温 + */ + @TableField(value = "WIMP") + @Schema(description = "水温") + @ExcelProperty("水温") + private BigDecimal wimp; + + /** + * PH值 + */ + @TableField(value = "PH") + @Schema(description = "PH值") + @ExcelProperty("PH值") + private BigDecimal ph; + + /** + * 电导率 + */ + @TableField(value = "COND") + @Schema(description = "电导率") + @ExcelProperty("电导率") + private BigDecimal cond; + + /** + * 浑浊度 + */ + @TableField(value = "TURB") + @Schema(description = "浑浊度") + @ExcelProperty("浑浊度") + private BigDecimal turb; + + /** + * 溶解氧 + */ + @TableField(value = "DOX") + @Schema(description = "溶解氧") + @ExcelProperty("溶解氧") + private BigDecimal dox; + + /** + * 高锰酸钾指数 + */ + @TableField(value = "CODMN") + @Schema(description = "高锰酸钾指数") + @ExcelProperty("高锰酸钾指数") + private BigDecimal codmn; + + /** + * 化学需氧量 + */ + @TableField(value = "CODCR") + @Schema(description = "化学需氧量") + @ExcelProperty("化学需氧量") + private BigDecimal codcr; + + /** + * 总氮 + */ + @TableField(value = "TN") + @Schema(description = "总氮") + @ExcelProperty("总氮") + private BigDecimal tn; + + /** + * 氨氮 + */ + @TableField(value = "NH3N") + @Schema(description = "氨氮") + @ExcelProperty("氨氮") + private BigDecimal nh3N; + + /** + * 亚硝酸盐氮 + */ + @TableField(value = "NO2") + @Schema(description = "亚硝酸盐氮") + @ExcelProperty("亚硝酸盐氮") + private BigDecimal no2; + + /** + * 硝酸盐氮 + */ + @TableField(value = "NO3") + @Schema(description = "硝酸盐氮") + @ExcelProperty("硝酸盐氮") + private BigDecimal no3; + + /** + * 总磷 + */ + @TableField(value = "TP") + @Schema(description = "总磷") + @ExcelProperty("总磷") + private BigDecimal tp; + + /** + * 总有机碳 + */ + @TableField(value = "TOC") + @Schema(description = "总有机碳") + @ExcelProperty("总有机碳") + private BigDecimal toc; + + /** + * 挥发酚 + */ + @TableField(value = "VLPH") + @Schema(description = "挥发酚") + @ExcelProperty("挥发酚") + private BigDecimal vlph; + + /** + * 叶绿素a + */ + @TableField(value = "CHLA") + @Schema(description = "叶绿素a") + @ExcelProperty("叶绿素a") + private BigDecimal chla; + + /** + * 氟化物 + */ + @TableField(value = "F") + @Schema(description = "氟化物") + @ExcelProperty("氟化物") + private BigDecimal f; + + /** + * 砷 + */ + @TableField(value = "ARS") + @Schema(description = "砷") + @ExcelProperty("砷") + private BigDecimal ars; + + /** + * 汞 + */ + @TableField(value = "HG") + @Schema(description = "汞") + @ExcelProperty("汞") + private BigDecimal hg; + + /** + * 铬(六价) + */ + @TableField(value = "CR6") + @Schema(description = "铬(六价)") + @ExcelProperty("铬(六价)") + private BigDecimal cr6; + + /** + * 铜 + */ + @TableField(value = "CU") + @Schema(description = "铜") + @ExcelProperty("铜") + private BigDecimal cu; + + /** + * 铅 + */ + @TableField(value = "PB") + @Schema(description = "铅") + @ExcelProperty("铅") + private BigDecimal pb; + + /** + * 镉 + */ + @TableField(value = "CD") + @Schema(description = "镉") + @ExcelProperty("镉") + private BigDecimal cd; + + /** + * 锌 + */ + @TableField(value = "ZN") + @Schema(description = "锌") + @ExcelProperty("锌") + private BigDecimal zn; + + /** + * 锑 + */ + @TableField(value = "SB") + @Schema(description = "锑") + @ExcelProperty("锑") + private BigDecimal sb; + + /** + * 湿度 + */ + @TableField(value = "HUMIDITY") + @Schema(description = "湿度") + @ExcelProperty("湿度") + private BigDecimal humidity; + + /** + * 室温 + */ + @TableField(value = "ROOMTMP") + @Schema(description = "室温") + @ExcelProperty("室温") + private BigDecimal roomtmp; + + /** + * 水质类别 + */ + @TableField(value = "CATEGORY") + @Schema(description = "水质类别") + @ExcelProperty("水质类别") + private BigDecimal category; + + /** + * 污染物 + */ + @TableField(value = "POLLUTER") + @Schema(description = "污染物") + @ExcelProperty("污染物") + private BigDecimal polluter; + + +} diff --git a/src/main/java/com/gunshi/project/xyt/service/WaterQualityService.java b/src/main/java/com/gunshi/project/xyt/service/WaterQualityService.java new file mode 100644 index 0000000..9934eb3 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/service/WaterQualityService.java @@ -0,0 +1,34 @@ +package com.gunshi.project.xyt.service; + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.gunshi.project.xyt.model.StWaterQualityR; +import com.gunshi.project.xyt.so.WaterQualityPageSo; +import jakarta.servlet.http.HttpServletResponse; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.util.List; + +/** + * Description: + * Created by xusan on 2024/1/23 + * + * @author xusan + * @version 1.0 + */ +public interface WaterQualityService { + + Page page(WaterQualityPageSo waterQualityPageSo); + + void export(WaterQualityPageSo waterQualityPageSo, HttpServletResponse response); + + String importExcel(MultipartFile file) throws IOException; + + String add(StWaterQualityR stWaterQualityR); + + String addList(List stWaterQualityRList); + + String update(StWaterQualityR StWaterQualityR); + + String delete(String id); +} diff --git a/src/main/java/com/gunshi/project/xyt/service/impl/WaterQualityServiceImpl.java b/src/main/java/com/gunshi/project/xyt/service/impl/WaterQualityServiceImpl.java new file mode 100644 index 0000000..466ab9d --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/service/impl/WaterQualityServiceImpl.java @@ -0,0 +1,173 @@ +package com.gunshi.project.xyt.service.impl; + +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.read.listener.PageReadListener; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.gunshi.core.dateformat.DateFormatString; +import com.gunshi.db.dao.BaseOrderDao; +import com.gunshi.project.xyt.mapper.WaterQualityMapper; +import com.gunshi.project.xyt.model.StWaterQualityR; +import com.gunshi.project.xyt.service.WaterQualityService; +import com.gunshi.project.xyt.so.WaterQualityPageSo; +import jakarta.servlet.http.HttpServletResponse; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; + +import java.io.IOException; +import java.net.URLEncoder; +import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.List; + +/** + * Description: + * Created by xusan on 2023/1/23. + * + * @author xusan + * @version 1.0 + */ +@EqualsAndHashCode(callSuper = true) +@Service +@Data +@Transactional(rollbackFor = Exception.class) +@Slf4j +public class WaterQualityServiceImpl extends BaseOrderDao implements WaterQualityService { + + /** + * 水质列表分页查询 + * + * @param so 水质列表分页查询 + */ + @Override + public Page page(WaterQualityPageSo so) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + + + if (so.getStm() != null) { + query.ge(StWaterQualityR::getSpt, so.getStm()); + } + if (so.getEtm() != null) { + query.le(StWaterQualityR::getSpt, so.getEtm()); + } + + return super.page(so.toPage(), query); + } + + /** + * 水质列表分页导出 + * + * @param so 水质列表分页 + */ + @Override + public void export(WaterQualityPageSo so , HttpServletResponse response) { + + // 获取基础数据 + Page page = page(so); + + // 生成文件名 + String fileName = "水质统计表 " + + DateFormatUtils.format(so.getStm(), DateFormatString.YYYY_MM_DD_HH_MM_SS) + + "至" + + DateFormatUtils.format(so.getEtm(), DateFormatString.YYYY_MM_DD_HH_MM_SS) + + ".xlsx"; + +// String tempPath = System.getProperty("java.io.tmpdir") + IdUtil.fastSimpleUUID() + ".xlsx"; +// String tempPath = System.getProperty("java.io.tmpdir") + fileName + ".xlsx"; +// File file = new File(tempPath); +// +// // 指定模板文件 +// ExcelWriter excelWriter = EasyExcel.write(file, StWaterQualityR.class).build(); +// +// WriteSheet writeSheet = EasyExcel.writerSheet(1, "水质").build(); +// // 分页去数据库查询数据 这里可以去数据库查询每一页的数据 +// List data = page.getRecords(); +// excelWriter.write(data, writeSheet); +// +// // 千万别忘记finish 会帮忙关闭流 +// excelWriter.finish(); + + + + response.setContentType("application/vnd.ms-excel"); + response.setCharacterEncoding("utf-8"); + + // 这里URLEncoder.encode可以防止中文乱码 + response.setHeader("content-disposition", "attachment;filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8)); + + // 数据输出 + try { + EasyExcel.write(response.getOutputStream(), StWaterQualityR.class).sheet("水质").doWrite(page.getRecords()); + } catch (IOException e) { + log.error("水质文件下载失败, " + e.getMessage(),e); + throw new RuntimeException(e); + } + + } + + @Override + public String importExcel(MultipartFile file) throws IOException { + + // 创建一个用于存储数据的List + List data = new ArrayList<>(); + + EasyExcel.read(file.getInputStream(), StWaterQualityR.class, new PageReadListener(data::addAll)).sheet().doRead(); + + for (StWaterQualityR o : data) { + o.setId(null); + } + + return this.addList(data); + } + + + /** + * 新增水质 + * + * @param o 水质 + */ + @Override + public String add(StWaterQualityR o) { + return this.save(o) ? "成功":"失败"; + } + + @Override + public String addList(List stWaterQualityRList) { + try { + for (StWaterQualityR o : stWaterQualityRList) { + this.add(o); + } + }catch (Exception e) { + return "失败"; + } + return "成功"; + +// return this.saveBatch(stWaterQualityRList) ? "成功":"失败"; + } + + /** + * 修改水质 + * + * @param o 水质 + */ + @Override + public String update(StWaterQualityR o) { + return this.updateById(o) ? "成功":"失败"; + } + + /** + * 删除水质 + * + * @param id id + */ + @Override + public String delete(String id) { + return this.removeById(id) ? "成功":"失败"; + } +} diff --git a/src/main/java/com/gunshi/project/xyt/so/WaterQualityPageSo.java b/src/main/java/com/gunshi/project/xyt/so/WaterQualityPageSo.java new file mode 100644 index 0000000..10d1a76 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/so/WaterQualityPageSo.java @@ -0,0 +1,36 @@ +package com.gunshi.project.xyt.so; + +import com.fasterxml.jackson.annotation.JsonFormat; +import com.gunshi.core.dateformat.DateFormatString; +import com.gunshi.db.dto.PageSo; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * Description: + * Created by XuSan on 2024/1/23. + * + * @author XuSan + * @version 1.0 + */ +@EqualsAndHashCode(callSuper = true) +@Data +public class WaterQualityPageSo extends PageSo { + + @Schema(description = "查询开始时间", pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, + example = DateFormatString.YYYY_MM_DD_HH_MM_SS_EXAMPLE) + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") + @DateTimeFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS) + private Date stm; + + @Schema(description = "查询结束时间", pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, + example = DateFormatString.YYYY_MM_DD_HH_MM_SS_EXAMPLE) + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") + @DateTimeFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS) + private Date etm; + +} diff --git a/src/main/resources/mapper/WaterQualityMapper.xml b/src/main/resources/mapper/WaterQualityMapper.xml new file mode 100644 index 0000000..446a997 --- /dev/null +++ b/src/main/resources/mapper/WaterQualityMapper.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/sql/HYD_RI_WQAMD_W.sql b/src/main/resources/sql/HYD_RI_WQAMD_W.sql index 947c58f..d6e7896 100644 --- a/src/main/resources/sql/HYD_RI_WQAMD_W.sql +++ b/src/main/resources/sql/HYD_RI_WQAMD_W.sql @@ -1,40 +1,76 @@ -CREATE TABLE [xyt].[HYD_RI_WQAMD_W] -( -[STCD] CHAR(14) NOT NULL, -[SPT] DATETIME2(6) NOT NULL, -[WIMP] DECIMAL(4,2), -[PH] DECIMAL(4,2), -[COND] DECIMAL(6,0), -[TURB] DECIMAL(3,0), -[DOX] DECIMAL(4,2), -[CODMN] DECIMAL(6,1), -[CODCR] DECIMAL(7,1), -[TN] DECIMAL(6,3), -[NH3N] DECIMAL(6,3), -[NO2] DECIMAL(5,3), -[NO3] DECIMAL(5,3), -[TP] DECIMAL(8,3), -[TOC] DECIMAL(4,1), -[VLPH] DECIMAL(10,6), -[CHLA] DECIMAL(6,4), -[F] DECIMAL(5,2), -[ARS] DECIMAL(8,6), -[HG] DECIMAL(9,7), -[CR6] DECIMAL(5,3), -[CU] DECIMAL(7,5), -[PB] DECIMAL(7,5), -[CD] DECIMAL(7,5), -[ZN] DECIMAL(6,4), -[SB] DECIMAL(7,5), -[HUMIDITY] DECIMAL(4,2), -[ROOMTMP] DECIMAL(4,2), -[ID] INT IDENTITY(1, 1) NOT NULL, -CONSTRAINT [PK_HYD_RI_WQAMD_W] PRIMARY KEY CLUSTERED ([ID]), -CONSTRAINT [UQ_HYD_RI_WQAMD_W_ID] UNIQUE ([ID]), -CONSTRAINT [UQ_HYD_RI_WQAMD_W_STCD_SPT] UNIQUE ([STCD], [SPT]) -) ON [MAIN] WITH (DATA_COMPRESSION = CLUSTERED COLUMNSTORE); +# CREATE TABLE [xyt].[HYD_RI_WQAMD_W] +# ( +# [STCD] CHAR(14) NOT NULL, +# [SPT] DATETIME2(6) NOT NULL, +# [WIMP] DECIMAL(4,2), +# [PH] DECIMAL(4,2), +# [COND] DECIMAL(6,0), +# [TURB] DECIMAL(3,0), +# [DOX] DECIMAL(4,2), +# [CODMN] DECIMAL(6,1), +# [CODCR] DECIMAL(7,1), +# [TN] DECIMAL(6,3), +# [NH3N] DECIMAL(6,3), +# [NO2] DECIMAL(5,3), +# [NO3] DECIMAL(5,3), +# [TP] DECIMAL(8,3), +# [TOC] DECIMAL(4,1), +# [VLPH] DECIMAL(10,6), +# [CHLA] DECIMAL(6,4), +# [F] DECIMAL(5,2), +# [ARS] DECIMAL(8,6), +# [HG] DECIMAL(9,7), +# [CR6] DECIMAL(5,3), +# [CU] DECIMAL(7,5), +# [PB] DECIMAL(7,5), +# [CD] DECIMAL(7,5), +# [ZN] DECIMAL(6,4), +# [SB] DECIMAL(7,5), +# [HUMIDITY] DECIMAL(4,2), +# [ROOMTMP] DECIMAL(4,2), +# [ID] INT IDENTITY(1, 1) NOT NULL, +# CONSTRAINT [PK_HYD_RI_WQAMD_W] PRIMARY KEY CLUSTERED ([ID]), +# CONSTRAINT [UQ_HYD_RI_WQAMD_W_ID] UNIQUE ([ID]), +# CONSTRAINT [UQ_HYD_RI_WQAMD_W_STCD_SPT] UNIQUE ([STCD], [SPT]) +# ) ON [MAIN] WITH (DATA_COMPRESSION = CLUSTERED COLUMNSTORE); -EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'水质自动监测数据' , @level0type=N'SCHEMA',@level0name=N'xyt', @level1type=N'TABLE',@level1name=N'HYD_RI_WQAMD_W'; +CREATE TABLE [HYD_RI_WQAMD_W] +( + [STCD] VARCHAR(14) NOT NULL, + [SPT] DATETIME2(6) NOT NULL, + [WIMP] DECIMAL(4,2), + [PH] DECIMAL(4,2), + [COND] DECIMAL(6,0), + [TURB] DECIMAL(3,0), + [DOX] DECIMAL(4,2), + [CODMN] DECIMAL(6,1), + [CODCR] DECIMAL(7,1), + [TN] DECIMAL(6,3), + [NH3N] DECIMAL(6,3), + [NO2] DECIMAL(5,3), + [NO3] DECIMAL(5,3), + [TP] DECIMAL(8,3), + [TOC] DECIMAL(4,1), + [VLPH] DECIMAL(10,6), + [CHLA] DECIMAL(6,4), + [F] DECIMAL(5,2), + [ARS] DECIMAL(8,6), + [HG] DECIMAL(9,7), + [CR6] DECIMAL(5,3), + [CU] DECIMAL(7,5), + [PB] DECIMAL(7,5), + [CD] DECIMAL(7,5), + [ZN] DECIMAL(6,4), + [SB] DECIMAL(7,5), + [HUMIDITY] DECIMAL(4,2), + [ROOMTMP] DECIMAL(4,2), + [ID] INT IDENTITY(1, 1) NOT NULL, + CONSTRAINT [PK_HYD_RI_WQAMD_W] PRIMARY KEY CLUSTERED ([ID]), + CONSTRAINT [UQ_HYD_RI_WQAMD_W_ID] UNIQUE ([ID]), + CONSTRAINT [UQ_HYD_RI_WQAMD_W_STCD_SPT] UNIQUE ([STCD], [SPT]) + ) + + EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'水质自动监测数据' , @level0type=N'SCHEMA',@level0name=N'xyt', @level1type=N'TABLE',@level1name=N'HYD_RI_WQAMD_W'; EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'砷' , @level0type=N'SCHEMA',@level0name=N'xyt', @level1type=N'TABLE',@level1name=N'HYD_RI_WQAMD_W', @level2type=N'COLUMN',@level2name=N'ARS'; @@ -93,3 +129,6 @@ EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'水温' , @lev EXEC sys.sp_addextendedproperty @name=N'MS_Description', @value=N'锌' , @level0type=N'SCHEMA',@level0name=N'xyt', @level1type=N'TABLE',@level1name=N'HYD_RI_WQAMD_W', @level2type=N'COLUMN',@level2name=N'ZN'; CREATE INDEX [IX_HYD_RI_WQAMD_W_STCD_SPT] ON [xyt].[HYD_RI_WQAMD_W] ([STCD] ASC, [SPT] ASC) ON [MAIN] WITH (DATA_COMPRESSION = CLUSTERED COLUMNSTORE); + + +SET IDENTITY_INSERT ST_WATER_QUALITY_R ON; \ No newline at end of file