diff --git a/src/main/java/com/gunshi/core/xss/jackson/JacksonDeserializerXssStringDefender.java b/src/main/java/com/gunshi/core/xss/jackson/JacksonDeserializerXssStringDefender.java new file mode 100644 index 0000000..7389a0a --- /dev/null +++ b/src/main/java/com/gunshi/core/xss/jackson/JacksonDeserializerXssStringDefender.java @@ -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 { +} diff --git a/src/main/java/com/gunshi/project/xyt/controller/AttWaterItemController.java b/src/main/java/com/gunshi/project/xyt/controller/AttWaterItemController.java index fdbb9b0..85cd0b8 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/AttWaterItemController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/AttWaterItemController.java @@ -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() { - return R.ok(service.lambdaQuery().list()); + LambdaQueryWrapper wrapper = new QueryWrapper().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)); } -} \ No newline at end of file +} diff --git a/src/main/java/com/gunshi/project/xyt/controller/OsmoticWaterRController.java b/src/main/java/com/gunshi/project/xyt/controller/OsmoticWaterRController.java index 0fe42dd..1c7af7d 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/OsmoticWaterRController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/OsmoticWaterRController.java @@ -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 insert(@Validated(Insert.class) @RequestBody OsmoticWaterR dto) { @@ -50,14 +73,52 @@ public class OsmoticWaterRController { @Operation(summary = "列表") @PostMapping("/list") - public R> list() { - return R.ok(service.lambdaQuery().list()); + public R> list(@RequestBody @Validated OsmoticWaterR osmoticWaterR) { + LambdaQueryWrapper wrapper = new QueryWrapper().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> page() { - return R.ok(service.page(null,null)); + public R> page(@RequestBody @Validated OsmoticWaterR osmoticWaterR) { + QueryWrapper 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)); } -} \ No newline at end of file + /** + * 获取导入模板 + */ + @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 importData(@RequestPart("file") MultipartFile file) throws Exception { + ExcelResult 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 vos = ConvertUtil.entityToVoList(this.list(osmoticWaterR).getData(), OsmoticWaterRVo.class); + ExcelUtil.exportExcel(vos, filename, OsmoticWaterRVo.class, response, "水质整编表"); + } +} diff --git a/src/main/java/com/gunshi/project/xyt/controller/StWaterRController.java b/src/main/java/com/gunshi/project/xyt/controller/StWaterRController.java index fc474ba..3568ba5 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/StWaterRController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/StWaterRController.java @@ -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() { - return R.ok(service.lambdaQuery().list()); + public R> list(@RequestBody @Validated StWaterR stWaterR) { + LambdaQueryWrapper wrapper = new QueryWrapper().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> page() { - return R.ok(service.page(null,null)); + public R> page(@RequestBody @Validated StWaterR stWaterR) { + QueryWrapper 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)); } -} \ No newline at end of file + @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 vos = ConvertUtil.entityToVoList(this.list(stWaterR).getData(), StWaterRVo.class); + ExcelUtil.exportExcel(vos, filename, StWaterRVo.class, response, "供水流量表"); + } +} diff --git a/src/main/java/com/gunshi/project/xyt/controller/StWaterRRealController.java b/src/main/java/com/gunshi/project/xyt/controller/StWaterRRealController.java index ccfad6d..bc5719b 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/StWaterRRealController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/StWaterRRealController.java @@ -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 getById(@Schema(name = "stcd", description = "测站编码")@PathVariable("stcd") @NotNull String stcd) { + QueryWrapper 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)); } -} \ No newline at end of file +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/page/GenericPageParams.java b/src/main/java/com/gunshi/project/xyt/entity/page/GenericPageParams.java new file mode 100644 index 0000000..55fa551 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/page/GenericPageParams.java @@ -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; + +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticWaterRVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticWaterRVo.java new file mode 100644 index 0000000..88f1317 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/OsmoticWaterRVo.java @@ -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; +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/StWaterRVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/StWaterRVo.java new file mode 100644 index 0000000..e306f80 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/StWaterRVo.java @@ -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; +} diff --git a/src/main/java/com/gunshi/project/xyt/listener/OsmoticWaterRImportListener.java b/src/main/java/com/gunshi/project/xyt/listener/OsmoticWaterRImportListener.java new file mode 100644 index 0000000..0d4f4bb --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/listener/OsmoticWaterRImportListener.java @@ -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 implements ExcelListener { + + 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("
").append(successNum).append("监测仪数据导入成功"); + } + + @Override + public void doAfterAllAnalysed(AnalysisContext analysisContext) { + + } + + /** + * 导入结果 + * @return + */ + @Override + public ExcelResult getExcelResult() { + return new ExcelResult() { + + @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 getList() { + return null; + } + + @Override + public List getErrorList() { + return null; + } + }; + } +} diff --git a/src/main/java/com/gunshi/project/xyt/model/AttWaterItem.java b/src/main/java/com/gunshi/project/xyt/model/AttWaterItem.java index 52edc9e..db813f0 100644 --- a/src/main/java/com/gunshi/project/xyt/model/AttWaterItem.java +++ b/src/main/java/com/gunshi/project/xyt/model/AttWaterItem.java @@ -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; -} \ No newline at end of file + /** + * 是否显示 + */ + @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; + +} diff --git a/src/main/java/com/gunshi/project/xyt/model/OsmoticWaterR.java b/src/main/java/com/gunshi/project/xyt/model/OsmoticWaterR.java index 18cb72f..8420ed0 100644 --- a/src/main/java/com/gunshi/project/xyt/model/OsmoticWaterR.java +++ b/src/main/java/com/gunshi/project/xyt/model/OsmoticWaterR.java @@ -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; -} \ No newline at end of file + /** + * 选择的结束时间 + */ + @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; +} diff --git a/src/main/java/com/gunshi/project/xyt/model/StWaterR.java b/src/main/java/com/gunshi/project/xyt/model/StWaterR.java index d6b2c0e..ec4b316 100644 --- a/src/main/java/com/gunshi/project/xyt/model/StWaterR.java +++ b/src/main/java/com/gunshi/project/xyt/model/StWaterR.java @@ -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; -} \ No newline at end of file + + /** + * 选择的起始时间 + */ + @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; +} diff --git a/src/main/java/com/gunshi/project/xyt/util/ConvertUtil.java b/src/main/java/com/gunshi/project/xyt/util/ConvertUtil.java new file mode 100644 index 0000000..56168f0 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/util/ConvertUtil.java @@ -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 entityToVo(Object source, Class 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 List entityToVoList(Collection sourceList, Class target) { + if (sourceList == null) { + return null; + } + List 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; + } +} diff --git a/src/main/java/com/gunshi/project/xyt/util/DateUtil.java b/src/main/java/com/gunshi/project/xyt/util/DateUtil.java index df86990..20d8f9c 100644 --- a/src/main/java/com/gunshi/project/xyt/util/DateUtil.java +++ b/src/main/java/com/gunshi/project/xyt/util/DateUtil.java @@ -36,6 +36,12 @@ public class DateUtil { } } + public static final ThreadLocal sdfhmsS = new ThreadLocal() { + protected SimpleDateFormat initialValue() { + return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSS"); + } + }; + public static String convertDateToString(Date date){ return sdf.format(date); } diff --git a/src/main/java/com/gunshi/project/xyt/util/ExcelUtil.java b/src/main/java/com/gunshi/project/xyt/util/ExcelUtil.java index 41d30a1..46e54ec 100644 --- a/src/main/java/com/gunshi/project/xyt/util/ExcelUtil.java +++ b/src/main/java/com/gunshi/project/xyt/util/ExcelUtil.java @@ -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 ExcelResult importExcel(InputStream is, Class clazz, ExcelListener listener) { + EasyExcel.read(is, clazz, listener).sheet().doRead(); + return listener.getExcelResult(); + } } diff --git a/src/main/java/com/gunshi/project/xyt/util/ResultJson.java b/src/main/java/com/gunshi/project/xyt/util/ResultJson.java new file mode 100644 index 0000000..0b0a7d1 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/util/ResultJson.java @@ -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 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 + + '}'; + } +} diff --git a/src/main/java/com/gunshi/project/xyt/util/ServiceException.java b/src/main/java/com/gunshi/project/xyt/util/ServiceException.java new file mode 100644 index 0000000..a5cb26b --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/util/ServiceException.java @@ -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; + + /** + * 错误明细,内部调试错误 + *

+ */ + 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; + } +} diff --git a/src/main/java/com/gunshi/project/xyt/util/excel/DefautExcelResult.java b/src/main/java/com/gunshi/project/xyt/util/excel/DefautExcelResult.java new file mode 100644 index 0000000..a3a579f --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/util/excel/DefautExcelResult.java @@ -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 implements ExcelResult { + + /** + * 数据对象list + */ + @Setter + private List list; + + /** + * 错误信息列表 + */ + @Setter + private List errorList; + + public DefautExcelResult() { + this.list = new ArrayList<>(); + this.errorList = new ArrayList<>(); + } + + public DefautExcelResult(List list, List errorList) { + this.list = list; + this.errorList = errorList; + } + + public DefautExcelResult(ExcelResult excelResult) { + this.list = excelResult.getList(); + this.errorList = excelResult.getErrorList(); + } + + @Override + public List getList() { + return list; + } + + @Override + public List 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 ""; + } + } + } +} diff --git a/src/main/java/com/gunshi/project/xyt/util/excel/ExcelListener.java b/src/main/java/com/gunshi/project/xyt/util/excel/ExcelListener.java new file mode 100644 index 0000000..a342de4 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/util/excel/ExcelListener.java @@ -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 extends ReadListener { + + ExcelResult getExcelResult(); + +} diff --git a/src/main/java/com/gunshi/project/xyt/util/excel/ExcelResult.java b/src/main/java/com/gunshi/project/xyt/util/excel/ExcelResult.java new file mode 100644 index 0000000..08f8cd5 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/util/excel/ExcelResult.java @@ -0,0 +1,26 @@ +package com.gunshi.project.xyt.util.excel; + +import java.util.List; + +/** + * excel返回对象 + * + * @author Lion Li + */ +public interface ExcelResult { + + /** + * 对象列表 + */ + List getList(); + + /** + * 错误列表 + */ + List getErrorList(); + + /** + * 导入回执 + */ + String getAnalysis(); +} diff --git a/src/main/java/com/gunshi/project/xyt/util/spring/SpringUtils.java b/src/main/java/com/gunshi/project/xyt/util/spring/SpringUtils.java new file mode 100644 index 0000000..bfcef09 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/util/spring/SpringUtils.java @@ -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 { + + /** + * 如果BeanFactory包含一个与所给名称匹配的bean定义,则返回true + * + * @param name + * @return boolean + */ + public static boolean containsBean(String name) { + return getBeanFactory().containsBean(name); + } + + /** + * 判断以给定名字注册的bean定义是一个singleton还是一个prototype。 + * 如果与给定名字相应的bean定义没有被找到,将会抛出一个异常(NoSuchBeanDefinitionException) + * + * @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); + } + + /** + * 如果给定的bean名字在bean定义中有别名,则返回这些别名 + * + * @param name + */ + public static String[] getAliases(String name) throws NoSuchBeanDefinitionException { + return getBeanFactory().getAliases(name); + } + + /** + * 获取aop代理对象 + * + * @param invoker + * @return + */ + @SuppressWarnings("unchecked") + public static T getAopProxy(T invoker) { + return (T) AopContext.currentProxy(); + } + +} diff --git a/src/main/resources/config-dev.yml b/src/main/resources/config-dev.yml index ef61ab7..571beab 100644 --- a/src/main/resources/config-dev.yml +++ b/src/main/resources/config-dev.yml @@ -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 \ No newline at end of file + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl diff --git a/src/main/resources/config-prod.yml b/src/main/resources/config-prod.yml index e50721b..c58861d 100644 --- a/src/main/resources/config-prod.yml +++ b/src/main/resources/config-prod.yml @@ -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 \ No newline at end of file + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl