Compare commits
6 Commits
d7c4d22de3
...
dyf-device
| Author | SHA1 | Date | |
|---|---|---|---|
| ca11ef0e35 | |||
| ef2dc6a6f6 | |||
| dff37b245a | |||
| 6a058318f2 | |||
| f2d74b8f17 | |||
| aaf142ca67 |
@ -227,7 +227,7 @@ public class AppDeviceShareService {
|
|||||||
appDeviceShare.setPermission(bo.getPermission());
|
appDeviceShare.setPermission(bo.getPermission());
|
||||||
appDeviceShare.setCreateBy(userId);
|
appDeviceShare.setCreateBy(userId);
|
||||||
return appDeviceShareMapper.insert(appDeviceShare);
|
return appDeviceShareMapper.insert(appDeviceShare);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public int remove(Long[] ids) {
|
public int remove(Long[] ids) {
|
||||||
|
|||||||
@ -739,6 +739,7 @@ public class DeviceXinghanBizService {
|
|||||||
device.setCreateByName(loginUser.getNickname());
|
device.setCreateByName(loginUser.getNickname());
|
||||||
device.setTypeName(deviceTypes.getTypeName());
|
device.setTypeName(deviceTypes.getTypeName());
|
||||||
device.setDeviceType(deviceTypes.getId());
|
device.setDeviceType(deviceTypes.getId());
|
||||||
|
device.setDevicePic(deviceTypes.getDevicePic());
|
||||||
if (device.getDeviceImei() != null) {
|
if (device.getDeviceImei() != null) {
|
||||||
device.setPubTopic("A/" + device.getDeviceImei());
|
device.setPubTopic("A/" + device.getDeviceImei());
|
||||||
device.setSubTopic("B/" + device.getDeviceImei());
|
device.setSubTopic("B/" + device.getDeviceImei());
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import lombok.RequiredArgsConstructor;
|
|||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -50,7 +51,7 @@ public class DeviceTypeController {
|
|||||||
// @Log("新增设备类型")
|
// @Log("新增设备类型")
|
||||||
@Operation(summary = "新增设备类型")
|
@Operation(summary = "新增设备类型")
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
public R<Void> createDeviceType(@Validated @RequestBody DeviceType resources) {
|
public R<Void> createDeviceType(@Validated @ModelAttribute DeviceTypeForm resources) throws IOException {
|
||||||
deviceTypeService.create(resources);
|
deviceTypeService.create(resources);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
@ -59,7 +60,7 @@ public class DeviceTypeController {
|
|||||||
// @Log("修改设备类型")
|
// @Log("修改设备类型")
|
||||||
@Operation(summary = "修改设备类型")
|
@Operation(summary = "修改设备类型")
|
||||||
@PutMapping(value = "/update")
|
@PutMapping(value = "/update")
|
||||||
public R<Void> updateDeviceType(@Validated @RequestBody DeviceTypeForm resources) {
|
public R<Void> updateDeviceType(@Validated @ModelAttribute DeviceTypeForm resources) throws IOException {
|
||||||
deviceTypeService.update(resources);
|
deviceTypeService.update(resources);
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|||||||
@ -44,7 +44,7 @@ public class TrackServiceController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 查询轨迹服务列表
|
* 查询轨迹服务列表
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:trackService:list")
|
// @SaCheckPermission("equipment:trackService:list")
|
||||||
@GetMapping("/list")
|
@GetMapping("/list")
|
||||||
public TableDataInfo<TrackServiceVo> list(TrackServiceBo bo, PageQuery pageQuery) {
|
public TableDataInfo<TrackServiceVo> list(TrackServiceBo bo, PageQuery pageQuery) {
|
||||||
return trackServiceService.queryPageList(bo, pageQuery);
|
return trackServiceService.queryPageList(bo, pageQuery);
|
||||||
@ -53,7 +53,7 @@ public class TrackServiceController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 轨迹服务列表
|
* 轨迹服务列表
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:trackService:export")
|
// @SaCheckPermission("equipment:trackService:export")
|
||||||
@Log(title = "轨迹服务", businessType = BusinessType.EXPORT)
|
@Log(title = "轨迹服务", businessType = BusinessType.EXPORT)
|
||||||
@PostMapping("/export")
|
@PostMapping("/export")
|
||||||
public void export(TrackServiceBo bo, HttpServletResponse response) {
|
public void export(TrackServiceBo bo, HttpServletResponse response) {
|
||||||
@ -75,7 +75,7 @@ public class TrackServiceController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 新增轨迹服务
|
* 新增轨迹服务
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:trackService:add")
|
// @SaCheckPermission("equipment:trackService:add")
|
||||||
@Log(title = "轨迹服务", businessType = BusinessType.INSERT)
|
@Log(title = "轨迹服务", businessType = BusinessType.INSERT)
|
||||||
@PostMapping(value = "/add")
|
@PostMapping(value = "/add")
|
||||||
public R<Void> add(@Validated(AddGroup.class) @RequestBody TrackServiceBo bo) {
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody TrackServiceBo bo) {
|
||||||
@ -85,7 +85,7 @@ public class TrackServiceController extends BaseController {
|
|||||||
/**
|
/**
|
||||||
* 修改轨迹服务
|
* 修改轨迹服务
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:trackService:edit")
|
// @SaCheckPermission("equipment:trackService:edit")
|
||||||
@Log(title = "轨迹服务", businessType = BusinessType.UPDATE)
|
@Log(title = "轨迹服务", businessType = BusinessType.UPDATE)
|
||||||
@PostMapping(value = "/update")
|
@PostMapping(value = "/update")
|
||||||
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TrackServiceBo bo) {
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody TrackServiceBo bo) {
|
||||||
@ -97,7 +97,7 @@ public class TrackServiceController extends BaseController {
|
|||||||
*
|
*
|
||||||
* @param ids 主键串
|
* @param ids 主键串
|
||||||
*/
|
*/
|
||||||
@SaCheckPermission("equipment:trackService:remove")
|
// @SaCheckPermission("equipment:trackService:remove")
|
||||||
@Log(title = "轨迹服务", businessType = BusinessType.DELETE)
|
@Log(title = "轨迹服务", businessType = BusinessType.DELETE)
|
||||||
@DeleteMapping(value = "/delete")
|
@DeleteMapping(value = "/delete")
|
||||||
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
public R<Void> remove(@NotEmpty(message = "主键不能为空")
|
||||||
|
|||||||
@ -85,5 +85,8 @@ public class DeviceType extends TenantEntity {
|
|||||||
@Schema(title = "型号字典用于PC页面跳转")
|
@Schema(title = "型号字典用于PC页面跳转")
|
||||||
private String pcModelDictionary;
|
private String pcModelDictionary;
|
||||||
|
|
||||||
|
@Schema(title = "设备图片")
|
||||||
|
private String devicePic;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ package com.fuyuanshen.equipment.domain.form;
|
|||||||
|
|
||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Description: 设备类型
|
* @Description: 设备类型
|
||||||
@ -48,5 +49,10 @@ public class DeviceTypeForm {
|
|||||||
*/
|
*/
|
||||||
@Schema(title = "型号字典用于PC页面跳转")
|
@Schema(title = "型号字典用于PC页面跳转")
|
||||||
private String pcModelDictionary;
|
private String pcModelDictionary;
|
||||||
|
@Schema(title = "设备图片")
|
||||||
|
private String devicePic;
|
||||||
|
|
||||||
|
@Schema(title = "设备图片")
|
||||||
|
private MultipartFile file;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -12,6 +12,7 @@ import com.fuyuanshen.equipment.domain.DeviceType;
|
|||||||
import com.fuyuanshen.equipment.domain.dto.DeviceExcelImportDTO;
|
import com.fuyuanshen.equipment.domain.dto.DeviceExcelImportDTO;
|
||||||
import com.fuyuanshen.equipment.domain.dto.ImportResult;
|
import com.fuyuanshen.equipment.domain.dto.ImportResult;
|
||||||
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
import com.fuyuanshen.equipment.domain.form.DeviceForm;
|
||||||
|
import com.fuyuanshen.equipment.domain.form.DeviceTypeForm;
|
||||||
import com.fuyuanshen.equipment.handler.ImageWriteHandler;
|
import com.fuyuanshen.equipment.handler.ImageWriteHandler;
|
||||||
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
@ -437,8 +438,10 @@ public class UploadDeviceDataListener implements ReadListener<DeviceExcelImportD
|
|||||||
newDeviceType.setAppModelDictionary(originalDto.getAppModelDictionary());
|
newDeviceType.setAppModelDictionary(originalDto.getAppModelDictionary());
|
||||||
newDeviceType.setPcModelDictionary(originalDto.getPcModelDictionary());
|
newDeviceType.setPcModelDictionary(originalDto.getPcModelDictionary());
|
||||||
|
|
||||||
|
DeviceTypeForm deviceTypeForm = new DeviceTypeForm();
|
||||||
|
BeanUtil.copyProperties(newDeviceType, deviceTypeForm, true);
|
||||||
// 创建新的设备类型
|
// 创建新的设备类型
|
||||||
params.getDeviceTypeService().create(newDeviceType);
|
params.getDeviceTypeService().create(deviceTypeForm);
|
||||||
|
|
||||||
// 重新查询确保获取到正确的ID
|
// 重新查询确保获取到正确的ID
|
||||||
deviceType = params.getDeviceTypeService().queryByName(device.getTypeName());
|
deviceType = params.getDeviceTypeService().queryByName(device.getTypeName());
|
||||||
|
|||||||
@ -8,6 +8,7 @@ import com.fuyuanshen.equipment.domain.DeviceType;
|
|||||||
import com.fuyuanshen.equipment.domain.form.DeviceTypeForm;
|
import com.fuyuanshen.equipment.domain.form.DeviceTypeForm;
|
||||||
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
import com.fuyuanshen.equipment.domain.query.DeviceTypeQueryCriteria;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -63,14 +64,14 @@ public interface DeviceTypeService extends IService<DeviceType> {
|
|||||||
*
|
*
|
||||||
* @param resources /
|
* @param resources /
|
||||||
*/
|
*/
|
||||||
void create(DeviceType resources);
|
void create(DeviceTypeForm resources) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改设备类型
|
* 修改设备类型
|
||||||
*
|
*
|
||||||
* @param resources /
|
* @param resources /
|
||||||
*/
|
*/
|
||||||
void update(DeviceTypeForm resources);
|
void update(DeviceTypeForm resources) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 多选删除
|
* 多选删除
|
||||||
|
|||||||
@ -19,12 +19,16 @@ import com.fuyuanshen.equipment.mapper.DeviceMapper;
|
|||||||
import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceTypeGrantsMapper;
|
||||||
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
import com.fuyuanshen.equipment.mapper.DeviceTypeMapper;
|
||||||
import com.fuyuanshen.equipment.service.DeviceTypeService;
|
import com.fuyuanshen.equipment.service.DeviceTypeService;
|
||||||
|
import com.fuyuanshen.equipment.utils.FileHashUtil;
|
||||||
|
import com.fuyuanshen.system.domain.vo.SysOssVo;
|
||||||
import com.fuyuanshen.system.domain.vo.SysRoleVo;
|
import com.fuyuanshen.system.domain.vo.SysRoleVo;
|
||||||
|
import com.fuyuanshen.system.service.ISysOssService;
|
||||||
import com.fuyuanshen.system.service.ISysRoleService;
|
import com.fuyuanshen.system.service.ISysRoleService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -46,6 +50,8 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
private final DeviceAssignmentsMapper deviceAssignmentsMapper;
|
||||||
|
|
||||||
private final ISysRoleService roleService;
|
private final ISysRoleService roleService;
|
||||||
|
private final ISysOssService ossService;
|
||||||
|
private final FileHashUtil fileHashUtil;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -181,24 +187,38 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void create(DeviceType resources) {
|
public void create(DeviceTypeForm resources) throws IOException {
|
||||||
|
|
||||||
// 校验设备类型名称
|
// 校验设备类型名称
|
||||||
List<DeviceType> typeName = deviceTypeMapper.selectList(new QueryWrapper<DeviceType>().eq("type_name", resources.getTypeName()));
|
List<DeviceType> typeName = deviceTypeMapper.selectList(new QueryWrapper<DeviceType>().eq("type_name", resources.getTypeName()));
|
||||||
if (CollectionUtil.isNotEmpty(typeName)) {
|
if (CollectionUtil.isNotEmpty(typeName)) {
|
||||||
throw new RuntimeException("设备类型名称已存在,无法新增!!!");
|
throw new RuntimeException("设备类型名称已存在,无法新增!!!");
|
||||||
}
|
}
|
||||||
|
// 保存图片并获取URL
|
||||||
|
if (resources.getFile() != null) {
|
||||||
|
String fileHash = fileHashUtil.hash(resources.getFile());
|
||||||
|
SysOssVo upload = ossService.updateHash(resources.getFile(), fileHash);
|
||||||
|
// 强制将HTTP替换为HTTPS
|
||||||
|
if (upload.getUrl() != null && upload.getUrl().startsWith("http://")) {
|
||||||
|
upload.setUrl(upload.getUrl().replaceFirst("^http://", "https://"));
|
||||||
|
}
|
||||||
|
// 设置图片路径
|
||||||
|
resources.setDevicePic(upload.getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
|
DeviceType deviceType = new DeviceType();
|
||||||
|
BeanUtil.copyProperties(resources, deviceType, true);
|
||||||
|
|
||||||
LoginUser loginUser = LoginHelper.getLoginUser();
|
LoginUser loginUser = LoginHelper.getLoginUser();
|
||||||
resources.setCustomerId(loginUser.getUserId());
|
deviceType.setCustomerId(loginUser.getUserId());
|
||||||
resources.setOwnerCustomerId(loginUser.getUserId());
|
deviceType.setOwnerCustomerId(loginUser.getUserId());
|
||||||
resources.setOriginalOwnerId(loginUser.getUserId());
|
deviceType.setOriginalOwnerId(loginUser.getUserId());
|
||||||
resources.setCreateByName(loginUser.getNickname());
|
deviceType.setCreateByName(loginUser.getNickname());
|
||||||
deviceTypeMapper.insert(resources);
|
deviceTypeMapper.insert(deviceType);
|
||||||
|
|
||||||
// 自动授权给自己
|
// 自动授权给自己
|
||||||
DeviceTypeGrants deviceTypeGrants = new DeviceTypeGrants();
|
DeviceTypeGrants deviceTypeGrants = new DeviceTypeGrants();
|
||||||
deviceTypeGrants.setDeviceTypeId(resources.getId());
|
deviceTypeGrants.setDeviceTypeId(deviceType.getId());
|
||||||
deviceTypeGrants.setCustomerId(loginUser.getUserId());
|
deviceTypeGrants.setCustomerId(loginUser.getUserId());
|
||||||
deviceTypeGrants.setGrantorCustomerId(loginUser.getUserId());
|
deviceTypeGrants.setGrantorCustomerId(loginUser.getUserId());
|
||||||
deviceTypeGrants.setGrantedAt(new Date());
|
deviceTypeGrants.setGrantedAt(new Date());
|
||||||
@ -213,7 +233,7 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
public void update(DeviceTypeForm resources) {
|
public void update(DeviceTypeForm resources) throws IOException {
|
||||||
DeviceTypeGrants deviceTypeGrants = deviceTypeGrantsMapper.selectById(resources.getId());
|
DeviceTypeGrants deviceTypeGrants = deviceTypeGrantsMapper.selectById(resources.getId());
|
||||||
if (deviceTypeGrants == null) {
|
if (deviceTypeGrants == null) {
|
||||||
throw new RuntimeException("设备类型不存在");
|
throw new RuntimeException("设备类型不存在");
|
||||||
@ -244,6 +264,17 @@ public class DeviceTypeServiceImpl extends ServiceImpl<DeviceTypeMapper, DeviceT
|
|||||||
throw new RuntimeException("无权修改该设备类型");
|
throw new RuntimeException("无权修改该设备类型");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 保存图片并获取URL
|
||||||
|
if (resources.getFile() != null) {
|
||||||
|
String fileHash = fileHashUtil.hash(resources.getFile());
|
||||||
|
SysOssVo upload = ossService.updateHash(resources.getFile(), fileHash);
|
||||||
|
// 强制将HTTP替换为HTTPS
|
||||||
|
if (upload.getUrl() != null && upload.getUrl().startsWith("http://")) {
|
||||||
|
upload.setUrl(upload.getUrl().replaceFirst("^http://", "https://"));
|
||||||
|
}
|
||||||
|
// 设置图片路径
|
||||||
|
resources.setDevicePic(upload.getUrl());
|
||||||
|
}
|
||||||
|
|
||||||
BeanUtil.copyProperties(resources, deviceType);
|
BeanUtil.copyProperties(resources, deviceType);
|
||||||
deviceTypeMapper.updateById(deviceType);
|
deviceTypeMapper.updateById(deviceType);
|
||||||
|
|||||||
@ -13,8 +13,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||||||
a.content,
|
a.content,
|
||||||
a.create_time AS createTime
|
a.create_time AS createTime
|
||||||
FROM
|
FROM
|
||||||
device_log a left join device b on a.device_id = b.id
|
device_log a inner join device b on a.device_id = b.id
|
||||||
left join device_type c on b.device_type = c.id
|
inner join device_type c on b.device_type = c.id
|
||||||
WHERE 1 = 1
|
WHERE 1 = 1
|
||||||
<if test="bo.deviceType != null">
|
<if test="bo.deviceType != null">
|
||||||
AND c.id = #{bo.deviceType}
|
AND c.id = #{bo.deviceType}
|
||||||
|
|||||||
Reference in New Issue
Block a user