23 changed files with 1244 additions and 8 deletions
			
			
		@ -1 +1 @@ | 
				
			|||
Subproject commit 2c711c34b8ce648b6a2bab712e1d03a6c29d2cfe | 
				
			|||
Subproject commit a2fed4ff196b53fa08785a944a073b4e2de4a626 | 
				
			|||
@ -0,0 +1,116 @@ | 
				
			|||
<?xml version="1.0" encoding="UTF-8"?> | 
				
			|||
<project xmlns="http://maven.apache.org/POM/4.0.0" | 
				
			|||
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | 
				
			|||
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | 
				
			|||
    <parent> | 
				
			|||
        <groupId>com.esua.epdc.yushan</groupId> | 
				
			|||
        <artifactId>epdc-cloud-parent-yushan</artifactId> | 
				
			|||
        <version>1.0.0</version> | 
				
			|||
        <relativePath>../epdc-cloud-parent-yushan</relativePath> | 
				
			|||
    </parent> | 
				
			|||
    <modelVersion>4.0.0</modelVersion> | 
				
			|||
 | 
				
			|||
    <version>1.0.0</version> | 
				
			|||
    <artifactId>epdc-cloud-optimize-department</artifactId> | 
				
			|||
    <packaging>jar</packaging> | 
				
			|||
    <description>党群e家部门机构优化微服务模块</description> | 
				
			|||
 | 
				
			|||
    <dependencies> | 
				
			|||
        <dependency> | 
				
			|||
            <groupId>org.projectlombok</groupId> | 
				
			|||
            <artifactId>lombok</artifactId> | 
				
			|||
            <scope>provided</scope> | 
				
			|||
        </dependency> | 
				
			|||
        <dependency> | 
				
			|||
            <groupId>org.springframework.boot</groupId> | 
				
			|||
            <artifactId>spring-boot-autoconfigure</artifactId> | 
				
			|||
            <scope>compile</scope> | 
				
			|||
        </dependency> | 
				
			|||
        <dependency> | 
				
			|||
            <groupId>com.esua.epdc.yushan</groupId> | 
				
			|||
            <artifactId>epdc-commons-mybatis</artifactId> | 
				
			|||
            <version>${epdc-cloud-commons.version}</version> | 
				
			|||
        </dependency> | 
				
			|||
        <!--微信小程序--> | 
				
			|||
        <dependency> | 
				
			|||
            <groupId>com.esua.epdc.yushan</groupId> | 
				
			|||
            <artifactId>epdc-commons-tools-wx-ma</artifactId> | 
				
			|||
            <version>${epdc-cloud-commons.version}</version> | 
				
			|||
        </dependency> | 
				
			|||
        <dependency> | 
				
			|||
            <groupId>org.springframework.boot</groupId> | 
				
			|||
            <artifactId>spring-boot-starter-web</artifactId> | 
				
			|||
        </dependency> | 
				
			|||
        <dependency> | 
				
			|||
            <groupId>org.springframework</groupId> | 
				
			|||
            <artifactId>spring-context-support</artifactId> | 
				
			|||
        </dependency> | 
				
			|||
        <dependency> | 
				
			|||
            <groupId>com.esua.epdc.yushan</groupId> | 
				
			|||
            <artifactId>epdc-commons-api-version-control</artifactId> | 
				
			|||
            <version>${epdc-cloud-commons.version}</version> | 
				
			|||
        </dependency> | 
				
			|||
 | 
				
			|||
        <!--业务模块--> | 
				
			|||
        <dependency> | 
				
			|||
            <groupId>com.esua.epdc.yushan</groupId> | 
				
			|||
            <artifactId>epdc-cloud-admin-client</artifactId> | 
				
			|||
            <version>${epdc-cloud-client.version}</version> | 
				
			|||
        </dependency> | 
				
			|||
    </dependencies> | 
				
			|||
 | 
				
			|||
 | 
				
			|||
    <build> | 
				
			|||
        <finalName>${project.artifactId}</finalName> | 
				
			|||
        <plugins> | 
				
			|||
            <!--<plugin> | 
				
			|||
                <groupId>org.springframework.boot</groupId> | 
				
			|||
                <artifactId>spring-boot-maven-plugin</artifactId> | 
				
			|||
            </plugin>--> | 
				
			|||
            <plugin> | 
				
			|||
                <groupId>org.apache.maven.plugins</groupId> | 
				
			|||
                <artifactId>maven-surefire-plugin</artifactId> | 
				
			|||
                <configuration> | 
				
			|||
                    <skipTests>true</skipTests> | 
				
			|||
                </configuration> | 
				
			|||
            </plugin> | 
				
			|||
            <plugin> | 
				
			|||
                <groupId>org.apache.maven.plugins</groupId> | 
				
			|||
                <artifactId>maven-deploy-plugin</artifactId> | 
				
			|||
                <configuration> | 
				
			|||
                    <skip>true</skip> | 
				
			|||
                </configuration> | 
				
			|||
            </plugin> | 
				
			|||
            <plugin> | 
				
			|||
                <groupId>com.spotify</groupId> | 
				
			|||
                <artifactId>dockerfile-maven-plugin</artifactId> | 
				
			|||
            </plugin> | 
				
			|||
        </plugins> | 
				
			|||
 | 
				
			|||
        <sourceDirectory>${project.basedir}/src/main/java</sourceDirectory> | 
				
			|||
 | 
				
			|||
        <resources> | 
				
			|||
            <resource> | 
				
			|||
                <filtering>true</filtering> | 
				
			|||
                <directory>${basedir}/src/main/resources</directory> | 
				
			|||
                <includes> | 
				
			|||
                    <include>**/application*.yml</include> | 
				
			|||
                    <include>**/*.properties</include> | 
				
			|||
                    <include>logback-spring.xml</include> | 
				
			|||
                    <include>registry.conf</include> | 
				
			|||
                </includes> | 
				
			|||
            </resource> | 
				
			|||
            <resource> | 
				
			|||
                <directory>${basedir}/src/main/resources</directory> | 
				
			|||
                <excludes> | 
				
			|||
                    <exclude>**/application*.yml</exclude> | 
				
			|||
                    <exclude>**/*.properties</exclude> | 
				
			|||
                    <exclude>logback-spring.xml</exclude> | 
				
			|||
                    <exclude>registry.conf</exclude> | 
				
			|||
                </excludes> | 
				
			|||
            </resource> | 
				
			|||
        </resources> | 
				
			|||
    </build> | 
				
			|||
 | 
				
			|||
 | 
				
			|||
</project> | 
				
			|||
@ -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 '所有部门名称'; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
@ -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<java.lang.String> | 
				
			|||
     * @author work@yujt.net.cn | 
				
			|||
     * @date 2019/9/19 10:15 | 
				
			|||
     */ | 
				
			|||
    @PostMapping(value = "oss/file/uploadFile", consumes = MediaType.APPLICATION_JSON_VALUE) | 
				
			|||
    Result<String> uploadFile(UploadToOssDTO dto); | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -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<String> uploadFile(UploadToOssDTO dto) { | 
				
			|||
        return ModuleUtils.feignConError(ServiceConstant.EPDC_OSS_SERVER, "uploadFile", dto.getFileName()); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,133 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
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<PageData<OptDeptMaCodeDTO>> page(@RequestParam Map<String, Object> params) { | 
				
			|||
        PageData<OptDeptMaCodeDTO> page = deptMaCodeService.page(params); | 
				
			|||
        return new Result<PageData<OptDeptMaCodeDTO>>().ok(page); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @GetMapping("{id}") | 
				
			|||
    public Result<DeptMaCodeDTO> get(@PathVariable("id") String id) { | 
				
			|||
        DeptMaCodeDTO data = deptMaCodeService.get(id); | 
				
			|||
        return new Result<DeptMaCodeDTO>().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<String, Object> params, HttpServletResponse response) throws Exception { | 
				
			|||
        List<DeptMaCodeDTO> 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(); | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -0,0 +1,69 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
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<OptDeptMaCodeEntity> { | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 根据机构类型,查询机构id及pids | 
				
			|||
     * | 
				
			|||
     * @param dataScopeDeptIds 用户部门数据权限 | 
				
			|||
     * @param typeKey          机构类型{@link com.elink.esua.epdc.commons.tools.constant.OrganizationTypeConstant} | 
				
			|||
     * @return java.util.List<com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity> | 
				
			|||
     * @author work@yujt.net.cn | 
				
			|||
     * @date 2020/5/15 13:58 | 
				
			|||
     */ | 
				
			|||
    List<OptDeptMaCodeEntity> selectListDeptIdByTypeKey(@Param("dataScopeDeptIds") List<Long> dataScopeDeptIds, @Param("typeKey") String typeKey); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 根据机构id和机构父id,查询机构及父机构名称 | 
				
			|||
     * | 
				
			|||
     * @param deptId    机构id | 
				
			|||
     * @param parentIds 父机构id | 
				
			|||
     * @return java.util.List<com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity> | 
				
			|||
     * @author work@yujt.net.cn | 
				
			|||
     * @date 2020/5/15 14:10 | 
				
			|||
     */ | 
				
			|||
    List<OptDeptMaCodeEntity> selectListDeptAndParents(@Param("deptId") Long deptId, @Param("parentIds") String[] parentIds); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 小程序码维护 - 分页查询 | 
				
			|||
     * | 
				
			|||
     * @param params | 
				
			|||
     * @return java.util.List<com.elink.esua.epdc.optimize.modules.macode.dto.OptDeptMaCodeDTO> | 
				
			|||
     * @author work@yujt.net.cn | 
				
			|||
     * @date 2020/5/18 14:35 | 
				
			|||
     */ | 
				
			|||
    List<OptDeptMaCodeDTO> selectListDeptMaCode(Map<String, Object> params); | 
				
			|||
} | 
				
			|||
@ -0,0 +1,111 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
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; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,60 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
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; | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,80 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
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; | 
				
			|||
 | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,47 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
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; | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -0,0 +1,125 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
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<OptDeptMaCodeEntity> { | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 默认分页 | 
				
			|||
     * | 
				
			|||
     * @param params | 
				
			|||
     * @return PageData<OptDeptMaCodeDTO> | 
				
			|||
     * @author generator | 
				
			|||
     * @date 2020-05-15 | 
				
			|||
     */ | 
				
			|||
    PageData<OptDeptMaCodeDTO> page(Map<String, Object> params); | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 默认查询 | 
				
			|||
     * | 
				
			|||
     * @param params | 
				
			|||
     * @return java.util.List<OptDeptMaCodeDTO> | 
				
			|||
     * @author generator | 
				
			|||
     * @date 2020-05-15 | 
				
			|||
     */ | 
				
			|||
    List<DeptMaCodeDTO> list(Map<String, Object> 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(); | 
				
			|||
} | 
				
			|||
@ -0,0 +1,266 @@ | 
				
			|||
/** | 
				
			|||
 * Copyright 2018 人人开源 https://www.renren.io
 | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * 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. | 
				
			|||
 * <p> | 
				
			|||
 * You should have received a copy of the GNU General Public License | 
				
			|||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
				
			|||
 */ | 
				
			|||
 | 
				
			|||
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<OptDeptMaCodeDao, OptDeptMaCodeEntity> implements OptDeptMaCodeService { | 
				
			|||
 | 
				
			|||
    @Autowired | 
				
			|||
    private WxMaServiceUtils wxMaServiceUtils; | 
				
			|||
 | 
				
			|||
    @Autowired | 
				
			|||
    private OptOssFeignClient ossFeignClient; | 
				
			|||
 | 
				
			|||
    /** | 
				
			|||
     * 小程序首页 | 
				
			|||
     */ | 
				
			|||
    private final static String MA_FRONT_PAGE_URL = "pages/index/index"; | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public PageData<OptDeptMaCodeDTO> page(Map<String, Object> params) { | 
				
			|||
        params.put("dataScopeDeptIds", SecurityUser.getUser().getDeptIdList()); | 
				
			|||
        IPage<OptDeptMaCodeDTO> page = getPage(params); | 
				
			|||
        List<OptDeptMaCodeDTO> pageDataList = baseDao.selectListDeptMaCode(params); | 
				
			|||
        return new PageData<>(pageDataList, page.getTotal()); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public Result initDeptForMaCode() { | 
				
			|||
        List<Long> dataScopeList = SecurityUser.getUser().getDeptIdList(); | 
				
			|||
        List<OptDeptMaCodeEntity> deptIdList = baseDao.selectListDeptIdByTypeKey(dataScopeList, OrganizationTypeConstant.ORG_TYPE_GRID_PARTY); | 
				
			|||
        if (CollUtil.isEmpty(deptIdList)) { | 
				
			|||
            return new Result(); | 
				
			|||
        } | 
				
			|||
        List<OptDeptMaCodeEntity> 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<OptDeptMaCodeEntity> wrapper = new UpdateWrapper<>(); | 
				
			|||
        wrapper.eq(FieldConstant.GRID_ID, gridId); | 
				
			|||
 | 
				
			|||
        baseDao.update(entity, wrapper); | 
				
			|||
        return new Result(); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    @Override | 
				
			|||
    public Result createGridLeaderMaCode() { | 
				
			|||
        QueryWrapper<OptDeptMaCodeEntity> 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<String> 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<OptDeptMaCodeEntity> deptList = baseDao.selectListDeptAndParents(deptId, deptPids); | 
				
			|||
        if (CollUtil.isEmpty(deptList)) { | 
				
			|||
            return null; | 
				
			|||
        } | 
				
			|||
        // 按上下级顺序组装部门集合
 | 
				
			|||
        List<OptDeptMaCodeEntity> 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<DeptMaCodeDTO> list(Map<String, Object> params) { | 
				
			|||
        List<OptDeptMaCodeEntity> entityList = baseDao.selectList(getWrapper(params)); | 
				
			|||
 | 
				
			|||
        return ConvertUtils.sourceToTarget(entityList, DeptMaCodeDTO.class); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
    private QueryWrapper<OptDeptMaCodeEntity> getWrapper(Map<String, Object> params) { | 
				
			|||
        String id = (String) params.get(FieldConstant.ID_HUMP); | 
				
			|||
 | 
				
			|||
        QueryWrapper<OptDeptMaCodeEntity> 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)); | 
				
			|||
    } | 
				
			|||
 | 
				
			|||
 | 
				
			|||
} | 
				
			|||
@ -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; | 
				
			|||
    } | 
				
			|||
} | 
				
			|||
@ -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' | 
				
			|||
 | 
				
			|||
@ -0,0 +1,31 @@ | 
				
			|||
<?xml version="1.0" encoding="UTF-8"?> | 
				
			|||
<configuration> | 
				
			|||
 | 
				
			|||
    <!-- 开发、测试环境 --> | 
				
			|||
    <springProfile name="dev,test"> | 
				
			|||
        <logger name="org.springframework.web" level="INFO"/> | 
				
			|||
        <logger name="org.springboot.sample" level="INFO"/> | 
				
			|||
        <logger name="com.elink.esua.epdc" level="INFO"/> | 
				
			|||
        <logger name="com.elink.esua.epdc.optimize.modules.macode.dao" level="DEBUG"/> | 
				
			|||
        <root level="INFO"> | 
				
			|||
            <appender-ref ref="DEBUG_FILE"/> | 
				
			|||
            <appender-ref ref="INFO_FILE"/> | 
				
			|||
            <appender-ref ref="WARN_FILE"/> | 
				
			|||
            <appender-ref ref="ERROR_FILE"/> | 
				
			|||
        </root> | 
				
			|||
    </springProfile> | 
				
			|||
 | 
				
			|||
    <!-- 生产环境 --> | 
				
			|||
    <springProfile name="prod"> | 
				
			|||
        <logger name="org.springframework.web" level="INFO"/> | 
				
			|||
        <logger name="org.springboot.sample" level="INFO"/> | 
				
			|||
        <logger name="com.elink.esua.epdc" level="INFO"/> | 
				
			|||
        <root level="INFO"> | 
				
			|||
            <appender-ref ref="DEBUG_FILE"/> | 
				
			|||
            <appender-ref ref="INFO_FILE"/> | 
				
			|||
            <appender-ref ref="WARN_FILE"/> | 
				
			|||
            <appender-ref ref="ERROR_FILE"/> | 
				
			|||
        </root> | 
				
			|||
    </springProfile> | 
				
			|||
 | 
				
			|||
</configuration> | 
				
			|||
@ -0,0 +1,59 @@ | 
				
			|||
<?xml version="1.0" encoding="UTF-8"?> | 
				
			|||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | 
				
			|||
 | 
				
			|||
<mapper namespace="com.elink.esua.epdc.optimize.modules.macode.dao.OptDeptMaCodeDao"> | 
				
			|||
 | 
				
			|||
    <select id="selectListDeptIdByTypeKey" | 
				
			|||
            resultType="com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity"> | 
				
			|||
	    SELECT | 
				
			|||
	        t.id as gridId,t.pids as parentDeptIds | 
				
			|||
	    FROM | 
				
			|||
	        sys_dept t | 
				
			|||
	    WHERE | 
				
			|||
	        t.type_key = #{typeKey} AND t.del_flag = '0' | 
				
			|||
            AND NOT EXISTS (SELECT 1 FROM epdc_dept_ma_code_copy1 c WHERE c.GRID_ID = t.id AND c.del_flag = '0') | 
				
			|||
            <if test="dataScopeDeptIds != null and  dataScopeDeptIds.size() > 0"> | 
				
			|||
                AND t.id IN <foreach collection="dataScopeDeptIds" open="(" separator="," close=")" item="deptId">#{deptId}</foreach> | 
				
			|||
            </if> | 
				
			|||
	    ORDER BY t.update_date ASC; | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
    <select id="selectListDeptAndParents" | 
				
			|||
            resultType="com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity"> | 
				
			|||
        SELECT | 
				
			|||
            t.id as  gridId, t.`name` as grid | 
				
			|||
        FROM | 
				
			|||
            sys_dept t | 
				
			|||
        WHERE | 
				
			|||
            t.id = #{deptId} | 
				
			|||
            <if test="parentIds != null and  parentIds.length > 0"> | 
				
			|||
                OR t.id IN <foreach collection="parentIds" open="(" separator="," close=")" item="parentId">#{parentId}</foreach> | 
				
			|||
            </if> | 
				
			|||
        ORDER BY t.update_date ASC; | 
				
			|||
    </select> | 
				
			|||
    <select id="selectListDeptMaCode" | 
				
			|||
            resultType="com.elink.esua.epdc.optimize.modules.macode.dto.OptDeptMaCodeDTO"> | 
				
			|||
        select * from epdc_dept_ma_code_copy1 ma | 
				
			|||
        where  ma.del_flag = '0' | 
				
			|||
        <choose> | 
				
			|||
            <when test='leaderFlag != null and leaderFlag != "" and leaderFlag == "1"'>and ma.leader_flag = '1'</when> | 
				
			|||
            <otherwise> | 
				
			|||
                and ma.leader_flag = '0' | 
				
			|||
                <if test="gridId != null and gridId != ''"> | 
				
			|||
                    and ma.grid_id = #{gridId} | 
				
			|||
                </if> | 
				
			|||
                <if test="communityId != null and communityId != ''"> | 
				
			|||
                    and ma.all_dept_ids like '%${communityId}%' | 
				
			|||
                </if> | 
				
			|||
                <if test="streetId != null and streetId != ''"> | 
				
			|||
                    and ma.all_dept_ids like '%${streetId}%' | 
				
			|||
                </if> | 
				
			|||
                <if test='dataScopeDeptIds != null and  dataScopeDeptIds.size() > 0'> | 
				
			|||
                    AND ma.grid_id IN <foreach collection="dataScopeDeptIds" open="(" separator="," close=")" item="deptId">#{deptId}</foreach> | 
				
			|||
                </if> | 
				
			|||
            </otherwise> | 
				
			|||
        </choose> | 
				
			|||
    </select> | 
				
			|||
 | 
				
			|||
 | 
				
			|||
</mapper> | 
				
			|||
					Loading…
					
					
				
		Reference in new issue