+ * 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.optimize.modules.macode.controller;
+
+import com.elink.esua.epdc.commons.tools.page.PageData;
+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.DeptMaCodeDTO;
+import com.elink.esua.epdc.optimize.modules.macode.dto.OptDeptMaCodeDTO;
+import com.elink.esua.epdc.optimize.modules.macode.excel.DeptMaCodeExcel;
+import com.elink.esua.epdc.optimize.modules.macode.service.OptDeptMaCodeService;
+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 elink elink@elink-cn.com
+ * @since v1.0.0 2020-05-15
+ */
+@RestController
+@RequestMapping("optimize/deptmacode")
+public class OptDeptMaCodeController {
+
+ @Autowired
+ private OptDeptMaCodeService deptMaCodeService;
+
+ @GetMapping("page")
+ public Result> page(@RequestParam Map params) {
+ PageData page = deptMaCodeService.page(params);
+ return new Result>().ok(page);
+ }
+
+ @GetMapping("{id}")
+ public Result get(@PathVariable("id") String id) {
+ DeptMaCodeDTO data = deptMaCodeService.get(id);
+ return new Result().ok(data);
+ }
+
+ @PostMapping
+ public Result save(@RequestBody DeptMaCodeDTO dto) {
+ //效验数据
+ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
+ deptMaCodeService.save(dto);
+ return new Result();
+ }
+
+ @PutMapping
+ public Result update(@RequestBody DeptMaCodeDTO dto) {
+ //效验数据
+ ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
+ deptMaCodeService.update(dto);
+ return new Result();
+ }
+
+ @DeleteMapping
+ public Result delete(@RequestBody String[] ids) {
+ //效验数据
+ AssertUtils.isArrayEmpty(ids, "id");
+ deptMaCodeService.delete(ids);
+ return new Result();
+ }
+
+ @GetMapping("export")
+ public void export(@RequestParam Map params, HttpServletResponse response) throws Exception {
+ List list = deptMaCodeService.list(params);
+ ExcelUtils.exportExcelToTarget(response, null, list, DeptMaCodeExcel.class);
+ }
+
+ /**
+ * 将网格机构信息同步到小程序码表(只是同步机构信息,不会创建小程序码)
+ *
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ * @author work@yujt.net.cn
+ * @date 2020/5/18 15:18
+ */
+ @PostMapping("initDeptForMaCode")
+ public Result initDeptForMaCode() {
+ deptMaCodeService.initDeptForMaCode();
+ return new Result();
+ }
+
+
+ /**
+ * 生成指定网格小程序码
+ *
+ * @param gridId
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ * @author work@yujt.net.cn
+ * @date 2019/9/19 11:04
+ */
+ @PostMapping("create/{gridId}")
+ public Result createDeptMaCode(@PathVariable("gridId") String gridId) {
+ return deptMaCodeService.createDeptMaCode(gridId);
+ }
+
+ /**
+ * 创建网格长注册小程序码
+ *
+ * @return com.elink.esua.epdc.commons.tools.utils.Result
+ * @author work@yujt.net.cn
+ * @date 2019/10/22 09:59
+ */
+ @PostMapping("gridLeader")
+ public Result createGridLeaderMaCode() {
+ return deptMaCodeService.createGridLeaderMaCode();
+ }
+}
\ No newline at end of file
diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dao/OptDeptMaCodeDao.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dao/OptDeptMaCodeDao.java
new file mode 100644
index 0000000..7f255b3
--- /dev/null
+++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dao/OptDeptMaCodeDao.java
@@ -0,0 +1,69 @@
+/**
+ * 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.optimize.modules.macode.dao;
+
+import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
+import com.elink.esua.epdc.optimize.modules.macode.dto.OptDeptMaCodeDTO;
+import com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 网格小程序码
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2020-05-15
+ */
+@Mapper
+public interface OptDeptMaCodeDao extends BaseDao {
+
+ /**
+ * 根据机构类型,查询机构id及pids
+ *
+ * @param dataScopeDeptIds 用户部门数据权限
+ * @param typeKey 机构类型{@link com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant}
+ * @return java.util.List
+ * @author work@yujt.net.cn
+ * @date 2020/5/15 13:58
+ */
+ List selectListDeptIdByTypeKey(@Param("dataScopeDeptIds") List dataScopeDeptIds, @Param("typeKey") String typeKey);
+
+ /**
+ * 根据机构id和机构父id,查询机构及父机构名称
+ *
+ * @param deptId 机构id
+ * @param parentIds 父机构id
+ * @return java.util.List
+ * @author work@yujt.net.cn
+ * @date 2020/5/15 14:10
+ */
+ List selectListDeptAndParents(@Param("deptId") Long deptId, @Param("parentIds") String[] parentIds);
+
+ /**
+ * 小程序码维护 - 分页查询
+ *
+ * @param params
+ * @return java.util.List
+ * @author work@yujt.net.cn
+ * @date 2020/5/18 14:35
+ */
+ List selectListDeptMaCode(Map params);
+}
\ No newline at end of file
diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dto/OptDeptMaCodeDTO.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dto/OptDeptMaCodeDTO.java
new file mode 100644
index 0000000..2dba190
--- /dev/null
+++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dto/OptDeptMaCodeDTO.java
@@ -0,0 +1,111 @@
+/**
+ * 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.optimize.modules.macode.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+
+import com.elink.esua.epdc.commons.mybatis.entity.DeptScope;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+
+/**
+ * 网格小程序码
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2020-05-15
+ */
+@Data
+@EqualsAndHashCode(callSuper=false)
+@TableName("epdc_dept_ma_code_copy1")
+public class OptDeptMaCodeEntity extends DeptScope {
+
+ private static final long serialVersionUID = -6665011097985008073L;
+
+ /**
+ * 网格ID
+ */
+ private Long gridId;
+
+ /**
+ * 小程序码URL
+ */
+ private String codeUrl;
+
+ /**
+ * 是否是网格长码,0否 1是
+ */
+ private String leaderFlag;
+
+ /**
+ * 网格名称
+ */
+ private String grid;
+
+}
\ No newline at end of file
diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/excel/DeptMaCodeExcel.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/excel/DeptMaCodeExcel.java
new file mode 100644
index 0000000..ed5317b
--- /dev/null
+++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/excel/DeptMaCodeExcel.java
@@ -0,0 +1,80 @@
+/**
+ * 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.optimize.modules.macode.excel;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * 网格小程序码
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2020-05-15
+ */
+@Data
+public class DeptMaCodeExcel {
+
+ @Excel(name = "主键")
+ private String id;
+
+ @Excel(name = "网格ID")
+ private Long gridId;
+
+ @Excel(name = "小程序码URL")
+ private String codeUrl;
+
+ @Excel(name = "乐观锁")
+ private Integer revision;
+
+ @Excel(name = "创建人")
+ private String createdBy;
+
+ @Excel(name = "创建时间")
+ private Date createdTime;
+
+ @Excel(name = "更新人")
+ private String updatedBy;
+
+ @Excel(name = "更新时间")
+ private Date updatedTime;
+
+ @Excel(name = "删除标记")
+ private String delFlag;
+
+ @Excel(name = "是否是网格长码,0否 1是")
+ private String leaderFlag;
+
+ @Excel(name = "网格名称")
+ private String grid;
+
+ @Excel(name = "父所有部门")
+ private String parentDeptIds;
+
+ @Excel(name = "父所有部门")
+ private String parentDeptNames;
+
+ @Excel(name = "所有部门ID")
+ private String allDeptIds;
+
+ @Excel(name = "所有部门名称")
+ private String allDeptNames;
+
+
+}
\ No newline at end of file
diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/redis/DeptMaCodeRedis.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/redis/DeptMaCodeRedis.java
new file mode 100644
index 0000000..9bcdccd
--- /dev/null
+++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/redis/DeptMaCodeRedis.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.optimize.modules.macode.redis;
+
+import com.elink.esua.epdc.commons.tools.redis.RedisUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+/**
+ * 网格小程序码
+ *
+ * @author elink elink@elink-cn.com
+ * @since v1.0.0 2020-05-15
+ */
+@Component
+public class DeptMaCodeRedis {
+ @Autowired
+ private RedisUtils redisUtils;
+
+ public void delete(Object[] ids) {
+
+ }
+
+ public void set(){
+
+ }
+
+ public String get(String id){
+ return null;
+ }
+
+}
\ No newline at end of file
diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/OptDeptMaCodeService.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/OptDeptMaCodeService.java
new file mode 100644
index 0000000..11a3c46
--- /dev/null
+++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/OptDeptMaCodeService.java
@@ -0,0 +1,125 @@
+/**
+ * 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.
+ *