1.任务执行

2.设备查询
This commit is contained in:
chenlinghy 2023-08-24 22:56:22 +08:00
parent eb9aebfa15
commit 79013dc906
66 changed files with 1190 additions and 704 deletions

View File

@ -116,7 +116,12 @@
<artifactId>snakeyaml</artifactId> <artifactId>snakeyaml</artifactId>
<version>2.1</version> <version>2.1</version>
</dependency> </dependency>
</dependencies> <dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>1.5.3.Final</version>
</dependency>
</dependencies>
<build> <build>
<plugins> <plugins>

View File

@ -4,4 +4,5 @@ public interface EnumerationBase {
Integer getValue(); Integer getValue();
String getDescription(); String getDescription();
} }

View File

@ -29,4 +29,15 @@ public enum AlarmControlTypeName implements EnumerationBase {
public String getDescription() { public String getDescription() {
return this.desc; return this.desc;
} }
// 根据code值获取枚举类型
public static AlarmControlTypeName getByCode(int code) {
for (AlarmControlTypeName myEnum : AlarmControlTypeName.values()) {
if (myEnum.getValue() == code) {
return myEnum;
}
}
// 如果找不到对应的枚举类型可以根据具体需求抛出异常或者返回null
throw new IllegalArgumentException("Invalid code: " + code);
}
} }

View File

@ -25,4 +25,15 @@ public enum AlarmModeName implements EnumerationBase {
public String getDescription() { public String getDescription() {
return this.desc; return this.desc;
} }
// 根据code值获取枚举类型
public static AlarmModeName getByCode(int code) {
for (AlarmModeName myEnum : AlarmModeName.values()) {
if (myEnum.getValue() == code) {
return myEnum;
}
}
// 如果找不到对应的枚举类型可以根据具体需求抛出异常或者返回null
throw new IllegalArgumentException("Invalid code: " + code);
}
} }

View File

@ -28,4 +28,15 @@ public enum AlarmTypeName implements EnumerationBase {
public String getDescription() { public String getDescription() {
return this.desc; return this.desc;
} }
// 根据code值获取枚举类型
public static AlarmTypeName getByCode(int code) {
for (AlarmTypeName myEnum : AlarmTypeName.values()) {
if (myEnum.getValue() == code) {
return myEnum;
}
}
// 如果找不到对应的枚举类型可以根据具体需求抛出异常或者返回null
throw new IllegalArgumentException("Invalid code: " + code);
}
} }

View File

@ -8,6 +8,8 @@ public enum SensorControlTunnelName implements EnumerationBase {
TUNNEL_WIRELESS(2, "Wireless tunnel"), TUNNEL_WIRELESS(2, "Wireless tunnel"),
TUNNEL_TEL(4, "Telephone tunnel"), TUNNEL_TEL(4, "Telephone tunnel"),
TUNNEL_ALL(7,"All")
; ;
private final Integer code; private final Integer code;

View File

@ -10,6 +10,8 @@ public enum TaskStatusName implements EnumerationBase {
TASK_TIMEOUT(2, "TASK_TIMEOUT"), TASK_TIMEOUT(2, "TASK_TIMEOUT"),
TASK_UNRESPONSE(3, "TASK_UNRESPONSE"), TASK_UNRESPONSE(3, "TASK_UNRESPONSE"),
TASK_EXECUTING(4, "TASK_EXECUTING")
; ;
private final Integer code; private final Integer code;

View File

@ -0,0 +1,39 @@
package com.zjyr.beidouservice.constenum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import java.util.ArrayList;
import java.util.List;
@Getter
@AllArgsConstructor
public enum ApprovalStatusEnum {
APPROVAL_PENDING(1, "待审批"),
APPROVAL_SUCCESS(2, "审批通过"),
APPROVAL_FAIL(3, "审批拒绝");
private final Integer code;
private final String msg;
public static String getByCode(Integer code) {
ApprovalStatusEnum[] values = ApprovalStatusEnum.values();
for (ApprovalStatusEnum v : values) {
if (code.equals(v.getCode())) {
return v.getMsg();
}
}
return null;
}
public static List<Integer> getAllCodes() {
ApprovalStatusEnum[] values = ApprovalStatusEnum.values();
List<Integer> codes = new ArrayList<>();
for (ApprovalStatusEnum v : values) {
codes.add(v.getCode());
}
return codes;
}
}

View File

@ -1,10 +1,10 @@
package com.zjyr.beidouservice.controller; package com.zjyr.beidouservice.controller;
import com.zjyr.beidouservice.pojo.MyResp; import com.zjyr.beidouservice.pojo.MyResp;
import com.zjyr.beidouservice.pojo.dto.AlarmDevRespDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceReqDTO; import com.zjyr.beidouservice.pojo.dto.DeviceReqDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceRespDTO; import com.zjyr.beidouservice.pojo.dto.DeviceRespDTO;
import com.zjyr.beidouservice.pojo.dto.ManufacturerRespDTO; import com.zjyr.beidouservice.pojo.dto.DeviceSearchDTO;
import com.zjyr.beidouservice.service.DeviceService; import com.zjyr.beidouservice.service.DeviceService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -16,6 +16,7 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List; import java.util.List;
@RestController @RestController
@RequestMapping("/") @RequestMapping("/")
@Validated @Validated
@ -25,24 +26,25 @@ public class DeviceController {
@Resource @Resource
DeviceService deviceService; DeviceService deviceService;
/**
* 根据省份地市和区域信息获取设备
*
* @return 设备列表
*/
@PostMapping("device/location") @PostMapping("device/location")
public MyResp<List<DeviceRespDTO>> getDeviceInfo(@RequestBody DeviceReqDTO deviceReqDTO) { public MyResp<List<DeviceRespDTO>> getDeviceByLocation(@RequestBody DeviceReqDTO deviceReqDTO) {
List<DeviceRespDTO> deviceRespDTO = deviceService.getDeviceInfo(deviceReqDTO); List<DeviceRespDTO> deviceRespDTO = deviceService.getDeviceByLocation(deviceReqDTO);
return MyResp.success(deviceRespDTO); return MyResp.success(deviceRespDTO);
} }
@PostMapping("device/manufacturer") /**
public MyResp<ManufacturerRespDTO> getDeviceManufacturerInfo() { * 根据设备id获取设备信息
ManufacturerRespDTO manufacturerRes = deviceService.getDeviceManufacturerInfo(); *
return MyResp.success(manufacturerRes); * @return 设备
*/
@PostMapping("device/info/deviceId")
public MyResp<DeviceRespDTO> getDeviceByDeviceId(@RequestBody DeviceSearchDTO deviceSearchDTO) {
DeviceRespDTO deviceRespDTO = deviceService.getDeviceByDeviceId(deviceSearchDTO);
return MyResp.success(deviceRespDTO);
} }
@PostMapping("alarm/device")
public MyResp<AlarmDevRespDTO> getAlarmDeviceInfo() {
AlarmDevRespDTO alarmDevRespDTO = deviceService.getAlarmDeviceInfo();
return MyResp.success(alarmDevRespDTO);
}
} }

View File

@ -1,18 +1,17 @@
package com.zjyr.beidouservice.controller; package com.zjyr.beidouservice.controller;
import com.zjyr.beidouservice.pojo.MyResp; import com.zjyr.beidouservice.pojo.MyResp;
import com.zjyr.beidouservice.pojo.dto.DevTaskExecRespDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceTaskExecReqDTO; import com.zjyr.beidouservice.pojo.dto.task.AlarmTaskReqDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceTaskRespDTO; import com.zjyr.beidouservice.service.AlarmTaskService;
import com.zjyr.beidouservice.service.DeviceTaskService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; 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.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.List;
@RestController @RestController
@RequestMapping("/") @RequestMapping("/")
@ -21,19 +20,18 @@ import java.util.List;
public class DeviceTaskController { public class DeviceTaskController {
@Resource @Resource
DeviceTaskService deviceTaskService; AlarmTaskService alarmTaskService;
/**
@PostMapping("task/info") * 执行告警任务
public MyResp<List<DeviceTaskRespDTO>> getDeviceTaskInfo() { *
List<DeviceTaskRespDTO> deviceTaskRespDTOS = deviceTaskService.getDeviceTaskInfo(); * @param alarmTaskReqDTO alarmTaskReqDTO
return MyResp.success(deviceTaskRespDTOS); * @return MyResp
*/
@PostMapping("/alarm/task/exec")
public MyResp alarmTaskExec(@RequestBody AlarmTaskReqDTO alarmTaskReqDTO) {
return alarmTaskService.alarmTaskExec(alarmTaskReqDTO);
} }
@PostMapping("task/exec")
public MyResp<DevTaskExecRespDTO> deviceTaskExec(DeviceTaskExecReqDTO deviceTaskExecReqDTO) {
DevTaskExecRespDTO deviceTaskExecResp = deviceTaskService.deviceTaskExec(deviceTaskExecReqDTO);
return MyResp.success(deviceTaskExecResp);
}
} }

View File

@ -0,0 +1,19 @@
package com.zjyr.beidouservice.mapper;
import com.zjyr.beidouservice.pojo.dataobject.AlarmDeviceTaskDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface AlarmDeviceTaskMapper {
/**
* Add alarm device task info list int.
*
* @param taskLists the task lists
* @return the int
*/
int addAlarmDevTaskInfoList(@Param("taskLists") List<AlarmDeviceTaskDO> taskLists);
}

View File

@ -0,0 +1,15 @@
package com.zjyr.beidouservice.mapper;
import com.zjyr.beidouservice.pojo.dataobject.AlarmTaskDO;
import org.apache.ibatis.annotations.Mapper;
@Mapper
public interface AlarmTaskMapper {
/**
* 新增告警任务
*
* @param alarmTaskDO alarmTaskDO
* @return int
*/
int addAlarmTask(AlarmTaskDO alarmTaskDO);
}

View File

@ -1,17 +0,0 @@
package com.zjyr.beidouservice.mapper;
import com.zjyr.beidouservice.pojo.dataobject.DevAttributesDO;
import com.zjyr.beidouservice.pojo.dto.DevMaunDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface DevAttributesMapper {
List<DevMaunDTO> selectManuByManufacturer(@Param("deviceId") Long deviceId, @Param("manufacturer") String manufacturer);
List<DevAttributesDO> selectManuAll();
}

View File

@ -1,17 +0,0 @@
package com.zjyr.beidouservice.mapper;
import com.zjyr.beidouservice.pojo.dataobject.DevBasicInfoDO;
import com.zjyr.beidouservice.pojo.dto.DeviceInfoByLocDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface DevBasicInfoMapper {
List<DevBasicInfoDO> selectDeviceByLoc(DeviceInfoByLocDTO deviceInfoByLocDTO);
DevBasicInfoDO selectDeviceByDeviceId(@Param("deviceId") Long deviceId);
}

View File

@ -1,15 +0,0 @@
package com.zjyr.beidouservice.mapper;
import com.zjyr.beidouservice.pojo.dataobject.DevTaskDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface DevTaskMapper {
List<DevTaskDO> selectDevTaskByTaskId(@Param("taskId") String taskId);
}

View File

@ -0,0 +1,19 @@
package com.zjyr.beidouservice.mapper;
import com.zjyr.beidouservice.pojo.dataobject.DeviceDO;
import com.zjyr.beidouservice.pojo.dto.DeviceByLocationDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface DeviceMapper {
List<DeviceDO> selectDeviceByLoc(DeviceByLocationDTO deviceByLocationDTO);
DeviceDO selectDeviceByDeviceId(@Param("deviceId") Long deviceId);
}

View File

@ -9,8 +9,10 @@ import java.util.List;
@Mapper @Mapper
public interface LocCityMapper { public interface LocCityMapper {
List<LocCityDO> selectCityByProvince(@Param("provinceCode") String provinceCode); List<LocCityDO> selectCityByProvince(@Param("provinceCode") Integer provinceCode);
List<String> selectCitys(@Param("provinceCode") Integer provinceCode);
List<LocCityDO> selectCity(@Param("provinceCode") String provinceCode, @Param("cityCode") String cityCode); List<LocCityDO> selectCity(@Param("provinceCode") Integer provinceCode, @Param("cityCode") Integer cityCode);
} }

View File

@ -1,5 +1,6 @@
package com.zjyr.beidouservice.mapper; package com.zjyr.beidouservice.mapper;
import com.zjyr.beidouservice.pojo.dataobject.LocCityDO;
import com.zjyr.beidouservice.pojo.dataobject.LocCountyDO; import com.zjyr.beidouservice.pojo.dataobject.LocCountyDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@ -9,5 +10,6 @@ import java.util.List;
@Mapper @Mapper
public interface LocCountyMapper { public interface LocCountyMapper {
List<LocCountyDO> selectCountyByCity(@Param("provinceCode") String provinceCode, @Param("cityCode") String cityCode); List<LocCountyDO> selectCountyByCity(@Param("provinceCode") Integer provinceCode, @Param("cityCode") Integer cityCode);
} }

View File

@ -11,5 +11,5 @@ public interface LocProvinceMapper {
List<LocProvinceDO> selectAllProvince(); List<LocProvinceDO> selectAllProvince();
List<LocProvinceDO> selectProvince(@Param("provinceCode") String provinceCode); List<LocProvinceDO> selectProvince(@Param("provinceCode") Integer provinceCode);
} }

View File

@ -0,0 +1,18 @@
package com.zjyr.beidouservice.mapper;
import com.zjyr.beidouservice.pojo.dataobject.SystemConfigDO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@Mapper
public interface SystemConfigMapper {
int addConfig(@Param("name") String name, @Param("value") String value);
int updateConfig(@Param("name") String name, @Param("value") String value);
SystemConfigDO getConfigByName(@Param("name") String name);
}

View File

@ -1,12 +0,0 @@
package com.zjyr.beidouservice.mapper;
import com.zjyr.beidouservice.pojo.dataobject.TaskDO;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface TaskMapper {
List<TaskDO> selectAllTask();
}

View File

@ -0,0 +1,47 @@
package com.zjyr.beidouservice.pojo.dataobject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class AlarmDeviceTaskDO {
/**
* 自增长id
*/
private Long id;
/**
* 记录编号
*/
private String taskId;
/**
* 设备id
*/
private Integer deviceId;
/**
* 控制通道2:无线 3:北斗 4:电话 5:all
*/
private Integer controlChannel;
/**
* 发放时间
*/
private Date sendTime;
/**
* 执行状态
*/
private Integer status;
/**
* 回示时间
*/
private Date reportTime;
}

View File

@ -0,0 +1,68 @@
package com.zjyr.beidouservice.pojo.dataobject;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AlarmTaskDO {
/**
* 自增长id
*/
private Long id;
/**
* 记录编号
*/
private String taskId;
/**
* 警报类型 1:语言广播 2:警报发送 3:警报试鸣,默认警报发送2
*/
private Integer alarmType;
/**
* 警报种类 1:预先警报 2:空袭警报 3:灾情警 4:解除警报灾 5:解除警报
*/
private Integer alarmKind;
/**
* 警报区域
*/
private String alarmCounty;
/**
* 设备id.包含多个设备信息
*/
private String deviceIds;
/**
* 警报方式 1:人工 2:定时默认人工
*/
private Integer alarmMode;
/**
* 控制通道2:无线 3:北斗 4:电话 5:all
*/
private Integer controlChannel;
/**
* 发放人
*/
private String sender;
/**
* 发放时间
*/
private Date sendTime;
/**
* 审批状态 1:待审批 2:审批通过 3:审批拒绝
*/
private Integer approvalStatus;
}

View File

@ -1,54 +0,0 @@
package com.zjyr.beidouservice.pojo.dataobject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DevAttributesDO {
private Long id;
private Long deviceId;
private Integer deviceStatus;
private String alarmModel;
private String alarmStatus;
private Integer alarmType;
private Integer alarmPower;
private Integer alarmManufacturer;
private Date alarmInstallTime;
private String controlModel;
private Integer controlStatus;
private Integer controlManufacturer;
private Date controlInstallTime;
private String powerModel;
private Integer powerStatus;
private Integer powerType;
private Integer power;
private Integer powerManufacturer;
private Date powerInstallTime;
private Date createTime;
private Date updateTime;
}

View File

@ -1,48 +0,0 @@
package com.zjyr.beidouservice.pojo.dataobject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DevBasicInfoDO implements Serializable {
private Long id;
private Long deviceId;
private String deviceName;
private String deviceDesc;
private String provinceCode;
private String cityCode;
private String countyCode;
private String subordinateUnits;
private Integer controlStationId;
private String administrator;
private String mobile;
private String installAddr;
private String latitude;
private String longitude;
private String devData;
private Date createTime;
private Date updateTime;
}

View File

@ -1,32 +0,0 @@
package com.zjyr.beidouservice.pojo.dataobject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DevTaskDO {
private Long id;
private String taskId;
private Integer controlMode;
private String countyCode;
private Integer controlType;
private Long deviceId;
private String deviceName;
private String execCmd;
private Integer execState;
private Date createTime;
private Date updateTime;
}

View File

@ -0,0 +1,110 @@
package com.zjyr.beidouservice.pojo.dataobject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class DeviceDO {
/**
* 自增长id
*/
private Long id;
/**
* 设备id
*/
private Integer deviceId;
/**
* 本机北斗ID
*/
private Integer beidouId;
/**
* 终端名称
*/
private String deviceName;
/**
* 通波号
*/
private Integer directDialing;
/**
* 经度
*/
private Float latitude;
/**
* 纬度
*/
private Float longitude;
/**
* 所属街道
*/
private String streetCode;
/**
* 所属区县
*/
private Integer countyCode;
/**
* 所属地市
*/
private Integer cityCode;
/**
* 所属省份
*/
private Integer provinceCode;
/**
* 信号强度
*/
private Integer signalStrength;
/**
* 安装地址
*/
private String installSite;
/**
* 安装地联系人
*/
private String mobile;
/**
* 安装时间
*/
private Date installTime;
/**
* 设备状态 1:在线 2:离线
*/
private Integer state;
/**
* 警报器型号
*/
private String model;
/**
* 警报器类型
*/
private Integer type;
/**
* 警报器厂商
*/
private String manufacturer;
/**
* 警报器功率
*/
private Integer power;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@ -15,12 +15,13 @@ public class LocCityDO implements Serializable {
private String cityName; private String cityName;
private String cityCode; private Integer cityCode;
private String provinceCode; private Integer provinceCode;
private String beidouBroadcastId; private Integer beidouBroadcastId;
private Date createTime; private Date createTime;
private Date updateTime; private Date updateTime;
} }

View File

@ -15,13 +15,15 @@ public class LocCountyDO implements Serializable {
private String countyName; private String countyName;
private String countyCode; private Integer countyCode;
private String cityCode;
private String provinceCode; private Integer cityCode;
private String beidouBroadcastId; private Integer provinceCode;
private Integer beidouBroadcastId;
private Date createTime; private Date createTime;
private Date updateTime; private Date updateTime;
} }

View File

@ -15,8 +15,9 @@ public class LocProvinceDO implements Serializable {
private String provinceName; private String provinceName;
private String provinceCode; private Integer provinceCode;
private Date createTime; private Date createTime;
private Date updateTime; private Date updateTime;
} }

View File

@ -0,0 +1,36 @@
package com.zjyr.beidouservice.pojo.dataobject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class SystemConfigDO {
/**
* 自增长id
*/
private Long id;
/**
* 名称
*/
private String name;
/**
*
*/
private String value;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

View File

@ -1,38 +0,0 @@
package com.zjyr.beidouservice.pojo.dataobject;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class TaskDO {
private Long id;
private String taskId;
private Integer controlChannel;
private Integer beidouId;
private String provinceCode;
private String cityCode;
private String countyCode;
private String deviceIds;
private Integer deviceNum;
private Integer execNormalNum;
private Integer execAbnormalNum;
private Date createTime;
private Date updateTime;
}

View File

@ -10,12 +10,12 @@ import lombok.NoArgsConstructor;
@Builder @Builder
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class DeviceInfoByLocDTO { public class DeviceByLocationDTO {
private String provinceCode; private Integer provinceCode;
private String cityCode; private Integer cityCode;
private String countyCode; private Integer countyCode;
private String deviceName; private String deviceName;
} }

View File

@ -0,0 +1,32 @@
package com.zjyr.beidouservice.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DeviceInfoDTO {
/**
* 执行任务设备所属省默认浙江省
*/
private Integer provinceCode;
/**
* 执行任务设备所属地市
*/
private List<Integer> cityCodes;
/**
* 执行任务设备所属区域
*/
private List<Integer> countyCodes;
/**
* 执行任务设备
*/
private List<Integer> deviceIds;
}

View File

@ -11,15 +11,24 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class DeviceReqDTO { public class DeviceReqDTO {
private String provinceCode; /**
* 终端名称
private String cityCode; */
private String countyCode;
private String manufacturer;
private String deviceName; private String deviceName;
/**
* 所属区县
*/
private Integer countyCode;
/**
* 所属地市
*/
private Integer cityCode;
/**
* 所属省份
*/
private Integer provinceCode;
} }

View File

@ -12,25 +12,43 @@ import lombok.NoArgsConstructor;
@AllArgsConstructor @AllArgsConstructor
public class DeviceRespDTO { public class DeviceRespDTO {
private Long deviceId; /**
* 设备id
*/
private Integer deviceId;
/**
* 终端名称
*/
private String deviceName; private String deviceName;
private String provinceCode; /**
* 经度
*/
private Float latitude;
private String cityCode; /**
* 纬度
*/
private Float longitude;
private String countyCode; /**
* 所属区县
*/
private Integer countyCode;
/**
* 所属地市
*/
private Integer cityCode;
private String installAddr; /**
* 所属省份
private String latitude; */
private Integer provinceCode;
private String longitude;
private String alarmManufacturer;
private String controlManufacturer;
/**
* 安装地址
*/
private String installSite;
} }

View File

@ -0,0 +1,17 @@
package com.zjyr.beidouservice.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DeviceSearchDTO {
/**
* 设备id
*/
private Long deviceId;
}

View File

@ -17,7 +17,6 @@ public class DeviceTaskContentDTO {
private String deviceName; private String deviceName;
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date respTime; private Date respTime;

View File

@ -1,26 +0,0 @@
package com.zjyr.beidouservice.pojo.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class DeviceTaskExecReqDTO {
private Integer controlChannel;
private String provinceCode;
private String cityCode;
private String countyCode;
private String deviceIds;
private Integer controlMode;
private String execCmd;
}

View File

@ -9,10 +9,11 @@ import java.util.List;
@Data @Data
@NoArgsConstructor @NoArgsConstructor
public class CityCountyDTO { public class CityCountyDTO {
private String provinceCode; private Integer provinceCode;
private String cityName; private String cityName;
private String cityCode; private Integer cityCode;
List<CountyContent> countyList; List<CountyContent> countyList;
} }

View File

@ -10,7 +10,7 @@ import java.io.Serializable;
@NoArgsConstructor @NoArgsConstructor
@AllArgsConstructor @AllArgsConstructor
public class CitySearchDTO implements Serializable { public class CitySearchDTO implements Serializable {
private String provinceCode; private Integer provinceCode;
private String cityCode; private Integer cityCode;
} }

View File

@ -8,5 +8,5 @@ import lombok.NoArgsConstructor;
public class CountyContent { public class CountyContent {
private String countyName; private String countyName;
private String countyCode; private Integer countyCode;
} }

View File

@ -9,6 +9,6 @@ import lombok.NoArgsConstructor;
public class CityContentDTO { public class CityContentDTO {
private String cityName; private String cityName;
private String cityCode; private Integer cityCode;
} }

View File

@ -8,5 +8,5 @@ import lombok.NoArgsConstructor;
public class OnlyProvinceContentDTO { public class OnlyProvinceContentDTO {
private String provinceName; private String provinceName;
private String provinceCode; private Integer provinceCode;
} }

View File

@ -10,7 +10,7 @@ import java.util.List;
public class ProvinceContent { public class ProvinceContent {
private String provinceName; private String provinceName;
private String provinceCode; private Integer provinceCode;
private List<CityContentDTO> cityList; private List<CityContentDTO> cityList;
} }

View File

@ -11,5 +11,5 @@ import java.io.Serializable;
@AllArgsConstructor @AllArgsConstructor
public class ProvinceSearchDTO implements Serializable { public class ProvinceSearchDTO implements Serializable {
private String provinceCode; private Integer provinceCode;
} }

View File

@ -0,0 +1,62 @@
package com.zjyr.beidouservice.pojo.dto.task;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.Date;
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AlarmTaskReqDTO {
/**
* 省份默认浙江省 33.
*/
private String provinceCode;
/**
* 地市默认杭州市 1.
*/
private String cityCode;
/**
* 所属区域
*/
private String countyCode;
/**
* 设备id.包含多个设备信息
*/
private String deviceIds;
/**
* 警报类型 1:语言广播 2:警报发送 3:警报试鸣,默认警报发送2
*/
private Integer alarmType;
/**
* 警报种类 1:预先警报 2:空袭警报 3:灾情警 4:解除警报灾 5:解除警报
*/
private Integer alarmKind;
/**
* 警报方式 1:人工 2:定时默认人工
*/
private Integer alarmMode;
/**
* 控制通道2:无线 3:北斗 4:电话 5:all
*/
private Integer controlChannel;
/**
* 发放时间
*/
private Date sendTime;
/**
* 发放人
*/
private String sender;
}

View File

@ -0,0 +1,19 @@
package com.zjyr.beidouservice.service;
import com.zjyr.beidouservice.pojo.MyResp;
import com.zjyr.beidouservice.pojo.dto.task.AlarmTaskReqDTO;
public interface AlarmTaskService {
/**
* 执行告警任务
* @param alarmTaskReqDTO alarmTaskReqDTO
* @return MyResp
*/
MyResp alarmTaskExec(AlarmTaskReqDTO alarmTaskReqDTO);
}

View File

@ -1,17 +1,25 @@
package com.zjyr.beidouservice.service; package com.zjyr.beidouservice.service;
import com.zjyr.beidouservice.pojo.dto.AlarmDevRespDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceReqDTO; import com.zjyr.beidouservice.pojo.dto.DeviceReqDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceRespDTO; import com.zjyr.beidouservice.pojo.dto.DeviceRespDTO;
import com.zjyr.beidouservice.pojo.dto.ManufacturerRespDTO; import com.zjyr.beidouservice.pojo.dto.DeviceSearchDTO;
import java.util.List; import java.util.List;
public interface DeviceService { public interface DeviceService {
List<DeviceRespDTO> getDeviceInfo(DeviceReqDTO deviceReqDTO); /**
* 根据省份地市和区域信息获取设备
*
* @return 设备列表
*/
List<DeviceRespDTO> getDeviceByLocation(DeviceReqDTO deviceReqDTO);
ManufacturerRespDTO getDeviceManufacturerInfo(); /**
* 根据设备id获取设备信息
*
* @return 设备
*/
DeviceRespDTO getDeviceByDeviceId(DeviceSearchDTO deviceSearchDTO);
AlarmDevRespDTO getAlarmDeviceInfo();
} }

View File

@ -1,14 +0,0 @@
package com.zjyr.beidouservice.service;
import com.zjyr.beidouservice.pojo.dto.DevTaskExecRespDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceTaskExecReqDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceTaskRespDTO;
import java.util.List;
public interface DeviceTaskService {
List<DeviceTaskRespDTO> getDeviceTaskInfo();
DevTaskExecRespDTO deviceTaskExec(DeviceTaskExecReqDTO deviceTaskExecReqDTO);
}

View File

@ -11,7 +11,6 @@ public interface LocationService {
ProvinceRespDTO getProvinces(ProvinceSearchDTO provinceSearchDTO); ProvinceRespDTO getProvinces(ProvinceSearchDTO provinceSearchDTO);
CityRespDTO getCity(CitySearchDTO citySearchDTO); CityRespDTO getCity(CitySearchDTO citySearchDTO);

View File

@ -0,0 +1,259 @@
package com.zjyr.beidouservice.service.impl;
import com.zjyr.beidouservice.common.impl.AlarmControlTypeName;
import com.zjyr.beidouservice.common.impl.AlarmModeName;
import com.zjyr.beidouservice.common.impl.AlarmTypeName;
import com.zjyr.beidouservice.common.impl.SensorControlTunnelName;
import com.zjyr.beidouservice.common.impl.TaskStatusName;
import com.zjyr.beidouservice.constenum.ApprovalStatusEnum;
import com.zjyr.beidouservice.mapper.AlarmDeviceTaskMapper;
import com.zjyr.beidouservice.mapper.AlarmTaskMapper;
import com.zjyr.beidouservice.mapper.DeviceMapper;
import com.zjyr.beidouservice.mapper.LocCityMapper;
import com.zjyr.beidouservice.mapper.LocCountyMapper;
import com.zjyr.beidouservice.mapper.LocProvinceMapper;
import com.zjyr.beidouservice.mapper.SystemConfigMapper;
import com.zjyr.beidouservice.pojo.MyResp;
import com.zjyr.beidouservice.pojo.dataobject.AlarmDeviceTaskDO;
import com.zjyr.beidouservice.pojo.dataobject.AlarmTaskDO;
import com.zjyr.beidouservice.pojo.dataobject.DeviceDO;
import com.zjyr.beidouservice.pojo.dataobject.LocCountyDO;
import com.zjyr.beidouservice.pojo.dataobject.SystemConfigDO;
import com.zjyr.beidouservice.pojo.dto.DeviceByLocationDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceInfoDTO;
import com.zjyr.beidouservice.pojo.dto.task.AlarmTaskReqDTO;
import com.zjyr.beidouservice.service.AdapterProtocolService;
import com.zjyr.beidouservice.service.AlarmTaskService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@Service
@Slf4j
public class AlarmTaskServiceImpl implements AlarmTaskService {
@Resource
AdapterProtocolService adapterProtocolService;
@Resource
AlarmTaskMapper alarmTaskMapper;
@Resource
AlarmDeviceTaskMapper alarmDeviceTaskMapper;
@Resource
SystemConfigMapper systemConfigMapper;
@Resource
LocCityMapper locCityMapper;
@Resource
LocProvinceMapper locProvinceMapper;
@Resource
LocCountyMapper locCountyMapper;
@Resource
DeviceMapper deviceMapper;
@Override
public MyResp alarmTaskExec(AlarmTaskReqDTO alarmTaskReqDTO) {
//根据选择的省份地市区域或指定设备信息获取执行任务的deviceIdprovinceCode默认为null
DeviceInfoDTO deviceInfo = getExecDeviceInfo(alarmTaskReqDTO);
//生成规则为"JL"+"当前年月日"+"4位自增ID"
String taskId = generateRecordNumber();
AlarmTaskDO alarmTaskDO = AlarmTaskDO.builder()
.taskId(taskId)
.alarmType(alarmTaskReqDTO.getAlarmType())
.alarmKind(alarmTaskReqDTO.getAlarmKind())
.alarmCounty(deviceInfo.getCountyCodes() == null ? " " : deviceInfo.getCountyCodes().toString())
.deviceIds(deviceInfo.getDeviceIds().toString())
.alarmMode(alarmTaskReqDTO.getAlarmMode())
.controlChannel(alarmTaskReqDTO.getControlChannel())
.sender(alarmTaskReqDTO.getSender())
.sendTime(alarmTaskReqDTO.getSendTime())
.approvalStatus(ApprovalStatusEnum.APPROVAL_SUCCESS.getCode()).build();
//入库
alarmTaskMapper.addAlarmTask(alarmTaskDO);
List<AlarmDeviceTaskDO> alarmDeviceTaskDOS = getAlarmDeviceTaskDOS(alarmTaskReqDTO, deviceInfo, taskId);
alarmDeviceTaskMapper.addAlarmDevTaskInfoList(alarmDeviceTaskDOS);
//执行控制任务
//默认只有一种通道方式
adapterProtocolService.createSensorControlProtocol(
Integer.parseInt(taskId),
AlarmModeName.getByCode(alarmTaskReqDTO.getAlarmMode()),
AlarmControlTypeName.getByCode(alarmTaskReqDTO.getAlarmType()),
AlarmTypeName.getByCode(alarmTaskReqDTO.getAlarmKind()),
alarmTaskReqDTO.getControlChannel(),
alarmTaskReqDTO.getSendTime(),
deviceInfo.getCityCodes(),
deviceInfo.getCountyCodes(),
deviceInfo.getDeviceIds()
);
return MyResp.build();
}
private static List<AlarmDeviceTaskDO> getAlarmDeviceTaskDOS(AlarmTaskReqDTO alarmTaskReqDTO, DeviceInfoDTO deviceInfo, String taskId) {
List<AlarmDeviceTaskDO> alarmDeviceTaskDOS = new ArrayList<>();
List<Integer> deviceIds = deviceInfo.getDeviceIds();
if (alarmTaskReqDTO.getControlChannel().equals(SensorControlTunnelName.TUNNEL_ALL.getValue())) {
List<Integer> controlTunnel = new ArrayList<>();
controlTunnel.add(SensorControlTunnelName.TUNNEL_BEIDOU.getValue());
controlTunnel.add(SensorControlTunnelName.TUNNEL_WIRELESS.getValue());
controlTunnel.add(SensorControlTunnelName.TUNNEL_TEL.getValue());
controlTunnel.forEach(v ->
deviceIds.forEach(k -> {
AlarmDeviceTaskDO task = new AlarmDeviceTaskDO();
task.setTaskId(taskId);
task.setDeviceId(k);
task.setControlChannel(alarmTaskReqDTO.getControlChannel());
task.setSendTime(alarmTaskReqDTO.getSendTime());
task.setStatus(TaskStatusName.TASK_EXECUTING.getValue());
alarmDeviceTaskDOS.add(task);
}));
} else {
deviceIds.forEach(dev -> {
AlarmDeviceTaskDO task = new AlarmDeviceTaskDO();
task.setTaskId(taskId);
task.setDeviceId(dev);
task.setControlChannel(alarmTaskReqDTO.getControlChannel());
task.setSendTime(alarmTaskReqDTO.getSendTime());
task.setStatus(TaskStatusName.TASK_EXECUTING.getValue());
alarmDeviceTaskDOS.add(task);
});
}
return alarmDeviceTaskDOS;
}
private DeviceInfoDTO getExecDeviceInfo(AlarmTaskReqDTO alarmTaskReqDTO) {
//默认浙江省
int province = Integer.parseInt(alarmTaskReqDTO.getProvinceCode());
log.info("province: [{}]", province);
DeviceInfoDTO deviceInfo = new DeviceInfoDTO();
List<Integer> cityCodes = new ArrayList<>();
List<Integer> countyCodes = null;
List<Integer> deviceIds = null;
//cityCode不为null,默认为杭州市-所属区域为杭州市所有区域
if (Objects.nonNull(alarmTaskReqDTO.getCityCode())) {
log.info("选择所属地市:[{}] 所有设备执行告警任务", alarmTaskReqDTO.getCityCode());
int city = Integer.parseInt(alarmTaskReqDTO.getCityCode());
cityCodes.add(city);
//根据杭州市获取所有区信息
List<LocCountyDO> countyDOList = locCountyMapper.selectCountyByCity(province, city);
countyCodes = countyDOList.stream().map(LocCountyDO::getCountyCode).toList();
//获取杭州市所有设备信息
DeviceByLocationDTO searchDTO = DeviceByLocationDTO.builder().cityCode(city).build();
List<DeviceDO> deviceDOList = deviceMapper.selectDeviceByLoc(searchDTO);
deviceIds = deviceDOList.stream().map(DeviceDO::getDeviceId).toList();
} else if (Objects.nonNull(alarmTaskReqDTO.getCountyCode())) {
log.info("选择所属区域:[{}] 所有设备执行告警任务", alarmTaskReqDTO.getCountyCode());
//区存在多个
countyCodes = Arrays.stream(alarmTaskReqDTO.getCountyCode().split(",")).map(Integer::parseInt).toList();
//根据county查找设备信息
List<Integer> finalDeviceIds = new ArrayList<>();
countyCodes.forEach(county -> {
DeviceByLocationDTO searchDTO = DeviceByLocationDTO.builder().countyCode(county).build();
List<Integer> device = deviceMapper.selectDeviceByLoc(searchDTO).stream().map(DeviceDO::getDeviceId).toList();
finalDeviceIds.addAll(device);
});
deviceIds = finalDeviceIds;
} else if (Objects.nonNull(alarmTaskReqDTO.getDeviceIds())) {
log.info("指定设备: [{}]执行告警任务", alarmTaskReqDTO.getDeviceIds());
//todo 根据deviceId获取区信息
deviceIds = Arrays.stream(alarmTaskReqDTO.getDeviceIds().split(",")).map(Integer::parseInt).toList();
}
//默认浙江省杭州市
deviceInfo.setProvinceCode(province);
deviceInfo.setCityCodes(cityCodes);
deviceInfo.setCountyCodes(countyCodes);
deviceInfo.setDeviceIds(deviceIds);
return deviceInfo;
}
/**
* 记录编号生成规则为"JL"+"当前年月日"+"4位自增ID",不同日期从0001开始自增长例如JL202308180001JL202308190001
*/
private String generateRecordNumber() {
String currentDateStr = null;
int currentId = 0;
/*
* 考虑代码重启最新的字段值存数据库,默认currentDateStr为nullcurrentId为0*/
SystemConfigDO systemConfig = systemConfigMapper.getConfigByName("currentDate");
if (systemConfig == null) {
//新增日期信息
systemConfigMapper.addConfig("currentDate", currentDateStr);
} else {
currentDateStr = systemConfig.getValue();
log.info("current date: [{}]", currentDateStr);
}
SystemConfigDO config = systemConfigMapper.getConfigByName("currentId");
if (config == null) {
//新增ID信息
systemConfigMapper.addConfig("currentId", String.valueOf(currentId));
} else {
currentId = Integer.parseInt(config.getValue());
log.info("current id: [{}]", currentId);
}
// 获取当前日期
Date currentDate = new Date();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
String newDateStr = dateFormat.format(currentDate);
// 检查日期是否变化如果变化则重置自增ID
if (currentDateStr == null || !currentDateStr.equals(newDateStr)) {
currentId = 1;
currentDateStr = newDateStr;
systemConfigMapper.updateConfig("currentDate", currentDateStr);
}
// 生成自增的ID
DecimalFormat idFormat = new DecimalFormat("0000");
String idStr = idFormat.format(currentId);
// 更新自增ID
currentId++;
systemConfigMapper.updateConfig("currentId", String.valueOf(currentId++));
// 拼接记录编号
String recordNumber = "JL" + currentDateStr + idStr;
log.info("record number : [{}]", recordNumber);
return recordNumber;
}
}

View File

@ -1,19 +1,12 @@
package com.zjyr.beidouservice.service.impl; package com.zjyr.beidouservice.service.impl;
import com.zjyr.beidouservice.constenum.AlarmTypeEnum;
import com.zjyr.beidouservice.constenum.ManufacturerTypeEnum; import com.zjyr.beidouservice.mapper.DeviceMapper;
import com.zjyr.beidouservice.mapper.DevAttributesMapper; import com.zjyr.beidouservice.pojo.dataobject.DeviceDO;
import com.zjyr.beidouservice.mapper.DevBasicInfoMapper; import com.zjyr.beidouservice.pojo.dto.DeviceByLocationDTO;
import com.zjyr.beidouservice.pojo.dataobject.DevAttributesDO;
import com.zjyr.beidouservice.pojo.dataobject.DevBasicInfoDO;
import com.zjyr.beidouservice.pojo.dto.AlarmDevContentDTO;
import com.zjyr.beidouservice.pojo.dto.AlarmDevRespDTO;
import com.zjyr.beidouservice.pojo.dto.DevMaunDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceInfoByLocDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceReqDTO; import com.zjyr.beidouservice.pojo.dto.DeviceReqDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceRespDTO; import com.zjyr.beidouservice.pojo.dto.DeviceRespDTO;
import com.zjyr.beidouservice.pojo.dto.ManufacturerContentDTO; import com.zjyr.beidouservice.pojo.dto.DeviceSearchDTO;
import com.zjyr.beidouservice.pojo.dto.ManufacturerRespDTO;
import com.zjyr.beidouservice.service.DeviceService; import com.zjyr.beidouservice.service.DeviceService;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -21,118 +14,72 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
@Service @Service
@Slf4j @Slf4j
public class DeviceServiceImpl implements DeviceService { public class DeviceServiceImpl implements DeviceService {
@Resource @Resource
DevBasicInfoMapper devBasicInfoMapper; DeviceMapper deviceMapper;
@Resource
DevAttributesMapper devAttributesMapper;
@Override @Override
public List<DeviceRespDTO> getDeviceInfo(DeviceReqDTO deviceReqDTO) { public List<DeviceRespDTO> getDeviceByLocation(DeviceReqDTO deviceReqDTO) {
log.info("get device info : [{}]", deviceReqDTO); log.info("get device info : [{}]", deviceReqDTO);
List<DeviceRespDTO> deviceRespList = new ArrayList<>(); List<DeviceRespDTO> deviceRespList = new ArrayList<>();
//根据省份地市区信息查询设备 //根据省份地市区信息查询设备
DeviceInfoByLocDTO searchDTO = new DeviceInfoByLocDTO(); DeviceByLocationDTO searchDTO = DeviceByLocationDTO.builder()
searchDTO.setProvinceCode(deviceReqDTO.getProvinceCode()); .provinceCode(deviceReqDTO.getProvinceCode())
searchDTO.setCityCode(deviceReqDTO.getCityCode()); .cityCode(deviceReqDTO.getCityCode())
searchDTO.setCountyCode(deviceReqDTO.getCountyCode()); .countyCode(deviceReqDTO.getCountyCode())
searchDTO.setDeviceName(deviceReqDTO.getDeviceName()); .deviceName(deviceReqDTO.getDeviceName()).build();
log.info("device search info : [{}]", searchDTO); log.info("device search info : [{}]", searchDTO);
List<DevBasicInfoDO> devBasicInfoList = devBasicInfoMapper.selectDeviceByLoc(searchDTO); List<DeviceDO> deviceDOList = deviceMapper.selectDeviceByLoc(searchDTO);
if (devBasicInfoList.isEmpty()) { if (deviceDOList.isEmpty()) {
log.warn("根据省份、地市、区编码未查找到设备信息"); log.warn("未查找到设备信息");
return new ArrayList<>(); return new ArrayList<>();
} }
devBasicInfoList.forEach(dev -> { deviceDOList.forEach(v -> {
Long deviceId = dev.getDeviceId(); DeviceRespDTO resp = new DeviceRespDTO();
String manufacturer = deviceReqDTO.getManufacturer(); resp.setDeviceId(v.getDeviceId());
List<DevMaunDTO> devMaunDTO = devAttributesMapper.selectManuByManufacturer(deviceId, manufacturer); resp.setDeviceName(v.getDeviceName());
//根据过滤过厂商的device查找device基本信息 resp.setCountyCode(v.getCountyCode());
devMaunDTO.forEach(v -> { resp.setCityCode(v.getCityCode());
DeviceRespDTO deviceResp = new DeviceRespDTO(); resp.setProvinceCode(v.getProvinceCode());
deviceResp.setDeviceId(v.getDeviceId()); resp.setLatitude(v.getLatitude());
deviceResp.setAlarmManufacturer(ManufacturerTypeEnum.getByCode(v.getAlarmManufacturer())); resp.setLongitude(v.getLongitude());
deviceResp.setControlManufacturer(ManufacturerTypeEnum.getByCode(v.getControlManufacturer())); resp.setInstallSite(v.getInstallSite());
//根据deviceId查找device basic info deviceRespList.add(resp);
DevBasicInfoDO devBasicInfo = devBasicInfoMapper.selectDeviceByDeviceId(v.getDeviceId());
deviceResp.setDeviceName(devBasicInfo.getDeviceName());
deviceResp.setProvinceCode(devBasicInfo.getProvinceCode());
deviceResp.setCityCode(devBasicInfo.getCityCode());
deviceResp.setCountyCode(devBasicInfo.getCountyCode());
//获取设备安装地址经纬度
deviceResp.setInstallAddr(devBasicInfo.getInstallAddr());
deviceResp.setLatitude(devBasicInfo.getLatitude());
deviceResp.setLatitude(devBasicInfo.getLatitude());
deviceRespList.add(deviceResp);
});
}); });
return deviceRespList; return deviceRespList;
} }
@Override @Override
public ManufacturerRespDTO getDeviceManufacturerInfo() { public DeviceRespDTO getDeviceByDeviceId(DeviceSearchDTO deviceSearchDTO) {
ManufacturerRespDTO manufacturerResp = new ManufacturerRespDTO(); log.info("get device info by deviceId: [{}]", deviceSearchDTO.getDeviceId());
//获取厂家名称和类型
List<ManufacturerContentDTO> contents = new ArrayList<>();
List<Integer> codeList = ManufacturerTypeEnum.getAllCodes();
codeList.forEach(v -> {
ManufacturerContentDTO content = new ManufacturerContentDTO();
content.setManufacturerType(v);
content.setManufacturerName(ManufacturerTypeEnum.getByCode(v));
contents.add(content); DeviceDO deviceDO = deviceMapper.selectDeviceByDeviceId(deviceSearchDTO.getDeviceId());
}); if (deviceDO == null) {
log.warn("根据deviceId未查找到设备信息");
manufacturerResp.setData(contents); return null;
return manufacturerResp;
}
@Override
public AlarmDevRespDTO getAlarmDeviceInfo() {
AlarmDevRespDTO respDTO = new AlarmDevRespDTO();
List<AlarmDevContentDTO> contents = new ArrayList<>();
//获取所有的设备属性信息
List<DevAttributesDO> devMaunDTOList = devAttributesMapper.selectManuAll();
if (devMaunDTOList.isEmpty()) {
log.warn("不存在告警终端");
return new AlarmDevRespDTO();
} }
int totalMum = devMaunDTOList.size(); DeviceRespDTO respDTO = DeviceRespDTO.builder()
.deviceId(deviceDO.getDeviceId())
.deviceName(deviceDO.getDeviceName())
.countyCode(deviceDO.getCountyCode())
.cityCode(deviceDO.getCityCode())
.provinceCode(deviceDO.getProvinceCode())
.latitude(deviceDO.getLatitude())
.longitude(deviceDO.getLongitude())
.installSite(deviceDO.getInstallSite()).build();
//分别过滤出不同的警报器类型
List<Integer> typeList = AlarmTypeEnum.getAllCodes();
typeList.forEach(type -> {
AlarmDevContentDTO content = new AlarmDevContentDTO();
String typeMsg = AlarmTypeEnum.getByCode(type);
log.info("alarm type :[{}]", typeMsg);
//过滤出不同类型的设备属性
List<DevAttributesDO> devType = devMaunDTOList.stream().filter(v -> v.getAlarmType().equals(type)).collect(Collectors.toList());
content.setAlarmType(typeMsg);
content.setAlarmNum(devType.size());
double ratio = (double) devType.size() / (double) totalMum;
content.setAlarmRatio(ratio);
contents.add(content);
});
respDTO.setAlarmDevTotalNum(totalMum);
respDTO.setData(contents);
return respDTO; return respDTO;
} }
} }

View File

@ -1,107 +0,0 @@
package com.zjyr.beidouservice.service.impl;
import com.zjyr.beidouservice.mapper.DevTaskMapper;
import com.zjyr.beidouservice.mapper.TaskMapper;
import com.zjyr.beidouservice.pojo.dataobject.DevTaskDO;
import com.zjyr.beidouservice.pojo.dataobject.TaskDO;
import com.zjyr.beidouservice.pojo.dto.DevTaskExecRespDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceTaskContentDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceTaskExecReqDTO;
import com.zjyr.beidouservice.pojo.dto.DeviceTaskRespDTO;
import com.zjyr.beidouservice.service.DeviceTaskService;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
@Service
@Slf4j
public class DeviceTaskServiceImpl implements DeviceTaskService {
@Resource
DevTaskMapper devTaskMapper;
@Resource
TaskMapper taskMapper;
@Override
public List<DeviceTaskRespDTO> getDeviceTaskInfo() {
log.info(" get all device task information");
List<DeviceTaskRespDTO> respDTOList = new ArrayList<>();
//获取所有任务id
List<TaskDO> taskDOList = taskMapper.selectAllTask();
if (taskDOList.isEmpty()) {
log.warn("不存在终端设备告警任务");
return new ArrayList<>();
}
taskDOList.forEach(task -> {
DeviceTaskRespDTO taskResp = new DeviceTaskRespDTO();
taskResp.setId(task.getId());
taskResp.setTaskId(task.getTaskId());
//告警任务记录时间为任务创建时间
taskResp.setRecodeTime(task.getCreateTime());
//告警任务回示率,收到响应信息的设备数量(执行成功执行失败)/总设备数量
int respNum = task.getExecNormalNum() + task.getExecAbnormalNum();
int deviceNum = task.getDeviceNum();
double respRate = (double) respNum / (double) deviceNum;
//告警任务执行设备数量执行正常数量执行异常数量回示率
taskResp.setDeviceNum(deviceNum);
taskResp.setExecNormalNum(task.getExecNormalNum());
taskResp.setExecAbnormalNum(task.getExecAbnormalNum());
taskResp.setRespRate(respRate);
//获取任务id详细信息
List<DeviceTaskContentDTO> devTaskContents = new ArrayList<>();
List<DevTaskDO> devTaskDOList = devTaskMapper.selectDevTaskByTaskId(task.getTaskId());
if (devTaskDOList.isEmpty()) {
log.warn("根据任务Id: [{}] 获取不到告警任务详情信息", task.getTaskId());
taskResp.setData(new ArrayList<>());
}
devTaskDOList.forEach(devTask -> {
DeviceTaskContentDTO devTaskContent = new DeviceTaskContentDTO();
devTaskContent.setDeviceId(devTask.getDeviceId());
devTaskContent.setDeviceName(devTask.getDeviceName());
//回示时间为dev task表中的更新时间收到执行状态后更新时间
devTaskContent.setRespTime(devTask.getUpdateTime());
devTaskContent.setExecState(devTask.getExecState());
devTaskContents.add(devTaskContent);
});
taskResp.setData(devTaskContents);
respDTOList.add(taskResp);
});
// 使用自定义比较器按recodeTime排序
respDTOList.sort(new Comparator<DeviceTaskRespDTO>() {
public int compare(DeviceTaskRespDTO t1, DeviceTaskRespDTO t2) {
return t2.getRecodeTime().compareTo(t1.getRecodeTime());
}
});
return respDTOList;
}
@Override
public DevTaskExecRespDTO deviceTaskExec(DeviceTaskExecReqDTO deviceTaskExecReqDTO) {
DevTaskExecRespDTO deviceTaskRespDTO = new DevTaskExecRespDTO();
//todo 北斗号 beidouId如果以市为单位则携带市北斗号区为单位携带区北斗号具体设备则携带区北斗号
//todo 控制类型 controlType:1:单点控制 2:市属控制 3:区属控制
return deviceTaskRespDTO;
}
}

View File

@ -38,7 +38,7 @@ public class LocationServiceImpl implements LocationService {
@Override @Override
public OnlyProvinceResp getOnlyProvinces() { public OnlyProvinceResp getOnlyProvinces() {
OnlyProvinceResp onlyProvinceResp = new OnlyProvinceResp(); OnlyProvinceResp onlyProvinceResp = new OnlyProvinceResp();
List<OnlyProvinceContentDTO> onlyProvinceList = new ArrayList<>(); List<OnlyProvinceContentDTO> onlyProvinceList = new ArrayList<>();
//获取省份信息 //获取省份信息
@ -61,12 +61,12 @@ public class LocationServiceImpl implements LocationService {
@Override @Override
public ProvinceRespDTO getProvinces(ProvinceSearchDTO provinceSearchDTO) { public ProvinceRespDTO getProvinces(ProvinceSearchDTO provinceSearchDTO) {
ProvinceRespDTO provinceResp = new ProvinceRespDTO(); ProvinceRespDTO provinceResp = new ProvinceRespDTO();
List<ProvinceContent> provinceContents = new ArrayList<>(); List<ProvinceContent> provinceContents = new ArrayList<>();
//获取省份信息 //获取省份信息
String provinceCode = provinceSearchDTO.getProvinceCode(); Integer provinceCode = provinceSearchDTO.getProvinceCode();
List<LocProvinceDO> provinceDOS = locProvinceMapper.selectProvince(provinceCode); List<LocProvinceDO> provinceDOS = locProvinceMapper.selectProvince(provinceCode);
if (provinceDOS.isEmpty()) { if (provinceDOS.isEmpty()) {
log.warn("不存在省份信息"); log.warn("不存在省份信息");
return new ProvinceRespDTO(); return new ProvinceRespDTO();
@ -80,7 +80,7 @@ public class LocationServiceImpl implements LocationService {
//根据省份查询对应的地市信息 //根据省份查询对应的地市信息
List<CityContentDTO> cityContentDTOList = new ArrayList<>(); List<CityContentDTO> cityContentDTOList = new ArrayList<>();
List<LocCityDO> cityDOList = locCityMapper.selectCityByProvince(province.getProvinceCode()); List<LocCityDO> cityDOList = locCityMapper.selectCityByProvince(province.getProvinceCode());
cityDOList.forEach(city -> { cityDOList.forEach(city -> {
CityContentDTO cityContent = new CityContentDTO(); CityContentDTO cityContent = new CityContentDTO();
cityContent.setCityName(city.getCityName()); cityContent.setCityName(city.getCityName());
@ -100,13 +100,13 @@ public class LocationServiceImpl implements LocationService {
@Override @Override
public CityRespDTO getCity(CitySearchDTO citySearchDTO) { public CityRespDTO getCity(CitySearchDTO citySearchDTO) {
CityRespDTO cityResp = new CityRespDTO(); CityRespDTO cityResp = new CityRespDTO();
List<CityCountyDTO> cityContents = new ArrayList<>(); List<CityCountyDTO> cityContents = new ArrayList<>();
//获取地市信息 //获取地市信息
String provinceCode = citySearchDTO.getProvinceCode(); Integer provinceCode = citySearchDTO.getProvinceCode();
String cityCode = citySearchDTO.getCityCode(); Integer cityCode = citySearchDTO.getCityCode();
List<LocCityDO> cityDOS = locCityMapper.selectCity(provinceCode, cityCode); List<LocCityDO> cityDOS = locCityMapper.selectCity(provinceCode, cityCode);
if (cityDOS.isEmpty()) { if (cityDOS.isEmpty()) {
log.warn("不存在地市信息"); log.warn("不存在地市信息");
return new CityRespDTO(); return new CityRespDTO();
@ -120,7 +120,7 @@ public class LocationServiceImpl implements LocationService {
//根据地市查询对应的区信息 //根据地市查询对应的区信息
List<CountyContent> countyContentList = new ArrayList<>(); List<CountyContent> countyContentList = new ArrayList<>();
List<LocCountyDO> countyDOList = locCountyMapper.selectCountyByCity(city.getProvinceCode(), city.getCityCode()); List<LocCountyDO> countyDOList = locCountyMapper.selectCountyByCity(city.getProvinceCode(), city.getCityCode());
countyDOList.forEach(county -> { countyDOList.forEach(county -> {
CountyContent countyContent = new CountyContent(); CountyContent countyContent = new CountyContent();
countyContent.setCountyName(county.getCountyName()); countyContent.setCountyName(county.getCountyName());

View File

@ -0,0 +1,27 @@
<?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.zjyr.beidouservice.mapper.AlarmDeviceTaskMapper">
<resultMap id="alarm_device_task" type="com.zjyr.beidouservice.pojo.dataobject.AlarmDeviceTaskDO">
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="taskId" column="task_id" jdbcType="VARCHAR"/>
<result property="deviceId" column="device_id" jdbcType="INTEGER"/>
<result property="controlChannel" column="control_channel" jdbcType="INTEGER"/>
<result property="sendTime" column="send_time" jdbcType="TIMESTAMP"/>
<result property="status" column="status" jdbcType="INTEGER"/>
<result property="reportTime" column="report_time" jdbcType="TIMESTAMP"/>
</resultMap>
<insert id="addAlarmDevTaskInfoList" useGeneratedKeys="true" keyProperty="id"
parameterType="com.zjyr.beidouservice.pojo.dataobject.AlarmDeviceTaskDO">
INSERT IGNORE INTO alarm_device_task(taskId, deviceId, controlChannel, sendTime, status, reportTime)
VALUES
<foreach collection="taskLists" item="task" separator=",">
(#{task.taskId}, #{task.deviceId}, #{controlChannel},#{task.sendTime}, #{task.status}, #{task.reportTime})
</foreach>
</insert>
</mapper>

View File

@ -0,0 +1,91 @@
<?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.zjyr.beidouservice.mapper.AlarmTaskMapper">
<resultMap id="alarm_task" type="com.zjyr.beidouservice.pojo.dataobject.AlarmTaskDO">
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="taskId" column="task_id" jdbcType="VARCHAR"/>
<result property="alarmType" column="alarm_type" jdbcType="INTEGER"/>
<result property="alarmKind" column="alarm_kind" jdbcType="INTEGER"/>
<result property="alarmCounty" column="alarm_county" jdbcType="VARCHAR"/>
<result property="deviceIds" column="device_ids" jdbcType="VARCHAR"/>
<result property="alarmMode" column="alarm_mode" jdbcType="INTEGER"/>
<result property="controlChannel" column="control_channel" jdbcType="INTEGER"/>
<result property="sender" column="sender" jdbcType="VARCHAR"/>
<result property="sendTime" column="send_time" jdbcType="TIMESTAMP"/>
<result property="approvalStatus" column="approval_status" jdbcType="INTEGER"/>
</resultMap>
<insert id="addAlarmTask" parameterType="com.zjyr.beidouservice.pojo.dataobject.AlarmTaskDO" useGeneratedKeys="true" keyProperty="id">
<!--@mbg.generated-->
insert into alarm_task
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="taskId != null">
task_id,
</if>
<if test="alarmType != null">
alarm_type,
</if>
<if test="alarmKind != null">
alarm_kind,
</if>
<if test="alarmCounty != null and alarmCounty != ''">
alarm_county,
</if>
<if test="deviceIds != null and deviceIds != ''">
device_ids,
</if>
<if test="alarmMode != null">
alarm_mode,
</if>
<if test="controlChannel != null">
control_channel,
</if>
<if test="sender != null and sender != ''">
sender,
</if>
<if test="sendTime != null and sendTime != ''">
send_time,
</if>
<if test="approvalStatus != null ">
approval_status,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="taskId != null">
#{task, jdbcType=VARCHAR},
</if>
<if test="alarmType != null">
#{alarmType,jdbcType=TINYINT},
</if>
<if test="alarmKind != null">
#{alarmKind,jdbcType=TINYINT},
</if>
<if test="alarmCounty != null and alarmCounty != ''">
#{alarmCounty,jdbcType=VARCHAR},
</if>
<if test="deviceIds != null and deviceIds != ''">
#{deviceIds,jdbcType=VARCHAR},
</if>
<if test="alarmMode != null">
#{alarmMode,jdbcType=TINYINT},
</if>
<if test="controlChannel != null">
#{controlChannel,jdbcType=TINYINT},
</if>
<if test="sender != null and sender != ''">
#{sender,jdbcType=VARCHAR},
</if>
<if test="sendTime != null and sendTime != ''">
#{sendTime,jdbcType=VARCHAR},
</if>
<if test="approvalStatus != null ">
#{approvalStatus,jdbcType=TINYINT},
</if>
</trim>
</insert>
</mapper>

View File

@ -1,49 +0,0 @@
<?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.zjyr.beidouservice.mapper.DevAttributesMapper">
<resultMap id="device_attributes" type="com.zjyr.beidouservice.pojo.dataobject.DevAttributesDO">
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="deviceId" column="device_id" jdbcType="BIGINT"/>
<result property="deviceStatus" column="device_status" jdbcType="INTEGER"/>
<result property="alarmModel" column="alarm_model" jdbcType="VARCHAR"/>
<result property="alarmStatus" column="alarm_status" jdbcType="INTEGER"/>
<result property="alarmType" column="alarm_type" jdbcType="INTEGER"/>
<result property="alarmPower" column="alarm_power" jdbcType="INTEGER"/>
<result property="alarmManufacturer" column="alarm_manufacturer" jdbcType="INTEGER"/>
<result property="alarmInstallTime" column="alarm_install_time" jdbcType="TIMESTAMP"/>
<result property="controlModel" column="control_model" jdbcType="VARCHAR"/>
<result property="controlStatus" column="control_status" jdbcType="INTEGER"/>
<result property="controlManufacturer" column="control_manufacturer" jdbcType="INTEGER"/>
<result property="controlInstallTime" column="control_install_time" jdbcType="TIMESTAMP"/>
<result property="powerModel" column="power_model" jdbcType="VARCHAR"/>
<result property="powerStatus" column="power_status" jdbcType="INTEGER"/>
<result property="powerType" column="power_type" jdbcType="INTEGER"/>
<result property="power" column="power" jdbcType="INTEGER"/>
<result property="powerManufacturer" column="power_manufacturer" jdbcType="INTEGER"/>
<result property="powerInstallTime" column="power_install_time" jdbcType="TIMESTAMP"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<select id="selectManuByManufacturer" resultType="com.zjyr.beidouservice.pojo.dto.DevMaunDTO">
select device_id as deviceId,
alarm_manufacturer as alarmManufacturer,
control_manufacturer as controlManufacturer
from device_attributes
<where>
<if test="deviceId != null">
and device_id = #{deviceId}
</if>
<if test="manufacturer != null and manufacturer != ''">
and (alarm_manufacturer = #{manufacturer} or control_manufacturer = #{manufacturer})
</if>
</where>
</select>
<select id="selectManuAll" resultType="com.zjyr.beidouservice.pojo.dto.DevMaunDTO" resultMap="device_attributes">
select *
from device_attributes
</select>
</mapper>

View File

@ -1,26 +0,0 @@
<?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.zjyr.beidouservice.mapper.DevTaskMapper">
<resultMap id="device_task" type="com.zjyr.beidouservice.pojo.dataobject.DevTaskDO">
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="taskId" column="task_id" jdbcType="VARCHAR"/>
<result property="controlMode" column="control_mode" jdbcType="INTEGER"/>
<result property="countyCode" column="county_code" jdbcType="VARCHAR"/>
<result property="controlType" column="control_type" jdbcType="INTEGER"/>
<result property="deviceId" column="device_id" jdbcType="INTEGER"/>
<result property="deviceName" column="device_name" jdbcType="VARCHAR"/>
<result property="execCmd" column="exec_cmd" jdbcType="VARCHAR"/>
<result property="execState" column="exec_state" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<select id="selectDevTaskByTaskId" resultType="com.zjyr.beidouservice.pojo.dataobject.DevTaskDO"
parameterType="java.lang.String" resultMap="device_task">
select *
from device_task
where task_id = #{taskId}
</select>
</mapper>

View File

@ -1,38 +1,43 @@
<?xml version="1.0" encoding="UTF-8"?> <?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"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zjyr.beidouservice.mapper.DevBasicInfoMapper"> <mapper namespace="com.zjyr.beidouservice.mapper.DeviceMapper">
<resultMap id="device_basic_info" type="com.zjyr.beidouservice.pojo.dataobject.DevBasicInfoDO"> <resultMap id="device" type="com.zjyr.beidouservice.pojo.dataobject.DeviceDO">
<result property="id" column="id" jdbcType="BIGINT"/> <result property="id" column="id" jdbcType="BIGINT"/>
<result property="deviceId" column="device_id" jdbcType="INTEGER"/> <result property="deviceId" column="device_id" jdbcType="INTEGER"/>
<result property="beidouId" column="beidou_id" jdbcType="INTEGER"/>
<result property="deviceName" column="device_name" jdbcType="VARCHAR"/> <result property="deviceName" column="device_name" jdbcType="VARCHAR"/>
<result property="deviceDesc" column="device_desc" jdbcType="VARCHAR"/> <result property="directDialing" column="direct_dialing" jdbcType="INTEGER"/>
<result property="provinceCode" column="province_code" jdbcType="VARCHAR"/> <result property="latitude" column="latitude" jdbcType="FLOAT"/>
<result property="cityCode" column="city_code" jdbcType="VARCHAR"/> <result property="longitude" column="longitude" jdbcType="FLOAT"/>
<result property="countyCode" column="county_code" jdbcType="VARCHAR"/> <result property="streetCode" column="street_code" jdbcType="VARCHAR"/>
<result property="subordinateUnits" column="subordinate_units" jdbcType="VARCHAR"/> <result property="countyCode" column="county_code" jdbcType="INTEGER"/>
<result property="controlStationId" column="control_station_id" jdbcType="INTEGER"/> <result property="cityCode" column="city_code" jdbcType="INTEGER"/>
<result property="administrator" column="administrator" jdbcType="VARCHAR"/> <result property="provinceCode" column="province_code" jdbcType="INTEGER"/>
<result property="signalStrength" column="signal_strength" jdbcType="INTEGER"/>
<result property="installSite" column="install_site" jdbcType="VARCHAR"/>
<result property="mobile" column="mobile" jdbcType="VARCHAR"/> <result property="mobile" column="mobile" jdbcType="VARCHAR"/>
<result property="installAddr" column="install_addr" jdbcType="VARCHAR"/> <result property="installTime" column="install_time" jdbcType="TIMESTAMP"/>
<result property="latitude" column="latitude" jdbcType="VARCHAR"/> <result property="state" column="state" jdbcType="INTEGER"/>
<result property="longitude" column="longitude" jdbcType="VARCHAR"/> <result property="model" column="model" jdbcType="VARCHAR"/>
<result property="devData" column="dev_data" jdbcType="VARCHAR"/> <result property="type" column="type" jdbcType="INTEGER"/>
<result property="manufacturer" column="manufacturer" jdbcType="VARCHAR"/>
<result property="power" column="power" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
<select id="selectDeviceByLoc" resultType="com.zjyr.beidouservice.pojo.dataobject.DevBasicInfoDO" <select id="selectDeviceByLoc" resultType="com.zjyr.beidouservice.pojo.dataobject.DeviceDO"
parameterType="com.zjyr.beidouservice.pojo.dto.DeviceInfoByLocDTO" resultMap="device_basic_info"> parameterType="com.zjyr.beidouservice.pojo.dto.DeviceByLocationDTO" resultMap="device">
select * select *
from device_basic_info from device
<where> <where>
<if test="provinceCode != null and provinceCode != ''"> <if test="provinceCode != null">
and province_code = #{provinceCode} and province_code = #{provinceCode}
</if> </if>
<if test="cityCode != null and cityCode != ''"> <if test="cityCode != null">
and city_code = #{cityCode} and city_code = #{cityCode}
</if> </if>
<if test="countyCode != null and countyCode != ''"> <if test="countyCode != null">
and county_code = #{countyCode} and county_code = #{countyCode}
</if> </if>
<if test="deviceName != null and deviceName != ''"> <if test="deviceName != null and deviceName != ''">
@ -41,11 +46,13 @@
</where> </where>
</select> </select>
<select id="selectDeviceByDeviceId" resultType="com.zjyr.beidouservice.pojo.dataobject.DevBasicInfoDO"
parameterType="java.lang.Long" resultMap="device_basic_info"> <select id="selectDeviceByDeviceId" resultType="com.zjyr.beidouservice.pojo.dataobject.DeviceDO"
parameterType="java.lang.Long" resultMap="device">
select * select *
from device_basic_info from device
where device_id = #{deviceId} where device_id = #{deviceId}
</select> </select>
</mapper> </mapper>

View File

@ -4,9 +4,9 @@
<resultMap id="location_city" type="com.zjyr.beidouservice.pojo.dataobject.LocCityDO"> <resultMap id="location_city" type="com.zjyr.beidouservice.pojo.dataobject.LocCityDO">
<result property="id" column="id" jdbcType="BIGINT"/> <result property="id" column="id" jdbcType="BIGINT"/>
<result property="cityName" column="city_name" jdbcType="VARCHAR"/> <result property="cityName" column="city_name" jdbcType="VARCHAR"/>
<result property="cityCode" column="city_code" jdbcType="VARCHAR"/> <result property="cityCode" column="city_code" jdbcType="INTEGER"/>
<result property="provinceCode" column="province_code" jdbcType="VARCHAR"/> <result property="provinceCode" column="province_code" jdbcType="INTEGER"/>
<result property="beidouBroadcastId" column="beidou_broadcast_id" jdbcType="VARCHAR"/> <result property="beidouBroadcastId" column="beidou_broadcast_id" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
@ -17,24 +17,38 @@
select * select *
from location_city from location_city
<where> <where>
<if test="provinceCode != null and provinceCode != ''"> <if test="provinceCode != null">
and province_code = #{provinceCode} and province_code = #{provinceCode}
</if> </if>
<if test="cityCode != null and cityCode != ''"> <if test="cityCode != null">
and city_code = #{cityCode} and city_code = #{cityCode}
</if> </if>
</where> </where>
</select> </select>
<select id="selectCitys" resultType="java.lang.String" parameterType="java.lang.String" resultMap="location_city">
select city_code
from location_city
<where>
<if test="provinceCode != null">
and province_code = #{provinceCode}
</if>
</where>
</select>
<select id="selectCityByProvince" resultType="com.zjyr.beidouservice.pojo.dataobject.LocCityDO" <select id="selectCityByProvince" resultType="com.zjyr.beidouservice.pojo.dataobject.LocCityDO"
parameterType="java.lang.String" resultMap="location_city"> parameterType="java.lang.String" resultMap="location_city">
select * select *
from location_city from location_city
<where> <where>
<if test="provinceCode != null and provinceCode != ''"> <if test="provinceCode != null">
and province_code = #{provinceCode} and province_code = #{provinceCode}
</if> </if>
</where> </where>
</select> </select>
</mapper> </mapper>

View File

@ -27,4 +27,5 @@
</select> </select>
</mapper> </mapper>

View File

@ -4,7 +4,7 @@
<resultMap id="location_province" type="com.zjyr.beidouservice.pojo.dataobject.LocProvinceDO"> <resultMap id="location_province" type="com.zjyr.beidouservice.pojo.dataobject.LocProvinceDO">
<result property="id" column="id" jdbcType="BIGINT"/> <result property="id" column="id" jdbcType="BIGINT"/>
<result property="provinceName" column="province_name" jdbcType="VARCHAR"/> <result property="provinceName" column="province_name" jdbcType="VARCHAR"/>
<result property="provinceCode" column="province_code" jdbcType="VARCHAR"/> <result property="provinceCode" column="province_code" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap> </resultMap>
@ -20,7 +20,7 @@
select * select *
from location_province from location_province
<where> <where>
<if test="provinceCode != null and provinceCode != ''"> <if test="provinceCode != null">
and province_code = #{provinceCode} and province_code = #{provinceCode}
</if> </if>
</where> </where>

View File

@ -0,0 +1,35 @@
<?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.zjyr.beidouservice.mapper.SystemConfigMapper">
<resultMap id="system_config" type="com.zjyr.beidouservice.pojo.dataobject.SystemConfigDO">
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="name" column="name" jdbcType="VARCHAR"/>
<result property="value" column="value" jdbcType="VARCHAR"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<insert id="addConfig" useGeneratedKeys="true" keyProperty="id">
insert
ignore into system_config(name, value)
values (
#{name},
#{vale}
)
</insert>
<update id="updateConfig">
update system_config
set value = #{value},
where name = #{name}
</update>
<select id="getConfigByName" resultType="com.zjyr.beidouservice.pojo.dataobject.SystemConfigDO"
parameterType="java.lang.String" resultMap="system_config">
select *
from system_config
where name = #{name}
</select>
</mapper>

View File

@ -1,26 +0,0 @@
<?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.zjyr.beidouservice.mapper.TaskMapper">
<resultMap id="task" type="com.zjyr.beidouservice.pojo.dataobject.TaskDO">
<result property="id" column="id" jdbcType="BIGINT"/>
<result property="taskId" column="task_id" jdbcType="VARCHAR"/>
<result property="controlChannel" column="control_channel" jdbcType="INTEGER"/>
<result property="beidouId" column="beidou_id" jdbcType="INTEGER"/>
<result property="provinceCode" column="province_code" jdbcType="VARCHAR"/>
<result property="cityCode" column="city_code" jdbcType="VARCHAR"/>
<result property="countyCode" column="county_code" jdbcType="VARCHAR"/>
<result property="deviceIds" column="device_ids" jdbcType="VARCHAR"/>
<result property="deviceNum" column="device_num" jdbcType="INTEGER"/>
<result property="execNormalNum" column="exec_normal_num" jdbcType="INTEGER"/>
<result property="execAbnormalNum" column="exec_abnormal_num" jdbcType="INTEGER"/>
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
</resultMap>
<select id="selectAllTask" resultType="com.zjyr.beidouservice.pojo.dataobject.TaskDO" resultMap="task">
select *
from task
</select>
</mapper>