From 40e0c17e72a215e813a65bcb46dae699d555a4b7 Mon Sep 17 00:00:00 2001 From: wany <13995595726@qq.com> Date: Mon, 8 Jul 2024 13:18:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=A2=E9=99=A9=E9=98=9F=E4=BC=8D=EF=BC=8C?= =?UTF-8?q?=E6=8A=A2=E9=99=A9=E7=89=A9=E8=B5=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/RescueGoodsBController.java | 2 +- .../xyt/controller/RescueTeamBController.java | 130 +++++++++++++++ .../xyt/entity/so/RescueGoodsPageSo.java | 10 -- .../xyt/entity/so/RescueTeamPageSo.java | 30 ++++ .../project/xyt/entity/vo/RescueTeamVo.java | 23 +++ .../project/xyt/mapper/RescueGoodsMapper.java | 22 +-- .../xyt/mapper/RescueTeamFileMapper.java | 22 +++ .../project/xyt/mapper/RescueTeamMapper.java | 42 +++++ .../project/xyt/model/RescueGoodsB.java | 33 ---- .../gunshi/project/xyt/model/RescueTeamB.java | 153 ++++++++++++++++++ .../project/xyt/model/RescueTeamDetail.java | 105 ++++++++++++ .../project/xyt/model/RescueTeamFile.java | 74 +++++++++ .../xyt/service/RescueTeamService.java | 138 ++++++++++++++++ src/main/resources/application-gs.yml | 5 - src/main/resources/config-common.yml | 4 +- src/main/resources/config-dev.yml | 18 ++- src/main/resources/config-gs.yml | 12 -- src/main/resources/config-prod.yml | 27 +++- 18 files changed, 757 insertions(+), 93 deletions(-) create mode 100644 src/main/java/com/gunshi/project/xyt/controller/RescueTeamBController.java create mode 100644 src/main/java/com/gunshi/project/xyt/entity/so/RescueTeamPageSo.java create mode 100644 src/main/java/com/gunshi/project/xyt/entity/vo/RescueTeamVo.java create mode 100644 src/main/java/com/gunshi/project/xyt/mapper/RescueTeamFileMapper.java create mode 100644 src/main/java/com/gunshi/project/xyt/mapper/RescueTeamMapper.java create mode 100644 src/main/java/com/gunshi/project/xyt/model/RescueTeamB.java create mode 100644 src/main/java/com/gunshi/project/xyt/model/RescueTeamDetail.java create mode 100644 src/main/java/com/gunshi/project/xyt/model/RescueTeamFile.java create mode 100644 src/main/java/com/gunshi/project/xyt/service/RescueTeamService.java delete mode 100644 src/main/resources/application-gs.yml delete mode 100644 src/main/resources/config-gs.yml diff --git a/src/main/java/com/gunshi/project/xyt/controller/RescueGoodsBController.java b/src/main/java/com/gunshi/project/xyt/controller/RescueGoodsBController.java index cd59e70..1b9b475 100644 --- a/src/main/java/com/gunshi/project/xyt/controller/RescueGoodsBController.java +++ b/src/main/java/com/gunshi/project/xyt/controller/RescueGoodsBController.java @@ -85,7 +85,7 @@ public class RescueGoodsBController extends AbstractCommonFileController impleme @Override public String getGroupId() { - return "RescueGoodsB"; + return "rescueGoodsB"; } diff --git a/src/main/java/com/gunshi/project/xyt/controller/RescueTeamBController.java b/src/main/java/com/gunshi/project/xyt/controller/RescueTeamBController.java new file mode 100644 index 0000000..3ff7b81 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/controller/RescueTeamBController.java @@ -0,0 +1,130 @@ +package com.gunshi.project.xyt.controller; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.baomidou.mybatisplus.core.toolkit.StringUtils; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.gunshi.core.annotation.Get; +import com.gunshi.core.annotation.Post; +import com.gunshi.core.result.R; +import com.gunshi.project.xyt.entity.so.RescueTeamPageSo; +import com.gunshi.project.xyt.entity.vo.RescueTeamVo; +import com.gunshi.project.xyt.model.RescueTeamB; +import com.gunshi.project.xyt.model.RescueTeamBAutoMapper; +import com.gunshi.project.xyt.model.RescueTeamFile; +import com.gunshi.project.xyt.model.RescueTeamFileAutoDao; +import com.gunshi.project.xyt.service.AbstractModelWithAttachService; +import com.gunshi.project.xyt.service.RescueTeamService; +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 java.io.Serializable; +import java.util.Date; +import java.util.List; + +/** + * Description: + * Created by wanyan on 2024/3/18 + * + * @author wanyan + * @version 1.0 + */ +@Tag(name = "抢险队伍") +@RestController +@RequestMapping("/rescue/team") +public class RescueTeamBController extends AbstractCommonFileController implements + ICommonInsertWithAttach, + ICommonUpdateByIdWithAttach, + ICommonDeleteByIdWithAttach, + ICommonQueryAttach +{ + + @Autowired + private RescueTeamBAutoMapper rescueTeamBAutoMapper; + + @Autowired + private RescueTeamFileAutoDao attachAutoDao; + + @Autowired + private RescueTeamService rescueTeamService; + + + @Override + public Long getId(Serializable id) { + return Long.valueOf(id.toString()); + } + + @Override + public void customSetFieldForUpdate(RescueTeamB model) { + model.setTm(new Date()); + rescueTeamService.updateDetailAndObj(model); + } + + @Override + public AbstractModelWithAttachService getModelService() { + return rescueTeamService; + } + + @Override + public void customSetFieldForInsert(RescueTeamB model) { + long teamId = IdWorker.getId(); + model.setTeamId(teamId); + model.setTm(new Date()); + rescueTeamService.saveDetailAndObj(model,teamId); + } + + @Override + public String getGroupId() { + return "rescueTeamB"; + } + + + /** + * 防汛准备-分页查询 + */ + @Post(path = "/page/query", summary = "防汛准备-分页查询") + public R> pageQuery(@RequestBody @Validated RescueTeamPageSo RescueTeamPageSo) { + return R.ok(rescueTeamService.pageQuery(RescueTeamPageSo)); + } + + + + /** + * 列表查询 + */ + @Get(path = "/list", summary = "列表查询") + public R> list(@Schema(name = "teamName",description = "队伍名称") @RequestParam(name = "teamName",required = false) String teamName) { + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); + if(StringUtils.isNotEmpty(teamName)){ + queryWrapper.like(RescueTeamB::getTeamName,teamName); + } + return R.ok(rescueTeamBAutoMapper.selectList(queryWrapper)); + } + + /** + * 详情 + */ + @Get(path = "/detail", summary = "详情") + public R detail(@Schema(name = "teamId",description = "队伍ID") @RequestParam(name = "teamId") Long teamId) { + return R.ok(rescueTeamService.detail(teamId)); + } + + @Get(path ="/delete/{id}", summary = "删除") + public R delete(@Schema(name = "teamId") @PathVariable("teamId") Long teamId) { + return R.ok(rescueTeamService.delete(teamId)); + } + + @Override + public RescueTeamFileAutoDao getAttachAutoDao() { + return attachAutoDao; + } + + @Override + public String getAttachBzIdName() { + return "team_id"; + } +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/so/RescueGoodsPageSo.java b/src/main/java/com/gunshi/project/xyt/entity/so/RescueGoodsPageSo.java index 41c4f5c..a629bcf 100644 --- a/src/main/java/com/gunshi/project/xyt/entity/so/RescueGoodsPageSo.java +++ b/src/main/java/com/gunshi/project/xyt/entity/so/RescueGoodsPageSo.java @@ -20,19 +20,9 @@ public class RescueGoodsPageSo { @Schema(description = "分页参数") private PageSo pageSo; - @Schema(description="政区/工程( 1 政区 2 工程)") - @NotNull(message = "type不能为空") - private Integer type; - - @Schema(description="编码") - private String code; - @Schema(description="物资名称") private String goodsName; - @Schema(description = "防汛仓库") - private Long warehouseId; - @Schema(description = "排序字段") private String sortField; diff --git a/src/main/java/com/gunshi/project/xyt/entity/so/RescueTeamPageSo.java b/src/main/java/com/gunshi/project/xyt/entity/so/RescueTeamPageSo.java new file mode 100644 index 0000000..ae8586a --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/so/RescueTeamPageSo.java @@ -0,0 +1,30 @@ +package com.gunshi.project.xyt.entity.so; + +import com.gunshi.db.dto.DateRangeSo; +import com.gunshi.db.dto.PageSo; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +/** + * Description: + * Created by wanyan on 2024/3/19 + * + * @author wanyan + * @version 1.0 + */ +@Data +@Schema(description = "抢险队伍分页查询对象") +public class RescueTeamPageSo { + + @NotNull(message = "分页参数不能为空") + @Schema(description = "分页参数") + private PageSo pageSo; + + @Schema(description="队伍名称") + private String teamName; + + @Schema(description = "时间范围") + private DateRangeSo dateSo; + +} diff --git a/src/main/java/com/gunshi/project/xyt/entity/vo/RescueTeamVo.java b/src/main/java/com/gunshi/project/xyt/entity/vo/RescueTeamVo.java new file mode 100644 index 0000000..a935015 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/entity/vo/RescueTeamVo.java @@ -0,0 +1,23 @@ +package com.gunshi.project.xyt.entity.vo; + +import com.gunshi.project.xyt.model.RescueTeamB; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + + +@Data +public class RescueTeamVo extends RescueTeamB { + + /** + * 人员总数 + */ + @Schema(description="人员总数") + private Integer personCount; + + /** + * 是否有效 + */ + @Schema(description = "是否有效(0 否 1 是)") + private Integer isValid; + +} diff --git a/src/main/java/com/gunshi/project/xyt/mapper/RescueGoodsMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/RescueGoodsMapper.java index 3984584..311b5b2 100644 --- a/src/main/java/com/gunshi/project/xyt/mapper/RescueGoodsMapper.java +++ b/src/main/java/com/gunshi/project/xyt/mapper/RescueGoodsMapper.java @@ -17,30 +17,16 @@ public interface RescueGoodsMapper extends BaseMapper { @Select(""" """) Page pageQuery(@Param("page") Page page,@Param("obj") RescueGoodsPageSo RescueGoodsPageSo); diff --git a/src/main/java/com/gunshi/project/xyt/mapper/RescueTeamFileMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/RescueTeamFileMapper.java new file mode 100644 index 0000000..9d040e8 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/mapper/RescueTeamFileMapper.java @@ -0,0 +1,22 @@ +package com.gunshi.project.xyt.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.gunshi.file.model.FileDescriptor; +import com.gunshi.project.xyt.model.RescueTeamFile; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +import java.util.List; + +@Mapper +public interface RescueTeamFileMapper extends BaseMapper { + + @Select(""" + + """) + List queryFiles(@Param("teamId") Long teamId); +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/mapper/RescueTeamMapper.java b/src/main/java/com/gunshi/project/xyt/mapper/RescueTeamMapper.java new file mode 100644 index 0000000..387e6da --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/mapper/RescueTeamMapper.java @@ -0,0 +1,42 @@ +package com.gunshi.project.xyt.mapper; + +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.gunshi.project.xyt.entity.so.RescueTeamPageSo; +import com.gunshi.project.xyt.entity.vo.RescueTeamVo; +import com.gunshi.project.xyt.model.RescueTeamB; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; +import org.apache.ibatis.annotations.Select; + +@Mapper +public interface RescueTeamMapper extends BaseMapper { + + + @Select(""" + + """) + Page pageQuery(@Param("page") Page page, @Param("obj") RescueTeamPageSo rescueTeamPageSo); + + + + +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/model/RescueGoodsB.java b/src/main/java/com/gunshi/project/xyt/model/RescueGoodsB.java index c2cfe63..6f7355f 100644 --- a/src/main/java/com/gunshi/project/xyt/model/RescueGoodsB.java +++ b/src/main/java/com/gunshi/project/xyt/model/RescueGoodsB.java @@ -6,7 +6,6 @@ import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; -import com.github.jeffreyning.mybatisplus.anno.MppMultiId; import com.gunshi.project.xyt.service.AbstractModelWithAttachService; import com.gunshi.project.xyt.validate.markers.Insert; import com.gunshi.project.xyt.validate.markers.Update; @@ -37,23 +36,6 @@ public class RescueGoodsB implements Serializable, AbstractModelWithAttachServic @JsonSerialize(using = ToStringSerializer.class) private Long goodsId; - /** - * 行政区划id/水库编码/水电站编码 - */ - @MppMultiId - @TableField(value = "code") - @Schema(description="行政区划id/水库编码/水电站编码") - @NotEmpty(message = "行政区划id/水库编码/水电站编码不能为空", groups = {Insert.class, Update.class}) - private String code; - - /** - * 类型 1政区 2工程 - */ - @TableField(value = "type") - @Schema(description="类型 1政区 2工程") - @NotNull(message = "类型不能为空", groups = {Insert.class, Update.class}) - private Integer type; - /** * 物资名称 */ @@ -93,14 +75,6 @@ public class RescueGoodsB implements Serializable, AbstractModelWithAttachServic @NotNull(message = "库存数量不能为空", groups = {Insert.class, Update.class}) private BigDecimal storeQuantity; - /** - * 存放仓库 - */ - @TableField(value = "warehouse_id") - @Schema(description="存放仓库") - @JsonSerialize(using = ToStringSerializer.class) - private Long warehouseId; - /** * 存放地点 */ @@ -137,13 +111,6 @@ public class RescueGoodsB implements Serializable, AbstractModelWithAttachServic @Schema(description = "文件id集合") private List fileIds; - /** - * 仓库名称 - */ - @Schema(description="仓库名称") - @TableField(exist = false) - private String warehouseName; - private static final long serialVersionUID = 1L; diff --git a/src/main/java/com/gunshi/project/xyt/model/RescueTeamB.java b/src/main/java/com/gunshi/project/xyt/model/RescueTeamB.java new file mode 100644 index 0000000..91b79c8 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/model/RescueTeamB.java @@ -0,0 +1,153 @@ +package com.gunshi.project.xyt.model; + +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.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.gunshi.core.dateformat.DateFormatString; +import com.gunshi.file.model.FileDescriptor; +import com.gunshi.project.xyt.service.AbstractModelWithAttachService; +import com.gunshi.project.xyt.validate.markers.Insert; +import com.gunshi.project.xyt.validate.markers.Update; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.Data; + +import java.io.Serializable; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * 抢险队伍 + */ +@Schema(description="抢险队伍") +@Data +@TableName(value = "public.rescue_team_b") +public class RescueTeamB implements Serializable, AbstractModelWithAttachService.GetFileIds { + /** + * 主键 + */ + @TableId(value = "team_id", type = IdType.INPUT) + @Schema(description="主键") + @NotNull(message = "主键不能为空", groups = {Update.class}) + @JsonSerialize(using = ToStringSerializer.class) + private Long teamId; + + /** + * 队伍名称 + */ + @TableField(value = "team_name") + @Schema(description="队伍名称") + @Size(max = 100,message = "队伍名称最大长度要小于 100") + @NotEmpty(message = "队伍名称不能为空", groups = {Insert.class, Update.class}) + private String teamName; + + /** + * 地址 + */ + @TableField(value = "address") + @Schema(description="地址") + @NotEmpty(message = "地址不能为空", groups = {Insert.class, Update.class}) + private String address; + + /** + * 经度 (°) + */ + @TableField(value = "lgtd") + @Schema(description="经度 (°)") + private BigDecimal lgtd; + + /** + * 纬度 (°) + */ + @TableField(value = "lttd") + @Schema(description="纬度 (°)") + private BigDecimal lttd; + + /** + * 管理单位 + */ + @TableField(value = "management_unit") + @Schema(description="管理单位") + @Size(max = 150,message = "管理单位最大长度要小于 150", groups = {Insert.class, Update.class}) + private String managementUnit; + + /** + * 队伍负责人 + */ + @TableField(value = "team_leader") + @Schema(description="队伍负责人") + @Size(max = 150,message = "队伍负责人最大长度要小于 150", groups = {Insert.class, Update.class}) + private String teamLeader; + + /** + * 联系电话 + */ + @TableField(value = "phone") + @Schema(description="联系电话") + @Size(max = 20,message = "联系电话最大长度要小于 20", groups = {Insert.class, Update.class}) + private String phone; + + /** + * 登记日期 + */ + @TableField(value = "register_date") + @Schema(description="登记日期") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8") + @NotNull(message = "登记日期不能为空", groups = {Insert.class, Update.class}) + private Date registerDate; + + /** + * 有效期开始时间 + */ + @TableField(value = "valid_start_date") + @Schema(description="有效期开始时间") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8") + @NotNull(message = "有效期开始时间不能为空", groups = {Insert.class, Update.class}) + private Date validStartDate; + + /** + * 有效期结束时间 + */ + @TableField(value = "valid_end_date") + @Schema(description="有效期结束时间") + @JsonFormat(pattern = DateFormatString.YYYY_MM_DD, timezone = "GMT+8") + @NotNull(message = "有效期结束时间不能为空", groups = {Insert.class, Update.class}) + private Date validEndDate; + + + /** + * 时间戳 + */ + @TableField(value = "tm") + @Schema(description="时间戳") + @NotNull(message = "时间戳不能为空") + private Date tm; + + @TableField(exist = false) + @Schema(description = "文件id集合") + private List fileIds; + + /** + * 文件上传数据 + */ + @Schema(description="文件上传数据") + @TableField(exist = false) + private List files; + + /** + * 队伍明细 + */ + @Schema(description="队伍明细") + @TableField(exist = false) + private List details; + + private static final long serialVersionUID = 1L; + +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/model/RescueTeamDetail.java b/src/main/java/com/gunshi/project/xyt/model/RescueTeamDetail.java new file mode 100644 index 0000000..18ddd29 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/model/RescueTeamDetail.java @@ -0,0 +1,105 @@ +package com.gunshi.project.xyt.model; + +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.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import com.gunshi.project.xyt.validate.markers.Insert; +import com.gunshi.project.xyt.validate.markers.Update; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import jakarta.validation.constraints.Size; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 抢险队伍明细 + */ +@Schema(description="抢险队伍明细") +@Data +@TableName(value = "public.rescue_team_detail") +public class RescueTeamDetail implements Serializable { + /** + * 主键 + */ + @TableId(value = "detail_id", type = IdType.INPUT) + @Schema(description="主键") + @NotNull(message = "主键不能为空", groups = {Update.class}) + @JsonSerialize(using = ToStringSerializer.class) + private Long detailId; + + /** + * 队伍id + */ + @TableField(value = "team_id") + @Schema(description="队伍id") + @NotNull(message = "队伍id不能为空", groups = {Insert.class, Update.class}) + @JsonSerialize(using = ToStringSerializer.class) + private Long teamId; + + /** + * 姓名 + */ + @TableField(value = "name") + @Schema(description="姓名") + @Size(max = 100,message = "姓名最大长度要小于 100") + @NotEmpty(message = "姓名不能为空", groups = {Insert.class, Update.class}) + private String name; + + /** + * 性别,F女,M男 + */ + @TableField(value = "sex") + @Schema(description="性别,F女,M男") + @NotNull(message = "性别不能为空", groups = {Insert.class, Update.class}) + private String sex; + + /** + * 年龄 + */ + @TableField(value = "age") + @Schema(description="年龄") + @NotNull(message = "年龄不能为空", groups = {Insert.class, Update.class}) + private Integer age; + + /** + * 工作单位 + */ + @TableField(value = "work_unit") + @Schema(description="工作单位") + @Size(max = 150,message = "工作单位最大长度要小于 150", groups = {Insert.class, Update.class}) + private String workUnit; + + + /** + * 职务 + */ + @TableField(value = "duty") + @Schema(description="职务") + @Size(max = 20,message = "工作单位最大长度要小于 20", groups = {Insert.class, Update.class}) + private String duty; + + /** + * 联系电话 + */ + @TableField(value = "phone") + @Schema(description="联系电话") + @Size(max = 20,message = "联系电话最大长度要小于 20", groups = {Insert.class, Update.class}) + private String phone; + + /** + * 时间戳 + */ + @TableField(value = "tm") + @Schema(description="时间戳") + @NotNull(message = "时间戳不能为空") + private Date tm; + + private static final long serialVersionUID = 1L; + +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/model/RescueTeamFile.java b/src/main/java/com/gunshi/project/xyt/model/RescueTeamFile.java new file mode 100644 index 0000000..371f15b --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/model/RescueTeamFile.java @@ -0,0 +1,74 @@ +package com.gunshi.project.xyt.model; + +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.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + +/** + * 抢险队伍-附件 + */ +@Schema(description="抢险队伍-附件") +@Data +@TableName(value = "public.rescue_team_file") +public class RescueTeamFile implements Serializable { + /** + * 主键 + */ + @TableId(value = "id", type = IdType.INPUT) + @Schema(description="主键") + @NotNull(message = "主键不能为空") + @JsonSerialize(using = ToStringSerializer.class) + private Long id; + + /** + * 抢险队伍id + */ + @TableField(value = "team_id") + @Schema(description="抢险队伍id") + @JsonSerialize(using = ToStringSerializer.class) + private Long teamId; + + /** + * 文件id + */ + @TableField(value = "file_id") + @Schema(description="文件id") + @JsonSerialize(using = ToStringSerializer.class) + private Long fileId; + + /** + * 序号 + */ + @TableField(value = "sort_on") + @Schema(description="序号") + private Integer sortOn; + + /** + * 时间戳 + */ + @TableField(value = "tm") + @Schema(description="时间戳") + @NotNull(message = "时间戳不能为空") + private Date tm; + + private static final long serialVersionUID = 1L; + + public static final String COL_ID = "id"; + + public static final String COL_TEAM_ID = "team_id"; + + public static final String COL_FILE_ID = "file_id"; + + public static final String COL_SORT_ON = "sort_on"; + + public static final String COL_TM = "tm"; +} \ No newline at end of file diff --git a/src/main/java/com/gunshi/project/xyt/service/RescueTeamService.java b/src/main/java/com/gunshi/project/xyt/service/RescueTeamService.java new file mode 100644 index 0000000..6b1f1f0 --- /dev/null +++ b/src/main/java/com/gunshi/project/xyt/service/RescueTeamService.java @@ -0,0 +1,138 @@ +package com.gunshi.project.xyt.service; + +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.IdWorker; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.gunshi.project.xyt.entity.so.RescueTeamPageSo; +import com.gunshi.project.xyt.entity.vo.RescueTeamVo; +import com.gunshi.project.xyt.mapper.RescueTeamFileMapper; +import com.gunshi.project.xyt.mapper.RescueTeamMapper; +import com.gunshi.project.xyt.model.RescueTeamB; +import com.gunshi.project.xyt.model.RescueTeamDetail; +import com.gunshi.project.xyt.model.RescueTeamFile; +import com.gunshi.project.xyt.model.RescueTeamFileAutoDao; +import jakarta.annotation.Resource; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.CollectionUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Description: + * Created by wanyan on 2024/3/18 + * + * @author wanyan + * @version 1.0 + */ +@Service +@Slf4j +@Transactional(rollbackFor = Exception.class) +public class RescueTeamService extends AbstractModelWithAttachService{ + @Autowired + private com.gunshi.project.xyt.model.RescueTeamBAutoDao autoDao; + + @Autowired + private RescueTeamFileAutoDao attachFileAutoDao; + + + @Resource + private RescueTeamMapper rescueTeamMapper; + + @Resource + private RescueTeamFileMapper rescueTeamFileMapper; + + @Resource + private com.gunshi.project.xyt.model.RescueTeamDetailAutoDao detailAutoDao; + + public Page pageQuery(RescueTeamPageSo rescueTeamPageSo) { + return rescueTeamMapper.pageQuery(rescueTeamPageSo.getPageSo().toPage(),rescueTeamPageSo); + } + + public RescueTeamB detail(Long teamId) { + RescueTeamB team = rescueTeamMapper.selectById(teamId); + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); + queryWrapper.eq(RescueTeamDetail::getTeamId, teamId); + team.setDetails(detailAutoDao.list(queryWrapper)); + + team.setFiles(rescueTeamFileMapper.queryFiles(teamId)); + + return team; + } + + public void saveDetailAndObj(RescueTeamB model, long teamId) { + List details = model.getDetails(); + if(CollectionUtils.isNotEmpty(details)){ + detailAutoDao.saveBatch(details.stream().map(o->{ + o.setDetailId(IdWorker.getId()); + o.setTeamId(teamId); + return o; + }).collect(Collectors.toList())); + } + } + + public void updateDetailAndObj(RescueTeamB model) { + //根据teamId删除队伍明细和服务对象 + Long teamId = model.getTeamId(); + deleteDetailAndObj(teamId); + saveDetailAndObj(model,teamId); + } + + private void deleteDetailAndObj(Long teamId){ + LambdaQueryWrapper queryWrapper = Wrappers.lambdaQuery(); + queryWrapper.eq(RescueTeamDetail::getTeamId,teamId); + detailAutoDao.remove(queryWrapper); + + } + + public Boolean delete(Long teamId) { + deleteDetailAndObj(teamId); + rescueTeamFileMapper.delete(new LambdaUpdateWrapper() + .eq(RescueTeamFile::getTeamId,teamId)); + int i = rescueTeamMapper.deleteById(teamId); + return i > 0 ; + } + + @Override + com.gunshi.project.xyt.model.RescueTeamBAutoDao getAutoDao() { + return autoDao; + } + + @Override + RescueTeamFileAutoDao getAttachFileAutoDao() { + return attachFileAutoDao; + } + + @Override + List createAttachList(RescueTeamB RescueTeamB) { + List fileIds = RescueTeamB.getFileIds(); + if (fileIds == null) return null; + List attachList = new ArrayList<>(); + for (String fileId : fileIds) { + RescueTeamFile attach = new RescueTeamFile(); + attach.setFileId(Long.valueOf(fileId)); + attach.setTeamId(RescueTeamB.getTeamId()); + attach.setTm(new Date()); + attach.setId(IdWorker.getId()); + attachList.add(attach); + } + return attachList; + } + + @Override + Object getModelId(RescueTeamB rescueTeamB) { + return rescueTeamB.getTeamId(); + } + + @Override + public String getAttachBzIdName() { + return "team_id"; + } +} diff --git a/src/main/resources/application-gs.yml b/src/main/resources/application-gs.yml deleted file mode 100644 index ec3a139..0000000 --- a/src/main/resources/application-gs.yml +++ /dev/null @@ -1,5 +0,0 @@ -spring: - config: - import: - - config-common.yml - - config-gs.yml \ No newline at end of file diff --git a/src/main/resources/config-common.yml b/src/main/resources/config-common.yml index 5daea55..817111e 100644 --- a/src/main/resources/config-common.yml +++ b/src/main/resources/config-common.yml @@ -1,7 +1,7 @@ server: port: 24105 servlet: - context-path: /api + context-path: /gunshiApp/xyt mybatis-plus: configuration: @@ -17,7 +17,7 @@ spring: max-request-size: 100MB gunshi: core: - appName: project-xf-flood + appName: project-xyt file: key: test.by_lyf.tmp secret: xPXPAb63FphkGkPU0ZZkNIXmDzjDVeF3PBH6ZEKw diff --git a/src/main/resources/config-dev.yml b/src/main/resources/config-dev.yml index 1317cc9..ef61ab7 100644 --- a/src/main/resources/config-dev.yml +++ b/src/main/resources/config-dev.yml @@ -2,13 +2,21 @@ spring: profiles: active: dev datasource: - url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan - username: gunshiiot - password: 1234567a - driver-class-name: org.postgresql.Driver + dynamic: + datasource: + master: + url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan + username: gunshiiot + password: 1234567a + driver-class-name: org.postgresql.Driver + access-logging: + url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan + username: gunshiiot + password: 1234567a + driver-class-name: org.postgresql.Driver data: redis: - host: 36.133.116.124 + host: 10.0.41.112 port: 6379 password: 1234567a database: 4 diff --git a/src/main/resources/config-gs.yml b/src/main/resources/config-gs.yml deleted file mode 100644 index 4590f11..0000000 --- a/src/main/resources/config-gs.yml +++ /dev/null @@ -1,12 +0,0 @@ -spring: - profiles: - active: gs - datasource: - url: jdbc:postgresql://10.0.41.112:5432/xintankou - username: gunshiiot - password: 1234567a - driver-class-name: org.postgresql.Driver - -mybatis-plus: - configuration: - log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file diff --git a/src/main/resources/config-prod.yml b/src/main/resources/config-prod.yml index a0b3eb7..e50721b 100644 --- a/src/main/resources/config-prod.yml +++ b/src/main/resources/config-prod.yml @@ -2,11 +2,24 @@ spring: profiles: active: prod datasource: - url: jdbc:postgresql://127.0.0.1:15432/postgres - username: postgres - password: QWEasd123 - driver-class-name: org.postgresql.Driver - + dynamic: + datasource: + master: + url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan + username: gunshiiot + password: 1234567a + driver-class-name: org.postgresql.Driver + access-logging: + url: jdbc:postgresql://10.0.41.112:5432/xiaoyutan + username: gunshiiot + password: 1234567a + driver-class-name: org.postgresql.Driver + data: + redis: + host: 36.133.116.124 + port: 6379 + password: 1234567a + database: 4 mybatis-plus: - configuration: - log-impl: org.apache.ibatis.logging.nologging.NoLoggingImpl \ No newline at end of file + configuration: + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl \ No newline at end of file