1、调整8864环境阿里云OCR的key

2、护理单元同步接口(未完成)
This commit is contained in:
1378012178@qq.com 2025-06-23 15:23:48 +08:00
parent 57020079be
commit 707bbf25ed
10 changed files with 468 additions and 2 deletions

View File

@ -0,0 +1,162 @@
package com.nu.modules.nuBaseInfo.controller;
import cn.hutool.core.util.IdUtil;
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.plugins.pagination.Page;
import com.nu.dto.NuBaseInfoMQDto;
import com.nu.enums.MQStatus;
import com.nu.modules.async.entity.AsyncMain;
import com.nu.modules.async.entity.AsyncStatus;
import com.nu.modules.async.service.IAsyncMainService;
import com.nu.modules.async.service.IAsyncStatusService;
import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
import com.nu.modules.nuBaseInfo.service.INuBaseInfoService;
import com.nu.utils.RabbitMQUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.system.query.QueryRuleEnum;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;
/**
* @Description: 护理单元
* @Author: jeecg-boot
* @Date: 2025-04-11
* @Version: V1.0
*/
@Api(tags = "护理单元")
@RestController
@RequestMapping("/nuBaseInfo/nuBaseInfo")
@Slf4j
public class NuBaseInfoController extends JeecgController<NuBaseInfo, INuBaseInfoService> {
@Autowired
private INuBaseInfoService nuBaseInfoService;
@Autowired
private IAsyncMainService asyncMainService;
@Autowired
private IAsyncStatusService asyncStatusService;
@Autowired
private RabbitMQUtil rabbitMQUtil;
/**
* 分页列表查询
*
* @param nuBaseInfo
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "护理单元-分页列表查询")
@ApiOperation(value = "护理单元-分页列表查询", notes = "护理单元-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<NuBaseInfo>> queryPageList(NuBaseInfo nuBaseInfo,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
IPage<NuBaseInfo> pageList = getNuBaseInfoIPage(nuBaseInfo, pageNo, pageSize, req);
return Result.OK(pageList);
}
/**
* 业务机构分页列表查询
*
* @param nuBaseInfo
* @param pageNo
* @param pageSize
* @param req
* @return
*/
@ApiOperation(value = "护理单元-业务机构分页列表查询", notes = "护理单元-业务机构分页列表查询")
@GetMapping(value = "/listByOrgCode")
@DS("#dataSourceCode")
public Result<IPage<NuBaseInfo>> listByOrgCode(@RequestParam("dataSourceCode") String dataSourceCode,NuBaseInfo nuBaseInfo,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
IPage<NuBaseInfo> pageList = getNuBaseInfoIPage(nuBaseInfo, pageNo, pageSize, req);
return Result.OK(pageList);
}
private IPage<NuBaseInfo> getNuBaseInfoIPage(NuBaseInfo nuBaseInfo, Integer pageNo, Integer pageSize, HttpServletRequest req) {
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
customeRuleMap.put("area_flag", QueryRuleEnum.LIKE_WITH_OR);
customeRuleMap.put("status", QueryRuleEnum.LIKE_WITH_OR);
QueryWrapper<NuBaseInfo> queryWrapper = QueryGenerator.initQueryWrapper(nuBaseInfo, req.getParameterMap(), customeRuleMap);
if(StringUtils.isNotBlank(nuBaseInfo.getOrgCode())){
queryWrapper.eq("sys_org_code",nuBaseInfo.getOrgCode());
}
Page<NuBaseInfo> page = new Page<NuBaseInfo>(pageNo, pageSize);
IPage<NuBaseInfo> pageList = nuBaseInfoService.page(page, queryWrapper);
return pageList;
}
// /**
// * 添加
// *
// * @param nuBaseInfo
// * @return
// */
// @AutoLog(value = "护理单元-添加")
// @ApiOperation(value = "护理单元-添加", notes = "护理单元-添加")
// @RequiresPermissions("nuBaseInfo:nu_base_info:add")
// @PostMapping(value = "/add")
// public Result<String> add(@RequestBody NuBaseInfo nuBaseInfo) {
// service.setNuId(nuBaseInfo);
// nuBaseInfoService.save(nuBaseInfo);
// return Result.OK("添加成功!");
// }
/**
* 添加
*
* @param nuBaseInfo
* @return
*/
@AutoLog(value = "护理单元-同步")
@ApiOperation(value = "护理单元-同步", notes = "护理单元-同步")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody NuBaseInfo nuBaseInfo) {
NuBaseInfoMQDto bi = new NuBaseInfoMQDto();
BeanUtils.copyProperties(nuBaseInfo,bi);
String queue = nuBaseInfo.getOrgCode() + ".hldy.async";
if (StringUtils.isNotBlank(queue)) {
//先在数据同步表中插入数据
AsyncMain asyncMain = new AsyncMain();
asyncMain.setType("nuBaseInfo");
asyncMain.setOrgCode(nuBaseInfo.getOrgCode());
asyncMain.setDescr("护理单元同步");
asyncMainService.save(asyncMain);
bi.setAsyncId(asyncMain.getId());
AsyncStatus asyncStatus_data = new AsyncStatus();
asyncStatus_data.setPkid(asyncMain.getId());
asyncStatus_data.setCode("data");
asyncStatus_data.setName("数据");
asyncStatus_data.setStatus(MQStatus.LOADING.getCode() + "");
asyncStatus_data.setMsg("同步中");
asyncStatusService.save(asyncStatus_data);
//通过mq通知业务系统同步数据
rabbitMQUtil.sendToExchange("hldy.hldy.sync", queue, bi);
} else {
return Result.error("机构未配置MQ映射关系需先在数据字典(mq_org_queue)中添加相应对应数据!");
}
return Result.ok("");
}
}

View File

@ -0,0 +1,83 @@
package com.nu.modules.nuBaseInfo.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
/**
* @Description: 护理单元
* @Author: jeecg-boot
* @Date: 2025-04-11
* @Version: V1.0
*/
@Data
@TableName("nu_base_info")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@ApiModel(value="nu_base_info对象", description="护理单元")
public class NuBaseInfo 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 nuName;
/**护理单元编码*/
@Excel(name = "护理单元编码", width = 15)
@ApiModelProperty(value = "护理单元编码")
private java.lang.String nuId;
/**区域标签ID*/
@Excel(name = "区域标签ID", width = 15, dicCode = "nu_type")
@Dict(dicCode = "nu_type")
@ApiModelProperty(value = "区域标签ID")
private java.lang.String areaFlag;
/**使用状态 0未使用 1占用 2入住 3退住 4留床*/
@Excel(name = "使用状态 0未使用 1占用 2入住 3退住 4留床", width = 15, dicCode = "nu_status")
@Dict(dicCode = "nu_status")
@ApiModelProperty(value = "使用状态 0未使用 1占用 2入住 3退住 4留床")
private java.lang.String status;
/**客户*/
@Excel(name = "客户", width = 15)
@ApiModelProperty(value = "客户")
private java.lang.String customerId;
/**是否删除 0未删除 1删除*/
@Excel(name = "是否删除 0未删除 1删除", width = 15)
@ApiModelProperty(value = "是否删除 0未删除 1删除")
@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;
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private java.lang.String sysOrgCode;
@TableField(exist = false)
private String orgCode;
}

View File

@ -0,0 +1,19 @@
package com.nu.modules.nuBaseInfo.mapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;
import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 护理单元
* @Author: jeecg-boot
* @Date: 2025-04-11
* @Version: V1.0
*/
public interface NuBaseInfoMapper extends BaseMapper<NuBaseInfo> {
String getNuId();
}

View File

@ -0,0 +1,10 @@
<?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.nuBaseInfo.mapper.NuBaseInfoMapper">
<select id="getNuId" resultType="java.lang.String">
SELECT MAX(nu_id) AS max_number
FROM nu_base_info
WHERE RIGHT(nu_id, 3) REGEXP '^[0-9]{3}$'
</select>
</mapper>

View File

@ -0,0 +1,15 @@
package com.nu.modules.nuBaseInfo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
/**
* @Description: 护理单元
* @Author: jeecg-boot
* @Date: 2025-04-11
* @Version: V1.0
*/
public interface INuBaseInfoService extends IService<NuBaseInfo> {
void setNuId(NuBaseInfo nuBaseInfo);
}

View File

@ -0,0 +1,50 @@
package com.nu.modules.nuBaseInfo.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
import com.nu.modules.nuBaseInfo.mapper.NuBaseInfoMapper;
import com.nu.modules.nuBaseInfo.service.INuBaseInfoService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
/**
* @Description: 护理单元
* @Author: jeecg-boot
* @Date: 2025-04-11
* @Version: V1.0
*/
@Service
public class NuBaseInfoServiceImpl extends ServiceImpl<NuBaseInfoMapper, NuBaseInfo> implements INuBaseInfoService {
@Override
public void setNuId(NuBaseInfo nuBaseInfo) {
String orgCode = nuBaseInfo.getOrgCode();
if (StringUtils.isBlank(orgCode)) {
throw new RuntimeException("请先在部门管理中设置机构编码!");
}
try {
String nuId = baseMapper.getNuId();
if (nuId == null) {
// 年月 + 机构编码 + 001
nuBaseInfo.setNuId(LocalDate.now().format(DateTimeFormatter.ofPattern("yyMM")) + orgCode + "001");
} else {
// 取最后3位
String last3Digits = nuId.substring(nuId.length() - 3);
// 转为整数并加1
int nextNum = Integer.parseInt(last3Digits) + 1;
// 格式化为3位数字不足补零
String formattedNum = String.format("%03d", nextNum);
// 设置新的nuId
nuBaseInfo.setNuId(LocalDate.now().format(DateTimeFormatter.ofPattern("yyMM")) + orgCode + formattedNum);
}
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("护理单元添加失败,请联系管理员进行处理!");
}
}
}

View File

@ -0,0 +1,28 @@
package com.nu.mq.nubaseinfo.exceptionhandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.AmqpRejectAndDontRequeueException;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.listener.api.RabbitListenerErrorHandler;
import org.springframework.amqp.rabbit.support.ListenerExecutionFailedException;
import org.springframework.stereotype.Component;
@Slf4j
@Component("nuBaseInfoMQErrorHandler")
public class NuBaseInfoMQExceptionHandler implements RabbitListenerErrorHandler {
@Override
public Object handleError(Message message, org.springframework.messaging.Message<?> message1, ListenerExecutionFailedException e) {
log.error("MQ消息处理失败 | 消息体: {} | 异常原因: {}", new String(message.getBody()), e.getCause().getMessage());
// 根据异常类型选择处理策略
// if (isRetryable(e)) {
// // 可重试异常抛出异常触发重试
// throw e;
// } else {
// 不可恢复异常拒绝消息且不重新入队
throw new AmqpRejectAndDontRequeueException("消息处理失败且禁止重试", e);
// }
}
}

View File

@ -0,0 +1,45 @@
package com.nu.mq.nubaseinfo.listener;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.nu.dto.StatusMQDto;
import com.nu.enums.MQStatus;
import com.nu.modules.async.entity.AsyncStatus;
import com.nu.modules.async.service.IAsyncStatusService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@Slf4j
@Component
public class NuBaseInfoMQListener {
@Autowired
private IAsyncStatusService asyncStatusService;
@RabbitListener(
bindings = @QueueBinding(
value = @Queue(name = "hldy.async.result"),
exchange = @Exchange(name = "hldy.hldy", type = ExchangeTypes.DIRECT),
key = "hldy.async.result"
),
errorHandler = "nuBaseInfoMQErrorHandler"
)
public void handleNuBaseInfoSyncMessageStatus(StatusMQDto dto) {
LambdaQueryWrapper<AsyncStatus> qw = new LambdaQueryWrapper<>();
qw.eq(AsyncStatus::getPkid, dto.getPrimaryKey());
AsyncStatus asyncStatus = asyncStatusService.getOne(qw);
if (dto.getStatus() == MQStatus.SUCCESS.getCode()) {
asyncStatus.setStatus(dto.getStatus() + "");
} else {
asyncStatus.setStatus("500");
}
asyncStatus.setMsg(dto.getMessage());
asyncStatusService.updateById(asyncStatus);
}
}

View File

@ -0,0 +1,52 @@
package com.nu.dto;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
/**
* @Description: 护理单元
* @Author: jeecg-boot
* @Date: 2025-04-11
* @Version: V1.0
*/
@Data
public class NuBaseInfoMQDto implements Serializable {
private static final long serialVersionUID = 1L;
/**ID*/
private String id;
/**护理单元名称*/
private String nuName;
/**护理单元编码*/
private String nuId;
/**区域标签ID*/
private String areaFlag;
/**使用状态 0未使用 1占用 2入住 3退住 4留床*/
private String status;
/**客户*/
private String customerId;
/**是否删除 0未删除 1删除*/
private String delFlag;
/**创建人*/
private String createBy;
/**创建日期*/
private java.util.Date createTime;
/**更新人*/
private String updateBy;
/**更新日期*/
private java.util.Date updateTime;
/**所属部门*/
private String sysOrgCode;
private String orgCode;
private String asyncId;
}

View File

@ -366,8 +366,10 @@ justauth:
#zmy
aliyun:
ocr:
accessKeyId: LTAI5tMoCTt4sb9VQrcnZFsb
accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
accessKeyId: LTAI5tJxmaqyXSG1T8Q6PSE9
accessKeySecret: baBJyQOvph6dVugiSnx3tsiEuJeMy3
# accessKeyId: LTAI5tMoCTt4sb9VQrcnZFsb
# accessKeySecret: pQBMT6TlUWgRfvvDnOu0IKVYXCfKee
#文件传输秘钥
downloadkey: hP2K9Z!WLuj"M#8,