|
@@ -0,0 +1,224 @@
|
|
|
|
+/**
|
|
|
|
+ * Copyright © 2015-2020 <a href="http://www.jeeplus.org/">JeePlus</a> All rights reserved.
|
|
|
|
+ */
|
|
|
|
+package com.jeeplus.modules.sg.managementcenter.moduleacquisition.web;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+import com.jeeplus.common.json.AjaxJson;
|
|
|
|
+import com.jeeplus.common.utils.StringUtils;
|
|
|
|
+import com.jeeplus.common.utils.excel.ImportExcel;
|
|
|
|
+import com.jeeplus.core.persistence.Page;
|
|
|
|
+import com.jeeplus.core.web.BaseController;
|
|
|
|
+import com.jeeplus.modules.sg.managementcenter.moduleacquisition.entity.ModuleBlock;
|
|
|
|
+import com.jeeplus.modules.sg.managementcenter.moduleacquisition.entity.ModuleListing;
|
|
|
|
+import com.jeeplus.modules.sg.managementcenter.moduleacquisition.entity.ModuleVersion;
|
|
|
|
+import com.jeeplus.modules.sg.managementcenter.moduleacquisition.service.ModuleBlockService;
|
|
|
|
+import com.jeeplus.modules.sg.managementcenter.moduleacquisition.service.ModuleListingService;
|
|
|
|
+import com.jeeplus.modules.sg.managementcenter.moduleacquisition.util.ModuleUtil;
|
|
|
|
+import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
|
|
|
|
+import org.apache.shiro.authz.annotation.Logical;
|
|
|
|
+import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.stereotype.Controller;
|
|
|
|
+import org.springframework.ui.Model;
|
|
|
|
+import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
+import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
+
|
|
|
|
+import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
|
+import javax.servlet.http.HttpSession;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+@Controller
|
|
|
|
+@RequestMapping(value = "${adminPath}/managementcenter/moduleacquisition")
|
|
|
|
+public class ModuleBlockWeb extends BaseController {
|
|
|
|
+
|
|
|
|
+ @Autowired
|
|
|
|
+ private ModuleBlockService moduleBlockService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ModuleListingService moduleListingService;
|
|
|
|
+
|
|
|
|
+ @ModelAttribute
|
|
|
|
+ public ModuleBlock get(@RequestParam(required=false) String id) {
|
|
|
|
+ ModuleBlock entity = null;
|
|
|
|
+ if (StringUtils.isNotBlank(id)){
|
|
|
|
+ entity = moduleBlockService.get(id);
|
|
|
|
+ }
|
|
|
|
+ if (entity == null){
|
|
|
|
+ entity = new ModuleBlock();
|
|
|
|
+ }
|
|
|
|
+ return entity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 项目列表页面
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("managementcenter:moduleacquisition:list")
|
|
|
|
+ @RequestMapping(value = {"list", ""})
|
|
|
|
+ public String list(ModuleBlock moduleBlock, Model model) {
|
|
|
|
+ model.addAttribute("ModuleBlock", moduleBlock);
|
|
|
|
+ return "modules/sg/managementcenter/moduleacquisition/moduleBlockList";
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 列表数据
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequiresPermissions("managementcenter:moduleacquisition:list")
|
|
|
|
+ @RequestMapping(value = "data")
|
|
|
|
+ public Map<String, Object> data(ModuleBlock moduleBlock, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
+ Page<ModuleBlock> page = moduleBlockService.findPage(new Page<ModuleBlock>(request, response), moduleBlock);
|
|
|
|
+ return getBootstrapData(page);
|
|
|
|
+ }
|
|
|
|
+ /**
|
|
|
|
+ * 生成新版本列表数据
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "newData")
|
|
|
|
+ public Map<String, Object> newData(ModuleBlock moduleBlock, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
+ String md_version = (String) session.getAttribute("md_version");
|
|
|
|
+ Integer version = new Integer(md_version) + 1;
|
|
|
|
+ moduleBlock.setMdVersion(String.valueOf(version));
|
|
|
|
+ Page<ModuleBlock> page = moduleBlockService.findPage(new Page<ModuleBlock>(request, response), moduleBlock);
|
|
|
|
+ return getBootstrapData(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看,增加,编辑表单页面
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions(value={"managementcenter:moduleacquisition:view","managementcenter:moduleacquisition:list","managementcenter:moduleacquisition:edit"},logical=Logical.OR)
|
|
|
|
+ @RequestMapping(value = "form")
|
|
|
|
+ public String form(ModuleBlock moduleBlock, Model model) {
|
|
|
|
+ model.addAttribute("moduleBlock", moduleBlock);
|
|
|
|
+ return "modules/sg/managementcenter/moduleacquisition/moduleBlockNewForm";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 查看,增加,编辑表单页面
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions(value={"managementcenter:moduleacquisition:view","managementcenter:moduleacquisition:list","managementcenter:moduleacquisition:edit"},logical=Logical.OR)
|
|
|
|
+ @RequestMapping(value = "form1")
|
|
|
|
+ public String form1(ModuleBlock moduleBlock, Model model) {
|
|
|
|
+ model.addAttribute("moduleBlock", moduleBlock);
|
|
|
|
+ return "modules/sg/managementcenter/moduleacquisition/moduleBlockForm";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 保存
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+// @RequiresPermissions(value={"managementcenter:moduleacquisition:add","managementcenter:moduleacquisition:edit"},logical=Logical.OR)
|
|
|
|
+ @RequestMapping(value = "save")
|
|
|
|
+ public AjaxJson save(ModuleBlock moduleBlock, Model model,HttpServletRequest request) throws Exception{
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
+ String md_version = (String) session.getAttribute("md_version");
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ /**
|
|
|
|
+ * 后台hibernate-validation插件校验
|
|
|
|
+ */
|
|
|
|
+ String errMsg = beanValidator(moduleBlock);
|
|
|
|
+ if (StringUtils.isNotBlank(errMsg)){
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg(errMsg);
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+ //新增或编辑表单保存
|
|
|
|
+ Integer version = new Integer(md_version) + 1;
|
|
|
|
+ moduleBlock.setMdVersion(String.valueOf(version));
|
|
|
|
+ moduleBlockService.save(moduleBlock);//保存
|
|
|
|
+ j.setSuccess(true);
|
|
|
|
+ j.setMsg("保存模块成功");
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 删除项目
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequiresPermissions("managementcenter:moduleacquisition:del")
|
|
|
|
+ @RequestMapping(value = "delete")
|
|
|
|
+ public AjaxJson delete(ModuleBlock moduleBlock) {
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ moduleBlockService.delete(moduleBlock);
|
|
|
|
+ j.setMsg("删除项目成功");
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 批量删除
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequiresPermissions("managementcenter:moduleacquisition:del")
|
|
|
|
+ @RequestMapping(value = "deleteAll")
|
|
|
|
+ public AjaxJson deleteAll(String ids) {
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ String idArray[] =ids.split(",");
|
|
|
|
+ for(String id : idArray){
|
|
|
|
+ moduleBlockService.delete(moduleBlockService.get(id));
|
|
|
|
+ }
|
|
|
|
+ j.setMsg("删除项目成功");
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 导入Excel数据
|
|
|
|
+
|
|
|
|
+ */
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequiresPermissions("managementcenter:moduleacquisition:import")
|
|
|
|
+ @RequestMapping(value = "import")
|
|
|
|
+ public AjaxJson importFile(@RequestParam("file")MultipartFile file, HttpServletResponse response, HttpServletRequest request) throws IOException, InvalidFormatException {
|
|
|
|
+ AjaxJson j = new AjaxJson();
|
|
|
|
+ try {
|
|
|
|
+ ImportExcel importBlock = new ImportExcel(file, 0, "模块表");
|
|
|
|
+ ImportExcel importListing = new ImportExcel(file, 0, "模块清单");
|
|
|
|
+ List<ModuleBlock> moduleBlockUtil = ModuleUtil.getModuleBlockUtil(importBlock);
|
|
|
|
+ List<ModuleListing> moduleListingUtil = ModuleUtil.getModuleListingUtil(importListing);
|
|
|
|
+ String maxVersion = moduleBlockService.findVersion();//获得版本号
|
|
|
|
+ moduleBlockService.savaList(moduleBlockUtil,moduleListingUtil,maxVersion);
|
|
|
|
+ j.setMsg( "已成功导入 "+moduleBlockUtil.size()+" 条记录");
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ j.setSuccess(false);
|
|
|
|
+ j.setMsg("导入表单失败!失败信息:"+e.getMessage());
|
|
|
|
+ }
|
|
|
|
+ return j;
|
|
|
|
+ }
|
|
|
|
+ /*
|
|
|
|
+ 生成新版本
|
|
|
|
+ */
|
|
|
|
+ @RequestMapping(value = "insertVersion")
|
|
|
|
+ public String saveVersion(String mdVersion,ModuleBlock moduleBlock,Model model,HttpServletRequest request) {
|
|
|
|
+ String version = moduleBlockService.findVersion();
|
|
|
|
+ HttpSession session = request.getSession();
|
|
|
|
+ session.setAttribute("md_version",version);
|
|
|
|
+ moduleBlock.setMdVersion(mdVersion);
|
|
|
|
+ List<ModuleBlock> moduleBlocks = moduleBlockService.findList(moduleBlock);
|
|
|
|
+ List<ModuleListing> moduleListings = moduleListingService.findByList(moduleBlocks);
|
|
|
|
+ moduleBlockService.savaList(moduleBlocks,moduleListings,version);
|
|
|
|
+ model.addAttribute("ModuleBlock",moduleBlock);
|
|
|
|
+ return "modules/sg/managementcenter/moduleacquisition/moduleBlockNewList";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @ResponseBody
|
|
|
|
+ @RequestMapping(value = "dataVersion")
|
|
|
|
+ public Map<String, Object> dataVersion(ModuleVersion version, HttpServletRequest request, HttpServletResponse response, Model model) {
|
|
|
|
+ Page<ModuleVersion> page = moduleBlockService.findPage(new Page<ModuleVersion>(request, response), version);
|
|
|
|
+ return getBootstrapData(page);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 生成新版本页面
|
|
|
|
+ */
|
|
|
|
+ @RequiresPermissions("managementcenter:moduleacquisition:insertVersion")
|
|
|
|
+ @RequestMapping(value ="listVersion")
|
|
|
|
+ public String listVersion(ModuleVersion moduleVersion, Model model,HttpServletRequest request) {
|
|
|
|
+ model.addAttribute("ModuleVersion",moduleVersion);
|
|
|
|
+ return "modules/sg/managementcenter/moduleacquisition/moduleVersionList";
|
|
|
|
+ }
|
|
|
|
+}
|