Browse Source

screen_index_data_monthly数据插入代码微调

dev_shibei_match
zxc 4 years ago
parent
commit
8245dd3dfb
  1. 21
      epmet-module/data-statistical/data-statistical-client/src/main/java/com/epmet/dto/extract/result/AgencyMonthCountResultDTO.java
  2. 9
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenCustomerAgencyDao.java
  3. 10
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/dao/evaluationindex/screen/ScreenIndexDataMonthlyDao.java
  4. 34
      epmet-module/data-statistical/data-statistical-server/src/main/java/com/epmet/service/evaluationindex/indexcoll/impl/FactIndexCollectServiceImpl.java
  5. 7
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml
  6. 15
      epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml

21
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;
}

9
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.PartyBaseInfoFormDTO;
import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO; import com.epmet.dto.extract.form.ScreenPartyBranchDataFormDTO;
import com.epmet.dto.extract.form.ScreenPartyLinkMassesDataFormDTO; 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.CustomerAgencyInfoResultDTO;
import com.epmet.dto.extract.result.OrgNameResultDTO; import com.epmet.dto.extract.result.OrgNameResultDTO;
import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO; import com.epmet.dto.indexcollect.form.CustomerBizOrgFormDTO;
@ -204,4 +205,12 @@ public interface ScreenCustomerAgencyDao extends BaseDao<ScreenCustomerAgencyEnt
* @date 2021/3/9 上午9:41 * @date 2021/3/9 上午9:41
*/ */
List<ScreenProjectOrgDailyDTO> selectAgencyByParentAreaCode(@Param("areaCode") String areaCode); List<ScreenProjectOrgDailyDTO> selectAgencyByParentAreaCode(@Param("areaCode") String areaCode);
/**
* @Description 根据客户ID查询客户下所有orgagencygriddept
* @Param customerId
* @author zxc
* @date 2021/5/8 9:03 上午
*/
List<AgencyMonthCountResultDTO> selectAllOrgByCustomerId(@Param("customerId")String customerId);
} }

10
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; package com.epmet.dao.evaluationindex.screen;
import com.epmet.commons.mybatis.dao.BaseDao; import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dto.extract.result.AgencyMonthCountResultDTO;
import com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO; import com.epmet.dto.screencoll.form.IndexDataMonthlyFormDTO;
import com.epmet.entity.evaluationindex.screen.ScreenIndexDataMonthlyEntity; import com.epmet.entity.evaluationindex.screen.ScreenIndexDataMonthlyEntity;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@ -81,6 +82,15 @@ public interface ScreenIndexDataMonthlyDao extends BaseDao<ScreenIndexDataMonthl
Integer selectCountIndexDataMonthly(@Param("customerId") String customerId, Integer selectCountIndexDataMonthly(@Param("customerId") String customerId,
@Param("yearId") String yearId); @Param("yearId") String yearId);
/**
* @Description 根据orgIds查询在 screen_index_data_monthly 表里本年度有多少条记录
* @Param yearId
* @Param orgIds
* @author zxc
* @date 2021/5/8 9:37 上午
*/
List<AgencyMonthCountResultDTO> selectMonthCountByOrgId(@Param("yearId") String yearId,@Param("orgIds")List<AgencyMonthCountResultDTO> orgIds);
/** /**
* 批量删除月表数据 * 批量删除月表数据
* 根据CUSTOMER_IDMONTH_IDORG_TYPE进行查询如果有数据则先进行物理删除, 一次删除1000条 * 根据CUSTOMER_IDMONTH_IDORG_TYPE进行查询如果有数据则先进行物理删除, 一次删除1000条

34
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.indexcoll.*;
import com.epmet.dao.evaluationindex.screen.*; import com.epmet.dao.evaluationindex.screen.*;
import com.epmet.dto.ScreenCustomerGridDTO; import com.epmet.dto.ScreenCustomerGridDTO;
import com.epmet.dto.extract.result.AgencyMonthCountResultDTO;
import com.epmet.dto.indexcal.AgencyScoreDTO; import com.epmet.dto.indexcal.AgencyScoreDTO;
import com.epmet.dto.indexcal.CalculateCommonFormDTO; import com.epmet.dto.indexcal.CalculateCommonFormDTO;
import com.epmet.dto.indexcal.DeptScoreDTO; import com.epmet.dto.indexcal.DeptScoreDTO;
@ -851,8 +852,41 @@ public class FactIndexCollectServiceImpl implements FactIndexCollectService {
**/ **/
private void insertIndexDataYear(String monthId, String customerId){ private void insertIndexDataYear(String monthId, String customerId){
// 查询今年,上报了几个月的指数统计 // 查询今年,上报了几个月的指数统计
List<AgencyMonthCountResultDTO> orgIds = screenCustomerAgencyDao.selectAllOrgByCustomerId(customerId);
if (CollectionUtils.isEmpty(orgIds)){
throw new RenException("客户下没有查到agencyId,gridId,deptId");
}
List<AgencyMonthCountResultDTO> 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)); Integer monthCount = screenIndexDataMonthlyDao.selectCountIndexDataMonthly(customerId, getYearStr(monthId));
List<IndexDataMonthlyFormDTO> monthlyFormList = screenIndexDataMonthlyDao.selectListIndexDataMonthlyByYear(customerId, getYearStr(monthId), monthCount); List<IndexDataMonthlyFormDTO> 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){ if (monthlyFormList.size() > NumConstant.ZERO){
int deleteNum; int deleteNum;
do { do {

7
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenCustomerAgencyDao.xml

@ -419,4 +419,11 @@
where sca.DEL_FLAG = '0' where sca.DEL_FLAG = '0'
and sca.AREA_CODE= #{areaCode} and sca.AREA_CODE= #{areaCode}
</select> </select>
<!-- 根据客户ID查询客户下所有org【agency,grid,dept】 -->
<select id="selectAllOrgByCustomerId" resultType="com.epmet.dto.extract.result.AgencyMonthCountResultDTO">
(SELECT AGENCY_ID AS orgId FROM screen_customer_agency WHERE DEL_FLAG = 0 AND CUSTOMER_ID = #{customerId}) UNION ALL
(SELECT GRID_ID AS orgId FROM screen_customer_grid WHERE DEL_FLAG = 0 AND CUSTOMER_ID = #{customerId}) UNION ALL
(SELECT DEPT_ID AS orgId FROM screen_customer_dept WHERE DEL_FLAG = 0 AND CUSTOMER_ID = #{customerId})
</select>
</mapper> </mapper>

15
epmet-module/data-statistical/data-statistical-server/src/main/resources/mapper/evaluationindex/screen/ScreenIndexDataMonthlyDao.xml

@ -96,6 +96,21 @@
) monthCount ) monthCount
</select> </select>
<!-- 根据orgIds查询在 screen_index_data_monthly 表里本年度有多少条记录 -->
<select id="selectMonthCountByOrgId" resultType="com.epmet.dto.extract.result.AgencyMonthCountResultDTO">
SELECT
ORG_ID,
COUNT(DISTINCT MONTH_ID) AS monthCount
FROM screen_index_data_monthly
WHERE DEL_FLAG = '0'
AND YEAR_ID = #{yearId}
AND
(<foreach collection="orgIds" item="o" separator=" OR ">
ORG_ID = #{o.orgId}
</foreach>)
GROUP BY ORG_ID
</select>
<delete id="deleteIndexDataMonthlyByOrgType"> <delete id="deleteIndexDataMonthlyByOrgType">
delete from screen_index_data_monthly delete from screen_index_data_monthly
where CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} AND ORG_TYPE = #{orgType} where CUSTOMER_ID = #{customerId} AND MONTH_ID = #{monthId} AND ORG_TYPE = #{orgType}

Loading…
Cancel
Save