forked from dyf/fys-Multi-tenant
Compare commits
13 Commits
d219105b73
...
3250dd3f83
Author | SHA1 | Date | |
---|---|---|---|
3250dd3f83 | |||
4cc02e1040 | |||
185d521472 | |||
7e688e16b3 | |||
b876d051d8 | |||
d75658e81e | |||
1dc00f0431 | |||
2a6b9eafb3 | |||
f0bfc4aa35 | |||
ff81b791fc | |||
87f2e3a8b5 | |||
c075c09ee7 | |||
3fb692e7fb |
@ -32,7 +32,7 @@ public class AppDeviceController extends BaseController {
|
||||
private final APPDeviceService appDeviceService;
|
||||
|
||||
/**
|
||||
* 查询文件列表
|
||||
* 查询设备列表
|
||||
*/
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo<AppDeviceVo> list(DeviceQueryCriteria bo, PageQuery pageQuery) {
|
||||
|
@ -52,9 +52,9 @@ spring:
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
# jdbc 所有参数配置参考 https://lionli.blog.csdn.net/article/details/122018562
|
||||
# rewriteBatchedStatements=true 批处理优化 大幅提升批量插入更新删除性能(对数据库有性能损耗 使用批量操作应考虑性能问题)
|
||||
url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
url: jdbc:mysql://localhost:3306/fys_vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&autoReconnect=true&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: root
|
||||
password: Jz_5623_cl1
|
||||
# # 从库数据源
|
||||
# slave:
|
||||
# lazy: true
|
||||
@ -105,9 +105,9 @@ spring.data:
|
||||
# 端口,默认为6379
|
||||
port: 6379
|
||||
# 数据库索引
|
||||
database: 0
|
||||
database: 1
|
||||
# redis 密码必须配置
|
||||
password: fys123
|
||||
password: re_fs_11520631
|
||||
# 连接超时时间
|
||||
timeout: 10s
|
||||
# 是否开启ssl
|
||||
@ -272,3 +272,37 @@ justauth:
|
||||
client-id: 10**********6
|
||||
client-secret: 1f7d08**********5b7**********29e
|
||||
redirect-uri: ${justauth.address}/social-callback?source=gitea
|
||||
|
||||
|
||||
# MQTT配置
|
||||
mqtt:
|
||||
username: admin
|
||||
password: #YtvpSfCNG
|
||||
url: tcp://47.120.79.150:2883
|
||||
subClientId: fys_subClient
|
||||
subTopic: worker/alert/#,worker/location/#
|
||||
pubTopic: worker/location
|
||||
pubClientId: fys_pubClient
|
||||
|
||||
|
||||
# 文件存储路径
|
||||
file:
|
||||
mac:
|
||||
path: ~/file/
|
||||
avatar: ~/avatar/
|
||||
linux:
|
||||
path: /home/eladmin/file/
|
||||
avatar: /home/eladmin/avatar/
|
||||
windows:
|
||||
path: C:\eladmin\file\
|
||||
avatar: C:\eladmin\avatar\
|
||||
# 文件大小 /M
|
||||
maxSize: 100
|
||||
avatarMaxSize: 5
|
||||
device:
|
||||
pic: C:\eladmin\file\ #设备图片存储路径
|
||||
ip: http://fuyuanshen.com:81/ #服务器地址
|
||||
app_avatar:
|
||||
pic: C:\eladmin\file\ #设备图片存储路径
|
||||
#ip: http://fuyuanshen.com:81/ #服务器地址
|
||||
ip: https://fuyuanshen.com/ #服务器地址
|
@ -1,7 +1,7 @@
|
||||
# 开发环境配置
|
||||
server:
|
||||
# 服务器的HTTP端口,默认为8080
|
||||
port: 8001
|
||||
port: 8000
|
||||
servlet:
|
||||
# 应用的访问路径
|
||||
context-path: /
|
||||
|
@ -6,8 +6,20 @@ import com.fuyuanshen.app.domain.APPDeviceType;
|
||||
import com.fuyuanshen.app.domain.dto.APPUnbindDTO;
|
||||
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
||||
import com.fuyuanshen.app.service.equipment.APPDeviceService;
|
||||
import com.fuyuanshen.common.core.domain.R;
|
||||
import com.fuyuanshen.common.core.domain.ResponseVO;
|
||||
import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.log.enums.BusinessType;
|
||||
import com.fuyuanshen.common.mybatis.core.page.PageQuery;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.bo.UserAppBo;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.equipment.service.AppUserService;
|
||||
import com.fuyuanshen.equipment.service.DeviceService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -27,9 +39,11 @@ import java.util.List;
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/app/device")
|
||||
public class APPDeviceController {
|
||||
public class APPDeviceController extends BaseController {
|
||||
|
||||
private final APPDeviceService appDeviceService;
|
||||
private final AppUserService appUserService;
|
||||
private final DeviceService deviceService;
|
||||
|
||||
|
||||
@PostMapping(value = "/list")
|
||||
@ -59,11 +73,8 @@ public class APPDeviceController {
|
||||
|
||||
@GetMapping
|
||||
@Operation(summary = "WEB端查看APP客户设备绑定")
|
||||
public TableDataInfo<APPDevice> queryAPPDevice(APPDeviceQueryCriteria criteria) {
|
||||
Page<APPDevice> page = new Page<>(criteria.getPage(), criteria.getSize());
|
||||
TableDataInfo<APPDevice> devices = null;
|
||||
devices = appDeviceService.queryAll(page, criteria);
|
||||
return devices;
|
||||
public TableDataInfo<AppDeviceVo> queryAPPDevice(DeviceQueryCriteria bo, PageQuery pageQuery) {
|
||||
return deviceService.queryAppDeviceList(bo, pageQuery);
|
||||
}
|
||||
|
||||
|
||||
@ -75,5 +86,16 @@ public class APPDeviceController {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 修改APP用户信息
|
||||
*/
|
||||
// @SaCheckPermission("app:user:edit")
|
||||
@Log(title = "APP用户信息", businessType = BusinessType.UPDATE)
|
||||
@RepeatSubmit()
|
||||
@PutMapping()
|
||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody UserAppBo bo) {
|
||||
return toAjax(appUserService.updateByBo(bo));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ import com.fuyuanshen.app.domain.dto.APPUnbindDTO;
|
||||
import com.fuyuanshen.app.domain.query.APPDeviceQueryCriteria;
|
||||
import com.fuyuanshen.app.domain.vo.APPDeviceTypeVo;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -62,4 +63,14 @@ public interface APPDeviceService extends IService<APPDevice> {
|
||||
List<APPDeviceTypeVo> getTypeList();
|
||||
|
||||
void reName(APPReNameDTO reNameDTO);
|
||||
|
||||
/**
|
||||
* WEB端查看APP客户设备绑定
|
||||
*
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
TableDataInfo<APPDevice> queryAppDeviceList(DeviceQueryCriteria criteria);
|
||||
|
||||
|
||||
}
|
||||
|
@ -23,6 +23,8 @@ import com.fuyuanshen.common.satoken.utils.AppLoginHelper;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.vo.AppDeviceVo;
|
||||
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
|
||||
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
@ -210,4 +212,20 @@ public class APPDeviceServiceImpl extends ServiceImpl<APPDeviceMapper, APPDevice
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* WEB端查看APP客户设备绑定
|
||||
*
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<APPDevice> queryAppDeviceList(DeviceQueryCriteria criteria) {
|
||||
|
||||
// Page<AppDeviceVo> result = baseMapper.queryAppDeviceList(pageQuery.build(), bo);
|
||||
// return TableDataInfo.build(result);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -79,17 +79,19 @@
|
||||
<if test="criteria.createTime != null and criteria.createTime.size() != 0">
|
||||
and d.create_time between #{criteria.createTime[0]} and #{criteria.createTime[1]}
|
||||
</if>
|
||||
<if test="criteria.tenantId != null">
|
||||
AND tenant_id = #{criteria.tenantId}
|
||||
</if>
|
||||
and d.customer_id = #{criteria.customerId}
|
||||
</where>
|
||||
order by d.create_time desc
|
||||
</select>
|
||||
|
||||
<select id="getTypeList" resultType="com.fuyuanshen.app.domain.vo.APPDeviceTypeVo">
|
||||
SELECT dt.id, dt.type_name, dt.communication_mode FROM device_type dt
|
||||
WHERE EXISTS(select 1 from device d where d.device_type = dt.id and d.binding_user_id = #{userId} AND d.binding_status = 1 )
|
||||
SELECT dt.id, dt.type_name, dt.communication_mode
|
||||
FROM device_type dt
|
||||
WHERE EXISTS(select 1
|
||||
from device d
|
||||
where d.device_type = dt.id
|
||||
and d.binding_user_id = #{userId}
|
||||
AND d.binding_status = 1)
|
||||
</select>
|
||||
|
||||
|
||||
|
@ -6,17 +6,17 @@ import com.fuyuanshen.common.core.validate.EditGroup;
|
||||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||||
import com.fuyuanshen.common.log.annotation.Log;
|
||||
import com.fuyuanshen.common.log.enums.BusinessType;
|
||||
import com.fuyuanshen.common.mybatis.core.page.TableDataInfo;
|
||||
import com.fuyuanshen.common.web.core.BaseController;
|
||||
import com.fuyuanshen.equipment.domain.bo.UserAppBo;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.service.AppUserService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PutMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
@ -27,7 +27,7 @@ import org.springframework.web.bind.annotation.RestController;
|
||||
@Tag(name = "设备管理", description = "设备:设备管理")
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/api/app/device")
|
||||
@RequestMapping("/api/app/device1")
|
||||
public class DeviceAPPController extends BaseController {
|
||||
|
||||
private final AppUserService appUserService;
|
||||
@ -44,6 +44,11 @@ public class DeviceAPPController extends BaseController {
|
||||
return toAjax(appUserService.updateByBo(bo));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -21,6 +21,7 @@ import com.fuyuanshen.equipment.excel.UploadDeviceDataListener;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||
import com.fuyuanshen.equipment.service.DeviceService;
|
||||
import com.fuyuanshen.equipment.service.DeviceTypeService;
|
||||
import com.fuyuanshen.equipment.service.impl.DeviceExportService;
|
||||
import com.fuyuanshen.system.service.ISysOssService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
@ -54,6 +55,7 @@ public class DeviceController {
|
||||
private final DeviceService deviceService;
|
||||
private final DeviceMapper deviceMapper;
|
||||
private final CustomerMapper customerMapper;
|
||||
private final DeviceTypeService deviceTypeService;
|
||||
private final DeviceTypeMapper deviceTypeMapper;
|
||||
|
||||
private final DeviceExportService exportService;
|
||||
@ -179,7 +181,11 @@ public class DeviceController {
|
||||
ImportResult result = new ImportResult();
|
||||
try {
|
||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||
DeviceImportParams params = DeviceImportParams.builder().ossService(ossService).deviceService(deviceService).tenantId(loginUser.getTenantId()).file(file).filePath("").deviceMapper(deviceMapper).deviceTypeMapper(deviceTypeMapper).userId(loginUser.getUserId()).customerMapper(customerMapper).build();
|
||||
DeviceImportParams params = DeviceImportParams.builder().ossService(ossService)
|
||||
.deviceService(deviceService).tenantId(loginUser.getTenantId())
|
||||
.file(file).filePath("").deviceMapper(deviceMapper).deviceTypeService(deviceTypeService)
|
||||
.deviceTypeMapper(deviceTypeMapper).userId(loginUser.getUserId())
|
||||
.customerMapper(customerMapper).build();
|
||||
// 创建监听器
|
||||
UploadDeviceDataListener listener = new UploadDeviceDataListener(params);
|
||||
// 读取Excel
|
||||
|
@ -0,0 +1,106 @@
|
||||
package com.fuyuanshen.equipment.domain;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.bean.copier.CopyOptions;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fuyuanshen.common.tenant.core.TenantEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @Description: 设备表
|
||||
* @Author: WY
|
||||
* @Date: 2025/5/16
|
||||
**/
|
||||
@Data
|
||||
@TableName("app_device")
|
||||
public class APPDevice1 extends TenantEntity {
|
||||
|
||||
@TableId(value = "app_device_id", type = IdType.AUTO)
|
||||
@Schema(name = "ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(name = "设备类型")
|
||||
private Long deviceType;
|
||||
|
||||
@Schema(name = "设备类型名称")
|
||||
private String deviceTypeName;
|
||||
|
||||
@Schema(name = "客户号")
|
||||
private Long customerId;
|
||||
|
||||
@Schema(name = "所属客户")
|
||||
private String customerName;
|
||||
|
||||
/*@Schema(name = "设备编号")
|
||||
private String deviceNo;*/
|
||||
|
||||
@Schema(name = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(name = "设备图片")
|
||||
private String devicePic;
|
||||
|
||||
@Schema(name = "设备MAC")
|
||||
private String deviceMac;
|
||||
|
||||
@Schema(name = "设备IMEI")
|
||||
private String deviceImei;
|
||||
|
||||
@Schema(name = "设备SN")
|
||||
private String deviceSn;
|
||||
|
||||
@Schema(name = "经度")
|
||||
private String longitude;
|
||||
|
||||
@Schema(name = "纬度")
|
||||
private String latitude;
|
||||
|
||||
@Schema(name = "备注")
|
||||
private String remark;
|
||||
|
||||
@TableField(exist = false)
|
||||
@Schema(name = "设备类型名称")
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@TableField(value = "tenant_id")
|
||||
@Schema(hidden = true)
|
||||
private String tenantId;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
* 0 失效
|
||||
* 1 正常
|
||||
*/
|
||||
@Schema(name = "设备状态")
|
||||
private Integer deviceStatus;
|
||||
|
||||
/**
|
||||
* 绑定状态
|
||||
* 0 未绑定
|
||||
* 1 已绑定
|
||||
*/
|
||||
@Schema(name = "绑定状态")
|
||||
private Integer bindingStatus;
|
||||
|
||||
/**
|
||||
* 绑定类型
|
||||
* 0 APP
|
||||
* 1 小程序
|
||||
*/
|
||||
@Schema(name = "绑定类型")
|
||||
private Integer bindingType;
|
||||
|
||||
|
||||
public void copy(APPDevice1 source) {
|
||||
BeanUtil.copyProperties(source, this, CopyOptions.create().setIgnoreNullValue(true));
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -59,7 +59,7 @@ public class Device extends TenantEntity {
|
||||
@Schema(name = "原始设备")
|
||||
private Long originalDeviceId;
|
||||
|
||||
@Schema( name = "设备编号")
|
||||
@Schema(name = "设备编号")
|
||||
private String deviceNo;
|
||||
|
||||
@Schema(name = "设备名称")
|
||||
@ -71,6 +71,9 @@ public class Device extends TenantEntity {
|
||||
@Schema(name = "设备MAC")
|
||||
private String deviceMac;
|
||||
|
||||
@Schema(name = "蓝牙名称")
|
||||
private String bluetoothName;
|
||||
|
||||
@Schema(name = "设备IMEI")
|
||||
private String deviceImei;
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
|
||||
import com.alibaba.excel.annotation.write.style.ContentRowHeight;
|
||||
import com.alibaba.excel.annotation.write.style.HeadRowHeight;
|
||||
import com.fuyuanshen.equipment.converter.IgnoreFailedImageConverter;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.net.URL;
|
||||
@ -42,6 +43,10 @@ public class DeviceExcelExportDTO {
|
||||
@ColumnWidth(20)
|
||||
private String deviceMac;
|
||||
|
||||
@ExcelProperty("蓝牙名称")
|
||||
@ColumnWidth(20)
|
||||
private String bluetoothName;
|
||||
|
||||
@ExcelProperty("设备IMEI")
|
||||
@ColumnWidth(20)
|
||||
private String deviceImei;
|
||||
|
@ -40,6 +40,10 @@ public class DeviceForm {
|
||||
@Schema(title = "设备MAC")
|
||||
private String deviceMac;
|
||||
|
||||
@Schema(name = "蓝牙名称")
|
||||
private String bluetoothName;
|
||||
|
||||
|
||||
@Schema(title = "设备IMEI")
|
||||
private String deviceImei;
|
||||
|
||||
|
@ -0,0 +1,65 @@
|
||||
package com.fuyuanshen.equipment.domain.query;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
* @Author: WY
|
||||
* @Date: 2025/5/16
|
||||
**/
|
||||
@Data
|
||||
public class APPDeviceQueryCriteria1 {
|
||||
|
||||
@Schema(name = "设备名称")
|
||||
private String deviceName;
|
||||
|
||||
@Schema(name = "设备类型")
|
||||
private Long deviceType;
|
||||
|
||||
@Schema(name = "设备MAC")
|
||||
private String deviceMac;
|
||||
|
||||
@Schema(name = "设备IMEI")
|
||||
private String deviceImei;
|
||||
|
||||
@Schema(name = "设备SN")
|
||||
private String deviceSn;
|
||||
|
||||
/**
|
||||
* 设备状态
|
||||
* 0 失效
|
||||
* 1 正常
|
||||
*/
|
||||
@Schema(name = "设备状态 0 失效 1 正常 ")
|
||||
private Integer deviceStatus;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd'T'HH:mm:ss'Z'")
|
||||
@Schema(name = "创建时间")
|
||||
private List<Timestamp> createTime;
|
||||
|
||||
@Schema(name = "页码", example = "1")
|
||||
private Integer page = 1;
|
||||
|
||||
@Schema(name = "每页数据量", example = "10")
|
||||
private Integer size = 10;
|
||||
|
||||
@Schema(name = "客户id")
|
||||
private Long customerId;
|
||||
private Set<Long> customerIds;
|
||||
|
||||
@Schema(name = "当前所有者")
|
||||
private Long currentOwnerId;
|
||||
|
||||
@Schema(name = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
@Schema(name = "通讯方式", example = "0:4G;1:蓝牙")
|
||||
private Integer communicationMode;
|
||||
|
||||
}
|
@ -29,7 +29,17 @@ public class AppDeviceVo {
|
||||
private Integer communicationMode;
|
||||
|
||||
/**
|
||||
* 设备图片
|
||||
* 设备图片
|
||||
*/
|
||||
private String devicePic;
|
||||
|
||||
/**
|
||||
* 设备类型
|
||||
*/
|
||||
private String typeName;
|
||||
|
||||
/**
|
||||
* 蓝牙名称
|
||||
*/
|
||||
private String bluetoothName;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@ import com.fuyuanshen.customer.mapper.CustomerMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||
import com.fuyuanshen.equipment.service.DeviceService;
|
||||
import com.fuyuanshen.equipment.service.DeviceTypeService;
|
||||
import com.fuyuanshen.system.service.ISysOssService;
|
||||
import lombok.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@ -23,6 +24,7 @@ public class DeviceImportParams {
|
||||
private DeviceMapper deviceMapper;
|
||||
private CustomerMapper customerMapper;
|
||||
private DeviceTypeMapper deviceTypeMapper;
|
||||
private DeviceTypeService deviceTypeService;
|
||||
private ISysOssService ossService;
|
||||
private MultipartFile file;
|
||||
private String filePath;
|
||||
|
@ -1,12 +1,10 @@
|
||||
package com.fuyuanshen.equipment.excel;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.excel.EasyExcel;
|
||||
import com.alibaba.excel.context.AnalysisContext;
|
||||
import com.alibaba.excel.read.listener.ReadListener;
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.fuyuanshen.common.core.domain.model.LoginUser;
|
||||
import com.fuyuanshen.common.satoken.utils.LoginHelper;
|
||||
import com.fuyuanshen.equipment.constants.DeviceConstants;
|
||||
@ -14,7 +12,7 @@ import com.fuyuanshen.equipment.domain.Device;
|
||||
import com.fuyuanshen.equipment.domain.DeviceType;
|
||||
import com.fuyuanshen.equipment.domain.dto.DeviceExcelImportDTO;
|
||||
import com.fuyuanshen.equipment.domain.dto.ImportResult;
|
||||
import com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria;
|
||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||
import com.fuyuanshen.equipment.handler.ImageWriteHandler;
|
||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -30,13 +28,13 @@ import java.util.*;
|
||||
public class UploadDeviceDataListener implements ReadListener<DeviceExcelImportDTO> {
|
||||
|
||||
// 存储图片数据的映射
|
||||
private final Map<Integer, byte[]> rowImageMap = new HashMap<>();
|
||||
private Map<Integer, byte[]> rowImageMap = new HashMap<>();
|
||||
|
||||
private final DeviceImportParams params;
|
||||
private DeviceImportParams params;
|
||||
|
||||
private final Map<Integer, Device> rowDeviceMap = new HashMap<>();
|
||||
private final Map<Integer, DeviceExcelImportDTO> rowDtoMap = new HashMap<>();
|
||||
private final List<Integer> rowIndexList = new ArrayList<>();
|
||||
private Map<Integer, Device> rowDeviceMap = new HashMap<>();
|
||||
private Map<Integer, DeviceExcelImportDTO> rowDtoMap = new HashMap<>();
|
||||
private List<Integer> rowIndexList = new ArrayList<>();
|
||||
|
||||
private int successCount = 0;
|
||||
private int failureCount = 0;
|
||||
@ -105,7 +103,6 @@ public class UploadDeviceDataListener implements ReadListener<DeviceExcelImportD
|
||||
.sheet("失败数据").doWrite(failedRecordsWithImages);
|
||||
|
||||
// 生成访问URL
|
||||
// String errorExcelUrl = params.getIp() + DeviceConstants.FILE_ACCESS_PREFIX + "/" + DeviceConstants.ERROR_REPORT_DIR + "/" + fileName;
|
||||
SysOssVo upload = params.getOssService().upload(errorFile);
|
||||
result.setErrorExcelUrl(upload.getUrl());
|
||||
log.info("错误报告已保存: {}", errorFile.getAbsolutePath());
|
||||
@ -151,27 +148,18 @@ public class UploadDeviceDataListener implements ReadListener<DeviceExcelImportD
|
||||
Device device = rowDeviceMap.get(rowIndex);
|
||||
DeviceExcelImportDTO originalDto = rowDtoMap.get(rowIndex);
|
||||
try {
|
||||
// DeviceQueryCriteria criteria = new DeviceQueryCriteria();
|
||||
// criteria.setDeviceMac(device.getDeviceMac());
|
||||
// criteria.setTenantId(params.getTenantId());
|
||||
// List<Device> deviceList = params.getDeviceMapper().findAll(criteria);
|
||||
// if (!deviceList.isEmpty()) {
|
||||
// throw new RuntimeException("设备MAC重复");
|
||||
// }
|
||||
// device.setTenantId(params.getTenantId());
|
||||
|
||||
// 设备类型
|
||||
QueryWrapper<DeviceType> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("type_name", device.getTypeName());
|
||||
// wrapper.eq("customer_id", params.getUserId());
|
||||
List<DeviceType> deviceTypes = params.getDeviceTypeMapper().selectList(wrapper);
|
||||
if (CollectionUtil.isNotEmpty(deviceTypes)) {
|
||||
device.setDeviceType(deviceTypes.get(0).getId());
|
||||
}
|
||||
device.setCurrentOwnerId(loginUser.getUserId());
|
||||
device.setOriginalOwnerId(loginUser.getUserId());
|
||||
device.setCreateByName(loginUser.getNickname());
|
||||
params.getDeviceService().save(device);
|
||||
DeviceType deviceType = params.getDeviceTypeService().queryByName(device.getTypeName());
|
||||
// params.getDeviceService().save(device);
|
||||
DeviceForm deviceForm = new DeviceForm();
|
||||
deviceForm.setDeviceName(device.getDeviceName());
|
||||
deviceForm.setDeviceType(deviceType.getId());
|
||||
deviceForm.setRemark(device.getRemark());
|
||||
deviceForm.setDeviceMac(device.getDeviceMac());
|
||||
deviceForm.setDeviceImei(device.getDeviceImei());
|
||||
deviceForm.setBluetoothName(device.getBluetoothName());
|
||||
deviceForm.setDevicePic(device.getDevicePic());
|
||||
params.getDeviceService().addDevice(deviceForm);
|
||||
successCount++;
|
||||
log.info("行 {} 数据插入成功", rowIndex);
|
||||
} catch (Exception e) {
|
||||
@ -225,10 +213,8 @@ public class UploadDeviceDataListener implements ReadListener<DeviceExcelImportD
|
||||
private String getCellValue(XSSFSheet sheet, int rowIndex, int colIndex) {
|
||||
XSSFRow row = sheet.getRow(rowIndex);
|
||||
if (row == null) return null;
|
||||
|
||||
XSSFCell cell = row.getCell(colIndex);
|
||||
if (cell == null) return null;
|
||||
|
||||
return cell.toString();
|
||||
}
|
||||
|
||||
@ -240,18 +226,6 @@ public class UploadDeviceDataListener implements ReadListener<DeviceExcelImportD
|
||||
try {
|
||||
String fileExtension = "jpg";
|
||||
String newFileName = "PS_" + new Random(8) + "." + fileExtension;
|
||||
// String targetDirPath = params.getFilePath() + DeviceConstants.FILE_ACCESS_ISOLATION;
|
||||
// File targetDir = new File(targetDirPath);
|
||||
//
|
||||
// if (!targetDir.exists() && !targetDir.mkdirs()) {
|
||||
// log.error("无法创建目录: {}", targetDirPath);
|
||||
// return null;
|
||||
// }
|
||||
//
|
||||
// File newFile = new File(targetDir, newFileName);
|
||||
// Files.write(newFile.toPath(), imageData);
|
||||
//
|
||||
// return params.getIp() + DeviceConstants.FILE_ACCESS_PREFIX + "/" + DeviceConstants.FILE_ACCESS_ISOLATION + "/" + newFileName;
|
||||
SysOssVo upload = params.getOssService().upload(imageData, newFileName);
|
||||
return upload.getUrl();
|
||||
} catch (Exception e) {
|
||||
|
@ -32,7 +32,16 @@ public interface DeviceMapper extends BaseMapper<Device> {
|
||||
|
||||
List<Device> findAllDevices(@Param("criteria") DeviceQueryCriteria criteria);
|
||||
|
||||
Page<AppDeviceVo> queryAppDeviceList(Page<AppDeviceVo> page,@Param("criteria") DeviceQueryCriteria criteria);
|
||||
/**
|
||||
* 根据条件查询
|
||||
*
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
List<Device> findDevices(@Param("criteria") DeviceQueryCriteria criteria);
|
||||
|
||||
Page<AppDeviceVo> queryAppDeviceList(Page<AppDeviceVo> page, @Param("criteria") DeviceQueryCriteria criteria);
|
||||
|
||||
/**
|
||||
* 获取分配设备的客户
|
||||
*
|
||||
|
@ -27,7 +27,6 @@ public interface DeviceTypeMapper extends BaseMapper<DeviceType> {
|
||||
*/
|
||||
IPage<DeviceType> findAll(@Param("criteria") DeviceTypeQueryCriteria criteria, Page<DeviceType> page);
|
||||
|
||||
|
||||
/**
|
||||
* 查询所有设备类型
|
||||
*
|
||||
@ -44,4 +43,12 @@ public interface DeviceTypeMapper extends BaseMapper<DeviceType> {
|
||||
*/
|
||||
DeviceType getAssignType(@Param("deviceType") Long deviceType, @Param("customerId") Long customerId);
|
||||
|
||||
/**
|
||||
* 根据名称查询设备类型
|
||||
*
|
||||
* @param criteria
|
||||
* @return
|
||||
*/
|
||||
DeviceType queryByName(@Param("criteria") DeviceTypeQueryCriteria criteria);
|
||||
|
||||
}
|
||||
|
@ -41,6 +41,14 @@ public interface DeviceTypeService extends IService<DeviceType> {
|
||||
*/
|
||||
List<DeviceType> queryDeviceTypes();
|
||||
|
||||
/**
|
||||
* 根据设备类型名称查询设备类型
|
||||
*
|
||||
* @param typeName 条件参数
|
||||
* @return List<DeviceTypeDto>
|
||||
*/
|
||||
DeviceType queryByName(String typeName);
|
||||
|
||||
/**
|
||||
* 新增设备类型
|
||||
*
|
||||
|
@ -43,6 +43,8 @@ public class DeviceExportService {
|
||||
dto.setDeviceMac(device.getDeviceMac());
|
||||
// 设备IMEI
|
||||
dto.setDeviceImei(device.getDeviceImei());
|
||||
// 蓝牙名称
|
||||
dto.setBluetoothName(device.getBluetoothName());
|
||||
dto.setLongitude(device.getLongitude());
|
||||
dto.setLatitude(device.getLatitude());
|
||||
dto.setRemark(device.getRemark());
|
||||
|
@ -3,7 +3,6 @@ package com.fuyuanshen.equipment.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.lang.UUID;
|
||||
import cn.hutool.core.lang.generator.SnowflakeGenerator;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
||||
@ -32,7 +31,6 @@ import com.fuyuanshen.equipment.domain.vo.CustomerVo;
|
||||
import com.fuyuanshen.equipment.enums.BindingStatusEnum;
|
||||
import com.fuyuanshen.equipment.enums.CommunicationModeEnum;
|
||||
import com.fuyuanshen.equipment.enums.DeviceActiveStatusEnum;
|
||||
import com.fuyuanshen.equipment.enums.DeviceStatusEnum;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceAssignmentsMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
||||
import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper;
|
||||
@ -42,7 +40,6 @@ import com.fuyuanshen.equipment.service.DeviceService;
|
||||
import com.fuyuanshen.equipment.service.DeviceTypeGrantsService;
|
||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||
import com.fuyuanshen.system.service.ISysOssService;
|
||||
import com.fuyuanshen.system.service.ISysUserService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
@ -54,7 +51,9 @@ import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.sql.Timestamp;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description:
|
||||
@ -113,6 +112,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
|
||||
@Override
|
||||
public List<Device> queryAll(DeviceQueryCriteria criteria) {
|
||||
criteria.setCurrentOwnerId(LoginHelper.getUserId());
|
||||
return deviceMapper.findAll(criteria);
|
||||
}
|
||||
|
||||
@ -142,6 +142,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
queryCriteria.setDeviceTypeId(deviceForm.getDeviceType());
|
||||
queryCriteria.setCustomerId(LoginHelper.getUserId());
|
||||
DeviceTypeGrants typeGrants = deviceTypeGrantsMapper.selectById(queryCriteria.getDeviceTypeId());
|
||||
if (typeGrants == null) {
|
||||
throw new Exception("设备类型不存在!!!");
|
||||
}
|
||||
DeviceType deviceTypes = deviceTypeMapper.selectById(typeGrants.getDeviceTypeId());
|
||||
if (deviceTypes == null) {
|
||||
throw new Exception("设备类型不存在!!!");
|
||||
@ -207,16 +210,12 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
if (deviceTypes.isEmpty()) {
|
||||
throw new Exception("设备类型不存在!!!");
|
||||
}
|
||||
|
||||
DeviceQueryCriteria queryCriteria = new DeviceQueryCriteria();
|
||||
queryCriteria.setDeviceId(deviceAssignments.getDeviceId());
|
||||
queryCriteria.setCustomerId(LoginHelper.getUserId());
|
||||
queryCriteria.setCurrentOwnerId(LoginHelper.getUserId());
|
||||
List<Device> devices = deviceMapper.findAll(queryCriteria);
|
||||
if (devices.isEmpty()) {
|
||||
Device device = deviceMapper.selectById(deviceAssignments.getDeviceId());
|
||||
if (device == null) {
|
||||
throw new Exception("设备不存在!!!");
|
||||
}
|
||||
Device device = devices.get(0);
|
||||
// 设备类型
|
||||
Long deviceType = device.getDeviceType();
|
||||
|
||||
// 处理上传的图片
|
||||
if (deviceForm.getFile() != null) {
|
||||
@ -228,6 +227,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
// 更新字段
|
||||
BeanUtil.copyProperties(deviceForm, device, true);
|
||||
device.setId(deviceAssignments.getDeviceId());
|
||||
device.setDeviceType(deviceType);
|
||||
device.setUpdateTime(new Timestamp(System.currentTimeMillis()));
|
||||
deviceMapper.updateById(device);
|
||||
}
|
||||
@ -312,6 +312,12 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
// 批量更新设备状态
|
||||
List<DeviceTypeGrants> deviceTypeGrants = new ArrayList<>();
|
||||
for (DeviceAssignments assignment : assignments) {
|
||||
|
||||
if (assignment.getToCustomerId() != null) {
|
||||
log.info("设备已经分配客户!!!");
|
||||
continue;
|
||||
}
|
||||
|
||||
Device device = deviceMapper.selectById(assignment.getDeviceId());
|
||||
|
||||
// 如果设备已分配给需要分配的客户,则跳过
|
||||
@ -326,6 +332,7 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
|
||||
// 更改分配客户
|
||||
assignment.setAssigneeName(assignUser.getNickName());
|
||||
assignment.setToCustomerId(customerVo.getCustomerId());
|
||||
deviceAssignmentsMapper.updateById(assignment);
|
||||
|
||||
// 设备失效
|
||||
@ -356,7 +363,9 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
deviceAssignmentsService.save(dam);
|
||||
|
||||
// 判断设备类型是否存在
|
||||
DeviceTypeGrants dtg = deviceTypeGrantsMapper.selectOne(new LambdaQueryWrapper<DeviceTypeGrants>().eq(DeviceTypeGrants::getDeviceTypeId, device.getId()));
|
||||
DeviceTypeGrants dtg = deviceTypeGrantsMapper.selectOne(new LambdaQueryWrapper<DeviceTypeGrants>()
|
||||
.eq(DeviceTypeGrants::getDeviceTypeId, device.getDeviceType())
|
||||
.eq(DeviceTypeGrants::getCustomerId, assignUser.getCustomerId()));
|
||||
if (dtg != null) {
|
||||
continue;
|
||||
}
|
||||
@ -397,51 +406,82 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 撤回设备
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
// @Override
|
||||
// public void withdrawDevice(List<Long> ids) {
|
||||
// ids.forEach((id) -> {
|
||||
// List<Device> deviceChain = getDeviceChain(id);
|
||||
// deviceChain.forEach((device) -> {
|
||||
// device.setDeviceStatus(DeviceStatusEnum.INVALID.getCode());
|
||||
// deviceMapper.updateById(device);
|
||||
// });
|
||||
// });
|
||||
//
|
||||
// ids.forEach((id) -> {
|
||||
// Device device = new Device();
|
||||
// device.setId(id);
|
||||
// device.setCustomerId(null);
|
||||
// device.setCustomerName("");
|
||||
// deviceMapper.updateById(device);
|
||||
// });
|
||||
//
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public List<Device> getDeviceChain(Long originalDeviceId) {
|
||||
// List<Device> chain = new ArrayList<>();
|
||||
// Set<Long> visited = new HashSet<>(); // 防止循环引用
|
||||
// findNext(chain, visited, originalDeviceId);
|
||||
// return chain;
|
||||
// }
|
||||
//
|
||||
// private void findNext(List<Device> chain, Set<Long> visited, Long currentOriginalDeviceId) {
|
||||
// if (visited.contains(currentOriginalDeviceId)) {
|
||||
// log.info("检测到循环引用,终止递归");
|
||||
// return;
|
||||
// }
|
||||
// visited.add(currentOriginalDeviceId);
|
||||
//
|
||||
// List<Device> devices = deviceMapper.findByOriginalDeviceId(currentOriginalDeviceId);
|
||||
// for (Device device : devices) {
|
||||
// chain.add(device);
|
||||
// findNext(chain, visited, device.getId());
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
/**
|
||||
* 撤回设备
|
||||
*
|
||||
* @param ids
|
||||
*/
|
||||
@Override
|
||||
@Transactional
|
||||
public void withdrawDevice(List<Long> ids) {
|
||||
ids.forEach((id) -> {
|
||||
List<Device> deviceChain = getDeviceChain(id);
|
||||
deviceChain.forEach((device) -> {
|
||||
device.setDeviceStatus(DeviceStatusEnum.INVALID.getCode());
|
||||
deviceMapper.updateById(device);
|
||||
});
|
||||
});
|
||||
|
||||
ids.forEach((id) -> {
|
||||
Device device = new Device();
|
||||
device.setId(id);
|
||||
device.setCustomerId(null);
|
||||
device.setCustomerName("");
|
||||
deviceMapper.updateById(device);
|
||||
});
|
||||
for (Long id : ids) {
|
||||
DeviceAssignments assignment = deviceAssignmentsMapper.selectById(id);
|
||||
Device device = deviceMapper.selectById(assignment.getDeviceId());
|
||||
// 接收者
|
||||
assignment.setAssigneeName("");
|
||||
assignment.setToCustomerId(null);
|
||||
deviceAssignmentsMapper.updateById(assignment);
|
||||
|
||||
}
|
||||
|
||||
|
||||
public List<Device> getDeviceChain(Long originalDeviceId) {
|
||||
List<Device> chain = new ArrayList<>();
|
||||
Set<Long> visited = new HashSet<>(); // 防止循环引用
|
||||
findNext(chain, visited, originalDeviceId);
|
||||
return chain;
|
||||
}
|
||||
|
||||
private void findNext(List<Device> chain, Set<Long> visited, Long currentOriginalDeviceId) {
|
||||
if (visited.contains(currentOriginalDeviceId)) {
|
||||
log.info("检测到循环引用,终止递归");
|
||||
return;
|
||||
// 获取所有已分配的设备
|
||||
DeviceAssignmentQuery dq = DeviceAssignmentQuery.builder().deviceId(device.getId())
|
||||
.active(DeviceActiveStatusEnum.ACTIVE.getCode()).lever(assignment.getLever() + USER_ID_SEPARATOR).build();
|
||||
// 查询分配
|
||||
List<DeviceAssignments> assignmentsList = deviceAssignmentsMapper.deviceAssignmentsMapper(dq);
|
||||
for (DeviceAssignments assignments : assignmentsList) {
|
||||
assignments.setActive(DeviceActiveStatusEnum.INACTIVE.getCode());
|
||||
deviceAssignmentsMapper.updateById(assignments);
|
||||
}
|
||||
}
|
||||
visited.add(currentOriginalDeviceId);
|
||||
|
||||
List<Device> devices = deviceMapper.findByOriginalDeviceId(currentOriginalDeviceId);
|
||||
for (Device device : devices) {
|
||||
chain.add(device);
|
||||
findNext(chain, visited, device.getId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -459,8 +499,10 @@ public class DeviceServiceImpl extends ServiceImpl<DeviceMapper, Device> impleme
|
||||
|
||||
@Override
|
||||
public TableDataInfo<AppDeviceVo> queryAppDeviceList(DeviceQueryCriteria bo, PageQuery pageQuery) {
|
||||
Long userId = AppLoginHelper.getUserId();
|
||||
bo.setBindingUserId(userId);
|
||||
if (bo.getBindingUserId() == null) {
|
||||
Long userId = AppLoginHelper.getUserId();
|
||||
bo.setBindingUserId(userId);
|
||||
}
|
||||
Page<AppDeviceVo> result = baseMapper.queryAppDeviceList(pageQuery.build(), bo);
|
||||
return TableDataInfo.build(result);
|
||||
}
|
||||
|
@ -78,6 +78,21 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
||||
return deviceTypeMapper.findAll(criteria);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据设备类型名称查询设备类型
|
||||
*
|
||||
* @param typeName 条件参数
|
||||
* @return List<DeviceTypeDto>
|
||||
*/
|
||||
@Override
|
||||
public DeviceType queryByName(String typeName) {
|
||||
DeviceTypeQueryCriteria criteria = new DeviceTypeQueryCriteria();
|
||||
criteria.setCustomerId(LoginHelper.getUserId());
|
||||
criteria.setTypeName(typeName);
|
||||
DeviceType deviceType = deviceTypeMapper.queryByName(criteria);
|
||||
return deviceType;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增设备类型
|
||||
|
@ -5,7 +5,7 @@
|
||||
<id column="id" property="id"/>
|
||||
<result column="device_type" property="deviceType"/>
|
||||
<result column="customer_id" property="customerId"/>
|
||||
<!--<result column="device_no" property="deviceNo"/>-->
|
||||
<result column="device_no" property="deviceNo"/>
|
||||
<result column="device_name" property="deviceName"/>
|
||||
<result column="device_pic" property="devicePic"/>
|
||||
<result column="device_mac" property="deviceMac"/>
|
||||
@ -75,7 +75,7 @@
|
||||
<!-- 分页查询设备 -->
|
||||
<select id="findAll" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||
select
|
||||
da.id AS id,d.device_name,
|
||||
da.id AS id,d.device_name,d.bluetooth_name,
|
||||
d.device_pic, d.device_mac, d.device_sn, d.update_by,d.device_imei,
|
||||
d.update_time, dg.id AS device_type, d.remark, d.binding_status,d.type_name AS typeName,
|
||||
da.assignee_id AS customerId, da.assignee_name AS customerName, da.active AS deviceStatus,
|
||||
@ -105,14 +105,14 @@
|
||||
and da.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
||||
</if>
|
||||
AND da.assignee_id = #{criteria.currentOwnerId}
|
||||
|
||||
AND dg.customer_id = #{criteria.currentOwnerId}
|
||||
</where>
|
||||
ORDER BY da.create_time DESC
|
||||
</select>
|
||||
|
||||
<select id="findAllDevices" resultType="com.fuyuanshen.equipment.domain.Device">
|
||||
select
|
||||
d.id, d.customer_id, d.device_name,
|
||||
d.id, d.customer_id, d.device_name,d.bluetooth_name,
|
||||
d.device_pic, d.device_mac, d.device_sn, d.create_by, d.update_by,
|
||||
d.create_time, d.update_time, d.longitude, d.latitude, d.remark
|
||||
from device d
|
||||
@ -133,17 +133,63 @@
|
||||
order by d.id desc
|
||||
</select>
|
||||
|
||||
<!-- 根据条件查询 -->
|
||||
<select id="findDevices" resultType="com.fuyuanshen.equipment.domain.Device"
|
||||
parameterType="com.fuyuanshen.equipment.domain.query.DeviceQueryCriteria">
|
||||
SELECT d.*
|
||||
FROM device d
|
||||
<where>
|
||||
<!-- 时间范围等其他条件保持原样 -->
|
||||
<if test="criteria.deviceName != null and criteria.deviceName.trim() != ''">
|
||||
and d.device_name like concat('%', TRIM(#{criteria.deviceName}), '%')
|
||||
</if>
|
||||
<if test="criteria.deviceMac != null">
|
||||
and d.device_mac = #{criteria.deviceMac}
|
||||
</if>
|
||||
<if test="criteria.deviceImei != null">
|
||||
and d.device_imei = #{criteria.deviceImei}
|
||||
</if>
|
||||
<if test="criteria.deviceType != null">
|
||||
and d.device_type = #{criteria.deviceType}
|
||||
</if>
|
||||
<if test="criteria.deviceStatus != null">
|
||||
and d.device_status = #{criteria.deviceStatus}
|
||||
</if>
|
||||
<if test="criteria.currentOwnerId != null">
|
||||
and d.current_owner_id = #{criteria.currentOwnerId}
|
||||
</if>
|
||||
<if test="criteria.params.beginTime != null and criteria.params.endTime != null">
|
||||
and d.create_time between #{criteria.params.beginTime} and #{criteria.params.endTime}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
|
||||
<select id="queryAppDeviceList" resultType="com.fuyuanshen.equipment.domain.vo.AppDeviceVo">
|
||||
select d.id,
|
||||
d.device_name,
|
||||
d.device_mac,
|
||||
d.device_sn,
|
||||
d.device_imei,
|
||||
d.device_mac,
|
||||
dt.communication_mode
|
||||
d.device_name,
|
||||
d.device_mac,
|
||||
d.device_sn,
|
||||
d.device_imei,
|
||||
d.device_pic,
|
||||
dt.type_name,
|
||||
dt.communication_mode,
|
||||
d.bluetooth_name
|
||||
from device d
|
||||
inner join device_type dt on d.device_type = dt.id
|
||||
inner join device_type dt on d.device_type = dt.id
|
||||
where d.binding_user_id = #{criteria.bindingUserId}
|
||||
<if test="criteria.deviceType != null">
|
||||
and d.device_type = #{criteria.deviceType}
|
||||
</if>
|
||||
<if test="criteria.deviceName != null">
|
||||
and d.device_name = #{criteria.deviceName}
|
||||
</if>
|
||||
<if test="criteria.deviceMac != null">
|
||||
and d.device_mac = #{criteria.deviceMac}
|
||||
</if>
|
||||
<if test="criteria.deviceImei != null">
|
||||
and d.device_imei = #{criteria.deviceImei}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<!-- 获取分配设备的客户 -->
|
||||
|
@ -42,4 +42,14 @@
|
||||
WHERE owner_customer_id = #{customerId}
|
||||
AND original_device_id = #{deviceType}
|
||||
</select>
|
||||
|
||||
<!-- 根据名称查询设备类型 -->
|
||||
<select id="queryByName" resultMap="BaseResultMap"
|
||||
parameterType="com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria">
|
||||
SELECT dt.*, dg.id AS grant_id
|
||||
FROM device_type dt
|
||||
JOIN device_type_grants dg ON dt.id = dg.device_type_id
|
||||
WHERE dt.type_name = #{criteria.typeName}
|
||||
AND dg.customer_id = #{criteria.customerId}
|
||||
</select>
|
||||
</mapper>
|
@ -26,6 +26,9 @@ public class MqttConfiguration {
|
||||
options.setUserName(mqttPropertiesConfig.getUsername());
|
||||
options.setPassword(mqttPropertiesConfig.getPassword().toCharArray());
|
||||
options.setServerURIs(new String[]{mqttPropertiesConfig.getUrl()});
|
||||
options.setAutomaticReconnect(true); // 启用自动重连
|
||||
options.setConnectionTimeout(10); // 设置连接超时时间
|
||||
options.setKeepAliveInterval(60); // 设置心跳间隔
|
||||
factory.setConnectionOptions(options);
|
||||
return factory;
|
||||
}
|
||||
|
Reference in New Issue
Block a user