From b6f52505550cdfc03f81ab5efde294840b45e35a Mon Sep 17 00:00:00 2001 From: songyunpeng Date: Tue, 3 Mar 2020 09:35:31 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BD=91=E6=A0=BC=E5=91=98=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=A1=A8=E8=A1=A8=E5=90=8E=E5=8F=B0=E4=BB=A3=E7=A0=81=E6=8F=90?= =?UTF-8?q?=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../epdc/dto/consult/GridOperatorInfoDTO.java | 146 +++++++++++++++++ .../GridOperatorDutyCategoryController.java | 7 +- .../GridOperatorInfoController.java | 101 ++++++++++++ .../consult/dao/GridOperatorInfoDao.java | 33 ++++ .../entity/GridOperatorInfoEntity.java | 116 +++++++++++++ .../consult/excel/GridOperatorInfoExcel.java | 101 ++++++++++++ .../consult/redis/GridOperatorInfoRedis.java | 47 ++++++ .../service/GridOperatorInfoService.java | 103 ++++++++++++ .../impl/GridOperatorInfoServiceImpl.java | 152 ++++++++++++++++++ .../mapper/consult/GridOperatorInfoDao.xml | 32 ++++ 10 files changed, 837 insertions(+), 1 deletion(-) create mode 100755 esua-epdc/epdc-module/epdc-custom/epdc-custom-client/src/main/java/com/elink/esua/epdc/dto/consult/GridOperatorInfoDTO.java create mode 100755 esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/controller/GridOperatorInfoController.java create mode 100755 esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/dao/GridOperatorInfoDao.java create mode 100755 esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/entity/GridOperatorInfoEntity.java create mode 100755 esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/excel/GridOperatorInfoExcel.java create mode 100755 esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/redis/GridOperatorInfoRedis.java create mode 100755 esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/service/GridOperatorInfoService.java create mode 100755 esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/service/impl/GridOperatorInfoServiceImpl.java create mode 100755 esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/resources/mapper/consult/GridOperatorInfoDao.xml diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-client/src/main/java/com/elink/esua/epdc/dto/consult/GridOperatorInfoDTO.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-client/src/main/java/com/elink/esua/epdc/dto/consult/GridOperatorInfoDTO.java new file mode 100755 index 000000000..ed063ccbd --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-client/src/main/java/com/elink/esua/epdc/dto/consult/GridOperatorInfoDTO.java @@ -0,0 +1,146 @@ +/** + * 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.dto.consult; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 网格员信息 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-02 + */ +@Data +public class GridOperatorInfoDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 用户姓名 + */ + private String realName; + + /** + * 性别 0女 1男 + */ + private String sex; + + /** + * 排序 + */ + private Integer sort; + + /** + * 联系电话 + */ + private String mobile; + + /** + * 身份证号 + */ + private String identityNo; + + /** + * 头像访问地址 + */ + private String faceImg; + + /** + * 工作单位 + */ + private String workUnit; + + /** + * 职责类别id + */ + private String dutyCategoryId; + + /** + * 前端收费展示 0否 1是 + */ + private String showFlag; + + /** + * 备注 + */ + private String remark; + + /** + * 居住网格id + */ + private Long deptId; + + /** + * 父所有部门 + */ + private String parentDeptIds; + + /** + * 父所有部门 + */ + private String parentDeptNames; + + /** + * 所有部门ID + */ + private String[] allDeptIds; + + /** + * 所有部门名称 + */ + private String allDeptNames; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 删除标识 0:否,1:是 + */ + private String delFlag; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/controller/GridOperatorDutyCategoryController.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/controller/GridOperatorDutyCategoryController.java index f6188c406..1072ca8ae 100644 --- a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/controller/GridOperatorDutyCategoryController.java +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/controller/GridOperatorDutyCategoryController.java @@ -32,6 +32,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletResponse; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -90,5 +91,9 @@ public class GridOperatorDutyCategoryController { List list = gridOperatorDutyCategoryService.list(params); ExcelUtils.exportExcelToTarget(response, null, list, GridOperatorDutyCategoryExcel.class); } - + @GetMapping("getAllDutyCat") + public Result> getAllDutyCat(){ + List list = gridOperatorDutyCategoryService.list(new HashMap<>()); + return new Result>().ok(list); + } } \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/controller/GridOperatorInfoController.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/controller/GridOperatorInfoController.java new file mode 100755 index 000000000..70d628d47 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/controller/GridOperatorInfoController.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.modules.consult.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.consult.GridOperatorInfoDTO; +import com.elink.esua.epdc.modules.consult.excel.GridOperatorInfoExcel; +import com.elink.esua.epdc.modules.consult.service.GridOperatorInfoService; +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-03-02 + */ +@RestController +@RequestMapping("gridoperatorinfo") +public class GridOperatorInfoController { + + @Autowired + private GridOperatorInfoService gridOperatorInfoService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = gridOperatorInfoService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + GridOperatorInfoDTO data = gridOperatorInfoService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody GridOperatorInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + dto.setShowFlag("0"); + gridOperatorInfoService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody GridOperatorInfoDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + gridOperatorInfoService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + gridOperatorInfoService.delete(ids); + return new Result(); + } + @PostMapping("changeShowFlag") + public Result changeShowFlag(@RequestBody GridOperatorInfoDTO dto){ + gridOperatorInfoService.changeShowFlag(dto); + return new Result(); + } + + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = gridOperatorInfoService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, GridOperatorInfoExcel.class); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/dao/GridOperatorInfoDao.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/dao/GridOperatorInfoDao.java new file mode 100755 index 000000000..785b07ce6 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/dao/GridOperatorInfoDao.java @@ -0,0 +1,33 @@ +/** + * 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.modules.consult.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.modules.consult.entity.GridOperatorInfoEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 网格员信息 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-02 + */ +@Mapper +public interface GridOperatorInfoDao extends BaseDao { + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/entity/GridOperatorInfoEntity.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/entity/GridOperatorInfoEntity.java new file mode 100755 index 000000000..9229c4c8a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/entity/GridOperatorInfoEntity.java @@ -0,0 +1,116 @@ +/** + * 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.modules.consult.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.Date; + +/** + * 网格员信息 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-02 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_grid_operator_info") +public class GridOperatorInfoEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 用户姓名 + */ + private String realName; + + /** + * 性别 0女 1男 + */ + private String sex; + + /** + * 排序 + */ + private Integer sort; + + /** + * 联系电话 + */ + private String mobile; + + /** + * 身份证号 + */ + private String identityNo; + + /** + * 头像访问地址 + */ + private String faceImg; + + /** + * 工作单位 + */ + private String workUnit; + + /** + * 职责类别id + */ + private String dutyCategoryId; + + /** + * 前端是否展示 0否 1是 + */ + private String showFlag; + + /** + * 备注 + */ + private String remark; + + /** + * 居住网格id + */ + private Long deptId; + + /** + * 父所有部门 + */ + private String parentDeptIds; + + /** + * 父所有部门 + */ + private String parentDeptNames; + + /** + * 所有部门ID + */ + private String allDeptIds; + + /** + * 所有部门名称 + */ + private String allDeptNames; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/excel/GridOperatorInfoExcel.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/excel/GridOperatorInfoExcel.java new file mode 100755 index 000000000..7758ef19f --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/excel/GridOperatorInfoExcel.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.modules.consult.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-03-02 + */ +@Data +public class GridOperatorInfoExcel { + + @Excel(name = "主键") + private String id; + + @Excel(name = "用户姓名") + private String realName; + + @Excel(name = "性别 0女 1男") + private String sex; + + @Excel(name = "排序") + private Integer sort; + + @Excel(name = "联系电话") + private String mobile; + + @Excel(name = "身份证号") + private String identityNo; + + @Excel(name = "头像访问地址") + private String faceImg; + + @Excel(name = "工作单位") + private String workUnit; + + @Excel(name = "职责类别id") + private String dutyCategoryId; + + @Excel(name = "前端收费展示 0否 1是") + private String showFlag; + + @Excel(name = "备注") + private String remark; + + @Excel(name = "居住网格id") + private Long deptId; + + @Excel(name = "父所有部门") + private String parentDeptIds; + + @Excel(name = "父所有部门") + private String parentDeptNames; + + @Excel(name = "所有部门ID") + private String allDeptIds; + + @Excel(name = "所有部门名称") + private String allDeptNames; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "删除标识 0:否,1:是") + private String delFlag; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/redis/GridOperatorInfoRedis.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/redis/GridOperatorInfoRedis.java new file mode 100755 index 000000000..4acf8d2cb --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/redis/GridOperatorInfoRedis.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.modules.consult.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-03-02 + */ +@Component +public class GridOperatorInfoRedis { + @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/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/service/GridOperatorInfoService.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/service/GridOperatorInfoService.java new file mode 100755 index 000000000..a443b769d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/service/GridOperatorInfoService.java @@ -0,0 +1,103 @@ +/** + * 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.modules.consult.service; + +import com.elink.esua.epdc.commons.mybatis.service.BaseService; +import com.elink.esua.epdc.commons.tools.page.PageData; +import com.elink.esua.epdc.dto.consult.GridOperatorInfoDTO; +import com.elink.esua.epdc.modules.consult.entity.GridOperatorInfoEntity; + +import java.util.List; +import java.util.Map; + +/** + * 网格员信息 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-02 + */ +public interface GridOperatorInfoService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-03-02 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-03-02 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return GridOperatorInfoDTO + * @author generator + * @date 2020-03-02 + */ + GridOperatorInfoDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-02 + */ + void save(GridOperatorInfoDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-03-02 + */ + void update(GridOperatorInfoDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-03-02 + */ + void delete(String[] ids); + /** + * @Description 是否展示 + * @Author songyunpeng + * @Date 2020/3/2 + * @Param [dto] + * @return void + **/ + void changeShowFlag(GridOperatorInfoDTO dto); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/service/impl/GridOperatorInfoServiceImpl.java b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/service/impl/GridOperatorInfoServiceImpl.java new file mode 100755 index 000000000..a5a4e5a05 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/java/com/elink/esua/epdc/modules/consult/service/impl/GridOperatorInfoServiceImpl.java @@ -0,0 +1,152 @@ +/** + * 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.modules.consult.service.impl; + +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.exception.RenException; +import com.elink.esua.epdc.commons.tools.page.PageData; +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.ParentAndAllDeptDTO; +import com.elink.esua.epdc.dto.consult.GridOperatorInfoDTO; +import com.elink.esua.epdc.modules.consult.dao.GridOperatorInfoDao; +import com.elink.esua.epdc.modules.consult.entity.GridOperatorInfoEntity; +import com.elink.esua.epdc.modules.consult.redis.GridOperatorInfoRedis; +import com.elink.esua.epdc.modules.consult.service.GridOperatorInfoService; +import com.elink.esua.epdc.modules.feign.AdminFeignClient; +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.util.Arrays; +import java.util.List; +import java.util.Map; + +/** + * 网格员信息 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-03-02 + */ +@Service +public class GridOperatorInfoServiceImpl extends BaseServiceImpl implements GridOperatorInfoService { + + @Autowired + private GridOperatorInfoRedis gridOperatorInfoRedis; + + @Autowired + private AdminFeignClient adminFeignClient; + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, GridOperatorInfoDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, GridOperatorInfoDTO.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 GridOperatorInfoDTO get(String id) { + GridOperatorInfoEntity entity = baseDao.selectById(id); + GridOperatorInfoDTO gridOperatorInfoDTO = ConvertUtils.sourceToTarget(entity, GridOperatorInfoDTO.class); + if(StringUtils.isNotBlank(entity.getAllDeptIds())){ + String depts[] = entity.getAllDeptIds().split(","); + gridOperatorInfoDTO.setAllDeptIds(depts); + } + return gridOperatorInfoDTO; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(GridOperatorInfoDTO dto) { + GridOperatorInfoEntity entity = ConvertUtils.sourceToTarget(dto, GridOperatorInfoEntity.class); + Result parentResult = null; + if (dto.getAllDeptIds() != null && dto.getAllDeptIds().length > 1) { + parentResult = adminFeignClient.getParentAndAllDept(dto.getAllDeptIds()[dto.getAllDeptIds().length - 1]); + } + if (parentResult != null) { + if (!parentResult.success() || parentResult.getData() == null) { + throw new RenException("获取部门信息失败"); + } else { + ParentAndAllDeptDTO deptDTO = parentResult.getData(); + entity.setAllDeptIds(deptDTO.getAllDeptIds()); + entity.setAllDeptNames(deptDTO.getAllDeptNames()); + entity.setParentDeptIds(deptDTO.getParentDeptIds()); + entity.setParentDeptNames(deptDTO.getParentDeptNames()); + entity.setDeptId(Long.valueOf(dto.getAllDeptIds()[dto.getAllDeptIds().length - 1])); + } + } + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(GridOperatorInfoDTO dto) { + GridOperatorInfoEntity entity = ConvertUtils.sourceToTarget(dto, GridOperatorInfoEntity.class); + String[] allDeptIds = dto.getAllDeptIds(); + Result parentResult = adminFeignClient.getParentAndAllDept(String.valueOf(allDeptIds[allDeptIds.length - 1])); + if (!parentResult.success() || parentResult.getData() == null) { + throw new RenException("获取部门信息失败"); + } else { + ParentAndAllDeptDTO deptDTO = parentResult.getData(); + entity.setAllDeptIds(deptDTO.getAllDeptIds()); + entity.setAllDeptNames(deptDTO.getAllDeptNames()); + entity.setParentDeptIds(deptDTO.getParentDeptIds()); + entity.setParentDeptNames(deptDTO.getParentDeptNames()); + } + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void changeShowFlag(GridOperatorInfoDTO dto) { + GridOperatorInfoEntity gridOperatorInfoEntity = new GridOperatorInfoEntity(); + gridOperatorInfoEntity.setId(dto.getId()); + gridOperatorInfoEntity.setShowFlag(dto.getShowFlag()); + updateById(gridOperatorInfoEntity); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/resources/mapper/consult/GridOperatorInfoDao.xml b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/resources/mapper/consult/GridOperatorInfoDao.xml new file mode 100755 index 000000000..fd9d9f6cd --- /dev/null +++ b/esua-epdc/epdc-module/epdc-custom/epdc-custom-server/src/main/resources/mapper/consult/GridOperatorInfoDao.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file