diff --git a/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/LingshanPublicServiceTimeStatsRstDTO.java b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/LingshanPublicServiceTimeStatsRstDTO.java new file mode 100644 index 0000000000..c0f2e6beb6 --- /dev/null +++ b/epmet-module/epmet-heart/epmet-heart-client/src/main/java/com/epmet/dto/result/LingshanPublicServiceTimeStatsRstDTO.java @@ -0,0 +1,42 @@ +package com.epmet.dto.result; + +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.math.BigDecimal; + +/** + * @Description 【灵山】大屏:公共服务->柱状图统计服务次数和满意率 + * @Author wangxianzhang + * @Time 2023/6/1 10:15 AM + */ +@Data +@NoArgsConstructor +@AllArgsConstructor +public class LingshanPublicServiceTimeStatsRstDTO { + + private String orgId; + private String orgType; + private String orgName; + private String orgIdPath; + /** + * 服务总次数,包括完成了和没完成的 + */ + private int serveTimes = 0; + + /** + * 满意的次数 + */ + private int satisfactionTimes = 0; + /** + * 完成了多少次 + */ + private int completedTimes = 0; + + /** + * 满意率,分子,还是用浮点数吧,精确一点 + */ + private BigDecimal satisfactionRate = BigDecimal.ZERO; + +} diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceRecordV2Controller.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceRecordV2Controller.java index 9449689fc2..9ee258f26c 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceRecordV2Controller.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/controller/IcServiceRecordV2Controller.java @@ -14,11 +14,13 @@ import com.epmet.dto.IcServiceRecordV2DTO; import com.epmet.dto.form.ServiceRecordV2DetailFormDTO; import com.epmet.dto.form.IcServiceRecordV2AddEditFormDTO; import com.epmet.dto.form.ServiceRecordV2ListFormDTO; +import com.epmet.dto.result.LingshanPublicServiceTimeStatsRstDTO; import com.epmet.dto.result.ServiceRecordV2DetailResultDTO; import com.epmet.service.IcServiceRecordV2Service; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; +import java.util.List; import java.util.Map; @@ -109,4 +111,20 @@ public class IcServiceRecordV2Controller { ValidatorUtils.validateEntity(formDTO,ServiceRecordV2DetailFormDTO.ServiceRecordV2DetailForm.class); return new Result().ok(icServiceRecordV2Service.serviceRecordV2Detail(formDTO)); } + + /** + * @Description: 【灵山】大屏:公共服务->柱状图统计服务次数和满意率 + * @param orgId: + * @param orgType: + * @Return com.epmet.commons.tools.utils.Result> + * @Author: wangxianzhang + * @Date: 2023/6/1 10:15 AM + */ + @GetMapping("lingshan/screen/serviceTimeAndSatisStats") + public Result> lingshanServiceTimeAndSatisStats(@RequestParam("orgId") String orgId, + @RequestParam("orgType") String orgType) { + + List rl = icServiceRecordV2Service.lingshanServiceTimeAndSatisStats(orgId, orgType); + return new Result>().ok(rl); + } } diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceRecordV2Dao.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceRecordV2Dao.java index 55ae94e6aa..7068d26a7e 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceRecordV2Dao.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/dao/IcServiceRecordV2Dao.java @@ -2,9 +2,11 @@ package com.epmet.dao; import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.form.ServiceRecordV2ListFormDTO; +import com.epmet.dto.result.LingshanPublicServiceTimeStatsRstDTO; import com.epmet.dto.result.ServiceRecordV2ListResultDTO; import com.epmet.entity.IcServiceRecordV2Entity; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; import java.util.List; @@ -25,4 +27,12 @@ public interface IcServiceRecordV2Dao extends BaseDao { */ List serviceRecordV2List(ServiceRecordV2ListFormDTO formDTO); + /** + * @Description: 【灵山】大屏:公共服务->柱状图统计服务次数和满意率 + * @param orgIdPath: + * @Return java.util.List + * @Author: wangxianzhang + * @Date: 2023/6/1 10:18 AM + */ + List serviceTimeStatsByOrg(@Param("orgIdPath") String orgIdPath); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordV2Service.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordV2Service.java index 4682517a00..dc4d896831 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordV2Service.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/IcServiceRecordV2Service.java @@ -6,6 +6,7 @@ import com.epmet.dto.IcServiceRecordV2DTO; import com.epmet.dto.form.ServiceRecordV2DetailFormDTO; import com.epmet.dto.form.IcServiceRecordV2AddEditFormDTO; import com.epmet.dto.form.ServiceRecordV2ListFormDTO; +import com.epmet.dto.result.LingshanPublicServiceTimeStatsRstDTO; import com.epmet.dto.result.ServiceRecordV2DetailResultDTO; import com.epmet.entity.IcServiceRecordV2Entity; @@ -97,4 +98,6 @@ public interface IcServiceRecordV2Service extends BaseService lingshanServiceTimeAndSatisStats(String orgId, String orgType); } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordV2ServiceImpl.java b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordV2ServiceImpl.java index c261588910..5b0966196e 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordV2ServiceImpl.java +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/java/com/epmet/service/impl/IcServiceRecordV2ServiceImpl.java @@ -7,15 +7,20 @@ import com.baomidou.mybatisplus.core.toolkit.IdWorker; import com.epmet.commons.mybatis.service.impl.BaseServiceImpl; import com.epmet.commons.tools.constant.FieldConstant; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.commons.tools.constant.ServiceConstant; import com.epmet.commons.tools.constant.StrConstant; import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; import com.epmet.commons.tools.exception.EpmetErrorCode; import com.epmet.commons.tools.exception.EpmetException; +import com.epmet.commons.tools.feign.ResultDataResolver; import com.epmet.commons.tools.page.PageData; +import com.epmet.commons.tools.redis.common.CustomerOrgRedis; import com.epmet.commons.tools.redis.common.CustomerStaffRedis; import com.epmet.commons.tools.utils.ConvertUtils; import com.epmet.commons.tools.utils.DateUtils; +import com.epmet.commons.tools.utils.PidUtils; import com.epmet.commons.tools.utils.SpringContextUtils; +import com.epmet.constant.OrgInfoConstant; import com.epmet.constant.SmsTemplateConstant; import com.epmet.dao.*; import com.epmet.dto.IcServiceFeedbackV2DTO; @@ -25,11 +30,12 @@ import com.epmet.dto.form.IcServiceRecordV2AddEditFormDTO; import com.epmet.dto.form.SendSmsFormDTO; import com.epmet.dto.form.ServiceRecordV2DetailFormDTO; import com.epmet.dto.form.ServiceRecordV2ListFormDTO; -import com.epmet.dto.result.ServiceRecordV2DetailResultDTO; -import com.epmet.dto.result.ServiceRecordV2ListResultDTO; +import com.epmet.dto.result.*; import com.epmet.entity.*; import com.epmet.feign.EpmetMessageOpenFeignClient; +import com.epmet.feign.GovOrgOpenFeignClient; import com.epmet.redis.IcPartyUnitRedis; +import com.epmet.remote.EpmetUserRemoteService; import com.epmet.service.*; import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageInfo; @@ -40,7 +46,9 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import java.math.BigDecimal; import java.util.*; +import java.util.stream.Collectors; /** * 服务记录表 @@ -50,7 +58,7 @@ import java.util.*; */ @Service @Slf4j -public class IcServiceRecordV2ServiceImpl extends BaseServiceImpl implements IcServiceRecordV2Service { +public class IcServiceRecordV2ServiceImpl extends BaseServiceImpl implements IcServiceRecordV2Service, ResultDataResolver { @Autowired private IcPartyUnitRedis partyUnitRedis; @@ -73,6 +81,12 @@ public class IcServiceRecordV2ServiceImpl extends BaseServiceImpl page(Map params) { @@ -276,4 +290,46 @@ public class IcServiceRecordV2ServiceImpl extends BaseServiceImpl lingshanServiceTimeAndSatisStats(String orgId, String orgType) { + + // 1.先拿orgIdPath,方便查询数据 + String orgIdPath; + if (StringUtils.isAnyBlank(orgId, orgType)) { + // 前端没传递,那就用当前staff所属的 + LoginUserDetailsResultDTO loginUserDetails = epmetUserRemoteService.getLoginUserDetails(); + orgIdPath = loginUserDetails.getOrgIdPath(); + orgId = loginUserDetails.getAgencyId(); + orgType = OrgInfoConstant.AGENCY; + } else { + orgIdPath = CustomerOrgRedis.getOrgIdPath(orgId, orgType); + } + + //2. 再拿该组织所有下级组织,用于展示横坐标(因为没有服务数据,也要展示出来) + List subOrgList = getResultDataOrThrowsException(govOrgOpenFeignClient.subOrgList(orgId), ServiceConstant.GOV_ORG_SERVER, null, "没有找到下级组织", null) + .stream().map(so -> { + return new LingshanPublicServiceTimeStatsRstDTO(so.getOrgId(), so.getOrgType(), so.getOrgName(), + PidUtils.convertPid2OrgIdPath(so.getOrgId(), so.getPids()), 0, 0, 0, BigDecimal.ZERO); + }).collect(Collectors.toList()); + + // 查询次数+满意率 + List tl = baseDao.serviceTimeStatsByOrg(orgIdPath); + + subOrgList.forEach(so -> { + for (LingshanPublicServiceTimeStatsRstDTO e : tl) { + String eOrgIdPath = e.getOrgIdPath(); + if (eOrgIdPath.contains(so.getOrgIdPath())) { + // 说明这条数据,是这个子级组织下的数据 + so.setServeTimes(so.getServeTimes() + e.getServeTimes()); + so.setCompletedTimes(so.getCompletedTimes() + e.getCompletedTimes()); + so.setSatisfactionTimes(so.getSatisfactionTimes() + e.getSatisfactionTimes()); + + double satisfactionRate = so.getSatisfactionTimes() * 100.0 / so.getCompletedTimes(); + so.setSatisfactionRate(new BigDecimal(satisfactionRate).setScale(2, BigDecimal.ROUND_HALF_UP)); + } + } + }); + + return subOrgList; + } } \ No newline at end of file diff --git a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceRecordV2Dao.xml b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceRecordV2Dao.xml index 05bcf1ad4b..b3bbd79a9e 100644 --- a/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceRecordV2Dao.xml +++ b/epmet-module/epmet-heart/epmet-heart-server/src/main/resources/mapper/IcServiceRecordV2Dao.xml @@ -43,5 +43,24 @@ ORDER BY sr.SERVICE_TIME_START DESC,sr.SERVICE_TIME_END DESC + + + \ No newline at end of file