服务指令文件同步
This commit is contained in:
parent
ad522cd293
commit
6841a8f56f
|
@ -9,5 +9,11 @@
|
|||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>nu-admin-local-api</artifactId>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nursing-unit-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,20 @@
|
|||
package com.nu.modules.mediamanage;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.nu.dto.MediaManageMQDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IMediaManageApi {
|
||||
|
||||
/**
|
||||
* 根据ids查询数据
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> queryByIds(List<String> ids);
|
||||
|
||||
void saveOrUpdate(MediaManageMQDto m, boolean isSave);
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
package com.nu.modules.mediaasyncerrorlog.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import com.nu.modules.mediaasyncerrorlog.entity.MediaAsyncErrorLog;
|
||||
import com.nu.modules.mediaasyncerrorlog.service.IMediaAsyncErrorLogService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: 资源同步错误日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-22
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="资源同步错误日志")
|
||||
@RestController
|
||||
@RequestMapping("/mediaasyncerrorlog/mediaAsyncErrorLog")
|
||||
@Slf4j
|
||||
public class MediaAsyncErrorLogController extends JeecgController<MediaAsyncErrorLog, IMediaAsyncErrorLogService> {
|
||||
@Autowired
|
||||
private IMediaAsyncErrorLogService mediaAsyncErrorLogService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param mediaAsyncErrorLog
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "资源同步错误日志-分页列表查询")
|
||||
@ApiOperation(value="资源同步错误日志-分页列表查询", notes="资源同步错误日志-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MediaAsyncErrorLog>> queryPageList(MediaAsyncErrorLog mediaAsyncErrorLog,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MediaAsyncErrorLog> queryWrapper = QueryGenerator.initQueryWrapper(mediaAsyncErrorLog, req.getParameterMap());
|
||||
Page<MediaAsyncErrorLog> page = new Page<MediaAsyncErrorLog>(pageNo, pageSize);
|
||||
IPage<MediaAsyncErrorLog> pageList = mediaAsyncErrorLogService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param mediaAsyncErrorLog
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "资源同步错误日志-添加")
|
||||
@ApiOperation(value="资源同步错误日志-添加", notes="资源同步错误日志-添加")
|
||||
@RequiresPermissions("mediaasyncerrorlog:nu_media_async_error_log:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MediaAsyncErrorLog mediaAsyncErrorLog) {
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param mediaAsyncErrorLog
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "资源同步错误日志-编辑")
|
||||
@ApiOperation(value="资源同步错误日志-编辑", notes="资源同步错误日志-编辑")
|
||||
@RequiresPermissions("mediaasyncerrorlog:nu_media_async_error_log:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MediaAsyncErrorLog mediaAsyncErrorLog) {
|
||||
mediaAsyncErrorLogService.updateById(mediaAsyncErrorLog);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "资源同步错误日志-通过id删除")
|
||||
@ApiOperation(value="资源同步错误日志-通过id删除", notes="资源同步错误日志-通过id删除")
|
||||
@RequiresPermissions("mediaasyncerrorlog:nu_media_async_error_log:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
mediaAsyncErrorLogService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "资源同步错误日志-批量删除")
|
||||
@ApiOperation(value="资源同步错误日志-批量删除", notes="资源同步错误日志-批量删除")
|
||||
@RequiresPermissions("mediaasyncerrorlog:nu_media_async_error_log:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.mediaAsyncErrorLogService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "资源同步错误日志-通过id查询")
|
||||
@ApiOperation(value="资源同步错误日志-通过id查询", notes="资源同步错误日志-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MediaAsyncErrorLog> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = mediaAsyncErrorLogService.getById(id);
|
||||
if(mediaAsyncErrorLog==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(mediaAsyncErrorLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param mediaAsyncErrorLog
|
||||
*/
|
||||
@RequiresPermissions("mediaasyncerrorlog:nu_media_async_error_log:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MediaAsyncErrorLog mediaAsyncErrorLog) {
|
||||
return super.exportXls(request, mediaAsyncErrorLog, MediaAsyncErrorLog.class, "资源同步错误日志");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("mediaasyncerrorlog:nu_media_async_error_log:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, MediaAsyncErrorLog.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package com.nu.modules.mediaasyncerrorlog.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 资源同步错误日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-22
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_media_async_error_log")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_media_async_error_log对象", description="资源同步错误日志")
|
||||
public class MediaAsyncErrorLog implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**id*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
private java.lang.String id;
|
||||
/**nu_media_manage.id*/
|
||||
@Excel(name = "nu_media_manage.id", width = 15)
|
||||
@ApiModelProperty(value = "nu_media_manage.id")
|
||||
private java.lang.String mediaid;
|
||||
/**找到id就是对应的nu_media_manage.id*/
|
||||
@ApiModelProperty(value = "找到id就是对应的nu_media_manage.id")
|
||||
private java.lang.String msg;
|
||||
/**createTime*/
|
||||
@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "createTime")
|
||||
private java.util.Date createTime;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.nu.modules.mediaasyncerrorlog.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.nu.modules.mediaasyncerrorlog.entity.MediaAsyncErrorLog;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 资源同步错误日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-22
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface MediaAsyncErrorLogMapper extends BaseMapper<MediaAsyncErrorLog> {
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.mediaasyncerrorlog.mapper.MediaAsyncErrorLogMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.mediaasyncerrorlog.mapper.NuMediaAsyncErrorLogMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,14 @@
|
|||
package com.nu.modules.mediaasyncerrorlog.service;
|
||||
|
||||
import com.nu.modules.mediaasyncerrorlog.entity.MediaAsyncErrorLog;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 资源同步错误日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-22
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IMediaAsyncErrorLogService extends IService<MediaAsyncErrorLog> {
|
||||
|
||||
}
|
|
@ -0,0 +1,19 @@
|
|||
package com.nu.modules.mediaasyncerrorlog.service.impl;
|
||||
|
||||
import com.nu.modules.mediaasyncerrorlog.entity.MediaAsyncErrorLog;
|
||||
import com.nu.modules.mediaasyncerrorlog.mapper.MediaAsyncErrorLogMapper;
|
||||
import com.nu.modules.mediaasyncerrorlog.service.IMediaAsyncErrorLogService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 资源同步错误日志
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-22
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class MediaAsyncErrorLogServiceImpl extends ServiceImpl<MediaAsyncErrorLogMapper, MediaAsyncErrorLog> implements IMediaAsyncErrorLogService {
|
||||
|
||||
}
|
|
@ -0,0 +1,180 @@
|
|||
package com.nu.modules.mediamanage.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.system.query.QueryRuleEnum;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import com.nu.modules.mediamanage.entity.MediaManage;
|
||||
import com.nu.modules.mediamanage.service.IMediaManageService;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.ImportParams;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
|
||||
/**
|
||||
* @Description: 媒体资源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-15
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="媒体资源管理")
|
||||
@RestController
|
||||
@RequestMapping("/mediamanage/mediaManage")
|
||||
@Slf4j
|
||||
public class MediaManageController extends JeecgController<MediaManage, IMediaManageService> {
|
||||
@Autowired
|
||||
private IMediaManageService mediaManageService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param mediaManage
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "媒体资源管理-分页列表查询")
|
||||
@ApiOperation(value="媒体资源管理-分页列表查询", notes="媒体资源管理-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<MediaManage>> queryPageList(MediaManage mediaManage,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MediaManage> queryWrapper = QueryGenerator.initQueryWrapper(mediaManage, req.getParameterMap());
|
||||
Page<MediaManage> page = new Page<MediaManage>(pageNo, pageSize);
|
||||
IPage<MediaManage> pageList = mediaManageService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param mediaManage
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "媒体资源管理-添加")
|
||||
@ApiOperation(value="媒体资源管理-添加", notes="媒体资源管理-添加")
|
||||
@RequiresPermissions("mediamanage:nu_media_manage:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody MediaManage mediaManage) {
|
||||
mediaManageService.save(mediaManage);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param mediaManage
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "媒体资源管理-编辑")
|
||||
@ApiOperation(value="媒体资源管理-编辑", notes="媒体资源管理-编辑")
|
||||
@RequiresPermissions("mediamanage:nu_media_manage:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody MediaManage mediaManage) {
|
||||
mediaManageService.updateById(mediaManage);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "媒体资源管理-通过id删除")
|
||||
@ApiOperation(value="媒体资源管理-通过id删除", notes="媒体资源管理-通过id删除")
|
||||
@RequiresPermissions("mediamanage:nu_media_manage:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
mediaManageService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "媒体资源管理-批量删除")
|
||||
@ApiOperation(value="媒体资源管理-批量删除", notes="媒体资源管理-批量删除")
|
||||
@RequiresPermissions("mediamanage:nu_media_manage:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.mediaManageService.removeByIds(Arrays.asList(ids.split(",")));
|
||||
return Result.OK("批量删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "媒体资源管理-通过id查询")
|
||||
@ApiOperation(value="媒体资源管理-通过id查询", notes="媒体资源管理-通过id查询")
|
||||
@GetMapping(value = "/queryById")
|
||||
public Result<MediaManage> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
MediaManage mediaManage = mediaManageService.getById(id);
|
||||
if(mediaManage==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(mediaManage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param mediaManage
|
||||
*/
|
||||
@RequiresPermissions("mediamanage:nu_media_manage:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, MediaManage mediaManage) {
|
||||
return super.exportXls(request, mediaManage, MediaManage.class, "媒体资源管理");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("mediamanage:nu_media_manage:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, MediaManage.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,126 @@
|
|||
package com.nu.modules.mediamanage.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
import org.jeecg.common.constant.ProvinceCityArea;
|
||||
import org.jeecg.common.util.SpringContextUtils;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 媒体资源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-15
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_media_manage")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false, onlyExplicitlyIncluded = true)
|
||||
@ApiModel(value = "nu_media_manage对象", description = "媒体资源管理")
|
||||
public class MediaManage implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* id
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@ApiModelProperty(value = "id")
|
||||
@EqualsAndHashCode.Include//参与对象对比
|
||||
private java.lang.String id;
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Excel(name = "名称", width = 15)
|
||||
@ApiModelProperty(value = "名称")
|
||||
@EqualsAndHashCode.Include
|
||||
private java.lang.String name;
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
@ApiModelProperty(value = "备注")
|
||||
@EqualsAndHashCode.Include
|
||||
private java.lang.String descr;
|
||||
/**
|
||||
* 文件类型
|
||||
*/
|
||||
@Excel(name = "文件类型", width = 15)
|
||||
@ApiModelProperty(value = "文件类型")
|
||||
@Dict(dicCode = "file_type")
|
||||
@EqualsAndHashCode.Include
|
||||
private java.lang.String fileType;
|
||||
/**
|
||||
* 系统功能
|
||||
*/
|
||||
@Excel(name = "系统功能", width = 15)
|
||||
@ApiModelProperty(value = "系统功能")
|
||||
@Dict(dicCode = "sys_function")
|
||||
@EqualsAndHashCode.Include
|
||||
private java.lang.String sysFunc;
|
||||
/**
|
||||
* 文件路径
|
||||
*/
|
||||
@Excel(name = "文件路径", width = 15)
|
||||
@ApiModelProperty(value = "文件路径")
|
||||
@EqualsAndHashCode.Include
|
||||
private java.lang.String filePath;
|
||||
/**
|
||||
* 是否网络资源
|
||||
*/
|
||||
@Excel(name = "是否网络资源", width = 15)
|
||||
@ApiModelProperty(value = "是否网络资源")
|
||||
@Dict(dicCode = "iz_net_url")
|
||||
@EqualsAndHashCode.Include
|
||||
private java.lang.String izNetUrl;
|
||||
/**
|
||||
* 是否删除
|
||||
*/
|
||||
@Excel(name = "是否删除", width = 15)
|
||||
@ApiModelProperty(value = "是否删除")
|
||||
@TableLogic
|
||||
@EqualsAndHashCode.Include
|
||||
private java.lang.String delFlag;
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
@EqualsAndHashCode.Include
|
||||
private java.lang.String createBy;
|
||||
/**
|
||||
* 创建日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "创建日期")
|
||||
@EqualsAndHashCode.Include
|
||||
private java.util.Date createTime;
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
@EqualsAndHashCode.Include
|
||||
private java.lang.String updateBy;
|
||||
/**
|
||||
* 更新日期
|
||||
*/
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty(value = "更新日期")
|
||||
@EqualsAndHashCode.Include
|
||||
private java.util.Date updateTime;
|
||||
}
|
|
@ -0,0 +1,17 @@
|
|||
package com.nu.modules.mediamanage.mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import com.nu.modules.mediamanage.entity.MediaManage;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 媒体资源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-15
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface MediaManageMapper extends BaseMapper<MediaManage> {
|
||||
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.mediamanage.mapper.MediaManageMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,14 @@
|
|||
package com.nu.modules.mediamanage.service;
|
||||
|
||||
import com.nu.modules.mediamanage.entity.MediaManage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 媒体资源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-15
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IMediaManageService extends IService<MediaManage> {
|
||||
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.nu.modules.mediamanage.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.nu.dto.MediaManageMQDto;
|
||||
import com.nu.modules.mediamanage.IMediaManageApi;
|
||||
import com.nu.modules.mediamanage.entity.MediaManage;
|
||||
import com.nu.modules.mediamanage.mapper.MediaManageMapper;
|
||||
import com.nu.modules.mediamanage.service.IMediaManageService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 媒体资源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-15
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class MediaManageServiceImpl extends ServiceImpl<MediaManageMapper, MediaManage> implements IMediaManageService, IMediaManageApi {
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
@Override
|
||||
public List<JSONObject> queryByIds(List<String> ids) {
|
||||
QueryWrapper<MediaManage> qw = new QueryWrapper<>();
|
||||
qw.in("id", ids);
|
||||
List<MediaManage> mediaManages = baseMapper.selectList(qw);
|
||||
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
for (MediaManage media : mediaManages) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", media.getId());
|
||||
json.put("name", media.getName());
|
||||
json.put("descr", media.getDescr());
|
||||
json.put("sysFunc", media.getSysFunc());
|
||||
json.put("fileType", media.getFileType());
|
||||
json.put("filePath", media.getFilePath());
|
||||
json.put("izNetUrl", media.getIzNetUrl());
|
||||
json.put("delFlag", media.getDelFlag());
|
||||
json.put("createBy", media.getCreateBy());
|
||||
json.put("createTime", media.getCreateTime());
|
||||
json.put("updateBy", media.getUpdateBy());
|
||||
json.put("updateTime", media.getUpdateTime());
|
||||
result.add(json);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveOrUpdate(MediaManageMQDto m, boolean isSave) {
|
||||
MediaManage mediaManage = new MediaManage();
|
||||
BeanUtils.copyProperties(m, mediaManage);
|
||||
|
||||
if (isSave) {
|
||||
baseMapper.insert(mediaManage);
|
||||
} else {
|
||||
baseMapper.updateById(mediaManage);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,28 @@
|
|||
package com.nu.mq.mediamanage.exceptionhandler;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.amqp.AmqpRejectAndDontRequeueException;
|
||||
import org.springframework.amqp.core.Message;
|
||||
import org.springframework.amqp.rabbit.listener.api.RabbitListenerErrorHandler;
|
||||
import org.springframework.amqp.rabbit.support.ListenerExecutionFailedException;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Slf4j
|
||||
@Component("mediaManageMQErrorHandler")
|
||||
public class MediaManageMQExceptionHandler implements RabbitListenerErrorHandler {
|
||||
|
||||
@Override
|
||||
public Object handleError(Message message, org.springframework.messaging.Message<?> message1, ListenerExecutionFailedException e) {
|
||||
log.error("MQ消息处理失败 | 消息体: {} | 异常原因: {}", new String(message.getBody()), e.getCause().getMessage());
|
||||
|
||||
// 根据异常类型选择处理策略
|
||||
// if (isRetryable(e)) {
|
||||
// // 可重试异常:抛出异常触发重试
|
||||
// throw e;
|
||||
// } else {
|
||||
// 不可恢复异常:拒绝消息且不重新入队
|
||||
throw new AmqpRejectAndDontRequeueException("消息处理失败且禁止重试", e);
|
||||
// }
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,184 @@
|
|||
package com.nu.mq.mediamanage.listener;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nu.dto.MediaManageMQDto;
|
||||
import com.nu.dto.StatusMQDto;
|
||||
import com.nu.modules.async.entity.AsyncMain;
|
||||
import com.nu.modules.async.service.IAsyncMainService;
|
||||
import com.nu.modules.mediaasyncerrorlog.entity.MediaAsyncErrorLog;
|
||||
import com.nu.modules.mediaasyncerrorlog.service.IMediaAsyncErrorLogService;
|
||||
import com.nu.modules.mediamanage.IMediaManageApi;
|
||||
import com.nu.modules.mediamanage.entity.MediaManage;
|
||||
import com.nu.modules.sysconfig.entity.SysConfig;
|
||||
import com.nu.modules.sysconfig.service.ISysConfigService;
|
||||
import com.nu.utils.FileDownloader;
|
||||
import com.nu.utils.SafetyUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.springframework.amqp.core.ExchangeTypes;
|
||||
import org.springframework.amqp.rabbit.annotation.Exchange;
|
||||
import org.springframework.amqp.rabbit.annotation.Queue;
|
||||
import org.springframework.amqp.rabbit.annotation.QueueBinding;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.io.File;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class MediaManageMQListener {
|
||||
|
||||
@Value("${jeecg.path.upload}")
|
||||
private String upLoadPath;
|
||||
@Value("${jeecg.path.directivepath}")
|
||||
private String directiveUpLoadPath;
|
||||
|
||||
@Autowired
|
||||
private IMediaManageApi mediaManageApi;
|
||||
@Autowired
|
||||
private ISysConfigService sysConfigService;
|
||||
@Autowired
|
||||
private IMediaAsyncErrorLogService mediaAsyncErrorLogService;
|
||||
|
||||
@RabbitListener(bindings = @QueueBinding(value = @Queue(name = "mediamanage.async", durable = "true"), exchange = @Exchange(name = "hldy.mediamanage", type = ExchangeTypes.DIRECT), key = "mediamanage.async"), errorHandler = "mediaManageMQErrorHandler")
|
||||
public void handleMessage(List<Map<String, Object>> mediaMaps) {
|
||||
//转下对象,不然要改的代码太多
|
||||
List<MediaManageMQDto> list = mediaMaps.stream().map(this::convertToMediaManageMQDto).collect(Collectors.toList());
|
||||
|
||||
List<String> mediaIds = Lists.newArrayList();
|
||||
mediaMaps.stream().forEach(m -> {
|
||||
mediaIds.add((String) m.get("id"));
|
||||
});
|
||||
// 运维系统中的数据
|
||||
List<JSONObject> jsonObjects = mediaManageApi.queryByIds(mediaIds);
|
||||
Map<String, JSONObject> map = Maps.newHashMap();
|
||||
if (jsonObjects != null && !jsonObjects.isEmpty()) {
|
||||
jsonObjects.stream().forEach(j -> {
|
||||
map.put(j.getStr("id"), j);
|
||||
});
|
||||
}
|
||||
//map是运维系统媒体资源数据 m是试验田传过来的媒体资源数据
|
||||
list.stream().forEach(m -> {
|
||||
if (map.get(m.getId()) != null) {
|
||||
//处理同一条数据
|
||||
JSONObject enty = map.get(m.getId());
|
||||
MediaManage yewu = new MediaManage();//业务
|
||||
BeanUtils.copyProperties(m, yewu);
|
||||
MediaManage yunwei = new MediaManage();//运维
|
||||
yunwei.setId(enty.getStr("id"));
|
||||
yunwei.setName(enty.getStr("name"));
|
||||
yunwei.setDescr(enty.getStr("descr"));
|
||||
yunwei.setFileType(enty.getStr("fileType"));
|
||||
yunwei.setSysFunc(enty.getStr("sysFunc"));
|
||||
yunwei.setFilePath(enty.getStr("filePath"));
|
||||
yunwei.setIzNetUrl(enty.getStr("izNetUrl"));
|
||||
yunwei.setDelFlag(enty.getStr("delFlag"));
|
||||
yunwei.setCreateBy(enty.getStr("createBy"));
|
||||
yunwei.setCreateTime(enty.getDate("createTime"));
|
||||
yunwei.setUpdateBy(enty.getStr("updateBy"));
|
||||
yunwei.setUpdateTime(enty.getDate("updateTime"));
|
||||
//存储数据
|
||||
if (!yewu.equals(yunwei)) {
|
||||
mediaManageApi.saveOrUpdate(m, false);
|
||||
}
|
||||
//存储文件
|
||||
if (!yunwei.getFilePath().equals(m.getFilePath())) {
|
||||
handleSaveFile(m);
|
||||
}
|
||||
} else {
|
||||
//新增数据
|
||||
mediaManageApi.saveOrUpdate(m, true);
|
||||
handleSaveFile(m);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
private MediaManageMQDto convertToMediaManageMQDto(Map<String, Object> map) {
|
||||
MediaManageMQDto dto = new MediaManageMQDto();
|
||||
dto.setId((String) map.get("id"));
|
||||
dto.setName((String) map.get("name"));
|
||||
dto.setDescr((String) map.get("descr"));
|
||||
dto.setFileType((String) map.get("fileType"));
|
||||
dto.setSysFunc((String) map.get("sysFunc"));
|
||||
dto.setFilePath((String) map.get("filePath"));
|
||||
dto.setIzNetUrl((String) map.get("izNetUrl"));
|
||||
dto.setDelFlag((String) map.get("delFlag"));
|
||||
dto.setCreateBy((String) map.get("createBy"));
|
||||
dto.setUpdateBy((String) map.get("updateBy"));
|
||||
dto.setNetFilePath((String) map.get("netFilePath"));
|
||||
return dto;
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理文件存储
|
||||
*
|
||||
* @param media
|
||||
*/
|
||||
private void handleSaveFile(MediaManageMQDto media) {
|
||||
try {
|
||||
LambdaQueryWrapper<SysConfig> qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(SysConfig::getDelFlag, "0");
|
||||
qw.eq(SysConfig::getConfigKey, "directive_source_url");
|
||||
SysConfig urlObj = sysConfigService.getOne(qw);
|
||||
//试验田协议+域名(/ip+端口)
|
||||
String baseUrl = urlObj.getConfigValue();
|
||||
if (baseUrl.endsWith("/")) {
|
||||
baseUrl = baseUrl.substring(0, baseUrl.length() - 1); // 移除末尾斜杠
|
||||
}
|
||||
//通过系统上传的文件
|
||||
if ("local".equals(media.getIzNetUrl())) {
|
||||
qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(SysConfig::getDelFlag, "0");
|
||||
qw.eq(SysConfig::getConfigKey, "directive_source_name");
|
||||
SysConfig nameObj = sysConfigService.getOne(qw);
|
||||
//获取到对应试验田的服务名 用于通过接口获取对应媒体资源文件
|
||||
String servName = nameObj.getConfigValue();
|
||||
if (servName.startsWith("/")) {
|
||||
servName = servName.substring(1);
|
||||
}
|
||||
//协议域名服务名
|
||||
String url = baseUrl + "/" + servName + "/sys/common/open/static/" + media.getFilePath() + "?name=" + SafetyUtil.getSecureKey();
|
||||
if (upLoadPath.endsWith("/") || upLoadPath.endsWith("\\")) {
|
||||
upLoadPath = upLoadPath.substring(0, upLoadPath.length() - 1);
|
||||
}
|
||||
String filePath = media.getFilePath();
|
||||
if (filePath.startsWith("/") || filePath.startsWith("\\")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
FileDownloader.downloadFile(url, upLoadPath + File.separator + filePath.substring(0, filePath.lastIndexOf("/")), media.getFilePath().substring(media.getFilePath().lastIndexOf("/") + 1));
|
||||
}
|
||||
//存储到媒体资源公共目录中的媒体资源 通过nginx可以访问的静态资源
|
||||
if ("net".equals(media.getIzNetUrl())) {
|
||||
String filePath = media.getFilePath();
|
||||
if (filePath.startsWith("/")) {
|
||||
filePath = filePath.substring(1);
|
||||
}
|
||||
String url = baseUrl + "/" + filePath;
|
||||
if (directiveUpLoadPath.endsWith("/") || directiveUpLoadPath.endsWith("\\")) {
|
||||
directiveUpLoadPath = directiveUpLoadPath.substring(0, directiveUpLoadPath.length() - 1);
|
||||
}
|
||||
FileDownloader.downloadFile(url, directiveUpLoadPath, media.getFilePath().substring(media.getFilePath().lastIndexOf("/") + 1));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
MediaAsyncErrorLog mediaAsyncErrorLog = new MediaAsyncErrorLog();
|
||||
mediaAsyncErrorLog.setMediaid(media.getId());
|
||||
mediaAsyncErrorLogService.save(mediaAsyncErrorLog);
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -17,5 +17,9 @@
|
|||
<artifactId>nursing-unit-base-core</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nursing-unit-common</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
package com.nu.modules.documentrecognition;
|
||||
|
||||
import com.nu.modules.aliyun.documentrecognition.DocumentRecognitionUtils;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/api/ocr")
|
||||
public class DocumentRecognitionApi {
|
||||
|
||||
@Value("${aliyun.ocr.accessKeyId}")
|
||||
private String accessKeyId;
|
||||
|
||||
@Value("${aliyun.ocr.accessKeySecret}")
|
||||
private String accessKeySecret;
|
||||
|
||||
/**
|
||||
* 身份证识别
|
||||
* @param file 图片文件
|
||||
*/
|
||||
@PostMapping("/idCard")
|
||||
public Result<String> recognizeIdCard(
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
DocumentRecognitionUtils utils = new DocumentRecognitionUtils(accessKeyId, accessKeySecret);
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
String result = utils.recognizeIdCard(inputStream);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("身份证识别失败: " + e.getMessage());
|
||||
} finally {
|
||||
utils.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 户口本首页识别
|
||||
* @param file 图片文件
|
||||
*/
|
||||
@PostMapping("/household")
|
||||
public Result<String> recognizeHousehold(
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
DocumentRecognitionUtils utils = new DocumentRecognitionUtils(accessKeyId, accessKeySecret);
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
String result = utils.recognizeHouseholdRegister(inputStream);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("户口本识别失败: " + e.getMessage());
|
||||
} finally {
|
||||
utils.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 银行卡识别
|
||||
* @param file 图片文件
|
||||
*/
|
||||
@PostMapping("/bankCard")
|
||||
public Result<String> recognizeBankCard(
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
DocumentRecognitionUtils utils = new DocumentRecognitionUtils(accessKeyId, accessKeySecret);
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
String result = utils.recognizeBankCard(inputStream);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("银行卡识别失败: " + e.getMessage());
|
||||
} finally {
|
||||
utils.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 医保卡识别
|
||||
* @param file 图片文件
|
||||
*/
|
||||
@PostMapping("/medicalCard")
|
||||
public Result<String> recognizeMedicalCard(
|
||||
@RequestParam("file") MultipartFile file) {
|
||||
|
||||
DocumentRecognitionUtils utils = new DocumentRecognitionUtils(accessKeyId, accessKeySecret);
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
String result = utils.recognizeMedicalCard(inputStream);
|
||||
return Result.ok(result);
|
||||
} catch (Exception e) {
|
||||
return Result.error("医保卡识别失败: " + e.getMessage());
|
||||
} finally {
|
||||
utils.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -115,6 +115,7 @@ public class ShiroConfig {
|
|||
filterChainDefinitionMap.put("/sys/checkAuth", "anon"); //授权接口排除
|
||||
filterChainDefinitionMap.put("/api/pad/versionUpdate", "anon");//pad端版本检测接口
|
||||
filterChainDefinitionMap.put("/nuIpadApi/versionManage/versionUpdate", "anon");//pad端版本检测接口
|
||||
filterChainDefinitionMap.put("/api/ocr/**", "anon");//阿里云证件识别
|
||||
|
||||
//update-begin--Author:scott Date:20221116 for:排除静态资源后缀
|
||||
filterChainDefinitionMap.put("/", "anon");
|
||||
|
|
|
@ -22,6 +22,18 @@
|
|||
<artifactId>nu-system-local-api</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!-- 阿里云证件照识别 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>alibabacloud-ocr_api20210707</artifactId>
|
||||
<version>3.0.4</version>
|
||||
</dependency>
|
||||
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>33.4.8-jre</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package com.nu.dto;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @Description: 媒体资源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-15
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
public class MediaManageMQDto implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**id*/
|
||||
private String id;
|
||||
/**名称*/
|
||||
private String name;
|
||||
/**备注*/
|
||||
private String descr;
|
||||
/**文件类型*/
|
||||
private String fileType;
|
||||
/**系统功能*/
|
||||
private String sysFunc;
|
||||
/**文件路径*/
|
||||
private String filePath;
|
||||
/**是否网络资源*/
|
||||
private String izNetUrl;
|
||||
/**是否删除*/
|
||||
private String delFlag;
|
||||
/**创建人*/
|
||||
private String createBy;
|
||||
/**创建日期*/
|
||||
private Date createTime;
|
||||
/**更新人*/
|
||||
private String updateBy;
|
||||
/**更新日期*/
|
||||
private Date updateTime;
|
||||
|
||||
private String netFilePath;
|
||||
}
|
|
@ -0,0 +1,102 @@
|
|||
package com.nu.modules.aliyun.documentrecognition;
|
||||
|
||||
import com.aliyun.auth.credentials.Credential;
|
||||
import com.aliyun.auth.credentials.provider.StaticCredentialProvider;
|
||||
import com.aliyun.sdk.service.ocr_api20210707.*;
|
||||
import com.aliyun.sdk.service.ocr_api20210707.models.*;
|
||||
import com.google.gson.Gson;
|
||||
import darabonba.core.client.ClientOverrideConfiguration;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
public class DocumentRecognitionUtils {
|
||||
|
||||
private final AsyncClient client;
|
||||
|
||||
public DocumentRecognitionUtils(String accessKeyId, String accessKeySecret) {
|
||||
// 配置认证信息
|
||||
StaticCredentialProvider provider = StaticCredentialProvider.create(
|
||||
Credential.builder()
|
||||
.accessKeyId(accessKeyId)
|
||||
.accessKeySecret(accessKeySecret)
|
||||
.build());
|
||||
|
||||
// 配置客户端
|
||||
this.client = AsyncClient.builder()
|
||||
.region("cn-hangzhou")
|
||||
.credentialsProvider(provider)
|
||||
.overrideConfiguration(
|
||||
ClientOverrideConfiguration.create()
|
||||
.setEndpointOverride("ocr-api.cn-hangzhou.aliyuncs.com")
|
||||
)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭客户端连接
|
||||
*/
|
||||
public void close() {
|
||||
this.client.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别身份证
|
||||
* @param inputStream 图片输入流
|
||||
* @return 识别结果JSON字符串
|
||||
*/
|
||||
public String recognizeIdCard(InputStream inputStream) throws Exception {
|
||||
RecognizeIdcardRequest request = RecognizeIdcardRequest.builder()
|
||||
.body(inputStream)
|
||||
.build();
|
||||
|
||||
CompletableFuture<RecognizeIdcardResponse> future = client.recognizeIdcard(request);
|
||||
RecognizeIdcardResponse response = future.get();
|
||||
return new Gson().toJson(response.getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别户口本首页
|
||||
* @param inputStream 图片输入流
|
||||
* @return 识别结果JSON字符串
|
||||
*/
|
||||
public String recognizeHouseholdRegister(InputStream inputStream) throws Exception {
|
||||
RecognizeHouseholdRequest request = RecognizeHouseholdRequest.builder()
|
||||
.body(inputStream)
|
||||
.build();
|
||||
|
||||
CompletableFuture<RecognizeHouseholdResponse> future = client.recognizeHousehold(request);
|
||||
RecognizeHouseholdResponse response = future.get();
|
||||
return new Gson().toJson(response.getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别银行卡
|
||||
* @param inputStream 图片输入流
|
||||
* @return 识别结果JSON字符串
|
||||
*/
|
||||
public String recognizeBankCard(InputStream inputStream) throws Exception {
|
||||
RecognizeBankCardRequest request = RecognizeBankCardRequest.builder()
|
||||
.body(inputStream)
|
||||
.build();
|
||||
|
||||
CompletableFuture<RecognizeBankCardResponse> future = client.recognizeBankCard(request);
|
||||
RecognizeBankCardResponse response = future.get();
|
||||
return new Gson().toJson(response.getBody());
|
||||
}
|
||||
|
||||
/**
|
||||
* 识别医保卡
|
||||
* @param inputStream 图片输入流
|
||||
* @return 识别结果JSON字符串
|
||||
*/
|
||||
public String recognizeMedicalCard(InputStream inputStream) throws Exception {
|
||||
RecognizeSocialSecurityCardVersionIIRequest request = RecognizeSocialSecurityCardVersionIIRequest.builder()
|
||||
.body(inputStream)
|
||||
.build();
|
||||
|
||||
CompletableFuture<RecognizeSocialSecurityCardVersionIIResponse> future = client.recognizeSocialSecurityCardVersionII(request);
|
||||
RecognizeSocialSecurityCardVersionIIResponse response = future.get();
|
||||
return new Gson().toJson(response.getBody());
|
||||
}
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
package com.nu.utils;
|
||||
|
||||
import com.google.common.util.concurrent.RateLimiter;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
public class FileDownloader {
|
||||
|
||||
/**
|
||||
* 下载网络资源到本地目录
|
||||
*
|
||||
* @param fileUrl 完整的文件URL(自动处理路径中的斜杠)
|
||||
* @param saveDir 本地保存目录(如:/data/files)
|
||||
* @param fileName 保存的文件名(如:image.jpg)
|
||||
* @return 保存后的完整路径
|
||||
* @throws Exception
|
||||
*/
|
||||
public static String downloadFile(String fileUrl, String saveDir, String fileName) throws Exception {
|
||||
// 标准化URL路径
|
||||
fileUrl = normalizeUrl(fileUrl);
|
||||
|
||||
// 创建保存目录
|
||||
File dir = new File(saveDir);
|
||||
if (!dir.exists()) {
|
||||
dir.mkdirs();
|
||||
}
|
||||
|
||||
// 构建完整保存路径
|
||||
String savePath = Paths.get(saveDir, fileName).toString();
|
||||
File outputFile = new File(savePath);
|
||||
|
||||
// 如果文件已存在,直接返回路径
|
||||
if (outputFile.exists()) {
|
||||
return savePath;
|
||||
}
|
||||
|
||||
// 创建RateLimiter 限制下载速度为100k/s
|
||||
RateLimiter rateLimiter = RateLimiter.create(100*1024);
|
||||
|
||||
// 打开URL连接
|
||||
URL url = new URL(fileUrl);
|
||||
InputStream in = url.openStream();
|
||||
|
||||
try (BufferedInputStream bis = new BufferedInputStream(in);
|
||||
FileOutputStream fos = new FileOutputStream(outputFile);
|
||||
BufferedOutputStream bos = new BufferedOutputStream(fos)) {
|
||||
|
||||
byte[] buffer = new byte[8192]; // 8KB缓冲区
|
||||
int bytesRead;
|
||||
|
||||
while ((bytesRead = bis.read(buffer)) != -1) {
|
||||
// 获取所需数量的许可
|
||||
rateLimiter.acquire(bytesRead);
|
||||
|
||||
// 写入文件
|
||||
bos.write(buffer, 0, bytesRead);
|
||||
}
|
||||
}
|
||||
|
||||
return savePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* 标准化URL路径(处理开头/结尾的斜杠)
|
||||
*
|
||||
* @param url
|
||||
* @return
|
||||
*/
|
||||
private static String normalizeUrl(String url) {
|
||||
if (url == null || url.trim().isEmpty()) {
|
||||
return url;
|
||||
}
|
||||
|
||||
String normalized = url.replaceFirst("^(https?:)/", "$1//");
|
||||
|
||||
normalized = normalized.replaceAll("(?<!:)/{2,}", "/");
|
||||
|
||||
return normalized;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,120 @@
|
|||
package com.nu.utils;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
@Component
|
||||
public class SafetyUtil {
|
||||
private static String downloadkey;
|
||||
|
||||
@Value("${downloadkey}")
|
||||
public void setDownloadkey(String key) {
|
||||
downloadkey = key;
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证 secureKey
|
||||
* 是否合法
|
||||
*
|
||||
* @param secureKey 客户端传入的密钥(MD5 值)
|
||||
* @return true=验证通过,false=验证失败
|
||||
*/
|
||||
|
||||
public static boolean validateSecureKey(String secureKey) {
|
||||
if (secureKey == null || downloadkey == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 1. 获取当前日期(yyyyMMdd)
|
||||
String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
|
||||
// 2. 复杂混拼(固定规则)
|
||||
String mixedKey = complexMix(downloadkey, currentDate);
|
||||
|
||||
// 3. 计算 MD5
|
||||
String md5Hash = calculateMD5(mixedKey);
|
||||
|
||||
// 4. 比较 secureKey 是否匹配(忽略大小写)
|
||||
return secureKey.equalsIgnoreCase(md5Hash);
|
||||
}
|
||||
|
||||
/**
|
||||
* 混拼规则:
|
||||
* 1.
|
||||
* 交替插入 downloadkey
|
||||
* 和 date
|
||||
* 的字符
|
||||
* 2.
|
||||
* 对 date
|
||||
* 进行倒序
|
||||
* 3.每 3个字符插入一个固定干扰符 '#'
|
||||
*/
|
||||
|
||||
private static String complexMix(String key, String date) {
|
||||
StringBuilder mixed = new StringBuilder();
|
||||
|
||||
// 1. 倒序 date
|
||||
String reversedDate = new StringBuilder(date).reverse().toString();
|
||||
|
||||
// 2. 交替插入 key 和 reversedDate
|
||||
int maxLen = Math.max(key.length(), reversedDate.length());
|
||||
for (int i = 0; i < maxLen; i++) {
|
||||
if (i < key.length()) {
|
||||
mixed.append(key.charAt(i));
|
||||
}
|
||||
if (i < reversedDate.length()) {
|
||||
mixed.append(reversedDate.charAt(i));
|
||||
}
|
||||
|
||||
// 3. 每 3 个字符插入 '#'
|
||||
if (i % 3 == 2) {
|
||||
mixed.append('#');
|
||||
}
|
||||
}
|
||||
|
||||
return mixed.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算字符串的 MD5(32位小写)
|
||||
*/
|
||||
private static String calculateMD5(String input) {
|
||||
try {
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
byte[] hashBytes = md.digest(input.getBytes());
|
||||
|
||||
StringBuilder hexString = new StringBuilder();
|
||||
for (byte b : hashBytes) {
|
||||
String hex = Integer.toHexString(0xff & b);
|
||||
if (hex.length() == 1) {
|
||||
hexString.append('0');
|
||||
}
|
||||
hexString.append(hex);
|
||||
}
|
||||
return hexString.toString();
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException("MD5 algorithm not found", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getSecureKey() {
|
||||
if (downloadkey == null) {
|
||||
return "aaa";
|
||||
}
|
||||
|
||||
// 1. 获取当前日期(yyyyMMdd)
|
||||
String currentDate = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
|
||||
// 2. 复杂混拼(固定规则)
|
||||
String mixedKey = complexMix(downloadkey, currentDate);
|
||||
|
||||
// 3. 计算 MD5 并返回
|
||||
return calculateMD5(mixedKey);
|
||||
}
|
||||
}
|
|
@ -26,7 +26,7 @@ public class DictMQListener {
|
|||
bindings = @QueueBinding(
|
||||
value = @Queue(name = "sysdict.async.result", durable = "true"),
|
||||
exchange = @Exchange(name = "hldy.sysdict", type = ExchangeTypes.DIRECT),
|
||||
key = "sysconfig.async.result"
|
||||
key = "sysdict.async.result"
|
||||
),
|
||||
errorHandler = "dictMQErrorHandler"
|
||||
)
|
||||
|
|
|
@ -248,6 +248,8 @@ jeecg:
|
|||
pc: http://localhost:3100
|
||||
app: http://localhost:8051
|
||||
path:
|
||||
#服务指令上传目录
|
||||
directivepath: /opt/upFiles/directive
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/upFiles
|
||||
#webapp文件路径
|
||||
|
@ -361,3 +363,10 @@ justauth:
|
|||
type: default
|
||||
prefix: 'demo::'
|
||||
timeout: 1h
|
||||
#zmy
|
||||
aliyun:
|
||||
ocr:
|
||||
accessKeyId: LTAI5tMoCTt4sb9VQrcnZFsb
|
||||
accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
|
||||
#文件传输秘钥
|
||||
downloadkey: hP2K9Z!WLuj"M#8,
|
||||
|
|
|
@ -247,6 +247,8 @@ jeecg:
|
|||
pc: http://localhost:3100
|
||||
app: http://localhost:8051
|
||||
path:
|
||||
#服务指令上传目录
|
||||
directivepath: /opt/upFiles/directive
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/nu/upFiles
|
||||
#webapp文件路径
|
||||
|
@ -360,3 +362,10 @@ justauth:
|
|||
type: default
|
||||
prefix: 'demo::'
|
||||
timeout: 1h
|
||||
#zmy
|
||||
aliyun:
|
||||
ocr:
|
||||
accessKeyId: LTAI5tMoCTt4sb9VQrcnZFsb
|
||||
accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
|
||||
#文件传输秘钥
|
||||
downloadkey: hP2K9Z!WLuj"M#8,
|
||||
|
|
Loading…
Reference in New Issue