diff --git a/src/main/java/com/glxp/api/controller/trace/UdiTraceController.java b/src/main/java/com/glxp/api/controller/trace/UdiTraceController.java index 799a74e..278fde2 100644 --- a/src/main/java/com/glxp/api/controller/trace/UdiTraceController.java +++ b/src/main/java/com/glxp/api/controller/trace/UdiTraceController.java @@ -16,7 +16,9 @@ import com.glxp.api.req.basic.FilterUdiRelRequest; import com.glxp.api.req.trace.TraceOrderUploadRequest; import com.glxp.api.req.trace.TraceRecordRequest; import com.glxp.api.res.basic.BasicUdiRelResponse; +import com.glxp.api.res.trace.TraceSearchReponse; import com.glxp.api.service.basic.BasicUdiRelService; +import com.glxp.api.service.sup.UserCompanyService; import com.glxp.api.service.trace.*; import com.glxp.api.util.GennerOrderUtils; import com.glxp.api.util.udi.FilterUdiUtils; @@ -54,6 +56,8 @@ public class UdiTraceController extends BaseController { TraceRecordService traceRecordService; @Resource UdiTraceService udiTraceService; + @Resource + UserCompanyService userCompanyService; /** @@ -65,13 +69,17 @@ public class UdiTraceController extends BaseController { @AuthRuleAnnotation("udi/trace/source/search") @GetMapping("udi/trace/source/search") public BaseResponse createTrace(TraceRecordRequest traceRecordRequest) { - TraceRecordLogEntity traceRecordLogEntity = null; + + TraceRecordLogEntity traceRecordLogEntity; TraceProductDetailEntity traceProductDetailEntity = null; BasicUdiRelResponse basicUdiRelResponse = null; UdiEntity udiEntity = null; UserCompanyEntity userCompanyEntity = null; - if (traceRecordRequest.getTraceType() == Constant.UDI_TRACE) { + if (StrUtil.isNotEmpty(traceRecordRequest.getUdiCode())) { + traceRecordRequest.setTraceType(Constant.UDI_TRACE); + } + if (traceRecordRequest.getTraceType() == Constant.UDI_TRACE) { //1.校验UDI码格式 udiEntity = FilterUdiUtils.getUdi(traceRecordRequest.getUdiCode()); if (udiEntity == null) { @@ -90,28 +98,18 @@ public class UdiTraceController extends BaseController { return ResultVOUtils.error(500, "未查询到产品信息"); } - //4.生成查询记录 String userId = getUserId() + ""; - traceRecordLogEntity = traceRecordService.getById(traceRecordRequest.getRecordCode()); - if (traceRecordLogEntity == null) - traceRecordLogEntity = udiTraceService.createRecordLog(userId, traceRecordRequest.getFromType(), traceRecordRequest.getTraceType()); + traceRecordLogEntity = udiTraceService.createRecordLog(userId, traceRecordRequest.getFromType(), traceRecordRequest.getTraceType()); //5.创建查询详情记录,若存在相同查询记录则直接获取 - if (traceRecordLogEntity.getTraceProductIdFk() != null) { - traceProductDetailEntity = traceProductDetailService.getById(traceRecordLogEntity.getTraceProductIdFk()); - if (traceProductDetailEntity == null) { - traceProductDetailEntity = udiTraceService.createTracerProductByUdiCode(traceRecordRequest.getUdiCode(), 1, 1, basicUdiRelResponse, udiEntity); - traceRecordLogEntity.setTraceProductIdFk(traceProductDetailEntity.getId()); - traceRecordService.updateById(traceRecordLogEntity); - } - } else { - traceProductDetailEntity = udiTraceService.createTracerProductByUdiCode(traceRecordRequest.getUdiCode(), 1, 1, basicUdiRelResponse, udiEntity); - } + traceProductDetailEntity = udiTraceService.createTracerProductByUdiCode(traceRecordRequest.getUdiCode(), 1, 1, basicUdiRelResponse, udiEntity); + traceRecordLogEntity.setTraceProductIdFk(traceProductDetailEntity.getId()); + traceRecordService.updateById(traceRecordLogEntity); + udiTraceService.createSourceTraceTask(traceProductDetailEntity, userCompanyEntity.getId()); } else { - //1:校验参数是否正确 if (StrUtil.isEmpty(traceRecordRequest.getYlqxzcrbarmc())) { return ResultVOUtils.error(500, "医疗器械注册人不能为空!"); @@ -123,7 +121,6 @@ public class UdiTraceController extends BaseController { return ResultVOUtils.error(500, "规格型号不能为空!"); } - //2.查询源头企业 FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); filterUdiRelRequest.setYlqxzcrbarmc(traceRecordRequest.getYlqxzcrbarmc()); @@ -146,12 +143,13 @@ public class UdiTraceController extends BaseController { //5.创建查询详情记录,若存在相同查询记录则直接获取 traceProductDetailEntity = udiTraceService.createTracerProductByBatchNo(traceRecordRequest, 1, 2, basicUdiRelResponse); - + traceRecordLogEntity.setTraceProductIdFk(traceProductDetailEntity.getId()); + traceRecordService.updateById(traceRecordLogEntity); + udiTraceService.createSourceTraceTask(traceProductDetailEntity, userCompanyEntity.getId()); } - - - return ResultVOUtils.success(traceRecordLogEntity); + List traceOrderEntities = traceOrderService.findByProductIdFk(traceRecordLogEntity.getTraceProductIdFk()); + return ResultVOUtils.success(traceOrderEntities); } /** @@ -164,14 +162,97 @@ public class UdiTraceController extends BaseController { @GetMapping("udi/trace/scene/search") public BaseResponse sceneTrace(TraceRecordRequest traceRecordRequest) { + TraceSearchReponse traceSearchReponse = new TraceSearchReponse(); + TraceRecordLogEntity traceRecordLogEntity = traceRecordService.getById(traceRecordRequest.getRecordCode()); + if (traceRecordLogEntity != null) { + List traceOrderEntities = traceOrderService.findByProductIdFk(traceRecordLogEntity.getTraceProductIdFk()); + traceSearchReponse.setTraceRecordLogEntity(traceRecordLogEntity); + traceSearchReponse.setTraceOrderEntities(traceOrderEntities); + return ResultVOUtils.success(traceSearchReponse); + } + + TraceProductDetailEntity traceProductDetailEntity = null; + BasicUdiRelResponse basicUdiRelResponse = null; + UdiEntity udiEntity = null; + UserCompanyEntity userCompanyEntity = null; if (traceRecordRequest.getTraceType() == Constant.UDI_TRACE) { - } else if (traceRecordRequest.getTraceType() == Constant.UDI_BATCHNO) { + //1.校验UDI码格式 + udiEntity = FilterUdiUtils.getUdi(traceRecordRequest.getUdiCode()); + if (udiEntity == null) { + return ResultVOUtils.error(500, "UDI码格式错误"); + } + + //2.查询报备企业 + userCompanyEntity = userCompanyService.getById(traceRecordRequest.getCompanyId()); + if (userCompanyEntity == null) { + return ResultVOUtils.error(500, "未查询到该报备企业信息!"); + } + + //3.查询产品信息 + basicUdiRelResponse = basicUdiRelService.findByProductNameCode(udiEntity.getUdi()); + if (basicUdiRelResponse == null) { + return ResultVOUtils.error(500, "未查询到产品信息"); + } + + //4.生成查询记录 + String userId = getUserId() + ""; + if (traceRecordLogEntity == null) + traceRecordLogEntity = udiTraceService.createRecordLog(userId, traceRecordRequest.getFromType(), traceRecordRequest.getTraceType()); + + + //5.创建查询详情记录,若存在相同查询记录则直接获取 + if (traceRecordLogEntity.getTraceProductIdFk() != null) { + traceProductDetailEntity = traceProductDetailService.getById(traceRecordLogEntity.getTraceProductIdFk()); + if (traceProductDetailEntity == null) { + traceProductDetailEntity = udiTraceService.createTracerProductByUdiCode(traceRecordRequest.getUdiCode(), 2, 1, basicUdiRelResponse, udiEntity); + traceRecordLogEntity.setTraceProductIdFk(traceProductDetailEntity.getId()); + traceRecordService.updateById(traceRecordLogEntity); + } + } else { + traceProductDetailEntity = udiTraceService.createTracerProductByUdiCode(traceRecordRequest.getUdiCode(), 2, 1, basicUdiRelResponse, udiEntity); + } + udiTraceService.createCheckTraceTask(traceProductDetailEntity, userCompanyEntity.getId()); } else { - return ResultVOUtils.error(500, "请选择查询方式!"); + //1:校验参数是否正确 + if (StrUtil.isEmpty(traceRecordRequest.getYlqxzcrbarmc())) { + return ResultVOUtils.error(500, "医疗器械注册人不能为空!"); + } + if (StrUtil.isEmpty(traceRecordRequest.getCpmctymc())) { + return ResultVOUtils.error(500, "产品通用名称不能为空!"); + } + if (StrUtil.isEmpty(traceRecordRequest.getGgxh())) { + return ResultVOUtils.error(500, "规格型号不能为空!"); + } + + //2.查询源头企业 + FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); + filterUdiRelRequest.setYlqxzcrbarmc(traceRecordRequest.getYlqxzcrbarmc()); + filterUdiRelRequest.setCpmctymc(traceRecordRequest.getCpmctymc()); + filterUdiRelRequest.setGgxh(traceRecordRequest.getGgxh()); + + userCompanyEntity = userCompanyService.getById(traceRecordRequest.getCompanyId()); + if (userCompanyEntity == null) { + return ResultVOUtils.error(500, "未查询到该报备企业信息!"); + } + + //3.查询产品信息 + basicUdiRelResponse = basicUdiRelService.findByProductName(filterUdiRelRequest); + if (basicUdiRelResponse == null) { + return ResultVOUtils.error(500, "未查询到产品信息"); + } + + //4.生成查询记录 + String userId = getUserId() + ""; + traceRecordLogEntity = udiTraceService.createRecordLog(userId, traceRecordRequest.getFromType(), traceRecordRequest.getTraceType()); + + //5.创建查询详情记录,若存在相同查询记录则直接获取 + traceProductDetailEntity = udiTraceService.createTracerProductByBatchNo(traceRecordRequest, 2, 2, basicUdiRelResponse); + udiTraceService.createCheckTraceTask(traceProductDetailEntity, userCompanyEntity.getId()); } - return ResultVOUtils.error(500, "查询失败"); + traceSearchReponse.setTraceRecordLogEntity(traceRecordLogEntity); + return ResultVOUtils.success(traceSearchReponse); } diff --git a/src/main/java/com/glxp/api/entity/trace/MqTraceMessage.java b/src/main/java/com/glxp/api/entity/trace/MqTraceMessage.java index d1362d0..f2a1f4b 100644 --- a/src/main/java/com/glxp/api/entity/trace/MqTraceMessage.java +++ b/src/main/java/com/glxp/api/entity/trace/MqTraceMessage.java @@ -2,10 +2,11 @@ package com.glxp.api.entity.trace; import lombok.Data; +import java.io.Serializable; import java.util.Date; @Data -public class MqTraceMessage { +public class MqTraceMessage implements Serializable { /** * 消息创建时间 diff --git a/src/main/java/com/glxp/api/entity/trace/TraceTaskNoticeEntity.java b/src/main/java/com/glxp/api/entity/trace/TraceTaskNoticeEntity.java index d81117e..8a3791c 100644 --- a/src/main/java/com/glxp/api/entity/trace/TraceTaskNoticeEntity.java +++ b/src/main/java/com/glxp/api/entity/trace/TraceTaskNoticeEntity.java @@ -9,6 +9,7 @@ import java.io.Serializable; import java.util.Date; import java.util.List; +import com.baomidou.mybatisplus.extension.handlers.FastjsonTypeHandler; import lombok.Data; /** @@ -109,7 +110,7 @@ public class TraceTaskNoticeEntity implements Serializable { @TableField(value = "updateTime") private Date updateTime; - @TableField(value = "diList") + @TableField(value = "diList",typeHandler = FastjsonTypeHandler.class) private List diList; diff --git a/src/main/java/com/glxp/api/req/trace/TraceRecordRequest.java b/src/main/java/com/glxp/api/req/trace/TraceRecordRequest.java index 99b5f15..08eb4a7 100644 --- a/src/main/java/com/glxp/api/req/trace/TraceRecordRequest.java +++ b/src/main/java/com/glxp/api/req/trace/TraceRecordRequest.java @@ -76,5 +76,7 @@ public class TraceRecordRequest extends ListPageRequest { */ private String batchNo; + private Long companyId; + } diff --git a/src/main/java/com/glxp/api/res/trace/TraceSearchReponse.java b/src/main/java/com/glxp/api/res/trace/TraceSearchReponse.java new file mode 100644 index 0000000..01a1c77 --- /dev/null +++ b/src/main/java/com/glxp/api/res/trace/TraceSearchReponse.java @@ -0,0 +1,16 @@ +package com.glxp.api.res.trace; + +import com.glxp.api.entity.trace.TraceOrderEntity; +import com.glxp.api.entity.trace.TraceRecordLogEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class TraceSearchReponse { + + + TraceRecordLogEntity traceRecordLogEntity; + List traceOrderEntities; + +} diff --git a/src/main/java/com/glxp/api/service/sup/UserCompanyService.java b/src/main/java/com/glxp/api/service/sup/UserCompanyService.java index 85b451d..eb235df 100644 --- a/src/main/java/com/glxp/api/service/sup/UserCompanyService.java +++ b/src/main/java/com/glxp/api/service/sup/UserCompanyService.java @@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.extension.service.IService; import com.glxp.api.entity.sup.UserCompanyEntity; import com.glxp.api.entity.sup.UserRegisterEntity; -public interface UserCompanyService extends IService{ +public interface UserCompanyService extends IService { + int insert(UserCompanyEntity userCompany); + boolean update(UserCompanyEntity userCompany); } 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 52183df..2f679b6 100644 --- a/src/main/java/com/glxp/api/service/trace/TraceOrderService.java +++ b/src/main/java/com/glxp/api/service/trace/TraceOrderService.java @@ -2,6 +2,7 @@ package com.glxp.api.service.trace; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.github.pagehelper.PageHelper; +import com.glxp.api.entity.trace.TraceRecordLogEntity; import com.glxp.api.req.trace.TraceOrderDetailRequest; import com.glxp.api.res.trace.TraceOrderResponse; import org.springframework.stereotype.Service; @@ -18,6 +19,8 @@ public class TraceOrderService extends ServiceImpl queryTraceOrderList(TraceOrderDetailRequest traceOrderDetailRequest) { if (traceOrderDetailRequest == null) { @@ -30,8 +33,16 @@ public class TraceOrderService extends ServiceImpl findByProductIdFk(Long traceProductIdFk) { + public List findByProductIdFk(Long traceProductIdFk) { return traceOrderMapper.selectList(new QueryWrapper().eq("traceProductIdFk", traceProductIdFk)); } + public List findByRecordId(Long recordId) { + TraceRecordLogEntity traceRecordLogEntity = traceRecordService.getById(recordId); + if (traceRecordLogEntity == null) + return null; + return traceOrderMapper.selectList(new QueryWrapper().eq("traceProductIdFk", traceRecordLogEntity.getTraceProductIdFk())); + } + + } diff --git a/src/main/java/com/glxp/api/service/trace/TraceTaskNoticeService.java b/src/main/java/com/glxp/api/service/trace/TraceTaskNoticeService.java index 7f02ede..fdbaace 100644 --- a/src/main/java/com/glxp/api/service/trace/TraceTaskNoticeService.java +++ b/src/main/java/com/glxp/api/service/trace/TraceTaskNoticeService.java @@ -16,9 +16,11 @@ public class TraceTaskNoticeService extends ServiceImpl taskNoticeEntities = traceTaskNoticeMapper. - selectList(new QueryWrapper().eq("taskType", taskType).eq("produdctRecordIdFk", produdctRecordIdFk).last("limit 1")); + selectList(new QueryWrapper().eq("taskType", taskType).eq("produdctRecordIdFk", produdctRecordIdFk) + .eq("companyIdFk", companyIdFk) + .last("limit 1")); if (CollUtil.isNotEmpty(taskNoticeEntities)) { return taskNoticeEntities.get(0); } else 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 33404f0..74a8194 100644 --- a/src/main/java/com/glxp/api/service/trace/UdiTraceService.java +++ b/src/main/java/com/glxp/api/service/trace/UdiTraceService.java @@ -1,22 +1,26 @@ package com.glxp.api.service.trace; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.IdUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.glxp.api.entity.basic.UdiEntity; -import com.glxp.api.entity.trace.MqTraceMessage; -import com.glxp.api.entity.trace.TraceProductDetailEntity; -import com.glxp.api.entity.trace.TraceRecordLogEntity; -import com.glxp.api.entity.trace.TraceTaskNoticeEntity; +import com.glxp.api.entity.sup.UserCompanyEntity; +import com.glxp.api.entity.trace.*; import com.glxp.api.req.basic.FilterUdiRelRequest; import com.glxp.api.req.trace.TraceRecordRequest; import com.glxp.api.res.basic.BasicUdiRelResponse; import com.glxp.api.service.basic.BasicUdiProductService; import com.glxp.api.service.basic.BasicUdiRelService; +import com.glxp.api.service.sup.UserCompanyService; import com.glxp.api.util.GennerOrderUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; @Service public class UdiTraceService { @@ -38,6 +42,8 @@ public class UdiTraceService { TraceTaskNoticeService traceTaskNoticeService; @Resource RabbitPushService rabbitPushService; + @Resource + TraceManuOrderService traceManuOrderService; //创建查询日志 public TraceRecordLogEntity createRecordLog(String userId, Integer fromType, Integer traceType) { @@ -59,8 +65,12 @@ public class UdiTraceService { TraceProductDetailEntity traceProductDetailEntity = null; traceProductDetailEntity = traceProductDetailService.findUniqueByCode(1, udiCode); if (traceProductDetailEntity == null) { + traceProductDetailEntity = new TraceProductDetailEntity(); traceProductDetailEntity.setId(IdUtil.getSnowflakeNextId()); traceProductDetailEntity.setTraceSource(traceSource); + if (traceSource == 1) { + traceProductDetailEntity.setManuStatus(1); + } traceProductDetailEntity.setTraceType(traceType); traceProductDetailEntity.setUdiCode(udiCode); traceProductDetailEntity.setYlqxzcrbarmc(basicUdiRelResponse.getYlqxzcrbarmc()); @@ -72,6 +82,7 @@ public class UdiTraceService { traceProductDetailEntity.setProduceDate(udiEntity.getProduceDate()); traceProductDetailEntity.setExpireDate(udiEntity.getExpireDate()); traceProductDetailEntity.setSerialNo(udiEntity.getSerialNo()); + traceProductDetailEntity.setStatus(1); traceProductDetailService.save(traceProductDetailEntity); return traceProductDetailEntity; @@ -89,6 +100,9 @@ public class UdiTraceService { if (traceProductDetailEntity == null) { traceProductDetailEntity.setId(IdUtil.getSnowflakeNextId()); traceProductDetailEntity.setTraceSource(traceSource); + if (traceSource == 1) { + traceProductDetailEntity.setManuStatus(1); + } traceProductDetailEntity.setTraceType(traceType); traceProductDetailEntity.setYlqxzcrbarmc(basicUdiRelResponse.getYlqxzcrbarmc()); traceProductDetailEntity.setCreditNum(basicUdiRelResponse.getTyshxydm()); @@ -103,42 +117,89 @@ public class UdiTraceService { } @Resource - TraceManuOrderService traceManuOrderService; - - //创建任务列表 - public void createTraceTask(TraceProductDetailEntity traceProductDetailEntity, Long companyId) { + UserCompanyService userCompanyService; + //创建源头查询任务 + public void createSourceTraceTask(TraceProductDetailEntity traceProductDetailEntity, Long companyId) { //1.查询生产订单信息是否已上传 //生产订单关联关系 - if (traceProductDetailEntity.getManuStatus() == 1) { //生产订单未处理 + TraceTaskNoticeEntity manuTaskNotity = traceTaskNoticeService.findTask(1, traceProductDetailEntity.getId(), companyId); + if (manuTaskNotity == null) { createTraceNotice(1, traceProductDetailEntity, companyId); pushMq(traceProductDetailEntity, companyId); - } else if (traceProductDetailEntity.getManuStatus() == 2) { //生产订单处理未完成 - TraceTaskNoticeEntity taskNoticeEntity = traceTaskNoticeService.findTask(1, traceProductDetailEntity.getId()); - if (taskNoticeEntity == null) { - createTraceNotice(1, traceProductDetailEntity, companyId); - pushMq(traceProductDetailEntity, companyId); - } else if (taskNoticeEntity.getStatus() == 4) { - //任务超时未处理,重新推送消息 - pushMq(traceProductDetailEntity, companyId); + } else if (manuTaskNotity.getStatus() == 4) { + //任务超时未处理,重新推送消息 + pushMq(traceProductDetailEntity, companyId); + } + + + //列出需要查询推送企业 + List traceOrderEntities = traceOrderService.findByProductIdFk(traceProductDetailEntity.getId()); + if (CollUtil.isNotEmpty(traceOrderEntities)) { + List toCorpCreditNums = new ArrayList<>(); + for (TraceOrderEntity traceOrderEntity : traceOrderEntities) { + if (StrUtil.isNotEmpty(traceOrderEntity.getToCorpCreditNum())) { + toCorpCreditNums.add(traceOrderEntity.getToCorpCreditNum()); + } + } + + List certNums = toCorpCreditNums.stream().distinct().collect(Collectors.toList()); + for (String certNum : certNums) { + UserCompanyEntity userCompanyEntity = userCompanyService.getOne(new QueryWrapper().eq("creditNum", certNum)); + TraceTaskNoticeEntity taskNoticeEntity = traceTaskNoticeService.findTask(1, traceProductDetailEntity.getId(), userCompanyEntity.getId()); + if (taskNoticeEntity == null) { + createTraceNotice(1, traceProductDetailEntity, companyId); + pushMq(traceProductDetailEntity, companyId); + } else if (taskNoticeEntity.getStatus() == 4) { + //任务超时未处理,重新推送消息 + pushMq(traceProductDetailEntity, companyId); + } } } + } + + // 创建现场检查询任务 + + public void createCheckTraceTask(TraceProductDetailEntity traceProductDetailEntity, Long companyId) { - //2.查询出入库单消息是否已经上传 + //1.查询出入库单消息是否已经上传 if (traceProductDetailEntity.getStatus() == 1) { //出入库订单未处理 createTraceNotice(2, traceProductDetailEntity, companyId); pushMq(traceProductDetailEntity, companyId); } else if (traceProductDetailEntity.getStatus() == 2) { //出入库订单未处理完成 - + //列出需要查询推送企业 + List traceOrderEntities = traceOrderService.findByProductIdFk(traceProductDetailEntity.getId()); + if (CollUtil.isNotEmpty(traceOrderEntities)) { + List toCorpCreditNums = new ArrayList<>(); + for (TraceOrderEntity traceOrderEntity : traceOrderEntities) { + if (StrUtil.isNotEmpty(traceOrderEntity.getToCorpCreditNum())) { + toCorpCreditNums.add(traceOrderEntity.getToCorpCreditNum()); + } + if (StrUtil.isNotEmpty(traceOrderEntity.getFromCorpCreditNum())) { + toCorpCreditNums.add(traceOrderEntity.getFromCorpCreditNum()); + } + } + List certNums = toCorpCreditNums.stream().distinct().collect(Collectors.toList()); + for (String certNum : certNums) { + UserCompanyEntity userCompanyEntity = userCompanyService.getOne(new QueryWrapper().eq("creditNum", certNum)); + TraceTaskNoticeEntity taskNoticeEntity = traceTaskNoticeService.findTask(1, traceProductDetailEntity.getId(), userCompanyEntity.getId()); + if (taskNoticeEntity == null) { + createTraceNotice(1, traceProductDetailEntity, companyId); + pushMq(traceProductDetailEntity, companyId); + } else if (taskNoticeEntity.getStatus() == 4) { + //任务超时未处理,重新推送消息 + pushMq(traceProductDetailEntity, companyId); + } + } + } } - - } //创建任务列表 public TraceTaskNoticeEntity createTraceNotice(Integer taskType, TraceProductDetailEntity traceProductDetailEntity, Long companyId) { + TraceTaskNoticeEntity traceTaskNoticeEntity = new TraceTaskNoticeEntity(); traceTaskNoticeEntity.setId(IdUtil.getSnowflakeNextId()); traceTaskNoticeEntity.setProdudctRecordIdFk(traceProductDetailEntity.getId()); @@ -155,6 +216,10 @@ public class UdiTraceService { traceTaskNoticeEntity.setSerialNo(traceProductDetailEntity.getSerialNo()); traceTaskNoticeEntity.setCreateTime(new Date()); FilterUdiRelRequest filterUdiRelRequest = new FilterUdiRelRequest(); + filterUdiRelRequest.setYlqxzcrbarmc(traceProductDetailEntity.getYlqxzcrbarmc()); + filterUdiRelRequest.setCpmctymc(traceProductDetailEntity.getCpmctymc()); + filterUdiRelRequest.setGgxh(traceProductDetailEntity.getGgxh()); + filterUdiRelRequest.setNameCode(traceProductDetailEntity.getNameCode()); List diList = basicUdiRelService.findDiListByProduct(filterUdiRelRequest); traceTaskNoticeEntity.setDiList(diList); traceTaskNoticeService.save(traceTaskNoticeEntity); diff --git a/src/main/java/com/glxp/api/task/mq/TraceSearchReceiver.java b/src/main/java/com/glxp/api/task/mq/TraceSearchReceiver.java new file mode 100644 index 0000000..31bc9bf --- /dev/null +++ b/src/main/java/com/glxp/api/task/mq/TraceSearchReceiver.java @@ -0,0 +1,21 @@ +package com.glxp.api.task.mq; + +import com.glxp.api.entity.trace.MqTraceMessage; +import org.springframework.amqp.rabbit.annotation.RabbitHandler; +import org.springframework.amqp.rabbit.annotation.RabbitListener; +import org.springframework.stereotype.Component; + + +@Component + +public class TraceSearchReceiver { + + @RabbitHandler + @RabbitListener(queues = "topic.trace") + public void traceReceiver(MqTraceMessage mqTraceMessage) { + System.out.println("topic.trace消费者收到消息 : " + mqTraceMessage.toString()); + } + + + +} diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 4011118..dc28405 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -14,7 +14,7 @@ spring: redis: - database: 8 + database: 14 host: 127.0.0.1 port: 6379 # password: 123456 @@ -34,10 +34,10 @@ spring: max-request-size: 500MB rabbitmq: - host: 192.168.0.66 + host: 127.0.0.1 port: 5672 - username: glxp - password: glxp1234 + username: cpt + password: 123456 virtual-host: / publisher-confirms: false connection-timeout: 15000 diff --git a/src/main/resources/application-test.yml b/src/main/resources/application-test.yml index f01be81..f101988 100644 --- a/src/main/resources/application-test.yml +++ b/src/main/resources/application-test.yml @@ -29,6 +29,14 @@ spring: multipart: max-file-size: 500MB max-request-size: 500MB + rabbitmq: + host: 192.168.0.66 + port: 5672 + username: glxp + password: glxp1234 + virtual-host: / + publisher-confirms: false + connection-timeout: 15000 ok: http: @@ -43,7 +51,7 @@ logging: level: com.glxp.api.dao: debug -file_path: /udi/udiwms/udiwmsfile/ +file_path: /udi/udiwms/udiwmsfile/ back_file_path: /share/udisps/back/ UDI_KEY: 6b137c66-6286-46c6-8efa-c2f5dd9237df UDI_SERVER_URL: https://www.udims.com/UDI_DL_Server_test 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: