+ * 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.optimize.modules.macode.dto.OptDeptMaCodeDTO;
+import com.elink.esua.epdc.optimize.modules.macode.service.OptDeptMaCodeService;
+import com.elink.esua.epdc.commons.tools.page.PageData;
+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 org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+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) {
+ OptDeptMaCodeDTO data = deptMaCodeService.get(id);
+ return new Result().ok(data);
+ }
+
+ @PostMapping
+ public Result save(@RequestBody OptDeptMaCodeDTO dto) {
+ //效验数据
+ ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
+ deptMaCodeService.save(dto);
+ return new Result();
+ }
+
+ @PutMapping
+ public Result update(@RequestBody OptDeptMaCodeDTO 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();
+ }
+
+ /**
+ * 将网格机构信息同步到小程序码表(只是同步机构信息,不会创建小程序码)
+ *
+ * @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/esua-epdc/epdc-admin/epdc-cloud-optimize/epdc-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dao/OptDeptMaCodeDao.java b/esua-epdc/epdc-admin/epdc-cloud-optimize/epdc-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dao/OptDeptMaCodeDao.java
new file mode 100644
index 000000000..d5d169afd
--- /dev/null
+++ b/esua-epdc/epdc-admin/epdc-cloud-optimize/epdc-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dao/OptDeptMaCodeDao.java
@@ -0,0 +1,58 @@
+/**
+ * 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.optimize.modules.macode.dto.OptDeptMaCodeDTO;
+import com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity;
+import com.elink.esua.epdc.commons.mybatis.dao.BaseDao;
+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);
+
+ /**
+ * 小程序码维护 - 分页查询
+ *
+ * @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/esua-epdc/epdc-admin/epdc-cloud-optimize/epdc-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dto/OptDeptMaCodeDTO.java b/esua-epdc/epdc-admin/epdc-cloud-optimize/epdc-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dto/OptDeptMaCodeDTO.java
new file mode 100644
index 000000000..2dba1900f
--- /dev/null
+++ b/esua-epdc/epdc-admin/epdc-cloud-optimize/epdc-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")
+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/esua-epdc/epdc-admin/epdc-cloud-optimize/epdc-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/OptDeptMaCodeService.java b/esua-epdc/epdc-admin/epdc-cloud-optimize/epdc-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/OptDeptMaCodeService.java
new file mode 100644
index 000000000..4e5e01327
--- /dev/null
+++ b/esua-epdc/epdc-admin/epdc-cloud-optimize/epdc-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/OptDeptMaCodeService.java
@@ -0,0 +1,124 @@
+/**
+ * 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.
+ *