首页供水(弹层)、水质整编接口

master
chenxiwang 2024-07-10 14:04:43 +08:00
parent e3ed61daa9
commit d31ad04ca4
23 changed files with 1271 additions and 45 deletions

View File

@ -0,0 +1,10 @@
package com.gunshi.core.xss.jackson;
/**
* @author cxw
* @description:
* @classname JacksonDeserializerXssStringDefender.java
* @create 2024-07-09, , 14:08:09
*/
public class JacksonDeserializerXssStringDefender {
}

View File

@ -1,5 +1,7 @@
package com.gunshi.project.xyt.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gunshi.core.result.R;
import com.gunshi.project.xyt.model.AttWaterItem;
import com.gunshi.project.xyt.service.AttWaterItemService;
@ -10,7 +12,12 @@ import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.Serializable;
import java.util.List;
@ -51,7 +58,10 @@ public class AttWaterItemController {
@Operation(summary = "列表")
@PostMapping("/list")
public R<List<AttWaterItem>> list() {
return R.ok(service.lambdaQuery().list());
LambdaQueryWrapper<AttWaterItem> wrapper = new QueryWrapper<AttWaterItem>().lambda()
.eq(true, AttWaterItem::getIsEnable, "0")
.orderBy(true, true, AttWaterItem::getSort);
return R.ok(service.list(wrapper));
}
@Operation(summary = "分页")
@ -60,4 +70,4 @@ public class AttWaterItemController {
return R.ok(service.page(null,null));
}
}
}

View File

@ -1,19 +1,43 @@
package com.gunshi.project.xyt.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.vo.OsmoticWaterRVo;
import com.gunshi.project.xyt.listener.OsmoticWaterRImportListener;
import com.gunshi.project.xyt.model.OsmoticWaterR;
import com.gunshi.project.xyt.service.OsmoticWaterRService;
import com.gunshi.project.xyt.util.ConvertUtil;
import com.gunshi.project.xyt.util.DateUtil;
import com.gunshi.project.xyt.util.ExcelUtil;
import com.gunshi.project.xyt.util.ResultJson;
import com.gunshi.project.xyt.util.excel.ExcelResult;
import com.gunshi.project.xyt.validate.markers.Insert;
import com.gunshi.project.xyt.validate.markers.Update;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
/**
* :
* author: xusan
@ -27,7 +51,6 @@ public class OsmoticWaterRController {
@Autowired
private OsmoticWaterRService service;
@Operation(summary = "新增")
@PostMapping("/insert")
public R<OsmoticWaterR> insert(@Validated(Insert.class) @RequestBody OsmoticWaterR dto) {
@ -50,14 +73,52 @@ public class OsmoticWaterRController {
@Operation(summary = "列表")
@PostMapping("/list")
public R<List<OsmoticWaterR>> list() {
return R.ok(service.lambdaQuery().list());
public R<List<OsmoticWaterR>> list(@RequestBody @Validated OsmoticWaterR osmoticWaterR) {
LambdaQueryWrapper<OsmoticWaterR> wrapper = new QueryWrapper<OsmoticWaterR>().lambda()
.ge(ObjectUtils.isNotNull(osmoticWaterR.getStartTime()), OsmoticWaterR::getTm, osmoticWaterR.getStartTime())
.le(ObjectUtils.isNotNull(osmoticWaterR.getEndTime()), OsmoticWaterR::getTm, osmoticWaterR.getEndTime())
.orderBy(StringUtils.isNotBlank(osmoticWaterR.getSortField()), osmoticWaterR.getIsAsc(), OsmoticWaterR::getTm);
return R.ok(service.list(wrapper));
}
@Operation(summary = "分页")
@PostMapping("/page")
public R<List<OsmoticWaterR>> page() {
return R.ok(service.page(null,null));
public R<Page<OsmoticWaterR>> page(@RequestBody @Validated OsmoticWaterR osmoticWaterR) {
QueryWrapper<OsmoticWaterR> qw = new QueryWrapper<>();
qw.ge(ObjectUtils.isNotNull(osmoticWaterR.getStartTime()), "tm", osmoticWaterR.getStartTime())
.le(ObjectUtils.isNotNull(osmoticWaterR.getEndTime()), "tm", osmoticWaterR.getEndTime())
.orderBy(StringUtils.isNotBlank(osmoticWaterR.getSortField()), osmoticWaterR.getIsAsc(), "tm");
return R.ok(service.page(osmoticWaterR.getPageSo().toPage(), qw));
}
}
/**
*
*/
@Operation(summary = "导入模板")
@PostMapping("/importTemplate")
public void importTemplate(HttpServletResponse response) {
ExcelUtil.exportExcel(new ArrayList<>(), "水质整编表", OsmoticWaterRVo.class, response, "水质整编表");
}
/**
*
*
* @param file
*
*/
@Operation(summary = "导入数据")
@PostMapping(value = "/importData", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
public ResultJson<String> importData(@RequestPart("file") MultipartFile file) throws Exception {
ExcelResult<OsmoticWaterRVo> result = ExcelUtil.importExcel(file.getInputStream(), OsmoticWaterRVo.class, new OsmoticWaterRImportListener());
return ResultJson.ok(result.getAnalysis());
}
@Operation(summary = "导出")
@PostMapping("/exportOsmoticWaterRDataExcel")
@CrossOrigin
public void exportOsmoticWaterRDataExcel(@RequestBody @Validated OsmoticWaterR osmoticWaterR, HttpServletResponse response) {
String filename = "水质整编表" + DateUtil.convertDateToString(osmoticWaterR.getStartTime()) + "_" + DateUtil.convertDateToString(osmoticWaterR.getEndTime());
List<OsmoticWaterRVo> vos = ConvertUtil.entityToVoList(this.list(osmoticWaterR).getData(), OsmoticWaterRVo.class);
ExcelUtil.exportExcel(vos, filename, OsmoticWaterRVo.class, response, "水质整编表");
}
}

View File

@ -1,19 +1,36 @@
package com.gunshi.project.xyt.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gunshi.core.result.R;
import com.gunshi.project.xyt.entity.vo.StWaterRVo;
import com.gunshi.project.xyt.model.StWaterR;
import com.gunshi.project.xyt.service.StWaterRService;
import com.gunshi.project.xyt.util.ConvertUtil;
import com.gunshi.project.xyt.util.DateUtil;
import com.gunshi.project.xyt.util.ExcelUtil;
import com.gunshi.project.xyt.validate.markers.Insert;
import com.gunshi.project.xyt.validate.markers.Update;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.io.Serializable;
import java.util.List;
/**
* :
* author: xusan
@ -50,14 +67,32 @@ public class StWaterRController {
@Operation(summary = "列表")
@PostMapping("/list")
public R<List<StWaterR>> list() {
return R.ok(service.lambdaQuery().list());
public R<List<StWaterR>> list(@RequestBody @Validated StWaterR stWaterR) {
LambdaQueryWrapper<StWaterR> wrapper = new QueryWrapper<StWaterR>().lambda()
.eq(StringUtils.isNotBlank(stWaterR.getStcd()), StWaterR::getStcd, stWaterR.getStcd())
.ge(ObjectUtils.isNotNull(stWaterR.getStartTime()), StWaterR::getTm, stWaterR.getStartTime())
.le(ObjectUtils.isNotNull(stWaterR.getEndTime()), StWaterR::getTm, stWaterR.getEndTime())
.orderBy(StringUtils.isNotBlank(stWaterR.getSortField()), stWaterR.getIsAsc(), StWaterR::getTm);
return R.ok(service.list(wrapper));
}
@Operation(summary = "分页")
@PostMapping("/page")
public R<List<StWaterR>> page() {
return R.ok(service.page(null,null));
public R<Page<StWaterR>> page(@RequestBody @Validated StWaterR stWaterR) {
QueryWrapper<StWaterR> qw = new QueryWrapper<>();
qw.eq(StringUtils.isNotBlank(stWaterR.getStcd()), "stcd", stWaterR.getStcd())
.ge(ObjectUtils.isNotNull(stWaterR.getStartTime()), "tm", stWaterR.getStartTime())
.le(ObjectUtils.isNotNull(stWaterR.getEndTime()), "tm", stWaterR.getEndTime())
.orderBy(StringUtils.isNotBlank(stWaterR.getSortField()), stWaterR.getIsAsc(), "tm");
return R.ok(service.page(stWaterR.getPageSo().toPage(), qw));
}
}
@Operation(summary = "导出")
@PostMapping("/exportWaterRDataExcel")
@CrossOrigin
public void exportWaterRDataExcel(@RequestBody @Validated StWaterR stWaterR, HttpServletResponse response) {
String filename = "供水流量表" + DateUtil.convertDateToString(stWaterR.getStartTime()) + "_" + DateUtil.convertDateToString(stWaterR.getEndTime());
List<StWaterRVo> vos = ConvertUtil.entityToVoList(this.list(stWaterR).getData(), StWaterRVo.class);
ExcelUtil.exportExcel(vos, filename, StWaterRVo.class, response, "供水流量表");
}
}

View File

@ -1,13 +1,16 @@
package com.gunshi.project.xyt.controller;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gunshi.core.result.R;
import com.gunshi.project.xyt.model.StWaterRReal;
import com.gunshi.project.xyt.service.StWaterRRealService;
import com.gunshi.project.xyt.validate.markers.Insert;
import com.gunshi.project.xyt.validate.markers.Query;
import com.gunshi.project.xyt.validate.markers.Update;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -27,6 +30,14 @@ public class StWaterRRealController {
@Autowired
private StWaterRRealService service;
@Operation(summary = "根据测站编码查询实时供水量")
@PostMapping("/getByStcd/{stcd}")
public R<StWaterRReal> getById(@Schema(name = "stcd", description = "测站编码")@PathVariable("stcd") @NotNull String stcd) {
QueryWrapper<StWaterRReal> qw = new QueryWrapper<>();
qw.eq("stcd", stcd).orderBy(true, false, "tm");
StWaterRReal result = service.getOne(qw);
return R.ok(result);
}
@Operation(summary = "新增")
@PostMapping("/insert")
@ -60,4 +71,4 @@ public class StWaterRRealController {
return R.ok(service.page(null,null));
}
}
}

View File

@ -0,0 +1,30 @@
package com.gunshi.project.xyt.entity.page;
import com.baomidou.mybatisplus.annotation.TableField;
import com.gunshi.db.dto.PageSo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
/**
* @author cxw
* @description:
* @classname GenericPageParams.java
* @create 2024-07-09, , 11:29:56
*/
@Schema(description = "通用分页查询对象")
@Data
public class GenericPageParams {
@Schema(description = "分页参数")
@TableField(exist = false)
private PageSo pageSo;
@Schema(description = "排序字段")
@TableField(exist = false)
private String sortField;
@Schema(description = "排序规则,是否升序")
@TableField(exist = false)
private Boolean isAsc;
}

View File

@ -0,0 +1,209 @@
package com.gunshi.project.xyt.entity.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import lombok.Data;
import java.util.Date;
/**
* @author cxw
* @description: ()
* @classname OsmoticWaterRVo.java
* @create 2024-07-10, , 10:46:43
*/
@Data
@ExcelIgnoreUnannotated
public class OsmoticWaterRVo {
private static final long serialVersionUID = 1L;
/**
*
*/
@ExcelProperty({"${title}", "时间"})
@ColumnWidth(15)
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date tm;
/**
*
*/
@ExcelProperty({"${title}", "水温"})
private String temp;
/**
* PH
*/
@ExcelProperty({"${title}", "PH"})
private String ph;
/**
*
*/
@ExcelProperty({"${title}", "溶解氧"})
private String bod;
/**
*
*/
@ExcelProperty({"${title}", "高锰酸钾指数"})
private String mn;
/**
*
*/
@ExcelProperty({"${title}", "化学需氧量"})
private String codcr;
/**
*
*/
@ExcelProperty({"${title}", "五日生化需氧量"})
private String bod5;
/**
*
*/
@ExcelProperty({"${title}", "氨氮"})
private String nh3n;
/**
*
*/
@ExcelProperty({"${title}", "总磷"})
private String tp;
/**
*
*/
@ExcelProperty({"${title}", "总氮"})
private String tn;
/**
*
*/
@ExcelProperty({"${title}", "铜"})
private String cu;
/**
*
*/
@ExcelProperty({"${title}", "锌"})
private String zn;
/**
*
*/
@ExcelProperty({"${title}", "氟化物"})
private String f;
/**
*
*/
@ExcelProperty({"${title}", "硒"})
private String se;
/**
*
*/
@ExcelProperty({"${title}", "砷"})
private String arsenic;
/**
*
*/
@ExcelProperty({"${title}", "汞"})
private String hg;
/**
*
*/
@ExcelProperty({"${title}", "镉"})
private String cd;
/**
*
*/
@ExcelProperty({"${title}", "铬"})
private String cr;
/**
*
*/
@ExcelProperty({"${title}", "铅"})
private String pb;
/**
*
*/
@ExcelProperty({"${title}", "氰化物"})
private String cn;
/**
*
*/
@ExcelProperty({"${title}", "挥发酚"})
private String vlph;
/**
*
*/
@ExcelProperty({"${title}", "石油类"})
private String oil;
/**
*
*/
@ExcelProperty({"${title}", "阴离子表面活性剂"})
private String las;
/**
*
*/
@ExcelProperty({"${title}", "硫化物"})
private String s;
/**
*
*/
@ExcelProperty({"${title}", "大肠菌群数"})
private String tcg;
/**
*
*/
@ExcelProperty({"${title}", "浊度"})
private String turb;
/**
*
*/
@ExcelProperty({"${title}", "电导率"})
private String cond;
/**
*
*/
@ExcelProperty({"${title}", "高锰酸盐"})
private String codmn;
/**
* 绿
*/
@ExcelProperty({"${title}", "叶绿素"})
private String chla;
/**
*
*/
@ExcelProperty({"${title}", "水质类别"})
private String level;
/**
*
*/
@ExcelProperty({"${title}", "污染物及超标倍数"})
private String paem;
}

View File

@ -0,0 +1,36 @@
package com.gunshi.project.xyt.entity.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import lombok.Data;
import java.util.Date;
/**
* @author cxw
* @description: ()
* @classname StWaterRVo.java
* @create 2024-07-10, , 10:26:04
*/
@Data
@ExcelIgnoreUnannotated
public class StWaterRVo {
@ExcelProperty({"${title}", "站码"})
@ColumnWidth(15)
private String stcd;
@ExcelProperty({"${title}", "时间"})
@ColumnWidth(15)
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date tm;
@ExcelProperty({"${title}", "流量(m³/s)"})
private String q;
@ExcelProperty({"${title}", "水量(m³)"})
private String v;
}

View File

@ -0,0 +1,85 @@
package com.gunshi.project.xyt.listener;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.gunshi.project.xyt.entity.vo.OsmoticWaterRVo;
import com.gunshi.project.xyt.model.OsmoticWaterR;
import com.gunshi.project.xyt.service.OsmoticWaterRService;
import com.gunshi.project.xyt.util.ConvertUtil;
import com.gunshi.project.xyt.util.ServiceException;
import com.gunshi.project.xyt.util.excel.ExcelListener;
import com.gunshi.project.xyt.util.excel.ExcelResult;
import com.gunshi.project.xyt.util.spring.SpringUtils;
import lombok.extern.slf4j.Slf4j;
import java.util.List;
/**
* @Author Hiram
* @Date 2023/03/14 10:23
*/
@Slf4j
public class OsmoticWaterRImportListener extends AnalysisEventListener<OsmoticWaterRVo> implements ExcelListener<OsmoticWaterRVo> {
private final OsmoticWaterRService osmoticWaterRService;
private int successNum = 0;
private int failureNum = 0;
private final StringBuilder successMsg = new StringBuilder();
private final StringBuilder failureMsg = new StringBuilder();
public OsmoticWaterRImportListener() {
this.osmoticWaterRService = SpringUtils.getBean(OsmoticWaterRService.class);
}
/**
* 使
* @param osmoticWaterRVo
* @param analysisContext
*/
@Override
public void invoke(OsmoticWaterRVo osmoticWaterRVo, AnalysisContext analysisContext) {
OsmoticWaterR osmoticWaterR = ConvertUtil.entityToVo(osmoticWaterRVo, OsmoticWaterR.class);
osmoticWaterR.setId(IdWorker.getId());
this.osmoticWaterRService.save(osmoticWaterR);
successNum++;
// successMsg.append("<br/>").append(successNum).append("监测仪数据导入成功");
}
@Override
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
}
/**
*
* @return
*/
@Override
public ExcelResult<OsmoticWaterRVo> getExcelResult() {
return new ExcelResult<OsmoticWaterRVo>() {
@Override
public String getAnalysis() {
if (failureNum > 0) {
failureMsg.insert(0, "很抱歉,导入失败!共 " + failureNum + " 条数据格式不正确");
throw new ServiceException(failureMsg.toString());
} else {
successMsg.insert(0, "恭喜您,数据已全部导入成功!共 " + successNum + " 条");
}
return successMsg.toString();
}
@Override
public List<OsmoticWaterRVo> getList() {
return null;
}
@Override
public List<String> getErrorList() {
return null;
}
};
}
}

View File

@ -5,15 +5,12 @@ 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 com.gunshi.core.dateformat.DateFormatString;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* :
@ -33,7 +30,7 @@ public class AttWaterItem implements Serializable {
*/
@TableId(value="id", type= IdType.AUTO)
@Schema(description="主键")
@NotBlank(message = "主键不能为空")
@NotNull(message = "主键不能为空")
private Long id;
/**
@ -60,4 +57,25 @@ public class AttWaterItem implements Serializable {
@Size(max = 10,message = "单位最大长度要小于 10")
private String unit;
}
/**
*
*/
@TableField(value="is_show")
@Schema(description="是否显示0 显示1 隐藏)")
private String isShow;
/**
*
*/
@TableField(value="is_enable")
@Schema(description="是否启用0 启动1 禁用)")
private String isEnable;
/**
*
*/
@TableField(value="sort")
@Schema(description="排序")
private String sort;
}

View File

@ -7,10 +7,12 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import com.gunshi.project.xyt.entity.page.GenericPageParams;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
@ -23,7 +25,8 @@ import java.util.Date;
@Schema(description="水质采样记录表")
@Data
@TableName("public.osmotic_water_r")
public class OsmoticWaterR implements Serializable {
@EqualsAndHashCode(callSuper = true)
public class OsmoticWaterR extends GenericPageParams implements Serializable {
private static final long serialVersionUID = 1L;
@ -34,7 +37,7 @@ public class OsmoticWaterR implements Serializable {
@TableId(value="id", type= IdType.AUTO)
@Schema(description="主键")
// @Size(max = 0,message = "主键最大长度要小于 0")
@NotBlank(message = "主键不能为空")
@NotNull(message = "主键不能为空")
private Long id;
/**
@ -153,10 +156,10 @@ public class OsmoticWaterR implements Serializable {
/**
*
*/
@TableField(value="as")
@TableField(value="arsenic")
@Schema(description="砷")
// @Size(max = 0,message = "砷最大长度要小于 0")
private String as;
private String arsenic;
/**
*
@ -191,7 +194,7 @@ public class OsmoticWaterR implements Serializable {
private String pb;
/**
*
*
*/
@TableField(value="cn")
@Schema(description="氰化物 ")
@ -199,7 +202,7 @@ public class OsmoticWaterR implements Serializable {
private String cn;
/**
*
*
*/
@TableField(value="vlph")
@Schema(description="挥发酚 ")
@ -215,7 +218,7 @@ public class OsmoticWaterR implements Serializable {
private String oil;
/**
*
*
*/
@TableField(value="las")
@Schema(description="阴离子表面活性剂 ")
@ -231,7 +234,7 @@ public class OsmoticWaterR implements Serializable {
private String s;
/**
*
*
*/
@TableField(value="tcg")
@Schema(description="大肠菌群数 ")
@ -255,12 +258,12 @@ public class OsmoticWaterR implements Serializable {
private String cond;
/**
* CODM
*
*/
@TableField(value="codm")
@Schema(description="CODM")
// @Size(max = 0,message = "CODM最大长度要小于 0")
private String codm;
@TableField(value="codmn")
@Schema(description="高锰酸盐")
// @Size(max = 0,message = "高锰酸盐最大长度要小于 0")
private String codmn;
/**
* 绿
@ -277,5 +280,222 @@ public class OsmoticWaterR implements Serializable {
@Schema(description="水质类别")
@Size(max = 10,message = "水质类别最大长度要小于 10")
private String level;
/**
*
*/
@Schema(description = "选择的起始时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
@TableField(exist = false)
private Date startTime;
}
/**
*
*/
@Schema(description = "选择的结束时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
@TableField(exist = false)
private Date endTime;
/**
* PH
*/
@TableField(value = "ph_level")
@Schema(description = "PH类别")
private String phLevel;
/**
*
*/
@TableField(value = "bod_level")
@Schema(description = "溶解氧类别")
private String bodLevel;
/**
*
*/
@TableField(value = "mn_level")
@Schema(description = "高锰酸钾类别")
private String mnLevel;
/**
*
*/
@TableField(value = "temp_level")
@Schema(description = "水温类别")
private String tempLevel;
/**
*
*/
@TableField(value = "codcr_level")
@Schema(description = "化学需氧量类别")
private String codcrLevel;
/**
*
*/
@TableField(value = "bod5_level")
@Schema(description = "五日生化需氧量类别")
private String bod5Level;
/**
*
*/
@TableField(value = "nh3n_level")
@Schema(description = "氨氮类别")
private String nh3nLevel;
/**
*
*/
@TableField(value = "tp_level")
@Schema(description = "总磷类别")
private String tpLevel;
/**
*
*/
@TableField(value = "tn_level")
@Schema(description = "总氮类别")
private String tnLevel;
/**
*
*/
@TableField(value = "cu_level")
@Schema(description = "铜类别")
private String cuLevel;
/**
*
*/
@TableField(value = "zn_level")
@Schema(description = "锌类别")
private String znLevel;
/**
*
*/
@TableField(value = "f_level")
@Schema(description = "氟化物类别")
private String fLevel;
/**
*
*/
@TableField(value = "se_level")
@Schema(description = "硒类别")
private String seLevel;
/**
*
*/
@TableField(value = "arsenic_level")
@Schema(description = "砷类别")
private String arsenicLevel;
/**
*
*/
@TableField(value = "hg_level")
@Schema(description = "汞类别")
private String hgLevel;
/**
*
*/
@TableField(value = "cd_level")
@Schema(description = "镉类别")
private String cdLevel;
/**
*
*/
@TableField(value = "cr_level")
@Schema(description = "铬类别")
private String crLevel;
/**
*
*/
@TableField(value = "pb_level")
@Schema(description = "铅类别")
private String pbLevel;
/**
*
*/
@TableField(value = "cn_level")
@Schema(description = "氰化物类别")
private String cnLevel;
/**
*
*/
@TableField(value = "vlph_level")
@Schema(description = "挥发酚类别")
private String vlphLevel;
/**
*
*/
@TableField(value = "oil_level")
@Schema(description = "石油类类别")
private String oilLevel;
/**
*
*/
@TableField(value = "las_level")
@Schema(description = "阴离子表面活性剂类别")
private String lasLevel;
/**
*
*/
@TableField(value = "s_level")
@Schema(description = "硫化物类别")
private String sLevel;
/**
*
*/
@TableField(value = "tcg_level")
@Schema(description = "大肠菌群数类别")
private String tcgLevel;
/**
*
*/
@TableField(value = "turb_level")
@Schema(description = "浊度类别")
private String turbLevel;
/**
*
*/
@TableField(value = "cond_level")
@Schema(description = "电导率类别")
private String condLevel;
/**
*
*/
@TableField(value = "codmn_level")
@Schema(description = "高锰酸盐类别")
private String codmnLevel;
/**
* 绿
*/
@TableField(value = "chla_level")
@Schema(description = "叶绿素类别")
private String chlaLevel;
/**
*
*/
@TableField(value = "paem")
@Schema(description = "污染物及超标倍数")
private String paem;
}

View File

@ -7,10 +7,12 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.gunshi.core.dateformat.DateFormatString;
import com.gunshi.project.xyt.entity.page.GenericPageParams;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
import java.util.Date;
@ -23,7 +25,8 @@ import java.util.Date;
@Schema(description="供水量表")
@Data
@TableName("public.st_water_r")
public class StWaterR implements Serializable {
@EqualsAndHashCode(callSuper = true)
public class StWaterR extends GenericPageParams implements Serializable {
private static final long serialVersionUID = 1L;
@ -43,7 +46,7 @@ public class StWaterR implements Serializable {
@TableField(value="tm")
@Schema(description="时间")
// @Size(max = 0,message = "时间最大长度要小于 0")
@NotBlank(message = "时间不能为空")
// @NotBlank(message = "时间不能为空")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
private Date tm;
@ -63,4 +66,20 @@ public class StWaterR implements Serializable {
// @Size(max = 0,message = "水量最大长度要小于 0")
private String v;
}
/**
*
*/
@Schema(description = "选择的起始时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
@TableField(exist = false)
private Date startTime;
/**
*
*/
@Schema(description = "选择的结束时间")
@JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8")
@TableField(exist = false)
private Date endTime;
}

View File

@ -0,0 +1,50 @@
package com.gunshi.project.xyt.util;
/**
* @author cxw
* @description: ()
* @classname ConvertUtil.java
* @create 2024-07-10, , 10:34:14
*/
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class ConvertUtil {
public static final Logger logger = LoggerFactory.getLogger(ConvertUtil.class);
public static <T> T entityToVo(Object source, Class<T> target) {
if (source == null) {
return null;
}
T targetObject = null;
try {
targetObject = target.newInstance();
BeanUtils.copyProperties(source, targetObject);
} catch (Exception e) {
e.printStackTrace();
}
return targetObject;
}
public static <T> List<T> entityToVoList(Collection<?> sourceList, Class<T> target) {
if (sourceList == null) {
return null;
}
List<T> targetList = new ArrayList<>(sourceList.size());
try {
for (Object source : sourceList) {
T targetObject = target.newInstance();
BeanUtils.copyProperties(source, targetObject);
targetList.add(targetObject);
}
} catch (Exception e) {
logger.error("convert error ", e);
}
return targetList;
}
}

View File

@ -36,6 +36,12 @@ public class DateUtil {
}
}
public static final ThreadLocal<SimpleDateFormat> sdfhmsS = new ThreadLocal<SimpleDateFormat>() {
protected SimpleDateFormat initialValue() {
return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS");
}
};
public static String convertDateToString(Date date){
return sdf.format(date);
}

View File

@ -7,9 +7,12 @@ import com.alibaba.excel.ExcelWriter;
import com.alibaba.excel.support.ExcelTypeEnum;
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
import com.alibaba.excel.write.metadata.WriteSheet;
import com.gunshi.project.xyt.util.excel.ExcelListener;
import com.gunshi.project.xyt.util.excel.ExcelResult;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
@ -105,5 +108,17 @@ public class ExcelUtil {
return null;
}
/**
* 使
*
* @param is
* @param clazz
* @param listener
* @return
*/
public static <T> ExcelResult<T> importExcel(InputStream is, Class<T> clazz, ExcelListener<T> listener) {
EasyExcel.read(is, clazz, listener).sheet().doRead();
return listener.getExcelResult();
}
}

View File

@ -0,0 +1,170 @@
package com.gunshi.project.xyt.util;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.stereotype.Component;
import java.io.Serializable;
import java.util.Date;
@Schema(description = "数据传输对象")
@Component
@SuppressWarnings("all")
public class ResultJson<T> implements Serializable {
private static final long serialVersionUID = 1L;
/**
*
*/
public static final Integer SUCCESS = 200;
public static final String SUCCESS_MSG = "success";
/**
*
*/
public static final Integer FAIL = 900;
public static final String FAIL_MSG = "fail";
public static final Integer PARAM_ERROR = 400; // 失败、参数错误等
public static final Integer UNAUTHORIZED = 401; // 用户验证失败,或者用户验证信息过期
public static final Integer PERMISSION_DENIED = 403; // 没有权限
public static final Integer NOT_FOUND = 404; // 未找到资源
public static final Integer METHOD_NOT_ALLOWED = 405; // 不支持的类型
public static final Integer NSUPPORTED_MEDIA_TYPE = 415; // 不支持的媒体
public static final Integer NOT_ALLOWED = 405; // 请求太频繁同一个用户token)、同一个url、同样的请求参数请求间隔小于0.5秒
public static final Integer SERVER_ERROR = 500; // 后台错误
public static final Integer SRC_TIMEOUT = 504; // 请求资源超时
@Schema(description="数据消息")
private String msg;
@Schema(description="传输状态码200=成功400=参数错误; 500=后端错误900=失败)")
private Integer code;
@Schema(description="传输数据")
private T data;
@Schema(description="接口响应时间戳")
private String restm; // 接口响应时间戳。如果有缓存,则该时间表示最后接口响应时间
public static ResultJson error() {
return error(FAIL, "未知异常,请联系管理员");
}
public static ResultJson error(String msg) {
return error(FAIL, msg);
}
public static ResultJson error(int code, String msg) {
ResultJson r = new ResultJson();
r.setCode(code);
r.setMsg(msg);
r.setRestm(DateUtil.sdfhmsS.get().format(new Date()));
return r;
}
public static ResultJson error(int code, String msg, Object data) {
ResultJson r = new ResultJson();
r.setCode(code);
r.setMsg(msg);
r.setData(data);
r.setRestm(DateUtil.sdfhmsS.get().format(new Date()));
return r;
}
public static ResultJson ok(Integer code, String msg) {
ResultJson r = new ResultJson();
r.setMsg(msg);
r.setCode(code);
r.setRestm(DateUtil.sdfhmsS.get().format(new Date()));
return r;
}
public static ResultJson ok() {
ResultJson r = new ResultJson();
r.setCode(SUCCESS);
r.setMsg(SUCCESS_MSG);
r.setRestm(DateUtil.sdfhmsS.get().format(new Date()));
return r;
}
public static ResultJson ok(Object data) {
ResultJson r = new ResultJson();
r.setCode(SUCCESS);
r.setMsg(SUCCESS_MSG);
r.setData(data);
r.setRestm(DateUtil.sdfhmsS.get().format(new Date()));
return r;
}
public static ResultJson ok(Object data, String msg) {
ResultJson r = new ResultJson();
r.setData(data);
r.setCode(SUCCESS);
r.setMsg(msg);
r.setRestm(DateUtil.sdfhmsS.get().format(new Date()));
return r;
}
public String getMsg() {
return msg;
}
public void setMsg(String msg) {
this.msg = msg;
}
public Integer getCode() {
return code;
}
public void setCode(Integer code) {
this.code = code;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
public static long getSerialVersionUID() {
return serialVersionUID;
}
public static Integer getSUCCESS() {
return SUCCESS;
}
public static String getSuccessMsg() {
return SUCCESS_MSG;
}
public static Integer getFAIL() {
return FAIL;
}
public static String getFailMsg() {
return FAIL_MSG;
}
public String getRestm() {
return restm;
}
public void setRestm(String restm) {
this.restm = restm;
}
@Override
public String toString() {
return "ResultJson{" +
"msg='" + msg + "'" +
", code=" + code +
", data=" + data +
", restm=" + restm +
'}';
}
}

View File

@ -0,0 +1,64 @@
package com.gunshi.project.xyt.util;
/**
*
*
* @author ruoyi
*/
public final class ServiceException extends RuntimeException {
private static final long serialVersionUID = 1L;
/**
*
*/
private Integer code;
/**
*
*/
private String message;
/**
*
* <p>
*/
private String detailMessage;
/**
*
*/
public ServiceException() {
}
public ServiceException(String message) {
this.message = message;
}
public ServiceException(String message, Integer code) {
this.message = message;
this.code = code;
}
public String getDetailMessage() {
return detailMessage;
}
@Override
public String getMessage() {
return message;
}
public Integer getCode() {
return code;
}
public ServiceException setMessage(String message) {
this.message = message;
return this;
}
public ServiceException setDetailMessage(String detailMessage) {
this.detailMessage = detailMessage;
return this;
}
}

View File

@ -0,0 +1,72 @@
package com.gunshi.project.xyt.util.excel;
import cn.hutool.core.util.StrUtil;
import lombok.Setter;
import java.util.ArrayList;
import java.util.List;
/**
* excel
*
*
*/
public class DefautExcelResult<T> implements ExcelResult<T> {
/**
* list
*/
@Setter
private List<T> list;
/**
*
*/
@Setter
private List<String> errorList;
public DefautExcelResult() {
this.list = new ArrayList<>();
this.errorList = new ArrayList<>();
}
public DefautExcelResult(List<T> list, List<String> errorList) {
this.list = list;
this.errorList = errorList;
}
public DefautExcelResult(ExcelResult<T> excelResult) {
this.list = excelResult.getList();
this.errorList = excelResult.getErrorList();
}
@Override
public List<T> getList() {
return list;
}
@Override
public List<String> getErrorList() {
return errorList;
}
/**
*
*
* @return
*/
@Override
public String getAnalysis() {
int successCount = list.size();
int errorCount = errorList.size();
if (successCount == 0) {
return "读取失败,未解析到数据";
} else {
if (errorCount == 0) {
return StrUtil.format("恭喜您,全部读取成功!共{}条", successCount);
} else {
return "";
}
}
}
}

View File

@ -0,0 +1,14 @@
package com.gunshi.project.xyt.util.excel;
import com.alibaba.excel.read.listener.ReadListener;
/**
* Excel
*
* @author Lion Li
*/
public interface ExcelListener<T> extends ReadListener<T> {
ExcelResult<T> getExcelResult();
}

View File

@ -0,0 +1,26 @@
package com.gunshi.project.xyt.util.excel;
import java.util.List;
/**
* excel
*
* @author Lion Li
*/
public interface ExcelResult<T> {
/**
*
*/
List<T> getList();
/**
*
*/
List<String> getErrorList();
/**
*
*/
String getAnalysis();
}

View File

@ -0,0 +1,65 @@
package com.gunshi.project.xyt.util.spring;
import cn.hutool.extra.spring.SpringUtil;
import org.springframework.aop.framework.AopContext;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.stereotype.Component;
/**
* spring
*
*
*/
@Component
public final class SpringUtils extends SpringUtil {
/**
* BeanFactorybeantrue
*
* @param name
* @return boolean
*/
public static boolean containsBean(String name) {
return getBeanFactory().containsBean(name);
}
/**
* beansingletonprototype
* beanNoSuchBeanDefinitionException
*
* @param name
* @return boolean
*/
public static boolean isSingleton(String name) throws NoSuchBeanDefinitionException {
return getBeanFactory().isSingleton(name);
}
/**
* @param name
* @return Class
*/
public static Class<?> getType(String name) throws NoSuchBeanDefinitionException {
return getBeanFactory().getType(name);
}
/**
* beanbean
*
* @param name
*/
public static String[] getAliases(String name) throws NoSuchBeanDefinitionException {
return getBeanFactory().getAliases(name);
}
/**
* aop
*
* @param invoker
* @return
*/
@SuppressWarnings("unchecked")
public static <T> T getAopProxy(T invoker) {
return (T) AopContext.currentProxy();
}
}

View File

@ -5,7 +5,7 @@ spring:
dynamic:
datasource:
master:
url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan
url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan?stringtype=unspecified
username: gunshiiot
password: 1234567a
driver-class-name: org.postgresql.Driver
@ -22,4 +22,4 @@ spring:
database: 4
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl

View File

@ -5,7 +5,7 @@ spring:
dynamic:
datasource:
master:
url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan
url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan?stringtype=unspecified
username: gunshiiot
password: 1234567a
driver-class-name: org.postgresql.Driver
@ -22,4 +22,4 @@ spring:
database: 4
mybatis-plus:
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl