+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.category.controller;
+
+import com.elink.esua.epdc.commons.tools.utils.ExcelUtils;
+import com.elink.esua.epdc.commons.tools.utils.Result;
+import com.elink.esua.epdc.commons.tools.validator.AssertUtils;
+import com.elink.esua.epdc.commons.tools.validator.ValidatorUtils;
+import com.elink.esua.epdc.commons.tools.validator.group.AddGroup;
+import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup;
+import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup;
+import com.elink.esua.epdc.dto.category.CategoryDTO;
+import com.elink.esua.epdc.modules.category.excel.CategoryExcel;
+import com.elink.esua.epdc.modules.category.service.CategoryService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.Map;
+
+
+/**
+ * 分类管理
+ *
+ * @author wjp wjp@elink-cn.com
+ * @since v1.0.0 2019-11-26
+ */
+@RestController
+@RequestMapping("category")
+public class CategoryController {
+
+ @Autowired
+ private CategoryService categoryService;
+
+ @GetMapping("list")
+ public Result> list(@RequestParam Map params){
+ List list = categoryService.list(params);
+ return new Result>().ok(list);
+ }
+
+ @GetMapping("{id}")
+ public Result get(@PathVariable("id") Long id){
+ CategoryDTO data = categoryService.get(id);
+ return new Result().ok(data);
+ }
+
+ @PostMapping
+ public Result save(@RequestBody CategoryDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
+ categoryService.save(dto);
+ return new Result();
+ }
+
+ @PutMapping
+ public Result update(@RequestBody CategoryDTO dto){
+ //效验数据
+ ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
+ categoryService.update(dto);
+ return new Result();
+ }
+
+ @DeleteMapping
+ public Result delete(@RequestBody Long id){
+ categoryService.delete(id);
+ return new Result();
+ }
+
+ @GetMapping("export")
+ public void export(@RequestParam Map params, HttpServletResponse response) throws Exception {
+ List list = categoryService.list(params);
+ ExcelUtils.exportExcelToTarget(response, null, list, CategoryExcel.class);
+ }
+
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/dao/CategoryDao.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/dao/CategoryDao.java
new file mode 100644
index 000000000..246e82610
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/dao/CategoryDao.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.category.dao;
+
+import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
+import com.elink.esua.epdc.modules.category.entity.CategoryEntity;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 分类管理
+ *
+ * @author wjp wjp@elink-cn.com
+ * @since v1.0.0 2019-11-26
+ */
+@Mapper
+public interface CategoryDao extends BaseDao {
+
+ List getList(Map params);
+
+ CategoryEntity getById(Long id);
+
+ /**
+ * 根据分类ID,获取所有子分类ID列表
+ *
+ * @param id 分类ID
+ */
+ List getSubCategoryIdList(String id);
+
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/entity/CategoryEntity.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/entity/CategoryEntity.java
new file mode 100644
index 000000000..7b485aaf4
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/entity/CategoryEntity.java
@@ -0,0 +1,108 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.category.excel;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 分类管理
+ *
+ * @author wjp wjp@elink-cn.com
+ * @since v1.0.0 2019-11-26
+ */
+@Data
+public class CategoryExcel {
+
+ @Excel(name = "id")
+ private Long id;
+
+ @Excel(name = "上级分类ID")
+ private Long pid;
+
+ @Excel(name = "所有上级分类ID,用逗号分开")
+ private String pids;
+
+ @Excel(name = "分类名称")
+ private String categoryName;
+
+ @Excel(name = "分类类别")
+ private String categoryType;
+
+ @Excel(name = "排序")
+ private Integer sort;
+
+ @Excel(name = "删除标识 0:未删除 1:删除")
+ private Integer delFlag;
+
+ @Excel(name = "创建者")
+ private Long creator;
+
+ @Excel(name = "创建时间")
+ private Date createDate;
+
+ @Excel(name = "更新者")
+ private Long updater;
+
+ @Excel(name = "更新时间")
+ private Date updateDate;
+
+
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/redis/CategoryRedis.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/redis/CategoryRedis.java
new file mode 100644
index 000000000..51bbeee86
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/redis/CategoryRedis.java
@@ -0,0 +1,47 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.category.redis;
+
+import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 分类管理
+ *
+ * @author wjp wjp@elink-cn.com
+ * @since v1.0.0 2019-11-26
+ */
+@Component
+public class CategoryRedis {
+ @Autowired
+ private RedisUtils redisUtils;
+
+ public void delete(Object[] ids) {
+
+ }
+
+ public void set(){
+
+ }
+
+ public String get(String id){
+ return null;
+ }
+
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/CategoryService.java b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/CategoryService.java
new file mode 100644
index 000000000..a3024ba3d
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/java/com/elink/esua/epdc/modules/category/service/CategoryService.java
@@ -0,0 +1,97 @@
+/**
+ * Copyright 2018 人人开源 https://www.renren.io
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+
+package com.elink.esua.epdc.modules.category.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.Wrapper;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl;
+import com.elink.esua.epdc.commons.tools.constant.Constant;
+import com.elink.esua.epdc.commons.tools.exception.ErrorCode;
+import com.elink.esua.epdc.commons.tools.exception.RenException;
+import com.elink.esua.epdc.commons.tools.page.PageData;
+import com.elink.esua.epdc.commons.tools.utils.ConvertUtils;
+import com.elink.esua.epdc.commons.tools.constant.FieldConstant;
+import com.elink.esua.epdc.dto.category.CategoryDTO;
+import com.elink.esua.epdc.modules.category.dao.CategoryDao;
+import com.elink.esua.epdc.modules.category.entity.CategoryEntity;
+import com.elink.esua.epdc.modules.category.redis.CategoryRedis;
+import com.elink.esua.epdc.modules.category.service.CategoryService;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.*;
+
+/**
+ * 分类管理
+ *
+ * @author wjp wjp@elink-cn.com
+ * @since v1.0.0 2019-11-26
+ */
+@Service
+public class CategoryServiceImpl extends BaseServiceImpl implements CategoryService {
+
+ @Autowired
+ private CategoryRedis categoryRedis;
+
+ @Override
+ public List list(Map params) {
+ List entityList = baseDao.getList(params);
+ return ConvertUtils.sourceToTarget(entityList, CategoryDTO.class);
+ }
+
+ @Override
+ public CategoryDTO get(Long id) {
+ if (id == null) {
+ return null;
+ }
+ CategoryEntity entity = baseDao.getById(id);
+
+ return ConvertUtils.sourceToTarget(entity, CategoryDTO.class);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void save(CategoryDTO dto) {
+ String categoryCode = dto.getCategoryCode();
+ if (StringUtils.isNotBlank(categoryCode)) {
+ if (getCodeCount(dto) > 0) {
+ throw new RenException("您输入的编码已存在");
+ }
+ }
+ CategoryEntity entity = ConvertUtils.sourceToTarget(dto, CategoryEntity.class);
+ List list = getPidListByPid(entity.getPid());
+ if (list.size() == 0){
+ entity.setPids("0");
+ }else {
+ String pids = "";
+ for (int i = 0; i < list.size(); i++){
+ if (i == list.size() -1){
+ pids = pids + list.get(i).getId().toString();
+ }else {
+ pids = pids + list.get(i).getId().toString() + ",";
+ }
+ }
+ entity.setPids(pids);
+ }
+ insert(entity);
+ }
+
+ @Override
+ public List getPidListById(Long id) {
+ //所有的分类列表
+ CategoryEntity categoryEntity = baseDao.selectById(id);
+ return getPidListByPid(categoryEntity.getPid());
+ }
+
+ /**
+ * 获取所有上级分类
+ *
+ * @param pid 上级ID
+ */
+ private List getPidListByPid(String pid) {
+ //顶级部门,无上级部门
+ if (Constant.CATEGORY_ROOT.equals(pid)) {
+ return new ArrayList<>();
+ }
+
+ //所有的分类列表
+ QueryWrapper wrapper = new QueryWrapper<>();
+ List categoryEntityList = baseDao.selectList(wrapper);
+
+ //list转map
+ Map map = new HashMap<>(categoryEntityList.size());
+ for (CategoryEntity entity : categoryEntityList) {
+ map.put(entity.getId(), entity);
+ }
+
+ //递归查询所有上级分类列表
+ List pCategoryEntityList = new ArrayList<>();
+
+ getPidTree(pid, map, pCategoryEntityList);
+
+ return pCategoryEntityList;
+ }
+
+ private void getPidTree(String pid, Map map, List pCategoryEntityList) {
+ //顶级,无上级
+ if (Constant.CATEGORY_ROOT.equals(pid)) {
+ return;
+ }
+ //上级存在
+ CategoryEntity parent = map.get(pid);
+ if (parent != null) {
+ getPidTree(parent.getPid(), map, pCategoryEntityList);
+ }
+
+ pCategoryEntityList.add(parent);
+ }
+
+ @Override
+ public Integer getCodeCount(CategoryDTO dto) {
+ QueryWrapper wrapper = new QueryWrapper<>();
+ wrapper.eq("category_code", dto.getCategoryCode());
+ String id = dto.getId();
+ wrapper.ne(id!=null, "id", dto.getId());
+ return baseDao.selectCount(wrapper);
+ }
+
+
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void update(CategoryDTO dto) {
+ String categoryCode = dto.getCategoryCode();
+ if (StringUtils.isNotBlank(categoryCode)) {
+ if (getCodeCount(dto) > 0) {
+ throw new RenException("您输入的编码已存在");
+ }
+ }
+ CategoryEntity entity = ConvertUtils.sourceToTarget(dto, CategoryEntity.class);
+ //上级部门不能为自身
+ if (entity.getId().equals(entity.getPid())) {
+ throw new RenException(ErrorCode.SUPERIOR_DEPT_ERROR);
+ }
+ List list = getPidListByPid(entity.getPid());
+ if (list.size() == 0){
+ entity.setPids("0");
+ }else {
+ String pids = "";
+ for (int i = 0; i < list.size(); i++){
+ if (i == list.size() -1){
+ pids = pids + list.get(i).getId().toString();
+ }else {
+ pids = pids + list.get(i).getId().toString() + ",";
+ }
+ }
+ entity.setPids(pids);
+ }
+ updateById(entity);
+ }
+
+ @Override
+ @Transactional(rollbackFor = Exception.class)
+ public void delete(Long id) {
+ //判断是否有子部门
+ List subList = getSubCategoryIdList(id);
+ if (subList.size() > 1) {
+ throw new RenException(ErrorCode.DEPT_SUB_DELETE_ERROR);
+ }
+ // 逻辑删除(@TableLogic 注解)
+ logicDelete(new Long[]{id}, CategoryEntity.class);
+
+ }
+
+ @Override
+ public List getSubCategoryIdList(Long id) {
+ List subCategoryIdList = baseDao.getSubCategoryIdList("%" + id + "%");
+ return subCategoryIdList;
+ }
+}
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/category/CategoryDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/category/CategoryDao.xml
new file mode 100644
index 000000000..29f1e9e85
--- /dev/null
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/category/CategoryDao.xml
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml
index 3f2f93a6a..4c64cdc66 100644
--- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/events/EpdcEventsDao.xml
@@ -14,7 +14,8 @@
-
+
+
@@ -37,7 +38,8 @@
e.ISSUE_LATITUDE,
e.ISSUE_LONGITUDE,
e.ADVICE,
- CONCAT(e.AREA,e.STREET,e.COMMUNITY,e.GRID) AS ownGrid
+ e.GROUP_NAME,
+ e.ALL_DEPT_NAMES
FROM
epdc_events e
LEFT JOIN epdc_img i ON e.ID = i.REFERENCE_ID
@@ -116,7 +118,8 @@
-
+
+
@@ -134,7 +137,8 @@
img.IMG_URL,
temp.ISSUE_LATITUDE,
temp.ISSUE_LONGITUDE,
- CONCAT(temp.AREA,temp.STREET,temp.COMMUNITY,temp.GRID) AS ownGrid
+ temp.ALL_DEPT_NAMES,
+ temp.GROUP_NAME
FROM
epdc_events temp
LEFT JOIN epdc_img img ON temp.ID = img.REFERENCE_ID
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml
index c689246b5..af567a471 100644
--- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/issue/IssueDao.xml
@@ -45,7 +45,8 @@
-
+
+
@@ -63,7 +64,8 @@
i.ISSUE_LATITUDE,
i.ISSUE_LONGITUDE,
cate.CATEGORY_NAME,
- CONCAT(i.AREA,i.STREET,i.COMMUNITY,i.GRID) AS ownGrid,
+ i.ALL_DEPT_NAMES,
+ i.GROUP_NAME,
img.IMG_URL
FROM
epdc_issue i
@@ -86,7 +88,8 @@
-
+
+
@@ -108,7 +111,8 @@
i.ISSUE_LATITUDE,
i.ISSUE_LONGITUDE,
cate.CATEGORY_NAME,
- CONCAT(i.AREA,i.STREET,i.COMMUNITY,i.GRID) AS ownGrid
+ i.ALL_DEPT_NAMES,
+ i.GROUP_NAME
FROM
epdc_issue i
LEFT JOIN epdc_events e ON i.EVENT_ID = e.ID
diff --git a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml
index 0ea4775a1..cd23d1337 100755
--- a/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml
+++ b/esua-epdc/epdc-module/epdc-events/epdc-events-server/src/main/resources/mapper/item/ItemDao.xml
@@ -429,6 +429,7 @@
+
@@ -447,7 +448,8 @@
eve.OPPOSE_NUM,
eve.COMMENT_NUM,
cate.CATEGORY_NAME,
- img.IMG_URL
+ img.IMG_URL,
+ item.GROUP_NAME
FROM
epdc_item item
LEFT JOIN epdc_img img ON item.EVENT_ID = img.REFERENCE_ID
@@ -595,6 +597,7 @@
+
@@ -616,6 +619,7 @@
item.ISSUE_ADDRESS,
item.ISSUE_LATITUDE,
item.ISSUE_LONGITUDE,
+ item.GROUP_NAME,
cate.CATEGORY_NAME,
eve.APPROVE_NUM,
eve.OPPOSE_NUM,