package com.landtool.lanbase.modules.res.controller;
|
|
import java.sql.Timestamp;
|
import java.util.Date;
|
import java.util.HashMap;
|
import java.util.LinkedList;
|
import java.util.List;
|
import java.util.Map;
|
|
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.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.landtool.lanbase.common.annotation.LogAction;
|
import com.landtool.lanbase.common.utils.Result;
|
import com.landtool.lanbase.config.SysTemPropertyConfig;
|
import com.landtool.lanbase.modules.log.service.LogActionService;
|
import com.landtool.lanbase.modules.res.entity.Res_Catalog;
|
import com.landtool.lanbase.modules.res.entity.Res_MainInfo;
|
import com.landtool.lanbase.modules.res.service.ResCatalogService;
|
import com.landtool.lanbase.modules.res.service.ResMainInfoService;
|
import com.landtool.lanbase.modules.sys.controller.AbstractController;
|
|
/**
|
* @Date: 2018-03-03 8:50
|
* @Description:资源目录编目管理
|
*/
|
|
@Controller
|
@RequestMapping("/res")
|
public class ResCatalogController extends AbstractController {
|
@Autowired
|
private ResMainInfoService resMainInfoService;
|
|
@Autowired
|
private ResCatalogService resCatalogService;
|
|
@Autowired
|
private SysTemPropertyConfig sysConfig;
|
|
@Autowired
|
private LogActionService logActionService;
|
|
/**
|
* @Description: 后台访问目录编目管理页面
|
* @author
|
* @date 2018/3/19 16:29
|
*/
|
/**@RequestMapping("/ResManage/ResRegister/IndexCatalog") public String IndexCatalog(Model model) {
|
model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
|
return "ResManage/ResCatalog/Index";
|
}
|
*/
|
|
/**
|
* @Description: 后台访问目录编目管理页面(新)
|
*/
|
@RequestMapping("manage/catalog/index")
|
public String CatalogIndex(Model model) {
|
model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
|
model.addAttribute("systemName", sysConfig.getAppFullName());
|
return "manage/catalog/index";
|
}
|
|
/**
|
* @Description: 查询目录结构
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/selectmulu")
|
public String selectDirectoryStructure(int id) {
|
List<Res_Catalog> resCatalogList = resCatalogService.selectResCatalogToParentid(id);
|
String resCatalogJson = "";
|
|
for (Res_Catalog resCatalog : resCatalogList) {
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(resCatalog.getCatlogid(),null);
|
resCatalogJson += (resCatalogJson.length() > 0 ? "," : "") + "{id:" + resCatalog.getCatlogid() + ", name:'" + resCatalog.getTitle()
|
+ "', pId:" + resCatalog.getParentid()
|
+ ", rpId:" + resCatalog.getParentid();
|
if(resCatalog.getIcon()==null || resCatalog.getIcon().equals("")){
|
resCatalogJson +=(childCount > 0 ? ",isParent:true,iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'" : ",icon:'/image/classicons/defaulticon.png'")
|
+ ", code: '" + resCatalog.getCatlogcode() + "'}";
|
}else {
|
resCatalogJson +=((childCount > 0 ? ",isParent:true":"")+",icon:'"+"/uploadPath/"+resCatalog.getIcon())
|
+ "', code: '" + resCatalog.getCatlogcode()+ "'}";
|
}
|
}
|
return "[" + resCatalogJson + "]";
|
}
|
|
/**
|
* @Description: 获取目录信息
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/getcataloginfo")
|
public Result getCatalogInfo(int id) {
|
Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(id);
|
String result = "";
|
Map<String, Object> map = new HashMap<>();
|
if (resCatalog == null) {
|
map.put("success",true);
|
map.put("id",0);
|
map.put("name","资源目录");
|
map.put("no",0);
|
map.put("index", null);
|
map.put("beizhu", null);
|
map.put("icon",null);
|
// result = "{ success: true,id:\"0\",name:\"资源目录\",no:0,index:null,beizhu:null,icon:null}";
|
} else {
|
map.put("success",true);
|
map.put("id", resCatalog.getCatlogid());
|
map.put("name", resCatalog.getTitle());
|
map.put("no", resCatalog.getCatlogcode());
|
map.put("index", resCatalog.getDescription());
|
map.put("beizhu", resCatalog.getRemark());
|
map.put("icon",resCatalog.getIcon());
|
// result = "{ success: true,id:\"" + resCatalog.getCatlogid() + "\",name:\"" + resCatalog.getTitle() + "\",no:\"" + resCatalog.getCatlogcode() + "\",index:\"" + resCatalog.getDescription() + "\",beizhu:\"" + resCatalog.getRemark() +"\",icon:\"" + resCatalog.getIcon() + "\"}";
|
}
|
return Result.ok().put("result",map);
|
}
|
|
/**
|
* @Description: 新增子集页面
|
*/
|
@ResponseBody
|
@RequestMapping("manage/catalog/addchildren")
|
public String addChildren(int id) {
|
Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(id);
|
String orderid = "";
|
if (resCatalog == null) {
|
//根目录的排序ID为0,需要特殊处理
|
orderid = resCatalogService.getMaxCATLOGCODEFromMainIndex(0);
|
if (orderid == null) {
|
orderid = "01";
|
} else {
|
int newOrderid = Integer.valueOf(orderid) + 1;
|
if(newOrderid < 10) {
|
orderid = "0" + String.valueOf(newOrderid);
|
} else {
|
orderid = String.valueOf(newOrderid);
|
}
|
}
|
} else {
|
orderid = resCatalogService.getMaxCATLOGCODE(id);
|
if (orderid == null) {
|
orderid = String.valueOf(resCatalog.getCatlogcode()) + "01";
|
} else {
|
int newOrderid = Integer.valueOf(orderid) + 1;
|
if(orderid.startsWith("0")) {
|
orderid = "0" + String.valueOf(newOrderid);
|
} else {
|
orderid = String.valueOf(newOrderid);
|
}
|
}
|
}
|
Object FatherName = "";
|
if (id == 0) {
|
//根目录的排序ID为0,需要特殊处理
|
FatherName = "资源目录";
|
} else {
|
FatherName = resCatalog.getTitle();
|
}
|
String resCatalogJson = "";
|
if (resCatalog == null) {
|
resCatalogJson += "{id:" + 0 + ", name:'" + FatherName + "', pId:" + 0 + ", oId:'" + orderid + "'}";
|
} else {
|
resCatalogJson += "{id:" + resCatalog.getCatlogid() + ", name:'" + FatherName + "', pId:" + resCatalog.getParentid() + ", oId:'" + orderid + "'}";
|
}
|
//查询当前父节点的信息 返回到前台
|
return resCatalogJson;
|
}
|
|
/**
|
* @Description: 新增子目录方法
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/insert")
|
@LogAction("资源管理,资源编目,资源目录新增(子级),新增")
|
public String insert(Res_Catalog model) {
|
//录入人暂时名字,以后修改
|
model.setCreateuser(getLoginName());
|
Timestamp audittime = new Timestamp(new Date().getTime());
|
//生成当前时间
|
model.setCreatedate(audittime);
|
String orderid = "";
|
if (model.getParentid() == 0) {
|
//根目录的排序ID为0,需要特殊处理
|
orderid = resCatalogService.getMaxOrderIdFromMainIndex(model.getParentid());
|
if (orderid == null) {
|
orderid = "1";
|
} else {
|
int newOrderid = Integer.valueOf(orderid) + 1;
|
orderid = String.valueOf(newOrderid);
|
}
|
} else {
|
orderid = resCatalogService.getMaxOrderId(model.getParentid());
|
//获取目标目录最大的排序ID
|
if (orderid == null) {
|
Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(model.getParentid());
|
orderid = String.valueOf(resCatalog.getOrderid()) + "01";
|
} else {
|
int newOrderid = Integer.valueOf(orderid) + 1;
|
orderid = String.valueOf(newOrderid);
|
}
|
}
|
model.setOrderid(Integer.valueOf(orderid));
|
int result = resCatalogService.insertSelective(model);
|
if (result == 1) {
|
return "新增成功";
|
} else {
|
return "失败";
|
}
|
}
|
|
/**
|
* @Description: 目录修改页面
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/edit")
|
public Result edit(int id) {
|
Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(id);
|
Res_Catalog resCatalogf = resCatalogService.getResCatalogInfoById(resCatalog.getParentid());
|
//查询需要修改目录的信息返回
|
String resCatalogJson = "";
|
Map<String,Object> map = new HashMap<>();
|
|
map.put("id", resCatalog.getCatlogid());
|
map.put("name", resCatalog.getTitle());
|
map.put("firstPY", resCatalog.getPingyinfiirst());
|
map.put("remark", resCatalog.getRemark());
|
map.put("icon", resCatalog.getIcon());
|
map.put("oId", resCatalog.getCatlogcode());
|
map.put("descrip", resCatalog.getDescription());
|
|
if (resCatalogf != null) {
|
|
map.put("Pid", resCatalog.getParentid());
|
map.put("fname", resCatalogf.getTitle());
|
// resCatalogJson += "{id:" + resCatalog.getCatlogid() + ", name:'" + resCatalog.getTitle() + "', Pid:" + resCatalog.getParentid() + ", firstPY:'" + resCatalog.getPingyinfiirst() + "', remark:'" + resCatalog.getRemark() + "', icon:'" + resCatalog.getIcon() + "', descrip:'" + resCatalog.getDescription() + "', fname:'" + resCatalogf.getTitle() + "', oId:'" + resCatalog.getCatlogcode() + "'}";
|
} else {
|
map.put("Pid", 0);
|
map.put("fname", "资源目录");
|
|
resCatalogJson += "{id:" + resCatalog.getCatlogid() + ", name:'" + resCatalog.getTitle() + "', Pid:" + 0 + ", firstPY:'" + resCatalog.getPingyinfiirst() + "', remark:'" + resCatalog.getRemark() + "', icon:'" + resCatalog.getIcon() + "', descrip:'" + resCatalog.getDescription() + "', fname:'" + "资源目录" + "', oId:'" + resCatalog.getCatlogcode() + "'}";
|
}
|
return Result.ok().put("result",map);
|
}
|
|
/**
|
* @Description: 目录修改方法
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/saveedit")
|
@LogAction("资源管理,资源编目,资源目录修改,修改")
|
public String saveEdit(Res_Catalog model) {
|
int result = resCatalogService.updateByPrimaryKeySelective(model);
|
if (result == 1) {
|
return "修改成功";
|
} else {
|
return "修改失败";
|
}
|
}
|
|
|
/**
|
* 检查删除的目录下是都存在资源
|
*/
|
@ResponseBody
|
@RequestMapping("manage/catalog/isDelete")
|
public String isDelete(int id) {
|
Integer resMainInfos = resCatalogService.selectMuLuZiYuanCount(id);
|
if (resMainInfos > 0) {
|
return "-1";
|
}
|
else {
|
logActionService.saveLogAction(("资源管理,资源编目,资源目录删除,删除"));
|
int result = resCatalogService.deleteByPrimaryKey(id);
|
if (result == 1) {
|
return "删除成功";
|
} else {
|
return "删除失败";
|
}
|
}
|
}
|
|
/**
|
* @Description: 目录删除方法
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/delete")
|
// @LogAction("资源管理,资源编目,资源目录删除,删除")
|
public String delete(int id) {
|
logActionService.saveLogAction(("资源管理,资源编目,资源目录删除,删除"));
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(id,null);
|
if (childCount > 0) {
|
DeleteChildNode(id);
|
}
|
List<Res_MainInfo> resMainInfos = resCatalogService.selectMuLuZiYuanList(id);
|
if (resMainInfos != null) {
|
for(Res_MainInfo resMainInfo : resMainInfos ) {
|
resMainInfoService.deleteByPrimaryKey(resMainInfo.getResourceid());
|
}
|
}
|
int result = resCatalogService.deleteByPrimaryKey(id);
|
if (result == 1) {
|
return "删除成功";
|
} else {
|
return "删除失败";
|
}
|
}
|
|
public void DeleteChildNode(int id) {
|
List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(id);
|
for (Res_Catalog Model : List) {
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(Model.getCatlogid(),null);
|
if (childCount > 0) {
|
DeleteChildNode(Model.getCatlogid());
|
}
|
resCatalogService.deleteByPrimaryKey(Model.getCatlogid());
|
}
|
}
|
|
/**
|
* @Description: 新增同级页面
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/addbrother")
|
@LogAction("资源管理,资源编目,资源目录新增(同级),新增")
|
public String addBrother(int id) {
|
Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(id);
|
int pid = resCatalog.getParentid();
|
String orderid = "";
|
if (pid == 0) {
|
//根目录的排序ID为0,需要特殊处理
|
orderid = resCatalogService.getMaxCATLOGCODEFromMainIndex(pid);
|
} else {
|
orderid = resCatalogService.getMaxCATLOGCODE(pid);
|
}
|
if (orderid == null) {
|
orderid = String.valueOf(resCatalog.getCatlogcode())+"01";
|
} else {
|
int newOrderid = Integer.valueOf(orderid) + 1;
|
if(newOrderid < 10) {
|
orderid = "0" + String.valueOf(newOrderid);
|
} else {
|
orderid = String.valueOf(newOrderid);
|
}
|
}
|
Object FatherName = "";
|
if (pid == 0) {
|
//根目录的排序ID为0,需要特殊处理
|
FatherName = "资源目录";
|
} else {
|
FatherName = resCatalogService.getResCatalogInfoById(resCatalog.getParentid()).getTitle();
|
}
|
String resCatalogJson = "";
|
resCatalogJson += "{id:" + resCatalog.getCatlogid() + ", name:'" + FatherName + "', pId:" + resCatalog.getParentid() + ", oId:'" + orderid + "'}";
|
//查询当前父节点的信息 返回到前台
|
return resCatalogJson;
|
}
|
|
/**
|
* @Description: 获取目录以及所属资源列表
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/selectmuluandziyuan")
|
public String selectMuLuAndZiYuan(int id) {
|
//先根据父节点ID获取子目录
|
List<Res_Catalog> resCatalogList = resCatalogService.selectResCatalogToParentid(id);
|
String resCatalogJson = "";
|
List<Map<String, Object>> maps = new LinkedList<>();
|
for (Res_Catalog resCatalog : resCatalogList) {
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(resCatalog.getCatlogid(),null);
|
|
Map<String, Object> map = new HashMap<>();
|
map.put("id", resCatalog.getCatlogid());
|
map.put("name", resCatalog.getTitle());
|
map.put("pId", resCatalog.getParentid());
|
map.put("isParent", true);
|
map.put("check", true);
|
map.put("rpId", resCatalog.getParentid());
|
map.put("iconOpen", "/image/classicons/folderOpen.png");
|
map.put("iconClose", "/image/classicons/folder.png");
|
maps.add(map);
|
|
// resCatalogJson += (resCatalogJson.length() > 0 ? "," : "")
|
// + "{id:" + resCatalog.getCatlogid()
|
// + ", name:'" + resCatalog.getTitle()
|
// + "', pId:" + resCatalog.getParentid()
|
// + ",isParent:true,check:true,rpId:"+ resCatalog.getParentid() + (",iconOpen:'/image/classicons/folderOpen.png',iconClose:'/image/classicons/folder.png'") + "}";
|
}
|
//获取完子目录后获取资源
|
List<Res_MainInfo> ZyList = resMainInfoService.selectZyByMuLuId(id);
|
for (Res_MainInfo Zymodel : ZyList) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("id", Zymodel.getResourceid());
|
map.put("name", Zymodel.getTitle());
|
map.put("pId", Zymodel.getCatlogid());
|
map.put("rpId", Zymodel.getCatlogid());
|
map.put("icon", "/image/classicons/"+Zymodel.getResourceclass()+".png");
|
maps.add(map);
|
|
// resCatalogJson += (resCatalogJson.length() > 0 ? "," : "") + "{id:" + Zymodel.getResourceid() + ", name:'" + Zymodel.getTitle() + "', pId:" + Zymodel.getCatlogid() + ", rpId:" + Zymodel.getCatlogid() + ",icon:'/image/classicons/"+Zymodel.getResourceclass()+".png'" +"}";//update:dsh(2018/12/05)
|
}
|
|
return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
|
}
|
|
/**
|
* @Description: 资源位置调整方法
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/merge")
|
@LogAction("资源管理,资源编目,资源目录修改(资源调整),修改")
|
public String merge(String ids, String fid) {
|
String[] idArr = ids.split(";");
|
//不修改目录编码,只修改目录ID会导致有些功能的查询只根据目录编码查询出错
|
//同一资源的目录ID和目录编码会不一致 alert ykm 2018/12/28
|
Res_Catalog resCatalog = resCatalogService.selectByPrimaryKey(Integer.valueOf(fid));
|
for (String zyid : idArr) {
|
Res_MainInfo Zymodel = resMainInfoService.selectByPrimaryKey(Integer.valueOf(zyid));
|
Zymodel.setCatlogcode(resCatalog.getCatlogcode());
|
Zymodel.setCatlogid(Integer.valueOf(fid));
|
int result = resMainInfoService.updateByPrimaryKeySelective(Zymodel);
|
}
|
return "调整成功";
|
}
|
|
/**
|
* @Description: 目录拖拉方法
|
*/
|
@ResponseBody
|
@RequestMapping("manage/catalog/changebianmu")
|
@LogAction("资源管理,资源编目,资源目录修改(拖拉),修改")
|
public String changeBianMu(String id, String newfid) {
|
changeBianMuMethod(id, newfid);
|
return "调整成功!";
|
}
|
|
/**
|
* @Description: 主目录调整方法
|
*/
|
public void changeBianMuMethod(String id, String newfid) {
|
Res_Catalog model = resCatalogService.getResCatalogInfoById(Integer.valueOf(id));
|
Integer rpid = model.getParentid();
|
Res_Catalog modelf = new Res_Catalog();
|
if (newfid.equals("0")) {
|
modelf.setTitle("资源目录");
|
modelf.setOrderid(0);
|
modelf.setCatlogcode("0");
|
} else {
|
modelf = resCatalogService.getResCatalogInfoById(Integer.valueOf(newfid));
|
}
|
model.setParentid(Integer.valueOf(newfid));
|
//首先更新新的父节点
|
String neworderid = "";
|
if (model.getParentid() == 0) {
|
//根目录的排序ID为0,需要特殊处理
|
neworderid = resCatalogService.getMaxOrderIdFromMainIndex(model.getParentid());
|
} else {
|
neworderid = resCatalogService.getMaxOrderId(model.getParentid());
|
}
|
if (neworderid == null) {
|
//如果当前目录下无子目录,则父目录排序+01
|
Res_Catalog resCatalog = resCatalogService.getResCatalogInfoById(model.getParentid());
|
neworderid = String.valueOf(modelf.getOrderid()) + "01";
|
} else {
|
//有子目录则+1
|
int newOrderid = Integer.valueOf(neworderid) + 1;
|
neworderid = String.valueOf(newOrderid);
|
}
|
//目录编码同样处理
|
String newcatlogcode = "";
|
if (model.getParentid() == 0) {
|
newcatlogcode = resCatalogService.getMaxCATLOGCODEFromMainIndex(model.getParentid());
|
if (newcatlogcode == null) {
|
newcatlogcode = "01";
|
} else {
|
int newCid = Integer.valueOf(newcatlogcode) + 1;
|
newcatlogcode = "0" + String.valueOf(newCid);
|
}
|
} else {
|
newcatlogcode = resCatalogService.getMaxCATLOGCODE(model.getParentid());
|
if (newcatlogcode == null) {
|
newcatlogcode = String.valueOf(modelf.getCatlogcode()) + "01";
|
} else {
|
int newCode = Integer.valueOf(newcatlogcode) + 1;
|
newcatlogcode = "0" + String.valueOf(newCode);
|
}
|
}
|
model.setCatlogcode(newcatlogcode);
|
model.setOrderid(Integer.valueOf(neworderid));
|
resCatalogService.updateByPrimaryKeySelective(model);
|
List<Res_MainInfo> ZyList = resMainInfoService.selectZyByMuLuId(model.getCatlogid());
|
//更新本目录下所属资源的编码
|
for (Res_MainInfo ChZymodel : ZyList) {
|
ChZymodel.setCatlogcode(model.getCatlogcode());
|
resMainInfoService.updateByPrimaryKeySelective(ChZymodel);
|
}
|
//如果有子目录,则更新子目录
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid(),null);
|
if (childCount > 0) {
|
updateChildNode(model.getCatlogid());
|
}
|
//更新完子目录后,更新原目录的编码与排序,防止错乱
|
updateOriginal(rpid);
|
}
|
|
/**
|
* @Description: 子目录调整方法
|
*/
|
public void updateChildNode(int id) {
|
List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(id);
|
for (Res_Catalog Cmodel : List) {
|
//循环处理每个子目录的编码和排序
|
Res_Catalog modelf = resCatalogService.getResCatalogInfoById(id);
|
String newcatlogcode = resCatalogService.getMaxCATLOGCODE(modelf.getCatlogid());
|
if (newcatlogcode == null) {
|
newcatlogcode = String.valueOf(modelf.getCatlogcode()) + "01";
|
} else {
|
String Pcatlogcode = String.valueOf(modelf.getCatlogcode());
|
if (newcatlogcode.length() > Pcatlogcode.length()) {
|
newcatlogcode = newcatlogcode.substring(0, Pcatlogcode.length());
|
} else {
|
Pcatlogcode = Pcatlogcode.substring(0, newcatlogcode.length());
|
}
|
if (newcatlogcode.equals(Pcatlogcode)) {
|
newcatlogcode = "0" + String.valueOf(Integer.valueOf(resCatalogService.getMaxCATLOGCODE(modelf.getCatlogid())) + 1);
|
} else {
|
newcatlogcode = String.valueOf(modelf.getCatlogcode()) + "01";
|
}
|
}
|
Cmodel.setCatlogcode(newcatlogcode);
|
String neworderid = resCatalogService.getMaxOrderId(modelf.getCatlogid());
|
if (neworderid == null) {
|
neworderid = String.valueOf(modelf.getOrderid()) + "01";
|
} else {
|
String Porderid = String.valueOf(modelf.getOrderid());
|
if (neworderid.length() > Porderid.length()) {
|
neworderid = neworderid.substring(0, Porderid.length());
|
} else {
|
Porderid = Porderid.substring(0, neworderid.length());
|
}
|
if (neworderid.equals(Porderid)) {
|
neworderid = String.valueOf(Integer.valueOf(resCatalogService.getMaxOrderId(modelf.getCatlogid())) + 1);
|
} else {
|
neworderid = String.valueOf(modelf.getOrderid()) + "01";
|
}
|
}
|
Cmodel.setOrderid(Integer.valueOf(neworderid));
|
resCatalogService.updateByPrimaryKeySelective(Cmodel);
|
List<Res_MainInfo> ZyList = resMainInfoService.selectZyByMuLuId(Cmodel.getCatlogid());
|
//更新所属资源的编码
|
for (Res_MainInfo ChZymodel : ZyList) {
|
ChZymodel.setCatlogcode(Cmodel.getCatlogcode());
|
resMainInfoService.updateByPrimaryKeySelective(ChZymodel);
|
}
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(Cmodel.getCatlogid(),null);
|
if (childCount > 0) {
|
//如果子目录下还有下级目录,则再次循环此方法
|
updateChildNode(Cmodel.getCatlogid());
|
}
|
}
|
}
|
|
/**
|
* @Description: 原目录调整方法
|
*/
|
public void updateOriginal(int id) {
|
Res_Catalog model = new Res_Catalog();
|
if (id == 0) {
|
model.setTitle("资源目录");
|
model.setOrderid(Integer.valueOf(0));
|
model.setCatlogcode("");
|
} else {
|
model = resCatalogService.getResCatalogInfoById(id);
|
}
|
//预先定义目录的第一个编码和排序ID
|
String minCode = String.valueOf(model.getCatlogcode());
|
minCode = minCode + "01";
|
String minOrderid = String.valueOf(model.getOrderid());
|
minOrderid = minOrderid + "01";
|
int i = 0;
|
List<Res_Catalog> Childrens = resCatalogService.selectResCatalogToParentid(id);
|
//查询目录下所有子目录
|
for (Res_Catalog item : Childrens) {
|
if (i == 0) {
|
//第一个子目录使用定义的编码和排序ID
|
item.setCatlogcode(minCode);
|
item.setOrderid(Integer.valueOf(minOrderid));
|
resCatalogService.updateByPrimaryKeySelective(item);
|
i++;
|
} else {
|
//第二个以后的目录则是在第一个目录的编码和排序ID基础上+1
|
String newCode = "";
|
if (id == 0) {
|
newCode = resCatalogService.getMinCATLOGCODEFromMainIndex(id);
|
newCode = "0" + String.valueOf(Integer.valueOf(newCode) + i);
|
} else {
|
newCode = resCatalogService.getMinCATLOGCODE(id);
|
newCode = "0" + String.valueOf(Integer.valueOf(newCode) + i);
|
}
|
String newOid = "";
|
if (id == 0) {
|
newOid = resCatalogService.getMinOrderIdFromMainIndex(id);
|
} else {
|
newOid = resCatalogService.getMinOrderId(id);
|
}
|
newOid = String.valueOf(Integer.valueOf(newOid) + i);
|
item.setOrderid(Integer.valueOf(newOid));
|
item.setCatlogcode(newCode);
|
resCatalogService.updateByPrimaryKeySelective(item);
|
List<Res_MainInfo> ZyList = resMainInfoService.selectZyByMuLuId(item.getCatlogid());
|
//更新所属资源
|
for (Res_MainInfo ChZymodel : ZyList) {
|
ChZymodel.setCatlogcode(item.getCatlogcode());
|
resMainInfoService.updateByPrimaryKeySelective(ChZymodel);
|
}
|
i++;
|
}
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(item.getCatlogid(),null);
|
if (childCount > 0) {
|
//如果含有子目录,则一并更新
|
updateOriginal(item.getCatlogid());
|
}
|
}
|
}
|
|
/**
|
* @Description: 编目排序页面
|
*/
|
@ResponseBody
|
@RequestMapping("manage/catalog/initsort")
|
public Result initSort(String id) {
|
List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(Integer.valueOf(id));
|
// String Result = "{count:" + List.size() + "," + "children:[";
|
List<Map<String, Object>> maps = new LinkedList<>();
|
for (Res_Catalog model : List) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("id", model.getCatlogid());
|
map.put("name", model.getTitle());
|
maps.add(map);
|
// Result = Result + "{id:" + model.getCatlogid() + ",name:'" + model.getTitle() + "'},";
|
}
|
// if (List.size() != 0) {
|
// Result = Result.substring(0, Result.length() - 1);
|
// }
|
// Result = Result + "]}";
|
return Result.ok().put("count", List.size()).put("children", maps);
|
}
|
|
/**
|
* @Description: 编目排序方法
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/sort")
|
@LogAction("资源管理,资源编目,资源目录修改(编目排序),修改")
|
public Result sort(String id, int pid) {
|
if(!"".equals(id)) {
|
String[] arr = id.split("\\|");//排序后资源ID列表
|
for (int i = 0; i < arr.length; i++) {
|
Res_Catalog resCatalog = resCatalogService.selectByPrimaryKey(Integer.parseInt(arr[i]));
|
resCatalog.setOrderid(i);
|
resCatalogService.updateByPrimaryKeySelective(resCatalog);
|
}
|
}
|
//修改完后把新的序列树返回到前台
|
List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
|
// String Result = "{count:" + List.size() + "," + "children:[";
|
List<Map<String, Object>> maps = new LinkedList<>();
|
for (Res_Catalog model : List) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("id", model.getCatlogid());
|
map.put("name", model.getTitle());
|
maps.add(map);
|
// Result = Result + "{id:" + model.getCatlogid() + ",name:'" + model.getTitle() + "'},";
|
}
|
// if (List.size() != 0) {
|
// Result = Result.substring(0, Result.length() - 1);
|
// }
|
// Result = Result + "]}";
|
return Result.ok().put("count", List.size()).put("children", maps);
|
}
|
|
/**
|
* @Description: 资源排序方法
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/zysort")
|
@LogAction("资源管理,资源编目,资源目录修改(资源排序),修改")
|
public Result zySort(String ids, Integer pid) {
|
if(!"".equals(ids)) {
|
String[] arr = ids.split("\\|");//排序后资源ID列表
|
//更新资源排序
|
for (int i = 0; i < arr.length; i++) {
|
Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(Integer.parseInt(arr[i]));
|
resMainInfo.setOrderid(i);
|
resMainInfoService.updateByPrimaryKeySelective(resMainInfo);
|
}
|
}
|
|
List<Res_MainInfo> List = resMainInfoService.selectZyByMuLuId(pid);
|
// String Result = "{count:" + List.size() + "," + "children:[";
|
|
List<Map<String, Object>> maps = new LinkedList<>();
|
for (Res_MainInfo model : List) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("id", model.getResourceid());
|
map.put("name", model.getTitle());
|
maps.add(map);
|
// Result = Result + "{id:" + model.getResourceid() + ",name:'" + model.getTitle() + "'},";
|
}
|
// if (List.size() != 0) {
|
// Result = Result.substring(0, Result.length() - 1);
|
// }
|
// Result = Result + "]}";
|
return Result.ok().put("count", List.size()).put("children", maps);
|
}
|
|
/**
|
* @Description: 编目上移方法
|
*/
|
public int UpSort(int id, int pid) {
|
List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
|
int index = -1;
|
for (Res_Catalog model : List) {
|
if (model.getCatlogid() == id) {
|
if (index == -1) {
|
return 0;
|
} else {
|
//当前目录的排序ID和前一个交换
|
int newoid = List.get(index).getOrderid();
|
List.get(index).setOrderid(model.getOrderid());
|
model.setOrderid(newoid);
|
resCatalogService.updateByPrimaryKeySelective(model);
|
resCatalogService.updateByPrimaryKeySelective(List.get(index));
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid(),null);
|
if (childCount > 0) {
|
updateChildrenOid(model.getCatlogid());
|
}
|
int childCount1 = resCatalogService.selectResCatalogIsExistsSon(List.get(index).getCatlogid(),null);
|
if (childCount1 > 0) {
|
//子目录自动修改
|
updateChildrenOid(List.get(index).getCatlogid());
|
}
|
}
|
}
|
index++;
|
}
|
return 1;
|
}
|
|
/**
|
* @Description: 编目下移方法
|
*/
|
public int DownSort(int id, int pid) {
|
List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
|
int index = 1;
|
for (Res_Catalog model : List) {
|
if (model.getCatlogid() == id) {
|
if (index >= List.size()) {
|
return 0;
|
} else {
|
//当前目录的排序ID和后一个交换
|
int newoid = List.get(index).getOrderid();
|
List.get(index).setOrderid(model.getOrderid());
|
model.setOrderid(newoid);
|
resCatalogService.updateByPrimaryKeySelective(model);
|
resCatalogService.updateByPrimaryKeySelective(List.get(index));
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid(),null);
|
if (childCount > 0) {
|
updateChildrenOid(model.getCatlogid());
|
}
|
int childCount1 = resCatalogService.selectResCatalogIsExistsSon(List.get(index).getCatlogid(),null);
|
if (childCount1 > 0) {
|
//子目录自动修改
|
updateChildrenOid(List.get(index).getCatlogid());
|
}
|
}
|
}
|
index++;
|
}
|
return 1;
|
}
|
|
/**
|
* @Description: 目录顶置方法
|
*/
|
public int TopSort(int id, int pid) {
|
List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
|
int index = 0;
|
for (Res_Catalog model : List) {
|
//当前目录的排序ID和第一个交换,从第一个到当前目录的所有目录依次往后退一位
|
if (model.getCatlogid() == id) {
|
if (index == 0) {
|
return 0;
|
} else {
|
int newoid = List.get(0).getOrderid();
|
for (int i = 0; i <= index - 1; i++) {
|
List.get(i).setOrderid(List.get(i + 1).getOrderid());
|
resCatalogService.updateByPrimaryKeySelective(List.get(i));
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(List.get(i).getCatlogid(),null);
|
if (childCount > 0) {
|
updateChildrenOid(List.get(i).getCatlogid());
|
}
|
}
|
model.setOrderid(newoid);
|
resCatalogService.updateByPrimaryKeySelective(model);
|
int childCount1 = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid(),null);
|
if (childCount1 > 0) {
|
//子目录自动修改
|
updateChildrenOid(model.getCatlogid());
|
}
|
}
|
}
|
index++;
|
}
|
return 1;
|
}
|
|
/**
|
* @Description: 目录底置方法
|
*/
|
public int BottomSort(int id, int pid) {
|
List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
|
int index = 0;
|
for (Res_Catalog model : List) {
|
//当前目录的排序ID和最后一个交换,从最后一个到当前目录的所有目录依次往前进一位
|
if (model.getCatlogid() == id) {
|
if (index >= List.size()) {
|
return 0;
|
} else {
|
int newoid = List.get(List.size() - 1).getOrderid();
|
for (int i = List.size() - 1; i >= index + 1; i--) {
|
List.get(i).setOrderid(List.get(i - 1).getOrderid());
|
resCatalogService.updateByPrimaryKeySelective(List.get(i));
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(List.get(i).getCatlogid());
|
if (childCount > 0) {
|
updateChildrenOid(List.get(i).getCatlogid());
|
}
|
}
|
model.setOrderid(newoid);
|
resCatalogService.updateByPrimaryKeySelective(model);
|
int childCount1 = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid());
|
if (childCount1 > 0) {
|
//子目录自动修改
|
updateChildrenOid(model.getCatlogid());
|
}
|
}
|
}
|
index++;
|
}
|
return 1;
|
}
|
|
/**
|
* @Description: 子目录自动拍戏方法
|
*/
|
public void updateChildrenOid(int pid) {
|
Res_Catalog pmodel = resCatalogService.getResCatalogInfoById(pid);
|
List<Res_Catalog> List = resCatalogService.selectResCatalogToParentid(pid);
|
for (Res_Catalog model : List) {
|
String neworderid = "";
|
neworderid = resCatalogService.getMaxOrderId(pid);
|
if (neworderid == null) {
|
neworderid = String.valueOf(pmodel.getOrderid()) + "01";
|
} else {
|
int newOrderid = Integer.valueOf(neworderid) + 1;
|
neworderid = String.valueOf(newOrderid);
|
}
|
model.setOrderid(Integer.valueOf(neworderid));
|
resCatalogService.updateByPrimaryKeySelective(model);
|
int childCount = resCatalogService.selectResCatalogIsExistsSon(model.getCatlogid());
|
if (childCount > 0) {
|
updateChildrenOid(model.getCatlogid());
|
}
|
}
|
}
|
|
/**
|
* @Description: 资源排序页面
|
*/
|
@ResponseBody
|
@RequiresPermissions("res:catalog:edit")
|
@RequestMapping("manage/catalog/initzysort")
|
public Result initZySort(Integer id) {
|
List<Res_MainInfo> List = resMainInfoService.selectZyByMuLuId(id);
|
// String Result = "{count:" + List.size() + ", children:[";
|
List<Map<String, Object>> maps = new LinkedList<>();
|
for (Res_MainInfo model : List) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("id", model.getResourceid());
|
map.put("name", model.getTitle());
|
maps.add(map);
|
// Result = Result + "{id:" + model.getResourceid() + ", name:'" + model.getTitle() + "'},";
|
}
|
// if (List.size() != 0) {
|
// Result = Result.substring(0, Result.length() - 1);
|
// }
|
// Result = Result + "]}";
|
return com.landtool.lanbase.common.utils.Result.ok().put("count", List.size()).put("children", maps);
|
}
|
|
|
/**
|
* @Description: 资源上移方法
|
*/
|
public int zyUpSort(int id, int pid) {
|
List<Res_MainInfo> List = resMainInfoService.selectZyByMuLuId(pid);
|
int index = -1;
|
for (Res_MainInfo model : List) {
|
if (model.getResourceid() == id) {
|
if (index == -1) {
|
return 0;
|
} else {
|
int newoid = List.get(index).getOrderid();
|
List.get(index).setOrderid(model.getOrderid());
|
model.setOrderid(newoid);
|
resMainInfoService.updateByPrimaryKeySelective(model);
|
resMainInfoService.updateByPrimaryKeySelective(List.get(index));
|
}
|
}
|
index++;
|
}
|
return 1;
|
}
|
|
/**
|
* @Description: 资源下移方法
|
*/
|
public int zyDownSort(int id, int pid) {
|
List<Res_MainInfo> List = resMainInfoService.selectZyByMuLuId(pid);
|
int index = 1;
|
for (Res_MainInfo model : List) {
|
if (model.getResourceid() == id) {
|
if (index >= List.size()) {
|
return 0;
|
} else {
|
int newoid = List.get(index).getOrderid();
|
List.get(index).setOrderid(model.getOrderid());
|
model.setOrderid(newoid);
|
resMainInfoService.updateByPrimaryKeySelective(model);
|
resMainInfoService.updateByPrimaryKeySelective(List.get(index));
|
}
|
}
|
index++;
|
}
|
return 1;
|
}
|
|
|
|
//
|
// @RequestMapping("manage/catalog/text1")
|
// public String text1(Model model) throws WSDLException {
|
// String wsdluri = "http://18.1.2.13:9090/gpsdateconversion/DateConversion.asmx?wsdl";
|
// List<String> operations = new ArrayList<String>();
|
// List<Object> list=new ArrayList<>();
|
// WAWsdlUtil.getOperationList(wsdluri, operations);
|
// for (String operationName : operations) {
|
// String Json = text(operationName,wsdluri);
|
// list.add(Json);
|
// }
|
//
|
// model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
|
// model.addAttribute("Obj", list);
|
// return "manage/catalog/text";
|
// }
|
|
|
|
}
|