1、服务指令文件同步
This commit is contained in:
parent
b41f9a3648
commit
96e15870ef
|
@ -0,0 +1,44 @@
|
|||
package com.nu.modules.mediamanage.entity;
|
||||
|
||||
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 MediaManageDto 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,35 @@
|
|||
package com.nu.modules.mediamanage.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.nu.modules.mediamanage.entity.MediaManageDto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public interface IMediaManageApi {
|
||||
|
||||
/**
|
||||
* 根据ids查询数据
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> queryByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据ids查询数据
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
List<JSONObject> queryByIdsHandlePath(List<String> ids);
|
||||
|
||||
/**
|
||||
* 新增数据:将新上传的资源存储到媒体资源中
|
||||
* @param filePath 文件相对路径
|
||||
* @return
|
||||
*/
|
||||
String saveByPath(String filePath, Map<String,String> params);
|
||||
|
||||
List<JSONObject> selectByDirectiveIds(String dataSourceCode, List<String> idList);
|
||||
|
||||
void saveOrUpdate(MediaManageDto m, boolean isSave);
|
||||
}
|
|
@ -4,4 +4,6 @@ import com.alibaba.fastjson.JSONObject;
|
|||
|
||||
public interface ISysConfigApi {
|
||||
JSONObject getAll();
|
||||
|
||||
JSONObject getByKey(String key);
|
||||
}
|
||||
|
|
|
@ -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,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,188 @@
|
|||
package com.nu.modules.mediamanage.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
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.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
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;
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @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) {
|
||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
String url = deptInfo.getString("url");
|
||||
QueryWrapper<MediaManage> queryWrapper = QueryGenerator.initQueryWrapper(mediaManage, req.getParameterMap());
|
||||
Page<MediaManage> page = new Page<MediaManage>(pageNo, pageSize);
|
||||
IPage<MediaManage> pageList = mediaManageService.page(page, queryWrapper);
|
||||
List<MediaManage> records = pageList.getRecords();
|
||||
records.stream().forEach(m -> {
|
||||
if("net".equals(m.getIzNetUrl())){
|
||||
m.setNetFilePath(url+m.getFilePath());
|
||||
}
|
||||
});
|
||||
pageList.setRecords(records);
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取协议、域名
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/getUrl", method = RequestMethod.GET)
|
||||
public Result<?> getUrl() {
|
||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
return Result.OK(deptInfo);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
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.*;
|
||||
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)
|
||||
@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")
|
||||
private java.lang.String id;
|
||||
/**名称*/
|
||||
@Excel(name = "名称", width = 15)
|
||||
@ApiModelProperty(value = "名称")
|
||||
private java.lang.String name;
|
||||
/**备注*/
|
||||
@Excel(name = "备注", width = 15)
|
||||
@ApiModelProperty(value = "备注")
|
||||
private java.lang.String descr;
|
||||
/**文件类型*/
|
||||
@Excel(name = "文件类型", width = 15)
|
||||
@ApiModelProperty(value = "文件类型")
|
||||
@Dict(dicCode = "file_type")
|
||||
private java.lang.String fileType;
|
||||
/**系统功能*/
|
||||
@Excel(name = "系统功能", width = 15)
|
||||
@ApiModelProperty(value = "系统功能")
|
||||
@Dict(dicCode = "sys_function")
|
||||
private java.lang.String sysFunc;
|
||||
/**文件路径*/
|
||||
@Excel(name = "文件路径", width = 15)
|
||||
@ApiModelProperty(value = "文件路径")
|
||||
private java.lang.String filePath;
|
||||
/**是否网络资源*/
|
||||
@Excel(name = "是否网络资源", width = 15)
|
||||
@ApiModelProperty(value = "是否网络资源")
|
||||
@Dict(dicCode = "iz_net_url")
|
||||
private java.lang.String izNetUrl;
|
||||
/**是否删除*/
|
||||
@Excel(name = "是否删除", width = 15)
|
||||
@ApiModelProperty(value = "是否删除")
|
||||
@TableLogic
|
||||
private java.lang.String delFlag;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
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 = "创建日期")
|
||||
private java.util.Date createTime;
|
||||
/**更新人*/
|
||||
@ApiModelProperty(value = "更新人")
|
||||
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 = "更新日期")
|
||||
private java.util.Date updateTime;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String netFilePath;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.nu.modules.mediamanage.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.nu.modules.mediamanage.entity.MediaManage;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 媒体资源管理
|
||||
* @Author: jeecg-boot
|
||||
* @Date: 2025-05-15
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface MediaManageMapper extends BaseMapper<MediaManage> {
|
||||
|
||||
List<MediaManage> selectByDirectiveIds(@Param("ids") List<String> idList);
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?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">
|
||||
|
||||
<select id="selectByDirectiveIds" resultType="com.nu.modules.mediamanage.entity.MediaManage">
|
||||
SELECT
|
||||
id,
|
||||
name,
|
||||
descr,
|
||||
file_type,
|
||||
sys_func,
|
||||
file_path,
|
||||
del_flag,
|
||||
create_by,
|
||||
create_time,
|
||||
update_by,
|
||||
update_time,
|
||||
iz_net_url
|
||||
FROM nu_media_manage
|
||||
<where>
|
||||
<if test="ids!=null and ids.size()>0">
|
||||
id IN (
|
||||
SELECT preview_file FROM nu_config_service_directive WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
UNION
|
||||
SELECT immediate_file FROM nu_config_service_directive WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
UNION
|
||||
SELECT mp3_file FROM nu_config_service_directive WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
UNION
|
||||
SELECT mp4_file FROM nu_config_service_directive WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
)
|
||||
</select>
|
||||
</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,178 @@
|
|||
package com.nu.modules.mediamanage.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.modules.mediamanage.entity.MediaManage;
|
||||
import com.nu.modules.mediamanage.entity.MediaManageDto;
|
||||
import com.nu.modules.mediamanage.mapper.MediaManageMapper;
|
||||
import com.nu.modules.mediamanage.service.IMediaManageApi;
|
||||
import com.nu.modules.mediamanage.service.IMediaManageService;
|
||||
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 org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @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) {
|
||||
if(CollectionUtils.isEmpty(ids)){
|
||||
return List.of();
|
||||
}
|
||||
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 List<JSONObject> queryByIdsHandlePath(List<String> ids) {
|
||||
com.alibaba.fastjson.JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
|
||||
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("fileType", media.getFileType());
|
||||
if ("net".equals(media.getIzNetUrl())) {
|
||||
json.put("filePath", deptInfo.getString("url") + media.getFilePath());
|
||||
} else {
|
||||
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 String saveByPath(String filePath, Map<String, String> params) {
|
||||
MediaManage mediaManage = new MediaManage();
|
||||
mediaManage.setName(params.get("fileName") == null ? null : params.get("fileName"));
|
||||
mediaManage.setDescr(params.get("descr") == null ? null : params.get("descr"));
|
||||
mediaManage.setSysFunc(params.get("sysFunc") == null ? null : params.get("sysFunc"));
|
||||
mediaManage.setFilePath(filePath);
|
||||
mediaManage.setFileType(getFileTypeByPath(filePath));
|
||||
baseMapper.insert(mediaManage);
|
||||
return mediaManage.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@DS("#dataSourceCode")
|
||||
public List<JSONObject> selectByDirectiveIds(String dataSourceCode, List<String> idList) {
|
||||
List<MediaManage> list = baseMapper.selectByDirectiveIds(idList);
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
List<JSONObject> result = new ArrayList<>();
|
||||
for (MediaManage item : list) {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("id", item.getId());
|
||||
json.put("name", item.getName());
|
||||
json.put("descr", item.getDescr());
|
||||
json.put("fileType", item.getFileType());
|
||||
json.put("sysFunc", item.getSysFunc());
|
||||
json.put("filePath", item.getFilePath());
|
||||
json.put("delFlag", item.getDelFlag());
|
||||
json.put("createBy", item.getCreateBy());
|
||||
json.put("createTime", item.getCreateTime());
|
||||
json.put("updateBy", item.getUpdateBy());
|
||||
json.put("updateTime", item.getUpdateTime());
|
||||
json.put("izNetUrl", item.getIzNetUrl());
|
||||
result.add(json);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private String getFileTypeByPath(String filePath) {
|
||||
// 获取文件后缀名(转为小写)
|
||||
String extension = "";
|
||||
int lastDotIndex = filePath.lastIndexOf('.');
|
||||
if (lastDotIndex > 0) {
|
||||
extension = filePath.substring(lastDotIndex + 1).toLowerCase();
|
||||
}
|
||||
|
||||
// 图片类型
|
||||
if (extension.matches("jpg|jpeg|png|gif|bmp|webp|svg")) {
|
||||
return "image";
|
||||
}
|
||||
// 视频类型
|
||||
else if (extension.matches("mp4|avi|mov|wmv|flv|mkv|webm")) {
|
||||
return "video";
|
||||
}
|
||||
// 音频类型
|
||||
else if (extension.matches("mp3|wav|ogg|aac|flac|m4a")) {
|
||||
return "audio";
|
||||
}
|
||||
// 文档类型
|
||||
else if (extension.matches("pdf|doc|docx|xls|xlsx|ppt|pptx|txt")) {
|
||||
return "document";
|
||||
}
|
||||
// 其他类型
|
||||
else {
|
||||
return "other";
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveOrUpdate(MediaManageDto m, boolean isSave) {
|
||||
MediaManage mediaManage = new MediaManage();
|
||||
BeanUtils.copyProperties(m, mediaManage);
|
||||
if (isSave) {
|
||||
baseMapper.insert(mediaManage);
|
||||
} else {
|
||||
baseMapper.updateById(mediaManage);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +0,0 @@
|
|||
package com.nu.modules.sysconfig.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.nu.modules.sysconfig.ISysConfigApi;
|
||||
|
||||
public class SysConfigApiServiceImpl implements ISysConfigApi {
|
||||
@Override
|
||||
public JSONObject getAll() {
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,11 +1,18 @@
|
|||
package com.nu.modules.sysconfig.service.impl;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nu.modules.sysconfig.ISysConfigApi;
|
||||
import com.nu.modules.sysconfig.entity.SysConfig;
|
||||
import com.nu.modules.sysconfig.mapper.SysConfigMapper;
|
||||
import com.nu.modules.sysconfig.service.ISysConfigService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 系统参数配置
|
||||
|
@ -14,10 +21,64 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService {
|
||||
public class SysConfigServiceImpl extends ServiceImpl<SysConfigMapper, SysConfig> implements ISysConfigService, ISysConfigApi {
|
||||
|
||||
@Override
|
||||
public int deletePhysicsById(String id) {
|
||||
return baseMapper.deletePhysicsById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getAll() {
|
||||
LambdaQueryWrapper<SysConfig> qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(SysConfig::getDelFlag, "0");
|
||||
List<SysConfig> list = baseMapper.selectList(qw);
|
||||
|
||||
JSONObject result = new JSONObject();
|
||||
if (list != null && !list.isEmpty()) {
|
||||
// 方式1:将配置项放入JSON数组
|
||||
JSONArray configArray = new JSONArray();
|
||||
list.forEach(c -> {
|
||||
JSONObject configJson = new JSONObject();
|
||||
configJson.put("id", c.getId());
|
||||
configJson.put("name", c.getName());
|
||||
configJson.put("configKey", c.getConfigKey());
|
||||
configJson.put("configValue", c.getConfigValue());
|
||||
configJson.put("descr", c.getDescr());
|
||||
configJson.put("izEnabled", c.getIzEnabled());
|
||||
configJson.put("createBy", c.getCreateBy());
|
||||
configJson.put("createTime", c.getCreateTime());
|
||||
configJson.put("updateBy", c.getUpdateBy());
|
||||
configJson.put("updateTime", c.getUpdateTime());
|
||||
configArray.add(configJson);
|
||||
});
|
||||
result.put("configs", configArray);
|
||||
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject getByKey(String key) {
|
||||
LambdaQueryWrapper<SysConfig> qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(SysConfig::getDelFlag, "0");
|
||||
qw.eq(SysConfig::getConfigKey,key);
|
||||
SysConfig sysConfig = baseMapper.selectOne(qw);
|
||||
JSONObject result = new JSONObject();
|
||||
if(sysConfig!=null){
|
||||
result.put("id", sysConfig.getId());
|
||||
result.put("name", sysConfig.getName());
|
||||
result.put("configKey", sysConfig.getConfigKey());
|
||||
result.put("configValue", sysConfig.getConfigValue());
|
||||
result.put("descr", sysConfig.getDescr());
|
||||
result.put("izEnabled", sysConfig.getIzEnabled());
|
||||
result.put("createBy", sysConfig.getCreateBy());
|
||||
result.put("createTime", sysConfig.getCreateTime());
|
||||
result.put("updateBy", sysConfig.getUpdateBy());
|
||||
result.put("updateTime", sysConfig.getUpdateTime());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,15 @@
|
|||
<artifactId>tums-auth</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nursing-unit-common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-system-local-api</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package com.nu.modules.commonutils;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.google.common.collect.Maps;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 获取常用信息(不涉及安全信息)
|
||||
* @author zmy
|
||||
* @date 2025-5-22 08:43:05
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/api/baseInfo")
|
||||
public class SysBaseInfoApi {
|
||||
|
||||
@Lazy
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
|
||||
/**
|
||||
* 返回机构信息配置的"协议域名"
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/sysUrl")
|
||||
public Result<?> sysUrl(){
|
||||
JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
Map<String,Object> result = Maps.newHashMap();
|
||||
result.put("url",deptInfo.getString("url"));
|
||||
return Result.ok(result);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -107,6 +107,9 @@ public class ShiroConfig {
|
|||
filterChainDefinitionMap.put("/generic/**", "anon");//pdf预览需要文件
|
||||
filterChainDefinitionMap.put("/ConfigMaterial/configMaterialCategory/**", "anon");//pdf预览需要文件
|
||||
filterChainDefinitionMap.put("/nuIpadApi/**", "anon");//pdf预览需要文件
|
||||
filterChainDefinitionMap.put("/api/ocr/**", "anon");//TODO 待删除 运维也删 阿里云证件识别
|
||||
filterChainDefinitionMap.put("/api/baseInfo/**", "anon");//获取系统中信息
|
||||
filterChainDefinitionMap.put("/sys/common/open/static/**", "anon");//获取本地文件资源
|
||||
|
||||
filterChainDefinitionMap.put("/sys/getLoginQrcode/**", "anon"); //登录二维码
|
||||
filterChainDefinitionMap.put("/sys/getQrcodeToken/**", "anon"); //监听扫码
|
||||
|
|
|
@ -17,6 +17,12 @@
|
|||
<artifactId>nursing-unit-base-core</artifactId>
|
||||
<version>2.0.0</version>
|
||||
</dependency>
|
||||
<!-- 阿里云证件照识别 -->
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>alibabacloud-ocr_api20210707</artifactId>
|
||||
<version>3.0.4</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);
|
||||
}
|
||||
}
|
|
@ -49,6 +49,17 @@
|
|||
<artifactId>nu-system-local-api</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-admin-local-api</artifactId>
|
||||
<version>${nursingunit.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.nursingunit.boot</groupId>
|
||||
<artifactId>nu-admin-biz</artifactId>
|
||||
<version>2.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
|
|
@ -1,16 +1,23 @@
|
|||
package com.nu.modules.directivepackage.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.nu.modules.directivepackage.entity.DirectivePackage;
|
||||
import com.nu.modules.directivepackage.mapper.DirectivePackageMapper;
|
||||
import com.nu.modules.directivepackage.service.IDirectivePackageService;
|
||||
import com.nu.modules.mediamanage.service.IMediaManageApi;
|
||||
import com.nu.modules.servicedirective.entity.ConfigServiceDirective;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令包
|
||||
|
@ -21,6 +28,9 @@ import java.util.List;
|
|||
@Service
|
||||
public class DirectivePackageServiceImpl extends ServiceImpl<DirectivePackageMapper, DirectivePackage> implements IDirectivePackageService {
|
||||
|
||||
@Autowired
|
||||
private IMediaManageApi mediaManageApi;
|
||||
|
||||
@Override
|
||||
public void saveDirectives(DirectivePackage directivePackage) {
|
||||
baseMapper.deleteDirectives(directivePackage);
|
||||
|
@ -47,6 +57,41 @@ public class DirectivePackageServiceImpl extends ServiceImpl<DirectivePackageMap
|
|||
DirectivePackage queryDto = new DirectivePackage().setId(id);
|
||||
query.add(queryDto);
|
||||
List<DirectivePackage> directivePackages = baseMapper.queryList(null, query);
|
||||
//处理媒体资源路径
|
||||
{
|
||||
if(directivePackages!=null && !directivePackages.isEmpty()){
|
||||
List<ConfigServiceDirective> directives = directivePackages.get(0).getDirectives();
|
||||
if(directives!=null && !directives.isEmpty()){
|
||||
//拿到所有媒体资源的id
|
||||
List<String> meidsIds = directives.stream()
|
||||
.flatMap(directive -> Stream.of(
|
||||
directive.getMp3File(),
|
||||
directive.getMp4File(),
|
||||
directive.getPreviewFile(),
|
||||
directive.getImmediateFile()
|
||||
))
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<JSONObject> mediaObjs = mediaManageApi.queryByIds(meidsIds);
|
||||
|
||||
Map<String, String> idToFilePathMap = mediaObjs.stream()
|
||||
.collect(Collectors.toMap(
|
||||
media -> media.getStr("id"),
|
||||
media -> media.getStr("filePath")
|
||||
));
|
||||
|
||||
directives.stream().forEach(record -> {
|
||||
record.setPreviewFileMedia(idToFilePathMap.get(record.getPreviewFile()));
|
||||
record.setImmediateFileMedia(idToFilePathMap.get(record.getImmediateFile()));
|
||||
record.setMp3FileMedia(idToFilePathMap.get(record.getMp3File()));
|
||||
record.setMp4FileMedia(idToFilePathMap.get(record.getMp4File()));
|
||||
});
|
||||
directivePackages.get(0).setDirectives(directives);
|
||||
}
|
||||
}
|
||||
}
|
||||
return directivePackages.stream().findFirst().orElse(null);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
package com.nu.modules.servicedirective.controller;
|
||||
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.nu.modules.servicedirective.entity.ConfigServiceDirective;
|
||||
import com.nu.modules.servicedirective.service.IConfigServiceDirectiveService;
|
||||
import com.nu.modules.sysconfig.ISysConfigApi;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -107,6 +110,8 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
@RequiresPermissions("serviceDirective:config_service_directive:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody ConfigServiceDirective configServiceDirective) {
|
||||
//处理媒体资源
|
||||
configServiceDirectiveService.handleMedia(configServiceDirective);
|
||||
configServiceDirectiveService.save(configServiceDirective);
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) {
|
||||
configServiceDirectiveService.saveBodyTags(configServiceDirective);
|
||||
|
@ -119,6 +124,10 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
} else {
|
||||
configServiceDirectiveService.removeEmotionTags(configServiceDirective);
|
||||
}
|
||||
|
||||
//放在最后一行 如果是试验田(数据源)机构 需通知运维更新媒体资源
|
||||
configServiceDirectiveService.noticeOpe(configServiceDirective);
|
||||
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
|
@ -133,6 +142,8 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
@RequiresPermissions("serviceDirective:config_service_directive:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody ConfigServiceDirective configServiceDirective) {
|
||||
//处理媒体资源
|
||||
configServiceDirectiveService.handleMedia(configServiceDirective);
|
||||
configServiceDirectiveService.updateById(configServiceDirective);
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getBodyTags())) {
|
||||
configServiceDirectiveService.saveBodyTags(configServiceDirective);
|
||||
|
@ -145,6 +156,9 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
} else {
|
||||
configServiceDirectiveService.removeEmotionTags(configServiceDirective);
|
||||
}
|
||||
|
||||
//放在最后一行 如果是试验田(数据源)机构 需通知运维更新媒体资源
|
||||
configServiceDirectiveService.noticeOpe(configServiceDirective);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
|
|
|
@ -125,15 +125,39 @@ public class ConfigServiceDirective implements Serializable {
|
|||
/**语音文件*/
|
||||
@ApiModelProperty(value = "语音文件")
|
||||
private java.lang.String mp3File;
|
||||
//语音文件是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean mp3FileChanged;
|
||||
//语音文件路径
|
||||
@TableField(exist = false)
|
||||
private java.lang.String mp3FileMedia;
|
||||
/**视频文件*/
|
||||
@ApiModelProperty(value = "视频文件")
|
||||
private java.lang.String mp4File;
|
||||
//视频文件是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean mp4FileChanged;
|
||||
//视频文件路径
|
||||
@TableField(exist = false)
|
||||
private java.lang.String mp4FileMedia;
|
||||
/**预览图片*/
|
||||
@ApiModelProperty(value = "预览图片")
|
||||
private java.lang.String previewFile;
|
||||
//预览图片是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean previewFileChanged;
|
||||
//预览图片路径
|
||||
@TableField(exist = false)
|
||||
private java.lang.String previewFileMedia;
|
||||
/**即时指令图片*/
|
||||
@ApiModelProperty(value = "即时指令图片")
|
||||
private java.lang.String immediateFile;
|
||||
//即时指令图片是否变更
|
||||
@TableField(exist = false)
|
||||
private boolean immediateFileChanged;
|
||||
//即时指令图片路径
|
||||
@TableField(exist = false)
|
||||
private java.lang.String immediateFileMedia;
|
||||
|
||||
//合并单元格用:类别合并的行数
|
||||
@TableField(exist = false)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.nu.modules.servicedirective.service;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.nu.modules.mediamanage.entity.MediaManage;
|
||||
import com.nu.modules.servicedirective.entity.ConfigServiceDirective;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
|
@ -51,4 +53,10 @@ public interface IConfigServiceDirectiveService extends IService<ConfigServiceDi
|
|||
List<ConfigServiceDirective> selectAllByIds(String dataSourceCode, List<String> idList);
|
||||
|
||||
void insertAllDirectives(List<ConfigServiceDirective> directives);
|
||||
|
||||
void handleMedia(ConfigServiceDirective configServiceDirective);
|
||||
|
||||
void noticeOpe(ConfigServiceDirective configServiceDirective);
|
||||
|
||||
List<JSONObject> selectMediaList(String dataSourceCode, List<String> idList);
|
||||
}
|
||||
|
|
|
@ -1,18 +1,29 @@
|
|||
package com.nu.modules.servicedirective.service.impl;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.nu.modules.directivetag.body.entity.DirectiveBodyTag;
|
||||
import com.nu.modules.directivetag.emotion.entity.DirectiveEmotionTag;
|
||||
import com.nu.modules.mediamanage.service.IMediaManageApi;
|
||||
import com.nu.modules.servicedirective.entity.ConfigServiceDirective;
|
||||
import com.nu.modules.servicedirective.mapper.ConfigServiceDirectiveMapper;
|
||||
import com.nu.modules.servicedirective.service.IConfigServiceDirectiveService;
|
||||
import com.nu.modules.sysconfig.ISysConfigApi;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* @Description: 服务指令
|
||||
|
@ -23,6 +34,14 @@ import java.util.stream.Collectors;
|
|||
@Service
|
||||
public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigServiceDirectiveMapper, ConfigServiceDirective> implements IConfigServiceDirectiveService {
|
||||
|
||||
@Autowired
|
||||
private IMediaManageApi mediaManageApi;
|
||||
@Autowired
|
||||
private ISysConfigApi sysConfigApi;
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
@Autowired
|
||||
private RabbitMQUtil rabbitMQUtil;
|
||||
|
||||
@Override
|
||||
public List<ConfigServiceDirective> pageList(ConfigServiceDirective configServiceDirective, IPage<ConfigServiceDirective> list_) {
|
||||
|
@ -39,9 +58,26 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
List<DirectiveEmotionTag> emotionTagList = record.getEmotionTagList();
|
||||
record.setEmotionTags(emotionTagList.stream().map(DirectiveEmotionTag::getId).collect(Collectors.joining(",")));
|
||||
});
|
||||
//处理媒体资源转换
|
||||
{
|
||||
List<String> meidsIds = list.stream().flatMap(directive -> Stream.of(directive.getMp3File(), directive.getMp4File(), directive.getPreviewFile(), directive.getImmediateFile())).filter(Objects::nonNull).distinct().collect(Collectors.toList());
|
||||
|
||||
List<JSONObject> mediaObjs = mediaManageApi.queryByIds(meidsIds);
|
||||
|
||||
Map<String, String> idToFilePathMap = mediaObjs.stream().collect(Collectors.toMap(media -> media.getStr("id"), media -> media.getStr("filePath")));
|
||||
|
||||
list.stream().forEach(record -> {
|
||||
record.setPreviewFileMedia(idToFilePathMap.get(record.getPreviewFile()));
|
||||
record.setImmediateFileMedia(idToFilePathMap.get(record.getImmediateFile()));
|
||||
record.setMp3FileMedia(idToFilePathMap.get(record.getMp3File()));
|
||||
record.setMp4FileMedia(idToFilePathMap.get(record.getMp4File()));
|
||||
});
|
||||
}
|
||||
}
|
||||
//处理单元格合并所需数据
|
||||
merge(list);
|
||||
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
@ -206,4 +242,99 @@ public class ConfigServiceDirectiveServiceImpl extends ServiceImpl<ConfigService
|
|||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleMedia(ConfigServiceDirective configServiceDirective) {
|
||||
Map<String, String> params = Maps.newHashMap();
|
||||
params.put("sysFunc", "directive");
|
||||
if (configServiceDirective.isImmediateFileChanged()) {
|
||||
params.put("fileName", configServiceDirective.getDirectiveName() + "预览图片");
|
||||
params.put("descr", "服务指令用户上传图片:" + configServiceDirective.getDirectiveName() + "预览图片");
|
||||
configServiceDirective.setImmediateFile((mediaManageApi.saveByPath(configServiceDirective.getImmediateFileMedia(), params)));
|
||||
}
|
||||
if (configServiceDirective.isPreviewFileChanged()) {
|
||||
params.put("fileName", configServiceDirective.getDirectiveName() + "即时指令图片");
|
||||
params.put("descr", "服务指令用户上传图片:" + configServiceDirective.getDirectiveName() + "即时指令图片");
|
||||
configServiceDirective.setPreviewFile(mediaManageApi.saveByPath(configServiceDirective.getPreviewFileMedia(), params));
|
||||
}
|
||||
if (configServiceDirective.isMp3FileChanged()) {
|
||||
params.put("fileName", configServiceDirective.getDirectiveName() + "音频文件");
|
||||
params.put("descr", "服务指令用户上传音频:" + configServiceDirective.getDirectiveName() + "音频文件");
|
||||
configServiceDirective.setMp3File(mediaManageApi.saveByPath(configServiceDirective.getMp3FileMedia(), params));
|
||||
}
|
||||
if (configServiceDirective.isMp4FileChanged()) {
|
||||
params.put("fileName", configServiceDirective.getDirectiveName() + "视频文件");
|
||||
params.put("descr", "服务指令用户上传视频:" + configServiceDirective.getDirectiveName() + "视频文件");
|
||||
configServiceDirective.setMp4File(mediaManageApi.saveByPath(configServiceDirective.getMp4FileMedia(), params));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void noticeOpe(ConfigServiceDirective configServiceDirective) {
|
||||
com.alibaba.fastjson.JSONObject all = sysConfigApi.getAll();
|
||||
JSONArray configs = all.getJSONArray("configs");
|
||||
configs.stream().forEach(c -> {
|
||||
System.out.println(c);
|
||||
});
|
||||
com.alibaba.fastjson.JSONObject config = sysConfigApi.getByKey("directive_source_url");
|
||||
String url1 = config.getString("configValue");
|
||||
|
||||
//获取本机构配置的协议+域名
|
||||
com.alibaba.fastjson.JSONObject deptInfo = sysBaseAPI.getDeptInfo();
|
||||
String url2 = deptInfo.getString("url");
|
||||
if (url1 != null && url2 != null) {
|
||||
if (url1.endsWith("/") ^ url2.endsWith("/")) {
|
||||
//一个结尾有斜杠 一个结尾没有斜杠
|
||||
if (url1.endsWith("/")) {
|
||||
url2 = url2 + "/";
|
||||
} else {
|
||||
url1 = url1 + "/";
|
||||
}
|
||||
}
|
||||
if ((url1).equals(url2)) {
|
||||
//给运维系统发通知
|
||||
//查询对应媒体资源作为参数给到运维系统
|
||||
List<String> mediaIds = Lists.newArrayList();
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getPreviewFile())) {
|
||||
mediaIds.add(configServiceDirective.getPreviewFile());
|
||||
}
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getImmediateFile())) {
|
||||
mediaIds.add(configServiceDirective.getImmediateFile());
|
||||
}
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getMp3File())) {
|
||||
mediaIds.add(configServiceDirective.getMp3File());
|
||||
}
|
||||
if (StringUtils.isNotBlank(configServiceDirective.getMp4File())) {
|
||||
mediaIds.add(configServiceDirective.getMp4File());
|
||||
}
|
||||
List<JSONObject> jsonObjects = mediaManageApi.queryByIds(mediaIds);
|
||||
List<Map<String, Object>> mediaMaps = new ArrayList<>();
|
||||
if (jsonObjects != null && !jsonObjects.isEmpty()) {
|
||||
jsonObjects.stream().forEach(m -> {
|
||||
Map<String, Object> mediaMap = new HashMap<>();
|
||||
mediaMap.put("id", m.getStr("id"));
|
||||
mediaMap.put("name", m.getStr("name"));
|
||||
mediaMap.put("descr", m.getStr("descr"));
|
||||
mediaMap.put("sysFunc", m.getStr("sysFunc"));
|
||||
mediaMap.put("fileType", m.getStr("fileType"));
|
||||
mediaMap.put("filePath", m.getStr("filePath"));
|
||||
mediaMap.put("izNetUrl", m.getStr("izNetUrl"));
|
||||
mediaMap.put("delFlag", m.getStr("delFlag"));
|
||||
mediaMap.put("createBy", m.getStr("createBy"));
|
||||
// mediaMap.put("createTime", m.getDate("createTime"));
|
||||
mediaMap.put("updateBy", m.getStr("updateBy"));
|
||||
// mediaMap.put("updateTime", m.getDate("updateTime"));
|
||||
mediaMaps.add(mediaMap);
|
||||
});
|
||||
|
||||
rabbitMQUtil.sendToExchange("hldy.mediamanage", "mediamanage.async", mediaMaps);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JSONObject> selectMediaList(String dataSourceCode, List<String> idList) {
|
||||
return mediaManageApi.selectByDirectiveIds(dataSourceCode,idList);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,11 @@
|
|||
package com.nu.mq.directive.listener;
|
||||
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
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.DirectiveMQDto;
|
||||
import com.nu.dto.StatusMQDto;
|
||||
import com.nu.enums.MQStatus;
|
||||
|
@ -11,13 +15,22 @@ import com.nu.modules.directivetag.body.service.IDirectiveBodyTagService;
|
|||
import com.nu.modules.directivetag.emotion.entity.DirectiveEmotionTag;
|
||||
import com.nu.modules.directivetag.emotion.entity.DirectiveEmotionTagRelation;
|
||||
import com.nu.modules.directivetag.emotion.service.IDirectiveEmotionTagService;
|
||||
import com.nu.modules.mediaasyncerrorlog.entity.MediaAsyncErrorLog;
|
||||
import com.nu.modules.mediaasyncerrorlog.service.IMediaAsyncErrorLogService;
|
||||
import com.nu.modules.mediamanage.entity.MediaManage;
|
||||
import com.nu.modules.mediamanage.entity.MediaManageDto;
|
||||
import com.nu.modules.mediamanage.service.IMediaManageApi;
|
||||
import com.nu.modules.servicecategory.entity.ConfigServiceCategory;
|
||||
import com.nu.modules.servicecategory.service.IConfigServiceCategoryService;
|
||||
import com.nu.modules.servicedirective.entity.ConfigServiceDirective;
|
||||
import com.nu.modules.servicedirective.service.IConfigServiceDirectiveService;
|
||||
import com.nu.modules.servicetype.entity.ConfigServiceType;
|
||||
import com.nu.modules.servicetype.service.IConfigServiceTypeService;
|
||||
import com.nu.modules.sysconfig.entity.SysConfig;
|
||||
import com.nu.modules.sysconfig.service.ISysConfigService;
|
||||
import com.nu.utils.FileDownloader;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
import com.nu.utils.SafetyUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.springframework.amqp.core.ExchangeTypes;
|
||||
|
@ -25,17 +38,34 @@ 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.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DirectiveMQListener {
|
||||
|
||||
@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;
|
||||
@Autowired
|
||||
private IConfigServiceDirectiveService directiveService;
|
||||
@Autowired
|
||||
|
@ -87,6 +117,12 @@ public class DirectiveMQListener {
|
|||
//增量
|
||||
handleIncremental(dto);
|
||||
}
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setStatus(MQStatus.SUCCESS.getCode());
|
||||
statusMQDto.setMessage("数据同步成功!");
|
||||
statusMQDto.setAsyncId(dto.getAsyncId());
|
||||
statusMQDto.setCode("data");
|
||||
rabbitMQUtil.sendToExchange("hldy.fwzl", "fwzl.async.result", statusMQDto);
|
||||
} catch (Exception e) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setStatus(MQStatus.PROCESS_FAILED.getCode());
|
||||
|
@ -96,17 +132,28 @@ public class DirectiveMQListener {
|
|||
rabbitMQUtil.sendToExchange("hldy.fwzl", "fwzl.async.result", statusMQDto);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
try {
|
||||
//处理文件同步
|
||||
handleFileAsync(dto);
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setStatus(MQStatus.SUCCESS.getCode());
|
||||
statusMQDto.setMessage("数据同步成功!");
|
||||
statusMQDto.setAsyncId(dto.getAsyncId());
|
||||
statusMQDto.setCode("data");
|
||||
statusMQDto.setCode("file");
|
||||
rabbitMQUtil.sendToExchange("hldy.fwzl", "fwzl.async.result", statusMQDto);
|
||||
} catch (Exception e) {
|
||||
StatusMQDto statusMQDto = new StatusMQDto();
|
||||
statusMQDto.setStatus(MQStatus.PROCESS_FAILED.getCode());
|
||||
statusMQDto.setMessage("【文件同步失败请至“服务指令更新功能”重新同步】" + e.getMessage());
|
||||
statusMQDto.setAsyncId(dto.getAsyncId());
|
||||
statusMQDto.setCode("file");
|
||||
rabbitMQUtil.sendToExchange("hldy.fwzl", "fwzl.async.result", statusMQDto);
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 处理全量
|
||||
* 处理全量同步数据
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
|
@ -128,7 +175,7 @@ public class DirectiveMQListener {
|
|||
}
|
||||
|
||||
/**
|
||||
* 处理增量
|
||||
* 处理增量同步数据
|
||||
*
|
||||
* @param dto
|
||||
* @throws Exception
|
||||
|
@ -230,4 +277,131 @@ public class DirectiveMQListener {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理文件同步
|
||||
*
|
||||
* @param dto
|
||||
*/
|
||||
private void handleFileAsync(DirectiveMQDto dto) {
|
||||
dto.setIdList(Arrays.asList(dto.getIdStr().split(",")));
|
||||
if (dto.getIdList() == null || dto.getIdList().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
List<JSONObject> objs = directiveService.selectMediaList("nuro", dto.getIdList());
|
||||
if (CollectionUtils.isEmpty(objs)) {
|
||||
return;
|
||||
}
|
||||
//试验田对应服务指令下的媒体资源
|
||||
List<MediaManageDto> mediaList = directiveService.selectMediaList("nuro", dto.getIdList())
|
||||
.stream()
|
||||
.map(json -> JSONUtil.toBean(json, MediaManageDto.class))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//获取机构下媒资数据
|
||||
List<String> mediaIds = mediaList.stream()
|
||||
.map(MediaManageDto::getId)
|
||||
.collect(Collectors.toList());
|
||||
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是试验田的媒体资源数据
|
||||
mediaList.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);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理文件存储
|
||||
*
|
||||
* @param media
|
||||
*/
|
||||
private void handleSaveFile(MediaManageDto 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();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package org.jeecg.modules.system.controller;
|
||||
|
||||
import com.nu.utils.SafetyUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
|
@ -22,6 +23,10 @@ import org.springframework.web.servlet.ModelAndView;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.time.LocalDate;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
|
@ -46,8 +51,8 @@ public class CommonController {
|
|||
private String uploadType;
|
||||
|
||||
/**
|
||||
* @Author 政辉
|
||||
* @return
|
||||
* @Author 政辉
|
||||
*/
|
||||
@GetMapping("/403")
|
||||
public Result<?> noauth() {
|
||||
|
@ -56,6 +61,7 @@ public class CommonController {
|
|||
|
||||
/**
|
||||
* 文件上传统一方法
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
|
@ -122,6 +128,7 @@ public class CommonController {
|
|||
|
||||
/**
|
||||
* 本地文件上传
|
||||
*
|
||||
* @param mf 文件
|
||||
* @param bizPath 自定义路径
|
||||
* @return
|
||||
|
@ -267,6 +274,77 @@ public class CommonController {
|
|||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/open/static/**")
|
||||
public void openView(@RequestParam(value = "name", defaultValue = "aaa") String secureKey, HttpServletRequest request, HttpServletResponse response) {
|
||||
if (!SafetyUtil.validateSecureKey(secureKey)) {
|
||||
try {
|
||||
response.setContentType("text/plain");
|
||||
response.setCharacterEncoding("UTF-8");
|
||||
response.getWriter().write("");
|
||||
return;
|
||||
} catch (IOException e) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// ISO-8859-1 ==> UTF-8 进行编码转换
|
||||
String imgPath = extractPathFromPattern(request);
|
||||
if (oConvertUtils.isEmpty(imgPath) || CommonConstant.STRING_NULL.equals(imgPath)) {
|
||||
return;
|
||||
}
|
||||
// 其余处理略
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
imgPath = imgPath.replace("..", "").replace("../", "");
|
||||
if (imgPath.endsWith(SymbolConstant.COMMA)) {
|
||||
imgPath = imgPath.substring(0, imgPath.length() - 1);
|
||||
}
|
||||
//update-begin---author:liusq ---date:20230912 for:检查下载文件类型--------------
|
||||
SsrfFileTypeFilter.checkDownloadFileType(imgPath);
|
||||
//update-end---author:liusq ---date:20230912 for:检查下载文件类型--------------
|
||||
|
||||
String filePath = uploadpath + File.separator + imgPath;
|
||||
File file = new File(filePath);
|
||||
if (!file.exists()) {
|
||||
response.setStatus(404);
|
||||
log.error("文件[" + imgPath + "]不存在..");
|
||||
return;
|
||||
//throw new RuntimeException();
|
||||
}
|
||||
// 设置强制下载不打开
|
||||
response.setContentType("application/force-download");
|
||||
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"), "iso-8859-1"));
|
||||
inputStream = new BufferedInputStream(new FileInputStream(filePath));
|
||||
outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
} catch (IOException e) {
|
||||
log.error("预览文件失败" + e.getMessage());
|
||||
response.setStatus(404);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 下载文件
|
||||
// * 请求地址:http://localhost:8080/common/download/{user/20190119/e1fe9925bc315c60addea1b98eb1cb1349547719_1547866868179.jpg}
|
||||
|
@ -326,9 +404,9 @@ public class CommonController {
|
|||
// }
|
||||
|
||||
/**
|
||||
* @功能:pdf预览Iframe
|
||||
* @param modelAndView
|
||||
* @return
|
||||
* @功能:pdf预览Iframe
|
||||
*/
|
||||
@RequestMapping("/pdf/pdfPreviewIframe")
|
||||
public ModelAndView pdfPreviewIframe(ModelAndView modelAndView) {
|
||||
|
@ -339,6 +417,7 @@ public class CommonController {
|
|||
/**
|
||||
* 把指定URL后的字符串全部截断当成参数
|
||||
* 这么做是为了防止URL中包含中文或者特殊字符(/等)时,匹配不了的问题
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
|
|
|
@ -54,6 +54,9 @@ public class SysDepart implements Serializable {
|
|||
/**机构编码*/
|
||||
@Excel(name="机构编码",width=15)
|
||||
private String orgCode;
|
||||
/**协议+域名*/
|
||||
@Excel(name="协议+域名",width=30)
|
||||
private String url;
|
||||
/**手机号*/
|
||||
@Excel(name="手机号",width=15)
|
||||
private String mobile;
|
||||
|
|
|
@ -20,13 +20,19 @@ public class SysDepartTreeModel implements Serializable{
|
|||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 对应SysDepart中的id字段,前端数据树中的key*/
|
||||
/**
|
||||
* 对应SysDepart中的id字段,前端数据树中的key
|
||||
*/
|
||||
private String key;
|
||||
|
||||
/** 对应SysDepart中的id字段,前端数据树中的value*/
|
||||
/**
|
||||
* 对应SysDepart中的id字段,前端数据树中的value
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/** 对应depart_name字段,前端数据树中的title*/
|
||||
/**
|
||||
* 对应depart_name字段,前端数据树中的title
|
||||
*/
|
||||
private String title;
|
||||
|
||||
|
||||
|
@ -53,6 +59,8 @@ public class SysDepartTreeModel implements Serializable{
|
|||
|
||||
private String orgCode;
|
||||
|
||||
private String url;
|
||||
|
||||
private String mobile;
|
||||
|
||||
private String fax;
|
||||
|
@ -76,7 +84,9 @@ public class SysDepartTreeModel implements Serializable{
|
|||
private Date updateTime;
|
||||
|
||||
//update-begin---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增字段部门负责人ids
|
||||
/**部门负责人ids*/
|
||||
/**
|
||||
* 部门负责人ids
|
||||
*/
|
||||
private String directorUserIds;
|
||||
//update-end---author:wangshuai ---date:20200308 for:[JTC-119]在部门管理菜单下设置部门负责人,新增字段部门负责人ids
|
||||
|
||||
|
@ -85,6 +95,7 @@ public class SysDepartTreeModel implements Serializable{
|
|||
|
||||
/**
|
||||
* 将SysDepart对象转换成SysDepartTreeModel对象
|
||||
*
|
||||
* @param sysDepart
|
||||
*/
|
||||
public SysDepartTreeModel(SysDepart sysDepart) {
|
||||
|
@ -101,6 +112,7 @@ public class SysDepartTreeModel implements Serializable{
|
|||
this.orgCategory = sysDepart.getOrgCategory();
|
||||
this.orgType = sysDepart.getOrgType();
|
||||
this.orgCode = sysDepart.getOrgCode();
|
||||
this.url = sysDepart.getUrl();
|
||||
this.mobile = sysDepart.getMobile();
|
||||
this.fax = sysDepart.getFax();
|
||||
this.address = sysDepart.getAddress();
|
||||
|
@ -221,6 +233,14 @@ public class SysDepartTreeModel implements Serializable{
|
|||
this.orgCode = orgCode;
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getMobile() {
|
||||
return mobile;
|
||||
}
|
||||
|
@ -341,7 +361,8 @@ public class SysDepartTreeModel implements Serializable{
|
|||
this.updateTime = updateTime;
|
||||
}
|
||||
|
||||
public SysDepartTreeModel() { }
|
||||
public SysDepartTreeModel() {
|
||||
}
|
||||
|
||||
public String getDirectorUserIds() {
|
||||
return directorUserIds;
|
||||
|
@ -373,6 +394,7 @@ public class SysDepartTreeModel implements Serializable{
|
|||
Objects.equals(orgCategory, model.orgCategory) &&
|
||||
Objects.equals(orgType, model.orgType) &&
|
||||
Objects.equals(orgCode, model.orgCode) &&
|
||||
Objects.equals(url, model.url) &&
|
||||
Objects.equals(mobile, model.mobile) &&
|
||||
Objects.equals(fax, model.fax) &&
|
||||
Objects.equals(address, model.address) &&
|
||||
|
@ -395,7 +417,7 @@ public class SysDepartTreeModel implements Serializable{
|
|||
public int hashCode() {
|
||||
|
||||
return Objects.hash(id, parentId, departName, departNameEn, departNameAbbr,
|
||||
departOrder, description, orgCategory, orgType, orgCode, mobile, fax, address,
|
||||
departOrder, description, orgCategory, orgType, orgCode, url, mobile, fax, address,
|
||||
memo, status, delFlag, qywxIdentifier, createBy, createTime, updateBy, updateTime,
|
||||
children, directorUserIds);
|
||||
}
|
||||
|
|
|
@ -1840,6 +1840,7 @@ public class SysBaseApiImpl implements ISysBaseAPI {
|
|||
if(list!=null && !list.isEmpty()){
|
||||
map.put("code",list.get(0).getOrgCode());
|
||||
map.put("name",list.get(0).getDepartName());
|
||||
map.put("url",list.get(0).getUrl());
|
||||
}
|
||||
return new JSONObject(map);
|
||||
}
|
||||
|
|
|
@ -191,7 +191,7 @@ spring:
|
|||
username: nu_sys
|
||||
password: nu_sys
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 多数据源配置-运维系统
|
||||
# 多数据源配置-试验田
|
||||
nuro:
|
||||
url: jdbc:mysql://192.168.2.199:3306/nursing_unit_001?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: nu_ro
|
||||
|
@ -254,10 +254,12 @@ jeecg:
|
|||
pc: http://localhost:3100
|
||||
app: http://localhost:8051
|
||||
path:
|
||||
#服务指令上传目录
|
||||
directivepath: /opt/upFiles002/directive
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/upFiles
|
||||
upload: /opt/upFiles002
|
||||
#webapp文件路径
|
||||
webapp: /opt/webapp
|
||||
webapp: /opt/webapp002
|
||||
shiro:
|
||||
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/**
|
||||
#阿里云oss存储和大鱼短信秘钥配置
|
||||
|
@ -379,3 +381,10 @@ tplink:
|
|||
username: administrator
|
||||
password: Root@123..
|
||||
uploadpath: /
|
||||
#zmy
|
||||
aliyun:
|
||||
ocr:
|
||||
accessKeyId: LTAI5tMoCTt4sb9VQrcnZFsb
|
||||
accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
|
||||
#文件传输秘钥
|
||||
downloadkey: hP2K9Z!WLuj"M#8,
|
||||
|
|
|
@ -191,6 +191,12 @@ spring:
|
|||
username: nu_sys
|
||||
password: nu_sys
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 多数据源配置-试验田
|
||||
nuro:
|
||||
url: jdbc:mysql://192.168.2.199:3306/nursing_unit_001?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
username: nu_ro
|
||||
password: nu_ro
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
#redis 配置
|
||||
redis:
|
||||
database: 0
|
||||
|
@ -249,10 +255,12 @@ jeecg:
|
|||
pc: http://localhost:3100
|
||||
app: http://localhost:8051
|
||||
path:
|
||||
#服务指令上传目录
|
||||
directivepath: /opt/upFiles001/directive
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/upFiles
|
||||
upload: /opt/upFiles001
|
||||
#webapp文件路径
|
||||
webapp: /opt/webapp
|
||||
webapp: /opt/webapp001
|
||||
shiro:
|
||||
excludeUrls: /test/jeecgDemo/demo3,/test/jeecgDemo/redisDemo/**,/bigscreen/category/**,/bigscreen/visual/**,/bigscreen/map/**,/jmreport/bigscreen2/**
|
||||
#阿里云oss存储和大鱼短信秘钥配置
|
||||
|
@ -374,3 +382,10 @@ tplink:
|
|||
username: administrator
|
||||
password: Root@123..
|
||||
uploadpath: /
|
||||
#zmy
|
||||
aliyun:
|
||||
ocr:
|
||||
accessKeyId: LTAI5tMoCTt4sb9VQrcnZFsb
|
||||
accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
|
||||
#文件传输秘钥
|
||||
downloadkey: hP2K9Z!WLuj"M#8,
|
||||
|
|
|
@ -191,6 +191,12 @@ spring:
|
|||
username: fw8864sshdang
|
||||
password: uGDBkM25I6nZCNM2
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# 多数据源配置-试验田
|
||||
# nuro:
|
||||
# url: jdbc:mysql://192.168.2.199:3306/nursing_unit_001?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
|
||||
# username: nu_ro
|
||||
# password: nu_ro
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
#redis 配置
|
||||
redis:
|
||||
database: 0
|
||||
|
@ -247,6 +253,8 @@ jeecg:
|
|||
pc: http://localhost:3100
|
||||
app: http://localhost:8051
|
||||
path:
|
||||
#服务指令上传目录
|
||||
directivepath: /opt/upFiles/directive
|
||||
#文件上传根目录 设置
|
||||
upload: /opt/nu001/upFiles
|
||||
#webapp文件路径
|
||||
|
@ -372,3 +380,10 @@ tplink:
|
|||
username: administrator
|
||||
password: Root@123..
|
||||
uploadpath: /
|
||||
#zmy
|
||||
aliyun:
|
||||
ocr:
|
||||
accessKeyId: LTAI5tMoCTt4sb9VQrcnZFsb
|
||||
accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
|
||||
#文件传输秘钥
|
||||
downloadkey: hP2K9Z!WLuj"M#8,
|
||||
|
|
Loading…
Reference in New Issue