From f4953c8e90132e2366c16b9b66d1272b4bba0fa0 Mon Sep 17 00:00:00 2001 From: qushutong <1976590620@qq.com> Date: Mon, 30 Oct 2023 15:52:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BE=AE=E7=BD=91=E6=A0=BC=E5=88=9D=E5=A7=8B?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/dto/MicroGridDTO.java | 141 ++++++++++++++++++ .../epmet/controller/MicroGridController.java | 93 ++++++++++++ .../main/java/com/epmet/dao/MicroGridDao.java | 33 ++++ .../com/epmet/entity/MicroGridEntity.java | 110 ++++++++++++++ .../java/com/epmet/excel/MicroGridExcel.java | 98 ++++++++++++ .../com/epmet/service/MicroGridService.java | 96 ++++++++++++ .../service/impl/MicroGridServiceImpl.java | 102 +++++++++++++ .../main/resources/mapper/MicroGridDao.xml | 31 ++++ 8 files changed, 704 insertions(+) create mode 100644 epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/MicroGridDTO.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/MicroGridController.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/MicroGridDao.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/MicroGridEntity.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/MicroGridExcel.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/MicroGridService.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/MicroGridServiceImpl.java create mode 100644 epmet-module/gov-org/gov-org-server/src/main/resources/mapper/MicroGridDao.xml diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/MicroGridDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/MicroGridDTO.java new file mode 100644 index 0000000000..5e86a15311 --- /dev/null +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/MicroGridDTO.java @@ -0,0 +1,141 @@ +/** + * 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.epmet.dto; + +import java.io.Serializable; +import java.util.Date; +import lombok.Data; + + +/** + * 微网格表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2023-10-27 + */ +@Data +public class MicroGridDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * ID 唯一标识 + */ + private String id; + + /** + * 客户ID + */ + private String customerId; + + /** + * 微网格名称 + */ + private String microgridName; + + /** + * 微网格长 + */ + private String contacts; + + /** + * 性别(女性-0,男性-1) + */ + private String sex; + + /** + * 联系电话 + */ + private String mobile; + + /** + * 地址 + */ + private String address; + + /** + * 所属组织机构ID + */ + private String pid; + + /** + * 所有上级组织ID + */ + private String pids; + + /** + * 当前网格总人数 + */ + private Integer totalUser; + + /** + * 网格排序 + */ + private Integer sort; + + /** + * 中心位置纬度 + */ + private String latitude; + + /** + * 中心点位地址 + */ + private String centerAddress; + + /** + * 坐标区域 + */ + private String coordinates; + + /** + * 编码 + */ + private String code; + + /** + * 删除标识:0.未删除 1.已删除 + */ + private Integer delFlag; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新时间 + */ + private Date updatedTime; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/MicroGridController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/MicroGridController.java new file mode 100644 index 0000000000..be2ff297f8 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/MicroGridController.java @@ -0,0 +1,93 @@ +/** + * 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.epmet.controller; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ExcelUtils; +import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.validator.AssertUtils; +import com.epmet.commons.tools.validator.ValidatorUtils; +import com.epmet.commons.tools.validator.group.AddGroup; +import com.epmet.commons.tools.validator.group.DefaultGroup; +import com.epmet.commons.tools.validator.group.UpdateGroup; +import com.epmet.dto.MicroGridDTO; +import com.epmet.excel.MicroGridExcel; +import com.epmet.service.MicroGridService; +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 2023-10-27 + */ +@RestController +@RequestMapping("microgrid") +public class MicroGridController { + + @Autowired + private MicroGridService microGridService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + PageData page = microGridService.page(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + MicroGridDTO data = microGridService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody MicroGridDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + microGridService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody MicroGridDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + microGridService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + microGridService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = microGridService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, MicroGridExcel.class); + } + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/MicroGridDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/MicroGridDao.java new file mode 100644 index 0000000000..f34a0f37a5 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/MicroGridDao.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.epmet.dao; + +import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.entity.MicroGridEntity; +import org.apache.ibatis.annotations.Mapper; + +/** + * 微网格表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2023-10-27 + */ +@Mapper +public interface MicroGridDao extends BaseDao { + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/MicroGridEntity.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/MicroGridEntity.java new file mode 100644 index 0000000000..6b0089e7df --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/entity/MicroGridEntity.java @@ -0,0 +1,110 @@ +/** + * 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.epmet.entity; + +import com.baomidou.mybatisplus.annotation.TableName; + +import com.epmet.commons.mybatis.entity.BaseEpmetEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + + +/** + * 微网格表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2023-10-27 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("micro_grid") +public class MicroGridEntity extends BaseEpmetEntity { + + private static final long serialVersionUID = 1L; + + /** + * 客户ID + */ + private String customerId; + + /** + * 微网格名称 + */ + private String microgridName; + + /** + * 微网格长 + */ + private String contacts; + + /** + * 性别(女性-0,男性-1) + */ + private String sex; + + /** + * 联系电话 + */ + private String mobile; + + /** + * 地址 + */ + private String address; + + /** + * 所属组织机构ID + */ + private String pid; + + /** + * 所有上级组织ID + */ + private String pids; + + /** + * 当前网格总人数 + */ + private Integer totalUser; + + /** + * 网格排序 + */ + private Integer sort; + + /** + * 中心位置纬度 + */ + private String latitude; + + /** + * 中心点位地址 + */ + private String centerAddress; + + /** + * 坐标区域 + */ + private String coordinates; + + /** + * 编码 + */ + private String code; + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/MicroGridExcel.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/MicroGridExcel.java new file mode 100644 index 0000000000..a939210496 --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/excel/MicroGridExcel.java @@ -0,0 +1,98 @@ +/** + * 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.epmet.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 2023-10-27 + */ +@Data +public class MicroGridExcel { + + @Excel(name = "ID 唯一标识") + private String id; + + @Excel(name = "客户ID") + private String customerId; + + @Excel(name = "微网格名称") + private String microgridName; + + @Excel(name = "微网格长") + private String contacts; + + @Excel(name = "性别(女性-0,男性-1)") + private String sex; + + @Excel(name = "联系电话") + private String mobile; + + @Excel(name = "地址") + private String address; + + @Excel(name = "所属组织机构ID") + private String pid; + + @Excel(name = "所有上级组织ID") + private String pids; + + @Excel(name = "当前网格总人数") + private Integer totalUser; + + @Excel(name = "网格排序") + private Integer sort; + + @Excel(name = "中心位置纬度") + private String latitude; + + @Excel(name = "中心点位地址") + private String centerAddress; + + @Excel(name = "坐标区域") + private String coordinates; + + @Excel(name = "编码") + private String code; + + @Excel(name = "删除标识:0.未删除 1.已删除") + private Integer delFlag; + + @Excel(name = "乐观锁") + private Integer revision; + + @Excel(name = "创建人") + private String createdBy; + + @Excel(name = "更新人") + private String updatedBy; + + @Excel(name = "创建时间") + private Date createdTime; + + @Excel(name = "更新时间") + private Date updatedTime; + + +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/MicroGridService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/MicroGridService.java new file mode 100644 index 0000000000..64bad2f2de --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/MicroGridService.java @@ -0,0 +1,96 @@ +/** + * 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.epmet.service; + + +import com.epmet.commons.mybatis.service.BaseService; +import com.epmet.commons.tools.page.PageData; +import com.epmet.dto.MicroGridDTO; +import com.epmet.entity.MicroGridEntity; + +import java.util.List; +import java.util.Map; + +/** + * 微网格表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2023-10-27 + */ +public interface MicroGridService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2023-10-27 + */ + PageData page(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2023-10-27 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return MicroGridDTO + * @author generator + * @date 2023-10-27 + */ + MicroGridDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2023-10-27 + */ + void save(MicroGridDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2023-10-27 + */ + void update(MicroGridDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2023-10-27 + */ + void delete(String[] ids); +} \ No newline at end of file diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/MicroGridServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/MicroGridServiceImpl.java new file mode 100644 index 0000000000..10b2241fac --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/MicroGridServiceImpl.java @@ -0,0 +1,102 @@ +/** + * 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.epmet.service.impl; + +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; + +import com.baomidou.mybatisplus.core.metadata.IPage; +import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; +import com.epmet.commons.tools.constant.FieldConstant; +import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.dao.MicroGridDao; +import com.epmet.dto.MicroGridDTO; +import com.epmet.entity.MicroGridEntity; +import com.epmet.service.MicroGridService; +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 2023-10-27 + */ +@Service +public class MicroGridServiceImpl extends BaseServiceImpl implements MicroGridService { + + + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, MicroGridDTO.class); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, MicroGridDTO.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 MicroGridDTO get(String id) { + MicroGridEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, MicroGridDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(MicroGridDTO dto) { + MicroGridEntity entity = ConvertUtils.sourceToTarget(dto, MicroGridEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(MicroGridDTO dto) { + MicroGridEntity entity = ConvertUtils.sourceToTarget(dto, MicroGridEntity.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/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/MicroGridDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/MicroGridDao.xml new file mode 100644 index 0000000000..d8d4775aad --- /dev/null +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/MicroGridDao.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file