Sfoglia il codice sorgente

Merge branch 'feature/1.0.0' of github.com:ab-inbev-apac/abi-cloud-qr-platform into feature/1.0.0

tanzhongran 3 anni fa
parent
commit
43378de8bc

+ 4 - 4
abi-cloud-qr-platform-server/pom.xml

@@ -108,10 +108,10 @@
                 </exclusion>
             </exclusions>
         </dependency>
-        <dependency>
-            <groupId>org.springframework.boot</groupId>
-            <artifactId>spring-boot-starter-actuator</artifactId>
-        </dependency>
+<!--        <dependency>-->
+<!--            <groupId>org.springframework.boot</groupId>-->
+<!--            <artifactId>spring-boot-starter-actuator</artifactId>-->
+<!--        </dependency>-->
         <dependency>
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-jdbc</artifactId>

+ 0 - 3
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/req/ListQrBoxCodeMappingReq.java

@@ -23,7 +23,4 @@ public class ListQrBoxCodeMappingReq extends PageReq implements Serializable {
 
     @ApiModelProperty(value = "激活状态 0-未激活 1-已激活 9-已作废")
     private Integer activeStatus;
-
-    @ApiModelProperty(value = "是否作废 0-未作废 1-已作废")
-    private Integer invalid;
 }

+ 1 - 2
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dto/res/ListQrBoxCodeMappingRes.java

@@ -84,7 +84,7 @@ public class ListQrBoxCodeMappingRes extends PageResp implements Serializable {
         @ApiModelProperty(value = "激活厂商")
         private String factoryName;
 
-        @ApiModelProperty(value = "激活状态 0-未激活 1-已激活")
+        @ApiModelProperty(value = "激活状态 0-未激活 1-已激活 9-已作废")
         private Integer activeStatus;
 
         @ApiModelProperty(value = "码包id")
@@ -92,7 +92,6 @@ public class ListQrBoxCodeMappingRes extends PageResp implements Serializable {
 
         @ApiModelProperty(value = "是否作废 0-未作废 1-已作废")
         private Integer invalid;
-
     }
 
 

+ 43 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/infrastructure/config/RabbitmqConfig.java

@@ -2,7 +2,16 @@ package com.abi.qms.platform.infrastructure.config;
 
 import com.abi.qms.platform.infrastructure.mq.TableStoreBatchInsertConsumer;
 import com.abi.qms.platform.infrastructure.mq.TableStoreBatchUpdateConsumer;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.amqp.core.Message;
 import org.springframework.amqp.core.Queue;
+import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
+import org.springframework.amqp.rabbit.connection.ConnectionFactory;
+import org.springframework.amqp.rabbit.connection.CorrelationData;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
+import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 
@@ -13,6 +22,7 @@ import org.springframework.context.annotation.Configuration;
  * @date: 2021-05-11
  */
 @Configuration
+@Slf4j
 public class RabbitmqConfig {
 
 	@Bean(name = "qms_table_store_queue")
@@ -25,4 +35,37 @@ public class RabbitmqConfig {
 		return new Queue(TableStoreBatchUpdateConsumer.TABLE_STORE_BATCH_UPDATE_QUEUE);
 	}
 
+	@Value("${spring.rabbitmq.addresses}")
+	private String addresses;
+	@Value("${spring.rabbitmq.username}")
+	private String username;
+	@Value("${spring.rabbitmq.password}")
+	private String password;
+	@Value("${spring.rabbitmq.virtual-host}")
+	private String virtualHost;
+
+	@Bean("qmsConnectionFactory")
+	public ConnectionFactory connectionFactory() {
+		CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
+		connectionFactory.setAddresses(addresses);
+		connectionFactory.setUsername(username);
+		connectionFactory.setPassword(password);
+		connectionFactory.setVirtualHost(virtualHost);
+		connectionFactory.setPublisherConfirmType(CachingConnectionFactory.ConfirmType.SIMPLE);
+		connectionFactory.setPublisherReturns(true);
+		return connectionFactory;
+	}
+
+	@Bean(name = "qmsRabbitTemplate")
+	public RabbitTemplate rabbitTemplate(){
+		RabbitTemplate template = new RabbitTemplate(this.connectionFactory());
+		template.setMessageConverter(new Jackson2JsonMessageConverter());
+		template.setMandatory(true);
+		template.setConfirmCallback((CorrelationData correlationData, boolean ack, String cause) ->
+				log.info("CorrelationData:{}, ack:{}, cause:{}", correlationData, ack, cause));
+		template.setReturnCallback((Message message, int replyCode, String replyText, String exchange, String routingKey) ->
+				log.info("message:{}, replyCode:{}, replyText:{}, exchange:{}, routingKey:{}", message, replyCode, replyText, exchange, routingKey));
+		return template;
+	}
+
 }

+ 6 - 9
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/infrastructure/util/AsyncTableStoreUtil.java

@@ -3,17 +3,13 @@ package com.abi.qms.platform.infrastructure.util;
 import com.abi.qms.platform.dao.tablestore.entity.QrCode;
 import com.abi.qms.platform.infrastructure.mq.TableStoreBatchInsertConsumer;
 import com.abi.qms.platform.infrastructure.mq.TableStoreBatchUpdateConsumer;
-import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.AllArgsConstructor;
 import lombok.Data;
-import lombok.NoArgsConstructor;
-import org.apache.poi.ss.formula.functions.T;
-import org.springframework.amqp.core.AmqpTemplate;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.stereotype.Component;
 
 import java.io.Serializable;
-import java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -24,7 +20,8 @@ import java.util.List;
 public class AsyncTableStoreUtil {
 
     @Autowired
-    private AmqpTemplate amqpTemplate;
+    @Qualifier("qmsRabbitTemplate")
+    private RabbitTemplate amqpTemplate;
 
     /**
      * 批量新增tableStore,码表
@@ -70,8 +67,8 @@ public class AsyncTableStoreUtil {
     }
 
     /**
-    * 更新行对象
-    */
+     * 更新行对象
+     */
     @Data
     public static class UpdateRowBean implements Serializable {
         private List<QrCode> entityList;

+ 5 - 2
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/GenerateCodeServiceImpl.java

@@ -35,7 +35,9 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.redisson.api.RLock;
 import org.redisson.api.RedissonClient;
 import org.springframework.amqp.core.AmqpTemplate;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.DigestUtils;
@@ -96,7 +98,8 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
     private BaseMaterialMapper baseMaterialMapper;
 
     @Autowired
-    private AmqpTemplate amqpTemplate;
+    @Qualifier("qmsRabbitTemplate")
+    private RabbitTemplate amqpTemplate;
 
     @Autowired
     private QrPackageBookingOrderService qrPackageBookingOrderService;
@@ -356,7 +359,7 @@ public class GenerateCodeServiceImpl implements GenerateCodeService {
             qrCodeCope.forEach(stable->{
                 stable.setBatchNumberId(qrPackageBatch.getId());
                 stable.setPackageId(qrPackageBatch.getPackageId());
-                stable.setCreateTime(LocalDateTime.now());
+//                stable.setCreateTime(LocalDateTime.now());
                 stable.setInvalid(InvalidEnum.NOT_INVALID.getCode());
             });
             qrCodes.addAll(qrCodeCope);

+ 5 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrBoxMappingServiceImpl.java

@@ -183,6 +183,11 @@ public class QrBoxMappingServiceImpl implements QrBoxMappingService {
         // 封装出参、放入分页信息
         ListQrBoxCodeMappingRes res = new ListQrBoxCodeMappingRes();
         PageUtil.copyPageInfo(res, iPage);
+        qrboxMappingList.forEach(item -> {
+            if (item.getInvalid().equals(1)) {
+                item.setActiveStatus(9);
+            }
+        });
         List<ListQrBoxCodeMappingRes.QrBoxMappingBean> beanList = PojoConverterUtils.copyList(qrboxMappingList, ListQrBoxCodeMappingRes.QrBoxMappingBean.class);
         res.setQrBoxMappingBeanList(beanList);
 

+ 4 - 1
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/impl/QrPackageServiceImpl.java

@@ -71,7 +71,9 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.amqp.core.AmqpTemplate;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.context.ApplicationContext;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -111,7 +113,8 @@ public class QrPackageServiceImpl implements QrPackageService {
     private QrPackageBatchMapper qrPackageBatchMapper;
 
     @Autowired
-    private AmqpTemplate amqpTemplate;
+    @Qualifier("qmsRabbitTemplate")
+    private RabbitTemplate amqpTemplate;
 
     @Autowired
     private SendmailUtil sendmailUtil;

+ 6 - 6
abi-cloud-qr-platform-server/src/main/resources/dao/mapper/QrBoxMappingMapper.xml

@@ -47,14 +47,15 @@
             left join base_factory bf on bf.id=qp.factory_beer_id
         <where>
             qbm.is_delete = 0
-            <if test="req.activeStatus != null ">
+            <if test="req.activeStatus != null and req.activeStatus != 9 ">
                 AND qbm.active_status = #{req.activeStatus}
+                AND qbm.invalid = 0
             </if>
             <if test="req.packageId != null ">
                 AND qbm.package_id = #{req.packageId}
             </if>
-            <if test=" req.invalid != null ">
-                AND qbm.invalid = #{req.invalid}
+            <if test=" req.activeStatus != null and req.activeStatus == 9  ">
+                AND qbm.invalid = 1
             </if>
         </where>
         order by qbm.create_time
@@ -132,19 +133,18 @@
 
     <select id="getActivationRecord" resultType="com.abi.qms.platform.dao.vo.result.ActivationRecordVO">
         select qbm.box_code,ba.active_name,bm.material_name,
-            qbm.active_time,ui.user_name
+            qbm.active_time,qbm.active_user_name as userName
         from qr_box_mapping qbm
         left join qr_package qp on qbm.package_id=qp.id
         left join base_material bm on bm.id = qp.material_id
         left join base_active ba on ba.id =bm.active_id
-        left join user_info ui on ui.id=qbm.create_by
         <where>
             qbm.active_status=1
             <if test="req.month != null and req.month !=''">
                 AND DATE_FORMAT(qbm.active_time,'%Y-%m') = #{req.month}
             </if>
             <if test="id != null">
-                AND ui.id =#{id}
+                AND qbm.active_user_id =#{id}
             </if>
         </where>
         ORDER BY qbm.active_time DESC

+ 4 - 1
abi-cloud-qr-platform-server/src/test/java/com/abi/qms/platform/GenerateCodeTest.java

@@ -7,7 +7,9 @@ import com.abi.qms.platform.dao.mapper.QrPackageMapper;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Test;
 import org.springframework.amqp.core.AmqpTemplate;
+import org.springframework.amqp.rabbit.core.RabbitTemplate;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.boot.test.context.SpringBootTest;
 
 import java.util.ArrayList;
@@ -23,7 +25,8 @@ import java.util.List;
 @Slf4j
 public class GenerateCodeTest {
 	@Autowired
-	private AmqpTemplate amqpTemplate;
+	@Qualifier("qmsRabbitTemplate")
+	private RabbitTemplate amqpTemplate;
 
 	@Autowired
 	private QrPackageMapper qrPackageMapper;