init
This commit is contained in:
@@ -0,0 +1,67 @@
|
||||
package com.newyetai.recruit.device.controller;
|
||||
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
|
||||
import com.newyetai.common.AlitaResult;
|
||||
import com.newyetai.tkmybatis.pojo.Page;
|
||||
import com.newyetai.recruit.device.dto.*;
|
||||
import com.newyetai.recruit.device.service.DeviceService;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@Api(tags = "设备")
|
||||
@RestController
|
||||
@RequestMapping("/device/")
|
||||
public class DeviceController {
|
||||
|
||||
@Autowired
|
||||
private DeviceService deviceService;
|
||||
|
||||
@PostMapping("create")
|
||||
@ApiOperation("设备-创建")
|
||||
public AlitaResult<DeviceDTO> create(@RequestBody @Validated DeviceOperatorDTO operatorDTO) {
|
||||
return AlitaResult.success(deviceService.create(operatorDTO));
|
||||
}
|
||||
|
||||
@PutMapping("modify")
|
||||
@ApiOperation("设备-修改")
|
||||
public AlitaResult<DeviceDTO> modify(@RequestBody DeviceOperatorDTO operatorDTO) {
|
||||
return AlitaResult.success(deviceService.modify(operatorDTO));
|
||||
}
|
||||
|
||||
@DeleteMapping("{id}")
|
||||
@ApiOperation("设备-删除")
|
||||
public AlitaResult<DeviceDTO> delete(@PathVariable("id") Long id) {
|
||||
return AlitaResult.success(deviceService.delete(id));
|
||||
}
|
||||
|
||||
@GetMapping("{id}")
|
||||
@ApiOperation("设备-查询单个")
|
||||
public AlitaResult<DeviceDTO> findById(@PathVariable("id") Long id) {
|
||||
return AlitaResult.success(deviceService.findById(id));
|
||||
}
|
||||
|
||||
@GetMapping("list")
|
||||
@ApiOperation("设备-列表查询")
|
||||
public AlitaResult<List<DeviceDTO>> list(DeviceQueryDTO queryDTO) {
|
||||
return AlitaResult.success(deviceService.list(queryDTO));
|
||||
}
|
||||
|
||||
@GetMapping("page")
|
||||
@ApiOperation("设备-分页查询")
|
||||
public AlitaResult<Page<DeviceDTO>> page(DevicePageQueryDTO queryDTO) {
|
||||
deviceService.page(queryDTO);
|
||||
return AlitaResult.success(queryDTO.getPageResult());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.newyetai.recruit.device.convert;
|
||||
|
||||
import com.newyetai.recruit.device.entity.Device;
|
||||
import com.newyetai.recruit.device.dto.DeviceDTO;
|
||||
import com.newyetai.recruit.device.dto.DeviceOperatorDTO;
|
||||
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceConvert {
|
||||
DeviceConvert INSTANCE = Mappers.getMapper(DeviceConvert.class);
|
||||
|
||||
Device convert(DeviceDTO dto);
|
||||
|
||||
DeviceDTO convert(Device entity);
|
||||
|
||||
Device convert(DeviceOperatorDTO dto);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.newyetai.recruit.device.dao;
|
||||
|
||||
import com.newyetai.tkmybatis.mybatis.MyMapper;
|
||||
import com.newyetai.recruit.device.entity.Device;
|
||||
import com.newyetai.recruit.device.dto.DeviceDTO;
|
||||
import com.newyetai.recruit.device.dto.DeviceQueryDTO;
|
||||
import com.newyetai.recruit.device.dto.DevicePageQueryDTO;
|
||||
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@Mapper
|
||||
public interface DeviceMapper extends MyMapper<Device> {
|
||||
|
||||
List<DeviceDTO> page(@Param("param") DevicePageQueryDTO queryDTO);
|
||||
|
||||
List<DeviceDTO> list(@Param("param") DeviceQueryDTO queryDTO);
|
||||
}
|
||||
38
src/main/java/com/newyetai/recruit/device/dto/DeviceDTO.java
Normal file
38
src/main/java/com/newyetai/recruit/device/dto/DeviceDTO.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package com.newyetai.recruit.device.dto;
|
||||
|
||||
import com.newyetai.common.dto.BaseDTO;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@ApiModel("设备")
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DeviceDTO extends BaseDTO {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("编号")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("场所地址")
|
||||
private String address;
|
||||
|
||||
private String geocoderJson;
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.newyetai.recruit.device.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@ApiModel("设备")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceOperatorDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
@Length(max = 128,message = "编号长度超长")
|
||||
@NotBlank(message = "请输入编号")
|
||||
@ApiModelProperty("编号")
|
||||
private String code;
|
||||
|
||||
@Length(max = 64,message = "名称长度超长")
|
||||
@NotBlank(message = "请输入名称")
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@Length(max = 255,message = "场所地址长度超长")
|
||||
@NotBlank(message = "请输入场所地址")
|
||||
@ApiModelProperty("场所地址")
|
||||
private String address;
|
||||
|
||||
private String geocoderJson;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.newyetai.recruit.device.dto;
|
||||
|
||||
import com.newyetai.common.dto.PageQueryDTO;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.*;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
|
||||
@ApiModel("设备")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class DevicePageQueryDTO extends PageQueryDTO<DeviceDTO> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long notId;
|
||||
|
||||
@ApiModelProperty("编号")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("名称 (模糊匹配)")
|
||||
private String nameLike;
|
||||
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("场所地址")
|
||||
private String address;
|
||||
|
||||
private String addressLike;
|
||||
|
||||
private String geocoderJson;
|
||||
|
||||
@ApiModelProperty("创建时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTimeStart;
|
||||
|
||||
@ApiModelProperty("创建时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTimeEnd;
|
||||
|
||||
@ApiModelProperty("更新时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTimeStart;
|
||||
|
||||
@ApiModelProperty("更新时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTimeEnd;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.newyetai.recruit.device.dto;
|
||||
|
||||
import com.newyetai.common.dto.BaseDTO;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@ApiModel("设备")
|
||||
@Data
|
||||
@Builder
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class DeviceQueryDTO implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long id;
|
||||
|
||||
private Long notId;
|
||||
|
||||
@ApiModelProperty("编号")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("名称 (模糊匹配)")
|
||||
private String nameLike;
|
||||
|
||||
@ApiModelProperty("场所地址")
|
||||
private String address;
|
||||
|
||||
private String addressLike;
|
||||
|
||||
private String geocoderJson;
|
||||
|
||||
@ApiModelProperty("创建时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTimeStart;
|
||||
|
||||
@ApiModelProperty("创建时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date createTimeEnd;
|
||||
|
||||
@ApiModelProperty("更新时间起,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTimeStart;
|
||||
|
||||
@ApiModelProperty("更新时间止,格式 (yyyy-MM-dd HH:mm:ss)")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
|
||||
private Date updateTimeEnd;
|
||||
|
||||
|
||||
}
|
||||
37
src/main/java/com/newyetai/recruit/device/entity/Device.java
Normal file
37
src/main/java/com/newyetai/recruit/device/entity/Device.java
Normal file
@@ -0,0 +1,37 @@
|
||||
package com.newyetai.recruit.device.entity;
|
||||
|
||||
import lombok.*;
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import java.math.BigDecimal;
|
||||
import com.newyetai.common.entity.BaseEntity;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@TableName(value = "hr_device")
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class Device extends BaseEntity {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
private String code;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 场所地址
|
||||
*/
|
||||
private String address;
|
||||
private String geocoderJson;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.newyetai.recruit.device.dao.DeviceMapper">
|
||||
|
||||
<select id="list" resultType="com.newyetai.recruit.device.dto.DeviceDTO">
|
||||
SELECT t.*
|
||||
<include refid="queryFromSql"></include>
|
||||
</select>
|
||||
|
||||
<select id="page" resultType="com.newyetai.recruit.device.dto.DeviceDTO">
|
||||
SELECT t.*
|
||||
<include refid="queryFromSql"></include>
|
||||
</select>
|
||||
|
||||
<sql id="queryFromSql">
|
||||
FROM
|
||||
hr_device t
|
||||
WHERE t.deleted = 0
|
||||
<if test='param.id != null'>
|
||||
AND t.id = #{param.id}
|
||||
</if>
|
||||
<if test='param.notId != null'>
|
||||
AND t.id <![CDATA[ <> ]]> #{param.notId}
|
||||
</if>
|
||||
<if test='param.code != null and param.code.trim() != ""'>
|
||||
AND t.code = #{param.code}
|
||||
</if>
|
||||
<if test='param.name != null and param.name.trim() != ""'>
|
||||
AND t.name = #{param.name}
|
||||
</if>
|
||||
<if test='param.nameLike != null and param.nameLike.trim() != ""'>
|
||||
<bind name="nameLike" value="'%' + param.nameLike + '%'"/>
|
||||
AND t.name like #{nameLike}
|
||||
</if>
|
||||
<if test='param.address != null and param.address.trim() != ""'>
|
||||
AND t.address = #{param.address}
|
||||
</if>
|
||||
<if test='param.addressLike != null and param.addressLike.trim() != ""'>
|
||||
<bind name="addressLike" value="'%' + param.addressLike + '%'"/>
|
||||
AND t.address like #{addressLike}
|
||||
</if>
|
||||
<if test='param.createTimeStart != null'>
|
||||
AND t.create_time >= #{param.createTimeStart}
|
||||
</if>
|
||||
<if test='param.createTimeEnd != null'>
|
||||
AND t.create_time <= #{param.createTimeEnd}
|
||||
</if>
|
||||
<if test='param.updateTimeStart != null'>
|
||||
AND t.update_time >= #{param.updateTimeStart}
|
||||
</if>
|
||||
<if test='param.updateTimeEnd != null'>
|
||||
AND t.update_time <= #{param.updateTimeEnd}
|
||||
</if>
|
||||
ORDER BY t.id DESC
|
||||
</sql>
|
||||
</mapper>
|
||||
@@ -0,0 +1,68 @@
|
||||
package com.newyetai.recruit.device.service;
|
||||
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.groups.Default;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.newyetai.recruit.device.dto.*;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@Validated(Default.class)
|
||||
public interface DeviceService {
|
||||
|
||||
/**
|
||||
* 设备 - 创建
|
||||
*
|
||||
* @param operatorDto 操作dto
|
||||
* @return {@link DeviceDTO}
|
||||
*/
|
||||
DeviceDTO create(@Valid DeviceOperatorDTO operatorDto);
|
||||
|
||||
/**
|
||||
* 设备 - 修改
|
||||
*
|
||||
* @param operatorDto 操作dto
|
||||
* @return {@link DeviceDTO}
|
||||
*/
|
||||
DeviceDTO modify(@Valid DeviceOperatorDTO operatorDto);
|
||||
|
||||
/**
|
||||
* 设备 - 删除
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link DeviceDTO}
|
||||
*/
|
||||
DeviceDTO delete(Long id);
|
||||
|
||||
/**
|
||||
* 设备 - 根据ID查询单个
|
||||
*
|
||||
* @param id id
|
||||
* @return {@link DeviceDTO}
|
||||
*/
|
||||
DeviceDTO findById(Long id);
|
||||
|
||||
/**
|
||||
* 设备 - 列表查询
|
||||
*
|
||||
* @param queryDTO 列表查询dto
|
||||
* @return {@link List}<{@link DeviceDTO}>
|
||||
*/
|
||||
List<DeviceDTO> list(DeviceQueryDTO queryDTO);
|
||||
|
||||
/**
|
||||
* 设备 - 分页查询
|
||||
*
|
||||
* @param queryDTO 分页查询dto
|
||||
* @return {@link DeviceDTO}
|
||||
*/
|
||||
List<DeviceDTO> page(DevicePageQueryDTO queryDTO);
|
||||
}
|
||||
@@ -0,0 +1,154 @@
|
||||
package com.newyetai.recruit.device.service.impl;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import com.newyetai.common.AlitaResult;
|
||||
import com.newyetai.common.exception.BusinessException;
|
||||
import com.newyetai.common.util.JsonUtils;
|
||||
import com.newyetai.recruit.device.convert.DeviceConvert;
|
||||
import com.newyetai.recruit.device.entity.Device;
|
||||
import com.newyetai.recruit.device.dto.*;
|
||||
import com.newyetai.recruit.device.dao.DeviceMapper;
|
||||
import com.newyetai.recruit.device.service.DeviceService;
|
||||
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.newyetai.common.util.UserContextHolder;
|
||||
import com.newyetai.sdk.tencent.map.TencentMapContext;
|
||||
import com.newyetai.sdk.tencent.map.dto.TencentMapGeocoderReqDTO;
|
||||
import com.newyetai.sdk.tencent.map.dto.TencentMapGeocoderResDTO;
|
||||
import com.newyetai.sdk.tencent.map.dto.TencentMapLocationV1IpResDTO;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*
|
||||
* @author guixinman
|
||||
* @since 1.0.0 2025-01-14
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class DeviceServiceImpl implements DeviceService {
|
||||
|
||||
@Resource
|
||||
private DeviceMapper deviceMapper;
|
||||
|
||||
@Autowired
|
||||
private TencentMapContext tencentMapContext;
|
||||
|
||||
|
||||
@Override
|
||||
public DeviceDTO create(DeviceOperatorDTO operatorDto) {
|
||||
List<DeviceDTO> deviceDTOList = this.list(DeviceQueryDTO.builder().code(operatorDto.getCode()).name(operatorDto.getName()).build());
|
||||
if (CollectionUtils.isNotEmpty(deviceDTOList)) {
|
||||
throw new BusinessException("该设备编码已存在");
|
||||
}
|
||||
|
||||
AlitaResult<TencentMapGeocoderResDTO> alitaResult = tencentMapContext.webServiceGeocoder(TencentMapGeocoderReqDTO.builder()
|
||||
.address(operatorDto.getAddress())
|
||||
.build());
|
||||
|
||||
if (Boolean.TRUE.equals(alitaResult.getSuccess())) {
|
||||
TencentMapGeocoderResDTO resultData = alitaResult.getData();
|
||||
|
||||
TencentMapGeocoderResDTO.TencentMapGeocoderLocationResDTO location = resultData.getLocation();
|
||||
TencentMapGeocoderResDTO.TencentMapGeocoderAddressComponentsDTO address_components = resultData.getAddress_components();
|
||||
TencentMapGeocoderResDTO.TencentMapGeocoderAdInfo ad_info = resultData.getAd_info();
|
||||
|
||||
if (Objects.nonNull(location)) {
|
||||
TencentMapLocationV1IpResDTO tencentMapLocationV1IpResDTO = new TencentMapLocationV1IpResDTO();
|
||||
tencentMapLocationV1IpResDTO.setLocation(TencentMapLocationV1IpResDTO.TencentMapLocationDTO.builder().lat(location.getLat()).lng(location.getLng()).build());
|
||||
tencentMapLocationV1IpResDTO.setAd_info(TencentMapLocationV1IpResDTO.TencentMapLocationAdInfoDTO.builder()
|
||||
.province(address_components.getProvince())
|
||||
.city(address_components.getCity())
|
||||
.district(address_components.getDistrict())
|
||||
.adcode(ad_info.getAdcode())
|
||||
.build());
|
||||
operatorDto.setGeocoderJson(JsonUtils.toJsonString(tencentMapLocationV1IpResDTO));
|
||||
}
|
||||
}
|
||||
Device device = DeviceConvert.INSTANCE.convert(operatorDto);
|
||||
deviceMapper.saveEntity(device);
|
||||
return DeviceConvert.INSTANCE.convert(device);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDTO modify(DeviceOperatorDTO operatorDto) {
|
||||
List<DeviceDTO> deviceDTOList = this.list(DeviceQueryDTO.builder().notId(operatorDto.getId()).name(operatorDto.getName()).build());
|
||||
if (CollectionUtils.isNotEmpty(deviceDTOList)) {
|
||||
throw new BusinessException("该设备编码已存在");
|
||||
}
|
||||
|
||||
DeviceDTO deviceDto = this.findById(operatorDto.getId());
|
||||
if (Objects.isNull(deviceDto)) {
|
||||
return null;
|
||||
}
|
||||
if (!StringUtils.equals(operatorDto.getAddress(), deviceDto.getAddress())) {
|
||||
AlitaResult<TencentMapGeocoderResDTO> alitaResult = tencentMapContext.webServiceGeocoder(TencentMapGeocoderReqDTO.builder()
|
||||
.address(operatorDto.getAddress())
|
||||
.build());
|
||||
|
||||
if (Boolean.TRUE.equals(alitaResult.getSuccess())) {
|
||||
TencentMapGeocoderResDTO resultData = alitaResult.getData();
|
||||
|
||||
TencentMapGeocoderResDTO.TencentMapGeocoderLocationResDTO location = resultData.getLocation();
|
||||
TencentMapGeocoderResDTO.TencentMapGeocoderAddressComponentsDTO address_components = resultData.getAddress_components();
|
||||
TencentMapGeocoderResDTO.TencentMapGeocoderAdInfo ad_info = resultData.getAd_info();
|
||||
|
||||
if (Objects.nonNull(location)) {
|
||||
TencentMapLocationV1IpResDTO tencentMapLocationV1IpResDTO = new TencentMapLocationV1IpResDTO();
|
||||
tencentMapLocationV1IpResDTO.setLocation(TencentMapLocationV1IpResDTO.TencentMapLocationDTO.builder().lat(location.getLat()).lng(location.getLng()).build());
|
||||
tencentMapLocationV1IpResDTO.setAd_info(TencentMapLocationV1IpResDTO.TencentMapLocationAdInfoDTO.builder()
|
||||
.province(address_components.getProvince())
|
||||
.city(address_components.getCity())
|
||||
.district(address_components.getDistrict())
|
||||
.adcode(ad_info.getAdcode())
|
||||
.build());
|
||||
operatorDto.setGeocoderJson(JsonUtils.toJsonString(tencentMapLocationV1IpResDTO));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Device device = DeviceConvert.INSTANCE.convert(operatorDto);
|
||||
device.setCode(null);
|
||||
deviceMapper.updateEntitySelective(device);
|
||||
return this.findById(operatorDto.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDTO delete(Long id) {
|
||||
DeviceDTO deviceDto = this.findById(id);
|
||||
if (Objects.isNull(deviceDto)) {
|
||||
return null;
|
||||
}
|
||||
Device device = Device.builder().build();
|
||||
device.setId(id);
|
||||
deviceMapper.deleteEntity(device, UserContextHolder.getLoginUserId());
|
||||
return deviceDto;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDTO findById(Long id) {
|
||||
Device device = deviceMapper.getById(id);
|
||||
if (Objects.isNull(device)) {
|
||||
return null;
|
||||
}
|
||||
return DeviceConvert.INSTANCE.convert(device);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceDTO> list(DeviceQueryDTO queryDTO) {
|
||||
return deviceMapper.list(queryDTO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceDTO> page(DevicePageQueryDTO queryDTO) {
|
||||
return deviceMapper.page(queryDTO);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user