From 86e770d7870a80577cb3292539d7c4636173bc6b Mon Sep 17 00:00:00 2001 From: lichao <326994889@qq.com> Date: Tue, 18 Apr 2023 15:01:09 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E7=BB=84=E7=BB=87=E5=BC=80=E9=80=9A?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/CustomerAgencyController.java | 6 ++--- .../java/com/epmet/dao/CustomerAgencyDao.java | 6 ++--- .../epmet/service/CustomerAgencyService.java | 4 ++-- .../impl/CustomerAgencyServiceImpl.java | 12 +++++----- .../resources/mapper/CustomerAgencyDao.xml | 22 +++++++++++++++++-- 5 files changed, 34 insertions(+), 16 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java index e0d4f9f644..1e0a66ddd8 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/CustomerAgencyController.java @@ -535,9 +535,9 @@ public class CustomerAgencyController { * @Author: lichao * @Date: 2023/4/7 14:48 */ - @GetMapping("getAgencyCountList") - public Result> getAgencyCountList(@RequestParam String agencyId){ - return new Result>().ok(customerAgencyService.getAgencyCountList(agencyId)); + @PostMapping("getAgencyCountList") + public Result> getAgencyCountList(@RequestBody CommunityCountCensusFormDTO dto){ + return new Result>().ok(customerAgencyService.getAgencyCountList(dto)); } /** diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java index 5639d33894..1b21c0059c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/dao/CustomerAgencyDao.java @@ -434,11 +434,11 @@ public interface CustomerAgencyDao extends BaseDao { */ List getAllCommunity(String customerId); - List agencyCount(@Param("pids") String pids); + List agencyCount(@Param("pids") String pids,@Param("timeStart")Date timeStart,@Param("timeEnd")Date timeEnd); - Integer agencyGridCount(@Param("pids") String pids); + Integer agencyGridCount(@Param("pids") String pids,@Param("timeStart")Date timeStart,@Param("timeEnd")Date timeEnd); - Integer agencyStaffCount(@Param("pids") String pids); + Integer agencyStaffCount(@Param("pids") String pids,@Param("timeStart")Date timeStart,@Param("timeEnd")Date timeEnd); Integer getCommunityCount(@Param("pids")String pids,@Param("timeStart")Date timeStart,@Param("timeEnd")Date timeEnd); diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java index f43de77102..ceac3653a9 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/CustomerAgencyService.java @@ -368,10 +368,10 @@ public interface CustomerAgencyService extends BaseService /** * 返回下级数量 - * @param agencyId + * @param dto * @return */ - List getAgencyCountList(String agencyId); + List getAgencyCountList(CommunityCountCensusFormDTO dto); /** * @Description: 获取下级组织的社区数量 diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java index 7a651ecc9a..cfb2dcda25 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/service/impl/CustomerAgencyServiceImpl.java @@ -1662,29 +1662,29 @@ public class CustomerAgencyServiceImpl extends BaseServiceImpl * @Author: lichao * @Date: 2023/4/7 14:17 */ @Override - public List getAgencyCountList(String agencyId) { + public List getAgencyCountList(CommunityCountCensusFormDTO dto) { List agencyCountCensusResultDTOS = new ArrayList<>(); - CustomerAgencyEntity customerAgency = baseDao.selectById(agencyId); + CustomerAgencyEntity customerAgency = baseDao.selectById(dto.getAgencyId()); if (customerAgency != null){ String pids = PidUtils.convertPid2OrgIdPath(customerAgency.getId(),customerAgency.getPids()); - agencyCountCensusResultDTOS = baseDao.agencyCount(pids); + agencyCountCensusResultDTOS = baseDao.agencyCount(pids,dto.getTimeStart(),dto.getTimeEnd()); AgencyCountCensusResultDTO agencyCountCensusResultDTOGrid = new AgencyCountCensusResultDTO(); agencyCountCensusResultDTOGrid.setLevel("grid"); - agencyCountCensusResultDTOGrid.setCount(baseDao.agencyGridCount(pids)); + agencyCountCensusResultDTOGrid.setCount(baseDao.agencyGridCount(pids,dto.getTimeStart(),dto.getTimeEnd())); agencyCountCensusResultDTOS.add(agencyCountCensusResultDTOGrid); AgencyCountCensusResultDTO agencyCountCensusResultDTOStaff = new AgencyCountCensusResultDTO(); agencyCountCensusResultDTOStaff.setLevel("staff"); - agencyCountCensusResultDTOStaff.setCount(baseDao.agencyStaffCount(pids)); + agencyCountCensusResultDTOStaff.setCount(baseDao.agencyStaffCount(pids,dto.getTimeStart(),dto.getTimeEnd())); agencyCountCensusResultDTOS.add(agencyCountCensusResultDTOStaff); }else{ diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index 7f3f76b2d0..08252c1b5c 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -889,6 +889,12 @@ from customer_agency where DEL_FLAG = 0 and PIDS like concat(#{pids},'%') + + and agency.UPDATED_TIME >= #{timeStart} + + + and agency.UPDATED_TIME <= #{timeEnd} + group by level @@ -899,6 +905,12 @@ from customer_grid where DEL_FLAG = 0 and PIDS like concat(#{pids},'%') + + and UPDATED_TIME >= #{timeStart} + + + and UPDATED_TIME <= #{timeEnd} + @@ -911,6 +923,12 @@ and staff.DEL_FLAG = 0 and agency.PIDS like concat(#{pids},'%') + + and agency.UPDATED_TIME >= #{timeStart} + + + and agency.UPDATED_TIME <= #{timeEnd} + @@ -1212,10 +1230,10 @@ and agency.LEVEL = 'community' and agency.PIDS like concat(#{pids},'%') - and agency.CREATED_TIME >= #{timeStart} + and agency.UPDATED_TIME >= #{timeStart} - and agency.CREATED_TIME <= #{timeEnd} + and agency.UPDATED_TIME <= #{timeEnd} + + + + + + \ No newline at end of file From dfb74fedc8d5771faa909069e2e28265b049895e Mon Sep 17 00:00:00 2001 From: lichao <326994889@qq.com> Date: Tue, 18 Apr 2023 15:14:01 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E9=95=87=E8=A1=97=E6=95=B0=E4=BF=AE?= =?UTF-8?q?=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/mapper/CustomerAgencyDao.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml index 08252c1b5c..0329a58092 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml +++ b/epmet-module/gov-org/gov-org-server/src/main/resources/mapper/CustomerAgencyDao.xml @@ -890,10 +890,10 @@ where DEL_FLAG = 0 and PIDS like concat(#{pids},'%') - and agency.UPDATED_TIME >= #{timeStart} + and UPDATED_TIME >= #{timeStart} - and agency.UPDATED_TIME <= #{timeEnd} + and UPDATED_TIME <= #{timeEnd} group by level From 24fc1b1af5e26b79b7a0eedab6dabe830c2236b0 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 18 Apr 2023 15:20:04 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=B1=85=E6=B0=91=E7=94=BB=E5=83=8ForgIdPa?= =?UTF-8?q?thlike?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/epmet/dao/IcResiUserDao.java | 7 +++++-- .../service/impl/IcResiUserServiceImpl.java | 18 +++++++++++++++--- .../main/resources/mapper/IcResiUserDao.xml | 6 +++--- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java index 1f78eb3726..a3a2f9d40d 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/dao/IcResiUserDao.java @@ -464,11 +464,13 @@ public interface IcResiUserDao extends BaseDao { */ List queryEducationDistribute(@Param("customerId") String customerId, @Param("orgId") String orgId, - @Param("orgType") String orgType); + @Param("orgType") String orgType, + @Param("orgIdPath")String orgIdPath); List selectAgeAgeDistribute(@Param("customerId") String customerId, @Param("orgId") String orgId, - @Param("orgType") String orgType); + @Param("orgType") String orgType, + @Param("orgIdPath")String orgIdPath); /** * @param customerId @@ -481,6 +483,7 @@ public interface IcResiUserDao extends BaseDao { List selectPortrayalResiList(@Param("customerId") String customerId, @Param("orgId") String orgId, @Param("orgType") String orgType, + @Param("orgIdPath") String orgIdPath, @Param("codeType")String codeType, @Param("code") String code); } diff --git a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java index 1c459733ee..7088071b64 100644 --- a/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java +++ b/epmet-user/epmet-user-server/src/main/java/com/epmet/service/impl/IcResiUserServiceImpl.java @@ -3919,8 +3919,12 @@ public class IcResiUserServiceImpl extends BaseServiceImpl resultList=getDefaultAgeDistribute(); - List list=baseDao.selectAgeAgeDistribute(customerId,orgId,orgType); + List list=baseDao.selectAgeAgeDistribute(customerId,orgId,orgType,orgIdPath); if(CollectionUtils.isEmpty(list)){ return resultList; } @@ -3986,8 +3990,12 @@ public class IcResiUserServiceImpl extends BaseServiceImpl totalList = baseDao.queryEducationDistribute(customerId, orgId, orgType); + List totalList = baseDao.queryEducationDistribute(customerId, orgId, orgType,orgIdPath); Map map = totalList.stream().collect(Collectors.toMap(ResiPortrayalResultDTO::getCode,ResiPortrayalResultDTO::getTotalResi)); List resultDTOList = new ArrayList<>(); dictResult.getData().forEach(dict -> { @@ -4037,8 +4045,12 @@ public class IcResiUserServiceImpl extends BaseServiceImpl list = baseDao.selectPortrayalResiList(customerId, orgId, orgType,codeType, code); + List list = baseDao.selectPortrayalResiList(customerId, orgId, orgType,orgIdPath,codeType, code); if(CollectionUtils.isNotEmpty(list)){ Set houseIds=list.stream().map(m -> m.getHomeId()).collect(Collectors.toSet()); //查询房子名称 diff --git a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml index 229652a45f..5db97e1f5e 100644 --- a/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml +++ b/epmet-user/epmet-user-server/src/main/resources/mapper/IcResiUserDao.xml @@ -1606,7 +1606,7 @@ r.DEL_FLAG = '0' AND r.CUSTOMER_ID = #{customerId} - AND ( r.AGENCY_ID = #{orgId} OR r.PIDS LIKE concat('%',#{orgId},'%') ) + and r.PIDS LIKE concat(#{orgIdPath},'%') and r.GRID_ID = #{orgId} @@ -1647,7 +1647,7 @@ and u.BIRTHDAY is not null and u.BIRTHDAY !='' - AND ( u.AGENCY_ID = #{orgId} OR u.PIDS LIKE concat('%',#{orgId},'%') ) + and u.PIDS LIKE concat(#{orgIdPath},'%') and u.GRID_ID = #{orgId} @@ -1683,7 +1683,7 @@ AND u.CUSTOMER_ID = #{customerId} AND u.`STATUS` = '0' - AND ( u.AGENCY_ID = #{orgId} OR u.PIDS LIKE concat('%',#{orgId},'%') ) + and u.PIDS LIKE concat(#{orgIdPath},'%') and u.GRID_ID = #{orgId} From b35a699620b9b6b2d7d78a57459bb996191cf259 Mon Sep 17 00:00:00 2001 From: yinzuomei <576302893@qq.com> Date: Tue, 18 Apr 2023 15:31:24 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E7=A4=BE=E5=8C=BA=E5=8F=8A=E8=B4=A6?= =?UTF-8?q?=E5=8F=B7=E7=99=BB=E5=BD=95=EF=BC=8C=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../result/yt/CommunityLoginResultDTO.java | 13 +++++ .../controller/StaffLoginLogController.java | 53 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/CommunityLoginResultDTO.java b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/CommunityLoginResultDTO.java index e1cb00a765..a8c1e4fb76 100644 --- a/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/CommunityLoginResultDTO.java +++ b/epmet-module/gov-org/gov-org-client/src/main/java/com/epmet/dto/result/yt/CommunityLoginResultDTO.java @@ -1,5 +1,8 @@ package com.epmet.dto.result.yt; +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; import lombok.Data; /** @@ -12,26 +15,36 @@ public class CommunityLoginResultDTO { /** * 组织id */ + @ExcelIgnore private String agencyId; /** * 组织名称 */ + @ColumnWidth(20) + @ExcelProperty(value = "社区名称") private String agencyName; /** * 组织级别(社区级:community, 乡(镇、街道)级:street, 区县级: district, 市级: city 省级:province) */ + @ExcelIgnore private String agencyLevel; /** * 所属街道名称; */ + @ColumnWidth(20) + @ExcelProperty(value = "所属街道") private String streetName; /** * 所属区县名称; */ + @ColumnWidth(20) + @ExcelProperty(value = "所属区县") private String districtName; /** * 登录次数 */ + @ColumnWidth(20) + @ExcelProperty(value = "登录次数") private Integer count; } diff --git a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffLoginLogController.java b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffLoginLogController.java index c2967945f7..12bb6d4cb4 100644 --- a/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffLoginLogController.java +++ b/epmet-module/gov-org/gov-org-server/src/main/java/com/epmet/controller/StaffLoginLogController.java @@ -1,12 +1,21 @@ package com.epmet.controller; +import com.alibaba.excel.EasyExcel; +import com.alibaba.excel.ExcelWriter; +import com.alibaba.excel.write.metadata.WriteSheet; +import com.alibaba.fastjson.JSON; import com.alibaba.nacos.client.naming.utils.CollectionUtils; import com.epmet.commons.tools.annotation.LoginUser; +import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.exception.EpmetErrorCode; +import com.epmet.commons.tools.exception.EpmetException; import com.epmet.commons.tools.page.PageData; import com.epmet.commons.tools.security.dto.TokenDto; import com.epmet.commons.tools.utils.ConvertUtils; +import com.epmet.commons.tools.utils.DateUtils; import com.epmet.commons.tools.utils.ExcelUtils; import com.epmet.commons.tools.utils.Result; +import com.epmet.commons.tools.utils.poi.excel.handler.FreezeAndFilter; import com.epmet.dto.form.yt.CommunityLoginFormDTO; import com.epmet.dto.form.yt.CountActivityFormDTO; import com.epmet.dto.form.yt.LoginLogCountByLevelFormDTO; @@ -16,6 +25,7 @@ import com.epmet.dto.result.yt.LoginLogCountByLevelResultDTO; import com.epmet.excel.yt.AccountActivityExcel; import com.epmet.excel.yt.AccountInactivityExcel; import com.epmet.service.StaffLoginLogService; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; @@ -24,6 +34,8 @@ import org.springframework.web.bind.annotation.RestController; import com.epmet.dto.result.yt.AccountActivityInfo; import javax.servlet.http.HttpServletResponse; +import java.io.PrintWriter; +import java.util.Date; import java.util.List; @@ -33,6 +45,7 @@ import java.util.List; * @author generator generator@elink-cn.com * @since v1.0.0 2023-04-04 */ +@Slf4j @RestController @RequestMapping("staffLoginLog") public class StaffLoginLogController { @@ -62,6 +75,46 @@ public class StaffLoginLogController { return new Result>().ok(staffLoginLogService.pageCommunityCount(formDTO)); } + /** + * 下级社区账号登录次数排名 + * + * @return + */ + @PostMapping("community-count-export") + public void communityCount(HttpServletResponse response, @RequestBody CommunityLoginFormDTO formDTO) throws Exception { + ExcelWriter excelWriter = null; + formDTO.setPageNo(NumConstant.ONE); + formDTO.setPageSize(NumConstant.TEN_THOUSAND); + try { + String fileName = "社区级账号登录情况" + DateUtils.format(new Date()) + ".xlsx"; + excelWriter = EasyExcel.write(ExcelUtils.getOutputStreamForExcel(fileName, response), CommunityLoginResultDTO.class).build(); + WriteSheet writeSheet = EasyExcel.writerSheet("Sheet1").registerWriteHandler(new FreezeAndFilter()).build(); + PageData data = null; + List list = null; + do { + // 默认查询本组织及下级 + data = staffLoginLogService.pageCommunityCount(formDTO); + list = ConvertUtils.sourceToTarget(data.getList(), CommunityLoginResultDTO.class); + formDTO.setPageNo(formDTO.getPageNo() + NumConstant.ONE); + excelWriter.write(list, writeSheet); + } while (org.apache.commons.collections4.CollectionUtils.isNotEmpty(list) && list.size() == formDTO.getPageSize()); + } catch (EpmetException e) { + response.reset(); + response.setCharacterEncoding("UTF-8"); + response.setHeader("content-type", "application/json; charset=UTF-8"); + PrintWriter printWriter = response.getWriter(); + Result result = new Result<>().error(EpmetErrorCode.EPMET_COMMON_OPERATION_FAIL.getCode(), e.getMsg()); + printWriter.write(JSON.toJSONString(result)); + printWriter.close(); + } catch (Exception e) { + log.error("社区级账号登录情况export exception", e); + } finally { + if (excelWriter != null) { + excelWriter.finish(); + } + } + } + /** * 柱状图:下级组织账号登录次数汇总 *