diff --git a/module-common/src/main/java/com/gunshi/project/ss/common/mapper/JcskSyBMapper.java b/module-common/src/main/java/com/gunshi/project/ss/common/mapper/JcskSyBMapper.java index 79a67eb..562ab2a 100644 --- a/module-common/src/main/java/com/gunshi/project/ss/common/mapper/JcskSyBMapper.java +++ b/module-common/src/main/java/com/gunshi/project/ss/common/mapper/JcskSyBMapper.java @@ -66,7 +66,7 @@ public interface JcskSyBMapper extends BaseMapper { List selectAllDvcd(); @Select(""" - select t1.dvcd as stcd,t1.dvcd as stnm, t3.mstm as latestTm,t1.lttd,t1.lgtd + select t1.dvcd as stcd,t1.dvcd as stnm, t3.mstm as tm,t1.lttd,t1.lgtd from jcsk_sy_b t1 left join( select stcd,mpcd,max(mstm) as max_tm from jcsk_sy_r group by stcd,mpcd diff --git a/module-common/src/main/java/com/gunshi/project/ss/common/mapper/StStbprpBMapper.java b/module-common/src/main/java/com/gunshi/project/ss/common/mapper/StStbprpBMapper.java index 2bdd6f9..b7f3a5d 100644 --- a/module-common/src/main/java/com/gunshi/project/ss/common/mapper/StStbprpBMapper.java +++ b/module-common/src/main/java/com/gunshi/project/ss/common/mapper/StStbprpBMapper.java @@ -79,7 +79,7 @@ public interface StStbprpBMapper extends BaseMapper { t1.lttd, t1.stcd, t1.stnm, - t4.tm as latestTm + t4.tm from st_stbprp_b t1 join st_stbprp_b_elem t2 on t1.stcd = t2.stcd left join ( @@ -98,7 +98,7 @@ public interface StStbprpBMapper extends BaseMapper { t1.lttd, t1.stcd, t1.stnm, - t4.tm as latestTm + t4.tm from st_stbprp_b t1 join st_stbprp_b_elem t2 on t1.stcd = t2.stcd left join ( diff --git a/module-common/src/main/java/com/gunshi/project/ss/common/model/StStbprpB.java b/module-common/src/main/java/com/gunshi/project/ss/common/model/StStbprpB.java index 235a4de..61c7288 100644 --- a/module-common/src/main/java/com/gunshi/project/ss/common/model/StStbprpB.java +++ b/module-common/src/main/java/com/gunshi/project/ss/common/model/StStbprpB.java @@ -16,7 +16,9 @@ import jakarta.validation.constraints.Size; import lombok.Data; import java.io.Serializable; +import java.math.BigDecimal; import java.util.Date; +import java.util.List; /** * 描述: sttp 以水利标准来 @@ -32,10 +34,13 @@ public class StStbprpB implements Serializable { private static final long serialVersionUID = 1L; + @TableId(value = "id",type = IdType.AUTO) + private Long id; + /** * 测站编码 */ - @TableId(value="stcd", type= IdType.AUTO) + @TableField(value="stcd") @Schema(description="测站编码") @Size(max = 32,message = "测站编码最大长度要小于 32") @NotBlank(message = "测站编码不能为空",groups = {Insert.class, Update.class}) @@ -49,37 +54,13 @@ public class StStbprpB implements Serializable { @Size(max = 150,message = "测站名称最大长度要小于 150") private String stnm; - /** - * 河流名称 - */ - @TableField(value="rvnm") - @Schema(description="河流名称") - @Size(max = 300,message = "河流名称最大长度要小于 300") - private String rvnm; - - /** - * 水系名称 - */ - @TableField(value="hnnm") - @Schema(description="水系名称") - @Size(max = 300,message = "水系名称最大长度要小于 300") - private String hnnm; - - /** - * 流域名称 - */ - @TableField(value="bsnm") - @Schema(description="流域名称") - @Size(max = 300,message = "流域名称最大长度要小于 300") - private String bsnm; - /** * 经度 */ @TableField(value="lgtd") @Schema(description="经度") // @Size(max = 0,message = "经度最大长度要小于 0") - private String lgtd; + private BigDecimal lgtd; /** * 纬度 @@ -87,7 +68,7 @@ public class StStbprpB implements Serializable { @TableField(value="lttd") @Schema(description="纬度") // @Size(max = 0,message = "纬度最大长度要小于 0") - private String lttd; + private BigDecimal lttd; /** * 站址 @@ -98,37 +79,6 @@ public class StStbprpB implements Serializable { private String stlc; - /** - * alt - */ - @TableField(value="alt") - @Schema(description="alt") - // @Size(max = 0,message = "alt最大长度要小于 0") - private String alt; - - /** - * mdbz - */ - @TableField(value="mdbz") - @Schema(description="mdbz") - // @Size(max = 0,message = "mdbz最大长度要小于 0") - private String mdbz; - - /** - * mdpr - */ - @TableField(value="mdpr") - @Schema(description="mdpr") - // @Size(max = 0,message = "mdpr最大长度要小于 0") - private String mdpr; - - /** - * 基面名称 - */ - @TableField(value="dtmnm") - @Schema(description="基面名称") - @Size(max = 160,message = "基面名称最大长度要小于 160") - private String dtmnm; /** * 基面高程 @@ -136,15 +86,7 @@ public class StStbprpB implements Serializable { @TableField(value="dtmel") @Schema(description="基面高程") // @Size(max = 0,message = "基面高程最大长度要小于 0") - private String dtmel; - - /** - * 基面修正值 - */ - @TableField(value="dtpr") - @Schema(description="基面修正值") - // @Size(max = 0,message = "基面修正值最大长度要小于 0") - private String dtpr; + private BigDecimal dtmel; /** * 站类,PP=雨量站,RR=水库水位站,ZQ=河道水位站,TX=图像站 @@ -154,125 +96,7 @@ public class StStbprpB implements Serializable { @Size(max = 30,message = "站类,MM=气象站,PP=雨量站,BB=蒸发站,ZQ=河道水文站,DD=堰闸水文站,ZZ=河道水位站,TT=潮位站,RR=水库水文站,DP=泵站,ZG=地下水站,SS=墒情站,ZB=分洪水位站,QQ=流量站,TX=图像站,ZI=渠道水位站,ZL=田间水层,QI=渠道流量站,ZT=塘堰,ZS=渗压渗流站,GT=闸位站,SZ=水质站,PQ=管道流量站。最大长度要小于 30") private String sttp; - /** - * dfrtms - */ - @TableField(value="dfrtms") - @Schema(description="dfrtms") - // @Size(max = 0,message = "dfrtms最大长度要小于 0") - private String dfrtms; - /** - * fritm - */ - @TableField(value="fritm") - @Schema(description="fritm") - @Size(max = 320,message = "fritm最大长度要小于 320") - private String fritm; - - /** - * 报汛等级 - */ - @TableField(value="frgrd") - @Schema(description="报汛等级") - @Size(max = 500,message = "报汛等级最大长度要小于 500") - private String frgrd; - - /** - * 建站年月 - */ - @TableField(value="esstym") - @Schema(description="建站年月") - @Size(max = 60,message = "建站年月最大长度要小于 60") - private String esstym; - - /** - * bgfrym - */ - @TableField(value="bgfrym") - @Schema(description="bgfrym") - @Size(max = 60,message = "bgfrym最大长度要小于 60") - private String bgfrym; - - /** - * edfrym - */ - @TableField(value="edfrym") - @Schema(description="edfrym") - @Size(max = 60,message = "edfrym最大长度要小于 60") - private String edfrym; - - /** - * 隶属行业单位 - */ - @TableField(value="atcunit") - @Schema(description="隶属行业单位") - @Size(max = 200,message = "隶属行业单位最大长度要小于 200") - private String atcunit; - - /** - * 信息管理单位 - */ - @TableField(value="admauth") - @Schema(description="信息管理单位") - @Size(max = 500,message = "信息管理单位最大长度要小于 500") - private String admauth; - - /** - * 交换管理单位 - */ - @TableField(value="locality") - @Schema(description="交换管理单位") - @Size(max = 200,message = "交换管理单位最大长度要小于 200") - private String locality; - - /** - * 测站岸别 - */ - @TableField(value="stbk") - @Schema(description="测站岸别") - @Size(max = 1,message = "测站岸别最大长度要小于 1") - private String stbk; - - /** - * 测站方位 - */ - @TableField(value="stazt") - @Schema(description="测站方位") - // @Size(max = 0,message = "测站方位最大长度要小于 0") - private String stazt; - - /** - * 至河口距离 - */ - @TableField(value="dstrvm") - @Schema(description="至河口距离") - // @Size(max = 0,message = "至河口距离最大长度要小于 0") - private String dstrvm; - - /** - * 集水面积 - */ - @TableField(value="drna") - @Schema(description="集水面积") - // @Size(max = 0,message = "集水面积最大长度要小于 0") - private String drna; - - /** - * 拼音码 - */ - @TableField(value="phcd") - @Schema(description="拼音码") - @Size(max = 60,message = "拼音码最大长度要小于 60") - private String phcd; - - /** - * 启用标志 - */ - @TableField(value="usfl") - @Schema(description="启用标志") - @Size(max = 1,message = "启用标志最大长度要小于 1") - private String usfl; /** * 备注 @@ -282,143 +106,6 @@ public class StStbprpB implements Serializable { @Size(max = 200,message = "备注最大长度要小于 200") private String comments; - /** - * 时间戳 - */ - @TableField(value="moditime") - @Schema(description="时间戳") - // @Size(max = 0,message = "时间戳最大长度要小于 0") - @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") - private Date moditime; - - /** - * rem_gd - */ - @TableField(value="rem_gd") - @Schema(description="rem_gd") - @Size(max = 300,message = "rem_gd最大长度要小于 300") - private String remGd; - - /** - * ogid - */ - @TableField(value="ogid") - @Schema(description="ogid") - @Size(max = 100,message = "ogid最大长度要小于 100") - private String ogid; - - /** - * vlfl - */ - @TableField(value="vlfl") - @Schema(description="vlfl") - // @Size(max = 0,message = "vlfl最大长度要小于 0") - private String vlfl; - - /** - * atid - */ - @TableField(value="atid") - @Schema(description="atid") - @Size(max = 180,message = "atid最大长度要小于 180") - private String atid; - - /** - * sdfl - */ - @TableField(value="sdfl") - @Schema(description="sdfl") - @Size(max = 500,message = "sdfl最大长度要小于 500") - private String sdfl; - - /** - * rma - */ - @TableField(value="rma") - @Schema(description="rma") - @Size(max = 256,message = "rma最大长度要小于 256") - private String rma; - - /** - * mdps - */ - @TableField(value="mdps") - @Schema(description="mdps") - @Size(max = 300,message = "mdps最大长度要小于 300") - private String mdps; - - /** - * mddt - */ - @TableField(value="mddt") - @Schema(description="mddt") - // @Size(max = 0,message = "mddt最大长度要小于 0") - @JsonFormat(pattern = DateFormatString.YYYY_MM_DD_HH_MM_SS, timezone = "GMT+8") - private Date mddt; - - /** - * stindex - */ - @TableField(value="stindex") - @Schema(description="stindex") - // @Size(max = 0,message = "stindex最大长度要小于 0") - private String stindex; - - /** - * starea - */ - @TableField(value="starea") - @Schema(description="starea") - @Size(max = 500,message = "starea最大长度要小于 500") - private String starea; - - /** - * stlevel - */ - @TableField(value="stlevel") - @Schema(description="stlevel") - @Size(max = 1,message = "stlevel最大长度要小于 1") - private String stlevel; - - /** - * code - */ - @TableField(value="code") - @Schema(description="code") - @Size(max = 300,message = "code最大长度要小于 300") - private String code; - - /** - * ispbj - */ - @TableField(value="ispbj") - @Schema(description="ispbj") - @Size(max = 1,message = "ispbj最大长度要小于 1") - private String ispbj; - - /** - * issxst - */ - @TableField(value="issxst") - @Schema(description="issxst") - @Size(max = 1,message = "issxst最大长度要小于 1") - private String issxst; - - /** - * stpq - */ - @TableField(value="stpq") - @Schema(description="stpq") - @Size(max = 500,message = "stpq最大长度要小于 500") - private String stpq; - - /** - * sthday - */ - @TableField(value="sthday") - @Schema(description="sthday") - // @Size(max = 0,message = "sthday最大长度要小于 0") - private Integer sthday; /** * source @@ -429,85 +116,15 @@ public class StStbprpB implements Serializable { @NotBlank(message = "站点来源不能为空") private String source; - /** - * importancy - */ - @TableField(value="importancy") - @Schema(description="importancy") - // @Size(max = 0,message = "importancy最大长度要小于 0") - private Integer importancy; - - /** - * clgtd - */ - @TableField(value="clgtd") - @Schema(description="clgtd") - // @Size(max = 0,message = "clgtd最大长度要小于 0") - private String clgtd; - - /** - * clttd - */ - @TableField(value="clttd") - @Schema(description="clttd") - // @Size(max = 0,message = "clttd最大长度要小于 0") - private String clttd; - - /** - * elev - */ - @TableField(value="elev") - @Schema(description="elev") - // @Size(max = 0,message = "elev最大长度要小于 0") - private String elev; - - /** - * crucial - */ - @TableField(value="crucial") - @Schema(description="crucial") - // @Size(max = 0,message = "crucial最大长度要小于 0") - private Integer crucial; /** * build_year */ @TableField(value="build_year") - @Schema(description="build_year") + @Schema(description="建设年份") @Size(max = 50,message = "build_year最大长度要小于 50") private String buildYear; - /** - * 行政区划编码 - */ - @TableField(value="adcd") - @Schema(description="行政区划编码") - @Size(max = 15,message = "行政区划编码最大长度要小于 15") - private String adcd; - - /** - * 流域编码 - */ - @TableField(value="lyid") - @Schema(description="流域编码") - @Size(max = 255,message = "流域编码最大长度要小于 255") - private String lyid; - - /** - * 水库编码 - */ - @TableField(value="res_code") - @Schema(description="水库编码") - @Size(max = 255,message = "水库编码最大长度要小于 255") - private String resCode; - - /** - * 河流编码 - */ - @TableField(value="rv_code") - @Schema(description="河流编码") - @Size(max = 255,message = "河流编码最大长度要小于 255") - private String rvCode; /** * 测站状态 0无效 1有效 @@ -517,27 +134,20 @@ public class StStbprpB implements Serializable { // @Size(max = 0,message = "测站状态 0无效 1有效最大长度要小于 0") private Integer status; - /** - * 归属协议 - */ - @Schema(description="归属协议") - @TableField(value="agreement") - private String agreement; - /** - * SIM卡 - */ - @Schema(description="SIM卡") - @TableField(value="sim_card") - private String simCard; + @TableField(value = "build_unit") + @Schema(description = "承建单位") + private String buildUnit; - /** - * 北斗卡号 - */ - @Schema(description="北斗卡号") - @TableField(value="bd_card") - private String bdCard; + @TableField(value = "management_unit") + @Schema(description = "管理单位") + private String managementUnit; - public static final String COL_STCD = "stcd"; + @TableField(value = "operate_unit") + @Schema(description = "运维单位") + private String operateUnit; + + @TableField(exist = false) + private List elems; } diff --git a/module-common/src/main/java/com/gunshi/project/ss/common/model/StationNormalVo.java b/module-common/src/main/java/com/gunshi/project/ss/common/model/StationNormalVo.java index 28a1b7c..113602b 100644 --- a/module-common/src/main/java/com/gunshi/project/ss/common/model/StationNormalVo.java +++ b/module-common/src/main/java/com/gunshi/project/ss/common/model/StationNormalVo.java @@ -42,5 +42,5 @@ public class StationNormalVo { * 最后监测的数据时间 */ @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") - private LocalDateTime latestTm; + private LocalDateTime tm; } diff --git a/src/main/java/com/gunshi/project/ss/controller/DebugController.java b/src/main/java/com/gunshi/project/ss/controller/DebugController.java index 36c7174..48d5a26 100644 --- a/src/main/java/com/gunshi/project/ss/controller/DebugController.java +++ b/src/main/java/com/gunshi/project/ss/controller/DebugController.java @@ -415,10 +415,10 @@ public class DebugController { String jsonString = JSONObject.toJSONString(entity); esObjectDocument.setJsonStr(jsonString); if(entity.getLgtd() != null){ - esObjectDocument.setLgtd(new BigDecimal(entity.getLgtd())); + esObjectDocument.setLgtd(entity.getLgtd()); } if(entity.getLgtd() != null){ - esObjectDocument.setLttd(new BigDecimal(entity.getLttd())); + esObjectDocument.setLttd(entity.getLttd()); } list.add(esObjectDocument); } diff --git a/src/main/java/com/gunshi/project/ss/controller/StStbprpBController.java b/src/main/java/com/gunshi/project/ss/controller/StStbprpBController.java index 347de8b..647feb0 100644 --- a/src/main/java/com/gunshi/project/ss/controller/StStbprpBController.java +++ b/src/main/java/com/gunshi/project/ss/controller/StStbprpBController.java @@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.gunshi.core.result.R; import com.gunshi.project.ss.entity.so.HomeStStbprpBSo; import com.gunshi.project.ss.entity.so.StStbprpBPage; +import com.gunshi.project.ss.entity.so.StStbprpBPageSo; import com.gunshi.project.ss.entity.so.StStbprpBSo; import com.gunshi.project.ss.entity.vo.HomeStStbprpBVo; import com.gunshi.project.ss.entity.vo.StStatusListVo; @@ -48,79 +49,61 @@ public class StStbprpBController { if (Objects.nonNull(service.getById(dto.getStcd()))){ throw new RuntimeException("测站编号已存在"); } - dto.setModitime(new Date()); - boolean result = service.save(dto); + boolean result = service.saveData(dto); return R.ok(result ? dto : null); } @Operation(summary = "修改") @PostMapping("/update") public R update(@Validated(Update.class) @RequestBody StStbprpB dto) { - if (Objects.isNull(service.getById(dto.getStcd()))){ - throw new RuntimeException("当前数据不存在"); - } - boolean result = service.updateById(dto); - return R.ok(result ? dto : null); + service.edit(dto); + return R.ok(dto); } @Operation(summary = "删除") @GetMapping("/del/{id}") public R del(@Schema(name = "id") @PathVariable("id") Serializable id) { - if (Objects.isNull(service.getById(id))){ - throw new RuntimeException("当前数据不存在"); - } - return R.ok(service.removeById(id)); + service.deleteById(id); + return R.ok(true); } - @Operation(summary = "列表") - @PostMapping("/list") - public R> list(@RequestBody StStbprpBSo dto) { - LambdaQueryChainWrapper query = service.lambdaQuery(); - query - .eq(StStbprpB::getSttp,dto.getSttp()) - .eq(StStbprpB::getStcd,dto.getStcd()) - .like(StStbprpB::getStnm,dto.getStnm()) - .like(StStbprpB::getRvnm,dto.getRvnm()) - .like(StStbprpB::getHnnm,dto.getHnnm()) - .like(StStbprpB::getBsnm,dto.getBsnm()) - ; - return R.ok(query.list()); - } +// @Operation(summary = "列表") +// @PostMapping("/list") +// public R> list(@RequestBody StStbprpBSo dto) { +// LambdaQueryChainWrapper query = service.lambdaQuery(); +// query +// .eq(StStbprpB::getSttp,dto.getSttp()) +// .eq(StStbprpB::getStcd,dto.getStcd()) +// .like(StStbprpB::getStnm,dto.getStnm()) +// .like(StStbprpB::getRvnm,dto.getRvnm()) +// .like(StStbprpB::getHnnm,dto.getHnnm()) +// .like(StStbprpB::getBsnm,dto.getBsnm()) +// ; +// return R.ok(query.list()); +// } @Operation(summary = "分页") @PostMapping("/page") - public R> page(@RequestBody @Validated StStbprpBPage page) { - LambdaQueryWrapper query = Wrappers.lambdaQuery(); - if (ObjectUtils.isNotNull(page.getCode())) { - query.like(StStbprpB::getStcd, page.getCode()); - } - if (ObjectUtils.isNotNull(page.getName())) { - query.like(StStbprpB::getStnm, page.getName()); - } - if (ObjectUtils.isNotNull(page.getAgreement())) { - query.like(StStbprpB::getAgreement, page.getAgreement()); - } - query.orderByDesc(StStbprpB::getModitime); - return R.ok(service.page(page.getPageSo().toPage(), query)); + public R> page(@RequestBody @Validated StStbprpBPageSo pageSo) { + Page pageinfo = service.pageInfo(pageSo); + + return R.ok(pageinfo); } @Operation(summary = "雨量站详情带雨量列表") @PostMapping("/rainfallStationDetails/rainfallList") - @Deprecated(since = "代码重构-废弃") public R> rainfallStationDetailsList(@RequestBody @Validated HomeStStbprpBSo dto) { return R.ok(service.rainfallStationDetailsList(dto)); } @Operation(summary = "水库站点详情带实时水位列表") @PostMapping("/reservoirStationDetails/realTimeWaterLevelList") - @Deprecated(since = "代码重构-废弃") public R> reservoirStationDetailsList() { return R.ok(service.reservoirStationDetailsList()); } @Operation(summary = "输/放水管流量站点详情带实时流量列表") @PostMapping("/trafficSiteDetails/realTimeTrafficList") - @Deprecated(since = "代码重构-废弃") public R> trafficStationDetailsList() { return R.ok(service.flowStationDetailsList()); } diff --git a/src/main/java/com/gunshi/project/ss/controller/StationController.java b/src/main/java/com/gunshi/project/ss/controller/StationController.java index 94ac348..cc866b6 100644 --- a/src/main/java/com/gunshi/project/ss/controller/StationController.java +++ b/src/main/java/com/gunshi/project/ss/controller/StationController.java @@ -106,7 +106,7 @@ public class StationController { public void handlerStatus(List stationNormalVos){ for (StationNormalVo station : stationNormalVos) { - LocalDateTime latestTm = station.getLatestTm(); + LocalDateTime latestTm = station.getTm(); if(latestTm == null){ station.setStatus(0); continue; diff --git a/src/main/java/com/gunshi/project/ss/entity/es/EsObjectDocument.java b/src/main/java/com/gunshi/project/ss/entity/es/EsObjectDocument.java index 99191f7..7d7a71e 100644 --- a/src/main/java/com/gunshi/project/ss/entity/es/EsObjectDocument.java +++ b/src/main/java/com/gunshi/project/ss/entity/es/EsObjectDocument.java @@ -9,7 +9,7 @@ import org.springframework.data.elasticsearch.annotations.FieldType; import java.math.BigDecimal; @Data -@Document(indexName="ss_object") +//@Document(indexName="ss_object") public class EsObjectDocument { @Id // 必须添加这个注解 private String id; // 字段名可以是id或自定义 diff --git a/src/main/java/com/gunshi/project/ss/entity/so/StStbprpBPage.java b/src/main/java/com/gunshi/project/ss/entity/so/StStbprpBPage.java index af2ebfd..8dad8fe 100644 --- a/src/main/java/com/gunshi/project/ss/entity/so/StStbprpBPage.java +++ b/src/main/java/com/gunshi/project/ss/entity/so/StStbprpBPage.java @@ -19,4 +19,6 @@ public class StStbprpBPage extends GeneralDataPage{ */ @Schema(description="归属协议") private String agreement; + + private Integer status; } diff --git a/src/main/java/com/gunshi/project/ss/entity/so/StStbprpBPageSo.java b/src/main/java/com/gunshi/project/ss/entity/so/StStbprpBPageSo.java new file mode 100644 index 0000000..999e266 --- /dev/null +++ b/src/main/java/com/gunshi/project/ss/entity/so/StStbprpBPageSo.java @@ -0,0 +1,22 @@ +package com.gunshi.project.ss.entity.so; + + +import com.gunshi.db.dto.PageSo; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Data +public class StStbprpBPageSo { + + + private String stcd; + + private String stnm; + + private Integer status; + + @NotNull(message = "分页参数不能为空") + @Schema(description = "分页参数") + private PageSo pageSo; +} diff --git a/src/main/java/com/gunshi/project/ss/service/StStbprpBElemService.java b/src/main/java/com/gunshi/project/ss/service/StStbprpBElemService.java index 2e36af1..5e2df82 100644 --- a/src/main/java/com/gunshi/project/ss/service/StStbprpBElemService.java +++ b/src/main/java/com/gunshi/project/ss/service/StStbprpBElemService.java @@ -1,8 +1,11 @@ package com.gunshi.project.ss.service; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gunshi.project.ss.common.mapper.StStbprpBElemMapper; import com.gunshi.project.ss.common.model.StStbprpBElem; +import jakarta.validation.constraints.NotBlank; +import jakarta.validation.constraints.Size; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -18,6 +21,11 @@ import org.springframework.transaction.annotation.Transactional; public class StStbprpBElemService extends ServiceImpl { + public void delete(String stcd) { + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(StStbprpBElem::getStcd, stcd); + int delete = baseMapper.delete(queryWrapper); + } } diff --git a/src/main/java/com/gunshi/project/ss/service/StStbprpBService.java b/src/main/java/com/gunshi/project/ss/service/StStbprpBService.java index a092a9e..a3929a7 100644 --- a/src/main/java/com/gunshi/project/ss/service/StStbprpBService.java +++ b/src/main/java/com/gunshi/project/ss/service/StStbprpBService.java @@ -2,20 +2,22 @@ package com.gunshi.project.ss.service; import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.gunshi.project.ss.common.mapper.StStbprpBMapper; -import com.gunshi.project.ss.common.model.StRiverR; -import com.gunshi.project.ss.common.model.StStbprpB; -import com.gunshi.project.ss.common.model.StationNormalVo; +import com.gunshi.project.ss.common.model.*; import com.gunshi.project.ss.common.model.vo.OsmoticShiftListVo2; import com.gunshi.project.ss.entity.dto.StZqrlBDto; import com.gunshi.project.ss.entity.so.HomeStStbprpBSo; +import com.gunshi.project.ss.entity.so.StStbprpBPage; +import com.gunshi.project.ss.entity.so.StStbprpBPageSo; import com.gunshi.project.ss.entity.vo.*; import com.gunshi.project.ss.mapper.OsmoticPressRMapper; import com.gunshi.project.ss.mapper.OsmoticShiftRMapper; import com.gunshi.project.ss.mapper.StWaterFlowMapper; import com.gunshi.project.ss.mapper.StbprpBVoMapper; -import com.gunshi.project.ss.common.model.StRsvrR; import com.gunshi.project.ss.model.*; import com.gunshi.project.ss.util.DateUtil; import com.ruoyi.common.utils.StringUtils; @@ -73,6 +75,9 @@ public class StStbprpBService extends ServiceImpl { @Autowired private StZqRSerivce stZqRSerivce; + @Autowired + private StStbprpBElemService stStbprpBElemService; + public List rainfallStationDetailsList(HomeStStbprpBSo dto) { return stbprpBVoMapper.rainfallStationDetailsList(dto); } @@ -588,6 +593,68 @@ public class StStbprpBService extends ServiceImpl { public List getFlowNormalStations() { return baseMapper.getFlowNormalStations(); } + + public boolean saveData(StStbprpB dto) { + boolean save = save(dto); + List elemList = new ArrayList<>(); + for (String el : dto.getElems()) { + StStbprpBElem elem = new StStbprpBElem(); + elem.setElem(el); + elem.setStcd(dto.getStcd()); + elemList.add(elem); + } + if(CollectionUtil.isNotEmpty(elemList)) { + stStbprpBElemService.saveBatch(elemList); + } + return save; + } + + public Page pageInfo(StStbprpBPageSo pageSo) { + LambdaQueryWrapper query = Wrappers.lambdaQuery(); + if (ObjectUtils.isNotNull(pageSo.getStcd())) { + query.like(StStbprpB::getStcd, pageSo.getStcd()); + } + if (ObjectUtils.isNotNull(pageSo.getStnm())) { + query.like(StStbprpB::getStnm, pageSo.getStnm()); + } + if (ObjectUtils.isNotNull(pageSo.getStatus())) { + query.like(StStbprpB::getStatus,pageSo.getStatus()); + } + Page stStbprpBPage = this.baseMapper.selectPage(pageSo.getPageSo().toPage(), query); + for (StStbprpB record : stStbprpBPage.getRecords()) { + List elemList = stStbprpBElemService.lambdaQuery() + .eq(StStbprpBElem::getStcd, record.getStcd()).list(); + List elems = elemList.stream().map(o -> o.getElem()).collect(Collectors.toList()); + record.setElems(elems); + } + return stStbprpBPage; + } + + public void edit(StStbprpB dto) { + StStbprpB byId = getById(dto.getId()); + updateById(dto); + stStbprpBElemService.delete(byId.getStcd()); + List elemList = new ArrayList<>(); + for (String el : dto.getElems()) { + StStbprpBElem elem = new StStbprpBElem(); + elem.setElem(el); + elem.setStcd(dto.getStcd()); + elemList.add(elem); + } + if(CollectionUtil.isNotEmpty(elemList)) { + stStbprpBElemService.saveBatch(elemList); + } + } + + public void deleteById(Serializable id) { + StStbprpB byId = getById(id); + if(byId == null){ + return; + } + stStbprpBElemService + .delete(byId.getStcd()); + removeById(id); + } }