|
|
@@ -1,11 +1,15 @@
|
|
|
package platform.modules.government.web;
|
|
|
|
|
|
+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;
|
|
|
+import org.springframework.http.HttpStatus;
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
@@ -13,6 +17,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
import platform.common.Constant;
|
|
|
import platform.common.annotation.OperationLog;
|
|
|
import platform.common.base.controller.BaseController;
|
|
|
@@ -22,6 +27,9 @@ import platform.common.base.model.Template;
|
|
|
import platform.common.base.service.DictionaryItemService;
|
|
|
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;
|
|
|
@@ -34,9 +42,14 @@ import platform.modules.government.service.AttachmentService;
|
|
|
import platform.modules.government.service.BuildTypeService;
|
|
|
import platform.modules.government.service.StreetService;
|
|
|
import platform.modules.government.service.UserService;
|
|
|
+import platform.modules.sys.entity.SysConfig;
|
|
|
+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
|
|
|
@RequestMapping(value = "/super")
|
|
|
public class SupermeController extends BaseController {
|
|
|
@@ -67,6 +80,12 @@ public class SupermeController extends BaseController {
|
|
|
|
|
|
@Autowired
|
|
|
private AttachmentService attachmentService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SysConfigService sysConfigService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private HolidayExcelTemplateUtil holidayExcelTemplateUtil;
|
|
|
|
|
|
@GetMapping(value = "")
|
|
|
public String list() {
|
|
|
@@ -1004,4 +1023,194 @@ public class SupermeController extends BaseController {
|
|
|
return BASE_SUPER_PATH + "industry/industry_file_list";
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 假日信息管理列表展示
|
|
|
+ *
|
|
|
+ * @param pageNum
|
|
|
+ * @param modelMap
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @OperationLog(value = "读取假日信息列表")
|
|
|
+ @GetMapping(value = "/holidayList")
|
|
|
+ public String holidayList(@RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
|
+ ModelMap modelMap) throws Exception {
|
|
|
+
|
|
|
+ PageInfo<SysConfig> pageInfo = sysConfigService.findPage(pageNum, PAGESIZE,"year_");
|
|
|
+ modelMap.put("pageInfo", pageInfo);
|
|
|
+ //modelMap.put("fileUrl", setFileUrl());
|
|
|
+ return BASE_SUPER_PATH + "holiday/holiday_list";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 添加假日信息
|
|
|
+ * @param pageNum
|
|
|
+ * @param modelMap
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @OperationLog(value = "新增假日信息")
|
|
|
+ @GetMapping(value = "/holiday/add")
|
|
|
+ public String addHolidayPage(ModelMap modelMap) {
|
|
|
+
|
|
|
+ Map<String,String> mapTemplateFileInfo = holidayExcelTemplateUtil.getTemplateFileInfo();
|
|
|
+ //modelMap.put("templateFileUrl",mapTemplateFileInfo.get("templateFileUrl"));
|
|
|
+ //modelMap.put("templateFileName",mapTemplateFileInfo.get("templateFileName"));
|
|
|
+ modelMap.putAll(mapTemplateFileInfo);
|
|
|
+ modelMap.put("fileUrl", setFileUrl());
|
|
|
+ return BASE_SUPER_PATH + "holiday/holiday_add";
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改相应假日信息
|
|
|
+ * @param modelMap
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @OperationLog(value = "编辑假日信息")
|
|
|
+ @GetMapping(value = "/holiday/edit/{id}")
|
|
|
+ public String editHolidayPage(@PathVariable("id") Integer id,ModelMap modelMap) {
|
|
|
+ SysConfig holidayInfo = sysConfigService.findById(id);
|
|
|
+
|
|
|
+ modelMap.put("id", holidayInfo.getId());
|
|
|
+ modelMap.put("configName", holidayInfo.getConfigName());
|
|
|
+ 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.putAll(mapTemplateFileInfo);
|
|
|
+ modelMap.put("fileUrl", setFileUrl());
|
|
|
+ return BASE_SUPER_PATH + "holiday/holiday_add";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @OperationLog(value = "节假日信息【物理】删除")
|
|
|
+ @ResponseBody
|
|
|
+ @DeleteMapping(value = "/holiday/delete/{id}")
|
|
|
+ public ResponseMessage deleteHoliday(@PathVariable("id") int id) {
|
|
|
+ /*
|
|
|
+ SysConfig ent2Del = sysConfigService.findById(id);
|
|
|
+ if (null == ent2Del) {
|
|
|
+ return ResponseMessage.error("未找到相应的假日信息");
|
|
|
+ }
|
|
|
+ ent2Del.setDel_flag(true);
|
|
|
+ sysConfigService.update(ent2Del);
|
|
|
+
|
|
|
+ */
|
|
|
+
|
|
|
+ sysConfigService.deleteById(id);
|
|
|
+
|
|
|
+ return ResponseMessage.success("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+ @OperationLog(value = "导入假日信息")
|
|
|
+ @PostMapping(value = "/holiday/import")
|
|
|
+ public ResponseEntity<String> importHoliday(HttpServletRequest request, @RequestParam("file") MultipartFile file) throws IOException {
|
|
|
+ Map<String, String> mapParseRet;
|
|
|
+
|
|
|
+ String retInfo = "";
|
|
|
+ if (file.isEmpty()) {
|
|
|
+ return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("文件不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ArrayList<String>> readExcel = new ArrayList<>();
|
|
|
+ try {
|
|
|
+ //调用util方法拿到解析的数据集合
|
|
|
+ readExcel = new ReadExcelUtil().readExcel(file);
|
|
|
+ // 进一步解析
|
|
|
+
|
|
|
+ mapParseRet = HolidayExcelParser.parse(readExcel);
|
|
|
+
|
|
|
+ if ("true".equals(mapParseRet.get("valid")))
|
|
|
+ {
|
|
|
+ retInfo = mapParseRet.get("data");
|
|
|
+ }else
|
|
|
+ {
|
|
|
+ retInfo = mapParseRet.get("errMsg");
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResponseEntity.status(HttpStatus.OK).body(retInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @OperationLog(value = "假日信息保存")
|
|
|
+ @ResponseBody
|
|
|
+ @PostMapping(value = "/holiday/save")
|
|
|
+ public ModelMap saveHoliday(@RequestParam(value = "id", defaultValue = "-1") int id,
|
|
|
+ @RequestParam(value = "configName", defaultValue = "") String configName,
|
|
|
+ @RequestParam(value = "configKey", defaultValue = "") String configKey,
|
|
|
+ @RequestParam(value = "configValue", defaultValue = "") String configValue) throws Exception {
|
|
|
+ ModelMap messagesMap = new ModelMap();
|
|
|
+
|
|
|
+ if(IsTooFrequently()) {
|
|
|
+ messagesMap.put("status", FAILURE);
|
|
|
+ messagesMap.put("message", "操作过于频繁,请稍后再试!");
|
|
|
+ return messagesMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ SysConfig ent2Save;
|
|
|
+ if (-1 < id)
|
|
|
+ {
|
|
|
+ ent2Save = sysConfigService.findById(id);
|
|
|
+ }else{
|
|
|
+ ent2Save = new SysConfig();
|
|
|
+ }
|
|
|
+
|
|
|
+ ent2Save.setConfigName(configName);
|
|
|
+ ent2Save.setConfigKey(configKey);
|
|
|
+ ent2Save.setConfigValue(configValue.replace(""","\""));
|
|
|
+ ent2Save.setDel_flag(false);
|
|
|
+
|
|
|
+
|
|
|
+ if (-1 < id)
|
|
|
+ {
|
|
|
+ sysConfigService.update(ent2Save);
|
|
|
+ }else{
|
|
|
+ sysConfigService.save(ent2Save);
|
|
|
+ }
|
|
|
+
|
|
|
+ messagesMap.put("status", SUCCESS);
|
|
|
+ messagesMap.put("message", "保存成功!");
|
|
|
+ return messagesMap;
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 同一年份假日信息是否存在
|
|
|
+ *
|
|
|
+ * @param configKey
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @OperationLog(value = "同一年份假日信息是否存在")
|
|
|
+ @ResponseBody
|
|
|
+ @GetMapping(value = "/isExistHoliday")
|
|
|
+ public Boolean isExistHoliday(String id, String configKey) throws Exception {
|
|
|
+ boolean flag = true;
|
|
|
+ log.debug("检验同一年份假日信息是否存在参数! id= {}, configKey= {}", id, configKey);
|
|
|
+ SysConfig entExist = sysConfigService.getByKey(configKey);
|
|
|
+
|
|
|
+ if (null != entExist) {
|
|
|
+ if (StringUtils.isBlank(id)) {
|
|
|
+ flag = false;
|
|
|
+
|
|
|
+ } else {
|
|
|
+ if (entExist.getId() != (Integer.parseInt(id))) {
|
|
|
+ flag = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ log.info("检验假日信息年份是否存在结果! flag = {}", flag);
|
|
|
+ return flag;
|
|
|
+ }
|
|
|
}
|
|
|
+
|