2018-03-06 10:06:42 +08:00
|
|
|
|
package com.nis.web.controller.basics;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
2018-07-02 16:24:50 +08:00
|
|
|
|
import java.util.ArrayList;
|
2018-03-28 13:05:56 +08:00
|
|
|
|
import java.util.Collections;
|
2018-10-22 19:15:21 +08:00
|
|
|
|
import java.util.HashMap;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
import java.util.List;
|
|
|
|
|
|
import java.util.Map;
|
2018-12-26 14:47:23 +08:00
|
|
|
|
import java.util.Properties;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
2018-03-28 08:42:32 +08:00
|
|
|
|
import org.apache.shiro.authz.annotation.Logical;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
|
|
|
|
import org.springframework.stereotype.Controller;
|
|
|
|
|
|
import org.springframework.ui.Model;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.ModelAttribute;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
2018-10-22 19:15:21 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.RequestMethod;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
|
|
|
|
import org.springframework.web.servlet.mvc.support.RedirectAttributes;
|
|
|
|
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
|
import com.google.common.collect.Maps;
|
|
|
|
|
|
import com.nis.domain.Page;
|
2018-12-26 14:47:23 +08:00
|
|
|
|
import com.nis.domain.SysUser;
|
2018-03-06 10:06:42 +08:00
|
|
|
|
import com.nis.domain.basics.ServiceDictInfo;
|
2018-03-31 17:23:11 +08:00
|
|
|
|
import com.nis.util.ConfigDictUtils;
|
2018-03-11 15:28:36 +08:00
|
|
|
|
import com.nis.util.Configurations;
|
2018-12-26 14:47:23 +08:00
|
|
|
|
import com.nis.util.Constants;
|
|
|
|
|
|
import com.nis.util.DateUtils;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
import com.nis.util.StringUtil;
|
|
|
|
|
|
import com.nis.util.StringUtils;
|
|
|
|
|
|
import com.nis.web.controller.BaseController;
|
2018-12-26 14:47:23 +08:00
|
|
|
|
import com.nis.web.security.UserUtils;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
|
|
|
|
|
@Controller
|
2018-03-06 10:06:42 +08:00
|
|
|
|
@RequestMapping(value = "${adminPath}/basics/serviceDictInfo")
|
2018-02-22 12:46:50 +08:00
|
|
|
|
public class ServiceDictInfoController extends BaseController {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ModelAttribute
|
|
|
|
|
|
public ServiceDictInfo get(@RequestParam(required=false) Integer serviceDictId) {
|
|
|
|
|
|
if (!StringUtil.isEmpty(serviceDictId)){
|
|
|
|
|
|
return serviceDictInfoService.getDictById(serviceDictId);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
return new ServiceDictInfo();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2018-11-09 21:11:09 +08:00
|
|
|
|
|
2018-10-22 19:15:21 +08:00
|
|
|
|
@ResponseBody
|
|
|
|
|
|
@RequestMapping(value="requestCancleInfoAjax", method = RequestMethod.POST)
|
|
|
|
|
|
public String requestCancleInfoAjax(Integer cancelRequestId,String ids,String indexTable){
|
|
|
|
|
|
if(!StringUtil.isEmpty(ids)){
|
|
|
|
|
|
String[] idArray = ids.split(",");
|
|
|
|
|
|
for(String id :idArray){
|
|
|
|
|
|
try {
|
|
|
|
|
|
serviceDictInfoService.auditCancleRequestInfo(cancelRequestId,indexTable,id);
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.error("审核添加取消来函信息失败",e);
|
|
|
|
|
|
return "false";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return "true";
|
|
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
*
|
|
|
|
|
|
* 根据id获取取消审核时的来函号信息
|
|
|
|
|
|
* @param ids
|
|
|
|
|
|
* @param indexTable
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
|
@RequestMapping(value="requestCancleInfoNumber")
|
|
|
|
|
|
public Map requestCancleInfoNumber(String ids,String indexTable){
|
|
|
|
|
|
List list = new ArrayList();
|
|
|
|
|
|
String requestTitle="";
|
|
|
|
|
|
Map map=new HashMap();
|
|
|
|
|
|
if(!StringUtil.isEmpty(ids)){
|
|
|
|
|
|
String[] idArray = ids.split(",");
|
|
|
|
|
|
// for(String id :idArray){
|
|
|
|
|
|
try {
|
|
|
|
|
|
Integer cancelRequestId= serviceDictInfoService.requestCancleInfoNumber(indexTable.trim(),Long.parseLong(ids));
|
|
|
|
|
|
if(cancelRequestId!=null) {
|
|
|
|
|
|
requestTitle = requestInfoService.getRequestTitleById(cancelRequestId.longValue());
|
|
|
|
|
|
if(StringUtils.isBlank(requestTitle)) {
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
|
logger.error("查询取消审核来函信息失败",e);
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
|
|
|
|
|
// }
|
|
|
|
|
|
}
|
|
|
|
|
|
map.put("requestTitle", requestTitle);
|
|
|
|
|
|
return map;
|
|
|
|
|
|
}
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-01 19:13:57 +08:00
|
|
|
|
* 查询业务辅助表-业务字典信息列表(无条件分页查询)
|
2018-03-12 14:47:59 +08:00
|
|
|
|
* (修改内容:添加查询数据总数,添加原则:不得修改原对象引用参数,不得影响原分页参数page数据)
|
2018-02-22 12:46:50 +08:00
|
|
|
|
* @param serviceDictInfo
|
|
|
|
|
|
* @param request
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-05 10:03:45 +08:00
|
|
|
|
@RequiresPermissions(value={"basics:classification:view","basics:attribute:view","basics:label:view","basics:vpn_ip:view"},logical=Logical.OR)
|
2018-02-22 12:46:50 +08:00
|
|
|
|
@RequestMapping(value = {"list", ""})
|
2018-03-28 08:42:32 +08:00
|
|
|
|
public String list(String itType, ServiceDictInfo serviceDictInfo,HttpServletRequest request, HttpServletResponse response, Model model) {
|
2018-03-04 19:20:32 +08:00
|
|
|
|
//处理数据
|
2018-03-31 17:23:11 +08:00
|
|
|
|
List<Integer> intArr = ConfigDictUtils.dealTypeCondition(Configurations.getStringProperty("SERVICE_DICT_ITM_TYPE", ""), itType);
|
2018-03-10 18:54:05 +08:00
|
|
|
|
String searchType = null;
|
|
|
|
|
|
String searchContent = null;
|
|
|
|
|
|
if(!StringUtils.isBlank(serviceDictInfo.getItemCode())){
|
|
|
|
|
|
searchType = "itemCode";
|
|
|
|
|
|
searchContent = serviceDictInfo.getItemCode();
|
|
|
|
|
|
}
|
|
|
|
|
|
if(!StringUtils.isBlank(serviceDictInfo.getItemValue())){
|
|
|
|
|
|
searchType = "itemValue";
|
|
|
|
|
|
searchContent = serviceDictInfo.getItemValue();
|
|
|
|
|
|
}
|
|
|
|
|
|
model.addAttribute("searchType", searchType);
|
|
|
|
|
|
model.addAttribute("searchContent", searchContent);
|
|
|
|
|
|
|
2018-03-21 13:43:43 +08:00
|
|
|
|
Page<ServiceDictInfo> pageCondition = new Page<ServiceDictInfo>(request, response);
|
2018-03-31 17:23:11 +08:00
|
|
|
|
|
2018-03-21 13:43:43 +08:00
|
|
|
|
//查询符合条件总数
|
|
|
|
|
|
List<ServiceDictInfo> allList = serviceDictInfoService.findAllServiceDictInfo(serviceDictInfo,intArr,pageCondition.getOrderBy());
|
2018-03-12 14:47:59 +08:00
|
|
|
|
model.addAttribute("showTotalCount", allList.size());
|
2018-03-21 13:43:43 +08:00
|
|
|
|
|
|
|
|
|
|
//查出顶层分页数据
|
2018-03-31 17:23:11 +08:00
|
|
|
|
Page<ServiceDictInfo> page = serviceDictInfoService.findTopDictList(pageCondition, serviceDictInfo,intArr);
|
|
|
|
|
|
|
|
|
|
|
|
|
2018-03-21 13:43:43 +08:00
|
|
|
|
// 植入序号
|
|
|
|
|
|
for (int i = 0; i < page.getList().size(); i++) {
|
|
|
|
|
|
page.getList().get(i).setShowSequence("" + (i + 1 + ((page.getPageNo() - 1) * page.getPageSize())));
|
2018-03-12 14:47:59 +08:00
|
|
|
|
}
|
2018-03-08 20:30:01 +08:00
|
|
|
|
model.addAttribute("page", page);
|
|
|
|
|
|
|
2018-03-28 08:42:32 +08:00
|
|
|
|
// 删除顶层数据、取出id
|
2018-03-21 13:43:43 +08:00
|
|
|
|
List<Integer> intList = Lists.newArrayList();
|
|
|
|
|
|
|
|
|
|
|
|
for(ServiceDictInfo tempSe : page.getList()) {
|
|
|
|
|
|
if (tempSe != null) {
|
|
|
|
|
|
intList.add(tempSe.getServiceDictId());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = allList.size() - 1; i >= 0; i--) {
|
2018-03-08 20:30:01 +08:00
|
|
|
|
ServiceDictInfo se = allList.get(i);
|
2018-03-21 13:43:43 +08:00
|
|
|
|
if(se!=null&&intList.contains(se.getServiceDictId())||(se!=null&&se.getParent().getServiceDictId()==0)){
|
|
|
|
|
|
allList.remove(se);
|
2018-03-08 20:30:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-21 13:43:43 +08:00
|
|
|
|
List<ServiceDictInfo> list = Lists.newArrayList();
|
|
|
|
|
|
|
2018-03-08 20:30:01 +08:00
|
|
|
|
allList.addAll(page.getList());
|
|
|
|
|
|
ServiceDictInfo.sortList(list,allList,0,true);
|
2018-03-21 13:43:43 +08:00
|
|
|
|
|
2018-03-12 14:47:59 +08:00
|
|
|
|
//处理下级序号
|
|
|
|
|
|
ServiceDictInfo.addChildrenSeq(list, 0);
|
2018-03-04 19:20:32 +08:00
|
|
|
|
model.addAttribute("itType", itType);
|
2018-03-31 17:23:11 +08:00
|
|
|
|
model.addAttribute("intArr", intArr);
|
2018-03-08 20:30:01 +08:00
|
|
|
|
model.addAttribute("list", list);
|
2018-03-21 13:43:43 +08:00
|
|
|
|
return "/basics/serviceDictList";
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 进入添加或修改页面
|
|
|
|
|
|
* @param serviceDictInfo
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-05 10:03:45 +08:00
|
|
|
|
@RequiresPermissions(value={"basics:classification:add","basics:attribute:add","basics:vpn_ip:add","basics:label:add","basics:classification:edit","basics:attribute:edit","basics:vpn_ip:edit","basics:label:edit","basics:classification:view","basics:attribute:view","basics:label:view","basics:vpn_ip:view"},logical=Logical.OR)
|
2018-02-22 12:46:50 +08:00
|
|
|
|
@RequestMapping(value={"form"})
|
2018-03-29 18:45:37 +08:00
|
|
|
|
public String form(ServiceDictInfo serviceDictInfo, Model model,String doAction,String itType) {
|
2018-02-22 12:46:50 +08:00
|
|
|
|
if(doAction!=null&&doAction.equals("0")){
|
2018-03-06 10:06:42 +08:00
|
|
|
|
return "/basics/serviceDictInfo";
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
2018-03-29 18:45:37 +08:00
|
|
|
|
if (serviceDictInfo==null||serviceDictInfo.getParent() == null || serviceDictInfo.getParent().getServiceDictId() == null) {
|
2018-03-01 19:13:57 +08:00
|
|
|
|
ServiceDictInfo parent = new ServiceDictInfo();
|
|
|
|
|
|
parent.setServiceDictId(0);
|
|
|
|
|
|
serviceDictInfo.setParent(parent);
|
|
|
|
|
|
}
|
2018-03-31 17:23:11 +08:00
|
|
|
|
List<Integer> intArr = ConfigDictUtils.dealTypeCondition(Configurations.getStringProperty("SERVICE_DICT_ITM_TYPE", ""), itType);
|
|
|
|
|
|
model.addAttribute("intArr", intArr);
|
2018-03-01 19:13:57 +08:00
|
|
|
|
model.addAttribute("serviceDictInfo", serviceDictInfo);
|
2018-03-04 19:20:32 +08:00
|
|
|
|
model.addAttribute("itType", itType);
|
2018-03-06 10:06:42 +08:00
|
|
|
|
return "/basics/serviceDictForm";
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 新增或修改
|
|
|
|
|
|
* @param serviceDictInfo
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @param redirectAttributes
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-05 10:03:45 +08:00
|
|
|
|
@RequiresPermissions(value={"basics:classification:add","basics:attribute:add","basics:label:add","basics:vpn_ip:add","basics:classification:edit","basics:attribute:edit","basics:label:edit","basics:vpn_ip:edit"},logical=Logical.OR)
|
2018-02-22 12:46:50 +08:00
|
|
|
|
@RequestMapping(value = "saveOrUpdate")
|
2018-03-04 19:20:32 +08:00
|
|
|
|
public String saveOrUpdate(ServiceDictInfo serviceDictInfo,Model model, RedirectAttributes redirectAttributes,String itType) {
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
serviceDictInfoService.saveOrUpdate(serviceDictInfo);
|
2018-12-13 14:01:06 +08:00
|
|
|
|
addMessage(redirectAttributes,"success", "save_success");
|
2018-02-22 12:46:50 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
2018-12-13 14:01:06 +08:00
|
|
|
|
addMessage(redirectAttributes,"error", "save_failed");
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
2018-03-04 19:20:32 +08:00
|
|
|
|
|
2018-03-06 10:06:42 +08:00
|
|
|
|
return "redirect:" + adminPath + "/basics/serviceDictInfo/list?itType="+itType;
|
2018-03-04 19:20:32 +08:00
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-01 19:13:57 +08:00
|
|
|
|
* 删除(删除时删除所有下级菜单)
|
2018-02-22 12:46:50 +08:00
|
|
|
|
* @param serviceDictInfo
|
|
|
|
|
|
* @param model
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-12-05 10:03:45 +08:00
|
|
|
|
@RequiresPermissions(value={"basics:classification:del","basics:attribute:del","basics:label:del","basics:vpn_ip:del"},logical=Logical.OR)
|
2018-02-22 12:46:50 +08:00
|
|
|
|
@RequestMapping(value={"delete"})
|
2018-03-10 18:54:05 +08:00
|
|
|
|
public String delete(ServiceDictInfo serviceDictInfo, RedirectAttributes redirectAttributes, String itType, String mulitId) {
|
2018-02-22 12:46:50 +08:00
|
|
|
|
try {
|
2018-03-10 18:54:05 +08:00
|
|
|
|
serviceDictInfoService.deleteDict(mulitId);
|
2018-12-13 14:01:06 +08:00
|
|
|
|
addMessage(redirectAttributes,"success", "delete_success");
|
2018-02-22 12:46:50 +08:00
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
e.printStackTrace();
|
2018-12-13 14:01:06 +08:00
|
|
|
|
addMessage(redirectAttributes,"error", "delete_failed");
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
2018-03-06 10:06:42 +08:00
|
|
|
|
return "redirect:" + adminPath + "/basics/serviceDictInfo/list?itType="+itType;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* isShowHide是否显示隐藏菜单
|
|
|
|
|
|
* @param extId
|
|
|
|
|
|
* @param isShowHidden
|
|
|
|
|
|
* @param response
|
2018-07-02 16:24:50 +08:00
|
|
|
|
* @param isShowLeaf是否查询叶子节点
|
2018-02-22 12:46:50 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
|
@RequestMapping(value = "treeData")
|
2018-07-02 16:24:50 +08:00
|
|
|
|
public List<Map<String, Object>> treeData(@RequestParam(required=false) String extId,@RequestParam(required=false) boolean isShowLeaf,
|
|
|
|
|
|
@RequestParam(required=false) String isShowHide, HttpServletResponse response, String itType) {
|
2018-02-22 12:46:50 +08:00
|
|
|
|
List<Map<String, Object>> mapList = Lists.newArrayList();
|
2018-03-04 19:20:32 +08:00
|
|
|
|
Map<String, Object> map2 = Maps.newHashMap();
|
2018-03-06 10:06:42 +08:00
|
|
|
|
map2.put("id", 0);
|
2018-03-04 19:20:32 +08:00
|
|
|
|
map2.put("pId", 0);
|
2018-03-28 08:42:32 +08:00
|
|
|
|
map2.put("name","root_node");
|
2018-03-04 19:20:32 +08:00
|
|
|
|
//map2.put("placeholder","0");
|
|
|
|
|
|
mapList.add(map2);
|
2018-07-02 16:24:50 +08:00
|
|
|
|
List<ServiceDictInfo> list = new ArrayList();
|
|
|
|
|
|
|
|
|
|
|
|
if(isShowLeaf){
|
|
|
|
|
|
if(itType.equals("1")){
|
|
|
|
|
|
list = serviceDictInfoService.findFlDict();
|
|
|
|
|
|
}else if(itType.equals("2")){
|
|
|
|
|
|
list = serviceDictInfoService.findXzDict();
|
|
|
|
|
|
}else{
|
|
|
|
|
|
list = serviceDictInfoService.findLableDict();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
//找出该类型所有的非叶子配置
|
|
|
|
|
|
list = serviceDictInfoService.findAllNoLeafDictList(itType);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
|
for (int i=0; i<list.size(); i++){
|
|
|
|
|
|
ServiceDictInfo serviceDictInfo = list.get(i);
|
|
|
|
|
|
if (StringUtils.isBlank(extId) || (extId !=null && !extId.equals(serviceDictInfo.getServiceDictId().toString()))) {
|
2018-03-01 19:13:57 +08:00
|
|
|
|
if(serviceDictInfo.getIsValid().equals(0)){
|
2018-02-22 12:46:50 +08:00
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
Map<String, Object> map = Maps.newHashMap();
|
|
|
|
|
|
map.put("id", serviceDictInfo.getServiceDictId());
|
|
|
|
|
|
map.put("pId", serviceDictInfo.getParent().getServiceDictId());
|
|
|
|
|
|
map.put("name",serviceDictInfo.getItemValue());
|
2018-03-04 19:20:32 +08:00
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
|
mapList.add(map);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return mapList;
|
|
|
|
|
|
}
|
2018-03-04 19:20:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
|
/**
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* 校验itemCode是否重复
|
|
|
|
|
|
* @param itemCode
|
2018-02-22 12:46:50 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-03-04 19:20:32 +08:00
|
|
|
|
@ResponseBody
|
|
|
|
|
|
@RequestMapping(value = "isItemCodeRepeat")
|
|
|
|
|
|
public boolean isItemCodeRepeat(String itemCode,String oldItemCode) {
|
|
|
|
|
|
List<ServiceDictInfo> list = Lists.newArrayList();
|
|
|
|
|
|
if(oldItemCode!=null&&itemCode.trim().equals(oldItemCode.trim())){
|
|
|
|
|
|
return true;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
2018-03-04 19:20:32 +08:00
|
|
|
|
if(!StringUtil.isEmpty(itemCode)){
|
2018-03-08 20:30:01 +08:00
|
|
|
|
list = serviceDictInfoService.findByItemCode(itemCode);
|
2018-03-01 19:13:57 +08:00
|
|
|
|
}
|
2018-03-04 19:20:32 +08:00
|
|
|
|
if(list==null||list.size()==0){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* 校验上下级配置数据类型
|
|
|
|
|
|
* @param parent 父级id
|
|
|
|
|
|
* param parent 子级类型
|
2018-02-22 12:46:50 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-03-04 19:20:32 +08:00
|
|
|
|
@ResponseBody
|
|
|
|
|
|
@RequestMapping(value = "ajaxType")
|
|
|
|
|
|
public boolean ajaxType(Integer parent,Integer child) {
|
|
|
|
|
|
if(parent==-1||parent==0){
|
|
|
|
|
|
return true;
|
2018-03-01 19:13:57 +08:00
|
|
|
|
}
|
2018-03-04 19:20:32 +08:00
|
|
|
|
ServiceDictInfo p = serviceDictInfoService.getDictById(parent);
|
|
|
|
|
|
if(p.getItemType()==child){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
2018-03-01 19:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* 校验更改数据类型后校验数据类型是否与下级冲突
|
|
|
|
|
|
* @param parent 父级id
|
|
|
|
|
|
* param parent 子级类型
|
2018-03-01 19:13:57 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-03-04 19:20:32 +08:00
|
|
|
|
@ResponseBody
|
|
|
|
|
|
@RequestMapping(value = "ajaxChildrenType")
|
2018-03-31 17:23:11 +08:00
|
|
|
|
public boolean ajaxChildrenType(Integer parent,Integer itemType) {
|
2018-03-04 19:20:32 +08:00
|
|
|
|
if(parent==null){
|
|
|
|
|
|
return true;
|
2018-03-01 19:13:57 +08:00
|
|
|
|
}
|
2018-03-04 19:20:32 +08:00
|
|
|
|
//比较下级任意一个对象
|
|
|
|
|
|
List<ServiceDictInfo> list = serviceDictInfoService.getDictByParentId(parent);
|
|
|
|
|
|
if(list==null||list.size()==0){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
for(ServiceDictInfo serviceDictInfo:list){
|
2018-03-31 17:23:11 +08:00
|
|
|
|
if(serviceDictInfo.getItemType()==itemType){
|
2018-03-04 19:20:32 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* 根据id取itemType
|
2018-02-22 12:46:50 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-03-04 19:20:32 +08:00
|
|
|
|
@ResponseBody
|
|
|
|
|
|
@RequestMapping(value = "ajaxItemType")
|
|
|
|
|
|
public Integer ajaxItemType(Integer parent) {
|
|
|
|
|
|
if(parent==0||parent==-1){
|
|
|
|
|
|
return 0;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
2018-03-04 19:20:32 +08:00
|
|
|
|
ServiceDictInfo p = serviceDictInfoService.getDictById(parent);
|
2018-02-22 12:46:50 +08:00
|
|
|
|
|
2018-03-04 19:20:32 +08:00
|
|
|
|
return p.getItemType();
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
/**
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* 校验叶子节点有下级不得更改为叶子节点
|
2018-02-22 12:46:50 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
2018-03-04 19:20:32 +08:00
|
|
|
|
@ResponseBody
|
|
|
|
|
|
@RequestMapping(value = "ajaxLeafChange")
|
|
|
|
|
|
public boolean ajaxLeafChange(Integer parent,Integer newIsLeaf) {
|
|
|
|
|
|
if(parent==null||parent==0){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
List<ServiceDictInfo> list = serviceDictInfoService.getDictByParentId(parent);
|
|
|
|
|
|
if(list==null||list.size()==0){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
if(newIsLeaf==0){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
2018-03-04 19:20:32 +08:00
|
|
|
|
return false;
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-01 19:13:57 +08:00
|
|
|
|
/**
|
2018-03-04 19:20:32 +08:00
|
|
|
|
* 校验叶子节点无父级不得更改为叶子节点
|
2018-03-01 19:13:57 +08:00
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ResponseBody
|
2018-03-04 19:20:32 +08:00
|
|
|
|
@RequestMapping(value = "ajaxLeafHasTree")
|
|
|
|
|
|
public boolean ajaxLeafHasTree(Integer serviceDictId,Integer newIsLeaf,Integer parentId) {
|
|
|
|
|
|
|
|
|
|
|
|
if(parentId==null||parentId==0||parentId==-1){
|
|
|
|
|
|
if(newIsLeaf==0){
|
|
|
|
|
|
return true;
|
2018-03-01 19:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-03-04 19:20:32 +08:00
|
|
|
|
if(parentId!=null&&parentId!=0){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
2018-03-01 19:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-08 20:30:01 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 校验层级关系
|
|
|
|
|
|
* @return
|
|
|
|
|
|
*/
|
|
|
|
|
|
@ResponseBody
|
|
|
|
|
|
@RequestMapping(value = "isLevelTotalSure")
|
|
|
|
|
|
public boolean isLevelTotalSure(Integer parentId,Integer currentId) {
|
2018-03-11 15:28:36 +08:00
|
|
|
|
//获取层级配置
|
|
|
|
|
|
int max = Integer.valueOf(Configurations.getIntProperty("maxLevelNo", 4));
|
2018-03-08 20:30:01 +08:00
|
|
|
|
if(parentId==-1||parentId==0){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}else{
|
|
|
|
|
|
ServiceDictInfo p = serviceDictInfoService.getDictById(parentId);
|
|
|
|
|
|
if(currentId==null){
|
2018-03-11 15:28:36 +08:00
|
|
|
|
if(p.getLevelNo()<max){
|
2018-03-08 20:30:01 +08:00
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}else{
|
2018-03-28 13:05:56 +08:00
|
|
|
|
if(p.getLevelNo()<max){
|
2018-03-31 17:23:11 +08:00
|
|
|
|
//查出该节点所有下级的层级数之和
|
2018-03-28 13:05:56 +08:00
|
|
|
|
List<ServiceDictInfo> list = serviceDictInfoService.getDictByParentId(currentId);
|
|
|
|
|
|
if(list==null||list.size()==0){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
List<ServiceDictInfo> resultList = Lists.newArrayList();
|
|
|
|
|
|
List<Integer> intList = Lists.newArrayList();
|
|
|
|
|
|
allTreeNode(1,list,resultList);
|
|
|
|
|
|
for(ServiceDictInfo se:resultList){
|
|
|
|
|
|
intList.add(se.getLevelNo());
|
|
|
|
|
|
}
|
|
|
|
|
|
int x = Collections.max(intList);
|
|
|
|
|
|
if((p.getLevelNo()+x)<(max+1)){
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
2018-03-08 20:30:01 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-03-28 13:05:56 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 查出所该节点下有树形子节点
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
2018-03-29 18:45:37 +08:00
|
|
|
|
public void allTreeNode(Integer levelNo, List<ServiceDictInfo> list,List<ServiceDictInfo> resultList){
|
2018-03-28 13:05:56 +08:00
|
|
|
|
if(list!=null&&list.size()>0){
|
|
|
|
|
|
for(ServiceDictInfo se:list){
|
|
|
|
|
|
se.setLevelNo(levelNo+1);
|
|
|
|
|
|
resultList.add(se);
|
|
|
|
|
|
List<ServiceDictInfo> newList = serviceDictInfoService.getDictByParentId(se.getServiceDictId());
|
|
|
|
|
|
allTreeNode(se.getLevelNo(),newList,resultList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-03-08 20:30:01 +08:00
|
|
|
|
|
|
|
|
|
|
|
2018-12-26 14:47:23 +08:00
|
|
|
|
// dict配置导出
|
|
|
|
|
|
@RequestMapping(value = "exportDict")
|
|
|
|
|
|
public void exportDict(String itType, ServiceDictInfo serviceDictInfo,Model model, HttpServletRequest request, HttpServletResponse response,
|
|
|
|
|
|
String ids, RedirectAttributes redirectAttributes,String exType,String hColumns) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
// export data info
|
|
|
|
|
|
List<String> titleList = new ArrayList<String>();
|
|
|
|
|
|
Map<String, Class<?>> classMap = new HashMap<String, Class<?>>();
|
|
|
|
|
|
Map<String, List> dataMap = new HashMap<String, List>();
|
|
|
|
|
|
Map<String, String> noExportMap = new HashMap<String, String>();
|
|
|
|
|
|
List<ServiceDictInfo> list = Lists.newArrayList();
|
|
|
|
|
|
List<Integer> intArr = ConfigDictUtils.dealTypeCondition(Configurations.getStringProperty("SERVICE_DICT_ITM_TYPE", ""), itType);
|
|
|
|
|
|
//处理数据
|
|
|
|
|
|
if (!StringUtil.isEmpty(ids)) {
|
|
|
|
|
|
list = serviceDictInfoService.findByDictInfo(ids,intArr);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
|
|
Page<ServiceDictInfo> pageCondition = new Page<ServiceDictInfo>(request, response);
|
|
|
|
|
|
pageCondition.setPageNo(1);
|
|
|
|
|
|
pageCondition.setPageSize(Constants.MAX_EXPORT_SIZE);
|
|
|
|
|
|
//查询符合条件总数
|
|
|
|
|
|
List<ServiceDictInfo> allList = serviceDictInfoService.findAllServiceDictInfo(serviceDictInfo,intArr,pageCondition.getOrderBy());
|
|
|
|
|
|
//查出顶层分页数据
|
|
|
|
|
|
Page<ServiceDictInfo> page = serviceDictInfoService.findTopDictList(pageCondition, serviceDictInfo,intArr);
|
|
|
|
|
|
// 删除顶层数据、取出id
|
|
|
|
|
|
List<Integer> intList = Lists.newArrayList();
|
|
|
|
|
|
for(ServiceDictInfo tempSe : page.getList()) {
|
|
|
|
|
|
if (tempSe != null) {
|
|
|
|
|
|
intList.add(tempSe.getServiceDictId());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
for (int i = allList.size() - 1; i >= 0; i--) {
|
|
|
|
|
|
ServiceDictInfo se = allList.get(i);
|
|
|
|
|
|
if(se!=null&&intList.contains(se.getServiceDictId())||(se!=null&&se.getParent().getServiceDictId()==0)){
|
|
|
|
|
|
allList.remove(se);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
allList.addAll(page.getList());
|
|
|
|
|
|
ServiceDictInfo.sortList(list,allList,0,true);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for(ServiceDictInfo tempSe : list) {
|
|
|
|
|
|
if(tempSe.getServiceDictCreator()!=null){
|
|
|
|
|
|
if(tempSe.getServiceDictCreator().getId()!=null){
|
|
|
|
|
|
SysUser creator=UserUtils.get(tempSe.getServiceDictCreator().getId().toString());
|
|
|
|
|
|
tempSe.setCreatorName(creator.getName());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(tempSe.getServiceDictEditor()!=null){
|
|
|
|
|
|
if(tempSe.getServiceDictEditor().getId()!=null){
|
|
|
|
|
|
SysUser creator=UserUtils.get(tempSe.getServiceDictEditor().getId().toString());
|
|
|
|
|
|
tempSe.setEditorName(creator.getName());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
String dictName=getDicName(intArr);
|
|
|
|
|
|
titleList.add(dictName);
|
|
|
|
|
|
classMap.put(dictName, ServiceDictInfo.class);
|
|
|
|
|
|
String cfgIndexInfoNoExport = "";
|
|
|
|
|
|
if("5".equals(itType)){
|
|
|
|
|
|
cfgIndexInfoNoExport=",item_type,is_leaf,&config_content:vpn_ip-";
|
|
|
|
|
|
}
|
|
|
|
|
|
if(serviceDictInfo.getBeginDate()==null){
|
|
|
|
|
|
cfgIndexInfoNoExport=",create_time,"+cfgIndexInfoNoExport;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(serviceDictInfo.getEditBeginDate()==null){
|
|
|
|
|
|
cfgIndexInfoNoExport=",edit_time,"+cfgIndexInfoNoExport;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!StringUtil.isEmpty(hColumns)) {
|
|
|
|
|
|
cfgIndexInfoNoExport = "," +hColumns+ ","+cfgIndexInfoNoExport;
|
|
|
|
|
|
}
|
|
|
|
|
|
noExportMap.put(dictName, cfgIndexInfoNoExport);
|
|
|
|
|
|
dataMap.put(dictName, list);
|
|
|
|
|
|
String timeRange = initDictMap(serviceDictInfo,dictName);
|
|
|
|
|
|
noExportMap.put("timeRange", timeRange);
|
|
|
|
|
|
if ("csv".equals(exType)) {
|
|
|
|
|
|
this._exportCsv(model, request, response, redirectAttributes, dictName, titleList,
|
|
|
|
|
|
classMap, dataMap, noExportMap);
|
|
|
|
|
|
} else {
|
|
|
|
|
|
this._export(model, request, response, redirectAttributes, dictName, titleList,
|
|
|
|
|
|
classMap, dataMap, noExportMap);
|
|
|
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
logger.error("dict white export failed", e);
|
|
|
|
|
|
addMessage(redirectAttributes, "error", "export_failed");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public String initDictMap(ServiceDictInfo cfg,String dictName){
|
|
|
|
|
|
Properties msgProp = getMsgProp();
|
|
|
|
|
|
String titleTime=dictName;
|
|
|
|
|
|
if(cfg.getBeginDate()!=null){
|
|
|
|
|
|
titleTime+=" "+msgProp.getProperty("create_time")+":"+DateUtils.formatDateTime(cfg.getBeginDate());
|
|
|
|
|
|
if(cfg.getEndDate()!=null){
|
|
|
|
|
|
titleTime+="—"+DateUtils.formatDateTime(cfg.getEndDate());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
titleTime+="—"+DateUtils.getDateTime();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if(cfg.getEditBeginDate()!=null){
|
|
|
|
|
|
titleTime+=" "+msgProp.getProperty("edit_time")+":"+DateUtils.formatDateTime(cfg.getEditBeginDate());
|
|
|
|
|
|
if(cfg.getEditEndDate()!=null){
|
|
|
|
|
|
titleTime+="—"+DateUtils.formatDateTime(cfg.getEditEndDate());
|
|
|
|
|
|
}else{
|
|
|
|
|
|
titleTime+="—"+DateUtils.getDateTime();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
return titleTime;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getDicName(List intArr){
|
|
|
|
|
|
String dicName="";
|
|
|
|
|
|
Properties msgProp = getMsgProp();
|
|
|
|
|
|
List<String> dict=ConfigDictUtils.getItemTypeByNo("SERVICE_DICT_ITM_TYPE",intArr);
|
|
|
|
|
|
if(dict.size()>0){
|
|
|
|
|
|
dicName=msgProp.getProperty(dict.get(0),dict.get(0));
|
|
|
|
|
|
}
|
|
|
|
|
|
return dicName;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-22 12:46:50 +08:00
|
|
|
|
}
|