From ad5e361674ce48e3a9a97b98abad703c497d4d02 Mon Sep 17 00:00:00 2001 From: anthonywj Date: Sun, 25 Jun 2023 16:53:42 +0800 Subject: [PATCH] =?UTF-8?q?bug=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/config/rabbit/TopicRabbitConfig.java | 1 - .../sup/UserRegisterController.java | 26 +++++++----- .../api/controller/trace/TestController.java | 13 ++++-- .../trace/TraceRecordController.java | 11 ++++- .../glxp/api/dao/trace/TraceOrderMapper.java | 3 ++ .../req/trace/TraceOrderDetailRequest.java | 3 ++ .../api/res/trace/TraceOrderResponse.java | 20 +++++++++ .../api/res/trace/TraceSearchReponse.java | 2 +- .../api/service/trace/RabbitPushService.java | 7 +++- .../api/service/trace/TraceOrderService.java | 13 ++++++ .../api/service/trace/UdiTraceService.java | 11 +++++ src/main/resources/application-dev.yml | 4 +- src/main/resources/application.yml | 2 +- .../mybatis/mapper/trace/TraceOrderMapper.xml | 42 +++++++++++++++++++ 14 files changed, 135 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/glxp/api/config/rabbit/TopicRabbitConfig.java b/src/main/java/com/glxp/api/config/rabbit/TopicRabbitConfig.java index c297ae6..74688a2 100644 --- a/src/main/java/com/glxp/api/config/rabbit/TopicRabbitConfig.java +++ b/src/main/java/com/glxp/api/config/rabbit/TopicRabbitConfig.java @@ -13,7 +13,6 @@ public class TopicRabbitConfig { //绑定键 public final static String common = "topic.common"; - public final static String common1 = "topic.common1"; public final static String trace = "topic.trace"; public final static String publicer = "topic.all"; diff --git a/src/main/java/com/glxp/api/controller/sup/UserRegisterController.java b/src/main/java/com/glxp/api/controller/sup/UserRegisterController.java index ba3a044..dcd74a2 100644 --- a/src/main/java/com/glxp/api/controller/sup/UserRegisterController.java +++ b/src/main/java/com/glxp/api/controller/sup/UserRegisterController.java @@ -22,6 +22,8 @@ import com.glxp.api.res.PageSimpleResponse; import com.glxp.api.res.auth.registComPerResponse; import com.glxp.api.service.purchase.IEmailService; import com.glxp.api.service.sup.*; +import com.glxp.api.service.trace.RabbitPushService; +import com.glxp.api.service.trace.RabbitQueueService; import com.glxp.api.util.UuidUtils; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -71,13 +73,13 @@ public class UserRegisterController extends BaseController { @Resource private IEmailService iEmailService; - @ApiOperation(value = "获取校验码",response = loginmobileRequest.class) + @ApiOperation(value = "获取校验码", response = loginmobileRequest.class) @PostMapping("/admin/auth/register/getCheckcode") public BaseResponse getCheckcode(@RequestBody loginmobileRequest params, HttpSession httpSession) { return CaptchaUtils.getCheckcode(params, httpSession); } - @ApiOperation(value = "校验码",response = loginmobileRequest.class) + @ApiOperation(value = "校验码", response = loginmobileRequest.class) @PostMapping("/admin/auth/register/checkCode") public BaseResponse checkCode(@RequestBody loginmobileRequest params) { return CaptchaUtils.checkCode(params); @@ -88,7 +90,7 @@ public class UserRegisterController extends BaseController { * * @param mobile 手机号 */ - @ApiOperation(value = "根据手机号获取注册信息",response = BaseResponse.class) + @ApiOperation(value = "根据手机号获取注册信息", response = BaseResponse.class) @GetMapping("/admin/auth/register/get/{mobile}") public BaseResponse getInfo(@PathVariable String mobile) { Map map = new HashMap<>(); @@ -110,7 +112,7 @@ public class UserRegisterController extends BaseController { return ResultVOUtils.success(map); } - @ApiOperation(value = "保存注册人信息",response = BaseResponse.class) + @ApiOperation(value = "保存注册人信息", response = BaseResponse.class) @PostMapping("/admin/auth/register/save") public BaseResponse saveRegister(@RequestBody @Valid UserRegisterEntity userRegisterEntity, HttpSession httpSession, BindingResult bindingResult) { @@ -145,7 +147,7 @@ public class UserRegisterController extends BaseController { //第一次完善信息 插入默认数据 - @ApiOperation(value = "第一次完善信息 插入默认数据",response = BaseResponse.class) + @ApiOperation(value = "第一次完善信息 插入默认数据", response = BaseResponse.class) @GetMapping("/admin/auth/register/insertInitial") public BaseResponse insertInitial(String mobile) { Map map = new HashMap<>(); @@ -194,7 +196,7 @@ public class UserRegisterController extends BaseController { } - @ApiOperation(value = "保存所有信息",response = BaseResponse.class) + @ApiOperation(value = "保存所有信息", response = BaseResponse.class) @PostMapping("/admin/auth/register/saveAllInfo") public BaseResponse saveAllInfo(@RequestBody registComPerResponse registComPerResponse) { @@ -225,7 +227,7 @@ public class UserRegisterController extends BaseController { } - @ApiOperation(value = "查询注册人列表",response = registComPerResponse.class) + @ApiOperation(value = "查询注册人列表", response = registComPerResponse.class) @PostMapping("/admin/auth/register/list") public BaseResponse selectReslist(@RequestBody UserRegisterFilterRequest userRegisterFilterRequest, BindingResult bindingResult) { if (bindingResult.hasErrors()) { @@ -243,8 +245,10 @@ public class UserRegisterController extends BaseController { @Resource UserCompanyConfigService userCompanyConfigService; + @Resource + RabbitQueueService rabbitQueueService; - @ApiOperation(value = "无证明注册",response = BaseResponse.class) + @ApiOperation(value = "无证明注册", response = BaseResponse.class) @PostMapping("/admin/auth/register/NotApproved") public BaseResponse NotApproved(@RequestBody registComPerResponse registComPerResponse, BindingResult bindingResult) { if (bindingResult.hasErrors()) { @@ -307,8 +311,8 @@ public class UserRegisterController extends BaseController { userCompanyEntity.setId(Long.valueOf(registComPerResponse.getUcId())); userCompanyEntity.setCheckStatus(registComPerResponse.getCheckStatus()); userCompanyEntity.setReason(registComPerResponse.getReason()); - - + String queueName = "fanout_" + userCompanyEntity.getId() + ""; + rabbitQueueService.createQueue(queueName); userRegisterService.updateById(userRegisterEntity); userCompanyService.updateById(userCompanyEntity); userCheckService.insert(userCheckEntity); @@ -317,7 +321,7 @@ public class UserRegisterController extends BaseController { } //对手机 验证码进行加密/解密 - @ApiOperation(value = "对手机 验证码进行加密/解密",response = MobileCaptchaRequest.class) + @ApiOperation(value = "对手机 验证码进行加密/解密", response = MobileCaptchaRequest.class) @PostMapping("/admin/auth/register/encrypt") public BaseResponse encrypt(@RequestBody MobileCaptchaRequest mobileCaptchaRequest) { if (mobileCaptchaRequest == null) { diff --git a/src/main/java/com/glxp/api/controller/trace/TestController.java b/src/main/java/com/glxp/api/controller/trace/TestController.java index 9629c20..30ad54b 100644 --- a/src/main/java/com/glxp/api/controller/trace/TestController.java +++ b/src/main/java/com/glxp/api/controller/trace/TestController.java @@ -6,6 +6,7 @@ import com.glxp.api.common.res.BaseResponse; import com.glxp.api.common.util.ResultVOUtils; import com.glxp.api.config.rabbit.TopicRabbitConfig; import com.glxp.api.entity.trace.MqTraceMessage; +import com.glxp.api.service.trace.RabbitQueueService; import com.glxp.api.util.DateUtil; import com.glxp.api.util.udi.FilterUdiUtils; import io.swagger.annotations.Api; @@ -29,8 +30,9 @@ import java.util.Map; public class TestController { @Resource private final RabbitTemplate rabbitTemplate; + @Resource + RabbitQueueService rabbitQueueService; - @ApiOperation(value = "UDI码推送接口",response = BaseResponse.class) @GetMapping("/sendUdi") public BaseResponse sendUdi(String key) { String messageId = String.valueOf(UUID.randomUUID()); @@ -54,13 +56,11 @@ public class TestController { // return ResultVOUtils.success("发送成功"); // } - @ApiOperation(value = "Mq跟踪消息推送接口",response = BaseResponse.class) @GetMapping("/sendCommon") public BaseResponse sendCommon(@RequestBody MqTraceMessage mqTraceMessage) { String messageId = String.valueOf(UUID.randomUUID()); // MqTraceMessage mqTraceMessage = new MqTraceMessage(); System.out.println(mqTraceMessage); - mqTraceMessage.setMessageId(messageId); mqTraceMessage.setMessageData(String.valueOf(mqTraceMessage)); mqTraceMessage.setCreateTime(new Date()); @@ -70,7 +70,12 @@ public class TestController { } - + @GetMapping("/createCompanyQueue") + public BaseResponse createCompanyQueue(String companyId) { + String queueName = "fanout_" + companyId + ""; + rabbitQueueService.createQueue(queueName); + return ResultVOUtils.success("创建成功!"); + } } diff --git a/src/main/java/com/glxp/api/controller/trace/TraceRecordController.java b/src/main/java/com/glxp/api/controller/trace/TraceRecordController.java index aae97e6..e0d97fe 100644 --- a/src/main/java/com/glxp/api/controller/trace/TraceRecordController.java +++ b/src/main/java/com/glxp/api/controller/trace/TraceRecordController.java @@ -1,5 +1,6 @@ package com.glxp.api.controller.trace; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.fastjson2.JSON; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; @@ -12,8 +13,10 @@ import com.glxp.api.controller.BaseController; import com.glxp.api.entity.trace.TraceManuOrderEntity; import com.glxp.api.entity.trace.TraceOrderEntity; import com.glxp.api.entity.trace.TraceRecordLogEntity; +import com.glxp.api.req.trace.TraceOrderDetailRequest; import com.glxp.api.req.trace.TraceRecordRequest; import com.glxp.api.res.PageSimpleResponse; +import com.glxp.api.res.trace.TraceOrderResponse; import com.glxp.api.res.trace.TraceRecordResponse; import com.glxp.api.res.trace.TraceSearchReponse; import com.glxp.api.service.trace.TraceManuOrderService; @@ -23,6 +26,7 @@ import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import lombok.extern.slf4j.Slf4j; import org.apache.poi.ss.formula.functions.T; +import org.apache.regexp.RE; import org.bouncycastle.util.encoders.UTF8; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -68,7 +72,12 @@ public class TraceRecordController extends BaseController { if (StrUtil.isNotEmpty(traceRecordRequest.getRecordCode())) { TraceRecordLogEntity traceRecordLogEntity = traceRecordService.getOne(new QueryWrapper().eq("recordCode", traceRecordRequest.getRecordCode())); - List traceOrderEntities = traceOrderService.findByProductIdFk(traceRecordLogEntity.getTraceProductIdFk()); + if (traceRecordLogEntity == null) { + return ResultVOUtils.error(500, "查询记录不存在!"); + } + TraceOrderDetailRequest traceOrderDetailRequest = new TraceOrderDetailRequest(); + traceOrderDetailRequest.setTraceProductIdFk(traceRecordLogEntity.getTraceProductIdFk()); + List traceOrderEntities = traceOrderService.filterJoin(traceOrderDetailRequest); List traceManuOrderEntities = traceManuOrderService.list(new QueryWrapper().eq("traceProductIdFk", traceRecordLogEntity.getTraceProductIdFk())); TraceSearchReponse traceSearchReponse = new TraceSearchReponse(); traceSearchReponse.setTraceOrderEntities(traceOrderEntities); diff --git a/src/main/java/com/glxp/api/dao/trace/TraceOrderMapper.java b/src/main/java/com/glxp/api/dao/trace/TraceOrderMapper.java index 9512ffa..19514b2 100644 --- a/src/main/java/com/glxp/api/dao/trace/TraceOrderMapper.java +++ b/src/main/java/com/glxp/api/dao/trace/TraceOrderMapper.java @@ -19,4 +19,7 @@ public interface TraceOrderMapper extends BaseMapper { List queryTraceOrderList(TraceOrderDetailRequest traceOrderDetailRequest); List filterBatchNo(TraceProductRecordRequest traceProductRecordRequest); + + List filterJoin(TraceOrderDetailRequest traceOrderDetailRequest); + } diff --git a/src/main/java/com/glxp/api/req/trace/TraceOrderDetailRequest.java b/src/main/java/com/glxp/api/req/trace/TraceOrderDetailRequest.java index 3d4d235..f3641cc 100644 --- a/src/main/java/com/glxp/api/req/trace/TraceOrderDetailRequest.java +++ b/src/main/java/com/glxp/api/req/trace/TraceOrderDetailRequest.java @@ -22,4 +22,7 @@ public class TraceOrderDetailRequest extends ListPageRequest { private String batchNo; @ApiModelProperty(value = "公司名称") private String companyName; + + @ApiModelProperty(value = "查询产品记录ID表") + private Long traceProductIdFk; } diff --git a/src/main/java/com/glxp/api/res/trace/TraceOrderResponse.java b/src/main/java/com/glxp/api/res/trace/TraceOrderResponse.java index 9abf7ea..7cb58da 100644 --- a/src/main/java/com/glxp/api/res/trace/TraceOrderResponse.java +++ b/src/main/java/com/glxp/api/res/trace/TraceOrderResponse.java @@ -147,4 +147,24 @@ public class TraceOrderResponse { */ @ApiModelProperty(value = "更新时间") private Date updateTime; + + //关联信息 + @ApiModelProperty(value = "产品名称") + private String cpmctymc; + @ApiModelProperty(value = "DI标识") + private String nameCode; + @ApiModelProperty(value = "规格型号") + private String ggxh; + @ApiModelProperty(value = "医疗器械注册人") + private String ylqxzcrbarmc; + @ApiModelProperty(value = "批次号") + private String batchNo; + @ApiModelProperty(value = "生产日期") + private String produceDate; + @ApiModelProperty(value = "失效日期") + private String expireDate; + @ApiModelProperty(value = "序列号") + private String serialNo; + @ApiModelProperty(value = "查询UDI码") + private String udiCode; } diff --git a/src/main/java/com/glxp/api/res/trace/TraceSearchReponse.java b/src/main/java/com/glxp/api/res/trace/TraceSearchReponse.java index 9777fd3..84e9c33 100644 --- a/src/main/java/com/glxp/api/res/trace/TraceSearchReponse.java +++ b/src/main/java/com/glxp/api/res/trace/TraceSearchReponse.java @@ -16,7 +16,7 @@ public class TraceSearchReponse { @ApiModelProperty(value = "追溯日志") TraceRecordLogEntity traceRecordLogEntity; @ApiModelProperty(value = "追溯查询出入库单结果") - List traceOrderEntities; + List traceOrderEntities; @ApiModelProperty(value = "追溯查询生产订单结果") List traceManuOrderEntities; diff --git a/src/main/java/com/glxp/api/service/trace/RabbitPushService.java b/src/main/java/com/glxp/api/service/trace/RabbitPushService.java index 63a1507..134d7a8 100644 --- a/src/main/java/com/glxp/api/service/trace/RabbitPushService.java +++ b/src/main/java/com/glxp/api/service/trace/RabbitPushService.java @@ -11,6 +11,7 @@ import com.glxp.api.util.JsonUtils; import com.rabbitmq.client.BuiltinExchangeType; import com.rabbitmq.client.Channel; import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; import org.springframework.amqp.core.MessageProperties; import org.springframework.amqp.rabbit.core.RabbitTemplate; import org.springframework.stereotype.Service; @@ -22,6 +23,7 @@ import java.util.Date; import java.util.HashMap; import java.util.Map; +@Slf4j @Service @RequiredArgsConstructor public class RabbitPushService { @@ -37,7 +39,6 @@ public class RabbitPushService { Channel channel = rabbitTemplate.getConnectionFactory().createConnection().createChannel(true); String queueName = "fanout_" + mqTraceMessage.getCompanyId() + ""; rabbitQueueService.createQueue(queueName); -// channel.basicPublish(FANOUT_EXCHANGE, "", null, JsonUtils.toJsonString(mqTraceMessage).getBytes()); rabbitTemplate.convertAndSend(FANOUT_EXCHANGE, null, JsonUtils.toJsonString(mqTraceMessage)); @@ -45,7 +46,9 @@ public class RabbitPushService { public BaseResponse send(MqTraceMessage mqTraceMessage) { - rabbitTemplate.convertAndSend(TopicRabbitConfig.TRACE_TOPIC_EXCHANGE, TopicRabbitConfig.trace, JsonUtils.toJsonString(mqTraceMessage)); + String msg = JsonUtils.toJsonString(mqTraceMessage); + log.info("推送消息:" + msg); + rabbitTemplate.convertAndSend(TopicRabbitConfig.TRACE_TOPIC_EXCHANGE, TopicRabbitConfig.common, msg); return ResultVOUtils.success("发送成功"); } diff --git a/src/main/java/com/glxp/api/service/trace/TraceOrderService.java b/src/main/java/com/glxp/api/service/trace/TraceOrderService.java index 50886ba..eed016f 100644 --- a/src/main/java/com/glxp/api/service/trace/TraceOrderService.java +++ b/src/main/java/com/glxp/api/service/trace/TraceOrderService.java @@ -71,4 +71,17 @@ public class TraceOrderService extends ServiceImpl data = traceOrderMapper.filterBatchNo(traceProductRecordRequest); return data; } + + public List filterJoin(TraceOrderDetailRequest traceOrderDetailRequest) { + if (traceOrderDetailRequest == null) { + return Collections.emptyList(); + } + if (traceOrderDetailRequest.getPage() != null) { + int offset = (traceOrderDetailRequest.getPage() - 1) * traceOrderDetailRequest.getLimit(); + PageHelper.offsetPage(offset, traceOrderDetailRequest.getLimit()); + } + return traceOrderMapper.filterJoin(traceOrderDetailRequest); + } + + } diff --git a/src/main/java/com/glxp/api/service/trace/UdiTraceService.java b/src/main/java/com/glxp/api/service/trace/UdiTraceService.java index 361dc9d..8684779 100644 --- a/src/main/java/com/glxp/api/service/trace/UdiTraceService.java +++ b/src/main/java/com/glxp/api/service/trace/UdiTraceService.java @@ -138,6 +138,17 @@ public class UdiTraceService { pushMq(traceProductDetailEntity, companyId); } + //2.出入库生产订单关联关系 + TraceTaskNoticeEntity inoutTaskNotity = traceTaskNoticeService.findTask(2, traceProductDetailEntity.getId(), companyId); + if (inoutTaskNotity == null) { + inoutTaskNotity = createTraceNotice(2, traceProductDetailEntity, companyId); + pushDelayExpireTask(inoutTaskNotity); + pushMq(traceProductDetailEntity, companyId); + } else if (inoutTaskNotity.getStatus() == 4) { + //任务超时未处理,重新推送消息 + pushMq(traceProductDetailEntity, companyId); + } + //列出需要查询推送企业 List traceOrderEntities = traceOrderService.findByProductIdFk(traceProductDetailEntity.getId()); diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 8b65c9e..bc35fe4 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -15,7 +15,7 @@ spring: redis: database: 14 - host: 127.0.0.1 + host: 192.168.0.166 port: 6379 # password: 123456 timeout: 300 @@ -34,7 +34,7 @@ spring: max-request-size: 500MB rabbitmq: - host: 127.0.0.1 + host: 192.168.0.166 port: 5672 username: cpt password: 123456 diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index a97493f..80e18f1 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: pro + active: dev jmx: enabled: false servlet: diff --git a/src/main/resources/mybatis/mapper/trace/TraceOrderMapper.xml b/src/main/resources/mybatis/mapper/trace/TraceOrderMapper.xml index 735d8c7..217b2bc 100644 --- a/src/main/resources/mybatis/mapper/trace/TraceOrderMapper.xml +++ b/src/main/resources/mybatis/mapper/trace/TraceOrderMapper.xml @@ -36,6 +36,48 @@ + + +