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/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-optimize-department/pom.xml b/epdc-cloud-optimize-department/pom.xml new file mode 100644 index 0000000..e240122 --- /dev/null +++ b/epdc-cloud-optimize-department/pom.xml @@ -0,0 +1,57 @@ + + + + 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} + + + 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} + + + + + \ 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/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..3eced8b --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/controller/OptDeptMaCodeController.java @@ -0,0 +1,101 @@ +/** + * 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.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); + } + + + + @PostMapping("initDeptForMaCode") + public Result initDeptForMaCode(){ + deptMaCodeService.initDeptForMaCode(); + return new Result(); + } +} \ 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..f5efac6 --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dao/OptDeptMaCodeDao.java @@ -0,0 +1,57 @@ +/** + * 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.entity.OptDeptMaCodeEntity; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * 网格小程序码 + * + * @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") String deptId, @Param("parentIds") String[] parentIds); +} \ No newline at end of file diff --git a/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dto/DeptMaCodeDTO.java b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dto/DeptMaCodeDTO.java new file mode 100644 index 0000000..34495aa --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/dto/DeptMaCodeDTO.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 DeptMaCodeDTO 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..7c2c759 --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/OptDeptMaCodeService.java @@ -0,0 +1,105 @@ +/** + * 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.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 DeptMaCodeDTO + * @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(); +} \ 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..713752b --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/java/com/elink/esua/epdc/optimize/modules/macode/service/impl/OptDeptMaCodeServiceImpl.java @@ -0,0 +1,154 @@ +/** + * 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 com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.elink.esua.epdc.commons.mybatis.service.impl.BaseServiceImpl; +import com.elink.esua.epdc.commons.tools.constant.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.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.optimize.modules.macode.dao.OptDeptMaCodeDao; +import com.elink.esua.epdc.optimize.modules.macode.entity.OptDeptMaCodeEntity; +import com.elink.esua.epdc.optimize.modules.macode.service.OptDeptMaCodeService; +import com.google.common.collect.Lists; +import org.apache.commons.lang3.StringUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +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 { + + @Override + public PageData page(Map params) { + + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, DeptMaCodeDTO.class); + } + + @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) { + insertList.add(packDeptBaseInfo(deptMaCodeEntity.getGrid(), deptMaCodeEntity.getParentDeptIds())); + } + insertBatch(insertList, NumConstant.FIFTY); + return new Result(); + } + + + private OptDeptMaCodeEntity packDeptBaseInfo(String deptId, String pids) { + // 查询机构及父级机构 + List deptList = baseDao.selectListDeptAndParents(deptId, pids.split(StrConstant.COMMA)); + if (CollUtil.isEmpty(deptList)) { + return null; + } + int size = deptList.size(); + + String[] allDeptIds = new String[size]; + String[] allDeptNames = new String[size]; + String[] parentDeptIds = new String[size - NumConstant.ONE]; + String[] parentDeptNames = new String[size - NumConstant.ONE]; + for (int i = 0; i < size; i++) { + allDeptIds[i] = String.valueOf(deptList.get(i).getGridId()); + allDeptNames[i] = deptList.get(i).getGrid(); + if (i < size - NumConstant.ONE) { + parentDeptIds[i] = String.valueOf(deptList.get(i).getGridId()); + parentDeptNames[i] = deptList.get(i).getGrid(); + } + } + OptDeptMaCodeEntity deptMaCodeEntity = deptList.get(size - NumConstant.ONE); + 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/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/mapper/macode/OptDeptMaCodeDao.xml b/epdc-cloud-optimize-department/src/main/resources/mapper/macode/OptDeptMaCodeDao.xml new file mode 100644 index 0000000..852b06d --- /dev/null +++ b/epdc-cloud-optimize-department/src/main/resources/mapper/macode/OptDeptMaCodeDao.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + \ 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