37 changed files with 2059 additions and 48 deletions
@ -0,0 +1,85 @@ |
|||||
|
package org.dromara.business.api.domain.vo; |
||||
|
|
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务-施工信息对象 business_alert_construct_info |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-21 |
||||
|
*/ |
||||
|
@Data |
||||
|
public class RemoteBusinessAlertConstructInfo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
private Long id; |
||||
|
|
||||
|
private String tenantId; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 1:图片比对预警 2:AI实时预警 |
||||
|
*/ |
||||
|
private Long businessType; |
||||
|
|
||||
|
/** |
||||
|
* job任务id |
||||
|
*/ |
||||
|
private String jobId; |
||||
|
|
||||
|
/** |
||||
|
* 预警名称 |
||||
|
*/ |
||||
|
private String jobName; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务id |
||||
|
*/ |
||||
|
private Long businessAlertId; |
||||
|
|
||||
|
/** |
||||
|
* 施工名称 |
||||
|
*/ |
||||
|
private String constructName; |
||||
|
|
||||
|
/** |
||||
|
* 施工单位 |
||||
|
*/ |
||||
|
private String constructDept; |
||||
|
|
||||
|
/** |
||||
|
* 施工单位负责人 |
||||
|
*/ |
||||
|
private String constructLeader; |
||||
|
|
||||
|
/** |
||||
|
* 联系电话 |
||||
|
*/ |
||||
|
private String phonenumber; |
||||
|
|
||||
|
/** |
||||
|
* 施工地址 |
||||
|
*/ |
||||
|
private String address; |
||||
|
|
||||
|
/** |
||||
|
* 所属管道 |
||||
|
*/ |
||||
|
private String pipeline; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,106 @@ |
|||||
|
package org.dromara.business.controller; |
||||
|
|
||||
|
import java.util.List; |
||||
|
|
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import jakarta.servlet.http.HttpServletResponse; |
||||
|
import jakarta.validation.constraints.*; |
||||
|
import cn.dev33.satoken.annotation.SaCheckPermission; |
||||
|
import org.springframework.web.bind.annotation.*; |
||||
|
import org.springframework.validation.annotation.Validated; |
||||
|
import org.dromara.common.idempotent.annotation.RepeatSubmit; |
||||
|
import org.dromara.common.log.annotation.Log; |
||||
|
import org.dromara.common.web.core.BaseController; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import org.dromara.common.core.domain.R; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.common.core.validate.EditGroup; |
||||
|
import org.dromara.common.log.enums.BusinessType; |
||||
|
import org.dromara.common.excel.utils.ExcelUtil; |
||||
|
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo; |
||||
|
import org.dromara.business.domain.bo.BusinessAlertConstructInfoBo; |
||||
|
import org.dromara.business.service.IBusinessAlertConstructInfoService; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务-施工信息 |
||||
|
* 前端访问路由地址为:/business/alertConstructInfo |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-21 |
||||
|
*/ |
||||
|
@Validated |
||||
|
@RequiredArgsConstructor |
||||
|
@RestController |
||||
|
@RequestMapping("/alertConstructInfo") |
||||
|
public class BusinessAlertConstructInfoController extends BaseController { |
||||
|
|
||||
|
private final IBusinessAlertConstructInfoService businessAlertConstructInfoService; |
||||
|
|
||||
|
/** |
||||
|
* 查询预警任务-施工信息列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("business:businessAlertConstructInfo:list") |
||||
|
@GetMapping("/list") |
||||
|
public TableDataInfo<BusinessAlertConstructInfoVo> list(BusinessAlertConstructInfoBo bo, PageQuery pageQuery) { |
||||
|
return businessAlertConstructInfoService.queryPageList(bo, pageQuery); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 导出预警任务-施工信息列表 |
||||
|
*/ |
||||
|
@SaCheckPermission("business:businessAlertConstructInfo:export") |
||||
|
@Log(title = "预警任务-施工信息", businessType = BusinessType.EXPORT) |
||||
|
@PostMapping("/export") |
||||
|
public void export(BusinessAlertConstructInfoBo bo, HttpServletResponse response) { |
||||
|
List<BusinessAlertConstructInfoVo> list = businessAlertConstructInfoService.queryList(bo); |
||||
|
ExcelUtil.exportExcel(list, "预警任务-施工信息", BusinessAlertConstructInfoVo.class, response); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取预警任务-施工信息详细信息 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
*/ |
||||
|
@SaCheckPermission("business:businessAlertConstructInfo:query") |
||||
|
@GetMapping("/{id}") |
||||
|
public R<BusinessAlertConstructInfoVo> getInfo(@NotNull(message = "主键不能为空") |
||||
|
@PathVariable Long id) { |
||||
|
return R.ok(businessAlertConstructInfoService.queryById(id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增预警任务-施工信息 |
||||
|
*/ |
||||
|
@SaCheckPermission("business:businessAlertConstructInfo:add") |
||||
|
@Log(title = "预警任务-施工信息", businessType = BusinessType.INSERT) |
||||
|
@RepeatSubmit() |
||||
|
@PostMapping() |
||||
|
public R<Void> add(@Validated(AddGroup.class) @RequestBody BusinessAlertConstructInfoBo bo) { |
||||
|
return toAjax(businessAlertConstructInfoService.insertByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改预警任务-施工信息 |
||||
|
*/ |
||||
|
@SaCheckPermission("business:businessAlertConstructInfo:edit") |
||||
|
@Log(title = "预警任务-施工信息", businessType = BusinessType.UPDATE) |
||||
|
@RepeatSubmit() |
||||
|
@PutMapping() |
||||
|
public R<Void> edit(@Validated(EditGroup.class) @RequestBody BusinessAlertConstructInfoBo bo) { |
||||
|
return toAjax(businessAlertConstructInfoService.updateByBo(bo)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除预警任务-施工信息 |
||||
|
* |
||||
|
* @param ids 主键串 |
||||
|
*/ |
||||
|
@SaCheckPermission("business:businessAlertConstructInfo:remove") |
||||
|
@Log(title = "预警任务-施工信息", businessType = BusinessType.DELETE) |
||||
|
@DeleteMapping("/{ids}") |
||||
|
public R<Void> remove(@NotEmpty(message = "主键不能为空") |
||||
|
@PathVariable Long[] ids) { |
||||
|
return toAjax(businessAlertConstructInfoService.deleteWithValidByIds(List.of(ids), true)); |
||||
|
} |
||||
|
} |
@ -0,0 +1,86 @@ |
|||||
|
package org.dromara.business.domain; |
||||
|
|
||||
|
import org.dromara.common.tenant.core.TenantEntity; |
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务-施工信息对象 business_alert_construct_info |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-21 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@TableName("business_alert_construct_info") |
||||
|
public class BusinessAlertConstructInfo extends TenantEntity { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
@TableId(value = "id") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 1:图片比对预警 2:AI实时预警 |
||||
|
*/ |
||||
|
private Long businessType; |
||||
|
|
||||
|
/** |
||||
|
* job任务id |
||||
|
*/ |
||||
|
private String jobId; |
||||
|
|
||||
|
/** |
||||
|
* 预警名称 |
||||
|
*/ |
||||
|
private String jobName; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务id |
||||
|
*/ |
||||
|
private Long businessAlertId; |
||||
|
|
||||
|
/** |
||||
|
* 施工名称 |
||||
|
*/ |
||||
|
private String constructName; |
||||
|
|
||||
|
/** |
||||
|
* 施工单位 |
||||
|
*/ |
||||
|
private String constructDept; |
||||
|
|
||||
|
/** |
||||
|
* 施工单位负责人 |
||||
|
*/ |
||||
|
private String constructLeader; |
||||
|
|
||||
|
/** |
||||
|
* 联系电话 |
||||
|
*/ |
||||
|
private String phonenumber; |
||||
|
|
||||
|
/** |
||||
|
* 施工地址 |
||||
|
*/ |
||||
|
private String address; |
||||
|
|
||||
|
/** |
||||
|
* 所属管道 |
||||
|
*/ |
||||
|
private String pipeline; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,87 @@ |
|||||
|
package org.dromara.business.domain.bo; |
||||
|
|
||||
|
import org.dromara.business.domain.BusinessAlertConstructInfo; |
||||
|
import org.dromara.common.mybatis.core.domain.BaseEntity; |
||||
|
import org.dromara.common.core.validate.AddGroup; |
||||
|
import org.dromara.common.core.validate.EditGroup; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
import lombok.EqualsAndHashCode; |
||||
|
import jakarta.validation.constraints.*; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务-施工信息业务对象 business_alert_construct_info |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-21 |
||||
|
*/ |
||||
|
@Data |
||||
|
@EqualsAndHashCode(callSuper = true) |
||||
|
@AutoMapper(target = BusinessAlertConstructInfo.class, reverseConvertGenerate = false) |
||||
|
public class BusinessAlertConstructInfoBo extends BaseEntity { |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
@NotNull(message = "不能为空", groups = { EditGroup.class }) |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 1:图片比对预警 2:AI实时预警 |
||||
|
*/ |
||||
|
private Long businessType; |
||||
|
|
||||
|
/** |
||||
|
* job任务id |
||||
|
*/ |
||||
|
private String jobId; |
||||
|
|
||||
|
/** |
||||
|
* 预警名称 |
||||
|
*/ |
||||
|
private String jobName; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务id |
||||
|
*/ |
||||
|
@NotNull(message = "预警任务id不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private Long businessAlertId; |
||||
|
|
||||
|
/** |
||||
|
* 施工名称 |
||||
|
*/ |
||||
|
@NotBlank(message = "施工名称不能为空", groups = { AddGroup.class, EditGroup.class }) |
||||
|
private String constructName; |
||||
|
|
||||
|
/** |
||||
|
* 施工单位 |
||||
|
*/ |
||||
|
private String constructDept; |
||||
|
|
||||
|
/** |
||||
|
* 施工单位负责人 |
||||
|
*/ |
||||
|
private String constructLeader; |
||||
|
|
||||
|
/** |
||||
|
* 联系电话 |
||||
|
*/ |
||||
|
private String phonenumber; |
||||
|
|
||||
|
/** |
||||
|
* 施工地址 |
||||
|
*/ |
||||
|
private String address; |
||||
|
|
||||
|
/** |
||||
|
* 所属管道 |
||||
|
*/ |
||||
|
private String pipeline; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
private String remark; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,104 @@ |
|||||
|
package org.dromara.business.domain.vo; |
||||
|
|
||||
|
import org.dromara.business.domain.BusinessAlertConstructInfo; |
||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
||||
|
import com.alibaba.excel.annotation.ExcelProperty; |
||||
|
import org.dromara.common.excel.annotation.ExcelDictFormat; |
||||
|
import org.dromara.common.excel.convert.ExcelDictConvert; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 预警任务-施工信息视图对象 business_alert_construct_info |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-21 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
@AutoMapper(target = BusinessAlertConstructInfo.class) |
||||
|
public class BusinessAlertConstructInfoVo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
@ExcelProperty(value = "") |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* 1:图片比对预警 2:AI实时预警 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "1:图片比对预警 2:AI实时预警") |
||||
|
private Long businessType; |
||||
|
|
||||
|
/** |
||||
|
* job任务id |
||||
|
*/ |
||||
|
@ExcelProperty(value = "job任务id") |
||||
|
private String jobId; |
||||
|
|
||||
|
/** |
||||
|
* 预警名称 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "预警名称") |
||||
|
private String jobName; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务id |
||||
|
*/ |
||||
|
@ExcelProperty(value = "预警任务id") |
||||
|
private Long businessAlertId; |
||||
|
|
||||
|
/** |
||||
|
* 施工名称 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "施工名称") |
||||
|
private String constructName; |
||||
|
|
||||
|
/** |
||||
|
* 施工单位 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "施工单位") |
||||
|
private String constructDept; |
||||
|
|
||||
|
/** |
||||
|
* 施工单位负责人 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "施工单位负责人") |
||||
|
private String constructLeader; |
||||
|
|
||||
|
/** |
||||
|
* 联系电话 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "联系电话") |
||||
|
private String phonenumber; |
||||
|
|
||||
|
/** |
||||
|
* 施工地址 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "施工地址") |
||||
|
private String address; |
||||
|
|
||||
|
/** |
||||
|
* 所属管道 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "所属管道") |
||||
|
private String pipeline; |
||||
|
|
||||
|
/** |
||||
|
* 备注 |
||||
|
*/ |
||||
|
@ExcelProperty(value = "备注") |
||||
|
private String remark; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package org.dromara.business.mapper; |
||||
|
|
||||
|
import org.dromara.business.domain.BusinessAlertConstructInfo; |
||||
|
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo; |
||||
|
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务-施工信息Mapper接口 |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-21 |
||||
|
*/ |
||||
|
public interface BusinessAlertConstructInfoMapper extends BaseMapperPlus<BusinessAlertConstructInfo, BusinessAlertConstructInfoVo> { |
||||
|
|
||||
|
} |
@ -0,0 +1,69 @@ |
|||||
|
package org.dromara.business.service; |
||||
|
|
||||
|
import org.dromara.business.domain.BusinessAlertConstructInfo; |
||||
|
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo; |
||||
|
import org.dromara.business.domain.bo.BusinessAlertConstructInfoBo; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
|
||||
|
import java.util.Collection; |
||||
|
import java.util.List; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务-施工信息Service接口 |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-21 |
||||
|
*/ |
||||
|
public interface IBusinessAlertConstructInfoService { |
||||
|
|
||||
|
/** |
||||
|
* 查询预警任务-施工信息 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 预警任务-施工信息 |
||||
|
*/ |
||||
|
BusinessAlertConstructInfoVo queryById(Long id); |
||||
|
|
||||
|
/** |
||||
|
* 分页查询预警任务-施工信息列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 预警任务-施工信息分页列表 |
||||
|
*/ |
||||
|
TableDataInfo<BusinessAlertConstructInfoVo> queryPageList(BusinessAlertConstructInfoBo bo, PageQuery pageQuery); |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的预警任务-施工信息列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 预警任务-施工信息列表 |
||||
|
*/ |
||||
|
List<BusinessAlertConstructInfoVo> queryList(BusinessAlertConstructInfoBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 新增预警任务-施工信息 |
||||
|
* |
||||
|
* @param bo 预警任务-施工信息 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
Boolean insertByBo(BusinessAlertConstructInfoBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 修改预警任务-施工信息 |
||||
|
* |
||||
|
* @param bo 预警任务-施工信息 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
Boolean updateByBo(BusinessAlertConstructInfoBo bo); |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除预警任务-施工信息信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid); |
||||
|
} |
@ -0,0 +1,138 @@ |
|||||
|
package org.dromara.business.service.impl; |
||||
|
|
||||
|
import org.dromara.common.core.utils.MapstructUtils; |
||||
|
import org.dromara.common.core.utils.StringUtils; |
||||
|
import org.dromara.common.mybatis.core.page.TableDataInfo; |
||||
|
import org.dromara.common.mybatis.core.page.PageQuery; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
||||
|
import lombok.RequiredArgsConstructor; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.dromara.business.domain.bo.BusinessAlertConstructInfoBo; |
||||
|
import org.dromara.business.domain.vo.BusinessAlertConstructInfoVo; |
||||
|
import org.dromara.business.domain.BusinessAlertConstructInfo; |
||||
|
import org.dromara.business.mapper.BusinessAlertConstructInfoMapper; |
||||
|
import org.dromara.business.service.IBusinessAlertConstructInfoService; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Collection; |
||||
|
|
||||
|
/** |
||||
|
* 预警任务-施工信息Service业务层处理 |
||||
|
* |
||||
|
* @author szs |
||||
|
* @date 2025-05-21 |
||||
|
*/ |
||||
|
@RequiredArgsConstructor |
||||
|
@Service |
||||
|
public class BusinessAlertConstructInfoServiceImpl implements IBusinessAlertConstructInfoService { |
||||
|
|
||||
|
private final BusinessAlertConstructInfoMapper baseMapper; |
||||
|
|
||||
|
/** |
||||
|
* 查询预警任务-施工信息 |
||||
|
* |
||||
|
* @param id 主键 |
||||
|
* @return 预警任务-施工信息 |
||||
|
*/ |
||||
|
@Override |
||||
|
public BusinessAlertConstructInfoVo queryById(Long id){ |
||||
|
return baseMapper.selectVoById(id); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 分页查询预警任务-施工信息列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @param pageQuery 分页参数 |
||||
|
* @return 预警任务-施工信息分页列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public TableDataInfo<BusinessAlertConstructInfoVo> queryPageList(BusinessAlertConstructInfoBo bo, PageQuery pageQuery) { |
||||
|
LambdaQueryWrapper<BusinessAlertConstructInfo> lqw = buildQueryWrapper(bo); |
||||
|
Page<BusinessAlertConstructInfoVo> result = baseMapper.selectVoPage(pageQuery.build(), lqw); |
||||
|
return TableDataInfo.build(result); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 查询符合条件的预警任务-施工信息列表 |
||||
|
* |
||||
|
* @param bo 查询条件 |
||||
|
* @return 预警任务-施工信息列表 |
||||
|
*/ |
||||
|
@Override |
||||
|
public List<BusinessAlertConstructInfoVo> queryList(BusinessAlertConstructInfoBo bo) { |
||||
|
LambdaQueryWrapper<BusinessAlertConstructInfo> lqw = buildQueryWrapper(bo); |
||||
|
return baseMapper.selectVoList(lqw); |
||||
|
} |
||||
|
|
||||
|
private LambdaQueryWrapper<BusinessAlertConstructInfo> buildQueryWrapper(BusinessAlertConstructInfoBo bo) { |
||||
|
Map<String, Object> params = bo.getParams(); |
||||
|
LambdaQueryWrapper<BusinessAlertConstructInfo> lqw = Wrappers.lambdaQuery(); |
||||
|
lqw.eq(bo.getBusinessType() != null, BusinessAlertConstructInfo::getBusinessType, bo.getBusinessType()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getJobId()), BusinessAlertConstructInfo::getJobId, bo.getJobId()); |
||||
|
lqw.like(StringUtils.isNotBlank(bo.getJobName()), BusinessAlertConstructInfo::getJobName, bo.getJobName()); |
||||
|
lqw.eq(bo.getBusinessAlertId() != null, BusinessAlertConstructInfo::getBusinessAlertId, bo.getBusinessAlertId()); |
||||
|
lqw.like(StringUtils.isNotBlank(bo.getConstructName()), BusinessAlertConstructInfo::getConstructName, bo.getConstructName()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getConstructDept()), BusinessAlertConstructInfo::getConstructDept, bo.getConstructDept()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getConstructLeader()), BusinessAlertConstructInfo::getConstructLeader, bo.getConstructLeader()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getPhonenumber()), BusinessAlertConstructInfo::getPhonenumber, bo.getPhonenumber()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getAddress()), BusinessAlertConstructInfo::getAddress, bo.getAddress()); |
||||
|
lqw.eq(StringUtils.isNotBlank(bo.getPipeline()), BusinessAlertConstructInfo::getPipeline, bo.getPipeline()); |
||||
|
return lqw; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 新增预警任务-施工信息 |
||||
|
* |
||||
|
* @param bo 预警任务-施工信息 |
||||
|
* @return 是否新增成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean insertByBo(BusinessAlertConstructInfoBo bo) { |
||||
|
BusinessAlertConstructInfo add = MapstructUtils.convert(bo, BusinessAlertConstructInfo.class); |
||||
|
validEntityBeforeSave(add); |
||||
|
boolean flag = baseMapper.insert(add) > 0; |
||||
|
if (flag) { |
||||
|
bo.setId(add.getId()); |
||||
|
} |
||||
|
return flag; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 修改预警任务-施工信息 |
||||
|
* |
||||
|
* @param bo 预警任务-施工信息 |
||||
|
* @return 是否修改成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean updateByBo(BusinessAlertConstructInfoBo bo) { |
||||
|
BusinessAlertConstructInfo update = MapstructUtils.convert(bo, BusinessAlertConstructInfo.class); |
||||
|
validEntityBeforeSave(update); |
||||
|
return baseMapper.updateById(update) > 0; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 保存前的数据校验 |
||||
|
*/ |
||||
|
private void validEntityBeforeSave(BusinessAlertConstructInfo entity){ |
||||
|
//TODO 做一些数据校验,如唯一约束
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 校验并批量删除预警任务-施工信息信息 |
||||
|
* |
||||
|
* @param ids 待删除的主键集合 |
||||
|
* @param isValid 是否进行有效性校验 |
||||
|
* @return 是否删除成功 |
||||
|
*/ |
||||
|
@Override |
||||
|
public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) { |
||||
|
if(isValid){ |
||||
|
//TODO 做一些业务上的校验,判断是否需要校验
|
||||
|
} |
||||
|
return baseMapper.deleteByIds(ids) > 0; |
||||
|
} |
||||
|
} |
@ -0,0 +1,183 @@ |
|||||
|
package org.dromara.business.utils; |
||||
|
|
||||
|
import cn.hutool.core.io.IoUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import io.minio.*; |
||||
|
import io.minio.http.Method; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.io.InputStream; |
||||
|
import java.util.HashMap; |
||||
|
|
||||
|
@Component |
||||
|
public class MinioUtil { |
||||
|
// 指定MinIO服务的访问地址(包括协议、域名或IP以及端口)
|
||||
|
private static String endpoint; |
||||
|
// MinIO的访问密钥(Access Key),用于身份验证
|
||||
|
private static String accessKey; |
||||
|
// MinIO的秘密密钥(Secret Key),与访问密钥配对使用,也是认证的一部分。
|
||||
|
private static String secretKey; |
||||
|
// 指定默认的存储桶(Bucket)名称,MinIO中用于组织和存储对象(文件)的基本容器。
|
||||
|
private static String bucket; |
||||
|
|
||||
|
@Value("${minio.endpoint:http://114.235.183.147:9090}") |
||||
|
public void setEndpoint(String endpoint) { |
||||
|
MinioUtil.endpoint = endpoint; |
||||
|
} |
||||
|
|
||||
|
@Value("${minio.accessKey:wuyuan@yf}") |
||||
|
public void setAccessKey(String accessKey) { |
||||
|
MinioUtil.accessKey = accessKey; |
||||
|
} |
||||
|
|
||||
|
@Value("${minio.secretKey:wuyuan@yf}") |
||||
|
public void setSecretKey(String secretKey) { |
||||
|
MinioUtil.secretKey = secretKey; |
||||
|
} |
||||
|
|
||||
|
@Value("${minio.bucket:dkcy}") |
||||
|
public void setBucket(String bucket) { |
||||
|
MinioUtil.bucket = bucket; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 创建并返回一个配置好的MinioClient实例 |
||||
|
* 用于与MinIO服务器交互,上传文件、下载文件、删除文件 |
||||
|
* |
||||
|
* @return 配置 |
||||
|
*/ |
||||
|
public static MinioClient getMinioClient() { |
||||
|
return MinioClient.builder() |
||||
|
.endpoint(endpoint) |
||||
|
.credentials(accessKey, secretKey) |
||||
|
.build(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 上传:将一个输入流中的文件上传到MinIO服务器上指定的存储桶(bucket)里 |
||||
|
* |
||||
|
* @param objectName .object(objectName)指定了上传后对象的名称。 |
||||
|
* @param inputStream 转换为 流 |
||||
|
* @param size 文件大小 |
||||
|
* @param contentType 内容类型 |
||||
|
* @throws Exception 异常 |
||||
|
*/ |
||||
|
public static void uploadFile(String objectName, InputStream inputStream, long size, String contentType,String newBucket) throws Exception { |
||||
|
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
||||
|
|
||||
|
MinioClient minioClient = getMinioClient(); |
||||
|
minioClient.putObject( |
||||
|
// .bucket(bucket) 指定了目标存储桶的名称。.object(objectName)指定了上传后对象的名称。
|
||||
|
PutObjectArgs.builder().bucket(bucketName).object(objectName).stream(inputStream, size, -1) |
||||
|
// .contentType(contentType)指定了上传文件的内容类型。
|
||||
|
.contentType(contentType) |
||||
|
.build()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 下载:从MinIO服务器下载指定存储桶(bucket)中的文件 |
||||
|
* |
||||
|
* @param objectName 指定要从MinIO下载的文件对象名称(即文件路径和文件名)。 |
||||
|
* @return 流 对象 |
||||
|
* @throws Exception 异常 |
||||
|
*/ |
||||
|
public static InputStream downloadFile(String objectName,String newBucket) throws Exception { |
||||
|
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
||||
|
|
||||
|
MinioClient minioClient = getMinioClient(); |
||||
|
return minioClient.getObject( |
||||
|
GetObjectArgs.builder() |
||||
|
// .bucket(bucket)指定了文件所在的存储桶名称。
|
||||
|
.bucket(bucketName) |
||||
|
// .object(objectName)指定了要下载的对象名称。
|
||||
|
.object(objectName) |
||||
|
.build()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 预览:生成一个预签名的URL,允许用户通过浏览器或其他HTTP客户端以GET方法访问MinIO存储桶中指定对象(文件)的临时链接 |
||||
|
* |
||||
|
* @param objectName 指定需要获取预览链接的文件对象名称(包括路径)。 |
||||
|
* @return 对象 |
||||
|
* @throws Exception .method(Method.GET)指定了请求的方法为GET,这是预览文件时的标准HTTP方法。 |
||||
|
* .bucket(bucket)指定了存储桶的名称。 |
||||
|
* .object(objectName)指定了对象(文件)的名称。 |
||||
|
*/ |
||||
|
public static String getPreviewUrl(String objectName,String newBucket) throws Exception { |
||||
|
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
||||
|
|
||||
|
MinioClient minioClient = getMinioClient(); |
||||
|
return minioClient.getPresignedObjectUrl( |
||||
|
GetPresignedObjectUrlArgs.builder() |
||||
|
.method(Method.GET) |
||||
|
.bucket(bucketName) |
||||
|
.object(objectName) |
||||
|
.build()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除:从MinIO服务器上的指定存储桶中删除一个文件 |
||||
|
* |
||||
|
* @param objectName 指定要删除的文件对象名称(包括路径和文件名) |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static void deleteFile(String objectName,String newBucket) throws Exception { |
||||
|
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
||||
|
|
||||
|
MinioClient minioClient = getMinioClient(); |
||||
|
minioClient.removeObject( |
||||
|
RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build()); |
||||
|
} |
||||
|
|
||||
|
//查询文件信息
|
||||
|
public static HashMap<String,Object> getFileAsMultipart(String objectName, String newBucket) throws Exception { |
||||
|
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
||||
|
MinioClient client = getMinioClient(); |
||||
|
|
||||
|
// 获取对象
|
||||
|
InputStream is = client.getObject(GetObjectArgs.builder() |
||||
|
.bucket(bucketName) |
||||
|
.object(objectName) |
||||
|
.build()); |
||||
|
|
||||
|
// 获取文件元信息(如 contentType)
|
||||
|
StatObjectResponse stat = client.statObject(StatObjectArgs.builder() |
||||
|
.bucket(bucketName) |
||||
|
.object(objectName) |
||||
|
.build()); |
||||
|
|
||||
|
String contentType = stat.contentType(); |
||||
|
|
||||
|
// 将流读为 byte[] 以生成 MockMultipartFile
|
||||
|
byte[] bytes = IoUtil.readBytes(is); // Hutool 工具类
|
||||
|
HashMap<String, Object> map = new HashMap<>(); |
||||
|
map.put("objectName",objectName); |
||||
|
map.put("contentType",contentType); |
||||
|
map.put("bytes",bytes); |
||||
|
|
||||
|
return map; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
//文件复制
|
||||
|
public static void copyFile(String sourceObjectName, String targetObjectName, String sourceBucket, String targetBucket) throws Exception { |
||||
|
MinioClient client = getMinioClient(); |
||||
|
|
||||
|
// 使用服务器端复制,无需下载上传
|
||||
|
client.copyObject(CopyObjectArgs.builder() |
||||
|
.bucket(targetBucket) // 目标桶
|
||||
|
.object(targetObjectName) // 目标对象
|
||||
|
.source(CopySource.builder() |
||||
|
.bucket(sourceBucket) |
||||
|
.object(sourceObjectName) |
||||
|
.build()) |
||||
|
.build()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,7 @@ |
|||||
|
<?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="org.dromara.business.mapper.BusinessAlertConstructInfoMapper"> |
||||
|
|
||||
|
</mapper> |
@ -0,0 +1,77 @@ |
|||||
|
package org.dromara.sample.manage.controller; |
||||
|
|
||||
|
import com.alibaba.nacos.common.utils.CollectionUtils; |
||||
|
import io.swagger.v3.oas.annotations.Operation; |
||||
|
import io.swagger.v3.oas.annotations.tags.Tag; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.dromara.common.sdk.common.HttpResultResponse; |
||||
|
import org.dromara.sample.manage.model.dto.CallBackDTO; |
||||
|
import org.dromara.sample.manage.model.dto.EventsDTO; |
||||
|
import org.dromara.sample.manage.model.entity.WarningRecordEntity; |
||||
|
import org.dromara.sample.manage.service.ISampleEngineRecordService; |
||||
|
import org.dromara.sample.manage.service.ISampleWarningRecordService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
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.RestController; |
||||
|
|
||||
|
import java.util.ArrayList; |
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @author sean.zhou |
||||
|
* @version 0.1 |
||||
|
* @date 2021/11/15 |
||||
|
*/ |
||||
|
@RestController |
||||
|
@Slf4j |
||||
|
@RequestMapping("${url.manage.prefix}${url.manage.version}/saEngineRecord") |
||||
|
@Tag(name = "无人机设备模块") |
||||
|
public class SampleEngineRecordController { |
||||
|
|
||||
|
@Autowired |
||||
|
private ISampleEngineRecordService sampleEngineRecordService; |
||||
|
|
||||
|
@Autowired |
||||
|
private ISampleWarningRecordService sampleWarningRecordService; |
||||
|
|
||||
|
/** |
||||
|
* 启动星罗引擎。 |
||||
|
* Get the topology list of all online devices in one workspace. |
||||
|
* @return |
||||
|
*/ |
||||
|
@PostMapping("/startEngine") |
||||
|
@Operation(summary = "启动星罗引擎。", description = "启动星罗引擎") |
||||
|
public HttpResultResponse<Map<String,Object>> startEngine(@RequestBody Map<String,Object> objectMap) { |
||||
|
return HttpResultResponse.success(sampleEngineRecordService.startEngine(objectMap)); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/closeEngine") |
||||
|
@Operation(summary = "关闭星罗引擎。", description = "关闭星罗引擎") |
||||
|
public HttpResultResponse closeEngine(@RequestBody Map<String,Object> objectMap) { |
||||
|
sampleEngineRecordService.closeEngine(objectMap); |
||||
|
return HttpResultResponse.success(); |
||||
|
} |
||||
|
|
||||
|
@PostMapping("/some") |
||||
|
@Operation(summary = "存储推流的预警(对外接口)。", description = "存储推流的预警(对外接口)。") |
||||
|
public void some(@RequestBody CallBackDTO callBackVo){ |
||||
|
WarningRecordEntity warningRecord = new WarningRecordEntity(); |
||||
|
List<WarningRecordEntity> list = new ArrayList<>(); |
||||
|
if (CollectionUtils.isNotEmpty(callBackVo.getEvents())){ |
||||
|
for (EventsDTO eventsVo :callBackVo.getEvents()){ |
||||
|
warningRecord.setTaskId(callBackVo.getTaskId()); |
||||
|
warningRecord.setAlgoId(eventsVo.getAlgoId()); |
||||
|
warningRecord.setEventId(eventsVo.getEventId()); |
||||
|
warningRecord.setExtraType(eventsVo.getExtraType()); |
||||
|
warningRecord.setPicUrl(eventsVo.getPicUrl()); |
||||
|
warningRecord.setTimestamp(eventsVo.getTimestamp()); |
||||
|
list.add(warningRecord); |
||||
|
} |
||||
|
sampleWarningRecordService.saveBatch(list); |
||||
|
System.out.println(callBackVo); |
||||
|
} |
||||
|
} |
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
package org.dromara.sample.manage.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.dromara.sample.manage.model.entity.EngineRecordEntity; |
||||
|
import org.mapstruct.Mapper; |
||||
|
|
||||
|
|
||||
|
public interface ISampleEngineRecordMapper extends BaseMapper<EngineRecordEntity> { |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package org.dromara.sample.manage.mapper; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.dromara.sample.manage.model.entity.PlayTextEntity; |
||||
|
import org.dromara.sample.manage.model.entity.TaskJobEntity; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author sean.zhou |
||||
|
* @date 2021/11/10 |
||||
|
* @version 0.1 |
||||
|
*/ |
||||
|
public interface ITaskJobMapper extends BaseMapper<TaskJobEntity> { |
||||
|
|
||||
|
} |
@ -0,0 +1,18 @@ |
|||||
|
package org.dromara.sample.manage.mapper; |
||||
|
|
||||
|
|
||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper; |
||||
|
import org.apache.ibatis.annotations.Mapper; |
||||
|
import org.dromara.sample.manage.model.entity.WarningRecordEntity; |
||||
|
|
||||
|
/** |
||||
|
* 设备对象-》用于存储设备Mapper接口 |
||||
|
* |
||||
|
* @author wuyuan |
||||
|
* @date 2022-10-25 |
||||
|
*/ |
||||
|
@Mapper |
||||
|
public interface SampleWarningRecordMapper extends BaseMapper<WarningRecordEntity> { |
||||
|
|
||||
|
} |
||||
|
|
@ -0,0 +1,212 @@ |
|||||
|
package org.dromara.sample.manage.model.dto; |
||||
|
|
||||
|
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; |
||||
|
import io.github.linpeilie.annotations.AutoMapper; |
||||
|
import lombok.Data; |
||||
|
|
||||
|
import java.io.Serial; |
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 预警任务视图对象 wayline_alert |
||||
|
* |
||||
|
* @author LionLi |
||||
|
* @date 2025-02-27 |
||||
|
*/ |
||||
|
@Data |
||||
|
@ExcelIgnoreUnannotated |
||||
|
public class BusinessAlertVo implements Serializable { |
||||
|
|
||||
|
@Serial |
||||
|
private static final long serialVersionUID = 1L; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
*/ |
||||
|
private Long id; |
||||
|
|
||||
|
/** |
||||
|
* job任务id |
||||
|
*/ |
||||
|
private String jobId; |
||||
|
|
||||
|
/** |
||||
|
* 预警名称 |
||||
|
*/ |
||||
|
private String jobName; |
||||
|
|
||||
|
/** |
||||
|
* 图片id 对应的media_file 的fileId |
||||
|
*/ |
||||
|
private String taskImageId; |
||||
|
|
||||
|
/** |
||||
|
* 处理原因 |
||||
|
*/ |
||||
|
private String reason; |
||||
|
|
||||
|
/** |
||||
|
* 是否指派 |
||||
|
*/ |
||||
|
private Boolean assign; |
||||
|
|
||||
|
/** |
||||
|
* 图片文件 |
||||
|
*/ |
||||
|
private String images; |
||||
|
|
||||
|
/** |
||||
|
* 纬度 |
||||
|
*/ |
||||
|
private String lat; |
||||
|
|
||||
|
/** |
||||
|
* 精度 |
||||
|
*/ |
||||
|
private String lng; |
||||
|
|
||||
|
/** |
||||
|
* 标签名-中 |
||||
|
*/ |
||||
|
private String labelCn; |
||||
|
|
||||
|
/** |
||||
|
* 标签名-英 |
||||
|
*/ |
||||
|
private String labelEn; |
||||
|
|
||||
|
/** |
||||
|
* 任务内容 |
||||
|
*/ |
||||
|
private String taskContent; |
||||
|
|
||||
|
/** |
||||
|
* 删除 0 正常 1已删除 |
||||
|
*/ |
||||
|
private Integer delFlag; |
||||
|
|
||||
|
/** |
||||
|
* 模板图片 |
||||
|
*/ |
||||
|
private String mateSourceImgUrl; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 放大模板违建区域图片 |
||||
|
*/ |
||||
|
private String maxMateSourceImgUrl; |
||||
|
|
||||
|
/** |
||||
|
* 预警类型 |
||||
|
*/ |
||||
|
private String alertType; |
||||
|
|
||||
|
/** |
||||
|
* 放大违建区域图片 |
||||
|
*/ |
||||
|
private String maxImages; |
||||
|
|
||||
|
/** |
||||
|
* 面积 |
||||
|
*/ |
||||
|
private Long area; |
||||
|
|
||||
|
/** |
||||
|
* 面积:长 |
||||
|
*/ |
||||
|
private Long areaL; |
||||
|
|
||||
|
/** |
||||
|
* 面积:宽 |
||||
|
*/ |
||||
|
private Long areaW; |
||||
|
|
||||
|
/** |
||||
|
* 流程处置状态(verify:验证,cancel:已撤销,draft:草稿,waiting:待审核,finish:已完成,invalid:已作废,back:已退回,termination:已终止) |
||||
|
*/ |
||||
|
private String handleType; |
||||
|
|
||||
|
/** |
||||
|
* 指派人员 |
||||
|
*/ |
||||
|
private String assignUserId; |
||||
|
|
||||
|
/** |
||||
|
* 指派时间 |
||||
|
*/ |
||||
|
private Date assignDate; |
||||
|
|
||||
|
/** |
||||
|
* 完成时间 |
||||
|
*/ |
||||
|
private Date completeDate; |
||||
|
|
||||
|
/** |
||||
|
* 是否违建 0:否,1:是 |
||||
|
*/ |
||||
|
private Boolean isIllegal; |
||||
|
|
||||
|
/** |
||||
|
* 部门id |
||||
|
*/ |
||||
|
private String deptId; |
||||
|
|
||||
|
/** |
||||
|
* 部门名称 |
||||
|
*/ |
||||
|
private String deptName; |
||||
|
|
||||
|
/** |
||||
|
* 处理时间 |
||||
|
*/ |
||||
|
private Date handleTime; |
||||
|
|
||||
|
/** |
||||
|
* 其他:内容 |
||||
|
*/ |
||||
|
private String taskHandle; |
||||
|
|
||||
|
/** |
||||
|
* 像素坐标 |
||||
|
*/ |
||||
|
private String pixelCoordinate; |
||||
|
|
||||
|
/** |
||||
|
* 当前位置预警数量 |
||||
|
*/ |
||||
|
private Integer handleNum; |
||||
|
|
||||
|
/** |
||||
|
* 地类信息数据 |
||||
|
*/ |
||||
|
private String landCategories; |
||||
|
|
||||
|
/** |
||||
|
* 忽略原因 |
||||
|
*/ |
||||
|
private String ignoringCause; |
||||
|
private Integer value; |
||||
|
|
||||
|
/** |
||||
|
* 来源:0:平台 1:小程序 |
||||
|
*/ |
||||
|
private Integer handleSource; |
||||
|
|
||||
|
/** |
||||
|
* 指派人员名称 |
||||
|
*/ |
||||
|
private String assignUserName; |
||||
|
|
||||
|
private Date createTime; |
||||
|
//1:图片比对预警 2:AI实时预警
|
||||
|
private Integer businessType; |
||||
|
private String deviceSn; |
||||
|
|
||||
|
/** |
||||
|
* 案件号 |
||||
|
*/ |
||||
|
private String caseNumber; |
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
package org.dromara.sample.manage.model.dto; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Builder; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* The entity class of the device |
||||
|
* |
||||
|
* @author sean.zhou |
||||
|
* @version 0.1 |
||||
|
* @date 2021/11/10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Builder |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
public class EngineType implements Serializable { |
||||
|
|
||||
|
private String scene; |
||||
|
|
||||
|
private int id; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,30 @@ |
|||||
|
package org.dromara.sample.manage.model.dto; |
||||
|
|
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Builder; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
|
||||
|
/** |
||||
|
* The entity class of the device |
||||
|
* |
||||
|
* @author sean.zhou |
||||
|
* @version 0.1 |
||||
|
* @date 2021/11/10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Builder |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
public class EngineTypeResponse implements Serializable { |
||||
|
|
||||
|
private Long code; |
||||
|
|
||||
|
private String message; |
||||
|
|
||||
|
private EngineType data; |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,33 @@ |
|||||
|
package org.dromara.sample.manage.model.entity; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.annotation.*; |
||||
|
import lombok.AllArgsConstructor; |
||||
|
import lombok.Builder; |
||||
|
import lombok.Data; |
||||
|
import lombok.NoArgsConstructor; |
||||
|
|
||||
|
import java.io.Serializable; |
||||
|
import java.util.Date; |
||||
|
|
||||
|
/** |
||||
|
* The entity class of the device |
||||
|
* |
||||
|
* @author sean.zhou |
||||
|
* @version 0.1 |
||||
|
* @date 2021/11/10 |
||||
|
*/ |
||||
|
@Data |
||||
|
@Builder |
||||
|
@NoArgsConstructor |
||||
|
@AllArgsConstructor |
||||
|
@TableName(value = "task_job") |
||||
|
public class TaskJobEntity implements Serializable { |
||||
|
|
||||
|
@TableId(type = IdType.AUTO) |
||||
|
private Integer id; |
||||
|
|
||||
|
private String taskId; |
||||
|
|
||||
|
private String jobId; |
||||
|
|
||||
|
} |
@ -0,0 +1,9 @@ |
|||||
|
package org.dromara.sample.manage.service; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
public interface ISampleEngineRecordService { |
||||
|
Map<String,Object> startEngine(Map<String,Object> objectMap); |
||||
|
|
||||
|
void closeEngine(Map<String,Object> objectMap); |
||||
|
} |
@ -0,0 +1,8 @@ |
|||||
|
package org.dromara.sample.manage.service; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import org.dromara.sample.manage.model.entity.WarningRecordEntity; |
||||
|
|
||||
|
|
||||
|
public interface ISampleWarningRecordService extends IService<WarningRecordEntity> { |
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package org.dromara.sample.manage.service; |
||||
|
|
||||
|
import org.dromara.common.sdk.common.HttpResultResponse; |
||||
|
import org.dromara.common.sdk.common.PaginationData; |
||||
|
import org.dromara.sample.manage.model.entity.PlayTextEntity; |
||||
|
|
||||
|
import java.util.Map; |
||||
|
|
||||
|
/** |
||||
|
* @author sean.zhou |
||||
|
* @date 2021/11/10 |
||||
|
* @version 0.1 |
||||
|
*/ |
||||
|
public interface ITaskJobService { |
||||
|
} |
@ -0,0 +1,250 @@ |
|||||
|
package org.dromara.sample.manage.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.map.MapUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.fasterxml.jackson.core.JsonProcessingException; |
||||
|
import com.fasterxml.jackson.databind.ObjectMapper; |
||||
|
import io.seata.common.util.StringUtils; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.dubbo.config.annotation.DubboReference; |
||||
|
import org.apache.http.client.methods.CloseableHttpResponse; |
||||
|
import org.apache.http.client.methods.HttpGet; |
||||
|
import org.apache.http.client.methods.HttpPost; |
||||
|
import org.apache.http.client.utils.URIBuilder; |
||||
|
import org.apache.http.entity.StringEntity; |
||||
|
import org.apache.http.impl.client.CloseableHttpClient; |
||||
|
import org.apache.http.impl.client.HttpClients; |
||||
|
import org.apache.http.util.EntityUtils; |
||||
|
import org.dromara.sample.common.util.Md5Utils; |
||||
|
import org.dromara.sample.manage.mapper.ISampleEngineRecordMapper; |
||||
|
import org.dromara.sample.manage.mapper.ITaskJobMapper; |
||||
|
import org.dromara.sample.manage.model.dto.*; |
||||
|
import org.dromara.sample.manage.model.entity.EngineRecordEntity; |
||||
|
import org.dromara.sample.manage.model.entity.TaskJobEntity; |
||||
|
import org.dromara.sample.manage.service.ISampleEngineRecordService; |
||||
|
import org.dromara.system.api.RemoteConfigService; |
||||
|
import org.json.JSONArray; |
||||
|
import org.json.JSONObject; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import javax.annotation.Resource; |
||||
|
import java.net.URI; |
||||
|
import java.net.URISyntaxException; |
||||
|
import java.util.*; |
||||
|
|
||||
|
import static org.apache.commons.compress.utils.ArchiveUtils.sanitize; |
||||
|
|
||||
|
@Service |
||||
|
@Slf4j |
||||
|
@Transactional |
||||
|
public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService { |
||||
|
@Resource |
||||
|
ISampleEngineRecordMapper mapper; |
||||
|
|
||||
|
@Resource |
||||
|
ITaskJobMapper taskJobMapper; |
||||
|
|
||||
|
@DubboReference |
||||
|
private RemoteConfigService remoteConfigService; |
||||
|
@Override |
||||
|
public Map<String, Object> startEngine(Map<String, Object> objectMap){ |
||||
|
EngineRecordEntity record = new EngineRecordEntity(); |
||||
|
String ip = remoteConfigService.selectStreamIp(); |
||||
|
//获取token
|
||||
|
//设置请求Header和Body(如JSON)
|
||||
|
String md5 = Md5Utils.hash("xuzhou_ai"); |
||||
|
JSONObject jsonObj = new JSONObject(); |
||||
|
jsonObj.put("username", sanitize("xuzhou_ai")); // sanitize函数见下文
|
||||
|
jsonObj.put("password", sanitize(md5)); |
||||
|
String responseBody = PostRequest(jsonObj, "http://60.204.247.65:8100/Third/Login",""); |
||||
|
JSONObject jsonObject = new JSONObject(responseBody); |
||||
|
// 逐层获取 data -> token
|
||||
|
JSONObject data = jsonObject.getJSONObject("data"); |
||||
|
String token = data.getString("token"); |
||||
|
String sceneResponseBody = null; |
||||
|
String algorithmResponseBody = null; |
||||
|
//查询用户开通的场景
|
||||
|
if (StringUtils.isNotEmpty(token)){ |
||||
|
// try {
|
||||
|
// URI uri = new URIBuilder("http://60.204.247.65:8100/V2/AI/WX/User/Scene")
|
||||
|
// .build();
|
||||
|
// sceneResponseBody = GetRequest(uri, token);
|
||||
|
// } catch (URISyntaxException e) {
|
||||
|
// throw new RuntimeException(e);
|
||||
|
// }
|
||||
|
// EngineTypeResponse engineTypeResponse = null;
|
||||
|
// try {
|
||||
|
// ObjectMapper mapper = new ObjectMapper();
|
||||
|
// engineTypeResponse = mapper.readValue(sceneResponseBody, EngineTypeResponse.class);
|
||||
|
// } catch (JsonProcessingException e) {
|
||||
|
// throw new RuntimeException(e);
|
||||
|
// }
|
||||
|
//// JSONObject jsonObject1 = new JSONObject(sceneResponseBody);
|
||||
|
// // 逐层获取 data -> token
|
||||
|
//// JSONObject data1 = jsonObject1.getJSONObject("data");
|
||||
|
// String scene = engineTypeResponse.getData().getScene();
|
||||
|
//
|
||||
|
// //查询场景算法
|
||||
|
// List<String> extra_type_list = new ArrayList<>();
|
||||
|
// try {
|
||||
|
// URI uri = new URIBuilder("http://60.204.247.65:8100/V2/AI/WX/User/ExtraType/Get")
|
||||
|
// .addParameter("scene",scene)
|
||||
|
// .addParameter("if_open","1")
|
||||
|
// .build();
|
||||
|
// algorithmResponseBody = GetRequest(uri, token);
|
||||
|
// ObjectMapper mapper = new ObjectMapper();
|
||||
|
// ExtraTypeResponse response = mapper.readValue(algorithmResponseBody,ExtraTypeResponse.class);
|
||||
|
// List<ExtraType> list = response.getData();
|
||||
|
// for (ExtraType extraType : list) {
|
||||
|
// extra_type_list.add(extraType.getExtra_type());
|
||||
|
// break;
|
||||
|
// }
|
||||
|
// } catch (URISyntaxException | JsonProcessingException e) {
|
||||
|
// throw new RuntimeException(e);
|
||||
|
// }
|
||||
|
|
||||
|
JSONObject jsonObj2 = new JSONObject(); |
||||
|
String type = objectMap.get("type").toString(); |
||||
|
if (StringUtils.isNotEmpty(type)){ |
||||
|
List<String> list = Arrays.asList(type.split(",")); |
||||
|
jsonObj2.put("scene", "可见光"); // sanitize函数见下文
|
||||
|
jsonObj2.put("callback_url", "http://114.235.183.162:9888/ces/iot/deviceLog/some"); |
||||
|
jsonObj2.put("extra_type_list",new JSONArray(list)); |
||||
|
jsonObj2.put("input_url","http://"+ip+":19008/live/livesteam/"+objectMap.get("rtmpUrl")+".flv"); |
||||
|
jsonObj2.put("push_url", "rtmp://"+ip+"/live/livesteam/"+objectMap.get("rtmpUrl")+"ai1"); |
||||
|
// jsonObj2.put("play_url", objectMap.get("play_url"));
|
||||
|
String responseBody2 = PostRequest(jsonObj2, "http://60.204.247.65:8100/Third/Engine/Start",token); |
||||
|
ObjectMapper mapper1 = new ObjectMapper(); |
||||
|
EngineResponse response = null; |
||||
|
try { |
||||
|
response = mapper1.readValue(responseBody2, EngineResponse.class); |
||||
|
if (response.getCode() != 200){ |
||||
|
throw new RuntimeException("第三方接口调用失败!"); |
||||
|
} |
||||
|
} catch (JsonProcessingException e) { |
||||
|
throw new RuntimeException(e); |
||||
|
} |
||||
|
objectMap.put("task_id",response.getData().getTask_id()); |
||||
|
record.setPushUrl(objectMap.get("rtmpUrl").toString()); |
||||
|
record.setTaskId(MapUtil.getStr(objectMap,"task_id","")); |
||||
|
record.setDeviceSn(MapUtil.getStr(objectMap,"deviceSn","")); |
||||
|
record.setTaskId(response.getData().getTask_id()); |
||||
|
record.setExtraType(objectMap.get("type").toString()); |
||||
|
System.out.print(objectMap); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
Map<String, Object> map = new HashMap(); |
||||
|
|
||||
|
map.put("push_url", "http://"+ip+":1985/rtc/v1/whep/?app=live/livesteam&stream="+objectMap.get("rtmpUrl")+"ai1"); |
||||
|
|
||||
|
map.put("task_id", objectMap.get("task_id")); |
||||
|
//添加启动引擎记录
|
||||
|
mapper.insert(record); |
||||
|
|
||||
|
//添加任务id和jobid关联关系
|
||||
|
TaskJobEntity taskJobEntity = new TaskJobEntity(); |
||||
|
taskJobEntity.setJobId(objectMap.get("jobId").toString()); |
||||
|
taskJobEntity.setTaskId(objectMap.get("task_id").toString()); |
||||
|
taskJobMapper.insert(taskJobEntity); |
||||
|
return map; |
||||
|
} |
||||
|
|
||||
|
@Override |
||||
|
public void closeEngine(Map<String, Object> objectMap) { |
||||
|
JSONObject jsonObj2 = new JSONObject(); |
||||
|
EngineRecordEntity record = mapper.selectOne(new LambdaQueryWrapper<EngineRecordEntity>().eq(EngineRecordEntity::getDeviceSn, objectMap.get("deviceSn"))); |
||||
|
if (record == null){ |
||||
|
// throw new RuntimeException("关闭引擎失败!");
|
||||
|
}else { |
||||
|
//获取token
|
||||
|
//设置请求Header和Body(如JSON)
|
||||
|
String md5 = Md5Utils.hash("xuzhou_ai"); |
||||
|
JSONObject jsonObj = new JSONObject(); |
||||
|
jsonObj.put("username", sanitize("xuzhou_ai")); // sanitize函数见下文
|
||||
|
jsonObj.put("password", sanitize(md5)); |
||||
|
String responseBody = PostRequest(jsonObj, "http://60.204.247.65:8100/Third/Login",""); |
||||
|
JSONObject jsonObject = new JSONObject(responseBody); |
||||
|
// 逐层获取 data -> token
|
||||
|
JSONObject data = jsonObject.getJSONObject("data"); |
||||
|
String token = data.getString("token"); |
||||
|
|
||||
|
|
||||
|
jsonObj2.put("task_id", record.getTaskId()); // sanitize函数见下文
|
||||
|
String responseBody2 = PostRequest(jsonObj2, "http://60.204.247.65:8100/Third/Engine/Stop",token); |
||||
|
JSONObject json = new JSONObject(responseBody2); |
||||
|
// 方式2:安全获取(先判空再转换)
|
||||
|
Object dataObj = json.get("data"); |
||||
|
if(dataObj != null && dataObj instanceof Integer) { |
||||
|
int data1 = (Integer) dataObj; |
||||
|
if (data1 ==1){ |
||||
|
mapper.delete(new LambdaQueryWrapper<EngineRecordEntity>().eq(EngineRecordEntity::getDeviceSn, objectMap.get("deviceSn"))); |
||||
|
}else { |
||||
|
throw new RuntimeException("关闭引擎失败!"); |
||||
|
} |
||||
|
} else { |
||||
|
throw new RuntimeException("关闭引擎失败!"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
public String PostRequest( JSONObject jsonObj, String url, String token |
||||
|
) { |
||||
|
try (CloseableHttpClient httpClient = HttpClients.createDefault()) { |
||||
|
// 1. 创建POST请求对象
|
||||
|
HttpPost post = new HttpPost(url); |
||||
|
StringEntity requestEntity = new StringEntity(jsonObj.toString(), "UTF-8"); |
||||
|
requestEntity.setContentType("application/json"); |
||||
|
post.setEntity(requestEntity); |
||||
|
post.setHeader("Accept", "application/json"); |
||||
|
post.setHeader("token", token); |
||||
|
// 3. 执行请求并获取响应
|
||||
|
try (CloseableHttpResponse response = httpClient.execute(post)) { |
||||
|
String responseBody = EntityUtils.toString(response.getEntity()); |
||||
|
if (response.getStatusLine().getStatusCode() == 200) { |
||||
|
return responseBody; |
||||
|
} else { |
||||
|
throw new RuntimeException("第三方接口调用失败!"); |
||||
|
} |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return null; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public String GetRequest(URI uri, String token |
||||
|
) { |
||||
|
try (CloseableHttpClient httpClient = HttpClients.createDefault()) { |
||||
|
// URI uri = new URIBuilder("https://api.example.com/data")
|
||||
|
// .addParameter("param1", "value1")
|
||||
|
// .addParameter("param2", "value2")
|
||||
|
// .build();
|
||||
|
HttpGet httpGet = new HttpGet(uri); |
||||
|
if (StringUtils.isNotEmpty(token)){ |
||||
|
httpGet.setHeader("token",token); |
||||
|
} |
||||
|
try (CloseableHttpResponse response = httpClient.execute(httpGet)) { |
||||
|
// 处理响应
|
||||
|
String responseBody = EntityUtils.toString(response.getEntity()); |
||||
|
if (response.getStatusLine().getStatusCode() == 200){ |
||||
|
return responseBody; |
||||
|
}else { |
||||
|
throw new RuntimeException("第三方接口调用失败!"); |
||||
|
} |
||||
|
} |
||||
|
} catch (Exception e) { |
||||
|
e.printStackTrace(); |
||||
|
} |
||||
|
return null; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
@ -0,0 +1,15 @@ |
|||||
|
package org.dromara.sample.manage.service.impl; |
||||
|
|
||||
|
import com.baomidou.mybatisplus.extension.service.IService; |
||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.dromara.sample.manage.mapper.SampleWarningRecordMapper; |
||||
|
import org.dromara.sample.manage.mapper.WarningRecordMapper; |
||||
|
import org.dromara.sample.manage.model.entity.WarningRecordEntity; |
||||
|
import org.dromara.sample.manage.service.ISampleWarningRecordService; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
|
||||
|
@Service |
||||
|
@Slf4j |
||||
|
public class SampleWarningRecordServiceImpl extends ServiceImpl<SampleWarningRecordMapper, WarningRecordEntity> implements ISampleWarningRecordService { |
||||
|
} |
@ -0,0 +1,44 @@ |
|||||
|
package org.dromara.sample.manage.service.impl; |
||||
|
|
||||
|
import cn.hutool.core.convert.Convert; |
||||
|
import cn.hutool.crypto.SecureUtil; |
||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
||||
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
||||
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
||||
|
import jakarta.annotation.Resource; |
||||
|
import lombok.extern.slf4j.Slf4j; |
||||
|
import org.apache.commons.collections.CollectionUtils; |
||||
|
import org.apache.dubbo.config.annotation.DubboReference; |
||||
|
import org.dromara.common.sdk.common.HttpResultResponse; |
||||
|
import org.dromara.common.sdk.common.Pagination; |
||||
|
import org.dromara.common.sdk.common.PaginationData; |
||||
|
import org.dromara.common.sdk.mqtt.CommonTopicRequest; |
||||
|
import org.dromara.common.sdk.mqtt.MqttGatewayPublish; |
||||
|
import org.dromara.sample.feign.RemoteSystemFeign; |
||||
|
import org.dromara.sample.manage.mapper.IPlayTextMapper; |
||||
|
import org.dromara.sample.manage.model.dto.StreamTypeDTO; |
||||
|
import org.dromara.sample.manage.model.entity.PlayTextEntity; |
||||
|
import org.dromara.sample.manage.service.IPlayTextService; |
||||
|
import org.dromara.sample.manage.service.ITaskJobService; |
||||
|
import org.dromara.system.api.RemoteConfigService; |
||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||
|
import org.springframework.stereotype.Service; |
||||
|
import org.springframework.transaction.annotation.Transactional; |
||||
|
|
||||
|
import java.util.List; |
||||
|
import java.util.Map; |
||||
|
import java.util.Objects; |
||||
|
import java.util.UUID; |
||||
|
|
||||
|
/** |
||||
|
* |
||||
|
* @author sean.zhou |
||||
|
* @version 0.1 |
||||
|
* @date 2021/11/10 |
||||
|
*/ |
||||
|
@Service |
||||
|
@Slf4j |
||||
|
@Transactional |
||||
|
public class TaskJobServiceImpl implements ITaskJobService { |
||||
|
|
||||
|
} |
@ -0,0 +1,183 @@ |
|||||
|
package org.dromara.sample.utils; |
||||
|
|
||||
|
import cn.hutool.core.io.IoUtil; |
||||
|
import cn.hutool.core.util.StrUtil; |
||||
|
import io.minio.*; |
||||
|
import io.minio.http.Method; |
||||
|
import org.springframework.beans.factory.annotation.Value; |
||||
|
import org.springframework.stereotype.Component; |
||||
|
|
||||
|
import java.io.InputStream; |
||||
|
import java.util.HashMap; |
||||
|
|
||||
|
@Component |
||||
|
public class MinioUtil { |
||||
|
// 指定MinIO服务的访问地址(包括协议、域名或IP以及端口)
|
||||
|
private static String endpoint; |
||||
|
// MinIO的访问密钥(Access Key),用于身份验证
|
||||
|
private static String accessKey; |
||||
|
// MinIO的秘密密钥(Secret Key),与访问密钥配对使用,也是认证的一部分。
|
||||
|
private static String secretKey; |
||||
|
// 指定默认的存储桶(Bucket)名称,MinIO中用于组织和存储对象(文件)的基本容器。
|
||||
|
private static String bucket; |
||||
|
|
||||
|
@Value("${minio.endpoint:http://114.235.183.147:9090}") |
||||
|
public void setEndpoint(String endpoint) { |
||||
|
MinioUtil.endpoint = endpoint; |
||||
|
} |
||||
|
|
||||
|
@Value("${minio.accessKey:wuyuan@yf}") |
||||
|
public void setAccessKey(String accessKey) { |
||||
|
MinioUtil.accessKey = accessKey; |
||||
|
} |
||||
|
|
||||
|
@Value("${minio.secretKey:wuyuan@yf}") |
||||
|
public void setSecretKey(String secretKey) { |
||||
|
MinioUtil.secretKey = secretKey; |
||||
|
} |
||||
|
|
||||
|
@Value("${minio.bucket:dkcy}") |
||||
|
public void setBucket(String bucket) { |
||||
|
MinioUtil.bucket = bucket; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 创建并返回一个配置好的MinioClient实例 |
||||
|
* 用于与MinIO服务器交互,上传文件、下载文件、删除文件 |
||||
|
* |
||||
|
* @return 配置 |
||||
|
*/ |
||||
|
public static MinioClient getMinioClient() { |
||||
|
return MinioClient.builder() |
||||
|
.endpoint(endpoint) |
||||
|
.credentials(accessKey, secretKey) |
||||
|
.build(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 上传:将一个输入流中的文件上传到MinIO服务器上指定的存储桶(bucket)里 |
||||
|
* |
||||
|
* @param objectName .object(objectName)指定了上传后对象的名称。 |
||||
|
* @param inputStream 转换为 流 |
||||
|
* @param size 文件大小 |
||||
|
* @param contentType 内容类型 |
||||
|
* @throws Exception 异常 |
||||
|
*/ |
||||
|
public static void uploadFile(String objectName, InputStream inputStream, long size, String contentType,String newBucket) throws Exception { |
||||
|
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
||||
|
|
||||
|
MinioClient minioClient = getMinioClient(); |
||||
|
minioClient.putObject( |
||||
|
// .bucket(bucket) 指定了目标存储桶的名称。.object(objectName)指定了上传后对象的名称。
|
||||
|
PutObjectArgs.builder().bucket(bucketName).object(objectName).stream(inputStream, size, -1) |
||||
|
// .contentType(contentType)指定了上传文件的内容类型。
|
||||
|
.contentType(contentType) |
||||
|
.build()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 下载:从MinIO服务器下载指定存储桶(bucket)中的文件 |
||||
|
* |
||||
|
* @param objectName 指定要从MinIO下载的文件对象名称(即文件路径和文件名)。 |
||||
|
* @return 流 对象 |
||||
|
* @throws Exception 异常 |
||||
|
*/ |
||||
|
public static InputStream downloadFile(String objectName,String newBucket) throws Exception { |
||||
|
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
||||
|
|
||||
|
MinioClient minioClient = getMinioClient(); |
||||
|
return minioClient.getObject( |
||||
|
GetObjectArgs.builder() |
||||
|
// .bucket(bucket)指定了文件所在的存储桶名称。
|
||||
|
.bucket(bucketName) |
||||
|
// .object(objectName)指定了要下载的对象名称。
|
||||
|
.object(objectName) |
||||
|
.build()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 预览:生成一个预签名的URL,允许用户通过浏览器或其他HTTP客户端以GET方法访问MinIO存储桶中指定对象(文件)的临时链接 |
||||
|
* |
||||
|
* @param objectName 指定需要获取预览链接的文件对象名称(包括路径)。 |
||||
|
* @return 对象 |
||||
|
* @throws Exception .method(Method.GET)指定了请求的方法为GET,这是预览文件时的标准HTTP方法。 |
||||
|
* .bucket(bucket)指定了存储桶的名称。 |
||||
|
* .object(objectName)指定了对象(文件)的名称。 |
||||
|
*/ |
||||
|
public static String getPreviewUrl(String objectName,String newBucket) throws Exception { |
||||
|
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
||||
|
|
||||
|
MinioClient minioClient = getMinioClient(); |
||||
|
return minioClient.getPresignedObjectUrl( |
||||
|
GetPresignedObjectUrlArgs.builder() |
||||
|
.method(Method.GET) |
||||
|
.bucket(bucketName) |
||||
|
.object(objectName) |
||||
|
.build()); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除:从MinIO服务器上的指定存储桶中删除一个文件 |
||||
|
* |
||||
|
* @param objectName 指定要删除的文件对象名称(包括路径和文件名) |
||||
|
* @throws Exception |
||||
|
*/ |
||||
|
public static void deleteFile(String objectName,String newBucket) throws Exception { |
||||
|
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
||||
|
|
||||
|
MinioClient minioClient = getMinioClient(); |
||||
|
minioClient.removeObject( |
||||
|
RemoveObjectArgs.builder().bucket(bucketName).object(objectName).build()); |
||||
|
} |
||||
|
|
||||
|
//查询文件信息
|
||||
|
public static HashMap<String,Object> getFileAsMultipart(String objectName, String newBucket) throws Exception { |
||||
|
String bucketName = StrUtil.isEmpty(newBucket) ? bucket : newBucket; |
||||
|
MinioClient client = getMinioClient(); |
||||
|
|
||||
|
// 获取对象
|
||||
|
InputStream is = client.getObject(GetObjectArgs.builder() |
||||
|
.bucket(bucketName) |
||||
|
.object(objectName) |
||||
|
.build()); |
||||
|
|
||||
|
// 获取文件元信息(如 contentType)
|
||||
|
StatObjectResponse stat = client.statObject(StatObjectArgs.builder() |
||||
|
.bucket(bucketName) |
||||
|
.object(objectName) |
||||
|
.build()); |
||||
|
|
||||
|
String contentType = stat.contentType(); |
||||
|
|
||||
|
// 将流读为 byte[] 以生成 MockMultipartFile
|
||||
|
byte[] bytes = IoUtil.readBytes(is); // Hutool 工具类
|
||||
|
HashMap<String, Object> map = new HashMap<>(); |
||||
|
map.put("objectName",objectName); |
||||
|
map.put("contentType",contentType); |
||||
|
map.put("bytes",bytes); |
||||
|
|
||||
|
return map; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
//文件复制
|
||||
|
public static void copyFile(String sourceObjectName, String targetObjectName, String sourceBucket, String targetBucket) throws Exception { |
||||
|
MinioClient client = getMinioClient(); |
||||
|
|
||||
|
// 使用服务器端复制,无需下载上传
|
||||
|
client.copyObject(CopyObjectArgs.builder() |
||||
|
.bucket(targetBucket) // 目标桶
|
||||
|
.object(targetObjectName) // 目标对象
|
||||
|
.source(CopySource.builder() |
||||
|
.bucket(sourceBucket) |
||||
|
.object(sourceObjectName) |
||||
|
.build()) |
||||
|
.build()); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
} |
Loading…
Reference in new issue