From d2c92de5540c693873034d1ab15e8f546dc01360 Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 20 Aug 2021 08:27:59 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E5=AF=BC=E5=87=BA=E5=B7=A1=E6=9F=A5?= =?UTF-8?q?=E8=AE=B0=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/EpmetUserController.java | 17 +++++-- .../dataaggre/excel/StaffPatrollExcel.java | 45 +++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/StaffPatrollExcel.java diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java index 7433f7e83d..43cb3df89b 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java @@ -5,6 +5,7 @@ import com.epmet.commons.tools.annotation.RequirePermission; import com.epmet.commons.tools.enums.RequirePermissionEnum; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.security.dto.TokenDto; +import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.commons.tools.validator.ValidatorUtils; import com.epmet.dataaggre.dto.epmetuser.form.OpenStaffDetailFormDTO; @@ -13,14 +14,13 @@ import com.epmet.dataaggre.dto.epmetuser.form.PatrolRecordListFormDTO; import com.epmet.dataaggre.dto.epmetuser.form.StaffListFormDTO; import com.epmet.dataaggre.dto.epmetuser.result.*; import com.epmet.dataaggre.dto.govorg.result.GridMemberDataAnalysisResultDTO; +import com.epmet.dataaggre.excel.StaffPatrollExcel; import com.epmet.dataaggre.service.datastats.DataStatsService; import com.epmet.dataaggre.service.epmetuser.EpmetUserService; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletResponse; import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -209,4 +209,13 @@ public class EpmetUserController { return new Result().ok(epmetUserService.mentionMeEvent(tokenDto.getUserId())); } + @GetMapping("export/staffpatroll") + public void export( @RequestBody StaffListFormDTO formDTO, HttpServletResponse response) throws Exception { + ValidatorUtils.validateEntity(formDTO, StaffListFormDTO.Staff.class); + //formDTO.setUserId(tokenDto.getUserId()); + formDTO.setUserId("73ae6280e46a6653a5605d51d5462725"); + List resultDTOS = epmetUserService.staffPatrolList(formDTO); + ExcelUtils.exportExcelToTarget(response, null, resultDTOS, StaffPatrollExcel.class); + } + } diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/StaffPatrollExcel.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/StaffPatrollExcel.java new file mode 100644 index 0000000000..503c8b4cab --- /dev/null +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/excel/StaffPatrollExcel.java @@ -0,0 +1,45 @@ +/** + * 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.dataaggre.excel; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import lombok.Data; + +/** + * 客户表 + * + * @author generator generator@elink-cn.com + * @since v1.0.0 2020-03-11 + */ +@Data +public class StaffPatrollExcel { + + @Excel(name = "组织") + private String gridName = ""; + @Excel(name = "姓名") + private String staffName = ""; + @Excel(name = "巡查总次数") + private Integer patrolTotal = 0; + @Excel(name = "上报项目数") + private Integer reportProjectCount; + @Excel(name = "巡查总时长") + private String totalTime = ""; + + + +} From 1e5413ea8d616b16ed220f169461bc4035c43091 Mon Sep 17 00:00:00 2001 From: jianjun Date: Fri, 20 Aug 2021 08:35:37 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=AF=BC=E5=87=BA=20=E4=B8=8A=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/epmet/dataaggre/controller/EpmetUserController.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java index 43cb3df89b..506048dbd4 100644 --- a/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java +++ b/epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/controller/EpmetUserController.java @@ -210,10 +210,10 @@ public class EpmetUserController { } @GetMapping("export/staffpatroll") - public void export( @RequestBody StaffListFormDTO formDTO, HttpServletResponse response) throws Exception { + public void export(@LoginUser TokenDto tokenDto, @RequestBody StaffListFormDTO formDTO, HttpServletResponse response) throws Exception { ValidatorUtils.validateEntity(formDTO, StaffListFormDTO.Staff.class); - //formDTO.setUserId(tokenDto.getUserId()); - formDTO.setUserId("73ae6280e46a6653a5605d51d5462725"); + formDTO.setUserId(tokenDto.getUserId()); + //formDTO.setUserId("73ae6280e46a6653a5605d51d5462725"); List resultDTOS = epmetUserService.staffPatrolList(formDTO); ExcelUtils.exportExcelToTarget(response, null, resultDTOS, StaffPatrollExcel.class); } From bd413ab9e8d8e61347f7f6c7661f174da90e65cd Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 20 Aug 2021 10:01:21 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=B7=A1=E6=9F=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/StaffPatrolRecordDao.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffPatrolRecordDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffPatrolRecordDao.xml index 27fc5211ec..2ae77add42 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/StaffPatrolRecordDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/StaffPatrolRecordDao.xml @@ -48,7 +48,7 @@ + + + \ No newline at end of file From b1ead3d4c89a21522bb44dad50c9e3b1af07e558 Mon Sep 17 00:00:00 2001 From: zxc <1272811460@qq.com> Date: Fri, 20 Aug 2021 10:41:59 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E5=B7=A1=E6=9F=A5=E4=BA=BA=E6=95=B0?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/StaffPatrolDetailController.java | 4 +-- .../user/StaffPatrolDetailService.java | 4 +-- .../impl/StaffPatrolDetailServiceImpl.java | 27 +++++-------------- 3 files changed, 11 insertions(+), 24 deletions(-) diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/user/StaffPatrolDetailController.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/user/StaffPatrolDetailController.java index 8f06a5850f..e20e1e7d5c 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/user/StaffPatrolDetailController.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/controller/user/StaffPatrolDetailController.java @@ -6,11 +6,11 @@ import com.epmet.datareport.service.user.StaffPatrolDetailService; import com.epmet.user.form.GridManagerListFormDTO; import com.epmet.dto.form.PatrolTrackFormDTO; import com.epmet.dto.form.RecordListFormDTO; -import com.epmet.user.form.PatrolCountFormDTO; +import com.epmet.dto.form.PatrolCountFormDTO; import com.epmet.user.result.GridManagerListResultDTO; import com.epmet.dto.result.PatrolTrackResultDTO; import com.epmet.dto.result.RecordListResultDTO; -import com.epmet.user.result.PatrolCountResultDTO; +import com.epmet.dto.result.PatrolCountResultDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/StaffPatrolDetailService.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/StaffPatrolDetailService.java index 20573e51a7..95fc1eb064 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/StaffPatrolDetailService.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/StaffPatrolDetailService.java @@ -3,11 +3,11 @@ package com.epmet.datareport.service.user; import com.epmet.user.form.GridManagerListFormDTO; import com.epmet.dto.form.PatrolTrackFormDTO; import com.epmet.dto.form.RecordListFormDTO; -import com.epmet.user.form.PatrolCountFormDTO; +import com.epmet.dto.form.PatrolCountFormDTO; import com.epmet.user.result.GridManagerListResultDTO; import com.epmet.dto.result.PatrolTrackResultDTO; import com.epmet.dto.result.RecordListResultDTO; -import com.epmet.user.result.PatrolCountResultDTO; +import com.epmet.dto.result.PatrolCountResultDTO; import java.util.List; diff --git a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/impl/StaffPatrolDetailServiceImpl.java b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/impl/StaffPatrolDetailServiceImpl.java index 4f36820709..6f01a162ac 100644 --- a/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/impl/StaffPatrolDetailServiceImpl.java +++ b/epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/user/impl/StaffPatrolDetailServiceImpl.java @@ -3,6 +3,7 @@ package com.epmet.datareport.service.user.impl; import com.epmet.commons.tools.constant.NumConstant; import com.epmet.commons.tools.exception.RenException; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.Result; import com.epmet.datareport.constant.PatrolConstant; import com.epmet.datareport.dao.user.StaffPatrolDetailDao; @@ -15,9 +16,9 @@ import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.user.form.GridManagerListFormDTO; import com.epmet.dto.form.PatrolTrackFormDTO; import com.epmet.dto.form.RecordListFormDTO; -import com.epmet.user.form.PatrolCountFormDTO; +import com.epmet.dto.form.PatrolCountFormDTO; import com.epmet.user.result.GridManagerListResultDTO; -import com.epmet.user.result.PatrolCountResultDTO; +import com.epmet.dto.result.PatrolCountResultDTO; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -26,7 +27,6 @@ import org.springframework.util.CollectionUtils; import java.util.ArrayList; import java.util.List; -import java.util.Map; import java.util.stream.Collectors; /** @@ -200,24 +200,11 @@ public class StaffPatrolDetailServiceImpl implements StaffPatrolDetailService { */ @Override public PatrolCountResultDTO patrolCount(PatrolCountFormDTO formDTO) { - PatrolCountResultDTO result = new PatrolCountResultDTO(); - GridManagerListFormDTO gridManagerListFormDTO = ConvertUtils.sourceToTarget(formDTO, GridManagerListFormDTO.class); - List resultDTOS = gridManagerList(gridManagerListFormDTO); - // 结果为空就是没网格员 - if (CollectionUtils.isEmpty(resultDTOS)){ - return result; - } - // 根据状态分组,只取巡查中的网格员;巡查中的为0,剩下的都是未巡查,巡查中不为0,总数 - 巡查中 = 未巡查 - Map> groupByStatus = resultDTOS.stream().collect(Collectors.groupingBy(GridManagerListResultDTO::getStatus)); - List patrolling = groupByStatus.get(PatrolConstant.PATROLLING); - if (CollectionUtils.isEmpty(patrolling)){ - result.setElseCount(resultDTOS.size()); - return result; + Result resultDTOResult = epmetUserOpenFeignClient.patrolCount(formDTO); + if (!resultDTOResult.success()){ + throw new RenException("查询巡查人数失败..."); } - result.setPatrollingCount(patrolling.size()); - result.setElseCount(resultDTOS.size() - patrolling.size()); - return result; + return resultDTOResult.getData(); } - }