Pārlūkot izejas kodu

案件编号返回省市

bess-WeiganCai 3 gadi atpakaļ
vecāks
revīzija
7b7c4b68f4

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

@@ -10,5 +10,5 @@ public interface InspectionCaseNumberService  {
 	/**
 	 * 根据cityId获取案件编号
 	 */
-	Long getCaseNumber(Long cityId);
+	String getCaseNumber(Long cityId);
 }

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

@@ -1,6 +1,9 @@
 package com.abi.qms.platform.service.impl;
 
+import com.abi.qms.platform.dao.entity.BaseArea;
+import com.abi.qms.platform.dao.mapper.BaseAreaMapper;
 import com.abi.qms.platform.dao.mapper.InspectionCaseNumberMapper;
+import com.abi.qms.platform.infrastructure.util.AssertUtil;
 import com.abi.qms.platform.service.InspectionCaseNumberService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,12 +21,22 @@ public class InspectionCaseNumberServiceImpl implements InspectionCaseNumberServ
     @Autowired
     private InspectionCaseNumberMapper caseNumberMapper;
 
+    @Autowired
+    private BaseAreaMapper areaMapper;
+
     /**
      * 根据cityId获取案件编号
      */
     @Override
-    public Long getCaseNumber(Long cityId) {
-        return caseNumberMapper.getCaseNumber(cityId);
+    public String getCaseNumber(Long cityId) {
+        BaseArea city = areaMapper.selectById(cityId);
+        AssertUtil.isNull(city, "城市不存在");
+
+        BaseArea province = areaMapper.selectById(city.getParentId());
+        AssertUtil.isNull(city, "省份不存在");
+
+        Long caseNumber = caseNumberMapper.getCaseNumber(cityId);
+        return new StringBuilder().append(province.getName()).append(city.getName()).append("#").append(caseNumber).toString();
     }
 
 }

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

@@ -568,7 +568,7 @@ public class InspectionCaseServiceImpl implements IInspectionCaseService {
     private String autoGenerateCaseNumber(Long provinceId, Long cityId) {
         AssertUtil.isNull(provinceId, "省份ID不能为空");
         AssertUtil.isNull(cityId, "城市ID不能为空");
-        return caseNumberService.getCaseNumber(cityId).toString();
+        return caseNumberService.getCaseNumber(cityId);
     }
 
 

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

@@ -23,12 +23,12 @@ public class InspectionTest {
 	public void getCaseNumber() {
 		int threadCount = 10;
 		CyclicBarrier cyclicBarrier = new CyclicBarrier(threadCount);
-		Long cityId = 10010L;
+		Long cityId = 320100L;
 		for (int i = 0; i < threadCount; i++) {
 			new Thread(() -> {
 				try {
 					cyclicBarrier.await();
-					String caseNumber = caseNumberService.getCaseNumber(cityId).toString();
+					String caseNumber = caseNumberService.getCaseNumber(cityId);
 					log.info(caseNumber);
 				} catch (Exception e) {
 					e.printStackTrace();