Browse Source

稽查案件编号

bess-WeiganCai 3 years ago
parent
commit
5fd697022f

+ 53 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/entity/InspectionCaseNumber.java

@@ -0,0 +1,53 @@
+package com.abi.qms.platform.dao.entity;
+
+import com.baomidou.mybatisplus.annotation.FieldFill;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 稽查案件编号 对象 inspection_case_number
+ * 
+ * @author WeiganCai
+ * @date 2021-07-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@Schema(name="稽查案件编号对象", description="稽查案件编号信息")
+public class InspectionCaseNumber implements Serializable {
+
+    @Schema(name = "编号id")
+    private Long id;
+
+    @Schema(name = "城市id")
+    private Long cityId;
+
+    @Schema(name = "编号")
+    private Long number;
+
+    @Schema(name = "创建时间")
+    @TableField(fill = FieldFill.INSERT)
+    private LocalDateTime createTime;
+
+    @Schema(name = "创建人id")
+    @TableField(fill = FieldFill.INSERT)
+    private Long createBy;
+
+    @Schema(name = "修改时间")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private LocalDateTime updateTime;
+
+    @Schema(name = "修改人id")
+    @TableField(fill = FieldFill.INSERT_UPDATE)
+    private Long updateBy;
+
+    @Schema(name = "是否删除")
+    private Integer isDelete;
+
+}

+ 17 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/dao/mapper/InspectionCaseNumberMapper.java

@@ -0,0 +1,17 @@
+package com.abi.qms.platform.dao.mapper;
+
+import com.abi.qms.platform.dao.entity.InspectionCaseNumber;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 稽查案件编号 Mapper接口
+ *
+ * @author WeiganCai
+ * @date 2021-07-20
+ */
+public interface InspectionCaseNumberMapper extends BaseMapper<InspectionCaseNumber> {
+	/**
+	 * 根据cityId获取案件编号
+	 */
+	Long getCaseNumber(Long cityId);
+}

+ 14 - 0
abi-cloud-qr-platform-server/src/main/java/com/abi/qms/platform/service/InspectionCaseNumberService.java

@@ -0,0 +1,14 @@
+package com.abi.qms.platform.service;
+
+/**
+ * 稽查案件编号 Service接口
+ *
+ * @author WeiganCai
+ * @date 2021-07-20
+ */
+public interface InspectionCaseNumberService  {
+	/**
+	 * 根据cityId获取案件编号
+	 */
+	Long getCaseNumber(Long cityId);
+}

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

@@ -114,7 +114,7 @@ public class GenerateCodeServiceImpl implements GenerateCodeService, Application
 
 //    TODO dckj配置
 //    @Value("${qms.route.url}")
-    private String qmsRouteUrl;
+    private String qmsRouteUrl = "qmsRouteUrl";
 
     /** 允许单个码生成重复的次数 */
     private static final int REPEAT_BUILD_CODE_TIMES = 10;

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

@@ -0,0 +1,29 @@
+package com.abi.qms.platform.service.impl;
+
+import com.abi.qms.platform.dao.mapper.InspectionCaseNumberMapper;
+import com.abi.qms.platform.service.InspectionCaseNumberService;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ * 稽查案件编号 Service业务层处理
+ *
+ * @author WeiganCai
+ * @date 2021-07-20
+ */
+@Service
+@Slf4j
+public class InspectionCaseNumberServiceImpl implements InspectionCaseNumberService {
+    @Autowired
+    private InspectionCaseNumberMapper caseNumberMapper;
+
+    /**
+     * 根据cityId获取案件编号
+     */
+    @Override
+    public Long getCaseNumber(Long cityId) {
+        return caseNumberMapper.getCaseNumber(cityId);
+    }
+
+}

+ 2 - 2
abi-cloud-qr-platform-server/src/main/resources/application.yml

@@ -28,12 +28,12 @@ spring:
 ###################在家办公#####################
     password: qmsqrdev@2021
     username: qmsqrdev
-    url: jdbc:mysql://rm-uf6t3m8yo40d5b905go.mysql.rds.aliyuncs.com:3306/qms_qr_platform_dev?characterEncoding=utf8&serverTimezone=Asia/Shanghai
+    url: jdbc:mysql://rm-uf6t3m8yo40d5b905go.mysql.rds.aliyuncs.com:3306/qms_qr_platform_dev?characterEncoding=utf8&allowMultiQueries=true&serverTimezone=Asia/Shanghai
   rabbitmq:
     password: guest
     username: guest
     virtual-host: /
-    addresses: 192.168.2.53:5672
+    addresses: 127.0.0.1:5672
   redis:
     password: Abi@12345
     database: 0

+ 24 - 0
abi-cloud-qr-platform-server/src/main/resources/dao/mapper/InspectionCaseNumberMapper.xml

@@ -0,0 +1,24 @@
+<?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.abi.qms.platform.dao.mapper.InspectionCaseNumberMapper">
+
+    <resultMap type="com.abi.qms.platform.dao.entity.InspectionCaseNumber" id="InspectionCaseNumberResult">
+        <result property="id" column="id"/>
+        <result property="cityId" column="city_id"/>
+        <result property="number" column="number"/>
+        <result property="createTime" column="create_time"/>
+        <result property="createBy" column="create_by"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="isDelete" column="is_delete"/>
+    </resultMap>
+
+    <select id="getCaseNumber" resultType="java.lang.Long">
+        INSERT INTO inspection_case_number (city_id, number) VALUE (#{cityId}, 1) ON DUPLICATE KEY UPDATE number = number + 1;
+        SELECT number FROM inspection_case_number WHERE city_id = #{cityId};
+    </select>
+
+
+</mapper>

+ 42 - 0
abi-cloud-qr-platform-server/src/test/java/com/abi/qms/platform/InspectionTest.java

@@ -0,0 +1,42 @@
+package com.abi.qms.platform;
+
+import com.abi.qms.platform.service.InspectionCaseNumberService;
+import lombok.extern.slf4j.Slf4j;
+import org.junit.jupiter.api.Test;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.boot.test.context.SpringBootTest;
+
+import java.util.concurrent.CyclicBarrier;
+
+/**
+ * 稽查模块测试
+ * @author WeiganCai
+ * @date: 2021-07-20
+ */
+@SpringBootTest
+@Slf4j
+public class InspectionTest {
+	@Autowired
+	private InspectionCaseNumberService caseNumberService;
+
+	@Test
+	public void getCaseNumber() {
+		int threadCount = 10;
+		CyclicBarrier cyclicBarrier = new CyclicBarrier(threadCount);
+		Long cityId = 10010L;
+		for (int i = 0; i < threadCount; i++) {
+			new Thread(() -> {
+				try {
+					cyclicBarrier.await();
+					String caseNumber = caseNumberService.getCaseNumber(cityId).toString();
+					log.info(caseNumber);
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}).start();
+		}
+		while (true) {
+
+		}
+	}
+}