diff --git a/epdc-cloud-admin/pom.xml b/epdc-cloud-admin/pom.xml index 9cf550f..ce6485a 100644 --- a/epdc-cloud-admin/pom.xml +++ b/epdc-cloud-admin/pom.xml @@ -84,6 +84,12 @@ ${epdc-cloud-client.version} + + + com.esua.epdc.yushan + epdc-cloud-optimize-department + 1.0.0 + @@ -158,7 +164,7 @@ false 47.104.224.45:8848 - a746dde3-7a13-4521-b986-7369b0b7c269 + de000340-5fc4-45aa-bdbc-dd96852012ad http://localhost:9411 diff --git a/epdc-cloud-admin/src/main/java/com/elink/esua/epdc/dao/DeptMaCodeDao.java b/epdc-cloud-admin/src/main/java/com/elink/esua/epdc/dao/DeptMaCodeDao.java index c5bb9c4..d8e4ba1 100644 --- a/epdc-cloud-admin/src/main/java/com/elink/esua/epdc/dao/DeptMaCodeDao.java +++ b/epdc-cloud-admin/src/main/java/com/elink/esua/epdc/dao/DeptMaCodeDao.java @@ -38,7 +38,7 @@ public interface DeptMaCodeDao extends BaseDao { * 获取部门小程序码列表 * * @param params - * @return java.util.List + * @return java.util.List * @author work@yujt.net.cn * @date 2019/9/19 09:18 */ diff --git a/epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/DeptMaCodeService.java b/epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/DeptMaCodeService.java index c82db65..f47db3a 100644 --- a/epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/DeptMaCodeService.java +++ b/epdc-cloud-admin/src/main/java/com/elink/esua/epdc/service/DeptMaCodeService.java @@ -38,7 +38,7 @@ public interface DeptMaCodeService extends BaseService { * 默认分页 * * @param params - * @return PageData + * @return PageData * @author generator * @date 2019-09-19 */ @@ -48,7 +48,7 @@ public interface DeptMaCodeService extends BaseService { * 默认查询 * * @param params - * @return java.util.List + * @return java.util.List * @author generator * @date 2019-09-19 */ @@ -58,7 +58,7 @@ public interface DeptMaCodeService extends BaseService { * 单条查询 * * @param id - * @return DeptMaCodeDTO + * @return OptDeptMaCodeDTO * @author generator * @date 2019-09-19 */ diff --git a/epdc-cloud-admin/src/main/resources/application.yml b/epdc-cloud-admin/src/main/resources/application.yml index 9156371..1920126 100644 --- a/epdc-cloud-admin/src/main/resources/application.yml +++ b/epdc-cloud-admin/src/main/resources/application.yml @@ -45,7 +45,7 @@ management: show-details: ALWAYS mybatis-plus: - mapper-locations: classpath:/mapper/**/*.xml + mapper-locations: classpath*:/mapper/**/*.xml #实体扫描,多个package用逗号或者分号分隔 typeAliasesPackage: com.elink.esua.epdc.entity global-config: diff --git a/epdc-cloud-admin/src/main/resources/logback-spring.xml b/epdc-cloud-admin/src/main/resources/logback-spring.xml index 3fa19ae..32be976 100644 --- a/epdc-cloud-admin/src/main/resources/logback-spring.xml +++ b/epdc-cloud-admin/src/main/resources/logback-spring.xml @@ -148,7 +148,6 @@ - diff --git a/epdc-cloud-gateway-yushan b/epdc-cloud-gateway-yushan index 2c711c3..a2fed4f 160000 --- a/epdc-cloud-gateway-yushan +++ b/epdc-cloud-gateway-yushan @@ -1 +1 @@ -Subproject commit 2c711c34b8ce648b6a2bab712e1d03a6c29d2cfe +Subproject commit a2fed4ff196b53fa08785a944a073b4e2de4a626 diff --git a/epdc-cloud-optimize-department/pom.xml b/epdc-cloud-optimize-department/pom.xml new file mode 100644 index 0000000..7b313c9 --- /dev/null +++ b/epdc-cloud-optimize-department/pom.xml @@ -0,0 +1,116 @@ + + + + com.esua.epdc.yushan + epdc-cloud-parent-yushan + 1.0.0 + ../epdc-cloud-parent-yushan + + 4.0.0 + + 1.0.0 + epdc-cloud-optimize-department + jar + 党群e家部门机构优化微服务模块 + + + + org.projectlombok + lombok + provided + + + org.springframework.boot + spring-boot-autoconfigure + compile + + + com.esua.epdc.yushan + epdc-commons-mybatis + ${epdc-cloud-commons.version} + + + + com.esua.epdc.yushan + epdc-commons-tools-wx-ma + ${epdc-cloud-commons.version} + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework + spring-context-support + + + com.esua.epdc.yushan + epdc-commons-api-version-control + ${epdc-cloud-commons.version} + + + + + com.esua.epdc.yushan + epdc-cloud-admin-client + ${epdc-cloud-client.version} + + + + + + ${project.artifactId} + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + com.spotify + dockerfile-maven-plugin + + + + ${project.basedir}/src/main/java + + + + true + ${basedir}/src/main/resources + + **/application*.yml + **/*.properties + logback-spring.xml + registry.conf + + + + ${basedir}/src/main/resources + + **/application*.yml + **/*.properties + logback-spring.xml + registry.conf + + + + + + + \ No newline at end of file diff --git a/epdc-cloud-optimize-department/src/db/update.sql b/epdc-cloud-optimize-department/src/db/update.sql new file mode 100644 index 0000000..93f6401 --- /dev/null +++ b/epdc-cloud-optimize-department/src/db/update.sql @@ -0,0 +1,8 @@ +-- 小程序码维护功能,新增表字段,不影响原本的代码及功能 +ALTER TABLE epdc_dept_ma_code ADD COLUMN `GRID` VARCHAR ( 128 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL COMMENT '网格名称'; +ALTER TABLE epdc_dept_ma_code ADD COLUMN `PARENT_DEPT_IDS` VARCHAR ( 512 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '父所有部门'; +ALTER TABLE epdc_dept_ma_code ADD COLUMN `PARENT_DEPT_NAMES` VARCHAR ( 512 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '父所有部门'; +ALTER TABLE epdc_dept_ma_code ADD COLUMN `ALL_DEPT_IDS` VARCHAR ( 512 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所有部门ID'; +ALTER TABLE epdc_dept_ma_code ADD COLUMN `ALL_DEPT_NAMES` VARCHAR ( 512 ) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NULL DEFAULT NULL COMMENT '所有部门名称'; + + diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/feign/OptOssFeignClient.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/feign/OptOssFeignClient.java new file mode 100644 index 0000000..04c1690 --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/feign/OptOssFeignClient.java @@ -0,0 +1,30 @@ +package com.elink.esua.epdc.optimize.modules.feign; + +import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.UploadToOssDTO; +import com.elink.esua.epdc.optimize.modules.feign.fallback.OptOssFeignClientFallback; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.http.MediaType; +import org.springframework.web.bind.annotation.PostMapping; + + +/** + * @author work@yujt.net.cn + * @date 19/9/19 10:12 + */ +@FeignClient(name = ServiceConstant.EPDC_OSS_SERVER, fallback = OptOssFeignClientFallback.class) +public interface OptOssFeignClient { + + /** + * File文件上传到文件服务器 + * + * @param dto + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author work@yujt.net.cn + * @date 2019/9/19 10:15 + */ + @PostMapping(value = "oss/file/uploadFile", consumes = MediaType.APPLICATION_JSON_VALUE) + Result uploadFile(UploadToOssDTO dto); + +} diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/feign/fallback/OptOssFeignClientFallback.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/feign/fallback/OptOssFeignClientFallback.java new file mode 100644 index 0000000..ef021b4 --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/feign/fallback/OptOssFeignClientFallback.java @@ -0,0 +1,22 @@ +package com.elink.esua.epdc.optimize.modules.feign.fallback; + +import com.elink.esua.epdc.commons.tools.constant.ServiceConstant; +import com.elink.esua.epdc.commons.tools.utils.ModuleUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.UploadToOssDTO; +import com.elink.esua.epdc.optimize.modules.feign.OptOssFeignClient; +import org.springframework.stereotype.Component; + +/** + * @author work@yujt.net.cn + * @date 19/9/19 10:12 + */ +@Component +public class OptOssFeignClientFallback implements OptOssFeignClient { + + @Override + public Result uploadFile(UploadToOssDTO dto) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_OSS_SERVER, "uploadFile", dto.getFileName()); + } + +} diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/controller/OptDeptMaCodeController.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/controller/OptDeptMaCodeController.java new file mode 100644 index 0000000..4db776c --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/controller/OptDeptMaCodeController.java @@ -0,0 +1,133 @@ +/** + * 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.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. + *

+ * 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.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 网格小程序码 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-05-15 + */ +@Data +public class OptDeptMaCodeDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 网格ID + */ + private Long gridId; + + /** + * 小程序码URL + */ + private String codeUrl; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 删除标记 + */ + private String delFlag; + + /** + * 是否是网格长码,0否 1是 + */ + private String leaderFlag; + + /** + * 网格名称 + */ + private String grid; + + /** + * 父所有部门 + */ + private String parentDeptIds; + + /** + * 父所有部门 + */ + private String parentDeptNames; + + /** + * 所有部门ID + */ + private String allDeptIds; + + /** + * 所有部门名称 + */ + 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/entity/OptDeptMaCodeEntity.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/entity/OptDeptMaCodeEntity.java new file mode 100644 index 0000000..7276c14 --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/entity/OptDeptMaCodeEntity.java @@ -0,0 +1,60 @@ +/** + * 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.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. + *

+ * 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.service; + +import com.elink.esua.epdc.commons.mybatis.service.BaseService; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.commons.tools.utils.Result; +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.entity.OptDeptMaCodeEntity; + +import java.util.List; +import java.util.Map; + +/** + * 网格小程序码 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-05-15 + */ +public interface OptDeptMaCodeService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-05-15 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-05-15 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return OptDeptMaCodeDTO + * @author generator + * @date 2020-05-15 + */ + DeptMaCodeDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-05-15 + */ + void save(DeptMaCodeDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-05-15 + */ + void update(DeptMaCodeDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-05-15 + */ + void delete(String[] ids); + + /** + * 根据部门权限,同步部门信息 + * + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author work@yujt.net.cn + * @date 2020/5/15 15:27 + */ + Result initDeptForMaCode(); + + /** + * 生成指定网格小程序码 + * + * @param gridId + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author work@yujt.net.cn + * @date 2020/5/18 15:19 + */ + Result createDeptMaCode(String gridId); + + /** + * 创建网格长注册小程序码 + * + * @return com.elink.esua.epdc.commons.tools.utils.Result + * @author work@yujt.net.cn + * @date 2020/5/18 15:34 + */ + Result createGridLeaderMaCode(); +} \ No newline at end of file diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/impl/OptDeptMaCodeServiceImpl.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/impl/OptDeptMaCodeServiceImpl.java new file mode 100644 index 0000000..c79ff63 --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/impl/OptDeptMaCodeServiceImpl.java @@ -0,0 +1,266 @@ +/** + * 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.service.impl; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ArrayUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; +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.NumConstant; +import com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant; +import com.elink.esua.epdc.commons.tools.constant.StrConstant; +import com.elink.esua.epdc.commons.tools.enums.YesOrNoEnum; +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.security.user.SecurityUser; +import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.commons.tools.constant.FieldConstant; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dto.DeptMaCodeDTO; +import com.elink.esua.epdc.dto.UploadToOssDTO; +import com.elink.esua.epdc.optimize.modules.feign.OptOssFeignClient; +import com.elink.esua.epdc.optimize.modules.macode.dao.OptDeptMaCodeDao; +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.optimize.modules.macode.service.OptDeptMaCodeService; +import com.elink.esua.epdc.optimize.utils.FileUtils; +import com.elink.esua.epdc.utils.WxMaServiceUtils; +import com.google.common.collect.Lists; +import me.chanjar.weixin.common.error.WxErrorException; +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.io.File; +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 网格小程序码 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-05-15 + */ +@Service +public class OptDeptMaCodeServiceImpl extends BaseServiceImpl implements OptDeptMaCodeService { + + @Autowired + private WxMaServiceUtils wxMaServiceUtils; + + @Autowired + private OptOssFeignClient ossFeignClient; + + /** + * 小程序首页 + */ + private final static String MA_FRONT_PAGE_URL = "pages/index/index"; + + @Override + public PageData page(Map params) { + params.put("dataScopeDeptIds", SecurityUser.getUser().getDeptIdList()); + IPage page = getPage(params); + List pageDataList = baseDao.selectListDeptMaCode(params); + return new PageData<>(pageDataList, page.getTotal()); + } + + @Override + public Result initDeptForMaCode() { + List dataScopeList = SecurityUser.getUser().getDeptIdList(); + List deptIdList = baseDao.selectListDeptIdByTypeKey(dataScopeList, OrganizationTypeConstant.ORG_TYPE_GRID_PARTY); + if (CollUtil.isEmpty(deptIdList)) { + return new Result(); + } + List insertList = Lists.newArrayList(); + for (OptDeptMaCodeEntity deptMaCodeEntity : deptIdList) { + OptDeptMaCodeEntity entity = packDeptBaseInfo(deptMaCodeEntity.getGridId(), deptMaCodeEntity.getParentDeptIds()); + if (null != entity) { + insertList.add(entity); + } + } + insertBatch(insertList, NumConstant.FIFTY); + return new Result(); + } + + @Override + public Result createDeptMaCode(String gridId) { + OptDeptMaCodeEntity entity = new OptDeptMaCodeEntity(); + entity.setCodeUrl(this.createMaCode(gridId, MA_FRONT_PAGE_URL)); + this.baseDao.insert(entity); + + UpdateWrapper wrapper = new UpdateWrapper<>(); + wrapper.eq(FieldConstant.GRID_ID, gridId); + + baseDao.update(entity, wrapper); + return new Result(); + } + + @Override + public Result createGridLeaderMaCode() { + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq("leader_flag", YesOrNoEnum.YES.value()); + Integer selectCount = this.baseDao.selectCount(wrapper); + if (selectCount > NumConstant.ZERO) { + return new Result(); + } + OptDeptMaCodeEntity entity = new OptDeptMaCodeEntity(); + entity.setAllDeptNames("全平台通用"); + entity.setCodeUrl(this.createMaCode("gridLeader", MA_FRONT_PAGE_URL)); + entity.setLeaderFlag(YesOrNoEnum.YES.value()); + this.baseDao.insert(entity); + return new Result(); + } + + /** + * 创建微信小程序码,并上传到oss + * + * @param param 小程序码的参数 + * @param pageUrl 小程序码的跳转链接 + * @return java.lang.String 小程序码的下载抵制 + * @author work@yujt.net.cn + * @date 2019/10/22 10:14 + */ + private String createMaCode(String param, String pageUrl) { + File wxaCodeUnlimit; + try { + wxaCodeUnlimit = wxMaServiceUtils.normalWxMaService().getQrcodeService() + .createWxaCodeUnlimit(param, pageUrl, 1280, true, null, false); + } catch (WxErrorException e) { + throw new RenException("请求微信接口失败"); + } + + UploadToOssDTO dto = new UploadToOssDTO(); + dto.setFileByte(FileUtils.fileToByteArray(wxaCodeUnlimit)); + dto.setFileName(wxaCodeUnlimit.getName()); + + Result ossResult = ossFeignClient.uploadFile(dto); + if (null == ossResult || !ossResult.success() || null == ossResult.getData()) { + throw new RenException("小程序码上传失败"); + } + return ossResult.getData(); + } + + /** + * 获取部门及父部门信息,拼接部门id,部门名称 + * + * @param deptId 本部门id + * @param pids 所有父部门id + * @return com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity + * @author work@yujt.net.cn + * @date 2020/5/18 14:06 + */ + private OptDeptMaCodeEntity packDeptBaseInfo(Long deptId, String pids) { + + String[] deptPids = pids.split(StrConstant.COMMA); + // 查询机构及父级机构 + List deptList = baseDao.selectListDeptAndParents(deptId, deptPids); + if (CollUtil.isEmpty(deptList)) { + return null; + } + // 按上下级顺序组装部门集合 + List newDeptIdList = Lists.newArrayList(); + if (ArrayUtil.isEmpty(deptPids)) { + // 父级部门为空,则只有部门本身,没有上级 + newDeptIdList = deptList; + } else { + // 按部门顺序开始组装 + for (int i = 0; i < deptPids.length; i++) { + for (OptDeptMaCodeEntity entity : deptList) { + if (String.valueOf(entity.getGridId()).equals(deptPids[i])) { + newDeptIdList.add(entity); + deptList.remove(entity); + break; + } + } + } + // 所有父级部门处理完成,最后剩下部门本身 + newDeptIdList.addAll(deptList); + } + + int size = newDeptIdList.size(); + int maxIndex = size - NumConstant.ONE; + + String[] allDeptIds = new String[size]; + String[] allDeptNames = new String[size]; + String[] parentDeptIds = new String[maxIndex]; + String[] parentDeptNames = new String[maxIndex]; + for (int i = 0; i < size; i++) { + allDeptIds[i] = String.valueOf(newDeptIdList.get(i).getGridId()); + allDeptNames[i] = newDeptIdList.get(i).getGrid(); + if (i < maxIndex) { + parentDeptIds[i] = String.valueOf(newDeptIdList.get(i).getGridId()); + parentDeptNames[i] = newDeptIdList.get(i).getGrid(); + } + } + OptDeptMaCodeEntity deptMaCodeEntity = newDeptIdList.get(maxIndex); + deptMaCodeEntity.setLeaderFlag(YesOrNoEnum.NO.value()); + deptMaCodeEntity.setAllDeptIds(StringUtils.join(allDeptIds, StrConstant.COMMA)); + deptMaCodeEntity.setParentDeptIds(StringUtils.join(parentDeptIds, StrConstant.COMMA)); + deptMaCodeEntity.setAllDeptNames(StringUtils.join(allDeptNames, StrConstant.HYPHEN)); + deptMaCodeEntity.setParentDeptNames(StringUtils.join(parentDeptNames, StrConstant.HYPHEN)); + return deptMaCodeEntity; + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, DeptMaCodeDTO.class); + } + + private QueryWrapper getWrapper(Map params) { + String id = (String) params.get(FieldConstant.ID_HUMP); + + QueryWrapper wrapper = new QueryWrapper<>(); + wrapper.eq(StringUtils.isNotBlank(id), FieldConstant.ID, id); + + return wrapper; + } + + @Override + public DeptMaCodeDTO get(String id) { + OptDeptMaCodeEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, DeptMaCodeDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(DeptMaCodeDTO dto) { + OptDeptMaCodeEntity entity = ConvertUtils.sourceToTarget(dto, OptDeptMaCodeEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(DeptMaCodeDTO dto) { + OptDeptMaCodeEntity entity = ConvertUtils.sourceToTarget(dto, OptDeptMaCodeEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + +} \ No newline at end of file diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/utils/FileUtils.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/utils/FileUtils.java new file mode 100644 index 0000000..286d22b --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/utils/FileUtils.java @@ -0,0 +1,48 @@ +package com.elink.esua.epdc.optimize.utils; + +import com.elink.esua.epdc.commons.tools.constant.NumConstant; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.FileInputStream; + +/** + * 文件操作工具 + * + * @author work@yujt.net.cn + * @date 2020/5/18 15:27 + */ +public class FileUtils { + + + /** + * File文件转为byte[] + * + * @param file + * @return byte[] + * @author work@yujt.net.cn + * @date 2019/9/19 15:56 + */ + public static byte[] fileToByteArray(File file) { + try { + //获取输入流 + FileInputStream fis = new FileInputStream(file); + //新的 byte 数组输出流,缓冲区容量1024byte + ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); + //缓存 + byte[] b = new byte[1024]; + int n; + while ((n = fis.read(b)) != NumConstant.ONE_NEG) { + bos.write(b, NumConstant.ZERO, n); + } + fis.close(); + //改变为byte[] + byte[] data = bos.toByteArray(); + bos.close(); + return data; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } +} diff --git a/epdc-cloud-optimize-department/src/main/resources/application.yml b/epdc-cloud-optimize-department/src/main/resources/application.yml new file mode 100644 index 0000000..1070a5d --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/resources/application.yml @@ -0,0 +1,25 @@ + +mybatis-plus: + mapper-locations: classpath:/mapper/**/*.xml + #实体扫描,多个package用逗号或者分号分隔 + typeAliasesPackage: com.elink.esua.epdc.optimize.modules.*.entity + global-config: + #数据库相关配置 + db-config: + #主键类型 AUTO:"数据库ID自增", INPUT:"用户输入ID", ID_WORKER:"全局唯一ID (数字类型唯一ID)", UUID:"全局唯一ID UUID"; + id-type: ID_WORKER + #字段策略 IGNORED:"忽略判断",NOT_NULL:"非 NULL 判断"),NOT_EMPTY:"非空判断" + field-strategy: NOT_NULL + #驼峰下划线转换 + column-underline: true + #db-type: mysql + #刷新mapper 调试神器 + refresh-mapper: true + banner: false + #原生配置 + configuration: + map-underscore-to-camel-case: true + cache-enabled: false + call-setters-on-nulls: true + jdbc-type-for-null: 'null' + diff --git a/epdc-cloud-optimize-department/src/main/resources/logback-spring.xml b/epdc-cloud-optimize-department/src/main/resources/logback-spring.xml new file mode 100644 index 0000000..775c3c4 --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/resources/logback-spring.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/epdc-cloud-optimize-department/src/main/resources/mapper/macode/OptDeptMaCodeDao.xml b/epdc-cloud-optimize-department/src/main/resources/mapper/macode/OptDeptMaCodeDao.xml new file mode 100644 index 0000000..1b0e498 --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/resources/mapper/macode/OptDeptMaCodeDao.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + \ No newline at end of file diff --git a/pom.xml b/pom.xml index c48ddad..eb3c91f 100644 --- a/pom.xml +++ b/pom.xml @@ -15,5 +15,6 @@ epdc-cloud-commons-yushan epdc-cloud-gateway-yushan epdc-cloud-parent-yushan + epdc-cloud-optimize-department