服务指令同步
This commit is contained in:
parent
af7b492bf8
commit
8156dc5355
|
@ -15,7 +15,7 @@ public class NuBizAdvisoryInfoListener {
|
|||
@Autowired
|
||||
private INuBizAdvisoryInfoService nuBizAdvisoryInfoService;
|
||||
@RabbitListener(queues = "register.addData", errorHandler = "AdvisoryMQExceptionHandler")
|
||||
public void handleMessage(NuBizAdvisoryInfoDto dto) {
|
||||
public void registerAddMessage(NuBizAdvisoryInfoDto dto) {
|
||||
try {
|
||||
System.out.println(111);
|
||||
NuBizAdvisoryInfo nuBizAdvisoryInfo = new NuBizAdvisoryInfo();
|
||||
|
@ -25,4 +25,16 @@ public class NuBizAdvisoryInfoListener {
|
|||
System.out.println("异常了:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@RabbitListener(queues = "register.editData", errorHandler = "AdvisoryMQExceptionHandler")
|
||||
public void registerEditMessage(NuBizAdvisoryInfoDto dto) {
|
||||
try {
|
||||
NuBizAdvisoryInfo nuBizAdvisoryInfo = new NuBizAdvisoryInfo();
|
||||
BeanUtils.copyProperties(dto,nuBizAdvisoryInfo);
|
||||
nuBizAdvisoryInfoService.updateById(nuBizAdvisoryInfo);
|
||||
} catch (Exception e) {
|
||||
System.out.println("异常了:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,15 @@ public class RabbitMQConfig {
|
|||
return new Queue("register.addData", true);
|
||||
}
|
||||
@Bean
|
||||
public Binding binding5(Queue registerAddQueue, DirectExchange registerExchange) {
|
||||
public Binding bindingRegAdd(Queue registerAddQueue, DirectExchange registerExchange) {
|
||||
return BindingBuilder.bind(registerAddQueue).to(registerExchange).with("register.addData");
|
||||
}
|
||||
@Bean
|
||||
public Queue registerEditQueue() {
|
||||
return new Queue("register.editData", true);
|
||||
}
|
||||
@Bean
|
||||
public Binding bindingRegEdit(Queue registerEditQueue, DirectExchange registerExchange) {
|
||||
return BindingBuilder.bind(registerEditQueue).to(registerExchange).with("register.editData");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,4 +10,9 @@ public class DirectiveMQDto {
|
|||
private String orgCode;//机构编码
|
||||
private String idStr;
|
||||
private List<String> idList;
|
||||
|
||||
//同步主表id
|
||||
private String asyncId;
|
||||
//同步子表code
|
||||
private String code;
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@ import java.io.Serializable;
|
|||
|
||||
/**
|
||||
* @Description: 咨询信息
|
||||
* @Author: jeecg-boot
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-04-07
|
||||
* @Version: V1.0
|
||||
*/
|
||||
|
|
|
@ -4,6 +4,13 @@ import lombok.Data;
|
|||
|
||||
@Data
|
||||
public class StatusMQDto {
|
||||
int status;
|
||||
String message;
|
||||
//同步状态 MQStatus枚举类
|
||||
private int status;
|
||||
//同步结果
|
||||
private String message;
|
||||
|
||||
//同步表主表id
|
||||
private String asyncId;
|
||||
//同步表子表code
|
||||
private String code;
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ public enum MQStatus {
|
|||
MESSAGE_FORMAT_ERROR(1002, "消息格式错误"),
|
||||
TIMEOUT(1003, "处理超时"),
|
||||
DUPLICATE_MESSAGE(1004, "消息重复消费"),
|
||||
UNKNOWN_ERROR(9999, "未知错误");
|
||||
UNKNOWN_ERROR(9999, "未知错误"),
|
||||
LOADING(100,"处理中");
|
||||
|
||||
private final int code;
|
||||
private final String message;
|
||||
|
|
|
@ -0,0 +1,171 @@
|
|||
package com.nu.modules.async.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
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 com.nu.modules.async.entity.AsyncMain;
|
||||
import com.nu.modules.async.service.IAsyncMainService;
|
||||
|
||||
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: 张明远
|
||||
* @Date: 2025-04-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags = "数据同步主表")
|
||||
@RestController
|
||||
@RequestMapping("/asyncmain/asyncMain")
|
||||
@Slf4j
|
||||
public class AsyncMainController extends JeecgController<AsyncMain, IAsyncMainService> {
|
||||
@Autowired
|
||||
private IAsyncMainService asyncMainService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param asyncMain
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "数据同步主表-分页列表查询")
|
||||
@ApiOperation(value = "数据同步主表-分页列表查询", notes = "数据同步主表-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<AsyncMain>> queryPageList(AsyncMain asyncMain,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<AsyncMain> queryWrapper = QueryGenerator.initQueryWrapper(asyncMain, req.getParameterMap());
|
||||
Page<AsyncMain> page = new Page<AsyncMain>(pageNo, pageSize);
|
||||
queryWrapper.select("id");
|
||||
IPage<AsyncMain> pageList = asyncMainService.page(page, queryWrapper);
|
||||
List<AsyncMain> records = pageList.getRecords();
|
||||
if (records != null && !records.isEmpty()) {
|
||||
records = asyncMainService.pageList(records);
|
||||
pageList.setRecords(records);
|
||||
}
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param asyncMain
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "数据同步主表-添加")
|
||||
@ApiOperation(value = "数据同步主表-添加", notes = "数据同步主表-添加")
|
||||
@RequiresPermissions("asyncmain:nu_async_main:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody AsyncMain asyncMain) {
|
||||
asyncMainService.save(asyncMain);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param asyncMain
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "数据同步主表-编辑")
|
||||
@ApiOperation(value = "数据同步主表-编辑", notes = "数据同步主表-编辑")
|
||||
@RequiresPermissions("asyncmain:nu_async_main:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody AsyncMain asyncMain) {
|
||||
asyncMainService.updateById(asyncMain);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "数据同步主表-通过id删除")
|
||||
@ApiOperation(value = "数据同步主表-通过id删除", notes = "数据同步主表-通过id删除")
|
||||
@RequiresPermissions("asyncmain:nu_async_main:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
|
||||
asyncMainService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "数据同步主表-批量删除")
|
||||
@ApiOperation(value = "数据同步主表-批量删除", notes = "数据同步主表-批量删除")
|
||||
@RequiresPermissions("asyncmain:nu_async_main:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
|
||||
this.asyncMainService.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<AsyncMain> queryById(@RequestParam(name = "id", required = true) String id) {
|
||||
AsyncMain asyncMain = asyncMainService.getById(id);
|
||||
if (asyncMain == null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(asyncMain);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param asyncMain
|
||||
*/
|
||||
@RequiresPermissions("asyncmain:nu_async_main:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, AsyncMain asyncMain) {
|
||||
return super.exportXls(request, asyncMain, AsyncMain.class, "数据同步主表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("asyncmain:nu_async_main:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, AsyncMain.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,161 @@
|
|||
package com.nu.modules.async.controller;
|
||||
|
||||
import java.util.Arrays;
|
||||
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 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: 张明远
|
||||
* @Date: 2025-04-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Api(tags="数据同步子表-状态记录表")
|
||||
@RestController
|
||||
@RequestMapping("/asyncstatus/asyncStatus")
|
||||
@Slf4j
|
||||
public class AsyncStatusController extends JeecgController<com.nu.modules.async.entity.AsyncStatus, com.nu.modules.async.service.IAsyncStatusService> {
|
||||
@Autowired
|
||||
private com.nu.modules.async.service.IAsyncStatusService asyncStatusService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
* @param asyncStatus
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param req
|
||||
* @return
|
||||
*/
|
||||
//@AutoLog(value = "数据同步子表-状态记录表-分页列表查询")
|
||||
@ApiOperation(value="数据同步子表-状态记录表-分页列表查询", notes="数据同步子表-状态记录表-分页列表查询")
|
||||
@GetMapping(value = "/list")
|
||||
public Result<IPage<com.nu.modules.async.entity.AsyncStatus>> queryPageList(com.nu.modules.async.entity.AsyncStatus asyncStatus,
|
||||
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<com.nu.modules.async.entity.AsyncStatus> queryWrapper = QueryGenerator.initQueryWrapper(asyncStatus, req.getParameterMap());
|
||||
Page<com.nu.modules.async.entity.AsyncStatus> page = new Page<com.nu.modules.async.entity.AsyncStatus>(pageNo, pageSize);
|
||||
IPage<com.nu.modules.async.entity.AsyncStatus> pageList = asyncStatusService.page(page, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*
|
||||
* @param asyncStatus
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "数据同步子表-状态记录表-添加")
|
||||
@ApiOperation(value="数据同步子表-状态记录表-添加", notes="数据同步子表-状态记录表-添加")
|
||||
@RequiresPermissions("asyncstatus:nu_async_status:add")
|
||||
@PostMapping(value = "/add")
|
||||
public Result<String> add(@RequestBody com.nu.modules.async.entity.AsyncStatus asyncStatus) {
|
||||
asyncStatusService.save(asyncStatus);
|
||||
return Result.OK("添加成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*
|
||||
* @param asyncStatus
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "数据同步子表-状态记录表-编辑")
|
||||
@ApiOperation(value="数据同步子表-状态记录表-编辑", notes="数据同步子表-状态记录表-编辑")
|
||||
@RequiresPermissions("asyncstatus:nu_async_status:edit")
|
||||
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
|
||||
public Result<String> edit(@RequestBody com.nu.modules.async.entity.AsyncStatus asyncStatus) {
|
||||
asyncStatusService.updateById(asyncStatus);
|
||||
return Result.OK("编辑成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "数据同步子表-状态记录表-通过id删除")
|
||||
@ApiOperation(value="数据同步子表-状态记录表-通过id删除", notes="数据同步子表-状态记录表-通过id删除")
|
||||
@RequiresPermissions("asyncstatus:nu_async_status:delete")
|
||||
@DeleteMapping(value = "/delete")
|
||||
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
|
||||
asyncStatusService.removeById(id);
|
||||
return Result.OK("删除成功!");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除
|
||||
*
|
||||
* @param ids
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "数据同步子表-状态记录表-批量删除")
|
||||
@ApiOperation(value="数据同步子表-状态记录表-批量删除", notes="数据同步子表-状态记录表-批量删除")
|
||||
@RequiresPermissions("asyncstatus:nu_async_status:deleteBatch")
|
||||
@DeleteMapping(value = "/deleteBatch")
|
||||
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
|
||||
this.asyncStatusService.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<com.nu.modules.async.entity.AsyncStatus> queryById(@RequestParam(name="id",required=true) String id) {
|
||||
com.nu.modules.async.entity.AsyncStatus asyncStatus = asyncStatusService.getById(id);
|
||||
if(asyncStatus==null) {
|
||||
return Result.error("未找到对应数据");
|
||||
}
|
||||
return Result.OK(asyncStatus);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel
|
||||
*
|
||||
* @param request
|
||||
* @param asyncStatus
|
||||
*/
|
||||
@RequiresPermissions("asyncstatus:nu_async_status:exportXls")
|
||||
@RequestMapping(value = "/exportXls")
|
||||
public ModelAndView exportXls(HttpServletRequest request, com.nu.modules.async.entity.AsyncStatus asyncStatus) {
|
||||
return super.exportXls(request, asyncStatus, com.nu.modules.async.entity.AsyncStatus.class, "数据同步子表-状态记录表");
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过excel导入数据
|
||||
*
|
||||
* @param request
|
||||
* @param response
|
||||
* @return
|
||||
*/
|
||||
@RequiresPermissions("asyncstatus:nu_async_status:importExcel")
|
||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||
return super.importExcel(request, response, com.nu.modules.async.entity.AsyncStatus.class);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,62 @@
|
|||
package com.nu.modules.async.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.jeecg.common.aspect.annotation.Dict;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 数据同步主表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-04-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_async_main")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_async_main对象", description="数据同步主表")
|
||||
public class AsyncMain 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 orgCode;
|
||||
/**类型(同步的是什么类型的数据)*/
|
||||
@Excel(name = "类型(同步的是什么类型的数据)", width = 15)
|
||||
@ApiModelProperty(value = "类型(同步的是什么类型的数据)")
|
||||
private java.lang.String type;
|
||||
/**备注/描述*/
|
||||
@Excel(name = "备注/描述", width = 15)
|
||||
@ApiModelProperty(value = "备注/描述")
|
||||
private java.lang.String descr;
|
||||
/**创建人*/
|
||||
@ApiModelProperty(value = "创建人")
|
||||
@Dict(dictTable = "sys_user",dicCode = "username",dicText = "realname")
|
||||
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;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<AsyncStatus> asyncStatusList;
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package com.nu.modules.async.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
|
||||
/**
|
||||
* @Description: 数据同步子表-状态记录表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-04-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Data
|
||||
@TableName("nu_async_status")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@ApiModel(value="nu_async_status对象", description="数据同步子表-状态记录表")
|
||||
public class AsyncStatus 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 code;
|
||||
/**同步内容*/
|
||||
@Excel(name = "同步内容", width = 15)
|
||||
@ApiModelProperty(value = "同步内容")
|
||||
private java.lang.String name;
|
||||
/**主表id*/
|
||||
@Excel(name = "主表id", width = 15)
|
||||
@ApiModelProperty(value = "主表id")
|
||||
private java.lang.String pkid;
|
||||
/**状态*/
|
||||
@Excel(name = "状态", width = 15)
|
||||
@ApiModelProperty(value = "状态")
|
||||
private java.lang.String status;
|
||||
/**结果*/
|
||||
@Excel(name = "结果", width = 15)
|
||||
@ApiModelProperty(value = "结果")
|
||||
private java.lang.String msg;
|
||||
/**更新日期*/
|
||||
@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;
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
package com.nu.modules.async.mapper;
|
||||
|
||||
import com.nu.modules.async.entity.AsyncMain;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 数据同步主表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-04-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface AsyncMainMapper extends BaseMapper<AsyncMain> {
|
||||
|
||||
List<AsyncMain> pageList(@Param("pojo") List<AsyncMain> records);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.nu.modules.async.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* @Description: 数据同步子表-状态记录表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-04-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface AsyncStatusMapper extends BaseMapper<com.nu.modules.async.entity.AsyncStatus> {
|
||||
|
||||
}
|
|
@ -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.async.mapper.AsyncMainMapper">
|
||||
|
||||
<resultMap id="asyncResultMap" type="com.nu.modules.async.entity.AsyncMain">
|
||||
<id property="id" column="id"/>
|
||||
<result property="orgCode" column="orgCode"/>
|
||||
<result property="type" column="type"/>
|
||||
<result property="descr" column="descr"/>
|
||||
<result property="createBy" column="createBy"/>
|
||||
<result property="createTime" column="createTime"/>
|
||||
<collection property="asyncStatusList" ofType="com.nu.modules.async.entity.AsyncStatus">
|
||||
<id property="id" column="zid"/>
|
||||
<result property="code" column="zcode"/>
|
||||
<result property="name" column="zname"/>
|
||||
<result property="status" column="zstatus"/>
|
||||
<result property="msg" column="zmsg"/>
|
||||
<result property="updateTime" column="zupdataTime"/>
|
||||
</collection>
|
||||
</resultMap>
|
||||
|
||||
<select id="pageList" resultMap="asyncResultMap">
|
||||
select
|
||||
f.id as id,
|
||||
f.org_code as orgCode,
|
||||
f.type as type,
|
||||
f.descr as descr,
|
||||
f.create_by as createBy,
|
||||
f.create_time as createTime,
|
||||
z.id as zid,
|
||||
z.code as zcode,
|
||||
z.name as zname,
|
||||
z.status as zstatus,
|
||||
z.msg as zmsg,
|
||||
z.update_time as zupdataTime
|
||||
from nu_async_main f
|
||||
left join nu_async_status z on f.id = z.pkid
|
||||
<where>
|
||||
f.id in
|
||||
<foreach collection="pojo" item="am" separator="," open="(" close=")">
|
||||
#{am.id}
|
||||
</foreach>
|
||||
</where>
|
||||
order by f.create_time desc,z.update_time desc
|
||||
</select>
|
||||
</mapper>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.nu.modules.async.mapper.AsyncStatusMapper">
|
||||
|
||||
</mapper>
|
|
@ -0,0 +1,17 @@
|
|||
package com.nu.modules.async.service;
|
||||
|
||||
import com.nu.modules.async.entity.AsyncMain;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 数据同步主表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-04-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IAsyncMainService extends IService<AsyncMain> {
|
||||
|
||||
List<AsyncMain> pageList(List<AsyncMain> records);
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package com.nu.modules.async.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* @Description: 数据同步子表-状态记录表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-04-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
public interface IAsyncStatusService extends IService<com.nu.modules.async.entity.AsyncStatus> {
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package com.nu.modules.async.service.impl;
|
||||
|
||||
import com.nu.modules.async.entity.AsyncMain;
|
||||
import com.nu.modules.async.mapper.AsyncMainMapper;
|
||||
import com.nu.modules.async.service.IAsyncMainService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Description: 数据同步主表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-04-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class AsyncMainServiceImpl extends ServiceImpl<AsyncMainMapper, AsyncMain> implements IAsyncMainService {
|
||||
|
||||
@Override
|
||||
public List<AsyncMain> pageList(List<AsyncMain> records) {
|
||||
return baseMapper.pageList(records);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package com.nu.modules.async.service.impl;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
|
||||
/**
|
||||
* @Description: 数据同步子表-状态记录表
|
||||
* @Author: 张明远
|
||||
* @Date: 2025-04-23
|
||||
* @Version: V1.0
|
||||
*/
|
||||
@Service
|
||||
public class AsyncStatusServiceImpl extends ServiceImpl<com.nu.modules.async.mapper.AsyncStatusMapper, com.nu.modules.async.entity.AsyncStatus> implements com.nu.modules.async.service.IAsyncStatusService {
|
||||
|
||||
}
|
|
@ -5,6 +5,11 @@ 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.DirectiveMQDto;
|
||||
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.servicedirective.entity.ConfigServiceDirective;
|
||||
import com.nu.modules.servicedirective.service.IConfigServiceDirectiveService;
|
||||
import com.nu.utils.RabbitMQUtil;
|
||||
|
@ -14,6 +19,7 @@ import lombok.extern.slf4j.Slf4j;
|
|||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.checkerframework.checker.units.qual.A;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.api.ISysBaseAPI;
|
||||
|
@ -50,6 +56,10 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
private RabbitMQUtil rabbitMQUtil;
|
||||
@Autowired
|
||||
private ISysBaseAPI sysBaseAPI;
|
||||
@Autowired
|
||||
private IAsyncMainService asyncMainService;
|
||||
@Autowired
|
||||
private IAsyncStatusService asyncStatusService;
|
||||
|
||||
/**
|
||||
* 分页列表查询
|
||||
|
@ -84,6 +94,19 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
customeRuleMap.put("cycleType", QueryRuleEnum.LIKE_WITH_OR);
|
||||
customeRuleMap.put("izEnabled", QueryRuleEnum.LIKE_WITH_OR);
|
||||
QueryWrapper<ConfigServiceDirective> queryWrapper = QueryGenerator.initQueryWrapper(configServiceDirective, req.getParameterMap(), customeRuleMap);
|
||||
//指令同步 - 筛选已选择/未选择
|
||||
if ("selected".equals(configServiceDirective.getViewType())) {
|
||||
if(configServiceDirective.getSelectedRowIds()!=null && !configServiceDirective.getSelectedRowIds().isEmpty()){
|
||||
queryWrapper.in("id",configServiceDirective.getSelectedRowIds());
|
||||
}else{
|
||||
queryWrapper.eq("id","--!--!--!--");
|
||||
}
|
||||
}
|
||||
if ("unselected".equals(configServiceDirective.getViewType())) {
|
||||
if(configServiceDirective.getSelectedRowIds()!=null && !configServiceDirective.getSelectedRowIds().isEmpty()){
|
||||
queryWrapper.notIn("id",configServiceDirective.getSelectedRowIds());
|
||||
}
|
||||
}
|
||||
queryWrapper.select("id");
|
||||
//如果有服务指令需要提前查询下对应的服务指令id
|
||||
List<ConfigServiceDirective> directiveIds = null;
|
||||
|
@ -115,8 +138,33 @@ public class ConfigServiceDirectiveController extends JeecgController<ConfigServ
|
|||
List<DictModel> dicts = sysBaseAPI.getDictItems("mq_org_queue");
|
||||
String queue = dicts.stream().filter(d -> d.getValue().equals(dto.getOrgCode())).findFirst().map(DictModel::getText).orElse(null);
|
||||
if (StringUtils.isNotBlank(queue)) {
|
||||
//先在数据同步表中插入数据
|
||||
AsyncMain asyncMain = new AsyncMain();
|
||||
asyncMain.setType("directive");
|
||||
asyncMain.setOrgCode(dto.getOrgCode());
|
||||
asyncMain.setDescr("服务指令同步:" + (dto.isIzInc() ? "增量同步" : "全量同步"));
|
||||
asyncMainService.save(asyncMain);
|
||||
dto.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);
|
||||
|
||||
AsyncStatus asyncStatus_file = new AsyncStatus();
|
||||
asyncStatus_file.setPkid(asyncMain.getId());
|
||||
asyncStatus_file.setCode("file");
|
||||
asyncStatus_file.setName("文件");
|
||||
asyncStatus_file.setStatus(MQStatus.LOADING.getCode() + "");
|
||||
asyncStatus_file.setMsg("同步中");
|
||||
asyncStatusService.save(asyncStatus_file);
|
||||
|
||||
//通过mq通知业务系统同步数据
|
||||
rabbitMQUtil.sendToExchange("hldy.fwzl", queue, dto);
|
||||
}else{
|
||||
} else {
|
||||
return Result.error("机构未配置MQ映射关系,需先在数据字典(mq_org_queue)中添加相应对应数据!");
|
||||
}
|
||||
return Result.ok("");
|
||||
|
|
|
@ -148,7 +148,13 @@ public class ConfigServiceDirective implements Serializable {
|
|||
//服务指令标签
|
||||
@TableField(exist = false)
|
||||
List<DirectiveTag> tagList;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String orgCode;
|
||||
|
||||
//如果是selected/unselecte 需要查询所有id in selectedRowIds的数据 / not in selectedRowIds的数据
|
||||
@TableField(exist = false)
|
||||
private String viewType;
|
||||
@TableField(exist = false)
|
||||
private List<String> selectedRowIds;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +1,50 @@
|
|||
package com.nu.mq.directive.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.AsyncMain;
|
||||
import com.nu.modules.async.entity.AsyncStatus;
|
||||
import com.nu.modules.async.service.IAsyncMainService;
|
||||
import com.nu.modules.async.service.IAsyncStatusService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.compress.utils.Lists;
|
||||
import org.springframework.amqp.rabbit.annotation.RabbitListener;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
@Component
|
||||
public class DirectiveMQListener {
|
||||
|
||||
@Autowired
|
||||
private IAsyncMainService asyncMainService;
|
||||
@Autowired
|
||||
private IAsyncStatusService asyncStatusService;
|
||||
|
||||
@RabbitListener(queues = "nu001.fwzl.status", errorHandler = "directiveMQErrorHandler")
|
||||
public void handleMessage(StatusMQDto dto) {
|
||||
public void handleNu001AsyncMessageStatus(StatusMQDto dto) {
|
||||
try {
|
||||
System.out.println("接收到了消息:" + dto.getStatus() + "消息体:" + dto.getMessage());
|
||||
} catch (Exception e) {
|
||||
System.out.println("异常了:" + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@RabbitListener(queues = "nu002.fwzl.status", errorHandler = "directiveMQErrorHandler")
|
||||
public void handleNu002AsyncMessageStatus(StatusMQDto dto) {
|
||||
LambdaQueryWrapper<AsyncStatus> qw = new LambdaQueryWrapper<>();
|
||||
qw.eq(AsyncStatus::getPkid, dto.getAsyncId());
|
||||
qw.eq(AsyncStatus::getCode, dto.getCode());
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue