diff --git a/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/AgencyMonthCountResultDTO.java b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/AgencyMonthCountResultDTO.java new file mode 100644 index 0000000000..adb9da6284 --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/AgencyMonthCountResultDTO.java @@ -0,0 +1,21 @@ +package com.epmet.dto.extract.result; + +import com.epmet.commons.tools.constant.NumConstant; +import lombok.Data; + +import java.io.Serializable; + +/** + * @Author zxc + * @DateTime 2021/5/8 9:34 上午 + * @DESC + */ +@Data +public class AgencyMonthCountResultDTO implements Serializable { + + private static final long serialVersionUID = 3473299876562651080L; + + private String orgId; + + private Integer monthCount = NumConstant.ZERO; +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java index 6aa48bf445..d0cb1d1726 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java @@ -21,6 +21,7 @@ import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.dto.extract.form.PartyBaseInfoFormDTO; import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; +import com.epmet.dto.extract.result.AgencyMonthCountResultDTO; import com.epmet.dto.extract.result.CustomerAgencyInfoResultDTO; import com.epmet.dto.extract.result.OrgNameResultDTO; import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO; @@ -204,4 +205,12 @@ public interface ScreenCustomerAgencyDao extends BaseDao selectAgencyByParentAreaCode(@Param("areaCode") String areaCode); + + /** + * @Description 根据客户ID查询客户下所有org【agency,grid,dept】 + * @Param customerId + * @author zxc + * @date 2021/5/8 9:03 上午 + */ + List selectAllOrgByCustomerId(@Param("customerId")String customerId); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java index ecb417b9b6..b484887e59 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java @@ -18,6 +18,7 @@ package com.epmet.dao.evaluationindex.screen; import com.epmet.commons.mybatis.dao.BaseDao; +import com.epmet.dto.extract.result.AgencyMonthCountResultDTO; import com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO; import com.epmet.entity.evaluationindex.screen.ScreenIndexDataMonthlyEntity; import org.apache.ibatis.annotations.Mapper; @@ -81,6 +82,15 @@ public interface ScreenIndexDataMonthlyDao extends BaseDao selectMonthCountByOrgId(@Param("yearId") String yearId,@Param("orgIds")List orgIds); + /** * 批量删除月表数据 * 根据CUSTOMER_ID、MONTH_ID、ORG_TYPE进行查询,如果有数据,则先进行物理删除, 一次删除1000条 diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java index 7df7c2920d..4e53c3db97 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java @@ -17,6 +17,7 @@ import com.epmet.dao.evaluationindex.indexcal.GridScoreDao; import com.epmet.dao.evaluationindex.indexcoll.*; import com.epmet.dao.evaluationindex.screen.*; import com.epmet.dto.ScreenCustomerGridDTO; +import com.epmet.dto.extract.result.AgencyMonthCountResultDTO; import com.epmet.dto.indexcal.AgencyScoreDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.DeptScoreDTO; @@ -851,8 +852,41 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService { **/ private void insertIndexDataYear(String monthId, String customerId){ // 查询今年,上报了几个月的指数统计 + List orgIds = screenCustomerAgencyDao.selectAllOrgByCustomerId(customerId); + if (CollectionUtils.isEmpty(orgIds)){ + throw new RenException("客户下没有查到agencyId,gridId,deptId"); + } + List agencyMonthCount = screenIndexDataMonthlyDao.selectMonthCountByOrgId(getYearStr(monthId), orgIds); + if (!CollectionUtils.isEmpty(agencyMonthCount)){ + agencyMonthCount.forEach(a -> { + orgIds.forEach(o -> { + if (a.getOrgId().equals(o.getOrgId())){ + o.setMonthCount(a.getMonthCount()); + } + }); + }); + } Integer monthCount = screenIndexDataMonthlyDao.selectCountIndexDataMonthly(customerId, getYearStr(monthId)); List monthlyFormList = screenIndexDataMonthlyDao.selectListIndexDataMonthlyByYear(customerId, getYearStr(monthId), monthCount); + BigDecimal monthCountBd = new BigDecimal(monthCount); + monthlyFormList.forEach(m -> { + orgIds.forEach(o -> { + if (m.getOrgId().equals(o.getOrgId())){ + BigDecimal selfCount = new BigDecimal(o.getMonthCount()); + if (o.getMonthCount() == NumConstant.ZERO){ + m.setIndexTotal(monthCountBd.multiply(m.getIndexTotal())); + m.setPartyDevAblity(monthCountBd.multiply(m.getPartyDevAblity())); + m.setServiceAblity(monthCountBd.multiply(m.getServiceAblity())); + m.setGovernAblity(monthCountBd.multiply(m.getGovernAblity())); + }else { + m.setIndexTotal(monthCountBd.multiply(m.getIndexTotal()).divide(selfCount)); + m.setPartyDevAblity(monthCountBd.multiply(m.getPartyDevAblity()).divide(selfCount)); + m.setServiceAblity(monthCountBd.multiply(m.getServiceAblity()).divide(selfCount)); + m.setGovernAblity(monthCountBd.multiply(m.getGovernAblity()).divide(selfCount)); + } + } + }); + }); if (monthlyFormList.size() > NumConstant.ZERO){ int deleteNum; do { diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml index 0d7434ba98..acb10f1bad 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml @@ -419,4 +419,11 @@ where sca.DEL_FLAG = '0' and sca.AREA_CODE= #{areaCode} + + + diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml index 91ecd0a870..dff0d6bbc6 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml @@ -96,6 +96,21 @@ ) monthCount + + + delete from screen_index_data_monthly where CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} AND ORG_TYPE = #{orgType}