diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/controller/BaseCodeController.java b/ruoyi-content/src/main/java/com/ruoyi/content/controller/BaseCodeController.java index 9092f916b..0941d928e 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/controller/BaseCodeController.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/controller/BaseCodeController.java @@ -20,6 +20,7 @@ import org.springframework.web.bind.annotation.ResponseBody; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.Serializable; import java.util.*; /** @@ -261,18 +262,138 @@ public class BaseCodeController extends BaseController { */ @RequestMapping(value = "/columnTree") @ResponseBody - public Message columnTree(HttpServletRequest request, HttpServletResponse response) throws Exception { + public List columnTree(HttpServletRequest request, HttpServletResponse response) throws Exception { response.setHeader("Access-Control-Allow-Origin", "*"); Message msg = new Message(); Map policyMap = new HashMap(); String codeCode = request.getParameter("codeCode"); + String codeType = request.getParameter("codeType"); // 查询栏目树 - List columnList = baseCodeService.columnTree(codeCode); - policyMap.put("columnList", columnList); - msg.setInfo("成功"); - msg.setObject(policyMap); - msg.setResult(true); - return msg; + List columnList = baseCodeService.columnTree(codeCode, codeType); +// policyMap.put("columnList", columnList); +// msg.setInfo("成功"); +// msg.setObject(policyMap); +// msg.setResult(true); + + return initZtree(columnList); + } + + public List initZtree(List deptList) { + + List ztreeList = new ArrayList<>(); + if (deptList != null && deptList.size() > 0) { + Ztree z = new Ztree(); + z.setId("FIRST_COLUMN"); + z.setpId(""); + z.setName("栏目"); + z.setTitle("栏目"); + ztreeList.add(z); + for (BaseCodeTree dept : deptList) { + Ztree ztree = new Ztree(); + ztree.setId(dept.getCodeCode()); + ztree.setpId(dept.getCodeType()); + ztree.setName(dept.getCodeCname()); + ztree.setTitle(dept.getCodeCname()); + ztreeList.add(ztree); + } + } + return ztreeList; + } + + static class Ztree implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 节点ID + */ + private String id; + + /** + * 节点父ID + */ + private String pId; + + /** + * 节点名称 + */ + private String name; + + /** + * 节点标题 + */ + private String title; + + /** + * 是否勾选 + */ + private boolean checked = false; + + /** + * 是否展开 + */ + private boolean open = false; + + /** + * 是否能勾选 + */ + private boolean nocheck = false; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getpId() { + return pId; + } + + public void setpId(String pId) { + this.pId = pId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public boolean isChecked() { + return checked; + } + + public void setChecked(boolean checked) { + this.checked = checked; + } + + public boolean isOpen() { + return open; + } + + public void setOpen(boolean open) { + this.open = open; + } + + public boolean isNocheck() { + return nocheck; + } + + public void setNocheck(boolean nocheck) { + this.nocheck = nocheck; + } } /** diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/mapper/BaseCodeExMapper.java b/ruoyi-content/src/main/java/com/ruoyi/content/mapper/BaseCodeExMapper.java index 756ed4684..a5afb23b1 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/mapper/BaseCodeExMapper.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/mapper/BaseCodeExMapper.java @@ -21,4 +21,6 @@ public interface BaseCodeExMapper { */ public List columnTree(HashMap parMap); + public List getNextNodeTree(HashMap parMap); + } \ No newline at end of file diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/service/BaseCodeService.java b/ruoyi-content/src/main/java/com/ruoyi/content/service/BaseCodeService.java index ab32fd6f2..f3a22f26f 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/service/BaseCodeService.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/service/BaseCodeService.java @@ -84,9 +84,10 @@ public interface BaseCodeService { * 查询栏目树 * * @param codeCode + * @param codeType * @return */ - public List columnTree(String codeCode); + public List columnTree(String codeCode, String codeType); /** * 操作栏目排序 diff --git a/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/BaseCodeServiceImpl.java b/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/BaseCodeServiceImpl.java index f8addd28b..a5bdcd276 100644 --- a/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/BaseCodeServiceImpl.java +++ b/ruoyi-content/src/main/java/com/ruoyi/content/service/impl/BaseCodeServiceImpl.java @@ -454,9 +454,9 @@ public class BaseCodeServiceImpl implements BaseCodeService { } @Override - public List columnTree(String codeCode) { + public List columnTree(String codeCode, String codeType) { logger.info("进入查询栏目树的方法"); - if (StringUtils.isBlank(codeCode)) { + if (StringUtils.isAllBlank(codeCode, codeType)) { logger.info("查询栏目树请求参数不正确codeCode【{}】", codeCode); throw new ParameterException("创建失败,参数不足!"); } @@ -468,13 +468,33 @@ public class BaseCodeServiceImpl implements BaseCodeService { parMap.put("codeCode", codeCode); parMap.put("companyId", companyId); parMap.put("state", state); + parMap.put("codeType", codeType); if (!"86".equals(branchId)) { parMap.put("branchId", branchId); } list = baseCodeExMapper.columnTree(parMap); + List baseCodeList = new ArrayList<>(); + if (list != null && list.size() > 0) { + recursion(list, baseCodeList); + } logger.info("查询栏目树结束,查询到的结果为【{}】" + JsonUtil.objectToJackson(list)); logger.info("查询栏目信息的方法结束!"); - return list; + return baseCodeList; + } + + private void recursion(List baseCodeList, List list1) { + for (BaseCodeTree baseCode : baseCodeList) { + HashMap map = new HashMap(); + map.put("CODE_CODE", baseCode.getCodeCode()); + map.put("parentCompanyId", baseCode.getCompanyId()); + map.put("parentState", baseCode.getState()); + map.put("parentBranchId", baseCode.getBranchId()); + List list = baseCodeExMapper.getNextNodeTree(map); + list1.add(baseCode); + if (list != null && list.size() > 0) { + recursion(list, list1); + } + } } @Override diff --git a/ruoyi-content/src/main/resources/mapper/content/BaseCodeExMapper.xml b/ruoyi-content/src/main/resources/mapper/content/BaseCodeExMapper.xml index d827fea22..873e61a1d 100644 --- a/ruoyi-content/src/main/resources/mapper/content/BaseCodeExMapper.xml +++ b/ruoyi-content/src/main/resources/mapper/content/BaseCodeExMapper.xml @@ -35,7 +35,7 @@ UPDATE_REMARK, BUSINESS_AREA,COMPANY_ID,BRANCH_ID from base_code where - STATE in (0,1) + STATE = '0' and COMPANY_ID = #{companyId,jdbcType=VARCHAR} @@ -73,8 +73,8 @@ - + + - - - -
  • - - -
  • -
  • - - -
  • -
  • -  搜索 -  重置 - - 添加 - -
  • - - - +
    +
    +
    +
    + 栏目管理 +
    +
    + + + + +
    -
    -
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    + +
    +
    +
    +
    +
    +
    @@ -112,13 +141,15 @@
    - +



    + +