提交 f6c35a3b 作者: 涂茂林

feat:事故点

上级 3bbfc8e1
......@@ -67,5 +67,5 @@ public class AlarmType implements Serializable {
@Comment(value = "是否删除")
@Column(nullable = false)
Boolean deleted;
private Boolean deleted;
}
......@@ -35,6 +35,6 @@ public interface LocationFenceRepository
* @param name 围栏名称
* @return 围栏信息
*/
@Query("SELECT f FROM LocationFence f WHERE name like %?1%")
@Query("SELECT f FROM LocationFence f WHERE name like %?1% AND deleted = false")
List<LocationFence> findLikeName(String name);
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.domain.rehearsal;
import com.yiring.app.domain.video.Video;
import com.yiring.common.domain.BasicEntity;
import java.io.Serial;
import java.io.Serializable;
import javax.persistence.*;
import lombok.*;
import lombok.experimental.FieldNameConstants;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Type;
import org.hibernate.annotations.Where;
import org.locationtech.jts.geom.Geometry;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
/**
* @author tml
* @version 1.0
* @date 2022/5/7 10:16
*/
@Getter
@Setter
@ToString
@SuperBuilder(toBuilder = true)
@NoArgsConstructor
@AllArgsConstructor
@FieldNameConstants
@Entity
@Where(clause = "deleted = false")
@Table(name = "BS_ACCIDENT_SPOT")
@Comment("事故点信息")
@EntityListeners(AuditingEntityListener.class)
public class AccidentSpot extends BasicEntity implements Serializable {
@Serial
private static final long serialVersionUID = 3599118033272730887L;
@Comment("事故点名称")
private String name;
@Comment("地图id")
private Long mapId;
@Comment("地图名称")
private String mapName;
@Comment("空间信息")
@Type(type = "jts_geometry")
@Column(columnDefinition = "geometry")
private Geometry geometry;
@Comment("摄像头")
@ManyToOne
@JoinColumn(name = "video_id")
private Video video;
@Comment("超时时间(秒)")
private Integer timeoutDuration;
@Comment("消抖时间(秒)")
private Integer threshold;
@Comment("是否启用")
private Boolean enable;
@Comment(value = "是否删除")
@Column(nullable = false)
private Boolean deleted;
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.domain.rehearsal;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
/**
* @author tml
* @version 1.0
* @date 2022/5/7 10:24
*/
@Repository
public interface AccidentSpotRepository
extends JpaRepository<AccidentSpot, Serializable>, JpaSpecificationExecutor<AccidentSpot> {
/**
* 查询名称是否存在
* @param name 事故点名称
* @return true:存在 false:不存在
*/
Boolean existsByName(String name);
/**
* 根据名称查询所有事故点
* @param name 事故点名称
* @return 事故点信息
*/
List<AccidentSpot> findAllByName(String name);
/**
* 根据名称全模糊查询
* @param name 名称
* @return 事故点信息
*/
@Query("SELECT a FROM AccidentSpot a WHERE name like %?1% AND deleted = false")
List<AccidentSpot> findLikeName(String name);
/**
* 批量启用
* @param ids 事故点id集
* @param now 当前时间
* @return 启用了多少条数据
*/
@Query("UPDATE AccidentSpot SET enable = true,updateTime = :now WHERE id in (:ids) AND deleted = false")
@Modifying
int batchEnable(@Param("ids") Set<Long> ids, @Param("now") LocalDateTime now);
/**
* 批量停用
* @param ids 事故点id集
* @param now 当前时间
* @return 停用了多少条数据
*/
@Query("UPDATE AccidentSpot SET enable = false ,updateTime = :now WHERE id in (:ids) AND deleted = false")
@Modifying
int batchUnEnable(@Param("ids") Set<Long> ids, @Param("now") LocalDateTime now);
}
......@@ -48,7 +48,7 @@ public class LocationFenceModifyParam {
@Range(min = FenceTypeEnum.MIN, max = FenceTypeEnum.MAX, message = "请选择正确的围栏类别")
private Integer fenceType;
@ApiModelProperty(value = "空间信息", example = "1")
@ApiModelProperty(value = "空间信息")
private Geometry geometry;
@ApiModelProperty(value = "滞留时间(秒)", example = "1")
......
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.param.rehearsal;
import com.yiring.app.domain.rehearsal.AccidentSpot;
import com.yiring.app.domain.video.Video;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serial;
import java.io.Serializable;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.locationtech.jts.geom.Geometry;
/**
* @author tml
* @version 1.0
* @date 2022/5/7 10:59
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("添加事故点参数")
public class AccidentSpotAddParam implements Serializable {
@Serial
private static final long serialVersionUID = 5678801405341645678L;
@ApiModelProperty(value = "事故点名称", example = "事故点1", required = true)
@NotEmpty(message = "事故点名称不能为空")
private String name;
@ApiModelProperty(value = "地图id", example = "1", required = true)
@NotNull(message = "地图id不能为空")
private Long mapId;
@ApiModelProperty(value = "地图名称", example = "总图", required = true)
@NotEmpty(message = "地图名称不能为空")
private String mapName;
@ApiModelProperty(value = "空间信息")
@NotNull(message = "空间信息不能为空")
private Geometry geometry;
@ApiModelProperty(value = "摄像头id", example = "1")
private Long videoId;
@ApiModelProperty(value = "超时时间(秒)", example = "100", required = true)
@NotNull(message = "超市时间不能为空")
private Integer timeoutDuration;
@ApiModelProperty(value = "消抖时间(秒)", example = "100", required = true)
@NotNull(message = "消抖时间不能为空")
private Integer threshold;
public AccidentSpot transform() {
Video video = Video.builder().id(videoId).build();
return AccidentSpot
.builder()
.name(name)
.mapId(mapId)
.mapName(mapName)
.geometry(geometry)
.video(video)
.timeoutDuration(timeoutDuration)
.threshold(threshold)
.enable(false)
.deleted(false)
.build();
}
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.param.rehearsal;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serial;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author tml
* @version 1.0
* @date 2022/5/7 10:48
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
@ApiModel("事故点查询条件")
public class AccidentSpotConditionParam implements Serializable {
@Serial
private static final long serialVersionUID = 3434244613930014725L;
@ApiModelProperty(value = "事故点名称", example = "工作区域")
private String name;
@ApiModelProperty(value = "地图id", example = "1", required = true)
@NotNull(message = "请选择一个地图")
private Long mapId;
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.param.rehearsal;
import com.yiring.app.domain.rehearsal.AccidentSpot;
import com.yiring.app.domain.video.Video;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serial;
import java.io.Serializable;
import javax.validation.constraints.NotNull;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.locationtech.jts.geom.Geometry;
/**
* @author tml
* @version 1.0
* @date 2022/5/7 10:59
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("添加事故点参数")
public class AccidentSpotModifyParam implements Serializable {
@Serial
private static final long serialVersionUID = 5678801405341645678L;
@ApiModelProperty(value = "事故点id", example = "1", required = true)
@NotNull(message = "请选择一个事故点id")
private Long id;
@ApiModelProperty(value = "事故点名称", example = "事故点1", required = true)
private String name;
@ApiModelProperty(value = "地图id", example = "1", required = true)
private Long mapId;
@ApiModelProperty(value = "地图名称", example = "总图", required = true)
private String mapName;
@ApiModelProperty(value = "空间信息")
private Geometry geometry;
@ApiModelProperty(value = "摄像头id", example = "1")
private Long videoId;
@ApiModelProperty(value = "超时时间(秒)", example = "100", required = true)
private Integer timeoutDuration;
@ApiModelProperty(value = "消抖时间(秒)", example = "100", required = true)
private Integer threshold;
public AccidentSpot transform() {
Video video = Video.builder().id(videoId).build();
return AccidentSpot
.builder()
.id(id)
.name(name)
.mapId(mapId)
.mapName(mapName)
.geometry(geometry)
.video(video)
.timeoutDuration(timeoutDuration)
.threshold(threshold)
.enable(false)
.deleted(false)
.build();
}
}
......@@ -4,6 +4,7 @@ package com.yiring.app.service.location.fence;
import com.yiring.app.param.location.fence.LocationFenceAddParam;
import com.yiring.app.param.location.fence.LocationFenceConditionParam;
import com.yiring.app.param.location.fence.LocationFenceModifyParam;
import com.yiring.app.vo.CodeNameVo;
import com.yiring.app.vo.location.fence.LocationFenceSearchVo;
import com.yiring.app.vo.location.fence.LocationFenceVo;
import com.yiring.common.core.Result;
......@@ -60,4 +61,10 @@ public interface LocationFenceService {
* @return 围栏信息
*/
Result<PageVo<LocationFenceSearchVo>> findByNameLike(String name);
/**
* 获取地图下拉框
* @return 地图下拉框
*/
Result<PageVo<CodeNameVo>> findMapList();
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.service.location.fence.impl;
import com.alibaba.fastjson.JSONArray;
import com.yiring.app.constant.RedisKey;
import com.yiring.app.domain.location.LocationFence;
import com.yiring.app.domain.location.LocationFenceRepository;
import com.yiring.app.param.location.fence.LocationFenceAddParam;
......@@ -8,8 +10,11 @@ import com.yiring.app.param.location.fence.LocationFenceConditionParam;
import com.yiring.app.param.location.fence.LocationFenceModifyParam;
import com.yiring.app.service.location.fence.LocationFenceService;
import com.yiring.app.util.JpaUtil;
import com.yiring.app.vo.CodeNameVo;
import com.yiring.app.vo.location.fence.LocationFenceSearchVo;
import com.yiring.app.vo.location.fence.LocationFenceVo;
import com.yiring.app.vo.map.MapVo;
import com.yiring.common.core.Redis;
import com.yiring.common.core.Result;
import com.yiring.common.core.Status;
import com.yiring.common.param.IdParam;
......@@ -42,6 +47,9 @@ public class LocationFenceServiceImpl implements LocationFenceService {
@Resource
private LocationFenceRepository locationFenceRepository;
@Resource
private Redis redis;
@Override
public Result<String> addLocationFence(LocationFenceAddParam param) {
Boolean exists = locationFenceRepository.existsByName(param.getName());
......@@ -129,4 +137,17 @@ public class LocationFenceServiceImpl implements LocationFenceService {
PageVo<LocationFenceSearchVo> pageVo = PageVo.build(voList, voList.size());
return Result.ok(pageVo);
}
@Override
public Result<PageVo<CodeNameVo>> findMapList() {
Object map = redis.get(RedisKey.ZY_MAP_AREAS);
String mapString = JSONArray.toJSONString(map);
List<MapVo.MapVoReuslt> mapVo = JSONArray.parseArray(mapString, MapVo.MapVoReuslt.class);
List<CodeNameVo> voList = mapVo
.stream()
.map(e -> new CodeNameVo(e.getId(), e.getName()))
.collect(Collectors.toList());
PageVo<CodeNameVo> pageVo = PageVo.build(voList, voList.size());
return Result.ok(pageVo);
}
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.service.rehearsal;
import com.yiring.app.param.rehearsal.AccidentSpotAddParam;
import com.yiring.app.param.rehearsal.AccidentSpotConditionParam;
import com.yiring.app.param.rehearsal.AccidentSpotModifyParam;
import com.yiring.app.vo.IdNameVo;
import com.yiring.app.vo.rehearsal.AccidentSpotVo;
import com.yiring.common.core.Result;
import com.yiring.common.param.IdParam;
import com.yiring.common.param.PageParam;
import com.yiring.common.vo.PageVo;
import java.util.Set;
/**
* @author tml
* @version 1.0
* @date 2022/5/7 13:45
*/
public interface AccidentSpotService {
/**
* 添加一个事故点
* @param param 事故点信息
* @return 是否成功
*/
Result<String> addAccidentSpot(AccidentSpotAddParam param);
/**
* 修改一个事故点
* @param param 事故点信息
* @return 是否成功
*/
Result<String> modifyAccidentSpot(AccidentSpotModifyParam param);
/**
* 删除一个事故点
* @param param id
* @return 是否成功
*/
Result<String> removeAccidentSpot(IdParam param);
/**
* 根据id查询事故点信息
* @param param id
* @return 事故点信息
*/
Result<AccidentSpotVo> findById(IdParam param);
/**
* 根据条件查询事故点
* @param conditionParam 条件参数
* @param pageParam 分页参数
* @return 事故点信息
*/
Result<PageVo<AccidentSpotVo>> findByCondition(AccidentSpotConditionParam conditionParam, PageParam pageParam);
/**
* 模糊事故点下拉框
* @param name 事故点名称
* @return 事故点列表
*/
Result<PageVo<IdNameVo>> findAccidentList(String name);
/**
* 批量启用事故点
* @param ids 事故点id集
* @return 是否成功
*/
Result<String> batchEnable(Set<Long> ids);
/**
* 批量停用事故点
* @param ids 事故点集
* @return 是否成功
*/
Result<String> batchUnEnable(Set<Long> ids);
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.service.rehearsal.impl;
import com.yiring.app.domain.rehearsal.AccidentSpot;
import com.yiring.app.domain.rehearsal.AccidentSpotRepository;
import com.yiring.app.param.rehearsal.AccidentSpotAddParam;
import com.yiring.app.param.rehearsal.AccidentSpotConditionParam;
import com.yiring.app.param.rehearsal.AccidentSpotModifyParam;
import com.yiring.app.service.rehearsal.AccidentSpotService;
import com.yiring.app.util.JpaUtil;
import com.yiring.app.vo.IdNameVo;
import com.yiring.app.vo.rehearsal.AccidentSpotVo;
import com.yiring.common.core.Result;
import com.yiring.common.core.Status;
import com.yiring.common.param.IdParam;
import com.yiring.common.param.PageParam;
import com.yiring.common.vo.PageVo;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.persistence.criteria.Predicate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* @author tml
* @version 1.0
* @date 2022/5/7 14:02
*/
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class AccidentSpotServiceImpl implements AccidentSpotService {
@Resource
private AccidentSpotRepository accidentSpotRepository;
@Override
public Result<String> addAccidentSpot(AccidentSpotAddParam param) {
Boolean exists = accidentSpotRepository.existsByName(param.getName());
if (exists) {
return Result.no(Status.EXPECTATION_FAILED, "事故点名称已被占用");
}
AccidentSpot accidentSpot = param.transform();
accidentSpotRepository.saveAndFlush(accidentSpot);
return Result.ok();
}
@Override
public Result<String> modifyAccidentSpot(AccidentSpotModifyParam param) {
List<AccidentSpot> allByName = accidentSpotRepository.findAllByName(param.getName());
if (allByName.size() > 1) {
log.warn("AccidentSpotServiceImpl.modifyAccidentSpot时查询出两条事故点名称相同的数据,param:[{}]", param);
}
AccidentSpot accidentSpot = null;
for (AccidentSpot item : allByName) {
if (item.getId().equals(param.getId())) {
accidentSpot = item;
} else {
return Result.no(Status.EXPECTATION_FAILED, "事故点名称已被占用");
}
}
if (accidentSpot == null) {
Optional<AccidentSpot> optional = accidentSpotRepository.findById(param.getId());
if (optional.isEmpty()) {
return Result.no(Status.EXPECTATION_FAILED, "要修改的事故点不存在");
}
accidentSpot = optional.get();
}
JpaUtil.copyNotNullProperties(param, accidentSpot);
return Result.ok();
}
@Override
public Result<String> removeAccidentSpot(IdParam param) {
Optional<AccidentSpot> optional = accidentSpotRepository.findById(param.getId());
if (optional.isEmpty()) {
return Result.no(Status.EXPECTATION_FAILED, "要修改的事故点不存在");
}
optional.get().setDeleted(true);
return Result.ok();
}
@Override
public Result<AccidentSpotVo> findById(IdParam param) {
Optional<AccidentSpot> optional = accidentSpotRepository.findById(param.getId());
if (optional.isEmpty()) {
return Result.no(Status.EXPECTATION_FAILED, "要修改的事故点不存在");
}
AccidentSpotVo vo = AccidentSpotVo.transform(optional.get());
return Result.ok(vo);
}
@Override
public Result<PageVo<AccidentSpotVo>> findByCondition(
AccidentSpotConditionParam conditionParam,
PageParam pageParam
) {
Pageable pageable = PageParam.toPageable(pageParam);
Specification<AccidentSpot> specification = (root, query, criteriaBuilder) -> {
ArrayList<Predicate> list = new ArrayList<>();
if (conditionParam.getMapId() != null) {
list.add(criteriaBuilder.equal(root.get(AccidentSpot.Fields.mapId), conditionParam.getMapId()));
}
if (conditionParam.getName() != null) {
list.add(
criteriaBuilder.like(root.get(AccidentSpot.Fields.name), "%" + conditionParam.getName() + "%")
);
}
Predicate[] array = list.toArray(new Predicate[0]);
return criteriaBuilder.and(array);
};
Page<AccidentSpot> page = accidentSpotRepository.findAll(specification, pageable);
List<AccidentSpotVo> voList = page.get().map(AccidentSpotVo::transform).collect(Collectors.toList());
PageVo<AccidentSpotVo> pageVo = PageVo.build(voList, voList.size());
return Result.ok(pageVo);
}
@Override
public Result<PageVo<IdNameVo>> findAccidentList(String name) {
List<AccidentSpot> list = accidentSpotRepository.findLikeName(name);
List<IdNameVo> voList = list
.stream()
.map(e -> new IdNameVo(e.getId(), e.getName()))
.collect(Collectors.toList());
PageVo<IdNameVo> pageVo = PageVo.build(voList, voList.size());
return Result.ok(pageVo);
}
@Override
public Result<String> batchEnable(Set<Long> ids) {
int num = accidentSpotRepository.batchEnable(ids, LocalDateTime.now());
return Result.ok("启用了" + num + "个事故点");
}
@Override
public Result<String> batchUnEnable(Set<Long> ids) {
int num = accidentSpotRepository.batchUnEnable(ids, LocalDateTime.now());
return Result.ok("停用了" + num + "个事故点");
}
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.vo.rehearsal;
import com.yiring.app.domain.rehearsal.AccidentSpot;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import java.io.Serial;
import java.io.Serializable;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.locationtech.jts.geom.Geometry;
/**
* @author tml
* @version 1.0
* @date 2022/5/7 11:25
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@ApiModel("事故点VO")
public class AccidentSpotVo implements Serializable {
@Serial
private static final long serialVersionUID = -7696351020089245510L;
@ApiModelProperty(value = "事故点id", example = "1")
private Long id;
@ApiModelProperty(value = "事故点名称", example = "事故点1")
private String name;
@ApiModelProperty(value = "地图id", example = "1")
private Long mapId;
@ApiModelProperty(value = "地图名称", example = "总图")
private String mapName;
@ApiModelProperty(value = "空间信息")
private Geometry geometry;
@ApiModelProperty(value = "摄像头id", example = "1")
private Long videoId;
@ApiModelProperty(value = "摄像头名称", example = "摄像头1")
private String videoName;
@ApiModelProperty(value = "超时时间(秒)", example = "100")
private Integer timeoutDuration;
@ApiModelProperty(value = "消抖时间(秒)", example = "100")
private Integer threshold;
@ApiModelProperty(value = "是否启用(true:启用,false:停用)", example = "true")
private Boolean enable;
public static AccidentSpotVo transform(AccidentSpot accidentSpot) {
return AccidentSpotVo
.builder()
.id(accidentSpot.getId())
.name(accidentSpot.getName())
.mapId(accidentSpot.getMapId())
.mapName(accidentSpot.getMapName())
.geometry(accidentSpot.getGeometry())
.videoId(accidentSpot.getVideo().getId())
.videoName(accidentSpot.getVideo().getVideoName())
.timeoutDuration(accidentSpot.getTimeoutDuration())
.threshold(accidentSpot.getThreshold())
.enable(accidentSpot.getEnable())
.build();
}
}
......@@ -6,6 +6,7 @@ import com.yiring.app.param.location.fence.LocationFenceAddParam;
import com.yiring.app.param.location.fence.LocationFenceConditionParam;
import com.yiring.app.param.location.fence.LocationFenceModifyParam;
import com.yiring.app.service.location.fence.LocationFenceService;
import com.yiring.app.vo.CodeNameVo;
import com.yiring.app.vo.location.fence.LocationFenceSearchVo;
import com.yiring.app.vo.location.fence.LocationFenceVo;
import com.yiring.common.core.Result;
......@@ -21,7 +22,10 @@ import javax.validation.Valid;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Sort;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
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;
/**
* @author tml
......@@ -84,4 +88,10 @@ public class LocationFenceController {
}
return locationFenceService.findByNameLike(name);
}
@ApiOperation("获取地图下拉框")
@PostMapping("/findMapList")
public Result<PageVo<CodeNameVo>> findMapList() {
return locationFenceService.findMapList();
}
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.app.web.rehearsal;
import com.yiring.app.param.rehearsal.AccidentSpotAddParam;
import com.yiring.app.param.rehearsal.AccidentSpotConditionParam;
import com.yiring.app.param.rehearsal.AccidentSpotModifyParam;
import com.yiring.app.service.rehearsal.AccidentSpotService;
import com.yiring.app.vo.IdNameVo;
import com.yiring.app.vo.rehearsal.AccidentSpotVo;
import com.yiring.common.core.Result;
import com.yiring.common.domain.BasicEntity;
import com.yiring.common.param.IdParam;
import com.yiring.common.param.PageParam;
import com.yiring.common.vo.PageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Resource;
import javax.validation.Valid;
import javax.validation.constraints.NotEmpty;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Sort;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
/**
* @author tml
* @version 1.0
* @date 2022/5/7 10:44
*/
@Slf4j
@Validated
@RestController
@Api(tags = "AccidentSpot(事故点管理)")
@RequestMapping("/accident/spot")
public class AccidentSpotController {
@Resource
private AccidentSpotService accidentSpotService;
@ApiOperation(value = "添加一个事故点")
@PostMapping("/addAccidentSpot")
public Result<String> addAccidentSpot(@Valid @RequestBody AccidentSpotAddParam param) {
return accidentSpotService.addAccidentSpot(param);
}
@ApiOperation("修改一个事故点")
@PostMapping("/modifyAccidentSpot")
public Result<String> modifyAccidentSpot(@Valid @RequestBody AccidentSpotModifyParam param) {
return accidentSpotService.modifyAccidentSpot(param);
}
@ApiOperation("删除一个事故点")
@PostMapping("/removeAccidentSpot")
public Result<String> removeAccidentSpot(@Valid IdParam param) {
return accidentSpotService.removeAccidentSpot(param);
}
@ApiOperation("根据id查询事故点")
@GetMapping("/findById")
public Result<AccidentSpotVo> findById(@Valid IdParam param) {
return accidentSpotService.findById(param);
}
@ApiOperation("根据条件查询事故点")
@GetMapping("/findByCondition")
public Result<PageVo<AccidentSpotVo>> findByCondition(
@Valid AccidentSpotConditionParam conditionParam,
@Valid PageParam pageParam
) {
if (Objects.isNull(pageParam.getSortField())) {
pageParam.setSortField(BasicEntity.Fields.createTime);
pageParam.setSortOrder(Sort.Direction.DESC);
}
return accidentSpotService.findByCondition(conditionParam, pageParam);
}
@ApiOperation("事故点名下拉框")
@ApiImplicitParam(value = "事故点名(全模糊)", name = "name", example = "事故", required = true)
@GetMapping("/findAccidentList")
public Result<PageVo<IdNameVo>> findAccidentList(String name) {
if (name == null) {
name = "";
}
return accidentSpotService.findAccidentList(name);
}
@ApiOperation("批量启用")
@ApiImplicitParam(value = "事故点id集", example = "1,2,3", name = "ids")
@GetMapping("/batchEnable")
public Result<String> batchEnable(
@RequestParam(value = "ids", required = false) @NotEmpty(message = "请传入至少一个事故点") Set<Long> ids
) {
return accidentSpotService.batchEnable(ids);
}
@ApiOperation("批量停用")
@ApiImplicitParam(value = "事故点id集", example = "1,2,3", name = "ids")
@GetMapping("/batchUnEnable")
public Result<String> batchUnEnable(
@RequestParam(value = "ids", required = false) @NotEmpty(message = "请传入至少一个事故点") Set<Long> ids
) {
return accidentSpotService.batchUnEnable(ids);
}
}
......@@ -17,10 +17,17 @@ dependencies {
// JTS 几何对象操作库
implementation "org.locationtech.jts:jts-core:${jtsVersion}"
// https://mvnrepository.com/artifact/com.graphhopper.external/jackson-datatype-jts
/*// https://mvnrepository.com/artifact/com.graphhopper.external/jackson-datatype-jts
implementation("com.graphhopper.external:jackson-datatype-jts:1.0-2.7") {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
exclude group: 'org.locationtech.jts', module: 'jts-core'
}*/
// https://mvnrepository.com/artifact/com.graphhopper.external/jackson-datatype-jts
implementation("org.n52.jackson:jackson-datatype-jts:1.2.10") {
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-databind'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-annotations'
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
exclude group: 'org.locationtech.jts', module: 'jts-core'
}
}
/* (C) 2022 YiRing, Inc. */
package com.yiring.common.config;
import com.bedatadriven.jackson.datatype.jts.JtsModule;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import javax.annotation.Resource;
import org.n52.jackson.datatype.jts.JtsModule;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论