Browse Source

5、【工作日志】本机及下级排名接口修改

dev_shibei_match
yinzuomei 5 years ago
parent
commit
30a704d329
  1. 20
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/AgencyInfoDTO.java
  2. 3
      epmet-module/data-report/data-report-client/src/main/java/com/epmet/plugins/form/WorkRecordRankFormDTO.java
  3. 2
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  4. 1
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerGridDao.java
  5. 21
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/plugins/ScreenWorkRecordOrgDailyDao.java
  6. 3
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java
  7. 12
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java
  8. 66
      epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java
  9. 102
      epmet-module/data-report/data-report-server/src/main/resources/mapper/plugins/ScreenWorkRecordOrgDailyDao.xml
  10. 17
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml
  11. 15
      epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml

20
epmet-module/data-report/data-report-client/src/main/java/com/epmet/dto/AgencyInfoDTO.java

@ -0,0 +1,20 @@
package com.epmet.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 描述一下
*
* @author yinzuomei@elink-cn.com
* @date 2021/2/27 17:52
*/
@Data
public class AgencyInfoDTO implements Serializable {
private String agencyId;
private String areaCode;
private List<String> subAgencyIds;
private List<String> subGridIds;
}

3
epmet-module/data-report/data-report-client/src/main/java/com/epmet/plugins/form/WorkRecordRankFormDTO.java

@ -35,4 +35,7 @@ public class WorkRecordRankFormDTO implements Serializable {
@NotBlank(message = "customerId不能为空")
private String customerId;
@NotBlank(message = "areaCode不能为空,目前只有平阴在传,默认赋值:370124")
private String areaCode;
}

2
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java

@ -151,4 +151,6 @@ public interface ScreenCustomerAgencyDao {
List<GridNodeDTO> selectGridList(@Param("areaCode") String areaCode,@Param("agencyId") String agencyId);
List<String> getNextAgencyIds(@Param("areaCode")String areaCode,@Param("agencyId")String agencyId);
List<String> selectSubAgencyIds(@Param("areaCode")String areaCode,@Param("agencyId")String agencyId);
}

1
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/evaluationindex/screen/ScreenCustomerGridDao.java

@ -81,4 +81,5 @@ public interface ScreenCustomerGridDao {
*/
List<TreeResultDTO> selectGridInfo(@Param("agencyId")String agencyId);
List<String> selectSubGridIds(@Param("areaCode")String areaCode, @Param("agencyId")String agencyId);
}

21
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/dao/plugins/ScreenWorkRecordOrgDailyDao.java

@ -35,23 +35,26 @@ import java.util.List;
@Mapper
public interface ScreenWorkRecordOrgDailyDao extends BaseDao<ScreenWorkRecordOrgDailyEntity> {
/**
* @param areaCode 当前组织对应的areaCode;
* @param dataType
* @param topRow
* @return com.epmet.plugins.result.WorkRecordRankResultDTO
* @author yinzuomei
* @description 5工作日志本机及下级排名
* @Date 2021/2/23 23:37
**/
List<WorkRecordSubRank> selectSubList(@Param("areaCode") String areaCode,
@Param("agencyId") String agencyId,
@Param("dataType") String dataType,
@Param("topRow") Integer topRow,
List<WorkRecordSubRank> selectSubList(@Param("subAgencyIds") List<String> subAgencyIds,
// @Param("subGridIds")List<String> subGridIds,
@Param("dataType")String dataType,
@Param("customerId")String customerId,
@Param("dateId")String dateId);
String selectLatestDateId(String customerId);
List<WorkRecordSubRank> selectSubGridList(@Param("subGridIds")List<String> subGridIds,
@Param("dataType")String dataType,
@Param("customerId")String customerId,
@Param("dateId")String dateId);
List<WorkRecordRankResultDTO> selectCurrentAgency(@Param("areaCode") String areaCode,
String selectLatestDateId(@Param("customerIds")List<String> customerIds);
WorkRecordRankResultDTO selectCurrentAgency(@Param("areaCode") String areaCode,
@Param("dataType") String dataType,
@Param("dateId")String dateId);
}

3
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/AgencyService.java

@ -1,5 +1,6 @@
package com.epmet.datareport.service.evaluationindex.screen;
import com.epmet.dto.AgencyInfoDTO;
import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO;
import com.epmet.dto.result.AreaCodeDictResultDTO;
@ -70,4 +71,6 @@ public interface AgencyService {
* @Date 2021/2/25 16:52
**/
List<String> getNextAgencyIds(String areaCode,String agencyId);
AgencyInfoDTO getAgencyInfoDTO(String areaCode, String agencyId);
}

12
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/evaluationindex/screen/impl/AgencyServiceImpl.java

@ -10,6 +10,7 @@ import com.epmet.constant.DataSourceConstant;
import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerAgencyDao;
import com.epmet.datareport.dao.evaluationindex.screen.ScreenCustomerGridDao;
import com.epmet.datareport.service.evaluationindex.screen.AgencyService;
import com.epmet.dto.AgencyInfoDTO;
import com.epmet.dto.form.AddAreaCodeDictFormDTO;
import com.epmet.dto.form.AreaCodeDictFormDTO;
import com.epmet.dto.result.AreaCodeDictResultDTO;
@ -310,4 +311,15 @@ public class AgencyServiceImpl implements AgencyService {
public List<String> getNextAgencyIds(String areaCode,String agencyId) {
return screenCustomerAgencyDao.getNextAgencyIds(areaCode,agencyId);
}
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true)
@Override
public AgencyInfoDTO getAgencyInfoDTO(String areaCode, String agencyId) {
AgencyInfoDTO agencyInfoDTO=new AgencyInfoDTO();
agencyInfoDTO.setAgencyId(agencyId);
agencyInfoDTO.setAreaCode(areaCode);
agencyInfoDTO.setSubAgencyIds(screenCustomerAgencyDao.selectSubAgencyIds(areaCode,agencyId));
agencyInfoDTO.setSubGridIds(screenCustomerGridDao.selectSubGridIds(areaCode,agencyId));
return agencyInfoDTO;
}
}

66
epmet-module/data-report/data-report-server/src/main/java/com/epmet/datareport/service/plugins/impl/ScreenWorkRecordOrgDailyServiceImpl.java

@ -26,6 +26,7 @@ import com.epmet.commons.tools.constant.NumConstant;
import com.epmet.commons.tools.exception.RenException;
import com.epmet.commons.tools.page.PageData;
import com.epmet.commons.tools.utils.ConvertUtils;
import com.epmet.commons.tools.utils.Result;
import com.epmet.constant.DataSourceConstant;
import com.epmet.datareport.dao.plugins.ScreenCustomerWorkRecordDictDao;
import com.epmet.datareport.dao.plugins.ScreenWorkRecordOrgDailyDao;
@ -34,18 +35,20 @@ import com.epmet.datareport.entity.plugins.ScreenWorkRecordOrgDailyEntity;
import com.epmet.datareport.service.evaluationindex.screen.AgencyService;
import com.epmet.datareport.service.plugins.ScreenWorkRecordOrgDailyService;
import com.epmet.datareport.utils.DateUtils;
import com.epmet.dto.result.ScreenCustomerAgencyDTO;
import com.epmet.dto.AgencyInfoDTO;
import com.epmet.feign.OperCrmOpenFeignClient;
import com.epmet.plugins.ScreenWorkRecordOrgDailyDTO;
import com.epmet.plugins.form.WorkRecordRankFormDTO;
import com.epmet.plugins.form.WorkRecordTrendFormDTO;
import com.epmet.plugins.result.WorkRecordRankResultDTO;
import com.epmet.plugins.result.WorkRecordSubRank;
import com.epmet.plugins.result.WorkRecordTrendResultDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
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.util.CollectionUtils;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
@ -71,7 +74,8 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl<ScreenW
private ScreenCustomerWorkRecordDictDao screenCustomerWorkRecordDictDao;
@Autowired
private ScreenWorkRecordOrgMonthlyDao screenWorkRecordOrgMonthlyDao;
@Autowired
private OperCrmOpenFeignClient operCrmOpenFeignClient;
@Override
public PageData<ScreenWorkRecordOrgDailyDTO> page(Map<String, Object> params) {
IPage<ScreenWorkRecordOrgDailyEntity> page = baseDao.selectPage(
@ -124,30 +128,46 @@ public class ScreenWorkRecordOrgDailyServiceImpl extends BaseServiceImpl<ScreenW
baseDao.deleteBatchIds(Arrays.asList(ids));
}
@DataSource(value = DataSourceConstant.EVALUATION_INDEX,datasourceNameFromArg = true)
@DataSource(value = DataSourceConstant.EVALUATION_INDEX, datasourceNameFromArg = true)
@Override
public WorkRecordRankResultDTO rankList(WorkRecordRankFormDTO formDTO) {
////todo 待完善 直属网格是否显示?
ScreenCustomerAgencyDTO agencyDTO = agencyService.queryAgencyInfo(formDTO.getAgencyId());
if (null == agencyDTO) {
throw new RenException(String.format("获取组织信息异常,agencyId:%s", formDTO.getAgencyId()));
List<String> customerIds=new ArrayList<>();
Result<List<String>> result=operCrmOpenFeignClient.getAllSubCustomerIds(formDTO.getCustomerId());
if (result.success() && CollectionUtils.isNotEmpty(result.getData())) {
log.info("包含子客户");
customerIds.add(formDTO.getCustomerId());
customerIds.addAll(result.getData());
}
String dateId= baseDao.selectLatestDateId(customerIds);
if(StringUtils.isBlank(dateId)){
throw new RenException("dateId is null");
}
String dateId = baseDao.selectLatestDateId(formDTO.getCustomerId());
log.info(String.format("最近一次上传dateId:%s", dateId));
if (agencyDTO.getLevel().equals("community")) {
log.warn("【工作日志】本机及下级排名接口待完善");
//todo
return new WorkRecordRankResultDTO(0, 0, new ArrayList<>());
} else {
//非社区的
List<WorkRecordRankResultDTO> resultDTOList = baseDao.selectCurrentAgency(agencyDTO.getAreaCode(), formDTO.getDataType(), dateId);
if(!CollectionUtils.isEmpty(resultDTOList)){
WorkRecordRankResultDTO resultDTO=resultDTOList.get(0);
resultDTO.setSubRankList(baseDao.selectSubList(agencyDTO.getAreaCode(), agencyDTO.getAgencyId(), formDTO.getDataType(), formDTO.getTopRow(), dateId));
return resultDTO;
}
WorkRecordRankResultDTO returnDto = new WorkRecordRankResultDTO();
//当前组织的自身的数据
AgencyInfoDTO agencyInfoDTO = agencyService.getAgencyInfoDTO(formDTO.getAreaCode(), formDTO.getAgencyId());
List<WorkRecordSubRank> subAgencyRankList = baseDao.selectSubList(
CollectionUtils.isNotEmpty(agencyInfoDTO.getSubAgencyIds()) ? agencyInfoDTO.getSubAgencyIds() : new ArrayList<>(),
formDTO.getDataType(),
formDTO.getCustomerId(),
dateId);
List<WorkRecordSubRank> subGridList = baseDao.selectSubGridList(
CollectionUtils.isNotEmpty(agencyInfoDTO.getSubGridIds()) ? agencyInfoDTO.getSubGridIds() : new ArrayList<>(),
formDTO.getDataType(),
formDTO.getCustomerId(),
dateId);
returnDto.getSubRankList().addAll(subAgencyRankList);
returnDto.getSubRankList().addAll(subGridList);
int participateUserTotal = 0;
int participateTotal = 0;
for (WorkRecordSubRank subAgency : returnDto.getSubRankList()) {
participateUserTotal += subAgency.getParticipateUserTotal();
participateTotal += subAgency.getParticipateTotal();
}
return new WorkRecordRankResultDTO();
returnDto.setParticipateTotal(participateTotal);
returnDto.setParticipateUserTotal(participateUserTotal);
returnDto.setSubRankList(CollectionUtils.isNotEmpty(returnDto.getSubRankList()) && returnDto.getSubRankList().size() >= formDTO.getTopRow() ?
returnDto.getSubRankList().subList(NumConstant.ZERO, formDTO.getTopRow()) : returnDto.getSubRankList());
return returnDto;
}
/**

102
epmet-module/data-report/data-report-server/src/main/resources/mapper/plugins/ScreenWorkRecordOrgDailyDao.xml

@ -3,49 +3,92 @@
<mapper namespace="com.epmet.datareport.dao.plugins.ScreenWorkRecordOrgDailyDao">
<select id="selectLatestDateId" resultType="java.lang.String" parameterType="java.lang.String">
<select id="selectLatestDateId" resultType="java.lang.String" parameterType="map">
SELECT
max( m.DATE_ID ) AS maxDateId
FROM
screen_work_record_org_daily m
WHERE
m.DEL_FLAG = '0'
AND m.CUSTOMER_ID = #{customerId}
AND m.CUSTOMER_ID in
<foreach item="customerId" collection="customerIds" open="(" separator="," close=")">
#{customerId}
</foreach>
</select>
<!-- 按照area_code查询当前组织的下级对应的数值,不包含本级 -->
<select id="selectSubList" parameterType="map" resultType="com.epmet.plugins.result.WorkRecordSubRank">
SELECT
SELECT
sca.AGENCY_ID AS orgId,
sca.AGENCY_NAME AS `NAME`,
IFNULL( sum( temp.PARTICIPATE_USER_TOTAL ), 0 ) AS participateUserTotal,
IFNULL( sum( temp.ORGANIZE_TOTAL ), 0 ) AS participateTotal
FROM
screen_customer_agency sca
left join (
select m.* from screen_work_record_org_daily m
where m.DEL_FLAG = '0'
AND m.DATE_ID = #{dateId}
and m.TYPE_CODE in(
select dict. RESOURCE_CODE from screen_customer_work_record_dict dict
where dict.DEL_FLAG = '0'
AND dict.DATA_TYPE = #{dataType}
and dict.`LEVEL`='1'
)
)temp on(
sca.AGENCY_ID = temp.ORG_ID AND temp.DEL_FLAG = '0' AND temp.DATE_ID =#{dateId}
)
screen_customer_agency sca
left join (
select m.* from screen_work_record_org_daily m
where m.DEL_FLAG = '0'
AND m.DATE_ID = #{dateId}
and m.TYPE_CODE in(
select distinct dict.RESOURCE_CODE
from screen_customer_work_record_dict dict
where dict.DEL_FLAG = '0'
and dict.`LEVEL`='1'
AND dict.DATA_TYPE =#{dataType}
and dict.CUSTOMER_ID=#{customerId}
)
and org_id in
<foreach item="agencyId" collection="subAgencyIds" open="(" separator="," close=")">
#{agencyId}
</foreach>
)temp on(sca.AGENCY_ID = temp.ORG_ID)
WHERE
sca.DEL_FLAG = '0'
AND sca.PARENT_AREA_CODE =#{areaCode}
AND sca.AGENCY_ID != #{agencyId}
GROUP BY
sca.AGENCY_ID,
sca.AGENCY_NAME
sca.DEL_FLAG = '0'
AND sca.AGENCY_ID in
<foreach item="agencyId" collection="subAgencyIds" open="(" separator="," close=")">
#{agencyId}
</foreach>
group by sca.AGENCY_ID,sca.AGENCY_NAME
ORDER BY
participateUserTotal DESC,
participateTotal DESC
</select>
<select id="selectSubGridList" parameterType="map" resultType="com.epmet.plugins.result.WorkRecordSubRank">
SELECT
scg.GRID_ID AS orgId,
scg.GRID_NAME AS `NAME`,
IFNULL( sum( temp.PARTICIPATE_USER_TOTAL ), 0 ) AS participateUserTotal,
IFNULL( sum( temp.ORGANIZE_TOTAL ), 0 ) AS participateTotal
FROM
screen_customer_grid scg
left join (
select m.* from screen_work_record_org_daily m
where m.DEL_FLAG = '0'
AND m.DATE_ID = #{dateId}
and m.TYPE_CODE in(
select distinct dict.RESOURCE_CODE
from screen_customer_work_record_dict dict
where dict.DEL_FLAG = '0'
and dict.`LEVEL`='1'
AND dict.DATA_TYPE =#{dataType}
and dict.CUSTOMER_ID=#{customerId}
)
and org_id in
<foreach item="gridId" collection="subGridIds" open="(" separator="," close=")">
#{gridId}
</foreach>
)temp on(scg.GRID_ID = temp.ORG_ID)
WHERE
scg.DEL_FLAG = '0'
AND scg.GRID_ID in
<foreach item="gridId" collection="subGridIds" open="(" separator="," close=")">
#{gridId}
</foreach>
group by scg.GRID_ID,scg.GRID_NAME
ORDER BY
participateUserTotal DESC,
participateTotal DESC
LIMIT #{topRow}
participateUserTotal DESC,
participateTotal DESC
</select>
<select id="selectCurrentAgency" parameterType="map" resultType="com.epmet.plugins.result.WorkRecordRankResultDTO">
@ -58,9 +101,10 @@
)
inner JOIN screen_customer_work_record_dict dict
ON ( m.TYPE_CODE = dict.RESOURCE_CODE
and dict.`LEVEL`='1'
AND dict.DEL_FLAG = '0'
AND dict.DATA_TYPE = #{dataType}
and dict.`LEVEL`='1'
AND dict.DEL_FLAG = '0'
and dict.customer
AND dict.DATA_TYPE = #{dataType}
)
WHERE
sca.DEL_FLAG = '0'

17
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerAgencyDao.xml

@ -302,4 +302,21 @@
</otherwise>
</choose>
</select>
<select id="selectSubAgencyIds" parameterType="map" resultType="java.lang.String">
SELECT
sca.AGENCY_ID as orgId
FROM
screen_customer_agency sca
WHERE
sca.DEL_FLAG = '0'
<choose>
<when test="areaCode != null and areaCode.trim() != ''">
AND sca.PARENT_AREA_CODE = #{areaCode}
</when>
<otherwise>
and sca.PID=#{agencyId}
</otherwise>
</choose>
</select>
</mapper>

15
epmet-module/data-report/data-report-server/src/main/resources/mapper/screen/ScreenCustomerGridDao.xml

@ -122,4 +122,19 @@
GROUP BY scg.PARENT_AGENCY_ID
</select>
<select id="selectSubGridIds" parameterType="map" resultType="java.lang.String">
SELECT
m.GRID_ID as orgId
FROM
screen_customer_grid m
where m.DEL_FLAG = '0'
<choose>
<when test="areaCode != null and areaCode.trim() != ''">
and m.AREA_CODE=#{areaCode}
</when>
<otherwise>
m.PARENT_AGENCY_ID=#{agencyId}
</otherwise>
</choose>
</select>
</mapper>
Loading…
Cancel
Save