lenovodn 2 سال پیش
والد
کامیت
91edb4a140

+ 18 - 21
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/entity/ConsumableMaterial.java

@@ -31,7 +31,13 @@ import lombok.experimental.Accessors;
 @ApiModel(value="consumable_material对象", description="consumable_material")
 public class ConsumableMaterial implements Serializable {
     private static final long serialVersionUID = 1L;
-
+    /**主键ID*/
+    @TableId(type = IdType.AUTO)
+    @ApiModelProperty(value = "主键ID")
+    private java.lang.Integer id;
+    @Excel(name = "耗材代码", width = 15,orderNum = "0")
+    @ApiModelProperty(value = "耗材编码")
+    private java.lang.String consumableCode;
     @Excel(name = "一级分类 (学科、  品类)", width = 15,orderNum = "1")
     @ApiModelProperty(value = "一级分类")
     private java.lang.String oneCategory;
@@ -41,26 +47,21 @@ public class ConsumableMaterial implements Serializable {
     @Excel(name = "三级分类 (部位、功能、  品种)", width = 15,orderNum = "3")
     @ApiModelProperty(value = "三级分类")
     private java.lang.String threeCategory;
+    @Excel(name = "医保通用名", width = 15,orderNum = "4")
+    @ApiModelProperty(value = "医保通用名")
+    private java.lang.String consumableName;
+    @Excel(name = "耗材材质", width = 15,orderNum = "5")
+    @ApiModelProperty(value = "耗材材质")
+    private java.lang.String consumableMaterial;
 
-
-    /**规格*/
     @Excel(name = "规格 (特征、参数)", width = 15,orderNum = "6")
     @ApiModelProperty(value = "规格 (特征、参数)")
     private java.lang.String regSpe;
+    @Excel(name = "耗材企业", width = 15,orderNum = "7")
+    @ApiModelProperty(value = "企业名称")
+    private java.lang.String companyName;
 
 
-	/**主键ID*/
-	@TableId(type = IdType.AUTO)
-    @ApiModelProperty(value = "主键ID")
-    private java.lang.Integer id;
-	/**耗材名称*/
-	@Excel(name = "医保通用名", width = 15,orderNum = "4")
-    @ApiModelProperty(value = "医保通用名")
-    private java.lang.String consumableName;
-	/**耗材编码*/
-	@Excel(name = "耗材编码", width = 15,orderNum = "0")
-    @ApiModelProperty(value = "耗材编码")
-    private java.lang.String consumableCode;
 
 //    @Excel(name = "单价", width = 15)
     @ApiModelProperty(value = "单价")
@@ -71,17 +72,13 @@ public class ConsumableMaterial implements Serializable {
     @ApiModelProperty(value = "耗材版本")
     private java.lang.String consumableVersion;
 	/**耗材材质*/
-	@Excel(name = "耗材材质", width = 15,orderNum = "5")
-    @ApiModelProperty(value = "耗材材质")
-    private java.lang.String consumableMaterial;
+
 	/**注册备案产品名称*/
 //	@Excel(name = "注册备案产品名称", width = 15)
     @ApiModelProperty(value = "注册备案产品名称")
     private java.lang.String registeredProductName;
 	/**企业名称*/
-	@Excel(name = "企业名称", width = 15,orderNum = "7")
-    @ApiModelProperty(value = "企业名称")
-    private java.lang.String companyName;
+
 	/**产品名称*/
 //	@Excel(name = "产品名称", width = 15)
     @ApiModelProperty(value = "产品名称")

+ 10 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/AsyncService.java

@@ -0,0 +1,10 @@
+package org.jeecg.modules.medical.service;
+
+import org.jeecg.modules.medical.entity.ConsumableMaterial;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+public interface AsyncService {
+    public void executeAsync(List<ConsumableMaterial> list, IConsumableMaterialService consumableMaterialService, CountDownLatch countDownLatch);
+}

+ 30 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/impl/AsyncServiceImpl.java

@@ -0,0 +1,30 @@
+package org.jeecg.modules.medical.service.impl;
+
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.modules.medical.entity.ConsumableMaterial;
+import org.jeecg.modules.medical.service.AsyncService;
+import org.jeecg.modules.medical.service.IConsumableMaterialService;
+import org.springframework.scheduling.annotation.Async;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+@Service
+@Slf4j
+public class AsyncServiceImpl implements AsyncService {
+    @Override
+    @Async("commonTaskAsyncPool")
+    public void executeAsync(List<ConsumableMaterial> list, IConsumableMaterialService consumableMaterialService, CountDownLatch countDownLatch) {
+        try {
+            log.info("start executeAsync");
+            // 异步线程需要做的事情
+            consumableMaterialService.saveBatch(list);
+            log.info("end executeAsync");
+        } finally {
+            // 无论上面程序是否异常必须执行 countDown,否则 await 无法释放
+            countDownLatch.countDown();
+        }
+    }
+}

+ 17 - 13
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/medical/service/impl/ConsumableMaterialServiceImpl.java

@@ -5,9 +5,11 @@ import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.medical.entity.ConsumableMaterial;
 import org.jeecg.modules.medical.mapper.ConsumableMaterialMapper;
+import org.jeecg.modules.medical.service.AsyncService;
 import org.jeecg.modules.medical.service.IConsumableMaterialService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.scheduling.annotation.Async;
 import org.springframework.stereotype.Service;
 
@@ -32,6 +34,8 @@ import java.util.concurrent.CountDownLatch;
 @Slf4j
 public class ConsumableMaterialServiceImpl extends ServiceImpl<ConsumableMaterialMapper, ConsumableMaterial> implements IConsumableMaterialService {
 
+    @Autowired
+    private AsyncService asyncService;
 
     /**
      * 通过excel导入数据
@@ -55,7 +59,7 @@ public class ConsumableMaterialServiceImpl extends ServiceImpl<ConsumableMateria
                 List<List<ConsumableMaterial>> lists = Lists.partition(list, 1000);
                 CountDownLatch countDownLatch = new CountDownLatch(lists.size());
                 long startTime = System.currentTimeMillis();
-                lists.forEach(listSub -> executeAsync(listSub,  countDownLatch));
+                lists.forEach(listSub -> asyncService.executeAsync(listSub, this, countDownLatch));
                 try {
                     // 保证之前的所有的线程都执行完成,才会走下面的
                     countDownLatch.await();
@@ -87,16 +91,16 @@ public class ConsumableMaterialServiceImpl extends ServiceImpl<ConsumableMateria
     }
 
 
-    @Async("commonTaskAsyncPool")
-    public void executeAsync(List<ConsumableMaterial> list,  CountDownLatch countDownLatch) {
-        try {
-            log.info("start executeAsync");
-            // 异步线程需要做的事情
-            this.saveBatch(list);
-            log.info("end executeAsync");
-        } finally {
-            // 无论上面程序是否异常必须执行 countDown,否则 await 无法释放
-            countDownLatch.countDown();
-        }
-    }
+//    @Async("commonTaskAsyncPool")
+//    public void executeAsync(List<ConsumableMaterial> list, IConsumableMaterialService consumableMaterialService, CountDownLatch countDownLatch) {
+//        try {
+//            log.info("start executeAsync");
+//            // 异步线程需要做的事情
+//            consumableMaterialService.saveBatch(list);
+//            log.info("end executeAsync");
+//        } finally {
+//            // 无论上面程序是否异常必须执行 countDown,否则 await 无法释放
+//            countDownLatch.countDown();
+//        }
+//    }
 }