护理单元同步

This commit is contained in:
1378012178@qq.com 2025-06-25 09:03:02 +08:00
parent 707bbf25ed
commit 30aaa37e29
10 changed files with 202 additions and 58 deletions

View File

@ -11,6 +11,7 @@ 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.NuBaseBatchAddDto;
import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
import com.nu.modules.nuBaseInfo.service.INuBaseInfoService;
import com.nu.utils.RabbitMQUtil;
@ -29,7 +30,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
@ -100,26 +103,42 @@ public class NuBaseInfoController extends JeecgController<NuBaseInfo, INuBaseInf
if(StringUtils.isNotBlank(nuBaseInfo.getOrgCode())){
queryWrapper.eq("sys_org_code",nuBaseInfo.getOrgCode());
}
queryWrapper.orderByDesc("nu_id + 0");
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) {
service.setNuId(nuBaseInfo);
nuBaseInfo.setNuName(nuBaseInfo.getNuId());
nuBaseInfo.setSysOrgCode(nuBaseInfo.getOrgCode());
nuBaseInfoService.save(nuBaseInfo);
return Result.OK("添加成功!");
}
/**
* 编辑
*
* @param nuBaseInfo
* @return
*/
@AutoLog(value = "护理单元-编辑")
@ApiOperation(value = "护理单元-编辑", notes = "护理单元-编辑")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody NuBaseInfo nuBaseInfo) {
nuBaseInfoService.updateById(nuBaseInfo);
return Result.OK("编辑成功!");
}
/**
* 添加
@ -129,16 +148,14 @@ public class NuBaseInfoController extends JeecgController<NuBaseInfo, INuBaseInf
*/
@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";
@PostMapping(value = "/sync")
public Result<String> sync(@RequestBody NuBaseInfoMQDto bi) {
String queue = bi.getOrgCode() + ".hldy.async";
if (StringUtils.isNotBlank(queue)) {
//先在数据同步表中插入数据
AsyncMain asyncMain = new AsyncMain();
asyncMain.setType("nuBaseInfo");
asyncMain.setOrgCode(nuBaseInfo.getOrgCode());
asyncMain.setOrgCode(bi.getOrgCode());
asyncMain.setDescr("护理单元同步");
asyncMainService.save(asyncMain);
bi.setAsyncId(asyncMain.getId());
@ -159,4 +176,43 @@ public class NuBaseInfoController extends JeecgController<NuBaseInfo, INuBaseInf
}
return Result.ok("");
}
/**
* 通过id删除
*
* @param id
* @return
*/
@AutoLog(value = "护理单元-通过id删除")
@ApiOperation(value = "护理单元-通过id删除", notes = "护理单元-通过id删除")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
nuBaseInfoService.del(id);
return Result.OK("删除成功!");
}
/**
* 批量删除
*
* @param ids
* @return
*/
@AutoLog(value = "护理单元-批量删除")
@ApiOperation(value = "护理单元-批量删除", notes = "护理单元-批量删除")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
nuBaseInfoService.batchDel(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* 批量新增
* @param batchAddDto
* @return
*/
@PostMapping("/batchAdd")
public Result<String> batchAdd(@RequestBody NuBaseInfo nuBaseInfo){
nuBaseInfoService.batchAdd(nuBaseInfo);
return Result.ok("新增成功!");
}
}

View File

@ -0,0 +1,24 @@
package com.nu.modules.nuBaseInfo.entity;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
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年6月24日10:26:58
* @Version: V1.0
*/
@Data
public class NuBaseBatchAddDto implements Serializable {
private String type;//区域类型
private Integer num;//数量
}

View File

@ -12,6 +12,7 @@ import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.List;
/**
* @Description: 护理单元
@ -77,7 +78,12 @@ public class NuBaseInfo implements Serializable {
/**所属部门*/
@ApiModelProperty(value = "所属部门")
private java.lang.String sysOrgCode;
/**是否已同步0已同步 1未同步*/
@ApiModelProperty(value = "是否已同步0已同步 1未同步")
private java.lang.String izSync;
@TableField(exist = false)
private String orgCode;
@TableField(exist = false)
private List<NuBaseBatchAddDto> batchAddList;
}

View File

@ -9,11 +9,15 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 护理单元
* @Author: jeecg-boot
* @Date: 2025-04-11
* @Date: 2025-04-11
* @Version: V1.0
*/
public interface NuBaseInfoMapper extends BaseMapper<NuBaseInfo> {
String getNuId();
String getNuId(@Param("orgCode") String orgCode);
int del(@Param("id") String id);
int batchDel(@Param("ids") List<String> ids);
}

View File

@ -5,6 +5,19 @@
<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}$'
WHERE RIGHT(nu_id, 3) REGEXP '^[0-9]{3}$' and sys_org_code = ${orgCode}
</select>
<delete id="del">
DELETE FROM nu_base_info
WHERE id = #{id}
</delete>
<delete id="batchDel">
DELETE FROM nu_base_info
WHERE id IN
<foreach collection="ids" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper>

View File

@ -2,6 +2,9 @@ package com.nu.modules.nuBaseInfo.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* @Description: 护理单元
@ -12,4 +15,12 @@ import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
public interface INuBaseInfoService extends IService<NuBaseInfo> {
void setNuId(NuBaseInfo nuBaseInfo);
int del(@Param("id") String id);
int batchDel(@Param("ids") List<String> ids);
int batchAdd(NuBaseInfo nuBaseInfo);
void upIzSyncByIds(String ids);
}

View File

@ -1,6 +1,8 @@
package com.nu.modules.nuBaseInfo.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.nu.modules.nuBaseInfo.entity.NuBaseBatchAddDto;
import com.nu.modules.nuBaseInfo.entity.NuBaseInfo;
import com.nu.modules.nuBaseInfo.mapper.NuBaseInfoMapper;
import com.nu.modules.nuBaseInfo.service.INuBaseInfoService;
@ -11,6 +13,7 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.List;
/**
* @Description: 护理单元
@ -28,7 +31,7 @@ public class NuBaseInfoServiceImpl extends ServiceImpl<NuBaseInfoMapper, NuBaseI
throw new RuntimeException("请先在部门管理中设置机构编码!");
}
try {
String nuId = baseMapper.getNuId();
String nuId = baseMapper.getNuId(orgCode);
if (nuId == null) {
// 年月 + 机构编码 + 001
nuBaseInfo.setNuId(LocalDate.now().format(DateTimeFormatter.ofPattern("yyMM")) + orgCode + "001");
@ -47,4 +50,51 @@ public class NuBaseInfoServiceImpl extends ServiceImpl<NuBaseInfoMapper, NuBaseI
throw new RuntimeException("护理单元添加失败,请联系管理员进行处理!");
}
}
@Override
public int del(String id) {
return baseMapper.del(id);
}
@Override
public int batchDel(List<String> ids) {
return baseMapper.batchDel(ids);
}
@Override
public int batchAdd(NuBaseInfo nuBaseInfo) {
List<NuBaseBatchAddDto> list = nuBaseInfo.getBatchAddList();
boolean needAdd = false;
for (int i = 0; i < list.size(); i++) {
if(list.get(i).getNum() != null && list.get(i).getNum()!=0){
needAdd = true;
String areaFlag = list.get(i).getType();//区域标签
Integer num = list.get(i).getNum();//需创建个数
for (int j = 0; j < num; j++) {
NuBaseInfo bf = new NuBaseInfo();
bf.setOrgCode(nuBaseInfo.getOrgCode());
setNuId(bf);
bf.setNuName(bf.getNuId());
bf.setSysOrgCode(nuBaseInfo.getOrgCode());
bf.setStatus("0");
bf.setAreaFlag(areaFlag);
baseMapper.insert(bf);
}
}
}
if(!needAdd){
throw new RuntimeException("请正确填写数值!");
}
return 0;
}
@Override
public void upIzSyncByIds(String ids) {
QueryWrapper<NuBaseInfo> qw = new QueryWrapper<>();
qw.in("id",ids.split(","));
NuBaseInfo nuBaseInfo = new NuBaseInfo();
nuBaseInfo.setIzSync("0");
baseMapper.update(nuBaseInfo,qw);
}
}

View File

@ -1,11 +1,15 @@
package com.nu.mq.nubaseinfo.listener;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ArrayUtil;
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 com.nu.modules.nuBaseInfo.service.INuBaseInfoService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
@ -20,6 +24,8 @@ public class NuBaseInfoMQListener {
@Autowired
private IAsyncStatusService asyncStatusService;
@Autowired
private INuBaseInfoService baseInfoService;
@RabbitListener(
bindings = @QueueBinding(
@ -35,6 +41,11 @@ public class NuBaseInfoMQListener {
AsyncStatus asyncStatus = asyncStatusService.getOne(qw);
if (dto.getStatus() == MQStatus.SUCCESS.getCode()) {
asyncStatus.setStatus(dto.getStatus() + "");
//将对应id的iz_sync改为已同步
{
String ids = dto.getNote();
baseInfoService.upIzSyncByIds(ids);
}
} else {
asyncStatus.setStatus("500");
}

View File

@ -1,15 +1,6 @@
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;
@ -23,30 +14,6 @@ import java.io.Serializable;
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

@ -17,4 +17,6 @@ public class StatusMQDto {
private String primaryKey;
private String orgCode;
private String orgName;
//备注字段可存储个性化内容用于数据交互处理
private String note;
}