Преглед изворни кода

李剑-假日信息维护-导入假日数据模板改进版,用模板类型的valu(uuid)定位,防止将来模板出现重名造成模板加载错误。

lijian пре 4 година
родитељ
комит
42f1f1b038

+ 28 - 2
src/main/java/platform/common/util/holiday/HolidayExcelTemplateUtil.java

@@ -3,7 +3,9 @@ package platform.common.util.holiday;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 import platform.common.Constant;
+import platform.common.base.model.DictionaryItem;
 import platform.common.base.model.Template;
+import platform.common.base.service.DictionaryItemService;
 import platform.common.base.service.TemplateService;
 import platform.modules.government.entity.Attachment;
 import platform.modules.government.service.AttachmentService;
@@ -21,7 +23,10 @@ public class HolidayExcelTemplateUtil {
     @Autowired
     private TemplateService templateService;
 
-    private final String HOLIDAY_IMPORT_XLS_TEMPLATE_NAME = "导入节假日数据模板";
+    @Autowired
+    private DictionaryItemService dictionaryItemService;
+
+    private final String DICT_ITEM_VALUE = "60dc644d-456d-4665-8dca-fbd7a2195592";
 
     public Map<String, String> getTemplateFileInfo() {
         Map<String,String> ret = new HashMap<>();
@@ -48,8 +53,16 @@ public class HolidayExcelTemplateUtil {
     }
 
     private int loadTemalateId() throws Exception{
+        //
+        int itemId = this.loadTemalateItemId();
+
+        if (-1 == itemId)
+        {
+            return -1;
+        }
+
         Template entCondition = new Template();
-        entCondition.setName(HOLIDAY_IMPORT_XLS_TEMPLATE_NAME);
+        entCondition.setItem_id(itemId);
         Template entRet;
         entRet = templateService.findOne(entCondition);
 
@@ -61,5 +74,18 @@ public class HolidayExcelTemplateUtil {
         return entRet.getId();
     }
 
+    private int loadTemalateItemId() {
+        DictionaryItem entCond = new DictionaryItem();
+        entCond.setValue(this.DICT_ITEM_VALUE);
+
+        DictionaryItem entRet = dictionaryItemService.findOne(entCond);
+
+        if (null == entRet)
+        {
+            return -1;
+        }
+        return entRet.getId();
+    }
+
 
 }