diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/BaseReportConstant.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/BaseReportConstant.java new file mode 100644 index 0000000000..0c6669c3bd --- /dev/null +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/constant/BaseReportConstant.java @@ -0,0 +1,13 @@ +package com.epmet.constant; + +/** + * @Author zxc + * @DateTime 2021/6/24 5:19 下午 + * @DESC + */ +public interface BaseReportConstant { + + String DATA_IS_NULL = "上传%s数据为空"; + + +} diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/BaseReportDao.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/BaseReportDao.java index d60d287216..5d65fe2ea3 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/BaseReportDao.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/stats/BaseReportDao.java @@ -1,5 +1,8 @@ package com.epmet.dao.stats; +import com.epmet.dto.basereport.form.AgencyProjectFormDTO; +import com.epmet.dto.basereport.form.AgencyRegUserFormDTO; +import com.epmet.dto.basereport.form.GridRegUserFormDTO; import com.epmet.dto.basereport.form.*; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -84,4 +87,21 @@ public interface BaseReportDao { * @author sun */ void insertBatchAgencyHotTopic(@Param("list") List dataList); + + /** + * @Description 根据dateId删除客户组织项目数据 + * @Param customerId + * @Param dateId + * @author zxc + * @date 2021/6/24 5:30 下午 + */ + int delAgencyProject(@Param("customerId") String customerId, @Param("dateId") String dateId); + + /** + * @Description 批量新增组织项目数据 + * @Param dataList + * @author zxc + * @date 2021/6/25 9:14 上午 + */ + void insertAgencyProject(@Param("list")List dataList); } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/BaseReportServiceImpl.java b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/BaseReportServiceImpl.java index 5c4f341e8d..2a92d567c8 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/BaseReportServiceImpl.java +++ b/epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/impl/BaseReportServiceImpl.java @@ -1,19 +1,25 @@ package com.epmet.service.impl; import com.epmet.commons.tools.constant.NumConstant; +import com.epmet.constant.BaseReportConstant; import com.epmet.dao.stats.BaseReportDao; import com.epmet.dto.basereport.form.*; import com.epmet.service.BaseReportService; +import lombok.extern.slf4j.Slf4j; +import org.apache.commons.collections4.ListUtils; 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.util.List; + /** * @Author sun * @Description 部分基础数据上报 */ @Service +@Slf4j public class BaseReportServiceImpl implements BaseReportService { @Autowired @@ -217,9 +223,21 @@ public class BaseReportServiceImpl implements BaseReportService { * @author sun */ @Override - @Transactional(rollbackFor = Exception.class) public void agencyProject(AgencyProjectFormDTO formDTO) { - + if (CollectionUtils.isEmpty(formDTO.getDataList())){ + log.warn(String.format(BaseReportConstant.DATA_IS_NULL),"组织项目"); + return; + } + if (formDTO.getIsFirst()) { + int deleteNum; + do { + deleteNum = baseReportDao.delAgencyProject(formDTO.getDataList().get(NumConstant.ZERO).getCustomerId(), formDTO.getDataList().get(NumConstant.ZERO).getDateId()); + } while (deleteNum > NumConstant.ZERO); + } + List> partition = ListUtils.partition(formDTO.getDataList(), NumConstant.ONE_HUNDRED); + partition.forEach(p -> { + baseReportDao.insertAgencyProject(p); + }); } } diff --git a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/BaseReportDao.xml b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/BaseReportDao.xml index 45f112c07b..147bbd845d 100644 --- a/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/BaseReportDao.xml +++ b/epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/stats/BaseReportDao.xml @@ -156,5 +156,80 @@ + + + DELETE FROM fact_agency_project_daily + WHERE customer_id = #{customerId} + AND date_id = #{dateId} + LIMIT 1000 + + + + + INSERT INTO fact_agency_project_daily + (REPLACE(UUID(), '-', ''), + CUSTOMER_ID, + AGENCY_ID, + PARENT_ID, + DATE_ID, + WEEK_ID, + MONTH_ID, + QUARTER_ID, + YEAR_ID, + PROJECT_TOTAL, + PENDING_TOTAL, + PENDING_RATIO, + CLOSED_TOTAL, + CLOSED_RATIO, + RESOLVED_TOTAL, + RESOLVED_RATIO, + UNRESOLVED_TOTAL, + UNRESOLVED_RATIO, + PROJECT_INCR, + PENDING_INCR, + CLOSED_INCR, + RESOLVED_INCR, + UNRESOLVED_INCR, + DEL_FLAG, + REVISION, + CREATED_BY, + CREATED_TIME, + UPDATED_BY, + UPDATED_TIME) + values + + ( + id + #{i.customerId}, + #{i.agencyId}, + #{i.parentId}, + #{i.dateId}, + #{i.weekId}, + #{i.monthId}, + #{i.quarterId}, + #{i.yearId}, + #{i.projectTotal}, + #{i.pendingTotal}, + #{i.pendingRatio}, + #{i.closedTotal}, + #{i.closedRatio}, + #{i.resolvedTotal}, + #{i.resolvedRatio}, + #{i.unresolvedTotal}, + #{i.unresolvedRatio}, + #{i.projectIncr}, + #{i.pendingIncr}, + #{i.closedIncr}, + #{i.resolvedIncr}, + #{i.unresolvedIncr}, + 0, + 0, + 'BASE_REPORT', + now(), + 'BASE_REPORT', + now() + ) + +