diff --git a/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/ExportTemplateInfoFormDTO.java b/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/ExportTemplateInfoFormDTO.java new file mode 100644 index 000000000..d8b2be885 --- /dev/null +++ b/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/epdc/form/ExportTemplateInfoFormDTO.java @@ -0,0 +1,35 @@ +package com.elink.esua.epdc.dto.epdc.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description + * @Author wanggongfeng + * @Date 2020/06/15 16:30 + */ +@Data +public class ExportTemplateInfoFormDTO implements Serializable { + + /** + * 权限 + */ + private List deptIdList; + + /** + * 年月 + */ + private String monthYear; + + /** + * 部门ID + */ + private String deptId; + + /** + * 部门类型 + */ + private String deptTypeKey; +} diff --git a/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/ExportTemplateInfoResultDTO.java b/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/ExportTemplateInfoResultDTO.java new file mode 100644 index 000000000..87f1e533e --- /dev/null +++ b/esua-epdc/epdc-admin/epdc-admin-client/src/main/java/com/elink/esua/epdc/dto/epdc/result/ExportTemplateInfoResultDTO.java @@ -0,0 +1,127 @@ +/** + * 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.epdc.result; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 获取导出模板 + * + * @author wanggongfeng + * @since v1.0.0 2020-06-15 + */ +@Data +public class ExportTemplateInfoResultDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 部门id + */ + private String deptId; + + /** + * 部门名称 + */ + private String deptName; + + /** + * 部门类别 + */ + private String deptTypeKey; + + /** + * 年月 + */ + private String monthYear; + + /** + * 民主协商机制 + */ + private String democraticConsultationMechanism; + + /** + * 居民公约制度 + */ + private String residentConventionSystem; + + /** + * 网格协商案例 + */ + private String gridNegotiationCase; + + /** + * 上级部门id + */ + private String parentDeptIds; + + /** + * 上级部门名称 + */ + private String parentDeptNames; + + /** + * 所有部门id + */ + private String allDeptIds; + + /** + * 所有部门名称 + */ + private String allDeptNames; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 逻辑删除标识 + */ + private String delFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java index 36b2b0bff..f34c5a5b0 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/controller/SysDeptController.java @@ -17,7 +17,9 @@ import com.elink.esua.epdc.commons.tools.validator.group.AddGroup; import com.elink.esua.epdc.commons.tools.validator.group.DefaultGroup; import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; import com.elink.esua.epdc.dto.*; +import com.elink.esua.epdc.dto.epdc.form.ExportTemplateInfoFormDTO; import com.elink.esua.epdc.dto.epdc.form.UserSysDeptInfoFormDTO; +import com.elink.esua.epdc.dto.epdc.result.ExportTemplateInfoResultDTO; import com.elink.esua.epdc.dto.epdc.result.UserSysDeptInfoResultDTO; import com.elink.esua.epdc.service.SysDeptService; import io.swagger.annotations.Api; @@ -320,4 +322,17 @@ public class SysDeptController { List list = sysDeptService.queryUserSysDeptTypeKey(formDTO); return new Result>().ok(list); } + + /** + * @param formDTO + * @return ExportTemplateInfoResultDTO + * @Author wanggongfeng + * @Description 获取网格建设打分模板 + * @Date 2020-06-15 + **/ + @PostMapping("getExportTemplateInfo") + public Result> getExportTemplateInfo(@RequestBody ExportTemplateInfoFormDTO formDTO) { + List list = sysDeptService.getExportTemplateInfo(formDTO); + return new Result>().ok(list); + } } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java index 60ff3154c..a684df9d3 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/dao/SysDeptDao.java @@ -9,10 +9,11 @@ package com.elink.esua.epdc.dao; import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; -import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.*; import com.elink.esua.epdc.dto.epdc.GridForLeaderRegisterDTO; +import com.elink.esua.epdc.dto.epdc.form.ExportTemplateInfoFormDTO; import com.elink.esua.epdc.dto.epdc.form.UserSysDeptInfoFormDTO; +import com.elink.esua.epdc.dto.epdc.result.ExportTemplateInfoResultDTO; import com.elink.esua.epdc.dto.epdc.result.UserSysDeptInfoResultDTO; import com.elink.esua.epdc.entity.SysDeptEntity; import org.apache.ibatis.annotations.Mapper; @@ -210,4 +211,13 @@ public interface SysDeptDao extends BaseDao { * @Date 2020-05-06 **/ List selectListUserSysDeptTypeKey(UserSysDeptInfoFormDTO formDTO); + + /** + * @param formDTO + * @return ExportTemplateInfoResultDTO + * @Author wanggongfeng + * @Description 获取网格建设打分模板 + * @Date 2020-06-15 + **/ + List getExportTemplateInfo(ExportTemplateInfoFormDTO formDTO); } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java index d387832ee..44e842de7 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/SysDeptService.java @@ -13,7 +13,9 @@ import com.elink.esua.epdc.commons.tools.page.PageData; import com.elink.esua.epdc.commons.tools.utils.Result; import com.elink.esua.epdc.dto.*; import com.elink.esua.epdc.dto.epdc.GridForLeaderRegisterDTO; +import com.elink.esua.epdc.dto.epdc.form.ExportTemplateInfoFormDTO; import com.elink.esua.epdc.dto.epdc.form.UserSysDeptInfoFormDTO; +import com.elink.esua.epdc.dto.epdc.result.ExportTemplateInfoResultDTO; import com.elink.esua.epdc.dto.epdc.result.UserSysDeptInfoResultDTO; import com.elink.esua.epdc.entity.SysDeptEntity; @@ -289,4 +291,13 @@ public interface SysDeptService extends BaseService { * @Date 2020-05-06 **/ List queryUserSysDeptTypeKey(UserSysDeptInfoFormDTO formDTO); + + /** + * @param formDTO + * @return ExportTemplateInfoResultDTO + * @Author wanggongfeng + * @Description 获取网格建设打分模板 + * @Date 2020-06-15 + **/ + List getExportTemplateInfo(ExportTemplateInfoFormDTO formDTO); } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java index 2604b8dcf..d0614871f 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/java/com/elink/esua/epdc/service/impl/SysDeptServiceImpl.java @@ -32,7 +32,9 @@ import com.elink.esua.epdc.constant.RoleTypeKeyConstant; import com.elink.esua.epdc.dao.SysDeptDao; import com.elink.esua.epdc.dto.*; import com.elink.esua.epdc.dto.epdc.GridForLeaderRegisterDTO; +import com.elink.esua.epdc.dto.epdc.form.ExportTemplateInfoFormDTO; import com.elink.esua.epdc.dto.epdc.form.UserSysDeptInfoFormDTO; +import com.elink.esua.epdc.dto.epdc.result.ExportTemplateInfoResultDTO; import com.elink.esua.epdc.dto.epdc.result.UserSysDeptInfoResultDTO; import com.elink.esua.epdc.entity.SysDeptEntity; import com.elink.esua.epdc.feign.GroupFeignClient; @@ -1093,4 +1095,9 @@ public class SysDeptServiceImpl extends BaseServiceImpl getExportTemplateInfo(ExportTemplateInfoFormDTO formDTO) { + return baseDao.getExportTemplateInfo(formDTO); + } } diff --git a/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml b/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml index f76eab54a..eddb6c85c 100644 --- a/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml +++ b/esua-epdc/epdc-admin/epdc-admin-server/src/main/resources/mapper/SysDeptDao.xml @@ -366,4 +366,35 @@ + + diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/KpiCommunityBuildingDTO.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/KpiCommunityBuildingDTO.java new file mode 100644 index 000000000..c83a42e8a --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/KpiCommunityBuildingDTO.java @@ -0,0 +1,127 @@ +/** + * 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; + +import lombok.Data; + +import java.io.Serializable; +import java.util.Date; + + +/** + * 网格建设打分表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-06-15 + */ +@Data +public class KpiCommunityBuildingDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 主键 + */ + private String id; + + /** + * 部门id + */ + private String deptId; + + /** + * 部门名称 + */ + private String deptName; + + /** + * 部门类别 + */ + private String deptTypeKey; + + /** + * 年月 + */ + private String monthYear; + + /** + * 民主协商机制 + */ + private String democraticConsultationMechanism; + + /** + * 居民公约制度 + */ + private String residentConventionSystem; + + /** + * 网格协商案例 + */ + private String gridNegotiationCase; + + /** + * 上级部门id + */ + private String parentDeptIds; + + /** + * 上级部门名称 + */ + private String parentDeptNames; + + /** + * 所有部门id + */ + private String allDeptIds; + + /** + * 所有部门名称 + */ + private String allDeptNames; + + /** + * 乐观锁 + */ + private Integer revision; + + /** + * 创建人 + */ + private String createdBy; + + /** + * 创建时间 + */ + private Date createdTime; + + /** + * 更新人 + */ + private String updatedBy; + + /** + * 更新时间 + */ + private Date updatedTime; + + /** + * 逻辑删除标识 + */ + private String delFlag; + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/form/CheckIsScoredFormDTO.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/form/CheckIsScoredFormDTO.java new file mode 100644 index 000000000..f9e160573 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-client/src/main/java/com/elink/esua/epdc/dto/form/CheckIsScoredFormDTO.java @@ -0,0 +1,26 @@ +package com.elink.esua.epdc.dto.form; + +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +/** + * @Description 查询某月份某部门是否已打分 + * @Author wanggongfeng + * @Date 2020/06/16 9:29 + */ +@Data +public class CheckIsScoredFormDTO implements Serializable { + private static final long serialVersionUID = -8214790072156444793L; + + /** + * 主键集合 + */ + private List checkList; + + /** + * 年月 + */ + private String monthYear; +} diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/controller/KpiCommunityBuildingController.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/controller/KpiCommunityBuildingController.java new file mode 100644 index 000000000..e9dd6c02d --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/controller/KpiCommunityBuildingController.java @@ -0,0 +1,118 @@ +/** + * 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.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.DefaultGroup; +import com.elink.esua.epdc.commons.tools.validator.group.UpdateGroup; +import com.elink.esua.epdc.dto.KpiCommunityBuildingDTO; +import com.elink.esua.epdc.excel.KpiCommunityBuildingExcel; +import com.elink.esua.epdc.service.KpiCommunityBuildingService; +import com.elink.esua.epdc.service.ManualScoreService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; +import java.util.Map; + + +/** + * 网格建设打分表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-06-15 + */ +@RestController +@RequestMapping("kpicommunitybuilding") +public class KpiCommunityBuildingController { + + @Autowired + private KpiCommunityBuildingService kpiCommunityBuildingService; + + @Autowired + private ManualScoreService manualScoreService; + + @GetMapping("page") + public Result> page(@RequestParam Map params){ + //PageData page = kpiCommunityBuildingService.page(params); + PageData page = kpiCommunityBuildingService.getInfoPage(params); + return new Result>().ok(page); + } + + @GetMapping("{id}") + public Result get(@PathVariable("id") String id){ + KpiCommunityBuildingDTO data = kpiCommunityBuildingService.get(id); + return new Result().ok(data); + } + + @PostMapping + public Result save(@RequestBody KpiCommunityBuildingDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class); + kpiCommunityBuildingService.save(dto); + return new Result(); + } + + @PutMapping + public Result update(@RequestBody KpiCommunityBuildingDTO dto){ + //效验数据 + ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class); + kpiCommunityBuildingService.update(dto); + return new Result(); + } + + @DeleteMapping + public Result delete(@RequestBody String[] ids){ + //效验数据 + AssertUtils.isArrayEmpty(ids, "id"); + kpiCommunityBuildingService.delete(ids); + return new Result(); + } + + @GetMapping("export") + public void export(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = kpiCommunityBuildingService.list(params); + ExcelUtils.exportExcelToTarget(response, null, list, KpiCommunityBuildingExcel.class); + } + + @GetMapping("exportTemplate") + public void exportTemplate(@RequestParam Map params, HttpServletResponse response) throws Exception { + List list = kpiCommunityBuildingService.exportTemplate(params); + ExcelUtils.exportExcelToTarget(response, null, list, KpiCommunityBuildingExcel.class); + } + + /** + * @Description: 导入治理排行管理-手动打分记录 + * @Param: [file] + * @return: Result + * @Author: wanggongfeng + * @Date: 2020-06-15 + */ + @PostMapping("importManualScoreExcel") + public Result importManualScoreExcel(@RequestParam("file") MultipartFile file) { + return kpiCommunityBuildingService.importManualScoreExcel(file); + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/dao/KpiCommunityBuildingDao.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/dao/KpiCommunityBuildingDao.java new file mode 100644 index 000000000..157f6de16 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/dao/KpiCommunityBuildingDao.java @@ -0,0 +1,58 @@ +/** + * 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.dao; + +import com.elink.esua.epdc.commons.mybatis.dao.BaseDao; +import com.elink.esua.epdc.dto.KpiCommunityBuildingDTO; +import com.elink.esua.epdc.dto.form.CheckIsScoredFormDTO; +import com.elink.esua.epdc.entity.KpiCommunityBuildingEntity; +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-06-15 + */ +@Mapper +public interface KpiCommunityBuildingDao extends BaseDao { + + /** + * 条件查询 + * @param params + * @return + */ + List getInfoPage(Map params); + + /** + * 条件查询 + * @param checkIsScoredFormDTO + * @return + */ + List getDuplicateData(CheckIsScoredFormDTO checkIsScoredFormDTO); + + /** + * 批量插入导入数据 + * @param kpiCommunityBuildingEntities + */ + void insertEntityList(@Param("kpiCommunityBuildingEntities")KpiCommunityBuildingEntity[] kpiCommunityBuildingEntities); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/entity/KpiCommunityBuildingEntity.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/entity/KpiCommunityBuildingEntity.java new file mode 100644 index 000000000..1986cfae9 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/entity/KpiCommunityBuildingEntity.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.elink.esua.epdc.entity; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.elink.esua.epdc.commons.mybatis.entity.BaseEpdcEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * 网格建设打分表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-06-15 + */ +@Data +@EqualsAndHashCode(callSuper=false) +@TableName("epdc_kpi_community_building") +public class KpiCommunityBuildingEntity extends BaseEpdcEntity { + + private static final long serialVersionUID = 1L; + + /** + * 部门id + */ + private String deptId; + + /** + * 部门名称 + */ + private String deptName; + + /** + * 部门类别 + */ + private String deptTypeKey; + + /** + * 年月 + */ + private String monthYear; + + /** + * 民主协商机制 + */ + private String democraticConsultationMechanism; + + /** + * 居民公约制度 + */ + private String residentConventionSystem; + + /** + * 网格协商案例 + */ + private String gridNegotiationCase; + + /** + * 上级部门id + */ + 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-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/excel/KpiCommunityBuildingExcel.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/excel/KpiCommunityBuildingExcel.java new file mode 100644 index 000000000..0d747c85f --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/excel/KpiCommunityBuildingExcel.java @@ -0,0 +1,87 @@ +/** + * 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.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +/** + * 网格建设打分表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-06-15 + */ +@Data +public class KpiCommunityBuildingExcel { + +// @Excel(name = "主键") +// private String id; + + @Excel(name = "部门id") + private String deptId; + + @Excel(name = "部门名称") + private String deptName; + + @Excel(name = "部门类别") + private String deptTypeKey; + + @Excel(name = "年月") + private String monthYear; + + @Excel(name = "民主协商机制得分") + private String democraticConsultationMechanism; + + @Excel(name = "居民公约制度得分") + private String residentConventionSystem; + + @Excel(name = "网格协商案例得分") + private String gridNegotiationCase; + +// @Excel(name = "上级部门id") +// 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 = "创建人") +// private String createdBy; +// +// @Excel(name = "创建时间") +// private Date createdTime; +// +// @Excel(name = "更新人") +// private String updatedBy; +// +// @Excel(name = "更新时间") +// private Date updatedTime; +// +// @Excel(name = "逻辑删除标识") +// private String delFlag; + + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java index 874e10a94..1b065d072 100644 --- a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/AdminFeignClient.java @@ -3,7 +3,10 @@ package com.elink.esua.epdc.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.DeptLevelAndLeaderDTO; +import com.elink.esua.epdc.dto.SysDeptDTO; +import com.elink.esua.epdc.dto.epdc.form.ExportTemplateInfoFormDTO; import com.elink.esua.epdc.dto.epdc.form.UserSysDeptInfoFormDTO; +import com.elink.esua.epdc.dto.epdc.result.ExportTemplateInfoResultDTO; import com.elink.esua.epdc.dto.epdc.result.UserSysDeptInfoResultDTO; import com.elink.esua.epdc.feign.fallback.AdminFeignClientFallback; import org.springframework.cloud.openfeign.FeignClient; @@ -82,4 +85,24 @@ public interface AdminFeignClient { **/ @PostMapping(value = "sys/dept/queryUserSysDeptTypeKey", consumes = MediaType.APPLICATION_JSON_VALUE) Result> queryUserSysDeptTypeKey(UserSysDeptInfoFormDTO userSysDeptInfoFormDTO); + + /** + * @Description: 通过部门ID获取部门基本信息 + * @Param: deptId 部门ID + * @return: com.elink.esua.epdc.dto.SysDeptDTO + * @Author: wanggongfeng + * @Date: 2020-06-15 + */ + @GetMapping("/sys/dept/{deptId}") + Result get(@PathVariable("deptId") Long deptId); + + /** + * @Description: 获取导出模板 + * @Param: deptId 部门ID + * @return: com.elink.esua.epdc.dto.SysDeptDTO + * @Author: wanggongfeng + * @Date: 2020-06-15 + */ + @PostMapping("/sys/dept/getExportTemplateInfo") + Result> getExportTemplateInfo(ExportTemplateInfoFormDTO exportTemplateInfoFormDTO); } diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java index af0e7cbe1..44ab214e4 100644 --- a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/feign/fallback/AdminFeignClientFallback.java @@ -4,7 +4,10 @@ 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.DeptLevelAndLeaderDTO; +import com.elink.esua.epdc.dto.SysDeptDTO; +import com.elink.esua.epdc.dto.epdc.form.ExportTemplateInfoFormDTO; import com.elink.esua.epdc.dto.epdc.form.UserSysDeptInfoFormDTO; +import com.elink.esua.epdc.dto.epdc.result.ExportTemplateInfoResultDTO; import com.elink.esua.epdc.dto.epdc.result.UserSysDeptInfoResultDTO; import com.elink.esua.epdc.feign.AdminFeignClient; import org.springframework.stereotype.Component; @@ -50,4 +53,14 @@ public class AdminFeignClientFallback implements AdminFeignClient { return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "queryUserSysDeptTypeKey", userSysDeptInfoFormDTO); } + @Override + public Result get(Long deptId) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "get", deptId); + } + + @Override + public Result> getExportTemplateInfo(ExportTemplateInfoFormDTO exportTemplateInfoFormDTO) { + return ModuleUtils.feignConError(ServiceConstant.EPDC_ADMIN_SERVER, "getExportTemplateInfo", exportTemplateInfoFormDTO); + } + } diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/redis/KpiCommunityBuildingRedis.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/redis/KpiCommunityBuildingRedis.java new file mode 100644 index 000000000..b7d2b6fb1 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/redis/KpiCommunityBuildingRedis.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.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-06-15 + */ +@Component +public class KpiCommunityBuildingRedis { + @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-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/KpiCommunityBuildingService.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/KpiCommunityBuildingService.java new file mode 100644 index 000000000..2a14ae73e --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/KpiCommunityBuildingService.java @@ -0,0 +1,124 @@ +/** + * 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.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.KpiCommunityBuildingDTO; +import com.elink.esua.epdc.entity.KpiCommunityBuildingEntity; +import org.springframework.web.multipart.MultipartFile; + +import java.util.List; +import java.util.Map; + +/** + * 网格建设打分表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-06-15 + */ +public interface KpiCommunityBuildingService extends BaseService { + + /** + * 默认分页 + * + * @param params + * @return PageData + * @author generator + * @date 2020-06-15 + */ + PageData page(Map params); + + /** + * 分页条件查询 + * @param params + * @return + */ + PageData getInfoPage(Map params); + + /** + * 默认查询 + * + * @param params + * @return java.util.List + * @author generator + * @date 2020-06-15 + */ + List list(Map params); + + /** + * 单条查询 + * + * @param id + * @return KpiCommunityBuildingDTO + * @author generator + * @date 2020-06-15 + */ + KpiCommunityBuildingDTO get(String id); + + /** + * 默认保存 + * + * @param dto + * @return void + * @author generator + * @date 2020-06-15 + */ + void save(KpiCommunityBuildingDTO dto); + + /** + * 默认更新 + * + * @param dto + * @return void + * @author generator + * @date 2020-06-15 + */ + void update(KpiCommunityBuildingDTO dto); + + /** + * 批量删除 + * + * @param ids + * @return void + * @author generator + * @date 2020-06-15 + */ + void delete(String[] ids); + + /** + * 导出模板 + * + * @param params + * @return java.util.List + * @author wanggongfeng + * @date 2020-06-15 + */ + List exportTemplate(Map params); + + /** + * 网格建设打分导入 + * + * @param file + * @return Result + * @author wanggongfeng + * @date 2020-06-15 + */ + Result importManualScoreExcel(MultipartFile file); +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiCommunityBuildingServiceImpl.java b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiCommunityBuildingServiceImpl.java new file mode 100644 index 000000000..0d72ea1f8 --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/java/com/elink/esua/epdc/service/impl/KpiCommunityBuildingServiceImpl.java @@ -0,0 +1,481 @@ +/** + * 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.service.impl; + +import cn.afterturn.easypoi.excel.ExcelImportUtil; +import cn.afterturn.easypoi.excel.entity.ImportParams; +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.FieldConstant; +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.security.user.UserDetail; +import com.elink.esua.epdc.commons.tools.utils.ConvertUtils; +import com.elink.esua.epdc.commons.tools.utils.Result; +import com.elink.esua.epdc.dao.KpiCommunityBuildingDao; +import com.elink.esua.epdc.dto.DeptLevelAndLeaderDTO; +import com.elink.esua.epdc.dto.KpiCommunityBuildingDTO; +import com.elink.esua.epdc.dto.SysDeptDTO; +import com.elink.esua.epdc.dto.epdc.form.ExportTemplateInfoFormDTO; +import com.elink.esua.epdc.dto.epdc.result.ExportTemplateInfoResultDTO; +import com.elink.esua.epdc.dto.form.CheckIsScoredFormDTO; +import com.elink.esua.epdc.entity.KpiCommunityBuildingEntity; +import com.elink.esua.epdc.excel.KpiCommunityBuildingExcel; +import com.elink.esua.epdc.feign.AdminFeignClient; +import com.elink.esua.epdc.redis.KpiCommunityBuildingRedis; +import com.elink.esua.epdc.service.KpiCommunityBuildingService; +import com.elink.esua.epdc.utils.DeptUtils; +import com.elink.esua.epdc.utils.StreamUtils; +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 org.springframework.web.multipart.MultipartFile; + +import java.io.File; +import java.text.SimpleDateFormat; +import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * 网格建设打分表 + * + * @author elink elink@elink-cn.com + * @since v1.0.0 2020-06-15 + */ +@Service +public class KpiCommunityBuildingServiceImpl extends BaseServiceImpl implements KpiCommunityBuildingService { + + @Autowired + private KpiCommunityBuildingRedis kpiCommunityBuildingRedis; + + @Autowired + private AdminFeignClient adminFeignClient; + + @Autowired + private DeptUtils deptUtils; + + public static int Guid=100;//id自增值 + + @Override + public PageData page(Map params) { + IPage page = baseDao.selectPage( + getPage(params, FieldConstant.CREATED_TIME, false), + getWrapper(params) + ); + return getPageData(page, KpiCommunityBuildingDTO.class); + } + + /** + * 条件查询 + * @param params + * @return + */ + @Override + public PageData getInfoPage(Map params) { + IPage page = getPage(params); + List list = baseDao.getInfoPage(params); + return new PageData<>(list, page.getTotal()); + } + + @Override + public List list(Map params) { + List entityList = baseDao.selectList(getWrapper(params)); + + return ConvertUtils.sourceToTarget(entityList, KpiCommunityBuildingDTO.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 KpiCommunityBuildingDTO get(String id) { + KpiCommunityBuildingEntity entity = baseDao.selectById(id); + return ConvertUtils.sourceToTarget(entity, KpiCommunityBuildingDTO.class); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void save(KpiCommunityBuildingDTO dto) { + String deptId = dto.getDeptId(); + List checkList = new ArrayList(); + checkList.add(deptId); + // 判断录入月份是否为当前月或者前一个月 + if(!dto.getMonthYear().equals(getLastMonth()) && !dto.getMonthYear().equals(getCurrentMonth())){ + throw new RenException("只能对当前月份或者上个月份进行打分,请维护后重试!"); + } + // 检测excel中是否存在已打分部门 + StringBuffer deptErrorInfo = this.getDuplicateData(checkList,dto.getMonthYear()); + if (deptErrorInfo.length() > 0) { + throw new RenException(deptErrorInfo + " 已打分, 不可重复打分!"); + } + // 查询机构类型键值 + Result result = adminFeignClient.get(Long.valueOf(deptId)); + SysDeptDTO sysDeptDTO = result.getData(); + // 设置部门类别 + dto.setDeptTypeKey(sysDeptDTO.getTypeKey()); + KpiCommunityBuildingEntity entity = ConvertUtils.sourceToTarget(dto, KpiCommunityBuildingEntity.class); + insert(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void update(KpiCommunityBuildingDTO dto) { + KpiCommunityBuildingEntity entity = ConvertUtils.sourceToTarget(dto, KpiCommunityBuildingEntity.class); + updateById(entity); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void delete(String[] ids) { + // 逻辑删除(@TableLogic 注解) + baseDao.deleteBatchIds(Arrays.asList(ids)); + } + + /** + * 获取导出模板 + * + * @param params + * @return java.util.List + * @author wanggongfeng + * @date 2020-06-15 + */ + @Override + public List exportTemplate(Map params) { + List deptIdList = SecurityUser.getUser().getDeptIdList(); //获取用户权限 + ExportTemplateInfoFormDTO exportTemplateInfoFormDTO = new ExportTemplateInfoFormDTO(); + exportTemplateInfoFormDTO.setDeptIdList(deptIdList); + exportTemplateInfoFormDTO.setDeptId(params.get("deptId") == null ? "" : params.get("deptId").toString()); + exportTemplateInfoFormDTO.setDeptTypeKey(params.get("deptTypeKey") == null ? "" : params.get("deptTypeKey").toString()); + exportTemplateInfoFormDTO.setMonthYear(params.get("monthYear") == null ? "" : params.get("monthYear").toString()); + Result> result = adminFeignClient.getExportTemplateInfo(exportTemplateInfoFormDTO); + List resultList = result.getData(); + return ConvertUtils.sourceToTarget(resultList, KpiCommunityBuildingDTO.class); + } + + /** + * @Description: 导入治理排行管理-手动打分记录 + * @Param: [file] + * @return: Result + * @Author: wanggongfeng + * @Date: 2020-06-15 + */ + @Override + public Result importManualScoreExcel(MultipartFile file) { + File f = StreamUtils.conversionFile(file); + try { + //判断上传文件类型 + String originalFilename = file.getOriginalFilename(); + if (!originalFilename.endsWith(StrConstant.EXCEL_SUFFIX_2003) && !originalFilename.endsWith(StrConstant.EXCEL_SUFFIX_2007)) { + return new Result().error("请选择.xls或者.xlsx格式文件"); + } + List recordList = ExcelImportUtil.importExcel(f, KpiCommunityBuildingExcel.class, new ImportParams()); + if (CollUtil.isEmpty(recordList)) { + return new Result().error("导入内容不能为空"); + } + // 存储检测excel是否存在重复ID使用 + List checkList = new ArrayList(); + StringBuffer checkInfo = new StringBuffer(); + String monthYear = ""; + for(int i = 0 ; i < recordList.size() ; i++){ + KpiCommunityBuildingExcel kpiCommunityBuildingExcel = recordList.get(i); + + // 校验是否存在空单元格 + if(checkNullCell(kpiCommunityBuildingExcel)){ + return new Result().error("导入文件中存在空单元格,请完善后重试!"); + } + + // 校验是否存在分数范围不正确的打分 + if(checkScoreCell(kpiCommunityBuildingExcel)){ + return new Result().error("存在不符合分值范围的分数!"); + } + + // 校验月份是否不一致 + if(i == 0){ + monthYear = kpiCommunityBuildingExcel.getMonthYear(); + }else{ + if(!monthYear.equals(kpiCommunityBuildingExcel.getMonthYear())){ + return new Result().error("导入文件中月份不一致,请修改一致后重试!"); + } + monthYear = kpiCommunityBuildingExcel.getMonthYear(); + } + + // 校验ID是否存在重复 + if(checkList.contains(kpiCommunityBuildingExcel.getDeptId())){ + return new Result().error(kpiCommunityBuildingExcel.getDeptName() + "ID重复,请维护唯一ID后重试!"); + } + checkList.add(kpiCommunityBuildingExcel.getDeptId()); + + // 拼接部门ID不在当前用户权限内的部门名称 + checkInfo.append(splicingErrorDeptName(i,kpiCommunityBuildingExcel,recordList)); + } + // 判断导入月份是否为当前月或者前一个月 + if(!monthYear.equals(getLastMonth()) && !monthYear.equals(getCurrentMonth())){ + return new Result().error("只能对当前月份或者上个月份进行打分,请维护后重试!"); + } + // 校验部门ID是否存在当前用户权限内 + if (checkInfo.length() > 0) { + return new Result().error(checkInfo.append("部门ID错误,请维护后重试!").toString()); + } + // 检测excel中是否存在已打分部门 + StringBuffer deptErrorInfo = this.getDuplicateData(checkList,monthYear); + if (deptErrorInfo.length() > 0) { + return new Result().error(deptErrorInfo + " 已打分, 不可重复打分!"); + } + + // 循环插入网格建设打分数据(必要时可改为批量插入) + /*KpiCommunityBuildingEntity[] kpiCommunityBuildingEntities = new KpiCommunityBuildingEntity[recordList.size()]; + for(int i = 0 ; i < recordList.size() ; i++){ + KpiCommunityBuildingExcel kpiCommunityBuildingExcel = recordList.get(i); + KpiCommunityBuildingEntity entity = splicingEntity(kpiCommunityBuildingExcel); + kpiCommunityBuildingEntities[i] = entity; + } + baseDao.insertEntityList(kpiCommunityBuildingEntities);*/ + for (KpiCommunityBuildingExcel kpiCommunityBuildingExcel : recordList) { + KpiCommunityBuildingEntity entity = splicingEntity(kpiCommunityBuildingExcel); + insert(entity); + } + } catch (Exception e) { + return new Result().error("数据异常,解析excel文件失败"); + } finally { + // 删除文件 + this.deleteAllFilesOfDir(f); + } + return new Result(); + } + + /** + * 拼接部门ID不在当前用户权限内的部门名称 + * @param index + * @param kpiCommunityBuildingExcel + * @param recordList + * @return + */ + private String splicingErrorDeptName(int index,KpiCommunityBuildingExcel kpiCommunityBuildingExcel,List recordList){ + UserDetail user = SecurityUser.getUser(); + List deptIdList = user.getDeptIdList(); + if(!deptIdList.contains(Long.valueOf(kpiCommunityBuildingExcel.getDeptId()))){ + if(index == (recordList.size()-1)){ + return kpiCommunityBuildingExcel.getDeptName(); + }else{ + return kpiCommunityBuildingExcel.getDeptName() + "、"; + } + } + return ""; + } + + /** + * 校验是否存在空单元格 + * @param kpiCommunityBuildingExcel + * @return + */ + private Boolean checkNullCell(KpiCommunityBuildingExcel kpiCommunityBuildingExcel){ + if(StringUtils.isBlank(kpiCommunityBuildingExcel.getDeptId()) || StringUtils.isBlank(kpiCommunityBuildingExcel.getDeptName()) || StringUtils.isBlank(kpiCommunityBuildingExcel.getMonthYear()) + || StringUtils.isBlank(kpiCommunityBuildingExcel.getDemocraticConsultationMechanism()) || StringUtils.isBlank(kpiCommunityBuildingExcel.getDeptTypeKey()) + || StringUtils.isBlank(kpiCommunityBuildingExcel.getGridNegotiationCase()) || StringUtils.isBlank(kpiCommunityBuildingExcel.getResidentConventionSystem())){ + return true; + } + return false; + } + + /** + * 校验分数是否规范 + * @param kpiCommunityBuildingExcel + * @return + */ + private Boolean checkScoreCell(KpiCommunityBuildingExcel kpiCommunityBuildingExcel){ + // 民主协商机制分数(3分) + String democraticConsultationMechanism = kpiCommunityBuildingExcel.getDemocraticConsultationMechanism(); + if(checkNumber(democraticConsultationMechanism)){ + return true; + } + Double democraticConsultationMechanismInt = Double.parseDouble(democraticConsultationMechanism); + // 网格协商案例分数(4分) + String gridNegotiationCase = kpiCommunityBuildingExcel.getGridNegotiationCase(); + if(checkNumber(gridNegotiationCase)){ + return true; + } + Double gridNegotiationCaseInt = Double.parseDouble(gridNegotiationCase); + // 居民公约制度分数(3分) + String residentConventionSystem = kpiCommunityBuildingExcel.getResidentConventionSystem(); + if(checkNumber(residentConventionSystem)){ + return true; + } + Double residentConventionSystemInt = Double.parseDouble(residentConventionSystem); + if(democraticConsultationMechanismInt < 0 || democraticConsultationMechanismInt > 3 + || gridNegotiationCaseInt < 0 || gridNegotiationCaseInt > 4 + || residentConventionSystemInt < 0 || residentConventionSystemInt > 3){ + return true; + } + return false; + } + + /** + * 校验是否为数字字符串 + * @param numStr + * @return + */ + private Boolean checkNumber(String numStr){ + Pattern pattern = Pattern.compile("([1-9]\\d*\\.?\\d*)|(0\\.\\d*[1-9])"); + Matcher isNum = pattern.matcher(numStr); + if( !isNum.matches() ){ + return true; + } + return false; + } + + /** + * 获取上一个月字符串yyyy-MM + * @return + */ + public String getLastMonth() { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); + Date date = new Date(); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); // 设置为当前时间 + calendar.set(Calendar.MONTH, calendar.get(Calendar.MONTH) - 1); // 设置为上一个月 + date = calendar.getTime(); + String accDate = format.format(date); + return accDate; + } + + /** + * 获取当前月字符串yyyy-MM + * @return + */ + public String getCurrentMonth() { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); + Date date = new Date(); + String currentDate = format.format(date); + return currentDate; + } + + /** + * 拼接已打分部门提示信息 + * @param checkList + * @return + */ + private StringBuffer getDuplicateData(List checkList ,String monthYear){ + CheckIsScoredFormDTO checkIsScoredFormDTO = new CheckIsScoredFormDTO(); + checkIsScoredFormDTO.setCheckList(checkList); + checkIsScoredFormDTO.setMonthYear(monthYear); + StringBuffer deptErrorInfo = new StringBuffer(); + List list = baseDao.getDuplicateData(checkIsScoredFormDTO); + for(int i = 0 ; i < list.size() ; i++){ + KpiCommunityBuildingDTO kpiCommunityBuildingDTO = list.get(i); + if(i == (list.size()-1)){ + deptErrorInfo.append(kpiCommunityBuildingDTO.getDeptName()); + }else{ + deptErrorInfo.append(kpiCommunityBuildingDTO.getDeptName()).append("、"); + } + } + return deptErrorInfo; + } + + /** + * 拼接网格建设打分实体 + * @param kpiCommunityBuildingExcel + * @return + */ + private KpiCommunityBuildingEntity splicingEntity(KpiCommunityBuildingExcel kpiCommunityBuildingExcel){ + //String userId = SecurityUser.getUserId() == null ? "" : SecurityUser.getUserId().toString(); + KpiCommunityBuildingEntity entity = ConvertUtils.sourceToTarget(kpiCommunityBuildingExcel, KpiCommunityBuildingEntity.class); + // 查询设置部门类别和部门名称 + String deptId = entity.getDeptId(); + Result result = adminFeignClient.get(Long.valueOf(deptId)); + SysDeptDTO sysDeptDTO = result.getData(); + entity.setDeptTypeKey(sysDeptDTO.getTypeKey()); + entity.setDeptName(sysDeptDTO.getName()); + // 查询设置上级部门信息 + DeptLevelAndLeaderDTO deptLevelInfo = deptUtils.getDeptLevelInfo(Long.valueOf(deptId), YesOrNoEnum.YES); + entity.setAllDeptIds(deptLevelInfo.getAllDeptIds()); + entity.setAllDeptNames(deptLevelInfo.getAllDeptNames()); + entity.setParentDeptIds(deptLevelInfo.getParentDeptIds()); + entity.setParentDeptNames(deptLevelInfo.getParentDeptNames()); + // 设置其他字段 + /*entity.setRevision(0); + entity.setId(getLongRandom()); + entity.setCreatedBy(userId); + entity.setUpdatedBy(userId); + entity.setCreatedTime(new Date()); + entity.setUpdatedTime(new Date()); + entity.setDelFlag("0");*/ + return entity; + } + + /** + * 获取19位随机数 + * @return + */ + /*public String getLongRandom(){ + Guid+=1; + long now = System.currentTimeMillis(); + SimpleDateFormat dateFormat=new SimpleDateFormat("MMdd"); + String time=dateFormat.format(now); + String currentTimeMillis=now+""; + int ran=0; + if(Guid>999){ + Guid=100; + } + ran=Guid; + String str = time+currentTimeMillis.substring(1, currentTimeMillis.length())+ran; + return str; + }*/ + + + /** + * 删除文件夹(强制删除) + * + * @param path + */ + private void deleteAllFilesOfDir(File path) { + if (null != path) { + if (!path.exists()) { + return; + } + if (path.isFile()) { + boolean result = path.delete(); + int tryCount = 0; + while (!result && tryCount++ < 10) { + System.gc(); // 回收资源 + result = path.delete(); + } + } + File[] files = path.listFiles(); + if (null != files) { + for (int i = 0; i < files.length; i++) { + deleteAllFilesOfDir(files[i]); + } + } + path.delete(); + } + } + +} \ No newline at end of file diff --git a/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/resources/mapper/KpiCommunityBuildingDao.xml b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/resources/mapper/KpiCommunityBuildingDao.xml new file mode 100644 index 000000000..8b14039ce --- /dev/null +++ b/esua-epdc/epdc-module/epdc-kpi/epdc-kpi-server/src/main/resources/mapper/KpiCommunityBuildingDao.xml @@ -0,0 +1,139 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into epdc_kpi_community_building + (ID, + DEPT_ID, + DEPT_NAME, + DEPT_TYPE_KEY, + MONTH_YEAR, + DEMOCRATIC_CONSULTATION_MECHANISM, + RESIDENT_CONVENTION_SYSTEM, + GRID_NEGOTIATION_CASE, + PARENT_DEPT_IDS, + PARENT_DEPT_NAMES, + ALL_DEPT_IDS, + ALL_DEPT_NAMES, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME, + DEL_FLAG + ) + values + + (#{item.id}, + #{item.deptId}, + #{item.deptName}, + #{item.deptTypeKey}, + #{item.monthYear}, + #{item.democraticConsultationMechanism}, + #{item.residentConventionSystem}, + #{item.gridNegotiationCase}, + #{item.parentDeptIds}, + #{item.parentDeptNames}, + #{item.allDeptIds}, + #{item.allDeptNames}, + #{item.revision}, + #{item.createdBy}, + #{item.createdTime}, + #{item.updatedBy}, + #{item.updatedTime}, + #{item.delFlag}) + + + + + \ No newline at end of file