ソースを参照

李剑-节假日信息维护功能开发-完成模板下载(包括准备模板下载地址)功能。

lijian 4 年 前
コミット
d02ca7aa0c

+ 56 - 0
src/main/java/platform/common/util/holiday/HolidayExcelTemplateUtil.java

@@ -0,0 +1,56 @@
+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.Template;
+import platform.common.base.service.TemplateService;
+import platform.modules.government.entity.Attachment;
+import platform.modules.government.entity.FileDown;
+import platform.modules.government.service.AttachmentService;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Component
+public class HolidayExcelTemplateUtil {
+
+    @Autowired
+    private AttachmentService attachmentService;
+
+    @Autowired
+    private TemplateService templateService;
+
+    //private final int HOLIDAY_IMPORT_XLS_TEMPLATE_ID = 751;
+    private final String HOLIDAY_IMPORT_XLS_TEMPLATE_NAME = "导入节假日数据模板";
+
+    public Map<String, String> getTemplateFileInfo() {
+        Map<String,String> ret = new HashMap<>();
+
+        try {
+            int id = this.loadTemalateId();
+
+            List<Attachment> attachments = attachmentService.selectByIdAndBusinessId(Constant.Attachment.TEMPLATE, id, null);
+            if (null != attachments && attachments.size()>0) {
+                ret.put("templateFileUrl",attachments.get(0).getFile_url());
+                ret.put("templateFileName",attachments.get(0).getFile_name());
+            }
+        }catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+
+        return ret;
+    }
+
+    private int loadTemalateId() throws Exception{
+        Template entCondition = new Template();
+        entCondition.setName(HOLIDAY_IMPORT_XLS_TEMPLATE_NAME);
+        Template entRet;
+        entRet = templateService.findOne(entCondition);
+        return entRet.getId();
+    }
+
+
+}

+ 16 - 0
src/main/java/platform/modules/government/web/SupermeController.java

@@ -4,6 +4,7 @@ import java.io.IOException;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +29,7 @@ import platform.common.base.service.DictionaryTypeService;
 import platform.common.base.service.TemplateService;
 import platform.common.util.ReadExcelUtil;
 import platform.common.util.holiday.HolidayExcelParser;
+import platform.common.util.holiday.HolidayExcelTemplateUtil;
 import platform.modules.build.entity.BuildInfo;
 import platform.modules.build.service.BuildInfoService;
 import platform.modules.build.service.CompanyService;
@@ -45,6 +47,7 @@ import platform.modules.sys.service.SysConfigService;
 import platform.modules.sys.web.ResponseMessage;
 import tk.mybatis.mapper.entity.Example;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 
 @Controller
@@ -80,6 +83,9 @@ public class SupermeController extends BaseController {
 
 	@Autowired
 	private SysConfigService sysConfigService;
+
+	@Resource
+	private HolidayExcelTemplateUtil holidayExcelTemplateUtil;
 	
 	@GetMapping(value = "")
 	public String list() {
@@ -1047,6 +1053,11 @@ public class SupermeController extends BaseController {
 	@OperationLog(value = "新增假日信息")
 	@GetMapping(value = "/holiday/add")
 	public String addHolidayPage(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,ModelMap modelMap) {
+
+		Map<String,String> mapTemplateFileInfo = holidayExcelTemplateUtil.getTemplateFileInfo();
+		modelMap.put("templateFileUrl",mapTemplateFileInfo.get("templateFileUrl"));
+		modelMap.put("templateFileName",mapTemplateFileInfo.get("templateFileName"));
+		modelMap.put("fileUrl", setFileUrl());
 		return BASE_SUPER_PATH + "holiday/holiday_add";
 	}
 
@@ -1067,6 +1078,11 @@ public class SupermeController extends BaseController {
 		modelMap.put("configKey", holidayInfo.getConfigKey());
 		modelMap.put("configValue", holidayInfo.getConfigValue());
 
+
+		Map<String,String> mapTemplateFileInfo = holidayExcelTemplateUtil.getTemplateFileInfo();
+		modelMap.put("templateFileUrl",mapTemplateFileInfo.get("templateFileUrl"));
+		modelMap.put("templateFileName",mapTemplateFileInfo.get("templateFileName"));
+
 		modelMap.put("fileUrl", setFileUrl());
 		return BASE_SUPER_PATH + "holiday/holiday_add";
 	}

+ 3 - 1
src/main/resources/static/js/super/holiday/holiday_add.js

@@ -12,7 +12,9 @@ $(function () {
                         configKey: function () {
                             return $("#configKey").val();
                         },
-                        id: ''
+                        id: function () {
+                            return $("#id").val();
+                        }
                     }
                 }
             },

+ 8 - 0
src/main/resources/templates/admin/super/holiday/holiday_add.html

@@ -32,6 +32,14 @@
 			</div>
 		</div>
 
+
+		<div class="row cl">
+			<label class="form-label col-xs-4 col-sm-2"><span>模板文件:</span></label>
+			<div class="formControls col-xs-8 col-sm-9">
+				<a th:href="${fileUrl} + ${templateFileUrl}" target="_blank">[[${templateFileName}]]</a>
+			</div>
+		</div>
+
 		<div class="row cl">
 			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
 				<div class="uploader-thum-container">