新增批量下发,告警列表搜索、告警列表导出以及下发权限控制
parent
c9a72bc61b
commit
22195458c4
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,69 @@
|
||||
/*
|
||||
*
|
||||
* * | Licensed 未经许可不能去掉「OPENIITA」相关版权
|
||||
* * +----------------------------------------------------------------------
|
||||
* * | Author: xw2sy@163.com
|
||||
* * +----------------------------------------------------------------------
|
||||
*
|
||||
* Copyright [2024] [OPENIITA]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* /
|
||||
*/
|
||||
|
||||
package cc.iotkit.model.device;
|
||||
|
||||
|
||||
import cc.iotkit.model.Id;
|
||||
import cc.iotkit.model.Owned;
|
||||
import cc.iotkit.model.TenantModel;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.ParamDef;
|
||||
|
||||
import javax.persistence.*;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class DeviceIssue extends TenantModel implements Owned<String>{
|
||||
|
||||
|
||||
private String id;
|
||||
|
||||
private String productKey;
|
||||
|
||||
private Long tenantId;
|
||||
|
||||
private String fieldName;
|
||||
private String fieldNameValue;
|
||||
private String tenantName;
|
||||
|
||||
@Override
|
||||
public String getUid() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUid(String uid) {
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
/*
|
||||
*
|
||||
* * | Licensed 未经许可不能去掉「OPENIITA」相关版权
|
||||
* * +----------------------------------------------------------------------
|
||||
* * | Author: xw2sy@163.com
|
||||
* * +----------------------------------------------------------------------
|
||||
*
|
||||
* Copyright [2024] [OPENIITA]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* /
|
||||
*/
|
||||
package cc.iotkit.data.manager;
|
||||
|
||||
import cc.iotkit.data.ICommonData;
|
||||
import cc.iotkit.data.IOwnedData;
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.model.device.DeviceInstallInfo;
|
||||
import cc.iotkit.model.device.DeviceIssue;
|
||||
|
||||
|
||||
public interface IDeviceIssueData extends ICommonData<DeviceIssue, String> {
|
||||
|
||||
DeviceIssue findByTenantId(Long tenantId);
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
/*
|
||||
*
|
||||
* * | Licensed 未经许可不能去掉「OPENIITA」相关版权
|
||||
* * +----------------------------------------------------------------------
|
||||
* * | Author: xw2sy@163.com
|
||||
* * +----------------------------------------------------------------------
|
||||
*
|
||||
* Copyright [2024] [OPENIITA]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* /
|
||||
*/
|
||||
|
||||
package cc.iotkit.data.dao;
|
||||
|
||||
import cc.iotkit.data.model.TbDeviceInstallInfo;
|
||||
import cc.iotkit.data.model.TbDeviceIssue;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.data.querydsl.QuerydslPredicateExecutor;
|
||||
|
||||
public interface DeviceIssueRepository extends JpaRepository<TbDeviceIssue, String>, QuerydslPredicateExecutor<TbDeviceIssue> {
|
||||
TbDeviceIssue findByTenantId(Long tenantId);
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
*
|
||||
* * | Licensed 未经许可不能去掉「OPENIITA」相关版权
|
||||
* * +----------------------------------------------------------------------
|
||||
* * | Author: xw2sy@163.com
|
||||
* * +----------------------------------------------------------------------
|
||||
*
|
||||
* Copyright [2024] [OPENIITA]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* /
|
||||
*/
|
||||
|
||||
package cc.iotkit.data.model;
|
||||
|
||||
import cc.iotkit.common.tenant.dao.TenantAware;
|
||||
import cc.iotkit.common.tenant.listener.TenantListener;
|
||||
import cc.iotkit.model.device.DeviceInstallInfo;
|
||||
import cc.iotkit.model.device.DeviceIssue;
|
||||
import io.github.linpeilie.annotations.AutoMapper;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.hibernate.annotations.Filter;
|
||||
import org.hibernate.annotations.FilterDef;
|
||||
import org.hibernate.annotations.GenericGenerator;
|
||||
import org.hibernate.annotations.ParamDef;
|
||||
|
||||
import javax.persistence.*;
|
||||
import java.util.Date;
|
||||
|
||||
@Data
|
||||
@Entity
|
||||
@Table(name = "device_issue")
|
||||
@ApiModel(value = "设备下发权限")
|
||||
@AutoMapper(target = DeviceIssue.class)
|
||||
@FilterDef(name = "tenantFilter", parameters = {@ParamDef(name = "tenantId", type = "long")})
|
||||
@Filter(name = "tenantFilter", condition = "tenant_id = :tenantId")
|
||||
@EntityListeners(TenantListener.class)
|
||||
public class TbDeviceIssue extends BaseEntity implements TenantAware {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(generator = "SnowflakeIdGenerator")
|
||||
@GenericGenerator(name = "SnowflakeIdGenerator", strategy = "cc.iotkit.data.config.id.SnowflakeIdGenerator")
|
||||
private String id;
|
||||
@ApiModelProperty(value = "产品key")
|
||||
private String productKey;
|
||||
@ApiModelProperty(value = "字段标识")
|
||||
private String fieldName;
|
||||
@ApiModelProperty(value = "租户编号")
|
||||
private Long tenantId;
|
||||
|
||||
private String fieldNameValue;
|
||||
|
||||
}
|
@ -0,0 +1,74 @@
|
||||
/*
|
||||
*
|
||||
* * | Licensed 未经许可不能去掉「OPENIITA」相关版权
|
||||
* * +----------------------------------------------------------------------
|
||||
* * | Author: xw2sy@163.com
|
||||
* * +----------------------------------------------------------------------
|
||||
*
|
||||
* Copyright [2024] [OPENIITA]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* /
|
||||
*/
|
||||
|
||||
package cc.iotkit.data.service;
|
||||
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.dao.DeviceInstallInfoRepository;
|
||||
import cc.iotkit.data.dao.DeviceIssueRepository;
|
||||
import cc.iotkit.data.dao.IJPACommData;
|
||||
import cc.iotkit.data.manager.IDeviceInstallInfoData;
|
||||
import cc.iotkit.data.manager.IDeviceIssueData;
|
||||
import cc.iotkit.data.model.TbDeviceInstallInfo;
|
||||
import cc.iotkit.data.model.TbDeviceIssue;
|
||||
import cc.iotkit.model.device.DeviceInfo;
|
||||
import cc.iotkit.model.device.DeviceInstallInfo;
|
||||
import cc.iotkit.model.device.DeviceIssue;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.data.jpa.repository.JpaRepository;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Primary
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DeviceIssueDataImpl implements IDeviceIssueData, IJPACommData<DeviceIssue,String> {
|
||||
|
||||
@Autowired
|
||||
private DeviceIssueRepository homeRepository;
|
||||
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
@Override
|
||||
public JpaRepository getBaseRepository() {
|
||||
return homeRepository;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getJpaRepositoryClass() {
|
||||
return TbDeviceIssue.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getTClass() {
|
||||
return DeviceIssue.class;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public DeviceIssue findByTenantId(Long tenantId) {
|
||||
return MapstructUtils.convert(homeRepository.findByTenantId(tenantId), DeviceIssue.class);
|
||||
}
|
||||
}
|
@ -0,0 +1,185 @@
|
||||
/*
|
||||
*
|
||||
* * | Licensed 未经许可不能去掉「OPENIITA」相关版权
|
||||
* * +----------------------------------------------------------------------
|
||||
* * | Author: xw2sy@163.com
|
||||
* * +----------------------------------------------------------------------
|
||||
*
|
||||
* Copyright [2024] [OPENIITA]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* /
|
||||
*/
|
||||
package cc.iotkit.manager.controller;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.api.Request;
|
||||
import cc.iotkit.common.enums.ErrCode;
|
||||
import cc.iotkit.common.excel.utils.ExcelUtil;
|
||||
import cc.iotkit.common.exception.BizException;
|
||||
import cc.iotkit.common.log.annotation.Log;
|
||||
import cc.iotkit.common.log.enums.BusinessType;
|
||||
import cc.iotkit.common.satoken.utils.LoginHelper;
|
||||
import cc.iotkit.common.tenant.helper.TenantHelper;
|
||||
import cc.iotkit.common.utils.DeviceUtil;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.manager.IDeviceInstallInfoData;
|
||||
import cc.iotkit.data.manager.IDeviceIssueData;
|
||||
import cc.iotkit.manager.config.PDFGenerator;
|
||||
import cc.iotkit.manager.dto.bo.device.DeviceInstallInfoQueryBo;
|
||||
import cc.iotkit.manager.dto.vo.deviceinfo.DeviceInstallInfoExpordVo;
|
||||
import cc.iotkit.manager.dto.vo.deviceinfo.DeviceInstallInfoVo;
|
||||
import cc.iotkit.manager.service.IDeviceInstallInfoService;
|
||||
import cc.iotkit.manager.service.IDeviceIssueService;
|
||||
import cc.iotkit.model.device.DeviceInstallInfo;
|
||||
import cc.iotkit.model.device.DeviceIssue;
|
||||
import cc.iotkit.model.device.InstallationRecord;
|
||||
import cn.dev33.satoken.annotation.SaCheckPermission;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.itextpdf.io.font.PdfEncodings;
|
||||
import com.itextpdf.kernel.colors.DeviceRgb;
|
||||
import com.itextpdf.kernel.font.PdfFont;
|
||||
import com.itextpdf.kernel.font.PdfFontFactory;
|
||||
import com.itextpdf.kernel.pdf.PdfDocument;
|
||||
import com.itextpdf.kernel.pdf.PdfWriter;
|
||||
import com.itextpdf.layout.Document;
|
||||
import com.itextpdf.layout.element.AreaBreak;
|
||||
import com.itextpdf.layout.element.Cell;
|
||||
import com.itextpdf.layout.element.Paragraph;
|
||||
import com.itextpdf.layout.element.Table;
|
||||
import com.itextpdf.layout.properties.AreaBreakType;
|
||||
import com.itextpdf.layout.properties.TextAlignment;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@Api(tags = {"设备下发权限信息"})
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/deviceIssue")
|
||||
public class DeviceIssueController {
|
||||
|
||||
@Autowired
|
||||
private IDeviceIssueService deviceServiceImpl;
|
||||
@Autowired
|
||||
private IDeviceIssueData iDeviceInstallInfoData;
|
||||
|
||||
@ApiOperation(value = "下发权限列表", notes = "设备列表", httpMethod = "POST")
|
||||
//@SaCheckPermission("iot:device:query")
|
||||
@PostMapping("/page")
|
||||
public Paging<DeviceIssue> getDevices(@Validated @RequestBody PageRequest<DeviceIssue> pageRequest) {
|
||||
|
||||
return deviceServiceImpl.getPage(pageRequest);
|
||||
}
|
||||
|
||||
@PostMapping("/add")
|
||||
@SaCheckPermission("device:issue:add")
|
||||
public void addClientUser(@RequestBody Request<DeviceIssue> deviceInstallInfo) throws Exception {
|
||||
/* user.getData().setType(UserInfo.USER_TYPE_CLIENT);
|
||||
user.getData().setRoles(Collections.singletonList(Constants.ROLE_CLIENT));
|
||||
user.getData().setSecret(null);*/
|
||||
TenantHelper.enableIgnore();
|
||||
if (ObjectUtil.isNull(deviceInstallInfo.getData()) || ObjectUtil.isNull(deviceInstallInfo.getData().getFieldName())) {
|
||||
throw new BizException(ErrCode.PARAMS_EXCEPTION);
|
||||
}
|
||||
/* DeviceInstallInfo deviceRepetition = iDeviceInstallInfoData.findByDeviceNameAndUid(deviceInstallInfo.getData().getDeviceName(), deviceInstallInfo.getData().getUid());
|
||||
if (deviceRepetition != null) {
|
||||
throw new BizException(ErrCode.MODEL_DEVICE_ALREADY);
|
||||
}*/
|
||||
if (LoginHelper.isSuperAdmin() && TenantHelper.getTenantId() != 0) {
|
||||
deviceInstallInfo.getData().setTenantId(TenantHelper.getTenantId());
|
||||
// query.where(tbDeviceInstallInfo.tenantId.eq(TenantHelper.getTenantId()));
|
||||
}
|
||||
deviceInstallInfo.getData().setId(DeviceUtil.newDeviceId("0"));
|
||||
/* if(!LoginHelper.isSuperAdmin() && ObjectUtil.isNotNull(pageReqVO.getData().getTenantId())){
|
||||
query.where(tbDeviceInstallInfo.tenantId.eq(pageReqVO.getData().getTenantId()));
|
||||
}*/
|
||||
DeviceIssue deviceIssue = iDeviceInstallInfoData.findByTenantId(deviceInstallInfo.getData().getTenantId());
|
||||
if(ObjectUtil.isNotEmpty(deviceIssue)){
|
||||
throw new BizException("租户权限已存在");
|
||||
}
|
||||
iDeviceInstallInfoData.save(deviceInstallInfo.getData());
|
||||
|
||||
/* if(LoginHelper.isSuperAdmin() && TenantHelper.getTenantId() != 0) {
|
||||
userInfoData.save(user.getData());
|
||||
}else{
|
||||
user.getData().setTenantId(null);
|
||||
userInfoData.save(user.getData());
|
||||
}*/
|
||||
}
|
||||
|
||||
@PostMapping("/edit")
|
||||
@SaCheckPermission("device:issue:edit")
|
||||
public void editClientUser(@RequestBody Request<DeviceIssue> deviceInstallInfo) throws Exception {
|
||||
|
||||
TenantHelper.enableIgnore();
|
||||
if (ObjectUtil.isNull(deviceInstallInfo.getData()) || ObjectUtil.isNull(deviceInstallInfo.getData().getFieldName()) || ObjectUtil.isNull(deviceInstallInfo.getData().getId())) {
|
||||
throw new BizException(ErrCode.PARAMS_EXCEPTION);
|
||||
}
|
||||
if (LoginHelper.isSuperAdmin() && TenantHelper.getTenantId() != 0) {
|
||||
deviceInstallInfo.getData().setTenantId(TenantHelper.getTenantId());
|
||||
// query.where(tbDeviceInstallInfo.tenantId.eq(TenantHelper.getTenantId()));
|
||||
}
|
||||
DeviceIssue deviceIssue = iDeviceInstallInfoData.findById(deviceInstallInfo.getData().getId());
|
||||
// DeviceIssue deviceIssue = iDeviceInstallInfoData.findByTenantId(deviceInstallInfo.getData().getTenantId());
|
||||
|
||||
if(ObjectUtil.isNotEmpty(deviceIssue) && !deviceIssue.getTenantId().equals(deviceInstallInfo.getData().getTenantId())){
|
||||
DeviceIssue deviceIssue1 = iDeviceInstallInfoData.findByTenantId(deviceInstallInfo.getData().getTenantId());
|
||||
if(ObjectUtil.isNotEmpty(deviceIssue1)) {
|
||||
throw new BizException("租户权限已存在");
|
||||
}
|
||||
}
|
||||
iDeviceInstallInfoData.save(deviceInstallInfo.getData());
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/device/{id}/delete")
|
||||
@SaCheckPermission("device:issue:delete")
|
||||
public void deleteClientUser(@PathVariable("id") String id) {
|
||||
DeviceIssue user = iDeviceInstallInfoData.findById(id);
|
||||
if (user == null) {
|
||||
throw new BizException(ErrCode.RECORD_NOT_FOUND);
|
||||
}
|
||||
iDeviceInstallInfoData.deleteById(id);
|
||||
}
|
||||
|
||||
/* @PostMapping("/getDeviceInstallInfo")
|
||||
public DeviceInstallInfo getUserInfo() {
|
||||
return iDeviceInstallInfoData.findById(LoginHelper.getUserId());
|
||||
}*/
|
||||
@PostMapping("/getDetail")
|
||||
@SaCheckPermission("device:issue:query")
|
||||
public DeviceIssue getDetail(@Validated @RequestBody Request<String> request) {
|
||||
return iDeviceInstallInfoData.findById(request.getData());
|
||||
}
|
||||
|
||||
@PostMapping("/getDetailTenandId")
|
||||
// @SaCheckPermission("device:issue:query")
|
||||
public DeviceIssue getDetailTenandId() {
|
||||
|
||||
return iDeviceInstallInfoData.findByTenantId(TenantHelper.getTenantId());
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
*
|
||||
* * | Licensed 未经许可不能去掉「OPENIITA」相关版权
|
||||
* * +----------------------------------------------------------------------
|
||||
* * | Author: xw2sy@163.com
|
||||
* * +----------------------------------------------------------------------
|
||||
*
|
||||
* Copyright [2024] [OPENIITA]
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* /
|
||||
*/
|
||||
|
||||
package cc.iotkit.manager.service;
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.manager.dto.bo.device.DeviceInstallInfoQueryBo;
|
||||
import cc.iotkit.manager.dto.vo.deviceinfo.DeviceInstallInfoVo;
|
||||
import cc.iotkit.model.device.DeviceInstallInfo;
|
||||
import cc.iotkit.model.device.DeviceIssue;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author: jay
|
||||
* @Date: 2023/5/31 11:05
|
||||
* @Version: V1.0
|
||||
* @Description: 设备服务接口
|
||||
*/
|
||||
public interface IDeviceIssueService {
|
||||
Paging<DeviceIssue> getPage(PageRequest<DeviceIssue> pageRequest);
|
||||
//List<DeviceInstallInfoVo> getList(PageRequest<DeviceInstallInfoQueryBo> pageRequest);
|
||||
}
|
@ -0,0 +1,102 @@
|
||||
package cc.iotkit.manager.service.impl;
|
||||
|
||||
|
||||
import cc.iotkit.common.api.PageRequest;
|
||||
import cc.iotkit.common.api.Paging;
|
||||
import cc.iotkit.common.satoken.utils.LoginHelper;
|
||||
import cc.iotkit.common.tenant.helper.TenantHelper;
|
||||
import cc.iotkit.common.utils.MapstructUtils;
|
||||
import cc.iotkit.data.dao.DeviceInstallInfoRepository;
|
||||
import cc.iotkit.data.dao.DeviceIssueRepository;
|
||||
import cc.iotkit.data.manager.IDeviceInstallInfoData;
|
||||
import cc.iotkit.data.manager.IDeviceIssueData;
|
||||
import cc.iotkit.data.manager.IUserInfoData;
|
||||
import cc.iotkit.data.model.TbDeviceInstallInfo;
|
||||
import cc.iotkit.data.model.TbDeviceIssue;
|
||||
import cc.iotkit.data.system.ISysTenantData;
|
||||
import cc.iotkit.manager.dto.bo.device.DeviceInstallInfoQueryBo;
|
||||
import cc.iotkit.manager.dto.vo.deviceinfo.DeviceInstallInfoVo;
|
||||
import cc.iotkit.manager.service.IDeviceInstallInfoService;
|
||||
import cc.iotkit.manager.service.IDeviceIssueService;
|
||||
import cc.iotkit.model.UserInfo;
|
||||
import cc.iotkit.model.device.DeviceInstallInfo;
|
||||
import cc.iotkit.model.device.DeviceIssue;
|
||||
import cc.iotkit.model.system.SysTenant;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.querydsl.jpa.impl.JPAQuery;
|
||||
import com.querydsl.jpa.impl.JPAQueryFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Primary;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import static cc.iotkit.data.model.QTbDeviceIssue.tbDeviceIssue;
|
||||
|
||||
|
||||
/**
|
||||
* 物联网卡 Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@Primary
|
||||
@RequiredArgsConstructor
|
||||
public class DeviceIssueServiceImpl implements IDeviceIssueService {
|
||||
@Autowired
|
||||
private final ISysTenantData isSysTenantData;
|
||||
@Autowired
|
||||
private IDeviceIssueData iDeviceInstallInfoData;
|
||||
//@Autowired
|
||||
// private IUserInfoData iUserInfoData;
|
||||
@Autowired
|
||||
private DeviceIssueRepository deviceInstallInfoRepository;
|
||||
private final JPAQueryFactory jpaQueryFactory;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public Paging<DeviceIssue> getPage(PageRequest<DeviceIssue> pageReqVO) {
|
||||
|
||||
JPAQuery<TbDeviceIssue> query = jpaQueryFactory.selectFrom(tbDeviceIssue);
|
||||
|
||||
|
||||
if(LoginHelper.isSuperAdmin() && TenantHelper.getTenantId() != 0){
|
||||
query.where(tbDeviceIssue.tenantId.eq(TenantHelper.getTenantId()));
|
||||
}
|
||||
if(!LoginHelper.isSuperAdmin() && ObjectUtil.isNotNull(pageReqVO.getData().getTenantId())){
|
||||
query.where(tbDeviceIssue.tenantId.eq(pageReqVO.getData().getTenantId()));
|
||||
}
|
||||
query.orderBy(tbDeviceIssue.createTime.desc());
|
||||
Integer page = ObjectUtil.isNotNull(pageReqVO.getPageNum()) ?pageReqVO.getPageNum():1;
|
||||
Integer size = ObjectUtil.isNotNull(pageReqVO.getPageSize()) ?pageReqVO.getPageSize():10;
|
||||
query.offset((page - 1) * size).limit(size);
|
||||
List<TbDeviceIssue> tbDeviceInfos = query.fetch();
|
||||
List<DeviceIssue> deviceInfos = new ArrayList<>(tbDeviceInfos.size());
|
||||
long total = query.fetchCount();
|
||||
for (TbDeviceIssue tbDeviceInfo : tbDeviceInfos) {
|
||||
DeviceIssue deviceInfo = MapstructUtils.convert(tbDeviceInfo, DeviceIssue.class);
|
||||
if (ObjectUtil.isNotNull(tbDeviceInfo.getTenantId())) {
|
||||
SysTenant sysTenant = new SysTenant();
|
||||
sysTenant.setTenantId(tbDeviceInfo.getTenantId());
|
||||
SysTenant sysTenant1 = isSysTenantData.findOneByCondition(sysTenant);
|
||||
if (sysTenant1 != null) {
|
||||
deviceInfo.setTenantName(sysTenant1.getCompanyName());
|
||||
}
|
||||
|
||||
}
|
||||
deviceInfos.add(deviceInfo);
|
||||
}
|
||||
return new Paging<>(total, deviceInfos);
|
||||
|
||||
}
|
||||
// 构建动态查询条件(含排序)
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue