抢险队伍,抢险物资
parent
fe4aff2c71
commit
40e0c17e72
|
|
@ -85,7 +85,7 @@ public class RescueGoodsBController extends AbstractCommonFileController impleme
|
|||
|
||||
@Override
|
||||
public String getGroupId() {
|
||||
return "RescueGoodsB";
|
||||
return "rescueGoodsB";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -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<RescueTeamB, RescueTeamBAutoMapper, com.gunshi.project.xyt.model.RescueTeamBAutoDao, RescueTeamFile, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao>,
|
||||
ICommonUpdateByIdWithAttach<RescueTeamB, RescueTeamBAutoMapper, com.gunshi.project.xyt.model.RescueTeamBAutoDao, RescueTeamFile, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao>,
|
||||
ICommonDeleteByIdWithAttach<RescueTeamB, RescueTeamBAutoMapper, com.gunshi.project.xyt.model.RescueTeamBAutoDao, RescueTeamFile, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao>,
|
||||
ICommonQueryAttach<RescueTeamFile, Long, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao>
|
||||
{
|
||||
|
||||
@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<RescueTeamB, RescueTeamBAutoMapper, com.gunshi.project.xyt.model.RescueTeamBAutoDao, RescueTeamFile, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao> 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<Page<RescueTeamVo>> pageQuery(@RequestBody @Validated RescueTeamPageSo RescueTeamPageSo) {
|
||||
return R.ok(rescueTeamService.pageQuery(RescueTeamPageSo));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*/
|
||||
@Get(path = "/list", summary = "列表查询")
|
||||
public R<List<RescueTeamB>> list(@Schema(name = "teamName",description = "队伍名称") @RequestParam(name = "teamName",required = false) String teamName) {
|
||||
LambdaQueryWrapper<RescueTeamB> queryWrapper = Wrappers.lambdaQuery();
|
||||
if(StringUtils.isNotEmpty(teamName)){
|
||||
queryWrapper.like(RescueTeamB::getTeamName,teamName);
|
||||
}
|
||||
return R.ok(rescueTeamBAutoMapper.selectList(queryWrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 详情
|
||||
*/
|
||||
@Get(path = "/detail", summary = "详情")
|
||||
public R<RescueTeamB> detail(@Schema(name = "teamId",description = "队伍ID") @RequestParam(name = "teamId") Long teamId) {
|
||||
return R.ok(rescueTeamService.detail(teamId));
|
||||
}
|
||||
|
||||
@Get(path ="/delete/{id}", summary = "删除")
|
||||
public R<Boolean> 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";
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
@ -17,30 +17,16 @@ public interface RescueGoodsMapper extends BaseMapper<RescueGoodsB> {
|
|||
|
||||
@Select("""
|
||||
<script>
|
||||
select
|
||||
<if test = "obj.type == 1">
|
||||
t.*,s.warehouse_name
|
||||
</if>
|
||||
<if test = "obj.type == 2">
|
||||
t.*
|
||||
</if>
|
||||
from public._rescue_goods_b t
|
||||
<if test = "obj.type == 1">
|
||||
left join public._warehouse_b s on t.warehouse_id = s.warehouse_id
|
||||
</if>
|
||||
where t.type = #{obj.type}
|
||||
<if test="obj.code != null and obj.code !=''">
|
||||
and t.code = #{obj.code}
|
||||
</if>
|
||||
select t.*
|
||||
from public.rescue_goods_b t
|
||||
<where>
|
||||
<if test="obj.goodsName != null and obj.goodsName !=''">
|
||||
and t.goods_name LIKE concat('%',#{obj.goodsName},'%')
|
||||
</if>
|
||||
<if test="obj.warehouseId != null">
|
||||
and t.warehouse_id =#{obj.warehouseId}
|
||||
</if>
|
||||
<if test="obj.sortField != null and obj.sortField !=''">
|
||||
order by ${obj.sortField} asc
|
||||
</if>
|
||||
</where>
|
||||
</script>
|
||||
""")
|
||||
Page<RescueGoodsB> pageQuery(@Param("page") Page<RescueGoodsB> page,@Param("obj") RescueGoodsPageSo RescueGoodsPageSo);
|
||||
|
|
|
|||
|
|
@ -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<RescueTeamFile> {
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
select * from public.file_descriptor
|
||||
where file_id in (select file_id from public.rescue_team_file where team_id = #{teamId})
|
||||
</script>
|
||||
""")
|
||||
List<FileDescriptor> queryFiles(@Param("teamId") Long teamId);
|
||||
}
|
||||
|
|
@ -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<RescueTeamB> {
|
||||
|
||||
|
||||
@Select("""
|
||||
<script>
|
||||
with m1 as (
|
||||
select distinct t2.* from public.rescue_team_b t2
|
||||
<where>
|
||||
<if test="obj.teamName != null and obj.teamName !=''">
|
||||
and t2.team_name LIKE concat('%',#{obj.teamName},'%')
|
||||
</if>
|
||||
<if test="obj.dateSo != null and obj.dateSo.start != null">
|
||||
and t2.valid_end_date <![CDATA[>=]]> #{obj.dateSo.start}
|
||||
</if>
|
||||
<if test="obj.dateSo != null and obj.dateSo.end != null">
|
||||
and t2.valid_end_date <![CDATA[<=]]> #{obj.dateSo.end}
|
||||
</if>
|
||||
</where>
|
||||
),
|
||||
m2 as (select team_id,count(team_id) as personCount from rescue_team_detail GROUP BY team_id)
|
||||
select m1.*,m2.personCount,case when m1.valid_end_date <![CDATA[<]]> now() then 0 else 1 end as isValid from m1 left join m2 on m1.team_id = m2.team_id
|
||||
order by m1.register_date desc
|
||||
</script>
|
||||
""")
|
||||
Page<RescueTeamVo> pageQuery(@Param("page") Page<RescueTeamVo> page, @Param("obj") RescueTeamPageSo rescueTeamPageSo);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -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<String> fileIds;
|
||||
|
||||
/**
|
||||
* 仓库名称
|
||||
*/
|
||||
@Schema(description="仓库名称")
|
||||
@TableField(exist = false)
|
||||
private String warehouseName;
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<String> fileIds;
|
||||
|
||||
/**
|
||||
* 文件上传数据
|
||||
*/
|
||||
@Schema(description="文件上传数据")
|
||||
@TableField(exist = false)
|
||||
private List<FileDescriptor> files;
|
||||
|
||||
/**
|
||||
* 队伍明细
|
||||
*/
|
||||
@Schema(description="队伍明细")
|
||||
@TableField(exist = false)
|
||||
private List<RescueTeamDetail> details;
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
||||
}
|
||||
|
|
@ -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";
|
||||
}
|
||||
|
|
@ -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<RescueTeamB, com.gunshi.project.xyt.model.RescueTeamBAutoMapper, com.gunshi.project.xyt.model.RescueTeamBAutoDao, RescueTeamFile, com.gunshi.project.xyt.model.RescueTeamFileAutoMapper, RescueTeamFileAutoDao>{
|
||||
@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<RescueTeamVo> pageQuery(RescueTeamPageSo rescueTeamPageSo) {
|
||||
return rescueTeamMapper.pageQuery(rescueTeamPageSo.getPageSo().toPage(),rescueTeamPageSo);
|
||||
}
|
||||
|
||||
public RescueTeamB detail(Long teamId) {
|
||||
RescueTeamB team = rescueTeamMapper.selectById(teamId);
|
||||
LambdaQueryWrapper<RescueTeamDetail> 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<RescueTeamDetail> 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<RescueTeamDetail> queryWrapper = Wrappers.lambdaQuery();
|
||||
queryWrapper.eq(RescueTeamDetail::getTeamId,teamId);
|
||||
detailAutoDao.remove(queryWrapper);
|
||||
|
||||
}
|
||||
|
||||
public Boolean delete(Long teamId) {
|
||||
deleteDetailAndObj(teamId);
|
||||
rescueTeamFileMapper.delete(new LambdaUpdateWrapper<RescueTeamFile>()
|
||||
.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<RescueTeamFile> createAttachList(RescueTeamB RescueTeamB) {
|
||||
List<String> fileIds = RescueTeamB.getFileIds();
|
||||
if (fileIds == null) return null;
|
||||
List<RescueTeamFile> 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";
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +0,0 @@
|
|||
spring:
|
||||
config:
|
||||
import:
|
||||
- config-common.yml
|
||||
- config-gs.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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -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
|
||||
configuration:
|
||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||
Loading…
Reference in New Issue